@needle-tools/three 0.169.20-experimental.0 → 0.183.2-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +5 -6
- package/build/three.cjs +54184 -56703
- package/build/three.core.js +59506 -0
- package/build/three.core.min.js +6 -0
- package/build/three.module.js +11645 -73000
- package/build/three.module.min.js +2 -2
- package/build/three.tsl.js +648 -0
- package/build/three.tsl.min.js +6 -0
- package/build/three.webgpu.js +53912 -51652
- package/build/three.webgpu.min.js +2 -2
- package/build/three.webgpu.nodes.js +53888 -51806
- package/build/three.webgpu.nodes.min.js +2 -2
- package/examples/fonts/MPLUSRounded1c/MPLUSRounded1c-Regular.typeface.json.zip +0 -0
- package/examples/fonts/MPLUSRounded1c/OFL.txt +91 -0
- package/examples/jsm/Addons.js +5 -15
- package/examples/jsm/animation/AnimationClipCreator.js +58 -6
- package/examples/jsm/animation/CCDIKSolver.js +152 -45
- package/examples/jsm/capabilities/WebGL.js +28 -29
- package/examples/jsm/capabilities/WebGPU.js +19 -17
- package/examples/jsm/controls/ArcballControls.js +474 -178
- package/examples/jsm/controls/DragControls.js +100 -58
- package/examples/jsm/controls/FirstPersonControls.js +116 -6
- package/examples/jsm/controls/FlyControls.js +50 -2
- package/examples/jsm/controls/MapControls.js +96 -8
- package/examples/jsm/controls/OrbitControls.js +496 -57
- package/examples/jsm/controls/PointerLockControls.js +115 -22
- package/examples/jsm/controls/TrackballControls.js +166 -14
- package/examples/jsm/controls/TransformControls.js +336 -26
- package/examples/jsm/csm/CSM.js +232 -18
- package/examples/jsm/csm/CSMFrustum.js +61 -4
- package/examples/jsm/csm/CSMHelper.js +50 -0
- package/examples/jsm/csm/CSMShader.js +13 -1
- package/examples/jsm/csm/CSMShadowNode.js +599 -0
- package/examples/jsm/curves/CurveExtras.js +303 -31
- package/examples/jsm/curves/NURBSCurve.js +91 -16
- package/examples/jsm/curves/NURBSSurface.js +52 -6
- package/examples/jsm/curves/NURBSUtils.js +102 -112
- package/examples/jsm/curves/NURBSVolume.js +24 -4
- package/examples/jsm/effects/AnaglyphEffect.js +134 -7
- package/examples/jsm/effects/AsciiEffect.js +69 -22
- package/examples/jsm/effects/OutlineEffect.js +61 -111
- package/examples/jsm/effects/ParallaxBarrierEffect.js +30 -0
- package/examples/jsm/effects/StereoEffect.js +31 -0
- package/examples/jsm/environments/ColorEnvironment.js +59 -0
- package/examples/jsm/environments/DebugEnvironment.js +50 -0
- package/examples/jsm/environments/RoomEnvironment.js +83 -42
- package/examples/jsm/exporters/DRACOExporter.js +56 -14
- package/examples/jsm/exporters/EXRExporter.js +40 -9
- package/examples/jsm/exporters/GLTFExporter.js +502 -169
- package/examples/jsm/exporters/OBJExporter.js +21 -1
- package/examples/jsm/exporters/PLYExporter.js +44 -12
- package/examples/jsm/exporters/STLExporter.js +27 -5
- package/examples/jsm/exporters/USDZExporter.js +781 -291
- package/examples/jsm/geometries/BoxLineGeometry.js +23 -0
- package/examples/jsm/geometries/ConvexGeometry.js +19 -0
- package/examples/jsm/geometries/DecalGeometry.js +91 -30
- package/examples/jsm/geometries/ParametricFunctions.js +100 -0
- package/examples/jsm/geometries/ParametricGeometry.js +38 -5
- package/examples/jsm/geometries/RoundedBoxGeometry.js +68 -7
- package/examples/jsm/geometries/TeapotGeometry.js +23 -38
- package/examples/jsm/geometries/TextGeometry.js +48 -29
- package/examples/jsm/gpgpu/BitonicSort.js +715 -0
- package/examples/jsm/helpers/AnimationPathHelper.js +302 -0
- package/examples/jsm/helpers/LightProbeHelper.js +36 -0
- package/examples/jsm/helpers/LightProbeHelperGPU.js +38 -1
- package/examples/jsm/helpers/OctreeHelper.js +36 -0
- package/examples/jsm/helpers/PositionalAudioHelper.js +60 -0
- package/examples/jsm/helpers/RapierHelper.js +59 -0
- package/examples/jsm/helpers/RectAreaLightHelper.js +36 -3
- package/examples/jsm/helpers/TextureHelper.js +28 -0
- package/examples/jsm/helpers/TextureHelperGPU.js +214 -0
- package/examples/jsm/helpers/VertexNormalsHelper.js +61 -2
- package/examples/jsm/helpers/VertexTangentsHelper.js +47 -2
- package/examples/jsm/helpers/ViewHelper.js +181 -9
- package/examples/jsm/inspector/Inspector.js +487 -0
- package/examples/jsm/inspector/RendererInspector.js +425 -0
- package/examples/jsm/inspector/tabs/Console.js +238 -0
- package/examples/jsm/inspector/tabs/Parameters.js +348 -0
- package/examples/jsm/inspector/tabs/Performance.js +268 -0
- package/examples/jsm/inspector/tabs/Viewer.js +166 -0
- package/examples/jsm/inspector/ui/Graph.js +95 -0
- package/examples/jsm/inspector/ui/Item.js +170 -0
- package/examples/jsm/inspector/ui/List.js +75 -0
- package/examples/jsm/inspector/ui/Profiler.js +1975 -0
- package/examples/jsm/inspector/ui/Style.js +1613 -0
- package/examples/jsm/inspector/ui/Tab.js +233 -0
- package/examples/jsm/inspector/ui/Values.js +439 -0
- package/examples/jsm/inspector/ui/utils.js +56 -0
- package/examples/jsm/interactive/HTMLMesh.js +43 -12
- package/examples/jsm/interactive/InteractiveGroup.js +170 -52
- package/examples/jsm/interactive/SelectionBox.js +106 -9
- package/examples/jsm/interactive/SelectionHelper.js +76 -30
- package/examples/jsm/libs/demuxer_mp4.js +109 -0
- package/examples/jsm/libs/meshopt_decoder.module.js +76 -58
- package/examples/jsm/libs/motion-controllers.module.js +1 -1
- package/examples/jsm/lighting/TiledLighting.js +42 -0
- package/examples/jsm/lights/LightProbeGenerator.js +44 -7
- package/examples/jsm/lights/RectAreaLightTexturesLib.js +50 -14
- package/examples/jsm/lights/RectAreaLightUniformsLib.js +16 -0
- package/examples/jsm/lines/Line2.js +41 -4
- package/examples/jsm/lines/LineGeometry.js +80 -2
- package/examples/jsm/lines/LineMaterial.js +105 -5
- package/examples/jsm/lines/LineSegments2.js +54 -4
- package/examples/jsm/lines/LineSegmentsGeometry.js +65 -8
- package/examples/jsm/lines/Wireframe.js +41 -4
- package/examples/jsm/lines/WireframeGeometry2.js +27 -2
- package/examples/jsm/lines/webgpu/Line2.js +28 -2
- package/examples/jsm/lines/webgpu/LineSegments2.js +59 -24
- package/examples/jsm/lines/webgpu/Wireframe.js +86 -0
- package/examples/jsm/loaders/3DMLoader.js +78 -6
- package/examples/jsm/loaders/3MFLoader.js +148 -7
- package/examples/jsm/loaders/AMFLoader.js +34 -14
- package/examples/jsm/loaders/BVHLoader.js +59 -12
- package/examples/jsm/loaders/ColladaLoader.js +61 -4027
- package/examples/jsm/loaders/DDSLoader.js +68 -1
- package/examples/jsm/loaders/DRACOLoader.js +146 -22
- package/examples/jsm/loaders/EXRLoader.js +255 -34
- package/examples/jsm/loaders/FBXLoader.js +80 -42
- package/examples/jsm/loaders/FontLoader.js +83 -6
- package/examples/jsm/loaders/GCodeLoader.js +71 -14
- package/examples/jsm/loaders/GLTFLoader.js +381 -263
- package/examples/jsm/loaders/HDRCubeTextureLoader.js +52 -3
- package/examples/jsm/loaders/HDRLoader.js +485 -0
- package/examples/jsm/loaders/IESLoader.js +42 -0
- package/examples/jsm/loaders/KMZLoader.js +39 -6
- package/examples/jsm/loaders/KTX2Loader.js +124 -48
- package/examples/jsm/loaders/KTXLoader.js +31 -10
- package/examples/jsm/loaders/LDrawLoader.js +192 -145
- package/examples/jsm/loaders/LUT3dlLoader.js +47 -10
- package/examples/jsm/loaders/LUTCubeLoader.js +46 -9
- package/examples/jsm/loaders/LUTImageLoader.js +79 -38
- package/examples/jsm/loaders/LWOLoader.js +54 -59
- package/examples/jsm/loaders/LottieLoader.js +54 -1
- package/examples/jsm/loaders/MD2Loader.js +37 -1
- package/examples/jsm/loaders/MDDLoader.js +57 -12
- package/examples/jsm/loaders/MTLLoader.js +60 -35
- package/examples/jsm/loaders/MaterialXLoader.js +268 -34
- package/examples/jsm/loaders/NRRDLoader.js +40 -8
- package/examples/jsm/loaders/OBJLoader.js +51 -2
- package/examples/jsm/loaders/PCDLoader.js +173 -21
- package/examples/jsm/loaders/PDBLoader.js +41 -2
- package/examples/jsm/loaders/PLYLoader.js +70 -39
- package/examples/jsm/loaders/PVRLoader.js +25 -6
- package/examples/jsm/loaders/RGBELoader.js +6 -438
- package/examples/jsm/loaders/STLLoader.js +48 -38
- package/examples/jsm/loaders/SVGLoader.js +119 -25
- package/examples/jsm/loaders/TDSLoader.js +92 -74
- package/examples/jsm/loaders/TGALoader.js +23 -2
- package/examples/jsm/loaders/TIFFLoader.js +23 -0
- package/examples/jsm/loaders/TTFLoader.js +50 -3
- package/examples/jsm/loaders/USDLoader.js +279 -0
- package/examples/jsm/loaders/USDZLoader.js +4 -858
- package/examples/jsm/loaders/UltraHDRLoader.js +338 -166
- package/examples/jsm/loaders/VOXLoader.js +688 -87
- package/examples/jsm/loaders/VRMLLoader.js +121 -12
- package/examples/jsm/loaders/VTKLoader.js +77 -25
- package/examples/jsm/loaders/XYZLoader.js +36 -0
- package/examples/jsm/loaders/collada/ColladaComposer.js +2950 -0
- package/examples/jsm/loaders/collada/ColladaParser.js +1962 -0
- package/examples/jsm/loaders/lwo/IFFParser.js +77 -77
- package/examples/jsm/loaders/usd/USDAParser.js +822 -0
- package/examples/jsm/loaders/usd/USDCParser.js +1852 -0
- package/examples/jsm/loaders/usd/USDComposer.js +4041 -0
- package/examples/jsm/materials/LDrawConditionalLineMaterial.js +183 -0
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +154 -0
- package/examples/jsm/materials/WoodNodeMaterial.js +533 -0
- package/examples/jsm/math/Capsule.js +91 -14
- package/examples/jsm/math/ColorConverter.js +22 -0
- package/examples/jsm/math/ColorSpaces.js +74 -2
- package/examples/jsm/math/ConvexHull.js +517 -93
- package/examples/jsm/math/ImprovedNoise.js +32 -15
- package/examples/jsm/math/Lut.js +113 -0
- package/examples/jsm/math/MeshSurfaceSampler.js +78 -13
- package/examples/jsm/math/OBB.js +141 -29
- package/examples/jsm/math/Octree.js +283 -7
- package/examples/jsm/math/SimplexNoise.js +68 -42
- package/examples/jsm/misc/ConvexObjectBreaker.js +45 -25
- package/examples/jsm/misc/GPUComputationRenderer.js +96 -20
- package/examples/jsm/misc/Gyroscope.js +12 -0
- package/examples/jsm/misc/MD2Character.js +117 -2
- package/examples/jsm/misc/MD2CharacterComplex.js +175 -11
- package/examples/jsm/misc/MorphAnimMesh.js +44 -0
- package/examples/jsm/misc/MorphBlendMesh.js +103 -0
- package/examples/jsm/misc/ProgressiveLightMap.js +100 -54
- package/examples/jsm/misc/ProgressiveLightMapGPU.js +322 -0
- package/examples/jsm/misc/RollerCoaster.js +57 -0
- package/examples/jsm/misc/TubePainter.js +437 -40
- package/examples/jsm/misc/Volume.js +123 -76
- package/examples/jsm/misc/VolumeSlice.js +95 -49
- package/examples/jsm/modifiers/CurveModifier.js +66 -38
- package/examples/jsm/modifiers/CurveModifierGPU.js +42 -19
- package/examples/jsm/modifiers/EdgeSplitModifier.js +20 -0
- package/examples/jsm/modifiers/SimplifyModifier.js +24 -10
- package/examples/jsm/modifiers/TessellateModifier.js +35 -2
- package/examples/jsm/objects/GroundedSkybox.js +25 -6
- package/examples/jsm/objects/Lensflare.js +94 -2
- package/examples/jsm/objects/LensflareMesh.js +64 -10
- package/examples/jsm/objects/MarchingCubes.js +90 -5
- package/examples/jsm/objects/Reflector.js +76 -2
- package/examples/jsm/objects/ReflectorForSSRPass.js +41 -0
- package/examples/jsm/objects/Refractor.js +62 -0
- package/examples/jsm/objects/ShadowMesh.js +54 -4
- package/examples/jsm/objects/Sky.js +106 -16
- package/examples/jsm/objects/SkyMesh.js +211 -38
- package/examples/jsm/objects/Water.js +49 -8
- package/examples/jsm/objects/Water2.js +49 -7
- package/examples/jsm/objects/Water2Mesh.js +50 -9
- package/examples/jsm/objects/WaterMesh.js +136 -43
- package/examples/jsm/physics/AmmoPhysics.js +60 -7
- package/examples/jsm/physics/JoltPhysics.js +65 -12
- package/examples/jsm/physics/RapierPhysics.js +217 -21
- package/examples/jsm/postprocessing/AfterimagePass.js +110 -29
- package/examples/jsm/postprocessing/BloomPass.js +128 -26
- package/examples/jsm/postprocessing/BokehPass.js +99 -22
- package/examples/jsm/postprocessing/ClearPass.js +54 -3
- package/examples/jsm/postprocessing/CubeTexturePass.js +82 -21
- package/examples/jsm/postprocessing/DotScreenPass.js +59 -10
- package/examples/jsm/postprocessing/EffectComposer.js +140 -6
- package/examples/jsm/postprocessing/FXAAPass.js +40 -0
- package/examples/jsm/postprocessing/FilmPass.js +54 -5
- package/examples/jsm/postprocessing/GTAOPass.js +202 -57
- package/examples/jsm/postprocessing/GlitchPass.js +86 -34
- package/examples/jsm/postprocessing/HalftonePass.js +65 -10
- package/examples/jsm/postprocessing/LUTPass.js +38 -8
- package/examples/jsm/postprocessing/MaskPass.js +91 -0
- package/examples/jsm/postprocessing/OutlinePass.js +272 -135
- package/examples/jsm/postprocessing/OutputPass.js +65 -14
- package/examples/jsm/postprocessing/Pass.js +100 -4
- package/examples/jsm/postprocessing/RenderPass.js +94 -0
- package/examples/jsm/postprocessing/RenderPixelatedPass.js +124 -45
- package/examples/jsm/postprocessing/RenderTransitionPass.js +120 -21
- package/examples/jsm/postprocessing/SAOPass.js +128 -55
- package/examples/jsm/postprocessing/SMAAPass.js +106 -75
- package/examples/jsm/postprocessing/SSAARenderPass.js +118 -35
- package/examples/jsm/postprocessing/SSAOPass.js +173 -60
- package/examples/jsm/postprocessing/SSRPass.js +268 -53
- package/examples/jsm/postprocessing/SavePass.js +69 -16
- package/examples/jsm/postprocessing/ShaderPass.js +65 -7
- package/examples/jsm/postprocessing/TAARenderPass.js +79 -24
- package/examples/jsm/postprocessing/TexturePass.js +72 -8
- package/examples/jsm/postprocessing/UnrealBloomPass.js +168 -59
- package/examples/jsm/renderers/CSS2DRenderer.js +98 -5
- package/examples/jsm/renderers/CSS3DRenderer.js +111 -7
- package/examples/jsm/renderers/Projector.js +288 -32
- package/examples/jsm/renderers/SVGRenderer.js +323 -61
- package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +3 -1
- package/examples/jsm/renderers/webgl-legacy/nodes/SlotNode.js +1 -1
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +5 -1
- package/examples/jsm/shaders/ACESFilmicToneMappingShader.js +12 -5
- package/examples/jsm/shaders/AfterimageShader.js +8 -3
- package/examples/jsm/shaders/BasicShader.js +8 -1
- package/examples/jsm/shaders/BleachBypassShader.js +10 -3
- package/examples/jsm/shaders/BlendShader.js +8 -1
- package/examples/jsm/shaders/BokehShader.js +9 -3
- package/examples/jsm/shaders/BokehShader2.js +11 -4
- package/examples/jsm/shaders/BrightnessContrastShader.js +10 -4
- package/examples/jsm/shaders/ColorCorrectionShader.js +8 -1
- package/examples/jsm/shaders/ColorifyShader.js +8 -1
- package/examples/jsm/shaders/ConvolutionShader.js +9 -38
- package/examples/jsm/shaders/CopyShader.js +8 -1
- package/examples/jsm/shaders/DOFMipMapShader.js +10 -3
- package/examples/jsm/shaders/DepthLimitedBlurShader.js +10 -1
- package/examples/jsm/shaders/DigitalGlitch.js +10 -7
- package/examples/jsm/shaders/DotScreenShader.js +8 -3
- package/examples/jsm/shaders/ExposureShader.js +8 -1
- package/examples/jsm/shaders/FXAAShader.js +233 -221
- package/examples/jsm/shaders/FilmShader.js +13 -0
- package/examples/jsm/shaders/FocusShader.js +8 -3
- package/examples/jsm/shaders/FreiChenShader.js +10 -3
- package/examples/jsm/shaders/GTAOShader.js +55 -45
- package/examples/jsm/shaders/GammaCorrectionShader.js +11 -2
- package/examples/jsm/shaders/HalftoneShader.js +24 -4
- package/examples/jsm/shaders/HorizontalBlurShader.js +12 -3
- package/examples/jsm/shaders/HorizontalTiltShiftShader.js +9 -2
- package/examples/jsm/shaders/HueSaturationShader.js +10 -3
- package/examples/jsm/shaders/KaleidoShader.js +11 -4
- package/examples/jsm/shaders/LuminosityHighPassShader.js +8 -4
- package/examples/jsm/shaders/LuminosityShader.js +8 -2
- package/examples/jsm/shaders/MirrorShader.js +10 -4
- package/examples/jsm/shaders/NormalMapShader.js +7 -2
- package/examples/jsm/shaders/OutputShader.js +19 -1
- package/examples/jsm/shaders/PoissonDenoiseShader.js +30 -17
- package/examples/jsm/shaders/RGBShiftShader.js +8 -1
- package/examples/jsm/shaders/SAOShader.js +27 -5
- package/examples/jsm/shaders/SMAAShader.js +24 -1
- package/examples/jsm/shaders/SSAOShader.js +37 -6
- package/examples/jsm/shaders/SSRShader.js +32 -6
- package/examples/jsm/shaders/SepiaShader.js +8 -3
- package/examples/jsm/shaders/SobelOperatorShader.js +9 -3
- package/examples/jsm/shaders/SubsurfaceScatteringShader.js +13 -8
- package/examples/jsm/shaders/TechnicolorShader.js +10 -4
- package/examples/jsm/shaders/ToonShader.js +29 -6
- package/examples/jsm/shaders/TriangleBlurShader.js +9 -4
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +19 -6
- package/examples/jsm/shaders/VelocityShader.js +8 -1
- package/examples/jsm/shaders/VerticalBlurShader.js +9 -2
- package/examples/jsm/shaders/VerticalTiltShiftShader.js +8 -1
- package/examples/jsm/shaders/VignetteShader.js +8 -3
- package/examples/jsm/shaders/VolumeShader.js +11 -2
- package/examples/jsm/shaders/WaterRefractionShader.js +11 -0
- package/examples/jsm/textures/FlakesTexture.js +14 -0
- package/examples/jsm/transpiler/AST.js +436 -31
- package/examples/jsm/transpiler/GLSLDecoder.js +380 -135
- package/examples/jsm/transpiler/Linker.js +327 -0
- package/examples/jsm/transpiler/ShaderToyDecoder.js +3 -1
- package/examples/jsm/transpiler/TSLEncoder.js +363 -97
- package/examples/jsm/transpiler/Transpiler.js +50 -1
- package/examples/jsm/transpiler/TranspilerUtils.js +29 -0
- package/examples/jsm/transpiler/WGSLEncoder.js +839 -0
- package/examples/jsm/tsl/display/AfterImageNode.js +244 -0
- package/examples/jsm/tsl/display/AnaglyphPassNode.js +549 -0
- package/examples/jsm/tsl/display/AnamorphicNode.js +282 -0
- package/examples/jsm/tsl/display/BilateralBlurNode.js +364 -0
- package/{src/nodes → examples/jsm/tsl}/display/BleachBypass.js +11 -4
- package/examples/jsm/tsl/display/BloomNode.js +534 -0
- package/examples/jsm/tsl/display/CRT.js +150 -0
- package/examples/jsm/tsl/display/ChromaticAberrationNode.js +207 -0
- package/examples/jsm/tsl/display/DenoiseNode.js +334 -0
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +554 -0
- package/examples/jsm/tsl/display/DotScreenNode.js +104 -0
- package/examples/jsm/tsl/display/FXAANode.js +365 -0
- package/examples/jsm/tsl/display/FilmNode.js +101 -0
- package/examples/jsm/tsl/display/GTAONode.js +571 -0
- package/examples/jsm/tsl/display/GaussianBlurNode.js +389 -0
- package/examples/jsm/tsl/display/GodraysNode.js +624 -0
- package/examples/jsm/tsl/display/LensflareNode.js +279 -0
- package/examples/jsm/tsl/display/Lut3DNode.js +109 -0
- package/examples/jsm/tsl/display/MotionBlur.js +33 -0
- package/examples/jsm/tsl/display/OutlineNode.js +762 -0
- package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +89 -0
- package/examples/jsm/tsl/display/PixelationPassNode.js +335 -0
- package/examples/jsm/tsl/display/RGBShiftNode.js +96 -0
- package/examples/jsm/tsl/display/RetroPassNode.js +263 -0
- package/examples/jsm/tsl/display/SMAANode.js +768 -0
- package/{src/nodes → examples/jsm/tsl}/display/SSAAPassNode.js +120 -49
- package/examples/jsm/tsl/display/SSGINode.js +642 -0
- package/examples/jsm/tsl/display/SSRNode.js +656 -0
- package/examples/jsm/tsl/display/SSSNode.js +490 -0
- package/{src/nodes → examples/jsm/tsl}/display/Sepia.js +9 -2
- package/examples/jsm/tsl/display/Shape.js +29 -0
- package/{src/nodes → examples/jsm/tsl}/display/SobelOperatorNode.js +61 -19
- package/examples/jsm/tsl/display/StereoCompositePassNode.js +192 -0
- package/{src/nodes → examples/jsm/tsl}/display/StereoPassNode.js +48 -12
- package/examples/jsm/tsl/display/TRAANode.js +726 -0
- package/examples/jsm/tsl/display/TransitionNode.js +141 -0
- package/examples/jsm/tsl/display/boxBlur.js +65 -0
- package/examples/jsm/tsl/display/depthAwareBlend.js +80 -0
- package/examples/jsm/tsl/display/hashBlur.js +54 -0
- package/examples/jsm/tsl/display/radialBlur.js +68 -0
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +442 -0
- package/examples/jsm/tsl/math/Bayer.js +73 -0
- package/examples/jsm/tsl/shadows/TileShadowNode.js +456 -0
- package/examples/jsm/tsl/shadows/TileShadowNodeHelper.js +212 -0
- package/examples/jsm/tsl/utils/Raymarching.js +70 -0
- package/examples/jsm/utils/BufferGeometryUtils.js +91 -29
- package/examples/jsm/utils/CameraUtils.js +15 -6
- package/examples/jsm/utils/GeometryCompressionUtils.js +23 -30
- package/examples/jsm/utils/GeometryUtils.js +32 -27
- package/examples/jsm/utils/LDrawUtils.js +14 -5
- package/examples/jsm/utils/SceneOptimizer.js +458 -0
- package/examples/jsm/utils/SceneUtils.js +53 -3
- package/examples/jsm/utils/ShadowMapViewer.js +72 -33
- package/examples/jsm/utils/ShadowMapViewerGPU.js +61 -29
- package/examples/jsm/utils/SkeletonUtils.js +48 -0
- package/examples/jsm/utils/SortUtils.js +17 -5
- package/examples/jsm/utils/UVsDebug.js +12 -4
- package/examples/jsm/utils/{TextureUtils.js → WebGLTextureUtils.js} +16 -0
- package/examples/jsm/utils/{TextureUtilsGPU.js → WebGPUTextureUtils.js} +20 -2
- package/examples/jsm/utils/WorkerPool.js +67 -2
- package/examples/jsm/webxr/ARButton.js +19 -0
- package/examples/jsm/webxr/OculusHandModel.js +84 -0
- package/examples/jsm/webxr/OculusHandPointerModel.js +148 -22
- package/examples/jsm/webxr/Text2D.js +20 -6
- package/examples/jsm/webxr/VRButton.js +31 -0
- package/examples/jsm/webxr/XRButton.js +23 -0
- package/examples/jsm/webxr/XRControllerModelFactory.js +94 -3
- package/examples/jsm/webxr/XREstimatedLight.js +35 -4
- package/examples/jsm/webxr/XRHandMeshModel.js +37 -0
- package/examples/jsm/webxr/XRHandModelFactory.js +96 -6
- package/examples/jsm/webxr/XRHandPrimitiveModel.js +44 -0
- package/examples/jsm/webxr/XRPlanes.js +18 -0
- package/package.json +29 -37
- package/src/Three.Core.js +198 -0
- package/src/Three.Legacy.js +0 -21
- package/src/Three.TSL.js +641 -0
- package/src/Three.WebGPU.Nodes.js +14 -186
- package/src/Three.WebGPU.js +16 -186
- package/src/Three.js +2 -197
- package/src/animation/AnimationAction.js +263 -31
- package/src/animation/AnimationClip.js +162 -7
- package/src/animation/AnimationMixer.js +105 -15
- package/src/animation/AnimationObjectGroup.js +45 -21
- package/src/animation/AnimationUtils.js +163 -24
- package/src/animation/KeyframeTrack.js +191 -17
- package/src/animation/PropertyBinding.js +91 -16
- package/src/animation/PropertyMixer.js +72 -5
- package/src/animation/tracks/BooleanKeyframeTrack.js +33 -6
- package/src/animation/tracks/ColorKeyframeTrack.js +26 -5
- package/src/animation/tracks/NumberKeyframeTrack.js +26 -2
- package/src/animation/tracks/QuaternionKeyframeTrack.js +30 -1
- package/src/animation/tracks/StringKeyframeTrack.js +33 -2
- package/src/animation/tracks/VectorKeyframeTrack.js +26 -2
- package/src/audio/Audio.js +386 -8
- package/src/audio/AudioAnalyser.js +58 -1
- package/src/audio/AudioContext.js +15 -0
- package/src/audio/AudioListener.js +94 -13
- package/src/audio/PositionalAudio.js +107 -0
- package/src/cameras/ArrayCamera.js +37 -0
- package/src/cameras/Camera.js +61 -0
- package/src/cameras/CubeCamera.js +86 -0
- package/src/cameras/OrthographicCamera.js +110 -1
- package/src/cameras/PerspectiveCamera.js +174 -35
- package/src/cameras/StereoCamera.js +48 -2
- package/src/constants.js +1546 -11
- package/src/core/BufferAttribute.js +417 -3
- package/src/core/BufferGeometry.js +407 -22
- package/src/core/Clock.js +69 -8
- package/src/core/EventDispatcher.js +52 -8
- package/src/core/GLBufferAttribute.js +113 -2
- package/src/core/InstancedBufferAttribute.js +29 -0
- package/src/core/InstancedBufferGeometry.js +20 -0
- package/src/core/InstancedInterleavedBuffer.js +26 -0
- package/src/core/InterleavedBuffer.js +141 -7
- package/src/core/InterleavedBufferAttribute.js +200 -2
- package/src/core/Layers.js +71 -10
- package/src/core/Object3D.js +673 -26
- package/src/core/Raycaster.js +136 -2
- package/src/core/RenderTarget.js +256 -27
- package/src/core/RenderTarget3D.js +48 -0
- package/src/core/Timer.js +184 -0
- package/src/core/Uniform.js +29 -0
- package/src/core/UniformsGroup.js +84 -2
- package/src/extras/Controls.js +89 -1
- package/src/extras/DataUtils.js +50 -9
- package/src/extras/Earcut.js +18 -779
- package/src/extras/ImageUtils.js +22 -14
- package/src/extras/PMREMGenerator.js +316 -67
- package/src/extras/ShapeUtils.js +24 -2
- package/src/extras/TextureUtils.js +101 -15
- package/src/extras/core/Curve.js +156 -55
- package/src/extras/core/CurvePath.js +63 -22
- package/src/extras/core/Interpolations.js +34 -2
- package/src/extras/core/Path.js +134 -1
- package/src/extras/core/Shape.js +66 -3
- package/src/extras/core/ShapePath.js +80 -4
- package/src/extras/curves/ArcCurve.js +22 -0
- package/src/extras/curves/CatmullRomCurve3.js +89 -18
- package/src/extras/curves/CubicBezierCurve.js +67 -0
- package/src/extras/curves/CubicBezierCurve3.js +50 -0
- package/src/extras/curves/EllipseCurve.js +102 -0
- package/src/extras/curves/LineCurve.js +36 -0
- package/src/extras/curves/LineCurve3.js +36 -0
- package/src/extras/curves/QuadraticBezierCurve.js +59 -0
- package/src/extras/curves/QuadraticBezierCurve3.js +43 -0
- package/src/extras/curves/SplineCurve.js +48 -0
- package/src/extras/lib/earcut.js +685 -0
- package/src/geometries/BoxGeometry.js +39 -0
- package/src/geometries/CapsuleGeometry.js +196 -11
- package/src/geometries/CircleGeometry.js +41 -0
- package/src/geometries/ConeGeometry.js +39 -0
- package/src/geometries/CylinderGeometry.js +42 -2
- package/src/geometries/DodecahedronGeometry.js +33 -0
- package/src/geometries/EdgesGeometry.js +30 -2
- package/src/geometries/ExtrudeGeometry.js +148 -52
- package/src/geometries/IcosahedronGeometry.js +33 -0
- package/src/geometries/LatheGeometry.js +44 -3
- package/src/geometries/OctahedronGeometry.js +33 -0
- package/src/geometries/PlaneGeometry.js +35 -0
- package/src/geometries/PolyhedronGeometry.js +30 -1
- package/src/geometries/RingGeometry.js +37 -0
- package/src/geometries/ShapeGeometry.js +38 -0
- package/src/geometries/SphereGeometry.js +38 -0
- package/src/geometries/TetrahedronGeometry.js +33 -0
- package/src/geometries/TorusGeometry.js +44 -3
- package/src/geometries/TorusKnotGeometry.js +39 -0
- package/src/geometries/TubeGeometry.js +50 -0
- package/src/geometries/WireframeGeometry.js +32 -0
- package/src/helpers/ArrowHelper.js +62 -5
- package/src/helpers/AxesHelper.js +28 -0
- package/src/helpers/Box3Helper.js +28 -0
- package/src/helpers/BoxHelper.js +43 -7
- package/src/helpers/CameraHelper.js +103 -27
- package/src/helpers/DirectionalLightHelper.js +55 -0
- package/src/helpers/GridHelper.js +26 -0
- package/src/helpers/HemisphereLightHelper.js +42 -0
- package/src/helpers/PlaneHelper.js +33 -0
- package/src/helpers/PointLightHelper.js +43 -24
- package/src/helpers/PolarGridHelper.js +30 -0
- package/src/helpers/SkeletonHelper.js +73 -7
- package/src/helpers/SpotLightHelper.js +43 -0
- package/src/lights/AmbientLight.js +25 -0
- package/src/lights/DirectionalLight.js +70 -0
- package/src/lights/DirectionalLightShadow.js +15 -0
- package/src/lights/HemisphereLight.js +42 -0
- package/src/lights/Light.js +37 -11
- package/src/lights/LightProbe.js +37 -9
- package/src/lights/LightShadow.js +202 -7
- package/src/lights/PointLight.js +74 -0
- package/src/lights/PointLightShadow.js +15 -80
- package/src/lights/RectAreaLight.js +59 -0
- package/src/lights/SpotLight.js +124 -1
- package/src/lights/SpotLightShadow.js +33 -3
- package/src/lights/webgpu/IESSpotLight.js +22 -0
- package/src/lights/webgpu/ProjectorLight.js +46 -0
- package/src/loaders/AnimationLoader.js +34 -2
- package/src/loaders/AudioLoader.js +34 -2
- package/src/loaders/BufferGeometryLoader.js +38 -13
- package/src/loaders/Cache.js +75 -2
- package/src/loaders/CompressedTextureLoader.js +36 -3
- package/src/loaders/CubeTextureLoader.js +45 -0
- package/src/loaders/DataTextureLoader.js +45 -4
- package/src/loaders/FileLoader.js +85 -5
- package/src/loaders/ImageBitmapLoader.js +113 -11
- package/src/loaders/ImageLoader.js +85 -8
- package/src/loaders/Loader.js +150 -0
- package/src/loaders/LoaderUtils.js +18 -36
- package/src/loaders/LoadingManager.js +187 -0
- package/src/loaders/MaterialLoader.js +62 -3
- package/src/loaders/ObjectLoader.js +131 -31
- package/src/loaders/TextureLoader.js +33 -0
- package/src/loaders/nodes/NodeLoader.js +68 -4
- package/src/loaders/nodes/NodeMaterialLoader.js +45 -0
- package/src/loaders/nodes/NodeObjectLoader.js +61 -0
- package/src/materials/LineBasicMaterial.js +74 -1
- package/src/materials/LineDashedMaterial.js +52 -1
- package/src/materials/Material.js +502 -8
- package/src/materials/MeshBasicMaterial.js +168 -2
- package/src/materials/MeshDepthMaterial.js +94 -0
- package/src/materials/MeshDistanceMaterial.js +76 -0
- package/src/materials/MeshLambertMaterial.js +283 -0
- package/src/materials/MeshMatcapMaterial.js +164 -0
- package/src/materials/MeshNormalMaterial.js +114 -0
- package/src/materials/MeshPhongMaterial.js +298 -0
- package/src/materials/MeshPhysicalMaterial.js +296 -4
- package/src/materials/MeshStandardMaterial.js +300 -2
- package/src/materials/MeshToonMaterial.js +219 -0
- package/src/materials/PointsMaterial.js +89 -0
- package/src/materials/RawShaderMaterial.js +25 -0
- package/src/materials/ShaderMaterial.js +234 -6
- package/src/materials/ShadowMaterial.js +54 -0
- package/src/materials/SpriteMaterial.js +82 -0
- package/src/materials/nodes/Line2NodeMaterial.js +158 -53
- package/src/materials/nodes/LineBasicNodeMaterial.js +17 -2
- package/src/materials/nodes/LineDashedNodeMaterial.js +81 -6
- package/src/materials/nodes/MeshBasicNodeMaterial.js +59 -2
- package/src/materials/nodes/MeshLambertNodeMaterial.js +35 -0
- package/src/materials/nodes/MeshMatcapNodeMaterial.js +23 -3
- package/src/materials/nodes/MeshNormalNodeMaterial.js +27 -4
- package/src/materials/nodes/MeshPhongNodeMaterial.js +64 -1
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +276 -3
- package/src/materials/nodes/MeshSSSNodeMaterial.js +98 -10
- package/src/materials/nodes/MeshStandardNodeMaterial.js +83 -4
- package/src/materials/nodes/MeshToonNodeMaterial.js +28 -0
- package/src/materials/nodes/NodeMaterial.js +789 -74
- package/src/materials/nodes/NodeMaterials.js +0 -1
- package/src/materials/nodes/PointsNodeMaterial.js +180 -11
- package/src/materials/nodes/ShadowNodeMaterial.js +38 -0
- package/src/materials/nodes/SpriteNodeMaterial.js +86 -23
- package/src/materials/nodes/VolumeNodeMaterial.js +57 -84
- package/src/materials/nodes/manager/NodeMaterialObserver.js +329 -12
- package/src/math/Box2.js +177 -0
- package/src/math/Box3.js +271 -0
- package/src/math/Color.js +355 -11
- package/src/math/ColorManagement.js +158 -92
- package/src/math/Cylindrical.js +65 -6
- package/src/math/Euler.js +139 -5
- package/src/math/Frustum.js +108 -9
- package/src/math/FrustumArray.js +258 -0
- package/src/math/Interpolant.js +87 -8
- package/src/math/Line3.js +221 -2
- package/src/math/MathUtils.js +408 -20
- package/src/math/Matrix2.js +70 -0
- package/src/math/Matrix3.js +229 -4
- package/src/math/Matrix4.js +489 -94
- package/src/math/Plane.js +164 -2
- package/src/math/Quaternion.js +322 -90
- package/src/math/Ray.js +162 -0
- package/src/math/Sphere.js +175 -0
- package/src/math/Spherical.js +73 -11
- package/src/math/SphericalHarmonics3.js +112 -14
- package/src/math/Triangle.js +206 -2
- package/src/math/Vector2.js +396 -10
- package/src/math/Vector3.js +550 -15
- package/src/math/Vector4.js +415 -9
- package/src/math/interpolants/BezierInterpolant.js +108 -0
- package/src/math/interpolants/CubicInterpolant.js +10 -1
- package/src/math/interpolants/DiscreteInterpolant.js +10 -2
- package/src/math/interpolants/LinearInterpolant.js +13 -0
- package/src/math/interpolants/QuaternionLinearInterpolant.js +10 -1
- package/src/nodes/Nodes.js +91 -88
- package/src/nodes/TSL.js +32 -38
- package/src/nodes/accessors/AccessorsUtils.js +37 -9
- package/src/nodes/accessors/Arrays.js +68 -0
- package/src/nodes/accessors/BatchNode.js +49 -14
- package/src/nodes/accessors/Bitangent.js +82 -13
- package/src/nodes/accessors/BufferAttributeNode.js +269 -8
- package/src/nodes/accessors/BufferNode.js +91 -2
- package/src/nodes/accessors/BuiltinNode.js +63 -0
- package/src/nodes/accessors/Camera.js +400 -10
- package/src/nodes/accessors/ClippingNode.js +149 -45
- package/src/nodes/accessors/CubeTextureNode.js +137 -7
- package/src/nodes/accessors/InstanceNode.js +245 -40
- package/src/nodes/accessors/InstancedMeshNode.js +50 -0
- package/src/nodes/accessors/Lights.js +88 -0
- package/src/nodes/accessors/MaterialNode.js +355 -13
- package/src/nodes/accessors/MaterialProperties.js +57 -1
- package/src/nodes/accessors/MaterialReferenceNode.js +52 -14
- package/src/nodes/accessors/ModelNode.js +117 -5
- package/src/nodes/accessors/ModelViewProjectionNode.js +10 -39
- package/src/nodes/accessors/MorphNode.js +73 -26
- package/src/nodes/accessors/Normal.js +174 -19
- package/src/nodes/accessors/Object3DNode.js +146 -12
- package/src/nodes/accessors/PointUVNode.js +25 -0
- package/src/nodes/accessors/Position.js +119 -7
- package/src/nodes/accessors/ReferenceBaseNode.js +190 -4
- package/src/nodes/accessors/ReferenceNode.js +223 -8
- package/src/nodes/accessors/ReflectVector.js +29 -3
- package/src/nodes/accessors/RendererReferenceNode.js +45 -2
- package/src/nodes/accessors/SceneProperties.js +53 -0
- package/src/nodes/accessors/SkinningNode.js +180 -43
- package/src/nodes/accessors/StorageBufferNode.js +278 -26
- package/src/nodes/accessors/StorageTextureNode.js +205 -12
- package/src/nodes/accessors/Tangent.js +48 -10
- package/src/nodes/accessors/TangentUtils.js +46 -0
- package/src/nodes/accessors/Texture3DNode.js +104 -11
- package/src/nodes/accessors/TextureBicubic.js +31 -4
- package/src/nodes/accessors/TextureNode.js +564 -52
- package/src/nodes/accessors/TextureSizeNode.js +42 -1
- package/src/nodes/accessors/UV.js +9 -1
- package/src/nodes/accessors/UniformArrayNode.js +226 -34
- package/src/nodes/accessors/UserDataNode.js +46 -2
- package/src/nodes/accessors/VelocityNode.js +93 -3
- package/src/nodes/accessors/VertexColorNode.js +39 -4
- package/src/nodes/code/CodeNode.js +101 -8
- package/src/nodes/code/ExpressionNode.js +29 -2
- package/src/nodes/code/FunctionCallNode.js +98 -10
- package/src/nodes/code/FunctionNode.js +69 -2
- package/src/nodes/core/ArrayNode.js +174 -0
- package/src/nodes/core/AssignNode.js +80 -9
- package/src/nodes/core/AttributeNode.js +47 -4
- package/src/nodes/core/BypassNode.js +47 -3
- package/src/nodes/core/ConstNode.js +32 -0
- package/src/nodes/core/ContextNode.js +220 -14
- package/src/nodes/core/IndexNode.js +72 -7
- package/src/nodes/core/InputNode.js +50 -1
- package/src/nodes/core/InspectorNode.js +128 -0
- package/src/nodes/core/IsolateNode.js +133 -0
- package/src/nodes/core/LightingModel.js +65 -5
- package/src/nodes/core/MRTNode.js +113 -2
- package/src/nodes/core/Node.js +595 -36
- package/src/nodes/core/NodeAttribute.js +38 -0
- package/src/nodes/core/NodeBuilder.js +1840 -121
- package/src/nodes/core/NodeCache.js +41 -2
- package/src/nodes/core/NodeCode.js +31 -0
- package/src/nodes/core/NodeError.js +28 -0
- package/src/nodes/core/NodeFrame.js +153 -24
- package/src/nodes/core/NodeFunction.js +48 -1
- package/src/nodes/core/NodeFunctionInput.js +44 -0
- package/src/nodes/core/NodeParser.js +13 -1
- package/src/nodes/core/NodeUniform.js +53 -1
- package/src/nodes/core/NodeUtils.js +201 -51
- package/src/nodes/core/NodeVar.js +47 -1
- package/src/nodes/core/NodeVarying.js +47 -1
- package/src/nodes/core/OutputStructNode.js +54 -12
- package/src/nodes/core/ParameterNode.js +60 -2
- package/src/nodes/core/PropertyNode.js +286 -7
- package/src/nodes/core/StackNode.js +337 -20
- package/src/nodes/core/StackTrace.js +139 -0
- package/src/nodes/core/StructNode.js +134 -0
- package/src/nodes/core/StructType.js +13 -0
- package/src/nodes/core/StructTypeNode.js +126 -6
- package/src/nodes/core/SubBuildNode.js +89 -0
- package/src/nodes/core/TempNode.js +31 -5
- package/src/nodes/core/UniformGroupNode.js +85 -7
- package/src/nodes/core/UniformNode.js +163 -16
- package/src/nodes/core/VarNode.js +317 -10
- package/src/nodes/core/VaryingNode.js +115 -13
- package/src/nodes/core/constants.js +40 -0
- package/src/nodes/display/BlendModes.js +171 -0
- package/src/nodes/display/BumpMapNode.js +38 -2
- package/src/nodes/display/ColorAdjustment.js +118 -6
- package/src/nodes/display/ColorSpaceFunctions.js +22 -6
- package/src/nodes/display/ColorSpaceNode.js +97 -47
- package/src/nodes/display/FrontFacingNode.js +64 -7
- package/src/nodes/display/NormalMapNode.js +101 -54
- package/src/nodes/display/PassNode.js +690 -33
- package/src/nodes/display/RenderOutputNode.js +94 -4
- package/src/nodes/display/ScreenNode.js +138 -27
- package/src/nodes/display/ToneMappingFunctions.js +62 -10
- package/src/nodes/display/ToneMappingNode.js +88 -8
- package/src/nodes/display/ToonOutlinePassNode.js +84 -4
- package/src/nodes/display/ViewportDepthNode.js +227 -10
- package/src/nodes/display/ViewportDepthTextureNode.js +39 -5
- package/src/nodes/display/ViewportSharedTextureNode.js +35 -1
- package/src/nodes/display/ViewportTextureNode.js +171 -7
- package/src/nodes/fog/Fog.js +97 -0
- package/src/nodes/functions/BSDF/BRDF_GGX.js +2 -6
- package/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js +52 -0
- package/src/nodes/functions/BSDF/BRDF_Sheen.js +4 -4
- package/src/nodes/functions/BSDF/DFGLUT.js +56 -0
- package/src/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
- package/src/nodes/functions/BSDF/LTC.js +45 -1
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +1 -1
- package/src/nodes/functions/BasicLightingModel.js +28 -6
- package/src/nodes/functions/PhongLightingModel.js +36 -6
- package/src/nodes/functions/PhysicalLightingModel.js +336 -91
- package/src/nodes/functions/ShadowMaskModel.js +30 -3
- package/src/nodes/functions/ToonLightingModel.js +21 -2
- package/src/nodes/functions/VolumetricLightingModel.js +183 -0
- package/src/nodes/functions/material/getAlphaHashThreshold.js +68 -0
- package/src/nodes/functions/material/getGeometryRoughness.js +10 -4
- package/src/nodes/functions/material/getParallaxCorrectNormal.js +37 -0
- package/src/nodes/geometry/RangeNode.js +97 -8
- package/src/nodes/gpgpu/AtomicFunctionNode.js +198 -23
- package/src/nodes/gpgpu/BarrierNode.js +52 -3
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +135 -6
- package/src/nodes/gpgpu/ComputeNode.js +212 -16
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +455 -0
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +143 -9
- package/src/nodes/lighting/AONode.js +18 -0
- package/src/nodes/lighting/AmbientLightNode.js +10 -0
- package/src/nodes/lighting/AnalyticLightNode.js +186 -399
- package/src/nodes/lighting/BasicEnvironmentNode.js +19 -0
- package/src/nodes/lighting/BasicLightMapNode.js +17 -0
- package/src/nodes/lighting/DirectionalLightNode.js +12 -11
- package/src/nodes/lighting/EnvironmentNode.js +59 -19
- package/src/nodes/lighting/HemisphereLightNode.js +33 -2
- package/src/nodes/lighting/IESSpotLightNode.js +13 -1
- package/src/nodes/lighting/IrradianceNode.js +17 -0
- package/src/nodes/lighting/LightProbeNode.js +20 -0
- package/src/nodes/lighting/LightUtils.js +11 -3
- package/src/nodes/lighting/LightingContextNode.js +52 -4
- package/src/nodes/lighting/LightingNode.js +15 -6
- package/src/nodes/lighting/LightsNode.js +238 -35
- package/src/nodes/lighting/PointLightNode.js +60 -25
- package/src/nodes/lighting/PointShadowNode.js +325 -0
- package/src/nodes/lighting/ProjectorLightNode.js +91 -0
- package/src/nodes/lighting/RectAreaLightNode.js +50 -14
- package/src/nodes/lighting/ShadowBaseNode.js +81 -0
- package/src/nodes/lighting/ShadowFilterNode.js +264 -0
- package/src/nodes/lighting/ShadowNode.js +867 -0
- package/src/nodes/lighting/SpotLightNode.js +99 -18
- package/src/nodes/materialx/MaterialXNodes.js +131 -2
- package/src/nodes/materialx/lib/mx_noise.js +166 -2
- package/src/nodes/math/BitcastNode.js +156 -0
- package/src/nodes/math/BitcountNode.js +433 -0
- package/src/nodes/math/ConditionalNode.js +110 -21
- package/src/nodes/math/Hash.js +8 -0
- package/src/nodes/math/MathNode.js +820 -97
- package/src/nodes/math/MathUtils.js +47 -1
- package/src/nodes/math/OperatorNode.js +517 -84
- package/src/nodes/math/PackFloatNode.js +98 -0
- package/src/nodes/math/TriNoise3D.js +17 -7
- package/src/nodes/math/UnpackFloatNode.js +96 -0
- package/src/nodes/parsers/GLSLNodeFunction.js +16 -0
- package/src/nodes/parsers/GLSLNodeParser.js +11 -0
- package/src/nodes/pmrem/PMREMNode.js +180 -23
- package/src/nodes/pmrem/PMREMUtils.js +114 -5
- package/src/nodes/procedural/Checker.js +8 -0
- package/src/nodes/shapes/Shapes.js +33 -0
- package/src/nodes/tsl/TSLBase.js +10 -4
- package/src/nodes/tsl/TSLCore.js +732 -160
- package/src/nodes/utils/ArrayElementNode.js +55 -4
- package/src/nodes/utils/ConvertNode.js +31 -0
- package/src/nodes/utils/CubeMapNode.js +79 -2
- package/src/nodes/utils/DebugNode.js +83 -0
- package/src/nodes/utils/Discard.js +18 -2
- package/src/nodes/utils/EquirectUV.js +27 -0
- package/src/nodes/utils/EventNode.js +118 -0
- package/src/nodes/utils/FlipNode.js +38 -0
- package/src/nodes/utils/FunctionOverloadingNode.js +91 -22
- package/src/nodes/utils/JoinNode.js +57 -4
- package/src/nodes/utils/LoopNode.js +193 -55
- package/src/nodes/utils/MatcapUV.js +22 -0
- package/src/nodes/utils/MaxMipLevelNode.js +49 -1
- package/src/nodes/utils/MemberNode.js +120 -0
- package/src/nodes/utils/Oscillators.js +41 -0
- package/src/nodes/utils/Packing.js +30 -1
- package/src/nodes/utils/PostProcessingUtils.js +154 -0
- package/src/nodes/utils/RTTNode.js +165 -9
- package/src/nodes/utils/ReflectorNode.js +407 -21
- package/src/nodes/utils/RemapNode.js +81 -2
- package/src/nodes/utils/RotateNode.js +41 -1
- package/src/nodes/utils/SampleNode.js +91 -0
- package/src/nodes/utils/SetNode.js +44 -1
- package/src/nodes/utils/SplitNode.js +66 -3
- package/src/nodes/utils/SpriteSheetUV.js +35 -0
- package/src/nodes/utils/SpriteUtils.js +16 -0
- package/src/nodes/utils/StorageArrayElementNode.js +56 -3
- package/src/nodes/utils/Timer.js +26 -0
- package/src/nodes/utils/TriplanarTextures.js +65 -0
- package/src/nodes/utils/UVUtils.js +48 -0
- package/src/nodes/utils/ViewportUtils.js +12 -0
- package/src/objects/BatchedMesh.js +798 -309
- package/src/objects/Bone.js +24 -0
- package/src/objects/ClippingGroup.js +68 -0
- package/src/objects/Group.js +24 -0
- package/src/objects/InstancedMesh.js +131 -2
- package/src/objects/LOD.js +99 -5
- package/src/objects/Line.js +90 -7
- package/src/objects/LineLoop.js +20 -0
- package/src/objects/LineSegments.js +20 -1
- package/src/objects/Mesh.js +84 -0
- package/src/objects/Points.js +60 -0
- package/src/objects/Skeleton.js +120 -5
- package/src/objects/SkinnedMesh.js +102 -6
- package/src/objects/Sprite.js +65 -1
- package/src/renderers/WebGL3DRenderTarget.js +26 -0
- package/src/renderers/WebGLArrayRenderTarget.js +26 -0
- package/src/renderers/WebGLCubeRenderTarget.js +41 -5
- package/src/renderers/WebGLRenderTarget.js +19 -0
- package/src/renderers/WebGLRenderer.js +1016 -278
- package/src/renderers/common/Animation.js +123 -14
- package/src/renderers/common/Attributes.js +41 -1
- package/src/renderers/common/Backend.js +623 -44
- package/src/renderers/common/Background.js +99 -16
- package/src/renderers/common/BindGroup.js +37 -2
- package/src/renderers/common/Binding.js +46 -0
- package/src/renderers/common/Bindings.js +211 -20
- package/src/renderers/common/BlendMode.js +143 -0
- package/src/renderers/common/Buffer.js +89 -0
- package/src/renderers/common/BufferUtils.js +25 -0
- package/src/renderers/common/BundleGroup.js +57 -0
- package/src/renderers/common/CanvasTarget.js +341 -0
- package/src/renderers/common/ChainMap.js +73 -10
- package/src/renderers/common/ClippingContext.js +172 -87
- package/src/renderers/common/Color4.js +40 -0
- package/src/renderers/common/ComputePipeline.js +24 -0
- package/src/renderers/common/Constants.js +2 -1
- package/src/renderers/common/CubeRenderTarget.js +77 -7
- package/src/renderers/common/DataMap.js +37 -1
- package/src/renderers/common/Geometries.js +163 -14
- package/src/renderers/common/IndirectStorageBufferAttribute.js +38 -0
- package/src/renderers/common/Info.js +81 -36
- package/src/renderers/common/InspectorBase.js +146 -0
- package/src/renderers/common/Lighting.js +57 -0
- package/src/renderers/common/Pipeline.js +22 -0
- package/src/renderers/common/Pipelines.js +150 -7
- package/src/renderers/common/PostProcessing.js +22 -84
- package/src/renderers/common/ProgrammableStage.js +60 -2
- package/src/renderers/common/QuadMesh.js +63 -6
- package/src/renderers/common/RenderBundle.js +14 -8
- package/src/renderers/common/RenderBundles.js +40 -10
- package/src/renderers/common/RenderContext.js +219 -4
- package/src/renderers/common/RenderContexts.js +54 -17
- package/src/renderers/common/RenderList.js +233 -24
- package/src/renderers/common/RenderLists.js +46 -6
- package/src/renderers/common/RenderObject.js +548 -46
- package/src/renderers/common/RenderObjectPipeline.js +40 -0
- package/src/renderers/common/RenderObjects.js +133 -15
- package/src/renderers/common/RenderPipeline.js +216 -6
- package/src/renderers/common/Renderer.js +2155 -332
- package/src/renderers/common/RendererUtils.js +200 -0
- package/src/renderers/common/SampledTexture.js +99 -39
- package/src/renderers/common/Sampler.js +148 -1
- package/src/renderers/common/Storage3DTexture.js +100 -0
- package/src/renderers/common/StorageArrayTexture.js +84 -0
- package/src/renderers/common/StorageBuffer.js +38 -2
- package/src/renderers/common/StorageBufferAttribute.js +31 -2
- package/src/renderers/common/StorageInstancedBufferAttribute.js +31 -2
- package/src/renderers/common/StorageTexture.js +65 -0
- package/src/renderers/common/Textures.js +273 -57
- package/src/renderers/common/TimestampQueryPool.js +163 -0
- package/src/renderers/common/Uniform.js +233 -3
- package/src/renderers/common/UniformBuffer.js +19 -0
- package/src/renderers/common/UniformsGroup.js +235 -26
- package/src/renderers/common/XRManager.js +1677 -0
- package/src/renderers/common/XRRenderTarget.js +91 -0
- package/src/renderers/common/extras/PMREMGenerator.js +371 -108
- package/src/renderers/common/nodes/NodeBuilderState.js +100 -6
- package/src/renderers/common/nodes/NodeLibrary.js +95 -17
- package/src/renderers/common/nodes/NodeManager.js +852 -0
- package/src/renderers/common/nodes/NodeSampledTexture.js +84 -8
- package/src/renderers/common/nodes/NodeSampler.js +41 -1
- package/src/renderers/common/nodes/NodeStorageBuffer.js +48 -3
- package/src/renderers/common/nodes/NodeUniform.js +285 -2
- package/src/renderers/common/nodes/NodeUniformBuffer.js +81 -0
- package/src/renderers/common/nodes/NodeUniformsGroup.js +31 -18
- package/src/renderers/shaders/DFGLUTData.js +49 -0
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/color_fragment.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_pars_fragment.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +8 -10
- package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +4 -24
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +0 -12
- package/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +7 -11
- package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +5 -2
- package/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +6 -2
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +8 -4
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +154 -59
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/packing.glsl.js +20 -4
- package/src/renderers/shaders/ShaderChunk/premultiplied_alpha_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +230 -181
- package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +7 -7
- package/src/renderers/shaders/ShaderChunk.js +3 -3
- package/src/renderers/shaders/ShaderLib/background.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +14 -2
- package/src/renderers/shaders/ShaderLib/{distanceRGBA.glsl.js → distance.glsl.js} +1 -2
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +2 -1
- package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +1 -2
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +2 -1
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -9
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/vsm.glsl.js +4 -6
- package/src/renderers/shaders/ShaderLib.js +7 -5
- package/src/renderers/shaders/UniformsLib.js +2 -7
- package/src/renderers/shaders/UniformsUtils.js +21 -2
- package/src/renderers/webgl/WebGLAttributes.js +4 -0
- package/src/renderers/webgl/WebGLBackground.js +30 -5
- package/src/renderers/webgl/WebGLBindingStates.js +99 -27
- package/src/renderers/webgl/WebGLBufferRenderer.js +2 -6
- package/src/renderers/webgl/WebGLCapabilities.js +7 -14
- package/src/renderers/webgl/WebGLEnvironments.js +228 -0
- package/src/renderers/webgl/WebGLExtensions.js +2 -25
- package/src/renderers/webgl/WebGLGeometries.js +10 -35
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +2 -6
- package/src/renderers/webgl/WebGLInfo.js +3 -1
- package/src/renderers/webgl/WebGLLights.js +18 -1
- package/src/renderers/webgl/WebGLMaterials.js +12 -0
- package/src/renderers/webgl/WebGLObjects.js +3 -1
- package/src/renderers/webgl/WebGLOutput.js +267 -0
- package/src/renderers/webgl/WebGLProgram.js +87 -148
- package/src/renderers/webgl/WebGLPrograms.js +53 -51
- package/src/renderers/webgl/WebGLRenderLists.js +15 -0
- package/src/renderers/webgl/WebGLShadowMap.js +204 -28
- package/src/renderers/webgl/WebGLState.js +88 -56
- package/src/renderers/webgl/WebGLTextures.js +293 -59
- package/src/renderers/webgl/WebGLUniforms.js +40 -3
- package/src/renderers/webgl/WebGLUniformsGroups.js +5 -3
- package/src/renderers/webgl/WebGLUtils.js +7 -5
- package/src/renderers/webgl-fallback/WebGLBackend.js +1416 -293
- package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +5 -10
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +785 -92
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +62 -1
- package/src/renderers/webgl-fallback/utils/WebGLCapabilities.js +28 -0
- package/src/renderers/webgl-fallback/utils/WebGLConstants.js +3 -3
- package/src/renderers/webgl-fallback/utils/WebGLExtensions.js +45 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +584 -20
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +468 -80
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +396 -0
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +72 -24
- package/src/renderers/webgpu/WebGPUBackend.js +1517 -428
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +31 -4
- package/src/renderers/webgpu/WebGPURenderer.js +55 -4
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +23 -16
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +37 -42
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +1335 -241
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +32 -4
- package/src/renderers/webgpu/nodes/WGSLNodeParser.js +11 -0
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +144 -20
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +460 -116
- package/src/renderers/webgpu/utils/WebGPUConstants.js +17 -4
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +283 -69
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +225 -178
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +583 -191
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +310 -0
- package/src/renderers/webgpu/utils/WebGPUUtils.js +150 -28
- package/src/renderers/webxr/WebXRController.js +87 -2
- package/src/renderers/webxr/WebXRDepthSensing.js +52 -7
- package/src/renderers/webxr/WebXRManager.js +275 -15
- package/src/scenes/Fog.js +60 -0
- package/src/scenes/FogExp2.js +51 -0
- package/src/scenes/Scene.js +88 -0
- package/src/textures/CanvasTexture.js +28 -0
- package/src/textures/CompressedArrayTexture.js +57 -0
- package/src/textures/CompressedCubeTexture.js +29 -0
- package/src/textures/CompressedTexture.js +64 -6
- package/src/textures/CubeDepthTexture.js +76 -0
- package/src/textures/CubeTexture.js +52 -4
- package/src/textures/Data3DTexture.js +79 -2
- package/src/textures/DataArrayTexture.js +93 -0
- package/src/textures/DataTexture.js +65 -0
- package/src/textures/DepthTexture.js +59 -11
- package/src/textures/ExternalTexture.js +56 -0
- package/src/textures/FramebufferTexture.js +62 -0
- package/src/textures/Source.js +106 -4
- package/src/textures/Texture.js +488 -6
- package/src/textures/VideoFrameTexture.js +72 -0
- package/src/textures/VideoTexture.js +78 -6
- package/src/utils.js +322 -3
- package/examples/jsm/animation/MMDAnimationHelper.js +0 -1207
- package/examples/jsm/animation/MMDPhysics.js +0 -1406
- package/examples/jsm/cameras/CinematicCamera.js +0 -208
- package/examples/jsm/effects/PeppersGhostEffect.js +0 -153
- package/examples/jsm/exporters/MMDExporter.js +0 -217
- package/examples/jsm/geometries/InstancedPointsGeometry.js +0 -174
- package/examples/jsm/geometries/ParametricGeometries.js +0 -254
- package/examples/jsm/libs/mmdparser.module.js +0 -11530
- package/examples/jsm/loaders/GLTFLoaderAnimationPointer.js +0 -729
- package/examples/jsm/loaders/MMDLoader.js +0 -2295
- package/examples/jsm/loaders/RGBMLoader.js +0 -1081
- package/examples/jsm/materials/MeshGouraudMaterial.js +0 -432
- package/examples/jsm/materials/MeshPostProcessingMaterial.js +0 -144
- package/examples/jsm/misc/Timer.js +0 -128
- package/examples/jsm/objects/InstancedPoints.js +0 -21
- package/examples/jsm/shaders/GodRaysShader.js +0 -321
- package/examples/jsm/shaders/MMDToonShader.js +0 -134
- package/src/materials/nodes/InstancedPointsNodeMaterial.js +0 -156
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +0 -24
- package/src/nodes/accessors/SceneNode.js +0 -55
- package/src/nodes/code/ScriptableNode.js +0 -505
- package/src/nodes/code/ScriptableValueNode.js +0 -170
- package/src/nodes/core/CacheNode.js +0 -50
- package/src/nodes/core/UniformGroup.js +0 -13
- package/src/nodes/display/AfterImageNode.js +0 -158
- package/src/nodes/display/AnaglyphPassNode.js +0 -67
- package/src/nodes/display/AnamorphicNode.js +0 -151
- package/src/nodes/display/BlendMode.js +0 -54
- package/src/nodes/display/BloomNode.js +0 -341
- package/src/nodes/display/DenoiseNode.js +0 -204
- package/src/nodes/display/DepthOfFieldNode.js +0 -124
- package/src/nodes/display/DotScreenNode.js +0 -66
- package/src/nodes/display/FXAANode.js +0 -332
- package/src/nodes/display/FilmNode.js +0 -56
- package/src/nodes/display/GTAONode.js +0 -331
- package/src/nodes/display/GaussianBlurNode.js +0 -213
- package/src/nodes/display/Lut3DNode.js +0 -57
- package/src/nodes/display/MotionBlur.js +0 -25
- package/src/nodes/display/ParallaxBarrierPassNode.js +0 -58
- package/src/nodes/display/PixelationPassNode.js +0 -213
- package/src/nodes/display/PosterizeNode.js +0 -33
- package/src/nodes/display/RGBShiftNode.js +0 -53
- package/src/nodes/display/StereoCompositePassNode.js +0 -110
- package/src/nodes/display/TransitionNode.js +0 -80
- package/src/nodes/fog/FogExp2Node.js +0 -35
- package/src/nodes/fog/FogNode.js +0 -50
- package/src/nodes/fog/FogRangeNode.js +0 -36
- package/src/nodes/functions/BSDF/DFGApprox.js +0 -30
- package/src/nodes/utils/EquirectUVNode.js +0 -36
- package/src/nodes/utils/MatcapUVNode.js +0 -33
- package/src/nodes/utils/OscNode.js +0 -85
- package/src/nodes/utils/SpriteSheetUVNode.js +0 -45
- package/src/nodes/utils/TimerNode.js +0 -97
- package/src/nodes/utils/TriplanarTexturesNode.js +0 -64
- package/src/renderers/common/nodes/Nodes.js +0 -534
- package/src/renderers/webgl/WebGLCubeMaps.js +0 -99
- package/src/renderers/webgl/WebGLCubeUVMaps.js +0 -136
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright 2010-
|
|
3
|
+
* Copyright 2010-2026 Three.js Authors
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
*/
|
|
6
|
-
const t="169.19",e={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},n={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},i=0,s=1,r=2,a=3,o=0,l=1,c=2,u=3,h=0,d=1,p=2,m=0,f=1,g=2,v=3,y=4,_=5,x=100,M=101,b=102,T=103,S=104,w=200,E=201,A=202,N=203,C=204,R=205,I=206,L=207,P=208,U=209,D=210,O=211,z=212,V=213,F=214,B=0,k=1,H=2,G=3,W=4,j=5,X=6,q=7,Y=0,Z=1,$=2,J=0,K=1,Q=2,tt=3,et=4,nt=5,it=6,st=7,rt="attached",at="detached",ot=300,lt=301,ct=302,ut=303,ht=304,dt=306,pt=1e3,mt=1001,ft=1002,gt=1003,vt=1004,yt=1004,_t=1005,xt=1005,Mt=1006,bt=1007,Tt=1007,St=1008,wt=1008,Et=1009,At=1010,Nt=1011,Ct=1012,Rt=1013,It=1014,Lt=1015,Pt=1016,Ut=1017,Dt=1018,Ot=1020,zt=35902,Vt=35899,Ft=1021,Bt=1022,kt=1023,Ht=1024,Gt=1025,Wt=1026,jt=1027,Xt=1028,qt=1029,Yt=1030,Zt=1031,$t=1032,Jt=1033,Kt=33776,Qt=33777,te=33778,ee=33779,ne=35840,ie=35841,se=35842,re=35843,ae=36196,oe=37492,le=37496,ce=37808,ue=37809,he=37810,de=37811,pe=37812,me=37813,fe=37814,ge=37815,ve=37816,ye=37817,_e=37818,xe=37819,Me=37820,be=37821,Te=36492,Se=36494,we=36495,Ee=36283,Ae=36284,Ne=36285,Ce=36286,Re=2200,Ie=2201,Le=2202,Pe=2300,Ue=2301,De=2302,Oe=2400,ze=2401,Ve=2402,Fe=2500,Be=2501,ke=0,He=1,Ge=2,We=3200,je=3201,Xe=3202,qe=3203,Ye=0,Ze=1,$e="",Je="srgb",Ke="srgb-linear",Qe="display-p3",tn="display-p3-linear",en="linear",nn="srgb",sn="rec709",rn="p3",an=0,on=7680,ln=7681,cn=7682,un=7683,hn=34055,dn=34056,pn=5386,mn=512,fn=513,gn=514,vn=515,yn=516,_n=517,xn=518,Mn=519,bn=512,Tn=513,Sn=514,wn=515,En=516,An=517,Nn=518,Cn=519,Rn=35044,In=35048,Ln=35040,Pn=35045,Un=35049,Dn=35041,On=35046,zn=35050,Vn=35042,Fn="100",Bn="300 es",kn=2e3,Hn=2001;class Gn{addEventListener(t,e){void 0===this._listeners&&(this._listeners={});const n=this._listeners;void 0===n[t]&&(n[t]=[]),-1===n[t].indexOf(e)&&n[t].push(e)}hasEventListener(t,e){if(void 0===this._listeners)return!1;const n=this._listeners;return void 0!==n[t]&&-1!==n[t].indexOf(e)}removeEventListener(t,e){if(void 0===this._listeners)return;const n=this._listeners[t];if(void 0!==n){const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}dispatchEvent(t){if(void 0===this._listeners)return;const e=this._listeners[t.type];if(void 0!==e){t.target=this;const n=e.slice(0);for(let e=0,i=n.length;e<i;e++)n[e].call(this,t);t.target=null}}}const Wn=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let jn=1234567;const Xn=Math.PI/180,qn=180/Math.PI;function Yn(){const t=4294967295*Math.random()|0,e=4294967295*Math.random()|0,n=4294967295*Math.random()|0,i=4294967295*Math.random()|0;return(Wn[255&t]+Wn[t>>8&255]+Wn[t>>16&255]+Wn[t>>24&255]+"-"+Wn[255&e]+Wn[e>>8&255]+"-"+Wn[e>>16&15|64]+Wn[e>>24&255]+"-"+Wn[63&n|128]+Wn[n>>8&255]+"-"+Wn[n>>16&255]+Wn[n>>24&255]+Wn[255&i]+Wn[i>>8&255]+Wn[i>>16&255]+Wn[i>>24&255]).toLowerCase()}function Zn(t,e,n){return Math.max(e,Math.min(n,t))}function $n(t,e){return(t%e+e)%e}function Jn(t,e,n){return(1-n)*t+n*e}function Kn(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function Qn(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(4294967295*t);case Uint16Array:return Math.round(65535*t);case Uint8Array:return Math.round(255*t);case Int32Array:return Math.round(2147483647*t);case Int16Array:return Math.round(32767*t);case Int8Array:return Math.round(127*t);default:throw new Error("Invalid component type.")}}const ti={DEG2RAD:Xn,RAD2DEG:qn,generateUUID:Yn,clamp:Zn,euclideanModulo:$n,mapLinear:function(t,e,n,i,s){return i+(t-e)*(s-i)/(n-e)},inverseLerp:function(t,e,n){return t!==e?(n-t)/(e-t):0},lerp:Jn,damp:function(t,e,n,i){return Jn(t,e,1-Math.exp(-n*i))},pingpong:function(t,e=1){return e-Math.abs($n(t,2*e)-e)},smoothstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*(3-2*t)},smootherstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},seededRandom:function(t){void 0!==t&&(jn=t);let e=jn+=1831565813;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296},degToRad:function(t){return t*Xn},radToDeg:function(t){return t*qn},isPowerOfTwo:function(t){return!(t&t-1)&&0!==t},ceilPowerOfTwo:function(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},floorPowerOfTwo:function(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))},setQuaternionFromProperEuler:function(t,e,n,i,s){const r=Math.cos,a=Math.sin,o=r(n/2),l=a(n/2),c=r((e+i)/2),u=a((e+i)/2),h=r((e-i)/2),d=a((e-i)/2),p=r((i-e)/2),m=a((i-e)/2);switch(s){case"XYX":t.set(o*u,l*h,l*d,o*c);break;case"YZY":t.set(l*d,o*u,l*h,o*c);break;case"ZXZ":t.set(l*h,l*d,o*u,o*c);break;case"XZX":t.set(o*u,l*m,l*p,o*c);break;case"YXY":t.set(l*p,o*u,l*m,o*c);break;case"ZYZ":t.set(l*m,l*p,o*u,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}},normalize:Qn,denormalize:Kn};class ei{constructor(t=0,e=0){ei.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,n=this.y,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6],this.y=i[1]*e+i[4]*n+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(Zn(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const n=Math.cos(e),i=Math.sin(e),s=this.x-t.x,r=this.y-t.y;return this.x=s*n-r*i+t.x,this.y=s*i+r*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class ni{constructor(t,e,n,i,s,r,a,o,l){ni.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==t&&this.set(t,e,n,i,s,r,a,o,l)}set(t,e,n,i,s,r,a,o,l){const c=this.elements;return c[0]=t,c[1]=i,c[2]=a,c[3]=e,c[4]=s,c[5]=o,c[6]=n,c[7]=r,c[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,s=this.elements,r=n[0],a=n[3],o=n[6],l=n[1],c=n[4],u=n[7],h=n[2],d=n[5],p=n[8],m=i[0],f=i[3],g=i[6],v=i[1],y=i[4],_=i[7],x=i[2],M=i[5],b=i[8];return s[0]=r*m+a*v+o*x,s[3]=r*f+a*y+o*M,s[6]=r*g+a*_+o*b,s[1]=l*m+c*v+u*x,s[4]=l*f+c*y+u*M,s[7]=l*g+c*_+u*b,s[2]=h*m+d*v+p*x,s[5]=h*f+d*y+p*M,s[8]=h*g+d*_+p*b,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[1],i=t[2],s=t[3],r=t[4],a=t[5],o=t[6],l=t[7],c=t[8];return e*r*c-e*a*l-n*s*c+n*a*o+i*s*l-i*r*o}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],s=t[3],r=t[4],a=t[5],o=t[6],l=t[7],c=t[8],u=c*r-a*l,h=a*o-c*s,d=l*s-r*o,p=e*u+n*h+i*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const m=1/p;return t[0]=u*m,t[1]=(i*l-c*n)*m,t[2]=(a*n-i*r)*m,t[3]=h*m,t[4]=(c*e-i*o)*m,t[5]=(i*s-a*e)*m,t[6]=d*m,t[7]=(n*o-l*e)*m,t[8]=(r*e-n*s)*m,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(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,i,s,r,a){const o=Math.cos(s),l=Math.sin(s);return this.set(n*o,n*l,-n*(o*r+l*a)+r+t,-i*l,i*o,-i*(-l*r+o*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(ii.makeScale(t,e)),this}rotate(t){return this.premultiply(ii.makeRotation(-t)),this}translate(t,e){return this.premultiply(ii.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,n=t.elements;for(let t=0;t<9;t++)if(e[t]!==n[t])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return(new this.constructor).fromArray(this.elements)}}const ii=new ni;function si(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}const ri={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function ai(t,e){return new ri[t](e)}function oi(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function li(){const t=oi("canvas");return t.style.display="block",t}const ci={};function ui(t){t in ci||(ci[t]=!0,console.warn(t))}const hi=(new ni).set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),di=(new ni).set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),pi={[Ke]:{transfer:en,primaries:sn,luminanceCoefficients:[.2126,.7152,.0722],toReference:t=>t,fromReference:t=>t},[Je]:{transfer:nn,primaries:sn,luminanceCoefficients:[.2126,.7152,.0722],toReference:t=>t.convertSRGBToLinear(),fromReference:t=>t.convertLinearToSRGB()},[tn]:{transfer:en,primaries:rn,luminanceCoefficients:[.2289,.6917,.0793],toReference:t=>t.applyMatrix3(di),fromReference:t=>t.applyMatrix3(hi)},[Qe]:{transfer:nn,primaries:rn,luminanceCoefficients:[.2289,.6917,.0793],toReference:t=>t.convertSRGBToLinear().applyMatrix3(di),fromReference:t=>t.applyMatrix3(hi).convertLinearToSRGB()}},mi=new Set([Ke,tn]),fi={enabled:!0,_workingColorSpace:Ke,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(t){if(!mi.has(t))throw new Error(`Unsupported working color space, "${t}".`);this._workingColorSpace=t},convert:function(t,e,n){if(!1===this.enabled||e===n||!e||!n)return t;const i=pi[e].toReference;return(0,pi[n].fromReference)(i(t))},fromWorkingColorSpace:function(t,e){return this.convert(t,this._workingColorSpace,e)},toWorkingColorSpace:function(t,e){return this.convert(t,e,this._workingColorSpace)},getPrimaries:function(t){return pi[t].primaries},getTransfer:function(t){return t===$e?en:pi[t].transfer},getLuminanceCoefficients:function(t,e=this._workingColorSpace){return t.fromArray(pi[e].luminanceCoefficients)}};function gi(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function vi(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}let yi;class _i{static getDataURL(t){if(/^data:/i.test(t.src))return t.src;if("undefined"==typeof HTMLCanvasElement)return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{void 0===yi&&(yi=oi("canvas")),yi.width=t.width,yi.height=t.height;const n=yi.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),e=yi}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}static sRGBToLinear(t){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const e=oi("canvas");e.width=t.width,e.height=t.height;const n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const i=n.getImageData(0,0,t.width,t.height),s=i.data;for(let t=0;t<s.length;t++)s[t]=255*gi(s[t]/255);return n.putImageData(i,0,0),e}if(t.data){const e=t.data.slice(0);for(let t=0;t<e.length;t++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[t]=Math.floor(255*gi(e[t]/255)):e[t]=gi(e[t]);return{data:e,width:t.width,height:t.height}}return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let xi=0;class Mi{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:xi++}),this.uuid=Yn(),this.data=t,this.dataReady=!0,this.version=0}set needsUpdate(t){!0===t&&this.version++}toJSON(t){const e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.images[this.uuid])return t.images[this.uuid];const n={uuid:this.uuid,url:""},i=this.data;if(null!==i){let t;if(Array.isArray(i)){t=[];for(let e=0,n=i.length;e<n;e++)i[e].isDataTexture?t.push(bi(i[e].image)):t.push(bi(i[e]))}else t=bi(i);n.url=t}return e||(t.images[this.uuid]=n),n}}function bi(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap?_i.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let Ti=0;class Si extends Gn{constructor(t=Si.DEFAULT_IMAGE,e=Si.DEFAULT_MAPPING,n=1001,i=1001,s=1006,r=1008,a=1023,o=1009,l=Si.DEFAULT_ANISOTROPY,c=""){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Ti++}),this.uuid=Yn(),this.name="",this.source=new Mi(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=s,this.minFilter=r,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=o,this.offset=new ei(0,0),this.repeat=new ei(1,1),this.center=new ei(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new ni,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=c,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}get image(){return this.source.data}set image(t=null){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return(new this.constructor).copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}toJSON(t){const e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.textures[this.uuid])return t.textures[this.uuid];const n={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==ot)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case pt:t.x=t.x-Math.floor(t.x);break;case mt:t.x=t.x<0?0:1;break;case ft:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case pt:t.y=t.y-Math.floor(t.y);break;case mt:t.y=t.y<0?0:1;break;case ft:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){!0===t&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){!0===t&&this.pmremVersion++}}Si.DEFAULT_IMAGE=null,Si.DEFAULT_MAPPING=ot,Si.DEFAULT_ANISOTROPY=4;class wi{constructor(t=0,e=0,n=0,i=1){wi.prototype.isVector4=!0,this.x=t,this.y=e,this.z=n,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,i){return this.x=t,this.y=e,this.z=n,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){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: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,s=this.w,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*i+r[12]*s,this.y=r[1]*e+r[5]*n+r[9]*i+r[13]*s,this.z=r[2]*e+r[6]*n+r[10]*i+r[14]*s,this.w=r[3]*e+r[7]*n+r[11]*i+r[15]*s,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,i,s;const r=.01,a=.1,o=t.elements,l=o[0],c=o[4],u=o[8],h=o[1],d=o[5],p=o[9],m=o[2],f=o[6],g=o[10];if(Math.abs(c-h)<r&&Math.abs(u-m)<r&&Math.abs(p-f)<r){if(Math.abs(c+h)<a&&Math.abs(u+m)<a&&Math.abs(p+f)<a&&Math.abs(l+d+g-3)<a)return this.set(1,0,0,0),this;e=Math.PI;const t=(l+1)/2,o=(d+1)/2,v=(g+1)/2,y=(c+h)/4,_=(u+m)/4,x=(p+f)/4;return t>o&&t>v?t<r?(n=0,i=.707106781,s=.707106781):(n=Math.sqrt(t),i=y/n,s=_/n):o>v?o<r?(n=.707106781,i=0,s=.707106781):(i=Math.sqrt(o),n=y/i,s=x/i):v<r?(n=.707106781,i=.707106781,s=0):(s=Math.sqrt(v),n=_/s,i=x/s),this.set(n,i,s,e),this}let v=Math.sqrt((f-p)*(f-p)+(u-m)*(u-m)+(h-c)*(h-c));return Math.abs(v)<.001&&(v=1),this.x=(f-p)/v,this.y=(u-m)/v,this.z=(h-c)/v,this.w=Math.acos((l+d+g-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),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 Ei extends Gn{constructor(t=1,e=1,n={}){super(),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=1,this.scissor=new wi(0,0,t,e),this.scissorTest=!1,this.viewport=new wi(0,0,t,e);const i={width:t,height:e,depth:1};n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Mt,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},n);const s=new Si(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace);s.flipY=!1,s.generateMipmaps=n.generateMipmaps,s.internalFormat=n.internalFormat,this.textures=[];const r=n.count;for(let t=0;t<r;t++)this.textures[t]=s.clone(),this.textures[t].isRenderTargetTexture=!0;this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.depthTexture=n.depthTexture,this.samples=n.samples}get texture(){return this.textures[0]}set texture(t){this.textures[0]=t}setSize(t,e,n=1){if(this.width!==t||this.height!==e||this.depth!==n){this.width=t,this.height=e,this.depth=n;for(let i=0,s=this.textures.length;i<s;i++)this.textures[i].image.width=t,this.textures[i].image.height=e,this.textures[i].image.depth=n;this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return(new this.constructor).copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let e=0,n=t.textures.length;e<n;e++)this.textures[e]=t.textures[e].clone(),this.textures[e].isRenderTargetTexture=!0;const e=Object.assign({},t.texture.image);return this.texture.source=new Mi(e),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,null!==t.depthTexture&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Ai extends Ei{constructor(t=1,e=1,n={}){super(t,e,n),this.isWebGLRenderTarget=!0}}class Ni extends Si{constructor(t=null,e=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:n,depth:i},this.magFilter=gt,this.minFilter=gt,this.wrapR=mt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class Ci extends Ai{constructor(t=1,e=1,n=1,i={}){super(t,e,i),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new Ni(null,t,e,n),this.texture.isRenderTargetTexture=!0}}class Ri extends Si{constructor(t=null,e=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:n,depth:i},this.magFilter=gt,this.minFilter=gt,this.wrapR=mt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Ii extends Ai{constructor(t=1,e=1,n=1,i={}){super(t,e,i),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new Ri(null,t,e,n),this.texture.isRenderTargetTexture=!0}}class Li{constructor(t=0,e=0,n=0,i=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=i}static slerpFlat(t,e,n,i,s,r,a){let o=n[i+0],l=n[i+1],c=n[i+2],u=n[i+3];const h=s[r+0],d=s[r+1],p=s[r+2],m=s[r+3];if(0===a)return t[e+0]=o,t[e+1]=l,t[e+2]=c,void(t[e+3]=u);if(1===a)return t[e+0]=h,t[e+1]=d,t[e+2]=p,void(t[e+3]=m);if(u!==m||o!==h||l!==d||c!==p){let t=1-a;const e=o*h+l*d+c*p+u*m,n=e>=0?1:-1,i=1-e*e;if(i>Number.EPSILON){const s=Math.sqrt(i),r=Math.atan2(s,e*n);t=Math.sin(t*r)/s,a=Math.sin(a*r)/s}const s=a*n;if(o=o*t+h*s,l=l*t+d*s,c=c*t+p*s,u=u*t+m*s,t===1-a){const t=1/Math.sqrt(o*o+l*l+c*c+u*u);o*=t,l*=t,c*=t,u*=t}}t[e]=o,t[e+1]=l,t[e+2]=c,t[e+3]=u}static multiplyQuaternionsFlat(t,e,n,i,s,r){const a=n[i],o=n[i+1],l=n[i+2],c=n[i+3],u=s[r],h=s[r+1],d=s[r+2],p=s[r+3];return t[e]=a*p+c*u+o*d-l*h,t[e+1]=o*p+c*h+l*u-a*d,t[e+2]=l*p+c*d+a*h-o*u,t[e+3]=c*p-a*u-o*h-l*d,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,i){return this._x=t,this._y=e,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const n=t._x,i=t._y,s=t._z,r=t._order,a=Math.cos,o=Math.sin,l=a(n/2),c=a(i/2),u=a(s/2),h=o(n/2),d=o(i/2),p=o(s/2);switch(r){case"XYZ":this._x=h*c*u+l*d*p,this._y=l*d*u-h*c*p,this._z=l*c*p+h*d*u,this._w=l*c*u-h*d*p;break;case"YXZ":this._x=h*c*u+l*d*p,this._y=l*d*u-h*c*p,this._z=l*c*p-h*d*u,this._w=l*c*u+h*d*p;break;case"ZXY":this._x=h*c*u-l*d*p,this._y=l*d*u+h*c*p,this._z=l*c*p+h*d*u,this._w=l*c*u-h*d*p;break;case"ZYX":this._x=h*c*u-l*d*p,this._y=l*d*u+h*c*p,this._z=l*c*p-h*d*u,this._w=l*c*u+h*d*p;break;case"YZX":this._x=h*c*u+l*d*p,this._y=l*d*u+h*c*p,this._z=l*c*p-h*d*u,this._w=l*c*u-h*d*p;break;case"XZY":this._x=h*c*u-l*d*p,this._y=l*d*u-h*c*p,this._z=l*c*p+h*d*u,this._w=l*c*u+h*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+r)}return!0===e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,i=Math.sin(n);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],i=e[4],s=e[8],r=e[1],a=e[5],o=e[9],l=e[2],c=e[6],u=e[10],h=n+a+u;if(h>0){const t=.5/Math.sqrt(h+1);this._w=.25/t,this._x=(c-o)*t,this._y=(s-l)*t,this._z=(r-i)*t}else if(n>a&&n>u){const t=2*Math.sqrt(1+n-a-u);this._w=(c-o)/t,this._x=.25*t,this._y=(i+r)/t,this._z=(s+l)/t}else if(a>u){const t=2*Math.sqrt(1+a-n-u);this._w=(s-l)/t,this._x=(i+r)/t,this._y=.25*t,this._z=(o+c)/t}else{const t=2*Math.sqrt(1+u-n-a);this._w=(r-i)/t,this._x=(s+l)/t,this._y=(o+c)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<Number.EPSILON?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Zn(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(0===n)return this;const i=Math.min(1,e/n);return this.slerp(t,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const n=t._x,i=t._y,s=t._z,r=t._w,a=e._x,o=e._y,l=e._z,c=e._w;return this._x=n*c+r*a+i*l-s*o,this._y=i*c+r*o+s*a-n*l,this._z=s*c+r*l+n*o-i*a,this._w=r*c-n*a-i*o-s*l,this._onChangeCallback(),this}slerp(t,e){if(0===e)return this;if(1===e)return this.copy(t);const n=this._x,i=this._y,s=this._z,r=this._w;let a=r*t._w+n*t._x+i*t._y+s*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=r,this._x=n,this._y=i,this._z=s,this;const o=1-a*a;if(o<=Number.EPSILON){const t=1-e;return this._w=t*r+e*this._w,this._x=t*n+e*this._x,this._y=t*i+e*this._y,this._z=t*s+e*this._z,this.normalize(),this}const l=Math.sqrt(o),c=Math.atan2(l,a),u=Math.sin((1-e)*c)/l,h=Math.sin(e*c)/l;return this._w=r*u+this._w*h,this._x=n*u+this._x*h,this._y=i*u+this._y*h,this._z=s*u+this._z*h,this._onChangeCallback(),this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(i*Math.sin(t),i*Math.cos(t),s*Math.sin(e),s*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class Pi{constructor(t=0,e=0,n=0){Pi.prototype.isVector3=!0,this.x=t,this.y=e,this.z=n}set(t,e,n){return void 0===n&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(Di.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Di.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,i=this.z,s=t.elements;return this.x=s[0]*e+s[3]*n+s[6]*i,this.y=s[1]*e+s[4]*n+s[7]*i,this.z=s[2]*e+s[5]*n+s[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,s=t.elements,r=1/(s[3]*e+s[7]*n+s[11]*i+s[15]);return this.x=(s[0]*e+s[4]*n+s[8]*i+s[12])*r,this.y=(s[1]*e+s[5]*n+s[9]*i+s[13])*r,this.z=(s[2]*e+s[6]*n+s[10]*i+s[14])*r,this}applyQuaternion(t){const e=this.x,n=this.y,i=this.z,s=t.x,r=t.y,a=t.z,o=t.w,l=2*(r*i-a*n),c=2*(a*e-s*i),u=2*(s*n-r*e);return this.x=e+o*l+r*u-a*c,this.y=n+o*c+a*l-s*u,this.z=i+o*u+s*c-r*l,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,n=this.y,i=this.z,s=t.elements;return this.x=s[0]*e+s[4]*n+s[8]*i,this.y=s[1]*e+s[5]*n+s[9]*i,this.z=s[2]*e+s[6]*n+s[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,i=t.y,s=t.z,r=e.x,a=e.y,o=e.z;return this.x=i*o-s*a,this.y=s*r-n*o,this.z=n*a-i*r,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return Ui.copy(this).projectOnVector(t),this.sub(Ui)}reflect(t){return this.sub(Ui.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(Zn(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,i=this.z-t.z;return e*e+n*n+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){const i=Math.sin(e)*t;return this.x=i*Math.sin(n),this.y=Math.cos(e)*t,this.z=i*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,4*e)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,3*e)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),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=2*Math.random()-1,n=Math.sqrt(1-e*e);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}}const Ui=new Pi,Di=new Li;class Oi{constructor(t=new Pi(1/0,1/0,1/0),e=new Pi(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e+=3)this.expandByPoint(Vi.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint(Vi.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const n=Vi.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return(new this.constructor).copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.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(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const n=t.geometry;if(void 0!==n){const i=n.getAttribute("position");if(!0===e&&void 0!==i&&!0!==t.isInstancedMesh)for(let e=0,n=i.count;e<n;e++)!0===t.isMesh?t.getVertexPosition(e,Vi):Vi.fromBufferAttribute(i,e),Vi.applyMatrix4(t.matrixWorld),this.expandByPoint(Vi);else void 0!==t.boundingBox?(null===t.boundingBox&&t.computeBoundingBox(),Fi.copy(t.boundingBox)):(null===n.boundingBox&&n.computeBoundingBox(),Fi.copy(n.boundingBox)),Fi.applyMatrix4(t.matrixWorld),this.union(Fi)}const i=t.children;for(let t=0,n=i.length;t<n;t++)this.expandByObject(i[t],e);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,Vi),Vi.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Xi),qi.subVectors(this.max,Xi),Bi.subVectors(t.a,Xi),ki.subVectors(t.b,Xi),Hi.subVectors(t.c,Xi),Gi.subVectors(ki,Bi),Wi.subVectors(Hi,ki),ji.subVectors(Bi,Hi);let e=[0,-Gi.z,Gi.y,0,-Wi.z,Wi.y,0,-ji.z,ji.y,Gi.z,0,-Gi.x,Wi.z,0,-Wi.x,ji.z,0,-ji.x,-Gi.y,Gi.x,0,-Wi.y,Wi.x,0,-ji.y,ji.x,0];return!!$i(e,Bi,ki,Hi,qi)&&(e=[1,0,0,0,1,0,0,0,1],!!$i(e,Bi,ki,Hi,qi)&&(Yi.crossVectors(Gi,Wi),e=[Yi.x,Yi.y,Yi.z],$i(e,Bi,ki,Hi,qi)))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Vi).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=.5*this.getSize(Vi).length()),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()||(zi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),zi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),zi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),zi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),zi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),zi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),zi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),zi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(zi)),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const zi=[new Pi,new Pi,new Pi,new Pi,new Pi,new Pi,new Pi,new Pi],Vi=new Pi,Fi=new Oi,Bi=new Pi,ki=new Pi,Hi=new Pi,Gi=new Pi,Wi=new Pi,ji=new Pi,Xi=new Pi,qi=new Pi,Yi=new Pi,Zi=new Pi;function $i(t,e,n,i,s){for(let r=0,a=t.length-3;r<=a;r+=3){Zi.fromArray(t,r);const a=s.x*Math.abs(Zi.x)+s.y*Math.abs(Zi.y)+s.z*Math.abs(Zi.z),o=e.dot(Zi),l=n.dot(Zi),c=i.dot(Zi);if(Math.max(-Math.max(o,l,c),Math.min(o,l,c))>a)return!1}return!0}const Ji=new Oi,Ki=new Pi,Qi=new Pi;class ts{constructor(t=new Pi,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const n=this.center;void 0!==e?n.copy(e):Ji.setFromPoints(t).getCenter(n);let i=0;for(let e=0,s=t.length;e<s;e++)i=Math.max(i,n.distanceToSquared(t[e]));return this.radius=Math.sqrt(i),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const n=this.center.distanceToSquared(t);return e.copy(t),n>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;Ki.subVectors(t,this.center);const e=Ki.lengthSq();if(e>this.radius*this.radius){const t=Math.sqrt(e),n=.5*(t-this.radius);this.center.addScaledVector(Ki,n/t),this.radius+=n}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(!0===this.center.equals(t.center)?this.radius=Math.max(this.radius,t.radius):(Qi.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Ki.copy(t.center).add(Qi)),this.expandByPoint(Ki.copy(t.center).sub(Qi))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const es=new Pi,ns=new Pi,is=new Pi,ss=new Pi,rs=new Pi,as=new Pi,os=new Pi;class ls{constructor(t=new Pi,e=new Pi(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,es)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=es.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(es.copy(this.origin).addScaledVector(this.direction,e),es.distanceToSquared(t))}distanceSqToSegment(t,e,n,i){ns.copy(t).add(e).multiplyScalar(.5),is.copy(e).sub(t).normalize(),ss.copy(this.origin).sub(ns);const s=.5*t.distanceTo(e),r=-this.direction.dot(is),a=ss.dot(this.direction),o=-ss.dot(is),l=ss.lengthSq(),c=Math.abs(1-r*r);let u,h,d,p;if(c>0)if(u=r*o-a,h=r*a-o,p=s*c,u>=0)if(h>=-p)if(h<=p){const t=1/c;u*=t,h*=t,d=u*(u+r*h+2*a)+h*(r*u+h+2*o)+l}else h=s,u=Math.max(0,-(r*h+a)),d=-u*u+h*(h+2*o)+l;else h=-s,u=Math.max(0,-(r*h+a)),d=-u*u+h*(h+2*o)+l;else h<=-p?(u=Math.max(0,-(-r*s+a)),h=u>0?-s:Math.min(Math.max(-s,-o),s),d=-u*u+h*(h+2*o)+l):h<=p?(u=0,h=Math.min(Math.max(-s,-o),s),d=h*(h+2*o)+l):(u=Math.max(0,-(r*s+a)),h=u>0?s:Math.min(Math.max(-s,-o),s),d=-u*u+h*(h+2*o)+l);else h=r>0?-s:s,u=Math.max(0,-(r*h+a)),d=-u*u+h*(h+2*o)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,u),i&&i.copy(ns).addScaledVector(is,h),d}intersectSphere(t,e){es.subVectors(t.center,this.origin);const n=es.dot(this.direction),i=es.dot(es)-n*n,s=t.radius*t.radius;if(i>s)return null;const r=Math.sqrt(s-i),a=n-r,o=n+r;return o<0?null:a<0?this.at(o,e):this.at(a,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){const n=this.distanceToPlane(t);return null===n?null:this.at(n,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);if(0===e)return!0;return t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,i,s,r,a,o;const l=1/this.direction.x,c=1/this.direction.y,u=1/this.direction.z,h=this.origin;return l>=0?(n=(t.min.x-h.x)*l,i=(t.max.x-h.x)*l):(n=(t.max.x-h.x)*l,i=(t.min.x-h.x)*l),c>=0?(s=(t.min.y-h.y)*c,r=(t.max.y-h.y)*c):(s=(t.max.y-h.y)*c,r=(t.min.y-h.y)*c),n>r||s>i?null:((s>n||isNaN(n))&&(n=s),(r<i||isNaN(i))&&(i=r),u>=0?(a=(t.min.z-h.z)*u,o=(t.max.z-h.z)*u):(a=(t.max.z-h.z)*u,o=(t.min.z-h.z)*u),n>o||a>i?null:((a>n||n!=n)&&(n=a),(o<i||i!=i)&&(i=o),i<0?null:this.at(n>=0?n:i,e)))}intersectsBox(t){return null!==this.intersectBox(t,es)}intersectTriangle(t,e,n,i,s){rs.subVectors(e,t),as.subVectors(n,t),os.crossVectors(rs,as);let r,a=this.direction.dot(os);if(a>0){if(i)return null;r=1}else{if(!(a<0))return null;r=-1,a=-a}ss.subVectors(this.origin,t);const o=r*this.direction.dot(as.crossVectors(ss,as));if(o<0)return null;const l=r*this.direction.dot(rs.cross(ss));if(l<0)return null;if(o+l>a)return null;const c=-r*ss.dot(os);return c<0?null:this.at(c/a,s)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class cs{constructor(t,e,n,i,s,r,a,o,l,c,u,h,d,p,m,f){cs.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==t&&this.set(t,e,n,i,s,r,a,o,l,c,u,h,d,p,m,f)}set(t,e,n,i,s,r,a,o,l,c,u,h,d,p,m,f){const g=this.elements;return g[0]=t,g[4]=e,g[8]=n,g[12]=i,g[1]=s,g[5]=r,g[9]=a,g[13]=o,g[2]=l,g[6]=c,g[10]=u,g[14]=h,g[3]=d,g[7]=p,g[11]=m,g[15]=f,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 cs).fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,n=t.elements,i=1/us.setFromMatrixColumn(t,0).length(),s=1/us.setFromMatrixColumn(t,1).length(),r=1/us.setFromMatrixColumn(t,2).length();return e[0]=n[0]*i,e[1]=n[1]*i,e[2]=n[2]*i,e[3]=0,e[4]=n[4]*s,e[5]=n[5]*s,e[6]=n[6]*s,e[7]=0,e[8]=n[8]*r,e[9]=n[9]*r,e[10]=n[10]*r,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,n=t.x,i=t.y,s=t.z,r=Math.cos(n),a=Math.sin(n),o=Math.cos(i),l=Math.sin(i),c=Math.cos(s),u=Math.sin(s);if("XYZ"===t.order){const t=r*c,n=r*u,i=a*c,s=a*u;e[0]=o*c,e[4]=-o*u,e[8]=l,e[1]=n+i*l,e[5]=t-s*l,e[9]=-a*o,e[2]=s-t*l,e[6]=i+n*l,e[10]=r*o}else if("YXZ"===t.order){const t=o*c,n=o*u,i=l*c,s=l*u;e[0]=t+s*a,e[4]=i*a-n,e[8]=r*l,e[1]=r*u,e[5]=r*c,e[9]=-a,e[2]=n*a-i,e[6]=s+t*a,e[10]=r*o}else if("ZXY"===t.order){const t=o*c,n=o*u,i=l*c,s=l*u;e[0]=t-s*a,e[4]=-r*u,e[8]=i+n*a,e[1]=n+i*a,e[5]=r*c,e[9]=s-t*a,e[2]=-r*l,e[6]=a,e[10]=r*o}else if("ZYX"===t.order){const t=r*c,n=r*u,i=a*c,s=a*u;e[0]=o*c,e[4]=i*l-n,e[8]=t*l+s,e[1]=o*u,e[5]=s*l+t,e[9]=n*l-i,e[2]=-l,e[6]=a*o,e[10]=r*o}else if("YZX"===t.order){const t=r*o,n=r*l,i=a*o,s=a*l;e[0]=o*c,e[4]=s-t*u,e[8]=i*u+n,e[1]=u,e[5]=r*c,e[9]=-a*c,e[2]=-l*c,e[6]=n*u+i,e[10]=t-s*u}else if("XZY"===t.order){const t=r*o,n=r*l,i=a*o,s=a*l;e[0]=o*c,e[4]=-u,e[8]=l*c,e[1]=t*u+s,e[5]=r*c,e[9]=n*u-i,e[2]=i*u-n,e[6]=a*c,e[10]=s*u+t}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(ds,t,ps)}lookAt(t,e,n){const i=this.elements;return gs.subVectors(t,e),0===gs.lengthSq()&&(gs.z=1),gs.normalize(),ms.crossVectors(n,gs),0===ms.lengthSq()&&(1===Math.abs(n.z)?gs.x+=1e-4:gs.z+=1e-4,gs.normalize(),ms.crossVectors(n,gs)),ms.normalize(),fs.crossVectors(gs,ms),i[0]=ms.x,i[4]=fs.x,i[8]=gs.x,i[1]=ms.y,i[5]=fs.y,i[9]=gs.y,i[2]=ms.z,i[6]=fs.z,i[10]=gs.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,s=this.elements,r=n[0],a=n[4],o=n[8],l=n[12],c=n[1],u=n[5],h=n[9],d=n[13],p=n[2],m=n[6],f=n[10],g=n[14],v=n[3],y=n[7],_=n[11],x=n[15],M=i[0],b=i[4],T=i[8],S=i[12],w=i[1],E=i[5],A=i[9],N=i[13],C=i[2],R=i[6],I=i[10],L=i[14],P=i[3],U=i[7],D=i[11],O=i[15];return s[0]=r*M+a*w+o*C+l*P,s[4]=r*b+a*E+o*R+l*U,s[8]=r*T+a*A+o*I+l*D,s[12]=r*S+a*N+o*L+l*O,s[1]=c*M+u*w+h*C+d*P,s[5]=c*b+u*E+h*R+d*U,s[9]=c*T+u*A+h*I+d*D,s[13]=c*S+u*N+h*L+d*O,s[2]=p*M+m*w+f*C+g*P,s[6]=p*b+m*E+f*R+g*U,s[10]=p*T+m*A+f*I+g*D,s[14]=p*S+m*N+f*L+g*O,s[3]=v*M+y*w+_*C+x*P,s[7]=v*b+y*E+_*R+x*U,s[11]=v*T+y*A+_*I+x*D,s[15]=v*S+y*N+_*L+x*O,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[4],i=t[8],s=t[12],r=t[1],a=t[5],o=t[9],l=t[13],c=t[2],u=t[6],h=t[10],d=t[14];return t[3]*(+s*o*u-i*l*u-s*a*h+n*l*h+i*a*d-n*o*d)+t[7]*(+e*o*d-e*l*h+s*r*h-i*r*d+i*l*c-s*o*c)+t[11]*(+e*l*u-e*a*d-s*r*u+n*r*d+s*a*c-n*l*c)+t[15]*(-i*a*c-e*o*u+e*a*h+i*r*u-n*r*h+n*o*c)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){const i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],s=t[3],r=t[4],a=t[5],o=t[6],l=t[7],c=t[8],u=t[9],h=t[10],d=t[11],p=t[12],m=t[13],f=t[14],g=t[15],v=u*f*l-m*h*l+m*o*d-a*f*d-u*o*g+a*h*g,y=p*h*l-c*f*l-p*o*d+r*f*d+c*o*g-r*h*g,_=c*m*l-p*u*l+p*a*d-r*m*d-c*a*g+r*u*g,x=p*u*o-c*m*o-p*a*h+r*m*h+c*a*f-r*u*f,M=e*v+n*y+i*_+s*x;if(0===M)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const b=1/M;return t[0]=v*b,t[1]=(m*h*s-u*f*s-m*i*d+n*f*d+u*i*g-n*h*g)*b,t[2]=(a*f*s-m*o*s+m*i*l-n*f*l-a*i*g+n*o*g)*b,t[3]=(u*o*s-a*h*s-u*i*l+n*h*l+a*i*d-n*o*d)*b,t[4]=y*b,t[5]=(c*f*s-p*h*s+p*i*d-e*f*d-c*i*g+e*h*g)*b,t[6]=(p*o*s-r*f*s-p*i*l+e*f*l+r*i*g-e*o*g)*b,t[7]=(r*h*s-c*o*s+c*i*l-e*h*l-r*i*d+e*o*d)*b,t[8]=_*b,t[9]=(p*u*s-c*m*s-p*n*d+e*m*d+c*n*g-e*u*g)*b,t[10]=(r*m*s-p*a*s+p*n*l-e*m*l-r*n*g+e*a*g)*b,t[11]=(c*a*s-r*u*s-c*n*l+e*u*l+r*n*d-e*a*d)*b,t[12]=x*b,t[13]=(c*m*i-p*u*i+p*n*h-e*m*h-c*n*f+e*u*f)*b,t[14]=(p*a*i-r*m*i-p*n*o+e*m*o+r*n*f-e*a*f)*b,t[15]=(r*u*i-c*a*i+c*n*o-e*u*o-r*n*h+e*a*h)*b,this}scale(t){const e=this.elements,n=t.x,i=t.y,s=t.z;return e[0]*=n,e[4]*=i,e[8]*=s,e[1]*=n,e[5]*=i,e[9]*=s,e[2]*=n,e[6]*=i,e[10]*=s,e[3]*=n,e[7]*=i,e[11]*=s,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,i))}makeTranslation(t,e,n){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),i=Math.sin(e),s=1-n,r=t.x,a=t.y,o=t.z,l=s*r,c=s*a;return this.set(l*r+n,l*a-i*o,l*o+i*a,0,l*a+i*o,c*a+n,c*o-i*r,0,l*o-i*a,c*o+i*r,s*o*o+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,i,s,r){return this.set(1,n,s,0,t,1,r,0,e,i,1,0,0,0,0,1),this}compose(t,e,n){const i=this.elements,s=e._x,r=e._y,a=e._z,o=e._w,l=s+s,c=r+r,u=a+a,h=s*l,d=s*c,p=s*u,m=r*c,f=r*u,g=a*u,v=o*l,y=o*c,_=o*u,x=n.x,M=n.y,b=n.z;return i[0]=(1-(m+g))*x,i[1]=(d+_)*x,i[2]=(p-y)*x,i[3]=0,i[4]=(d-_)*M,i[5]=(1-(h+g))*M,i[6]=(f+v)*M,i[7]=0,i[8]=(p+y)*b,i[9]=(f-v)*b,i[10]=(1-(h+m))*b,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,n){const i=this.elements;let s=us.set(i[0],i[1],i[2]).length();const r=us.set(i[4],i[5],i[6]).length(),a=us.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),t.x=i[12],t.y=i[13],t.z=i[14],hs.copy(this);const o=1/s,l=1/r,c=1/a;return hs.elements[0]*=o,hs.elements[1]*=o,hs.elements[2]*=o,hs.elements[4]*=l,hs.elements[5]*=l,hs.elements[6]*=l,hs.elements[8]*=c,hs.elements[9]*=c,hs.elements[10]*=c,e.setFromRotationMatrix(hs),n.x=s,n.y=r,n.z=a,this}makePerspective(t,e,n,i,s,r,a=2e3){const o=this.elements,l=2*s/(e-t),c=2*s/(n-i),u=(e+t)/(e-t),h=(n+i)/(n-i);let d,p;if(a===kn)d=-(r+s)/(r-s),p=-2*r*s/(r-s);else{if(a!==Hn)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);d=-r/(r-s),p=-r*s/(r-s)}return o[0]=l,o[4]=0,o[8]=u,o[12]=0,o[1]=0,o[5]=c,o[9]=h,o[13]=0,o[2]=0,o[6]=0,o[10]=d,o[14]=p,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(t,e,n,i,s,r,a=2e3){const o=this.elements,l=1/(e-t),c=1/(n-i),u=1/(r-s),h=(e+t)*l,d=(n+i)*c;let p,m;if(a===kn)p=(r+s)*u,m=-2*u;else{if(a!==Hn)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);p=s*u,m=-1*u}return o[0]=2*l,o[4]=0,o[8]=0,o[12]=-h,o[1]=0,o[5]=2*c,o[9]=0,o[13]=-d,o[2]=0,o[6]=0,o[10]=m,o[14]=-p,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(t){const e=this.elements,n=t.elements;for(let t=0;t<16;t++)if(e[t]!==n[t])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}const us=new Pi,hs=new cs,ds=new Pi(0,0,0),ps=new Pi(1,1,1),ms=new Pi,fs=new Pi,gs=new Pi,vs=new cs,ys=new Li;class _s{constructor(t=0,e=0,n=0,i=_s.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=i}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,i=this._order){return this._x=t,this._y=e,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){const i=t.elements,s=i[0],r=i[4],a=i[8],o=i[1],l=i[5],c=i[9],u=i[2],h=i[6],d=i[10];switch(e){case"XYZ":this._y=Math.asin(Zn(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-c,d),this._z=Math.atan2(-r,s)):(this._x=Math.atan2(h,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Zn(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(o,l)):(this._y=Math.atan2(-u,s),this._z=0);break;case"ZXY":this._x=Math.asin(Zn(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(-u,d),this._z=Math.atan2(-r,l)):(this._y=0,this._z=Math.atan2(o,s));break;case"ZYX":this._y=Math.asin(-Zn(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(h,d),this._z=Math.atan2(o,s)):(this._x=0,this._z=Math.atan2(-r,l));break;case"YZX":this._z=Math.asin(Zn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-c,l),this._y=Math.atan2(-u,s)):(this._x=0,this._y=Math.atan2(a,d));break;case"XZY":this._z=Math.asin(-Zn(r,-1,1)),Math.abs(r)<.9999999?(this._x=Math.atan2(h,l),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-c,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!0===n&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return vs.makeRotationFromQuaternion(t),this.setFromRotationMatrix(vs,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return ys.setFromEuler(this),this.setFromQuaternion(ys,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}_s.DEFAULT_ORDER="XYZ";class xs{constructor(){this.mask=1}set(t){this.mask=1<<t>>>0}enable(t){this.mask|=1<<t}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t}disable(t){this.mask&=~(1<<t)}disableAll(){this.mask=0}test(t){return 0!==(this.mask&t.mask)}isEnabled(t){return!!(this.mask&1<<t)}}let Ms=0;const bs=new Pi,Ts=new Li,Ss=new cs,ws=new Pi,Es=new Pi,As=new Pi,Ns=new Li,Cs=new Pi(1,0,0),Rs=new Pi(0,1,0),Is=new Pi(0,0,1),Ls={type:"added"},Ps={type:"removed"},Us={type:"childadded",child:null},Ds={type:"childremoved",child:null};class Os extends Gn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Ms++}),this.uuid=Yn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Os.DEFAULT_UP.clone();const t=new Pi,e=new _s,n=new Li,i=new Pi(1,1,1);e._onChange(function(){n.setFromEuler(e,!1)}),n._onChange(function(){e.setFromQuaternion(n,void 0,!1)}),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new cs},normalMatrix:{value:new ni}}),this.matrix=new cs,this.matrixWorld=new cs,this.matrixAutoUpdate=Os.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Os.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new xs,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return Ts.setFromAxisAngle(t,e),this.quaternion.multiply(Ts),this}rotateOnWorldAxis(t,e){return Ts.setFromAxisAngle(t,e),this.quaternion.premultiply(Ts),this}rotateX(t){return this.rotateOnAxis(Cs,t)}rotateY(t){return this.rotateOnAxis(Rs,t)}rotateZ(t){return this.rotateOnAxis(Is,t)}translateOnAxis(t,e){return bs.copy(t).applyQuaternion(this.quaternion),this.position.add(bs.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(Cs,t)}translateY(t){return this.translateOnAxis(Rs,t)}translateZ(t){return this.translateOnAxis(Is,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(Ss.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?ws.copy(t):ws.set(t,e,n);const i=this.parent;this.updateWorldMatrix(!0,!1),Es.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ss.lookAt(Es,ws,this.up):Ss.lookAt(ws,Es,this.up),this.quaternion.setFromRotationMatrix(Ss),i&&(Ss.extractRotation(i.matrixWorld),Ts.setFromRotationMatrix(Ss),this.quaternion.premultiply(Ts.invert()))}add(t){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(Ls),Us.child=t,this.dispatchEvent(Us),Us.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.remove(arguments[t]);return this}const e=this.children.indexOf(t);return-1!==e&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(Ps),Ds.child=t,this.dispatchEvent(Ds),Ds.child=null),this}removeFromParent(){const t=this.parent;return null!==t&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),Ss.copy(this.matrixWorld).invert(),null!==t.parent&&(t.parent.updateWorldMatrix(!0,!1),Ss.multiply(t.parent.matrixWorld)),t.applyMatrix4(Ss),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(Ls),Us.child=t,this.dispatchEvent(Us),Us.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let n=0,i=this.children.length;n<i;n++){const i=this.children[n].getObjectByProperty(t,e);if(void 0!==i)return i}}getObjectsByProperty(t,e,n=[]){this[t]===e&&n.push(this);const i=this.children;for(let s=0,r=i.length;s<r;s++)i[s].getObjectsByProperty(t,e,n);return n}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Es,t,As),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Es,Ns,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverse(t)}traverseVisible(t){if(!1===this.visible)return;t(this);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverseVisible(t)}traverseAncestors(t){const e=this.parent;null!==e&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(!0===this.matrixWorldAutoUpdate&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let n=0,i=e.length;n<i;n++){e[n].updateMatrixWorld(t)}}updateWorldMatrix(t,e){const n=this.parent;if(!0===t&&null!==n&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),!0===this.matrixWorldAutoUpdate&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),!0===e){const t=this.children;for(let e=0,n=t.length;e<n;e++){t[e].updateWorldMatrix(!1,!0)}}}toJSON(t){const e=void 0===t||"string"==typeof t,n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const i={};function s(e,n){return void 0===e[n.uuid]&&(e[n.uuid]=n.toJSON(t)),n.uuid}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),!0===this.castShadow&&(i.castShadow=!0),!0===this.receiveShadow&&(i.receiveShadow=!0),!1===this.visible&&(i.visible=!1),!1===this.frustumCulled&&(i.frustumCulled=!1),0!==this.renderOrder&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map(t=>({boxInitialized:t.boxInitialized,boxMin:t.box.min.toArray(),boxMax:t.box.max.toArray(),sphereInitialized:t.sphereInitialized,sphereRadius:t.sphere.radius,sphereCenter:t.sphere.center.toArray()})),i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(t),null!==this._colorsTexture&&(i.colorsTexture=this._colorsTexture.toJSON(t)),null!==this.boundingSphere&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),null!==this.boundingBox&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()})),this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(t.geometries,this.geometry);const e=this.geometry.parameters;if(void 0!==e&&void 0!==e.shapes){const n=e.shapes;if(Array.isArray(n))for(let e=0,i=n.length;e<i;e++){const i=n[e];s(t.shapes,i)}else s(t.shapes,n)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(s(t.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){const e=[];for(let n=0,i=this.material.length;n<i;n++)e.push(s(t.materials,this.material[n]));i.material=e}else i.material=s(t.materials,this.material);if(this.children.length>0){i.children=[];for(let e=0;e<this.children.length;e++)i.children.push(this.children[e].toJSON(t).object)}if(this.animations.length>0){i.animations=[];for(let e=0;e<this.animations.length;e++){const n=this.animations[e];i.animations.push(s(t.animations,n))}}if(e){const e=r(t.geometries),i=r(t.materials),s=r(t.textures),a=r(t.images),o=r(t.shapes),l=r(t.skeletons),c=r(t.animations),u=r(t.nodes);e.length>0&&(n.geometries=e),i.length>0&&(n.materials=i),s.length>0&&(n.textures=s),a.length>0&&(n.images=a),o.length>0&&(n.shapes=o),l.length>0&&(n.skeletons=l),c.length>0&&(n.animations=c),u.length>0&&(n.nodes=u)}return n.object=i,n;function r(t){const e=[];for(const n in t){const i=t[n];delete i.metadata,e.push(i)}return e}}clone(t){return(new this.constructor).copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(let e=0;e<t.children.length;e++){const n=t.children[e];this.add(n.clone())}return this}}Os.DEFAULT_UP=new Pi(0,1,0),Os.DEFAULT_MATRIX_AUTO_UPDATE=!0,Os.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const zs=new Pi,Vs=new Pi,Fs=new Pi,Bs=new Pi,ks=new Pi,Hs=new Pi,Gs=new Pi,Ws=new Pi,js=new Pi,Xs=new Pi,qs=new wi,Ys=new wi,Zs=new wi;class $s{constructor(t=new Pi,e=new Pi,n=new Pi){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,i){i.subVectors(n,e),zs.subVectors(t,e),i.cross(zs);const s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(t,e,n,i,s){zs.subVectors(i,e),Vs.subVectors(n,e),Fs.subVectors(t,e);const r=zs.dot(zs),a=zs.dot(Vs),o=zs.dot(Fs),l=Vs.dot(Vs),c=Vs.dot(Fs),u=r*l-a*a;if(0===u)return s.set(0,0,0),null;const h=1/u,d=(l*o-a*c)*h,p=(r*c-a*o)*h;return s.set(1-d-p,p,d)}static containsPoint(t,e,n,i){return null!==this.getBarycoord(t,e,n,i,Bs)&&(Bs.x>=0&&Bs.y>=0&&Bs.x+Bs.y<=1)}static getInterpolation(t,e,n,i,s,r,a,o){return null===this.getBarycoord(t,e,n,i,Bs)?(o.x=0,o.y=0,"z"in o&&(o.z=0),"w"in o&&(o.w=0),null):(o.setScalar(0),o.addScaledVector(s,Bs.x),o.addScaledVector(r,Bs.y),o.addScaledVector(a,Bs.z),o)}static getInterpolatedAttribute(t,e,n,i,s,r){return qs.setScalar(0),Ys.setScalar(0),Zs.setScalar(0),qs.fromBufferAttribute(t,e),Ys.fromBufferAttribute(t,n),Zs.fromBufferAttribute(t,i),r.setScalar(0),r.addScaledVector(qs,s.x),r.addScaledVector(Ys,s.y),r.addScaledVector(Zs,s.z),r}static isFrontFacing(t,e,n,i){return zs.subVectors(n,e),Vs.subVectors(t,e),zs.cross(Vs).dot(i)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,i){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,e,n,i){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,i),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return zs.subVectors(this.c,this.b),Vs.subVectors(this.a,this.b),.5*zs.cross(Vs).length()}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return $s.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return $s.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,i,s){return $s.getInterpolation(t,this.a,this.b,this.c,e,n,i,s)}containsPoint(t){return $s.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return $s.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const n=this.a,i=this.b,s=this.c;let r,a;ks.subVectors(i,n),Hs.subVectors(s,n),Ws.subVectors(t,n);const o=ks.dot(Ws),l=Hs.dot(Ws);if(o<=0&&l<=0)return e.copy(n);js.subVectors(t,i);const c=ks.dot(js),u=Hs.dot(js);if(c>=0&&u<=c)return e.copy(i);const h=o*u-c*l;if(h<=0&&o>=0&&c<=0)return r=o/(o-c),e.copy(n).addScaledVector(ks,r);Xs.subVectors(t,s);const d=ks.dot(Xs),p=Hs.dot(Xs);if(p>=0&&d<=p)return e.copy(s);const m=d*l-o*p;if(m<=0&&l>=0&&p<=0)return a=l/(l-p),e.copy(n).addScaledVector(Hs,a);const f=c*p-d*u;if(f<=0&&u-c>=0&&d-p>=0)return Gs.subVectors(s,i),a=(u-c)/(u-c+(d-p)),e.copy(i).addScaledVector(Gs,a);const g=1/(f+m+h);return r=m*g,a=h*g,e.copy(n).addScaledVector(ks,r).addScaledVector(Hs,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const Js={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},Ks={h:0,s:0,l:0},Qs={h:0,s:0,l:0};function tr(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+6*(e-t)*(2/3-n):t}class er{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(void 0===e&&void 0===n){const e=t;e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Je){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,fi.toWorkingColorSpace(this,e),this}setRGB(t,e,n,i=fi.workingColorSpace){return this.r=t,this.g=e,this.b=n,fi.toWorkingColorSpace(this,i),this}setHSL(t,e,n,i=fi.workingColorSpace){if(t=$n(t,1),e=Zn(e,0,1),n=Zn(n,0,1),0===e)this.r=this.g=this.b=n;else{const i=n<=.5?n*(1+e):n+e-n*e,s=2*n-i;this.r=tr(s,i,t+1/3),this.g=tr(s,i,t),this.b=tr(s,i,t-1/3)}return fi.toWorkingColorSpace(this,i),this}setStyle(t,e=Je){function n(e){void 0!==e&&parseFloat(e)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(t)){let s;const r=i[1],a=i[2];switch(r){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,e);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,e);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){const n=i[1],s=n.length;if(3===s)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,e);if(6===s)return this.setHex(parseInt(n,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Je){const n=Js[t.toLowerCase()];return void 0!==n?this.setHex(n,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=gi(t.r),this.g=gi(t.g),this.b=gi(t.b),this}copyLinearToSRGB(t){return this.r=vi(t.r),this.g=vi(t.g),this.b=vi(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Je){return fi.fromWorkingColorSpace(nr.copy(this),t),65536*Math.round(Zn(255*nr.r,0,255))+256*Math.round(Zn(255*nr.g,0,255))+Math.round(Zn(255*nr.b,0,255))}getHexString(t=Je){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=fi.workingColorSpace){fi.fromWorkingColorSpace(nr.copy(this),e);const n=nr.r,i=nr.g,s=nr.b,r=Math.max(n,i,s),a=Math.min(n,i,s);let o,l;const c=(a+r)/2;if(a===r)o=0,l=0;else{const t=r-a;switch(l=c<=.5?t/(r+a):t/(2-r-a),r){case n:o=(i-s)/t+(i<s?6:0);break;case i:o=(s-n)/t+2;break;case s:o=(n-i)/t+4}o/=6}return t.h=o,t.s=l,t.l=c,t}getRGB(t,e=fi.workingColorSpace){return fi.fromWorkingColorSpace(nr.copy(this),e),t.r=nr.r,t.g=nr.g,t.b=nr.b,t}getStyle(t=Je){fi.fromWorkingColorSpace(nr.copy(this),t);const e=nr.r,n=nr.g,i=nr.b;return t!==Je?`color(${t} ${e.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(255*e)},${Math.round(255*n)},${Math.round(255*i)})`}offsetHSL(t,e,n){return this.getHSL(Ks),this.setHSL(Ks.h+t,Ks.s+e,Ks.l+n)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,n){return this.r=t.r+(e.r-t.r)*n,this.g=t.g+(e.g-t.g)*n,this.b=t.b+(e.b-t.b)*n,this}lerpHSL(t,e){this.getHSL(Ks),t.getHSL(Qs);const n=Jn(Ks.h,Qs.h,e),i=Jn(Ks.s,Qs.s,e),s=Jn(Ks.l,Qs.l,e);return this.setHSL(n,i,s),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,n=this.g,i=this.b,s=t.elements;return this.r=s[0]*e+s[3]*n+s[6]*i,this.g=s[1]*e+s[4]*n+s[7]*i,this.b=s[2]*e+s[5]*n+s[8]*i,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const nr=new er;er.NAMES=Js;let ir=0;class sr extends Gn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:ir++}),this.uuid=Yn(),this.name="",this.type="Material",this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=C,this.blendDst=R,this.blendEquation=x,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new er(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=on,this.stencilZFail=on,this.stencilZPass=on,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(void 0!==t)for(const e in t){const n=t[e];if(void 0===n){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}const i=this[e];void 0!==i?i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[e]=n:console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`)}}toJSON(t){const e=void 0===t||"string"==typeof t;e&&(t={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};function i(t){const e=[];for(const n in t){const i=t[n];delete i.metadata,e.push(i)}return e}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),void 0!==this.sheen&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),void 0!==this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),void 0!==this.dispersion&&(n.dispersion=this.dispersion),void 0!==this.iridescence&&(n.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(n.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),void 0!==this.anisotropy&&(n.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,void 0!==this.combine&&(n.combine=this.combine)),void 0!==this.envMapRotation&&(n.envMapRotation=this.envMapRotation.toArray()),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(n.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.transmission&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),void 0!==this.thickness&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(n.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(n.blending=this.blending),0!==this.side&&(n.side=this.side),!0===this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=!0),this.blendSrc!==C&&(n.blendSrc=this.blendSrc),this.blendDst!==R&&(n.blendDst=this.blendDst),this.blendEquation!==x&&(n.blendEquation=this.blendEquation),null!==this.blendSrcAlpha&&(n.blendSrcAlpha=this.blendSrcAlpha),null!==this.blendDstAlpha&&(n.blendDstAlpha=this.blendDstAlpha),null!==this.blendEquationAlpha&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),0!==this.blendAlpha&&(n.blendAlpha=this.blendAlpha),3!==this.depthFunc&&(n.depthFunc=this.depthFunc),!1===this.depthTest&&(n.depthTest=this.depthTest),!1===this.depthWrite&&(n.depthWrite=this.depthWrite),!1===this.colorWrite&&(n.colorWrite=this.colorWrite),255!==this.stencilWriteMask&&(n.stencilWriteMask=this.stencilWriteMask),519!==this.stencilFunc&&(n.stencilFunc=this.stencilFunc),0!==this.stencilRef&&(n.stencilRef=this.stencilRef),255!==this.stencilFuncMask&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==on&&(n.stencilFail=this.stencilFail),this.stencilZFail!==on&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==on&&(n.stencilZPass=this.stencilZPass),!0===this.stencilWrite&&(n.stencilWrite=this.stencilWrite),void 0!==this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaHash&&(n.alphaHash=!0),!0===this.alphaToCoverage&&(n.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=!0),!0===this.forceSinglePass&&(n.forceSinglePass=!0),!0===this.wireframe&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(n.flatShading=!0),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),!1===this.fog&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData),e){const e=i(t.textures),s=i(t.images);e.length>0&&(n.textures=e),s.length>0&&(n.images=s)}return n}clone(){return(new this.constructor).copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let n=null;if(null!==e){const t=e.length;n=new Array(t);for(let i=0;i!==t;++i)n[i]=e[i].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){!0===t&&this.version++}}class rr extends sr{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new er(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 _s,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const ar=or();function or(){const t=new ArrayBuffer(4),e=new Float32Array(t),n=new Uint32Array(t),i=new Uint32Array(512),s=new Uint32Array(512);for(let t=0;t<256;++t){const e=t-127;e<-27?(i[t]=0,i[256|t]=32768,s[t]=24,s[256|t]=24):e<-14?(i[t]=1024>>-e-14,i[256|t]=1024>>-e-14|32768,s[t]=-e-1,s[256|t]=-e-1):e<=15?(i[t]=e+15<<10,i[256|t]=e+15<<10|32768,s[t]=13,s[256|t]=13):e<128?(i[t]=31744,i[256|t]=64512,s[t]=24,s[256|t]=24):(i[t]=31744,i[256|t]=64512,s[t]=13,s[256|t]=13)}const r=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let t=1;t<1024;++t){let e=t<<13,n=0;for(;!(8388608&e);)e<<=1,n-=8388608;e&=-8388609,n+=947912704,r[t]=e|n}for(let t=1024;t<2048;++t)r[t]=939524096+(t-1024<<13);for(let t=1;t<31;++t)a[t]=t<<23;a[31]=1199570944,a[32]=2147483648;for(let t=33;t<63;++t)a[t]=2147483648+(t-32<<23);a[63]=3347054592;for(let t=1;t<64;++t)32!==t&&(o[t]=1024);return{floatView:e,uint32View:n,baseTable:i,shiftTable:s,mantissaTable:r,exponentTable:a,offsetTable:o}}function lr(t){Math.abs(t)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),t=Zn(t,-65504,65504),ar.floatView[0]=t;const e=ar.uint32View[0],n=e>>23&511;return ar.baseTable[n]+((8388607&e)>>ar.shiftTable[n])}function cr(t){const e=t>>10;return ar.uint32View[0]=ar.mantissaTable[ar.offsetTable[e]+(1023&t)]+ar.exponentTable[e],ar.floatView[0]}const ur={toHalfFloat:lr,fromHalfFloat:cr},hr=new Pi,dr=new ei;class pr{constructor(t,e,n=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=t,this.itemSize=e,this.count=void 0!==t?t.length/e:0,this.normalized=n,this.usage=Rn,this.updateRanges=[],this.gpuType=Lt,this.version=0}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let i=0,s=this.itemSize;i<s;i++)this.array[t+i]=e.array[n+i];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(2===this.itemSize)for(let e=0,n=this.count;e<n;e++)dr.fromBufferAttribute(this,e),dr.applyMatrix3(t),this.setXY(e,dr.x,dr.y);else if(3===this.itemSize)for(let e=0,n=this.count;e<n;e++)hr.fromBufferAttribute(this,e),hr.applyMatrix3(t),this.setXYZ(e,hr.x,hr.y,hr.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)hr.fromBufferAttribute(this,e),hr.applyMatrix4(t),this.setXYZ(e,hr.x,hr.y,hr.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)hr.fromBufferAttribute(this,e),hr.applyNormalMatrix(t),this.setXYZ(e,hr.x,hr.y,hr.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)hr.fromBufferAttribute(this,e),hr.transformDirection(t),this.setXYZ(e,hr.x,hr.y,hr.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let n=this.array[t*this.itemSize+e];return this.normalized&&(n=Kn(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=Qn(n,this.array)),this.array[t*this.itemSize+e]=n,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=Kn(e,this.array)),e}setX(t,e){return this.normalized&&(e=Qn(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=Kn(e,this.array)),e}setY(t,e){return this.normalized&&(e=Qn(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=Kn(e,this.array)),e}setZ(t,e){return this.normalized&&(e=Qn(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=Kn(e,this.array)),e}setW(t,e){return this.normalized&&(e=Qn(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=Qn(e,this.array),n=Qn(n,this.array)),this.array[t+0]=e,this.array[t+1]=n,this}setXYZ(t,e,n,i){return t*=this.itemSize,this.normalized&&(e=Qn(e,this.array),n=Qn(n,this.array),i=Qn(i,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this}setXYZW(t,e,n,i,s){return t*=this.itemSize,this.normalized&&(e=Qn(e,this.array),n=Qn(n,this.array),i=Qn(i,this.array),s=Qn(s,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this.array[t+3]=s,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return""!==this.name&&(t.name=this.name),this.usage!==Rn&&(t.usage=this.usage),t}}class mr extends pr{constructor(t,e,n){super(new Int8Array(t),e,n)}}class fr extends pr{constructor(t,e,n){super(new Uint8Array(t),e,n)}}class gr extends pr{constructor(t,e,n){super(new Uint8ClampedArray(t),e,n)}}class vr extends pr{constructor(t,e,n){super(new Int16Array(t),e,n)}}class yr extends pr{constructor(t,e,n){super(new Uint16Array(t),e,n)}}class _r extends pr{constructor(t,e,n){super(new Int32Array(t),e,n)}}class xr extends pr{constructor(t,e,n){super(new Uint32Array(t),e,n)}}class Mr extends pr{constructor(t,e,n){super(new Uint16Array(t),e,n),this.isFloat16BufferAttribute=!0}getX(t){let e=cr(this.array[t*this.itemSize]);return this.normalized&&(e=Kn(e,this.array)),e}setX(t,e){return this.normalized&&(e=Qn(e,this.array)),this.array[t*this.itemSize]=lr(e),this}getY(t){let e=cr(this.array[t*this.itemSize+1]);return this.normalized&&(e=Kn(e,this.array)),e}setY(t,e){return this.normalized&&(e=Qn(e,this.array)),this.array[t*this.itemSize+1]=lr(e),this}getZ(t){let e=cr(this.array[t*this.itemSize+2]);return this.normalized&&(e=Kn(e,this.array)),e}setZ(t,e){return this.normalized&&(e=Qn(e,this.array)),this.array[t*this.itemSize+2]=lr(e),this}getW(t){let e=cr(this.array[t*this.itemSize+3]);return this.normalized&&(e=Kn(e,this.array)),e}setW(t,e){return this.normalized&&(e=Qn(e,this.array)),this.array[t*this.itemSize+3]=lr(e),this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=Qn(e,this.array),n=Qn(n,this.array)),this.array[t+0]=lr(e),this.array[t+1]=lr(n),this}setXYZ(t,e,n,i){return t*=this.itemSize,this.normalized&&(e=Qn(e,this.array),n=Qn(n,this.array),i=Qn(i,this.array)),this.array[t+0]=lr(e),this.array[t+1]=lr(n),this.array[t+2]=lr(i),this}setXYZW(t,e,n,i,s){return t*=this.itemSize,this.normalized&&(e=Qn(e,this.array),n=Qn(n,this.array),i=Qn(i,this.array),s=Qn(s,this.array)),this.array[t+0]=lr(e),this.array[t+1]=lr(n),this.array[t+2]=lr(i),this.array[t+3]=lr(s),this}}class br extends pr{constructor(t,e,n){super(new Float32Array(t),e,n)}}let Tr=0;const Sr=new cs,wr=new Os,Er=new Pi,Ar=new Oi,Nr=new Oi,Cr=new Pi;class Rr extends Gn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Tr++}),this.uuid=Yn(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(si(t)?xr:yr)(t,1):this.index=t,this}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return void 0!==this.attributes[t]}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;void 0!==e&&(e.applyMatrix4(t),e.needsUpdate=!0);const n=this.attributes.normal;if(void 0!==n){const e=(new ni).getNormalMatrix(t);n.applyNormalMatrix(e),n.needsUpdate=!0}const i=this.attributes.tangent;return void 0!==i&&(i.transformDirection(t),i.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(t){return Sr.makeRotationFromQuaternion(t),this.applyMatrix4(Sr),this}rotateX(t){return Sr.makeRotationX(t),this.applyMatrix4(Sr),this}rotateY(t){return Sr.makeRotationY(t),this.applyMatrix4(Sr),this}rotateZ(t){return Sr.makeRotationZ(t),this.applyMatrix4(Sr),this}translate(t,e,n){return Sr.makeTranslation(t,e,n),this.applyMatrix4(Sr),this}scale(t,e,n){return Sr.makeScale(t,e,n),this.applyMatrix4(Sr),this}lookAt(t){return wr.lookAt(t),wr.updateMatrix(),this.applyMatrix4(wr.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Er).negate(),this.translate(Er.x,Er.y,Er.z),this}setFromPoints(t){const e=[];for(let n=0,i=t.length;n<i;n++){const i=t[n];e.push(i.x,i.y,i.z||0)}return this.setAttribute("position",new br(e,3)),this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Oi);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)return console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),void this.boundingBox.set(new Pi(-1/0,-1/0,-1/0),new Pi(1/0,1/0,1/0));if(void 0!==t){if(this.boundingBox.setFromBufferAttribute(t),e)for(let t=0,n=e.length;t<n;t++){const n=e[t];Ar.setFromBufferAttribute(n),this.morphTargetsRelative?(Cr.addVectors(this.boundingBox.min,Ar.min),this.boundingBox.expandByPoint(Cr),Cr.addVectors(this.boundingBox.max,Ar.max),this.boundingBox.expandByPoint(Cr)):(this.boundingBox.expandByPoint(Ar.min),this.boundingBox.expandByPoint(Ar.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new ts);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)return console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),void this.boundingSphere.set(new Pi,1/0);if(t){const n=this.boundingSphere.center;if(Ar.setFromBufferAttribute(t),e)for(let t=0,n=e.length;t<n;t++){const n=e[t];Nr.setFromBufferAttribute(n),this.morphTargetsRelative?(Cr.addVectors(Ar.min,Nr.min),Ar.expandByPoint(Cr),Cr.addVectors(Ar.max,Nr.max),Ar.expandByPoint(Cr)):(Ar.expandByPoint(Nr.min),Ar.expandByPoint(Nr.max))}Ar.getCenter(n);let i=0;for(let e=0,s=t.count;e<s;e++)Cr.fromBufferAttribute(t,e),i=Math.max(i,n.distanceToSquared(Cr));if(e)for(let s=0,r=e.length;s<r;s++){const r=e[s],a=this.morphTargetsRelative;for(let e=0,s=r.count;e<s;e++)Cr.fromBufferAttribute(r,e),a&&(Er.fromBufferAttribute(t,e),Cr.add(Er)),i=Math.max(i,n.distanceToSquared(Cr))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(null===t||void 0===e.position||void 0===e.normal||void 0===e.uv)return void console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");const n=e.position,i=e.normal,s=e.uv;!1===this.hasAttribute("tangent")&&this.setAttribute("tangent",new pr(new Float32Array(4*n.count),4));const r=this.getAttribute("tangent"),a=[],o=[];for(let t=0;t<n.count;t++)a[t]=new Pi,o[t]=new Pi;const l=new Pi,c=new Pi,u=new Pi,h=new ei,d=new ei,p=new ei,m=new Pi,f=new Pi;function g(t,e,i){l.fromBufferAttribute(n,t),c.fromBufferAttribute(n,e),u.fromBufferAttribute(n,i),h.fromBufferAttribute(s,t),d.fromBufferAttribute(s,e),p.fromBufferAttribute(s,i),c.sub(l),u.sub(l),d.sub(h),p.sub(h);const r=1/(d.x*p.y-p.x*d.y);isFinite(r)&&(m.copy(c).multiplyScalar(p.y).addScaledVector(u,-d.y).multiplyScalar(r),f.copy(u).multiplyScalar(d.x).addScaledVector(c,-p.x).multiplyScalar(r),a[t].add(m),a[e].add(m),a[i].add(m),o[t].add(f),o[e].add(f),o[i].add(f))}let v=this.groups;0===v.length&&(v=[{start:0,count:t.count}]);for(let e=0,n=v.length;e<n;++e){const n=v[e],i=n.start;for(let e=i,s=i+n.count;e<s;e+=3)g(t.getX(e+0),t.getX(e+1),t.getX(e+2))}const y=new Pi,_=new Pi,x=new Pi,M=new Pi;function b(t){x.fromBufferAttribute(i,t),M.copy(x);const e=a[t];y.copy(e),y.sub(x.multiplyScalar(x.dot(e))).normalize(),_.crossVectors(M,e);const n=_.dot(o[t])<0?-1:1;r.setXYZW(t,y.x,y.y,y.z,n)}for(let e=0,n=v.length;e<n;++e){const n=v[e],i=n.start;for(let e=i,s=i+n.count;e<s;e+=3)b(t.getX(e+0)),b(t.getX(e+1)),b(t.getX(e+2))}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(void 0!==e){let n=this.getAttribute("normal");if(void 0===n)n=new pr(new Float32Array(3*e.count),3),this.setAttribute("normal",n);else for(let t=0,e=n.count;t<e;t++)n.setXYZ(t,0,0,0);const i=new Pi,s=new Pi,r=new Pi,a=new Pi,o=new Pi,l=new Pi,c=new Pi,u=new Pi;if(t)for(let h=0,d=t.count;h<d;h+=3){const d=t.getX(h+0),p=t.getX(h+1),m=t.getX(h+2);i.fromBufferAttribute(e,d),s.fromBufferAttribute(e,p),r.fromBufferAttribute(e,m),c.subVectors(r,s),u.subVectors(i,s),c.cross(u),a.fromBufferAttribute(n,d),o.fromBufferAttribute(n,p),l.fromBufferAttribute(n,m),a.add(c),o.add(c),l.add(c),n.setXYZ(d,a.x,a.y,a.z),n.setXYZ(p,o.x,o.y,o.z),n.setXYZ(m,l.x,l.y,l.z)}else for(let t=0,a=e.count;t<a;t+=3)i.fromBufferAttribute(e,t+0),s.fromBufferAttribute(e,t+1),r.fromBufferAttribute(e,t+2),c.subVectors(r,s),u.subVectors(i,s),c.cross(u),n.setXYZ(t+0,c.x,c.y,c.z),n.setXYZ(t+1,c.x,c.y,c.z),n.setXYZ(t+2,c.x,c.y,c.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)Cr.fromBufferAttribute(t,e),Cr.normalize(),t.setXYZ(e,Cr.x,Cr.y,Cr.z)}toNonIndexed(){function t(t,e){const n=t.array,i=t.itemSize,s=t.normalized,r=new n.constructor(e.length*i);let a=0,o=0;for(let s=0,l=e.length;s<l;s++){a=t.isInterleavedBufferAttribute?e[s]*t.data.stride+t.offset:e[s]*i;for(let t=0;t<i;t++)r[o++]=n[a++]}return new pr(r,i,s)}if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new Rr,n=this.index.array,i=this.attributes;for(const s in i){const r=t(i[s],n);e.setAttribute(s,r)}const s=this.morphAttributes;for(const i in s){const r=[],a=s[i];for(let e=0,i=a.length;e<i;e++){const i=t(a[e],n);r.push(i)}e.morphAttributes[i]=r}e.morphTargetsRelative=this.morphTargetsRelative;const r=this.groups;for(let t=0,n=r.length;t<n;t++){const n=r[t];e.addGroup(n.start,n.count,n.materialIndex)}return e}toJSON(){const t={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,""!==this.name&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),void 0!==this.parameters){const e=this.parameters;for(const n in e)void 0!==e[n]&&(t[n]=e[n]);return t}t.data={attributes:{}};const e=this.index;null!==e&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const n=this.attributes;for(const e in n){const i=n[e];t.data.attributes[e]=i.toJSON(t.data)}const i={};let s=!1;for(const e in this.morphAttributes){const n=this.morphAttributes[e],r=[];for(let e=0,i=n.length;e<i;e++){const i=n[e];r.push(i.toJSON(t.data))}r.length>0&&(i[e]=r,s=!0)}s&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);const r=this.groups;r.length>0&&(t.data.groups=JSON.parse(JSON.stringify(r)));const a=this.boundingSphere;return null!==a&&(t.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),t}clone(){return(new this.constructor).copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const n=t.index;null!==n&&this.setIndex(n.clone(e));const i=t.attributes;for(const t in i){const n=i[t];this.setAttribute(t,n.clone(e))}const s=t.morphAttributes;for(const t in s){const n=[],i=s[t];for(let t=0,s=i.length;t<s;t++)n.push(i[t].clone(e));this.morphAttributes[t]=n}this.morphTargetsRelative=t.morphTargetsRelative;const r=t.groups;for(let t=0,e=r.length;t<e;t++){const e=r[t];this.addGroup(e.start,e.count,e.materialIndex)}const a=t.boundingBox;null!==a&&(this.boundingBox=a.clone());const o=t.boundingSphere;return null!==o&&(this.boundingSphere=o.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const Ir=new cs,Lr=new ls,Pr=new ts,Ur=new Pi,Dr=new Pi,Or=new Pi,zr=new Pi,Vr=new Pi,Fr=new Pi,Br=new Pi,kr=new Pi;class Hr extends Os{constructor(t=new Rr,e=new rr){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),void 0!==t.morphTargetInfluences&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),void 0!==t.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const n=t[e[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=n.length;t<e;t++){const e=n[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}}}getVertexPosition(t,e){const n=this.geometry,i=n.attributes.position,s=n.morphAttributes.position,r=n.morphTargetsRelative;e.fromBufferAttribute(i,t);const a=this.morphTargetInfluences;if(s&&a){Fr.set(0,0,0);for(let n=0,i=s.length;n<i;n++){const i=a[n],o=s[n];0!==i&&(Vr.fromBufferAttribute(o,t),r?Fr.addScaledVector(Vr,i):Fr.addScaledVector(Vr.sub(e),i))}e.add(Fr)}return e}raycast(t,e){const n=this.geometry,i=this.material,s=this.matrixWorld;if(void 0!==i){if(null===n.boundingSphere&&n.computeBoundingSphere(),Pr.copy(n.boundingSphere),Pr.applyMatrix4(s),Lr.copy(t.ray).recast(t.near),!1===Pr.containsPoint(Lr.origin)){if(null===Lr.intersectSphere(Pr,Ur))return;if(Lr.origin.distanceToSquared(Ur)>(t.far-t.near)**2)return}Ir.copy(s).invert(),Lr.copy(t.ray).applyMatrix4(Ir),null!==n.boundingBox&&!1===Lr.intersectsBox(n.boundingBox)||this._computeIntersections(t,e,Lr)}}_computeIntersections(t,e,n){let i;const s=this.geometry,r=this.material,a=s.index,o=s.attributes.position,l=s.attributes.uv,c=s.attributes.uv1,u=s.attributes.normal,h=s.groups,d=s.drawRange;if(null!==a)if(Array.isArray(r))for(let s=0,o=h.length;s<o;s++){const o=h[s],p=r[o.materialIndex];for(let s=Math.max(o.start,d.start),r=Math.min(a.count,Math.min(o.start+o.count,d.start+d.count));s<r;s+=3){i=Gr(this,p,t,n,l,c,u,a.getX(s),a.getX(s+1),a.getX(s+2)),i&&(i.faceIndex=Math.floor(s/3),i.face.materialIndex=o.materialIndex,e.push(i))}}else{for(let s=Math.max(0,d.start),o=Math.min(a.count,d.start+d.count);s<o;s+=3){i=Gr(this,r,t,n,l,c,u,a.getX(s),a.getX(s+1),a.getX(s+2)),i&&(i.faceIndex=Math.floor(s/3),e.push(i))}}else if(void 0!==o)if(Array.isArray(r))for(let s=0,a=h.length;s<a;s++){const a=h[s],p=r[a.materialIndex];for(let s=Math.max(a.start,d.start),r=Math.min(o.count,Math.min(a.start+a.count,d.start+d.count));s<r;s+=3){i=Gr(this,p,t,n,l,c,u,s,s+1,s+2),i&&(i.faceIndex=Math.floor(s/3),i.face.materialIndex=a.materialIndex,e.push(i))}}else{for(let s=Math.max(0,d.start),a=Math.min(o.count,d.start+d.count);s<a;s+=3){i=Gr(this,r,t,n,l,c,u,s,s+1,s+2),i&&(i.faceIndex=Math.floor(s/3),e.push(i))}}}}function Gr(t,e,n,i,s,r,a,o,l,c){t.getVertexPosition(o,Dr),t.getVertexPosition(l,Or),t.getVertexPosition(c,zr);const u=function(t,e,n,i,s,r,a,o){let l;if(l=1===e.side?i.intersectTriangle(a,r,s,!0,o):i.intersectTriangle(s,r,a,0===e.side,o),null===l)return null;kr.copy(o),kr.applyMatrix4(t.matrixWorld);const c=n.ray.origin.distanceTo(kr);return c<n.near||c>n.far?null:{distance:c,point:kr.clone(),object:t}}(t,e,n,i,Dr,Or,zr,Br);if(u){const t=new Pi;$s.getBarycoord(Br,Dr,Or,zr,t),s&&(u.uv=$s.getInterpolatedAttribute(s,o,l,c,t,new ei)),r&&(u.uv1=$s.getInterpolatedAttribute(r,o,l,c,t,new ei)),a&&(u.normal=$s.getInterpolatedAttribute(a,o,l,c,t,new Pi),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));const e={a:o,b:l,c:c,normal:new Pi,materialIndex:0};$s.getNormal(Dr,Or,zr,e.normal),u.face=e,u.barycoord=t}return u}class Wr extends Rr{constructor(t=1,e=1,n=1,i=1,s=1,r=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:i,heightSegments:s,depthSegments:r};const a=this;i=Math.floor(i),s=Math.floor(s),r=Math.floor(r);const o=[],l=[],c=[],u=[];let h=0,d=0;function p(t,e,n,i,s,r,p,m,f,g,v){const y=r/f,_=p/g,x=r/2,M=p/2,b=m/2,T=f+1,S=g+1;let w=0,E=0;const A=new Pi;for(let r=0;r<S;r++){const a=r*_-M;for(let o=0;o<T;o++){const h=o*y-x;A[t]=h*i,A[e]=a*s,A[n]=b,l.push(A.x,A.y,A.z),A[t]=0,A[e]=0,A[n]=m>0?1:-1,c.push(A.x,A.y,A.z),u.push(o/f),u.push(1-r/g),w+=1}}for(let t=0;t<g;t++)for(let e=0;e<f;e++){const n=h+e+T*t,i=h+e+T*(t+1),s=h+(e+1)+T*(t+1),r=h+(e+1)+T*t;o.push(n,i,r),o.push(i,s,r),E+=6}a.addGroup(d,E,v),d+=E,h+=w}p("z","y","x",-1,-1,n,e,t,r,s,0),p("z","y","x",1,-1,n,e,-t,r,s,1),p("x","z","y",1,1,t,n,e,i,r,2),p("x","z","y",1,-1,t,n,-e,i,r,3),p("x","y","z",1,-1,t,e,n,i,s,4),p("x","y","z",-1,-1,t,e,-n,i,s,5),this.setIndex(o),this.setAttribute("position",new br(l,3)),this.setAttribute("normal",new br(c,3)),this.setAttribute("uv",new br(u,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Wr(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}function jr(t){const e={};for(const n in t){e[n]={};for(const i in t[n]){const s=t[n][i];s&&(s.isColor||s.isMatrix3||s.isMatrix4||s.isVector2||s.isVector3||s.isVector4||s.isTexture||s.isQuaternion)?s.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[n][i]=null):e[n][i]=s.clone():Array.isArray(s)?e[n][i]=s.slice():e[n][i]=s}}return e}function Xr(t){const e={};for(let n=0;n<t.length;n++){const i=jr(t[n]);for(const t in i)e[t]=i[t]}return e}function qr(t){const e=t.getRenderTarget();return null===e?t.outputColorSpace:!0===e.isXRRenderTarget?e.texture.colorSpace:fi.workingColorSpace}const Yr={clone:jr,merge:Xr};class Zr extends sr{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,void 0!==t&&this.setValues(t)}copy(t){return super.copy(t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=jr(t.uniforms),this.uniformsGroups=function(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}(t.uniformsGroups),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.fog=t.fog,this.lights=t.lights,this.clipping=t.clipping,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this}toJSON(t){const e=super.toJSON(t);e.glslVersion=this.glslVersion,e.uniforms={};for(const n in this.uniforms){const i=this.uniforms[n].value;i&&i.isTexture?e.uniforms[n]={type:"t",value:i.toJSON(t).uuid}:i&&i.isColor?e.uniforms[n]={type:"c",value:i.getHex()}:i&&i.isVector2?e.uniforms[n]={type:"v2",value:i.toArray()}:i&&i.isVector3?e.uniforms[n]={type:"v3",value:i.toArray()}:i&&i.isVector4?e.uniforms[n]={type:"v4",value:i.toArray()}:i&&i.isMatrix3?e.uniforms[n]={type:"m3",value:i.toArray()}:i&&i.isMatrix4?e.uniforms[n]={type:"m4",value:i.toArray()}:e.uniforms[n]={value:i}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;const n={};for(const t in this.extensions)!0===this.extensions[t]&&(n[t]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}}const $r=new Pi,Jr=new Li,Kr=new Pi;class Qr extends Os{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new cs,this.projectionMatrix=new cs,this.projectionMatrixInverse=new cs,this.coordinateSystem=kn}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorld.decompose($r,Jr,Kr),1===Kr.x&&1===Kr.y&&1===Kr.z?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose($r,Jr,Kr.set(1,1,1)).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorld.decompose($r,Jr,Kr),1===Kr.x&&1===Kr.y&&1===Kr.z?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose($r,Jr,Kr.set(1,1,1)).invert()}clone(){return(new this.constructor).copy(this)}}const ta=new Pi,ea=new ei,na=new ei;class ia extends Qr{constructor(t=50,e=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=null===t.view?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=2*qn*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(.5*Xn*this.fov);return.5*this.getFilmHeight()/t}getEffectiveFOV(){return 2*qn*Math.atan(Math.tan(.5*Xn*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,e,n){ta.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(ta.x,ta.y).multiplyScalar(-t/ta.z),ta.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(ta.x,ta.y).multiplyScalar(-t/ta.z)}getViewSize(t,e){return this.getViewBounds(t,ea,na),e.subVectors(na,ea)}setViewOffset(t,e,n,i,s,r){this.aspect=t/e,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=s,this.view.height=r,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(.5*Xn*this.fov)/this.zoom,n=2*e,i=this.aspect*n,s=-.5*i;const r=this.view;if(null!==this.view&&this.view.enabled){const t=r.fullWidth,a=r.fullHeight;s+=r.offsetX*i/t,e-=r.offsetY*n/a,i*=r.width/t,n*=r.height/a}const a=this.filmOffset;0!==a&&(s+=t*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+i,e,e-n,t,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,null!==this.view&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}const sa=-90;class ra extends Os{constructor(t,e,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new ia(sa,1,t,e);i.layers=this.layers,this.add(i);const s=new ia(sa,1,t,e);s.layers=this.layers,this.add(s);const r=new ia(sa,1,t,e);r.layers=this.layers,this.add(r);const a=new ia(sa,1,t,e);a.layers=this.layers,this.add(a);const o=new ia(sa,1,t,e);o.layers=this.layers,this.add(o);const l=new ia(sa,1,t,e);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[n,i,s,r,a,o]=e;for(const t of e)this.remove(t);if(t===kn)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),r.up.set(0,0,1),r.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else{if(t!==Hn)throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),r.up.set(0,0,-1),r.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1)}for(const t of e)this.add(t),t.updateMatrixWorld()}update(t,e){null===this.parent&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[s,r,a,o,l,c]=this.children,u=t.getRenderTarget(),h=t.getActiveCubeFace(),d=t.getActiveMipmapLevel(),p=t.xr.enabled;t.xr.enabled=!1;const m=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,t.setRenderTarget(n,0,i),t.render(e,s),t.setRenderTarget(n,1,i),t.render(e,r),t.setRenderTarget(n,2,i),t.render(e,a),t.setRenderTarget(n,3,i),t.render(e,o),t.setRenderTarget(n,4,i),t.render(e,l),n.texture.generateMipmaps=m,t.setRenderTarget(n,5,i),t.render(e,c),t.setRenderTarget(u,h,d),t.xr.enabled=p,n.texture.needsPMREMUpdate=!0}}class aa extends Si{constructor(t,e,n,i,s,r,a,o,l,c){super(t=void 0!==t?t:[],e=void 0!==e?e:lt,n,i,s,r,a,o,l,c),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class oa extends Ai{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;const n={width:t,height:t,depth:1},i=[n,n,n,n,n,n];this.texture=new aa(i,e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==e.generateMipmaps&&e.generateMipmaps,this.texture.minFilter=void 0!==e.minFilter?e.minFilter:Mt}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include <common>\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t"},i=new Wr(5,5,5),s=new Zr({name:"CubemapFromEquirect",uniforms:jr(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:1,blending:0});s.uniforms.tEquirect.value=e;const r=new Hr(i,s),a=e.minFilter;e.minFilter===St&&(e.minFilter=Mt);return new ra(1,10,this).update(t,r),e.minFilter=a,r.geometry.dispose(),r.material.dispose(),this}clear(t,e,n,i){const s=t.getRenderTarget();for(let s=0;s<6;s++)t.setRenderTarget(this,s),t.clear(e,n,i);t.setRenderTarget(s)}}const la=new Pi,ca=new Pi,ua=new ni;class ha{constructor(t=new Pi(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,i){return this.normal.set(t,e,n),this.constant=i,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){const i=la.subVectors(n,e).cross(ca.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(i,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e){const n=t.delta(la),i=this.normal.dot(n);if(0===i)return 0===this.distanceToPoint(t.start)?e.copy(t.start):null;const s=-(t.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:e.copy(t.start).addScaledVector(n,s)}intersectsLine(t){const e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const n=e||ua.getNormalMatrix(t),i=this.coplanarPoint(la).applyMatrix4(t),s=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(s),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return(new this.constructor).copy(this)}}const da=new ts,pa=new Pi;class ma{constructor(t=new ha,e=new ha,n=new ha,i=new ha,s=new ha,r=new ha){this.planes=[t,e,n,i,s,r]}set(t,e,n,i,s,r){const a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(n),a[3].copy(i),a[4].copy(s),a[5].copy(r),this}copy(t){const e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t,e=2e3){const n=this.planes,i=t.elements,s=i[0],r=i[1],a=i[2],o=i[3],l=i[4],c=i[5],u=i[6],h=i[7],d=i[8],p=i[9],m=i[10],f=i[11],g=i[12],v=i[13],y=i[14],_=i[15];if(n[0].setComponents(o-s,h-l,f-d,_-g).normalize(),n[1].setComponents(o+s,h+l,f+d,_+g).normalize(),n[2].setComponents(o+r,h+c,f+p,_+v).normalize(),n[3].setComponents(o-r,h-c,f-p,_-v).normalize(),n[4].setComponents(o-a,h-u,f-m,_-y).normalize(),e===kn)n[5].setComponents(o+a,h+u,f+m,_+y).normalize();else{if(e!==Hn)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);n[5].setComponents(a,u,m,y).normalize()}return this}intersectsObject(t){if(void 0!==t.boundingSphere)null===t.boundingSphere&&t.computeBoundingSphere(),da.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;null===e.boundingSphere&&e.computeBoundingSphere(),da.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(da)}intersectsSprite(t){return da.center.set(0,0,0),da.radius=.7071067811865476,da.applyMatrix4(t.matrixWorld),this.intersectsSphere(da)}intersectsSphere(t){const e=this.planes,n=t.center,i=-t.radius;for(let t=0;t<6;t++){if(e[t].distanceToPoint(n)<i)return!1}return!0}intersectsBox(t){const e=this.planes;for(let n=0;n<6;n++){const i=e[n];if(pa.x=i.normal.x>0?t.max.x:t.min.x,pa.y=i.normal.y>0?t.max.y:t.min.y,pa.z=i.normal.z>0?t.max.z:t.min.z,i.distanceToPoint(pa)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function fa(){let t=null,e=!1,n=null,i=null;function s(e,r){n(e,r),i=t.requestAnimationFrame(s)}return{start:function(){!0!==e&&null!==n&&(i=t.requestAnimationFrame(s),e=!0)},stop:function(){t.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(t){n=t},setContext:function(e){t=e}}}function ga(t){const e=new WeakMap;return{get:function(t){return t.isInterleavedBufferAttribute&&(t=t.data),e.get(t)},remove:function(n){n.isInterleavedBufferAttribute&&(n=n.data);const i=e.get(n);i&&(t.deleteBuffer(i.buffer),e.delete(n))},update:function(n,i){if(n.isInterleavedBufferAttribute&&(n=n.data),n.isGLBufferAttribute){const t=e.get(n);return void((!t||t.version<n.version)&&e.set(n,{buffer:n.buffer,type:n.type,bytesPerElement:n.elementSize,version:n.version}))}const s=e.get(n);if(void 0===s)e.set(n,function(e,n){const i=e.array,s=e.usage,r=i.byteLength,a=t.createBuffer();let o;if(t.bindBuffer(n,a),t.bufferData(n,i,s),e.onUploadCallback(),i instanceof Float32Array)o=t.FLOAT;else if(i instanceof Uint16Array)o=e.isFloat16BufferAttribute?t.HALF_FLOAT:t.UNSIGNED_SHORT;else if(i instanceof Int16Array)o=t.SHORT;else if(i instanceof Uint32Array)o=t.UNSIGNED_INT;else if(i instanceof Int32Array)o=t.INT;else if(i instanceof Int8Array)o=t.BYTE;else if(i instanceof Uint8Array)o=t.UNSIGNED_BYTE;else{if(!(i instanceof Uint8ClampedArray))throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+i);o=t.UNSIGNED_BYTE}return{buffer:a,type:o,bytesPerElement:i.BYTES_PER_ELEMENT,version:e.version,size:r}}(n,i));else if(s.version<n.version){if(s.size!==n.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");!function(e,n,i){const s=n.array,r=n.updateRanges;if(t.bindBuffer(i,e),0===r.length)t.bufferSubData(i,0,s);else{r.sort((t,e)=>t.start-e.start);let e=0;for(let t=1;t<r.length;t++){const n=r[e],i=r[t];i.start<=n.start+n.count+1?n.count=Math.max(n.count,i.start+i.count-n.start):(++e,r[e]=i)}r.length=e+1;for(let e=0,n=r.length;e<n;e++){const n=r[e];t.bufferSubData(i,n.start*s.BYTES_PER_ELEMENT,s,n.start,n.count)}n.clearUpdateRanges()}n.onUploadCallback()}(s.buffer,n,i),s.version=n.version}}}}class va extends Rr{constructor(t=1,e=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:i};const s=t/2,r=e/2,a=Math.floor(n),o=Math.floor(i),l=a+1,c=o+1,u=t/a,h=e/o,d=[],p=[],m=[],f=[];for(let t=0;t<c;t++){const e=t*h-r;for(let n=0;n<l;n++){const i=n*u-s;p.push(i,-e,0),m.push(0,0,1),f.push(n/a),f.push(1-t/o)}}for(let t=0;t<o;t++)for(let e=0;e<a;e++){const n=e+l*t,i=e+l*(t+1),s=e+1+l*(t+1),r=e+1+l*t;d.push(n,i,r),d.push(i,s,r)}this.setIndex(d),this.setAttribute("position",new br(p,3)),this.setAttribute("normal",new br(m,3)),this.setAttribute("uv",new br(f,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new va(t.width,t.height,t.widthSegments,t.heightSegments)}}const ya={alphahash_fragment:"#ifdef USE_ALPHAHASH\n\tif ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;\n#endif",alphahash_pars_fragment:"#ifdef USE_ALPHAHASH\n\tconst float ALPHA_HASH_SCALE = 0.05;\n\tfloat hash2D( vec2 value ) {\n\t\treturn fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );\n\t}\n\tfloat hash3D( vec3 value ) {\n\t\treturn hash2D( vec2( hash2D( value.xy ), value.z ) );\n\t}\n\tfloat getAlphaHashThreshold( vec3 position ) {\n\t\tfloat maxDeriv = max(\n\t\t\tlength( dFdx( position.xyz ) ),\n\t\t\tlength( dFdy( position.xyz ) )\n\t\t);\n\t\tfloat pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );\n\t\tvec2 pixScales = vec2(\n\t\t\texp2( floor( log2( pixScale ) ) ),\n\t\t\texp2( ceil( log2( pixScale ) ) )\n\t\t);\n\t\tvec2 alpha = vec2(\n\t\t\thash3D( floor( pixScales.x * position.xyz ) ),\n\t\t\thash3D( floor( pixScales.y * position.xyz ) )\n\t\t);\n\t\tfloat lerpFactor = fract( log2( pixScale ) );\n\t\tfloat x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;\n\t\tfloat a = min( lerpFactor, 1.0 - lerpFactor );\n\t\tvec3 cases = vec3(\n\t\t\tx * x / ( 2.0 * a * ( 1.0 - a ) ),\n\t\t\t( x - 0.5 * a ) / ( 1.0 - a ),\n\t\t\t1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )\n\t\t);\n\t\tfloat threshold = ( x < ( 1.0 - a ) )\n\t\t\t? ( ( x < a ) ? cases.x : cases.y )\n\t\t\t: cases.z;\n\t\treturn clamp( threshold , 1.0e-6, 1.0 );\n\t}\n#endif",alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef USE_ALPHATEST\n\t#ifdef ALPHA_TO_COVERAGE\n\tdiffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );\n\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\tif ( diffuseColor.a < alphaTest ) discard;\n\t#endif\n#endif",alphatest_pars_fragment:"#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_CLEARCOAT ) \n\t\tclearcoatSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_SHEEN ) \n\t\tsheenSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometryNormal, geometryViewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",batching_pars_vertex:"#ifdef USE_BATCHING\n\t#if ! defined( GL_ANGLE_multi_draw )\n\t#define gl_DrawID _gl_DrawID\n\tuniform int _gl_DrawID;\n\t#endif\n\tuniform highp sampler2D batchingTexture;\n\tuniform highp usampler2D batchingIdTexture;\n\tmat4 getBatchingMatrix( const in float i ) {\n\t\tint size = textureSize( batchingTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n\tfloat getIndirectIndex( const in int i ) {\n\t\tint size = textureSize( batchingIdTexture, 0 ).x;\n\t\tint x = i % size;\n\t\tint y = i / size;\n\t\treturn float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );\n\t}\n#endif\n#ifdef USE_BATCHING_COLOR\n\tuniform sampler2D batchingColorTexture;\n\tvec3 getBatchingColor( const in float i ) {\n\t\tint size = textureSize( batchingColorTexture, 0 ).x;\n\t\tint j = int( i );\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\treturn texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;\n\t}\n#endif",batching_vertex:"#ifdef USE_BATCHING\n\tmat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );\n#endif",begin_vertex:"vec3 transformed = vec3( position );\n#ifdef USE_ALPHAHASH\n\tvPosition = vec3( position );\n#endif",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"float G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n} // validated",iridescence_fragment:"#ifdef USE_IRIDESCENCE\n\tconst mat3 XYZ_TO_REC709 = mat3(\n\t\t 3.2404542, -0.9692660, 0.0556434,\n\t\t-1.5371385, 1.8760108, -0.2040259,\n\t\t-0.4985314, 0.0415560, 1.0572252\n\t);\n\tvec3 Fresnel0ToIor( vec3 fresnel0 ) {\n\t\tvec3 sqrtF0 = sqrt( fresnel0 );\n\t\treturn ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n\t}\n\tvec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\n\t}\n\tfloat IorToFresnel0( float transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\n\t}\n\tvec3 evalSensitivity( float OPD, vec3 shift ) {\n\t\tfloat phase = 2.0 * PI * OPD * 1.0e-9;\n\t\tvec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\n\t\tvec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\n\t\tvec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\n\t\tvec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );\n\t\txyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );\n\t\txyz /= 1.0685e-7;\n\t\tvec3 rgb = XYZ_TO_REC709 * xyz;\n\t\treturn rgb;\n\t}\n\tvec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\n\t\tvec3 I;\n\t\tfloat iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\n\t\tfloat sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\n\t\tfloat cosTheta2Sq = 1.0 - sinTheta2Sq;\n\t\tif ( cosTheta2Sq < 0.0 ) {\n\t\t\treturn vec3( 1.0 );\n\t\t}\n\t\tfloat cosTheta2 = sqrt( cosTheta2Sq );\n\t\tfloat R0 = IorToFresnel0( iridescenceIOR, outsideIOR );\n\t\tfloat R12 = F_Schlick( R0, 1.0, cosTheta1 );\n\t\tfloat T121 = 1.0 - R12;\n\t\tfloat phi12 = 0.0;\n\t\tif ( iridescenceIOR < outsideIOR ) phi12 = PI;\n\t\tfloat phi21 = PI - phi12;\n\t\tvec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );\t\tvec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\n\t\tvec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\n\t\tvec3 phi23 = vec3( 0.0 );\n\t\tif ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;\n\t\tif ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;\n\t\tif ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;\n\t\tfloat OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\n\t\tvec3 phi = vec3( phi21 ) + phi23;\n\t\tvec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\n\t\tvec3 r123 = sqrt( R123 );\n\t\tvec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\n\t\tvec3 C0 = R12 + Rs;\n\t\tI = C0;\n\t\tvec3 Cm = Rs - T121;\n\t\tfor ( int m = 1; m <= 2; ++ m ) {\n\t\t\tCm *= r123;\n\t\t\tvec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\n\t\t\tI += Cm * Sm;\n\t\t}\n\t\treturn max( I, vec3( 0.0 ) );\n\t}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vBumpMapUv );\n\t\tvec2 dSTdy = dFdy( vBumpMapUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );\n\t\tvec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#ifdef ALPHA_TO_COVERAGE\n\t\tfloat distanceToPlane, distanceGradient;\n\t\tfloat clipOpacity = 1.0;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\tclipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\tif ( clipOpacity == 0.0 ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tfloat unionClipOpacity = 1.0;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\t\tunionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tclipOpacity *= 1.0 - unionClipOpacity;\n\t\t#endif\n\t\tdiffuseColor.a *= clipOpacity;\n\t\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tbool clipped = true;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tif ( clipped ) discard;\n\t\t#endif\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif\n#ifdef USE_BATCHING_COLOR\n\tvec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );\n\tvColor.xyz *= batchingColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = objectTangent;\n#endif\n#ifdef USE_BATCHING\n\tmat3 bm = mat3( batchingMatrix );\n\ttransformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );\n\ttransformedNormal = bm * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = bm * transformedTangent;\n\t#endif\n#endif\n#ifdef USE_INSTANCING\n\tmat3 im = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );\n\ttransformedNormal = im * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = im * transformedTangent;\n\t#endif\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\ttransformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",colorspace_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",colorspace_pars_fragment:"\nconst mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(\n\tvec3( 0.8224621, 0.177538, 0.0 ),\n\tvec3( 0.0331941, 0.9668058, 0.0 ),\n\tvec3( 0.0170827, 0.0723974, 0.9105199 )\n);\nconst mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.2249401, - 0.2249404, 0.0 ),\n\tvec3( - 0.0420569, 1.0420571, 0.0 ),\n\tvec3( - 0.0196376, - 0.0786361, 1.0982735 )\n);\nvec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {\n\treturn vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );\n}\nvec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {\n\treturn vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );\n}\nvec4 LinearTransferOETF( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n\treturn 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 );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform mat3 envMapRotation;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_fragment:"LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",lights_lambert_pars_fragment:"varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid 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 ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid 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 ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n\tuniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif ( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid 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 ) {\n\tvec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid 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 ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid 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 ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid 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 ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_DISPERSION\n\tmaterial.dispersion = dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tif( material.anisotropy == 0.0 ) {\n\t\tanisotropyV = vec2( 1.0, 0.0 );\n\t} else {\n\t\tanisotropyV /= material.anisotropy;\n\t\tmaterial.anisotropy = saturate( material.anisotropy );\n\t}\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\tfloat dispersion;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat 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 ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn saturate(v);\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColor;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid 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 ) {\n#else\nvoid 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 ) {\n#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid 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 ) {\n\t\tvec3 normal = geometryNormal;\n\t\tvec3 viewDir = geometryViewDir;\n\t\tvec3 position = geometryPosition;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid 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 ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid 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 ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid 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) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n\tgeometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometryViewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if defined( USE_LIGHT_PROBES )\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometryNormal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF )\n\tgl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\tvFragDepth = 1.0 + gl_Position.w;\n\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n#endif",map_fragment:"#ifdef USE_MAP\n#ifdef USE_MIPMAP_BIAS\n vec4 sampledDiffuseColor = texture2D( map, vMapUv, mipmapBias );\n#else\n\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n#endif\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );\n\t\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n \n#ifdef USE_MIPMAP_BIAS\n uniform float mipmapBias;\n#endif\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t#if defined( USE_POINTS_UV )\n\t\tvec2 uv = vUv;\n\t#else\n\t\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_POINTS_UV )\n\tvarying vec2 vUv;\n#else\n\t#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t\tuniform mat3 uvTransform;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphinstance_vertex:"#ifdef USE_INSTANCING_MORPH\n\tfloat morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\tfloat morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tmorphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;\n\t}\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_INSTANCING_MORPH\n\t\tuniform float morphTargetBaseInfluence;\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t#endif\n\tuniform sampler2DArray morphTargetsTexture;\n\tuniform ivec2 morphTargetsTextureSize;\n\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t}\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal,\n\t\t#if defined( USE_NORMALMAP )\n\t\t\tvNormalMapUv\n\t\t#elif defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tvClearcoatNormalMapUv\n\t\t#else\n\t\t\tvUv\n\t\t#endif\n\t\t);\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 nonPerturbedNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n\tmat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\t\treturn mat3( T * scale, B * scale, N );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = nonPerturbedNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\tclearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif",opaque_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;\nconst float Inv255 = 1. / 255.;\nconst vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );\nconst vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );\nconst vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );\nconst vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );\nvec4 packDepthToRGBA( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec4( 0., 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec4( 1., 1., 1., 1. );\n\tfloat vuf;\n\tfloat af = modf( v * PackFactors.a, vuf );\n\tfloat bf = modf( vuf * ShiftRight8, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );\n}\nvec3 packDepthToRGB( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec3( 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec3( 1., 1., 1. );\n\tfloat vuf;\n\tfloat bf = modf( v * PackFactors.b, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec3( vuf * Inv255, gf * PackUpscale, bf );\n}\nvec2 packDepthToRG( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec2( 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec2( 1., 1. );\n\tfloat vuf;\n\tfloat gf = modf( v * 256., vuf );\n\treturn vec2( vuf * Inv255, gf );\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors4 );\n}\nfloat unpackRGBToDepth( const in vec3 v ) {\n\treturn dot( v, UnpackFactors3 );\n}\nfloat unpackRGToDepth( const in vec2 v ) {\n\treturn v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;\n}\nvec4 pack2HalfToRGBA( const in vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( const in vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn depth * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * depth - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_BATCHING\n\tmvPosition = batchingMatrix * mvPosition;\n#endif\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\t\n\t\tfloat lightToPositionLength = length( lightToPosition );\n\t\tif ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {\n\t\t\tfloat dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\t\tdp += shadowBias;\n\t\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\t\tshadow = (\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t\t) * ( 1.0 / 9.0 );\n\t\t\t#else\n\t\t\t\tshadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\tvec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tint size = textureSize( boneTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 CineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.6605, - 0.1246, - 0.0182 ),\n\tvec3( - 0.5876, 1.1329, - 0.1006 ),\n\tvec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n\tvec3( 0.6274, 0.0691, 0.0164 ),\n\tvec3( 0.3293, 0.9195, 0.0880 ),\n\tvec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n\tvec3 x2 = x * x;\n\tvec3 x4 = x2 * x2;\n\treturn + 15.5 * x4 * x2\n\t\t- 40.14 * x4 * x\n\t\t+ 31.96 * x4\n\t\t- 6.868 * x2 * x\n\t\t+ 0.4298 * x2\n\t\t+ 0.1191 * x\n\t\t- 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n\tconst mat3 AgXInsetMatrix = mat3(\n\t\tvec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n\t\tvec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n\t\tvec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n\t);\n\tconst mat3 AgXOutsetMatrix = mat3(\n\t\tvec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n\t\tvec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n\t\tvec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n\t);\n\tconst float AgxMinEv = - 12.47393;\tconst float AgxMaxEv = 4.026069;\n\tcolor *= toneMappingExposure;\n\tcolor = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n\tcolor = AgXInsetMatrix * color;\n\tcolor = max( color, 1e-10 );\tcolor = log2( color );\n\tcolor = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n\tcolor = clamp( color, 0.0, 1.0 );\n\tcolor = agxDefaultContrastApprox( color );\n\tcolor = AgXOutsetMatrix * color;\n\tcolor = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n\tcolor = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n\tcolor = clamp( color, 0.0, 1.0 );\n\treturn color;\n}\nvec3 NeutralToneMapping( vec3 color ) {\n\tconst float StartCompression = 0.8 - 0.04;\n\tconst float Desaturation = 0.15;\n\tcolor *= toneMappingExposure;\n\tfloat x = min( color.r, min( color.g, color.b ) );\n\tfloat offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\n\tcolor -= offset;\n\tfloat peak = max( color.r, max( color.g, color.b ) );\n\tif ( peak < StartCompression ) return color;\n\tfloat d = 1. - StartCompression;\n\tfloat newPeak = 1. - d * d / ( peak + d - StartCompression );\n\tcolor *= newPeak / peak;\n\tfloat g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );\n\treturn mix( color, vec3( newPeak ), g );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn vec3( 1.0 );\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec4 transmittedLight;\n\t\tvec3 transmittance;\n\t\t#ifdef USE_DISPERSION\n\t\t\tfloat halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;\n\t\t\tvec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );\n\t\t\tfor ( int i = 0; i < 3; i ++ ) {\n\t\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );\n\t\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\n\t\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\t\trefractionCoords += 1.0;\n\t\t\t\trefractionCoords /= 2.0;\n\t\t\n\t\t\t\tvec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );\n\t\t\t\ttransmittedLight[ i ] = transmissionSample[ i ];\n\t\t\t\ttransmittedLight.a += transmissionSample.a;\n\t\t\t\ttransmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];\n\t\t\t}\n\t\t\ttransmittedLight.a /= 3.0;\n\t\t\n\t\t#else\n\t\t\n\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\trefractionCoords += 1.0;\n\t\t\trefractionCoords /= 2.0;\n\t\t\ttransmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\t\ttransmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\t\n\t\t#endif\n\t\tvec3 attenuatedColor = transmittance * transmittedLight.rgb;\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\tfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n\t}\n#endif",uv_pars_fragment:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_pars_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tuniform mat3 anisotropyMapTransform;\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n\tvMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n\tvAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n\tvLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n\tvAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n\tvBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n\tvNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tvDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n\tvMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n\tvSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tvTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n\tvThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_BATCHING\n\t\tworldPosition = batchingMatrix * worldPosition;\n\t#endif\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\ttexColor = 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 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nuniform mat3 backgroundRotation;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",cube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",depth_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <logdepthbuf_fragment>\n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#elif DEPTH_PACKING == 3202\n\t\tgl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );\n\t#elif DEPTH_PACKING == 3203\n\t\tgl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );\n\t#endif\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",meshbasic_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_lambert_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_lambert_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <packing>\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_DISPERSION\n\tuniform float dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <iridescence_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <iridescence_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n\t#endif\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n#ifdef USE_POINTS_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",shadow_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <logdepthbuf_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\t#include <logdepthbuf_fragment>\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix[ 3 ];\n\tvec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}"},_a={common:{diffuse:{value:new er(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new ni},alphaMap:{value:null},alphaMapTransform:{value:new ni},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new ni}},envmap:{envMap:{value:null},envMapRotation:{value:new ni},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new ni}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new ni}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new ni},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new ni},normalScale:{value:new ei(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new ni},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new ni}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new ni}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new ni}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new er(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 er(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new ni},alphaTest:{value:0},uvTransform:{value:new ni}},sprite:{diffuse:{value:new er(16777215)},opacity:{value:1},center:{value:new ei(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new ni},alphaMap:{value:null},alphaMapTransform:{value:new ni},alphaTest:{value:0}}},xa={basic:{uniforms:Xr([_a.common,_a.specularmap,_a.envmap,_a.aomap,_a.lightmap,_a.fog]),vertexShader:ya.meshbasic_vert,fragmentShader:ya.meshbasic_frag},lambert:{uniforms:Xr([_a.common,_a.specularmap,_a.envmap,_a.aomap,_a.lightmap,_a.emissivemap,_a.bumpmap,_a.normalmap,_a.displacementmap,_a.fog,_a.lights,{emissive:{value:new er(0)}}]),vertexShader:ya.meshlambert_vert,fragmentShader:ya.meshlambert_frag},phong:{uniforms:Xr([_a.common,_a.specularmap,_a.envmap,_a.aomap,_a.lightmap,_a.emissivemap,_a.bumpmap,_a.normalmap,_a.displacementmap,_a.fog,_a.lights,{emissive:{value:new er(0)},specular:{value:new er(1118481)},shininess:{value:30}}]),vertexShader:ya.meshphong_vert,fragmentShader:ya.meshphong_frag},standard:{uniforms:Xr([_a.common,_a.envmap,_a.aomap,_a.lightmap,_a.emissivemap,_a.bumpmap,_a.normalmap,_a.displacementmap,_a.roughnessmap,_a.metalnessmap,_a.fog,_a.lights,{emissive:{value:new er(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ya.meshphysical_vert,fragmentShader:ya.meshphysical_frag},toon:{uniforms:Xr([_a.common,_a.aomap,_a.lightmap,_a.emissivemap,_a.bumpmap,_a.normalmap,_a.displacementmap,_a.gradientmap,_a.fog,_a.lights,{emissive:{value:new er(0)}}]),vertexShader:ya.meshtoon_vert,fragmentShader:ya.meshtoon_frag},matcap:{uniforms:Xr([_a.common,_a.bumpmap,_a.normalmap,_a.displacementmap,_a.fog,{matcap:{value:null}}]),vertexShader:ya.meshmatcap_vert,fragmentShader:ya.meshmatcap_frag},points:{uniforms:Xr([_a.points,_a.fog]),vertexShader:ya.points_vert,fragmentShader:ya.points_frag},dashed:{uniforms:Xr([_a.common,_a.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ya.linedashed_vert,fragmentShader:ya.linedashed_frag},depth:{uniforms:Xr([_a.common,_a.displacementmap]),vertexShader:ya.depth_vert,fragmentShader:ya.depth_frag},normal:{uniforms:Xr([_a.common,_a.bumpmap,_a.normalmap,_a.displacementmap,{opacity:{value:1}}]),vertexShader:ya.meshnormal_vert,fragmentShader:ya.meshnormal_frag},sprite:{uniforms:Xr([_a.sprite,_a.fog]),vertexShader:ya.sprite_vert,fragmentShader:ya.sprite_frag},background:{uniforms:{uvTransform:{value:new ni},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:ya.background_vert,fragmentShader:ya.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new ni}},vertexShader:ya.backgroundCube_vert,fragmentShader:ya.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:ya.cube_vert,fragmentShader:ya.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ya.equirect_vert,fragmentShader:ya.equirect_frag},distanceRGBA:{uniforms:Xr([_a.common,_a.displacementmap,{referencePosition:{value:new Pi},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ya.distanceRGBA_vert,fragmentShader:ya.distanceRGBA_frag},shadow:{uniforms:Xr([_a.lights,_a.fog,{color:{value:new er(0)},opacity:{value:1}}]),vertexShader:ya.shadow_vert,fragmentShader:ya.shadow_frag}};xa.physical={uniforms:Xr([xa.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new ni},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new ni},clearcoatNormalScale:{value:new ei(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new ni},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new ni},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new ni},sheen:{value:0},sheenColor:{value:new er(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new ni},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new ni},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new ni},transmissionSamplerSize:{value:new ei},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new ni},attenuationDistance:{value:0},attenuationColor:{value:new er(0)},specularColor:{value:new er(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new ni},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new ni},anisotropyVector:{value:new ei},anisotropyMap:{value:null},anisotropyMapTransform:{value:new ni}}]),vertexShader:ya.meshphysical_vert,fragmentShader:ya.meshphysical_frag};const Ma={r:0,b:0,g:0},ba=new _s,Ta=new cs;function Sa(t,e,n,i,s,r,a){const o=new er(0);let l,c,u=!0===r?0:1,h=null,d=0,p=null;function m(t){let i=!0===t.isScene?t.background:null;if(i&&i.isTexture){i=(t.backgroundBlurriness>0?n:e).get(i)}return i}function f(e,n){e.getRGB(Ma,qr(t)),i.buffers.color.setClear(Ma.r,Ma.g,Ma.b,n,a)}return{getClearColor:function(){return o},setClearColor:function(t,e=1){o.set(t),u=e,f(o,u)},getClearAlpha:function(){return u},setClearAlpha:function(t){u=t,f(o,u)},render:function(e){let n=!1;const s=m(e);null===s?f(o,u):s&&s.isColor&&(f(s,1),n=!0);const r=t.xr.getEnvironmentBlendMode();"additive"===r?i.buffers.color.setClear(0,0,0,1,a):"alpha-blend"===r&&i.buffers.color.setClear(0,0,0,0,a),(t.autoClear||n)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil))},addToRenderList:function(e,n){const i=m(n);i&&(i.isCubeTexture||i.mapping===dt)?(void 0===c&&(c=new Hr(new Wr(1,1,1),new Zr({name:"BackgroundCubeMaterial",uniforms:jr(xa.backgroundCube.uniforms),vertexShader:xa.backgroundCube.vertexShader,fragmentShader:xa.backgroundCube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(t,e,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),s.update(c)),ba.copy(n.backgroundRotation),ba.x*=-1,ba.y*=-1,ba.z*=-1,i.isCubeTexture&&!1===i.isRenderTargetTexture&&(ba.y*=-1,ba.z*=-1),c.material.uniforms.envMap.value=i,c.material.uniforms.flipEnvMap.value=i.isCubeTexture&&!1===i.isRenderTargetTexture?-1:1,c.material.uniforms.backgroundBlurriness.value=n.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(Ta.makeRotationFromEuler(ba)),c.material.toneMapped=fi.getTransfer(i.colorSpace)!==nn,h===i&&d===i.version&&p===t.toneMapping||(c.material.needsUpdate=!0,h=i,d=i.version,p=t.toneMapping),c.layers.enableAll(),e.unshift(c,c.geometry,c.material,0,0,null)):i&&i.isTexture&&(void 0===l&&(l=new Hr(new va(2,2),new Zr({name:"BackgroundMaterial",uniforms:jr(xa.background.uniforms),vertexShader:xa.background.vertexShader,fragmentShader:xa.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),s.update(l)),l.material.uniforms.t2D.value=i,l.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,l.material.toneMapped=fi.getTransfer(i.colorSpace)!==nn,!0===i.matrixAutoUpdate&&i.updateMatrix(),l.material.uniforms.uvTransform.value.copy(i.matrix),h===i&&d===i.version&&p===t.toneMapping||(l.material.needsUpdate=!0,h=i,d=i.version,p=t.toneMapping),l.layers.enableAll(),e.unshift(l,l.geometry,l.material,0,0,null))}}}function wa(t,e){const n=t.getParameter(t.MAX_VERTEX_ATTRIBS),i={},s=c(null);let r=s,a=!1;function o(e){return t.bindVertexArray(e)}function l(e){return t.deleteVertexArray(e)}function c(t){const e=[],i=[],s=[];for(let t=0;t<n;t++)e[t]=0,i[t]=0,s[t]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:e,enabledAttributes:i,attributeDivisors:s,object:t,attributes:{},index:null}}function u(){const t=r.newAttributes;for(let e=0,n=t.length;e<n;e++)t[e]=0}function h(t){d(t,0)}function d(e,n){const i=r.newAttributes,s=r.enabledAttributes,a=r.attributeDivisors;i[e]=1,0===s[e]&&(t.enableVertexAttribArray(e),s[e]=1),a[e]!==n&&(t.vertexAttribDivisor(e,n),a[e]=n)}function p(){const e=r.newAttributes,n=r.enabledAttributes;for(let i=0,s=n.length;i<s;i++)n[i]!==e[i]&&(t.disableVertexAttribArray(i),n[i]=0)}function m(e,n,i,s,r,a,o){!0===o?t.vertexAttribIPointer(e,n,i,r,a):t.vertexAttribPointer(e,n,i,s,r,a)}function f(){g(),a=!0,r!==s&&(r=s,o(r.object))}function g(){s.geometry=null,s.program=null,s.wireframe=!1}return{setup:function(n,s,l,f,g){let v=!1;const y=function(e,n,s){const r=!0===s.wireframe;let a=i[e.id];void 0===a&&(a={},i[e.id]=a);let o=a[n.id];void 0===o&&(o={},a[n.id]=o);let l=o[r];void 0===l&&(l=c(t.createVertexArray()),o[r]=l);return l}(f,l,s);r!==y&&(r=y,o(r.object)),v=function(t,e,n,i){const s=r.attributes,a=e.attributes;let o=0;const l=n.getAttributes();for(const e in l){if(l[e].location>=0){const n=s[e];let i=a[e];if(void 0===i&&("instanceMatrix"===e&&t.instanceMatrix&&(i=t.instanceMatrix),"instanceColor"===e&&t.instanceColor&&(i=t.instanceColor)),void 0===n)return!0;if(n.attribute!==i)return!0;if(i&&n.data!==i.data)return!0;o++}}return r.attributesNum!==o||r.index!==i}(n,f,l,g),v&&function(t,e,n,i){const s={},a=e.attributes;let o=0;const l=n.getAttributes();for(const e in l){if(l[e].location>=0){let n=a[e];void 0===n&&("instanceMatrix"===e&&t.instanceMatrix&&(n=t.instanceMatrix),"instanceColor"===e&&t.instanceColor&&(n=t.instanceColor));const i={};i.attribute=n,n&&n.data&&(i.data=n.data),s[e]=i,o++}}r.attributes=s,r.attributesNum=o,r.index=i}(n,f,l,g),null!==g&&e.update(g,t.ELEMENT_ARRAY_BUFFER),(v||a)&&(a=!1,function(n,i,s,r){u();const a=r.attributes,o=s.getAttributes(),l=i.defaultAttributeValues;for(const i in o){const s=o[i];if(s.location>=0){let o=a[i];if(void 0===o&&("instanceMatrix"===i&&n.instanceMatrix&&(o=n.instanceMatrix),"instanceColor"===i&&n.instanceColor&&(o=n.instanceColor)),void 0!==o){const i=o.normalized,a=o.itemSize,l=e.get(o);if(void 0===l)continue;const c=l.buffer,u=l.type,p=l.bytesPerElement,f=u===t.INT||u===t.UNSIGNED_INT||o.gpuType===Rt;if(o.isInterleavedBufferAttribute){const e=o.data,l=e.stride,g=o.offset;if(e.isInstancedInterleavedBuffer){for(let t=0;t<s.locationSize;t++)d(s.location+t,e.meshPerAttribute);!0!==n.isInstancedMesh&&void 0===r._maxInstanceCount&&(r._maxInstanceCount=e.meshPerAttribute*e.count)}else for(let t=0;t<s.locationSize;t++)h(s.location+t);t.bindBuffer(t.ARRAY_BUFFER,c);for(let t=0;t<s.locationSize;t++)m(s.location+t,a/s.locationSize,u,i,l*p,(g+a/s.locationSize*t)*p,f)}else{if(o.isInstancedBufferAttribute){for(let t=0;t<s.locationSize;t++)d(s.location+t,o.meshPerAttribute);!0!==n.isInstancedMesh&&void 0===r._maxInstanceCount&&(r._maxInstanceCount=o.meshPerAttribute*o.count)}else for(let t=0;t<s.locationSize;t++)h(s.location+t);t.bindBuffer(t.ARRAY_BUFFER,c);for(let t=0;t<s.locationSize;t++)m(s.location+t,a/s.locationSize,u,i,a*p,a/s.locationSize*t*p,f)}}else if(void 0!==l){const e=l[i];if(void 0!==e)switch(e.length){case 2:t.vertexAttrib2fv(s.location,e);break;case 3:t.vertexAttrib3fv(s.location,e);break;case 4:t.vertexAttrib4fv(s.location,e);break;default:t.vertexAttrib1fv(s.location,e)}}}}p()}(n,s,l,f),null!==g&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.get(g).buffer))},reset:f,resetDefaultState:g,dispose:function(){f();for(const t in i){const e=i[t];for(const t in e){const n=e[t];for(const t in n)l(n[t].object),delete n[t];delete e[t]}delete i[t]}},releaseStatesOfGeometry:function(t){if(void 0===i[t.id])return;const e=i[t.id];for(const t in e){const n=e[t];for(const t in n)l(n[t].object),delete n[t];delete e[t]}delete i[t.id]},releaseStatesOfProgram:function(t){for(const e in i){const n=i[e];if(void 0===n[t.id])continue;const s=n[t.id];for(const t in s)l(s[t].object),delete s[t];delete n[t.id]}},initAttributes:u,enableAttribute:h,disableUnusedAttributes:p}}function Ea(t,e,n){let i;function s(e,s,r){0!==r&&(t.drawArraysInstanced(i,e,s,r),n.update(s,i,r))}this.setMode=function(t){i=t},this.render=function(e,s){t.drawArrays(i,e,s),n.update(s,i,1)},this.renderInstances=s,this.renderMultiDraw=function(t,s,r){if(0===r)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,t,0,s,0,r);let a=0;for(let t=0;t<r;t++)a+=s[t];n.update(a,i,1)},this.renderMultiDrawInstances=function(t,r,a,o){if(0===a)return;const l=e.get("WEBGL_multi_draw");if(null===l)for(let e=0;e<t.length;e++)s(t[e],r[e],o[e]);else{l.multiDrawArraysInstancedWEBGL(i,t,0,r,0,o,0,a);let e=0;for(let t=0;t<a;t++)e+=r[t];for(let t=0;t<o.length;t++)n.update(e,i,o[t])}}}function Aa(t,e,n,i){let s;function r(e){if("highp"===e){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let a=void 0!==n.precision?n.precision:"highp";const o=r(a);o!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",o,"instead."),a=o);const l=!0===n.logarithmicDepthBuffer,c=!0===n.reverseDepthBuffer&&e.has("EXT_clip_control");if(!0===c){const t=e.get("EXT_clip_control");t.clipControlEXT(t.LOWER_LEFT_EXT,t.ZERO_TO_ONE_EXT)}const u=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),h=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS);return{isWebGL2:!0,getMaxAnisotropy:function(){if(void 0!==s)return s;if(!0===e.has("EXT_texture_filter_anisotropic")){const n=e.get("EXT_texture_filter_anisotropic");s=t.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else s=0;return s},getMaxPrecision:r,textureFormatReadable:function(e){return e===kt||i.convert(e)===t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT)},textureTypeReadable:function(n){const s=n===Pt&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(n!==Et&&i.convert(n)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&n!==Lt&&!s)},precision:a,logarithmicDepthBuffer:l,reverseDepthBuffer:c,maxTextures:u,maxVertexTextures:h,maxTextureSize:t.getParameter(t.MAX_TEXTURE_SIZE),maxCubemapSize:t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),maxAttributes:t.getParameter(t.MAX_VERTEX_ATTRIBS),maxVertexUniforms:t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),maxVaryings:t.getParameter(t.MAX_VARYING_VECTORS),maxFragmentUniforms:t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),vertexTextures:h>0,maxSamples:t.getParameter(t.MAX_SAMPLES)}}function Na(t){const e=this;let n=null,i=0,s=!1,r=!1;const a=new ha,o=new ni,l={value:null,needsUpdate:!1};function c(t,n,i,s){const r=null!==t?t.length:0;let c=null;if(0!==r){if(c=l.value,!0!==s||null===c){const e=i+4*r,s=n.matrixWorldInverse;o.getNormalMatrix(s),(null===c||c.length<e)&&(c=new Float32Array(e));for(let e=0,n=i;e!==r;++e,n+=4)a.copy(t[e]).applyMatrix4(s,o),a.normal.toArray(c,n),c[n+3]=a.constant}l.value=c,l.needsUpdate=!0}return e.numPlanes=r,e.numIntersection=0,c}this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(t,e){const n=0!==t.length||e||0!==i||s;return s=e,i=t.length,n},this.beginShadows=function(){r=!0,c(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(t,e){n=c(t,e,0)},this.setState=function(a,o,u){const h=a.clippingPlanes,d=a.clipIntersection,p=a.clipShadows,m=t.get(a);if(!s||null===h||0===h.length||r&&!p)r?c(null):function(){l.value!==n&&(l.value=n,l.needsUpdate=i>0);e.numPlanes=i,e.numIntersection=0}();else{const t=r?0:i,e=4*t;let s=m.clippingState||null;l.value=s,s=c(h,o,e,u);for(let t=0;t!==e;++t)s[t]=n[t];m.clippingState=s,this.numIntersection=d?this.numPlanes:0,this.numPlanes+=t}}}function Ca(t){let e=new WeakMap;function n(t,e){return e===ut?t.mapping=lt:e===ht&&(t.mapping=ct),t}function i(t){const n=t.target;n.removeEventListener("dispose",i);const s=e.get(n);void 0!==s&&(e.delete(n),s.dispose())}return{get:function(s){if(s&&s.isTexture){const r=s.mapping;if(r===ut||r===ht){if(e.has(s)){return n(e.get(s).texture,s.mapping)}{const r=s.image;if(r&&r.height>0){const a=new oa(r.height);return a.fromEquirectangularTexture(t,s),e.set(s,a),s.addEventListener("dispose",i),n(a.texture,s.mapping)}return null}}}return s},dispose:function(){e=new WeakMap}}}class Ra extends Qr{constructor(t=-1,e=1,n=1,i=-1,s=.1,r=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=i,this.near=s,this.far=r,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=null===t.view?null:Object.assign({},t.view),this}setViewOffset(t,e,n,i,s,r){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=s,this.view.height=r,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let s=n-t,r=n+t,a=i+e,o=i-e;if(null!==this.view&&this.view.enabled){const t=(this.right-this.left)/this.view.fullWidth/this.zoom,e=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=t*this.view.offsetX,r=s+t*this.view.width,a-=e*this.view.offsetY,o=a-e*this.view.height}this.projectionMatrix.makeOrthographic(s,r,a,o,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,null!==this.view&&(e.object.view=Object.assign({},this.view)),e}}const Ia=[.125,.215,.35,.446,.526,.582],La=20,Pa=new Ra,Ua=new er;let Da=null,Oa=0,za=0,Va=!1;const Fa=(1+Math.sqrt(5))/2,Ba=1/Fa,ka=[new Pi(-Fa,Ba,0),new Pi(Fa,Ba,0),new Pi(-Ba,0,Fa),new Pi(Ba,0,Fa),new Pi(0,Fa,-Ba),new Pi(0,Fa,Ba),new Pi(-1,1,-1),new Pi(1,1,-1),new Pi(-1,1,1),new Pi(1,1,1)];let Ha=class{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(t,e=0,n=.1,i=100){Da=this._renderer.getRenderTarget(),Oa=this._renderer.getActiveCubeFace(),za=this._renderer.getActiveMipmapLevel(),Va=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(t,n,i,s),e>0&&this._blur(s,0,0,e),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=qa(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=Xa(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose()}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodPlanes.length;t++)this._lodPlanes[t].dispose()}_cleanup(t){this._renderer.setRenderTarget(Da,Oa,za),this._renderer.xr.enabled=Va,t.scissorTest=!1,ja(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===lt||t.mapping===ct?this._setSize(0===t.image.length?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),Da=this._renderer.getRenderTarget(),Oa=this._renderer.getActiveCubeFace(),za=this._renderer.getActiveMipmapLevel(),Va=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=e||this._allocateTargets();return this._textureToCubeUV(t,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,n={magFilter:Mt,minFilter:Mt,generateMipmaps:!1,type:Pt,format:kt,colorSpace:Ke,depthBuffer:!1},i=Wa(t,e,n),{_lodMax:s}=this;if(({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=Ga(s)),null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=Wa(t,e,n);const{_lodMax:i}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=Ga(i)),this._blurMaterial=function(t,e,n){const i=new Float32Array(La),s=new Pi(0,1,0),r=new Zr({name:"SphericalGaussianBlur",defines:{n:La,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:Ya(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include <cube_uv_reflection_fragment>\n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1});return r}(i,t,e)}return i}_compileMaterial(t){const e=new Hr(this._lodPlanes[0],t);this._renderer.compile(e,Pa)}_sceneToCubeUV(t,e,n,i){const s=new ia(90,1,e,n),r=[1,-1,1,1,1,1],a=[1,1,1,-1,-1,-1],o=this._renderer,l=o.autoClear,c=o.toneMapping;o.getClearColor(Ua),o.toneMapping=0,o.autoClear=!1;const u=new rr({name:"PMREM.Background",side:1,depthWrite:!1,depthTest:!1}),h=new Hr(new Wr,u);let d=!1;const p=t.background;p?p.isColor&&(u.color.copy(p),t.background=null,d=!0):(u.color.copy(Ua),d=!0);for(let e=0;e<6;e++){const n=e%3;0===n?(s.up.set(0,r[e],0),s.lookAt(a[e],0,0)):1===n?(s.up.set(0,0,r[e]),s.lookAt(0,a[e],0)):(s.up.set(0,r[e],0),s.lookAt(0,0,a[e]));const l=this._cubeSize;ja(i,n*l,e>2?l:0,l,l),o.setRenderTarget(i),d&&o.render(h,s),o.render(t,s)}h.geometry.dispose(),h.material.dispose(),o.toneMapping=c,o.autoClear=l,t.background=p}_textureToCubeUV(t,e){const n=this._renderer,i=t.mapping===lt||t.mapping===ct;i?(null===this._cubemapMaterial&&(this._cubemapMaterial=qa()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===t.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=Xa());const s=i?this._cubemapMaterial:this._equirectMaterial,r=new Hr(this._lodPlanes[0],s);s.uniforms.envMap.value=t;const a=this._cubeSize;ja(e,0,0,3*a,2*a),n.setRenderTarget(e),n.render(r,Pa)}_applyPMREM(t){const e=this._renderer,n=e.autoClear;e.autoClear=!1;const i=this._lodPlanes.length;for(let e=1;e<i;e++){const n=Math.sqrt(this._sigmas[e]*this._sigmas[e]-this._sigmas[e-1]*this._sigmas[e-1]),s=ka[(i-e-1)%ka.length];this._blur(t,e-1,e,n,s)}e.autoClear=n}_blur(t,e,n,i,s){const r=this._pingPongRenderTarget;this._halfBlur(t,r,e,n,i,"latitudinal",s),this._halfBlur(r,t,n,n,i,"longitudinal",s)}_halfBlur(t,e,n,i,s,r,a){const o=this._renderer,l=this._blurMaterial;"latitudinal"!==r&&"longitudinal"!==r&&console.error("blur direction must be either latitudinal or longitudinal!");const c=new Hr(this._lodPlanes[i],l),u=l.uniforms,h=this._sizeLods[n]-1,d=isFinite(s)?Math.PI/(2*h):2*Math.PI/39,p=s/d,m=isFinite(s)?1+Math.floor(3*p):La;m>La&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${m} samples when the maximum is set to 20`);const f=[];let g=0;for(let t=0;t<La;++t){const e=t/p,n=Math.exp(-e*e/2);f.push(n),0===t?g+=n:t<m&&(g+=2*n)}for(let t=0;t<f.length;t++)f[t]=f[t]/g;u.envMap.value=t.texture,u.samples.value=m,u.weights.value=f,u.latitudinal.value="latitudinal"===r,a&&(u.poleAxis.value=a);const{_lodMax:v}=this;u.dTheta.value=d,u.mipInt.value=v-n;const y=this._sizeLods[i];ja(e,3*y*(i>v-4?i-v+4:0),4*(this._cubeSize-y),3*y,2*y),o.setRenderTarget(e),o.render(c,Pa)}};function Ga(t){const e=[],n=[],i=[];let s=t;const r=t-4+1+Ia.length;for(let a=0;a<r;a++){const r=Math.pow(2,s);n.push(r);let o=1/r;a>t-4?o=Ia[a-t+4-1]:0===a&&(o=0),i.push(o);const l=1/(r-2),c=-l,u=1+l,h=[c,c,u,c,u,u,c,c,u,u,c,u],d=6,p=6,m=3,f=2,g=1,v=new Float32Array(m*p*d),y=new Float32Array(f*p*d),_=new Float32Array(g*p*d);for(let t=0;t<d;t++){const e=t%3*2/3-1,n=t>2?0:-1,i=[e,n,0,e+2/3,n,0,e+2/3,n+1,0,e,n,0,e+2/3,n+1,0,e,n+1,0];v.set(i,m*p*t),y.set(h,f*p*t);const s=[t,t,t,t,t,t];_.set(s,g*p*t)}const x=new Rr;x.setAttribute("position",new pr(v,m)),x.setAttribute("uv",new pr(y,f)),x.setAttribute("faceIndex",new pr(_,g)),e.push(x),s>4&&s--}return{lodPlanes:e,sizeLods:n,sigmas:i}}function Wa(t,e,n){const i=new Ai(t,e,n);return i.texture.mapping=dt,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function ja(t,e,n,i,s){t.viewport.set(e,n,i,s),t.scissor.set(e,n,i,s)}function Xa(){return new Zr({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Ya(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\n\t\t\t#include <common>\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function qa(){return new Zr({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Ya(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function Ya(){return"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t"}function Za(t){let e=new WeakMap,n=null;function i(t){const n=t.target;n.removeEventListener("dispose",i);const s=e.get(n);void 0!==s&&(e.delete(n),s.dispose())}return{get:function(s){if(s&&s.isTexture){const r=s.mapping,a=r===ut||r===ht,o=r===lt||r===ct;if(a||o){let r=e.get(s);const l=void 0!==r?r.texture.pmremVersion:0;if(s.isRenderTargetTexture&&s.pmremVersion!==l)return null===n&&(n=new Ha(t)),r=a?n.fromEquirectangular(s,r):n.fromCubemap(s,r),r.texture.pmremVersion=s.pmremVersion,e.set(s,r),r.texture;if(void 0!==r)return r.texture;{const l=s.image;return a&&l&&l.height>0||o&&l&&function(t){let e=0;const n=6;for(let i=0;i<n;i++)void 0!==t[i]&&e++;return e===n}(l)?(n=new Ha(t),r=a?n.fromEquirectangular(s):n.fromCubemap(s),r.texture.pmremVersion=s.pmremVersion,e.set(s,r),s.addEventListener("dispose",i),r.texture):null}}}return s},dispose:function(){e=new WeakMap,null!==n&&(n.dispose(),n=null)}}}function $a(t){const e={};function n(n){if(void 0!==e[n])return e[n];let i;switch(n){case"WEBGL_depth_texture":i=t.getExtension("WEBGL_depth_texture")||t.getExtension("MOZ_WEBGL_depth_texture")||t.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=t.getExtension("WEBGL_compressed_texture_s3tc")||t.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=t.getExtension(n)}return e[n]=i,i}return{has:function(t){return null!==n(t)},init:function(){n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance"),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture"),n("WEBGL_render_shared_exponent")},get:function(t){const e=n(t);return null===e&&ui("THREE.WebGLRenderer: "+t+" extension not supported."),e}}}function Ja(t,e,n,i){const s={},r=new WeakMap;function a(t){const o=t.target;null!==o.index&&e.remove(o.index);for(const t in o.attributes)e.remove(o.attributes[t]);for(const t in o.morphAttributes){const n=o.morphAttributes[t];for(let t=0,i=n.length;t<i;t++)e.remove(n[t])}o.removeEventListener("dispose",a),delete s[o.id];const l=r.get(o);l&&(e.remove(l),r.delete(o)),i.releaseStatesOfGeometry(o),!0===o.isInstancedBufferGeometry&&delete o._maxInstanceCount,n.memory.geometries--}function o(t){const n=[],i=t.index,s=t.attributes.position;let a=0;if(null!==i){const t=i.array;a=i.version;for(let e=0,i=t.length;e<i;e+=3){const i=t[e+0],s=t[e+1],r=t[e+2];n.push(i,s,s,r,r,i)}}else{if(void 0===s)return;{const t=s.array;a=s.version;for(let e=0,i=t.length/3-1;e<i;e+=3){const t=e+0,i=e+1,s=e+2;n.push(t,i,i,s,s,t)}}}const o=new(si(n)?xr:yr)(n,1);o.version=a;const l=r.get(t);l&&e.remove(l),r.set(t,o)}return{get:function(t,e){return!0===s[e.id]||(e.addEventListener("dispose",a),s[e.id]=!0,n.memory.geometries++),e},update:function(n){const i=n.attributes;for(const n in i)e.update(i[n],t.ARRAY_BUFFER);const s=n.morphAttributes;for(const n in s){const i=s[n];for(let n=0,s=i.length;n<s;n++)e.update(i[n],t.ARRAY_BUFFER)}},getWireframeAttribute:function(t){const e=r.get(t);if(e){const n=t.index;null!==n&&e.version<n.version&&o(t)}else o(t);return r.get(t)}}}function Ka(t,e,n){let i,s,r;function a(e,a,o){0!==o&&(t.drawElementsInstanced(i,a,s,e*r,o),n.update(a,i,o))}this.setMode=function(t){i=t},this.setIndex=function(t){s=t.type,r=t.bytesPerElement},this.render=function(e,a){t.drawElements(i,a,s,e*r),n.update(a,i,1)},this.renderInstances=a,this.renderMultiDraw=function(t,r,a){if(0===a)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,r,0,s,t,0,a);let o=0;for(let t=0;t<a;t++)o+=r[t];n.update(o,i,1)},this.renderMultiDrawInstances=function(t,o,l,c){if(0===l)return;const u=e.get("WEBGL_multi_draw");if(null===u)for(let e=0;e<t.length;e++)a(t[e]/r,o[e],c[e]);else{u.multiDrawElementsInstancedWEBGL(i,o,0,s,t,0,c,0,l);let e=0;for(let t=0;t<l;t++)e+=o[t];for(let t=0;t<c.length;t++)n.update(e,i,c[t])}}}function Qa(t){const e={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:e,programs:null,autoReset:!0,reset:function(){e.calls=0,e.triangles=0,e.points=0,e.lines=0},update:function(n,i,s){switch(e.calls++,i){case t.TRIANGLES:e.triangles+=s*(n/3);break;case t.LINES:e.lines+=s*(n/2);break;case t.LINE_STRIP:e.lines+=s*(n-1);break;case t.LINE_LOOP:e.lines+=s*n;break;case t.POINTS:e.points+=s*n;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",i)}}}}function to(t,e,n){const i=new WeakMap,s=new wi;return{update:function(r,a,o){const l=r.morphTargetInfluences,c=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,u=void 0!==c?c.length:0;let h=i.get(a);if(void 0===h||h.count!==u){void 0!==h&&h.texture.dispose();const d=void 0!==a.morphAttributes.position,p=void 0!==a.morphAttributes.normal,m=void 0!==a.morphAttributes.color,f=a.morphAttributes.position||[],g=a.morphAttributes.normal||[],v=a.morphAttributes.color||[];let y=0;!0===d&&(y=1),!0===p&&(y=2),!0===m&&(y=3);let _=a.attributes.position.count*y,x=1;_>e.maxTextureSize&&(x=Math.ceil(_/e.maxTextureSize),_=e.maxTextureSize);const M=new Float32Array(_*x*4*u),b=new Ni(M,_,x,u);b.type=Lt,b.needsUpdate=!0;const T=4*y;for(let w=0;w<u;w++){const E=f[w],A=g[w],N=v[w],C=_*x*4*w;for(let R=0;R<E.count;R++){const I=R*T;!0===d&&(s.fromBufferAttribute(E,R),M[C+I+0]=s.x,M[C+I+1]=s.y,M[C+I+2]=s.z,M[C+I+3]=0),!0===p&&(s.fromBufferAttribute(A,R),M[C+I+4]=s.x,M[C+I+5]=s.y,M[C+I+6]=s.z,M[C+I+7]=0),!0===m&&(s.fromBufferAttribute(N,R),M[C+I+8]=s.x,M[C+I+9]=s.y,M[C+I+10]=s.z,M[C+I+11]=4===N.itemSize?s.w:1)}}function S(){b.dispose(),i.delete(a),a.removeEventListener("dispose",S)}h={count:u,texture:b,size:new ei(_,x)},i.set(a,h),a.addEventListener("dispose",S)}if(!0===r.isInstancedMesh&&null!==r.morphTexture)o.getUniforms().setValue(t,"morphTexture",r.morphTexture,n);else{let L=0;for(let U=0;U<l.length;U++)L+=l[U];const P=a.morphTargetsRelative?1:1-L;o.getUniforms().setValue(t,"morphTargetBaseInfluence",P),o.getUniforms().setValue(t,"morphTargetInfluences",l)}o.getUniforms().setValue(t,"morphTargetsTexture",h.texture,n),o.getUniforms().setValue(t,"morphTargetsTextureSize",h.size)}}}function eo(t,e,n,i){let s=new WeakMap;function r(t){const e=t.target;e.removeEventListener("dispose",r),n.remove(e.instanceMatrix),null!==e.instanceColor&&n.remove(e.instanceColor)}return{update:function(a){const o=i.render.frame,l=a.geometry,c=e.get(a,l);if(s.get(c)!==o&&(e.update(c),s.set(c,o)),a.isInstancedMesh&&(!1===a.hasEventListener("dispose",r)&&a.addEventListener("dispose",r),s.get(a)!==o&&(n.update(a.instanceMatrix,t.ARRAY_BUFFER),null!==a.instanceColor&&n.update(a.instanceColor,t.ARRAY_BUFFER),s.set(a,o))),a.isSkinnedMesh){const t=a.skeleton;s.get(t)!==o&&(t.update(),s.set(t,o))}return c},dispose:function(){s=new WeakMap}}}class no extends Si{constructor(t,e,n,i,s,r,a,o,l,c=1026){if(c!==Wt&&c!==jt)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&c===Wt&&(n=It),void 0===n&&c===jt&&(n=Ot),super(null,i,s,r,a,o,c,n,l),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=void 0!==a?a:gt,this.minFilter=void 0!==o?o:gt,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return null!==this.compareFunction&&(e.compareFunction=this.compareFunction),e}}const io=new Si,so=new no(1,1),ro=new Ni,ao=new Ri,oo=new aa,lo=[],co=[],uo=new Float32Array(16),ho=new Float32Array(9),po=new Float32Array(4);function mo(t,e,n){const i=t[0];if(i<=0||i>0)return t;const s=e*n;let r=lo[s];if(void 0===r&&(r=new Float32Array(s),lo[s]=r),0!==e){i.toArray(r,0);for(let i=1,s=0;i!==e;++i)s+=n,t[i].toArray(r,s)}return r}function fo(t,e){if(t.length!==e.length)return!1;for(let n=0,i=t.length;n<i;n++)if(t[n]!==e[n])return!1;return!0}function go(t,e){for(let n=0,i=e.length;n<i;n++)t[n]=e[n]}function vo(t,e){let n=co[e];void 0===n&&(n=new Int32Array(e),co[e]=n);for(let i=0;i!==e;++i)n[i]=t.allocateTextureUnit();return n}function yo(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function _o(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y||(t.uniform2f(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(fo(n,e))return;t.uniform2fv(this.addr,e),go(n,e)}}function xo(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z||(t.uniform3f(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else if(void 0!==e.r)n[0]===e.r&&n[1]===e.g&&n[2]===e.b||(t.uniform3f(this.addr,e.r,e.g,e.b),n[0]=e.r,n[1]=e.g,n[2]=e.b);else{if(fo(n,e))return;t.uniform3fv(this.addr,e),go(n,e)}}function Mo(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z&&n[3]===e.w||(t.uniform4f(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(fo(n,e))return;t.uniform4fv(this.addr,e),go(n,e)}}function bo(t,e){const n=this.cache,i=e.elements;if(void 0===i){if(fo(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),go(n,e)}else{if(fo(n,i))return;po.set(i),t.uniformMatrix2fv(this.addr,!1,po),go(n,i)}}function To(t,e){const n=this.cache,i=e.elements;if(void 0===i){if(fo(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),go(n,e)}else{if(fo(n,i))return;ho.set(i),t.uniformMatrix3fv(this.addr,!1,ho),go(n,i)}}function So(t,e){const n=this.cache,i=e.elements;if(void 0===i){if(fo(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),go(n,e)}else{if(fo(n,i))return;uo.set(i),t.uniformMatrix4fv(this.addr,!1,uo),go(n,i)}}function wo(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function Eo(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y||(t.uniform2i(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(fo(n,e))return;t.uniform2iv(this.addr,e),go(n,e)}}function Ao(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z||(t.uniform3i(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(fo(n,e))return;t.uniform3iv(this.addr,e),go(n,e)}}function No(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z&&n[3]===e.w||(t.uniform4i(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(fo(n,e))return;t.uniform4iv(this.addr,e),go(n,e)}}function Co(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function Ro(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y||(t.uniform2ui(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(fo(n,e))return;t.uniform2uiv(this.addr,e),go(n,e)}}function Io(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z||(t.uniform3ui(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(fo(n,e))return;t.uniform3uiv(this.addr,e),go(n,e)}}function Lo(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z&&n[3]===e.w||(t.uniform4ui(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(fo(n,e))return;t.uniform4uiv(this.addr,e),go(n,e)}}function Po(t,e,n){const i=this.cache,s=n.allocateTextureUnit();let r;i[0]!==s&&(t.uniform1i(this.addr,s),i[0]=s),this.type===t.SAMPLER_2D_SHADOW?(so.compareFunction=515,r=so):r=io,n.setTexture2D(e||r,s)}function Uo(t,e,n){const i=this.cache,s=n.allocateTextureUnit();i[0]!==s&&(t.uniform1i(this.addr,s),i[0]=s),n.setTexture3D(e||ao,s)}function Do(t,e,n){const i=this.cache,s=n.allocateTextureUnit();i[0]!==s&&(t.uniform1i(this.addr,s),i[0]=s),n.setTextureCube(e||oo,s)}function Oo(t,e,n){const i=this.cache,s=n.allocateTextureUnit();i[0]!==s&&(t.uniform1i(this.addr,s),i[0]=s),n.setTexture2DArray(e||ro,s)}function zo(t,e){t.uniform1fv(this.addr,e)}function Vo(t,e){const n=mo(e,this.size,2);t.uniform2fv(this.addr,n)}function Fo(t,e){const n=mo(e,this.size,3);t.uniform3fv(this.addr,n)}function Bo(t,e){const n=mo(e,this.size,4);t.uniform4fv(this.addr,n)}function ko(t,e){const n=mo(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function Ho(t,e){const n=mo(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function Go(t,e){const n=mo(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function Wo(t,e){t.uniform1iv(this.addr,e)}function jo(t,e){t.uniform2iv(this.addr,e)}function Xo(t,e){t.uniform3iv(this.addr,e)}function qo(t,e){t.uniform4iv(this.addr,e)}function Yo(t,e){t.uniform1uiv(this.addr,e)}function Zo(t,e){t.uniform2uiv(this.addr,e)}function $o(t,e){t.uniform3uiv(this.addr,e)}function Jo(t,e){t.uniform4uiv(this.addr,e)}function Ko(t,e,n){const i=this.cache,s=e.length,r=vo(n,s);fo(i,r)||(t.uniform1iv(this.addr,r),go(i,r));for(let t=0;t!==s;++t)n.setTexture2D(e[t]||io,r[t])}function Qo(t,e,n){const i=this.cache,s=e.length,r=vo(n,s);fo(i,r)||(t.uniform1iv(this.addr,r),go(i,r));for(let t=0;t!==s;++t)n.setTexture3D(e[t]||ao,r[t])}function tl(t,e,n){const i=this.cache,s=e.length,r=vo(n,s);fo(i,r)||(t.uniform1iv(this.addr,r),go(i,r));for(let t=0;t!==s;++t)n.setTextureCube(e[t]||oo,r[t])}function el(t,e,n){const i=this.cache,s=e.length,r=vo(n,s);fo(i,r)||(t.uniform1iv(this.addr,r),go(i,r));for(let t=0;t!==s;++t)n.setTexture2DArray(e[t]||ro,r[t])}class nl{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.setValue=function(t){switch(t){case 5126:return yo;case 35664:return _o;case 35665:return xo;case 35666:return Mo;case 35674:return bo;case 35675:return To;case 35676:return So;case 5124:case 35670:return wo;case 35667:case 35671:return Eo;case 35668:case 35672:return Ao;case 35669:case 35673:return No;case 5125:return Co;case 36294:return Ro;case 36295:return Io;case 36296:return Lo;case 35678:case 36198:case 36298:case 36306:case 35682:return Po;case 35679:case 36299:case 36307:return Uo;case 35680:case 36300:case 36308:case 36293:return Do;case 36289:case 36303:case 36311:case 36292:return Oo}}(e.type)}}class il{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.size=e.size,this.setValue=function(t){switch(t){case 5126:return zo;case 35664:return Vo;case 35665:return Fo;case 35666:return Bo;case 35674:return ko;case 35675:return Ho;case 35676:return Go;case 5124:case 35670:return Wo;case 35667:case 35671:return jo;case 35668:case 35672:return Xo;case 35669:case 35673:return qo;case 5125:return Yo;case 36294:return Zo;case 36295:return $o;case 36296:return Jo;case 35678:case 36198:case 36298:case 36306:case 35682:return Ko;case 35679:case 36299:case 36307:return Qo;case 35680:case 36300:case 36308:case 36293:return tl;case 36289:case 36303:case 36311:case 36292:return el}}(e.type)}}class sl{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,n){const i=this.seq;for(let s=0,r=i.length;s!==r;++s){const r=i[s];r.setValue(t,e[r.id],n)}}}const rl=/(\w+)(\])?(\[|\.)?/g;function al(t,e){t.seq.push(e),t.map[e.id]=e}function ol(t,e,n){const i=t.name,s=i.length;for(rl.lastIndex=0;;){const r=rl.exec(i),a=rl.lastIndex;let o=r[1];const l="]"===r[2],c=r[3];if(l&&(o|=0),void 0===c||"["===c&&a+2===s){al(n,void 0===c?new nl(o,t,e):new il(o,t,e));break}{let t=n.map[o];void 0===t&&(t=new sl(o),al(n,t)),n=t}}}class ll{constructor(t,e){this.seq=[],this.map={};const n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let i=0;i<n;++i){const n=t.getActiveUniform(e,i);ol(n,t.getUniformLocation(e,n.name),this)}}setValue(t,e,n,i){const s=this.map[e];void 0!==s&&s.setValue(t,n,i)}setOptional(t,e,n){const i=e[n];void 0!==i&&this.setValue(t,n,i)}static upload(t,e,n,i){for(let s=0,r=e.length;s!==r;++s){const r=e[s],a=n[r.id];!1!==a.needsUpdate&&r.setValue(t,a.value,i)}}static seqWithValue(t,e){const n=[];for(let i=0,s=t.length;i!==s;++i){const s=t[i];s.id in e&&n.push(s)}return n}}function cl(t,e,n){const i=t.createShader(e);return t.shaderSource(i,n),t.compileShader(i),i}let ul=0;function hl(t,e,n){const i=t.getShaderParameter(e,t.COMPILE_STATUS),s=t.getShaderInfoLog(e).trim();if(i&&""===s)return"";const r=/ERROR: 0:(\d+)/.exec(s);if(r){const i=parseInt(r[1]);return n.toUpperCase()+"\n\n"+s+"\n\n"+function(t,e){const n=t.split("\n"),i=[],s=Math.max(e-6,0),r=Math.min(e+6,n.length);for(let t=s;t<r;t++){const s=t+1;i.push(`${s===e?">":" "} ${s}: ${n[t]}`)}return i.join("\n")}(t.getShaderSource(e),i)}return s}function dl(t,e){const n=function(t){const e=fi.getPrimaries(fi.workingColorSpace),n=fi.getPrimaries(t);let i;switch(e===n?i="":e===rn&&n===sn?i="LinearDisplayP3ToLinearSRGB":e===sn&&n===rn&&(i="LinearSRGBToLinearDisplayP3"),t){case Ke:case tn:return[i,"LinearTransferOETF"];case Je:case Qe:return[i,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",t),[i,"LinearTransferOETF"]}}(e);return`vec4 ${t}( vec4 value ) { return ${n[0]}( ${n[1]}( value ) ); }`}function pl(t,e){let n;switch(e){case 1:n="Linear";break;case 2:n="Reinhard";break;case 3:n="Cineon";break;case 4:n="ACESFilmic";break;case 6:n="AgX";break;case 7:n="Neutral";break;case 5:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const ml=new Pi;function fl(){fi.getLuminanceCoefficients(ml);return["float luminance( const in vec3 rgb ) {",`\tconst vec3 weights = vec3( ${ml.x.toFixed(4)}, ${ml.y.toFixed(4)}, ${ml.z.toFixed(4)} );`,"\treturn dot( weights, rgb );","}"].join("\n")}function gl(t){return""!==t}function vl(t,e){const n=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function yl(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const _l=/^[ \t]*#include +<([\w\d./]+)>/gm;function xl(t){return t.replace(_l,bl)}const Ml=new Map;function bl(t,e){let n=ya[e];if(void 0===n){const t=Ml.get(e);if(void 0===t)throw new Error("Can not resolve #include <"+e+">");n=ya[t],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,t)}return xl(n)}const Tl=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function Sl(t){return t.replace(Tl,wl)}function wl(t,e,n,i){let s="";for(let t=parseInt(e);t<parseInt(n);t++)s+=i.replace(/\[\s*i\s*\]/g,"[ "+t+" ]").replace(/UNROLLED_LOOP_INDEX/g,t);return s}function El(t){let e=`precision ${t.precision} float;\n\tprecision ${t.precision} int;\n\tprecision ${t.precision} sampler2D;\n\tprecision ${t.precision} samplerCube;\n\tprecision ${t.precision} sampler3D;\n\tprecision ${t.precision} sampler2DArray;\n\tprecision ${t.precision} sampler2DShadow;\n\tprecision ${t.precision} samplerCubeShadow;\n\tprecision ${t.precision} sampler2DArrayShadow;\n\tprecision ${t.precision} isampler2D;\n\tprecision ${t.precision} isampler3D;\n\tprecision ${t.precision} isamplerCube;\n\tprecision ${t.precision} isampler2DArray;\n\tprecision ${t.precision} usampler2D;\n\tprecision ${t.precision} usampler3D;\n\tprecision ${t.precision} usamplerCube;\n\tprecision ${t.precision} usampler2DArray;\n\t`;return"highp"===t.precision?e+="\n#define HIGH_PRECISION":"mediump"===t.precision?e+="\n#define MEDIUM_PRECISION":"lowp"===t.precision&&(e+="\n#define LOW_PRECISION"),e}function Al(t,e,n,i){const s=t.getContext(),r=n.defines;let a=n.vertexShader,o=n.fragmentShader;const l=function(t){let e="SHADOWMAP_TYPE_BASIC";return 1===t.shadowMapType?e="SHADOWMAP_TYPE_PCF":2===t.shadowMapType?e="SHADOWMAP_TYPE_PCF_SOFT":3===t.shadowMapType&&(e="SHADOWMAP_TYPE_VSM"),e}(n),c=function(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case lt:case ct:e="ENVMAP_TYPE_CUBE";break;case dt:e="ENVMAP_TYPE_CUBE_UV"}return e}(n),u=function(t){let e="ENVMAP_MODE_REFLECTION";t.envMap&&t.envMapMode===ct&&(e="ENVMAP_MODE_REFRACTION");return e}(n),h=function(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case 0:e="ENVMAP_BLENDING_MULTIPLY";break;case 1:e="ENVMAP_BLENDING_MIX";break;case 2:e="ENVMAP_BLENDING_ADD"}return e}(n),d=function(t){const e=t.envMapCubeUVHeight;if(null===e)return null;const n=Math.log2(e)-2,i=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:i,maxMip:n}}(n),p=function(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(gl).join("\n")}(n),m=function(t){const e=[];for(const n in t){const i=t[n];!1!==i&&e.push("#define "+n+" "+i)}return e.join("\n")}(r),f=s.createProgram();let g,v,y=n.glslVersion?"#version "+n.glslVersion+"\n":"";n.isRawShaderMaterial?(g=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m].filter(gl).join("\n"),g.length>0&&(g+="\n"),v=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m].filter(gl).join("\n"),v.length>0&&(v+="\n")):(g=[El(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","\tuniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(gl).join("\n"),v=[El(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+c:"",n.envMap?"#define "+u:"",n.envMap?"#define "+h:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor||n.batchingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==n.toneMapping?"#define TONE_MAPPING":"",0!==n.toneMapping?ya.tonemapping_pars_fragment:"",0!==n.toneMapping?pl("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",ya.colorspace_pars_fragment,dl("linearToOutputTexel",n.outputColorSpace),fl(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(gl).join("\n")),a=xl(a),a=vl(a,n),a=yl(a,n),o=xl(o),o=vl(o,n),o=yl(o,n),a=Sl(a),o=Sl(o),!0!==n.isRawShaderMaterial&&(y="#version 300 es\n",g=[p,"#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+g,v=["#define varying in",n.glslVersion===Bn?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===Bn?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+v);const _=y+g+a,x=y+v+o,M=cl(s,s.VERTEX_SHADER,_),b=cl(s,s.FRAGMENT_SHADER,x);function T(e){if(t.debug.checkShaderErrors){const n=s.getProgramInfoLog(f).trim(),i=s.getShaderInfoLog(M).trim(),r=s.getShaderInfoLog(b).trim();let a=!0,o=!0;if(!1===s.getProgramParameter(f,s.LINK_STATUS))if(a=!1,"function"==typeof t.debug.onShaderError)t.debug.onShaderError(s,f,M,b);else{const t=hl(s,M,"vertex"),i=hl(s,b,"fragment");console.error("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(f,s.VALIDATE_STATUS)+"\n\nMaterial Name: "+e.name+"\nMaterial Type: "+e.type+"\n\nProgram Info Log: "+n+"\n"+t+"\n"+i)}else""!==n?console.warn("THREE.WebGLProgram: Program Info Log:",n):""!==i&&""!==r||(o=!1);o&&(e.diagnostics={runnable:a,programLog:n,vertexShader:{log:i,prefix:g},fragmentShader:{log:r,prefix:v}})}s.deleteShader(M),s.deleteShader(b),S=new ll(s,f),w=function(t,e){const n={},i=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let s=0;s<i;s++){const i=t.getActiveAttrib(e,s),r=i.name;let a=1;i.type===t.FLOAT_MAT2&&(a=2),i.type===t.FLOAT_MAT3&&(a=3),i.type===t.FLOAT_MAT4&&(a=4),n[r]={type:i.type,location:t.getAttribLocation(e,r),locationSize:a}}return n}(s,f)}let S,w;s.attachShader(f,M),s.attachShader(f,b),void 0!==n.index0AttributeName?s.bindAttribLocation(f,0,n.index0AttributeName):!0===n.morphTargets&&s.bindAttribLocation(f,0,"position"),s.linkProgram(f),this.getUniforms=function(){return void 0===S&&T(this),S},this.getAttributes=function(){return void 0===w&&T(this),w};let E=!1===n.rendererExtensionParallelShaderCompile;return this.isReady=function(){return!1===E&&(E=s.getProgramParameter(f,37297)),E},this.destroy=function(){i.releaseStatesOfProgram(this),s.deleteProgram(f),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=ul++,this.cacheKey=e,this.usedTimes=1,this.program=f,this.vertexShader=M,this.fragmentShader=b,this}let Nl=0;class Cl{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){const e=t.vertexShader,n=t.fragmentShader,i=this._getShaderStage(e),s=this._getShaderStage(n),r=this._getShaderCacheForMaterial(t);return!1===r.has(i)&&(r.add(i),i.usedTimes++),!1===r.has(s)&&(r.add(s),s.usedTimes++),this}remove(t){const e=this.materialCache.get(t);for(const t of e)t.usedTimes--,0===t.usedTimes&&this.shaderCache.delete(t.code);return this.materialCache.delete(t),this}getVertexShaderID(t){return this._getShaderStage(t.vertexShader).id}getFragmentShaderID(t){return this._getShaderStage(t.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){const e=this.materialCache;let n=e.get(t);return void 0===n&&(n=new Set,e.set(t,n)),n}_getShaderStage(t){const e=this.shaderCache;let n=e.get(t);return void 0===n&&(n=new Rl(t),e.set(t,n)),n}}class Rl{constructor(t){this.id=Nl++,this.code=t,this.usedTimes=0}}function Il(t,e,n,i,s,r,a){const o=new xs,l=new Cl,c=new Set,u=[],h=s.logarithmicDepthBuffer,d=s.reverseDepthBuffer,p=s.vertexTextures;let m=s.precision;const f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function g(t){return c.add(t),0===t?"uv":`uv${t}`}return{getParameters:function(r,o,u,v,y){const _=v.fog,x=y.geometry,M=r.isMeshStandardMaterial?v.environment:null,b=(r.isMeshStandardMaterial?n:e).get(r.envMap||M),T=b&&b.mapping===dt?b.image.height:null,S=f[r.type];null!==r.precision&&(m=s.getMaxPrecision(r.precision),m!==r.precision&&console.warn("THREE.WebGLProgram.getParameters:",r.precision,"not supported, using",m,"instead."));const w=x.morphAttributes.position||x.morphAttributes.normal||x.morphAttributes.color,E=void 0!==w?w.length:0;let A,N,C,R,I=0;if(void 0!==x.morphAttributes.position&&(I=1),void 0!==x.morphAttributes.normal&&(I=2),void 0!==x.morphAttributes.color&&(I=3),S){const t=xa[S];A=t.vertexShader,N=t.fragmentShader}else A=r.vertexShader,N=r.fragmentShader,l.update(r),C=l.getVertexShaderID(r),R=l.getFragmentShaderID(r);const L=t.getRenderTarget(),P=!0===y.isInstancedMesh,U=!0===y.isBatchedMesh,D=!!r.map,O=!!r.matcap,z=!!b,V=!!r.aoMap,F=!!r.lightMap,B=!!r.bumpMap,k=!!r.normalMap,H=!!r.displacementMap,G=!!r.emissiveMap,W=!!r.metalnessMap,j=!!r.roughnessMap,X=r.anisotropy>0,q=r.clearcoat>0,Y=r.dispersion>0,Z=r.iridescence>0,$=r.sheen>0,J=r.transmission>0,K=X&&!!r.anisotropyMap,Q=q&&!!r.clearcoatMap,tt=q&&!!r.clearcoatNormalMap,et=q&&!!r.clearcoatRoughnessMap,nt=Z&&!!r.iridescenceMap,it=Z&&!!r.iridescenceThicknessMap,st=$&&!!r.sheenColorMap,rt=$&&!!r.sheenRoughnessMap,at=!!r.specularMap,ot=!!r.specularColorMap,lt=!!r.specularIntensityMap,ct=J&&!!r.transmissionMap,ut=J&&!!r.thicknessMap,ht=!!r.gradientMap,pt=!!r.alphaMap,mt=r.alphaTest>0,ft=!!r.alphaHash,gt=!!r.extensions;let vt=0;r.toneMapped&&(null!==L&&!0!==L.isXRRenderTarget||(vt=t.toneMapping));const yt={shaderID:S,shaderType:r.type,shaderName:r.name,vertexShader:A,fragmentShader:N,defines:r.defines,customVertexShaderID:C,customFragmentShaderID:R,isRawShaderMaterial:!0===r.isRawShaderMaterial,glslVersion:r.glslVersion,precision:m,batching:U,batchingColor:U&&null!==y._colorsTexture,instancing:P,instancingColor:P&&null!==y.instanceColor,instancingMorph:P&&null!==y.morphTexture,supportsVertexTextures:p,outputColorSpace:null===L?t.outputColorSpace:!0===L.isXRRenderTarget?L.texture.colorSpace:Ke,alphaToCoverage:!!r.alphaToCoverage,map:D,matcap:O,envMap:z,envMapMode:z&&b.mapping,envMapCubeUVHeight:T,aoMap:V,lightMap:F,bumpMap:B,normalMap:k,displacementMap:p&&H,emissiveMap:G,normalMapObjectSpace:k&&1===r.normalMapType,normalMapTangentSpace:k&&0===r.normalMapType,metalnessMap:W,roughnessMap:j,anisotropy:X,anisotropyMap:K,clearcoat:q,clearcoatMap:Q,clearcoatNormalMap:tt,clearcoatRoughnessMap:et,dispersion:Y,iridescence:Z,iridescenceMap:nt,iridescenceThicknessMap:it,sheen:$,sheenColorMap:st,sheenRoughnessMap:rt,specularMap:at,specularColorMap:ot,specularIntensityMap:lt,transmission:J,transmissionMap:ct,thicknessMap:ut,gradientMap:ht,opaque:!1===r.transparent&&1===r.blending&&!1===r.alphaToCoverage,alphaMap:pt,alphaTest:mt,alphaHash:ft,combine:r.combine,mapUv:D&&g(r.map.channel),aoMapUv:V&&g(r.aoMap.channel),lightMapUv:F&&g(r.lightMap.channel),bumpMapUv:B&&g(r.bumpMap.channel),normalMapUv:k&&g(r.normalMap.channel),displacementMapUv:H&&g(r.displacementMap.channel),emissiveMapUv:G&&g(r.emissiveMap.channel),metalnessMapUv:W&&g(r.metalnessMap.channel),roughnessMapUv:j&&g(r.roughnessMap.channel),anisotropyMapUv:K&&g(r.anisotropyMap.channel),clearcoatMapUv:Q&&g(r.clearcoatMap.channel),clearcoatNormalMapUv:tt&&g(r.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:et&&g(r.clearcoatRoughnessMap.channel),iridescenceMapUv:nt&&g(r.iridescenceMap.channel),iridescenceThicknessMapUv:it&&g(r.iridescenceThicknessMap.channel),sheenColorMapUv:st&&g(r.sheenColorMap.channel),sheenRoughnessMapUv:rt&&g(r.sheenRoughnessMap.channel),specularMapUv:at&&g(r.specularMap.channel),specularColorMapUv:ot&&g(r.specularColorMap.channel),specularIntensityMapUv:lt&&g(r.specularIntensityMap.channel),transmissionMapUv:ct&&g(r.transmissionMap.channel),thicknessMapUv:ut&&g(r.thicknessMap.channel),alphaMapUv:pt&&g(r.alphaMap.channel),vertexTangents:!!x.attributes.tangent&&(k||X),vertexColors:r.vertexColors,vertexAlphas:!0===r.vertexColors&&!!x.attributes.color&&4===x.attributes.color.itemSize,pointsUvs:!0===y.isPoints&&!!x.attributes.uv&&(D||pt),fog:!!_,useFog:!0===r.fog,fogExp2:!!_&&_.isFogExp2,flatShading:!0===r.flatShading,sizeAttenuation:!0===r.sizeAttenuation,logarithmicDepthBuffer:h,reverseDepthBuffer:d,skinning:!0===y.isSkinnedMesh,morphTargets:void 0!==x.morphAttributes.position,morphNormals:void 0!==x.morphAttributes.normal,morphColors:void 0!==x.morphAttributes.color,morphTargetsCount:E,morphTextureStride:I,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numLightProbes:o.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:r.dithering,shadowMapEnabled:t.shadowMap.enabled&&u.length>0,shadowMapType:t.shadowMap.type,toneMapping:vt,decodeVideoTexture:D&&!0===r.map.isVideoTexture&&fi.getTransfer(r.map.colorSpace)===nn,premultipliedAlpha:r.premultipliedAlpha,doubleSided:2===r.side,flipSided:1===r.side,useDepthPacking:r.depthPacking>=0,depthPacking:r.depthPacking||0,index0AttributeName:r.index0AttributeName,extensionClipCullDistance:gt&&!0===r.extensions.clipCullDistance&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(gt&&!0===r.extensions.multiDraw||U)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:r.customProgramCacheKey()};return yt.vertexUv1s=c.has(1),yt.vertexUv2s=c.has(2),yt.vertexUv3s=c.has(3),c.clear(),yt},getProgramCacheKey:function(e){const n=[];if(e.shaderID?n.push(e.shaderID):(n.push(e.customVertexShaderID),n.push(e.customFragmentShaderID)),void 0!==e.defines)for(const t in e.defines)n.push(t),n.push(e.defines[t]);return!1===e.isRawShaderMaterial&&(!function(t,e){t.push(e.precision),t.push(e.outputColorSpace),t.push(e.envMapMode),t.push(e.envMapCubeUVHeight),t.push(e.mapUv),t.push(e.alphaMapUv),t.push(e.lightMapUv),t.push(e.aoMapUv),t.push(e.bumpMapUv),t.push(e.normalMapUv),t.push(e.displacementMapUv),t.push(e.emissiveMapUv),t.push(e.metalnessMapUv),t.push(e.roughnessMapUv),t.push(e.anisotropyMapUv),t.push(e.clearcoatMapUv),t.push(e.clearcoatNormalMapUv),t.push(e.clearcoatRoughnessMapUv),t.push(e.iridescenceMapUv),t.push(e.iridescenceThicknessMapUv),t.push(e.sheenColorMapUv),t.push(e.sheenRoughnessMapUv),t.push(e.specularMapUv),t.push(e.specularColorMapUv),t.push(e.specularIntensityMapUv),t.push(e.transmissionMapUv),t.push(e.thicknessMapUv),t.push(e.combine),t.push(e.fogExp2),t.push(e.sizeAttenuation),t.push(e.morphTargetsCount),t.push(e.morphAttributeCount),t.push(e.numDirLights),t.push(e.numPointLights),t.push(e.numSpotLights),t.push(e.numSpotLightMaps),t.push(e.numHemiLights),t.push(e.numRectAreaLights),t.push(e.numDirLightShadows),t.push(e.numPointLightShadows),t.push(e.numSpotLightShadows),t.push(e.numSpotLightShadowsWithMaps),t.push(e.numLightProbes),t.push(e.shadowMapType),t.push(e.toneMapping),t.push(e.numClippingPlanes),t.push(e.numClipIntersection),t.push(e.depthPacking)}(n,e),function(t,e){o.disableAll(),e.supportsVertexTextures&&o.enable(0);e.instancing&&o.enable(1);e.instancingColor&&o.enable(2);e.instancingMorph&&o.enable(3);e.matcap&&o.enable(4);e.envMap&&o.enable(5);e.normalMapObjectSpace&&o.enable(6);e.normalMapTangentSpace&&o.enable(7);e.clearcoat&&o.enable(8);e.iridescence&&o.enable(9);e.alphaTest&&o.enable(10);e.vertexColors&&o.enable(11);e.vertexAlphas&&o.enable(12);e.vertexUv1s&&o.enable(13);e.vertexUv2s&&o.enable(14);e.vertexUv3s&&o.enable(15);e.vertexTangents&&o.enable(16);e.anisotropy&&o.enable(17);e.alphaHash&&o.enable(18);e.batching&&o.enable(19);e.dispersion&&o.enable(20);e.batchingColor&&o.enable(21);t.push(o.mask),o.disableAll(),e.fog&&o.enable(0);e.useFog&&o.enable(1);e.flatShading&&o.enable(2);e.logarithmicDepthBuffer&&o.enable(3);e.reverseDepthBuffer&&o.enable(4);e.skinning&&o.enable(5);e.morphTargets&&o.enable(6);e.morphNormals&&o.enable(7);e.morphColors&&o.enable(8);e.premultipliedAlpha&&o.enable(9);e.shadowMapEnabled&&o.enable(10);e.doubleSided&&o.enable(11);e.flipSided&&o.enable(12);e.useDepthPacking&&o.enable(13);e.dithering&&o.enable(14);e.transmission&&o.enable(15);e.sheen&&o.enable(16);e.opaque&&o.enable(17);e.pointsUvs&&o.enable(18);e.decodeVideoTexture&&o.enable(19);e.alphaToCoverage&&o.enable(20);t.push(o.mask)}(n,e),n.push(t.outputColorSpace)),n.push(e.customProgramCacheKey),n.join()},getUniforms:function(t){const e=f[t.type];let n;if(e){const t=xa[e];n=Yr.clone(t.uniforms)}else n=t.uniforms;return n},acquireProgram:function(e,n){let i;for(let t=0,e=u.length;t<e;t++){const e=u[t];if(e.cacheKey===n){i=e,++i.usedTimes;break}}return void 0===i&&(i=new Al(t,n,e,r),u.push(i)),i},releaseProgram:function(t){if(0===--t.usedTimes){const e=u.indexOf(t);u[e]=u[u.length-1],u.pop(),t.destroy()}},releaseShaderCache:function(t){l.remove(t)},programs:u,dispose:function(){l.dispose()}}}function Ll(){let t=new WeakMap;return{has:function(e){return t.has(e)},get:function(e){let n=t.get(e);return void 0===n&&(n={},t.set(e,n)),n},remove:function(e){t.delete(e)},update:function(e,n,i){t.get(e)[n]=i},dispose:function(){t=new WeakMap}}}function Pl(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.material.id!==e.material.id?t.material.id-e.material.id:t.z!==e.z?t.z-e.z:t.id-e.id}function Ul(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function Dl(){const t=[];let e=0;const n=[],i=[],s=[];function r(n,i,s,r,a,o){let l=t[e];return void 0===l?(l={id:n.id,object:n,geometry:i,material:s,groupOrder:r,renderOrder:n.renderOrder,z:a,group:o},t[e]=l):(l.id=n.id,l.object=n,l.geometry=i,l.material=s,l.groupOrder=r,l.renderOrder=n.renderOrder,l.z=a,l.group=o),e++,l}return{opaque:n,transmissive:i,transparent:s,init:function(){e=0,n.length=0,i.length=0,s.length=0},push:function(t,e,a,o,l,c){const u=r(t,e,a,o,l,c);t.onBeforeRenderListPush?.(t,e,a,c),a.transmission>0?i.push(u):!0===a.transparent?s.push(u):n.push(u),t.onAfterRenderListPush?.(t,e,a,c)},unshift:function(t,e,a,o,l,c){const u=r(t,e,a,o,l,c);a.transmission>0?i.unshift(u):!0===a.transparent?s.unshift(u):n.unshift(u)},finish:function(){for(let n=e,i=t.length;n<i;n++){const e=t[n];if(null===e.id)break;e.id=null,e.object=null,e.geometry=null,e.material=null,e.group=null}},sort:function(t,e){n.length>1&&n.sort(t||Pl),i.length>1&&i.sort(e||Ul),s.length>1&&s.sort(e||Ul)}}}function Ol(){let t=new WeakMap;return{get:function(e,n){const i=t.get(e);let s;return void 0===i?(s=new Dl,t.set(e,[s])):n>=i.length?(s=new Dl,i.push(s)):s=i[n],s},dispose:function(){t=new WeakMap}}}function zl(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let n;switch(e.type){case"DirectionalLight":n={direction:new Pi,color:new er};break;case"SpotLight":n={position:new Pi,direction:new Pi,color:new er,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Pi,color:new er,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Pi,skyColor:new er,groundColor:new er};break;case"RectAreaLight":n={color:new er,position:new Pi,halfWidth:new Pi,halfHeight:new Pi}}return t[e.id]=n,n}}}let Vl=0;function Fl(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function Bl(t){const e=new zl,n=function(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let n;switch(e.type){case"DirectionalLight":case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ei};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ei,shadowCameraNear:1,shadowCameraFar:1e3}}return t[e.id]=n,n}}}(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let t=0;t<9;t++)i.probe.push(new Pi);const s=new Pi,r=new cs,a=new cs;return{setup:function(s){let r=0,a=0,o=0;for(let t=0;t<9;t++)i.probe[t].set(0,0,0);let l=0,c=0,u=0,h=0,d=0,p=0,m=0,f=0,g=0,v=0,y=0;s.sort(Fl);for(let t=0,_=s.length;t<_;t++){const _=s[t],x=_.color,M=_.intensity,b=_.distance,T=_.shadow&&_.shadow.map?_.shadow.map.texture:null;if(_.isAmbientLight)r+=x.r*M,a+=x.g*M,o+=x.b*M;else if(_.isLightProbe){for(let t=0;t<9;t++)i.probe[t].addScaledVector(_.sh.coefficients[t],M);y++}else if(_.isDirectionalLight){const t=e.get(_);if(t.color.copy(_.color).multiplyScalar(_.intensity),_.castShadow){const t=_.shadow,e=n.get(_);e.shadowIntensity=t.intensity,e.shadowBias=t.bias,e.shadowNormalBias=t.normalBias,e.shadowRadius=t.radius,e.shadowMapSize=t.mapSize,i.directionalShadow[l]=e,i.directionalShadowMap[l]=T,i.directionalShadowMatrix[l]=_.shadow.matrix,p++}i.directional[l]=t,l++}else if(_.isSpotLight){const t=e.get(_);t.position.setFromMatrixPosition(_.matrixWorld),t.color.copy(x).multiplyScalar(M),t.distance=b,t.coneCos=Math.cos(_.angle),t.penumbraCos=Math.cos(_.angle*(1-_.penumbra)),t.decay=_.decay,i.spot[u]=t;const s=_.shadow;if(_.map&&(i.spotLightMap[g]=_.map,g++,s.updateMatrices(_),_.castShadow&&v++),i.spotLightMatrix[u]=s.matrix,_.castShadow){const t=n.get(_);t.shadowIntensity=s.intensity,t.shadowBias=s.bias,t.shadowNormalBias=s.normalBias,t.shadowRadius=s.radius,t.shadowMapSize=s.mapSize,i.spotShadow[u]=t,i.spotShadowMap[u]=T,f++}u++}else if(_.isRectAreaLight){const t=e.get(_);t.color.copy(x).multiplyScalar(M),t.halfWidth.set(.5*_.width,0,0),t.halfHeight.set(0,.5*_.height,0),i.rectArea[h]=t,h++}else if(_.isPointLight){const t=e.get(_);if(t.color.copy(_.color).multiplyScalar(_.intensity),t.distance=_.distance,t.decay=_.decay,_.castShadow){const t=_.shadow,e=n.get(_);e.shadowIntensity=t.intensity,e.shadowBias=t.bias,e.shadowNormalBias=t.normalBias,e.shadowRadius=t.radius,e.shadowMapSize=t.mapSize,e.shadowCameraNear=t.camera.near,e.shadowCameraFar=t.camera.far,i.pointShadow[c]=e,i.pointShadowMap[c]=T,i.pointShadowMatrix[c]=_.shadow.matrix,m++}i.point[c]=t,c++}else if(_.isHemisphereLight){const t=e.get(_);t.skyColor.copy(_.color).multiplyScalar(M),t.groundColor.copy(_.groundColor).multiplyScalar(M),i.hemi[d]=t,d++}}h>0&&(!0===t.has("OES_texture_float_linear")?(i.rectAreaLTC1=_a.LTC_FLOAT_1,i.rectAreaLTC2=_a.LTC_FLOAT_2):(i.rectAreaLTC1=_a.LTC_HALF_1,i.rectAreaLTC2=_a.LTC_HALF_2)),i.ambient[0]=r,i.ambient[1]=a,i.ambient[2]=o;const _=i.hash;_.directionalLength===l&&_.pointLength===c&&_.spotLength===u&&_.rectAreaLength===h&&_.hemiLength===d&&_.numDirectionalShadows===p&&_.numPointShadows===m&&_.numSpotShadows===f&&_.numSpotMaps===g&&_.numLightProbes===y||(i.directional.length=l,i.spot.length=u,i.rectArea.length=h,i.point.length=c,i.hemi.length=d,i.directionalShadow.length=p,i.directionalShadowMap.length=p,i.pointShadow.length=m,i.pointShadowMap.length=m,i.spotShadow.length=f,i.spotShadowMap.length=f,i.directionalShadowMatrix.length=p,i.pointShadowMatrix.length=m,i.spotLightMatrix.length=f+g-v,i.spotLightMap.length=g,i.numSpotLightShadowsWithMaps=v,i.numLightProbes=y,_.directionalLength=l,_.pointLength=c,_.spotLength=u,_.rectAreaLength=h,_.hemiLength=d,_.numDirectionalShadows=p,_.numPointShadows=m,_.numSpotShadows=f,_.numSpotMaps=g,_.numLightProbes=y,i.version=Vl++)},setupView:function(t,e){let n=0,o=0,l=0,c=0,u=0;const h=e.matrixWorldInverse;for(let e=0,d=t.length;e<d;e++){const d=t[e];if(d.isDirectionalLight){const t=i.directional[n];t.direction.setFromMatrixPosition(d.matrixWorld),s.setFromMatrixPosition(d.target.matrixWorld),t.direction.sub(s),t.direction.transformDirection(h),n++}else if(d.isSpotLight){const t=i.spot[l];t.position.setFromMatrixPosition(d.matrixWorld),t.position.applyMatrix4(h),t.direction.setFromMatrixPosition(d.matrixWorld),s.setFromMatrixPosition(d.target.matrixWorld),t.direction.sub(s),t.direction.transformDirection(h),l++}else if(d.isRectAreaLight){const t=i.rectArea[c];t.position.setFromMatrixPosition(d.matrixWorld),t.position.applyMatrix4(h),a.identity(),r.copy(d.matrixWorld),r.premultiply(h),a.extractRotation(r),t.halfWidth.set(.5*d.width,0,0),t.halfHeight.set(0,.5*d.height,0),t.halfWidth.applyMatrix4(a),t.halfHeight.applyMatrix4(a),c++}else if(d.isPointLight){const t=i.point[o];t.position.setFromMatrixPosition(d.matrixWorld),t.position.applyMatrix4(h),o++}else if(d.isHemisphereLight){const t=i.hemi[u];t.direction.setFromMatrixPosition(d.matrixWorld),t.direction.transformDirection(h),u++}}},state:i}}function kl(t){const e=new Bl(t),n=[],i=[];const s={lightsArray:n,shadowsArray:i,camera:null,lights:e,transmissionRenderTarget:{}};return{init:function(t){s.camera=t,n.length=0,i.length=0},state:s,setupLights:function(){e.setup(n)},setupLightsView:function(t){e.setupView(n,t)},pushLight:function(t){n.push(t)},pushShadow:function(t){i.push(t)}}}function Hl(t){let e=new WeakMap;return{get:function(n,i=0){const s=e.get(n);let r;return void 0===s?(r=new kl(t),e.set(n,[r])):i>=s.length?(r=new kl(t),s.push(r)):r=s[i],r},dispose:function(){e=new WeakMap}}}class Gl extends sr{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}}class Wl extends sr{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}function jl(t,e,n){let i=new ma;const s=new ei,r=new ei,a=new wi,o=new Gl({depthPacking:3201}),l=new Wl,c={},u=n.maxTextureSize,m={[h]:1,[d]:0,[p]:2},f=new Zr({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new ei},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include <packing>\nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),g=f.clone();g.defines.HORIZONTAL_PASS=1;const v=new Rr;v.setAttribute("position",new pr(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new Hr(v,f),_=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1;let x=this.type;function M(n,i){const r=e.update(y);f.defines.VSM_SAMPLES!==n.blurSamples&&(f.defines.VSM_SAMPLES=n.blurSamples,g.defines.VSM_SAMPLES=n.blurSamples,f.needsUpdate=!0,g.needsUpdate=!0),null===n.mapPass&&(n.mapPass=new Ai(s.x,s.y)),f.uniforms.shadow_pass.value=n.map.texture,f.uniforms.resolution.value=n.mapSize,f.uniforms.radius.value=n.radius,t.setRenderTarget(n.mapPass),t.clear(),t.renderBufferDirect(i,null,r,f,y,null),g.uniforms.shadow_pass.value=n.mapPass.texture,g.uniforms.resolution.value=n.mapSize,g.uniforms.radius.value=n.radius,t.setRenderTarget(n.map),t.clear(),t.renderBufferDirect(i,null,r,g,y,null)}function b(e,n,i,s){let r=null;const a=!0===i.isPointLight?e.customDistanceMaterial:e.customDepthMaterial;if(void 0!==a)r=a;else if(r=!0===i.isPointLight?l:o,t.localClippingEnabled&&!0===n.clipShadows&&Array.isArray(n.clippingPlanes)&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0||n.map&&n.alphaTest>0){const t=r.uuid,e=n.uuid;let i=c[t];void 0===i&&(i={},c[t]=i);let s=i[e];void 0===s&&(s=r.clone(),i[e]=s,n.addEventListener("dispose",S)),r=s}if(r.visible=n.visible,r.wireframe=n.wireframe,r.side=3===s?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:m[n.side],r.alphaMap=n.alphaMap,r.alphaTest=n.alphaTest,r.map=n.map,r.clipShadows=n.clipShadows,r.clippingPlanes=n.clippingPlanes,r.clipIntersection=n.clipIntersection,r.displacementMap=n.displacementMap,r.displacementScale=n.displacementScale,r.displacementBias=n.displacementBias,r.wireframeLinewidth=n.wireframeLinewidth,r.linewidth=n.linewidth,!0===i.isPointLight&&!0===r.isMeshDistanceMaterial){t.properties.get(r).light=i}return r}function T(n,s,r,a,o){if(!1===n.visible)return;if(n.layers.test(s.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&3===o)&&(!n.frustumCulled||i.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,n.matrixWorld);const i=e.update(n),l=n.material;if(Array.isArray(l)){const e=i.groups;for(let c=0,u=e.length;c<u;c++){const u=e[c],h=l[u.materialIndex];if(h&&h.visible){const e=b(n,h,a,o);n.onBeforeShadow(t,n,s,r,i,e,u),t.renderBufferDirect(r,null,i,e,n,u),n.onAfterShadow(t,n,s,r,i,e,u)}}}else if(l.visible){const e=b(n,l,a,o);n.onBeforeShadow(t,n,s,r,i,e,null),t.renderBufferDirect(r,null,i,e,n,null),n.onAfterShadow(t,n,s,r,i,e,null)}}const l=n.children;for(let t=0,e=l.length;t<e;t++)T(l[t],s,r,a,o)}function S(t){t.target.removeEventListener("dispose",S);for(const e in c){const n=c[e],i=t.target.uuid;if(i in n){n[i].dispose(),delete n[i]}}}this.render=function(e,n,o){if(!1===_.enabled)return;if(!1===_.autoUpdate&&!1===_.needsUpdate)return;if(0===e.length)return;const l=t.getRenderTarget(),c=t.getActiveCubeFace(),h=t.getActiveMipmapLevel(),d=t.state;d.setBlending(0),d.buffers.color.setClear(1,1,1,1),d.buffers.depth.setTest(!0),d.setScissorTest(!1);const p=3!==x&&3===this.type,m=3===x&&3!==this.type;for(let l=0,c=e.length;l<c;l++){const c=e[l],h=c.shadow;if(void 0===h){console.warn("THREE.WebGLShadowMap:",c,"has no shadow.");continue}if(!1===h.autoUpdate&&!1===h.needsUpdate)continue;s.copy(h.mapSize);const f=h.getFrameExtents();if(s.multiply(f),r.copy(h.mapSize),(s.x>u||s.y>u)&&(s.x>u&&(r.x=Math.floor(u/f.x),s.x=r.x*f.x,h.mapSize.x=r.x),s.y>u&&(r.y=Math.floor(u/f.y),s.y=r.y*f.y,h.mapSize.y=r.y)),null===h.map||!0===p||!0===m){const t=3!==this.type?{minFilter:gt,magFilter:gt}:{};null!==h.map&&h.map.dispose(),h.map=new Ai(s.x,s.y,t),h.map.texture.name=c.name+".shadowMap",h.camera.updateProjectionMatrix()}t.setRenderTarget(h.map),t.clear();const g=h.getViewportCount();for(let t=0;t<g;t++){const e=h.getViewport(t);a.set(r.x*e.x,r.y*e.y,r.x*e.z,r.y*e.w),d.viewport(a),h.updateMatrices(c,t),i=h.getFrustum(),T(n,o,h.camera,c,this.type)}!0!==h.isPointLightShadow&&3===this.type&&M(h,o),h.needsUpdate=!1}x=this.type,_.needsUpdate=!1,t.setRenderTarget(l,c,h)}}const Xl={[B]:1,[H]:6,[W]:7,[G]:5,[k]:0,[X]:2,[q]:4,[j]:3};function ql(t){const e=new function(){let e=!1;const n=new wi;let i=null;const s=new wi(0,0,0,0);return{setMask:function(n){i===n||e||(t.colorMask(n,n,n,n),i=n)},setLocked:function(t){e=t},setClear:function(e,i,r,a,o){!0===o&&(e*=a,i*=a,r*=a),n.set(e,i,r,a),!1===s.equals(n)&&(t.clearColor(e,i,r,a),s.copy(n))},reset:function(){e=!1,i=null,s.set(-1,0,0,0)}}},n=new function(){let e=!1,n=!1,i=null,s=null,r=null;return{setReversed:function(t){n=t},setTest:function(e){e?it(t.DEPTH_TEST):st(t.DEPTH_TEST)},setMask:function(n){i===n||e||(t.depthMask(n),i=n)},setFunc:function(e){if(n&&(e=Xl[e]),s!==e){switch(e){case 0:t.depthFunc(t.NEVER);break;case 1:t.depthFunc(t.ALWAYS);break;case 2:t.depthFunc(t.LESS);break;case 3:default:t.depthFunc(t.LEQUAL);break;case 4:t.depthFunc(t.EQUAL);break;case 5:t.depthFunc(t.GEQUAL);break;case 6:t.depthFunc(t.GREATER);break;case 7:t.depthFunc(t.NOTEQUAL)}s=e}},setLocked:function(t){e=t},setClear:function(e){r!==e&&(t.clearDepth(e),r=e)},reset:function(){e=!1,i=null,s=null,r=null}}},i=new function(){let e=!1,n=null,i=null,s=null,r=null,a=null,o=null,l=null,c=null;return{setTest:function(n){e||(n?it(t.STENCIL_TEST):st(t.STENCIL_TEST))},setMask:function(i){n===i||e||(t.stencilMask(i),n=i)},setFunc:function(e,n,a){i===e&&s===n&&r===a||(t.stencilFunc(e,n,a),i=e,s=n,r=a)},setOp:function(e,n,i){a===e&&o===n&&l===i||(t.stencilOp(e,n,i),a=e,o=n,l=i)},setLocked:function(t){e=t},setClear:function(e){c!==e&&(t.clearStencil(e),c=e)},reset:function(){e=!1,n=null,i=null,s=null,r=null,a=null,o=null,l=null,c=null}}},s=new WeakMap,r=new WeakMap;let a={},o={},l=new WeakMap,c=[],u=null,h=!1,d=null,p=null,m=null,f=null,g=null,v=null,y=null,_=new er(0,0,0),T=0,S=!1,B=null,k=null,H=null,G=null,W=null;const j=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let X=!1,q=0;const Y=t.getParameter(t.VERSION);-1!==Y.indexOf("WebGL")?(q=parseFloat(/^WebGL (\d)/.exec(Y)[1]),X=q>=1):-1!==Y.indexOf("OpenGL ES")&&(q=parseFloat(/^OpenGL ES (\d)/.exec(Y)[1]),X=q>=2);let Z=null,$={};const J=t.getParameter(t.SCISSOR_BOX),K=t.getParameter(t.VIEWPORT),Q=(new wi).fromArray(J),tt=(new wi).fromArray(K);function et(e,n,i,s){const r=new Uint8Array(4),a=t.createTexture();t.bindTexture(e,a),t.texParameteri(e,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(e,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let a=0;a<i;a++)e===t.TEXTURE_3D||e===t.TEXTURE_2D_ARRAY?t.texImage3D(n,0,t.RGBA,1,1,s,0,t.RGBA,t.UNSIGNED_BYTE,r):t.texImage2D(n+a,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,r);return a}const nt={};function it(e){!0!==a[e]&&(t.enable(e),a[e]=!0)}function st(e){!1!==a[e]&&(t.disable(e),a[e]=!1)}nt[t.TEXTURE_2D]=et(t.TEXTURE_2D,t.TEXTURE_2D,1),nt[t.TEXTURE_CUBE_MAP]=et(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),nt[t.TEXTURE_2D_ARRAY]=et(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),nt[t.TEXTURE_3D]=et(t.TEXTURE_3D,t.TEXTURE_3D,1,1),e.setClear(0,0,0,1),n.setClear(1),i.setClear(0),it(t.DEPTH_TEST),n.setFunc(3),lt(!1),ct(1),it(t.CULL_FACE),ot(0);const rt={[x]:t.FUNC_ADD,[M]:t.FUNC_SUBTRACT,[b]:t.FUNC_REVERSE_SUBTRACT};rt[103]=t.MIN,rt[104]=t.MAX;const at={[w]:t.ZERO,[E]:t.ONE,[A]:t.SRC_COLOR,[C]:t.SRC_ALPHA,[D]:t.SRC_ALPHA_SATURATE,[P]:t.DST_COLOR,[I]:t.DST_ALPHA,[N]:t.ONE_MINUS_SRC_COLOR,[R]:t.ONE_MINUS_SRC_ALPHA,[U]:t.ONE_MINUS_DST_COLOR,[L]:t.ONE_MINUS_DST_ALPHA,[O]:t.CONSTANT_COLOR,[z]:t.ONE_MINUS_CONSTANT_COLOR,[V]:t.CONSTANT_ALPHA,[F]:t.ONE_MINUS_CONSTANT_ALPHA};function ot(e,n,i,s,r,a,o,l,c,u){if(0!==e){if(!1===h&&(it(t.BLEND),h=!0),5===e)r=r||n,a=a||i,o=o||s,n===p&&r===g||(t.blendEquationSeparate(rt[n],rt[r]),p=n,g=r),i===m&&s===f&&a===v&&o===y||(t.blendFuncSeparate(at[i],at[s],at[a],at[o]),m=i,f=s,v=a,y=o),!1!==l.equals(_)&&c===T||(t.blendColor(l.r,l.g,l.b,c),_.copy(l),T=c),d=e,S=!1;else if(e!==d||u!==S){if(p===x&&g===x||(t.blendEquation(t.FUNC_ADD),p=x,g=x),u)switch(e){case 1:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case 2:t.blendFunc(t.ONE,t.ONE);break;case 3:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case 4:t.blendFuncSeparate(t.ZERO,t.SRC_COLOR,t.ZERO,t.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",e)}else switch(e){case 1:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case 2:t.blendFunc(t.SRC_ALPHA,t.ONE);break;case 3:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case 4:t.blendFunc(t.ZERO,t.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",e)}m=null,f=null,v=null,y=null,_.set(0,0,0),T=0,d=e,S=u}}else!0===h&&(st(t.BLEND),h=!1)}function lt(e){B!==e&&(e?t.frontFace(t.CW):t.frontFace(t.CCW),B=e)}function ct(e){0!==e?(it(t.CULL_FACE),e!==k&&(1===e?t.cullFace(t.BACK):2===e?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):st(t.CULL_FACE),k=e}function ut(e,n,i){e?(it(t.POLYGON_OFFSET_FILL),G===n&&W===i||(t.polygonOffset(n,i),G=n,W=i)):st(t.POLYGON_OFFSET_FILL)}return{buffers:{color:e,depth:n,stencil:i},enable:it,disable:st,bindFramebuffer:function(e,n){return o[e]!==n&&(t.bindFramebuffer(e,n),o[e]=n,e===t.DRAW_FRAMEBUFFER&&(o[t.FRAMEBUFFER]=n),e===t.FRAMEBUFFER&&(o[t.DRAW_FRAMEBUFFER]=n),!0)},drawBuffers:function(e,n){let i=c,s=!1;if(e){i=l.get(n),void 0===i&&(i=[],l.set(n,i));const r=e.textures;if(i.length!==r.length||i[0]!==t.COLOR_ATTACHMENT0){for(let e=0,n=r.length;e<n;e++)i[e]=t.COLOR_ATTACHMENT0+e;i.length=r.length,s=!0}}else i[0]!==t.BACK&&(i[0]=t.BACK,s=!0);s&&t.drawBuffers(i)},useProgram:function(e){return u!==e&&(t.useProgram(e),u=e,!0)},setBlending:ot,setMaterial:function(s,r){2===s.side?st(t.CULL_FACE):it(t.CULL_FACE);let a=1===s.side;r&&(a=!a),lt(a),1===s.blending&&!1===s.transparent?ot(0):ot(s.blending,s.blendEquation,s.blendSrc,s.blendDst,s.blendEquationAlpha,s.blendSrcAlpha,s.blendDstAlpha,s.blendColor,s.blendAlpha,s.premultipliedAlpha),n.setFunc(s.depthFunc),n.setTest(s.depthTest),n.setMask(s.depthWrite),e.setMask(s.colorWrite);const o=s.stencilWrite;i.setTest(o),o&&(i.setMask(s.stencilWriteMask),i.setFunc(s.stencilFunc,s.stencilRef,s.stencilFuncMask),i.setOp(s.stencilFail,s.stencilZFail,s.stencilZPass)),ut(s.polygonOffset,s.polygonOffsetFactor,s.polygonOffsetUnits),!0===s.alphaToCoverage?it(t.SAMPLE_ALPHA_TO_COVERAGE):st(t.SAMPLE_ALPHA_TO_COVERAGE)},setFlipSided:lt,setCullFace:ct,setLineWidth:function(e){e!==H&&(X&&t.lineWidth(e),H=e)},setPolygonOffset:ut,setScissorTest:function(e){e?it(t.SCISSOR_TEST):st(t.SCISSOR_TEST)},activeTexture:function(e){void 0===e&&(e=t.TEXTURE0+j-1),Z!==e&&(t.activeTexture(e),Z=e)},bindTexture:function(e,n,i){void 0===i&&(i=null===Z?t.TEXTURE0+j-1:Z);let s=$[i];void 0===s&&(s={type:void 0,texture:void 0},$[i]=s),s.type===e&&s.texture===n||(Z!==i&&(t.activeTexture(i),Z=i),t.bindTexture(e,n||nt[e]),s.type=e,s.texture=n)},unbindTexture:function(){const e=$[Z];void 0!==e&&void 0!==e.type&&(t.bindTexture(e.type,null),e.type=void 0,e.texture=void 0)},compressedTexImage2D:function(){try{t.compressedTexImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},compressedTexImage3D:function(){try{t.compressedTexImage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texImage2D:function(){try{t.texImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texImage3D:function(){try{t.texImage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},updateUBOMapping:function(e,n){let i=r.get(n);void 0===i&&(i=new WeakMap,r.set(n,i));let s=i.get(e);void 0===s&&(s=t.getUniformBlockIndex(n,e.name),i.set(e,s))},uniformBlockBinding:function(e,n){const i=r.get(n).get(e);s.get(n)!==i&&(t.uniformBlockBinding(n,i,e.__bindingPointIndex),s.set(n,i))},texStorage2D:function(){try{t.texStorage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texStorage3D:function(){try{t.texStorage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texSubImage2D:function(){try{t.texSubImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texSubImage3D:function(){try{t.texSubImage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},compressedTexSubImage2D:function(){try{t.compressedTexSubImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},compressedTexSubImage3D:function(){try{t.compressedTexSubImage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},scissor:function(e){!1===Q.equals(e)&&(t.scissor(e.x,e.y,e.z,e.w),Q.copy(e))},viewport:function(e){!1===tt.equals(e)&&(t.viewport(e.x,e.y,e.z,e.w),tt.copy(e))},reset:function(){t.disable(t.BLEND),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.blendColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(t.LESS),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),a={},Z=null,$={},o={},l=new WeakMap,c=[],u=null,h=!1,d=null,p=null,m=null,f=null,g=null,v=null,y=null,_=new er(0,0,0),T=0,S=!1,B=null,k=null,H=null,G=null,W=null,Q.set(0,0,t.canvas.width,t.canvas.height),tt.set(0,0,t.canvas.width,t.canvas.height),e.reset(),n.reset(),i.reset()}}}function Yl(t,e,n,i){const s=function(t){switch(t){case Et:case At:return{byteLength:1,components:1};case Ct:case Nt:case Pt:return{byteLength:2,components:1};case Ut:case Dt:return{byteLength:2,components:4};case It:case Rt:case Lt:return{byteLength:4,components:1};case zt:case Vt:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${t}.`)}(i);switch(n){case Ft:case Ht:return t*e;case Gt:return t*e*2;case Xt:case qt:return t*e/s.components*s.byteLength;case Yt:case Zt:return t*e*2/s.components*s.byteLength;case Bt:return t*e*3/s.components*s.byteLength;case kt:case Jt:return t*e*4/s.components*s.byteLength;case Kt:case Qt:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case te:case ee:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case ie:case re:return Math.max(t,16)*Math.max(e,8)/4;case ne:case se:return Math.max(t,8)*Math.max(e,8)/2;case ae:case oe:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case le:case ce:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case ue:return Math.floor((t+4)/5)*Math.floor((e+3)/4)*16;case he:return Math.floor((t+4)/5)*Math.floor((e+4)/5)*16;case de:return Math.floor((t+5)/6)*Math.floor((e+4)/5)*16;case pe:return Math.floor((t+5)/6)*Math.floor((e+5)/6)*16;case me:return Math.floor((t+7)/8)*Math.floor((e+4)/5)*16;case fe:return Math.floor((t+7)/8)*Math.floor((e+5)/6)*16;case ge:return Math.floor((t+7)/8)*Math.floor((e+7)/8)*16;case ve:return Math.floor((t+9)/10)*Math.floor((e+4)/5)*16;case ye:return Math.floor((t+9)/10)*Math.floor((e+5)/6)*16;case _e:return Math.floor((t+9)/10)*Math.floor((e+7)/8)*16;case xe:return Math.floor((t+9)/10)*Math.floor((e+9)/10)*16;case Me:return Math.floor((t+11)/12)*Math.floor((e+9)/10)*16;case be:return Math.floor((t+11)/12)*Math.floor((e+11)/12)*16;case Te:case Se:case we:return Math.ceil(t/4)*Math.ceil(e/4)*16;case Ee:case Ae:return Math.ceil(t/4)*Math.ceil(e/4)*8;case Ne:case Ce:return Math.ceil(t/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${n} format.`)}const Zl={contain:function(t,e){const n=t.image&&t.image.width?t.image.width/t.image.height:1;return n>e?(t.repeat.x=1,t.repeat.y=n/e,t.offset.x=0,t.offset.y=(1-t.repeat.y)/2):(t.repeat.x=e/n,t.repeat.y=1,t.offset.x=(1-t.repeat.x)/2,t.offset.y=0),t},cover:function(t,e){const n=t.image&&t.image.width?t.image.width/t.image.height:1;return n>e?(t.repeat.x=e/n,t.repeat.y=1,t.offset.x=(1-t.repeat.x)/2,t.offset.y=0):(t.repeat.x=1,t.repeat.y=n/e,t.offset.x=0,t.offset.y=(1-t.repeat.y)/2),t},fill:function(t){return t.repeat.x=1,t.repeat.y=1,t.offset.x=0,t.offset.y=0,t},getByteLength:Yl};function $l(t,e,n,i,s,r,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),c=new ei,u=new WeakMap;let h;const d=new WeakMap;let p=!1;try{p="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(t){}function m(t,e){return p?new OffscreenCanvas(t,e):oi("canvas")}function f(t,e,n){let i=1;const s=B(t);if((s.width>n||s.height>n)&&(i=n/Math.max(s.width,s.height)),i<1){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap||"undefined"!=typeof VideoFrame&&t instanceof VideoFrame){const n=Math.floor(i*s.width),r=Math.floor(i*s.height);void 0===h&&(h=m(n,r));const a=e?m(n,r):h;a.width=n,a.height=r;return a.getContext("2d").drawImage(t,0,0,n,r),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+s.width+"x"+s.height+") to ("+n+"x"+r+")."),a}return"data"in t&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+s.width+"x"+s.height+")."),t}return t}function g(t){return t.generateMipmaps&&t.minFilter!==gt&&t.minFilter!==Mt}function v(e){t.generateMipmap(e)}function y(n,i,s,r,a=!1){if(null!==n){if(void 0!==t[n])return t[n];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let o=i;if(i===t.RED&&(s===t.FLOAT&&(o=t.R32F),s===t.HALF_FLOAT&&(o=t.R16F),s===t.UNSIGNED_BYTE&&(o=t.R8)),i===t.RED_INTEGER&&(s===t.UNSIGNED_BYTE&&(o=t.R8UI),s===t.UNSIGNED_SHORT&&(o=t.R16UI),s===t.UNSIGNED_INT&&(o=t.R32UI),s===t.BYTE&&(o=t.R8I),s===t.SHORT&&(o=t.R16I),s===t.INT&&(o=t.R32I)),i===t.RG&&(s===t.FLOAT&&(o=t.RG32F),s===t.HALF_FLOAT&&(o=t.RG16F),s===t.UNSIGNED_BYTE&&(o=t.RG8)),i===t.RG_INTEGER&&(s===t.UNSIGNED_BYTE&&(o=t.RG8UI),s===t.UNSIGNED_SHORT&&(o=t.RG16UI),s===t.UNSIGNED_INT&&(o=t.RG32UI),s===t.BYTE&&(o=t.RG8I),s===t.SHORT&&(o=t.RG16I),s===t.INT&&(o=t.RG32I)),i===t.RGB_INTEGER&&(s===t.UNSIGNED_BYTE&&(o=t.RGB8UI),s===t.UNSIGNED_SHORT&&(o=t.RGB16UI),s===t.UNSIGNED_INT&&(o=t.RGB32UI),s===t.BYTE&&(o=t.RGB8I),s===t.SHORT&&(o=t.RGB16I),s===t.INT&&(o=t.RGB32I)),i===t.RGBA_INTEGER&&(s===t.UNSIGNED_BYTE&&(o=t.RGBA8UI),s===t.UNSIGNED_SHORT&&(o=t.RGBA16UI),s===t.UNSIGNED_INT&&(o=t.RGBA32UI),s===t.BYTE&&(o=t.RGBA8I),s===t.SHORT&&(o=t.RGBA16I),s===t.INT&&(o=t.RGBA32I)),i===t.RGB&&(s===t.UNSIGNED_INT_5_9_9_9_REV&&(o=t.RGB9_E5),s===t.UNSIGNED_INT_10F_11F_11F_REV&&(o=t.R11F_G11F_B10F)),i===t.RGBA){const e=a?en:fi.getTransfer(r);s===t.FLOAT&&(o=t.RGBA32F),s===t.HALF_FLOAT&&(o=t.RGBA16F),s===t.UNSIGNED_BYTE&&(o=e===nn?t.SRGB8_ALPHA8:t.RGBA8),s===t.UNSIGNED_SHORT_4_4_4_4&&(o=t.RGBA4),s===t.UNSIGNED_SHORT_5_5_5_1&&(o=t.RGB5_A1)}return o!==t.R16F&&o!==t.R32F&&o!==t.RG16F&&o!==t.RG32F&&o!==t.RGBA16F&&o!==t.RGBA32F||e.get("EXT_color_buffer_float"),o}function _(e,n){let i;return e?null===n||n===It||n===Ot?i=t.DEPTH24_STENCIL8:n===Lt?i=t.DEPTH32F_STENCIL8:n===Ct&&(i=t.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):null===n||n===It||n===Ot?i=t.DEPTH_COMPONENT24:n===Lt?i=t.DEPTH_COMPONENT32F:n===Ct&&(i=t.DEPTH_COMPONENT16),i}function x(t,e){return!0===g(t)||t.isFramebufferTexture&&t.minFilter!==gt&&t.minFilter!==Mt?Math.log2(Math.max(e.width,e.height))+1:void 0!==t.mipmaps&&t.mipmaps.length>0?t.mipmaps.length:t.isCompressedTexture&&Array.isArray(t.image)?e.mipmaps.length:1}function M(t){const e=t.target;e.removeEventListener("dispose",M),function(t){const e=i.get(t);if(void 0===e.__webglInit)return;const n=t.source,s=d.get(n);if(s){const i=s[e.__cacheKey];i.usedTimes--,0===i.usedTimes&&T(t),0===Object.keys(s).length&&d.delete(n)}i.remove(t)}(e),e.isVideoTexture&&u.delete(e)}function b(e){const n=e.target;n.removeEventListener("dispose",b),function(e){const n=i.get(e);e.depthTexture&&e.depthTexture.dispose();if(e.isWebGLCubeRenderTarget)for(let e=0;e<6;e++){if(Array.isArray(n.__webglFramebuffer[e]))for(let i=0;i<n.__webglFramebuffer[e].length;i++)t.deleteFramebuffer(n.__webglFramebuffer[e][i]);else t.deleteFramebuffer(n.__webglFramebuffer[e]);n.__webglDepthbuffer&&t.deleteRenderbuffer(n.__webglDepthbuffer[e])}else{if(Array.isArray(n.__webglFramebuffer))for(let e=0;e<n.__webglFramebuffer.length;e++)t.deleteFramebuffer(n.__webglFramebuffer[e]);else t.deleteFramebuffer(n.__webglFramebuffer);if(n.__webglDepthbuffer&&t.deleteRenderbuffer(n.__webglDepthbuffer),n.__webglMultisampledFramebuffer&&t.deleteFramebuffer(n.__webglMultisampledFramebuffer),n.__webglColorRenderbuffer)for(let e=0;e<n.__webglColorRenderbuffer.length;e++)n.__webglColorRenderbuffer[e]&&t.deleteRenderbuffer(n.__webglColorRenderbuffer[e]);n.__webglDepthRenderbuffer&&t.deleteRenderbuffer(n.__webglDepthRenderbuffer)}const s=e.textures;for(let e=0,n=s.length;e<n;e++){const n=i.get(s[e]);n.__webglTexture&&(t.deleteTexture(n.__webglTexture),a.memory.textures--),i.remove(s[e])}i.remove(e)}(n)}function T(e){const n=i.get(e);t.deleteTexture(n.__webglTexture);const s=e.source;delete d.get(s)[n.__cacheKey],a.memory.textures--}let S=0;function w(e,s){const r=i.get(e);if(e.isVideoTexture&&function(t){const e=a.render.frame;u.get(t)!==e&&(u.set(t,e),t.update())}(e),!1===e.isRenderTargetTexture&&e.version>0&&r.__version!==e.version){const t=e.image;if(null===t)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==t.complete)return void I(r,e,s);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.bindTexture(t.TEXTURE_2D,r.__webglTexture,t.TEXTURE0+s)}const E={[pt]:t.REPEAT,[mt]:t.CLAMP_TO_EDGE,[ft]:t.MIRRORED_REPEAT},A={[gt]:t.NEAREST,[vt]:t.NEAREST_MIPMAP_NEAREST,[_t]:t.NEAREST_MIPMAP_LINEAR,[Mt]:t.LINEAR,[bt]:t.LINEAR_MIPMAP_NEAREST,[St]:t.LINEAR_MIPMAP_LINEAR},N={[bn]:t.NEVER,[Cn]:t.ALWAYS,[Tn]:t.LESS,[wn]:t.LEQUAL,[Sn]:t.EQUAL,[Nn]:t.GEQUAL,[En]:t.GREATER,[An]:t.NOTEQUAL};function C(n,r){if(r.type!==Lt||!1!==e.has("OES_texture_float_linear")||r.magFilter!==Mt&&r.magFilter!==bt&&r.magFilter!==_t&&r.magFilter!==St&&r.minFilter!==Mt&&r.minFilter!==bt&&r.minFilter!==_t&&r.minFilter!==St||console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),t.texParameteri(n,t.TEXTURE_WRAP_S,E[r.wrapS]),t.texParameteri(n,t.TEXTURE_WRAP_T,E[r.wrapT]),n!==t.TEXTURE_3D&&n!==t.TEXTURE_2D_ARRAY||t.texParameteri(n,t.TEXTURE_WRAP_R,E[r.wrapR]),t.texParameteri(n,t.TEXTURE_MAG_FILTER,A[r.magFilter]),t.texParameteri(n,t.TEXTURE_MIN_FILTER,A[r.minFilter]),r.compareFunction&&(t.texParameteri(n,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(n,t.TEXTURE_COMPARE_FUNC,N[r.compareFunction])),!0===e.has("EXT_texture_filter_anisotropic")){if(r.magFilter===gt)return;if(r.minFilter!==_t&&r.minFilter!==St)return;if(r.type===Lt&&!1===e.has("OES_texture_float_linear"))return;if(r.anisotropy>1||i.get(r).__currentAnisotropy){const a=e.get("EXT_texture_filter_anisotropic");t.texParameterf(n,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(r.anisotropy,s.getMaxAnisotropy())),i.get(r).__currentAnisotropy=r.anisotropy}}}function R(e,n){let i=!1;void 0===e.__webglInit&&(e.__webglInit=!0,n.addEventListener("dispose",M));const s=n.source;let r=d.get(s);void 0===r&&(r={},d.set(s,r));const o=function(t){const e=[];return e.push(t.wrapS),e.push(t.wrapT),e.push(t.wrapR||0),e.push(t.magFilter),e.push(t.minFilter),e.push(t.anisotropy),e.push(t.internalFormat),e.push(t.format),e.push(t.type),e.push(t.generateMipmaps),e.push(t.premultiplyAlpha),e.push(t.flipY),e.push(t.unpackAlignment),e.push(t.colorSpace),e.join()}(n);if(o!==e.__cacheKey){void 0===r[o]&&(r[o]={texture:t.createTexture(),usedTimes:0},a.memory.textures++,i=!0),r[o].usedTimes++;const s=r[e.__cacheKey];void 0!==s&&(r[e.__cacheKey].usedTimes--,0===s.usedTimes&&T(n)),e.__cacheKey=o,e.__webglTexture=r[o].texture}return i}function I(e,a,o){let l=t.TEXTURE_2D;(a.isDataArrayTexture||a.isCompressedArrayTexture)&&(l=t.TEXTURE_2D_ARRAY),a.isData3DTexture&&(l=t.TEXTURE_3D);const c=R(e,a),u=a.source;n.bindTexture(l,e.__webglTexture,t.TEXTURE0+o);const h=i.get(u);if(u.version!==h.__version||!0===c){n.activeTexture(t.TEXTURE0+o);const e=fi.getPrimaries(fi.workingColorSpace),i=a.colorSpace===$e?null:fi.getPrimaries(a.colorSpace),d=a.colorSpace===$e||e===i?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,a.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,a.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,d);let p=f(a.image,!1,s.maxTextureSize);p=F(a,p);const m=r.convert(a.format,a.colorSpace),M=r.convert(a.type);let b,T=y(a.internalFormat,m,M,a.colorSpace,a.isVideoTexture);C(l,a);const S=a.mipmaps,w=!0!==a.isVideoTexture,E=void 0===h.__version||!0===c,A=u.dataReady,N=x(a,p);if(a.isDepthTexture)T=_(a.format===jt,a.type),E&&(w?n.texStorage2D(t.TEXTURE_2D,1,T,p.width,p.height):n.texImage2D(t.TEXTURE_2D,0,T,p.width,p.height,0,m,M,null));else if(a.isDataTexture)if(S.length>0){w&&E&&n.texStorage2D(t.TEXTURE_2D,N,T,S[0].width,S[0].height);for(let e=0,i=S.length;e<i;e++)b=S[e],w?A&&n.texSubImage2D(t.TEXTURE_2D,e,0,0,b.width,b.height,m,M,b.data):n.texImage2D(t.TEXTURE_2D,e,T,b.width,b.height,0,m,M,b.data);a.generateMipmaps=!1}else w?(E&&n.texStorage2D(t.TEXTURE_2D,N,T,p.width,p.height),A&&n.texSubImage2D(t.TEXTURE_2D,0,0,0,p.width,p.height,m,M,p.data)):n.texImage2D(t.TEXTURE_2D,0,T,p.width,p.height,0,m,M,p.data);else if(a.isCompressedTexture)if(a.isCompressedArrayTexture){w&&E&&n.texStorage3D(t.TEXTURE_2D_ARRAY,N,T,S[0].width,S[0].height,p.depth);for(let e=0,i=S.length;e<i;e++)if(b=S[e],a.format!==kt)if(null!==m)if(w){if(A)if(a.layerUpdates.size>0){const i=Yl(b.width,b.height,a.format,a.type);for(const s of a.layerUpdates){const r=b.data.subarray(s*i/b.data.BYTES_PER_ELEMENT,(s+1)*i/b.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,s,b.width,b.height,1,m,r,0,0)}a.clearLayerUpdates()}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,0,b.width,b.height,p.depth,m,b.data,0,0)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,e,T,b.width,b.height,p.depth,0,b.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else w?A&&n.texSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,0,b.width,b.height,p.depth,m,M,b.data):n.texImage3D(t.TEXTURE_2D_ARRAY,e,T,b.width,b.height,p.depth,0,m,M,b.data)}else{w&&E&&n.texStorage2D(t.TEXTURE_2D,N,T,S[0].width,S[0].height);for(let e=0,i=S.length;e<i;e++)b=S[e],a.format!==kt?null!==m?w?A&&n.compressedTexSubImage2D(t.TEXTURE_2D,e,0,0,b.width,b.height,m,b.data):n.compressedTexImage2D(t.TEXTURE_2D,e,T,b.width,b.height,0,b.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):w?A&&n.texSubImage2D(t.TEXTURE_2D,e,0,0,b.width,b.height,m,M,b.data):n.texImage2D(t.TEXTURE_2D,e,T,b.width,b.height,0,m,M,b.data)}else if(a.isDataArrayTexture)if(w){if(E&&n.texStorage3D(t.TEXTURE_2D_ARRAY,N,T,p.width,p.height,p.depth),A)if(a.layerUpdates.size>0){const e=Yl(p.width,p.height,a.format,a.type);for(const i of a.layerUpdates){const s=p.data.subarray(i*e/p.data.BYTES_PER_ELEMENT,(i+1)*e/p.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,i,p.width,p.height,1,m,M,s)}a.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,p.width,p.height,p.depth,m,M,p.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,T,p.width,p.height,p.depth,0,m,M,p.data);else if(a.isData3DTexture)w?(E&&n.texStorage3D(t.TEXTURE_3D,N,T,p.width,p.height,p.depth),A&&n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,p.width,p.height,p.depth,m,M,p.data)):n.texImage3D(t.TEXTURE_3D,0,T,p.width,p.height,p.depth,0,m,M,p.data);else if(a.isFramebufferTexture){if(E)if(w)n.texStorage2D(t.TEXTURE_2D,N,T,p.width,p.height);else{let e=p.width,i=p.height;for(let s=0;s<N;s++)n.texImage2D(t.TEXTURE_2D,s,T,e,i,0,m,M,null),e>>=1,i>>=1}}else if(S.length>0){if(w&&E){const e=B(S[0]);n.texStorage2D(t.TEXTURE_2D,N,T,e.width,e.height)}for(let e=0,i=S.length;e<i;e++)b=S[e],w?A&&n.texSubImage2D(t.TEXTURE_2D,e,0,0,m,M,b):n.texImage2D(t.TEXTURE_2D,e,T,m,M,b);a.generateMipmaps=!1}else if(w){if(E){const e=B(p);n.texStorage2D(t.TEXTURE_2D,N,T,e.width,e.height)}A&&n.texSubImage2D(t.TEXTURE_2D,0,0,0,m,M,p)}else n.texImage2D(t.TEXTURE_2D,0,T,m,M,p);g(a)&&v(l),h.__version=u.version,a.onUpdate&&a.onUpdate(a)}e.__version=a.version}function L(e,s,a,l,c,u){const h=r.convert(a.format,a.colorSpace),d=r.convert(a.type),p=y(a.internalFormat,h,d,a.colorSpace);if(!i.get(s).__hasExternalTextures){const e=Math.max(1,s.width>>u),i=Math.max(1,s.height>>u);c===t.TEXTURE_3D||c===t.TEXTURE_2D_ARRAY?n.texImage3D(c,u,p,e,i,s.depth,0,h,d,null):n.texImage2D(c,u,p,e,i,0,h,d,null)}n.bindFramebuffer(t.FRAMEBUFFER,e),V(s)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,l,c,i.get(a).__webglTexture,0,z(s)):(c===t.TEXTURE_2D||c>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&c<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,l,c,i.get(a).__webglTexture,u),n.bindFramebuffer(t.FRAMEBUFFER,null)}function P(e,n,i){if(t.bindRenderbuffer(t.RENDERBUFFER,e),n.depthBuffer){const s=n.depthTexture,r=s&&s.isDepthTexture?s.type:null,a=_(n.stencilBuffer,r),l=n.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,c=z(n);V(n)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,c,a,n.width,n.height):i?t.renderbufferStorageMultisample(t.RENDERBUFFER,c,a,n.width,n.height):t.renderbufferStorage(t.RENDERBUFFER,a,n.width,n.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,l,t.RENDERBUFFER,e)}else{const e=n.textures;for(let s=0;s<e.length;s++){const a=e[s],l=r.convert(a.format,a.colorSpace),c=r.convert(a.type),u=y(a.internalFormat,l,c,a.colorSpace),h=z(n);i&&!1===V(n)?t.renderbufferStorageMultisample(t.RENDERBUFFER,h,u,n.width,n.height):V(n)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,h,u,n.width,n.height):t.renderbufferStorage(t.RENDERBUFFER,u,n.width,n.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function U(e){const s=i.get(e),r=!0===e.isWebGLCubeRenderTarget;if(s.__boundDepthTexture!==e.depthTexture){const t=e.depthTexture;if(s.__depthDisposeCallback&&s.__depthDisposeCallback(),t){const e=()=>{delete s.__boundDepthTexture,delete s.__depthDisposeCallback,t.removeEventListener("dispose",e)};t.addEventListener("dispose",e),s.__depthDisposeCallback=e}s.__boundDepthTexture=t}if(e.depthTexture&&!s.__autoAllocateDepthBuffer){if(r)throw new Error("target.depthTexture not supported in Cube render targets");!function(e,s){if(s&&s.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,e),!s.depthTexture||!s.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");i.get(s.depthTexture).__webglTexture&&s.depthTexture.image.width===s.width&&s.depthTexture.image.height===s.height||(s.depthTexture.image.width=s.width,s.depthTexture.image.height=s.height,s.depthTexture.needsUpdate=!0),w(s.depthTexture,0);const r=i.get(s.depthTexture).__webglTexture,a=z(s);if(s.depthTexture.format===Wt)V(s)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,r,0,a):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,r,0);else{if(s.depthTexture.format!==jt)throw new Error("Unknown depthTexture format");V(s)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,r,0,a):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,r,0)}}(s.__webglFramebuffer,e)}else if(r){s.__webglDepthbuffer=[];for(let i=0;i<6;i++)if(n.bindFramebuffer(t.FRAMEBUFFER,s.__webglFramebuffer[i]),void 0===s.__webglDepthbuffer[i])s.__webglDepthbuffer[i]=t.createRenderbuffer(),P(s.__webglDepthbuffer[i],e,!1);else{const n=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,r=s.__webglDepthbuffer[i];t.bindRenderbuffer(t.RENDERBUFFER,r),t.framebufferRenderbuffer(t.FRAMEBUFFER,n,t.RENDERBUFFER,r)}}else if(n.bindFramebuffer(t.FRAMEBUFFER,s.__webglFramebuffer),void 0===s.__webglDepthbuffer)s.__webglDepthbuffer=t.createRenderbuffer(),P(s.__webglDepthbuffer,e,!1);else{const n=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,i=s.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,i),t.framebufferRenderbuffer(t.FRAMEBUFFER,n,t.RENDERBUFFER,i)}n.bindFramebuffer(t.FRAMEBUFFER,null)}const D=[],O=[];function z(t){return Math.min(s.maxSamples,t.samples)}function V(t){const n=i.get(t);return t.samples>0&&!0===e.has("WEBGL_multisampled_render_to_texture")&&!1!==n.__useRenderToTexture}function F(t,e){const n=t.colorSpace,i=t.format,s=t.type;return!0===t.isCompressedTexture||!0===t.isVideoTexture||n!==Ke&&n!==$e&&(fi.getTransfer(n)===nn?i===kt&&s===Et||console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",n)),e}function B(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement?(c.width=t.naturalWidth||t.width,c.height=t.naturalHeight||t.height):"undefined"!=typeof VideoFrame&&t instanceof VideoFrame?(c.width=t.displayWidth,c.height=t.displayHeight):(c.width=t.width,c.height=t.height),c}this.allocateTextureUnit=function(){const t=S;return t>=s.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+t+" texture units while this GPU supports only "+s.maxTextures),S+=1,t},this.resetTextureUnits=function(){S=0},this.setTexture2D=w,this.setTexture2DArray=function(e,s){const r=i.get(e);e.version>0&&r.__version!==e.version?I(r,e,s):n.bindTexture(t.TEXTURE_2D_ARRAY,r.__webglTexture,t.TEXTURE0+s)},this.setTexture3D=function(e,s){const r=i.get(e);e.version>0&&r.__version!==e.version?I(r,e,s):n.bindTexture(t.TEXTURE_3D,r.__webglTexture,t.TEXTURE0+s)},this.setTextureCube=function(e,a){const o=i.get(e);e.version>0&&o.__version!==e.version?function(e,a,o){if(6!==a.image.length)return;const l=R(e,a),c=a.source;n.bindTexture(t.TEXTURE_CUBE_MAP,e.__webglTexture,t.TEXTURE0+o);const u=i.get(c);if(c.version!==u.__version||!0===l){n.activeTexture(t.TEXTURE0+o);const e=fi.getPrimaries(fi.workingColorSpace),i=a.colorSpace===$e?null:fi.getPrimaries(a.colorSpace),h=a.colorSpace===$e||e===i?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,a.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,a.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,h);const d=a.isCompressedTexture||a.image[0].isCompressedTexture,p=a.image[0]&&a.image[0].isDataTexture,m=[];for(let t=0;t<6;t++)m[t]=d||p?p?a.image[t].image:a.image[t]:f(a.image[t],!0,s.maxCubemapSize),m[t]=F(a,m[t]);const _=m[0],M=r.convert(a.format,a.colorSpace),b=r.convert(a.type),T=y(a.internalFormat,M,b,a.colorSpace),S=!0!==a.isVideoTexture,w=void 0===u.__version||!0===l,E=c.dataReady;let A,N=x(a,_);if(C(t.TEXTURE_CUBE_MAP,a),d){S&&w&&n.texStorage2D(t.TEXTURE_CUBE_MAP,N,T,_.width,_.height);for(let e=0;e<6;e++){A=m[e].mipmaps;for(let i=0;i<A.length;i++){const s=A[i];a.format!==kt?null!==M?S?E&&n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i,0,0,s.width,s.height,M,s.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i,T,s.width,s.height,0,s.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):S?E&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i,0,0,s.width,s.height,M,b,s.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i,T,s.width,s.height,0,M,b,s.data)}}}else{if(A=a.mipmaps,S&&w){A.length>0&&N++;const e=B(m[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,N,T,e.width,e.height)}for(let e=0;e<6;e++)if(p){S?E&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,m[e].width,m[e].height,M,b,m[e].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,T,m[e].width,m[e].height,0,M,b,m[e].data);for(let i=0;i<A.length;i++){const s=A[i].image[e].image;S?E&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i+1,0,0,s.width,s.height,M,b,s.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i+1,T,s.width,s.height,0,M,b,s.data)}}else{S?E&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,M,b,m[e]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,T,M,b,m[e]);for(let i=0;i<A.length;i++){const s=A[i];S?E&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i+1,0,0,M,b,s.image[e]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i+1,T,M,b,s.image[e])}}}g(a)&&v(t.TEXTURE_CUBE_MAP),u.__version=c.version,a.onUpdate&&a.onUpdate(a)}e.__version=a.version}(o,e,a):n.bindTexture(t.TEXTURE_CUBE_MAP,o.__webglTexture,t.TEXTURE0+a)},this.rebindTextures=function(e,n,s){const r=i.get(e);void 0!==n&&L(r.__webglFramebuffer,e,e.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),void 0!==s&&U(e)},this.setupRenderTarget=function(e){const s=e.texture,o=i.get(e),l=i.get(s);e.addEventListener("dispose",b);const c=e.textures,u=!0===e.isWebGLCubeRenderTarget,h=c.length>1;if(h||(void 0===l.__webglTexture&&(l.__webglTexture=t.createTexture()),l.__version=s.version,a.memory.textures++),u){o.__webglFramebuffer=[];for(let e=0;e<6;e++)if(s.mipmaps&&s.mipmaps.length>0){o.__webglFramebuffer[e]=[];for(let n=0;n<s.mipmaps.length;n++)o.__webglFramebuffer[e][n]=t.createFramebuffer()}else o.__webglFramebuffer[e]=t.createFramebuffer()}else{if(s.mipmaps&&s.mipmaps.length>0){o.__webglFramebuffer=[];for(let e=0;e<s.mipmaps.length;e++)o.__webglFramebuffer[e]=t.createFramebuffer()}else o.__webglFramebuffer=t.createFramebuffer();if(h)for(let e=0,n=c.length;e<n;e++){const n=i.get(c[e]);void 0===n.__webglTexture&&(n.__webglTexture=t.createTexture(),a.memory.textures++)}if(e.samples>0&&!1===V(e)){o.__webglMultisampledFramebuffer=t.createFramebuffer(),o.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,o.__webglMultisampledFramebuffer);for(let n=0;n<c.length;n++){const i=c[n];o.__webglColorRenderbuffer[n]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,o.__webglColorRenderbuffer[n]);const s=r.convert(i.format,i.colorSpace),a=r.convert(i.type),l=y(i.internalFormat,s,a,i.colorSpace,!0===e.isXRRenderTarget),u=z(e);t.renderbufferStorageMultisample(t.RENDERBUFFER,u,l,e.width,e.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+n,t.RENDERBUFFER,o.__webglColorRenderbuffer[n])}t.bindRenderbuffer(t.RENDERBUFFER,null),e.depthBuffer&&(o.__webglDepthRenderbuffer=t.createRenderbuffer(),P(o.__webglDepthRenderbuffer,e,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(u){n.bindTexture(t.TEXTURE_CUBE_MAP,l.__webglTexture),C(t.TEXTURE_CUBE_MAP,s);for(let n=0;n<6;n++)if(s.mipmaps&&s.mipmaps.length>0)for(let i=0;i<s.mipmaps.length;i++)L(o.__webglFramebuffer[n][i],e,s,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+n,i);else L(o.__webglFramebuffer[n],e,s,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+n,0);g(s)&&v(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(h){for(let s=0,r=c.length;s<r;s++){const r=c[s],a=i.get(r);n.bindTexture(t.TEXTURE_2D,a.__webglTexture),C(t.TEXTURE_2D,r),L(o.__webglFramebuffer,e,r,t.COLOR_ATTACHMENT0+s,t.TEXTURE_2D,0),g(r)&&v(t.TEXTURE_2D)}n.unbindTexture()}else{let i=t.TEXTURE_2D;if((e.isWebGL3DRenderTarget||e.isWebGLArrayRenderTarget)&&(i=e.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(i,l.__webglTexture),C(i,s),s.mipmaps&&s.mipmaps.length>0)for(let n=0;n<s.mipmaps.length;n++)L(o.__webglFramebuffer[n],e,s,t.COLOR_ATTACHMENT0,i,n);else L(o.__webglFramebuffer,e,s,t.COLOR_ATTACHMENT0,i,0);g(s)&&v(i),n.unbindTexture()}e.depthBuffer&&U(e)},this.updateRenderTargetMipmap=function(e){const s=e.textures;for(let r=0,a=s.length;r<a;r++){const a=s[r];if(g(a)){const s=e.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,r=i.get(a).__webglTexture;n.bindTexture(s,r),v(s),n.unbindTexture()}}},this.updateMultisampleRenderTarget=function(e){if(e.samples>0)if(!1===V(e)){const s=e.textures,r=e.width,a=e.height;let o=t.COLOR_BUFFER_BIT;const c=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,u=i.get(e),h=s.length>1;if(h)for(let e=0;e<s.length;e++)n.bindFramebuffer(t.FRAMEBUFFER,u.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,u.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,u.__webglMultisampledFramebuffer),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,u.__webglFramebuffer);for(let n=0;n<s.length;n++){if(e.resolveDepthBuffer&&(e.depthBuffer&&(o|=t.DEPTH_BUFFER_BIT),e.stencilBuffer&&e.resolveStencilBuffer&&(o|=t.STENCIL_BUFFER_BIT)),h){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,u.__webglColorRenderbuffer[n]);const e=i.get(s[n]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0)}t.blitFramebuffer(0,0,r,a,0,0,r,a,o,t.NEAREST),!0===l&&(D.length=0,O.length=0,D.push(t.COLOR_ATTACHMENT0+n),e.depthBuffer&&!1===e.resolveDepthBuffer&&(D.push(c),O.push(c),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,O)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,D))}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),h)for(let e=0;e<s.length;e++){n.bindFramebuffer(t.FRAMEBUFFER,u.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.RENDERBUFFER,u.__webglColorRenderbuffer[e]);const r=i.get(s[e]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,u.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,r,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,u.__webglMultisampledFramebuffer)}else if(e.depthBuffer&&!1===e.resolveDepthBuffer&&l){const n=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[n])}},this.setupDepthRenderbuffer=U,this.setupFrameBufferTexture=L,this.useMultisampledRTT=V}function Jl(t,e){return{convert:function(n,i=""){let s;const r=fi.getTransfer(i);if(n===Et)return t.UNSIGNED_BYTE;if(n===Ut)return t.UNSIGNED_SHORT_4_4_4_4;if(n===Dt)return t.UNSIGNED_SHORT_5_5_5_1;if(n===zt)return t.UNSIGNED_INT_5_9_9_9_REV;if(n===Vt)return t.UNSIGNED_INT_10F_11F_11F_REV;if(n===At)return t.BYTE;if(n===Nt)return t.SHORT;if(n===Ct)return t.UNSIGNED_SHORT;if(n===Rt)return t.INT;if(n===It)return t.UNSIGNED_INT;if(n===Lt)return t.FLOAT;if(n===Pt)return t.HALF_FLOAT;if(n===Ft)return t.ALPHA;if(n===Bt)return t.RGB;if(n===kt)return t.RGBA;if(n===Ht)return t.LUMINANCE;if(n===Gt)return t.LUMINANCE_ALPHA;if(n===Wt)return t.DEPTH_COMPONENT;if(n===jt)return t.DEPTH_STENCIL;if(n===Xt)return t.RED;if(n===qt)return t.RED_INTEGER;if(n===Yt)return t.RG;if(n===Zt)return t.RG_INTEGER;if(n===Jt)return t.RGBA_INTEGER;if(n===Kt||n===Qt||n===te||n===ee)if(r===nn){if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),null===s)return null;if(n===Kt)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Qt)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===te)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===ee)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(s=e.get("WEBGL_compressed_texture_s3tc"),null===s)return null;if(n===Kt)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Qt)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===te)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===ee)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(n===ne||n===ie||n===se||n===re){if(s=e.get("WEBGL_compressed_texture_pvrtc"),null===s)return null;if(n===ne)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===ie)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===se)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===re)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(n===ae||n===oe||n===le){if(s=e.get("WEBGL_compressed_texture_etc"),null===s)return null;if(n===ae||n===oe)return r===nn?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(n===le)return r===nn?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}if(n===ce||n===ue||n===he||n===de||n===pe||n===me||n===fe||n===ge||n===ve||n===ye||n===_e||n===xe||n===Me||n===be){if(s=e.get("WEBGL_compressed_texture_astc"),null===s)return null;if(n===ce)return r===nn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===ue)return r===nn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===he)return r===nn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===de)return r===nn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===pe)return r===nn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===me)return r===nn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===fe)return r===nn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===ge)return r===nn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===ve)return r===nn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===ye)return r===nn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===_e)return r===nn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===xe)return r===nn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Me)return r===nn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===be)return r===nn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}if(n===Te||n===Se||n===we){if(s=e.get("EXT_texture_compression_bptc"),null===s)return null;if(n===Te)return r===nn?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Se)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===we)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}if(n===Ee||n===Ae||n===Ne||n===Ce){if(s=e.get("EXT_texture_compression_rgtc"),null===s)return null;if(n===Te)return s.COMPRESSED_RED_RGTC1_EXT;if(n===Ae)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Ne)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Ce)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return n===Ot?t.UNSIGNED_INT_24_8:void 0!==t[n]?t[n]:null}}}class Kl extends ia{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}}class Ql extends Os{constructor(){super(),this.isGroup=!0,this.type="Group"}}const tc={type:"move"};class ec{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new Ql,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return null===this._targetRay&&(this._targetRay=new Ql,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Pi,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Pi),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new Ql,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Pi,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Pi),this._grip}dispatchEvent(t){return null!==this._targetRay&&this._targetRay.dispatchEvent(t),null!==this._grip&&this._grip.dispatchEvent(t),null!==this._hand&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){const e=this._hand;if(e)for(const n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this}update(t,e,n){let i=null,s=null,r=null;const a=this._targetRay,o=this._grip,l=this._hand;if(t&&"visible-blurred"!==e.session.visibilityState){if(l&&t.hand){r=!0;for(const i of t.hand.values()){const t=e.getJointPose(i,n),s=this._getHandJoint(l,i);null!==t&&(s.matrix.fromArray(t.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),s.matrixWorldNeedsUpdate=!0,s.jointRadius=t.radius),s.visible=null!==t}const i=l.joints["index-finger-tip"],s=l.joints["thumb-tip"],a=i.position.distanceTo(s.position),o=.02,c=.005;l.inputState.pinching&&a>o+c?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!l.inputState.pinching&&a<=o-c&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else null!==o&&t.gripSpace&&(s=e.getPose(t.gripSpace,n),null!==s&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1));null!==a&&(i=e.getPose(t.targetRaySpace,n),null===i&&null!==s&&(i=s),null!==i&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(tc)))}return null!==a&&(a.visible=null!==i),null!==o&&(o.visible=null!==s),null!==l&&(l.visible=null!==r),this}_getHandJoint(t,e){if(void 0===t.joints[e.jointName]){const n=new Ql;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}}class nc{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e,n){if(null===this.texture){const i=new Si;t.properties.get(i).__webglTexture=e.texture,e.depthNear==n.depthNear&&e.depthFar==n.depthFar||(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(t){if(null!==this.texture&&null===this.mesh){const e=t.cameras[0].viewport,n=new Zr({vertexShader:"\nvoid main() {\n\n\tgl_Position = vec4( position, 1.0 );\n\n}",fragmentShader:"\nuniform sampler2DArray depthColor;\nuniform float depthWidth;\nuniform float depthHeight;\n\nvoid main() {\n\n\tvec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );\n\n\tif ( coord.x >= 1.0 ) {\n\n\t\tgl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;\n\n\t} else {\n\n\t\tgl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;\n\n\t}\n\n}",uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new Hr(new va(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class ic extends Gn{constructor(t,e){super();const n=this;let i=null,s=1,r=null,a="local-floor",o=1,l=null,c=null,u=null,h=null,d=null,p=null;const m=new nc,f=e.getContextAttributes();let g=null,v=null;const y=[],_=[],x=new ei;let M=null;const b=new ia;b.layers.enable(1),b.viewport=new wi;const T=new ia;T.layers.enable(2),T.viewport=new wi;const S=[b,T],w=new Kl;w.layers.enable(1),w.layers.enable(2);let E=null,A=null;function N(t){const e=_.indexOf(t.inputSource);if(-1===e)return;const n=y[e];void 0!==n&&(n.update(t.inputSource,t.frame,l||r),n.dispatchEvent({type:t.type,data:t.inputSource}))}function C(){i.removeEventListener("select",N),i.removeEventListener("selectstart",N),i.removeEventListener("selectend",N),i.removeEventListener("squeeze",N),i.removeEventListener("squeezestart",N),i.removeEventListener("squeezeend",N),i.removeEventListener("end",C),i.removeEventListener("inputsourceschange",R);for(let t=0;t<y.length;t++){const e=_[t];null!==e&&(_[t]=null,y[t]&&y[t].disconnect(e))}E=null,A=null,m.reset(),t.setRenderTarget(g),d=null,h=null,u=null,i=null,v=null,D.stop(),n.isPresenting=!1,t.setPixelRatio(M),t.setSize(x.width,x.height,!1),n.dispatchEvent({type:"sessionend"})}function R(t){for(let e=0;e<t.removed.length;e++){const n=t.removed[e],i=_.indexOf(n);i>=0&&(_[i]=null,y[i]&&y[i].disconnect(n))}for(let e=0;e<t.added.length;e++){const n=t.added[e];let i=_.indexOf(n);if(-1===i){for(let t=0;t<y.length;t++){if(t>=_.length){_.push(n),i=t;break}if(null===_[t]){_[t]=n,i=t;break}}if(-1===i)break}const s=y[i];s&&s.connect(n)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.controllerAutoUpdate=!0,this.getController=function(t){let e=y[t];return void 0===e&&(e=new ec,y[t]=e),e.getTargetRaySpace()},this.getControllerGrip=function(t){let e=y[t];return void 0===e&&(e=new ec,y[t]=e),e.getGripSpace()},this.getHand=function(t){let e=y[t];return void 0===e&&(e=new ec,y[t]=e),e.getHandSpace()},this.setFramebufferScaleFactor=function(t){s=t,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(t){a=t,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||r},this.setReferenceSpace=function(t){l=t},this.getBaseLayer=function(){return null!==h?h:d},this.getBinding=function(){return u},this.getFrame=function(){return p},this.getSession=function(){return i},this.setSession=async function(c){if(i=c,null!==i){g=t.getRenderTarget(),i.addEventListener("select",N),i.addEventListener("selectstart",N),i.addEventListener("selectend",N),i.addEventListener("squeeze",N),i.addEventListener("squeezestart",N),i.addEventListener("squeezeend",N),i.addEventListener("end",C),i.addEventListener("inputsourceschange",R),!0!==f.xrCompatible&&await e.makeXRCompatible(),M=t.getPixelRatio(),t.getSize(x);if("undefined"!=typeof XRWebGLBinding&&"createProjectionLayer"in XRWebGLBinding.prototype){let n=null,r=null,a=null;f.depth&&(a=f.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,n=f.stencil?jt:Wt,r=f.stencil?Ot:It);const o={colorFormat:e.RGBA8,depthFormat:a,scaleFactor:s};u=new XRWebGLBinding(i,e),h=u.createProjectionLayer(o),i.updateRenderState({layers:[h]}),t.setPixelRatio(1),t.setSize(h.textureWidth,h.textureHeight,!1),v=new Ai(h.textureWidth,h.textureHeight,{format:kt,type:Et,depthTexture:new no(h.textureWidth,h.textureHeight,r,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:f.stencil,colorSpace:t.outputColorSpace,samples:f.antialias?4:0,resolveDepthBuffer:!1===h.ignoreDepthValues})}else{const n={antialias:f.antialias,alpha:!0,depth:f.depth,stencil:f.stencil,framebufferScaleFactor:s};d=new XRWebGLLayer(i,e,n),i.updateRenderState({baseLayer:d}),t.setPixelRatio(1),t.setSize(d.framebufferWidth,d.framebufferHeight,!1),v=new Ai(d.framebufferWidth,d.framebufferHeight,{format:kt,type:Et,colorSpace:t.outputColorSpace,stencilBuffer:f.stencil})}v.isXRRenderTarget=!0,this.setFoveation(o),l=null,r=await i.requestReferenceSpace(a),D.setContext(i),D.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==i)return i.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};const I=new Pi,L=new Pi;function P(t,e){null===e?t.matrixWorld.copy(t.matrix):t.matrixWorld.multiplyMatrices(e.matrixWorld,t.matrix),t.matrixWorldInverse.copy(t.matrixWorld).invert()}this.updateCamera=function(t){if(null===i)return;let e=t.near,n=t.far;null!==m.texture&&(m.depthNear>0&&(e=m.depthNear),m.depthFar>0&&(n=m.depthFar)),w.near=T.near=b.near=e,w.far=T.far=b.far=n,E===w.near&&A===w.far||(i.updateRenderState({depthNear:w.near,depthFar:w.far}),E=w.near,A=w.far);const s=t.parent,r=w.cameras;P(w,s);for(let t=0;t<r.length;t++)P(r[t],s);2===r.length?function(t,e,n){I.setFromMatrixPosition(e.matrixWorld),L.setFromMatrixPosition(n.matrixWorld);const i=I.distanceTo(L),s=e.projectionMatrix.elements,r=n.projectionMatrix.elements,a=s[14]/(s[10]-1),o=s[14]/(s[10]+1),l=(s[9]+1)/s[5],c=(s[9]-1)/s[5],u=(s[8]-1)/s[0],h=(r[8]+1)/r[0],d=a*u,p=a*h,m=i/(-u+h),f=m*-u;if(e.matrixWorld.decompose(t.position,t.quaternion,t.scale),t.translateX(f),t.translateZ(m),t.matrixWorld.compose(t.position,t.quaternion,t.scale),t.matrixWorldInverse.copy(t.matrixWorld).invert(),-1===s[10])t.projectionMatrix.copy(e.projectionMatrix),t.projectionMatrixInverse.copy(e.projectionMatrixInverse);else{const e=a+m,n=o+m,s=d-f,r=p+(i-f),u=l*o/n*e,h=c*o/n*e;t.projectionMatrix.makePerspective(s,r,u,h,e,n),t.projectionMatrixInverse.copy(t.projectionMatrix).invert()}}(w,b,T):w.projectionMatrix.copy(b.projectionMatrix),function(t,e,n){null===n?t.matrix.copy(e.matrixWorld):(t.matrix.copy(n.matrixWorld),t.matrix.invert(),t.matrix.multiply(e.matrixWorld));t.matrix.decompose(t.position,t.quaternion,t.scale),t.updateMatrixWorld(!0),t.projectionMatrix.copy(e.projectionMatrix),t.projectionMatrixInverse.copy(e.projectionMatrixInverse),t.isPerspectiveCamera&&(t.fov=2*qn*Math.atan(1/t.projectionMatrix.elements[5]),t.zoom=1)}(t,w,s)},this.getCamera=function(){return w},this.getFoveation=function(){if(null!==h||null!==d)return o},this.setFoveation=function(t){o=t,null!==h&&(h.fixedFoveation=t),null!==d&&void 0!==d.fixedFoveation&&(d.fixedFoveation=t)},this.hasDepthSensing=function(){return null!==m.texture},this.getDepthSensingMesh=function(){return m.getMesh(w)};let U=null;const D=new fa;D.setAnimationLoop(function(e,s){if(c=s.getViewerPose(l||r),p=s,null!==c){const e=c.views;null!==d&&(t.setRenderTargetFramebuffer(v,d.framebuffer),t.setRenderTarget(v));let n=!1;e.length!==w.cameras.length&&(w.cameras.length=0,n=!0);for(let i=0;i<e.length;i++){const s=e[i];let r=null;if(null!==d)r=d.getViewport(s);else{const e=u.getViewSubImage(h,s);r=e.viewport,0===i&&(t.setRenderTargetTextures(v,e.colorTexture,h.ignoreDepthValues?void 0:e.depthStencilTexture),t.setRenderTarget(v))}let a=S[i];void 0===a&&(a=new ia,a.layers.enable(i),a.viewport=new wi,S[i]=a),a.matrix.fromArray(s.transform.matrix),a.matrix.decompose(a.position,a.quaternion,a.scale),a.projectionMatrix.fromArray(s.projectionMatrix),a.projectionMatrixInverse.copy(a.projectionMatrix).invert(),a.viewport.set(r.x,r.y,r.width,r.height),0===i&&(w.matrix.copy(a.matrix),w.matrix.decompose(w.position,w.quaternion,w.scale)),!0===n&&w.cameras.push(a)}const s=i.enabledFeatures;if(s&&s.includes("depth-sensing")){const n=u.getDepthInformation(e[0]);n&&n.isValid&&n.texture&&m.init(t,n,i.renderState)}}if(n.controllerAutoUpdate)for(let t=0;t<y.length;t++){const e=_[t],n=y[t];null!==e&&void 0!==n&&n.update(e,s,l||r)}U&&U(e,s),s.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:s}),p=null}),this.setAnimationLoop=function(t){U=t},this.dispose=function(){}}}const sc=new _s,rc=new cs;function ac(t,e){function n(t,e){!0===t.matrixAutoUpdate&&t.updateMatrix(),e.value.copy(t.matrix)}function i(t,i){t.opacity.value=i.opacity,i.color&&t.diffuse.value.copy(i.color),i.emissive&&t.emissive.value.copy(i.emissive).multiplyScalar(i.emissiveIntensity),i.map&&(t.map.value=i.map,n(i.map,t.mapTransform)),i.alphaMap&&(t.alphaMap.value=i.alphaMap,n(i.alphaMap,t.alphaMapTransform)),i.bumpMap&&(t.bumpMap.value=i.bumpMap,n(i.bumpMap,t.bumpMapTransform),t.bumpScale.value=i.bumpScale,1===i.side&&(t.bumpScale.value*=-1)),i.normalMap&&(t.normalMap.value=i.normalMap,n(i.normalMap,t.normalMapTransform),t.normalScale.value.copy(i.normalScale),1===i.side&&t.normalScale.value.negate()),i.displacementMap&&(t.displacementMap.value=i.displacementMap,n(i.displacementMap,t.displacementMapTransform),t.displacementScale.value=i.displacementScale,t.displacementBias.value=i.displacementBias),i.emissiveMap&&(t.emissiveMap.value=i.emissiveMap,n(i.emissiveMap,t.emissiveMapTransform)),i.specularMap&&(t.specularMap.value=i.specularMap,n(i.specularMap,t.specularMapTransform)),i.alphaTest>0&&(t.alphaTest.value=i.alphaTest);const s=e.get(i),r=s.envMap,a=s.envMapRotation;r&&(t.envMap.value=r,sc.copy(a),sc.x*=-1,sc.y*=-1,sc.z*=-1,r.isCubeTexture&&!1===r.isRenderTargetTexture&&(sc.y*=-1,sc.z*=-1),t.envMapRotation.value.setFromMatrix4(rc.makeRotationFromEuler(sc)),t.flipEnvMap.value=r.isCubeTexture&&!1===r.isRenderTargetTexture?-1:1,t.reflectivity.value=i.reflectivity,t.ior.value=i.ior,t.refractionRatio.value=i.refractionRatio),i.lightMap&&(t.lightMap.value=i.lightMap,t.lightMapIntensity.value=i.lightMapIntensity,n(i.lightMap,t.lightMapTransform)),i.aoMap&&(t.aoMap.value=i.aoMap,t.aoMapIntensity.value=i.aoMapIntensity,n(i.aoMap,t.aoMapTransform))}return{refreshFogUniforms:function(e,n){n.color.getRGB(e.fogColor.value,qr(t)),n.isFog?(e.fogNear.value=n.near,e.fogFar.value=n.far):n.isFogExp2&&(e.fogDensity.value=n.density)},refreshMaterialUniforms:function(t,s,r,a,o){s.isMeshBasicMaterial||s.isMeshLambertMaterial?i(t,s):s.isMeshToonMaterial?(i(t,s),function(t,e){e.gradientMap&&(t.gradientMap.value=e.gradientMap)}(t,s)):s.isMeshPhongMaterial?(i(t,s),function(t,e){t.specular.value.copy(e.specular),t.shininess.value=Math.max(e.shininess,1e-4)}(t,s)):s.isMeshStandardMaterial?(i(t,s),function(t,e){t.metalness.value=e.metalness,e.metalnessMap&&(t.metalnessMap.value=e.metalnessMap,n(e.metalnessMap,t.metalnessMapTransform));t.roughness.value=e.roughness,e.roughnessMap&&(t.roughnessMap.value=e.roughnessMap,n(e.roughnessMap,t.roughnessMapTransform));e.envMap&&(t.envMapIntensity.value=e.envMapIntensity)}(t,s),s.isMeshPhysicalMaterial&&function(t,e,i){t.ior.value=e.ior,e.sheen>0&&(t.sheenColor.value.copy(e.sheenColor).multiplyScalar(e.sheen),t.sheenRoughness.value=e.sheenRoughness,e.sheenColorMap&&(t.sheenColorMap.value=e.sheenColorMap,n(e.sheenColorMap,t.sheenColorMapTransform)),e.sheenRoughnessMap&&(t.sheenRoughnessMap.value=e.sheenRoughnessMap,n(e.sheenRoughnessMap,t.sheenRoughnessMapTransform)));e.clearcoat>0&&(t.clearcoat.value=e.clearcoat,t.clearcoatRoughness.value=e.clearcoatRoughness,e.clearcoatMap&&(t.clearcoatMap.value=e.clearcoatMap,n(e.clearcoatMap,t.clearcoatMapTransform)),e.clearcoatRoughnessMap&&(t.clearcoatRoughnessMap.value=e.clearcoatRoughnessMap,n(e.clearcoatRoughnessMap,t.clearcoatRoughnessMapTransform)),e.clearcoatNormalMap&&(t.clearcoatNormalMap.value=e.clearcoatNormalMap,n(e.clearcoatNormalMap,t.clearcoatNormalMapTransform),t.clearcoatNormalScale.value.copy(e.clearcoatNormalScale),1===e.side&&t.clearcoatNormalScale.value.negate()));e.dispersion>0&&(t.dispersion.value=e.dispersion);e.iridescence>0&&(t.iridescence.value=e.iridescence,t.iridescenceIOR.value=e.iridescenceIOR,t.iridescenceThicknessMinimum.value=e.iridescenceThicknessRange[0],t.iridescenceThicknessMaximum.value=e.iridescenceThicknessRange[1],e.iridescenceMap&&(t.iridescenceMap.value=e.iridescenceMap,n(e.iridescenceMap,t.iridescenceMapTransform)),e.iridescenceThicknessMap&&(t.iridescenceThicknessMap.value=e.iridescenceThicknessMap,n(e.iridescenceThicknessMap,t.iridescenceThicknessMapTransform)));e.transmission>0&&(t.transmission.value=e.transmission,t.transmissionSamplerMap.value=i.texture,t.transmissionSamplerSize.value.set(i.width,i.height),e.transmissionMap&&(t.transmissionMap.value=e.transmissionMap,n(e.transmissionMap,t.transmissionMapTransform)),t.thickness.value=e.thickness,e.thicknessMap&&(t.thicknessMap.value=e.thicknessMap,n(e.thicknessMap,t.thicknessMapTransform)),t.attenuationDistance.value=e.attenuationDistance,t.attenuationColor.value.copy(e.attenuationColor));e.anisotropy>0&&(t.anisotropyVector.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation)),e.anisotropyMap&&(t.anisotropyMap.value=e.anisotropyMap,n(e.anisotropyMap,t.anisotropyMapTransform)));t.specularIntensity.value=e.specularIntensity,t.specularColor.value.copy(e.specularColor),e.specularColorMap&&(t.specularColorMap.value=e.specularColorMap,n(e.specularColorMap,t.specularColorMapTransform));e.specularIntensityMap&&(t.specularIntensityMap.value=e.specularIntensityMap,n(e.specularIntensityMap,t.specularIntensityMapTransform))}(t,s,o)):s.isMeshMatcapMaterial?(i(t,s),function(t,e){e.matcap&&(t.matcap.value=e.matcap)}(t,s)):s.isMeshDepthMaterial?i(t,s):s.isMeshDistanceMaterial?(i(t,s),function(t,n){const i=e.get(n).light;t.referencePosition.value.setFromMatrixPosition(i.matrixWorld),t.nearDistance.value=i.shadow.camera.near,t.farDistance.value=i.shadow.camera.far}(t,s)):s.isMeshNormalMaterial?i(t,s):s.isLineBasicMaterial?(function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,e.map&&(t.map.value=e.map,n(e.map,t.mapTransform))}(t,s),s.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(t,s)):s.isPointsMaterial?function(t,e,i,s){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.size.value=e.size*i,t.scale.value=.5*s,e.map&&(t.map.value=e.map,n(e.map,t.uvTransform));e.alphaMap&&(t.alphaMap.value=e.alphaMap,n(e.alphaMap,t.alphaMapTransform));e.alphaTest>0&&(t.alphaTest.value=e.alphaTest)}(t,s,r,a):s.isSpriteMaterial?function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.rotation.value=e.rotation,e.map&&(t.map.value=e.map,n(e.map,t.mapTransform));e.alphaMap&&(t.alphaMap.value=e.alphaMap,n(e.alphaMap,t.alphaMapTransform));e.alphaTest>0&&(t.alphaTest.value=e.alphaTest)}(t,s):s.isShadowMaterial?(t.color.value.copy(s.color),t.opacity.value=s.opacity):s.isShaderMaterial&&(s.uniformsNeedUpdate=!1)}}}function oc(t,e,n,i){let s={},r={},a=[];const o=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function l(t,e,n,i){const s=t.value,r=e+"_"+n;if(void 0===i[r])return i[r]="number"==typeof s||"boolean"==typeof s?s:s.clone(),!0;{const t=i[r];if("number"==typeof s||"boolean"==typeof s){if(t!==s)return i[r]=s,!0}else if(!1===t.equals(s))return t.copy(s),!0}return!1}function c(t){const e={boundary:0,storage:0};return"number"==typeof t||"boolean"==typeof t?(e.boundary=4,e.storage=4):t.isVector2?(e.boundary=8,e.storage=8):t.isVector3||t.isColor?(e.boundary=16,e.storage=12):t.isVector4?(e.boundary=16,e.storage=16):t.isMatrix3?(e.boundary=48,e.storage=48):t.isMatrix4?(e.boundary=64,e.storage=64):t.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",t),e}function u(e){const n=e.target;n.removeEventListener("dispose",u);const i=a.indexOf(n.__bindingPointIndex);a.splice(i,1),t.deleteBuffer(s[n.id]),delete s[n.id],delete r[n.id]}return{bind:function(t,e){const n=e.program;i.uniformBlockBinding(t,n)},update:function(n,h){let d=s[n.id];void 0===d&&(!function(t){const e=t.uniforms;let n=0;const i=16;for(let t=0,s=e.length;t<s;t++){const s=Array.isArray(e[t])?e[t]:[e[t]];for(let t=0,e=s.length;t<e;t++){const e=s[t],r=Array.isArray(e.value)?e.value:[e.value];for(let t=0,s=r.length;t<s;t++){const s=c(r[t]),a=n%i,o=a%s.boundary,l=a+o;n+=o,0!==l&&i-l<s.storage&&(n+=i-l),e.__data=new Float32Array(s.storage/Float32Array.BYTES_PER_ELEMENT),e.__offset=n,n+=s.storage}}}const s=n%i;s>0&&(n+=i-s);t.__size=n,t.__cache={}}(n),d=function(e){const n=function(){for(let t=0;t<o;t++)if(-1===a.indexOf(t))return a.push(t),t;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}();e.__bindingPointIndex=n;const i=t.createBuffer(),s=e.__size,r=e.usage;return t.bindBuffer(t.UNIFORM_BUFFER,i),t.bufferData(t.UNIFORM_BUFFER,s,r),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,n,i),i}(n),s[n.id]=d,n.addEventListener("dispose",u));const p=h.program;i.updateUBOMapping(n,p);const m=e.render.frame;r[n.id]!==m&&(!function(e){const n=s[e.id],i=e.uniforms,r=e.__cache;t.bindBuffer(t.UNIFORM_BUFFER,n);for(let e=0,n=i.length;e<n;e++){const n=Array.isArray(i[e])?i[e]:[i[e]];for(let i=0,s=n.length;i<s;i++){const s=n[i];if(!0===l(s,e,i,r)){const e=s.__offset,n=Array.isArray(s.value)?s.value:[s.value];let i=0;for(let r=0;r<n.length;r++){const a=n[r],o=c(a);"number"==typeof a||"boolean"==typeof a?(s.__data[0]=a,t.bufferSubData(t.UNIFORM_BUFFER,e+i,s.__data)):a.isMatrix3?(s.__data[0]=a.elements[0],s.__data[1]=a.elements[1],s.__data[2]=a.elements[2],s.__data[3]=0,s.__data[4]=a.elements[3],s.__data[5]=a.elements[4],s.__data[6]=a.elements[5],s.__data[7]=0,s.__data[8]=a.elements[6],s.__data[9]=a.elements[7],s.__data[10]=a.elements[8],s.__data[11]=0):(a.toArray(s.__data,i),i+=o.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,e,s.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}(n),r[n.id]=m)},dispose:function(){for(const e in s)t.deleteBuffer(s[e]);a=[],s={},r={}}}}class lc{constructor(e={}){const{canvas:n=li(),context:i=null,depth:s=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:h=!1}=e;let d;if(this.isWebGLRenderer=!0,null!==i){if("undefined"!=typeof WebGLRenderingContext&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");d=i.getContextAttributes().alpha}else d=a;const p=new Uint32Array(4),m=new Int32Array(4);let f=null,g=null;const v=[],y=[];this.domElement=n,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Je,this.toneMapping=0,this.toneMappingExposure=1;const _=this;let x=!1,M=0,b=0,T=null,S=-1,w=null;const E=new wi,A=new wi;let N=null;const C=new er(0);let R=0,I=n.width,L=n.height,P=1,U=null,D=null;const O=new wi(0,0,I,L),z=new wi(0,0,I,L);let V=!1;const F=new ma;let B=!1,k=!1;const H=new cs,G=new cs,W=new Pi,j=new wi,X={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let q=!1;function Y(){return null===T?P:1}let Z,$,J,K,Q,tt,et,nt,it,st,rt,at,ot,lt,ct,ut,ht,dt,pt,mt,ft,gt,vt,yt,_t=i;function xt(t,e){return n.getContext(t,e)}try{const e={alpha:!0,depth:s,stencil:r,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:h};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${t}`),n.addEventListener("webglcontextlost",Tt,!1),n.addEventListener("webglcontextrestored",wt,!1),n.addEventListener("webglcontextcreationerror",At,!1),null===_t){const t="webgl2";if(_t=xt(t,e),null===_t)throw xt(t)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(t){throw console.error("THREE.WebGLRenderer: "+t.message),t}function Mt(){Z=new $a(_t),Z.init(),gt=new Jl(_t,Z),$=new Aa(_t,Z,e,gt),J=new ql(_t),$.reverseDepthBuffer&&J.buffers.depth.setReversed(!0),K=new Qa(_t),Q=new Ll,tt=new $l(_t,Z,J,Q,$,gt,K),et=new Ca(_),nt=new Za(_),it=new ga(_t),vt=new wa(_t,it),st=new Ja(_t,it,K,vt),rt=new eo(_t,st,it,K),pt=new to(_t,$,tt),ut=new Na(Q),at=new Il(_,et,nt,Z,$,vt,ut),ot=new ac(_,Q),lt=new Ol,ct=new Hl(Z),dt=new Sa(_,et,nt,J,rt,d,l),ht=new jl(_,rt,$),yt=new oc(_t,K,$,J),mt=new Ea(_t,Z,K),ft=new Ka(_t,Z,K),K.programs=at.programs,_.capabilities=$,_.extensions=Z,_.properties=Q,_.renderLists=lt,_.shadowMap=ht,_.state=J,_.info=K}Mt();const bt=new ic(_,_t);function Tt(t){t.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),x=!0}function wt(){console.log("THREE.WebGLRenderer: Context Restored."),x=!1;const t=K.autoReset,e=ht.enabled,n=ht.autoUpdate,i=ht.needsUpdate,s=ht.type;Mt(),K.autoReset=t,ht.enabled=e,ht.autoUpdate=n,ht.needsUpdate=i,ht.type=s}function At(t){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",t.statusMessage)}function Nt(t){const e=t.target;e.removeEventListener("dispose",Nt),function(t){(function(t){const e=Q.get(t).programs;void 0!==e&&(e.forEach(function(t){at.releaseProgram(t)}),t.isShaderMaterial&&at.releaseShaderCache(t))})(t),Q.remove(t)}(e)}function Rt(t,e,n){!0===t.transparent&&2===t.side&&!1===t.forceSinglePass?(t.side=1,t.needsUpdate=!0,jt(t,e,n),t.side=0,t.needsUpdate=!0,jt(t,e,n),t.side=2):jt(t,e,n)}this.xr=bt,this.getContext=function(){return _t},this.getContextAttributes=function(){return _t.getContextAttributes()},this.forceContextLoss=function(){const t=Z.get("WEBGL_lose_context");t&&t.loseContext()},this.forceContextRestore=function(){const t=Z.get("WEBGL_lose_context");t&&t.restoreContext()},this.getPixelRatio=function(){return P},this.setPixelRatio=function(t){void 0!==t&&(P=t,this.setSize(I,L,!1))},this.getSize=function(t){return t.set(I,L)},this.setSize=function(t,e,i=!0){bt.isPresenting?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(I=t,L=e,n.width=Math.floor(t*P),n.height=Math.floor(e*P),!0===i&&(n.style.width=t+"px",n.style.height=e+"px"),this.setViewport(0,0,t,e))},this.getDrawingBufferSize=function(t){return t.set(I*P,L*P).floor()},this.setDrawingBufferSize=function(t,e,i){I=t,L=e,P=i,n.width=Math.floor(t*i),n.height=Math.floor(e*i),this.setViewport(0,0,t,e)},this.getCurrentViewport=function(t){return t.copy(E)},this.getViewport=function(t){return t.copy(O)},this.setViewport=function(t,e,n,i){t.isVector4?O.set(t.x,t.y,t.z,t.w):O.set(t,e,n,i),J.viewport(E.copy(O).multiplyScalar(P).round())},this.getScissor=function(t){return t.copy(z)},this.setScissor=function(t,e,n,i){t.isVector4?z.set(t.x,t.y,t.z,t.w):z.set(t,e,n,i),J.scissor(A.copy(z).multiplyScalar(P).round())},this.getScissorTest=function(){return V},this.setScissorTest=function(t){J.setScissorTest(V=t)},this.setOpaqueSort=function(t){U=t},this.setTransparentSort=function(t){D=t},this.getClearColor=function(t){return t.copy(dt.getClearColor())},this.setClearColor=function(){dt.setClearColor.apply(dt,arguments)},this.getClearAlpha=function(){return dt.getClearAlpha()},this.setClearAlpha=function(){dt.setClearAlpha.apply(dt,arguments)},this.clear=function(t=!0,e=!0,n=!0){let i=0;if(t){let t=!1;if(null!==T){const e=T.texture.format;t=e===Jt||e===Zt||e===qt}if(t){const t=T.texture.type,e=t===Et||t===It||t===Ct||t===Ot||t===Ut||t===Dt,n=dt.getClearColor(),i=dt.getClearAlpha(),s=n.r,r=n.g,a=n.b;e?(p[0]=s,p[1]=r,p[2]=a,p[3]=i,_t.clearBufferuiv(_t.COLOR,0,p)):(m[0]=s,m[1]=r,m[2]=a,m[3]=i,_t.clearBufferiv(_t.COLOR,0,m))}else i|=_t.COLOR_BUFFER_BIT}e&&(i|=_t.DEPTH_BUFFER_BIT,_t.clearDepth(this.capabilities.reverseDepthBuffer?0:1)),n&&(i|=_t.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),_t.clear(i)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){n.removeEventListener("webglcontextlost",Tt,!1),n.removeEventListener("webglcontextrestored",wt,!1),n.removeEventListener("webglcontextcreationerror",At,!1),lt.dispose(),ct.dispose(),Q.dispose(),et.dispose(),nt.dispose(),rt.dispose(),vt.dispose(),yt.dispose(),at.dispose(),bt.dispose(),bt.removeEventListener("sessionstart",zt),bt.removeEventListener("sessionend",Vt),Ft.stop()},this.renderBufferDirect=function(t,e,n,i,s,r){null===e&&(e=X);const a=s.isMesh&&s.matrixWorld.determinant()<0,o=function(t,e,n,i,s){!0!==e.isScene&&(e=X);tt.resetTextureUnits();const r=e.fog,a=i.isMeshStandardMaterial?e.environment:null,o=null===T?_.outputColorSpace:!0===T.isXRRenderTarget?T.texture.colorSpace:Ke,l=(i.isMeshStandardMaterial?nt:et).get(i.envMap||a),c=!0===i.vertexColors&&!!n.attributes.color&&4===n.attributes.color.itemSize,u=!!n.attributes.tangent&&(!!i.normalMap||i.anisotropy>0),h=!!n.morphAttributes.position,d=!!n.morphAttributes.normal,p=!!n.morphAttributes.color;let m=0;i.toneMapped&&(null!==T&&!0!==T.isXRRenderTarget||(m=_.toneMapping));const f=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,v=void 0!==f?f.length:0,y=Q.get(i),x=g.state.lights;if(!0===B&&(!0===k||t!==w)){const e=t===w&&i.id===S;ut.setState(i,t,e)}let M=!1;i.version===y.__version?y.needsLights&&y.lightsStateVersion!==x.state.version||y.outputColorSpace!==o||s.isBatchedMesh&&!1===y.batching?M=!0:s.isBatchedMesh||!0!==y.batching?s.isBatchedMesh&&!0===y.batchingColor&&null===s.colorTexture||s.isBatchedMesh&&!1===y.batchingColor&&null!==s.colorTexture||s.isInstancedMesh&&!1===y.instancing?M=!0:s.isInstancedMesh||!0!==y.instancing?s.isSkinnedMesh&&!1===y.skinning?M=!0:s.isSkinnedMesh||!0!==y.skinning?s.isInstancedMesh&&!0===y.instancingColor&&null===s.instanceColor||s.isInstancedMesh&&!1===y.instancingColor&&null!==s.instanceColor||s.isInstancedMesh&&!0===y.instancingMorph&&null===s.morphTexture||s.isInstancedMesh&&!1===y.instancingMorph&&null!==s.morphTexture||y.envMap!==l||!0===i.fog&&y.fog!==r?M=!0:void 0===y.numClippingPlanes||y.numClippingPlanes===ut.numPlanes&&y.numIntersection===ut.numIntersection?(y.vertexAlphas!==c||y.vertexTangents!==u||y.morphTargets!==h||y.morphNormals!==d||y.morphColors!==p||y.toneMapping!==m||y.morphTargetsCount!==v)&&(M=!0):M=!0:M=!0:M=!0:M=!0:(M=!0,y.__version=i.version);let b=y.currentProgram;!0===M&&(b=jt(i,e,s));let E=!1,A=!1,N=!1;const C=b.getUniforms(),R=y.uniforms;J.useProgram(b.program)&&(E=!0,A=!0,N=!0);(i.id!==S||i._forceRefresh)&&(S=i.id,A=!0,i._forceRefresh=!1);if(E||w!==t){$.reverseDepthBuffer?(H.copy(t.projectionMatrix),function(t){const e=t.elements;e[2]=.5*e[2]+.5*e[3],e[6]=.5*e[6]+.5*e[7],e[10]=.5*e[10]+.5*e[11],e[14]=.5*e[14]+.5*e[15]}(H),function(t){const e=t.elements;-1===e[11]?(e[10]=-e[10]-1,e[14]=-e[14]):(e[10]=-e[10],e[14]=1-e[14])}(H),C.setValue(_t,"projectionMatrix",H)):C.setValue(_t,"projectionMatrix",t.projectionMatrix),C.setValue(_t,"viewMatrix",t.matrixWorldInverse);const e=C.map.cameraPosition;void 0!==e&&e.setValue(_t,W.setFromMatrixPosition(t.matrixWorld)),$.logarithmicDepthBuffer&&C.setValue(_t,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial)&&C.setValue(_t,"isOrthographic",!0===t.isOrthographicCamera),w!==t&&(w=t,A=!0,N=!0)}if(s.isSkinnedMesh){C.setOptional(_t,s,"bindMatrix"),C.setOptional(_t,s,"bindMatrixInverse");const t=s.skeleton;t&&(null===t.boneTexture&&t.computeBoneTexture(),C.setValue(_t,"boneTexture",t.boneTexture,tt))}s.isBatchedMesh&&(C.setOptional(_t,s,"batchingTexture"),C.setValue(_t,"batchingTexture",s._matricesTexture,tt),C.setOptional(_t,s,"batchingIdTexture"),C.setValue(_t,"batchingIdTexture",s._indirectTexture,tt),C.setOptional(_t,s,"batchingColorTexture"),null!==s._colorsTexture&&C.setValue(_t,"batchingColorTexture",s._colorsTexture,tt));const I=n.morphAttributes;void 0===I.position&&void 0===I.normal&&void 0===I.color||pt.update(s,n,b);(A||y.receiveShadow!==s.receiveShadow)&&(y.receiveShadow=s.receiveShadow,C.setValue(_t,"receiveShadow",s.receiveShadow));i.isMeshGouraudMaterial&&null!==i.envMap&&(R.envMap.value=l,R.flipEnvMap.value=l.isCubeTexture&&!1===l.isRenderTargetTexture?-1:1);i.isMeshStandardMaterial&&null===i.envMap&&null!==e.environment&&(R.envMapIntensity.value=e.environmentIntensity);A&&(C.setValue(_t,"toneMappingExposure",_.toneMappingExposure),y.needsLights&&function(t,e){t.ambientLightColor.needsUpdate=e,t.lightProbe.needsUpdate=e,t.directionalLights.needsUpdate=e,t.directionalLightShadows.needsUpdate=e,t.pointLights.needsUpdate=e,t.pointLightShadows.needsUpdate=e,t.spotLights.needsUpdate=e,t.spotLightShadows.needsUpdate=e,t.rectAreaLights.needsUpdate=e,t.hemisphereLights.needsUpdate=e}(R,N),r&&!0===i.fog&&ot.refreshFogUniforms(R,r),ot.refreshMaterialUniforms(R,i,P,L,g.state.transmissionRenderTarget[t.id]),ll.upload(_t,Xt(y),R,tt));i.isShaderMaterial&&!0===i.uniformsNeedUpdate&&(ll.upload(_t,Xt(y),R,tt),i.uniformsNeedUpdate=!1);i.isSpriteMaterial&&C.setValue(_t,"center",s.center);if(C.setValue(_t,"modelViewMatrix",s.modelViewMatrix),C.setValue(_t,"normalMatrix",s.normalMatrix),C.setValue(_t,"modelMatrix",s.matrixWorld),i.isShaderMaterial||i.isRawShaderMaterial){const t=i.uniformsGroups;for(let e=0,n=t.length;e<n;e++){const n=t[e];yt.update(n,b),yt.bind(n,b)}}return b}(t,e,n,i,s);J.setMaterial(i,a);let l=n.index,c=1;if(!0===i.wireframe){if(l=st.getWireframeAttribute(n),void 0===l)return;c=2}const u=n.drawRange,h=n.attributes.position;let d=u.start*c,p=(u.start+u.count)*c;null!==r&&(d=Math.max(d,r.start*c),p=Math.min(p,(r.start+r.count)*c)),null!==l?(d=Math.max(d,0),p=Math.min(p,l.count)):null!=h&&(d=Math.max(d,0),p=Math.min(p,h.count));const m=p-d;if(m<0||m===1/0)return;let f;vt.setup(s,i,o,n,l);let v=mt;if(null!==l&&(f=it.get(l),v=ft,v.setIndex(f)),s.isMesh)!0===i.wireframe?(J.setLineWidth(i.wireframeLinewidth*Y()),v.setMode(_t.LINES)):v.setMode(_t.TRIANGLES);else if(s.isLine){let t=i.linewidth;void 0===t&&(t=1),J.setLineWidth(t*Y()),s.isLineSegments?v.setMode(_t.LINES):s.isLineLoop?v.setMode(_t.LINE_LOOP):v.setMode(_t.LINE_STRIP)}else s.isPoints?v.setMode(_t.POINTS):s.isSprite&&v.setMode(_t.TRIANGLES);if(s.isBatchedMesh)if(null!==s._multiDrawInstances)v.renderMultiDrawInstances(s._multiDrawStarts,s._multiDrawCounts,s._multiDrawCount,s._multiDrawInstances);else if(Z.get("WEBGL_multi_draw"))v.renderMultiDraw(s._multiDrawStarts,s._multiDrawCounts,s._multiDrawCount);else{const t=s._multiDrawStarts,e=s._multiDrawCounts,n=s._multiDrawCount,r=l?it.get(l).bytesPerElement:1,a=Q.get(i).currentProgram.getUniforms();for(let i=0;i<n;i++)a.setValue(_t,"_gl_DrawID",i),v.render(t[i]/r,e[i])}else if(s.isInstancedMesh)v.renderInstances(d,m,s.count);else if(n.isInstancedBufferGeometry){const t=void 0!==n._maxInstanceCount?n._maxInstanceCount:1/0,e=Math.min(n.instanceCount,t);v.renderInstances(d,m,e)}else v.render(d,m)},this.compile=function(t,e,n=null){null===n&&(n=t),g=ct.get(n),g.init(e),y.push(g),n.traverseVisible(function(t){t.isLight&&t.layers.test(e.layers)&&(g.pushLight(t),t.castShadow&&g.pushShadow(t))}),t!==n&&t.traverseVisible(function(t){t.isLight&&t.layers.test(e.layers)&&(g.pushLight(t),t.castShadow&&g.pushShadow(t))}),g.setupLights();const i=new Set;return t.traverse(function(t){if(!(t.isMesh||t.isPoints||t.isLine||t.isSprite))return;const e=t.material;if(e)if(Array.isArray(e))for(let s=0;s<e.length;s++){const r=e[s];Rt(r,n,t),i.add(r)}else Rt(e,n,t),i.add(e)}),y.pop(),g=null,i},this.compileAsync=function(t,e,n=null){const i=this.compile(t,e,n);return new Promise(e=>{function n(){i.forEach(function(t){Q.get(t).currentProgram.isReady()&&i.delete(t)}),0!==i.size?setTimeout(n,10):e(t)}null!==Z.get("KHR_parallel_shader_compile")?n():setTimeout(n,10)})};let Lt=null;function zt(){Ft.stop()}function Vt(){Ft.start()}const Ft=new fa;function Bt(t,e,n,i){if(!1===t.visible)return;if(t.layers.test(e.layers))if(t.isGroup)n=t.renderOrder;else if(t.isLOD)!0===t.autoUpdate&&t.update(e);else if(t.isLight)g.pushLight(t),t.castShadow&&g.pushShadow(t);else if(t.isSprite){if(!t.frustumCulled||F.intersectsSprite(t)){i&&j.setFromMatrixPosition(t.matrixWorld).applyMatrix4(G);const e=rt.update(t),s=t.material;s.visible&&f.push(t,e,s,n,j.z,null)}}else if((t.isMesh||t.isLine||t.isPoints)&&(!t.frustumCulled||F.intersectsObject(t))){const e=rt.update(t),s=t.material;if(i&&(void 0!==t.boundingSphere?(null===t.boundingSphere&&t.computeBoundingSphere(),j.copy(t.boundingSphere.center)):(null===e.boundingSphere&&e.computeBoundingSphere(),j.copy(e.boundingSphere.center)),j.applyMatrix4(t.matrixWorld).applyMatrix4(G)),Array.isArray(s)){const i=e.groups;for(let r=0,a=i.length;r<a;r++){const a=i[r],o=s[a.materialIndex];o&&o.visible&&f.push(t,e,o,n,j.z,a)}}else s.visible&&f.push(t,e,s,n,j.z,null)}const s=t.children;for(let t=0,r=s.length;t<r;t++)Bt(s[t],e,n,i)}function kt(t,e,n,i){const s=t.opaque,r=t.transmissive,a=t.transparent;g.setupLightsView(n),!0===B&&ut.setGlobalState(_.clippingPlanes,n),i&&J.viewport(E.copy(i)),s.length>0&&Gt(s,e,n),r.length>0&&Gt(r,e,n),a.length>0&&Gt(a,e,n),J.buffers.depth.setTest(!0),J.buffers.depth.setMask(!0),J.buffers.color.setMask(!0),J.setPolygonOffset(!1)}function Ht(t,e,n,i){if(null!==(!0===n.isScene?n.overrideMaterial:null))return;void 0===g.state.transmissionRenderTarget[i.id]&&(g.state.transmissionRenderTarget[i.id]=new Ai(1,1,{generateMipmaps:!0,type:Z.has("EXT_color_buffer_half_float")||Z.has("EXT_color_buffer_float")?Pt:Et,minFilter:St,samples:4,stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:fi.workingColorSpace}));const s=g.state.transmissionRenderTarget[i.id],a=i.viewport||E;s.setSize(a.z,a.w);const o=_.getRenderTarget();_.setRenderTarget(s),_.getClearColor(C),R=_.getClearAlpha(),R<1&&_.setClearColor(16777215,.5),_.clear(),q&&dt.render(n);const l=_.toneMapping;_.toneMapping=0;const c=i.viewport;if(void 0!==i.viewport&&(i.viewport=void 0),g.setupLightsView(i),!0===B&&ut.setGlobalState(_.clippingPlanes,i),Gt(t,n,i),tt.updateMultisampleRenderTarget(s),tt.updateRenderTargetMipmap(s),!1===Z.has("WEBGL_multisampled_render_to_texture")){let t=!1;for(let s=0,r=e.length;s<r;s++){const r=e[s],a=r.object,o=r.geometry,l=r.material,c=r.group;if(2===l.side&&a.layers.test(i.layers)){const e=l.side;l.side=1,l.needsUpdate=!0,Wt(a,n,i,o,l,c),l.side=e,l.needsUpdate=!0,t=!0}}!0===t&&(tt.updateMultisampleRenderTarget(s),tt.updateRenderTargetMipmap(s))}_.setRenderTarget(o),_.setClearColor(C,R),void 0!==c&&(i.viewport=c),_.toneMapping=l}function Gt(t,e,n){const i=!0===e.isScene?e.overrideMaterial:null;for(let s=0,r=t.length;s<r;s++){const r=t[s],a=r.object,o=r.geometry,l=null===i?r.material:i,c=r.group;a.layers.test(n.layers)&&Wt(a,e,n,o,l,c)}}function Wt(t,e,n,i,s,r){t.onBeforeRender(_,e,n,i,s,r),t.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix),s.onBeforeRender(_,e,n,i,t,r),!0===s.transparent&&2===s.side&&!1===s.forceSinglePass?(s.side=1,s.needsUpdate=!0,_.renderBufferDirect(n,e,i,s,t,r),s.side=0,s.needsUpdate=!0,_.renderBufferDirect(n,e,i,s,t,r),s.side=2):_.renderBufferDirect(n,e,i,s,t,r),t.onAfterRender(_,e,n,i,s,r)}function jt(t,e,n){!0!==e.isScene&&(e=X);const i=Q.get(t),s=g.state.lights,r=g.state.shadowsArray,a=s.state.version,o=at.getParameters(t,s.state,r,e,n),l=at.getProgramCacheKey(o);let c=i.programs;i.environment=t.isMeshStandardMaterial?e.environment:null,i.fog=e.fog,i.envMap=(t.isMeshStandardMaterial?nt:et).get(t.envMap||i.environment),i.envMapRotation=null!==i.environment&&null===t.envMap?e.environmentRotation:t.envMapRotation,void 0===c&&(t.addEventListener("dispose",Nt),c=new Map,i.programs=c);let u=c.get(l);if(void 0!==u){if(i.currentProgram===u&&i.lightsStateVersion===a)return Yt(t,o),u}else o.uniforms=at.getUniforms(t),t.onBuild(n,o,_),t.onBeforeCompile(o,_),u=at.acquireProgram(o,l),c.set(l,u),i.uniforms=o.uniforms;const h=i.uniforms;return(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(h.clippingPlanes=ut.uniform),Yt(t,o),i.needsLights=function(t){return t.isMeshLambertMaterial||t.isMeshToonMaterial||t.isMeshPhongMaterial||t.isMeshStandardMaterial||t.isShadowMaterial||t.isShaderMaterial&&!0===t.lights}(t),i.lightsStateVersion=a,i.needsLights&&(h.ambientLightColor.value=s.state.ambient,h.lightProbe.value=s.state.probe,h.directionalLights.value=s.state.directional,h.directionalLightShadows.value=s.state.directionalShadow,h.spotLights.value=s.state.spot,h.spotLightShadows.value=s.state.spotShadow,h.rectAreaLights.value=s.state.rectArea,h.ltc_1.value=s.state.rectAreaLTC1,h.ltc_2.value=s.state.rectAreaLTC2,h.pointLights.value=s.state.point,h.pointLightShadows.value=s.state.pointShadow,h.hemisphereLights.value=s.state.hemi,h.directionalShadowMap.value=s.state.directionalShadowMap,h.directionalShadowMatrix.value=s.state.directionalShadowMatrix,h.spotShadowMap.value=s.state.spotShadowMap,h.spotLightMatrix.value=s.state.spotLightMatrix,h.spotLightMap.value=s.state.spotLightMap,h.pointShadowMap.value=s.state.pointShadowMap,h.pointShadowMatrix.value=s.state.pointShadowMatrix),i.currentProgram=u,i.uniformsList=null,u}function Xt(t){if(null===t.uniformsList){const e=t.currentProgram.getUniforms();t.uniformsList=ll.seqWithValue(e.seq,t.uniforms)}return t.uniformsList}function Yt(t,e){const n=Q.get(t);n.outputColorSpace=e.outputColorSpace,n.batching=e.batching,n.batchingColor=e.batchingColor,n.instancing=e.instancing,n.instancingColor=e.instancingColor,n.instancingMorph=e.instancingMorph,n.skinning=e.skinning,n.morphTargets=e.morphTargets,n.morphNormals=e.morphNormals,n.morphColors=e.morphColors,n.morphTargetsCount=e.morphTargetsCount,n.numClippingPlanes=e.numClippingPlanes,n.numIntersection=e.numClipIntersection,n.vertexAlphas=e.vertexAlphas,n.vertexTangents=e.vertexTangents,n.toneMapping=e.toneMapping}Ft.setAnimationLoop(function(t){Lt&&Lt(t)}),"undefined"!=typeof self&&Ft.setContext(self),this.setAnimationLoop=function(t){Lt=t,bt.setAnimationLoop(t),null===t?Ft.stop():Ft.start()},bt.addEventListener("sessionstart",zt),bt.addEventListener("sessionend",Vt),this.render=function(t,e){if(void 0!==e&&!0!==e.isCamera)return void console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===x)return;if(!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),null===e.parent&&!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),!0===bt.enabled&&!0===bt.isPresenting&&(!0===bt.cameraAutoUpdate&&bt.updateCamera(e),e=bt.getCamera()),!0===t.isScene&&t.onBeforeRender(_,t,e,T),g=ct.get(t,y.length),g.init(e),y.push(g),G.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),F.setFromProjectionMatrix(G),k=this.localClippingEnabled,B=ut.init(this.clippingPlanes,k),f=lt.get(t,v.length),f.init(),v.push(f),!0===bt.enabled&&!0===bt.isPresenting){const t=_.xr.getDepthSensingMesh();null!==t&&Bt(t,e,-1/0,_.sortObjects)}Bt(t,e,0,_.sortObjects),f.finish(),!0===_.sortObjects&&f.sort(U,D),q=!1===bt.enabled||!1===bt.isPresenting||!1===bt.hasDepthSensing(),q&&dt.addToRenderList(f,t),this.info.render.frame++,!0===B&&ut.beginShadows();const n=g.state.shadowsArray;ht.render(n,t,e),!0===B&&ut.endShadows(),!0===this.info.autoReset&&this.info.reset();const i=f.opaque,s=f.transmissive;if(g.setupLights(),e.isArrayCamera){const n=e.cameras;if(s.length>0)for(let e=0,r=n.length;e<r;e++){Ht(i,s,t,n[e])}q&&dt.render(t);for(let e=0,i=n.length;e<i;e++){const i=n[e];kt(f,t,i,i.viewport)}}else s.length>0&&Ht(i,s,t,e),q&&dt.render(t),kt(f,t,e);null!==T&&(tt.updateMultisampleRenderTarget(T),tt.updateRenderTargetMipmap(T)),!0===t.isScene&&t.onAfterRender(_,t,e),vt.resetDefaultState(),S=-1,w=null,y.pop(),y.length>0?(g=y[y.length-1],!0===B&&ut.setGlobalState(_.clippingPlanes,g.state.camera)):g=null,v.pop(),f=v.length>0?v[v.length-1]:null},this.getActiveCubeFace=function(){return M},this.getActiveMipmapLevel=function(){return b},this.getRenderTarget=function(){return T},this.setRenderTargetTextures=function(t,e,n){Q.get(t.texture).__webglTexture=e,Q.get(t.depthTexture).__webglTexture=n;const i=Q.get(t);i.__hasExternalTextures=!0,i.__autoAllocateDepthBuffer=void 0===n,i.__autoAllocateDepthBuffer||!0===Z.has("WEBGL_multisampled_render_to_texture")&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),i.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(t,e){const n=Q.get(t);n.__webglFramebuffer=e,n.__useDefaultFramebuffer=void 0===e},this.setRenderTarget=function(t,e=0,n=0){T=t,M=e,b=n;let i=!0,s=null,r=!1,a=!1;if(t){const o=Q.get(t);if(void 0!==o.__useDefaultFramebuffer)J.bindFramebuffer(_t.FRAMEBUFFER,null),i=!1;else if(void 0===o.__webglFramebuffer)tt.setupRenderTarget(t);else if(o.__hasExternalTextures)tt.rebindTextures(t,Q.get(t.texture).__webglTexture,Q.get(t.depthTexture).__webglTexture);else if(t.depthBuffer){const e=t.depthTexture;if(o.__boundDepthTexture!==e){if(null!==e&&Q.has(e)&&(t.width!==e.image.width||t.height!==e.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");tt.setupDepthRenderbuffer(t)}}const l=t.texture;(l.isData3DTexture||l.isDataArrayTexture||l.isCompressedArrayTexture)&&(a=!0);const c=Q.get(t).__webglFramebuffer;t.isWebGLCubeRenderTarget?(s=Array.isArray(c[e])?c[e][n]:c[e],r=!0):s=t.samples>0&&!1===tt.useMultisampledRTT(t)?Q.get(t).__webglMultisampledFramebuffer:Array.isArray(c)?c[n]:c,E.copy(t.viewport),A.copy(t.scissor),N=t.scissorTest}else E.copy(O).multiplyScalar(P).floor(),A.copy(z).multiplyScalar(P).floor(),N=V;if(J.bindFramebuffer(_t.FRAMEBUFFER,s)&&i&&J.drawBuffers(t,s),J.viewport(E),J.scissor(A),J.setScissorTest(N),r){const i=Q.get(t.texture);_t.framebufferTexture2D(_t.FRAMEBUFFER,_t.COLOR_ATTACHMENT0,_t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i.__webglTexture,n)}else if(a){const i=Q.get(t.texture),s=e||0;_t.framebufferTextureLayer(_t.FRAMEBUFFER,_t.COLOR_ATTACHMENT0,i.__webglTexture,n||0,s)}S=-1},this.readRenderTargetPixels=function(t,e,n,i,s,r,a){if(!t||!t.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let o=Q.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==a&&(o=o[a]),o){J.bindFramebuffer(_t.FRAMEBUFFER,o);try{const a=t.texture,o=a.format,l=a.type;if(!$.textureFormatReadable(o))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!$.textureTypeReadable(l))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");e>=0&&e<=t.width-i&&n>=0&&n<=t.height-s&&_t.readPixels(e,n,i,s,gt.convert(o),gt.convert(l),r)}finally{const t=null!==T?Q.get(T).__webglFramebuffer:null;J.bindFramebuffer(_t.FRAMEBUFFER,t)}}},this.readRenderTargetPixelsAsync=async function(t,e,n,i,s,r,a){if(!t||!t.isWebGLRenderTarget)throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let o=Q.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==a&&(o=o[a]),o){const a=t.texture,l=a.format,c=a.type;if(!$.textureFormatReadable(l))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!$.textureTypeReadable(c))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(e>=0&&e<=t.width-i&&n>=0&&n<=t.height-s){J.bindFramebuffer(_t.FRAMEBUFFER,o);const t=_t.createBuffer();_t.bindBuffer(_t.PIXEL_PACK_BUFFER,t),_t.bufferData(_t.PIXEL_PACK_BUFFER,r.byteLength,_t.STREAM_READ),_t.readPixels(e,n,i,s,gt.convert(l),gt.convert(c),0);const a=null!==T?Q.get(T).__webglFramebuffer:null;J.bindFramebuffer(_t.FRAMEBUFFER,a);const u=_t.fenceSync(_t.SYNC_GPU_COMMANDS_COMPLETE,0);return _t.flush(),await function(t,e,n){return new Promise(function(i,s){setTimeout(function r(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:s();break;case t.TIMEOUT_EXPIRED:setTimeout(r,n);break;default:i()}},n)})}(_t,u,4),_t.bindBuffer(_t.PIXEL_PACK_BUFFER,t),_t.getBufferSubData(_t.PIXEL_PACK_BUFFER,0,r),_t.deleteBuffer(t),_t.deleteSync(u),r}throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(t,e=null,n=0){!0!==t.isTexture&&(ui("WebGLRenderer: copyFramebufferToTexture function signature has changed."),e=arguments[0]||null,t=arguments[1]);const i=Math.pow(2,-n),s=Math.floor(t.image.width*i),r=Math.floor(t.image.height*i),a=null!==e?e.x:0,o=null!==e?e.y:0;tt.setTexture2D(t,0),_t.copyTexSubImage2D(_t.TEXTURE_2D,n,0,0,a,o,s,r),J.unbindTexture()},this.copyTextureToTexture=function(t,e,n=null,i=null,s=0){let r,a,o,l,c,u;!0!==t.isTexture&&(ui("WebGLRenderer: copyTextureToTexture function signature has changed."),i=arguments[0]||null,t=arguments[1],e=arguments[2],s=arguments[3]||0,n=null),null!==n?(r=n.max.x-n.min.x,a=n.max.y-n.min.y,o=n.min.x,l=n.min.y):(r=t.image.width,a=t.image.height,o=0,l=0),null!==i?(c=i.x,u=i.y):(c=0,u=0);const h=gt.convert(e.format),d=gt.convert(e.type);tt.setTexture2D(e,0),_t.pixelStorei(_t.UNPACK_FLIP_Y_WEBGL,e.flipY),_t.pixelStorei(_t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.premultiplyAlpha),_t.pixelStorei(_t.UNPACK_ALIGNMENT,e.unpackAlignment);const p=_t.getParameter(_t.UNPACK_ROW_LENGTH),m=_t.getParameter(_t.UNPACK_IMAGE_HEIGHT),f=_t.getParameter(_t.UNPACK_SKIP_PIXELS),g=_t.getParameter(_t.UNPACK_SKIP_ROWS),v=_t.getParameter(_t.UNPACK_SKIP_IMAGES),y=t.isCompressedTexture?t.mipmaps[s]:t.image;_t.pixelStorei(_t.UNPACK_ROW_LENGTH,y.width),_t.pixelStorei(_t.UNPACK_IMAGE_HEIGHT,y.height),_t.pixelStorei(_t.UNPACK_SKIP_PIXELS,o),_t.pixelStorei(_t.UNPACK_SKIP_ROWS,l),t.isDataTexture?_t.texSubImage2D(_t.TEXTURE_2D,s,c,u,r,a,h,d,y.data):t.isCompressedTexture?_t.compressedTexSubImage2D(_t.TEXTURE_2D,s,c,u,y.width,y.height,h,y.data):_t.texSubImage2D(_t.TEXTURE_2D,s,c,u,r,a,h,d,y),_t.pixelStorei(_t.UNPACK_ROW_LENGTH,p),_t.pixelStorei(_t.UNPACK_IMAGE_HEIGHT,m),_t.pixelStorei(_t.UNPACK_SKIP_PIXELS,f),_t.pixelStorei(_t.UNPACK_SKIP_ROWS,g),_t.pixelStorei(_t.UNPACK_SKIP_IMAGES,v),0===s&&e.generateMipmaps&&_t.generateMipmap(_t.TEXTURE_2D),J.unbindTexture()},this.copyTextureToTexture3D=function(t,e,n=null,i=null,s=0){let r,a,o,l,c,u,h,d,p;!0!==t.isTexture&&(ui("WebGLRenderer: copyTextureToTexture3D function signature has changed."),n=arguments[0]||null,i=arguments[1]||null,t=arguments[2],e=arguments[3],s=arguments[4]||0);const m=t.isCompressedTexture?t.mipmaps[s]:t.image;null!==n?(r=n.max.x-n.min.x,a=n.max.y-n.min.y,o=n.max.z-n.min.z,l=n.min.x,c=n.min.y,u=n.min.z):(r=m.width,a=m.height,o=m.depth,l=0,c=0,u=0),null!==i?(h=i.x,d=i.y,p=i.z):(h=0,d=0,p=0);const f=gt.convert(e.format),g=gt.convert(e.type);let v;if(e.isData3DTexture)tt.setTexture3D(e,0),v=_t.TEXTURE_3D;else{if(!e.isDataArrayTexture&&!e.isCompressedArrayTexture)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");tt.setTexture2DArray(e,0),v=_t.TEXTURE_2D_ARRAY}_t.pixelStorei(_t.UNPACK_FLIP_Y_WEBGL,e.flipY),_t.pixelStorei(_t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.premultiplyAlpha),_t.pixelStorei(_t.UNPACK_ALIGNMENT,e.unpackAlignment);const y=_t.getParameter(_t.UNPACK_ROW_LENGTH),_=_t.getParameter(_t.UNPACK_IMAGE_HEIGHT),x=_t.getParameter(_t.UNPACK_SKIP_PIXELS),M=_t.getParameter(_t.UNPACK_SKIP_ROWS),b=_t.getParameter(_t.UNPACK_SKIP_IMAGES);_t.pixelStorei(_t.UNPACK_ROW_LENGTH,m.width),_t.pixelStorei(_t.UNPACK_IMAGE_HEIGHT,m.height),_t.pixelStorei(_t.UNPACK_SKIP_PIXELS,l),_t.pixelStorei(_t.UNPACK_SKIP_ROWS,c),_t.pixelStorei(_t.UNPACK_SKIP_IMAGES,u),t.isDataTexture||t.isData3DTexture?_t.texSubImage3D(v,s,h,d,p,r,a,o,f,g,m.data):e.isCompressedArrayTexture?_t.compressedTexSubImage3D(v,s,h,d,p,r,a,o,f,m.data):_t.texSubImage3D(v,s,h,d,p,r,a,o,f,g,m),_t.pixelStorei(_t.UNPACK_ROW_LENGTH,y),_t.pixelStorei(_t.UNPACK_IMAGE_HEIGHT,_),_t.pixelStorei(_t.UNPACK_SKIP_PIXELS,x),_t.pixelStorei(_t.UNPACK_SKIP_ROWS,M),_t.pixelStorei(_t.UNPACK_SKIP_IMAGES,b),0===s&&e.generateMipmaps&&_t.generateMipmap(v),J.unbindTexture()},this.initRenderTarget=function(t){void 0===Q.get(t).__webglFramebuffer&&tt.setupRenderTarget(t)},this.initTexture=function(t){t.isCubeTexture?tt.setTextureCube(t,0):t.isData3DTexture?tt.setTexture3D(t,0):t.isDataArrayTexture||t.isCompressedArrayTexture?tt.setTexture2DArray(t,0):tt.setTexture2D(t,0),J.unbindTexture()},this.resetState=function(){M=0,b=0,T=null,J.reset(),vt.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return kn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorSpace=t===Qe?"display-p3":"srgb",e.unpackColorSpace=fi.workingColorSpace===tn?"display-p3":"srgb"}}class cc{constructor(t,e=25e-5){this.isFogExp2=!0,this.name="",this.color=new er(t),this.density=e}clone(){return new cc(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class uc{constructor(t,e=1,n=1e3){this.isFog=!0,this.name="",this.color=new er(t),this.near=e,this.far=n}clone(){return new uc(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class hc extends Os{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 _s,this.environmentIntensity=1,this.environmentRotation=new _s,this.overrideMaterial=null,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),null!==t.background&&(this.background=t.background.clone()),null!==t.environment&&(this.environment=t.environment.clone()),null!==t.fog&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,this.backgroundRotation.copy(t.backgroundRotation),this.environmentIntensity=t.environmentIntensity,this.environmentRotation.copy(t.environmentRotation),null!==t.overrideMaterial&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return null!==this.fog&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),1!==this.environmentIntensity&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}}class dc{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.usage=Rn,this.updateRanges=[],this.version=0,this.uuid=Yn()}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let i=0,s=this.stride;i<s;i++)this.array[t+i]=e.array[n+i];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){void 0===t.arrayBuffers&&(t.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=Yn()),void 0===t.arrayBuffers[this.array.buffer._uuid]&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(e,this.stride);return n.setUsage(this.usage),n}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return void 0===t.arrayBuffers&&(t.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=Yn()),void 0===t.arrayBuffers[this.array.buffer._uuid]&&(t.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}}}const pc=new Pi;class mc{constructor(t,e,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,n=this.data.count;e<n;e++)pc.fromBufferAttribute(this,e),pc.applyMatrix4(t),this.setXYZ(e,pc.x,pc.y,pc.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)pc.fromBufferAttribute(this,e),pc.applyNormalMatrix(t),this.setXYZ(e,pc.x,pc.y,pc.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)pc.fromBufferAttribute(this,e),pc.transformDirection(t),this.setXYZ(e,pc.x,pc.y,pc.z);return this}getComponent(t,e){let n=this.array[t*this.data.stride+this.offset+e];return this.normalized&&(n=Kn(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=Qn(n,this.array)),this.data.array[t*this.data.stride+this.offset+e]=n,this}setX(t,e){return this.normalized&&(e=Qn(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=Qn(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=Qn(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=Qn(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=Kn(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=Kn(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=Kn(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=Kn(e,this.array)),e}setXY(t,e,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=Qn(e,this.array),n=Qn(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this}setXYZ(t,e,n,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=Qn(e,this.array),n=Qn(n,this.array),i=Qn(i,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this}setXYZW(t,e,n,i,s){return t=t*this.data.stride+this.offset,this.normalized&&(e=Qn(e,this.array),n=Qn(n,this.array),i=Qn(i,this.array),s=Qn(s,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this.data.array[t+3]=s,this}clone(t){if(void 0===t){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let e=0;e<this.count;e++){const n=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)t.push(this.data.array[n+e])}return new pr(new this.array.constructor(t),this.itemSize,this.normalized)}return void 0===t.interleavedBuffers&&(t.interleavedBuffers={}),void 0===t.interleavedBuffers[this.data.uuid]&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new mc(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(void 0===t){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let e=0;e<this.count;e++){const n=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)t.push(this.data.array[n+e])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}return void 0===t.interleavedBuffers&&(t.interleavedBuffers={}),void 0===t.interleavedBuffers[this.data.uuid]&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class fc extends sr{constructor(t){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new er(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.rotation=t.rotation,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}let gc;const vc=new Pi,yc=new Pi,_c=new Pi,xc=new ei,Mc=new ei,bc=new cs,Tc=new Pi,Sc=new Pi,wc=new Pi,Ec=new ei,Ac=new ei,Nc=new ei;class Cc extends Os{constructor(t=new fc){if(super(),this.isSprite=!0,this.type="Sprite",void 0===gc){gc=new Rr;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),e=new dc(t,5);gc.setIndex([0,1,2,0,2,3]),gc.setAttribute("position",new mc(e,3,0,!1)),gc.setAttribute("uv",new mc(e,2,3,!1))}this.geometry=gc,this.material=t,this.center=new ei(.5,.5)}raycast(t,e){null===t.camera&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),yc.setFromMatrixScale(this.matrixWorld),bc.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),_c.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&yc.multiplyScalar(-_c.z);const n=this.material.rotation;let i,s;0!==n&&(s=Math.cos(n),i=Math.sin(n));const r=this.center;Rc(Tc.set(-.5,-.5,0),_c,r,yc,i,s),Rc(Sc.set(.5,-.5,0),_c,r,yc,i,s),Rc(wc.set(.5,.5,0),_c,r,yc,i,s),Ec.set(0,0),Ac.set(1,0),Nc.set(1,1);let a=t.ray.intersectTriangle(Tc,Sc,wc,!1,vc);if(null===a&&(Rc(Sc.set(-.5,.5,0),_c,r,yc,i,s),Ac.set(0,1),a=t.ray.intersectTriangle(Tc,wc,Sc,!1,vc),null===a))return;const o=t.ray.origin.distanceTo(vc);o<t.near||o>t.far||e.push({distance:o,point:vc.clone(),uv:$s.getInterpolation(vc,Tc,Sc,wc,Ec,Ac,Nc,new ei),face:null,object:this})}copy(t,e){return super.copy(t,e),void 0!==t.center&&this.center.copy(t.center),this.material=t.material,this}}function Rc(t,e,n,i,s,r){xc.subVectors(t,n).addScalar(.5).multiply(i),void 0!==s?(Mc.x=r*xc.x-s*xc.y,Mc.y=s*xc.x+r*xc.y):Mc.copy(xc),t.copy(e),t.x+=Mc.x,t.y+=Mc.y,t.applyMatrix4(bc)}const Ic=new Pi,Lc=new Pi;class Pc extends Os{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(t){super.copy(t,!1);const e=t.levels;for(let t=0,n=e.length;t<n;t++){const n=e[t];this.addLevel(n.object.clone(),n.distance,n.hysteresis)}return this.autoUpdate=t.autoUpdate,this}addLevel(t,e=0,n=0){e=Math.abs(e);const i=this.levels;let s;for(s=0;s<i.length&&!(e<i[s].distance);s++);return i.splice(s,0,{distance:e,hysteresis:n,object:t}),this.add(t),this}removeLevel(t){const e=this.levels;for(let n=0;n<e.length;n++)if(e[n].distance===t){const t=e.splice(n,1);return this.remove(t[0].object),!0}return!1}getCurrentLevel(){return this._currentLevel}getObjectForDistance(t){const e=this.levels;if(e.length>0){let n,i;for(n=1,i=e.length;n<i;n++){let i=e[n].distance;if(e[n].object.visible&&(i-=i*e[n].hysteresis),t<i)break}return e[n-1].object}return null}raycast(t,e){if(this.levels.length>0){Ic.setFromMatrixPosition(this.matrixWorld);const n=t.ray.origin.distanceTo(Ic);this.getObjectForDistance(n).raycast(t,e)}}update(t){const e=this.levels;if(e.length>1){Ic.setFromMatrixPosition(t.matrixWorld),Lc.setFromMatrixPosition(this.matrixWorld);const n=Ic.distanceTo(Lc)/t.zoom;let i,s;for(e[0].object.visible=!0,i=1,s=e.length;i<s;i++){let t=e[i].distance;if(e[i].object.visible&&(t-=t*e[i].hysteresis),!(n>=t))break;e[i-1].object.visible=!1,e[i].object.visible=!0}for(this._currentLevel=i-1;i<s;i++)e[i].object.visible=!1}}toJSON(t){const e=super.toJSON(t);!1===this.autoUpdate&&(e.object.autoUpdate=!1),e.object.levels=[];const n=this.levels;for(let t=0,i=n.length;t<i;t++){const i=n[t];e.object.levels.push({object:i.object.uuid,distance:i.distance,hysteresis:i.hysteresis})}return e}}const Uc=new Pi,Dc=new wi,Oc=new wi,zc=new Pi,Vc=new cs,Fc=new Pi,Bc=new ts,kc=new cs,Hc=new ls;class Gc extends Hr{constructor(t,e){super(t,e),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=rt,this.bindMatrix=new cs,this.bindMatrixInverse=new cs,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const t=this.geometry;null===this.boundingBox&&(this.boundingBox=new Oi),this.boundingBox.makeEmpty();const e=t.getAttribute("position");for(let t=0;t<e.count;t++)this.getVertexPosition(t,Fc),this.boundingBox.expandByPoint(Fc)}computeBoundingSphere(){const t=this.geometry;null===this.boundingSphere&&(this.boundingSphere=new ts),this.boundingSphere.makeEmpty();const e=t.getAttribute("position");for(let t=0;t<e.count;t++)this.getVertexPosition(t,Fc),this.boundingSphere.expandByPoint(Fc)}copy(t,e){return super.copy(t,e),this.bindMode=t.bindMode,this.bindMatrix.copy(t.bindMatrix),this.bindMatrixInverse.copy(t.bindMatrixInverse),this.skeleton=t.skeleton,null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),this}raycast(t,e){const n=this.material,i=this.matrixWorld;void 0!==n&&(null===this.boundingSphere&&this.computeBoundingSphere(),Bc.copy(this.boundingSphere),Bc.applyMatrix4(i),!1!==t.ray.intersectsSphere(Bc)&&(kc.copy(i).invert(),Hc.copy(t.ray).applyMatrix4(kc),null!==this.boundingBox&&!1===Hc.intersectsBox(this.boundingBox)||this._computeIntersections(t,e,Hc)))}getVertexPosition(t,e){return super.getVertexPosition(t,e),this.applyBoneTransform(t,e),e}bind(t,e){this.skeleton=t,void 0===e&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.copy(e).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const t=new wi,e=this.geometry.attributes.skinWeight;for(let n=0,i=e.count;n<i;n++){t.fromBufferAttribute(e,n);const i=1/t.manhattanLength();i!==1/0?t.multiplyScalar(i):t.set(1,0,0,0),e.setXYZW(n,t.x,t.y,t.z,t.w)}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.bindMode===rt?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===at?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(t,e){const n=this.skeleton,i=this.geometry;Dc.fromBufferAttribute(i.attributes.skinIndex,t),Oc.fromBufferAttribute(i.attributes.skinWeight,t),Uc.copy(e).applyMatrix4(this.bindMatrix),e.set(0,0,0);for(let t=0;t<4;t++){const i=Oc.getComponent(t);if(0!==i){const s=Dc.getComponent(t);Vc.multiplyMatrices(n.bones[s].matrixWorld,n.boneInverses[s]),e.addScaledVector(zc.copy(Uc).applyMatrix4(Vc),i)}}return e.applyMatrix4(this.bindMatrixInverse)}}class Wc extends Os{constructor(){super(),this.isBone=!0,this.type="Bone"}}class jc extends Si{constructor(t=null,e=1,n=1,i,s,r,a,o,l=1003,c=1003,u,h){super(null,r,a,o,l,c,i,s,u,h),this.isDataTexture=!0,this.image={data:t,width:e,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Xc=new cs,qc=new cs;class Yc{constructor(t=[],e=[]){this.uuid=Yn(),this.bones=t.slice(0),this.boneInverses=e,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const t=this.bones,e=this.boneInverses;if(this.boneMatrices=new Float32Array(16*t.length),0===e.length)this.calculateInverses();else if(t.length!==e.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let t=0,e=this.bones.length;t<e;t++)this.boneInverses.push(new cs)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){const e=new cs;this.bones[t]&&e.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(e)}}pose(){for(let t=0,e=this.bones.length;t<e;t++){const e=this.bones[t];e&&e.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;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 t=this.bones,e=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let i=0,s=t.length;i<s;i++){const s=t[i]?t[i].matrixWorld:qc;Xc.multiplyMatrices(s,e[i]),Xc.toArray(n,16*i)}null!==i&&(i.needsUpdate=!0)}clone(){return new Yc(this.bones,this.boneInverses)}computeBoneTexture(){let t=Math.sqrt(4*this.bones.length);t=4*Math.ceil(t/4),t=Math.max(t,4);const e=new Float32Array(t*t*4);e.set(this.boneMatrices);const n=new jc(e,t,t,kt,Lt);return n.needsUpdate=!0,this.boneMatrices=e,this.boneTexture=n,this}getBoneByName(t){for(let e=0,n=this.bones.length;e<n;e++){const n=this.bones[e];if(n.name===t)return n}}dispose(){null!==this.boneTexture&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(t,e){this.uuid=t.uuid;for(let n=0,i=t.bones.length;n<i;n++){const i=t.bones[n];let s=e[i];void 0===s&&(console.warn("THREE.Skeleton: No bone found with UUID:",i),s=new Wc),this.bones.push(s),this.boneInverses.push((new cs).fromArray(t.boneInverses[n]))}return this.init(),this}toJSON(){const t={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};t.uuid=this.uuid;const e=this.bones,n=this.boneInverses;for(let i=0,s=e.length;i<s;i++){const s=e[i];t.bones.push(s.uuid);const r=n[i];t.boneInverses.push(r.toArray())}return t}}class Zc extends pr{constructor(t,e,n,i=1){super(t,e,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){const t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}}const $c=new cs,Jc=new cs,Kc=[],Qc=new Oi,tu=new cs,eu=new Hr,nu=new ts;class iu extends Hr{constructor(t,e,n){super(t,e),this.isInstancedMesh=!0,this.instanceMatrix=new Zc(new Float32Array(16*n),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let t=0;t<n;t++)this.setMatrixAt(t,tu)}computeBoundingBox(){const t=this.geometry,e=this.count;null===this.boundingBox&&(this.boundingBox=new Oi),null===t.boundingBox&&t.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<e;n++)this.getMatrixAt(n,$c),Qc.copy(t.boundingBox).applyMatrix4($c),this.boundingBox.union(Qc)}computeBoundingSphere(){const t=this.geometry,e=this.count;null===this.boundingSphere&&(this.boundingSphere=new ts),null===t.boundingSphere&&t.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<e;n++)this.getMatrixAt(n,$c),nu.copy(t.boundingSphere).applyMatrix4($c),this.boundingSphere.union(nu)}copy(t,e){return super.copy(t,e),this.instanceMatrix.copy(t.instanceMatrix),null!==t.morphTexture&&(this.morphTexture=t.morphTexture.clone()),null!==t.instanceColor&&(this.instanceColor=t.instanceColor.clone()),this.count=t.count,null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),this}getColorAt(t,e){e.fromArray(this.instanceColor.array,3*t)}getMatrixAt(t,e){e.fromArray(this.instanceMatrix.array,16*t)}getMorphAt(t,e){const n=e.morphTargetInfluences,i=this.morphTexture.source.data.data,s=t*(n.length+1)+1;for(let t=0;t<n.length;t++)n[t]=i[s+t]}raycast(t,e){const n=this.matrixWorld,i=this.count;if(eu.geometry=this.geometry,eu.material=this.material,void 0!==eu.material&&(null===this.boundingSphere&&this.computeBoundingSphere(),nu.copy(this.boundingSphere),nu.applyMatrix4(n),!1!==t.ray.intersectsSphere(nu)))for(let s=0;s<i;s++){this.getMatrixAt(s,$c),Jc.multiplyMatrices(n,$c),eu.matrixWorld=Jc,eu.raycast(t,Kc);for(let t=0,n=Kc.length;t<n;t++){const n=Kc[t];n.instanceId=s,n.object=this,e.push(n)}Kc.length=0}}setColorAt(t,e){null===this.instanceColor&&(this.instanceColor=new Zc(new Float32Array(3*this.instanceMatrix.count).fill(1),3)),e.toArray(this.instanceColor.array,3*t)}setMatrixAt(t,e){e.toArray(this.instanceMatrix.array,16*t)}setMorphAt(t,e){const n=e.morphTargetInfluences,i=n.length+1;null===this.morphTexture&&(this.morphTexture=new jc(new Float32Array(i*this.count),i,this.count,Xt,Lt));const s=this.morphTexture.source.data.data;let r=0;for(let t=0;t<n.length;t++)r+=n[t];const a=this.geometry.morphTargetsRelative?1:1-r,o=i*t;s[o]=a,s.set(n,o+1)}updateMorphTargets(){}dispose(){return this.dispatchEvent({type:"dispose"}),null!==this.morphTexture&&(this.morphTexture.dispose(),this.morphTexture=null),this}}function su(t,e){return t.z-e.z}function ru(t,e){return e.z-t.z}class au{constructor(){this.index=0,this.pool=[],this.list=[]}push(t,e,n){const i=this.pool,s=this.list;this.index>=i.length&&i.push({start:-1,count:-1,z:-1,index:-1});const r=i[this.index];s.push(r),this.index++,r.start=t.start,r.count=t.count,r.z=e,r.index=n}reset(){this.list.length=0,this.index=0}}const ou=new cs,lu=new cs,cu=new cs,uu=new er(1,1,1),hu=new cs,du=new ma,pu=new Oi,mu=new ts,fu=new Pi,gu=new Pi,vu=new Pi,yu=new au,_u=new Hr,xu=[];function Mu(t,e,n=0){const i=e.itemSize;if(t.isInterleavedBufferAttribute||t.array.constructor!==e.array.constructor){const s=t.count;for(let r=0;r<s;r++)for(let s=0;s<i;s++)e.setComponent(r+n,s,t.getComponent(r,s))}else e.array.set(t.array,n*i);e.needsUpdate=!0}class bu extends Hr{get maxInstanceCount(){return this._maxInstanceCount}constructor(t,e,n=2*e,i){super(new Rr,i),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._drawInfo=[],this._availableInstanceIds=[],this._drawRanges=[],this._reservedRanges=[],this._bounds=[],this._maxInstanceCount=t,this._maxVertexCount=e,this._maxIndexCount=n,this._geometryInitialized=!1,this._geometryCount=0,this._multiDrawCounts=new Int32Array(t),this._multiDrawStarts=new Int32Array(t),this._multiDrawCount=0,this._multiDrawInstances=null,this._visibilityChanged=!0,this._matricesTexture=null,this._indirectTexture=null,this._colorsTexture=null,this._initMatricesTexture(),this._initIndirectTexture()}_initMatricesTexture(){let t=Math.sqrt(4*this._maxInstanceCount);t=4*Math.ceil(t/4),t=Math.max(t,4);const e=new Float32Array(t*t*4),n=new jc(e,t,t,kt,Lt);this._matricesTexture=n}_initIndirectTexture(){let t=Math.sqrt(this._maxInstanceCount);t=Math.ceil(t);const e=new Uint32Array(t*t),n=new jc(e,t,t,qt,It);this._indirectTexture=n}_initColorsTexture(){let t=Math.sqrt(this._maxInstanceCount);t=Math.ceil(t);const e=new Float32Array(t*t*4).fill(1),n=new jc(e,t,t,kt,Lt);n.colorSpace=fi.workingColorSpace,this._colorsTexture=n}_initializeGeometry(t){const e=this.geometry,n=this._maxVertexCount,i=this._maxIndexCount;if(!1===this._geometryInitialized){for(const i in t.attributes){const s=t.getAttribute(i),{array:r,itemSize:a,normalized:o}=s,l=new r.constructor(n*a),c=new pr(l,a,o);e.setAttribute(i,c)}if(null!==t.getIndex()){const t=n>65535?new Uint32Array(i):new Uint16Array(i);e.setIndex(new pr(t,1))}this._geometryInitialized=!0}}_validateGeometry(t){const e=this.geometry;if(Boolean(t.getIndex())!==Boolean(e.getIndex()))throw new Error('BatchedMesh: All geometries must consistently have "index".');for(const n in e.attributes){if(!t.hasAttribute(n))throw new Error(`BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);const i=t.getAttribute(n),s=e.getAttribute(n);if(i.itemSize!==s.itemSize||i.normalized!==s.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(t){return this.customSort=t,this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Oi);const t=this.boundingBox,e=this._drawInfo;t.makeEmpty();for(let n=0,i=e.length;n<i;n++){if(!1===e[n].active)continue;const i=e[n].geometryIndex;this.getMatrixAt(n,ou),this.getBoundingBoxAt(i,pu).applyMatrix4(ou),t.union(pu)}}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new ts);const t=this.boundingSphere,e=this._drawInfo;t.makeEmpty();for(let n=0,i=e.length;n<i;n++){if(!1===e[n].active)continue;const i=e[n].geometryIndex;this.getMatrixAt(n,ou),this.getBoundingSphereAt(i,mu).applyMatrix4(ou),t.union(mu)}}addInstance(t){if(this._drawInfo.length>=this.maxInstanceCount&&0===this._availableInstanceIds.length)throw new Error("BatchedMesh: Maximum item count reached.");const e={visible:!0,active:!0,geometryIndex:t};let n=null;this._availableInstanceIds.length>0?(n=this._availableInstanceIds.pop(),this._drawInfo[n]=e):(n=this._drawInfo.length,this._drawInfo.push(e));const i=this._matricesTexture,s=i.image.data;cu.toArray(s,16*n),i.needsUpdate=!0;const r=this._colorsTexture;return r&&(uu.toArray(r.image.data,4*n),r.needsUpdate=!0),n}addGeometry(t,e=-1,n=-1){if(this._initializeGeometry(t),this._validateGeometry(t),this._drawInfo.length>=this._maxInstanceCount)throw new Error("BatchedMesh: Maximum item count reached.");const i={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1};let s=null;const r=this._reservedRanges,a=this._drawRanges,o=this._bounds;0!==this._geometryCount&&(s=r[r.length-1]),i.vertexCount=-1===e?t.getAttribute("position").count:e,i.vertexStart=null===s?0:s.vertexStart+s.vertexCount;const l=t.getIndex(),c=null!==l;if(c&&(i.indexCount=-1===n?l.count:n,i.indexStart=null===s?0:s.indexStart+s.indexCount),-1!==i.indexStart&&i.indexStart+i.indexCount>this._maxIndexCount||i.vertexStart+i.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");const u=this._geometryCount;return this._geometryCount++,r.push(i),a.push({start:c?i.indexStart:i.vertexStart,count:-1}),o.push({boxInitialized:!1,box:new Oi,sphereInitialized:!1,sphere:new ts}),this.setGeometryAt(u,t),u}setGeometryAt(t,e){if(t>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(e);const n=this.geometry,i=null!==n.getIndex(),s=n.getIndex(),r=e.getIndex(),a=this._reservedRanges[t];if(i&&r.count>a.indexCount||e.attributes.position.count>a.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const o=a.vertexStart,l=a.vertexCount;for(const t in n.attributes){const i=e.getAttribute(t),s=n.getAttribute(t);Mu(i,s,o);const r=i.itemSize;for(let t=i.count,e=l;t<e;t++){const e=o+t;for(let t=0;t<r;t++)s.setComponent(e,t,0)}s.needsUpdate=!0,s.addUpdateRange(o*r,l*r)}if(i){const t=a.indexStart;for(let e=0;e<r.count;e++)s.setX(t+e,o+r.getX(e));for(let e=r.count,n=a.indexCount;e<n;e++)s.setX(t+e,o);s.needsUpdate=!0,s.addUpdateRange(t,a.indexCount)}const c=this._bounds[t];null!==e.boundingBox?(c.box.copy(e.boundingBox),c.boxInitialized=!0):c.boxInitialized=!1,null!==e.boundingSphere?(c.sphere.copy(e.boundingSphere),c.sphereInitialized=!0):c.sphereInitialized=!1;const u=this._drawRanges[t],h=e.getAttribute("position");return u.count=i?r.count:h.count,this._visibilityChanged=!0,t}deleteInstance(t){const e=this._drawInfo;return t>=e.length||!1===e[t].active||(e[t].active=!1,this._availableInstanceIds.push(t),this._visibilityChanged=!0),this}getBoundingBoxAt(t,e){if(t>=this._geometryCount)return null;const n=this._bounds[t],i=n.box,s=this.geometry;if(!1===n.boxInitialized){i.makeEmpty();const e=s.index,r=s.attributes.position,a=this._drawRanges[t];for(let t=a.start,n=a.start+a.count;t<n;t++){let n=t;e&&(n=e.getX(n)),i.expandByPoint(fu.fromBufferAttribute(r,n))}n.boxInitialized=!0}return e.copy(i),e}getBoundingSphereAt(t,e){if(t>=this._geometryCount)return null;const n=this._bounds[t],i=n.sphere,s=this.geometry;if(!1===n.sphereInitialized){i.makeEmpty(),this.getBoundingBoxAt(t,pu),pu.getCenter(i.center);const e=s.index,r=s.attributes.position,a=this._drawRanges[t];let o=0;for(let t=a.start,n=a.start+a.count;t<n;t++){let n=t;e&&(n=e.getX(n)),fu.fromBufferAttribute(r,n),o=Math.max(o,i.center.distanceToSquared(fu))}i.radius=Math.sqrt(o),n.sphereInitialized=!0}return e.copy(i),e}setMatrixAt(t,e){const n=this._drawInfo,i=this._matricesTexture,s=this._matricesTexture.image.data;return t>=n.length||!1===n[t].active||(e.toArray(s,16*t),i.needsUpdate=!0),this}getMatrixAt(t,e){const n=this._drawInfo,i=this._matricesTexture.image.data;return t>=n.length||!1===n[t].active?null:e.fromArray(i,16*t)}setColorAt(t,e){null===this._colorsTexture&&this._initColorsTexture();const n=this._colorsTexture,i=this._colorsTexture.image.data,s=this._drawInfo;return t>=s.length||!1===s[t].active||(e.toArray(i,4*t),n.needsUpdate=!0),this}getColorAt(t,e){const n=this._colorsTexture.image.data,i=this._drawInfo;return t>=i.length||!1===i[t].active?null:e.fromArray(n,4*t)}setVisibleAt(t,e){const n=this._drawInfo;return t>=n.length||!1===n[t].active||n[t].visible===e||(n[t].visible=e,this._visibilityChanged=!0),this}getVisibleAt(t){const e=this._drawInfo;return!(t>=e.length||!1===e[t].active)&&e[t].visible}setGeometryIdAt(t,e){const n=this._drawInfo;return t>=n.length||!1===n[t].active||e<0||e>=this._geometryCount?null:(n[t].geometryIndex=e,this)}getGeometryIdAt(t){const e=this._drawInfo;return t>=e.length||!1===e[t].active?-1:e[t].geometryIndex}getGeometryRangeAt(t,e={}){if(t<0||t>=this._geometryCount)return null;const n=this._drawRanges[t];return e.start=n.start,e.count=n.count,e}raycast(t,e){const n=this._drawInfo,i=this._drawRanges,s=this.matrixWorld,r=this.geometry;_u.material=this.material,_u.geometry.index=r.index,_u.geometry.attributes=r.attributes,null===_u.geometry.boundingBox&&(_u.geometry.boundingBox=new Oi),null===_u.geometry.boundingSphere&&(_u.geometry.boundingSphere=new ts);for(let r=0,a=n.length;r<a;r++){if(!n[r].visible||!n[r].active)continue;const a=n[r].geometryIndex,o=i[a];_u.geometry.setDrawRange(o.start,o.count),this.getMatrixAt(r,_u.matrixWorld).premultiply(s),this.getBoundingBoxAt(a,_u.geometry.boundingBox),this.getBoundingSphereAt(a,_u.geometry.boundingSphere),_u.raycast(t,xu);for(let t=0,n=xu.length;t<n;t++){const n=xu[t];n.object=this,n.batchId=r,e.push(n)}xu.length=0}_u.material=null,_u.geometry.index=null,_u.geometry.attributes={},_u.geometry.setDrawRange(0,1/0)}copy(t){return super.copy(t),this.geometry=t.geometry.clone(),this.perObjectFrustumCulled=t.perObjectFrustumCulled,this.sortObjects=t.sortObjects,this.boundingBox=null!==t.boundingBox?t.boundingBox.clone():null,this.boundingSphere=null!==t.boundingSphere?t.boundingSphere.clone():null,this._drawRanges=t._drawRanges.map(t=>({...t})),this._reservedRanges=t._reservedRanges.map(t=>({...t})),this._drawInfo=t._drawInfo.map(t=>({...t})),this._bounds=t._bounds.map(t=>({boxInitialized:t.boxInitialized,box:t.box.clone(),sphereInitialized:t.sphereInitialized,sphere:t.sphere.clone()})),this._maxInstanceCount=t._maxInstanceCount,this._maxVertexCount=t._maxVertexCount,this._maxIndexCount=t._maxIndexCount,this._geometryInitialized=t._geometryInitialized,this._geometryCount=t._geometryCount,this._multiDrawCounts=t._multiDrawCounts.slice(),this._multiDrawStarts=t._multiDrawStarts.slice(),this._matricesTexture=t._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),null!==this._colorsTexture&&(this._colorsTexture=t._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,null!==this._colorsTexture&&(this._colorsTexture.dispose(),this._colorsTexture=null),this}onBeforeRender(t,e,n,i,s){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const r=i.getIndex(),a=null===r?1:r.array.BYTES_PER_ELEMENT,o=this._drawInfo,l=this._multiDrawStarts,c=this._multiDrawCounts,u=this._drawRanges,h=this.perObjectFrustumCulled,d=this._indirectTexture,p=d.image.data;h&&(hu.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),du.setFromProjectionMatrix(hu,t.coordinateSystem));let m=0;if(this.sortObjects){lu.copy(this.matrixWorld).invert(),fu.setFromMatrixPosition(n.matrixWorld).applyMatrix4(lu),gu.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(lu);for(let t=0,e=o.length;t<e;t++)if(o[t].visible&&o[t].active){const e=o[t].geometryIndex;this.getMatrixAt(t,ou),this.getBoundingSphereAt(e,mu).applyMatrix4(ou);let n=!1;if(h&&(n=!du.intersectsSphere(mu)),!n){const n=vu.subVectors(mu.center,fu).dot(gu);yu.push(u[e],n,t)}}const t=yu.list,e=this.customSort;null===e?t.sort(s.transparent?ru:su):e.call(this,t,n);for(let e=0,n=t.length;e<n;e++){const n=t[e];l[m]=n.start*a,c[m]=n.count,p[m]=n.index,m++}yu.reset()}else for(let t=0,e=o.length;t<e;t++)if(o[t].visible&&o[t].active){const e=o[t].geometryIndex;let n=!1;if(h&&(this.getMatrixAt(t,ou),this.getBoundingSphereAt(e,mu).applyMatrix4(ou),n=!du.intersectsSphere(mu)),!n){const n=u[e];l[m]=n.start*a,c[m]=n.count,p[m]=t,m++}}d.needsUpdate=!0,this._multiDrawCount=m,this._visibilityChanged=!1}onBeforeShadow(t,e,n,i,s,r){this.onBeforeRender(t,null,i,s,r)}}class Tu extends sr{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new er(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}}const Su=new Pi,wu=new Pi,Eu=new cs,Au=new ls,Nu=new ts,Cu=new Pi,Ru=new Pi;class Iu extends Os{constructor(t=new Rr,e=new Tu){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}computeLineDistances(){const t=this.geometry;if(null===t.index){const e=t.attributes.position,n=[0];for(let t=1,i=e.count;t<i;t++)Su.fromBufferAttribute(e,t-1),wu.fromBufferAttribute(e,t),n[t]=n[t-1],n[t]+=Su.distanceTo(wu);t.setAttribute("lineDistance",new br(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){const n=this.geometry,i=this.matrixWorld,s=t.params.Line.threshold,r=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),Nu.copy(n.boundingSphere),Nu.applyMatrix4(i),Nu.radius+=s,!1===t.ray.intersectsSphere(Nu))return;Eu.copy(i).invert(),Au.copy(t.ray).applyMatrix4(Eu);const a=s/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,l=this.isLineSegments?2:1,c=n.index,u=n.attributes.position;if(null!==c){const n=Math.max(0,r.start),i=Math.min(c.count,r.start+r.count);for(let s=n,r=i-1;s<r;s+=l){const n=c.getX(s),i=c.getX(s+1),r=Lu(this,t,Au,o,n,i);r&&e.push(r)}if(this.isLineLoop){const s=c.getX(i-1),r=c.getX(n),a=Lu(this,t,Au,o,s,r);a&&e.push(a)}}else{const n=Math.max(0,r.start),i=Math.min(u.count,r.start+r.count);for(let s=n,r=i-1;s<r;s+=l){const n=Lu(this,t,Au,o,s,s+1);n&&e.push(n)}if(this.isLineLoop){const s=Lu(this,t,Au,o,i-1,n);s&&e.push(s)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const n=t[e[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=n.length;t<e;t++){const e=n[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}}}}function Lu(t,e,n,i,s,r){const a=t.geometry.attributes.position;Su.fromBufferAttribute(a,s),wu.fromBufferAttribute(a,r);if(n.distanceSqToSegment(Su,wu,Cu,Ru)>i)return;Cu.applyMatrix4(t.matrixWorld);const o=e.ray.origin.distanceTo(Cu);return o<e.near||o>e.far?void 0:{distance:o,point:Ru.clone().applyMatrix4(t.matrixWorld),index:s,face:null,faceIndex:null,barycoord:null,object:t}}const Pu=new Pi,Uu=new Pi;class Du extends Iu{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const t=this.geometry;if(null===t.index){const e=t.attributes.position,n=[];for(let t=0,i=e.count;t<i;t+=2)Pu.fromBufferAttribute(e,t),Uu.fromBufferAttribute(e,t+1),n[t]=0===t?0:n[t-1],n[t+1]=n[t]+Pu.distanceTo(Uu);t.setAttribute("lineDistance",new br(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class Ou extends Iu{constructor(t,e){super(t,e),this.isLineLoop=!0,this.type="LineLoop"}}class zu extends sr{constructor(t){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new er(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}const Vu=new cs,Fu=new ls,Bu=new ts,ku=new Pi;class Hu extends Os{constructor(t=new Rr,e=new zu){super(),this.isPoints=!0,this.type="Points",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}raycast(t,e){const n=this.geometry,i=this.matrixWorld,s=t.params.Points.threshold,r=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),Bu.copy(n.boundingSphere),Bu.applyMatrix4(i),Bu.radius+=s,!1===t.ray.intersectsSphere(Bu))return;Vu.copy(i).invert(),Fu.copy(t.ray).applyMatrix4(Vu);const a=s/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,l=n.index,c=n.attributes.position;if(null!==l){for(let n=Math.max(0,r.start),s=Math.min(l.count,r.start+r.count);n<s;n++){const s=l.getX(n);ku.fromBufferAttribute(c,s),Gu(ku,s,o,i,t,e,this)}}else{for(let n=Math.max(0,r.start),s=Math.min(c.count,r.start+r.count);n<s;n++)ku.fromBufferAttribute(c,n),Gu(ku,n,o,i,t,e,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const n=t[e[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=n.length;t<e;t++){const e=n[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}}}}function Gu(t,e,n,i,s,r,a){const o=Fu.distanceSqToPoint(t);if(o<n){const n=new Pi;Fu.closestPointToPoint(t,n),n.applyMatrix4(i);const l=s.ray.origin.distanceTo(n);if(l<s.near||l>s.far)return;r.push({distance:l,distanceToRay:Math.sqrt(o),point:n,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class Wu extends Si{constructor(t,e,n,i,s,r,a,o,l){super(t,e,n,i,s,r,a,o,l),this.isVideoTexture=!0,this.minFilter=void 0!==r?r:Mt,this.magFilter=void 0!==s?s:Mt,this.generateMipmaps=!1;const c=this;"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback(function e(){c.needsUpdate=!0,t.requestVideoFrameCallback(e)})}clone(){return new this.constructor(this.image).copy(this)}update(){const t=this.image;!1==="requestVideoFrameCallback"in t&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class ju extends Si{constructor(t,e){super({width:t,height:e}),this.isFramebufferTexture=!0,this.magFilter=gt,this.minFilter=gt,this.generateMipmaps=!1,this.needsUpdate=!0}}class Xu extends Si{constructor(t,e,n,i,s,r,a,o,l,c,u,h){super(null,r,a,o,l,c,i,s,u,h),this.isCompressedTexture=!0,this.image={width:e,height:n},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}}class qu extends Xu{constructor(t,e,n,i,s,r){super(t,e,n,s,r),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=mt,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class Yu extends Xu{constructor(t,e,n){super(void 0,t[0].width,t[0].height,e,n,lt),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=t}}class Zu extends Si{constructor(t,e,n,i,s,r,a,o,l){super(t,e,n,i,s,r,a,o,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class $u{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(t,e){const n=this.getUtoTmapping(t);return this.getPoint(n,e)}getPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return e}getSpacedPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const e=[];let n,i=this.getPoint(0),s=0;e.push(0);for(let r=1;r<=t;r++)n=this.getPoint(r/t),s+=n.distanceTo(i),e.push(s),i=n;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){const n=this.getLengths();let i=0;const s=n.length;let r;r=e||t*n[s-1];let a,o=0,l=s-1;for(;o<=l;)if(i=Math.floor(o+(l-o)/2),a=n[i]-r,a<0)o=i+1;else{if(!(a>0)){l=i;break}l=i-1}if(i=l,n[i]===r)return i/(s-1);const c=n[i];return(i+(r-c)/(n[i+1]-c))/(s-1)}getTangent(t,e){const n=1e-4;let i=t-n,s=t+n;i<0&&(i=0),s>1&&(s=1);const r=this.getPoint(i),a=this.getPoint(s),o=e||(r.isVector2?new ei:new Pi);return o.copy(a).sub(r).normalize(),o}getTangentAt(t,e){const n=this.getUtoTmapping(t);return this.getTangent(n,e)}computeFrenetFrames(t,e){const n=new Pi,i=[],s=[],r=[],a=new Pi,o=new cs;for(let e=0;e<=t;e++){const n=e/t;i[e]=this.getTangentAt(n,new Pi)}s[0]=new Pi,r[0]=new Pi;let l=Number.MAX_VALUE;const c=Math.abs(i[0].x),u=Math.abs(i[0].y),h=Math.abs(i[0].z);c<=l&&(l=c,n.set(1,0,0)),u<=l&&(l=u,n.set(0,1,0)),h<=l&&n.set(0,0,1),a.crossVectors(i[0],n).normalize(),s[0].crossVectors(i[0],a),r[0].crossVectors(i[0],s[0]);for(let e=1;e<=t;e++){if(s[e]=s[e-1].clone(),r[e]=r[e-1].clone(),a.crossVectors(i[e-1],i[e]),a.length()>Number.EPSILON){a.normalize();const t=Math.acos(Zn(i[e-1].dot(i[e]),-1,1));s[e].applyMatrix4(o.makeRotationAxis(a,t))}r[e].crossVectors(i[e],s[e])}if(!0===e){let e=Math.acos(Zn(s[0].dot(s[t]),-1,1));e/=t,i[0].dot(a.crossVectors(s[0],s[t]))>0&&(e=-e);for(let n=1;n<=t;n++)s[n].applyMatrix4(o.makeRotationAxis(i[n],e*n)),r[n].crossVectors(i[n],s[n])}return{tangents:i,normals:s,binormals:r}}clone(){return(new this.constructor).copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){const t={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}class Ju extends $u{constructor(t=0,e=0,n=1,i=1,s=0,r=2*Math.PI,a=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=n,this.yRadius=i,this.aStartAngle=s,this.aEndAngle=r,this.aClockwise=a,this.aRotation=o}getPoint(t,e=new ei){const n=e,i=2*Math.PI;let s=this.aEndAngle-this.aStartAngle;const r=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=i;for(;s>i;)s-=i;s<Number.EPSILON&&(s=r?0:i),!0!==this.aClockwise||r||(s===i?s=-i:s-=i);const a=this.aStartAngle+t*s;let o=this.aX+this.xRadius*Math.cos(a),l=this.aY+this.yRadius*Math.sin(a);if(0!==this.aRotation){const t=Math.cos(this.aRotation),e=Math.sin(this.aRotation),n=o-this.aX,i=l-this.aY;o=n*t-i*e+this.aX,l=n*e+i*t+this.aY}return n.set(o,l)}copy(t){return super.copy(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}toJSON(){const t=super.toJSON();return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t}fromJSON(t){return super.fromJSON(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}}class Ku extends Ju{constructor(t,e,n,i,s,r){super(t,e,n,n,i,s,r),this.isArcCurve=!0,this.type="ArcCurve"}}function Qu(){let t=0,e=0,n=0,i=0;function s(s,r,a,o){t=s,e=a,n=-3*s+3*r-2*a-o,i=2*s-2*r+a+o}return{initCatmullRom:function(t,e,n,i,r){s(e,n,r*(n-t),r*(i-e))},initNonuniformCatmullRom:function(t,e,n,i,r,a,o){let l=(e-t)/r-(n-t)/(r+a)+(n-e)/a,c=(n-e)/a-(i-e)/(a+o)+(i-n)/o;l*=a,c*=a,s(e,n,l,c)},calc:function(s){const r=s*s;return t+e*s+n*r+i*(r*s)}}}const th=new Pi,eh=new Qu,nh=new Qu,ih=new Qu;class sh extends $u{constructor(t=[],e=!1,n="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=n,this.tension=i}getPoint(t,e=new Pi){const n=e,i=this.points,s=i.length,r=(s-(this.closed?0:1))*t;let a,o,l=Math.floor(r),c=r-l;this.closed?l+=l>0?0:(Math.floor(Math.abs(l)/s)+1)*s:0===c&&l===s-1&&(l=s-2,c=1),this.closed||l>0?a=i[(l-1)%s]:(th.subVectors(i[0],i[1]).add(i[0]),a=th);const u=i[l%s],h=i[(l+1)%s];if(this.closed||l+2<s?o=i[(l+2)%s]:(th.subVectors(i[s-1],i[s-2]).add(i[s-1]),o=th),"centripetal"===this.curveType||"chordal"===this.curveType){const t="chordal"===this.curveType?.5:.25;let e=Math.pow(a.distanceToSquared(u),t),n=Math.pow(u.distanceToSquared(h),t),i=Math.pow(h.distanceToSquared(o),t);n<1e-4&&(n=1),e<1e-4&&(e=n),i<1e-4&&(i=n),eh.initNonuniformCatmullRom(a.x,u.x,h.x,o.x,e,n,i),nh.initNonuniformCatmullRom(a.y,u.y,h.y,o.y,e,n,i),ih.initNonuniformCatmullRom(a.z,u.z,h.z,o.z,e,n,i)}else"catmullrom"===this.curveType&&(eh.initCatmullRom(a.x,u.x,h.x,o.x,this.tension),nh.initCatmullRom(a.y,u.y,h.y,o.y,this.tension),ih.initCatmullRom(a.z,u.z,h.z,o.z,this.tension));return n.set(eh.calc(c),nh.calc(c),ih.calc(c)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const n=t.points[e];this.points.push(n.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){const n=this.points[e];t.points.push(n.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const n=t.points[e];this.points.push((new Pi).fromArray(n))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}}function rh(t,e,n,i,s){const r=.5*(i-e),a=.5*(s-n),o=t*t;return(2*n-2*i+r+a)*(t*o)+(-3*n+3*i-2*r-a)*o+r*t+n}function ah(t,e,n,i){return function(t,e){const n=1-t;return n*n*e}(t,e)+function(t,e){return 2*(1-t)*t*e}(t,n)+function(t,e){return t*t*e}(t,i)}function oh(t,e,n,i,s){return function(t,e){const n=1-t;return n*n*n*e}(t,e)+function(t,e){const n=1-t;return 3*n*n*t*e}(t,n)+function(t,e){return 3*(1-t)*t*t*e}(t,i)+function(t,e){return t*t*t*e}(t,s)}class lh extends $u{constructor(t=new ei,e=new ei,n=new ei,i=new ei){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=n,this.v3=i}getPoint(t,e=new ei){const n=e,i=this.v0,s=this.v1,r=this.v2,a=this.v3;return n.set(oh(t,i.x,s.x,r.x,a.x),oh(t,i.y,s.y,r.y,a.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}}class ch extends $u{constructor(t=new Pi,e=new Pi,n=new Pi,i=new Pi){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=n,this.v3=i}getPoint(t,e=new Pi){const n=e,i=this.v0,s=this.v1,r=this.v2,a=this.v3;return n.set(oh(t,i.x,s.x,r.x,a.x),oh(t,i.y,s.y,r.y,a.y),oh(t,i.z,s.z,r.z,a.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}}class uh extends $u{constructor(t=new ei,e=new ei){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new ei){const n=e;return 1===t?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new ei){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class hh extends $u{constructor(t=new Pi,e=new Pi){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new Pi){const n=e;return 1===t?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new Pi){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class dh extends $u{constructor(t=new ei,e=new ei,n=new ei){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new ei){const n=e,i=this.v0,s=this.v1,r=this.v2;return n.set(ah(t,i.x,s.x,r.x),ah(t,i.y,s.y,r.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class ph extends $u{constructor(t=new Pi,e=new Pi,n=new Pi){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new Pi){const n=e,i=this.v0,s=this.v1,r=this.v2;return n.set(ah(t,i.x,s.x,r.x),ah(t,i.y,s.y,r.y),ah(t,i.z,s.z,r.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class mh extends $u{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new ei){const n=e,i=this.points,s=(i.length-1)*t,r=Math.floor(s),a=s-r,o=i[0===r?r:r-1],l=i[r],c=i[r>i.length-2?i.length-1:r+1],u=i[r>i.length-3?i.length-1:r+2];return n.set(rh(a,o.x,l.x,c.x,u.x),rh(a,o.y,l.y,c.y,u.y)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const n=t.points[e];this.points.push(n.clone())}return this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){const n=this.points[e];t.points.push(n.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const n=t.points[e];this.points.push((new ei).fromArray(n))}return this}}var fh=Object.freeze({__proto__:null,ArcCurve:Ku,CatmullRomCurve3:sh,CubicBezierCurve:lh,CubicBezierCurve3:ch,EllipseCurve:Ju,LineCurve:uh,LineCurve3:hh,QuadraticBezierCurve:dh,QuadraticBezierCurve3:ph,SplineCurve:mh});class gh extends $u{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(t){this.curves.push(t)}closePath(){const t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);if(!t.equals(e)){const n=!0===t.isVector2?"LineCurve":"LineCurve3";this.curves.push(new fh[n](e,t))}return this}getPoint(t,e){const n=t*this.getLength(),i=this.getCurveLengths();let s=0;for(;s<i.length;){if(i[s]>=n){const t=i[s]-n,r=this.curves[s],a=r.getLength(),o=0===a?0:1-t/a;return r.getPointAt(o,e)}s++}return null}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const t=[];let e=0;for(let n=0,i=this.curves.length;n<i;n++)e+=this.curves[n].getLength(),t.push(e);return this.cacheLengths=t,t}getSpacedPoints(t=40){const e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){const e=[];let n;for(let i=0,s=this.curves;i<s.length;i++){const r=s[i],a=r.isEllipseCurve?2*t:r.isLineCurve||r.isLineCurve3?1:r.isSplineCurve?t*r.points.length:t,o=r.getPoints(a);for(let t=0;t<o.length;t++){const i=o[t];n&&n.equals(i)||(e.push(i),n=i)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){const n=t.curves[e];this.curves.push(n.clone())}return this.autoClose=t.autoClose,this}toJSON(){const t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let e=0,n=this.curves.length;e<n;e++){const n=this.curves[e];t.curves.push(n.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){const n=t.curves[e];this.curves.push((new fh[n.type]).fromJSON(n))}return this}}class vh extends gh{constructor(t){super(),this.type="Path",this.currentPoint=new ei,t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,n=t.length;e<n;e++)this.lineTo(t[e].x,t[e].y);return this}moveTo(t,e){return this.currentPoint.set(t,e),this}lineTo(t,e){const n=new uh(this.currentPoint.clone(),new ei(t,e));return this.curves.push(n),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,n,i){const s=new dh(this.currentPoint.clone(),new ei(t,e),new ei(n,i));return this.curves.push(s),this.currentPoint.set(n,i),this}bezierCurveTo(t,e,n,i,s,r){const a=new lh(this.currentPoint.clone(),new ei(t,e),new ei(n,i),new ei(s,r));return this.curves.push(a),this.currentPoint.set(s,r),this}splineThru(t){const e=[this.currentPoint.clone()].concat(t),n=new mh(e);return this.curves.push(n),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,n,i,s,r){const a=this.currentPoint.x,o=this.currentPoint.y;return this.absarc(t+a,e+o,n,i,s,r),this}absarc(t,e,n,i,s,r){return this.absellipse(t,e,n,n,i,s,r),this}ellipse(t,e,n,i,s,r,a,o){const l=this.currentPoint.x,c=this.currentPoint.y;return this.absellipse(t+l,e+c,n,i,s,r,a,o),this}absellipse(t,e,n,i,s,r,a,o){const l=new Ju(t,e,n,i,s,r,a,o);if(this.curves.length>0){const t=l.getPoint(0);t.equals(this.currentPoint)||this.lineTo(t.x,t.y)}this.curves.push(l);const c=l.getPoint(1);return this.currentPoint.copy(c),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){const t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}}class yh extends Rr{constructor(t=[new ei(0,-.5),new ei(.5,0),new ei(0,.5)],e=12,n=0,i=2*Math.PI){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:n,phiLength:i},e=Math.floor(e),i=Zn(i,0,2*Math.PI);const s=[],r=[],a=[],o=[],l=[],c=1/e,u=new Pi,h=new ei,d=new Pi,p=new Pi,m=new Pi;let f=0,g=0;for(let e=0;e<=t.length-1;e++)switch(e){case 0:f=t[e+1].x-t[e].x,g=t[e+1].y-t[e].y,d.x=1*g,d.y=-f,d.z=0*g,m.copy(d),d.normalize(),o.push(d.x,d.y,d.z);break;case t.length-1:o.push(m.x,m.y,m.z);break;default:f=t[e+1].x-t[e].x,g=t[e+1].y-t[e].y,d.x=1*g,d.y=-f,d.z=0*g,p.copy(d),d.x+=m.x,d.y+=m.y,d.z+=m.z,d.normalize(),o.push(d.x,d.y,d.z),m.copy(p)}for(let s=0;s<=e;s++){const d=n+s*c*i,p=Math.sin(d),m=Math.cos(d);for(let n=0;n<=t.length-1;n++){u.x=t[n].x*p,u.y=t[n].y,u.z=t[n].x*m,r.push(u.x,u.y,u.z),h.x=s/e,h.y=n/(t.length-1),a.push(h.x,h.y);const i=o[3*n+0]*p,c=o[3*n+1],d=o[3*n+0]*m;l.push(i,c,d)}}for(let n=0;n<e;n++)for(let e=0;e<t.length-1;e++){const i=e+n*t.length,r=i,a=i+t.length,o=i+t.length+1,l=i+1;s.push(r,a,l),s.push(o,l,a)}this.setIndex(s),this.setAttribute("position",new br(r,3)),this.setAttribute("uv",new br(a,2)),this.setAttribute("normal",new br(l,3))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new yh(t.points,t.segments,t.phiStart,t.phiLength)}}class _h extends yh{constructor(t=1,e=1,n=4,i=8){const s=new vh;s.absarc(0,-e/2,t,1.5*Math.PI,0),s.absarc(0,e/2,t,0,.5*Math.PI),super(s.getPoints(n),i),this.type="CapsuleGeometry",this.parameters={radius:t,length:e,capSegments:n,radialSegments:i}}static fromJSON(t){return new _h(t.radius,t.length,t.capSegments,t.radialSegments)}}class xh extends Rr{constructor(t=1,e=32,n=0,i=2*Math.PI){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:i},e=Math.max(3,e);const s=[],r=[],a=[],o=[],l=new Pi,c=new ei;r.push(0,0,0),a.push(0,0,1),o.push(.5,.5);for(let s=0,u=3;s<=e;s++,u+=3){const h=n+s/e*i;l.x=t*Math.cos(h),l.y=t*Math.sin(h),r.push(l.x,l.y,l.z),a.push(0,0,1),c.x=(r[u]/t+1)/2,c.y=(r[u+1]/t+1)/2,o.push(c.x,c.y)}for(let t=1;t<=e;t++)s.push(t,t+1,0);this.setIndex(s),this.setAttribute("position",new br(r,3)),this.setAttribute("normal",new br(a,3)),this.setAttribute("uv",new br(o,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new xh(t.radius,t.segments,t.thetaStart,t.thetaLength)}}class Mh extends Rr{constructor(t=1,e=1,n=1,i=32,s=1,r=!1,a=0,o=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:n,radialSegments:i,heightSegments:s,openEnded:r,thetaStart:a,thetaLength:o};const l=this;i=Math.floor(i),s=Math.floor(s);const c=[],u=[],h=[],d=[];let p=0;const m=[],f=n/2;let g=0;function v(n){const s=p,r=new ei,m=new Pi;let v=0;const y=!0===n?t:e,_=!0===n?1:-1;for(let t=1;t<=i;t++)u.push(0,f*_,0),h.push(0,_,0),d.push(.5,.5),p++;const x=p;for(let t=0;t<=i;t++){const e=t/i*o+a,n=Math.cos(e),s=Math.sin(e);m.x=y*s,m.y=f*_,m.z=y*n,u.push(m.x,m.y,m.z),h.push(0,_,0),r.x=.5*n+.5,r.y=.5*s*_+.5,d.push(r.x,r.y),p++}for(let t=0;t<i;t++){const e=s+t,i=x+t;!0===n?c.push(i,i+1,e):c.push(i+1,i,e),v+=3}l.addGroup(g,v,!0===n?1:2),g+=v}!function(){const r=new Pi,v=new Pi;let y=0;const _=(e-t)/n;for(let l=0;l<=s;l++){const c=[],g=l/s,y=g*(e-t)+t;for(let t=0;t<=i;t++){const e=t/i,s=e*o+a,l=Math.sin(s),m=Math.cos(s);v.x=y*l,v.y=-g*n+f,v.z=y*m,u.push(v.x,v.y,v.z),r.set(l,_,m).normalize(),h.push(r.x,r.y,r.z),d.push(e,1-g),c.push(p++)}m.push(c)}for(let n=0;n<i;n++)for(let i=0;i<s;i++){const s=m[i][n],r=m[i+1][n],a=m[i+1][n+1],o=m[i][n+1];t>0&&(c.push(s,r,o),y+=3),e>0&&(c.push(r,a,o),y+=3)}l.addGroup(g,y,0),g+=y}(),!1===r&&(t>0&&v(!0),e>0&&v(!1)),this.setIndex(c),this.setAttribute("position",new br(u,3)),this.setAttribute("normal",new br(h,3)),this.setAttribute("uv",new br(d,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Mh(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class bh extends Mh{constructor(t=1,e=1,n=32,i=1,s=!1,r=0,a=2*Math.PI){super(0,t,e,n,i,s,r,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:i,openEnded:s,thetaStart:r,thetaLength:a}}static fromJSON(t){return new bh(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class Th extends Rr{constructor(t=[],e=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:n,detail:i};const s=[],r=[];function a(t,e,n,i){const s=i+1,r=[];for(let i=0;i<=s;i++){r[i]=[];const a=t.clone().lerp(n,i/s),o=e.clone().lerp(n,i/s),l=s-i;for(let t=0;t<=l;t++)r[i][t]=0===t&&i===s?a:a.clone().lerp(o,t/l)}for(let t=0;t<s;t++)for(let e=0;e<2*(s-t)-1;e++){const n=Math.floor(e/2);e%2==0?(o(r[t][n+1]),o(r[t+1][n]),o(r[t][n])):(o(r[t][n+1]),o(r[t+1][n+1]),o(r[t+1][n]))}}function o(t){s.push(t.x,t.y,t.z)}function l(e,n){const i=3*e;n.x=t[i+0],n.y=t[i+1],n.z=t[i+2]}function c(t,e,n,i){i<0&&1===t.x&&(r[e]=t.x-1),0===n.x&&0===n.z&&(r[e]=i/2/Math.PI+.5)}function u(t){return Math.atan2(t.z,-t.x)}function h(t){return Math.atan2(-t.y,Math.sqrt(t.x*t.x+t.z*t.z))}!function(t){const n=new Pi,i=new Pi,s=new Pi;for(let r=0;r<e.length;r+=3)l(e[r+0],n),l(e[r+1],i),l(e[r+2],s),a(n,i,s,t)}(i),function(t){const e=new Pi;for(let n=0;n<s.length;n+=3)e.x=s[n+0],e.y=s[n+1],e.z=s[n+2],e.normalize().multiplyScalar(t),s[n+0]=e.x,s[n+1]=e.y,s[n+2]=e.z}(n),function(){const t=new Pi;for(let e=0;e<s.length;e+=3){t.x=s[e+0],t.y=s[e+1],t.z=s[e+2];const n=u(t)/2/Math.PI+.5,i=h(t)/Math.PI+.5;r.push(n,1-i)}(function(){const t=new Pi,e=new Pi,n=new Pi,i=new Pi,a=new ei,o=new ei,l=new ei;for(let h=0,d=0;h<s.length;h+=9,d+=6){t.set(s[h+0],s[h+1],s[h+2]),e.set(s[h+3],s[h+4],s[h+5]),n.set(s[h+6],s[h+7],s[h+8]),a.set(r[d+0],r[d+1]),o.set(r[d+2],r[d+3]),l.set(r[d+4],r[d+5]),i.copy(t).add(e).add(n).divideScalar(3);const p=u(i);c(a,d+0,t,p),c(o,d+2,e,p),c(l,d+4,n,p)}})(),function(){for(let t=0;t<r.length;t+=6){const e=r[t+0],n=r[t+2],i=r[t+4],s=Math.max(e,n,i),a=Math.min(e,n,i);s>.9&&a<.1&&(e<.2&&(r[t+0]+=1),n<.2&&(r[t+2]+=1),i<.2&&(r[t+4]+=1))}}()}(),this.setAttribute("position",new br(s,3)),this.setAttribute("normal",new br(s.slice(),3)),this.setAttribute("uv",new br(r,2)),0===i?this.computeVertexNormals():this.normalizeNormals()}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Th(t.vertices,t.indices,t.radius,t.details)}}class Sh extends Th{constructor(t=1,e=0){const n=(1+Math.sqrt(5))/2,i=1/n;super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],t,e),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new Sh(t.radius,t.detail)}}const wh=new Pi,Eh=new Pi,Ah=new Pi,Nh=new $s;class Ch extends Rr{constructor(t=null,e=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:t,thresholdAngle:e},null!==t){const n=4,i=Math.pow(10,n),s=Math.cos(Xn*e),r=t.getIndex(),a=t.getAttribute("position"),o=r?r.count:a.count,l=[0,0,0],c=["a","b","c"],u=new Array(3),h={},d=[];for(let t=0;t<o;t+=3){r?(l[0]=r.getX(t),l[1]=r.getX(t+1),l[2]=r.getX(t+2)):(l[0]=t,l[1]=t+1,l[2]=t+2);const{a:e,b:n,c:o}=Nh;if(e.fromBufferAttribute(a,l[0]),n.fromBufferAttribute(a,l[1]),o.fromBufferAttribute(a,l[2]),Nh.getNormal(Ah),u[0]=`${Math.round(e.x*i)},${Math.round(e.y*i)},${Math.round(e.z*i)}`,u[1]=`${Math.round(n.x*i)},${Math.round(n.y*i)},${Math.round(n.z*i)}`,u[2]=`${Math.round(o.x*i)},${Math.round(o.y*i)},${Math.round(o.z*i)}`,u[0]!==u[1]&&u[1]!==u[2]&&u[2]!==u[0])for(let t=0;t<3;t++){const e=(t+1)%3,n=u[t],i=u[e],r=Nh[c[t]],a=Nh[c[e]],o=`${n}_${i}`,p=`${i}_${n}`;p in h&&h[p]?(Ah.dot(h[p].normal)<=s&&(d.push(r.x,r.y,r.z),d.push(a.x,a.y,a.z)),h[p]=null):o in h||(h[o]={index0:l[t],index1:l[e],normal:Ah.clone()})}}for(const t in h)if(h[t]){const{index0:e,index1:n}=h[t];wh.fromBufferAttribute(a,e),Eh.fromBufferAttribute(a,n),d.push(wh.x,wh.y,wh.z),d.push(Eh.x,Eh.y,Eh.z)}this.setAttribute("position",new br(d,3))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}}class Rh extends vh{constructor(t){super(t),this.uuid=Yn(),this.type="Shape",this.holes=[]}getPointsHoles(t){const e=[];for(let n=0,i=this.holes.length;n<i;n++)e[n]=this.holes[n].getPoints(t);return e}extractPoints(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}}copy(t){super.copy(t),this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){const n=t.holes[e];this.holes.push(n.clone())}return this}toJSON(){const t=super.toJSON();t.uuid=this.uuid,t.holes=[];for(let e=0,n=this.holes.length;e<n;e++){const n=this.holes[e];t.holes.push(n.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.uuid=t.uuid,this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){const n=t.holes[e];this.holes.push((new vh).fromJSON(n))}return this}}const Ih=function(t,e,n=2){const i=e&&e.length,s=i?e[0]*n:t.length;let r=Lh(t,0,s,n,!0);const a=[];if(!r||r.next===r.prev)return a;let o,l,c,u,h,d,p;if(i&&(r=function(t,e,n,i){const s=[];let r,a,o,l,c;for(r=0,a=e.length;r<a;r++)o=e[r]*i,l=r<a-1?e[r+1]*i:t.length,c=Lh(t,o,l,i,!1),c===c.next&&(c.steiner=!0),s.push(Gh(c));for(s.sort(Fh),r=0;r<s.length;r++)n=Bh(s[r],n);return n}(t,e,r,n)),t.length>80*n){o=c=t[0],l=u=t[1];for(let e=n;e<s;e+=n)h=t[e],d=t[e+1],h<o&&(o=h),d<l&&(l=d),h>c&&(c=h),d>u&&(u=d);p=Math.max(c-o,u-l),p=0!==p?32767/p:0}return Uh(r,a,n,o,l,p,0),a};function Lh(t,e,n,i,s){let r,a;if(s===function(t,e,n,i){let s=0;for(let r=e,a=n-i;r<n;r+=i)s+=(t[a]-t[r])*(t[r+1]+t[a+1]),a=r;return s}(t,e,n,i)>0)for(r=e;r<n;r+=i)a=Qh(r,t[r],t[r+1],a);else for(r=n-i;r>=e;r-=i)a=Qh(r,t[r],t[r+1],a);return a&&qh(a,a.next)&&(td(a),a=a.next),a}function Ph(t,e){if(!t)return t;e||(e=t);let n,i=t;do{if(n=!1,i.steiner||!qh(i,i.next)&&0!==Xh(i.prev,i,i.next))i=i.next;else{if(td(i),i=e=i.prev,i===i.next)break;n=!0}}while(n||i!==e);return e}function Uh(t,e,n,i,s,r,a){if(!t)return;!a&&r&&function(t,e,n,i){let s=t;do{0===s.z&&(s.z=Hh(s.x,s.y,e,n,i)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next}while(s!==t);s.prevZ.nextZ=null,s.prevZ=null,function(t){let e,n,i,s,r,a,o,l,c=1;do{for(n=t,t=null,r=null,a=0;n;){for(a++,i=n,o=0,e=0;e<c&&(o++,i=i.nextZ,i);e++);for(l=c;o>0||l>0&&i;)0!==o&&(0===l||!i||n.z<=i.z)?(s=n,n=n.nextZ,o--):(s=i,i=i.nextZ,l--),r?r.nextZ=s:t=s,s.prevZ=r,r=s;n=i}r.nextZ=null,c*=2}while(a>1)}(s)}(t,i,s,r);let o,l,c=t;for(;t.prev!==t.next;)if(o=t.prev,l=t.next,r?Oh(t,i,s,r):Dh(t))e.push(o.i/n|0),e.push(t.i/n|0),e.push(l.i/n|0),td(t),t=l.next,c=l.next;else if((t=l)===c){a?1===a?Uh(t=zh(Ph(t),e,n),e,n,i,s,r,2):2===a&&Vh(t,e,n,i,s,r):Uh(Ph(t),e,n,i,s,r,1);break}}function Dh(t){const e=t.prev,n=t,i=t.next;if(Xh(e,n,i)>=0)return!1;const s=e.x,r=n.x,a=i.x,o=e.y,l=n.y,c=i.y,u=s<r?s<a?s:a:r<a?r:a,h=o<l?o<c?o:c:l<c?l:c,d=s>r?s>a?s:a:r>a?r:a,p=o>l?o>c?o:c:l>c?l:c;let m=i.next;for(;m!==e;){if(m.x>=u&&m.x<=d&&m.y>=h&&m.y<=p&&Wh(s,o,r,l,a,c,m.x,m.y)&&Xh(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function Oh(t,e,n,i){const s=t.prev,r=t,a=t.next;if(Xh(s,r,a)>=0)return!1;const o=s.x,l=r.x,c=a.x,u=s.y,h=r.y,d=a.y,p=o<l?o<c?o:c:l<c?l:c,m=u<h?u<d?u:d:h<d?h:d,f=o>l?o>c?o:c:l>c?l:c,g=u>h?u>d?u:d:h>d?h:d,v=Hh(p,m,e,n,i),y=Hh(f,g,e,n,i);let _=t.prevZ,x=t.nextZ;for(;_&&_.z>=v&&x&&x.z<=y;){if(_.x>=p&&_.x<=f&&_.y>=m&&_.y<=g&&_!==s&&_!==a&&Wh(o,u,l,h,c,d,_.x,_.y)&&Xh(_.prev,_,_.next)>=0)return!1;if(_=_.prevZ,x.x>=p&&x.x<=f&&x.y>=m&&x.y<=g&&x!==s&&x!==a&&Wh(o,u,l,h,c,d,x.x,x.y)&&Xh(x.prev,x,x.next)>=0)return!1;x=x.nextZ}for(;_&&_.z>=v;){if(_.x>=p&&_.x<=f&&_.y>=m&&_.y<=g&&_!==s&&_!==a&&Wh(o,u,l,h,c,d,_.x,_.y)&&Xh(_.prev,_,_.next)>=0)return!1;_=_.prevZ}for(;x&&x.z<=y;){if(x.x>=p&&x.x<=f&&x.y>=m&&x.y<=g&&x!==s&&x!==a&&Wh(o,u,l,h,c,d,x.x,x.y)&&Xh(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function zh(t,e,n){let i=t;do{const s=i.prev,r=i.next.next;!qh(s,r)&&Yh(s,i,i.next,r)&&Jh(s,r)&&Jh(r,s)&&(e.push(s.i/n|0),e.push(i.i/n|0),e.push(r.i/n|0),td(i),td(i.next),i=t=r),i=i.next}while(i!==t);return Ph(i)}function Vh(t,e,n,i,s,r){let a=t;do{let t=a.next.next;for(;t!==a.prev;){if(a.i!==t.i&&jh(a,t)){let o=Kh(a,t);return a=Ph(a,a.next),o=Ph(o,o.next),Uh(a,e,n,i,s,r,0),void Uh(o,e,n,i,s,r,0)}t=t.next}a=a.next}while(a!==t)}function Fh(t,e){return t.x-e.x}function Bh(t,e){const n=function(t,e){let n,i=e,s=-1/0;const r=t.x,a=t.y;do{if(a<=i.y&&a>=i.next.y&&i.next.y!==i.y){const t=i.x+(a-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(t<=r&&t>s&&(s=t,n=i.x<i.next.x?i:i.next,t===r))return n}i=i.next}while(i!==e);if(!n)return null;const o=n,l=n.x,c=n.y;let u,h=1/0;i=n;do{r>=i.x&&i.x>=l&&r!==i.x&&Wh(a<c?r:s,a,l,c,a<c?s:r,a,i.x,i.y)&&(u=Math.abs(a-i.y)/(r-i.x),Jh(i,t)&&(u<h||u===h&&(i.x>n.x||i.x===n.x&&kh(n,i)))&&(n=i,h=u)),i=i.next}while(i!==o);return n}(t,e);if(!n)return e;const i=Kh(n,t);return Ph(i,i.next),Ph(n,n.next)}function kh(t,e){return Xh(t.prev,t,e.prev)<0&&Xh(e.next,t,t.next)<0}function Hh(t,e,n,i,s){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*s|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*s|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Gh(t){let e=t,n=t;do{(e.x<n.x||e.x===n.x&&e.y<n.y)&&(n=e),e=e.next}while(e!==t);return n}function Wh(t,e,n,i,s,r,a,o){return(s-a)*(e-o)>=(t-a)*(r-o)&&(t-a)*(i-o)>=(n-a)*(e-o)&&(n-a)*(r-o)>=(s-a)*(i-o)}function jh(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&Yh(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&(Jh(t,e)&&Jh(e,t)&&function(t,e){let n=t,i=!1;const s=(t.x+e.x)/2,r=(t.y+e.y)/2;do{n.y>r!=n.next.y>r&&n.next.y!==n.y&&s<(n.next.x-n.x)*(r-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==t);return i}(t,e)&&(Xh(t.prev,t,e.prev)||Xh(t,e.prev,e))||qh(t,e)&&Xh(t.prev,t,t.next)>0&&Xh(e.prev,e,e.next)>0)}function Xh(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function qh(t,e){return t.x===e.x&&t.y===e.y}function Yh(t,e,n,i){const s=$h(Xh(t,e,n)),r=$h(Xh(t,e,i)),a=$h(Xh(n,i,t)),o=$h(Xh(n,i,e));return s!==r&&a!==o||(!(0!==s||!Zh(t,n,e))||(!(0!==r||!Zh(t,i,e))||(!(0!==a||!Zh(n,t,i))||!(0!==o||!Zh(n,e,i)))))}function Zh(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function $h(t){return t>0?1:t<0?-1:0}function Jh(t,e){return Xh(t.prev,t,t.next)<0?Xh(t,e,t.next)>=0&&Xh(t,t.prev,e)>=0:Xh(t,e,t.prev)<0||Xh(t,t.next,e)<0}function Kh(t,e){const n=new ed(t.i,t.x,t.y),i=new ed(e.i,e.x,e.y),s=t.next,r=e.prev;return t.next=e,e.prev=t,n.next=s,s.prev=n,i.next=n,n.prev=i,r.next=i,i.prev=r,i}function Qh(t,e,n,i){const s=new ed(t,e,n);return i?(s.next=i.next,s.prev=i,i.next.prev=s,i.next=s):(s.prev=s,s.next=s),s}function td(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function ed(t,e,n){this.i=t,this.x=e,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}class nd{static area(t){const e=t.length;let n=0;for(let i=e-1,s=0;s<e;i=s++)n+=t[i].x*t[s].y-t[s].x*t[i].y;return.5*n}static isClockWise(t){return nd.area(t)<0}static triangulateShape(t,e){const n=[],i=[],s=[];id(t),sd(n,t);let r=t.length;e.forEach(id);for(let t=0;t<e.length;t++)i.push(r),r+=e[t].length,sd(n,e[t]);const a=Ih(n,i);for(let t=0;t<a.length;t+=3)s.push(a.slice(t,t+3));return s}}function id(t){const e=t.length;e>2&&t[e-1].equals(t[0])&&t.pop()}function sd(t,e){for(let n=0;n<e.length;n++)t.push(e[n].x),t.push(e[n].y)}class rd extends Rr{constructor(t=new Rh([new ei(.5,.5),new ei(-.5,.5),new ei(-.5,-.5),new ei(.5,-.5)]),e={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:t,options:e},t=Array.isArray(t)?t:[t];const n=this,i=[],s=[];for(let e=0,n=t.length;e<n;e++){r(t[e])}function r(t){const r=[],a=void 0!==e.curveSegments?e.curveSegments:12,o=void 0!==e.steps?e.steps:1,l=void 0!==e.depth?e.depth:1;let c=void 0===e.bevelEnabled||e.bevelEnabled,u=void 0!==e.bevelThickness?e.bevelThickness:.2,h=void 0!==e.bevelSize?e.bevelSize:u-.1,d=void 0!==e.bevelOffset?e.bevelOffset:0,p=void 0!==e.bevelSegments?e.bevelSegments:3;const m=e.extrudePath,f=void 0!==e.UVGenerator?e.UVGenerator:ad;let g,v,y,_,x,M=!1;m&&(g=m.getSpacedPoints(o),M=!0,c=!1,v=m.computeFrenetFrames(o,!1),y=new Pi,_=new Pi,x=new Pi),c||(p=0,u=0,h=0,d=0);const b=t.extractPoints(a);let T=b.shape;const S=b.holes;if(!nd.isClockWise(T)){T=T.reverse();for(let t=0,e=S.length;t<e;t++){const e=S[t];nd.isClockWise(e)&&(S[t]=e.reverse())}}const w=nd.triangulateShape(T,S),E=T;for(let t=0,e=S.length;t<e;t++){const e=S[t];T=T.concat(e)}function A(t,e,n){return e||console.error("THREE.ExtrudeGeometry: vec does not exist"),t.clone().addScaledVector(e,n)}const N=T.length,C=w.length;function R(t,e,n){let i,s,r;const a=t.x-e.x,o=t.y-e.y,l=n.x-t.x,c=n.y-t.y,u=a*a+o*o,h=a*c-o*l;if(Math.abs(h)>Number.EPSILON){const h=Math.sqrt(u),d=Math.sqrt(l*l+c*c),p=e.x-o/h,m=e.y+a/h,f=((n.x-c/d-p)*c-(n.y+l/d-m)*l)/(a*c-o*l);i=p+a*f-t.x,s=m+o*f-t.y;const g=i*i+s*s;if(g<=2)return new ei(i,s);r=Math.sqrt(g/2)}else{let t=!1;a>Number.EPSILON?l>Number.EPSILON&&(t=!0):a<-Number.EPSILON?l<-Number.EPSILON&&(t=!0):Math.sign(o)===Math.sign(c)&&(t=!0),t?(i=-o,s=a,r=Math.sqrt(u)):(i=a,s=o,r=Math.sqrt(u/2))}return new ei(i/r,s/r)}const I=[];for(let t=0,e=E.length,n=e-1,i=t+1;t<e;t++,n++,i++)n===e&&(n=0),i===e&&(i=0),I[t]=R(E[t],E[n],E[i]);const L=[];let P,U=I.concat();for(let t=0,e=S.length;t<e;t++){const e=S[t];P=[];for(let t=0,n=e.length,i=n-1,s=t+1;t<n;t++,i++,s++)i===n&&(i=0),s===n&&(s=0),P[t]=R(e[t],e[i],e[s]);L.push(P),U=U.concat(P)}for(let t=0;t<p;t++){const e=t/p,n=u*Math.cos(e*Math.PI/2),i=h*Math.sin(e*Math.PI/2)+d;for(let t=0,e=E.length;t<e;t++){const e=A(E[t],I[t],i);z(e.x,e.y,-n)}for(let t=0,e=S.length;t<e;t++){const e=S[t];P=L[t];for(let t=0,s=e.length;t<s;t++){const s=A(e[t],P[t],i);z(s.x,s.y,-n)}}}const D=h+d;for(let t=0;t<N;t++){const e=c?A(T[t],U[t],D):T[t];M?(_.copy(v.normals[0]).multiplyScalar(e.x),y.copy(v.binormals[0]).multiplyScalar(e.y),x.copy(g[0]).add(_).add(y),z(x.x,x.y,x.z)):z(e.x,e.y,0)}for(let t=1;t<=o;t++)for(let e=0;e<N;e++){const n=c?A(T[e],U[e],D):T[e];M?(_.copy(v.normals[t]).multiplyScalar(n.x),y.copy(v.binormals[t]).multiplyScalar(n.y),x.copy(g[t]).add(_).add(y),z(x.x,x.y,x.z)):z(n.x,n.y,l/o*t)}for(let t=p-1;t>=0;t--){const e=t/p,n=u*Math.cos(e*Math.PI/2),i=h*Math.sin(e*Math.PI/2)+d;for(let t=0,e=E.length;t<e;t++){const e=A(E[t],I[t],i);z(e.x,e.y,l+n)}for(let t=0,e=S.length;t<e;t++){const e=S[t];P=L[t];for(let t=0,s=e.length;t<s;t++){const s=A(e[t],P[t],i);M?z(s.x,s.y+g[o-1].y,g[o-1].x+n):z(s.x,s.y,l+n)}}}function O(t,e){let n=t.length;for(;--n>=0;){const i=n;let s=n-1;s<0&&(s=t.length-1);for(let t=0,n=o+2*p;t<n;t++){const n=N*t,r=N*(t+1);F(e+i+n,e+s+n,e+s+r,e+i+r)}}}function z(t,e,n){r.push(t),r.push(e),r.push(n)}function V(t,e,s){B(t),B(e),B(s);const r=i.length/3,a=f.generateTopUV(n,i,r-3,r-2,r-1);k(a[0]),k(a[1]),k(a[2])}function F(t,e,s,r){B(t),B(e),B(r),B(e),B(s),B(r);const a=i.length/3,o=f.generateSideWallUV(n,i,a-6,a-3,a-2,a-1);k(o[0]),k(o[1]),k(o[3]),k(o[1]),k(o[2]),k(o[3])}function B(t){i.push(r[3*t+0]),i.push(r[3*t+1]),i.push(r[3*t+2])}function k(t){s.push(t.x),s.push(t.y)}!function(){const t=i.length/3;if(c){let t=0,e=N*t;for(let t=0;t<C;t++){const n=w[t];V(n[2]+e,n[1]+e,n[0]+e)}t=o+2*p,e=N*t;for(let t=0;t<C;t++){const n=w[t];V(n[0]+e,n[1]+e,n[2]+e)}}else{for(let t=0;t<C;t++){const e=w[t];V(e[2],e[1],e[0])}for(let t=0;t<C;t++){const e=w[t];V(e[0]+N*o,e[1]+N*o,e[2]+N*o)}}n.addGroup(t,i.length/3-t,0)}(),function(){const t=i.length/3;let e=0;O(E,e),e+=E.length;for(let t=0,n=S.length;t<n;t++){const n=S[t];O(n,e),e+=n.length}n.addGroup(t,i.length/3-t,1)}()}this.setAttribute("position",new br(i,3)),this.setAttribute("uv",new br(s,2)),this.computeVertexNormals()}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON();return function(t,e,n){if(n.shapes=[],Array.isArray(t))for(let e=0,i=t.length;e<i;e++){const i=t[e];n.shapes.push(i.uuid)}else n.shapes.push(t.uuid);n.options=Object.assign({},e),void 0!==e.extrudePath&&(n.options.extrudePath=e.extrudePath.toJSON());return n}(this.parameters.shapes,this.parameters.options,t)}static fromJSON(t,e){const n=[];for(let i=0,s=t.shapes.length;i<s;i++){const s=e[t.shapes[i]];n.push(s)}const i=t.options.extrudePath;return void 0!==i&&(t.options.extrudePath=(new fh[i.type]).fromJSON(i)),new rd(n,t.options)}}const ad={generateTopUV:function(t,e,n,i,s){const r=e[3*n],a=e[3*n+1],o=e[3*i],l=e[3*i+1],c=e[3*s],u=e[3*s+1];return[new ei(r,a),new ei(o,l),new ei(c,u)]},generateSideWallUV:function(t,e,n,i,s,r){const a=e[3*n],o=e[3*n+1],l=e[3*n+2],c=e[3*i],u=e[3*i+1],h=e[3*i+2],d=e[3*s],p=e[3*s+1],m=e[3*s+2],f=e[3*r],g=e[3*r+1],v=e[3*r+2];return Math.abs(o-u)<Math.abs(a-c)?[new ei(a,1-l),new ei(c,1-h),new ei(d,1-m),new ei(f,1-v)]:[new ei(o,1-l),new ei(u,1-h),new ei(p,1-m),new ei(g,1-v)]}};class od extends Th{constructor(t=1,e=0){const n=(1+Math.sqrt(5))/2;super([-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],t,e),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new od(t.radius,t.detail)}}class ld extends Th{constructor(t=1,e=0){super([1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],t,e),this.type="OctahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new ld(t.radius,t.detail)}}class cd extends Rr{constructor(t=.5,e=1,n=32,i=1,s=0,r=2*Math.PI){super(),this.type="RingGeometry",this.parameters={innerRadius:t,outerRadius:e,thetaSegments:n,phiSegments:i,thetaStart:s,thetaLength:r},n=Math.max(3,n);const a=[],o=[],l=[],c=[];let u=t;const h=(e-t)/(i=Math.max(1,i)),d=new Pi,p=new ei;for(let t=0;t<=i;t++){for(let t=0;t<=n;t++){const i=s+t/n*r;d.x=u*Math.cos(i),d.y=u*Math.sin(i),o.push(d.x,d.y,d.z),l.push(0,0,1),p.x=(d.x/e+1)/2,p.y=(d.y/e+1)/2,c.push(p.x,p.y)}u+=h}for(let t=0;t<i;t++){const e=t*(n+1);for(let t=0;t<n;t++){const i=t+e,s=i,r=i+n+1,o=i+n+2,l=i+1;a.push(s,r,l),a.push(r,o,l)}}this.setIndex(a),this.setAttribute("position",new br(o,3)),this.setAttribute("normal",new br(l,3)),this.setAttribute("uv",new br(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new cd(t.innerRadius,t.outerRadius,t.thetaSegments,t.phiSegments,t.thetaStart,t.thetaLength)}}class ud extends Rr{constructor(t=new Rh([new ei(0,.5),new ei(-.5,-.5),new ei(.5,-.5)]),e=12){super(),this.type="ShapeGeometry",this.parameters={shapes:t,curveSegments:e};const n=[],i=[],s=[],r=[];let a=0,o=0;if(!1===Array.isArray(t))l(t);else for(let e=0;e<t.length;e++)l(t[e]),this.addGroup(a,o,e),a+=o,o=0;function l(t){const a=i.length/3,l=t.extractPoints(e);let c=l.shape;const u=l.holes;!1===nd.isClockWise(c)&&(c=c.reverse());for(let t=0,e=u.length;t<e;t++){const e=u[t];!0===nd.isClockWise(e)&&(u[t]=e.reverse())}const h=nd.triangulateShape(c,u);for(let t=0,e=u.length;t<e;t++){const e=u[t];c=c.concat(e)}for(let t=0,e=c.length;t<e;t++){const e=c[t];i.push(e.x,e.y,0),s.push(0,0,1),r.push(e.x,e.y)}for(let t=0,e=h.length;t<e;t++){const e=h[t],i=e[0]+a,s=e[1]+a,r=e[2]+a;n.push(i,s,r),o+=3}}this.setIndex(n),this.setAttribute("position",new br(i,3)),this.setAttribute("normal",new br(s,3)),this.setAttribute("uv",new br(r,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON();return function(t,e){if(e.shapes=[],Array.isArray(t))for(let n=0,i=t.length;n<i;n++){const i=t[n];e.shapes.push(i.uuid)}else e.shapes.push(t.uuid);return e}(this.parameters.shapes,t)}static fromJSON(t,e){const n=[];for(let i=0,s=t.shapes.length;i<s;i++){const s=e[t.shapes[i]];n.push(s)}return new ud(n,t.curveSegments)}}class hd extends Rr{constructor(t=1,e=32,n=16,i=0,s=2*Math.PI,r=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:n,phiStart:i,phiLength:s,thetaStart:r,thetaLength:a},e=Math.max(3,Math.floor(e)),n=Math.max(2,Math.floor(n));const o=Math.min(r+a,Math.PI);let l=0;const c=[],u=new Pi,h=new Pi,d=[],p=[],m=[],f=[];for(let d=0;d<=n;d++){const g=[],v=d/n;let y=0;0===d&&0===r?y=.5/e:d===n&&o===Math.PI&&(y=-.5/e);for(let n=0;n<=e;n++){const o=n/e;u.x=-t*Math.cos(i+o*s)*Math.sin(r+v*a),u.y=t*Math.cos(r+v*a),u.z=t*Math.sin(i+o*s)*Math.sin(r+v*a),p.push(u.x,u.y,u.z),h.copy(u).normalize(),m.push(h.x,h.y,h.z),f.push(o+y,1-v),g.push(l++)}c.push(g)}for(let t=0;t<n;t++)for(let i=0;i<e;i++){const e=c[t][i+1],s=c[t][i],a=c[t+1][i],l=c[t+1][i+1];(0!==t||r>0)&&d.push(e,s,l),(t!==n-1||o<Math.PI)&&d.push(s,a,l)}this.setIndex(d),this.setAttribute("position",new br(p,3)),this.setAttribute("normal",new br(m,3)),this.setAttribute("uv",new br(f,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new hd(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}class dd extends Th{constructor(t=1,e=0){super([1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],t,e),this.type="TetrahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new dd(t.radius,t.detail)}}class pd extends Rr{constructor(t=1,e=.4,n=12,i=48,s=2*Math.PI){super(),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:n,tubularSegments:i,arc:s},n=Math.floor(n),i=Math.floor(i);const r=[],a=[],o=[],l=[],c=new Pi,u=new Pi,h=new Pi;for(let r=0;r<=n;r++)for(let d=0;d<=i;d++){const p=d/i*s,m=r/n*Math.PI*2;u.x=(t+e*Math.cos(m))*Math.cos(p),u.y=(t+e*Math.cos(m))*Math.sin(p),u.z=e*Math.sin(m),a.push(u.x,u.y,u.z),c.x=t*Math.cos(p),c.y=t*Math.sin(p),h.subVectors(u,c).normalize(),o.push(h.x,h.y,h.z),l.push(d/i),l.push(r/n)}for(let t=1;t<=n;t++)for(let e=1;e<=i;e++){const n=(i+1)*t+e-1,s=(i+1)*(t-1)+e-1,a=(i+1)*(t-1)+e,o=(i+1)*t+e;r.push(n,s,o),r.push(s,a,o)}this.setIndex(r),this.setAttribute("position",new br(a,3)),this.setAttribute("normal",new br(o,3)),this.setAttribute("uv",new br(l,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new pd(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc)}}class md extends Rr{constructor(t=1,e=.4,n=64,i=8,s=2,r=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:t,tube:e,tubularSegments:n,radialSegments:i,p:s,q:r},n=Math.floor(n),i=Math.floor(i);const a=[],o=[],l=[],c=[],u=new Pi,h=new Pi,d=new Pi,p=new Pi,m=new Pi,f=new Pi,g=new Pi;for(let a=0;a<=n;++a){const y=a/n*s*Math.PI*2;v(y,s,r,t,d),v(y+.01,s,r,t,p),f.subVectors(p,d),g.addVectors(p,d),m.crossVectors(f,g),g.crossVectors(m,f),m.normalize(),g.normalize();for(let t=0;t<=i;++t){const s=t/i*Math.PI*2,r=-e*Math.cos(s),p=e*Math.sin(s);u.x=d.x+(r*g.x+p*m.x),u.y=d.y+(r*g.y+p*m.y),u.z=d.z+(r*g.z+p*m.z),o.push(u.x,u.y,u.z),h.subVectors(u,d).normalize(),l.push(h.x,h.y,h.z),c.push(a/n),c.push(t/i)}}for(let t=1;t<=n;t++)for(let e=1;e<=i;e++){const n=(i+1)*(t-1)+(e-1),s=(i+1)*t+(e-1),r=(i+1)*t+e,o=(i+1)*(t-1)+e;a.push(n,s,o),a.push(s,r,o)}function v(t,e,n,i,s){const r=Math.cos(t),a=Math.sin(t),o=n/e*t,l=Math.cos(o);s.x=i*(2+l)*.5*r,s.y=i*(2+l)*a*.5,s.z=i*Math.sin(o)*.5}this.setIndex(a),this.setAttribute("position",new br(o,3)),this.setAttribute("normal",new br(l,3)),this.setAttribute("uv",new br(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new md(t.radius,t.tube,t.tubularSegments,t.radialSegments,t.p,t.q)}}class fd extends Rr{constructor(t=new ph(new Pi(-1,-1,0),new Pi(-1,1,0),new Pi(1,1,0)),e=64,n=1,i=8,s=!1){super(),this.type="TubeGeometry",this.parameters={path:t,tubularSegments:e,radius:n,radialSegments:i,closed:s};const r=t.computeFrenetFrames(e,s);this.tangents=r.tangents,this.normals=r.normals,this.binormals=r.binormals;const a=new Pi,o=new Pi,l=new ei;let c=new Pi;const u=[],h=[],d=[],p=[];function m(s){c=t.getPointAt(s/e,c);const l=r.normals[s],d=r.binormals[s];for(let t=0;t<=i;t++){const e=t/i*Math.PI*2,s=Math.sin(e),r=-Math.cos(e);o.x=r*l.x+s*d.x,o.y=r*l.y+s*d.y,o.z=r*l.z+s*d.z,o.normalize(),h.push(o.x,o.y,o.z),a.x=c.x+n*o.x,a.y=c.y+n*o.y,a.z=c.z+n*o.z,u.push(a.x,a.y,a.z)}}!function(){for(let t=0;t<e;t++)m(t);m(!1===s?e:0),function(){for(let t=0;t<=e;t++)for(let n=0;n<=i;n++)l.x=t/e,l.y=n/i,d.push(l.x,l.y)}(),function(){for(let t=1;t<=e;t++)for(let e=1;e<=i;e++){const n=(i+1)*(t-1)+(e-1),s=(i+1)*t+(e-1),r=(i+1)*t+e,a=(i+1)*(t-1)+e;p.push(n,s,a),p.push(s,r,a)}}()}(),this.setIndex(p),this.setAttribute("position",new br(u,3)),this.setAttribute("normal",new br(h,3)),this.setAttribute("uv",new br(d,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON();return t.path=this.parameters.path.toJSON(),t}static fromJSON(t){return new fd((new fh[t.path.type]).fromJSON(t.path),t.tubularSegments,t.radius,t.radialSegments,t.closed)}}class gd extends Rr{constructor(t=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:t},null!==t){const e=[],n=new Set,i=new Pi,s=new Pi;if(null!==t.index){const r=t.attributes.position,a=t.index;let o=t.groups;0===o.length&&(o=[{start:0,count:a.count,materialIndex:0}]);for(let t=0,l=o.length;t<l;++t){const l=o[t],c=l.start;for(let t=c,o=c+l.count;t<o;t+=3)for(let o=0;o<3;o++){const l=a.getX(t+o),c=a.getX(t+(o+1)%3);i.fromBufferAttribute(r,l),s.fromBufferAttribute(r,c),!0===vd(i,s,n)&&(e.push(i.x,i.y,i.z),e.push(s.x,s.y,s.z))}}}else{const r=t.attributes.position;for(let t=0,a=r.count/3;t<a;t++)for(let a=0;a<3;a++){const o=3*t+a,l=3*t+(a+1)%3;i.fromBufferAttribute(r,o),s.fromBufferAttribute(r,l),!0===vd(i,s,n)&&(e.push(i.x,i.y,i.z),e.push(s.x,s.y,s.z))}}this.setAttribute("position",new br(e,3))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}}function vd(t,e,n){const i=`${t.x},${t.y},${t.z}-${e.x},${e.y},${e.z}`,s=`${e.x},${e.y},${e.z}-${t.x},${t.y},${t.z}`;return!0!==n.has(i)&&!0!==n.has(s)&&(n.add(i),n.add(s),!0)}var yd=Object.freeze({__proto__:null,BoxGeometry:Wr,CapsuleGeometry:_h,CircleGeometry:xh,ConeGeometry:bh,CylinderGeometry:Mh,DodecahedronGeometry:Sh,EdgesGeometry:Ch,ExtrudeGeometry:rd,IcosahedronGeometry:od,LatheGeometry:yh,OctahedronGeometry:ld,PlaneGeometry:va,PolyhedronGeometry:Th,RingGeometry:cd,ShapeGeometry:ud,SphereGeometry:hd,TetrahedronGeometry:dd,TorusGeometry:pd,TorusKnotGeometry:md,TubeGeometry:fd,WireframeGeometry:gd});class _d extends sr{constructor(t){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new er(0),this.transparent=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.fog=t.fog,this}}class xd extends Zr{constructor(t){super(t),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Md extends sr{constructor(t){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new er(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 er(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ei(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 _s,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.envMapIntensity=t.envMapIntensity,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class bd extends Md{constructor(t){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 ei(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Zn(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new er(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 er(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new er(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(t)}get anisotropy(){return this._anisotropy}set anisotropy(t){this._anisotropy>0!=t>0&&this.version++,this._anisotropy=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get iridescence(){return this._iridescence}set iridescence(t){this._iridescence>0!=t>0&&this.version++,this._iridescence=t}get dispersion(){return this._dispersion}set dispersion(t){this._dispersion>0!=t>0&&this.version++,this._dispersion=t}get sheen(){return this._sheen}set sheen(t){this._sheen>0!=t>0&&this.version++,this._sheen=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=t.anisotropy,this.anisotropyRotation=t.anisotropyRotation,this.anisotropyMap=t.anisotropyMap,this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.dispersion=t.dispersion,this.ior=t.ior,this.iridescence=t.iridescence,this.iridescenceMap=t.iridescenceMap,this.iridescenceIOR=t.iridescenceIOR,this.iridescenceThicknessRange=[...t.iridescenceThicknessRange],this.iridescenceThicknessMap=t.iridescenceThicknessMap,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}}class Td extends sr{constructor(t){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new er(16777215),this.specular=new er(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new er(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ei(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new _s,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class Sd extends sr{constructor(t){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new er(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new er(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ei(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(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.gradientMap=t.gradientMap,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}class wd extends sr{constructor(t){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ei(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.flatShading=t.flatShading,this}}class Ed extends sr{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new er(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new er(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ei(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new _s,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class Ad extends sr{constructor(t){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new er(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ei(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.flatShading=t.flatShading,this.fog=t.fog,this}}class Nd extends Tu{constructor(t){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}copy(t){return super.copy(t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this}}function Cd(t,e,n){return!t||!n&&t.constructor===e?t:"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t)}function Rd(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Id(t){const e=t.length,n=new Array(e);for(let t=0;t!==e;++t)n[t]=t;return n.sort(function(e,n){return t[e]-t[n]}),n}function Ld(t,e,n){const i=t.length,s=new t.constructor(i);for(let r=0,a=0;a!==i;++r){const i=n[r]*e;for(let n=0;n!==e;++n)s[a++]=t[i+n]}return s}function Pd(t,e,n,i){let s=1,r=t[0];for(;void 0!==r&&void 0===r[i];)r=t[s++];if(void 0===r)return;let a=r[i];if(void 0!==a)if(Array.isArray(a))do{a=r[i],void 0!==a&&(e.push(r.time),n.push.apply(n,a)),r=t[s++]}while(void 0!==r);else if(void 0!==a.toArray)do{a=r[i],void 0!==a&&(e.push(r.time),a.toArray(n,n.length)),r=t[s++]}while(void 0!==r);else do{a=r[i],void 0!==a&&(e.push(r.time),n.push(a)),r=t[s++]}while(void 0!==r)}const Ud={convertArray:Cd,isTypedArray:Rd,getKeyframeOrder:Id,sortedArray:Ld,flattenJSON:Pd,subclip:function(t,e,n,i,s=30){const r=t.clone();r.name=e;const a=[];for(let t=0;t<r.tracks.length;++t){const e=r.tracks[t],o=e.getValueSize(),l=[],c=[];for(let t=0;t<e.times.length;++t){const r=e.times[t]*s;if(!(r<n||r>=i)){l.push(e.times[t]);for(let n=0;n<o;++n)c.push(e.values[t*o+n])}}0!==l.length&&(e.times=Cd(l,e.times.constructor),e.values=Cd(c,e.values.constructor),a.push(e))}r.tracks=a;let o=1/0;for(let t=0;t<r.tracks.length;++t)o>r.tracks[t].times[0]&&(o=r.tracks[t].times[0]);for(let t=0;t<r.tracks.length;++t)r.tracks[t].shift(-1*o);return r.resetDuration(),r},makeClipAdditive:function(t,e=0,n=t,i=30){i<=0&&(i=30);const s=n.tracks.length,r=e/i;for(let e=0;e<s;++e){const i=n.tracks[e],s=i.ValueTypeName;if("bool"===s||"string"===s)continue;const a=t.tracks.find(function(t){return t.name===i.name&&t.ValueTypeName===s});if(void 0===a)continue;let o=0;const l=i.getValueSize();i.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(o=l/3);let c=0;const u=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(c=u/3);const h=i.times.length-1;let d;if(r<=i.times[0]){const t=o,e=l-o;d=i.values.slice(t,e)}else if(r>=i.times[h]){const t=h*l+o,e=t+l-o;d=i.values.slice(t,e)}else{const t=i.createInterpolant(),e=o,n=l-o;t.evaluate(r),d=t.resultBuffer.slice(e,n)}if("quaternion"===s){(new Li).fromArray(d).normalize().conjugate().toArray(d)}const p=a.times.length;for(let t=0;t<p;++t){const e=t*u+c;if("quaternion"===s)Li.multiplyQuaternionsFlat(a.values,e,d,0,a.values,e);else{const t=u-2*c;for(let n=0;n<t;++n)a.values[e+n]-=d[n]}}}return t.blendMode=Be,t}};class Dd{constructor(t,e,n,i){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=void 0!==i?i:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){const e=this.parameterPositions;let n=this._cachedIndex,i=e[n],s=e[n-1];t:{e:{let r;n:{i:if(!(t<i)){for(let r=n+2;;){if(void 0===i){if(t<s)break i;return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===r)break;if(s=i,i=e[++n],t<i)break e}r=e.length;break n}if(!(t>=s)){const a=e[1];t<a&&(n=2,s=a);for(let r=n-2;;){if(void 0===s)return this._cachedIndex=0,this.copySampleValue_(0);if(n===r)break;if(i=s,s=e[--n-1],t>=s)break e}r=n,n=0;break n}break t}for(;n<r;){const i=n+r>>>1;t<e[i]?r=i:n=i+1}if(i=e[n],s=e[n-1],void 0===s)return this._cachedIndex=0,this.copySampleValue_(0);if(void 0===i)return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,s,i)}return this.interpolate_(n,s,t,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){const e=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=t*i;for(let t=0;t!==i;++t)e[t]=n[s+t];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class Od extends Dd{constructor(t,e,n,i){super(t,e,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Oe,endingEnd:Oe}}intervalChanged_(t,e,n){const i=this.parameterPositions;let s=t-2,r=t+1,a=i[s],o=i[r];if(void 0===a)switch(this.getSettings_().endingStart){case ze:s=t,a=2*e-n;break;case Ve:s=i.length-2,a=e+i[s]-i[s+1];break;default:s=t,a=n}if(void 0===o)switch(this.getSettings_().endingEnd){case ze:r=t,o=2*n-e;break;case Ve:r=1,o=n+i[1]-i[0];break;default:r=t-1,o=e}const l=.5*(n-e),c=this.valueSize;this._weightPrev=l/(e-a),this._weightNext=l/(o-n),this._offsetPrev=s*c,this._offsetNext=r*c}interpolate_(t,e,n,i){const s=this.resultBuffer,r=this.sampleValues,a=this.valueSize,o=t*a,l=o-a,c=this._offsetPrev,u=this._offsetNext,h=this._weightPrev,d=this._weightNext,p=(n-e)/(i-e),m=p*p,f=m*p,g=-h*f+2*h*m-h*p,v=(1+h)*f+(-1.5-2*h)*m+(-.5+h)*p+1,y=(-1-d)*f+(1.5+d)*m+.5*p,_=d*f-d*m;for(let t=0;t!==a;++t)s[t]=g*r[c+t]+v*r[l+t]+y*r[o+t]+_*r[u+t];return s}}class zd extends Dd{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){const s=this.resultBuffer,r=this.sampleValues,a=this.valueSize,o=t*a,l=o-a,c=(n-e)/(i-e),u=1-c;for(let t=0;t!==a;++t)s[t]=r[l+t]*u+r[o+t]*c;return s}}class Vd extends Dd{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t){return this.copySampleValue_(t-1)}}class Fd{constructor(t,e,n,i){if(void 0===t)throw new Error("THREE.KeyframeTrack: track name is undefined");if(void 0===e||0===e.length)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=Cd(e,this.TimeBufferType),this.values=Cd(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(t){const e=t.constructor;let n;if(e.toJSON!==this.toJSON)n=e.toJSON(t);else{n={name:t.name,times:Cd(t.times,Array),values:Cd(t.values,Array)};const e=t.getInterpolation();e!==t.DefaultInterpolation&&(n.interpolation=e)}return n.type=t.ValueTypeName,n}InterpolantFactoryMethodDiscrete(t){return new Vd(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new zd(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new Od(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case Pe:e=this.InterpolantFactoryMethodDiscrete;break;case Ue:e=this.InterpolantFactoryMethodLinear;break;case De:e=this.InterpolantFactoryMethodSmooth}if(void 0===e){const e="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(t===this.DefaultInterpolation)throw new Error(e);this.setInterpolation(this.DefaultInterpolation)}return console.warn("THREE.KeyframeTrack:",e),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Pe;case this.InterpolantFactoryMethodLinear:return Ue;case this.InterpolantFactoryMethodSmooth:return De}}getValueSize(){return this.values.length/this.times.length}shift(t){if(0!==t){const e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]+=t}return this}scale(t){if(1!==t){const e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]*=t}return this}trim(t,e){const n=this.times,i=n.length;let s=0,r=i-1;for(;s!==i&&n[s]<t;)++s;for(;-1!==r&&n[r]>e;)--r;if(++r,0!==s||r!==i){s>=r&&(r=Math.max(r,1),s=r-1);const t=this.getValueSize();this.times=n.slice(s,r),this.values=this.values.slice(s*t,r*t)}return this}validate(){let t=!0;const e=this.getValueSize();e-Math.floor(e)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);const n=this.times,i=this.values,s=n.length;0===s&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let r=null;for(let e=0;e!==s;e++){const i=n[e];if("number"==typeof i&&isNaN(i)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,e,i),t=!1;break}if(null!==r&&r>i){console.error("THREE.KeyframeTrack: Out of order keys.",this,e,i,r),t=!1;break}r=i}if(void 0!==i&&Rd(i))for(let e=0,n=i.length;e!==n;++e){const n=i[e];if(isNaN(n)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,e,n),t=!1;break}}return t}optimize(){const t=this.times.slice(),e=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===De,s=t.length-1;let r=1;for(let a=1;a<s;++a){let s=!1;const o=t[a];if(o!==t[a+1]&&(1!==a||o!==t[0]))if(i)s=!0;else{const t=a*n,i=t-n,r=t+n;for(let a=0;a!==n;++a){const n=e[t+a];if(n!==e[i+a]||n!==e[r+a]){s=!0;break}}}if(s){if(a!==r){t[r]=t[a];const i=a*n,s=r*n;for(let t=0;t!==n;++t)e[s+t]=e[i+t]}++r}}if(s>0){t[r]=t[s];for(let t=s*n,i=r*n,a=0;a!==n;++a)e[i+a]=e[t+a];++r}return r!==t.length?(this.times=t.slice(0,r),this.values=e.slice(0,r*n)):(this.times=t,this.values=e),this}clone(){const t=this.times.slice(),e=this.values.slice(),n=new(0,this.constructor)(this.name,t,e);return n.createInterpolant=this.createInterpolant,n}}Fd.prototype.TimeBufferType=Float32Array,Fd.prototype.ValueBufferType=Float32Array,Fd.prototype.DefaultInterpolation=Ue;class Bd extends Fd{constructor(t,e,n){super(t,e,n)}}Bd.prototype.ValueTypeName="bool",Bd.prototype.ValueBufferType=Array,Bd.prototype.DefaultInterpolation=Pe,Bd.prototype.InterpolantFactoryMethodLinear=void 0,Bd.prototype.InterpolantFactoryMethodSmooth=void 0;class kd extends Fd{}kd.prototype.ValueTypeName="color";class Hd extends Fd{}Hd.prototype.ValueTypeName="number";class Gd extends Dd{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){const s=this.resultBuffer,r=this.sampleValues,a=this.valueSize,o=(n-e)/(i-e);let l=t*a;for(let t=l+a;l!==t;l+=4)Li.slerpFlat(s,0,r,l-a,r,l,o);return s}}class Wd extends Fd{InterpolantFactoryMethodLinear(t){return new Gd(this.times,this.values,this.getValueSize(),t)}}Wd.prototype.ValueTypeName="quaternion",Wd.prototype.InterpolantFactoryMethodSmooth=void 0;class jd extends Fd{constructor(t,e,n){super(t,e,n)}}jd.prototype.ValueTypeName="string",jd.prototype.ValueBufferType=Array,jd.prototype.DefaultInterpolation=Pe,jd.prototype.InterpolantFactoryMethodLinear=void 0,jd.prototype.InterpolantFactoryMethodSmooth=void 0;class Xd extends Fd{}Xd.prototype.ValueTypeName="vector";class qd{constructor(t="",e=-1,n=[],i=2500){this.name=t,this.tracks=n,this.duration=e,this.blendMode=i,this.uuid=Yn(),this.duration<0&&this.resetDuration()}static parse(t){const e=[],n=t.tracks,i=1/(t.fps||1);for(let t=0,s=n.length;t!==s;++t)e.push(Yd(n[t]).scale(i));const s=new this(t.name,t.duration,e,t.blendMode);return s.uuid=t.uuid,s}static toJSON(t){const e=[],n=t.tracks,i={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let t=0,i=n.length;t!==i;++t)e.push(Fd.toJSON(n[t]));return i}static CreateFromMorphTargetSequence(t,e,n,i){const s=e.length,r=[];for(let t=0;t<s;t++){let a=[],o=[];a.push((t+s-1)%s,t,(t+1)%s),o.push(0,1,0);const l=Id(a);a=Ld(a,1,l),o=Ld(o,1,l),i||0!==a[0]||(a.push(s),o.push(o[0])),r.push(new Hd(".morphTargetInfluences["+e[t].name+"]",a,o).scale(1/n))}return new this(t,-1,r)}static findByName(t,e){let n=t;if(!Array.isArray(t)){const e=t;n=e.geometry&&e.geometry.animations||e.animations}for(let t=0;t<n.length;t++)if(n[t].name===e)return n[t];return null}static CreateClipsFromMorphTargetSequences(t,e,n){const i={},s=/^([\w-]*?)([\d]+)$/;for(let e=0,n=t.length;e<n;e++){const n=t[e],r=n.name.match(s);if(r&&r.length>1){const t=r[1];let e=i[t];e||(i[t]=e=[]),e.push(n)}}const r=[];for(const t in i)r.push(this.CreateFromMorphTargetSequence(t,i[t],e,n));return r}static parseAnimation(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(t,e,n,i,s){if(0!==n.length){const r=[],a=[];Pd(n,r,a,i),0!==r.length&&s.push(new t(e,r,a))}},i=[],s=t.name||"default",r=t.fps||30,a=t.blendMode;let o=t.length||-1;const l=t.hierarchy||[];for(let t=0;t<l.length;t++){const s=l[t].keys;if(s&&0!==s.length)if(s[0].morphTargets){const t={};let e;for(e=0;e<s.length;e++)if(s[e].morphTargets)for(let n=0;n<s[e].morphTargets.length;n++)t[s[e].morphTargets[n]]=-1;for(const n in t){const t=[],r=[];for(let i=0;i!==s[e].morphTargets.length;++i){const i=s[e];t.push(i.time),r.push(i.morphTarget===n?1:0)}i.push(new Hd(".morphTargetInfluence["+n+"]",t,r))}o=t.length*r}else{const r=".bones["+e[t].name+"]";n(Xd,r+".position",s,"pos",i),n(Wd,r+".quaternion",s,"rot",i),n(Xd,r+".scale",s,"scl",i)}}if(0===i.length)return null;return new this(s,o,i,a)}resetDuration(){let t=0;for(let e=0,n=this.tracks.length;e!==n;++e){const n=this.tracks[e];t=Math.max(t,n.times[n.times.length-1])}return this.duration=t,this}trim(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this}validate(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t}optimize(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this}clone(){const t=[];for(let e=0;e<this.tracks.length;e++)t.push(this.tracks[e].clone());return new this.constructor(this.name,this.duration,t,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function Yd(t){if(void 0===t.type)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=function(t){switch(t.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Hd;case"vector":case"vector2":case"vector3":case"vector4":return Xd;case"color":return kd;case"quaternion":return Wd;case"bool":case"boolean":return Bd;case"string":return jd}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+t)}(t.type);if(void 0===t.times){const e=[],n=[];Pd(t.keys,e,n,"value"),t.times=e,t.values=n}return void 0!==e.parse?e.parse(t):new e(t.name,t.times,t.values,t.interpolation)}const Zd={enabled:!1,files:{},add:function(t,e){!1!==this.enabled&&(this.files[t]=e)},get:function(t){if(!1!==this.enabled)return this.files[t]},remove:function(t){delete this.files[t]},clear:function(){this.files={}}};class $d{constructor(t,e,n){const i=this;let s,r=!1,a=0,o=0;const l=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this.itemStart=function(t){o++,!1===r&&void 0!==i.onStart&&i.onStart(t,a,o),r=!0},this.itemEnd=function(t){a++,void 0!==i.onProgress&&i.onProgress(t,a,o),a===o&&(r=!1,void 0!==i.onLoad&&i.onLoad())},this.itemError=function(t){void 0!==i.onError&&i.onError(t)},this.resolveURL=function(t){return s?s(t):t},this.setURLModifier=function(t){return s=t,this},this.addHandler=function(t,e){return l.push(t,e),this},this.removeHandler=function(t){const e=l.indexOf(t);return-1!==e&&l.splice(e,2),this},this.getHandler=function(t){for(let e=0,n=l.length;e<n;e+=2){const n=l[e],i=l[e+1];if(n.global&&(n.lastIndex=0),n.test(t))return i}return null}}}const Jd=new $d;class Kd{constructor(t){this.manager=void 0!==t?t:Jd,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){const n=this;return new Promise(function(i,s){n.load(t,i,e,s)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}}Kd.DEFAULT_MATERIAL_NAME="__DEFAULT";const Qd={};class tp extends Error{constructor(t,e){super(t),this.response=e}}class ep extends Kd{constructor(t){super(t)}load(t,e,n,i){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const s=Zd.get(t);if(void 0!==s)return this.manager.itemStart(t),setTimeout(()=>{e&&e(s),this.manager.itemEnd(t)},0),s;if(void 0!==Qd[t])return void Qd[t].push({onLoad:e,onProgress:n,onError:i});Qd[t]=[],Qd[t].push({onLoad:e,onProgress:n,onError:i});const r=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,o=this.responseType;fetch(r).then(e=>{if(200===e.status||0===e.status){if(0===e.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),"undefined"==typeof ReadableStream||void 0===e.body||void 0===e.body.getReader)return e;const n=Qd[t],i=e.body.getReader(),s=e.headers.get("X-File-Size")||e.headers.get("Content-Length"),r=s?parseInt(s):0,a=0!==r;let o=0;const l=new ReadableStream({start(t){!function e(){i.read().then(({done:i,value:s})=>{if(i)t.close();else{o+=s.byteLength;const i=new ProgressEvent("progress",{lengthComputable:a,loaded:o,total:r});for(let t=0,e=n.length;t<e;t++){const e=n[t];e.onProgress&&e.onProgress(i)}t.enqueue(s),e()}},e=>{t.error(e)})}()}});return new Response(l)}throw new tp(`fetch for "${e.url}" responded with ${e.status}: ${e.statusText}`,e)}).then(t=>{switch(o){case"arraybuffer":return t.arrayBuffer();case"blob":return t.blob();case"document":return t.text().then(t=>(new DOMParser).parseFromString(t,a));case"json":return t.json();default:if(void 0===a)return t.text();{const e=/charset="?([^;"\s]*)"?/i.exec(a),n=e&&e[1]?e[1].toLowerCase():void 0,i=new TextDecoder(n);return t.arrayBuffer().then(t=>i.decode(t))}}}).then(e=>{Zd.add(t,e);const n=Qd[t];delete Qd[t];for(let t=0,i=n.length;t<i;t++){const i=n[t];i.onLoad&&i.onLoad(e)}}).catch(e=>{const n=Qd[t];if(void 0===n)throw this.manager.itemError(t),e;delete Qd[t];for(let t=0,i=n.length;t<i;t++){const i=n[t];i.onError&&i.onError(e)}this.manager.itemError(t)}).finally(()=>{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}}class np extends Kd{constructor(t){super(t)}load(t,e,n,i){const s=this,r=new ep(this.manager);r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(t,function(n){try{e(s.parse(JSON.parse(n)))}catch(e){i?i(e):console.error(e),s.manager.itemError(t)}},n,i)}parse(t){const e=[];for(let n=0;n<t.length;n++){const i=qd.parse(t[n]);e.push(i)}return e}}class ip extends Kd{constructor(t){super(t)}load(t,e,n,i){const s=this,r=[],a=new Xu,o=new ep(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(s.withCredentials);let l=0;function c(c){o.load(t[c],function(t){const n=s.parse(t,!0);r[c]={width:n.width,height:n.height,format:n.format,mipmaps:n.mipmaps},l+=1,6===l&&(1===n.mipmapCount&&(a.minFilter=Mt),a.image=r,a.format=n.format,a.needsUpdate=!0,e&&e(a))},n,i)}if(Array.isArray(t))for(let e=0,n=t.length;e<n;++e)c(e);else o.load(t,function(t){const n=s.parse(t,!0);if(n.isCubemap){const t=n.mipmaps.length/n.mipmapCount;for(let e=0;e<t;e++){r[e]={mipmaps:[]};for(let t=0;t<n.mipmapCount;t++)r[e].mipmaps.push(n.mipmaps[e*n.mipmapCount+t]),r[e].format=n.format,r[e].width=n.width,r[e].height=n.height}a.image=r}else a.image.width=n.width,a.image.height=n.height,a.mipmaps=n.mipmaps;1===n.mipmapCount&&(a.minFilter=Mt),a.format=n.format,a.needsUpdate=!0,e&&e(a)},n,i);return a}}class sp extends Kd{constructor(t){super(t)}load(t,e,n,i){void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const s=this,r=Zd.get(t);if(void 0!==r)return s.manager.itemStart(t),setTimeout(function(){e&&e(r),s.manager.itemEnd(t)},0),r;const a=oi("img");function o(){c(),Zd.add(t,this),e&&e(this),s.manager.itemEnd(t)}function l(e){c(),i&&i(e),s.manager.itemError(t),s.manager.itemEnd(t)}function c(){a.removeEventListener("load",o,!1),a.removeEventListener("error",l,!1)}return a.addEventListener("load",o,!1),a.addEventListener("error",l,!1),"data:"!==t.slice(0,5)&&void 0!==this.crossOrigin&&(a.crossOrigin=this.crossOrigin),s.manager.itemStart(t),a.src=t,a}}class rp extends Kd{constructor(t){super(t)}load(t,e,n,i){const s=new aa;s.colorSpace=Je;const r=new sp(this.manager);r.setCrossOrigin(this.crossOrigin),r.setPath(this.path);let a=0;function o(n){r.load(t[n],function(t){s.images[n]=t,a++,6===a&&(s.needsUpdate=!0,e&&e(s))},void 0,i)}for(let e=0;e<t.length;++e)o(e);return s}}class ap extends Kd{constructor(t){super(t)}load(t,e,n,i){const s=this,r=new jc,a=new ep(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(s.withCredentials),a.load(t,function(t){let n;try{n=s.parse(t)}catch(t){if(void 0===i)return void console.error(t);i(t)}void 0!==n.image?r.image=n.image:void 0!==n.data&&(r.image.width=n.width,r.image.height=n.height,r.image.data=n.data),r.wrapS=void 0!==n.wrapS?n.wrapS:mt,r.wrapT=void 0!==n.wrapT?n.wrapT:mt,r.magFilter=void 0!==n.magFilter?n.magFilter:Mt,r.minFilter=void 0!==n.minFilter?n.minFilter:Mt,r.anisotropy=void 0!==n.anisotropy?n.anisotropy:1,void 0!==n.colorSpace&&(r.colorSpace=n.colorSpace),void 0!==n.flipY&&(r.flipY=n.flipY),void 0!==n.format&&(r.format=n.format),void 0!==n.type&&(r.type=n.type),void 0!==n.mipmaps&&(r.mipmaps=n.mipmaps,r.minFilter=St),1===n.mipmapCount&&(r.minFilter=Mt),void 0!==n.generateMipmaps&&(r.generateMipmaps=n.generateMipmaps),r.needsUpdate=!0,e&&e(r,n)},n,i),r}}class op extends Kd{constructor(t){super(t)}load(t,e,n,i){const s=new Si,r=new sp(this.manager);return r.setCrossOrigin(this.crossOrigin),r.setPath(this.path),r.load(t,function(t){s.image=t,s.needsUpdate=!0,void 0!==e&&e(s)},n,i),s}}class lp extends Os{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new er(t),this.intensity=e}dispose(){}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){const e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,void 0!==this.groundColor&&(e.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(e.object.distance=this.distance),void 0!==this.angle&&(e.object.angle=this.angle),void 0!==this.decay&&(e.object.decay=this.decay),void 0!==this.penumbra&&(e.object.penumbra=this.penumbra),void 0!==this.shadow&&(e.object.shadow=this.shadow.toJSON()),void 0!==this.target&&(e.object.target=this.target.uuid),e}}class cp extends lp{constructor(t,e,n){super(t,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Os.DEFAULT_UP),this.updateMatrix(),this.groundColor=new er(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}}const up=new cs,hp=new Pi,dp=new Pi;class pp{constructor(t){this.camera=t,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new ei(512,512),this.map=null,this.mapPass=null,this.matrix=new cs,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new ma,this._frameExtents=new ei(1,1),this._viewportCount=1,this._viewports=[new wi(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,n=this.matrix;hp.setFromMatrixPosition(t.matrixWorld),e.position.copy(hp),dp.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(dp),e.updateMatrixWorld(),up.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(up),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(up)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.intensity=t.intensity,this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this}clone(){return(new this.constructor).copy(this)}toJSON(){const t={};return 1!==this.intensity&&(t.intensity=this.intensity),0!==this.bias&&(t.bias=this.bias),0!==this.normalBias&&(t.normalBias=this.normalBias),1!==this.radius&&(t.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}class mp extends pp{constructor(){super(new ia(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(t){const e=this.camera,n=2*qn*t.angle*this.focus,i=this.mapSize.width/this.mapSize.height,s=t.distance||e.far;n===e.fov&&i===e.aspect&&s===e.far||(e.fov=n,e.aspect=i,e.far=s,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}}class fp extends lp{constructor(t,e,n=0,i=Math.PI/3,s=0,r=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Os.DEFAULT_UP),this.updateMatrix(),this.target=new Os,this.distance=n,this.angle=i,this.penumbra=s,this.decay=r,this.map=null,this.shadow=new mp}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}const gp=new cs,vp=new Pi,yp=new Pi;class _p extends pp{constructor(){super(new ia(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new ei(4,2),this._viewportCount=6,this._viewports=[new wi(2,1,1,1),new wi(0,1,1,1),new wi(3,1,1,1),new wi(1,1,1,1),new wi(3,0,1,1),new wi(1,0,1,1)],this._cubeDirections=[new Pi(1,0,0),new Pi(-1,0,0),new Pi(0,0,1),new Pi(0,0,-1),new Pi(0,1,0),new Pi(0,-1,0)],this._cubeUps=[new Pi(0,1,0),new Pi(0,1,0),new Pi(0,1,0),new Pi(0,1,0),new Pi(0,0,1),new Pi(0,0,-1)]}updateMatrices(t,e=0){const n=this.camera,i=this.matrix,s=t.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),vp.setFromMatrixPosition(t.matrixWorld),n.position.copy(vp),yp.copy(n.position),yp.add(this._cubeDirections[e]),n.up.copy(this._cubeUps[e]),n.lookAt(yp),n.updateMatrixWorld(),i.makeTranslation(-vp.x,-vp.y,-vp.z),gp.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(gp)}}class xp extends lp{constructor(t,e,n=0,i=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new _p}get power(){return 4*this.intensity*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}}class Mp extends pp{constructor(){super(new Ra(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class bp extends lp{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Os.DEFAULT_UP),this.updateMatrix(),this.target=new Os,this.shadow=new Mp}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}class Tp extends lp{constructor(t,e){super(t,e),this.isAmbientLight=!0,this.type="AmbientLight"}}class Sp extends lp{constructor(t,e,n=10,i=10){super(t,e),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=n,this.height=i}get power(){return this.intensity*this.width*this.height*Math.PI}set power(t){this.intensity=t/(this.width*this.height*Math.PI)}copy(t){return super.copy(t),this.width=t.width,this.height=t.height,this}toJSON(t){const e=super.toJSON(t);return e.object.width=this.width,e.object.height=this.height,e}}class wp{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let t=0;t<9;t++)this.coefficients.push(new Pi)}set(t){for(let e=0;e<9;e++)this.coefficients[e].copy(t[e]);return this}zero(){for(let t=0;t<9;t++)this.coefficients[t].set(0,0,0);return this}getAt(t,e){const n=t.x,i=t.y,s=t.z,r=this.coefficients;return e.copy(r[0]).multiplyScalar(.282095),e.addScaledVector(r[1],.488603*i),e.addScaledVector(r[2],.488603*s),e.addScaledVector(r[3],.488603*n),e.addScaledVector(r[4],n*i*1.092548),e.addScaledVector(r[5],i*s*1.092548),e.addScaledVector(r[6],.315392*(3*s*s-1)),e.addScaledVector(r[7],n*s*1.092548),e.addScaledVector(r[8],.546274*(n*n-i*i)),e}getIrradianceAt(t,e){const n=t.x,i=t.y,s=t.z,r=this.coefficients;return e.copy(r[0]).multiplyScalar(.886227),e.addScaledVector(r[1],1.023328*i),e.addScaledVector(r[2],1.023328*s),e.addScaledVector(r[3],1.023328*n),e.addScaledVector(r[4],.858086*n*i),e.addScaledVector(r[5],.858086*i*s),e.addScaledVector(r[6],.743125*s*s-.247708),e.addScaledVector(r[7],.858086*n*s),e.addScaledVector(r[8],.429043*(n*n-i*i)),e}add(t){for(let e=0;e<9;e++)this.coefficients[e].add(t.coefficients[e]);return this}addScaledSH(t,e){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(t.coefficients[n],e);return this}scale(t){for(let e=0;e<9;e++)this.coefficients[e].multiplyScalar(t);return this}lerp(t,e){for(let n=0;n<9;n++)this.coefficients[n].lerp(t.coefficients[n],e);return this}equals(t){for(let e=0;e<9;e++)if(!this.coefficients[e].equals(t.coefficients[e]))return!1;return!0}copy(t){return this.set(t.coefficients)}clone(){return(new this.constructor).copy(this)}fromArray(t,e=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].fromArray(t,e+3*i);return this}toArray(t=[],e=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].toArray(t,e+3*i);return t}static getBasisAt(t,e){const n=t.x,i=t.y,s=t.z;e[0]=.282095,e[1]=.488603*i,e[2]=.488603*s,e[3]=.488603*n,e[4]=1.092548*n*i,e[5]=1.092548*i*s,e[6]=.315392*(3*s*s-1),e[7]=1.092548*n*s,e[8]=.546274*(n*n-i*i)}}class Ep extends lp{constructor(t=new wp,e=1){super(void 0,e),this.isLightProbe=!0,this.sh=t}copy(t){return super.copy(t),this.sh.copy(t.sh),this}fromJSON(t){return this.intensity=t.intensity,this.sh.fromArray(t.sh),this}toJSON(t){const e=super.toJSON(t);return e.object.sh=this.sh.toArray(),e}}class Ap extends Kd{constructor(t){super(t),this.textures={}}load(t,e,n,i){const s=this,r=new ep(s.manager);r.setPath(s.path),r.setRequestHeader(s.requestHeader),r.setWithCredentials(s.withCredentials),r.load(t,function(n){try{e(s.parse(JSON.parse(n)))}catch(e){i?i(e):console.error(e),s.manager.itemError(t)}},n,i)}parse(t){const e=this.textures;function n(t){return void 0===e[t]&&console.warn("THREE.MaterialLoader: Undefined texture",t),e[t]}const i=this.createMaterialFromType(t.type);if(void 0!==t.uuid&&(i.uuid=t.uuid),void 0!==t.name&&(i.name=t.name),void 0!==t.color&&void 0!==i.color&&i.color.setHex(t.color),void 0!==t.roughness&&(i.roughness=t.roughness),void 0!==t.metalness&&(i.metalness=t.metalness),void 0!==t.sheen&&(i.sheen=t.sheen),void 0!==t.sheenColor&&(i.sheenColor=(new er).setHex(t.sheenColor)),void 0!==t.sheenRoughness&&(i.sheenRoughness=t.sheenRoughness),void 0!==t.emissive&&void 0!==i.emissive&&i.emissive.setHex(t.emissive),void 0!==t.specular&&void 0!==i.specular&&i.specular.setHex(t.specular),void 0!==t.specularIntensity&&(i.specularIntensity=t.specularIntensity),void 0!==t.specularColor&&void 0!==i.specularColor&&i.specularColor.setHex(t.specularColor),void 0!==t.shininess&&(i.shininess=t.shininess),void 0!==t.clearcoat&&(i.clearcoat=t.clearcoat),void 0!==t.clearcoatRoughness&&(i.clearcoatRoughness=t.clearcoatRoughness),void 0!==t.dispersion&&(i.dispersion=t.dispersion),void 0!==t.iridescence&&(i.iridescence=t.iridescence),void 0!==t.iridescenceIOR&&(i.iridescenceIOR=t.iridescenceIOR),void 0!==t.iridescenceThicknessRange&&(i.iridescenceThicknessRange=t.iridescenceThicknessRange),void 0!==t.transmission&&(i.transmission=t.transmission),void 0!==t.thickness&&(i.thickness=t.thickness),void 0!==t.attenuationDistance&&(i.attenuationDistance=t.attenuationDistance),void 0!==t.attenuationColor&&void 0!==i.attenuationColor&&i.attenuationColor.setHex(t.attenuationColor),void 0!==t.anisotropy&&(i.anisotropy=t.anisotropy),void 0!==t.anisotropyRotation&&(i.anisotropyRotation=t.anisotropyRotation),void 0!==t.fog&&(i.fog=t.fog),void 0!==t.flatShading&&(i.flatShading=t.flatShading),void 0!==t.blending&&(i.blending=t.blending),void 0!==t.combine&&(i.combine=t.combine),void 0!==t.side&&(i.side=t.side),void 0!==t.shadowSide&&(i.shadowSide=t.shadowSide),void 0!==t.opacity&&(i.opacity=t.opacity),void 0!==t.transparent&&(i.transparent=t.transparent),void 0!==t.alphaTest&&(i.alphaTest=t.alphaTest),void 0!==t.alphaHash&&(i.alphaHash=t.alphaHash),void 0!==t.depthFunc&&(i.depthFunc=t.depthFunc),void 0!==t.depthTest&&(i.depthTest=t.depthTest),void 0!==t.depthWrite&&(i.depthWrite=t.depthWrite),void 0!==t.colorWrite&&(i.colorWrite=t.colorWrite),void 0!==t.blendSrc&&(i.blendSrc=t.blendSrc),void 0!==t.blendDst&&(i.blendDst=t.blendDst),void 0!==t.blendEquation&&(i.blendEquation=t.blendEquation),void 0!==t.blendSrcAlpha&&(i.blendSrcAlpha=t.blendSrcAlpha),void 0!==t.blendDstAlpha&&(i.blendDstAlpha=t.blendDstAlpha),void 0!==t.blendEquationAlpha&&(i.blendEquationAlpha=t.blendEquationAlpha),void 0!==t.blendColor&&void 0!==i.blendColor&&i.blendColor.setHex(t.blendColor),void 0!==t.blendAlpha&&(i.blendAlpha=t.blendAlpha),void 0!==t.stencilWriteMask&&(i.stencilWriteMask=t.stencilWriteMask),void 0!==t.stencilFunc&&(i.stencilFunc=t.stencilFunc),void 0!==t.stencilRef&&(i.stencilRef=t.stencilRef),void 0!==t.stencilFuncMask&&(i.stencilFuncMask=t.stencilFuncMask),void 0!==t.stencilFail&&(i.stencilFail=t.stencilFail),void 0!==t.stencilZFail&&(i.stencilZFail=t.stencilZFail),void 0!==t.stencilZPass&&(i.stencilZPass=t.stencilZPass),void 0!==t.stencilWrite&&(i.stencilWrite=t.stencilWrite),void 0!==t.wireframe&&(i.wireframe=t.wireframe),void 0!==t.wireframeLinewidth&&(i.wireframeLinewidth=t.wireframeLinewidth),void 0!==t.wireframeLinecap&&(i.wireframeLinecap=t.wireframeLinecap),void 0!==t.wireframeLinejoin&&(i.wireframeLinejoin=t.wireframeLinejoin),void 0!==t.rotation&&(i.rotation=t.rotation),void 0!==t.linewidth&&(i.linewidth=t.linewidth),void 0!==t.dashSize&&(i.dashSize=t.dashSize),void 0!==t.gapSize&&(i.gapSize=t.gapSize),void 0!==t.scale&&(i.scale=t.scale),void 0!==t.polygonOffset&&(i.polygonOffset=t.polygonOffset),void 0!==t.polygonOffsetFactor&&(i.polygonOffsetFactor=t.polygonOffsetFactor),void 0!==t.polygonOffsetUnits&&(i.polygonOffsetUnits=t.polygonOffsetUnits),void 0!==t.dithering&&(i.dithering=t.dithering),void 0!==t.alphaToCoverage&&(i.alphaToCoverage=t.alphaToCoverage),void 0!==t.premultipliedAlpha&&(i.premultipliedAlpha=t.premultipliedAlpha),void 0!==t.forceSinglePass&&(i.forceSinglePass=t.forceSinglePass),void 0!==t.visible&&(i.visible=t.visible),void 0!==t.toneMapped&&(i.toneMapped=t.toneMapped),void 0!==t.userData&&(i.userData=t.userData),void 0!==t.vertexColors&&("number"==typeof t.vertexColors?i.vertexColors=t.vertexColors>0:i.vertexColors=t.vertexColors),void 0!==t.uniforms)for(const e in t.uniforms){const s=t.uniforms[e];switch(i.uniforms[e]={},s.type){case"t":i.uniforms[e].value=n(s.value);break;case"c":i.uniforms[e].value=(new er).setHex(s.value);break;case"v2":i.uniforms[e].value=(new ei).fromArray(s.value);break;case"v3":i.uniforms[e].value=(new Pi).fromArray(s.value);break;case"v4":i.uniforms[e].value=(new wi).fromArray(s.value);break;case"m3":i.uniforms[e].value=(new ni).fromArray(s.value);break;case"m4":i.uniforms[e].value=(new cs).fromArray(s.value);break;default:i.uniforms[e].value=s.value}}if(void 0!==t.defines&&(i.defines=t.defines),void 0!==t.vertexShader&&(i.vertexShader=t.vertexShader),void 0!==t.fragmentShader&&(i.fragmentShader=t.fragmentShader),void 0!==t.glslVersion&&(i.glslVersion=t.glslVersion),void 0!==t.extensions)for(const e in t.extensions)i.extensions[e]=t.extensions[e];if(void 0!==t.lights&&(i.lights=t.lights),void 0!==t.clipping&&(i.clipping=t.clipping),void 0!==t.size&&(i.size=t.size),void 0!==t.sizeAttenuation&&(i.sizeAttenuation=t.sizeAttenuation),void 0!==t.map&&(i.map=n(t.map)),void 0!==t.matcap&&(i.matcap=n(t.matcap)),void 0!==t.alphaMap&&(i.alphaMap=n(t.alphaMap)),void 0!==t.bumpMap&&(i.bumpMap=n(t.bumpMap)),void 0!==t.bumpScale&&(i.bumpScale=t.bumpScale),void 0!==t.normalMap&&(i.normalMap=n(t.normalMap)),void 0!==t.normalMapType&&(i.normalMapType=t.normalMapType),void 0!==t.normalScale){let e=t.normalScale;!1===Array.isArray(e)&&(e=[e,e]),i.normalScale=(new ei).fromArray(e)}return void 0!==t.displacementMap&&(i.displacementMap=n(t.displacementMap)),void 0!==t.displacementScale&&(i.displacementScale=t.displacementScale),void 0!==t.displacementBias&&(i.displacementBias=t.displacementBias),void 0!==t.roughnessMap&&(i.roughnessMap=n(t.roughnessMap)),void 0!==t.metalnessMap&&(i.metalnessMap=n(t.metalnessMap)),void 0!==t.emissiveMap&&(i.emissiveMap=n(t.emissiveMap)),void 0!==t.emissiveIntensity&&(i.emissiveIntensity=t.emissiveIntensity),void 0!==t.specularMap&&(i.specularMap=n(t.specularMap)),void 0!==t.specularIntensityMap&&(i.specularIntensityMap=n(t.specularIntensityMap)),void 0!==t.specularColorMap&&(i.specularColorMap=n(t.specularColorMap)),void 0!==t.envMap&&(i.envMap=n(t.envMap)),void 0!==t.envMapRotation&&i.envMapRotation.fromArray(t.envMapRotation),void 0!==t.envMapIntensity&&(i.envMapIntensity=t.envMapIntensity),void 0!==t.reflectivity&&(i.reflectivity=t.reflectivity),void 0!==t.refractionRatio&&(i.refractionRatio=t.refractionRatio),void 0!==t.lightMap&&(i.lightMap=n(t.lightMap)),void 0!==t.lightMapIntensity&&(i.lightMapIntensity=t.lightMapIntensity),void 0!==t.aoMap&&(i.aoMap=n(t.aoMap)),void 0!==t.aoMapIntensity&&(i.aoMapIntensity=t.aoMapIntensity),void 0!==t.gradientMap&&(i.gradientMap=n(t.gradientMap)),void 0!==t.clearcoatMap&&(i.clearcoatMap=n(t.clearcoatMap)),void 0!==t.clearcoatRoughnessMap&&(i.clearcoatRoughnessMap=n(t.clearcoatRoughnessMap)),void 0!==t.clearcoatNormalMap&&(i.clearcoatNormalMap=n(t.clearcoatNormalMap)),void 0!==t.clearcoatNormalScale&&(i.clearcoatNormalScale=(new ei).fromArray(t.clearcoatNormalScale)),void 0!==t.iridescenceMap&&(i.iridescenceMap=n(t.iridescenceMap)),void 0!==t.iridescenceThicknessMap&&(i.iridescenceThicknessMap=n(t.iridescenceThicknessMap)),void 0!==t.transmissionMap&&(i.transmissionMap=n(t.transmissionMap)),void 0!==t.thicknessMap&&(i.thicknessMap=n(t.thicknessMap)),void 0!==t.anisotropyMap&&(i.anisotropyMap=n(t.anisotropyMap)),void 0!==t.sheenColorMap&&(i.sheenColorMap=n(t.sheenColorMap)),void 0!==t.sheenRoughnessMap&&(i.sheenRoughnessMap=n(t.sheenRoughnessMap)),i}setTextures(t){return this.textures=t,this}createMaterialFromType(t){return Ap.createMaterialFromType(t)}static createMaterialFromType(t){return new{ShadowMaterial:_d,SpriteMaterial:fc,RawShaderMaterial:xd,ShaderMaterial:Zr,PointsMaterial:zu,MeshPhysicalMaterial:bd,MeshStandardMaterial:Md,MeshPhongMaterial:Td,MeshToonMaterial:Sd,MeshNormalMaterial:wd,MeshLambertMaterial:Ed,MeshDepthMaterial:Gl,MeshDistanceMaterial:Wl,MeshBasicMaterial:rr,MeshMatcapMaterial:Ad,LineDashedMaterial:Nd,LineBasicMaterial:Tu,Material:sr}[t]}}class Np{static decodeText(t){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),"undefined"!=typeof TextDecoder)return(new TextDecoder).decode(t);let e="";for(let n=0,i=t.length;n<i;n++)e+=String.fromCharCode(t[n]);try{return decodeURIComponent(escape(e))}catch(t){return e}}static extractUrlBase(t){const e=t.lastIndexOf("/");return-1===e?"./":t.slice(0,e+1)}static resolveURL(t,e){return"string"!=typeof t||""===t?"":(/^https?:\/\//i.test(e)&&/^\//.test(t)&&(e=e.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(t)||/^data:.*,.*$/i.test(t)||/^blob:.*$/i.test(t)?t:e+t)}}class Cp extends Rr{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(t){return super.copy(t),this.instanceCount=t.instanceCount,this}toJSON(){const t=super.toJSON();return t.instanceCount=this.instanceCount,t.isInstancedBufferGeometry=!0,t}}class Rp extends Kd{constructor(t){super(t)}load(t,e,n,i){const s=this,r=new ep(s.manager);r.setPath(s.path),r.setRequestHeader(s.requestHeader),r.setWithCredentials(s.withCredentials),r.load(t,function(n){try{e(s.parse(JSON.parse(n)))}catch(e){i?i(e):console.error(e),s.manager.itemError(t)}},n,i)}parse(t){const e={},n={};function i(t,i){if(void 0!==e[i])return e[i];const s=t.interleavedBuffers[i],r=function(t,e){if(void 0!==n[e])return n[e];const i=t.arrayBuffers,s=i[e],r=new Uint32Array(s).buffer;return n[e]=r,r}(t,s.buffer),a=ai(s.type,r),o=new dc(a,s.stride);return o.uuid=s.uuid,e[i]=o,o}const s=t.isInstancedBufferGeometry?new Cp:new Rr,r=t.data.index;if(void 0!==r){const t=ai(r.type,r.array);s.setIndex(new pr(t,1))}const a=t.data.attributes;for(const e in a){const n=a[e];let r;if(n.isInterleavedBufferAttribute){const e=i(t.data,n.data);r=new mc(e,n.itemSize,n.offset,n.normalized)}else{const t=ai(n.type,n.array);r=new(n.isInstancedBufferAttribute?Zc:pr)(t,n.itemSize,n.normalized)}void 0!==n.name&&(r.name=n.name),void 0!==n.usage&&r.setUsage(n.usage),s.setAttribute(e,r)}const o=t.data.morphAttributes;if(o)for(const e in o){const n=o[e],r=[];for(let e=0,s=n.length;e<s;e++){const s=n[e];let a;if(s.isInterleavedBufferAttribute){const e=i(t.data,s.data);a=new mc(e,s.itemSize,s.offset,s.normalized)}else{const t=ai(s.type,s.array);a=new pr(t,s.itemSize,s.normalized)}void 0!==s.name&&(a.name=s.name),r.push(a)}s.morphAttributes[e]=r}t.data.morphTargetsRelative&&(s.morphTargetsRelative=!0);const l=t.data.groups||t.data.drawcalls||t.data.offsets;if(void 0!==l)for(let t=0,e=l.length;t!==e;++t){const e=l[t];s.addGroup(e.start,e.count,e.materialIndex)}const c=t.data.boundingSphere;if(void 0!==c){const t=new Pi;void 0!==c.center&&t.fromArray(c.center),s.boundingSphere=new ts(t,c.radius)}return t.name&&(s.name=t.name),t.userData&&(s.userData=t.userData),s}}class Ip extends Kd{constructor(t){super(t)}load(t,e,n,i){const s=this,r=""===this.path?Np.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||r;const a=new ep(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(t,function(n){let r=null;try{r=JSON.parse(n)}catch(e){return void 0!==i&&i(e),void console.error("THREE:ObjectLoader: Can't parse "+t+".",e.message)}const a=r.metadata;if(void 0===a||void 0===a.type||"geometry"===a.type.toLowerCase())return void 0!==i&&i(new Error("THREE.ObjectLoader: Can't load "+t)),void console.error("THREE.ObjectLoader: Can't load "+t);s.parse(r,e)},n,i)}async loadAsync(t,e){const n=""===this.path?Np.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||n;const i=new ep(this.manager);i.setPath(this.path),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials);const s=await i.loadAsync(t,e),r=JSON.parse(s),a=r.metadata;if(void 0===a||void 0===a.type||"geometry"===a.type.toLowerCase())throw new Error("THREE.ObjectLoader: Can't load "+t);return await this.parseAsync(r)}parse(t,e){const n=this.parseAnimations(t.animations),i=this.parseShapes(t.shapes),s=this.parseGeometries(t.geometries,i),r=this.parseImages(t.images,function(){void 0!==e&&e(l)}),a=this.parseTextures(t.textures,r),o=this.parseMaterials(t.materials,a),l=this.parseObject(t.object,s,o,a,n),c=this.parseSkeletons(t.skeletons,l);if(this.bindSkeletons(l,c),this.bindLightTargets(l),void 0!==e){let t=!1;for(const e in r)if(r[e].data instanceof HTMLImageElement){t=!0;break}!1===t&&e(l)}return l}async parseAsync(t){const e=this.parseAnimations(t.animations),n=this.parseShapes(t.shapes),i=this.parseGeometries(t.geometries,n),s=await this.parseImagesAsync(t.images),r=this.parseTextures(t.textures,s),a=this.parseMaterials(t.materials,r),o=this.parseObject(t.object,i,a,r,e),l=this.parseSkeletons(t.skeletons,o);return this.bindSkeletons(o,l),this.bindLightTargets(o),o}parseShapes(t){const e={};if(void 0!==t)for(let n=0,i=t.length;n<i;n++){const i=(new Rh).fromJSON(t[n]);e[i.uuid]=i}return e}parseSkeletons(t,e){const n={},i={};if(e.traverse(function(t){t.isBone&&(i[t.uuid]=t)}),void 0!==t)for(let e=0,s=t.length;e<s;e++){const s=(new Yc).fromJSON(t[e],i);n[s.uuid]=s}return n}parseGeometries(t,e){const n={};if(void 0!==t){const i=new Rp;for(let s=0,r=t.length;s<r;s++){let r;const a=t[s];switch(a.type){case"BufferGeometry":case"InstancedBufferGeometry":r=i.parse(a);break;default:a.type in yd?r=yd[a.type].fromJSON(a,e):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${a.type}"`)}r.uuid=a.uuid,void 0!==a.name&&(r.name=a.name),void 0!==a.userData&&(r.userData=a.userData),n[a.uuid]=r}}return n}parseMaterials(t,e){const n={},i={};if(void 0!==t){const s=new Ap;s.setTextures(e);for(let e=0,r=t.length;e<r;e++){const r=t[e];void 0===n[r.uuid]&&(n[r.uuid]=s.parse(r)),i[r.uuid]=n[r.uuid]}}return i}parseAnimations(t){const e={};if(void 0!==t)for(let n=0;n<t.length;n++){const i=t[n],s=qd.parse(i);e[s.uuid]=s}return e}parseImages(t,e){const n=this,i={};let s;function r(t){if("string"==typeof t){const e=t;return function(t){return n.manager.itemStart(t),s.load(t,function(){n.manager.itemEnd(t)},void 0,function(){n.manager.itemError(t),n.manager.itemEnd(t)})}(/^(\/\/)|([a-z]+:(\/\/)?)/i.test(e)?e:n.resourcePath+e)}return t.data?{data:ai(t.type,t.data),width:t.width,height:t.height}:null}if(void 0!==t&&t.length>0){const n=new $d(e);s=new sp(n),s.setCrossOrigin(this.crossOrigin);for(let e=0,n=t.length;e<n;e++){const n=t[e],s=n.url;if(Array.isArray(s)){const t=[];for(let e=0,n=s.length;e<n;e++){const n=r(s[e]);null!==n&&(n instanceof HTMLImageElement?t.push(n):t.push(new jc(n.data,n.width,n.height)))}i[n.uuid]=new Mi(t)}else{const t=r(n.url);i[n.uuid]=new Mi(t)}}}return i}async parseImagesAsync(t){const e=this,n={};let i;async function s(t){if("string"==typeof t){const n=t,s=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(n)?n:e.resourcePath+n;return await i.loadAsync(s)}return t.data?{data:ai(t.type,t.data),width:t.width,height:t.height}:null}if(void 0!==t&&t.length>0){i=new sp(this.manager),i.setCrossOrigin(this.crossOrigin);for(let e=0,i=t.length;e<i;e++){const i=t[e],r=i.url;if(Array.isArray(r)){const t=[];for(let e=0,n=r.length;e<n;e++){const n=r[e],i=await s(n);null!==i&&(i instanceof HTMLImageElement?t.push(i):t.push(new jc(i.data,i.width,i.height)))}n[i.uuid]=new Mi(t)}else{const t=await s(i.url);n[i.uuid]=new Mi(t)}}}return n}parseTextures(t,e){function n(t,e){return"number"==typeof t?t:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",t),e[t])}const i={};if(void 0!==t)for(let s=0,r=t.length;s<r;s++){const r=t[s];void 0===r.image&&console.warn('THREE.ObjectLoader: No "image" specified for',r.uuid),void 0===e[r.image]&&console.warn("THREE.ObjectLoader: Undefined image",r.image);const a=e[r.image],o=a.data;let l;Array.isArray(o)?(l=new aa,6===o.length&&(l.needsUpdate=!0)):(l=o&&o.data?new jc:new Si,o&&(l.needsUpdate=!0)),l.source=a,l.uuid=r.uuid,void 0!==r.name&&(l.name=r.name),void 0!==r.mapping&&(l.mapping=n(r.mapping,Lp)),void 0!==r.channel&&(l.channel=r.channel),void 0!==r.offset&&l.offset.fromArray(r.offset),void 0!==r.repeat&&l.repeat.fromArray(r.repeat),void 0!==r.center&&l.center.fromArray(r.center),void 0!==r.rotation&&(l.rotation=r.rotation),void 0!==r.wrap&&(l.wrapS=n(r.wrap[0],Pp),l.wrapT=n(r.wrap[1],Pp)),void 0!==r.format&&(l.format=r.format),void 0!==r.internalFormat&&(l.internalFormat=r.internalFormat),void 0!==r.type&&(l.type=r.type),void 0!==r.colorSpace&&(l.colorSpace=r.colorSpace),void 0!==r.minFilter&&(l.minFilter=n(r.minFilter,Up)),void 0!==r.magFilter&&(l.magFilter=n(r.magFilter,Up)),void 0!==r.anisotropy&&(l.anisotropy=r.anisotropy),void 0!==r.flipY&&(l.flipY=r.flipY),void 0!==r.generateMipmaps&&(l.generateMipmaps=r.generateMipmaps),void 0!==r.premultiplyAlpha&&(l.premultiplyAlpha=r.premultiplyAlpha),void 0!==r.unpackAlignment&&(l.unpackAlignment=r.unpackAlignment),void 0!==r.compareFunction&&(l.compareFunction=r.compareFunction),void 0!==r.userData&&(l.userData=r.userData),i[r.uuid]=l}return i}parseObject(t,e,n,i,s){let r,a,o;function l(t){return void 0===e[t]&&console.warn("THREE.ObjectLoader: Undefined geometry",t),e[t]}function c(t){if(void 0!==t){if(Array.isArray(t)){const e=[];for(let i=0,s=t.length;i<s;i++){const s=t[i];void 0===n[s]&&console.warn("THREE.ObjectLoader: Undefined material",s),e.push(n[s])}return e}return void 0===n[t]&&console.warn("THREE.ObjectLoader: Undefined material",t),n[t]}}function u(t){return void 0===i[t]&&console.warn("THREE.ObjectLoader: Undefined texture",t),i[t]}switch(t.type){case"Scene":r=new hc,void 0!==t.background&&(Number.isInteger(t.background)?r.background=new er(t.background):r.background=u(t.background)),void 0!==t.environment&&(r.environment=u(t.environment)),void 0!==t.fog&&("Fog"===t.fog.type?r.fog=new uc(t.fog.color,t.fog.near,t.fog.far):"FogExp2"===t.fog.type&&(r.fog=new cc(t.fog.color,t.fog.density)),""!==t.fog.name&&(r.fog.name=t.fog.name)),void 0!==t.backgroundBlurriness&&(r.backgroundBlurriness=t.backgroundBlurriness),void 0!==t.backgroundIntensity&&(r.backgroundIntensity=t.backgroundIntensity),void 0!==t.backgroundRotation&&r.backgroundRotation.fromArray(t.backgroundRotation),void 0!==t.environmentIntensity&&(r.environmentIntensity=t.environmentIntensity),void 0!==t.environmentRotation&&r.environmentRotation.fromArray(t.environmentRotation);break;case"PerspectiveCamera":r=new ia(t.fov,t.aspect,t.near,t.far),void 0!==t.focus&&(r.focus=t.focus),void 0!==t.zoom&&(r.zoom=t.zoom),void 0!==t.filmGauge&&(r.filmGauge=t.filmGauge),void 0!==t.filmOffset&&(r.filmOffset=t.filmOffset),void 0!==t.view&&(r.view=Object.assign({},t.view));break;case"OrthographicCamera":r=new Ra(t.left,t.right,t.top,t.bottom,t.near,t.far),void 0!==t.zoom&&(r.zoom=t.zoom),void 0!==t.view&&(r.view=Object.assign({},t.view));break;case"AmbientLight":r=new Tp(t.color,t.intensity);break;case"DirectionalLight":r=new bp(t.color,t.intensity),r.target=t.target||"";break;case"PointLight":r=new xp(t.color,t.intensity,t.distance,t.decay);break;case"RectAreaLight":r=new Sp(t.color,t.intensity,t.width,t.height);break;case"SpotLight":r=new fp(t.color,t.intensity,t.distance,t.angle,t.penumbra,t.decay),r.target=t.target||"";break;case"HemisphereLight":r=new cp(t.color,t.groundColor,t.intensity);break;case"LightProbe":r=(new Ep).fromJSON(t);break;case"SkinnedMesh":a=l(t.geometry),o=c(t.material),r=new Gc(a,o),void 0!==t.bindMode&&(r.bindMode=t.bindMode),void 0!==t.bindMatrix&&r.bindMatrix.fromArray(t.bindMatrix),void 0!==t.skeleton&&(r.skeleton=t.skeleton);break;case"Mesh":a=l(t.geometry),o=c(t.material),r=new Hr(a,o);break;case"InstancedMesh":a=l(t.geometry),o=c(t.material);const e=t.count,n=t.instanceMatrix,i=t.instanceColor;r=new iu(a,o,e),r.instanceMatrix=new Zc(new Float32Array(n.array),16),void 0!==i&&(r.instanceColor=new Zc(new Float32Array(i.array),i.itemSize));break;case"BatchedMesh":a=l(t.geometry),o=c(t.material),r=new bu(t.maxInstanceCount,t.maxVertexCount,t.maxIndexCount,o),r.geometry=a,r.perObjectFrustumCulled=t.perObjectFrustumCulled,r.sortObjects=t.sortObjects,r._drawRanges=t.drawRanges,r._reservedRanges=t.reservedRanges,r._visibility=t.visibility,r._active=t.active,r._bounds=t.bounds.map(t=>{const e=new Oi;e.min.fromArray(t.boxMin),e.max.fromArray(t.boxMax);const n=new ts;return n.radius=t.sphereRadius,n.center.fromArray(t.sphereCenter),{boxInitialized:t.boxInitialized,box:e,sphereInitialized:t.sphereInitialized,sphere:n}}),r._maxInstanceCount=t.maxInstanceCount,r._maxVertexCount=t.maxVertexCount,r._maxIndexCount=t.maxIndexCount,r._geometryInitialized=t.geometryInitialized,r._geometryCount=t.geometryCount,r._matricesTexture=u(t.matricesTexture.uuid),void 0!==t.colorsTexture&&(r._colorsTexture=u(t.colorsTexture.uuid));break;case"LOD":r=new Pc;break;case"Line":r=new Iu(l(t.geometry),c(t.material));break;case"LineLoop":r=new Ou(l(t.geometry),c(t.material));break;case"LineSegments":r=new Du(l(t.geometry),c(t.material));break;case"PointCloud":case"Points":r=new Hu(l(t.geometry),c(t.material));break;case"Sprite":r=new Cc(c(t.material));break;case"Group":r=new Ql;break;case"Bone":r=new Wc;break;default:r=new Os}if(r.uuid=t.uuid,void 0!==t.name&&(r.name=t.name),void 0!==t.matrix?(r.matrix.fromArray(t.matrix),void 0!==t.matrixAutoUpdate&&(r.matrixAutoUpdate=t.matrixAutoUpdate),r.matrixAutoUpdate&&r.matrix.decompose(r.position,r.quaternion,r.scale)):(void 0!==t.position&&r.position.fromArray(t.position),void 0!==t.rotation&&r.rotation.fromArray(t.rotation),void 0!==t.quaternion&&r.quaternion.fromArray(t.quaternion),void 0!==t.scale&&r.scale.fromArray(t.scale)),void 0!==t.up&&r.up.fromArray(t.up),void 0!==t.castShadow&&(r.castShadow=t.castShadow),void 0!==t.receiveShadow&&(r.receiveShadow=t.receiveShadow),t.shadow&&(void 0!==t.shadow.intensity&&(r.shadow.intensity=t.shadow.intensity),void 0!==t.shadow.bias&&(r.shadow.bias=t.shadow.bias),void 0!==t.shadow.normalBias&&(r.shadow.normalBias=t.shadow.normalBias),void 0!==t.shadow.radius&&(r.shadow.radius=t.shadow.radius),void 0!==t.shadow.mapSize&&r.shadow.mapSize.fromArray(t.shadow.mapSize),void 0!==t.shadow.camera&&(r.shadow.camera=this.parseObject(t.shadow.camera))),void 0!==t.visible&&(r.visible=t.visible),void 0!==t.frustumCulled&&(r.frustumCulled=t.frustumCulled),void 0!==t.renderOrder&&(r.renderOrder=t.renderOrder),void 0!==t.userData&&(r.userData=t.userData),void 0!==t.layers&&(r.layers.mask=t.layers),void 0!==t.children){const a=t.children;for(let t=0;t<a.length;t++)r.add(this.parseObject(a[t],e,n,i,s))}if(void 0!==t.animations){const e=t.animations;for(let t=0;t<e.length;t++){const n=e[t];r.animations.push(s[n])}}if("LOD"===t.type){void 0!==t.autoUpdate&&(r.autoUpdate=t.autoUpdate);const e=t.levels;for(let t=0;t<e.length;t++){const n=e[t],i=r.getObjectByProperty("uuid",n.object);void 0!==i&&r.addLevel(i,n.distance,n.hysteresis)}}return r}bindSkeletons(t,e){0!==Object.keys(e).length&&t.traverse(function(t){if(!0===t.isSkinnedMesh&&void 0!==t.skeleton){const n=e[t.skeleton];void 0===n?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",t.skeleton):t.bind(n,t.bindMatrix)}})}bindLightTargets(t){t.traverse(function(e){if(e.isDirectionalLight||e.isSpotLight){const n=e.target,i=t.getObjectByProperty("uuid",n);e.target=void 0!==i?i:new Os}})}}const Lp={UVMapping:ot,CubeReflectionMapping:lt,CubeRefractionMapping:ct,EquirectangularReflectionMapping:ut,EquirectangularRefractionMapping:ht,CubeUVReflectionMapping:dt},Pp={RepeatWrapping:pt,ClampToEdgeWrapping:mt,MirroredRepeatWrapping:ft},Up={NearestFilter:gt,NearestMipmapNearestFilter:vt,NearestMipmapLinearFilter:_t,LinearFilter:Mt,LinearMipmapNearestFilter:bt,LinearMipmapLinearFilter:St};class Dp extends Kd{constructor(t){super(t),this.isImageBitmapLoader=!0,"undefined"==typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(t){return this.options=t,this}load(t,e,n,i){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const s=this,r=Zd.get(t);if(void 0!==r)return s.manager.itemStart(t),r.then?void r.then(n=>{e&&e(n),s.manager.itemEnd(t)}).catch(t=>{i&&i(t)}):(setTimeout(function(){e&&e(r),s.manager.itemEnd(t)},0),r);const a={};a.credentials="anonymous"===this.crossOrigin?"same-origin":"include",a.headers=this.requestHeader;const o=fetch(t,a).then(function(t){return t.blob()}).then(function(t){return createImageBitmap(t,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(n){return Zd.add(t,n),e&&e(n),s.manager.itemEnd(t),n}).catch(function(e){i&&i(e),Zd.remove(t),s.manager.itemError(t),s.manager.itemEnd(t)});Zd.add(t,o),s.manager.itemStart(t)}}let Op;class zp{static getContext(){return void 0===Op&&(Op=new(window.AudioContext||window.webkitAudioContext)),Op}static setContext(t){Op=t}}class Vp extends Kd{constructor(t){super(t)}load(t,e,n,i){const s=this,r=new ep(this.manager);function a(e){i?i(e):console.error(e),s.manager.itemError(t)}r.setResponseType("arraybuffer"),r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(t,function(t){try{const n=t.slice(0);zp.getContext().decodeAudioData(n,function(t){e(t)}).catch(a)}catch(t){a(t)}},n,i)}}const Fp=new cs,Bp=new cs,kp=new cs;class Hp{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new ia,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new ia,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(t){const e=this._cache;if(e.focus!==t.focus||e.fov!==t.fov||e.aspect!==t.aspect*this.aspect||e.near!==t.near||e.far!==t.far||e.zoom!==t.zoom||e.eyeSep!==this.eyeSep){e.focus=t.focus,e.fov=t.fov,e.aspect=t.aspect*this.aspect,e.near=t.near,e.far=t.far,e.zoom=t.zoom,e.eyeSep=this.eyeSep,kp.copy(t.projectionMatrix);const n=e.eyeSep/2,i=n*e.near/e.focus,s=e.near*Math.tan(Xn*e.fov*.5)/e.zoom;let r,a;Bp.elements[12]=-n,Fp.elements[12]=n,r=-s*e.aspect+i,a=s*e.aspect+i,kp.elements[0]=2*e.near/(a-r),kp.elements[8]=(a+r)/(a-r),this.cameraL.projectionMatrix.copy(kp),r=-s*e.aspect-i,a=s*e.aspect-i,kp.elements[0]=2*e.near/(a-r),kp.elements[8]=(a+r)/(a-r),this.cameraR.projectionMatrix.copy(kp)}this.cameraL.matrixWorld.copy(t.matrixWorld).multiply(Bp),this.cameraR.matrixWorld.copy(t.matrixWorld).multiply(Fp)}}class Gp{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=Wp(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const e=Wp();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}}function Wp(){return performance.now()}const jp=new Pi,Xp=new Li,qp=new Pi,Yp=new Pi;class Zp extends Os{constructor(){super(),this.type="AudioListener",this.context=zp.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Gp}getInput(){return this.gain}removeFilter(){return null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(t){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=t,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}updateMatrixWorld(t){super.updateMatrixWorld(t);const e=this.context.listener,n=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(jp,Xp,qp),Number.isFinite(jp.x)&&Number.isFinite(jp.y)&&Number.isFinite(jp.z))if(Yp.set(0,0,-1).applyQuaternion(Xp),e.positionX){const t=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(jp.x,t),e.positionY.linearRampToValueAtTime(jp.y,t),e.positionZ.linearRampToValueAtTime(jp.z,t),e.forwardX.linearRampToValueAtTime(Yp.x,t),e.forwardY.linearRampToValueAtTime(Yp.y,t),e.forwardZ.linearRampToValueAtTime(Yp.z,t),e.upX.linearRampToValueAtTime(n.x,t),e.upY.linearRampToValueAtTime(n.y,t),e.upZ.linearRampToValueAtTime(n.z,t)}else e.setPosition(jp.x,jp.y,jp.z),e.setOrientation(Yp.x,Yp.y,Yp.z,n.x,n.y,n.z)}}class $p extends Os{constructor(t){super(),this.type="Audio",this.listener=t,this.context=t.context,this.gain=this.context.createGain(),this.gain.connect(t.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(t){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=t,this.connect(),this}setMediaElementSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(t),this.connect(),this}setMediaStreamSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(t),this.connect(),this}setBuffer(t){return this.buffer=t,this.sourceType="buffer",this.autoplay&&this.play(),this}play(t=0){if(!0===this.isPlaying)return void console.warn("THREE.Audio: Audio is already playing.");if(!1===this.hasPlaybackControl)return void console.warn("THREE.Audio: this Audio has no playback control.");this._startedAt=this.context.currentTime+t;const e=this.context.createBufferSource();return e.buffer=this.buffer,e.loop=this.loop,e.loopStart=this.loopStart,e.loopEnd=this.loopEnd,e.onended=this.onEnded.bind(this),e.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=e,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(!1!==this.hasPlaybackControl)return!0===this.isPlaying&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,!0===this.loop&&(this._progress=this._progress%(this.duration||(this.buffer?this.buffer.duration:Number.MAX_VALUE))),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this;console.warn("THREE.Audio: this Audio has no playback control.")}stop(t=0){if(!1!==this.hasPlaybackControl)return this._progress=0,null!==this.source&&(this.source.stop(this.context.currentTime+t),this.source.onended=null),this.isPlaying=!1,this;console.warn("THREE.Audio: this Audio has no playback control.")}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let t=1,e=this.filters.length;t<e;t++)this.filters[t-1].connect(this.filters[t]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(!1!==this._connected){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let t=1,e=this.filters.length;t<e;t++)this.filters[t-1].disconnect(this.filters[t]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}}getFilters(){return this.filters}setFilters(t){return t||(t=[]),!0===this._connected?(this.disconnect(),this.filters=t.slice(),this.connect()):this.filters=t.slice(),this}setDetune(t){return this.detune=t,!0===this.isPlaying&&void 0!==this.source.detune&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(t){return this.setFilters(t?[t]:[])}setPlaybackRate(t){if(!1!==this.hasPlaybackControl)return this.playbackRate=t,!0===this.isPlaying&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this;console.warn("THREE.Audio: this Audio has no playback control.")}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return!1===this.hasPlaybackControl?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(t){if(!1!==this.hasPlaybackControl)return this.loop=t,!0===this.isPlaying&&(this.source.loop=this.loop),this;console.warn("THREE.Audio: this Audio has no playback control.")}setLoopStart(t){return this.loopStart=t,this}setLoopEnd(t){return this.loopEnd=t,this}getVolume(){return this.gain.gain.value}setVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}}const Jp=new Pi,Kp=new Li,Qp=new Pi,tm=new Pi;class em extends $p{constructor(t){super(t),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){super.connect(),this.panner.connect(this.gain)}disconnect(){super.disconnect(),this.panner.disconnect(this.gain)}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(t){return this.panner.refDistance=t,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(t){return this.panner.rolloffFactor=t,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(t){return this.panner.distanceModel=t,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(t){return this.panner.maxDistance=t,this}setDirectionalCone(t,e,n){return this.panner.coneInnerAngle=t,this.panner.coneOuterAngle=e,this.panner.coneOuterGain=n,this}updateMatrixWorld(t){if(super.updateMatrixWorld(t),!0===this.hasPlaybackControl&&!1===this.isPlaying)return;this.matrixWorld.decompose(Jp,Kp,Qp),tm.set(0,0,1).applyQuaternion(Kp);const e=this.panner;if(e.positionX){const t=this.context.currentTime+this.listener.timeDelta;e.positionX.linearRampToValueAtTime(Jp.x,t),e.positionY.linearRampToValueAtTime(Jp.y,t),e.positionZ.linearRampToValueAtTime(Jp.z,t),e.orientationX.linearRampToValueAtTime(tm.x,t),e.orientationY.linearRampToValueAtTime(tm.y,t),e.orientationZ.linearRampToValueAtTime(tm.z,t)}else e.setPosition(Jp.x,Jp.y,Jp.z),e.setOrientation(tm.x,tm.y,tm.z)}}class nm{constructor(t,e=2048){this.analyser=t.context.createAnalyser(),this.analyser.fftSize=e,this.data=new Uint8Array(this.analyser.frequencyBinCount),t.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let t=0;const e=this.getFrequencyData();for(let n=0;n<e.length;n++)t+=e[n];return t/e.length}}class im{constructor(t,e,n){let i,s,r;switch(this.binding=t,this.valueSize=n,e){case"quaternion":i=this._slerp,s=this._slerpAdditive,r=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(6*n),this._workIndex=5;break;case"string":case"bool":i=this._select,s=this._select,r=this._setAdditiveIdentityOther,this.buffer=new Array(5*n);break;default:i=this._lerp,s=this._lerpAdditive,r=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(5*n)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=s,this._setIdentity=r,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(t,e){const n=this.buffer,i=this.valueSize,s=t*i+i;let r=this.cumulativeWeight;if(0===r){for(let t=0;t!==i;++t)n[s+t]=n[t];r=e}else{r+=e;const t=e/r;this._mixBufferRegion(n,s,0,t,i)}this.cumulativeWeight=r}accumulateAdditive(t){const e=this.buffer,n=this.valueSize,i=n*this._addIndex;0===this.cumulativeWeightAdditive&&this._setIdentity(),this._mixBufferRegionAdditive(e,i,0,t,n),this.cumulativeWeightAdditive+=t}apply(t){const e=this.valueSize,n=this.buffer,i=t*e+e,s=this.cumulativeWeight,r=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){const t=e*this._origIndex;this._mixBufferRegion(n,i,t,1-s,e)}r>0&&this._mixBufferRegionAdditive(n,i,this._addIndex*e,1,e);for(let t=e,s=e+e;t!==s;++t)if(n[t]!==n[t+e]){a.setValue(n,i);break}}saveOriginalState(){const t=this.binding,e=this.buffer,n=this.valueSize,i=n*this._origIndex;t.getValue(e,i);for(let t=n,s=i;t!==s;++t)e[t]=e[i+t%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const t=3*this.valueSize;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){const t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let n=t;n<e;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const t=this._origIndex*this.valueSize,e=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[e+n]=this.buffer[t+n]}_select(t,e,n,i,s){if(i>=.5)for(let i=0;i!==s;++i)t[e+i]=t[n+i]}_slerp(t,e,n,i){Li.slerpFlat(t,e,t,e,t,n,i)}_slerpAdditive(t,e,n,i,s){const r=this._workIndex*s;Li.multiplyQuaternionsFlat(t,r,t,e,t,n),Li.slerpFlat(t,e,t,e,t,r,i)}_lerp(t,e,n,i,s){const r=1-i;for(let a=0;a!==s;++a){const s=e+a;t[s]=t[s]*r+t[n+a]*i}}_lerpAdditive(t,e,n,i,s){for(let r=0;r!==s;++r){const s=e+r;t[s]=t[s]+t[n+r]*i}}}const sm="\\[\\]\\.:\\/",rm=new RegExp("["+sm+"]","g"),am="[^"+sm+"]",om="[^"+sm.replace("\\.","")+"]",lm=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",am)+/(WCOD+)?/.source.replace("WCOD",om)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",am)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",am)+"$"),cm=["material","materials","bones","map"];class um{constructor(t,e,n){this.path=e,this.parsedPath=n||um.parseTrackName(e),this.node=um.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new um.Composite(t,e,n):new um(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(rm,"")}static parseTrackName(t){const e=lm.exec(t);if(null===e)throw new Error("PropertyBinding: Cannot parse trackName: "+t);const n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==i&&-1!==i){const t=n.nodeName.substring(i+1);-1!==cm.indexOf(t)&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=t)}if(null===n.propertyName||0===n.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(void 0===e||""===e||"."===e||-1===e||e===t.name||e===t.uuid)return t;if(t.skeleton){const n=t.skeleton.getBoneByName(e);if(void 0!==n)return n}if(t.children){const n=function(t,i){for(let s=0;s<t.length;s++){const r=t[s];if(!(i||r.name!==e&&r.uuid!==e))return r;if(i&&r.userData&&r.userData.name===e)return r;const a=n(r.children,i);if(a)return a}return null},i=n(t.children);if(i)return i;{const e=n(t.children,!0);if(e)return e}}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)t[e++]=n[i]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=t[e++]}_setValue_array_setNeedsUpdate(t,e){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node;const e=this.parsedPath,n=e.objectName,i=e.propertyName;let s=e.propertyIndex;if(t||(t=um.findNode(this.rootNode,e.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t)return void console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");if(n){let i=e.objectIndex;switch(n){case"materials":if(!t.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!t.material.materials)return void console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);t=t.material.materials;break;case"bones":if(!t.skeleton)return void console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);t=t.skeleton.bones;for(let e=0;e<t.length;e++)if(t[e].name===i){i=e;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!t.material.map)return void console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);t=t.material.map;break;default:if(void 0===t[n])return void console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);t=t[n]}if(void 0!==i){if(void 0===t[i])return void console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);t=t[i]}}const r=t[i];if(void 0===r){const n=e.nodeName;return void console.error("THREE.PropertyBinding: Trying to update property for track: "+n+"."+i+" but it wasn't found.",t)}let a=this.Versioning.None;this.targetObject=t,void 0!==t.needsUpdate?a=this.Versioning.NeedsUpdate:void 0!==t.matrixWorldNeedsUpdate&&(a=this.Versioning.MatrixWorldNeedsUpdate);let o=this.BindingType.Direct;if(void 0!==s){if("morphTargetInfluences"===i){if(!t.geometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(!t.geometry.morphAttributes)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);void 0!==t.morphTargetDictionary[s]&&(s=t.morphTargetDictionary[s])}o=this.BindingType.ArrayElement,this.resolvedProperty=r,this.propertyIndex=s}else void 0!==r.fromArray&&void 0!==r.toArray?(o=this.BindingType.HasFromToArray,this.resolvedProperty=r):Array.isArray(r)?(o=this.BindingType.EntireArray,this.resolvedProperty=r):this.propertyName=i;this.getValue=this.GetterByBindingType[o],this.setValue=this.SetterByBindingTypeAndVersioning[o][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}um.Composite=class{constructor(t,e,n){const i=n||um.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,i)}getValue(t,e){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];void 0!==i&&i.getValue(t,e)}setValue(t,e){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=n.length;i!==s;++i)n[i].setValue(t,e)}bind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()}unbind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}},um.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},um.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},um.prototype.GetterByBindingType=[um.prototype._getValue_direct,um.prototype._getValue_array,um.prototype._getValue_arrayElement,um.prototype._getValue_toArray],um.prototype.SetterByBindingTypeAndVersioning=[[um.prototype._setValue_direct,um.prototype._setValue_direct_setNeedsUpdate,um.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[um.prototype._setValue_array,um.prototype._setValue_array_setNeedsUpdate,um.prototype._setValue_array_setMatrixWorldNeedsUpdate],[um.prototype._setValue_arrayElement,um.prototype._setValue_arrayElement_setNeedsUpdate,um.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[um.prototype._setValue_fromArray,um.prototype._setValue_fromArray_setNeedsUpdate,um.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class hm{constructor(){this.isAnimationObjectGroup=!0,this.uuid=Yn(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const t={};this._indicesByUUID=t;for(let e=0,n=arguments.length;e!==n;++e)t[arguments[e].uuid]=e;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const e=this;this.stats={objects:{get total(){return e._objects.length},get inUse(){return this.total-e.nCachedObjects_}},get bindingsPerObject(){return e._bindings.length}}}add(){const t=this._objects,e=this._indicesByUUID,n=this._paths,i=this._parsedPaths,s=this._bindings,r=s.length;let a,o=t.length,l=this.nCachedObjects_;for(let c=0,u=arguments.length;c!==u;++c){const u=arguments[c],h=u.uuid;let d=e[h];if(void 0===d){d=o++,e[h]=d,t.push(u);for(let t=0,e=r;t!==e;++t)s[t].push(new um(u,n[t],i[t]))}else if(d<l){a=t[d];const o=--l,c=t[o];e[c.uuid]=d,t[d]=c,e[h]=o,t[o]=u;for(let t=0,e=r;t!==e;++t){const e=s[t],r=e[o];let a=e[d];e[d]=r,void 0===a&&(a=new um(u,n[t],i[t])),e[o]=a}}else t[d]!==a&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=l}remove(){const t=this._objects,e=this._indicesByUUID,n=this._bindings,i=n.length;let s=this.nCachedObjects_;for(let r=0,a=arguments.length;r!==a;++r){const a=arguments[r],o=a.uuid,l=e[o];if(void 0!==l&&l>=s){const r=s++,c=t[r];e[c.uuid]=l,t[l]=c,e[o]=r,t[r]=a;for(let t=0,e=i;t!==e;++t){const e=n[t],i=e[r],s=e[l];e[l]=i,e[r]=s}}}this.nCachedObjects_=s}uncache(){const t=this._objects,e=this._indicesByUUID,n=this._bindings,i=n.length;let s=this.nCachedObjects_,r=t.length;for(let a=0,o=arguments.length;a!==o;++a){const o=arguments[a].uuid,l=e[o];if(void 0!==l)if(delete e[o],l<s){const a=--s,o=t[a],c=--r,u=t[c];e[o.uuid]=l,t[l]=o,e[u.uuid]=a,t[a]=u,t.pop();for(let t=0,e=i;t!==e;++t){const e=n[t],i=e[a],s=e[c];e[l]=i,e[a]=s,e.pop()}}else{const s=--r,a=t[s];s>0&&(e[a.uuid]=l),t[l]=a,t.pop();for(let t=0,e=i;t!==e;++t){const e=n[t];e[l]=e[s],e.pop()}}}this.nCachedObjects_=s}subscribe_(t,e){const n=this._bindingsIndicesByPath;let i=n[t];const s=this._bindings;if(void 0!==i)return s[i];const r=this._paths,a=this._parsedPaths,o=this._objects,l=o.length,c=this.nCachedObjects_,u=new Array(l);i=s.length,n[t]=i,r.push(t),a.push(e),s.push(u);for(let n=c,i=o.length;n!==i;++n){const i=o[n];u[n]=new um(i,t,e)}return u}unsubscribe_(t){const e=this._bindingsIndicesByPath,n=e[t];if(void 0!==n){const i=this._paths,s=this._parsedPaths,r=this._bindings,a=r.length-1,o=r[a];e[t[a]]=n,r[n]=o,r.pop(),s[n]=s[a],s.pop(),i[n]=i[a],i.pop()}}}class dm{constructor(t,e,n=null,i=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=n,this.blendMode=i;const s=e.tracks,r=s.length,a=new Array(r),o={endingStart:Oe,endingEnd:Oe};for(let t=0;t!==r;++t){const e=s[t].createInterpolant(null);a[t]=e,e.settings=o}this._interpolantSettings=o,this._interpolants=a,this._propertyBindings=new Array(r),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,n){if(t.fadeOut(e),this.fadeIn(e),n){const n=this._clip.duration,i=t._clip.duration,s=i/n,r=n/i;t.warp(1,s,e),this.warp(r,1,e)}return this}crossFadeTo(t,e,n){return t.crossFadeFrom(this,e,n)}stopFading(){const t=this._weightInterpolant;return null!==t&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,n){const i=this._mixer,s=i.time,r=this.timeScale;let a=this._timeScaleInterpolant;null===a&&(a=i._lendControlInterpolant(),this._timeScaleInterpolant=a);const o=a.parameterPositions,l=a.sampleValues;return o[0]=s,o[1]=s+n,l[0]=t/r,l[1]=e/r,this}stopWarping(){const t=this._timeScaleInterpolant;return null!==t&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,n,i){if(!this.enabled)return void this._updateWeight(t);const s=this._startTime;if(null!==s){const i=(t-s)*n;i<0||0===n?e=0:(this._startTime=null,e=n*i)}e*=this._updateTimeScale(t);const r=this._updateTime(e),a=this._updateWeight(t);if(a>0){const t=this._interpolants,e=this._propertyBindings;if(this.blendMode===Be)for(let n=0,i=t.length;n!==i;++n)t[n].evaluate(r),e[n].accumulateAdditive(a);else for(let n=0,s=t.length;n!==s;++n)t[n].evaluate(r),e[n].accumulate(i,a)}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;const n=this._weightInterpolant;if(null!==n){const i=n.evaluate(t)[0];e*=i,t>n.parameterPositions[1]&&(this.stopFading(),0===i&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;const n=this._timeScaleInterpolant;if(null!==n){e*=n.evaluate(t)[0],t>n.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e)}}return this._effectiveTimeScale=e,e}_updateTime(t){const e=this._clip.duration,n=this.loop;let i=this.time+t,s=this._loopCount;const r=2202===n;if(0===t)return-1===s||!r||1&~s?i:e-i;if(2200===n){-1===s&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(i>=e)i=e;else{if(!(i<0)){this.time=i;break t}i=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(-1===s&&(t>=0?(s=0,this._setEndings(!0,0===this.repetitions,r)):this._setEndings(0===this.repetitions,!0,r)),i>=e||i<0){const n=Math.floor(i/e);i-=e*n,s+=Math.abs(n);const a=this.repetitions-s;if(a<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=t>0?e:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(1===a){const e=t<0;this._setEndings(e,!e,r)}else this._setEndings(!1,!1,r);this._loopCount=s,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:n})}}else this.time=i;if(r&&!(1&~s))return e-i}return i}_setEndings(t,e,n){const i=this._interpolantSettings;n?(i.endingStart=ze,i.endingEnd=ze):(i.endingStart=t?this.zeroSlopeAtStart?ze:Oe:Ve,i.endingEnd=e?this.zeroSlopeAtEnd?ze:Oe:Ve)}_scheduleFading(t,e,n){const i=this._mixer,s=i.time;let r=this._weightInterpolant;null===r&&(r=i._lendControlInterpolant(),this._weightInterpolant=r);const a=r.parameterPositions,o=r.sampleValues;return a[0]=s,o[0]=e,a[1]=s+t,o[1]=n,this}}const pm=new Float32Array(1);class mm extends Gn{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){const n=t._localRoot||this._root,i=t._clip.tracks,s=i.length,r=t._propertyBindings,a=t._interpolants,o=n.uuid,l=this._bindingsByRootAndName;let c=l[o];void 0===c&&(c={},l[o]=c);for(let t=0;t!==s;++t){const s=i[t],l=s.name;let u=c[l];if(void 0!==u)++u.referenceCount,r[t]=u;else{if(u=r[t],void 0!==u){null===u._cacheIndex&&(++u.referenceCount,this._addInactiveBinding(u,o,l));continue}const i=e&&e._propertyBindings[t].binding.parsedPath;u=new im(um.create(n,l,i),s.ValueTypeName,s.getValueSize()),++u.referenceCount,this._addInactiveBinding(u,o,l),r[t]=u}a[t].resultBuffer=u.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){const e=(t._localRoot||this._root).uuid,n=t._clip.uuid,i=this._actionsByClip[n];this._bindAction(t,i&&i.knownActions[0]),this._addInactiveAction(t,n,e)}const e=t._propertyBindings;for(let t=0,n=e.length;t!==n;++t){const n=e[t];0===n.useCount++&&(this._lendBinding(n),n.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){const e=t._propertyBindings;for(let t=0,n=e.length;t!==n;++t){const n=e[t];0===--n.useCount&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){const e=t._cacheIndex;return null!==e&&e<this._nActiveActions}_addInactiveAction(t,e,n){const i=this._actions,s=this._actionsByClip;let r=s[e];if(void 0===r)r={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,s[e]=r;else{const e=r.knownActions;t._byClipCacheIndex=e.length,e.push(t)}t._cacheIndex=i.length,i.push(t),r.actionByRoot[n]=t}_removeInactiveAction(t){const e=this._actions,n=e[e.length-1],i=t._cacheIndex;n._cacheIndex=i,e[i]=n,e.pop(),t._cacheIndex=null;const s=t._clip.uuid,r=this._actionsByClip,a=r[s],o=a.knownActions,l=o[o.length-1],c=t._byClipCacheIndex;l._byClipCacheIndex=c,o[c]=l,o.pop(),t._byClipCacheIndex=null;delete a.actionByRoot[(t._localRoot||this._root).uuid],0===o.length&&delete r[s],this._removeInactiveBindingsForAction(t)}_removeInactiveBindingsForAction(t){const e=t._propertyBindings;for(let t=0,n=e.length;t!==n;++t){const n=e[t];0===--n.referenceCount&&this._removeInactiveBinding(n)}}_lendAction(t){const e=this._actions,n=t._cacheIndex,i=this._nActiveActions++,s=e[i];t._cacheIndex=i,e[i]=t,s._cacheIndex=n,e[n]=s}_takeBackAction(t){const e=this._actions,n=t._cacheIndex,i=--this._nActiveActions,s=e[i];t._cacheIndex=i,e[i]=t,s._cacheIndex=n,e[n]=s}_addInactiveBinding(t,e,n){const i=this._bindingsByRootAndName,s=this._bindings;let r=i[e];void 0===r&&(r={},i[e]=r),r[n]=t,t._cacheIndex=s.length,s.push(t)}_removeInactiveBinding(t){const e=this._bindings,n=t.binding,i=n.rootNode.uuid,s=n.path,r=this._bindingsByRootAndName,a=r[i],o=e[e.length-1],l=t._cacheIndex;o._cacheIndex=l,e[l]=o,e.pop(),delete a[s],0===Object.keys(a).length&&delete r[i]}_lendBinding(t){const e=this._bindings,n=t._cacheIndex,i=this._nActiveBindings++,s=e[i];t._cacheIndex=i,e[i]=t,s._cacheIndex=n,e[n]=s}_takeBackBinding(t){const e=this._bindings,n=t._cacheIndex,i=--this._nActiveBindings,s=e[i];t._cacheIndex=i,e[i]=t,s._cacheIndex=n,e[n]=s}_lendControlInterpolant(){const t=this._controlInterpolants,e=this._nActiveControlInterpolants++;let n=t[e];return void 0===n&&(n=new zd(new Float32Array(2),new Float32Array(2),1,pm),n.__cacheIndex=e,t[e]=n),n}_takeBackControlInterpolant(t){const e=this._controlInterpolants,n=t.__cacheIndex,i=--this._nActiveControlInterpolants,s=e[i];t.__cacheIndex=i,e[i]=t,s.__cacheIndex=n,e[n]=s}clipAction(t,e,n){const i=e||this._root,s=i.uuid;let r="string"==typeof t?qd.findByName(i,t):t;const a=null!==r?r.uuid:t,o=this._actionsByClip[a];let l=null;if(void 0===n&&(n=null!==r?r.blendMode:Fe),void 0!==o){const t=o.actionByRoot[s];if(void 0!==t&&t.blendMode===n)return t;l=o.knownActions[0],null===r&&(r=l._clip)}if(null===r)return null;const c=new dm(this,r,e,n);return this._bindAction(c,l),this._addInactiveAction(c,a,s),c}existingAction(t,e){const n=e||this._root,i=n.uuid,s="string"==typeof t?qd.findByName(n,t):t,r=s?s.uuid:t,a=this._actionsByClip[r];return void 0!==a&&a.actionByRoot[i]||null}stopAllAction(){const t=this._actions;for(let e=this._nActiveActions-1;e>=0;--e)t[e].stop();return this}update(t){t*=this.timeScale;const e=this._actions,n=this._nActiveActions,i=this.time+=t,s=Math.sign(t),r=this._accuIndex^=1;for(let a=0;a!==n;++a){e[a]._update(i,t,s,r)}const a=this._bindings,o=this._nActiveBindings;for(let t=0;t!==o;++t)a[t].apply(r);return this}setTime(t){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(t)}getRoot(){return this._root}uncacheClip(t){const e=this._actions,n=t.uuid,i=this._actionsByClip,s=i[n];if(void 0!==s){const t=s.knownActions;for(let n=0,i=t.length;n!==i;++n){const i=t[n];this._deactivateAction(i);const s=i._cacheIndex,r=e[e.length-1];i._cacheIndex=null,i._byClipCacheIndex=null,r._cacheIndex=s,e[s]=r,e.pop(),this._removeInactiveBindingsForAction(i)}delete i[n]}}uncacheRoot(t){const e=t.uuid,n=this._actionsByClip;for(const t in n){const i=n[t].actionByRoot[e];void 0!==i&&(this._deactivateAction(i),this._removeInactiveAction(i))}const i=this._bindingsByRootAndName[e];if(void 0!==i)for(const t in i){const e=i[t];e.restoreOriginalState(),this._removeInactiveBinding(e)}}uncacheAction(t,e){const n=this.existingAction(t,e);null!==n&&(this._deactivateAction(n),this._removeInactiveAction(n))}}let fm=class t{constructor(t){this.value=t}clone(){return new t(void 0===this.value.clone?this.value:this.value.clone())}},gm=0;class vm extends Gn{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:gm++}),this.name="",this.usage=Rn,this.uniforms=[]}add(t){return this.uniforms.push(t),this}remove(t){const e=this.uniforms.indexOf(t);return-1!==e&&this.uniforms.splice(e,1),this}setName(t){return this.name=t,this}setUsage(t){return this.usage=t,this}dispose(){return this.dispatchEvent({type:"dispose"}),this}copy(t){this.name=t.name,this.usage=t.usage;const e=t.uniforms;this.uniforms.length=0;for(let t=0,n=e.length;t<n;t++){const n=Array.isArray(e[t])?e[t]:[e[t]];for(let t=0;t<n.length;t++)this.uniforms.push(n[t].clone())}return this}clone(){return(new this.constructor).copy(this)}}class ym extends dc{constructor(t,e,n=1){super(t,e),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}clone(t){const e=super.clone(t);return e.meshPerAttribute=this.meshPerAttribute,e}toJSON(t){const e=super.toJSON(t);return e.isInstancedInterleavedBuffer=!0,e.meshPerAttribute=this.meshPerAttribute,e}}class _m{constructor(t,e,n,i,s){this.isGLBufferAttribute=!0,this.name="",this.buffer=t,this.type=e,this.itemSize=n,this.elementSize=i,this.count=s,this.version=0}set needsUpdate(t){!0===t&&this.version++}setBuffer(t){return this.buffer=t,this}setType(t,e){return this.type=t,this.elementSize=e,this}setItemSize(t){return this.itemSize=t,this}setCount(t){return this.count=t,this}}const xm=new cs;class Mm{constructor(t,e,n=0,i=1/0){this.ray=new ls(t,e),this.near=n,this.far=i,this.camera=null,this.layers=new xs,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):console.error("THREE.Raycaster: Unsupported camera type: "+e.type)}setFromXRController(t){return xm.identity().extractRotation(t.matrixWorld),this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(xm),this}intersectObject(t,e=!0,n=[]){return Tm(t,this,n,e),n.sort(bm),n}intersectObjects(t,e=!0,n=[]){for(let i=0,s=t.length;i<s;i++)Tm(t[i],this,n,e);return n.sort(bm),n}}function bm(t,e){return t.distance-e.distance}function Tm(t,e,n,i){let s=!0;if(t.layers.test(e.layers)){!1===t.raycast(e,n)&&(s=!1)}if(!0===s&&!0===i){const i=t.children;for(let t=0,s=i.length;t<s;t++)Tm(i[t],e,n,!0)}}class Sm{constructor(t=1,e=0,n=0){return this.radius=t,this.phi=e,this.theta=n,this}set(t,e,n){return this.radius=t,this.phi=e,this.theta=n,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){const t=1e-6;return this.phi=Math.max(t,Math.min(Math.PI-t,this.phi)),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,n){return this.radius=Math.sqrt(t*t+e*e+n*n),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,n),this.phi=Math.acos(Zn(e/this.radius,-1,1))),this}clone(){return(new this.constructor).copy(this)}}class wm{constructor(t=1,e=0,n=0){return this.radius=t,this.theta=e,this.y=n,this}set(t,e,n){return this.radius=t,this.theta=e,this.y=n,this}copy(t){return this.radius=t.radius,this.theta=t.theta,this.y=t.y,this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,n){return this.radius=Math.sqrt(t*t+n*n),this.theta=Math.atan2(t,n),this.y=e,this}clone(){return(new this.constructor).copy(this)}}class Em{constructor(t,e,n,i){Em.prototype.isMatrix2=!0,this.elements=[1,0,0,1],void 0!==t&&this.set(t,e,n,i)}identity(){return this.set(1,0,0,1),this}fromArray(t,e=0){for(let n=0;n<4;n++)this.elements[n]=t[n+e];return this}set(t,e,n,i){const s=this.elements;return s[0]=t,s[2]=e,s[1]=n,s[3]=i,this}}const Am=new ei;class Nm{constructor(t=new ei(1/0,1/0),e=new ei(-1/0,-1/0)){this.isBox2=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const n=Am.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Am).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const Cm=new Pi,Rm=new Pi;class Im{constructor(t=new Pi,e=new Pi){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){Cm.subVectors(t,this.start),Rm.subVectors(this.end,this.start);const n=Rm.dot(Rm);let i=Rm.dot(Cm)/n;return e&&(i=Zn(i,0,1)),i}closestPointToPoint(t,e,n){const i=this.closestPointToPointParameter(t,e);return this.delta(n).multiplyScalar(i).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return(new this.constructor).copy(this)}}const Lm=new Pi;class Pm extends Os{constructor(t,e){super(),this.light=t,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";const n=new Rr,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let t=0,e=1,n=32;t<n;t++,e++){const s=t/n*Math.PI*2,r=e/n*Math.PI*2;i.push(Math.cos(s),Math.sin(s),1,Math.cos(r),Math.sin(r),1)}n.setAttribute("position",new br(i,3));const s=new Tu({fog:!1,toneMapped:!1});this.cone=new Du(n,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);const t=this.light.distance?this.light.distance:1e3,e=t*Math.tan(this.light.angle);this.cone.scale.set(e,e,t),Lm.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Lm),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const Um=new Pi,Dm=new cs,Om=new cs;class zm extends Du{constructor(t){const e=Vm(t),n=new Rr,i=[],s=[],r=new er(0,0,1),a=new er(0,1,0);for(let t=0;t<e.length;t++){const n=e[t];n.parent&&n.parent.isBone&&(i.push(0,0,0),i.push(0,0,0),s.push(r.r,r.g,r.b),s.push(a.r,a.g,a.b))}n.setAttribute("position",new br(i,3)),n.setAttribute("color",new br(s,3));super(n,new Tu({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0})),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=t,this.bones=e,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(t){const e=this.bones,n=this.geometry,i=n.getAttribute("position");Om.copy(this.root.matrixWorld).invert();for(let t=0,n=0;t<e.length;t++){const s=e[t];s.parent&&s.parent.isBone&&(Dm.multiplyMatrices(Om,s.matrixWorld),Um.setFromMatrixPosition(Dm),i.setXYZ(n,Um.x,Um.y,Um.z),Dm.multiplyMatrices(Om,s.parent.matrixWorld),Um.setFromMatrixPosition(Dm),i.setXYZ(n+1,Um.x,Um.y,Um.z),n+=2)}n.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(t)}dispose(){this.geometry.dispose(),this.material.dispose()}}function Vm(t){const e=[];!0===t.isBone&&e.push(t);for(let n=0;n<t.children.length;n++)e.push.apply(e,Vm(t.children[n]));return e}class Fm extends Hr{constructor(t,e,n){super(new hd(e,4,2),new rr({wireframe:!0,fog:!1,toneMapped:!1})),this.light=t,this.color=n,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),void 0!==this.color?this.material.color.set(this.color):this.material.color.copy(this.light.color)}}const Bm=new Pi,km=new er,Hm=new er;class Gm extends Os{constructor(t,e,n){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="HemisphereLightHelper";const i=new ld(e);i.rotateY(.5*Math.PI),this.material=new rr({wireframe:!0,fog:!1,toneMapped:!1}),void 0===this.color&&(this.material.vertexColors=!0);const s=i.getAttribute("position"),r=new Float32Array(3*s.count);i.setAttribute("color",new pr(r,3)),this.add(new Hr(i,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const t=this.children[0];if(void 0!==this.color)this.material.color.set(this.color);else{const e=t.geometry.getAttribute("color");km.copy(this.light.color),Hm.copy(this.light.groundColor);for(let t=0,n=e.count;t<n;t++){const i=t<n/2?km:Hm;e.setXYZ(t,i.r,i.g,i.b)}e.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),t.lookAt(Bm.setFromMatrixPosition(this.light.matrixWorld).negate())}}class Wm extends Du{constructor(t=10,e=10,n=4473924,i=8947848){n=new er(n),i=new er(i);const s=e/2,r=t/e,a=t/2,o=[],l=[];for(let t=0,c=0,u=-a;t<=e;t++,u+=r){o.push(-a,0,u,a,0,u),o.push(u,0,-a,u,0,a);const e=t===s?n:i;e.toArray(l,c),c+=3,e.toArray(l,c),c+=3,e.toArray(l,c),c+=3,e.toArray(l,c),c+=3}const c=new Rr;c.setAttribute("position",new br(o,3)),c.setAttribute("color",new br(l,3));super(c,new Tu({vertexColors:!0,toneMapped:!1})),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class jm extends Du{constructor(t=10,e=16,n=8,i=64,s=4473924,r=8947848){s=new er(s),r=new er(r);const a=[],o=[];if(e>1)for(let n=0;n<e;n++){const i=n/e*(2*Math.PI),l=Math.sin(i)*t,c=Math.cos(i)*t;a.push(0,0,0),a.push(l,0,c);const u=1&n?s:r;o.push(u.r,u.g,u.b),o.push(u.r,u.g,u.b)}for(let e=0;e<n;e++){const l=1&e?s:r,c=t-t/n*e;for(let t=0;t<i;t++){let e=t/i*(2*Math.PI),n=Math.sin(e)*c,s=Math.cos(e)*c;a.push(n,0,s),o.push(l.r,l.g,l.b),e=(t+1)/i*(2*Math.PI),n=Math.sin(e)*c,s=Math.cos(e)*c,a.push(n,0,s),o.push(l.r,l.g,l.b)}}const l=new Rr;l.setAttribute("position",new br(a,3)),l.setAttribute("color",new br(o,3));super(l,new Tu({vertexColors:!0,toneMapped:!1})),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const Xm=new Pi,qm=new Pi,Ym=new Pi;class Zm extends Os{constructor(t,e,n){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="DirectionalLightHelper",void 0===e&&(e=1);let i=new Rr;i.setAttribute("position",new br([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));const s=new Tu({fog:!1,toneMapped:!1});this.lightPlane=new Iu(i,s),this.add(this.lightPlane),i=new Rr,i.setAttribute("position",new br([0,0,0,0,0,1],3)),this.targetLine=new Iu(i,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),Xm.setFromMatrixPosition(this.light.matrixWorld),qm.setFromMatrixPosition(this.light.target.matrixWorld),Ym.subVectors(qm,Xm),this.lightPlane.lookAt(qm),void 0!==this.color?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(qm),this.targetLine.scale.z=Ym.length()}}const $m=new Pi,Jm=new Qr;class Km extends Du{constructor(t){const e=new Rr,n=new Tu({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],s=[],r={};function a(t,e){o(t),o(e)}function o(t){i.push(0,0,0),s.push(0,0,0),void 0===r[t]&&(r[t]=[]),r[t].push(i.length/3-1)}a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4"),e.setAttribute("position",new br(i,3)),e.setAttribute("color",new br(s,3)),super(e,n),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=r,this.update();const l=new er(16755200),c=new er(16711680),u=new er(43775),h=new er(16777215),d=new er(3355443);this.setColors(l,c,u,h,d)}setColors(t,e,n,i,s){const r=this.geometry.getAttribute("color");r.setXYZ(0,t.r,t.g,t.b),r.setXYZ(1,t.r,t.g,t.b),r.setXYZ(2,t.r,t.g,t.b),r.setXYZ(3,t.r,t.g,t.b),r.setXYZ(4,t.r,t.g,t.b),r.setXYZ(5,t.r,t.g,t.b),r.setXYZ(6,t.r,t.g,t.b),r.setXYZ(7,t.r,t.g,t.b),r.setXYZ(8,t.r,t.g,t.b),r.setXYZ(9,t.r,t.g,t.b),r.setXYZ(10,t.r,t.g,t.b),r.setXYZ(11,t.r,t.g,t.b),r.setXYZ(12,t.r,t.g,t.b),r.setXYZ(13,t.r,t.g,t.b),r.setXYZ(14,t.r,t.g,t.b),r.setXYZ(15,t.r,t.g,t.b),r.setXYZ(16,t.r,t.g,t.b),r.setXYZ(17,t.r,t.g,t.b),r.setXYZ(18,t.r,t.g,t.b),r.setXYZ(19,t.r,t.g,t.b),r.setXYZ(20,t.r,t.g,t.b),r.setXYZ(21,t.r,t.g,t.b),r.setXYZ(22,t.r,t.g,t.b),r.setXYZ(23,t.r,t.g,t.b),r.setXYZ(24,e.r,e.g,e.b),r.setXYZ(25,e.r,e.g,e.b),r.setXYZ(26,e.r,e.g,e.b),r.setXYZ(27,e.r,e.g,e.b),r.setXYZ(28,e.r,e.g,e.b),r.setXYZ(29,e.r,e.g,e.b),r.setXYZ(30,e.r,e.g,e.b),r.setXYZ(31,e.r,e.g,e.b),r.setXYZ(32,n.r,n.g,n.b),r.setXYZ(33,n.r,n.g,n.b),r.setXYZ(34,n.r,n.g,n.b),r.setXYZ(35,n.r,n.g,n.b),r.setXYZ(36,n.r,n.g,n.b),r.setXYZ(37,n.r,n.g,n.b),r.setXYZ(38,i.r,i.g,i.b),r.setXYZ(39,i.r,i.g,i.b),r.setXYZ(40,s.r,s.g,s.b),r.setXYZ(41,s.r,s.g,s.b),r.setXYZ(42,s.r,s.g,s.b),r.setXYZ(43,s.r,s.g,s.b),r.setXYZ(44,s.r,s.g,s.b),r.setXYZ(45,s.r,s.g,s.b),r.setXYZ(46,s.r,s.g,s.b),r.setXYZ(47,s.r,s.g,s.b),r.setXYZ(48,s.r,s.g,s.b),r.setXYZ(49,s.r,s.g,s.b),r.needsUpdate=!0}update(){const t=this.geometry,e=this.pointMap;Jm.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),Qm("c",e,t,Jm,0,0,-1),Qm("t",e,t,Jm,0,0,1),Qm("n1",e,t,Jm,-1,-1,-1),Qm("n2",e,t,Jm,1,-1,-1),Qm("n3",e,t,Jm,-1,1,-1),Qm("n4",e,t,Jm,1,1,-1),Qm("f1",e,t,Jm,-1,-1,1),Qm("f2",e,t,Jm,1,-1,1),Qm("f3",e,t,Jm,-1,1,1),Qm("f4",e,t,Jm,1,1,1),Qm("u1",e,t,Jm,.7,1.1,-1),Qm("u2",e,t,Jm,-.7,1.1,-1),Qm("u3",e,t,Jm,0,2,-1),Qm("cf1",e,t,Jm,-1,0,1),Qm("cf2",e,t,Jm,1,0,1),Qm("cf3",e,t,Jm,0,-1,1),Qm("cf4",e,t,Jm,0,1,1),Qm("cn1",e,t,Jm,-1,0,-1),Qm("cn2",e,t,Jm,1,0,-1),Qm("cn3",e,t,Jm,0,-1,-1),Qm("cn4",e,t,Jm,0,1,-1),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function Qm(t,e,n,i,s,r,a){$m.set(s,r,a).unproject(i);const o=e[t];if(void 0!==o){const t=n.getAttribute("position");for(let e=0,n=o.length;e<n;e++)t.setXYZ(o[e],$m.x,$m.y,$m.z)}}const tf=new Oi;class ef extends Du{constructor(t,e=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=new Float32Array(24),s=new Rr;s.setIndex(new pr(n,1)),s.setAttribute("position",new pr(i,3)),super(s,new Tu({color:e,toneMapped:!1})),this.object=t,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(t){if(void 0!==t&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),void 0!==this.object&&tf.setFromObject(this.object),tf.isEmpty())return;const e=tf.min,n=tf.max,i=this.geometry.attributes.position,s=i.array;s[0]=n.x,s[1]=n.y,s[2]=n.z,s[3]=e.x,s[4]=n.y,s[5]=n.z,s[6]=e.x,s[7]=e.y,s[8]=n.z,s[9]=n.x,s[10]=e.y,s[11]=n.z,s[12]=n.x,s[13]=n.y,s[14]=e.z,s[15]=e.x,s[16]=n.y,s[17]=e.z,s[18]=e.x,s[19]=e.y,s[20]=e.z,s[21]=n.x,s[22]=e.y,s[23]=e.z,i.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(t){return this.object=t,this.update(),this}copy(t,e){return super.copy(t,e),this.object=t.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class nf extends Du{constructor(t,e=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=new Rr;i.setIndex(new pr(n,1)),i.setAttribute("position",new br([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],3)),super(i,new Tu({color:e,toneMapped:!1})),this.box=t,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(t){const e=this.box;e.isEmpty()||(e.getCenter(this.position),e.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(t))}dispose(){this.geometry.dispose(),this.material.dispose()}}class sf extends Iu{constructor(t,e=1,n=16776960){const i=n,s=new Rr;s.setAttribute("position",new br([1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),s.computeBoundingSphere(),super(s,new Tu({color:i,toneMapped:!1})),this.type="PlaneHelper",this.plane=t,this.size=e;const r=new Rr;r.setAttribute("position",new br([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),r.computeBoundingSphere(),this.add(new Hr(r,new rr({color:i,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(t){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(t)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}const rf=new Pi;let af,of;class lf extends Os{constructor(t=new Pi(0,0,1),e=new Pi(0,0,0),n=1,i=16776960,s=.2*n,r=.2*s){super(),this.type="ArrowHelper",void 0===af&&(af=new Rr,af.setAttribute("position",new br([0,0,0,0,1,0],3)),of=new Mh(0,.5,1,5,1),of.translate(0,-.5,0)),this.position.copy(e),this.line=new Iu(af,new Tu({color:i,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Hr(of,new rr({color:i,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(t),this.setLength(n,s,r)}setDirection(t){if(t.y>.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{rf.set(t.z,0,-t.x).normalize();const e=Math.acos(t.y);this.quaternion.setFromAxisAngle(rf,e)}}setLength(t,e=.2*t,n=.2*e){this.line.scale.set(1,Math.max(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(n,e,n),this.cone.position.y=t,this.cone.updateMatrix()}setColor(t){this.line.material.color.set(t),this.cone.material.color.set(t)}copy(t){return super.copy(t,!1),this.line.copy(t.line),this.cone.copy(t.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class cf extends Du{constructor(t=1){const e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],n=new Rr;n.setAttribute("position",new br(e,3)),n.setAttribute("color",new br([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3));super(n,new Tu({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(t,e,n){const i=new er,s=this.geometry.attributes.color.array;return i.set(t),i.toArray(s,0),i.toArray(s,3),i.set(e),i.toArray(s,6),i.toArray(s,9),i.set(n),i.toArray(s,12),i.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class uf{constructor(){this.type="ShapePath",this.color=new er,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new vh,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath.lineTo(t,e),this}quadraticCurveTo(t,e,n,i){return this.currentPath.quadraticCurveTo(t,e,n,i),this}bezierCurveTo(t,e,n,i,s,r){return this.currentPath.bezierCurveTo(t,e,n,i,s,r),this}splineThru(t){return this.currentPath.splineThru(t),this}toShapes(t){function e(t,e){const n=e.length;let i=!1;for(let s=n-1,r=0;r<n;s=r++){let n=e[s],a=e[r],o=a.x-n.x,l=a.y-n.y;if(Math.abs(l)>Number.EPSILON){if(l<0&&(n=e[r],o=-o,a=e[s],l=-l),t.y<n.y||t.y>a.y)continue;if(t.y===n.y){if(t.x===n.x)return!0}else{const e=l*(t.x-n.x)-o*(t.y-n.y);if(0===e)return!0;if(e<0)continue;i=!i}}else{if(t.y!==n.y)continue;if(a.x<=t.x&&t.x<=n.x||n.x<=t.x&&t.x<=a.x)return!0}}return i}const n=nd.isClockWise,i=this.subPaths;if(0===i.length)return[];let s,r,a;const o=[];if(1===i.length)return r=i[0],a=new Rh,a.curves=r.curves,o.push(a),o;let l=!n(i[0].getPoints());l=t?!l:l;const c=[],u=[];let h,d,p=[],m=0;u[m]=void 0,p[m]=[];for(let e=0,a=i.length;e<a;e++)r=i[e],h=r.getPoints(),s=n(h),s=t?!s:s,s?(!l&&u[m]&&m++,u[m]={s:new Rh,p:h},u[m].s.curves=r.curves,l&&m++,p[m]=[]):p[m].push({h:r,p:h[0]});if(!u[0])return function(t){const e=[];for(let n=0,i=t.length;n<i;n++){const i=t[n],s=new Rh;s.curves=i.curves,e.push(s)}return e}(i);if(u.length>1){let t=!1,n=0;for(let t=0,e=u.length;t<e;t++)c[t]=[];for(let i=0,s=u.length;i<s;i++){const s=p[i];for(let r=0;r<s.length;r++){const a=s[r];let o=!0;for(let s=0;s<u.length;s++)e(a.p,u[s].p)&&(i!==s&&n++,o?(o=!1,c[s].push(a)):t=!0);o&&c[i].push(a)}}n>0&&!1===t&&(p=c)}for(let t=0,e=u.length;t<e;t++){a=u[t].s,o.push(a),d=p[t];for(let t=0,e=d.length;t<e;t++)a.holes.push(d[t].h)}return o}}class hf extends Gn{constructor(t,e=null){super(),this.object=t,this.domElement=e,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(){}disconnect(){}dispose(){}update(){}}class df extends Ai{constructor(t=1,e=1,n=1,i={}){console.warn('THREE.WebGLMultipleRenderTargets has been deprecated and will be removed in r172. Use THREE.WebGLRenderTarget and set the "count" parameter to enable MRT.'),super(t,e,{...i,count:n}),this.isWebGLMultipleRenderTargets=!0}get texture(){return this.textures}}const pf=["alphaMap","alphaTest","anisotropy","anisotropyMap","anisotropyRotation","aoMap","attenuationColor","attenuationDistance","bumpMap","clearcoat","clearcoatMap","clearcoatNormalMap","clearcoatNormalScale","clearcoatRoughness","color","dispersion","displacementMap","emissive","emissiveMap","envMap","gradientMap","ior","iridescence","iridescenceIOR","iridescenceMap","iridescenceThicknessMap","lightMap","map","matcap","metalness","metalnessMap","normalMap","normalScale","opacity","roughness","roughnessMap","sheen","sheenColor","sheenColorMap","sheenRoughnessMap","shininess","specular","specularColor","specularColorMap","specularIntensity","specularIntensityMap","specularMap","thickness","transmission","transmissionMap"];class mf{constructor(t){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(t),this.hasAnimation=!0===t.object.isSkinnedMesh,this.refreshUniforms=pf,this.renderId=0}firstInitialization(t){return!1===this.renderObjects.has(t)&&(this.getRenderObjectData(t),!0)}getRenderObjectData(t){let e=this.renderObjects.get(t);return void 0===e&&(e={material:this.getMaterialData(t.material),worldMatrix:t.object.matrixWorld.clone()},t.object.center&&(e.center=t.object.center.clone()),t.object.morphTargetInfluences&&(e.morphTargetInfluences=t.object.morphTargetInfluences.slice()),null!==t.bundle&&(e.version=t.bundle.version),this.renderObjects.set(t,e)),e}containsNode(t){const e=t.material;for(const t in e)if(e[t]&&e[t].isNode)return!0;return null!==t.renderer.nodes.modelViewMatrix||null!==t.renderer.nodes.modelNormalViewMatrix}getMaterialData(t){const e={};for(const n of this.refreshUniforms){const i=t[n];null!=i&&("object"==typeof i&&void 0!==i.clone?!0===i.isTexture?e[n]={id:i.id,version:i.version}:e[n]=i.clone():e[n]=i)}return e}equals(t){const{object:e,material:n}=t,i=this.getRenderObjectData(t);if(!0!==i.worldMatrix.equals(e.matrixWorld))return i.worldMatrix.copy(e.matrixWorld),!1;const s=i.material;for(const t in s){const e=s[t],i=n[t];if(void 0!==e.equals){if(!1===e.equals(i))return e.copy(i),!1}else if(!0===i.isTexture){if(e.id!==i.id||e.version!==i.version)return e.id=i.id,e.version=i.version,!1}else if(e!==i)return s[t]=i,!1}if(i.morphTargetInfluences){let t=!1;for(let n=0;n<i.morphTargetInfluences.length;n++)i.morphTargetInfluences[n]!==e.morphTargetInfluences[n]&&(t=!0);if(t)return!0}return i.center&&!1===i.center.equals(e.center)?(i.center.copy(e.center),!0):(null!==t.bundle&&(i.version=t.bundle.version),!0)}needsRefresh(t,e){if(this.hasNode||this.hasAnimation||this.firstInitialization(t))return!0;const{renderId:n}=e;if(this.renderId!==n)return this.renderId=n,!0;const i=!0===t.object.static,s=null!==t.bundle&&!0===t.bundle.static&&this.getRenderObjectData(t).version===t.bundle.version;if(i||s)return!1;return!0!==this.equals(t)}}function ff(t,e=0){let n=3735928559^e,i=1103547991^e;if(t instanceof Array)for(let e,s=0;s<t.length;s++)e=t[s],n=Math.imul(n^e,2654435761),i=Math.imul(i^e,1597334677);else for(let e,s=0;s<t.length;s++)e=t.charCodeAt(s),n=Math.imul(n^e,2654435761),i=Math.imul(i^e,1597334677);return n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(i^i>>>13,3266489909),i=Math.imul(i^i>>>16,2246822507),i^=Math.imul(n^n>>>13,3266489909),4294967296*(2097151&i)+(n>>>0)}const gf=t=>ff(t),vf=t=>ff(t),yf=(...t)=>ff(t);function _f(t,e=!1){const n=[];!0===t.isNode&&(n.push(t.id),t=t.getSelf());for(const{property:i,childNode:s}of xf(t))n.push(n,ff(i.slice(0,-4)),s.getCacheKey(e));return ff(n)}function*xf(t,e=!1){for(const n in t){if(!0===n.startsWith("_"))continue;const i=t[n];if(!0===Array.isArray(i))for(let t=0;t<i.length;t++){const s=i[t];s&&(!0===s.isNode||e&&"function"==typeof s.toJSON)&&(yield{property:n,index:t,childNode:s})}else if(i&&!0===i.isNode)yield{property:n,childNode:i};else if("object"==typeof i)for(const t in i){const s=i[t];s&&(!0===s.isNode||e&&"function"==typeof s.toJSON)&&(yield{property:n,index:t,childNode:s})}}}function Mf(t){if(null==t)return null;const e=typeof t;return!0===t.isNode?"node":"number"===e?"float":"boolean"===e?"bool":"string"===e?"string":"function"===e?"shader":!0===t.isVector2?"vec2":!0===t.isVector3?"vec3":!0===t.isVector4?"vec4":!0===t.isMatrix3?"mat3":!0===t.isMatrix4?"mat4":!0===t.isColor?"color":t instanceof ArrayBuffer?"ArrayBuffer":null}function bf(t,...e){const n=t?t.slice(-4):void 0;return 1===e.length&&("vec2"===n?e=[e[0],e[0]]:"vec3"===n?e=[e[0],e[0],e[0]]:"vec4"===n&&(e=[e[0],e[0],e[0],e[0]])),"color"===t?new er(...e):"vec2"===n?new ei(...e):"vec3"===n?new Pi(...e):"vec4"===n?new wi(...e):"mat3"===n?new ni(...e):"mat4"===n?new cs(...e):"bool"===t?e[0]||!1:"float"===t||"int"===t||"uint"===t?e[0]||0:"string"===t?e[0]||"":"ArrayBuffer"===t?Sf(e[0]):null}function Tf(t){let e="";const n=new Uint8Array(t);for(let t=0;t<n.length;t++)e+=String.fromCharCode(n[t]);return btoa(e)}function Sf(t){return Uint8Array.from(atob(t),t=>t.charCodeAt(0)).buffer}var wf=Object.freeze({__proto__:null,arrayBufferToBase64:Tf,base64ToArrayBuffer:Sf,getCacheKey:_f,getNodeChildren:xf,getValueFromType:bf,getValueType:Mf,hash:yf,hashArray:vf,hashString:gf});const Ef={VERTEX:"vertex",FRAGMENT:"fragment"},Af={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},Nf={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},Cf=["fragment","vertex"],Rf=["setup","analyze","generate"],If=[...Cf,"compute"],Lf=["x","y","z","w"];let Pf=0;class Uf extends Gn{static get type(){return"Node"}constructor(t=null){super(),this.nodeType=t,this.updateType=Af.NONE,this.updateBeforeType=Af.NONE,this.updateAfterType=Af.NONE,this.uuid=ti.generateUUID(),this.version=0,this._cacheKey=null,this._cacheKeyVersion=0,this.global=!1,this.isNode=!0,Object.defineProperty(this,"id",{value:Pf++})}set needsUpdate(t){!0===t&&this.version++}get type(){return this.constructor.type}onUpdate(t,e){return this.updateType=e,this.update=t.bind(this.getSelf()),this}onFrameUpdate(t){return this.onUpdate(t,Af.FRAME)}onRenderUpdate(t){return this.onUpdate(t,Af.RENDER)}onObjectUpdate(t){return this.onUpdate(t,Af.OBJECT)}onReference(t){return this.updateReference=t.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:t}of xf(this))yield t}dispose(){this.dispatchEvent({type:"dispose"})}traverse(t){t(this);for(const e of this.getChildren())e.traverse(t)}getCacheKey(t=!1){return!0!==(t=t||this.version!==this._cacheKeyVersion)&&null!==this._cacheKey||(this._cacheKey=_f(this,t),this._cacheKeyVersion=this.version),this._cacheKey}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(t){const e=this.getNodeType(t);return t.getElementType(e)}getNodeType(t){const e=t.getNodeProperties(this);return e.outputNode?e.outputNode.getNodeType(t):this.nodeType}getShared(t){const e=this.getHash(t);return t.getNodeFromHash(e)||this}setup(t){const e=t.getNodeProperties(this);let n=0;for(const t of this.getChildren())e["node"+n++]=t;return null}analyze(t){if(1===t.increaseUsage(this)){const e=t.getNodeProperties(this);for(const n of Object.values(e))n&&!0===n.isNode&&n.build(t)}}generate(t,e){const{outputNode:n}=t.getNodeProperties(this);if(n&&!0===n.isNode)return n.build(t,e)}updateBefore(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(t,e=null){const n=this.getShared(t);if(this!==n)return n.build(t,e);t.addNode(this),t.addChain(this);let i=null;const s=t.getBuildStage();if("setup"===s){this.updateReference(t);const e=t.getNodeProperties(this);if(!0!==e.initialized){t.stack.nodes.length;e.initialized=!0,e.outputNode=this.setup(t),null!==e.outputNode&&t.stack.nodes.length;for(const n of Object.values(e))n&&!0===n.isNode&&n.build(t)}}else if("analyze"===s)this.analyze(t);else if("generate"===s){if(1===this.generate.length){const n=this.getNodeType(t),s=t.getDataFromNode(this);i=s.snippet,void 0===i?(i=this.generate(t)||"",s.snippet=i):void 0!==s.flowCodes&&void 0!==t.context.nodeBlock&&t.addFlowCodeHierarchy(this,t.context.nodeBlock),i=t.format(i,n,e)}else i=this.generate(t,e)||""}return t.removeChain(this),i}getSerializeChildren(){return xf(this)}serialize(t){const e=this.getSerializeChildren(),n={};for(const{property:i,index:s,childNode:r}of e)void 0!==s?(void 0===n[i]&&(n[i]=Number.isInteger(s)?[]:{}),n[i][s]=r.toJSON(t.meta).uuid):n[i]=r.toJSON(t.meta).uuid;Object.keys(n).length>0&&(t.inputNodes=n)}deserialize(t){if(void 0!==t.inputNodes){const e=t.meta.nodes;for(const n in t.inputNodes)if(Array.isArray(t.inputNodes[n])){const i=[];for(const s of t.inputNodes[n])i.push(e[s]);this[n]=i}else if("object"==typeof t.inputNodes[n]){const i={};for(const s in t.inputNodes[n]){const r=t.inputNodes[n][s];i[s]=e[r]}this[n]=i}else{const i=t.inputNodes[n];this[n]=e[i]}}}toJSON(t){const{uuid:e,type:n}=this,i=void 0===t||"string"==typeof t;i&&(t={textures:{},images:{},nodes:{}});let s=t.nodes[e];function r(t){const e=[];for(const n in t){const i=t[n];delete i.metadata,e.push(i)}return e}if(void 0===s&&(s={uuid:e,type:n,meta:t,metadata:{version:4.6,type:"Node",generator:"Node.toJSON"}},!0!==i&&(t.nodes[s.uuid]=s),this.serialize(s),delete s.meta),i){const e=r(t.textures),n=r(t.images),i=r(t.nodes);e.length>0&&(s.textures=e),n.length>0&&(s.images=n),i.length>0&&(s.nodes=i)}return s}}class Df extends Uf{static get type(){return"ArrayElementNode"}constructor(t,e){super(),this.node=t,this.indexNode=e,this.isArrayElementNode=!0}getNodeType(t){return this.node.getElementType(t)}generate(t){return`${this.node.build(t)}[ ${this.indexNode.build(t,"uint")} ]`}}class Of extends Uf{static get type(){return"ConvertNode"}constructor(t,e){super(),this.node=t,this.convertTo=e}getNodeType(t){const e=this.node.getNodeType(t);let n=null;for(const i of this.convertTo.split("|"))null!==n&&t.getTypeLength(e)!==t.getTypeLength(i)||(n=i);return n}serialize(t){super.serialize(t),t.convertTo=this.convertTo}deserialize(t){super.deserialize(t),this.convertTo=t.convertTo}generate(t,e){const n=this.node,i=this.getNodeType(t),s=n.build(t,i);return t.format(s,i,e)}}class zf extends Uf{static get type(){return"TempNode"}constructor(t){super(t),this.isTempNode=!0}hasDependencies(t){return t.getDataFromNode(this).usageCount>1}build(t,e){if("generate"===t.getBuildStage()){const n=t.getVectorType(this.getNodeType(t,e)),i=t.getDataFromNode(this);if(void 0!==i.propertyName)return t.format(i.propertyName,n,e);if("void"!==n&&"void"!==e&&this.hasDependencies(t)){const s=super.build(t,n),r=t.getVarFromNode(this,null,n),a=t.getPropertyName(r);return t.addLineFlowCode(`${a} = ${s}`,this),i.snippet=s,i.propertyName=a,t.format(i.propertyName,n,e)}}return super.build(t,e)}}class Vf extends zf{static get type(){return"JoinNode"}constructor(t=[],e=null){super(e),this.nodes=t}getNodeType(t){return null!==this.nodeType?t.getVectorType(this.nodeType):t.getTypeFromLength(this.nodes.reduce((e,n)=>e+t.getTypeLength(n.getNodeType(t)),0))}generate(t,e){const n=this.getNodeType(t),i=this.nodes,s=t.getComponentType(n),r=[];for(const e of i){let n=e.build(t);const i=t.getComponentType(e.getNodeType(t));i!==s&&(n=t.format(n,i,s)),r.push(n)}const a=`${t.getType(n)}( ${r.join(", ")} )`;return t.format(a,n,e)}}const Ff=Lf.join("");class Bf extends Uf{static get type(){return"SplitNode"}constructor(t,e="x"){super(),this.node=t,this.components=e,this.isSplitNode=!0}getVectorLength(){let t=this.components.length;for(const e of this.components)t=Math.max(Lf.indexOf(e)+1,t);return t}getComponentType(t){return t.getComponentType(this.node.getNodeType(t))}getNodeType(t){return t.getTypeFromLength(this.components.length,this.getComponentType(t))}generate(t,e){const n=this.node,i=t.getTypeLength(n.getNodeType(t));let s=null;if(i>1){let r=null;this.getVectorLength()>=i&&(r=t.getTypeFromLength(this.getVectorLength(),this.getComponentType(t)));const a=n.build(t,r);s=this.components.length===i&&this.components===Ff.slice(0,this.components.length)?t.format(a,r,e):t.format(`${a}.${this.components}`,this.getNodeType(t),e)}else s=n.build(t,e);return s}serialize(t){super.serialize(t),t.components=this.components}deserialize(t){super.deserialize(t),this.components=t.components}}class kf extends zf{static get type(){return"SetNode"}constructor(t,e,n){super(),this.sourceNode=t,this.components=e,this.targetNode=n}getNodeType(t){return this.sourceNode.getNodeType(t)}generate(t){const{sourceNode:e,components:n,targetNode:i}=this,s=this.getNodeType(t),r=t.getTypeFromLength(n.length,i.getNodeType(t)),a=i.build(t,r),o=e.build(t,s),l=t.getTypeLength(s),c=[];for(let t=0;t<l;t++){const e=Lf[t];e===n[0]?(c.push(a),t+=n.length-1):c.push(o+"."+e)}return`${t.getType(s)}( ${c.join(", ")} )`}}class Hf extends zf{static get type(){return"FlipNode"}constructor(t,e){super(),this.sourceNode=t,this.components=e}getNodeType(t){return this.sourceNode.getNodeType(t)}generate(t){const{components:e,sourceNode:n}=this,i=this.getNodeType(t),s=n.build(t),r=t.getVarFromNode(this),a=t.getPropertyName(r);t.addLineFlowCode(a+" = "+s,this);const o=t.getTypeLength(i),l=[];let c=0;for(let t=0;t<o;t++){const n=Lf[t];n===e[c]?(l.push("1.0 - "+a+"."+n),c++):l.push(a+"."+n)}return`${t.getType(i)}( ${l.join(", ")} )`}}class Gf extends Uf{static get type(){return"InputNode"}constructor(t,e=null){super(e),this.isInputNode=!0,this.value=t,this.precision=null}getNodeType(){return null===this.nodeType?Mf(this.value):this.nodeType}getInputType(t){return this.getNodeType(t)}setPrecision(t){return this.precision=t,this}serialize(t){super.serialize(t),t.value=this.value,this.value&&this.value.toArray&&(t.value=this.value.toArray()),t.valueType=Mf(this.value),t.nodeType=this.nodeType,"ArrayBuffer"===t.valueType&&(t.value=Tf(t.value)),t.precision=this.precision}deserialize(t){super.deserialize(t),this.nodeType=t.nodeType,this.value=Array.isArray(t.value)?bf(t.valueType,...t.value):t.value,this.precision=t.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(t.value))}generate(){console.warn("Abstract function.")}}class Wf extends Gf{static get type(){return"ConstNode"}constructor(t,e=null){super(t,e),this.isConstNode=!0}generateConst(t){return t.generateConst(this.getNodeType(t),this.value)}generate(t,e){const n=this.getNodeType(t);return t.format(this.generateConst(t),n,e)}}let jf=null;const Xf=new Map;function qf(t,e){if(Xf.has(t))console.warn(`Redefinition of method chaining ${t}`);else{if("function"!=typeof e)throw new Error(`Node element ${t} is not a function`);Xf.set(t,e)}}const Yf=t=>t.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),Zf=t=>Yf(t).split("").sort().join(""),$f={setup(t,e){const n=e.shift();return t(Mg(n),...e)},get(t,e,n){if("string"==typeof e&&void 0===t[e]){if(!0!==t.isStackNode&&"assign"===e)return(...t)=>(jf.assign(n,...t),n);if(Xf.has(e)){const i=Xf.get(e);return t.isStackNode?(...t)=>n.add(i(...t)):(...t)=>i(n,...t)}if("self"===e)return t;if(e.endsWith("Assign")&&Xf.has(e.slice(0,e.length-6))){const i=Xf.get(e.slice(0,e.length-6));return t.isStackNode?(...t)=>n.assign(t[0],i(...t)):(...t)=>n.assign(i(n,...t))}if(!0===/^[xyzwrgbastpq]{1,4}$/.test(e))return e=Yf(e),xg(new Bf(n,e));if(!0===/^set[XYZWRGBASTPQ]{1,4}$/.test(e))return e=Zf(e.slice(3).toLowerCase()),n=>xg(new kf(t,e,n));if(!0===/^flip[XYZWRGBASTPQ]{1,4}$/.test(e))return e=Zf(e.slice(4).toLowerCase()),()=>xg(new Hf(xg(t),e));if("width"===e||"height"===e||"depth"===e)return"width"===e?e="x":"height"===e?e="y":"depth"===e&&(e="z"),xg(new Bf(t,e));if(!0===/^\d+$/.test(e))return xg(new Df(n,new Wf(Number(e),"uint")))}return Reflect.get(t,e,n)},set:(t,e,n,i)=>"string"!=typeof e||void 0!==t[e]||!0!==/^[xyzwrgbastpq]{1,4}$/.test(e)&&"width"!==e&&"height"!==e&&"depth"!==e&&!0!==/^\d+$/.test(e)?Reflect.set(t,e,n,i):(i[e].assign(n),!0)},Jf=new WeakMap,Kf=new WeakMap,Qf=function(t,e=null){for(const n in t)t[n]=xg(t[n],e);return t},tg=function(t,e=null){const n=t.length;for(let i=0;i<n;i++)t[i]=xg(t[i],e);return t},eg=function(t,e=null,n=null,i=null){const s=t=>xg(null!==i?Object.assign(t,i):t);return null===e?(...e)=>s(new t(...bg(e))):null!==n?(n=xg(n),(...i)=>s(new t(e,...bg(i),n))):(...n)=>s(new t(e,...bg(n)))},ng=function(t,...e){return xg(new t(...bg(e)))};class ig extends Uf{constructor(t,e){super(),this.shaderNode=t,this.inputNodes=e}getNodeType(t){return this.shaderNode.nodeType||this.getOutputNode(t).getNodeType(t)}call(t){const{shaderNode:e,inputNodes:n}=this,i=t.getNodeProperties(e);if(i.onceOutput)return i.onceOutput;let s=null;if(e.layout){let i=Kf.get(t.constructor);void 0===i&&(i=new WeakMap,Kf.set(t.constructor,i));let r=i.get(e);void 0===r&&(r=xg(t.buildFunctionNode(e)),i.set(e,r)),null!==t.currentFunctionNode&&t.currentFunctionNode.includes.push(r),s=xg(r.call(n))}else{const i=e.jsFunc,r=null!==n?i(n,t):i(t);s=xg(r)}return e.once&&(i.onceOutput=s),s}getOutputNode(t){const e=t.getNodeProperties(this);return null===e.outputNode&&(e.outputNode=this.setupOutput(t)),e.outputNode}setup(t){return this.getOutputNode(t)}setupOutput(t){return t.addStack(),t.stack.outputNode=this.call(t),t.removeStack()}generate(t,e){return this.getOutputNode(t).build(t,e)}}class sg extends Uf{constructor(t,e){super(e),this.jsFunc=t,this.layout=null,this.global=!0,this.once=!1}setLayout(t){return this.layout=t,this}call(t=null){return Mg(t),xg(new ig(this,t))}setup(){return this.call()}}const rg=[!1,!0],ag=[0,1,2,3],og=[-1,-2],lg=[.5,1.5,1/3,1e-6,1e6,Math.PI,2*Math.PI,1/Math.PI,2/Math.PI,1/(2*Math.PI),Math.PI/2],cg=new Map;for(const t of rg)cg.set(t,new Wf(t));const ug=new Map;for(const t of ag)ug.set(t,new Wf(t,"uint"));const hg=new Map([...ug].map(t=>new Wf(t.value,"int")));for(const t of og)hg.set(t,new Wf(t,"int"));const dg=new Map([...hg].map(t=>new Wf(t.value)));for(const t of lg)dg.set(t,new Wf(t));for(const t of lg)dg.set(-t,new Wf(-t));const pg={bool:cg,uint:ug,ints:hg,float:dg},mg=new Map([...cg,...dg]),fg=(t,e)=>mg.has(t)?mg.get(t):!0===t.isNode?t:new Wf(t,e),gg=function(t,e=null){return(...n)=>{if((0===n.length||!["bool","float","int","uint"].includes(t)&&n.every(t=>"object"!=typeof t))&&(n=[bf(t,...n)]),1===n.length&&null!==e&&e.has(n[0]))return xg(e.get(n[0]));if(1===n.length){const e=fg(n[0],t);return(t=>{try{return t.getNodeType()}catch(t){return}})(e)===t?xg(e):xg(new Of(e,t))}const i=n.map(t=>fg(t));return xg(new Vf(i,t))}},vg=t=>"object"==typeof t&&null!==t?t.value:t,yg=t=>null!=t?t.nodeType||t.convertTo||("string"==typeof t?t:null):null;function _g(t,e){return new Proxy(new sg(t,e),$f)}const xg=(t,e=null)=>function(t,e=null){const n=Mf(t);if("node"===n){let e=Jf.get(t);return void 0===e&&(e=new Proxy(t,$f),Jf.set(t,e),Jf.set(e,e)),e}return null===e&&("float"===n||"boolean"===n)||n&&"shader"!==n&&"string"!==n?xg(fg(t,e)):"shader"===n?wg(t):t}(t,e),Mg=(t,e=null)=>new Qf(t,e),bg=(t,e=null)=>new tg(t,e),Tg=(...t)=>new eg(...t),Sg=(...t)=>new ng(...t),wg=(t,e)=>{const n=new _g(t,e),i=(...t)=>{let e;return Mg(t),e=t[0]&&t[0].isNode?[...t]:t[0],n.call(e)};return i.shaderNode=n,i.setLayout=t=>(n.setLayout(t),i),i.once=()=>(n.once=!0,i),i},Eg=(...t)=>(console.warn("TSL.ShaderNode: tslFn() has been renamed to Fn()."),wg(...t));qf("toGlobal",t=>(t.global=!0,t));const Ag=t=>{jf=t},Ng=()=>jf,Cg=(...t)=>jf.If(...t);function Rg(t){return jf&&jf.add(t),t}qf("append",Rg);const Ig=new gg("color"),Lg=new gg("float",pg.float),Pg=new gg("int",pg.ints),Ug=new gg("uint",pg.uint),Dg=new gg("bool",pg.bool),Og=new gg("vec2"),zg=new gg("ivec2"),Vg=new gg("uvec2"),Fg=new gg("bvec2"),Bg=new gg("vec3"),kg=new gg("ivec3"),Hg=new gg("uvec3"),Gg=new gg("bvec3"),Wg=new gg("vec4"),jg=new gg("ivec4"),Xg=new gg("uvec4"),qg=new gg("bvec4"),Yg=new gg("mat2"),Zg=new gg("mat3"),$g=new gg("mat4"),Jg=(t="")=>xg(new Wf(t,"string")),Kg=t=>xg(new Wf(t,"ArrayBuffer"));qf("toColor",Ig),qf("toFloat",Lg),qf("toInt",Pg),qf("toUint",Ug),qf("toBool",Dg),qf("toVec2",Og),qf("toIVec2",zg),qf("toUVec2",Vg),qf("toBVec2",Fg),qf("toVec3",Bg),qf("toIVec3",kg),qf("toUVec3",Hg),qf("toBVec3",Gg),qf("toVec4",Wg),qf("toIVec4",jg),qf("toUVec4",Xg),qf("toBVec4",qg),qf("toMat2",Yg),qf("toMat3",Zg),qf("toMat4",$g);const Qg=Tg(Df),tv=(t,e)=>xg(new Of(xg(t),e)),ev=(t,e)=>xg(new Bf(xg(t),e));qf("element",Qg),qf("convert",tv);class nv extends Uf{static get type(){return"UniformGroupNode"}constructor(t,e=!1,n=1){super("string"),this.name=t,this.version=0,this.shared=e,this.order=n,this.isUniformGroup=!0}set needsUpdate(t){!0===t&&this.version++}serialize(t){super.serialize(t),t.name=this.name,t.version=this.version,t.shared=this.shared}deserialize(t){super.deserialize(t),this.name=t.name,this.version=t.version,this.shared=t.shared}}const iv=t=>new nv(t),sv=(t,e=0)=>new nv(t,!0,e),rv=sv("frame"),av=sv("render"),ov=iv("object");class lv extends Gf{static get type(){return"UniformNode"}constructor(t,e=null){super(t,e),this.isUniformNode=!0,this.name="",this.groupNode=ov}label(t){return this.name=t,this}setGroup(t){return this.groupNode=t,this}getGroup(){return this.groupNode}getUniformHash(t){return this.getHash(t)}onUpdate(t,e){const n=this.getSelf();return t=t.bind(n),super.onUpdate(e=>{const i=t(e,n);void 0!==i&&(this.value=i)},e)}generate(t,e){const n=this.getNodeType(t),i=this.getUniformHash(t);let s=t.getNodeFromHash(i);void 0===s&&(t.setHashNode(this,i),s=this);const r=s.getInputType(t),a=t.getUniformFromNode(s,r,t.shaderStage,this.name||t.context.label),o=t.getPropertyName(a);return void 0!==t.context.label&&delete t.context.label,t.format(o,n,e)}}const cv=(t,e)=>{const n=yg(e||t),i=t&&!0===t.isNode?t.node&&t.node.value||t.value:t;return xg(new lv(i,n))};class uv extends Uf{static get type(){return"PropertyNode"}constructor(t,e=null,n=!1){super(t),this.name=e,this.varying=n,this.isPropertyNode=!0}getHash(t){return this.name||super.getHash(t)}isGlobal(){return!0}generate(t){let e;return!0===this.varying?(e=t.getVaryingFromNode(this,this.name),e.needsInterpolation=!0):e=t.getVarFromNode(this,this.name),t.getPropertyName(e)}}const hv=(t,e)=>xg(new uv(t,e)),dv=(t,e)=>xg(new uv(t,e,!0)),pv=Sg(uv,"vec4","DiffuseColor"),mv=Sg(uv,"vec3","EmissiveColor"),fv=Sg(uv,"float","Roughness"),gv=Sg(uv,"float","Metalness"),vv=Sg(uv,"float","Clearcoat"),yv=Sg(uv,"float","ClearcoatRoughness"),_v=Sg(uv,"vec3","Sheen"),xv=Sg(uv,"float","SheenRoughness"),Mv=Sg(uv,"float","Iridescence"),bv=Sg(uv,"float","IridescenceIOR"),Tv=Sg(uv,"float","IridescenceThickness"),Sv=Sg(uv,"float","AlphaT"),wv=Sg(uv,"float","Anisotropy"),Ev=Sg(uv,"vec3","AnisotropyT"),Av=Sg(uv,"vec3","AnisotropyB"),Nv=Sg(uv,"color","SpecularColor"),Cv=Sg(uv,"float","SpecularF90"),Rv=Sg(uv,"float","Shininess"),Iv=Sg(uv,"vec4","Output"),Lv=Sg(uv,"float","dashSize"),Pv=Sg(uv,"float","gapSize"),Uv=Sg(uv,"float","pointWidth"),Dv=Sg(uv,"float","IOR"),Ov=Sg(uv,"float","Transmission"),zv=Sg(uv,"float","Thickness"),Vv=Sg(uv,"float","AttenuationDistance"),Fv=Sg(uv,"color","AttenuationColor"),Bv=Sg(uv,"float","Dispersion");class kv extends zf{static get type(){return"AssignNode"}constructor(t,e){super(),this.targetNode=t,this.sourceNode=e}hasDependencies(){return!1}getNodeType(t,e){return"void"!==e?this.targetNode.getNodeType(t):"void"}needsSplitAssign(t){const{targetNode:e}=this;if(!1===t.isAvailable("swizzleAssign")&&e.isSplitNode&&e.components.length>1){const n=t.getTypeLength(e.node.getNodeType(t));return Lf.join("").slice(0,n)!==e.components}return!1}generate(t,e){const{targetNode:n,sourceNode:i}=this,s=this.needsSplitAssign(t),r=n.getNodeType(t),a=n.context({assign:!0}).build(t),o=i.build(t,r),l=i.getNodeType(t),c=t.getDataFromNode(this);let u;if(!0===c.initialized)"void"!==e&&(u=a);else if(s){const i=t.getVarFromNode(this,null,r),s=t.getPropertyName(i);t.addLineFlowCode(`${s} = ${o}`,this);const l=n.node.context({assign:!0}).build(t);for(let e=0;e<n.components.length;e++){const i=n.components[e];t.addLineFlowCode(`${l}.${i} = ${s}[ ${e} ]`,this)}"void"!==e&&(u=a)}else u=`${a} = ${o}`,"void"!==e&&"void"!==l||(t.addLineFlowCode(u,this),"void"!==e&&(u=a));return c.initialized=!0,t.format(u,r,e)}}const Hv=Tg(kv);qf("assign",Hv);class Gv extends zf{static get type(){return"FunctionCallNode"}constructor(t=null,e={}){super(),this.functionNode=t,this.parameters=e}setParameters(t){return this.parameters=t,this}getParameters(){return this.parameters}getNodeType(t){return this.functionNode.getNodeType(t)}generate(t){const e=[],n=this.functionNode,i=n.getInputs(t),s=this.parameters;if(Array.isArray(s))for(let n=0;n<s.length;n++){const r=i[n],a=s[n];e.push(a.build(t,r.type))}else for(const n of i){const i=s[n.name];if(void 0===i)throw new Error(`FunctionCallNode: Input '${n.name}' not found in FunctionNode.`);e.push(i.build(t,n.type))}return`${n.build(t,"property")}( ${e.join(", ")} )`}}const Wv=(t,...e)=>(e=e.length>1||e[0]&&!0===e[0].isNode?bg(e):Mg(e[0]),xg(new Gv(xg(t),e)));qf("call",Wv);class jv extends zf{static get type(){return"OperatorNode"}constructor(t,e,n,...i){if(super(),i.length>0){let s=new jv(t,e,n);for(let e=0;e<i.length-1;e++)s=new jv(t,s,i[e]);e=s,n=i[i.length-1]}this.op=t,this.aNode=e,this.bNode=n}getNodeType(t,e){const n=this.op,i=this.aNode,s=this.bNode,r=i.getNodeType(t),a=void 0!==s?s.getNodeType(t):null;if("void"===r||"void"===a)return"void";if("%"===n)return r;if("~"===n||"&"===n||"|"===n||"^"===n||">>"===n||"<<"===n)return t.getIntegerType(r);if("!"===n||"=="===n||"&&"===n||"||"===n||"^^"===n)return"bool";if("<"===n||">"===n||"<="===n||">="===n){const n=e?t.getTypeLength(e):Math.max(t.getTypeLength(r),t.getTypeLength(a));return n>1?`bvec${n}`:"bool"}return"float"===r&&t.isMatrix(a)?a:t.isMatrix(r)&&t.isVector(a)?t.getVectorFromMatrix(r):t.isVector(r)&&t.isMatrix(a)?t.getVectorFromMatrix(a):t.getTypeLength(a)>t.getTypeLength(r)?a:r}generate(t,e){const n=this.op,i=this.aNode,s=this.bNode,r=this.getNodeType(t,e);let a=null,o=null;"void"!==r?(a=i.getNodeType(t),o=void 0!==s?s.getNodeType(t):null,"<"===n||">"===n||"<="===n||">="===n||"=="===n?t.isVector(a)?o=a:a!==o&&(a=o="float"):">>"===n||"<<"===n?(a=r,o=t.changeComponentType(o,"uint")):t.isMatrix(a)&&t.isVector(o)?o=t.getVectorFromMatrix(a):a=t.isVector(a)&&t.isMatrix(o)?t.getVectorFromMatrix(o):o=r):a=o=r;const l=i.build(t,a),c=void 0!==s?s.build(t,o):null,u=t.getTypeLength(e),h=t.getFunctionOperator(n);return"void"!==e?"<"===n&&u>1?t.useComparisonMethod?t.format(`${t.getMethod("lessThan",e)}( ${l}, ${c} )`,r,e):t.format(`( ${l} < ${c} )`,r,e):"<="===n&&u>1?t.useComparisonMethod?t.format(`${t.getMethod("lessThanEqual",e)}( ${l}, ${c} )`,r,e):t.format(`( ${l} <= ${c} )`,r,e):">"===n&&u>1?t.useComparisonMethod?t.format(`${t.getMethod("greaterThan",e)}( ${l}, ${c} )`,r,e):t.format(`( ${l} > ${c} )`,r,e):">="===n&&u>1?t.useComparisonMethod?t.format(`${t.getMethod("greaterThanEqual",e)}( ${l}, ${c} )`,r,e):t.format(`( ${l} >= ${c} )`,r,e):"!"===n||"~"===n?t.format(`(${n}${l})`,a,e):h?t.format(`${h}( ${l}, ${c} )`,r,e):t.format(`( ${l} ${n} ${c} )`,r,e):"void"!==a?h?t.format(`${h}( ${l}, ${c} )`,r,e):t.format(`${l} ${n} ${c}`,r,e):void 0}serialize(t){super.serialize(t),t.op=this.op}deserialize(t){super.deserialize(t),this.op=t.op}}const Xv=Tg(jv,"+"),qv=Tg(jv,"-"),Yv=Tg(jv,"*"),Zv=Tg(jv,"/"),$v=Tg(jv,"%"),Jv=Tg(jv,"=="),Kv=Tg(jv,"!="),Qv=Tg(jv,"<"),ty=Tg(jv,">"),ey=Tg(jv,"<="),ny=Tg(jv,">="),iy=Tg(jv,"&&"),sy=Tg(jv,"||"),ry=Tg(jv,"!"),ay=Tg(jv,"^^"),oy=Tg(jv,"&"),ly=Tg(jv,"~"),cy=Tg(jv,"|"),uy=Tg(jv,"^"),hy=Tg(jv,"<<"),dy=Tg(jv,">>");qf("add",Xv),qf("sub",qv),qf("mul",Yv),qf("div",Zv),qf("modInt",$v),qf("equal",Jv),qf("notEqual",Kv),qf("lessThan",Qv),qf("greaterThan",ty),qf("lessThanEqual",ey),qf("greaterThanEqual",ny),qf("and",iy),qf("or",sy),qf("not",ry),qf("xor",ay),qf("bitAnd",oy),qf("bitNot",ly),qf("bitOr",cy),qf("bitXor",uy),qf("shiftLeft",hy),qf("shiftRight",dy);const py=(...t)=>(console.warn("TSL.OperatorNode: .remainder() has been renamed to .modInt()."),$v(...t));qf("remainder",py);class my extends zf{static get type(){return"MathNode"}constructor(t,e,n=null,i=null){super(),this.method=t,this.aNode=e,this.bNode=n,this.cNode=i}getInputType(t){const e=this.aNode.getNodeType(t),n=this.bNode?this.bNode.getNodeType(t):null,i=this.cNode?this.cNode.getNodeType(t):null,s=t.isMatrix(e)?0:t.getTypeLength(e),r=t.isMatrix(n)?0:t.getTypeLength(n),a=t.isMatrix(i)?0:t.getTypeLength(i);return s>r&&s>a?e:r>a?n:a>s?i:e}getNodeType(t){const e=this.method;return e===my.LENGTH||e===my.DISTANCE||e===my.DOT?"float":e===my.CROSS?"vec3":e===my.ALL?"bool":e===my.EQUALS?t.changeComponentType(this.aNode.getNodeType(t),"bool"):e===my.MOD?this.aNode.getNodeType(t):this.getInputType(t)}generate(t,e){const n=this.method,i=this.getNodeType(t),s=this.getInputType(t),r=this.aNode,a=this.bNode,o=this.cNode,l=!0===t.renderer.isWebGLRenderer;if(n===my.TRANSFORM_DIRECTION){let n=r,i=a;t.isMatrix(n.getNodeType(t))?i=Wg(Bg(i),0):n=Wg(Bg(n),0);const s=Yv(n,i).xyz;return Ly(s).build(t,e)}if(n===my.NEGATE)return t.format("( - "+r.build(t,s)+" )",i,e);if(n===my.ONE_MINUS)return qv(1,r).build(t,e);if(n===my.RECIPROCAL)return Zv(1,r).build(t,e);if(n===my.DIFFERENCE)return By(qv(r,a)).build(t,e);{const c=[];return n===my.CROSS||n===my.MOD?c.push(r.build(t,i),a.build(t,i)):l&&n===my.STEP?c.push(r.build(t,1===t.getTypeLength(r.getNodeType(t))?"float":s),a.build(t,s)):l&&(n===my.MIN||n===my.MAX)||n===my.MOD?c.push(r.build(t,s),a.build(t,1===t.getTypeLength(a.getNodeType(t))?"float":s)):n===my.REFRACT?c.push(r.build(t,s),a.build(t,s),o.build(t,"float")):n===my.MIX?c.push(r.build(t,s),a.build(t,s),o.build(t,1===t.getTypeLength(o.getNodeType(t))?"float":s)):(c.push(r.build(t,s)),null!==a&&c.push(a.build(t,s)),null!==o&&c.push(o.build(t,s))),t.format(`${t.getMethod(n,i)}( ${c.join(", ")} )`,i,e)}}serialize(t){super.serialize(t),t.method=this.method}deserialize(t){super.deserialize(t),this.method=t.method}}my.ALL="all",my.ANY="any",my.EQUALS="equals",my.RADIANS="radians",my.DEGREES="degrees",my.EXP="exp",my.EXP2="exp2",my.LOG="log",my.LOG2="log2",my.SQRT="sqrt",my.INVERSE_SQRT="inversesqrt",my.FLOOR="floor",my.CEIL="ceil",my.NORMALIZE="normalize",my.FRACT="fract",my.SIN="sin",my.COS="cos",my.TAN="tan",my.ASIN="asin",my.ACOS="acos",my.ATAN="atan",my.ABS="abs",my.SIGN="sign",my.LENGTH="length",my.NEGATE="negate",my.ONE_MINUS="oneMinus",my.DFDX="dFdx",my.DFDY="dFdy",my.ROUND="round",my.RECIPROCAL="reciprocal",my.TRUNC="trunc",my.FWIDTH="fwidth",my.BITCAST="bitcast",my.TRANSPOSE="transpose",my.ATAN2="atan2",my.MIN="min",my.MAX="max",my.MOD="mod",my.STEP="step",my.REFLECT="reflect",my.DISTANCE="distance",my.DIFFERENCE="difference",my.DOT="dot",my.CROSS="cross",my.POW="pow",my.TRANSFORM_DIRECTION="transformDirection",my.MIX="mix",my.CLAMP="clamp",my.REFRACT="refract",my.SMOOTHSTEP="smoothstep",my.FACEFORWARD="faceforward";const fy=Lg(1e-6),gy=Lg(1e6),vy=Lg(Math.PI),yy=Lg(2*Math.PI),_y=Tg(my,my.ALL),xy=Tg(my,my.ANY),My=Tg(my,my.EQUALS),by=Tg(my,my.RADIANS),Ty=Tg(my,my.DEGREES),Sy=Tg(my,my.EXP),wy=Tg(my,my.EXP2),Ey=Tg(my,my.LOG),Ay=Tg(my,my.LOG2),Ny=Tg(my,my.SQRT),Cy=Tg(my,my.INVERSE_SQRT),Ry=Tg(my,my.FLOOR),Iy=Tg(my,my.CEIL),Ly=Tg(my,my.NORMALIZE),Py=Tg(my,my.FRACT),Uy=Tg(my,my.SIN),Dy=Tg(my,my.COS),Oy=Tg(my,my.TAN),zy=Tg(my,my.ASIN),Vy=Tg(my,my.ACOS),Fy=Tg(my,my.ATAN),By=Tg(my,my.ABS),ky=Tg(my,my.SIGN),Hy=Tg(my,my.LENGTH),Gy=Tg(my,my.NEGATE),Wy=Tg(my,my.ONE_MINUS),jy=Tg(my,my.DFDX),Xy=Tg(my,my.DFDY),qy=Tg(my,my.ROUND),Yy=Tg(my,my.RECIPROCAL),Zy=Tg(my,my.TRUNC),$y=Tg(my,my.FWIDTH),Jy=Tg(my,my.BITCAST),Ky=Tg(my,my.TRANSPOSE),Qy=Tg(my,my.ATAN2),t_=Tg(my,my.MIN),e_=Tg(my,my.MAX),n_=Tg(my,my.MOD),i_=Tg(my,my.STEP),s_=Tg(my,my.REFLECT),r_=Tg(my,my.DISTANCE),a_=Tg(my,my.DIFFERENCE),o_=Tg(my,my.DOT),l_=Tg(my,my.CROSS),c_=Tg(my,my.POW),u_=Tg(my,my.POW,2),h_=Tg(my,my.POW,3),d_=Tg(my,my.POW,4),p_=Tg(my,my.TRANSFORM_DIRECTION),m_=t=>Yv(ky(t),c_(By(t),1/3)),f_=t=>o_(t,t),g_=Tg(my,my.MIX),v_=(t,e=0,n=1)=>xg(new my(my.CLAMP,xg(t),xg(e),xg(n))),y_=t=>v_(t),__=Tg(my,my.REFRACT),x_=Tg(my,my.SMOOTHSTEP),M_=Tg(my,my.FACEFORWARD),b_=wg(([t])=>{const e=o_(t.xy,Og(12.9898,78.233)),n=n_(e,vy);return Py(Uy(n).mul(43758.5453))}),T_=(t,e,n)=>g_(e,n,t),S_=(t,e,n)=>x_(e,n,t);qf("all",_y),qf("any",xy),qf("equals",My),qf("radians",by),qf("degrees",Ty),qf("exp",Sy),qf("exp2",wy),qf("log",Ey),qf("log2",Ay),qf("sqrt",Ny),qf("inverseSqrt",Cy),qf("floor",Ry),qf("ceil",Iy),qf("normalize",Ly),qf("fract",Py),qf("sin",Uy),qf("cos",Dy),qf("tan",Oy),qf("asin",zy),qf("acos",Vy),qf("atan",Fy),qf("abs",By),qf("sign",ky),qf("length",Hy),qf("lengthSq",f_),qf("negate",Gy),qf("oneMinus",Wy),qf("dFdx",jy),qf("dFdy",Xy),qf("round",qy),qf("reciprocal",Yy),qf("trunc",Zy),qf("fwidth",$y),qf("atan2",Qy),qf("min",t_),qf("max",e_),qf("mod",n_),qf("step",i_),qf("reflect",s_),qf("distance",r_),qf("dot",o_),qf("cross",l_),qf("pow",c_),qf("pow2",u_),qf("pow3",h_),qf("pow4",d_),qf("transformDirection",p_),qf("mix",T_),qf("clamp",v_),qf("refract",__),qf("smoothstep",S_),qf("faceForward",M_),qf("difference",a_),qf("saturate",y_),qf("cbrt",m_),qf("transpose",Ky),qf("rand",b_);class w_ extends Uf{static get type(){return"ConditionalNode"}constructor(t,e,n=null){super(),this.condNode=t,this.ifNode=e,this.elseNode=n}getNodeType(t){const e=this.ifNode.getNodeType(t);if(null!==this.elseNode){const n=this.elseNode.getNodeType(t);if(t.getTypeLength(n)>t.getTypeLength(e))return n}return e}setup(t){const e=this.condNode.cache(),n=this.ifNode.cache(),i=this.elseNode?this.elseNode.cache():null,s=t.context.nodeBlock;t.getDataFromNode(n).parentNodeBlock=s,null!==i&&(t.getDataFromNode(i).parentNodeBlock=s);const r=t.getNodeProperties(this);r.condNode=e,r.ifNode=n.context({nodeBlock:n}),r.elseNode=i?i.context({nodeBlock:i}):null}generate(t,e){const n=this.getNodeType(t),i=t.getDataFromNode(this);if(void 0!==i.nodeProperty)return i.nodeProperty;const{condNode:s,ifNode:r,elseNode:a}=t.getNodeProperties(this),o="void"!==e,l=o?hv(n).build(t):"";i.nodeProperty=l;const c=s.build(t,"bool");t.addFlowCode(`\n${t.tab}if ( ${c} ) {\n\n`).addFlowTab();let u=r.build(t,n);if(u&&(u=o?l+" = "+u+";":"return "+u+";"),t.removeFlowTab().addFlowCode(t.tab+"\t"+u+"\n\n"+t.tab+"}"),null!==a){t.addFlowCode(" else {\n\n").addFlowTab();let e=a.build(t,n);e&&(e=o?l+" = "+e+";":"return "+e+";"),t.removeFlowTab().addFlowCode(t.tab+"\t"+e+"\n\n"+t.tab+"}\n\n")}else t.addFlowCode("\n\n");return t.format(l,n,e)}}const E_=Tg(w_);qf("select",E_);const A_=(...t)=>(console.warn("TSL.ConditionalNode: cond() has been renamed to select()."),E_(...t));qf("cond",A_);class N_ extends Uf{static get type(){return"ContextNode"}constructor(t,e={}){super(),this.isContextNode=!0,this.node=t,this.value=e}getScope(){return this.node.getScope()}getNodeType(t){return this.node.getNodeType(t)}analyze(t){this.node.build(t)}setup(t){const e=t.getContext();t.setContext({...t.context,...this.value});const n=this.node.build(t);return t.setContext(e),n}generate(t,e){const n=t.getContext();t.setContext({...t.context,...this.value});const i=this.node.build(t,e);return t.setContext(n),i}}const C_=Tg(N_),R_=(t,e)=>C_(t,{label:e});qf("context",C_),qf("label",R_);class I_ extends Uf{static get type(){return"VarNode"}constructor(t,e=null){super(),this.node=t,this.name=e,this.global=!0,this.isVarNode=!0}getHash(t){return this.name||super.getHash(t)}getNodeType(t){return this.node.getNodeType(t)}generate(t){const{node:e,name:n}=this,i=t.getVarFromNode(this,n,t.getVectorType(this.getNodeType(t))),s=t.getPropertyName(i),r=e.build(t,i.type);return t.addLineFlowCode(`${s} = ${r}`,this),s}}const L_=Tg(I_);qf("temp",L_),qf("toVar",(...t)=>L_(...t).append());class P_ extends Uf{static get type(){return"VaryingNode"}constructor(t,e=null){super(),this.node=t,this.name=e,this.isVaryingNode=!0}isGlobal(){return!0}getHash(t){return this.name||super.getHash(t)}getNodeType(t){return this.node.getNodeType(t)}setupVarying(t){const e=t.getNodeProperties(this);let n=e.varying;if(void 0===n){const i=this.name,s=this.getNodeType(t);e.varying=n=t.getVaryingFromNode(this,i,s),e.node=this.node}return n.needsInterpolation||(n.needsInterpolation="fragment"===t.shaderStage),n}setup(t){this.setupVarying(t)}analyze(t){return this.setupVarying(t),this.node.analyze(t)}generate(t){const e=t.getNodeProperties(this),n=this.setupVarying(t);if(void 0===e.propertyName){const i=this.getNodeType(t),s=t.getPropertyName(n,Ef.VERTEX);t.flowNodeFromShaderStage(Ef.VERTEX,this.node,i,s),e.propertyName=s}return t.getPropertyName(n)}}const U_=Tg(P_);qf("varying",U_);const D_="WorkingColorSpace",O_="OutputColorSpace";function z_(t){let e=null;return t===Ke?e="Linear":t===Je&&(e="sRGB"),e}function V_(t,e){return z_(t)+"To"+z_(e)}class F_ extends zf{static get type(){return"ColorSpaceNode"}constructor(t,e,n){super("vec4"),this.colorNode=t,this.source=e,this.target=n}getColorSpace(t,e){return e===D_?fi.workingColorSpace:e===O_?t.context.outputColorSpace||t.renderer.outputColorSpace:e}setup(t){const{renderer:e}=t,{colorNode:n}=this,i=this.getColorSpace(t,this.source),s=this.getColorSpace(t,this.target);if(i===s)return n;const r=V_(i,s);let a=null;const o=e.nodes.library.getColorSpaceFunction(r);return null!==o?a=Wg(o(n.rgb),n.a):(console.error("ColorSpaceNode: Unsupported Color Space configuration.",r),a=n),a}}const B_=t=>xg(new F_(xg(t),D_,O_)),k_=t=>xg(new F_(xg(t),O_,D_)),H_=(t,e)=>xg(new F_(xg(t),D_,e)),G_=(t,e)=>xg(new F_(xg(t),e,D_));qf("toOutputColorSpace",B_),qf("toWorkingColorSpace",k_),qf("workingToColorSpace",H_),qf("colorSpaceToWorking",G_);let W_=class extends Df{static get type(){return"ReferenceElementNode"}constructor(t,e){super(t,e),this.referenceNode=t,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(t){const e=super.generate(t),n=this.referenceNode.getNodeType(),i=this.getNodeType();return t.format(e,n,i)}};class j_ extends Uf{static get type(){return"ReferenceBaseNode"}constructor(t,e,n=null,i=null){super(),this.property=t,this.uniformType=e,this.object=n,this.count=i,this.properties=t.split("."),this.reference=n,this.node=null,this.group=null,this.updateType=Af.OBJECT}setGroup(t){return this.group=t,this}element(t){return xg(new W_(this,xg(t)))}setNodeType(t){const e=cv(null,t).getSelf();null!==this.group&&e.setGroup(this.group),this.node=e}getNodeType(t){return null===this.node&&(this.updateReference(t),this.updateValue()),this.node.getNodeType(t)}getValueFromReference(t=this.reference){const{properties:e}=this;let n=t[e[0]];for(let t=1;t<e.length;t++)n=n[e[t]];return n}updateReference(t){return this.reference=null!==this.object?this.object:t.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){null===this.node&&this.setNodeType(this.uniformType);const t=this.getValueFromReference();Array.isArray(t)?this.node.array=t:this.node.value=t}}class X_ extends j_{static get type(){return"RendererReferenceNode"}constructor(t,e,n=null){super(t,e,n),this.renderer=n,this.setGroup(av)}updateReference(t){return this.reference=null!==this.renderer?this.renderer:t.renderer,this.reference}}const q_=(t,e,n)=>xg(new X_(t,e,n));class Y_ extends zf{static get type(){return"ToneMappingNode"}constructor(t,e=$_,n=null){super("vec3"),this.toneMapping=t,this.exposureNode=e,this.colorNode=n}getCacheKey(){return yf(super.getCacheKey(),this.toneMapping)}setup(t){const e=this.colorNode||t.context.color,n=this.toneMapping;if(0===n)return e;let i=null;const s=t.renderer.nodes.library.getToneMappingFunction(n);return null!==s?i=Wg(s(e.rgb,this.exposureNode),e.a):(console.error("ToneMappingNode: Unsupported Tone Mapping configuration.",n),i=e),i}}const Z_=(t,e,n)=>xg(new Y_(t,xg(e),xg(n))),$_=q_("toneMappingExposure","float");qf("toneMapping",(t,e,n)=>Z_(e,n,t));class J_ extends Gf{static get type(){return"BufferAttributeNode"}constructor(t,e=null,n=0,i=0){super(t,e),this.isBufferNode=!0,this.bufferType=e,this.bufferStride=n,this.bufferOffset=i,this.usage=Rn,this.instanced=!1,this.attribute=null,this.global=!0,t&&!0===t.isBufferAttribute&&(this.attribute=t,this.usage=t.usage,this.instanced=t.isInstancedBufferAttribute)}getHash(t){if(0===this.bufferStride&&0===this.bufferOffset){let e=t.globalCache.getData(this.value);return void 0===e&&(e={node:this},t.globalCache.setData(this.value,e)),e.node.uuid}return this.uuid}getNodeType(t){return null===this.bufferType&&(this.bufferType=t.getTypeFromAttribute(this.attribute)),this.bufferType}setup(t){if(null!==this.attribute)return;const e=this.getNodeType(t),n=this.value,i=t.getTypeLength(e),s=this.bufferStride||i,r=this.bufferOffset,a=!0===n.isInterleavedBuffer?n:new dc(n,s),o=new mc(a,i,r);a.setUsage(this.usage),this.attribute=o,this.attribute.isInstancedBufferAttribute=this.instanced}generate(t){const e=this.getNodeType(t),n=t.getBufferAttributeFromNode(this,e),i=t.getPropertyName(n);let s=null;if("vertex"===t.shaderStage||"compute"===t.shaderStage)this.name=i,s=i;else{s=U_(this).build(t,e)}return s}getInputType(){return"bufferAttribute"}setUsage(t){return this.usage=t,this.attribute&&!0===this.attribute.isBufferAttribute&&(this.attribute.usage=t),this}setInstanced(t){return this.instanced=t,this}}const K_=(t,e,n,i)=>xg(new J_(t,e,n,i)),Q_=(t,e,n,i)=>K_(t,e,n,i).setUsage(In),tx=(t,e,n,i)=>K_(t,e,n,i).setInstanced(!0),ex=(t,e,n,i)=>Q_(t,e,n,i).setInstanced(!0);qf("toAttribute",t=>K_(t.value));class nx extends Uf{static get type(){return"ComputeNode"}constructor(t,e,n=[64]){super("void"),this.isComputeNode=!0,this.computeNode=t,this.count=e,this.workgroupSize=n,this.dispatchCount=0,this.version=1,this.updateBeforeType=Af.OBJECT,this.updateDispatchCount()}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){!0===t&&this.version++}updateDispatchCount(){const{count:t,workgroupSize:e}=this;let n=e[0];for(let t=1;t<e.length;t++)n*=e[t];this.dispatchCount=Math.ceil(t/n)}onInit(){}updateBefore({renderer:t}){t.compute(this)}generate(t){const{shaderStage:e}=t;if("compute"===e){const e=this.computeNode.build(t,"void");""!==e&&t.addLineFlowCode(e,this)}}}const ix=(t,e,n)=>xg(new nx(xg(t),e,n));qf("compute",ix);class sx extends Uf{static get type(){return"CacheNode"}constructor(t,e=!0){super(),this.node=t,this.parent=e,this.isCacheNode=!0}getNodeType(t){return this.node.getNodeType(t)}build(t,...e){const n=t.getCache(),i=t.getCacheFromNode(this,this.parent);t.setCache(i);const s=this.node.build(t,...e);return t.setCache(n),s}}const rx=(t,...e)=>xg(new sx(xg(t),...e));qf("cache",rx);class ax extends Uf{static get type(){return"BypassNode"}constructor(t,e){super(),this.isBypassNode=!0,this.outputNode=t,this.callNode=e}getNodeType(t){return this.outputNode.getNodeType(t)}generate(t){const e=this.callNode.build(t,"void");return""!==e&&t.addLineFlowCode(e,this),this.outputNode.build(t)}}const ox=Tg(ax);qf("bypass",ox);class lx extends Uf{static get type(){return"RemapNode"}constructor(t,e,n,i=Lg(0),s=Lg(1)){super(),this.node=t,this.inLowNode=e,this.inHighNode=n,this.outLowNode=i,this.outHighNode=s,this.doClamp=!0}setup(){const{node:t,inLowNode:e,inHighNode:n,outLowNode:i,outHighNode:s,doClamp:r}=this;let a=t.sub(e).div(n.sub(e));return!0===r&&(a=a.clamp()),a.mul(s.sub(i)).add(i)}}const cx=Tg(lx,null,null,{doClamp:!1}),ux=Tg(lx);qf("remap",cx),qf("remapClamp",ux);class hx extends Uf{static get type(){return"ExpressionNode"}constructor(t="",e="void"){super(e),this.snippet=t}generate(t,e){const n=this.getNodeType(t),i=this.snippet;if("void"!==n)return t.format(`( ${i} )`,n,e);t.addLineFlowCode(i,this)}}const dx=Tg(hx),px=t=>(t?E_(t,dx("discard")):dx("discard")).append(),mx=()=>dx("return").append();qf("discard",px);class fx extends zf{static get type(){return"RenderOutputNode"}constructor(t,e,n){super("vec4"),this.colorNode=t,this.toneMapping=e,this.outputColorSpace=n,this.isRenderOutput=!0}setup({context:t}){let e=this.colorNode||t.color;const n=(null!==this.toneMapping?this.toneMapping:t.toneMapping)||0,i=(null!==this.outputColorSpace?this.outputColorSpace:t.outputColorSpace)||$e;return 0!==n&&(e=e.toneMapping(n)),i!==$e&&i!==fi.workingColorSpace&&(e=e.workingToColorSpace(i)),e}}const gx=(t,e=null,n=null)=>xg(new fx(xg(t),e,n));function vx(t){console.warn("THREE.TSLBase: AddNodeElement has been removed in favor of tree-shaking. Trying add",t)}qf("renderOutput",gx);class yx extends Uf{static get type(){return"AttributeNode"}constructor(t,e=null){super(e),this.global=!0,this._attributeName=t}getHash(t){return this.getAttributeName(t)}getNodeType(t){let e=this.nodeType;if(null===e){const n=this.getAttributeName(t);if(t.hasGeometryAttribute(n)){const i=t.geometry.getAttribute(n);e=t.getTypeFromAttribute(i)}else e="float"}return e}setAttributeName(t){return this._attributeName=t,this}getAttributeName(){return this._attributeName}generate(t){const e=this.getAttributeName(t),n=this.getNodeType(t);if(!0===t.hasGeometryAttribute(e)){const i=t.geometry.getAttribute(e),s=t.getTypeFromAttribute(i),r=t.getAttribute(e,s);if("vertex"===t.shaderStage)return t.format(r.name,s,n);return U_(this).build(t,n)}return console.warn(`AttributeNode: Vertex attribute "${e}" not found on geometry.`),t.generateConst(n)}serialize(t){super.serialize(t),t.global=this.global,t._attributeName=this._attributeName}deserialize(t){super.deserialize(t),this.global=t.global,this._attributeName=t._attributeName}}const _x=(t,e)=>xg(new yx(t,e)),xx=t=>_x("uv"+(t>0?t:""),"vec2");class Mx extends Uf{static get type(){return"TextureSizeNode"}constructor(t,e=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=t,this.levelNode=e}generate(t,e){const n=this.textureNode.build(t,"property"),i=null===this.levelNode?"0":this.levelNode.build(t,"int");return t.format(`${t.getMethod("textureDimensions")}( ${n}, ${i} )`,this.getNodeType(t),e)}}const bx=Tg(Mx);class Tx extends lv{static get type(){return"MaxMipLevelNode"}constructor(t){super(0),this._textureNode=t,this.updateType=Af.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){const t=this.texture,e=t.images,n=e&&e.length>0?e[0]&&e[0].image||e[0]:t.image;if(n&&void 0!==n.width){const{width:t,height:e}=n;this.value=Math.log2(Math.max(t,e))}}}const Sx=Tg(Tx);class wx extends lv{static get type(){return"TextureNode"}constructor(t,e=null,n=null,i=null){super(t),this.isTextureNode=!0,this.uvNode=e,this.levelNode=n,this.biasNode=i,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=Af.NONE,this.referenceNode=null,this._value=t,this._matrixUniform=null,this.setUpdateMatrix(null===e)}set value(t){this.referenceNode?this.referenceNode.value=t:this._value=t}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}getNodeType(){return!0===this.value.isDepthTexture?"float":this.value.type===It?"uvec4":this.value.type===Rt?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return xx(this.value.channel)}updateReference(){return this.value}getTransformedUV(t){return null===this._matrixUniform&&(this._matrixUniform=cv(this.value.matrix)),this._matrixUniform.mul(Bg(t,1)).xy}setUpdateMatrix(t){return this.updateMatrix=t,this.updateType=t?Af.FRAME:Af.NONE,this}setupUV(t,e){const n=this.value;return!t.isFlipY()||!0!==n.isRenderTargetTexture&&!0!==n.isFramebufferTexture&&!0!==n.isDepthTexture||(e=this.sampler?e.flipY():e.setY(Pg(bx(this,this.levelNode).y).sub(e.y).sub(1))),e}setup(t){const e=t.getNodeProperties(this);e.referenceNode=this.referenceNode;let n=this.uvNode;null!==n&&!0!==t.context.forceUVContext||!t.context.getUV||(n=t.context.getUV(this)),n||(n=this.getDefaultUV()),!0===this.updateMatrix&&(n=this.getTransformedUV(n)),n=this.setupUV(t,n);let i=this.levelNode;null===i&&t.context.getTextureLevel&&(i=t.context.getTextureLevel(this)),e.uvNode=n,e.levelNode=i,e.biasNode=this.biasNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.depthNode=this.depthNode}generateUV(t,e){return e.build(t,!0===this.sampler?"vec2":"ivec2")}generateSnippet(t,e,n,i,s,r,a,o){const l=this.value;let c;return c=i?t.generateTextureLevel(l,e,n,i,r):s?t.generateTextureBias(l,e,n,s,r):o?t.generateTextureGrad(l,e,n,o,r):a?t.generateTextureCompare(l,e,n,a,r):!1===this.sampler?t.generateTextureLoad(l,e,n,r):t.generateTexture(l,e,n,r),c}generate(t,e){const n=t.getNodeProperties(this),i=this.value;if(!i||!0!==i.isTexture)throw new Error("TextureNode: Need a three.js texture.");const s=super.generate(t,"property");if("sampler"===e)return s+"_sampler";if(t.isReference(e))return s;{const r=t.getDataFromNode(this);let a=r.propertyName;if(void 0===a){const{uvNode:e,levelNode:i,biasNode:o,compareNode:l,depthNode:c,gradNode:u}=n,h=this.generateUV(t,e),d=i?i.build(t,"float"):null,p=o?o.build(t,"float"):null,m=c?c.build(t,"int"):null,f=l?l.build(t,"float"):null,g=u?[u[0].build(t,"vec2"),u[1].build(t,"vec2")]:null,v=t.getVarFromNode(this);a=t.getPropertyName(v);const y=this.generateSnippet(t,s,h,d,p,m,f,g);t.addLineFlowCode(`${a} = ${y}`,this),r.snippet=y,r.propertyName=a}let o=a;const l=this.getNodeType(t);return t.needsToWorkingColorSpace(i)&&(o=G_(dx(o,l),i.colorSpace).setup(t).build(t,l)),t.format(o,l,e)}}setSampler(t){return this.sampler=t,this}getSampler(){return this.sampler}uv(t){const e=this.clone();return e.uvNode=xg(t),e.referenceNode=this.getSelf(),xg(e)}blur(t){const e=this.clone();return e.biasNode=xg(t).mul(Sx(e)),e.referenceNode=this.getSelf(),xg(e)}level(t){const e=this.clone();return e.levelNode=xg(t),e.referenceNode=this.getSelf(),xg(e)}size(t){return bx(this,t)}bias(t){const e=this.clone();return e.biasNode=xg(t),e.referenceNode=this.getSelf(),xg(e)}compare(t){const e=this.clone();return e.compareNode=xg(t),e.referenceNode=this.getSelf(),xg(e)}grad(t,e){const n=this.clone();return n.gradNode=[xg(t),xg(e)],n.referenceNode=this.getSelf(),xg(n)}depth(t){const e=this.clone();return e.depthNode=xg(t),e.referenceNode=this.getSelf(),xg(e)}serialize(t){super.serialize(t),t.value=this.value.toJSON(t.meta).uuid,t.sampler=this.sampler,t.updateMatrix=this.updateMatrix,t.updateType=this.updateType}deserialize(t){super.deserialize(t),this.value=t.meta.textures[t.value],this.sampler=t.sampler,this.updateMatrix=t.updateMatrix,this.updateType=t.updateType}update(){const t=this.value,e=this._matrixUniform;null!==e&&(e.value=t.matrix),!0===t.matrixAutoUpdate&&t.updateMatrix()}clone(){const t=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return t.sampler=this.sampler,t}}const Ex=Tg(wx),Ax=(...t)=>Ex(...t).setSampler(!1),Nx=t=>(!0===t.isNode?t:Ex(t)).convert("sampler"),Cx=cv("float").label("cameraNear").setGroup(av).onRenderUpdate(({camera:t})=>t.near),Rx=cv("float").label("cameraFar").setGroup(av).onRenderUpdate(({camera:t})=>t.far),Ix=cv("float").label("cameraLogDepth").setGroup(av).onRenderUpdate(({camera:t})=>2/(Math.log(t.far+1)/Math.LN2)),Lx=cv("mat4").label("cameraProjectionMatrix").setGroup(av).onRenderUpdate(({camera:t})=>t.projectionMatrix),Px=cv("mat4").label("cameraProjectionMatrixInverse").setGroup(av).onRenderUpdate(({camera:t})=>t.projectionMatrixInverse),Ux=cv("mat4").label("cameraViewMatrix").setGroup(av).onRenderUpdate(({camera:t})=>t.matrixWorldInverse),Dx=cv("mat4").label("cameraWorldMatrix").setGroup(av).onRenderUpdate(({camera:t})=>t.matrixWorld),Ox=cv("mat3").label("cameraNormalMatrix").setGroup(av).onRenderUpdate(({camera:t})=>t.normalMatrix),zx=cv(new Pi).label("cameraPosition").setGroup(av).onRenderUpdate(({camera:t},e)=>e.value.setFromMatrixPosition(t.matrixWorld));class Vx extends Uf{static get type(){return"Object3DNode"}constructor(t,e=null){super(),this.scope=t,this.object3d=e,this.updateType=Af.OBJECT,this._uniformNode=new lv(null)}getNodeType(){const t=this.scope;return t===Vx.WORLD_MATRIX?"mat4":t===Vx.POSITION||t===Vx.VIEW_POSITION||t===Vx.DIRECTION||t===Vx.SCALE?"vec3":void 0}update(t){const e=this.object3d,n=this._uniformNode,i=this.scope;if(i===Vx.WORLD_MATRIX)n.value=e.matrixWorld;else if(i===Vx.POSITION)n.value=n.value||new Pi,n.value.setFromMatrixPosition(e.matrixWorld);else if(i===Vx.SCALE)n.value=n.value||new Pi,n.value.setFromMatrixScale(e.matrixWorld);else if(i===Vx.DIRECTION)n.value=n.value||new Pi,e.getWorldDirection(n.value);else if(i===Vx.VIEW_POSITION){const i=t.camera;n.value=n.value||new Pi,n.value.setFromMatrixPosition(e.matrixWorld),n.value.applyMatrix4(i.matrixWorldInverse)}}generate(t){const e=this.scope;return e===Vx.WORLD_MATRIX?this._uniformNode.nodeType="mat4":e!==Vx.POSITION&&e!==Vx.VIEW_POSITION&&e!==Vx.DIRECTION&&e!==Vx.SCALE||(this._uniformNode.nodeType="vec3"),this._uniformNode.build(t)}serialize(t){super.serialize(t),t.scope=this.scope}deserialize(t){super.deserialize(t),this.scope=t.scope}}Vx.WORLD_MATRIX="worldMatrix",Vx.POSITION="position",Vx.SCALE="scale",Vx.VIEW_POSITION="viewPosition",Vx.DIRECTION="direction";const Fx=Tg(Vx,Vx.DIRECTION),Bx=Tg(Vx,Vx.WORLD_MATRIX),kx=Tg(Vx,Vx.POSITION),Hx=Tg(Vx,Vx.SCALE),Gx=Tg(Vx,Vx.VIEW_POSITION);class Wx extends Vx{static get type(){return"ModelNode"}constructor(t){super(t)}update(t){this.object3d=t.object,super.update(t)}}const jx=Sg(Wx,Wx.DIRECTION),Xx=Sg(Wx,Wx.WORLD_MATRIX),qx=Sg(Wx,Wx.POSITION),Yx=Sg(Wx,Wx.SCALE),Zx=Sg(Wx,Wx.VIEW_POSITION),$x=cv(new ni).onObjectUpdate(({object:t},e)=>e.value.getNormalMatrix(t.matrixWorld)),Jx=cv(new cs).onObjectUpdate(({object:t},e)=>e.value.copy(t.matrixWorld).invert()),Kx=Ux.mul(Xx).toVar("modelViewMatrix_2"),Qx=wg(t=>(t.context.isHighPrecisionModelViewMatrix=!0,cv("mat4").onObjectUpdate(({object:t,camera:e})=>t.modelViewMatrix.multiplyMatrices(e.matrixWorldInverse,t.matrixWorld)))).once()().toVar("highPrecisionModelViewMatrix"),tM=wg(t=>{const e=t.context.isHighPrecisionModelViewMatrix;return cv("mat3").onObjectUpdate(({object:t,camera:n})=>(!0!==e&&t.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix)))}).once()().toVar("highPrecisionModelNormalMatrix"),eM=_x("position","vec3"),nM=eM.varying("positionLocal"),iM=eM.varying("positionPrevious"),sM=Xx.mul(nM).xyz.varying("v_positionWorld"),rM=nM.transformDirection(Xx).varying("v_positionWorldDirection").normalize().toVar("positionWorldDirection"),aM=Kx.mul(nM).xyz.varying("v_positionView"),oM=aM.negate().varying("v_positionViewDirection").normalize().toVar("positionViewDirection");class lM extends Uf{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(t){const{renderer:e,material:n}=t;return e.coordinateSystem===kn&&1===n.side?"false":t.getFrontFacing()}}const cM=Sg(lM),uM=Lg(cM).mul(2).sub(1),hM=_x("normal","vec3"),dM=wg(t=>!1===t.geometry.hasAttribute("normal")?(console.warn('TSL.NormalNode: Vertex attribute "normal" not found on geometry.'),Bg(0,1,0)):hM,"vec3").once()().toVar("normalLocal"),pM=aM.dFdx().cross(aM.dFdy()).normalize().toVar("normalFlat"),mM=wg(t=>{let e;return e=!0===t.material.flatShading?pM:U_(xM(dM),"v_normalView").normalize(),e},"vec3").once()().toVar("normalView"),fM=U_(mM.transformDirection(Ux),"v_normalWorld").normalize().toVar("normalWorld"),gM=wg(t=>t.context.setupNormal(),"vec3").once()().mul(uM).toVar("transformedNormalView"),vM=gM.transformDirection(Ux).toVar("transformedNormalWorld"),yM=wg(t=>t.context.setupClearcoatNormal(),"vec3").once()().mul(uM).toVar("transformedClearcoatNormalView"),_M=wg(([t,e=Xx])=>{const n=Zg(e),i=t.div(Bg(n[0].dot(n[0]),n[1].dot(n[1]),n[2].dot(n[2])));return n.mul(i).xyz}),xM=wg(([t],e)=>{const n=e.renderer.nodes.modelNormalViewMatrix;if(null!==n)return n.transformDirection(t);const i=$x.mul(t);return Ux.transformDirection(i)}),MM=cv(0).onReference(({material:t})=>t).onRenderUpdate(({material:t})=>t.refractionRatio),bM=oM.negate().reflect(gM),TM=oM.negate().refract(gM,MM),SM=bM.transformDirection(Ux).toVar("reflectVector"),wM=TM.transformDirection(Ux).toVar("reflectVector");class EM extends wx{static get type(){return"CubeTextureNode"}constructor(t,e=null,n=null,i=null){super(t,e,n,i),this.isCubeTextureNode=!0}getInputType(){return"cubeTexture"}getDefaultUV(){const t=this.value;return t.mapping===lt?SM:t.mapping===ct?wM:(console.error('THREE.CubeTextureNode: Mapping "%s" not supported.',t.mapping),Bg(0,0,0))}setUpdateMatrix(){}setupUV(t,e){const n=this.value;return t.renderer.coordinateSystem!==Hn&&n.isRenderTargetTexture?e:Bg(e.x.negate(),e.yz)}generateUV(t,e){return e.build(t,"vec3")}}const AM=Tg(EM);class NM extends lv{static get type(){return"BufferNode"}constructor(t,e,n=0){super(t,e),this.isBufferNode=!0,this.bufferType=e,this.bufferCount=n}getElementType(t){return this.getNodeType(t)}getInputType(){return"buffer"}}const CM=(t,e,n)=>xg(new NM(t,e,n));class RM extends Df{static get type(){return"UniformArrayElementNode"}constructor(t,e){super(t,e),this.isArrayBufferElementNode=!0}generate(t){const e=super.generate(t),n=this.getNodeType();return t.format(e,"vec4",n)}}class IM extends NM{static get type(){return"UniformArrayNode"}constructor(t,e=null){super(null,"vec4"),this.array=t,this.elementType=e,this._elementType=null,this._elementLength=0,this.updateType=Af.RENDER,this.isArrayBufferNode=!0}getElementType(){return this.elementType||this._elementType}getElementLength(){return this._elementLength}update(){const{array:t,value:e}=this,n=this.getElementLength(),i=this.getElementType();if(1===n)for(let n=0;n<t.length;n++){e[4*n]=t[n]}else if("color"===i)for(let n=0;n<t.length;n++){const i=4*n,s=t[n];e[i]=s.r,e[i+1]=s.g,e[i+2]=s.b||0}else for(let n=0;n<t.length;n++){const i=4*n,s=t[n];e[i]=s.x,e[i+1]=s.y,e[i+2]=s.z||0,e[i+3]=s.w||0}}setup(t){const e=this.array.length;this._elementType=null===this.elementType?Mf(this.array[0]):this.elementType,this._elementLength=t.getTypeLength(this._elementType);let n=Float32Array;return"i"===this._elementType.charAt(0)?n=Int32Array:"u"===this._elementType.charAt(0)&&(n=Uint32Array),this.value=new n(4*e),this.bufferCount=e,this.bufferType=t.changeComponentType("vec4",t.getComponentType(this._elementType)),super.setup(t)}element(t){return xg(new RM(this,xg(t)))}}const LM=(t,e)=>xg(new IM(t,e)),PM=(t,e)=>(console.warn("TSL.UniformArrayNode: uniforms() has been renamed to uniformArray()."),xg(new IM(t,e)));class UM extends Df{static get type(){return"ReferenceElementNode"}constructor(t,e){super(t,e),this.referenceNode=t,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(t){const e=super.generate(t),n=this.referenceNode.getNodeType(),i=this.getNodeType();return t.format(e,n,i)}}class DM extends Uf{static get type(){return"ReferenceNode"}constructor(t,e,n=null,i=null){super(),this.property=t,this.uniformType=e,this.object=n,this.count=i,this.properties=t.split("."),this.reference=n,this.node=null,this.group=null,this.name=null,this.updateType=Af.OBJECT}element(t){return xg(new UM(this,xg(t)))}setGroup(t){return this.group=t,this}label(t){return this.name=t,this}setNodeType(t){let e=null;e=null!==this.count?CM(null,t,this.count):Array.isArray(this.getValueFromReference())?LM(null,t):"texture"===t?Ex(null):"cubeTexture"===t?AM(null):cv(null,t),null!==this.group&&e.setGroup(this.group),null!==this.name&&e.label(this.name),this.node=e.getSelf()}getNodeType(t){return null===this.node&&(this.updateReference(t),this.updateValue()),this.node.getNodeType(t)}getValueFromReference(t=this.reference){const{properties:e}=this;let n=t[e[0]];for(let t=1;t<e.length;t++)n=n[e[t]];return n}updateReference(t){return this.reference=null!==this.object?this.object:t.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){null===this.node&&this.setNodeType(this.uniformType);const t=this.getValueFromReference();Array.isArray(t)?this.node.array=t:this.node.value=t}}const OM=(t,e,n)=>xg(new DM(t,e,n)),zM=(t,e,n,i)=>xg(new DM(t,e,i,n));class VM extends DM{static get type(){return"MaterialReferenceNode"}constructor(t,e,n=null){super(t,e,n),this.material=n,this.isMaterialReferenceNode=!0}updateReference(t){return this.reference=null!==this.material?this.material:t.material,this.reference}}const FM=(t,e,n)=>xg(new VM(t,e,n)),BM=wg(t=>(!1===t.geometry.hasAttribute("tangent")&&t.geometry.computeTangents(),_x("tangent","vec4")))(),kM=BM.xyz.toVar("tangentLocal"),HM=Kx.mul(Wg(kM,0)).xyz.varying("v_tangentView").normalize().toVar("tangentView"),GM=HM.transformDirection(Ux).varying("v_tangentWorld").normalize().toVar("tangentWorld"),WM=HM.toVar("transformedTangentView"),jM=WM.transformDirection(Ux).normalize().toVar("transformedTangentWorld"),XM=t=>t.mul(BM.w).xyz,qM=U_(XM(hM.cross(BM)),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),YM=U_(XM(dM.cross(kM)),"v_bitangentLocal").normalize().toVar("bitangentLocal"),ZM=U_(XM(mM.cross(HM)),"v_bitangentView").normalize().toVar("bitangentView"),$M=U_(XM(fM.cross(GM)),"v_bitangentWorld").normalize().toVar("bitangentWorld"),JM=XM(gM.cross(WM)).normalize().toVar("transformedBitangentView"),KM=JM.transformDirection(Ux).normalize().toVar("transformedBitangentWorld"),QM=Zg(HM,ZM,mM),tb=oM.mul(QM),eb=(t,e)=>t.sub(tb.mul(e)),nb=(()=>{let t=Av.cross(oM);return t=t.cross(Av).normalize(),t=g_(t,gM,wv.mul(fv.oneMinus()).oneMinus().pow2().pow2()).normalize(),t})(),ib=wg(t=>{const{eye_pos:e,surf_norm:n,mapN:i,uv:s}=t,r=e.dFdx(),a=e.dFdy(),o=s.dFdx(),l=s.dFdy(),c=n,u=a.cross(c),h=c.cross(r),d=u.mul(o.x).add(h.mul(l.x)),p=u.mul(o.y).add(h.mul(l.y)),m=d.dot(d).max(p.dot(p)),f=uM.mul(m.inverseSqrt());return Xv(d.mul(i.x,f),p.mul(i.y,f),c.mul(i.z)).normalize()});class sb extends zf{static get type(){return"NormalMapNode"}constructor(t,e=null){super("vec3"),this.node=t,this.scaleNode=e,this.normalMapType=0}setup(t){const{normalMapType:e,scaleNode:n}=this;let i=this.node.mul(2).sub(1);null!==n&&(i=Bg(i.xy.mul(n),i.z));let s=null;if(1===e)s=xM(i);else if(0===e){s=!0===t.hasGeometryAttribute("tangent")?QM.mul(i).normalize():ib({eye_pos:aM,surf_norm:mM,mapN:i,uv:xx()})}return s}}const rb=Tg(sb),ab=wg(({textureNode:t,bumpScale:e})=>{const n=e=>t.cache().context({getUV:t=>e(t.uvNode||xx()),forceUVContext:!0}),i=Lg(n(t=>t));return Og(Lg(n(t=>t.add(t.dFdx()))).sub(i),Lg(n(t=>t.add(t.dFdy()))).sub(i)).mul(e)}),ob=wg(t=>{const{surf_pos:e,surf_norm:n,dHdxy:i}=t,s=e.dFdx().normalize(),r=n,a=e.dFdy().normalize().cross(r),o=r.cross(s),l=s.dot(a).mul(uM),c=l.sign().mul(i.x.mul(a).add(i.y.mul(o)));return l.abs().mul(n).sub(c).normalize()});class lb extends zf{static get type(){return"BumpMapNode"}constructor(t,e=null){super("vec3"),this.textureNode=t,this.scaleNode=e}setup(){const t=null!==this.scaleNode?this.scaleNode:1,e=ab({textureNode:this.textureNode,bumpScale:t});return ob({surf_pos:aM,surf_norm:mM,dHdxy:e})}}const cb=Tg(lb),ub=new Map;class hb extends Uf{static get type(){return"MaterialNode"}constructor(t){super(),this.scope=t}getCache(t,e){let n=ub.get(t);return void 0===n&&(n=FM(t,e),ub.set(t,n)),n}getFloat(t){return this.getCache(t,"float")}getColor(t){return this.getCache(t,"color")}getTexture(t){return this.getCache("map"===t?"map":t+"Map","texture")}setup(t){const e=t.context.material,n=this.scope;let i=null;if(n===hb.COLOR){const t=void 0!==e.color?this.getColor(n):Bg();i=e.map&&!0===e.map.isTexture?t.mul(this.getTexture("map")):t}else if(n===hb.OPACITY){const t=this.getFloat(n);i=e.alphaMap&&!0===e.alphaMap.isTexture?t.mul(this.getTexture("alpha")):t}else if(n===hb.SPECULAR_STRENGTH)i=e.specularMap&&!0===e.specularMap.isTexture?this.getTexture("specular").r:Lg(1);else if(n===hb.SPECULAR_INTENSITY){const t=this.getFloat(n);i=e.specularMap?t.mul(this.getTexture(n).a):t}else if(n===hb.SPECULAR_COLOR){const t=this.getColor(n);i=e.specularColorMap&&!0===e.specularColorMap.isTexture?t.mul(this.getTexture(n).rgb):t}else if(n===hb.ROUGHNESS){const t=this.getFloat(n);i=e.roughnessMap&&!0===e.roughnessMap.isTexture?t.mul(this.getTexture(n).g):t}else if(n===hb.METALNESS){const t=this.getFloat(n);i=e.metalnessMap&&!0===e.metalnessMap.isTexture?t.mul(this.getTexture(n).b):t}else if(n===hb.EMISSIVE){const t=this.getFloat("emissiveIntensity"),s=this.getColor(n).mul(t);i=e.emissiveMap&&!0===e.emissiveMap.isTexture?s.mul(this.getTexture(n)):s}else if(n===hb.NORMAL)e.normalMap?(i=rb(this.getTexture("normal"),this.getCache("normalScale","vec2")),i.normalMapType=e.normalMapType):i=e.bumpMap?cb(this.getTexture("bump").r,this.getFloat("bumpScale")):mM;else if(n===hb.CLEARCOAT){const t=this.getFloat(n);i=e.clearcoatMap&&!0===e.clearcoatMap.isTexture?t.mul(this.getTexture(n).r):t}else if(n===hb.CLEARCOAT_ROUGHNESS){const t=this.getFloat(n);i=e.clearcoatRoughnessMap&&!0===e.clearcoatRoughnessMap.isTexture?t.mul(this.getTexture(n).r):t}else if(n===hb.CLEARCOAT_NORMAL)i=e.clearcoatNormalMap?rb(this.getTexture(n),this.getCache(n+"Scale","vec2")):mM;else if(n===hb.SHEEN){const t=this.getColor("sheenColor").mul(this.getFloat("sheen"));i=e.sheenColorMap&&!0===e.sheenColorMap.isTexture?t.mul(this.getTexture("sheenColor").rgb):t}else if(n===hb.SHEEN_ROUGHNESS){const t=this.getFloat(n);i=e.sheenRoughnessMap&&!0===e.sheenRoughnessMap.isTexture?t.mul(this.getTexture(n).a):t,i=i.clamp(.07,1)}else if(n===hb.ANISOTROPY)if(e.anisotropyMap&&!0===e.anisotropyMap.isTexture){const t=this.getTexture(n);i=Yg(Zb.x,Zb.y,Zb.y.negate(),Zb.x).mul(t.rg.mul(2).sub(Og(1)).normalize().mul(t.b))}else i=Zb;else if(n===hb.IRIDESCENCE_THICKNESS){const t=OM("1","float",e.iridescenceThicknessRange);if(e.iridescenceThicknessMap){const s=OM("0","float",e.iridescenceThicknessRange);i=t.sub(s).mul(this.getTexture(n).g).add(s)}else i=t}else if(n===hb.TRANSMISSION){const t=this.getFloat(n);i=e.transmissionMap?t.mul(this.getTexture(n).r):t}else if(n===hb.THICKNESS){const t=this.getFloat(n);i=e.thicknessMap?t.mul(this.getTexture(n).g):t}else if(n===hb.IOR)i=this.getFloat(n);else if(n===hb.LIGHT_MAP)i=this.getTexture(n).rgb.mul(this.getFloat("lightMapIntensity"));else if(n===hb.AO_MAP)i=this.getTexture(n).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else{const e=this.getNodeType(t);i=this.getCache(n,e)}return i}}hb.ALPHA_TEST="alphaTest",hb.COLOR="color",hb.OPACITY="opacity",hb.SHININESS="shininess",hb.SPECULAR="specular",hb.SPECULAR_STRENGTH="specularStrength",hb.SPECULAR_INTENSITY="specularIntensity",hb.SPECULAR_COLOR="specularColor",hb.REFLECTIVITY="reflectivity",hb.ROUGHNESS="roughness",hb.METALNESS="metalness",hb.NORMAL="normal",hb.CLEARCOAT="clearcoat",hb.CLEARCOAT_ROUGHNESS="clearcoatRoughness",hb.CLEARCOAT_NORMAL="clearcoatNormal",hb.EMISSIVE="emissive",hb.ROTATION="rotation",hb.SHEEN="sheen",hb.SHEEN_ROUGHNESS="sheenRoughness",hb.ANISOTROPY="anisotropy",hb.IRIDESCENCE="iridescence",hb.IRIDESCENCE_IOR="iridescenceIOR",hb.IRIDESCENCE_THICKNESS="iridescenceThickness",hb.IOR="ior",hb.TRANSMISSION="transmission",hb.THICKNESS="thickness",hb.ATTENUATION_DISTANCE="attenuationDistance",hb.ATTENUATION_COLOR="attenuationColor",hb.LINE_SCALE="scale",hb.LINE_DASH_SIZE="dashSize",hb.LINE_GAP_SIZE="gapSize",hb.LINE_WIDTH="linewidth",hb.LINE_DASH_OFFSET="dashOffset",hb.POINT_WIDTH="pointWidth",hb.DISPERSION="dispersion",hb.LIGHT_MAP="light",hb.AO_MAP="ao";const db=Sg(hb,hb.ALPHA_TEST),pb=Sg(hb,hb.COLOR),mb=Sg(hb,hb.SHININESS),fb=Sg(hb,hb.EMISSIVE),gb=Sg(hb,hb.OPACITY),vb=Sg(hb,hb.SPECULAR),yb=Sg(hb,hb.SPECULAR_INTENSITY),_b=Sg(hb,hb.SPECULAR_COLOR),xb=Sg(hb,hb.SPECULAR_STRENGTH),Mb=Sg(hb,hb.REFLECTIVITY),bb=Sg(hb,hb.ROUGHNESS),Tb=Sg(hb,hb.METALNESS),Sb=Sg(hb,hb.NORMAL).context({getUV:null}),wb=Sg(hb,hb.CLEARCOAT),Eb=Sg(hb,hb.CLEARCOAT_ROUGHNESS),Ab=Sg(hb,hb.CLEARCOAT_NORMAL).context({getUV:null}),Nb=Sg(hb,hb.ROTATION),Cb=Sg(hb,hb.SHEEN),Rb=Sg(hb,hb.SHEEN_ROUGHNESS),Ib=Sg(hb,hb.ANISOTROPY),Lb=Sg(hb,hb.IRIDESCENCE),Pb=Sg(hb,hb.IRIDESCENCE_IOR),Ub=Sg(hb,hb.IRIDESCENCE_THICKNESS),Db=Sg(hb,hb.TRANSMISSION),Ob=Sg(hb,hb.THICKNESS),zb=Sg(hb,hb.IOR),Vb=Sg(hb,hb.ATTENUATION_DISTANCE),Fb=Sg(hb,hb.ATTENUATION_COLOR),Bb=Sg(hb,hb.LINE_SCALE),kb=Sg(hb,hb.LINE_DASH_SIZE),Hb=Sg(hb,hb.LINE_GAP_SIZE),Gb=Sg(hb,hb.LINE_WIDTH),Wb=Sg(hb,hb.LINE_DASH_OFFSET),jb=Sg(hb,hb.POINT_WIDTH),Xb=Sg(hb,hb.DISPERSION),qb=Sg(hb,hb.LIGHT_MAP),Yb=Sg(hb,hb.AO_MAP),Zb=cv(new ei).onReference(function(t){return t.material}).onRenderUpdate(function({material:t}){this.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation))});class $b extends zf{static get type(){return"ModelViewProjectionNode"}constructor(t=null){super("vec4"),this.positionNode=t}setup(t){if("fragment"===t.shaderStage)return U_(t.context.mvp);const e=this.positionNode||nM,n=t.renderer.nodes.modelViewMatrix||Kx;return Lx.mul(n).mul(e)}}const Jb=Tg($b);class Kb extends Uf{static get type(){return"IndexNode"}constructor(t){super("uint"),this.scope=t,this.isInstanceIndexNode=!0}generate(t){const e=this.getNodeType(t),n=this.scope;let i,s;if(n===Kb.VERTEX)i=t.getVertexIndex();else if(n===Kb.INSTANCE)i=t.getInstanceIndex();else if(n===Kb.DRAW)i=t.getDrawIndex();else if(n===Kb.INVOCATION_LOCAL)i=t.getInvocationLocalIndex();else if(n===Kb.INVOCATION_SUBGROUP)i=t.getInvocationSubgroupIndex();else{if(n!==Kb.SUBGROUP)throw new Error("THREE.IndexNode: Unknown scope: "+n);i=t.getSubgroupIndex()}if("vertex"===t.shaderStage||"compute"===t.shaderStage)s=i;else{s=U_(this).build(t,e)}return s}}Kb.VERTEX="vertex",Kb.INSTANCE="instance",Kb.SUBGROUP="subgroup",Kb.INVOCATION_LOCAL="invocationLocal",Kb.INVOCATION_SUBGROUP="invocationSubgroup",Kb.DRAW="draw";const Qb=Sg(Kb,Kb.VERTEX),tT=Sg(Kb,Kb.INSTANCE),eT=Sg(Kb,Kb.SUBGROUP),nT=Sg(Kb,Kb.INVOCATION_SUBGROUP),iT=Sg(Kb,Kb.INVOCATION_LOCAL),sT=Sg(Kb,Kb.DRAW);class rT extends Uf{static get type(){return"InstanceNode"}constructor(t){super("void"),this.instanceMesh=t,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=Af.FRAME,this.buffer=null,this.bufferColor=null}setup(t){let e=this.instanceMatrixNode,n=this.instanceColorNode;const i=this.instanceMesh;if(null===e){const t=i.instanceMatrix;if(i.count<=1e3)e=CM(t.array,"mat4",Math.max(i.count,1)).element(tT);else{const n=new ym(t.array,16,1);this.buffer=n;const i=t.usage===In?ex:tx,s=[i(n,"vec4",16,0),i(n,"vec4",16,4),i(n,"vec4",16,8),i(n,"vec4",16,12)];e=$g(...s)}this.instanceMatrixNode=e}const s=i.instanceColor;if(s&&null===n){const t=new Zc(s.array,3),e=s.usage===In?ex:tx;this.bufferColor=t,n=Bg(e(t,"vec3",3,0)),this.instanceColorNode=n}const r=e.mul(nM).xyz;if(nM.assign(r),t.hasGeometryAttribute("normal")){const t=_M(dM,e);dM.assign(t)}null!==this.instanceColorNode&&dv("vec3","vInstanceColor").assign(this.instanceColorNode)}update(){this.instanceMesh.instanceMatrix.usage!==In&&null!=this.buffer&&this.instanceMesh.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMesh.instanceMatrix.version),this.instanceMesh.instanceColor&&this.instanceMesh.instanceColor.usage!==In&&null!=this.bufferColor&&this.instanceMesh.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceMesh.instanceColor.version)}}const aT=Tg(rT);class oT extends Uf{static get type(){return"BatchNode"}constructor(t){super("void"),this.batchMesh=t,this.batchingIdNode=null}setup(t){null===this.batchingIdNode&&(null===t.getDrawIndex()?this.batchingIdNode=tT:this.batchingIdNode=sT);const e=wg(([t])=>{const e=bx(Ax(this.batchMesh._indirectTexture),0),n=Pg(t).modInt(Pg(e)),i=Pg(t).div(Pg(e));return Ax(this.batchMesh._indirectTexture,zg(n,i)).x}).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]}),n=e(Pg(this.batchingIdNode)),i=this.batchMesh._matricesTexture,s=bx(Ax(i),0),r=Lg(n).mul(4).toInt().toVar(),a=r.modInt(s),o=r.div(Pg(s)),l=$g(Ax(i,zg(a,o)),Ax(i,zg(a.add(1),o)),Ax(i,zg(a.add(2),o)),Ax(i,zg(a.add(3),o))),c=this.batchMesh._colorsTexture;if(null!==c){const t=wg(([t])=>{const e=bx(Ax(c),0).x,n=t,i=n.modInt(e),s=n.div(e);return Ax(c,zg(i,s)).rgb}).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]}),e=t(n);dv("vec3","vBatchColor").assign(e)}const u=Zg(l);nM.assign(l.mul(nM));const h=dM.div(Bg(u[0].dot(u[0]),u[1].dot(u[1]),u[2].dot(u[2]))),d=u.mul(h).xyz;dM.assign(d),t.hasGeometryAttribute("tangent")&&kM.mulAssign(u)}}const lT=Tg(oT),cT=new WeakMap;class uT extends Uf{static get type(){return"SkinningNode"}constructor(t,e=!1){let n,i,s;super("void"),this.skinnedMesh=t,this.useReference=e,this.updateType=Af.OBJECT,this.skinIndexNode=_x("skinIndex","uvec4"),this.skinWeightNode=_x("skinWeight","vec4"),e?(n=OM("bindMatrix","mat4"),i=OM("bindMatrixInverse","mat4"),s=zM("skeleton.boneMatrices","mat4",t.skeleton.bones.length)):(n=cv(t.bindMatrix,"mat4"),i=cv(t.bindMatrixInverse,"mat4"),s=CM(t.skeleton.boneMatrices,"mat4",t.skeleton.bones.length)),this.bindMatrixNode=n,this.bindMatrixInverseNode=i,this.boneMatricesNode=s,this.previousBoneMatricesNode=null}getSkinnedPosition(t=this.boneMatricesNode,e=nM){const{skinIndexNode:n,skinWeightNode:i,bindMatrixNode:s,bindMatrixInverseNode:r}=this,a=t.element(n.x),o=t.element(n.y),l=t.element(n.z),c=t.element(n.w),u=s.mul(e),h=Xv(a.mul(i.x).mul(u),o.mul(i.y).mul(u),l.mul(i.z).mul(u),c.mul(i.w).mul(u));return r.mul(h).xyz}getSkinnedNormal(t=this.boneMatricesNode,e=dM){const{skinIndexNode:n,skinWeightNode:i,bindMatrixNode:s,bindMatrixInverseNode:r}=this,a=t.element(n.x),o=t.element(n.y),l=t.element(n.z),c=t.element(n.w);let u=Xv(i.x.mul(a),i.y.mul(o),i.z.mul(l),i.w.mul(c));return u=r.mul(u).mul(s),u.transformDirection(e).xyz}getPreviousSkinnedPosition(t){const e=t.object;return null===this.previousBoneMatricesNode&&(e.skeleton.previousBoneMatrices=new Float32Array(e.skeleton.boneMatrices),this.previousBoneMatricesNode=zM("skeleton.previousBoneMatrices","mat4",e.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,iM)}needsPreviousBoneMatrices(t){const e=t.renderer.getMRT();return e&&e.has("velocity")}setup(t){this.needsPreviousBoneMatrices(t)&&iM.assign(this.getPreviousSkinnedPosition(t));const e=this.getSkinnedPosition();if(nM.assign(e),t.hasGeometryAttribute("normal")){const e=this.getSkinnedNormal();dM.assign(e),t.hasGeometryAttribute("tangent")&&kM.assign(e)}}generate(t,e){if("void"!==e)return nM.build(t,e)}update(t){const e=(this.useReference?t.object:this.skinnedMesh).skeleton;cT.get(e)!==t.frameId&&(cT.set(e,t.frameId),null!==this.previousBoneMatricesNode&&e.previousBoneMatrices.set(e.boneMatrices),e.update())}}const hT=t=>xg(new uT(t)),dT=t=>xg(new uT(t,!0));class pT extends Uf{static get type(){return"LoopNode"}constructor(t=[]){super(),this.params=t}getVarName(t){return String.fromCharCode("i".charCodeAt()+t)}getProperties(t){const e=t.getNodeProperties(this);if(void 0!==e.stackNode)return e;const n={};for(let t=0,e=this.params.length-1;t<e;t++){const e=this.params[t],i=!0!==e.isNode&&e.name||this.getVarName(t),s=!0!==e.isNode&&e.type||"int";n[i]=dx(i,s)}const i=t.addStack();return e.returnsNode=this.params[this.params.length-1](n,i,t),e.stackNode=i,t.removeStack(),e}getNodeType(t){const{returnsNode:e}=this.getProperties(t);return e?e.getNodeType(t):"void"}setup(t){this.getProperties(t)}generate(t){const e=this.getProperties(t),n=this.params,i=e.stackNode;for(let e=0,i=n.length-1;e<i;e++){const i=n[e];let s=null,r=null,a=null,o=null,l=null,c=null;i.isNode?(o="int",a=this.getVarName(e),s="0",r=i.build(t,o),l="<"):(o=i.type||"int",a=i.name||this.getVarName(e),s=i.start,r=i.end,l=i.condition,c=i.update,"number"==typeof s?s=s.toString():s&&s.isNode&&(s=s.build(t,o)),"number"==typeof r?r=r.toString():r&&r.isNode&&(r=r.build(t,o)),void 0!==s&&void 0===r?(s+=" - 1",r="0",l=">="):void 0!==r&&void 0===s&&(s="0",l="<"),void 0===l&&(l=Number(s)>Number(r)?">=":"<"));const u={start:s,end:r},h=u.start,d=u.end;let p="",m="",f="";c||(c="int"===o||"uint"===o?l.includes("<")?"++":"--":l.includes("<")?"+= 1.":"-= 1."),p+=t.getVar(o,a)+" = "+h,m+=a+" "+l+" "+d,f+=a+" "+c;const g=`for ( ${p}; ${m}; ${f} )`;t.addFlowCode((0===e?"\n":"")+t.tab+g+" {\n\n").addFlowTab()}const s=i.build(t,"void"),r=e.returnsNode?e.returnsNode.build(t):"";t.removeFlowTab().addFlowCode("\n"+t.tab+s);for(let e=0,n=this.params.length-1;e<n;e++)t.addFlowCode((0===e?"":t.tab)+"}\n\n").removeFlowTab();return t.addFlowTab(),r}}const mT=(...t)=>xg(new pT(bg(t,"int"))).append(),fT=()=>dx("continue").append(),gT=()=>dx("break").append(),vT=(...t)=>(console.warn("TSL.LoopNode: loop() has been renamed to Loop()."),mT(...t)),yT=new WeakMap,_T=new wi,xT=wg(({bufferMap:t,influence:e,stride:n,width:i,depth:s,offset:r})=>{const a=Pg(Qb).mul(n).add(r),o=a.div(i),l=a.sub(o.mul(i));return Ax(t,zg(l,o)).depth(s).mul(e)});class MT extends Uf{static get type(){return"MorphNode"}constructor(t){super("void"),this.mesh=t,this.morphBaseInfluence=cv(1),this.updateType=Af.OBJECT}setup(t){const{geometry:e}=t,n=void 0!==e.morphAttributes.position,i=e.hasAttribute("normal")&&void 0!==e.morphAttributes.normal,s=e.morphAttributes.position||e.morphAttributes.normal||e.morphAttributes.color,r=void 0!==s?s.length:0,{texture:a,stride:o,size:l}=function(t){const e=void 0!==t.morphAttributes.position,n=void 0!==t.morphAttributes.normal,i=void 0!==t.morphAttributes.color,s=t.morphAttributes.position||t.morphAttributes.normal||t.morphAttributes.color,r=void 0!==s?s.length:0;let a=yT.get(t);if(void 0===a||a.count!==r){void 0!==a&&a.texture.dispose();const o=t.morphAttributes.position||[],l=t.morphAttributes.normal||[],c=t.morphAttributes.color||[];let u=0;!0===e&&(u=1),!0===n&&(u=2),!0===i&&(u=3);let h=t.attributes.position.count*u,d=1;const p=4096;h>p&&(d=Math.ceil(h/p),h=p);const m=new Float32Array(h*d*4*r),f=new Ni(m,h,d,r);f.type=Lt,f.needsUpdate=!0;const g=4*u;for(let y=0;y<r;y++){const _=o[y],x=l[y],M=c[y],b=h*d*4*y;for(let T=0;T<_.count;T++){const S=T*g;!0===e&&(_T.fromBufferAttribute(_,T),m[b+S+0]=_T.x,m[b+S+1]=_T.y,m[b+S+2]=_T.z,m[b+S+3]=0),!0===n&&(_T.fromBufferAttribute(x,T),m[b+S+4]=_T.x,m[b+S+5]=_T.y,m[b+S+6]=_T.z,m[b+S+7]=0),!0===i&&(_T.fromBufferAttribute(M,T),m[b+S+8]=_T.x,m[b+S+9]=_T.y,m[b+S+10]=_T.z,m[b+S+11]=4===M.itemSize?_T.w:1)}}function v(){f.dispose(),yT.delete(t),t.removeEventListener("dispose",v)}a={count:r,texture:f,stride:u,size:new ei(h,d)},yT.set(t,a),t.addEventListener("dispose",v)}return a}(e);!0===n&&nM.mulAssign(this.morphBaseInfluence),!0===i&&dM.mulAssign(this.morphBaseInfluence);const c=Pg(l.width);mT(r,({i:t})=>{const e=Lg(0).toVar();this.mesh.count>1&&null!==this.mesh.morphTexture&&void 0!==this.mesh.morphTexture?e.assign(Ax(this.mesh.morphTexture,zg(Pg(t).add(1),Pg(tT))).r):e.assign(OM("morphTargetInfluences","float").element(t).toVar()),!0===n&&nM.addAssign(xT({bufferMap:a,influence:e,stride:o,width:c,depth:t,offset:Pg(0)})),!0===i&&dM.addAssign(xT({bufferMap:a,influence:e,stride:o,width:c,depth:t,offset:Pg(1)}))})}update(){const t=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?t.value=1:t.value=1-this.mesh.morphTargetInfluences.reduce((t,e)=>t+e,0)}}const bT=Tg(MT),TT=(t,e)=>{for(const n of e)if(n.isAnalyticLightNode&&n.light.id===t)return n;return null},ST=new WeakMap;class wT extends Uf{static get type(){return"LightsNode"}constructor(t=[]){super("vec3"),this.totalDiffuseNode=Bg().toVar("totalDiffuse"),this.totalSpecularNode=Bg().toVar("totalSpecular"),this.outgoingLightNode=Bg().toVar("outgoingLight"),this._lights=t,this._lightNodes=null,this._lightNodesHash=null,this.global=!0}getHash(t){if(null===this._lightNodesHash){null===this._lightNodes&&this.setupLightsNode(t);const e=[];for(const t of this._lightNodes)e.push(t.getHash());this._lightNodesHash="lights-"+e.join(",")}return this._lightNodesHash}analyze(t){const e=t.getDataFromNode(this);for(const n of e.nodes)n.build(t)}setupLightsNode(t){const e=[],n=this._lightNodes,i=(t=>t.sort((t,e)=>t.id-e.id))(this._lights),s=t.renderer.nodes.library;for(const t of i)if(t.isNode)e.push(xg(t));else{let i=null;if(null!==n&&(i=TT(t.id,n)),null===i){const n=s.getLightNodeClass(t.constructor);if(null===n){console.warn(`LightsNode.setupNodeLights: Light node not found for ${t.constructor.name}`);continue}let i=null;ST.has(t)?i=ST.get(t):(i=new n(t),ST.set(t,i)),e.push(i)}}this._lightNodes=e}setup(t){null===this._lightNodes&&this.setupLightsNode(t);const e=t.context,n=e.lightingModel;let i=this.outgoingLightNode;if(n){const{_lightNodes:s,totalDiffuseNode:r,totalSpecularNode:a}=this;e.outgoingLight=i;const o=t.addStack();t.getDataFromNode(this).nodes=o.nodes,n.start(e,o,t);for(const e of s)e.build(t);n.indirect(e,o,t);const{backdrop:l,backdropAlpha:c}=e,{directDiffuse:u,directSpecular:h,indirectDiffuse:d,indirectSpecular:p}=e.reflectedLight;let m=u.add(d);null!==l&&(m=Bg(null!==c?c.mix(m,l):l),e.material.transparent=!0),r.assign(m),a.assign(h.add(p)),i.assign(r.add(a)),n.finish(e,o,t),i=i.bypass(t.removeStack())}return i}setLights(t){return this._lights=t,this._lightNodes=null,this._lightNodesHash=null,this}getLights(){return this._lights}}const ET=Tg(wT);class AT extends Uf{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}generate(){console.warn("Abstract function.")}}class NT extends AT{static get type(){return"AONode"}constructor(t=null){super(),this.aoNode=t}setup(t){t.context.ambientOcclusion.mulAssign(this.aoNode)}}class CT extends N_{static get type(){return"LightingContextNode"}constructor(t,e=null,n=null,i=null){super(t),this.lightingModel=e,this.backdropNode=n,this.backdropAlphaNode=i,this._value=null}getContext(){const{backdropNode:t,backdropAlphaNode:e}=this,n={directDiffuse:Bg().toVar("directDiffuse"),directSpecular:Bg().toVar("directSpecular"),indirectDiffuse:Bg().toVar("indirectDiffuse"),indirectSpecular:Bg().toVar("indirectSpecular")};return{radiance:Bg().toVar("radiance"),irradiance:Bg().toVar("irradiance"),iblIrradiance:Bg().toVar("iblIrradiance"),ambientOcclusion:Lg(1).toVar("ambientOcclusion"),reflectedLight:n,backdrop:t,backdropAlpha:e}}setup(t){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||t.context.lightingModel,super.setup(t)}}const RT=Tg(CT);class IT extends AT{static get type(){return"IrradianceNode"}constructor(t){super(),this.node=t}setup(t){t.context.irradiance.addAssign(this.node)}}let LT,PT;class UT extends Uf{static get type(){return"ScreenNode"}constructor(t){super(),this.scope=t,this.isViewportNode=!0}getNodeType(){return this.scope===UT.VIEWPORT?"vec4":"vec2"}getUpdateType(){let t=Af.NONE;return this.scope!==UT.SIZE&&this.scope!==UT.VIEWPORT||(t=Af.RENDER),this.updateType=t,t}update({renderer:t}){const e=t.getRenderTarget();this.scope===UT.VIEWPORT?null!==e?PT.copy(e.viewport):(t.getViewport(PT),PT.multiplyScalar(t.getPixelRatio())):null!==e?(LT.width=e.width,LT.height=e.height):t.getDrawingBufferSize(LT)}setup(){const t=this.scope;let e=null;return e=t===UT.SIZE?cv(LT||(LT=new ei)):t===UT.VIEWPORT?cv(PT||(PT=new wi)):Og(zT.div(OT)),e}generate(t){if(this.scope===UT.COORDINATE){let e=t.getFragCoord();if(t.isFlipY()){const n=t.getNodeProperties(OT).outputNode.build(t);e=`${t.getType("vec2")}( ${e}.x, ${n}.y - ${e}.y )`}return e}return super.generate(t)}}UT.COORDINATE="coordinate",UT.VIEWPORT="viewport",UT.SIZE="size",UT.UV="uv";const DT=Sg(UT,UT.UV),OT=Sg(UT,UT.SIZE),zT=Sg(UT,UT.COORDINATE),VT=Sg(UT,UT.VIEWPORT),FT=VT.zw,BT=zT.sub(VT.xy),kT=BT.div(FT),HT=wg(()=>(console.warn('TSL.ViewportNode: "viewportResolution" is deprecated. Use "screenSize" instead.'),OT),"vec2").once()(),GT=wg(()=>(console.warn('TSL.ViewportNode: "viewportTopLeft" is deprecated. Use "screenUV" instead.'),DT),"vec2").once()(),WT=wg(()=>(console.warn('TSL.ViewportNode: "viewportBottomLeft" is deprecated. Use "screenUV.flipY()" instead.'),DT.flipY()),"vec2").once()(),jT=new ei;class XT extends wx{static get type(){return"ViewportTextureNode"}constructor(t=DT,e=null,n=null){null===n&&((n=new ju).minFilter=St),super(n,t,e),this.generateMipmaps=!1,this.isOutputTextureNode=!0,this.updateBeforeType=Af.FRAME}updateBefore(t){const e=t.renderer;e.getDrawingBufferSize(jT);const n=this.value;n.image.width===jT.width&&n.image.height===jT.height||(n.image.width=jT.width,n.image.height=jT.height,n.needsUpdate=!0);const i=n.generateMipmaps;n.generateMipmaps=this.generateMipmaps,e.copyFramebufferToTexture(n),n.generateMipmaps=i}clone(){const t=new this.constructor(this.uvNode,this.levelNode,this.value);return t.generateMipmaps=this.generateMipmaps,t}}const qT=Tg(XT),YT=Tg(XT,null,null,{generateMipmaps:!0});let ZT=null;class $T extends XT{static get type(){return"ViewportDepthTextureNode"}constructor(t=DT,e=null){null===ZT&&(ZT=new no),super(t,e,ZT)}}const JT=Tg($T);class KT extends Uf{static get type(){return"ViewportDepthNode"}constructor(t,e=null){super("float"),this.scope=t,this.valueNode=e,this.isViewportDepthNode=!0}generate(t){const{scope:e}=this;return e===KT.DEPTH_BASE?t.getFragDepth():super.generate(t)}setup({camera:t}){const{scope:e}=this,n=this.valueNode;let i=null;if(e===KT.DEPTH_BASE)null!==n&&(i=iS().assign(n));else if(e===KT.DEPTH)i=t.isPerspectiveCamera?eS(aM.z,Cx,Rx):QT(aM.z,Cx,Rx);else if(e===KT.LINEAR_DEPTH)if(null!==n)if(t.isPerspectiveCamera){const t=nS(n,Cx,Rx);i=QT(t,Cx,Rx)}else i=n;else i=QT(aM.z,Cx,Rx);return i}}KT.DEPTH_BASE="depthBase",KT.DEPTH="depth",KT.LINEAR_DEPTH="linearDepth";const QT=(t,e,n)=>t.add(e).div(e.sub(n)),tS=(t,e,n)=>e.sub(n).mul(t).sub(e),eS=(t,e,n)=>e.add(t).mul(n).div(n.sub(e).mul(t)),nS=(t,e,n)=>e.mul(n).div(n.sub(e).mul(t).sub(n)),iS=Tg(KT,KT.DEPTH_BASE),sS=Sg(KT,KT.DEPTH),rS=Tg(KT,KT.LINEAR_DEPTH),aS=rS(JT());sS.assign=t=>iS(t);class oS extends Uf{static get type(){return"ClippingNode"}constructor(t=oS.DEFAULT){super(),this.scope=t}setup(t){super.setup(t);const e=t.clippingContext,{localClipIntersection:n,localClippingCount:i,globalClippingCount:s}=e,r=s+i,a=n?r-i:r;return this.scope===oS.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(e.planes,r,a):this.setupDefault(e.planes,r,a)}setupAlphaToCoverage(t,e,n){return wg(()=>{const i=LM(t),s=hv("float","distanceToPlane"),r=hv("float","distanceToGradient"),a=hv("float","clipOpacity");let o;if(a.assign(1),mT(n,({i:t})=>{o=i.element(t),s.assign(aM.dot(o.xyz).negate().add(o.w)),r.assign(s.fwidth().div(2)),a.mulAssign(x_(r.negate(),r,s)),a.equal(0).discard()}),n<e){const t=hv("float","unionclipOpacity");t.assign(1),mT({start:n,end:e},({i:e})=>{o=i.element(e),s.assign(aM.dot(o.xyz).negate().add(o.w)),r.assign(s.fwidth().div(2)),t.mulAssign(x_(r.negate(),r,s).oneMinus())}),a.mulAssign(t.oneMinus())}pv.a.mulAssign(a),pv.a.equal(0).discard()})()}setupDefault(t,e,n){return wg(()=>{const i=LM(t);let s;if(mT(n,({i:t})=>{s=i.element(t),aM.dot(s.xyz).greaterThan(s.w).discard()}),n<e){const t=hv("bool","clipped");t.assign(!0),mT({start:n,end:e},({i:e})=>{s=i.element(e),t.assign(aM.dot(s.xyz).greaterThan(s.w).and(t))}),t.discard()}})()}}oS.ALPHA_TO_COVERAGE="alphaToCoverage",oS.DEFAULT="default";class lS extends sr{static get type(){return"NodeMaterial"}constructor(){super(),this.isNodeMaterial=!0,this.type=this.constructor.type,this.forceSinglePass=!1,this.fog=!0,this.lights=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.positionNode=null,this.depthNode=null,this.shadowNode=null,this.shadowPositionNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null}customProgramCacheKey(){return this.type+_f(this)}build(t){this.setup(t)}setupObserver(t){return new mf(t)}setup(t){let e;t.context.setupNormal=()=>this.setupNormal(t),t.addStack(),t.stack.outputNode=this.vertexNode||this.setupPosition(t),t.addFlow("vertex",t.removeStack()),t.addStack();const n=this.setupClipping(t);if(!0===this.depthWrite&&this.setupDepth(t),null===this.fragmentNode){this.setupDiffuseColor(t),this.setupVariants(t);const i=this.setupLighting(t);null!==n&&t.stack.add(n);const s=Wg(i,pv.a).max(0);e=this.setupOutput(t,s),Iv.assign(e),null!==this.outputNode&&(e=this.outputNode);if(null!==t.renderer.getRenderTarget()){const n=t.renderer.getMRT(),i=this.mrtNode;null!==n?(e=n,null!==i&&(e=n.merge(i))):null!==i&&(e=i)}}else{let n=this.fragmentNode;!0!==n.isOutputStructNode&&(n=Wg(n)),e=this.setupOutput(t,n)}t.stack.outputNode=e,t.addFlow("fragment",t.removeStack()),t.monitor=this.setupObserver(t)}setupClipping(t){if(null===t.clippingContext)return null;const{globalClippingCount:e,localClippingCount:n}=t.clippingContext;let i=null;if(e||n){const e=t.renderer.samples;this.alphaToCoverage&&e>1?i=xg(new oS(oS.ALPHA_TO_COVERAGE)):t.stack.add(xg(new oS))}return i}setupDepth(t){const{renderer:e}=t;let n=this.depthNode;if(null===n){const t="getMRT"in e&&e.getMRT();if(t&&t.has("depth"))n=t.get("depth");else if(!0===e.logarithmicDepthBuffer){n=Jb().w.add(1).log2().mul(Ix).mul(.5)}}null!==n&&sS.assign(n).append()}setupPosition(t){const{object:e}=t,n=e.geometry;if(t.addStack(),(n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color)&&bT(e).append(),!0===e.isSkinnedMesh&&dT(e).append(),this.displacementMap){const t=FM("displacementMap","texture"),e=FM("displacementScale","float"),n=FM("displacementBias","float");nM.addAssign(dM.normalize().mul(t.x.mul(e).add(n)))}e.isBatchedMesh&&lT(e).append(),e.instanceMatrix&&!0===e.instanceMatrix.isInstancedBufferAttribute&&aT(e).append(),null!==this.positionNode&&nM.assign(this.positionNode);const i=Jb();return t.context.vertex=t.removeStack(),t.context.mvp=i,i}setupDiffuseColor({object:t,geometry:e}){let n=this.colorNode?Wg(this.colorNode):pb;if(!0===this.vertexColors&&e.hasAttribute("color")&&(n=Wg(n.xyz.mul(_x("color","vec3")),n.a)),t.instanceColor){n=dv("vec3","vInstanceColor").mul(n)}if(t.isBatchedMesh&&t._colorsTexture){n=dv("vec3","vBatchColor").mul(n)}pv.assign(n);const i=this.opacityNode?Lg(this.opacityNode):gb;if(pv.a.assign(pv.a.mul(i)),null!==this.alphaTestNode||this.alphaTest>0){const t=null!==this.alphaTestNode?Lg(this.alphaTestNode):db;pv.a.lessThanEqual(t).discard()}!1===this.transparent&&1===this.blending&&!1===this.alphaToCoverage&&pv.a.assign(1)}setupVariants(){}setupOutgoingLight(){return!0===this.lights?Bg(0):pv.rgb}setupNormal(){return this.normalNode?Bg(this.normalNode):Sb}setupEnvironment(){let t=null;return this.envNode?t=this.envNode:this.envMap&&(t=this.envMap.isCubeTexture?FM("envMap","cubeTexture"):FM("envMap","texture")),t}setupLightMap(t){let e=null;return t.material.lightMap&&(e=new IT(qb)),e}setupLights(t){const e=[],n=this.setupEnvironment(t);n&&n.isLightingNode&&e.push(n);const i=this.setupLightMap(t);if(i&&i.isLightingNode&&e.push(i),null!==this.aoNode||t.material.aoMap){const t=null!==this.aoNode?this.aoNode:Yb;e.push(new NT(t))}let s=this.lightsNode||t.lightsNode;return e.length>0&&(s=ET([...s.getLights(),...e])),s}setupLightingModel(){}setupLighting(t){const{material:e}=t,{backdropNode:n,backdropAlphaNode:i,emissiveNode:s}=this,r=!0===this.lights||null!==this.lightsNode?this.setupLights(t):null;let a=this.setupOutgoingLight(t);if(r&&r.getScope().getLights().length>0){const e=this.setupLightingModel(t);a=RT(r,e,n,i)}else null!==n&&(a=Bg(null!==i?g_(a,n,i):n));return(s&&!0===s.isNode||e.emissive&&!0===e.emissive.isColor)&&(mv.assign(Bg(s||fb)),a=a.add(mv)),a}setupOutput(t,e){if(!0===this.fog){const n=t.fogNode;n&&(e=Wg(n.mix(e.rgb,n.colorNode),e.a))}return e}setDefaultValues(t){for(const e in t){const n=t[e];void 0===this[e]&&(this[e]=n,n&&n.clone&&(this[e]=n.clone()))}const e=Object.getOwnPropertyDescriptors(t.constructor.prototype);for(const t in e)void 0===Object.getOwnPropertyDescriptor(this.constructor.prototype,t)&&void 0!==e[t].get&&Object.defineProperty(this.constructor.prototype,t,e[t])}toJSON(t){const e=void 0===t||"string"==typeof t;e&&(t={textures:{},images:{},nodes:{}});const n=sr.prototype.toJSON.call(this,t),i=xf(this);n.inputNodes={};for(const{property:e,childNode:s}of i)n.inputNodes[e]=s.toJSON(t).uuid;function s(t){const e=[];for(const n in t){const i=t[n];delete i.metadata,e.push(i)}return e}if(e){const e=s(t.textures),i=s(t.images),r=s(t.nodes);e.length>0&&(n.textures=e),i.length>0&&(n.images=i),r.length>0&&(n.nodes=r)}return n}copy(t){return this.lightsNode=t.lightsNode,this.envNode=t.envNode,this.colorNode=t.colorNode,this.normalNode=t.normalNode,this.opacityNode=t.opacityNode,this.backdropNode=t.backdropNode,this.backdropAlphaNode=t.backdropAlphaNode,this.alphaTestNode=t.alphaTestNode,this.positionNode=t.positionNode,this.depthNode=t.depthNode,this.shadowNode=t.shadowNode,this.shadowPositionNode=t.shadowPositionNode,this.outputNode=t.outputNode,this.mrtNode=t.mrtNode,this.fragmentNode=t.fragmentNode,this.vertexNode=t.vertexNode,super.copy(t)}}const cS=new zu;class uS extends lS{static get type(){return"InstancedPointsNodeMaterial"}constructor(t={}){super(),this.lights=!1,this.useAlphaToCoverage=!0,this.useColor=t.vertexColors,this.pointWidth=1,this.pointColorNode=null,this.pointWidthNode=null,this.setDefaultValues(cS),this.setValues(t)}setup(t){this.setupShaders(t),super.setup(t)}setupShaders({renderer:t}){const e=this.alphaToCoverage,n=this.useColor;this.vertexNode=wg(()=>{const t=_x("instancePosition").xyz,e=Wg(Kx.mul(Wg(t,1))),n=VT.z.div(VT.w),i=Lx.mul(e),s=eM.xy.toVar();return s.mulAssign(this.pointWidthNode?this.pointWidthNode:jb),s.assign(s.div(VT.z)),s.y.assign(s.y.mul(n)),s.assign(s.mul(i.w)),i.addAssign(Wg(s,0,0)),i})(),this.fragmentNode=wg(()=>{const i=Lg(1).toVar(),s=f_(xx().mul(2).sub(1));if(e&&t.samples>1){const t=Lg(s.fwidth()).toVar();i.assign(x_(t.oneMinus(),t.add(1),s).oneMinus())}else s.greaterThan(1).discard();let r;if(this.pointColorNode)r=this.pointColorNode;else if(n){r=_x("instanceColor").mul(pb)}else r=pb;return i.mulAssign(gb),Wg(r,i)})()}get alphaToCoverage(){return this.useAlphaToCoverage}set alphaToCoverage(t){this.useAlphaToCoverage!==t&&(this.useAlphaToCoverage=t,this.needsUpdate=!0)}}const hS=new Tu;class dS extends lS{static get type(){return"LineBasicNodeMaterial"}constructor(t){super(),this.isLineBasicNodeMaterial=!0,this.lights=!1,this.setDefaultValues(hS),this.setValues(t)}}const pS=new Nd;class mS extends lS{static get type(){return"LineDashedNodeMaterial"}constructor(t){super(),this.isLineDashedNodeMaterial=!0,this.lights=!1,this.setDefaultValues(pS),this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(t)}setupVariants(){const t=this.offsetNode,e=this.dashScaleNode?Lg(this.dashScaleNode):Bb,n=this.dashSizeNode?Lg(this.dashSizeNode):kb,i=this.dashSizeNode?Lg(this.dashGapNode):Hb;Lv.assign(n),Pv.assign(i);const s=U_(_x("lineDistance").mul(e));(t?s.add(t):s).mod(Lv.add(Pv)).greaterThan(Lv).discard()}}const fS=new Nd;class gS extends lS{static get type(){return"Line2NodeMaterial"}constructor(t={}){super(),this.lights=!1,this.setDefaultValues(fS),this.useAlphaToCoverage=!0,this.useColor=t.vertexColors,this.useDash=t.dashed,this.useWorldUnits=!1,this.dashOffset=0,this.lineWidth=1,this.lineColorNode=null,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(t)}setup(t){this.setupShaders(t),super.setup(t)}setupShaders({renderer:t}){const e=this.alphaToCoverage,n=this.useColor,i=this.dashed,s=this.worldUnits,r=wg(({start:t,end:e})=>{const n=Lx.element(2).element(2),i=Lx.element(3).element(2).mul(-.5).div(n).sub(t.z).div(e.z.sub(t.z));return Wg(g_(t.xyz,e.xyz,i),e.w)}).setLayout({name:"trimSegment",type:"vec4",inputs:[{name:"start",type:"vec4"},{name:"end",type:"vec4"}]});this.vertexNode=wg(()=>{const t=_x("instanceStart"),e=_x("instanceEnd"),n=Wg(Kx.mul(Wg(t,1))).toVar("start"),a=Wg(Kx.mul(Wg(e,1))).toVar("end");s&&(dv("vec3","worldStart").assign(n.xyz),dv("vec3","worldEnd").assign(a.xyz));const o=VT.z.div(VT.w),l=Lx.element(2).element(3).equal(-1);Cg(l,()=>{Cg(n.z.lessThan(0).and(a.z.greaterThan(0)),()=>{a.assign(r({start:n,end:a}))}).ElseIf(a.z.lessThan(0).and(n.z.greaterThanEqual(0)),()=>{n.assign(r({start:a,end:n}))})});const c=Lx.mul(n),u=Lx.mul(a),h=c.xyz.div(c.w),d=u.xyz.div(u.w),p=d.xy.sub(h.xy).toVar();p.x.assign(p.x.mul(o)),p.assign(p.normalize());const m=Wg().toVar();if(s){const t=a.xyz.sub(n.xyz).normalize(),e=g_(n.xyz,a.xyz,.5).normalize(),s=t.cross(e).normalize(),r=t.cross(s),o=dv("vec4","worldPos");o.assign(eM.y.lessThan(.5).select(n,a));const l=Gb.mul(.5);o.addAssign(Wg(eM.x.lessThan(0).select(s.mul(l),s.mul(l).negate()),0)),i||(o.addAssign(Wg(eM.y.lessThan(.5).select(t.mul(l).negate(),t.mul(l)),0)),o.addAssign(Wg(r.mul(l),0)),Cg(eM.y.greaterThan(1).or(eM.y.lessThan(0)),()=>{o.subAssign(Wg(r.mul(2).mul(l),0))})),m.assign(Lx.mul(o));const c=Bg().toVar();c.assign(eM.y.lessThan(.5).select(h,d)),m.z.assign(c.z.mul(m.w))}else{const t=Og(p.y,p.x.negate()).toVar("offset");p.x.assign(p.x.div(o)),t.x.assign(t.x.div(o)),t.assign(eM.x.lessThan(0).select(t.negate(),t)),Cg(eM.y.lessThan(0),()=>{t.assign(t.sub(p))}).ElseIf(eM.y.greaterThan(1),()=>{t.assign(t.add(p))}),t.assign(t.mul(Gb)),t.assign(t.div(VT.w)),m.assign(eM.y.lessThan(.5).select(c,u)),t.assign(t.mul(m.w)),m.assign(m.add(Wg(t,0,0)))}return m})();const a=wg(({p1:t,p2:e,p3:n,p4:i})=>{const s=t.sub(n),r=i.sub(n),a=e.sub(t),o=s.dot(r),l=r.dot(a),c=s.dot(a),u=r.dot(r),h=a.dot(a).mul(u).sub(l.mul(l)),d=o.mul(l).sub(c.mul(u)).div(h).clamp(),p=o.add(l.mul(d)).div(u).clamp();return Og(d,p)});this.fragmentNode=wg(()=>{const r=xx();if(i){const t=this.offsetNode?Lg(this.offsetNodeNode):Wb,e=this.dashScaleNode?Lg(this.dashScaleNode):Bb,n=this.dashSizeNode?Lg(this.dashSizeNode):kb,i=this.dashSizeNode?Lg(this.dashGapNode):Hb;Lv.assign(n),Pv.assign(i);const s=_x("instanceDistanceStart"),a=_x("instanceDistanceEnd"),o=eM.y.lessThan(.5).select(e.mul(s),Bb.mul(a)),l=U_(o.add(Wb)),c=t?l.add(t):l;r.y.lessThan(-1).or(r.y.greaterThan(1)).discard(),c.mod(Lv.add(Pv)).greaterThan(Lv).discard()}const o=Lg(1).toVar("alpha");if(s){const n=dv("vec3","worldStart"),s=dv("vec3","worldEnd"),r=dv("vec4","worldPos").xyz.normalize().mul(1e5),l=s.sub(n),c=a({p1:n,p2:s,p3:Bg(0,0,0),p4:r}),u=n.add(l.mul(c.x)),h=r.mul(c.y),d=u.sub(h).length().div(Gb);if(!i)if(e&&t.samples>1){const t=d.fwidth();o.assign(x_(t.negate().add(.5),t.add(.5),d).oneMinus())}else d.greaterThan(.5).discard()}else if(e&&t.samples>1){const t=r.x,e=r.y.greaterThan(0).select(r.y.sub(1),r.y.add(1)),n=t.mul(t).add(e.mul(e)),i=Lg(n.fwidth()).toVar("dlen");Cg(r.y.abs().greaterThan(1),()=>{o.assign(x_(i.oneMinus(),i.add(1),n).oneMinus())})}else Cg(r.y.abs().greaterThan(1),()=>{const t=r.x,e=r.y.greaterThan(0).select(r.y.sub(1),r.y.add(1));t.mul(t).add(e.mul(e)).greaterThan(1).discard()});let l;if(this.lineColorNode)l=this.lineColorNode;else if(n){const t=_x("instanceColorStart"),e=_x("instanceColorEnd");l=eM.y.lessThan(.5).select(t,e).mul(pb)}else l=pb;return Wg(l,o)})()}get worldUnits(){return this.useWorldUnits}set worldUnits(t){this.useWorldUnits!==t&&(this.useWorldUnits=t,this.needsUpdate=!0)}get dashed(){return this.useDash}set dashed(t){this.useDash!==t&&(this.useDash=t,this.needsUpdate=!0)}get alphaToCoverage(){return this.useAlphaToCoverage}set alphaToCoverage(t){this.useAlphaToCoverage!==t&&(this.useAlphaToCoverage=t,this.needsUpdate=!0)}}const vS=t=>xg(t).mul(.5).add(.5),yS=t=>xg(t).mul(2).sub(1),_S=new wd;class xS extends lS{static get type(){return"MeshNormalNodeMaterial"}constructor(t){super(),this.lights=!1,this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(_S),this.setValues(t)}setupDiffuseColor(){const t=this.opacityNode?Lg(this.opacityNode):gb;pv.assign(Wg(vS(gM),t))}}class MS extends zf{static get type(){return"EquirectUVNode"}constructor(t=rM){super("vec2"),this.dirNode=t}setup(){const t=this.dirNode,e=t.z.atan2(t.x).mul(1/(2*Math.PI)).add(.5),n=t.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return Og(e,n)}}const bS=Tg(MS);class TS extends oa{constructor(t=1,e={}){super(t,e),this.isCubeRenderTarget=!0}fromEquirectangularTexture(t,e){const n=e.minFilter,i=e.generateMipmaps;e.generateMipmaps=!0,this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;const s=new Wr(5,5,5),r=bS(rM),a=new lS;a.colorNode=Ex(e,r,0),a.side=1,a.blending=0;const o=new Hr(s,a),l=new hc;l.add(o),e.minFilter===St&&(e.minFilter=Mt);const c=new ra(1,10,this),u=t.getMRT();return t.setMRT(null),c.update(t,l),t.setMRT(u),e.minFilter=n,e.currentGenerateMipmaps=i,o.geometry.dispose(),o.material.dispose(),this}}const SS=new WeakMap;class wS extends zf{static get type(){return"CubeMapNode"}constructor(t){super("vec3"),this.envNode=t,this._cubeTexture=null,this._cubeTextureNode=AM();const e=new aa;e.isRenderTargetTexture=!0,this._defaultTexture=e,this.updateBeforeType=Af.RENDER}updateBefore(t){const{renderer:e,material:n}=t,i=this.envNode;if(i.isTextureNode||i.isMaterialReferenceNode){const t=i.isTextureNode?i.value:n[i.property];if(t&&t.isTexture){const n=t.mapping;if(n===ut||n===ht){if(SS.has(t)){const e=SS.get(t);AS(e,t.mapping),this._cubeTexture=e}else{const n=t.image;if(function(t){return null!=t&&t.height>0}(n)){const i=new TS(n.height);i.fromEquirectangularTexture(e,t),AS(i.texture,t.mapping),this._cubeTexture=i.texture,SS.set(t,i.texture),t.addEventListener("dispose",ES)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(t){return this.updateBefore(t),this._cubeTextureNode}}function ES(t){const e=t.target;e.removeEventListener("dispose",ES);const n=SS.get(e);void 0!==n&&(SS.delete(e),n.dispose())}function AS(t,e){e===ut?t.mapping=lt:e===ht&&(t.mapping=ct)}const NS=Tg(wS);class CS extends AT{static get type(){return"BasicEnvironmentNode"}constructor(t=null){super(),this.envNode=t}setup(t){t.context.environment=NS(this.envNode)}}class RS extends AT{static get type(){return"BasicLightMapNode"}constructor(t=null){super(),this.lightMapNode=t}setup(t){const e=Lg(1/Math.PI);t.context.irradianceLightMap=this.lightMapNode.mul(e)}}class IS{start(){}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}class LS extends IS{constructor(){super()}indirect(t,e,n){const i=t.ambientOcclusion,s=t.reflectedLight,r=n.context.irradianceLightMap;s.indirectDiffuse.assign(Wg(0)),r?s.indirectDiffuse.addAssign(r):s.indirectDiffuse.addAssign(Wg(1,1,1,0)),s.indirectDiffuse.mulAssign(i),s.indirectDiffuse.mulAssign(pv.rgb)}finish(t,e,n){const i=n.material,s=t.outgoingLight,r=n.context.environment;if(r)switch(i.combine){case 0:s.rgb.assign(g_(s.rgb,s.rgb.mul(r.rgb),xb.mul(Mb)));break;case 1:s.rgb.assign(g_(s.rgb,r.rgb,xb.mul(Mb)));break;case 2:s.rgb.addAssign(r.rgb.mul(xb.mul(Mb)));break;default:console.warn("THREE.BasicLightingModel: Unsupported .combine value:",i.combine)}}}const PS=new rr;class US extends lS{static get type(){return"MeshBasicNodeMaterial"}constructor(t){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(PS),this.setValues(t)}setupNormal(){return mM}setupEnvironment(t){const e=super.setupEnvironment(t);return e?new CS(e):null}setupLightMap(t){let e=null;return t.material.lightMap&&(e=new RS(qb)),e}setupOutgoingLight(){return pv.rgb}setupLightingModel(){return new LS}}const DS=wg(({f0:t,f90:e,dotVH:n})=>{const i=n.mul(-5.55473).sub(6.98316).mul(n).exp2();return t.mul(i.oneMinus()).add(e.mul(i))}),OS=wg(t=>t.diffuseColor.mul(1/Math.PI)),zS=wg(({dotNH:t})=>Rv.mul(Lg(.5)).add(1).mul(Lg(1/Math.PI)).mul(t.pow(Rv))),VS=wg(({lightDirection:t})=>{const e=t.add(oM).normalize(),n=gM.dot(e).clamp(),i=oM.dot(e).clamp(),s=DS({f0:Nv,f90:1,dotVH:i}),r=Lg(.25),a=zS({dotNH:n});return s.mul(r).mul(a)});class FS extends LS{constructor(t=!0){super(),this.specular=t}direct({lightDirection:t,lightColor:e,reflectedLight:n}){const i=gM.dot(t).clamp().mul(e);n.directDiffuse.addAssign(i.mul(OS({diffuseColor:pv.rgb}))),!0===this.specular&&n.directSpecular.addAssign(i.mul(VS({lightDirection:t})).mul(xb))}indirect({ambientOcclusion:t,irradiance:e,reflectedLight:n}){n.indirectDiffuse.addAssign(e.mul(OS({diffuseColor:pv}))),n.indirectDiffuse.mulAssign(t)}}const BS=new Ed;class kS extends lS{static get type(){return"MeshLambertNodeMaterial"}constructor(t){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(BS),this.setValues(t)}setupEnvironment(t){const e=super.setupEnvironment(t);return e?new CS(e):null}setupLightingModel(){return new FS(!1)}}const HS=new Td;class GS extends lS{static get type(){return"MeshPhongNodeMaterial"}constructor(t){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(HS),this.setValues(t)}setupEnvironment(t){const e=super.setupEnvironment(t);return e?new CS(e):null}setupLightingModel(){return new FS}setupVariants(){const t=(this.shininessNode?Lg(this.shininessNode):mb).max(1e-4);Rv.assign(t);const e=this.specularNode||vb;Nv.assign(e)}copy(t){return this.shininessNode=t.shininessNode,this.specularNode=t.specularNode,super.copy(t)}}const WS=wg(()=>{const t=mM.dFdx().abs().max(mM.dFdy().abs());return t.x.max(t.y).max(t.z)}),jS=wg(t=>{const{roughness:e}=t,n=WS();let i=e.max(.0525);return i=i.add(n),i=i.min(1),i}),XS=wg(({alpha:t,dotNL:e,dotNV:n})=>{const i=t.pow2(),s=e.mul(i.add(i.oneMinus().mul(n.pow2())).sqrt()),r=n.mul(i.add(i.oneMinus().mul(e.pow2())).sqrt());return Zv(.5,s.add(r).max(fy))}).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),qS=wg(({alphaT:t,alphaB:e,dotTV:n,dotBV:i,dotTL:s,dotBL:r,dotNV:a,dotNL:o})=>{const l=o.mul(Bg(t.mul(n),e.mul(i),a).length()),c=a.mul(Bg(t.mul(s),e.mul(r),o).length());return Zv(.5,l.add(c)).saturate()}).setLayout({name:"V_GGX_SmithCorrelated_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotTV",type:"float",qualifier:"in"},{name:"dotBV",type:"float",qualifier:"in"},{name:"dotTL",type:"float",qualifier:"in"},{name:"dotBL",type:"float",qualifier:"in"},{name:"dotNV",type:"float",qualifier:"in"},{name:"dotNL",type:"float",qualifier:"in"}]}),YS=wg(({alpha:t,dotNH:e})=>{const n=t.pow2(),i=e.pow2().mul(n.oneMinus()).oneMinus();return n.div(i.pow2()).mul(1/Math.PI)}).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),ZS=Lg(1/Math.PI),$S=wg(({alphaT:t,alphaB:e,dotNH:n,dotTH:i,dotBH:s})=>{const r=t.mul(e),a=Bg(e.mul(i),t.mul(s),r.mul(n)),o=a.dot(a),l=r.div(o);return ZS.mul(r.mul(l.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"}]}),JS=wg(t=>{const{lightDirection:e,f0:n,f90:i,roughness:s,f:r,USE_IRIDESCENCE:a,USE_ANISOTROPY:o}=t,l=t.normalView||gM,c=s.pow2(),u=e.add(oM).normalize(),h=l.dot(e).clamp(),d=l.dot(oM).clamp(),p=l.dot(u).clamp(),m=oM.dot(u).clamp();let f,g,v=DS({f0:n,f90:i,dotVH:m});if(vg(a)&&(v=Mv.mix(v,r)),vg(o)){const t=Ev.dot(e),n=Ev.dot(oM),i=Ev.dot(u),s=Av.dot(e),r=Av.dot(oM),a=Av.dot(u);f=qS({alphaT:Sv,alphaB:c,dotTV:n,dotBV:r,dotTL:t,dotBL:s,dotNV:d,dotNL:h}),g=$S({alphaT:Sv,alphaB:c,dotNH:p,dotTH:i,dotBH:a})}else f=XS({alpha:c,dotNL:h,dotNV:d}),g=YS({alpha:c,dotNH:p});return v.mul(f).mul(g)}),KS=wg(({roughness:t,dotNV:e})=>{const n=Wg(-1,-.0275,-.572,.022),i=Wg(1,.0425,1.04,-.04),s=t.mul(n).add(i),r=s.x.mul(s.x).min(e.mul(-9.28).exp2()).mul(s.x).add(s.y);return Og(-1.04,1.04).mul(r).add(s.zw)}).setLayout({name:"DFGApprox",type:"vec2",inputs:[{name:"roughness",type:"float"},{name:"dotNV",type:"vec3"}]}),QS=wg(t=>{const{dotNV:e,specularColor:n,specularF90:i,roughness:s}=t,r=KS({dotNV:e,roughness:s});return n.mul(r.x).add(i.mul(r.y))}),tw=wg(({f:t,f90:e,dotVH:n})=>{const i=n.oneMinus().saturate(),s=i.mul(i),r=i.mul(s,s).clamp(0,.9999);return t.sub(Bg(e).mul(r)).div(r.oneMinus())}).setLayout({name:"Schlick_to_F0",type:"vec3",inputs:[{name:"f",type:"vec3"},{name:"f90",type:"float"},{name:"dotVH",type:"float"}]}),ew=wg(({roughness:t,dotNH:e})=>{const n=t.pow2(),i=Lg(1).div(n),s=e.pow2().oneMinus().max(.0078125);return Lg(2).add(i).mul(s.pow(i.mul(.5))).div(2*Math.PI)}).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),nw=wg(({dotNV:t,dotNL:e})=>Lg(1).div(Lg(4).mul(e.add(t).sub(e.mul(t))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),iw=wg(({lightDirection:t})=>{const e=t.add(oM).normalize(),n=gM.dot(t).clamp(),i=gM.dot(oM).clamp(),s=gM.dot(e).clamp(),r=ew({roughness:xv,dotNH:s}),a=nw({dotNV:i,dotNL:n});return _v.mul(r).mul(a)}),sw=wg(({N:t,V:e,roughness:n})=>{const i=t.dot(e).saturate(),s=Og(n,i.oneMinus().sqrt());return s.assign(s.mul(.984375).add(.0078125)),s}).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]}),rw=wg(({f:t})=>{const e=t.length();return e_(e.mul(e).add(t.z).div(e.add(1)),0)}).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),aw=wg(({v1:t,v2:e})=>{const n=t.dot(e),i=n.abs().toVar(),s=i.mul(.0145206).add(.4965155).mul(i).add(.8543985).toVar(),r=i.add(4.1616724).mul(i).add(3.417594).toVar(),a=s.div(r),o=n.greaterThan(0).select(a,e_(n.mul(n).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(a));return t.cross(e).mul(o)}).setLayout({name:"LTC_EdgeVectorFormFactor",type:"vec3",inputs:[{name:"v1",type:"vec3"},{name:"v2",type:"vec3"}]}),ow=wg(({N:t,V:e,P:n,mInv:i,p0:s,p1:r,p2:a,p3:o})=>{const l=r.sub(s).toVar(),c=o.sub(s).toVar(),u=l.cross(c),h=Bg().toVar();return Cg(u.dot(n.sub(s)).greaterThanEqual(0),()=>{const l=e.sub(t.mul(e.dot(t))).normalize(),c=t.cross(l).negate(),u=i.mul(Zg(l,c,t).transpose()).toVar(),d=u.mul(s.sub(n)).normalize().toVar(),p=u.mul(r.sub(n)).normalize().toVar(),m=u.mul(a.sub(n)).normalize().toVar(),f=u.mul(o.sub(n)).normalize().toVar(),g=Bg(0).toVar();g.addAssign(aw({v1:d,v2:p})),g.addAssign(aw({v1:p,v2:m})),g.addAssign(aw({v1:m,v2:f})),g.addAssign(aw({v1:f,v2:d})),h.assign(Bg(rw({f:g})))}),h}).setLayout({name:"LTC_Evaluate",type:"vec3",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"P",type:"vec3"},{name:"mInv",type:"mat3"},{name:"p0",type:"vec3"},{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"}]}),lw=1/6,cw=t=>Yv(lw,Yv(t,Yv(t,t.negate().add(3)).sub(3)).add(1)),uw=t=>Yv(lw,Yv(t,Yv(t,Yv(3,t).sub(6))).add(4)),hw=t=>Yv(lw,Yv(t,Yv(t,Yv(-3,t).add(3)).add(3)).add(1)),dw=t=>Yv(lw,c_(t,3)),pw=t=>cw(t).add(uw(t)),mw=t=>hw(t).add(dw(t)),fw=t=>Xv(-1,uw(t).div(cw(t).add(uw(t)))),gw=t=>Xv(1,dw(t).div(hw(t).add(dw(t)))),vw=(t,e,n)=>{const i=t.uvNode,s=Yv(i,e.zw).add(.5),r=Ry(s),a=Py(s),o=pw(a.x),l=mw(a.x),c=fw(a.x),u=gw(a.x),h=fw(a.y),d=gw(a.y),p=Og(r.x.add(c),r.y.add(h)).sub(.5).mul(e.xy),m=Og(r.x.add(u),r.y.add(h)).sub(.5).mul(e.xy),f=Og(r.x.add(c),r.y.add(d)).sub(.5).mul(e.xy),g=Og(r.x.add(u),r.y.add(d)).sub(.5).mul(e.xy),v=pw(a.y).mul(Xv(o.mul(t.uv(p).level(n)),l.mul(t.uv(m).level(n)))),y=mw(a.y).mul(Xv(o.mul(t.uv(f).level(n)),l.mul(t.uv(g).level(n))));return v.add(y)},yw=wg(([t,e=Lg(3)])=>{const n=Og(t.size(Pg(e))),i=Og(t.size(Pg(e.add(1)))),s=Zv(1,n),r=Zv(1,i),a=vw(t,Wg(s,n),Ry(e)),o=vw(t,Wg(r,i),Iy(e));return Py(e).mix(a,o)}),_w=wg(([t,e,n,i,s])=>{const r=Bg(__(e.negate(),Ly(t),Zv(1,i))),a=Bg(Hy(s[0].xyz),Hy(s[1].xyz),Hy(s[2].xyz));return Ly(r).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"}]}),xw=wg(([t,e])=>t.mul(v_(e.mul(2).sub(2),0,1))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),Mw=YT(),bw=wg(([t,e,n])=>{const i=Mw.uv(t),s=Ay(Lg(OT.x)).mul(xw(e,n));return yw(i,s)}),Tw=wg(([t,e,n])=>(Cg(n.notEqual(0),()=>{const i=Ey(e).negate().div(n);return Sy(i.negate().mul(t))}),Bg(1))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),Sw=wg(([t,e,n,i,s,r,a,o,l,c,u,h,d,p,m])=>{let f,g;if(m){f=Wg().toVar(),g=Bg().toVar();const s=u.sub(1).mul(m.mul(.025)),r=Bg(u.sub(s),u,u.add(s));mT({start:0,end:3},({i:s})=>{const u=r.element(s),m=_w(t,e,h,u,o),v=a.add(m),y=c.mul(l.mul(Wg(v,1))),_=Og(y.xy.div(y.w)).toVar();_.addAssign(1),_.divAssign(2),_.assign(Og(_.x,_.y.oneMinus()));const x=bw(_,n,u);f.element(s).assign(x.element(s)),f.a.addAssign(x.a),g.element(s).assign(i.element(s).mul(Tw(Hy(m),d,p).element(s)))}),f.a.divAssign(3)}else{const s=_w(t,e,h,u,o),r=a.add(s),m=c.mul(l.mul(Wg(r,1))),v=Og(m.xy.div(m.w)).toVar();v.addAssign(1),v.divAssign(2),v.assign(Og(v.x,v.y.oneMinus())),f=bw(v,n,u),g=i.mul(Tw(Hy(s),d,p))}const v=g.rgb.mul(f.rgb),y=t.dot(e).clamp(),_=Bg(QS({dotNV:y,specularColor:s,specularF90:r,roughness:n})),x=g.r.add(g.g,g.b).div(3);return Wg(_.oneMinus().mul(v),f.a.oneMinus().mul(x).oneMinus())}),ww=Zg(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),Ew=(t,e)=>t.sub(e).div(t.add(e)).pow2(),Aw=(t,e)=>{const n=t.mul(2*Math.PI*1e-9),i=Bg(54856e-17,44201e-17,52481e-17),s=Bg(1681e3,1795300,2208400),r=Bg(43278e5,93046e5,66121e5),a=Lg(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(n.mul(2239900).add(e.x).cos()).mul(n.pow2().mul(-45282e5).exp());let o=i.mul(r.mul(2*Math.PI).sqrt()).mul(s.mul(n).add(e).cos()).mul(n.pow2().negate().mul(r).exp());o=Bg(o.x.add(a),o.y,o.z).div(1.0685e-7);return ww.mul(o)},Nw=wg(({outsideIOR:t,eta2:e,cosTheta1:n,thinFilmThickness:i,baseF0:s})=>{const r=g_(t,e,x_(0,.03,i)),a=t.div(r).pow2().mul(Lg(1).sub(n.pow2())),o=Lg(1).sub(a).sqrt(),l=Ew(r,t),c=DS({f0:l,f90:1,dotVH:n}),u=c.oneMinus(),h=r.lessThan(t).select(Math.PI,0),d=Lg(Math.PI).sub(h),p=(t=>{const e=t.sqrt();return Bg(1).add(e).div(Bg(1).sub(e))})(s.clamp(0,.9999)),m=Ew(p,r.toVec3()),f=DS({f0:m,f90:1,dotVH:o}),g=Bg(p.x.lessThan(r).select(Math.PI,0),p.y.lessThan(r).select(Math.PI,0),p.z.lessThan(r).select(Math.PI,0)),v=r.mul(i,o,2),y=Bg(d).add(g),_=c.mul(f).clamp(1e-5,.9999),x=_.sqrt(),M=u.pow2().mul(f).div(Bg(1).sub(_));let b=c.add(M),T=M.sub(u);for(let t=1;t<=2;++t){T=T.mul(x);const e=Aw(Lg(t).mul(v),Lg(t).mul(y)).mul(2);b=b.add(T.mul(e))}return b.max(Bg(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"}]}),Cw=wg(({normal:t,viewDir:e,roughness:n})=>{const i=t.dot(e).saturate(),s=n.pow2(),r=E_(n.lessThan(.25),Lg(-339.2).mul(s).add(Lg(161.4).mul(n)).sub(25.9),Lg(-8.48).mul(s).add(Lg(14.3).mul(n)).sub(9.95)),a=E_(n.lessThan(.25),Lg(44).mul(s).sub(Lg(23.7).mul(n)).add(3.26),Lg(1.97).mul(s).sub(Lg(3.27).mul(n)).add(.72));return E_(n.lessThan(.25),0,Lg(.1).mul(n).sub(.025)).add(r.mul(i).add(a).exp()).mul(1/Math.PI).saturate()}),Rw=Bg(.04),Iw=Lg(1);class Lw extends IS{constructor(t=!1,e=!1,n=!1,i=!1,s=!1,r=!1){super(),this.clearcoat=t,this.sheen=e,this.iridescence=n,this.anisotropy=i,this.transmission=s,this.dispersion=r,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0=null}start(t){if(!0===this.clearcoat&&(this.clearcoatRadiance=Bg().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=Bg().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=Bg().toVar("clearcoatSpecularIndirect")),!0===this.sheen&&(this.sheenSpecularDirect=Bg().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=Bg().toVar("sheenSpecularIndirect")),!0===this.iridescence){const t=gM.dot(oM).clamp();this.iridescenceFresnel=Nw({outsideIOR:Lg(1),eta2:bv,cosTheta1:t,thinFilmThickness:Tv,baseF0:Nv}),this.iridescenceF0=tw({f:this.iridescenceFresnel,f90:1,dotVH:t})}if(!0===this.transmission){const e=sM,n=zx.sub(sM).normalize(),i=vM;t.backdrop=Sw(i,n,fv,pv,Nv,Cv,e,Xx,Ux,Lx,Dv,zv,Fv,Vv,this.dispersion?Bv:null),t.backdropAlpha=Ov,pv.a.mulAssign(g_(1,t.backdrop.a,Ov))}}computeMultiscattering(t,e,n){const i=gM.dot(oM).clamp(),s=KS({roughness:fv,dotNV:i}),r=(this.iridescenceF0?Mv.mix(Nv,this.iridescenceF0):Nv).mul(s.x).add(n.mul(s.y)),a=s.x.add(s.y).oneMinus(),o=Nv.add(Nv.oneMinus().mul(.047619)),l=r.mul(o).div(a.mul(o).oneMinus());t.addAssign(r),e.addAssign(l.mul(a))}direct({lightDirection:t,lightColor:e,reflectedLight:n}){const i=gM.dot(t).clamp().mul(e);if(!0===this.sheen&&this.sheenSpecularDirect.addAssign(i.mul(iw({lightDirection:t}))),!0===this.clearcoat){const n=yM.dot(t).clamp().mul(e);this.clearcoatSpecularDirect.addAssign(n.mul(JS({lightDirection:t,f0:Rw,f90:Iw,roughness:yv,normalView:yM})))}n.directDiffuse.addAssign(i.mul(OS({diffuseColor:pv.rgb}))),n.directSpecular.addAssign(i.mul(JS({lightDirection:t,f0:Nv,f90:1,roughness:fv,iridescence:this.iridescence,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:t,lightPosition:e,halfWidth:n,halfHeight:i,reflectedLight:s,ltc_1:r,ltc_2:a}){const o=e.add(n).sub(i),l=e.sub(n).sub(i),c=e.sub(n).add(i),u=e.add(n).add(i),h=gM,d=oM,p=aM.toVar(),m=sw({N:h,V:d,roughness:fv}),f=r.uv(m).toVar(),g=a.uv(m).toVar(),v=Zg(Bg(f.x,0,f.y),Bg(0,1,0),Bg(f.z,0,f.w)).toVar(),y=Nv.mul(g.x).add(Nv.oneMinus().mul(g.y)).toVar();s.directSpecular.addAssign(t.mul(y).mul(ow({N:h,V:d,P:p,mInv:v,p0:o,p1:l,p2:c,p3:u}))),s.directDiffuse.addAssign(t.mul(pv).mul(ow({N:h,V:d,P:p,mInv:Zg(1,0,0,0,1,0,0,0,1),p0:o,p1:l,p2:c,p3:u})))}indirect(t,e,n){this.indirectDiffuse(t,e,n),this.indirectSpecular(t,e,n),this.ambientOcclusion(t,e,n)}indirectDiffuse({irradiance:t,reflectedLight:e}){e.indirectDiffuse.addAssign(t.mul(OS({diffuseColor:pv})))}indirectSpecular({radiance:t,iblIrradiance:e,reflectedLight:n}){if(!0===this.sheen&&this.sheenSpecularIndirect.addAssign(e.mul(_v,Cw({normal:gM,viewDir:oM,roughness:xv}))),!0===this.clearcoat){const t=yM.dot(oM).clamp(),e=QS({dotNV:t,specularColor:Rw,specularF90:Iw,roughness:yv});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(e))}const i=Bg().toVar("singleScattering"),s=Bg().toVar("multiScattering"),r=e.mul(1/Math.PI);this.computeMultiscattering(i,s,Cv);const a=i.add(s),o=pv.mul(a.r.max(a.g).max(a.b).oneMinus());n.indirectSpecular.addAssign(t.mul(i)),n.indirectSpecular.addAssign(s.mul(r)),n.indirectDiffuse.addAssign(o.mul(r))}ambientOcclusion({ambientOcclusion:t,reflectedLight:e}){const n=gM.dot(oM).clamp().add(t),i=fv.mul(-16).oneMinus().negate().exp2(),s=t.sub(n.pow(i).oneMinus()).clamp();!0===this.clearcoat&&this.clearcoatSpecularIndirect.mulAssign(t),!0===this.sheen&&this.sheenSpecularIndirect.mulAssign(t),e.indirectDiffuse.mulAssign(t),e.indirectSpecular.mulAssign(s)}finish(t){const{outgoingLight:e}=t;if(!0===this.clearcoat){const t=yM.dot(oM).clamp(),n=DS({dotVH:t,f0:Rw,f90:Iw}),i=e.mul(vv.mul(n).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(vv));e.assign(i)}if(!0===this.sheen){const t=_v.r.max(_v.g).max(_v.b).mul(.157).oneMinus(),n=e.mul(t).add(this.sheenSpecularDirect,this.sheenSpecularIndirect);e.assign(n)}}}const Pw=Lg(1),Uw=Lg(-2),Dw=Lg(.8),Ow=Lg(-1),zw=Lg(.4),Vw=Lg(2),Fw=Lg(.305),Bw=Lg(3),kw=Lg(.21),Hw=Lg(4),Gw=Lg(4),Ww=Lg(16),jw=wg(([t])=>{const e=Bg(By(t)).toVar(),n=Lg(-1).toVar();return Cg(e.x.greaterThan(e.z),()=>{Cg(e.x.greaterThan(e.y),()=>{n.assign(E_(t.x.greaterThan(0),0,3))}).Else(()=>{n.assign(E_(t.y.greaterThan(0),1,4))})}).Else(()=>{Cg(e.z.greaterThan(e.y),()=>{n.assign(E_(t.z.greaterThan(0),2,5))}).Else(()=>{n.assign(E_(t.y.greaterThan(0),1,4))})}),n}).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),Xw=wg(([t,e])=>{const n=Og().toVar();return Cg(e.equal(0),()=>{n.assign(Og(t.z,t.y).div(By(t.x)))}).ElseIf(e.equal(1),()=>{n.assign(Og(t.x.negate(),t.z.negate()).div(By(t.y)))}).ElseIf(e.equal(2),()=>{n.assign(Og(t.x.negate(),t.y).div(By(t.z)))}).ElseIf(e.equal(3),()=>{n.assign(Og(t.z.negate(),t.y).div(By(t.x)))}).ElseIf(e.equal(4),()=>{n.assign(Og(t.x.negate(),t.z).div(By(t.y)))}).Else(()=>{n.assign(Og(t.x,t.y).div(By(t.z)))}),Yv(.5,n.add(1))}).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),qw=wg(([t])=>{const e=Lg(0).toVar();return Cg(t.greaterThanEqual(Dw),()=>{e.assign(Pw.sub(t).mul(Ow.sub(Uw)).div(Pw.sub(Dw)).add(Uw))}).ElseIf(t.greaterThanEqual(zw),()=>{e.assign(Dw.sub(t).mul(Vw.sub(Ow)).div(Dw.sub(zw)).add(Ow))}).ElseIf(t.greaterThanEqual(Fw),()=>{e.assign(zw.sub(t).mul(Bw.sub(Vw)).div(zw.sub(Fw)).add(Vw))}).ElseIf(t.greaterThanEqual(kw),()=>{e.assign(Fw.sub(t).mul(Hw.sub(Bw)).div(Fw.sub(kw)).add(Bw))}).Else(()=>{e.assign(Lg(-2).mul(Ay(Yv(1.16,t))))}),e}).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),Yw=wg(([t,e])=>{const n=t.toVar();n.assign(Yv(2,n).sub(1));const i=Bg(n,1).toVar();return Cg(e.equal(0),()=>{i.assign(i.zyx)}).ElseIf(e.equal(1),()=>{i.assign(i.xzy),i.xz.mulAssign(-1)}).ElseIf(e.equal(2),()=>{i.x.mulAssign(-1)}).ElseIf(e.equal(3),()=>{i.assign(i.zyx),i.xz.mulAssign(-1)}).ElseIf(e.equal(4),()=>{i.assign(i.xzy),i.xy.mulAssign(-1)}).ElseIf(e.equal(5),()=>{i.z.mulAssign(-1)}),i}).setLayout({name:"getDirection",type:"vec3",inputs:[{name:"uv",type:"vec2"},{name:"face",type:"float"}]}),Zw=wg(([t,e,n,i,s,r])=>{const a=Lg(n),o=Bg(e),l=v_(qw(a),Uw,r),c=Py(l),u=Ry(l),h=Bg($w(t,o,u,i,s,r)).toVar();return Cg(c.notEqual(0),()=>{const e=Bg($w(t,o,u.add(1),i,s,r)).toVar();h.assign(g_(h,e,c))}),h}),$w=wg(([t,e,n,i,s,r])=>{const a=Lg(n).toVar(),o=Bg(e),l=Lg(jw(o)).toVar(),c=Lg(e_(Gw.sub(a),0)).toVar();a.assign(e_(a,Gw));const u=Lg(wy(a)).toVar(),h=Og(Xw(o,l).mul(u.sub(2)).add(1)).toVar();return Cg(l.greaterThan(2),()=>{h.y.addAssign(u),l.subAssign(3)}),h.x.addAssign(l.mul(u)),h.x.addAssign(c.mul(Yv(3,Ww))),h.y.addAssign(Yv(4,wy(r).sub(u))),h.x.mulAssign(i),h.y.mulAssign(s),t.uv(h).grad(Og(),Og())}),Jw=wg(({envMap:t,mipInt:e,outputDirection:n,theta:i,axis:s,CUBEUV_TEXEL_WIDTH:r,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:o})=>{const l=Dy(i),c=n.mul(l).add(s.cross(n).mul(Uy(i))).add(s.mul(s.dot(n).mul(l.oneMinus())));return $w(t,c,e,r,a,o)}),Kw=wg(({n:t,latitudinal:e,poleAxis:n,outputDirection:i,weights:s,samples:r,dTheta:a,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:c,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:h})=>{const d=Bg(E_(e,n,l_(n,i))).toVar();Cg(_y(d.equals(Bg(0))),()=>{d.assign(Bg(i.z,0,i.x.negate()))}),d.assign(Ly(d));const p=Bg().toVar();return p.addAssign(s.element(Pg(0)).mul(Jw({theta:0,axis:d,outputDirection:i,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:c,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:h}))),mT({start:Pg(1),end:t},({i:t})=>{Cg(t.greaterThanEqual(r),()=>{gT()});const e=Lg(a.mul(Lg(t))).toVar();p.addAssign(s.element(t).mul(Jw({theta:e.mul(-1),axis:d,outputDirection:i,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:c,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:h}))),p.addAssign(s.element(t).mul(Jw({theta:e,axis:d,outputDirection:i,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:c,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:h})))}),Wg(p,1)});let Qw=null;const tE=new WeakMap;function eE(t){let e=tE.get(t);if((void 0!==e?e.pmremVersion:-1)!==t.pmremVersion){const n=t.image;if(t.isCubeTexture){if(!function(t){if(null==t)return!1;let e=0;const n=6;for(let i=0;i<n;i++)void 0!==t[i]&&e++;return e===n}(n))return null;e=Qw.fromCubemap(t,e)}else{if(!function(t){return null!=t&&t.height>0}(n))return null;e=Qw.fromEquirectangular(t,e)}e.pmremVersion=t.pmremVersion,tE.set(t,e)}return e.texture}class nE extends zf{static get type(){return"PMREMNode"}constructor(t,e=null,n=null){super("vec3"),this._value=t,this._pmrem=null,this.uvNode=e,this.levelNode=n,this._generator=null;const i=new Si;i.isRenderTargetTexture=!0,this._texture=Ex(i),this._width=cv(0),this._height=cv(0),this._maxMip=cv(0),this.updateBeforeType=Af.RENDER}set value(t){this._value=t,this._pmrem=null}get value(){return this._value}updateFromTexture(t){const e=function(t){const e=Math.log2(t)-2,n=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,e),112)),texelHeight:n,maxMip:e}}(t.image.height);this._texture.value=t,this._width.value=e.texelWidth,this._height.value=e.texelHeight,this._maxMip.value=e.maxMip}updateBefore(){let t=this._pmrem;const e=t?t.pmremVersion:-1,n=this._value;e!==n.pmremVersion&&(t=!0===n.isPMREMTexture?n:eE(n),null!==t&&(this._pmrem=t,this.updateFromTexture(t)))}setup(t){null===Qw&&(Qw=t.createPMREMGenerator()),this.updateBefore(t);let e=this.uvNode;null===e&&t.context.getUV&&(e=t.context.getUV(this));const n=this.value;t.renderer.coordinateSystem===kn&&!0!==n.isPMREMTexture&&!0===n.isRenderTargetTexture&&(e=Bg(e.x.negate(),e.yz));let i=this.levelNode;return null===i&&t.context.getTextureLevel&&(i=t.context.getTextureLevel(this)),Zw(this._texture,e,i,this._width,this._height,this._maxMip)}}const iE=Tg(nE),sE=new WeakMap;class rE extends AT{static get type(){return"EnvironmentNode"}constructor(t=null){super(),this.envNode=t}setup(t){const{material:e}=t;let n=this.envNode;if(n.isTextureNode||n.isMaterialReferenceNode){const t=n.isTextureNode?n.value:e[n.property];let i=sE.get(t);void 0===i&&(i=iE(t),sE.set(t,i)),n=i}const i=e.envMap?OM("envMapIntensity","float",t.material):OM("environmentIntensity","float",t.scene),s=!0===e.useAnisotropy||e.anisotropy>0?nb:gM,r=n.context(aE(fv,s)).mul(i),a=n.context(oE(vM)).mul(Math.PI).mul(i),o=rx(r),l=rx(a);t.context.radiance.addAssign(o),t.context.iblIrradiance.addAssign(l);const c=t.context.lightingModel.clearcoatRadiance;if(c){const t=n.context(aE(yv,yM)).mul(i),e=rx(t);c.addAssign(e)}}}const aE=(t,e)=>{let n=null;return{getUV:()=>(null===n&&(n=oM.negate().reflect(e),n=t.mul(t).mix(n,e).normalize(),n=n.transformDirection(Ux)),n),getTextureLevel:()=>t}},oE=t=>({getUV:()=>t,getTextureLevel:()=>Lg(1)}),lE=new Md;class cE extends lS{static get type(){return"MeshStandardNodeMaterial"}constructor(t){super(),this.isMeshStandardNodeMaterial=!0,this.lights=!0,this.emissiveNode=null,this.metalnessNode=null,this.roughnessNode=null,this.setDefaultValues(lE),this.setValues(t)}setupEnvironment(t){let e=super.setupEnvironment(t);return null===e&&t.environmentNode&&(e=t.environmentNode),e?new rE(e):null}setupLightingModel(){return new Lw}setupSpecular(){const t=g_(Bg(.04),pv.rgb,gv);Nv.assign(t),Cv.assign(1)}setupVariants(){const t=this.metalnessNode?Lg(this.metalnessNode):Tb;gv.assign(t);let e=this.roughnessNode?Lg(this.roughnessNode):bb;e=jS({roughness:e}),fv.assign(e),this.setupSpecular(),pv.assign(Wg(pv.rgb.mul(t.oneMinus()),pv.a))}copy(t){return this.emissiveNode=t.emissiveNode,this.metalnessNode=t.metalnessNode,this.roughnessNode=t.roughnessNode,super.copy(t)}}const uE=new bd;class hE extends cE{static get type(){return"MeshPhysicalNodeMaterial"}constructor(t){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(uE),this.setValues(t)}get useClearcoat(){return this.clearcoat>0||null!==this.clearcoatNode}get useIridescence(){return this.iridescence>0||null!==this.iridescenceNode}get useSheen(){return this.sheen>0||null!==this.sheenNode}get useAnisotropy(){return this.anisotropy>0||null!==this.anisotropyNode}get useTransmission(){return this.transmission>0||null!==this.transmissionNode}get useDispersion(){return this.dispersion>0||null!==this.dispersionNode}setupSpecular(){const t=this.iorNode?Lg(this.iorNode):zb;Dv.assign(t),Nv.assign(g_(t_(u_(Dv.sub(1).div(Dv.add(1))).mul(_b),Bg(1)).mul(yb),pv.rgb,gv)),Cv.assign(g_(yb,1,gv))}setupLightingModel(){return new Lw(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(t){if(super.setupVariants(t),this.useClearcoat){const t=this.clearcoatNode?Lg(this.clearcoatNode):wb,e=this.clearcoatRoughnessNode?Lg(this.clearcoatRoughnessNode):Eb;vv.assign(t),yv.assign(jS({roughness:e}))}if(this.useSheen){const t=this.sheenNode?Bg(this.sheenNode):Cb,e=this.sheenRoughnessNode?Lg(this.sheenRoughnessNode):Rb;_v.assign(t),xv.assign(e)}if(this.useIridescence){const t=this.iridescenceNode?Lg(this.iridescenceNode):Lb,e=this.iridescenceIORNode?Lg(this.iridescenceIORNode):Pb,n=this.iridescenceThicknessNode?Lg(this.iridescenceThicknessNode):Ub;Mv.assign(t),bv.assign(e),Tv.assign(n)}if(this.useAnisotropy){const t=(this.anisotropyNode?Og(this.anisotropyNode):Ib).toVar();wv.assign(t.length()),Cg(wv.equal(0),()=>{t.assign(Og(1,0))}).Else(()=>{t.divAssign(Og(wv)),wv.assign(wv.saturate())}),Sv.assign(wv.pow2().mix(fv.pow2(),1)),Ev.assign(QM[0].mul(t.x).add(QM[1].mul(t.y))),Av.assign(QM[1].mul(t.x).sub(QM[0].mul(t.y)))}if(this.useTransmission){const t=this.transmissionNode?Lg(this.transmissionNode):Db,e=this.thicknessNode?Lg(this.thicknessNode):Ob,n=this.attenuationDistanceNode?Lg(this.attenuationDistanceNode):Vb,i=this.attenuationColorNode?Bg(this.attenuationColorNode):Fb;if(Ov.assign(t),zv.assign(e),Vv.assign(n),Fv.assign(i),this.useDispersion){const t=this.dispersionNode?Lg(this.dispersionNode):Xb;Bv.assign(t)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?Bg(this.clearcoatNormalNode):Ab}setup(t){t.context.setupClearcoatNormal=()=>this.setupClearcoatNormal(t),super.setup(t)}copy(t){return this.clearcoatNode=t.clearcoatNode,this.clearcoatRoughnessNode=t.clearcoatRoughnessNode,this.clearcoatNormalNode=t.clearcoatNormalNode,this.sheenNode=t.sheenNode,this.sheenRoughnessNode=t.sheenRoughnessNode,this.iridescenceNode=t.iridescenceNode,this.iridescenceIORNode=t.iridescenceIORNode,this.iridescenceThicknessNode=t.iridescenceThicknessNode,this.specularIntensityNode=t.specularIntensityNode,this.specularColorNode=t.specularColorNode,this.transmissionNode=t.transmissionNode,this.thicknessNode=t.thicknessNode,this.attenuationDistanceNode=t.attenuationDistanceNode,this.attenuationColorNode=t.attenuationColorNode,this.dispersionNode=t.dispersionNode,this.anisotropyNode=t.anisotropyNode,super.copy(t)}}class dE extends Lw{constructor(t,e,n,i){super(t,e,n),this.useSSS=i}direct({lightDirection:t,lightColor:e,reflectedLight:n},i,s){if(!0===this.useSSS){const i=s.material,{thicknessColorNode:r,thicknessDistortionNode:a,thicknessAmbientNode:o,thicknessAttenuationNode:l,thicknessPowerNode:c,thicknessScaleNode:u}=i,h=t.add(gM.mul(a)).normalize(),d=Lg(oM.dot(h.negate()).saturate().pow(c).mul(u)),p=Bg(d.add(o).mul(r));n.directDiffuse.addAssign(p.mul(l.mul(e)))}super.direct({lightDirection:t,lightColor:e,reflectedLight:n},i,s)}}class pE extends hE{static get type(){return"MeshSSSNodeMaterial"}constructor(t){super(t),this.thicknessColorNode=null,this.thicknessDistortionNode=Lg(.1),this.thicknessAmbientNode=Lg(0),this.thicknessAttenuationNode=Lg(.1),this.thicknessPowerNode=Lg(2),this.thicknessScaleNode=Lg(10)}get useSSS(){return null!==this.thicknessColorNode}setupLightingModel(){return new dE(this.useClearcoat,this.useSheen,this.useIridescence,this.useSSS)}copy(t){return this.thicknessColorNode=t.thicknessColorNode,this.thicknessDistortionNode=t.thicknessDistortionNode,this.thicknessAmbientNode=t.thicknessAmbientNode,this.thicknessAttenuationNode=t.thicknessAttenuationNode,this.thicknessPowerNode=t.thicknessPowerNode,this.thicknessScaleNode=t.thicknessScaleNode,super.copy(t)}}const mE=wg(({normal:t,lightDirection:e,builder:n})=>{const i=t.dot(e),s=Og(i.mul(.5).add(.5),0);if(n.material.gradientMap){const t=FM("gradientMap","texture").context({getUV:()=>s});return Bg(t.r)}{const t=s.fwidth().mul(.5);return g_(Bg(.7),Bg(1),x_(Lg(.7).sub(t.x),Lg(.7).add(t.x),s.x))}});class fE extends IS{direct({lightDirection:t,lightColor:e,reflectedLight:n},i,s){const r=mE({normal:hM,lightDirection:t,builder:s}).mul(e);n.directDiffuse.addAssign(r.mul(OS({diffuseColor:pv.rgb})))}indirect({ambientOcclusion:t,irradiance:e,reflectedLight:n}){n.indirectDiffuse.addAssign(e.mul(OS({diffuseColor:pv}))),n.indirectDiffuse.mulAssign(t)}}const gE=new Sd;class vE extends lS{static get type(){return"MeshToonNodeMaterial"}constructor(t){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(gE),this.setValues(t)}setupLightingModel(){return new fE}}class yE extends zf{static get type(){return"MatcapUVNode"}constructor(){super("vec2")}setup(){const t=Bg(oM.z,0,oM.x.negate()).normalize(),e=oM.cross(t);return Og(t.dot(gM),e.dot(gM)).mul(.495).add(.5)}}const _E=Sg(yE),xE=new Ad;class ME extends lS{static get type(){return"MeshMatcapNodeMaterial"}constructor(t){super(),this.lights=!1,this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(xE),this.setValues(t)}setupVariants(t){const e=_E;let n;n=t.material.matcap?FM("matcap","texture").context({getUV:()=>e}):Bg(g_(.2,.8,e.y)),pv.rgb.mulAssign(n.rgb)}}const bE=new zu;class TE extends lS{static get type(){return"PointsNodeMaterial"}constructor(t){super(),this.isPointsNodeMaterial=!0,this.lights=!1,this.transparent=!0,this.sizeNode=null,this.setDefaultValues(bE),this.setValues(t)}copy(t){return this.sizeNode=t.sizeNode,super.copy(t)}}class SE extends zf{static get type(){return"RotateNode"}constructor(t,e){super(),this.positionNode=t,this.rotationNode=e}getNodeType(t){return this.positionNode.getNodeType(t)}setup(t){const{rotationNode:e,positionNode:n}=this;if("vec2"===this.getNodeType(t)){const t=e.cos(),i=e.sin();return Yg(t,i,i.negate(),t).mul(n)}{const t=e,i=$g(Wg(1,0,0,0),Wg(0,Dy(t.x),Uy(t.x).negate(),0),Wg(0,Uy(t.x),Dy(t.x),0),Wg(0,0,0,1)),s=$g(Wg(Dy(t.y),0,Uy(t.y),0),Wg(0,1,0,0),Wg(Uy(t.y).negate(),0,Dy(t.y),0),Wg(0,0,0,1)),r=$g(Wg(Dy(t.z),Uy(t.z).negate(),0,0),Wg(Uy(t.z),Dy(t.z),0,0),Wg(0,0,1,0),Wg(0,0,0,1));return i.mul(s).mul(r).mul(Wg(n,1)).xyz}}}const wE=Tg(SE),EE=new fc;class AE extends lS{static get type(){return"SpriteNodeMaterial"}constructor(t){super(),this.isSpriteNodeMaterial=!0,this.lights=!1,this._useSizeAttenuation=!0,this.positionNode=null,this.rotationNode=null,this.scaleNode=null,this.setDefaultValues(EE),this.setValues(t)}setupPosition({object:t,camera:e,context:n}){const i=this.sizeAttenuation,{positionNode:s,rotationNode:r,scaleNode:a}=this,o=nM;let l=Kx.mul(Bg(s||0)),c=Og(Xx[0].xyz.length(),Xx[1].xyz.length());null!==a&&(c=c.mul(a)),!i&&e.isPerspectiveCamera&&(c=c.mul(l.z.negate()));let u=o.xy;if(t.center&&!0===t.center.isVector2){const t=((t,e,n)=>xg(new j_(t,e,n)))("center","vec2");u=u.sub(t.sub(.5))}u=u.mul(c);const h=Lg(r||Nb),d=wE(u,h);l=Wg(l.xy.add(d),l.zw);const p=Lx.mul(l);return n.vertex=o,p}copy(t){return this.positionNode=t.positionNode,this.rotationNode=t.rotationNode,this.scaleNode=t.scaleNode,super.copy(t)}get sizeAttenuation(){return this._useSizeAttenuation}set sizeAttenuation(t){this._useSizeAttenuation!==t&&(this._useSizeAttenuation=t,this.needsUpdate=!0)}}class NE extends IS{constructor(){super(),this.shadowNode=Lg(1).toVar("shadowMask")}direct({shadowMask:t}){this.shadowNode.mulAssign(t)}finish(t){pv.a.mulAssign(this.shadowNode.oneMinus()),t.outgoingLight.rgb.assign(pv.rgb)}}const CE=new _d;class RE extends lS{static get type(){return"ShadowNodeMaterial"}constructor(t){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.setDefaultValues(CE),this.setValues(t)}setupLightingModel(){return new NE}}const IE=wg(({texture:t,uv:e})=>{const n=1e-4,i=Bg().toVar();return Cg(e.x.lessThan(n),()=>{i.assign(Bg(1,0,0))}).ElseIf(e.y.lessThan(n),()=>{i.assign(Bg(0,1,0))}).ElseIf(e.z.lessThan(n),()=>{i.assign(Bg(0,0,1))}).ElseIf(e.x.greaterThan(.9999),()=>{i.assign(Bg(-1,0,0))}).ElseIf(e.y.greaterThan(.9999),()=>{i.assign(Bg(0,-1,0))}).ElseIf(e.z.greaterThan(.9999),()=>{i.assign(Bg(0,0,-1))}).Else(()=>{const n=.01,s=t.uv(e.add(Bg(-.01,0,0))).r.sub(t.uv(e.add(Bg(n,0,0))).r),r=t.uv(e.add(Bg(0,-.01,0))).r.sub(t.uv(e.add(Bg(0,n,0))).r),a=t.uv(e.add(Bg(0,0,-.01))).r.sub(t.uv(e.add(Bg(0,0,n))).r);i.assign(Bg(s,r,a))}),i.normalize()});class LE extends wx{static get type(){return"Texture3DNode"}constructor(t,e=null,n=null){super(t,e,n),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return Bg(.5,.5,.5)}setUpdateMatrix(){}setupUV(t,e){return e}generateUV(t,e){return e.build(t,"vec3")}normal(t){return IE({texture:this,uv:t})}}const PE=Tg(LE);class UE extends lS{static get type(){return"VolumeNodeMaterial"}constructor(t={}){super(),this.lights=!1,this.isVolumeNodeMaterial=!0,this.testNode=null,this.setValues(t)}setup(t){const e=PE(this.map,null,0),n=wg(({orig:t,dir:e})=>{const n=Bg(-.5),i=Bg(.5),s=e.reciprocal(),r=n.sub(t).mul(s),a=i.sub(t).mul(s),o=t_(r,a),l=e_(r,a),c=e_(o.x,e_(o.y,o.z)),u=t_(l.x,t_(l.y,l.z));return Og(c,u)});this.fragmentNode=wg(()=>{const t=U_(Bg(Jx.mul(Wg(zx,1)))),i=U_(eM.sub(t)).normalize(),s=Og(n({orig:t,dir:i})).toVar();s.x.greaterThan(s.y).discard(),s.assign(Og(e_(s.x,0),s.y));const r=Bg(t.add(s.x.mul(i))).toVar(),a=Bg(i.abs().reciprocal()).toVar(),o=Lg(t_(a.x,t_(a.y,a.z))).toVar("delta");o.divAssign(FM("steps","float"));const l=Wg(FM("base","color"),0).toVar();return mT({type:"float",start:s.x,end:s.y,update:"+= delta"},()=>{const t=hv("float","d").assign(e.uv(r.add(.5)).r);null!==this.testNode?this.testNode({map:e,mapValue:t,probe:r,finalColor:l}).append():(l.a.assign(1),gT()),r.addAssign(i.mul(o))}),l.a.equal(0).discard(),Wg(l)})(),super.setup(t)}}class DE extends Kd{constructor(t){super(t),this.textures={},this.nodes={}}load(t,e,n,i){const s=new ep(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,n=>{try{e(this.parse(JSON.parse(n)))}catch(e){i?i(e):console.error(e),this.manager.itemError(t)}},n,i)}parseNodes(t){const e={};if(void 0!==t){for(const n of t){const{uuid:t,type:i}=n;e[t]=this.createNodeFromType(i),e[t].uuid=t}const n={nodes:e,textures:this.textures};for(const i of t){i.meta=n;e[i.uuid].deserialize(i),delete i.meta}}return e}parse(t){const e=this.createNodeFromType(t.type);e.uuid=t.uuid;const n={nodes:this.parseNodes(t.nodes),textures:this.textures};return t.meta=n,e.deserialize(t),delete t.meta,e}setTextures(t){return this.textures=t,this}setNodes(t){return this.nodes=t,this}createNodeFromType(t){return void 0===this.nodes[t]?(console.error("THREE.NodeLoader: Node type not found:",t),Lg()):xg(new this.nodes[t])}}class OE extends Ap{constructor(t){super(t),this.nodes={},this.nodeMaterials={}}parse(t){const e=super.parse(t),n=this.nodes,i=t.inputNodes;for(const t in i){const s=i[t];e[t]=n[s]}return e}setNodes(t){return this.nodes=t,this}setNodeMaterials(t){return this.nodeMaterials=t,this}createMaterialFromType(t){const e=this.nodeMaterials[t];return void 0!==e?new e:super.createMaterialFromType(t)}}class zE extends Ip{constructor(t){super(t),this.nodes={},this.nodeMaterials={},this._nodesJSON=null}setNodes(t){return this.nodes=t,this}setNodeMaterials(t){return this.nodeMaterials=t,this}parse(t,e){this._nodesJSON=t.nodes;const n=super.parse(t,e);return this._nodesJSON=null,n}parseNodes(t,e){if(void 0!==t){const n=new DE;return n.setNodes(this.nodes),n.setTextures(e),n.parseNodes(t)}return{}}parseMaterials(t,e){const n={};if(void 0!==t){const i=this.parseNodes(this._nodesJSON,e),s=new OE;s.setTextures(e),s.setNodes(i),s.setNodeMaterials(this.nodeMaterials);for(let e=0,i=t.length;e<i;e++){const i=t[e];n[i.uuid]=s.parse(i)}}return n}}class VE{constructor(t,e,n=null){this.isNodeAttribute=!0,this.name=t,this.type=e,this.node=n}}class FE{constructor(t,e,n){this.isNodeUniform=!0,this.name=t,this.type=e,this.node=n.getSelf()}get value(){return this.node.value}set value(t){this.node.value=t}get id(){return this.node.id}get groupNode(){return this.node.groupNode}}class BE{constructor(t,e){this.isNodeVar=!0,this.name=t,this.type=e}}class kE extends BE{constructor(t,e){super(t,e),this.needsInterpolation=!1,this.isNodeVarying=!0}}class HE{constructor(t,e,n=""){this.name=t,this.type=e,this.code=n,Object.defineProperty(this,"isNodeCode",{value:!0})}}let GE=0;class WE{constructor(t=null){this.id=GE++,this.nodesData=new WeakMap,this.parent=t}getData(t){let e=this.nodesData.get(t);return void 0===e&&null!==this.parent&&(e=this.parent.getData(t)),e}setData(t,e){this.nodesData.set(t,e)}}class jE extends uv{static get type(){return"ParameterNode"}constructor(t,e=null){super(t,e),this.isParameterNode=!0}getHash(){return this.uuid}generate(){return this.name}}const XE=(t,e)=>xg(new jE(t,e));class qE extends Uf{static get type(){return"CodeNode"}constructor(t="",e=[],n=""){super("code"),this.isCodeNode=!0,this.code=t,this.language=n,this.includes=e}isGlobal(){return!0}setIncludes(t){return this.includes=t,this}getIncludes(){return this.includes}generate(t){const e=this.getIncludes(t);for(const n of e)n.build(t);const n=t.getCodeFromNode(this,this.getNodeType(t));return n.code=this.code,n.code}serialize(t){super.serialize(t),t.code=this.code,t.language=this.language}deserialize(t){super.deserialize(t),this.code=t.code,this.language=t.language}}const YE=Tg(qE),ZE=(t,e)=>YE(t,e,"js"),$E=(t,e)=>YE(t,e,"wgsl"),JE=(t,e)=>YE(t,e,"glsl");class KE extends qE{static get type(){return"FunctionNode"}constructor(t="",e=[],n=""){super(t,e,n)}getNodeType(t){return this.getNodeFunction(t).type}getInputs(t){return this.getNodeFunction(t).inputs}getNodeFunction(t){const e=t.getDataFromNode(this);let n=e.nodeFunction;return void 0===n&&(n=t.parser.parseFunction(this.code),e.nodeFunction=n),n}generate(t,e){super.generate(t);const n=this.getNodeFunction(t),i=n.name,s=n.type,r=t.getCodeFromNode(this,s);""!==i&&(r.name=i);const a=t.getPropertyName(r),o=this.getNodeFunction(t).getCode(a);return r.code=o+"\n","property"===e?a:t.format(`${a}()`,s,e)}}const QE=(t,e=[],n="")=>{for(let t=0;t<e.length;t++){const n=e[t];"function"==typeof n&&(e[t]=n.functionNode)}const i=xg(new KE(t,e,n)),s=(...t)=>i.call(...t);return s.functionNode=i,s},tA=(t,e)=>QE(t,e,"glsl"),eA=(t,e)=>QE(t,e,"wgsl");class nA{constructor(t,e){this.name=t,this.value=e,this.boundary=0,this.itemSize=0,this.offset=0}setValue(t){this.value=t}getValue(){return this.value}}class iA extends nA{constructor(t,e=0){super(t,e),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class sA extends nA{constructor(t,e=new ei){super(t,e),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class rA extends nA{constructor(t,e=new Pi){super(t,e),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class aA extends nA{constructor(t,e=new wi){super(t,e),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class oA extends nA{constructor(t,e=new er){super(t,e),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class lA extends nA{constructor(t,e=new ni){super(t,e),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class cA extends nA{constructor(t,e=new cs){super(t,e),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class uA extends iA{constructor(t){super(t.name,t.value),this.nodeUniform=t}getValue(){return this.nodeUniform.value}}class hA extends sA{constructor(t){super(t.name,t.value),this.nodeUniform=t}getValue(){return this.nodeUniform.value}}class dA extends rA{constructor(t){super(t.name,t.value),this.nodeUniform=t}getValue(){return this.nodeUniform.value}}class pA extends aA{constructor(t){super(t.name,t.value),this.nodeUniform=t}getValue(){return this.nodeUniform.value}}class mA extends oA{constructor(t){super(t.name,t.value),this.nodeUniform=t}getValue(){return this.nodeUniform.value}}class fA extends lA{constructor(t){super(t.name,t.value),this.nodeUniform=t}getValue(){return this.nodeUniform.value}}class gA extends cA{constructor(t){super(t.name,t.value),this.nodeUniform=t}getValue(){return this.nodeUniform.value}}class vA extends Uf{static get type(){return"StackNode"}constructor(t=null){super(),this.nodes=[],this.outputNode=null,this.parent=t,this._currentCond=null,this.isStackNode=!0}getNodeType(t){return this.outputNode?this.outputNode.getNodeType(t):"void"}add(t){return this.nodes.push(t),this}If(t,e){const n=new _g(e);return this._currentCond=E_(t,n),this.add(this._currentCond)}ElseIf(t,e){const n=new _g(e),i=E_(t,n);return this._currentCond.elseNode=i,this._currentCond=i,this}Else(t){return this._currentCond.elseNode=new _g(t),this}build(t,...e){const n=Ng();Ag(this);for(const e of this.nodes)e.build(t,"void");return Ag(n),this.outputNode?this.outputNode.build(t,...e):super.build(t,...e)}else(...t){return console.warn("TSL.StackNode: .else() has been renamed to .Else()."),this.Else(...t)}elseif(...t){return console.warn("TSL.StackNode: .elseif() has been renamed to .ElseIf()."),this.ElseIf(...t)}}const yA=Tg(vA);class _A{constructor(){this.weakMap=new WeakMap}get(t){let e=this.weakMap;for(let n=0;n<t.length;n++)if(e=e.get(t[n]),void 0===e)return;return e.get(t[t.length-1])}set(t,e){let n=this.weakMap;for(let e=0;e<t.length;e++){const i=t[e];!1===n.has(i)&&n.set(i,new WeakMap),n=n.get(i)}return n.set(t[t.length-1],e)}delete(t){let e=this.weakMap;for(let n=0;n<t.length;n++)if(e=e.get(t[n]),void 0===e)return!1;return e.delete(t[t.length-1])}}const xA=[.125,.215,.35,.446,.526,.582],MA=20,bA=new Ra(-1,1,1,-1,0,1),TA=new ia(90,1),SA=new er;let wA=null,EA=0,AA=0;const NA=(1+Math.sqrt(5))/2,CA=1/NA,RA=[new Pi(-NA,CA,0),new Pi(NA,CA,0),new Pi(-CA,0,NA),new Pi(CA,0,NA),new Pi(0,NA,-CA),new Pi(0,NA,CA),new Pi(-1,1,-1),new Pi(1,1,-1),new Pi(-1,1,1),new Pi(1,1,1)],IA=[3,1,5,0,4,2],LA=Yw(xx(),_x("faceIndex")).normalize(),PA=Bg(LA.x,LA.y.negate(),LA.z);class UA{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}fromScene(t,e=0,n=.1,i=100){wA=this._renderer.getRenderTarget(),EA=this._renderer.getActiveCubeFace(),AA=this._renderer.getActiveMipmapLevel(),this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(t,n,i,s),e>0&&this._blur(s,0,0,e),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}async compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=VA(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=FA(),await this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose(),null!==this._backgroundBox&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodPlanes.length;t++)this._lodPlanes[t].dispose()}_cleanup(t){this._renderer.setRenderTarget(wA,EA,AA),t.scissorTest=!1,OA(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===lt||t.mapping===ct?this._setSize(0===t.image.length?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),wA=this._renderer.getRenderTarget(),EA=this._renderer.getActiveCubeFace(),AA=this._renderer.getActiveMipmapLevel();const n=e||this._allocateTargets();return this._textureToCubeUV(t,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,n={magFilter:Mt,minFilter:Mt,generateMipmaps:!1,type:Pt,format:kt,colorSpace:Ke},i=DA(t,e,n);if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=DA(t,e,n);const{_lodMax:i}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas,lodMeshes:this._lodMeshes}=function(t){const e=[],n=[],i=[],s=[];let r=t;const a=t-4+1+xA.length;for(let o=0;o<a;o++){const a=Math.pow(2,r);n.push(a);let l=1/a;o>t-4?l=xA[o-t+4-1]:0===o&&(l=0),i.push(l);const c=1/(a-2),u=-c,h=1+c,d=[u,u,h,u,h,h,u,u,h,h,u,h],p=6,m=6,f=3,g=2,v=1,y=new Float32Array(f*m*p),_=new Float32Array(g*m*p),x=new Float32Array(v*m*p);for(let t=0;t<p;t++){const e=t%3*2/3-1,n=t>2?0:-1,i=[e,n,0,e+2/3,n,0,e+2/3,n+1,0,e,n,0,e+2/3,n+1,0,e,n+1,0],s=IA[t];y.set(i,f*m*s),_.set(d,g*m*s);const r=[s,s,s,s,s,s];x.set(r,v*m*s)}const M=new Rr;M.setAttribute("position",new pr(y,f)),M.setAttribute("uv",new pr(_,g)),M.setAttribute("faceIndex",new pr(x,v)),e.push(M),s.push(new Hr(M,null)),r>4&&r--}return{lodPlanes:e,sizeLods:n,sigmas:i,lodMeshes:s}}(i)),this._blurMaterial=function(t,e,n){const i=LM(new Array(MA).fill(0)),s=cv(new Pi(0,1,0)),r=cv(0),a=Lg(MA),o=cv(0),l=cv(1),c=Ex(null),u=cv(0),h=Lg(1/e),d=Lg(1/n),p=Lg(t),m={n:a,latitudinal:o,weights:i,poleAxis:s,outputDirection:PA,dTheta:r,samples:l,envMap:c,mipInt:u,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:p},f=zA("blur");return f.uniforms=m,f.fragmentNode=Kw({...m,latitudinal:o.equal(1)}),f}(i,t,e)}return i}async _compileMaterial(t){const e=new Hr(this._lodPlanes[0],t);await this._renderer.compile(e,bA)}_sceneToCubeUV(t,e,n,i){const s=TA;s.near=e,s.far=n;const r=[-1,1,-1,-1,-1,-1],a=[1,1,1,-1,-1,-1],o=this._renderer,l=o.autoClear;o.getClearColor(SA),o.autoClear=!1;let c=this._backgroundBox;if(null===c){const t=new rr({name:"PMREM.Background",side:1,depthWrite:!1,depthTest:!1});c=new Hr(new Wr,t)}let u=!1;const h=t.background;h?h.isColor&&(c.material.color.copy(h),t.background=null,u=!0):(c.material.color.copy(SA),u=!0),o.setRenderTarget(i),o.clear(),u&&o.render(c,s);for(let e=0;e<6;e++){const n=e%3;0===n?(s.up.set(0,r[e],0),s.lookAt(a[e],0,0)):1===n?(s.up.set(0,0,r[e]),s.lookAt(0,a[e],0)):(s.up.set(0,r[e],0),s.lookAt(0,0,a[e]));const l=this._cubeSize;OA(i,n*l,e>2?l:0,l,l),o.render(t,s)}o.autoClear=l,t.background=h}_textureToCubeUV(t,e){const n=this._renderer,i=t.mapping===lt||t.mapping===ct;i?null===this._cubemapMaterial&&(this._cubemapMaterial=VA(t)):null===this._equirectMaterial&&(this._equirectMaterial=FA(t));const s=i?this._cubemapMaterial:this._equirectMaterial;s.fragmentNode.value=t;const r=this._lodMeshes[0];r.material=s;const a=this._cubeSize;OA(e,0,0,3*a,2*a),n.setRenderTarget(e),n.render(r,bA)}_applyPMREM(t){const e=this._renderer,n=e.autoClear;e.autoClear=!1;const i=this._lodPlanes.length;for(let e=1;e<i;e++){const n=Math.sqrt(this._sigmas[e]*this._sigmas[e]-this._sigmas[e-1]*this._sigmas[e-1]),s=RA[(i-e-1)%RA.length];this._blur(t,e-1,e,n,s)}e.autoClear=n}_blur(t,e,n,i,s){const r=this._pingPongRenderTarget;this._halfBlur(t,r,e,n,i,"latitudinal",s),this._halfBlur(r,t,n,n,i,"longitudinal",s)}_halfBlur(t,e,n,i,s,r,a){const o=this._renderer,l=this._blurMaterial;"latitudinal"!==r&&"longitudinal"!==r&&console.error("blur direction must be either latitudinal or longitudinal!");const c=this._lodMeshes[i];c.material=l;const u=l.uniforms,h=this._sizeLods[n]-1,d=isFinite(s)?Math.PI/(2*h):2*Math.PI/39,p=s/d,m=isFinite(s)?1+Math.floor(3*p):MA;m>MA&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${m} samples when the maximum is set to 20`);const f=[];let g=0;for(let t=0;t<MA;++t){const e=t/p,n=Math.exp(-e*e/2);f.push(n),0===t?g+=n:t<m&&(g+=2*n)}for(let t=0;t<f.length;t++)f[t]=f[t]/g;t.texture.frame=(t.texture.frame||0)+1,u.envMap.value=t.texture,u.samples.value=m,u.weights.array=f,u.latitudinal.value="latitudinal"===r?1:0,a&&(u.poleAxis.value=a);const{_lodMax:v}=this;u.dTheta.value=d,u.mipInt.value=v-n;const y=this._sizeLods[i];OA(e,3*y*(i>v-4?i-v+4:0),4*(this._cubeSize-y),3*y,2*y),o.setRenderTarget(e),o.render(c,bA)}}function DA(t,e,n){const i=new Ei(t,e,n);return i.texture.mapping=dt,i.texture.name="PMREM.cubeUv",i.texture.isPMREMTexture=!0,i.scissorTest=!0,i}function OA(t,e,n,i,s){t.viewport.set(e,n,i,s),t.scissor.set(e,n,i,s)}function zA(t){const e=new lS;return e.depthTest=!1,e.depthWrite=!1,e.blending=0,e.name=`PMREM_${t}`,e}function VA(t){const e=zA("cubemap");return e.fragmentNode=AM(t,PA),e}function FA(t){const e=zA("equirect");return e.fragmentNode=Ex(t,bS(PA),0),e}let BA=0;class kA{constructor(t="",e=[],n=0,i=[]){this.name=t,this.bindings=e,this.index=n,this.bindingsReference=i,this.id=BA++}}const HA=new WeakMap,GA=new Map([[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),WA=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),jA=t=>(t=Number(t))+(t%1?"":".0");class XA{constructor(t,e,n){this.object=t,this.material=t&&t.material||null,this.geometry=t&&t.geometry||null,this.renderer=e,this.parser=n,this.scene=null,this.camera=null,this.nodes=[],this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.monitor=null,this.lightsNode=null,this.environmentNode=null,this.fogNode=null,this.clippingContext=null,this.vertexShader=null,this.fragmentShader=null,this.computeShader=null,this.flowNodes={vertex:[],fragment:[],compute:[]},this.flowCode={vertex:"",fragment:"",compute:""},this.uniforms={vertex:[],fragment:[],compute:[],index:0},this.structs={vertex:[],fragment:[],compute:[],index:0},this.bindings={vertex:{},fragment:{},compute:{}},this.bindingsIndexes={},this.bindGroups=null,this.attributes=[],this.bufferAttributes=[],this.varyings=[],this.codes={},this.vars={},this.flow={code:""},this.chaining=[],this.stack=yA(),this.stacks=[],this.tab="\t",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new WE,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null,this.useComparisonMethod=!1}getBindGroupsCache(){let t=HA.get(this.renderer);return void 0===t&&(t=new _A,HA.set(this.renderer,t)),t}createRenderTarget(t,e,n){return new Ei(t,e,n)}createCubeRenderTarget(t,e){return new TS(t,e)}createPMREMGenerator(){return new UA(this.renderer)}includes(t){return this.nodes.includes(t)}_getBindGroup(t,e){const n=this.getBindGroupsCache(),i=[];let s,r=!0;for(const t of e)i.push(t),r=r&&!0!==t.groupNode.shared;return r?(s=n.get(i),void 0===s&&(s=new kA(t,i,this.bindingsIndexes[t].group,i),n.set(i,s))):s=new kA(t,i,this.bindingsIndexes[t].group,i),s}getBindGroupArray(t,e){const n=this.bindings[e];let i=n[t];return void 0===i&&(void 0===this.bindingsIndexes[t]&&(this.bindingsIndexes[t]={binding:0,group:Object.keys(this.bindingsIndexes).length}),n[t]=i=[]),i}getBindings(){let t=this.bindGroups;if(null===t){const e={},n=this.bindings;for(const t of If)for(const i in n[t]){const s=n[t][i];(e[i]||(e[i]=[])).push(...s)}t=[];for(const n in e){const i=e[n],s=this._getBindGroup(n,i);t.push(s)}this.bindGroups=t}return t}sortBindingGroups(){const t=this.getBindings();t.sort((t,e)=>t.bindings[0].groupNode.order-e.bindings[0].groupNode.order);for(let e=0;e<t.length;e++){const n=t[e];this.bindingsIndexes[n.name].group=e,n.index=e}}setHashNode(t,e){this.hashNodes[e]=t}addNode(t){!1===this.nodes.includes(t)&&(this.nodes.push(t),this.setHashNode(t,t.getHash(this)))}buildUpdateNodes(){for(const t of this.nodes){const e=t.getUpdateType(),n=t.getUpdateBeforeType(),i=t.getUpdateAfterType();e!==Af.NONE&&this.updateNodes.push(t.getSelf()),n!==Af.NONE&&this.updateBeforeNodes.push(t.getSelf()),i!==Af.NONE&&this.updateAfterNodes.push(t.getSelf())}}get currentNode(){return this.chaining[this.chaining.length-1]}isFilteredTexture(t){return t.magFilter===Mt||t.magFilter===bt||t.magFilter===_t||t.magFilter===St||t.minFilter===Mt||t.minFilter===bt||t.minFilter===_t||t.minFilter===St}addChain(t){this.chaining.push(t)}removeChain(t){if(this.chaining.pop()!==t)throw new Error("NodeBuilder: Invalid node chaining!")}getMethod(t){return t}getNodeFromHash(t){return this.hashNodes[t]}addFlow(t,e){return this.flowNodes[t].push(e),e}setContext(t){this.context=t}getContext(){return this.context}getSharedContext(){return this.context,this.context}setCache(t){this.cache=t}getCache(){return this.cache}getCacheFromNode(t,e=!0){const n=this.getDataFromNode(t);return void 0===n.cache&&(n.cache=new WE(e?this.getCache():null)),n.cache}isAvailable(){return!1}getVertexIndex(){console.warn("Abstract function.")}getInstanceIndex(){console.warn("Abstract function.")}getDrawIndex(){console.warn("Abstract function.")}getFrontFacing(){console.warn("Abstract function.")}getFragCoord(){console.warn("Abstract function.")}isFlipY(){return!1}increaseUsage(t){const e=this.getDataFromNode(t);return e.usageCount=void 0===e.usageCount?1:e.usageCount+1,e.usageCount}generateTexture(){console.warn("Abstract function.")}generateTextureLod(){console.warn("Abstract function.")}generateConst(t,e=null){if(null===e&&("float"===t||"int"===t||"uint"===t?e=0:"bool"===t?e=!1:"color"===t?e=new er:"vec2"===t?e=new ei:"vec3"===t?e=new Pi:"vec4"===t&&(e=new wi)),"float"===t)return jA(e);if("int"===t)return`${Math.round(e)}`;if("uint"===t)return e>=0?`${Math.round(e)}u`:"0u";if("bool"===t)return e?"true":"false";if("color"===t)return`${this.getType("vec3")}( ${jA(e.r)}, ${jA(e.g)}, ${jA(e.b)} )`;const n=this.getTypeLength(t),i=this.getComponentType(t),s=t=>this.generateConst(i,t);if(2===n)return`${this.getType(t)}( ${s(e.x)}, ${s(e.y)} )`;if(3===n)return`${this.getType(t)}( ${s(e.x)}, ${s(e.y)}, ${s(e.z)} )`;if(4===n)return`${this.getType(t)}( ${s(e.x)}, ${s(e.y)}, ${s(e.z)}, ${s(e.w)} )`;if(n>4&&e&&(e.isMatrix3||e.isMatrix4))return`${this.getType(t)}( ${e.elements.map(s).join(", ")} )`;if(n>4)return`${this.getType(t)}()`;throw new Error(`NodeBuilder: Type '${t}' not found in generate constant attempt.`)}getType(t){return"color"===t?"vec3":t}hasGeometryAttribute(t){return this.geometry&&void 0!==this.geometry.getAttribute(t)}getAttribute(t,e){const n=this.attributes;for(const e of n)if(e.name===t)return e;const i=new VE(t,e);return n.push(i),i}getPropertyName(t){return t.name}isVector(t){return/vec\d/.test(t)}isMatrix(t){return/mat\d/.test(t)}isReference(t){return"void"===t||"property"===t||"sampler"===t||"texture"===t||"cubeTexture"===t||"storageTexture"===t||"depthTexture"===t||"texture3D"===t}needsToWorkingColorSpace(){return!1}getComponentTypeFromTexture(t){const e=t.type;if(t.isDataTexture){if(e===Rt)return"int";if(e===It)return"uint"}return"float"}getElementType(t){return"mat2"===t?"vec2":"mat3"===t?"vec3":"mat4"===t?"vec4":this.getComponentType(t)}getComponentType(t){if("float"===(t=this.getVectorType(t))||"bool"===t||"int"===t||"uint"===t)return t;const e=/(b|i|u|)(vec|mat)([2-4])/.exec(t);return null===e?null:"b"===e[1]?"bool":"i"===e[1]?"int":"u"===e[1]?"uint":"float"}getVectorType(t){return"color"===t?"vec3":"texture"===t||"cubeTexture"===t||"storageTexture"===t||"texture3D"===t?"vec4":t}getTypeFromLength(t,e="float"){if(1===t)return e;const n=GA.get(t);return("float"===e?"":e[0])+n}getTypeFromArray(t){return WA.get(t.constructor)}getTypeFromAttribute(t){let e=t;t.isInterleavedBufferAttribute&&(e=t.data);const n=e.array,i=t.itemSize,s=t.normalized;let r;return t instanceof Mr||!0===s||(r=this.getTypeFromArray(n)),this.getTypeFromLength(i,r)}getTypeLength(t){const e=this.getVectorType(t),n=/vec([2-4])/.exec(e);return null!==n?Number(n[1]):"float"===e||"bool"===e||"int"===e||"uint"===e?1:!0===/mat2/.test(t)?4:!0===/mat3/.test(t)?9:!0===/mat4/.test(t)?16:0}getVectorFromMatrix(t){return t.replace("mat","vec")}changeComponentType(t,e){return this.getTypeFromLength(this.getTypeLength(t),e)}getIntegerType(t){const e=this.getComponentType(t);return"int"===e||"uint"===e?t:this.changeComponentType(t,"int")}addStack(){return this.stack=yA(this.stack),this.stacks.push(Ng()||this.stack),Ag(this.stack),this.stack}removeStack(){const t=this.stack;return this.stack=t.parent,Ag(this.stacks.pop()),t}getDataFromNode(t,e=this.shaderStage,n=null){let i=(n=null===n?t.isGlobal(this)?this.globalCache:this.cache:n).getData(t);return void 0===i&&(i={},n.setData(t,i)),void 0===i[e]&&(i[e]={}),i[e]}getNodeProperties(t,e="any"){const n=this.getDataFromNode(t,e);return n.properties||(n.properties={outputNode:null})}getBufferAttributeFromNode(t,e){const n=this.getDataFromNode(t);let i=n.bufferAttribute;if(void 0===i){const s=this.uniforms.index++;i=new VE("nodeAttribute"+s,e,t),this.bufferAttributes.push(i),n.bufferAttribute=i}return i}getStructTypeFromNode(t,e=this.shaderStage){const n=this.getDataFromNode(t,e);if(void 0===n.structType){const i=this.structs.index++;t.name=`StructType${i}`,this.structs[e].push(t),n.structType=t}return t}getUniformFromNode(t,e,n=this.shaderStage,i=null){"in"===i&&(console.warn('NodeBuilder: "in" is a reserved word, using "inValue" instead.',t,i),t.name="inValue",i=t.name);const s=this.getDataFromNode(t,n,this.globalCache);let r=s.uniform;if(void 0===r){const a=this.uniforms.index++;r=new FE(i||"nodeUniform"+a,e,t),this.uniforms[n].push(r),s.uniform=r}return r}getVarFromNode(t,e=null,n=t.getNodeType(this),i=this.shaderStage){const s=this.getDataFromNode(t,i);let r=s.variable;if(void 0===r){const t=this.vars[i]||(this.vars[i]=[]);null===e&&(e="nodeVar"+t.length),r=new BE(e,n),t.push(r),s.variable=r}return r}getVaryingFromNode(t,e=null,n=t.getNodeType(this)){const i=this.getDataFromNode(t,"any");let s=i.varying;if(void 0===s){const t=this.varyings,r=t.length;null===e&&(e="nodeVarying"+r),s=new kE(e,n),t.push(s),i.varying=s}return s}getCodeFromNode(t,e,n=this.shaderStage){const i=this.getDataFromNode(t);let s=i.code;if(void 0===s){const t=this.codes[n]||(this.codes[n]=[]),r=t.length;s=new HE("nodeCode"+r,e),t.push(s),i.code=s}return s}addFlowCodeHierarchy(t,e){const{flowCodes:n,flowCodeBlock:i}=this.getDataFromNode(t);let s=!0,r=e;for(;r;){if(!0===i.get(r)){s=!1;break}r=this.getDataFromNode(r).parentNodeBlock}if(s)for(const t of n)this.addLineFlowCode(t)}addLineFlowCodeBlock(t,e,n){const i=this.getDataFromNode(t),s=i.flowCodes||(i.flowCodes=[]),r=i.flowCodeBlock||(i.flowCodeBlock=new WeakMap);s.push(e),r.set(n,!0)}addLineFlowCode(t,e=null){return""===t||(null!==e&&this.context.nodeBlock&&this.addLineFlowCodeBlock(e,t,this.context.nodeBlock),t=this.tab+t,/;\s*$/.test(t)||(t+=";\n"),this.flow.code+=t),this}addFlowCode(t){return this.flow.code+=t,this}addFlowTab(){return this.tab+="\t",this}removeFlowTab(){return this.tab=this.tab.slice(0,-1),this}getFlowData(t){return this.flowsData.get(t)}flowNode(t){const e=t.getNodeType(this),n=this.flowChildNode(t,e);return this.flowsData.set(t,n),n}buildFunctionNode(t){const e=new KE,n=this.currentFunctionNode;return this.currentFunctionNode=e,e.code=this.buildFunctionCode(t),this.currentFunctionNode=n,e}flowShaderNode(t){const e=t.layout,n={[Symbol.iterator](){let t=0;const e=Object.values(this);return{next:()=>({value:e[t],done:t++>=e.length})}}};for(const t of e.inputs)n[t.name]=new jE(t.type,t.name);t.layout=null;const i=t.call(n),s=this.flowStagesNode(i,e.type);return t.layout=e,s}flowStagesNode(t,e=null){const n=this.flow,i=this.vars,s=this.cache,r=this.buildStage,a=this.stack,o={code:""};this.flow=o,this.vars={},this.cache=new WE,this.stack=yA();for(const n of Rf)this.setBuildStage(n),o.result=t.build(this,e);return o.vars=this.getVars(this.shaderStage),this.flow=n,this.vars=i,this.cache=s,this.stack=a,this.setBuildStage(r),o}getFunctionOperator(){return null}flowChildNode(t,e=null){const n=this.flow,i={code:""};return this.flow=i,i.result=t.build(this,e),this.flow=n,i}flowNodeFromShaderStage(t,e,n=null,i=null){const s=this.shaderStage;this.setShaderStage(t);const r=this.flowChildNode(e,n);return null!==i&&(r.code+=`${this.tab+i} = ${r.result};\n`),this.flowCode[t]=this.flowCode[t]+r.code,this.setShaderStage(s),r}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){console.warn("Abstract function.")}getVaryings(){console.warn("Abstract function.")}getVar(t,e){return`${this.getType(t)} ${e}`}getVars(t){let e="";const n=this.vars[t];if(void 0!==n)for(const t of n)e+=`${this.getVar(t.type,t.name)}; `;return e}getUniforms(){console.warn("Abstract function.")}getCodes(t){const e=this.codes[t];let n="";if(void 0!==e)for(const t of e)n+=t.code+"\n";return n}getHash(){return this.vertexShader+this.fragmentShader+this.computeShader}setShaderStage(t){this.shaderStage=t}getShaderStage(){return this.shaderStage}setBuildStage(t){this.buildStage=t}getBuildStage(){return this.buildStage}buildCode(){console.warn("Abstract function.")}build(){const{object:t,material:e,renderer:n}=this;if(null!==e){let t=n.nodes.library.fromMaterial(e);null===t&&(console.error(`NodeMaterial: Material "${e.type}" is not compatible.`),t=new lS),t.build(this)}else this.addFlow("compute",t);for(const t of Rf){this.setBuildStage(t),this.context.vertex&&this.context.vertex.isNode&&this.flowNodeFromShaderStage("vertex",this.context.vertex);for(const e of If){this.setShaderStage(e);const n=this.flowNodes[e];for(const e of n)"generate"===t?this.flowNode(e):e.build(this)}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}getNodeUniform(t,e){if("float"===e||"int"===e||"uint"===e)return new uA(t);if("vec2"===e||"ivec2"===e||"uvec2"===e)return new hA(t);if("vec3"===e||"ivec3"===e||"uvec3"===e)return new dA(t);if("vec4"===e||"ivec4"===e||"uvec4"===e)return new pA(t);if("color"===e)return new mA(t);if("mat3"===e)return new fA(t);if("mat4"===e)return new gA(t);throw new Error(`Uniform "${e}" not declared.`)}createNodeMaterial(t="NodeMaterial"){throw new Error(`THREE.NodeBuilder: createNodeMaterial() was deprecated. Use new ${t}() instead.`)}format(t,e,n){if((e=this.getVectorType(e))===(n=this.getVectorType(n))||null===n||this.isReference(n))return t;const i=this.getTypeLength(e),s=this.getTypeLength(n);return 16===i&&9===s?`${this.getType(n)}(${t}[0].xyz, ${t}[1].xyz, ${t}[2].xyz)`:9===i&&4===s?`${this.getType(n)}(${t}[0].xy, ${t}[1].xy)`:i>4||s>4||0===s?t:i===s?`${this.getType(n)}( ${t} )`:i>s?this.format(`${t}.${"xyz".slice(0,s)}`,this.getTypeFromLength(s,this.getComponentType(e)),n):4===s&&i>1?`${this.getType(n)}( ${this.format(t,e,"vec3")}, 1.0 )`:2===i?`${this.getType(n)}( ${this.format(t,e,"vec2")}, 0.0 )`:(1===i&&s>1&&e!==this.getComponentType(n)&&(t=`${this.getType(this.getComponentType(n))}( ${t} )`),`${this.getType(n)}( ${t} )`)}getSignature(){return`// Three.js r${t} - Node System\n`}}class qA{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.startTime=null,this.updateMap=new WeakMap,this.updateBeforeMap=new WeakMap,this.updateAfterMap=new WeakMap,this.renderer=null,this.material=null,this.camera=null,this.object=null,this.scene=null}_getMaps(t,e){let n=t.get(e);return void 0===n&&(n={renderMap:new WeakMap,frameMap:new WeakMap},t.set(e,n)),n}updateBeforeNode(t){const e=t.getUpdateBeforeType(),n=t.updateReference(this);if(e===Af.FRAME){const{frameMap:e}=this._getMaps(this.updateBeforeMap,n);e.get(n)!==this.frameId&&!1!==t.updateBefore(this)&&e.set(n,this.frameId)}else if(e===Af.RENDER){const{renderMap:e}=this._getMaps(this.updateBeforeMap,n);e.get(n)!==this.renderId&&!1!==t.updateBefore(this)&&e.set(n,this.renderId)}else e===Af.OBJECT&&t.updateBefore(this)}updateAfterNode(t){const e=t.getUpdateAfterType(),n=t.updateReference(this);if(e===Af.FRAME){const{frameMap:e}=this._getMaps(this.updateAfterMap,n);e.get(n)!==this.frameId&&!1!==t.updateAfter(this)&&e.set(n,this.frameId)}else if(e===Af.RENDER){const{renderMap:e}=this._getMaps(this.updateAfterMap,n);e.get(n)!==this.renderId&&!1!==t.updateAfter(this)&&e.set(n,this.renderId)}else e===Af.OBJECT&&t.updateAfter(this)}updateNode(t){const e=t.getUpdateType(),n=t.updateReference(this);if(e===Af.FRAME){const{frameMap:e}=this._getMaps(this.updateMap,n);e.get(n)!==this.frameId&&!1!==t.update(this)&&e.set(n,this.frameId)}else if(e===Af.RENDER){const{renderMap:e}=this._getMaps(this.updateMap,n);e.get(n)!==this.renderId&&!1!==t.update(this)&&e.set(n,this.renderId)}else e===Af.OBJECT&&t.update(this)}update(){this.frameId++,void 0===this.lastTime&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}}class YA{constructor(t,e,n=null,i="",s=!1){this.type=t,this.name=e,this.count=n,this.qualifier=i,this.isConst=s}}YA.isNodeFunctionInput=!0;class ZA extends Uf{static get type(){return"StructTypeNode"}constructor(t){super(),this.types=t,this.isStructTypeNode=!0}getMemberTypes(){return this.types}}class $A extends Uf{static get type(){return"OutputStructNode"}constructor(...t){super(),this.members=t,this.isOutputStructNode=!0}setup(t){super.setup(t);const e=this.members,n=[];for(let i=0;i<e.length;i++)n.push(e[i].getNodeType(t));this.nodeType=t.getStructTypeFromNode(new ZA(n)).name}generate(t,e){const n=t.getOutputStructName(),i=this.members,s=""!==n?n+".":"";for(let n=0;n<i.length;n++){const r=i[n].build(t,e);t.addLineFlowCode(`${s}m${n} = ${r}`,this)}return n}}const JA=Tg($A);function KA(t,e){for(let n=0;n<t.length;n++)if(t[n].name===e)return n;return-1}class QA extends $A{static get type(){return"MRTNode"}constructor(t){super(),this.outputNodes=t,this.isMRTNode=!0}has(t){return void 0!==this.outputNodes[t]}get(t){return this.outputNodes[t]}merge(t){const e={...this.outputNodes,...t.outputNodes};return tN(e)}setup(t){const e=this.outputNodes,n=[],i=t.renderer.getRenderTarget().textures;for(const t in e){n[KA(i,t)]=Wg(e[t])}return this.members=n,super.setup(t)}}const tN=Tg(QA);class eN extends Uf{static get type(){return"FunctionOverloadingNode"}constructor(t=[],...e){super(),this.functionNodes=t,this.parametersNodes=e,this._candidateFnCall=null,this.global=!0}getNodeType(){return this.functionNodes[0].shaderNode.layout.type}setup(t){const e=this.parametersNodes;let n=this._candidateFnCall;if(null===n){let i=null,s=-1;for(const n of this.functionNodes){const r=n.shaderNode.layout;if(null===r)throw new Error("FunctionOverloadingNode: FunctionNode must be a layout.");const a=r.inputs;if(e.length===a.length){let r=0;for(let n=0;n<e.length;n++){const i=e[n],s=a[n];i.getNodeType(t)===s.type?r++:r=0}r>s&&(i=n,s=r)}}this._candidateFnCall=n=i(...e)}return n}}const nN=Tg(eN),iN=t=>(...e)=>nN(t,...e);class sN extends lv{static get type(){return"TimerNode"}constructor(t=sN.LOCAL,e=1,n=0){super(n),this.scope=t,this.scale=e,this.updateType=Af.FRAME}update(t){const e=this.scope,n=this.scale;e===sN.LOCAL?this.value+=t.deltaTime*n:e===sN.DELTA?this.value=t.deltaTime*n:e===sN.FRAME?this.value=t.frameId:this.value=t.time*n}serialize(t){super.serialize(t),t.scope=this.scope,t.scale=this.scale}deserialize(t){super.deserialize(t),this.scope=t.scope,this.scale=t.scale}}sN.LOCAL="local",sN.GLOBAL="global",sN.DELTA="delta",sN.FRAME="frame";const rN=(t,e=0)=>xg(new sN(sN.LOCAL,t,e)),aN=(t,e=0)=>xg(new sN(sN.GLOBAL,t,e)),oN=(t,e=0)=>xg(new sN(sN.DELTA,t,e)),lN=Sg(sN,sN.FRAME).toUint();class cN extends Uf{static get type(){return"OscNode"}constructor(t=cN.SINE,e=rN()){super(),this.method=t,this.timeNode=e}getNodeType(t){return this.timeNode.getNodeType(t)}setup(){const t=this.method,e=xg(this.timeNode);let n=null;return t===cN.SINE?n=e.add(.75).mul(2*Math.PI).sin().mul(.5).add(.5):t===cN.SQUARE?n=e.fract().round():t===cN.TRIANGLE?n=e.add(.5).fract().mul(2).sub(1).abs():t===cN.SAWTOOTH&&(n=e.fract()),n}serialize(t){super.serialize(t),t.method=this.method}deserialize(t){super.deserialize(t),this.method=t.method}}cN.SINE="sine",cN.SQUARE="square",cN.TRIANGLE="triangle",cN.SAWTOOTH="sawtooth";const uN=Tg(cN,cN.SINE),hN=Tg(cN,cN.SQUARE),dN=Tg(cN,cN.TRIANGLE),pN=Tg(cN,cN.SAWTOOTH);class mN extends Uf{static get type(){return"SpriteSheetUVNode"}constructor(t,e=xx(),n=Lg(0)){super("vec2"),this.countNode=t,this.uvNode=e,this.frameNode=n}setup(){const{frameNode:t,uvNode:e,countNode:n}=this,{width:i,height:s}=n,r=t.mod(i.mul(s)).floor(),a=r.mod(i),o=s.sub(r.add(1).div(i).ceil()),l=n.reciprocal(),c=Og(a,o);return e.add(c).mul(l)}}const fN=Tg(mN);class gN extends Df{static get type(){return"StorageArrayElementNode"}constructor(t,e){super(t,e),this.isStorageArrayElementNode=!0}set storageBufferNode(t){this.node=t}get storageBufferNode(){return this.node}setup(t){return!1===t.isAvailable("storageBuffer")&&!0===this.node.bufferObject&&t.setupPBO(this.node),super.setup(t)}generate(t,e){let n;const i=t.context.assign;if(n=!1===t.isAvailable("storageBuffer")?!0===this.node.bufferObject&&!0!==i?t.generatePBO(this):this.node.build(t):super.generate(t),!0!==i){const i=this.getNodeType(t);n=t.format(n,i,e)}return n}}const vN=Tg(gN);class yN extends Uf{static get type(){return"TriplanarTexturesNode"}constructor(t,e=null,n=null,i=Lg(1),s=nM,r=dM){super("vec4"),this.textureXNode=t,this.textureYNode=e,this.textureZNode=n,this.scaleNode=i,this.positionNode=s,this.normalNode=r}setup(){const{textureXNode:t,textureYNode:e,textureZNode:n,scaleNode:i,positionNode:s,normalNode:r}=this;let a=r.abs().normalize();a=a.div(a.dot(Bg(1)));const o=s.yz.mul(i),l=s.zx.mul(i),c=s.xy.mul(i),u=t.value,h=null!==e?e.value:u,d=null!==n?n.value:u,p=Ex(u,o).mul(a.x),m=Ex(h,l).mul(a.y),f=Ex(d,c).mul(a.z);return Xv(p,m,f)}}const _N=Tg(yN),xN=(...t)=>_N(...t),MN=new ha,bN=new Pi,TN=new Pi,SN=new Pi,wN=new cs,EN=new Pi(0,0,-1),AN=new wi,NN=new Pi,CN=new Pi,RN=new wi,IN=new ei,LN=new Ei,PN=DT.flipX();let UN=!1;class DN extends wx{static get type(){return"ReflectorNode"}constructor(t={}){super(LN.texture,PN);const{target:e=new Os,resolution:n=1,generateMipmaps:i=!1,bounces:s=!0}=t;this.target=e,this.resolution=n,this.generateMipmaps=i,this.bounces=s,this.updateBeforeType=s?Af.RENDER:Af.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new WeakMap}_updateResolution(t,e){const n=this.resolution;e.getDrawingBufferSize(IN),t.setSize(Math.round(IN.width*n),Math.round(IN.height*n))}setup(t){return this._updateResolution(LN,t.renderer),super.setup(t)}getTextureNode(){return this.textureNode}getVirtualCamera(t){let e=this.virtualCameras.get(t);return void 0===e&&(e=t.clone(),this.virtualCameras.set(t,e)),e}getRenderTarget(t){let e=this.renderTargets.get(t);return void 0===e&&(e=new Ei(0,0,{type:Pt}),!0===this.generateMipmaps&&(e.texture.minFilter=1008,e.texture.generateMipmaps=!0),this.renderTargets.set(t,e)),e}updateBefore(t){if(!1===this.bounces&&UN)return!1;UN=!0;const{scene:e,camera:n,renderer:i,material:s}=t,{target:r}=this,a=this.getVirtualCamera(n),o=this.getRenderTarget(a);if(i.getDrawingBufferSize(IN),this._updateResolution(o,i),TN.setFromMatrixPosition(r.matrixWorld),SN.setFromMatrixPosition(n.matrixWorld),wN.extractRotation(r.matrixWorld),bN.set(0,0,1),bN.applyMatrix4(wN),NN.subVectors(TN,SN),NN.dot(bN)>0)return;NN.reflect(bN).negate(),NN.add(TN),wN.extractRotation(n.matrixWorld),EN.set(0,0,-1),EN.applyMatrix4(wN),EN.add(SN),CN.subVectors(TN,EN),CN.reflect(bN).negate(),CN.add(TN),a.coordinateSystem=n.coordinateSystem,a.position.copy(NN),a.up.set(0,1,0),a.up.applyMatrix4(wN),a.up.reflect(bN),a.lookAt(CN),a.near=n.near,a.far=n.far,a.updateMatrixWorld(),a.projectionMatrix.copy(n.projectionMatrix),MN.setFromNormalAndCoplanarPoint(bN,TN),MN.applyMatrix4(a.matrixWorldInverse),AN.set(MN.normal.x,MN.normal.y,MN.normal.z,MN.constant);const l=a.projectionMatrix;RN.x=(Math.sign(AN.x)+l.elements[8])/l.elements[0],RN.y=(Math.sign(AN.y)+l.elements[9])/l.elements[5],RN.z=-1,RN.w=(1+l.elements[10])/l.elements[14],AN.multiplyScalar(1/AN.dot(RN));l.elements[2]=AN.x,l.elements[6]=AN.y,l.elements[10]=AN.z-0,l.elements[14]=AN.w,this.value=o.texture,s.visible=!1;const c=i.getRenderTarget(),u=i.getMRT();i.setMRT(null),i.setRenderTarget(o),i.render(e,a),i.setMRT(u),i.setRenderTarget(c),s.visible=!0,UN=!1}}const ON=t=>xg(new DN(t)),zN=new Ra(-1,1,1,-1,0,1);class VN extends Rr{constructor(t=!1){super();const e=!1===t?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new br([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new br(e,2))}}const FN=new VN;class BN extends Hr{constructor(t=null){super(FN,t),this.camera=zN,this.isQuadMesh=!0}renderAsync(t){return t.renderAsync(this,zN)}render(t){t.render(this,zN)}}const kN=new ei;class HN extends wx{static get type(){return"RTTNode"}constructor(t,e=null,n=null,i={type:Pt}){const s=new Ei(e,n,i);super(s.texture,xx()),this.node=t,this.width=e,this.height=n,this.renderTarget=s,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this.updateMap=new WeakMap,this._rttNode=null,this._quadMesh=new BN(new lS),this.updateBeforeType=Af.RENDER}get autoSize(){return null===this.width}setup(t){return this._rttNode=this.node.context(t.getSharedContext()),this._quadMesh.material.name="RTT",this._quadMesh.material.needsUpdate=!0,super.setup(t)}setSize(t,e){this.width=t,this.height=e;const n=t*this.pixelRatio,i=e*this.pixelRatio;this.renderTarget.setSize(n,i),this.textureNeedsUpdate=!0}setPixelRatio(t){this.pixelRatio=t,this.setSize(this.width,this.height)}updateBefore({renderer:t}){if(!1===this.textureNeedsUpdate&&!1===this.autoUpdate)return;if(this.textureNeedsUpdate=!1,!0===this.autoSize){this.pixelRatio=t.getPixelRatio();const e=t.getSize(kN);this.setSize(e.width,e.height)}this._quadMesh.material.fragmentNode=this._rttNode;const e=t.getRenderTarget();t.setRenderTarget(this.renderTarget),this._quadMesh.render(t),t.setRenderTarget(e)}clone(){const t=new wx(this.value,this.uvNode,this.levelNode);return t.sampler=this.sampler,t.referenceNode=this,t}}const GN=(t,...e)=>xg(new HN(xg(t),...e)),WN=(t,...e)=>t.isTextureNode?t:GN(t,...e);class jN extends yx{static get type(){return"VertexColorNode"}constructor(t=0){super(null,"vec4"),this.isVertexColorNode=!0,this.index=t}getAttributeName(){const t=this.index;return"color"+(t>0?t:"")}generate(t){const e=this.getAttributeName(t);let n;return n=!0===t.hasGeometryAttribute(e)?super.generate(t):t.generateConst(this.nodeType,new wi(1,1,1,1)),n}serialize(t){super.serialize(t),t.index=this.index}deserialize(t){super.deserialize(t),this.index=t.index}}const XN=(...t)=>xg(new jN(...t));class qN extends Uf{static get type(){return"PointUVNode"}constructor(){super("vec2"),this.isPointUVNode=!0}generate(){return"vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )"}}const YN=Sg(qN);class ZN extends Uf{static get type(){return"SceneNode"}constructor(t=ZN.BACKGROUND_BLURRINESS,e=null){super(),this.scope=t,this.scene=e}setup(t){const e=this.scope,n=null!==this.scene?this.scene:t.scene;let i;return e===ZN.BACKGROUND_BLURRINESS?i=OM("backgroundBlurriness","float",n):e===ZN.BACKGROUND_INTENSITY?i=OM("backgroundIntensity","float",n):console.error("THREE.SceneNode: Unknown scope:",e),i}}ZN.BACKGROUND_BLURRINESS="backgroundBlurriness",ZN.BACKGROUND_INTENSITY="backgroundIntensity";const $N=Sg(ZN,ZN.BACKGROUND_BLURRINESS),JN=Sg(ZN,ZN.BACKGROUND_INTENSITY),KN="storage",QN="read-only-storage",tC="write-only",eC="read-only";class nC extends NM{static get type(){return"StorageBufferNode"}constructor(t,e,n=0){super(t,e,n),this.isStorageBufferNode=!0,this.access=KN,this.isAtomic=!1,this.bufferObject=!1,this.bufferCount=n,this._attribute=null,this._varying=null,this.global=!0,!0!==t.isStorageBufferAttribute&&!0!==t.isStorageInstancedBufferAttribute&&(t.isInstancedBufferAttribute?t.isStorageInstancedBufferAttribute=!0:t.isStorageBufferAttribute=!0)}getHash(t){if(0===this.bufferCount){let e=t.globalCache.getData(this.value);return void 0===e&&(e={node:this},t.globalCache.setData(this.value,e)),e.node.uuid}return this.uuid}getInputType(){return"storageBuffer"}element(t){return vN(this,t)}setBufferObject(t){return this.bufferObject=t,this}setAccess(t){return this.access=t,this}toReadOnly(){return this.setAccess(QN)}setAtomic(t){return this.isAtomic=t,this}toAtomic(){return this.setAtomic(!0)}generate(t){if(t.isAvailable("storageBuffer"))return super.generate(t);const e=this.getNodeType(t);null===this._attribute&&(this._attribute=K_(this.value),this._varying=U_(this._attribute));const n=this._varying.build(t,e);return t.registerTransform(n,this._attribute),n}}const iC=(t,e,n)=>xg(new nC(t,e,n)),sC=(t,e,n)=>xg(new nC(t,e,n).setBufferObject(!0));class rC extends wx{static get type(){return"StorageTextureNode"}constructor(t,e,n=null){super(t,e),this.storeNode=n,this.isStorageTextureNode=!0,this.access=tC}getInputType(){return"storageTexture"}setup(t){super.setup(t);t.getNodeProperties(this).storeNode=this.storeNode}setAccess(t){return this.access=t,this}generate(t,e){let n;return n=null!==this.storeNode?this.generateStore(t):super.generate(t,e),n}toReadOnly(){return this.setAccess(eC)}toWriteOnly(){return this.setAccess(tC)}generateStore(t){const e=t.getNodeProperties(this),{uvNode:n,storeNode:i}=e,s=super.generate(t,"property"),r=n.build(t,"uvec2"),a=i.build(t,"vec4"),o=t.generateTextureStore(t,s,r,a);t.addLineFlowCode(o,this)}}const aC=Tg(rC),oC=(t,e,n)=>{const i=aC(t,e,n);return null!==n&&i.append(),i};class lC extends DM{static get type(){return"UserDataNode"}constructor(t,e,n=null){super(t,e,n),this.userData=n}updateReference(t){return this.reference=null!==this.userData?this.userData:t.object.userData,this.reference}}const cC=(t,e,n)=>xg(new lC(t,e,n));class uC extends zf{static get type(){return"PosterizeNode"}constructor(t,e){super(),this.sourceNode=t,this.stepsNode=e}setup(){const{sourceNode:t,stepsNode:e}=this;return t.mul(e).floor().div(e)}}const hC=Tg(uC);let dC=null;class pC extends XT{static get type(){return"ViewportSharedTextureNode"}constructor(t=DT,e=null){null===dC&&(dC=new ju),super(t,e,dC)}updateReference(){return this}}const mC=Tg(pC),fC=new ei;class gC extends wx{static get type(){return"PassTextureNode"}constructor(t,e){super(e),this.passNode=t,this.setUpdateMatrix(!1)}setup(t){return t.object.isQuadMesh&&this.passNode.build(t),super.setup(t)}clone(){return new this.constructor(this.passNode,this.value)}}class vC extends gC{static get type(){return"PassMultipleTextureNode"}constructor(t,e,n=!1){super(t,null),this.textureName=e,this.previousTexture=n}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(t){return this.updateTexture(),super.setup(t)}clone(){return new this.constructor(this.passNode,this.textureName,this.previousTexture)}}class yC extends zf{static get type(){return"PassNode"}constructor(t,e,n,i={}){super("vec4"),this.scope=t,this.scene=e,this.camera=n,this.options=i,this._pixelRatio=1,this._width=1,this._height=1;const s=new no;s.isRenderTargetTexture=!0,s.name="depth";const r=new Ei(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Pt,...i});r.texture.name="output",r.depthTexture=s,this.renderTarget=r,this.updateBeforeType=Af.FRAME,this._textures={output:r.texture,depth:s},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=cv(0),this._cameraFar=cv(0),this._mrt=null,this.isPassNode=!0}setMRT(t){return this._mrt=t,this}getMRT(){return this._mrt}isGlobal(){return!0}getTexture(t){let e=this._textures[t];if(void 0===e){e=this.renderTarget.texture.clone(),e.isRenderTargetTexture=!0,e.name=t,this._textures[t]=e,this.renderTarget.textures.push(e)}return e}getPreviousTexture(t){let e=this._previousTextures[t];return void 0===e&&(e=this.getTexture(t).clone(),e.isRenderTargetTexture=!0,this._previousTextures[t]=e),e}toggleTexture(t){const e=this._previousTextures[t];if(void 0!==e){const n=this._textures[t],i=this.renderTarget.textures.indexOf(n);this.renderTarget.textures[i]=e,this._textures[t]=e,this._previousTextures[t]=n,this._textureNodes[t].updateTexture(),this._previousTextureNodes[t].updateTexture()}}getTextureNode(t="output"){let e=this._textureNodes[t];return void 0===e&&(this._textureNodes[t]=e=xg(new vC(this,t)),this._textureNodes[t].updateTexture()),e}getPreviousTextureNode(t="output"){let e=this._previousTextureNodes[t];return void 0===e&&(void 0===this._textureNodes[t]&&this.getTextureNode(t),this._previousTextureNodes[t]=e=xg(new vC(this,t,!0)),this._previousTextureNodes[t].updateTexture()),e}getViewZNode(t="depth"){let e=this._viewZNodes[t];if(void 0===e){const n=this._cameraNear,i=this._cameraFar;this._viewZNodes[t]=e=nS(this.getTextureNode(t),n,i)}return e}getLinearDepthNode(t="depth"){let e=this._linearDepthNodes[t];if(void 0===e){const n=this._cameraNear,i=this._cameraFar,s=this.getViewZNode(t);this._linearDepthNodes[t]=e=QT(s,n,i)}return e}setup({renderer:t}){return this.renderTarget.samples=void 0===this.options.samples?t.samples:this.options.samples,!0===t.backend.isWebGLBackend&&(this.renderTarget.samples=0),this.renderTarget.depthTexture.isMultisampleRenderTargetTexture=this.renderTarget.samples>1,this.scope===yC.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(t){const{renderer:e}=t,{scene:n,camera:i}=this;this._pixelRatio=e.getPixelRatio();const s=e.getSize(fC);this.setSize(s.width,s.height);const r=e.getRenderTarget(),a=e.getMRT();this._cameraNear.value=i.near,this._cameraFar.value=i.far;for(const t in this._previousTextures)this.toggleTexture(t);e.setRenderTarget(this.renderTarget),e.setMRT(this._mrt),e.render(n,i),e.setRenderTarget(r),e.setMRT(a)}setSize(t,e){this._width=t,this._height=e;const n=this._width*this._pixelRatio,i=this._height*this._pixelRatio;this.renderTarget.setSize(n,i)}setPixelRatio(t){this._pixelRatio=t,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}}yC.COLOR="color",yC.DEPTH="depth";const _C=(t,e,n)=>xg(new yC(yC.COLOR,t,e,n)),xC=(t,e)=>xg(new gC(t,e)),MC=(t,e)=>xg(new yC(yC.DEPTH,t,e)),bC=new BN,TC=new BN;class SC extends zf{static get type(){return"GaussianBlurNode"}constructor(t,e=null,n=2){super("vec4"),this.textureNode=t,this.directionNode=e,this.sigma=n,this._invSize=cv(new ei),this._passDirection=cv(new ei),this._horizontalRT=new Ei,this._horizontalRT.texture.name="GaussianBlurNode.horizontal",this._verticalRT=new Ei,this._verticalRT.texture.name="GaussianBlurNode.vertical",this._textureNode=xC(this,this._verticalRT.texture),this.updateBeforeType=Af.RENDER,this.resolution=new ei(1,1)}setSize(t,e){t=Math.max(Math.round(t*this.resolution.x),1),e=Math.max(Math.round(e*this.resolution.y),1),this._invSize.value.set(1/t,1/e),this._horizontalRT.setSize(t,e),this._verticalRT.setSize(t,e)}updateBefore(t){const{renderer:e}=t,n=this.textureNode,i=n.value,s=e.getRenderTarget(),r=e.getMRT(),a=n.value;bC.material=this._material,TC.material=this._material,this.setSize(i.image.width,i.image.height);const o=i.type;this._horizontalRT.texture.type=o,this._verticalRT.texture.type=o,e.setMRT(null),e.setRenderTarget(this._horizontalRT),this._passDirection.value.set(1,0),bC.render(e),n.value=this._horizontalRT.texture,e.setRenderTarget(this._verticalRT),this._passDirection.value.set(0,1),TC.render(e),e.setRenderTarget(s),e.setMRT(r),n.value=a}getTextureNode(){return this._textureNode}setup(t){const e=this.textureNode;if(!0!==e.isTextureNode)return console.error("GaussianBlurNode requires a TextureNode."),Wg();const n=e.uvNode||xx(),i=Og(this.directionNode||1),s=t=>e.uv(t),r=wg(()=>{const t=3+2*this.sigma,e=this._getCoefficients(t),r=this._invSize,a=i.mul(this._passDirection),o=Lg(e[0]).toVar(),l=Wg(s(n).mul(o)).toVar();for(let i=1;i<t;i++){const t=Lg(i),c=Lg(e[i]),u=Og(a.mul(r.mul(t))).toVar(),h=Wg(s(n.add(u))),d=Wg(s(n.sub(u)));l.addAssign(h.add(d).mul(c)),o.addAssign(Yv(2,c))}return l.div(o)}),a=this._material||(this._material=new lS);a.fragmentNode=r().context(t.getSharedContext()),a.name="Gaussian_blur",a.needsUpdate=!0;return t.getNodeProperties(this).textureNode=e,this._textureNode}dispose(){this._horizontalRT.dispose(),this._verticalRT.dispose()}_getCoefficients(t){const e=[];for(let n=0;n<t;n++)e.push(.39894*Math.exp(-.5*n*n/(t*t))/t);return e}}const wC=(t,e,n)=>xg(new SC(WN(t),e,n)),EC=new ei,AC=new BN;class NC extends zf{static get type(){return"AfterImageNode"}constructor(t,e=.96){super(t),this.textureNode=t,this.textureNodeOld=Ex(),this.damp=cv(e),this._compRT=new Ei,this._compRT.texture.name="AfterImageNode.comp",this._oldRT=new Ei,this._oldRT.texture.name="AfterImageNode.old",this._textureNode=xC(this,this._compRT.texture),this.updateBeforeType=Af.RENDER}getTextureNode(){return this._textureNode}setSize(t,e){this._compRT.setSize(t,e),this._oldRT.setSize(t,e)}updateBefore(t){const{renderer:e}=t,n=this.textureNode,i=n.value.type;this._compRT.texture.type=i,this._oldRT.texture.type=i,e.getDrawingBufferSize(EC),this.setSize(EC.x,EC.y);const s=e.getRenderTarget(),r=n.value;this.textureNodeOld.value=this._oldRT.texture,e.setRenderTarget(this._compRT),AC.render(e);const a=this._oldRT;this._oldRT=this._compRT,this._compRT=a,e.setRenderTarget(s),n.value=r}setup(t){const e=this.textureNode,n=this.textureNodeOld,i=e.uvNode||xx();n.uvNode=i;const s=wg(([t,e])=>{const n=Lg(e).toVar(),i=Wg(t).toVar();return e_(ky(i.sub(n)),0)}),r=wg(()=>{const t=Wg(n),r=Wg((t=>e.uv(t))(i));return t.mulAssign(this.damp.mul(s(t,.1))),e_(r,t)}),a=this._materialComposed||(this._materialComposed=new lS);a.name="AfterImage",a.fragmentNode=r(),AC.material=a;return t.getNodeProperties(this).textureNode=e,this._textureNode}dispose(){this._compRT.dispose(),this._oldRT.dispose()}}const CC=(t,e)=>xg(new NC(WN(t),e)),RC=wg(([t])=>DC(t.rgb)),IC=wg(([t,e=Lg(1)])=>e.mix(DC(t.rgb),t.rgb)),LC=wg(([t,e=Lg(1)])=>{const n=Xv(t.r,t.g,t.b).div(3),i=t.r.max(t.g.max(t.b)),s=i.sub(n).mul(e).mul(-3);return g_(t.rgb,i,s)}),PC=wg(([t,e=Lg(1)])=>{const n=Bg(.57735,.57735,.57735),i=e.cos();return Bg(t.rgb.mul(i).add(n.cross(t.rgb).mul(e.sin()).add(n.mul(o_(n,t.rgb).mul(i.oneMinus())))))}),UC=new Pi,DC=(t,e=Bg(...fi.getLuminanceCoefficients(UC)))=>o_(t,e),OC=(t,e)=>g_(Bg(0),t,DC(t).sub(e).max(0)),zC=new BN;class VC extends zf{static get type(){return"AnamorphicNode"}constructor(t,e,n,i){super("vec4"),this.textureNode=t,this.tresholdNode=e,this.scaleNode=n,this.colorNode=Bg(.1,0,1),this.samples=i,this.resolution=new ei(1,1),this._renderTarget=new Ei,this._renderTarget.texture.name="anamorphic",this._invSize=cv(new ei),this._textureNode=xC(this,this._renderTarget.texture),this.updateBeforeType=Af.RENDER}getTextureNode(){return this._textureNode}setSize(t,e){this._invSize.value.set(1/t,1/e),t=Math.max(Math.round(t*this.resolution.x),1),e=Math.max(Math.round(e*this.resolution.y),1),this._renderTarget.setSize(t,e)}updateBefore(t){const{renderer:e}=t,n=this.textureNode,i=n.value;this._renderTarget.texture.type=i.type;const s=e.getRenderTarget(),r=n.value;zC.material=this._material,this.setSize(i.image.width,i.image.height),e.setRenderTarget(this._renderTarget),zC.render(e),e.setRenderTarget(s),n.value=r}setup(t){const e=this.textureNode,n=e.uvNode||xx(),i=wg(()=>{const t=this.samples,i=Math.floor(t/2),s=Bg(0).toVar();return mT({start:-i,end:i},({i:t})=>{const r=Lg(t).abs().div(i).oneMinus(),a=(t=>e.uv(t))(Og(n.x.add(this._invSize.x.mul(t).mul(this.scaleNode)),n.y)),o=OC(a,this.tresholdNode).mul(r);s.addAssign(o)}),s.mul(this.colorNode)}),s=this._material||(this._material=new lS);s.name="Anamorphic",s.fragmentNode=i();return t.getNodeProperties(this).textureNode=e,this._textureNode}dispose(){this._renderTarget.dispose()}}const FC=(t,e=.9,n=3,i=32)=>xg(new VC(WN(t),xg(e),xg(n),i));class BC extends zf{static get type(){return"SobelOperatorNode"}constructor(t){super(),this.textureNode=t,this.updateBeforeType=Af.RENDER,this._invSize=cv(new ei)}updateBefore(){const t=this.textureNode.value;this._invSize.value.set(1/t.image.width,1/t.image.height)}setup(){const{textureNode:t}=this,e=t.uvNode||xx(),n=e=>t.uv(e);return wg(()=>{const t=this._invSize,i=Zg(-1,-2,-1,0,0,0,1,2,1),s=Zg(-1,0,1,-2,0,2,-1,0,1),r=DC(n(e.add(t.mul(Og(-1,-1)))).xyz),a=DC(n(e.add(t.mul(Og(-1,0)))).xyz),o=DC(n(e.add(t.mul(Og(-1,1)))).xyz),l=DC(n(e.add(t.mul(Og(0,-1)))).xyz),c=DC(n(e.add(t.mul(Og(0,0)))).xyz),u=DC(n(e.add(t.mul(Og(0,1)))).xyz),h=DC(n(e.add(t.mul(Og(1,-1)))).xyz),d=DC(n(e.add(t.mul(Og(1,0)))).xyz),p=DC(n(e.add(t.mul(Og(1,1)))).xyz),m=Xv(i[0][0].mul(r),i[1][0].mul(l),i[2][0].mul(h),i[0][1].mul(a),i[1][1].mul(c),i[2][1].mul(d),i[0][2].mul(o),i[1][2].mul(u),i[2][2].mul(p)),f=Xv(s[0][0].mul(r),s[1][0].mul(l),s[2][0].mul(h),s[0][1].mul(a),s[1][1].mul(c),s[2][1].mul(d),s[0][2].mul(o),s[1][2].mul(u),s[2][2].mul(p)),g=m.mul(m).add(f.mul(f)).sqrt();return Wg(Bg(g),1)})()}}const kC=t=>xg(new BC(WN(t)));class HC extends zf{static get type(){return"DepthOfFieldNode"}constructor(t,e,n,i,s){super(),this.textureNode=t,this.viewZNode=e,this.focusNode=n,this.apertureNode=i,this.maxblurNode=s,this._aspect=cv(0),this.updateBeforeType=Af.RENDER}updateBefore(){const t=this.textureNode.value;this._aspect.value=t.image.width/t.image.height}setup(){const t=this.textureNode,e=t.uvNode||xx(),n=e=>t.uv(e);return wg(()=>{const t=Og(1,this._aspect),i=this.focusNode.add(this.viewZNode),s=Og(v_(i.mul(this.apertureNode),this.maxblurNode.negate(),this.maxblurNode)),r=s.mul(.9),a=s.mul(.7),o=s.mul(.4);let l=Wg(0);return l=l.add(n(e)),l=l.add(n(e.add(Og(0,.4).mul(t).mul(s)))),l=l.add(n(e.add(Og(.15,.37).mul(t).mul(s)))),l=l.add(n(e.add(Og(.29,.29).mul(t).mul(s)))),l=l.add(n(e.add(Og(-.37,.15).mul(t).mul(s)))),l=l.add(n(e.add(Og(.4,0).mul(t).mul(s)))),l=l.add(n(e.add(Og(.37,-.15).mul(t).mul(s)))),l=l.add(n(e.add(Og(.29,-.29).mul(t).mul(s)))),l=l.add(n(e.add(Og(-.15,-.37).mul(t).mul(s)))),l=l.add(n(e.add(Og(0,-.4).mul(t).mul(s)))),l=l.add(n(e.add(Og(-.15,.37).mul(t).mul(s)))),l=l.add(n(e.add(Og(-.29,.29).mul(t).mul(s)))),l=l.add(n(e.add(Og(.37,.15).mul(t).mul(s)))),l=l.add(n(e.add(Og(-.4,0).mul(t).mul(s)))),l=l.add(n(e.add(Og(-.37,-.15).mul(t).mul(s)))),l=l.add(n(e.add(Og(-.29,-.29).mul(t).mul(s)))),l=l.add(n(e.add(Og(.15,-.37).mul(t).mul(s)))),l=l.add(n(e.add(Og(.15,.37).mul(t).mul(r)))),l=l.add(n(e.add(Og(-.37,.15).mul(t).mul(r)))),l=l.add(n(e.add(Og(.37,-.15).mul(t).mul(r)))),l=l.add(n(e.add(Og(-.15,-.37).mul(t).mul(r)))),l=l.add(n(e.add(Og(-.15,.37).mul(t).mul(r)))),l=l.add(n(e.add(Og(.37,.15).mul(t).mul(r)))),l=l.add(n(e.add(Og(-.37,-.15).mul(t).mul(r)))),l=l.add(n(e.add(Og(.15,-.37).mul(t).mul(r)))),l=l.add(n(e.add(Og(.29,.29).mul(t).mul(a)))),l=l.add(n(e.add(Og(.4,0).mul(t).mul(a)))),l=l.add(n(e.add(Og(.29,-.29).mul(t).mul(a)))),l=l.add(n(e.add(Og(0,-.4).mul(t).mul(a)))),l=l.add(n(e.add(Og(-.29,.29).mul(t).mul(a)))),l=l.add(n(e.add(Og(-.4,0).mul(t).mul(a)))),l=l.add(n(e.add(Og(-.29,-.29).mul(t).mul(a)))),l=l.add(n(e.add(Og(0,.4).mul(t).mul(a)))),l=l.add(n(e.add(Og(.29,.29).mul(t).mul(o)))),l=l.add(n(e.add(Og(.4,0).mul(t).mul(o)))),l=l.add(n(e.add(Og(.29,-.29).mul(t).mul(o)))),l=l.add(n(e.add(Og(0,-.4).mul(t).mul(o)))),l=l.add(n(e.add(Og(-.29,.29).mul(t).mul(o)))),l=l.add(n(e.add(Og(-.4,0).mul(t).mul(o)))),l=l.add(n(e.add(Og(-.29,-.29).mul(t).mul(o)))),l=l.add(n(e.add(Og(0,.4).mul(t).mul(o)))),l=l.div(41),l.a=1,Wg(l)})()}}const GC=(t,e,n=1,i=.025,s=1)=>xg(new HC(WN(t),xg(e),xg(n),xg(i),xg(s)));class WC extends zf{static get type(){return"DotScreenNode"}constructor(t,e=new ei(.5,.5),n=1.57,i=1){super("vec4"),this.inputNode=t,this.center=cv(e),this.angle=cv(n),this.scale=cv(i)}setup(){const t=this.inputNode,e=wg(()=>{const t=Uy(this.angle),e=Dy(this.angle),n=xx().mul(OT).sub(this.center),i=Og(e.mul(n.x).sub(t.mul(n.y)),t.mul(n.x).add(e.mul(n.y))).mul(this.scale);return Uy(i.x).mul(Uy(i.y)).mul(4)}),n=wg(()=>{const n=t,i=Xv(n.r,n.g,n.b).div(3);return Wg(Bg(i.mul(10).sub(5).add(e())),n.a)});return n()}}const jC=(t,e,n,i)=>xg(new WC(xg(t),e,n,i));class XC extends zf{static get type(){return"RGBShiftNode"}constructor(t,e=.005,n=0){super("vec4"),this.textureNode=t,this.amount=cv(e),this.angle=cv(n)}setup(){const{textureNode:t}=this,e=t.uvNode||xx(),n=e=>t.uv(e);return wg(()=>{const t=Og(Dy(this.angle),Uy(this.angle)).mul(this.amount),i=n(e.add(t)),s=n(e),r=n(e.sub(t));return Wg(i.r,s.g,r.b,s.a)})()}}const qC=(t,e,n)=>xg(new XC(WN(t),e,n));class YC extends zf{static get type(){return"FilmNode"}constructor(t,e=null,n=null){super(),this.inputNode=t,this.intensityNode=e,this.uvNode=n}setup(){const t=this.uvNode||xx(),e=wg(()=>{const e=this.inputNode.rgb,n=b_(Py(t.add(rN())));let i=e.add(e.mul(v_(n.add(.1),0,1)));return null!==this.intensityNode&&(i=g_(e,i,this.intensityNode)),Wg(i,this.inputNode.a)});return e()}}const ZC=Tg(YC);class $C extends zf{static get type(){return"Lut3DNode"}constructor(t,e,n,i){super(),this.inputNode=t,this.lutNode=e,this.size=cv(n),this.intensityNode=i}setup(){const{inputNode:t,lutNode:e}=this,n=wg(()=>{const n=t,i=Lg(1).div(this.size),s=Lg(.5).div(this.size),r=Bg(s).add(n.rgb.mul(Lg(1).sub(i))),a=Wg((t=>e.uv(t))(r).rgb,n.a);return Wg(g_(n,a,this.intensityNode))});return n()}}const JC=(t,e,n,i)=>xg(new $C(xg(t),xg(e),n,xg(i))),KC=new BN,QC=new er,tR=new ei;class eR extends zf{static get type(){return"GTAONode"}constructor(t,e,n){super(),this.depthNode=t,this.normalNode=e,this.radius=cv(.25),this.resolution=cv(new ei),this.thickness=cv(1),this.distanceExponent=cv(1),this.distanceFallOff=cv(1),this.scale=cv(1),this.noiseNode=Ex(function(t=5){const e=Math.floor(t)%2==0?Math.floor(t)+1:Math.floor(t),n=function(t){const e=Math.floor(t)%2==0?Math.floor(t)+1:Math.floor(t),n=e*e,i=Array(n).fill(0);let s=Math.floor(e/2),r=e-1;for(let t=1;t<=n;)-1===s&&r===e?(r=e-2,s=0):(r===e&&(r=0),s<0&&(s=e-1)),0===i[s*e+r]?(i[s*e+r]=t++,r++,s--):(r-=2,s++);return i}(e),i=n.length,s=new Uint8Array(4*i);for(let t=0;t<i;++t){const e=n[t],r=2*Math.PI*e/i,a=new Pi(Math.cos(r),Math.sin(r),0).normalize();s[4*t]=255*(.5*a.x+.5),s[4*t+1]=255*(.5*a.y+.5),s[4*t+2]=127,s[4*t+3]=255}const r=new jc(s,e,e);return r.wrapS=pt,r.wrapT=pt,r.needsUpdate=!0,r}()),this.cameraProjectionMatrix=cv(n.projectionMatrix),this.cameraProjectionMatrixInverse=cv(n.projectionMatrixInverse),this.SAMPLES=cv(16),this._aoRenderTarget=new Ei,this._aoRenderTarget.texture.name="GTAONode.AO",this._material=null,this._textureNode=xC(this,this._aoRenderTarget.texture),this.updateBeforeType=Af.FRAME}getTextureNode(){return this._textureNode}setSize(t,e){this.resolution.value.set(t,e),this._aoRenderTarget.setSize(t,e)}updateBefore(t){const{renderer:e}=t,n=e.getDrawingBufferSize(tR),i=e.getRenderTarget(),s=e.getMRT();e.getClearColor(QC);const r=e.getClearAlpha();KC.material=this._material,this.setSize(n.width,n.height),e.setMRT(null),e.setClearColor(16777215,1),e.setRenderTarget(this._aoRenderTarget),KC.render(e),e.setRenderTarget(i),e.setMRT(s),e.setClearColor(QC,r)}setup(t){const e=xx(),n=t=>this.depthNode.uv(t).x,i=t=>this.noiseNode.uv(t),s=wg(([t])=>{const e=this.cameraProjectionMatrix.mul(Wg(t,1));let i=e.xy.div(e.w).mul(.5).add(.5).toVar();i=Og(i.x,i.y.oneMinus());const s=n(i);return Bg(i,s)}),r=wg(([t,e])=>{t=Og(t.x,t.y.oneMinus()).mul(2).sub(1);const n=Wg(Bg(t,e),1),i=Wg(this.cameraProjectionMatrixInverse.mul(n));return i.xyz.div(i.w)}),a=wg(()=>{const t=n(e);t.greaterThanEqual(1).discard();const a=r(e,t),o=this.normalNode.rgb.normalize(),l=this.radius,c=bx(this.noiseNode,0);let u=Og(e.x,e.y.oneMinus());u=u.mul(this.resolution.div(c));const h=i(u),d=h.xyz.mul(2).sub(1),p=Bg(d.xy,0).normalize(),m=Bg(p.y.mul(-1),p.x,0),f=Zg(p,m,Bg(0,0,1)),g=this.SAMPLES.lessThan(30).select(3,5),v=Xv(this.SAMPLES,g.sub(1)).div(g),y=Lg(0).toVar();return mT({start:Pg(0),end:g,type:"int",condition:"<"},({i:t})=>{const e=Lg(t).div(Lg(g)).mul(vy),n=Wg(Dy(e),Uy(e),0,Xv(.5,Yv(.5,h.w)));n.xyz=Ly(f.mul(n.xyz));const i=Ly(a.xyz.negate()),c=Ly(l_(n.xyz,i)),u=l_(c,i),d=Ly(o.sub(c.mul(o_(o,c)))),p=l_(d,c),m=Og(o_(i,p),o_(i,p.negate())).toVar();mT({end:v,type:"int",name:"j",condition:"<"},({j:t})=>{const e=n.xyz.mul(l).mul(n.w).mul(c_(Zv(Lg(t).add(1),Lg(v)),this.distanceExponent)),o=s(a.add(e)),c=r(o.xy,o.z).sub(a);Cg(By(c.z).lessThan(this.thickness),()=>{const e=o_(i,Ly(c));m.x.addAssign(e_(0,Yv(e.sub(m.x),g_(1,Lg(2).div(Lg(t).add(2)),this.distanceFallOff))))});const u=s(a.sub(e)),h=r(u.xy,u.z).sub(a);Cg(By(h.z).lessThan(this.thickness),()=>{const e=o_(i,Ly(h));m.y.addAssign(e_(0,Yv(e.sub(m.y),g_(1,Lg(2).div(Lg(t).add(2)),this.distanceFallOff))))})});const _=Ny(qv(1,m.mul(m))),x=o_(d,u),M=o_(d,i),b=Yv(.5,Vy(m.y).sub(Vy(m.x)).add(_.x.mul(m.x).sub(_.y.mul(m.y)))),T=Yv(.5,qv(2,m.x.mul(m.x)).sub(m.y.mul(m.y))),S=x.mul(b).add(M.mul(T));y.addAssign(S)}),y.assign(v_(y.div(g),0,1)),y.assign(c_(y,this.scale)),Wg(Bg(y),1)}),o=this._material||(this._material=new lS);return o.fragmentNode=a().context(t.getSharedContext()),o.name="GTAO",o.needsUpdate=!0,this._textureNode}dispose(){this._aoRenderTarget.dispose()}}const nR=(t,e,n)=>xg(new eR(xg(t),xg(e),n));class iR extends zf{static get type(){return"DenoiseNode"}constructor(t,e,n,i,s){super(),this.textureNode=t,this.depthNode=e,this.normalNode=n,this.noiseNode=i,this.cameraProjectionMatrixInverse=cv(s.projectionMatrixInverse),this.lumaPhi=cv(5),this.depthPhi=cv(5),this.normalPhi=cv(5),this.radius=cv(5),this.index=cv(0),this._resolution=cv(new ei),this._sampleVectors=LM(function(t,e,n){const i=function(t,e,n){const i=[];for(let s=0;s<t;s++){const r=2*Math.PI*e*s/t,a=Math.pow(s/(t-1),n);i.push(new Pi(Math.cos(r),Math.sin(r),a))}return i}(t,e,n),s=[];for(let e=0;e<t;e++){const t=i[e];s.push(t)}return s}(16,2,1)),this.updateBeforeType=Af.RENDER}updateBefore(){const t=this.textureNode.value;this._resolution.value.set(t.image.width,t.image.height)}setup(){const t=xx(),e=t=>this.textureNode.uv(t),n=t=>this.depthNode.uv(t).x,i=t=>this.normalNode.uv(t),s=t=>this.noiseNode.uv(t),r=wg(([t,e])=>{t=Og(t.x,t.y.oneMinus()).mul(2).sub(1);const n=Wg(Bg(t,e),1),i=Wg(this.cameraProjectionMatrixInverse.mul(n));return i.xyz.div(i.w)}),a=wg(([t,s,a,o])=>{const l=e(o),c=n(o),u=i(o).rgb.normalize(),h=l.rgb,d=r(o,c),p=o_(s,u).toVar(),m=c_(e_(p,0),this.normalPhi).toVar(),f=By(DC(h).sub(DC(t))).toVar(),g=e_(Lg(1).sub(f.div(this.lumaPhi)),0).toVar(),v=By(o_(a.sub(d),s)).toVar(),y=e_(Lg(1).sub(v.div(this.depthPhi)),0),_=g.mul(y).mul(m);return Wg(h.mul(_),_)}),o=wg(([t])=>{const o=n(t),l=i(t).rgb.normalize(),c=e(t);Cg(o.greaterThanEqual(1).or(o_(l,l).equal(0)),()=>c);const u=Bg(c.rgb),h=r(t,o),d=bx(this.noiseNode,0);let p=Og(t.x,t.y.oneMinus());p=p.mul(this._resolution.div(d));const m=s(p),f=Uy(m.element(this.index.mod(4).mul(2).mul(vy))),g=Dy(m.element(this.index.mod(4).mul(2).mul(vy))),v=Og(f,g),y=Yg(v.x,v.y.negate(),v.x,v.y),_=Lg(1).toVar(),x=Bg(c.rgb).toVar();return mT({start:Pg(0),end:Pg(16),type:"int",condition:"<"},({i:e})=>{const n=this._sampleVectors.element(e).toVar(),i=y.mul(n.xy.mul(Lg(1).add(n.z.mul(this.radius.sub(1))))).div(this._resolution).toVar(),s=t.add(i).toVar(),r=a(u,l,h,s);x.addAssign(r.xyz),_.addAssign(r.w)}),Cg(_.greaterThan(Lg(0)),()=>{x.divAssign(_)}),Wg(x,c.a)}).setLayout({name:"denoise",type:"vec4",inputs:[{name:"uv",type:"vec2"}]});return wg(()=>o(t))()}}const sR=(t,e,n,i,s)=>xg(new iR(WN(t),xg(e),xg(n),xg(i),s));class rR extends zf{static get type(){return"FXAANode"}constructor(t){super(),this.textureNode=t,this.updateBeforeType=Af.RENDER,this._invSize=cv(new ei)}updateBefore(){const t=this.textureNode.value;this._invSize.value.set(1/t.image.width,1/t.image.height)}setup(){const t=this.textureNode.bias(-100),e=t.uvNode||xx(),n=e=>t.uv(e),i=(e,n,i)=>t.uv(e.add(n.mul(i))),s=Pg(5),r=wg(([t,e])=>{const n=Wg(e).toVar(),i=Wg(t).toVar(),s=Wg(By(i.sub(n))).toVar();return e_(e_(e_(s.r,s.g),s.b),s.a)}),a=wg(([t,e,a,o])=>{const l=n(t).toVar(),c=i(t,Og(0,-1),e.xy).toVar(),u=i(t,Og(1,0),e.xy).toVar(),h=i(t,Og(0,1),e.xy).toVar(),d=i(t,Og(-1,0),e.xy).toVar(),p=r(l,h).toVar(),m=r(l,c).toVar(),f=r(l,u).toVar(),g=r(l,d).toVar(),v=e_(p,e_(m,e_(f,g))).toVar();Cg(v.lessThan(a),()=>l);const y=qv(p.add(m),f.add(g)).toVar();y.mulAssign(o),Cg(By(y).lessThan(.3),()=>{const n=f.greaterThan(g).select(1,-1).toVar(),s=m.greaterThan(p).select(1,-1).toVar(),a=Og(n,s).toVar(),v=i(t,Og(a.x,a.y),e.xy),_=r(l,v).toVar(),x=i(t,Og(a.x.negate(),a.y.negate()),e.xy),M=r(l,x).toVar();y.assign(M.sub(_)),y.mulAssign(o),Cg(By(y).lessThan(.3),()=>{const t=h.add(c).add(u).add(d);return g_(l,t.mul(.25),.4)})});const _=Og().toVar();Cg(y.lessThanEqual(0),()=>{h.assign(d),c.assign(u),_.x.assign(0),_.y.assign(e.y)}).Else(()=>{_.x.assign(e.x),_.y.assign(0)});const x=r(l,h).toVar(),M=r(l,c).toVar();Cg(x.lessThanEqual(M),()=>{h.assign(c)});const b=Pg(0).toVar(),T=Pg(0).toVar(),S=Lg(0).toVar(),w=Lg(0).toVar(),E=Og(t).toVar(),A=Og(t).toVar(),N=Pg(0).toVar(),C=Pg(0).toVar();mT(s,({i:e})=>{const i=e.add(1).toVar();Cg(b.equal(0),()=>{S.addAssign(i),E.assign(t.add(_.mul(S)));const s=n(E.xy),a=r(s,l).toVar(),o=r(s,h).toVar();Cg(a.greaterThan(o),()=>{b.assign(1)}),N.assign(e)}),Cg(T.equal(0),()=>{w.addAssign(i),A.assign(t.sub(_.mul(w)));const s=n(A.xy),a=r(s,l).toVar(),o=r(s,h).toVar();Cg(a.greaterThan(o),()=>{T.assign(1)}),C.assign(e)}),Cg(b.equal(1).or(T.equal(1)),()=>{gT()})}),Cg(b.equal(0).and(T.equal(0)),()=>l);const R=Lg(1).toVar(),I=Lg(1).toVar();Cg(b.equal(1),()=>{R.assign(Lg(N).div(Lg(s.sub(1))))}),Cg(T.equal(1),()=>{I.assign(Lg(C).div(Lg(s.sub(1))))});const L=t_(R,I);return L.assign(c_(L,.5)),L.assign(Lg(1).sub(L)),g_(l,h,L.mul(.5))}).setLayout({name:"FxaaPixelShader",type:"vec4",inputs:[{name:"uv",type:"vec2"},{name:"fxaaQualityRcpFrame",type:"vec2"},{name:"fxaaQualityEdgeThreshold",type:"float"},{name:"fxaaQualityinvEdgeThreshold",type:"float"}]});return wg(()=>{const t=Lg(.2),n=Lg(1).div(t);return a(e,this._invSize,t,n)})()}}const aR=t=>xg(new rR(WN(t))),oR=new BN,lR=new er(0,0,0),cR=new er,uR=new ei,hR=new ei(1,0),dR=new ei(0,1);class pR extends zf{static get type(){return"BloomNode"}constructor(t,e=1,n=0,i=0){super(),this.inputNode=t,this.strength=cv(e),this.radius=cv(n),this.threshold=cv(i),this.smoothWidth=cv(.01),this._renderTargetsHorizontal=[],this._renderTargetsVertical=[],this._nMips=5,this._renderTargetBright=new Ei(1,1,{type:Pt}),this._renderTargetBright.texture.name="UnrealBloomPass.bright",this._renderTargetBright.texture.generateMipmaps=!1;for(let t=0;t<this._nMips;t++){const e=new Ei(1,1,{type:Pt});e.texture.name="UnrealBloomPass.h"+t,e.texture.generateMipmaps=!1,this._renderTargetsHorizontal.push(e);const n=new Ei(1,1,{type:Pt});n.texture.name="UnrealBloomPass.v"+t,n.texture.generateMipmaps=!1,this._renderTargetsVertical.push(n)}this._compositeMaterial=null,this._highPassFilterMaterial=null,this._separableBlurMaterials=[],this._textureNodeBright=Ex(this._renderTargetBright.texture),this._textureNodeBlur0=Ex(this._renderTargetsVertical[0].texture),this._textureNodeBlur1=Ex(this._renderTargetsVertical[1].texture),this._textureNodeBlur2=Ex(this._renderTargetsVertical[2].texture),this._textureNodeBlur3=Ex(this._renderTargetsVertical[3].texture),this._textureNodeBlur4=Ex(this._renderTargetsVertical[4].texture),this._textureOutput=xC(this,this._renderTargetsHorizontal[0].texture),this.updateBeforeType=Af.FRAME}getTextureNode(){return this._textureOutput}setSize(t,e){let n=Math.round(t/2),i=Math.round(e/2);this._renderTargetBright.setSize(n,i);for(let t=0;t<this._nMips;t++)this._renderTargetsHorizontal[t].setSize(n,i),this._renderTargetsVertical[t].setSize(n,i),this._separableBlurMaterials[t].invSize.value.set(1/n,1/i),n=Math.round(n/2),i=Math.round(i/2)}updateBefore(t){const{renderer:e}=t,n=e.getDrawingBufferSize(uR);this.setSize(n.width,n.height);const i=e.getRenderTarget(),s=e.getMRT();e.getClearColor(cR);const r=e.getClearAlpha();this.setSize(n.width,n.height),e.setMRT(null),e.setClearColor(lR,0),e.setRenderTarget(this._renderTargetBright),oR.material=this._highPassFilterMaterial,oR.render(e);let a=this._renderTargetBright;for(let t=0;t<this._nMips;t++)oR.material=this._separableBlurMaterials[t],this._separableBlurMaterials[t].colorTexture.value=a.texture,this._separableBlurMaterials[t].direction.value=hR,e.setRenderTarget(this._renderTargetsHorizontal[t]),e.clear(),oR.render(e),this._separableBlurMaterials[t].colorTexture.value=this._renderTargetsHorizontal[t].texture,this._separableBlurMaterials[t].direction.value=dR,e.setRenderTarget(this._renderTargetsVertical[t]),e.clear(),oR.render(e),a=this._renderTargetsVertical[t];e.setRenderTarget(this._renderTargetsHorizontal[0]),e.clear(),oR.material=this._compositeMaterial,oR.render(e),e.setRenderTarget(i),e.setMRT(s),e.setClearColor(cR,r)}setup(t){const e=wg(()=>{const t=this.inputNode,e=DC(t.rgb),n=x_(this.threshold,this.threshold.add(this.smoothWidth),e);return g_(Wg(0),t,n)});this._highPassFilterMaterial=this._highPassFilterMaterial||new lS,this._highPassFilterMaterial.fragmentNode=e().context(t.getSharedContext()),this._highPassFilterMaterial.name="Bloom_highPass",this._highPassFilterMaterial.needsUpdate=!0;const n=[3,5,7,9,11];for(let e=0;e<this._nMips;e++)this._separableBlurMaterials.push(this._getSeperableBlurMaterial(t,n[e]));const i=LM([1,.8,.6,.4,.2]),s=LM([new Pi(1,1,1),new Pi(1,1,1),new Pi(1,1,1),new Pi(1,1,1),new Pi(1,1,1)]),r=wg(([t,e])=>{const n=Lg(1.2).sub(t);return g_(t,n,e)}).setLayout({name:"lerpBloomFactor",type:"float",inputs:[{name:"factor",type:"float"},{name:"radius",type:"float"}]}),a=wg(()=>{const t=r(i.element(0),this.radius).mul(Wg(s.element(0),1)).mul(this._textureNodeBlur0),e=r(i.element(1),this.radius).mul(Wg(s.element(1),1)).mul(this._textureNodeBlur1),n=r(i.element(2),this.radius).mul(Wg(s.element(2),1)).mul(this._textureNodeBlur2),a=r(i.element(3),this.radius).mul(Wg(s.element(3),1)).mul(this._textureNodeBlur3),o=r(i.element(4),this.radius).mul(Wg(s.element(4),1)).mul(this._textureNodeBlur4);return t.add(e).add(n).add(a).add(o).mul(this.strength)});return this._compositeMaterial=this._compositeMaterial||new lS,this._compositeMaterial.fragmentNode=a().context(t.getSharedContext()),this._compositeMaterial.name="Bloom_comp",this._compositeMaterial.needsUpdate=!0,this._textureOutput}dispose(){for(let t=0;t<this._renderTargetsHorizontal.length;t++)this._renderTargetsHorizontal[t].dispose();for(let t=0;t<this._renderTargetsVertical.length;t++)this._renderTargetsVertical[t].dispose();this._renderTargetBright.dispose()}_getSeperableBlurMaterial(t,e){const n=[];for(let t=0;t<e;t++)n.push(.39894*Math.exp(-.5*t*t/(e*e))/e);const i=Ex(),s=LM(n),r=cv(new ei),a=cv(new ei(.5,.5)),o=xx(),l=t=>i.uv(t),c=wg(()=>{const t=s.element(0).toVar(),n=l(o).rgb.mul(t).toVar();return mT({start:Pg(1),end:Pg(e),type:"int",condition:"<"},({i:e})=>{const i=Lg(e),c=s.element(e),u=a.mul(r).mul(i),h=l(o.add(u)).rgb,d=l(o.sub(u)).rgb;n.addAssign(Xv(h,d).mul(c)),t.addAssign(Lg(2).mul(c))}),Wg(n.div(t),1)}),u=new lS;return u.fragmentNode=c().context(t.getSharedContext()),u.name="Bloom_seperable",u.needsUpdate=!0,u.colorTexture=i,u.direction=a,u.invSize=r,u}}const mR=(t,e,n,i)=>xg(new pR(xg(t),e,n,i));class fR extends zf{static get type(){return"TransitionNode"}constructor(t,e,n,i,s,r){super(),this.textureNodeA=t,this.textureNodeB=e,this.mixTextureNode=n,this.mixRatioNode=i,this.thresholdNode=s,this.useTextureNode=r}setup(){const{textureNodeA:t,textureNodeB:e,mixTextureNode:n,mixRatioNode:i,thresholdNode:s,useTextureNode:r}=this,a=t=>{const e=t.uvNode||xx();return t.uv(e)},o=wg(()=>{const o=a(t),l=a(e),c=Wg().toVar();return Cg(r.equal(Pg(1)),()=>{const t=a(n),e=i.mul(s.mul(2).add(1)).sub(s),r=v_(qv(t.r,e).mul(Lg(1).div(s)),0,1);c.assign(g_(o,l,r))}).Else(()=>{c.assign(g_(l,o,i))}),c});return o()}}const gR=(t,e,n,i=0,s=.1,r=0)=>xg(new fR(WN(t),WN(e),WN(n),xg(i),xg(s),xg(r)));class vR extends zf{static get type(){return"PixelationNode"}constructor(t,e,n,i,s,r){super(),this.textureNode=t,this.depthNode=e,this.normalNode=n,this.pixelSize=i,this.normalEdgeStrength=s,this.depthEdgeStrength=r,this._resolution=cv(new wi),this.updateBeforeType=Af.RENDER}updateBefore(){const t=this.textureNode.value,e=t.image.width,n=t.image.height;this._resolution.value.set(e,n,1/e,1/n)}setup(){const{textureNode:t,depthNode:e,normalNode:n}=this,i=t.uvNode||xx(),s=e.uvNode||xx(),r=n.uvNode||xx(),a=(t,n)=>e.uv(s.add(Og(t,n).mul(this._resolution.zw))).r,o=(t,e)=>n.uv(r.add(Og(t,e).mul(this._resolution.zw))).rgb.normalize(),l=(t,e,n,i)=>{const s=a(t,e).sub(n),r=o(t,e),l=Bg(1,1,1),c=o_(i.sub(r),l),u=v_(x_(-.01,.01,c),0,1),h=v_(ky(s.mul(.25).add(.0025)),0,1);return Lg(1).sub(o_(i,r)).mul(h).mul(u)},c=wg(()=>{const e=t.uv(i),n=hv("float","depth"),s=hv("vec3","normal");Cg(this.depthEdgeStrength.greaterThan(0).or(this.normalEdgeStrength.greaterThan(0)),()=>{n.assign(a(0,0)),s.assign(o(0,0))});const r=hv("float","dei");Cg(this.depthEdgeStrength.greaterThan(0),()=>{r.assign((t=>{const e=hv("float","diff");return e.addAssign(v_(a(1,0).sub(t))),e.addAssign(v_(a(-1,0).sub(t))),e.addAssign(v_(a(0,1).sub(t))),e.addAssign(v_(a(0,-1).sub(t))),Ry(x_(.01,.02,e).mul(2)).div(2)})(n))});const c=hv("float","nei");Cg(this.normalEdgeStrength.greaterThan(0),()=>{c.assign(((t,e)=>{const n=hv("float","indicator");return n.addAssign(l(0,-1,t,e)),n.addAssign(l(0,1,t,e)),n.addAssign(l(-1,0,t,e)),n.addAssign(l(1,0,t,e)),i_(.1,n)})(n,s))});const u=r.greaterThan(0).select(Lg(1).sub(r.mul(this.depthEdgeStrength)),c.mul(this.normalEdgeStrength).add(1));return e.mul(u)});return c()}}class yR extends yC{static get type(){return"PixelationPassNode"}constructor(t,e,n=6,i=.3,s=.4){super("color",t,e,{minFilter:gt,magFilter:gt}),this.pixelSize=n,this.normalEdgeStrength=i,this.depthEdgeStrength=s,this.isPixelationPassNode=!0,this._mrt=tN({output:Iv,normal:mM})}setSize(t,e){const n=this.pixelSize.value?this.pixelSize.value:this.pixelSize,i=Math.floor(t/n),s=Math.floor(e/n);super.setSize(i,s)}setup(){return((t,e,n,i=6,s=.3,r=.4)=>xg(new vR(WN(t),WN(e),WN(n),xg(i),xg(s),xg(r))))(super.getTextureNode("output"),super.getTextureNode("depth"),super.getTextureNode("normal"),this.pixelSize,this.normalEdgeStrength,this.depthEdgeStrength)}}const _R=(t,e,n,i,s)=>xg(new yR(t,e,n,i,s)),xR=new ei;class MR extends yC{static get type(){return"SSAAPassNode"}constructor(t,e){super(yC.COLOR,t,e),this.isSSAAPassNode=!0,this.sampleLevel=4,this.unbiased=!0,this.clearColor=new er(0),this.clearAlpha=0,this._currentClearColor=new er,this.sampleWeight=cv(1),this.sampleRenderTarget=null,this._quadMesh=new BN}updateBefore(t){const{renderer:e}=t,{scene:n,camera:i}=this;this._pixelRatio=e.getPixelRatio();const s=e.getSize(xR);this.setSize(s.width,s.height),this.sampleRenderTarget.setSize(this.renderTarget.width,this.renderTarget.height),e.getClearColor(this._currentClearColor);const r=e.getClearAlpha(),a=e.getRenderTarget(),o=e.getMRT(),l=e.autoClear;this._cameraNear.value=i.near,this._cameraFar.value=i.far,e.setMRT(this.getMRT()),e.autoClear=!1;const c=bR[Math.max(0,Math.min(this.sampleLevel,5))],u=1/c.length,h={fullWidth:this.renderTarget.width,fullHeight:this.renderTarget.height,offsetX:0,offsetY:0,width:this.renderTarget.width,height:this.renderTarget.height},d=Object.assign({},i.view);d.enabled&&Object.assign(h,d);for(let t=0;t<c.length;t++){const s=c[t];if(i.setViewOffset&&i.setViewOffset(h.fullWidth,h.fullHeight,h.offsetX+.0625*s[0],h.offsetY+.0625*s[1],h.width,h.height),this.sampleWeight.value=u,this.unbiased){const e=(t+.5)/c.length-.5;this.sampleWeight.value+=.03125*e}e.setClearColor(this.clearColor,this.clearAlpha),e.setRenderTarget(this.sampleRenderTarget),e.clear(),e.render(n,i),e.setRenderTarget(this.renderTarget),0===t&&(e.setClearColor(0,0),e.clear()),this._quadMesh.render(e)}e.copyTextureToTexture(this.sampleRenderTarget.depthTexture,this.renderTarget.depthTexture),i.setViewOffset&&d.enabled?i.setViewOffset(d.fullWidth,d.fullHeight,d.offsetX,d.offsetY,d.width,d.height):i.clearViewOffset&&i.clearViewOffset(),e.setRenderTarget(a),e.setMRT(o),e.autoClear=l,e.setClearColor(this._currentClearColor,r)}setup(t){let e;null===this.sampleRenderTarget&&(this.sampleRenderTarget=this.renderTarget.clone());const n=this.getMRT();if(null!==n){const t={};for(const e in n.outputNodes){const n=KA(this.sampleRenderTarget.textures,e);n>=0&&(t[e]=Ex(this.sampleRenderTarget.textures[n]).mul(this.sampleWeight))}e=tN(t)}else e=Ex(this.sampleRenderTarget.texture).mul(this.sampleWeight);return this._quadMesh.material=new lS,this._quadMesh.material.fragmentNode=e,this._quadMesh.material.transparent=!0,this._quadMesh.material.depthTest=!1,this._quadMesh.material.depthWrite=!1,this._quadMesh.material.premultipliedAlpha=!0,this._quadMesh.material.blending=2,this._quadMesh.material.normals=!1,this._quadMesh.material.name="SSAA",super.setup(t)}dispose(){super.dispose(),null!==this.sampleRenderTarget&&this.sampleRenderTarget.dispose()}}const bR=[[[0,0]],[[4,4],[-4,-4]],[[-2,-6],[6,-2],[-6,2],[2,6]],[[1,-3],[-1,3],[5,1],[-3,-5],[-5,5],[-7,-1],[3,7],[7,-7]],[[1,1],[-1,-3],[-3,2],[4,-1],[-5,-2],[2,5],[5,3],[3,-5],[-2,6],[0,-7],[-4,-6],[-6,4],[-8,0],[7,-4],[6,7],[-7,-8]],[[-4,-7],[-7,-5],[-3,-5],[-5,-4],[-1,-4],[-2,-2],[-6,-1],[-4,0],[-7,1],[-1,2],[-6,3],[-3,3],[-7,6],[-3,6],[-5,7],[-1,7],[5,-7],[1,-6],[6,-5],[4,-4],[2,-3],[7,-2],[1,-1],[4,-1],[2,1],[6,2],[0,4],[4,4],[2,5],[7,5],[5,6],[3,7]]],TR=(t,e)=>xg(new MR(t,e)),SR=new ei;class wR extends yC{static get type(){return"StereoPassNode"}constructor(t,e){super(yC.COLOR,t,e),this.isStereoPassNode=!0,this.stereo=new Hp,this.stereo.aspect=.5}updateBefore(t){const{renderer:e}=t,{scene:n,camera:i,stereo:s,renderTarget:r}=this;this._pixelRatio=e.getPixelRatio(),s.cameraL.coordinateSystem=e.coordinateSystem,s.cameraR.coordinateSystem=e.coordinateSystem,s.update(i);const a=e.getSize(SR);this.setSize(a.width,a.height);const o=e.autoClear;e.autoClear=!1;const l=e.getRenderTarget(),c=e.getMRT();this._cameraNear.value=i.near,this._cameraFar.value=i.far;for(const t in this._previousTextures)this.toggleTexture(t);e.setRenderTarget(r),e.setMRT(this._mrt),e.clear(),r.scissorTest=!0,r.scissor.set(0,0,r.width/2,r.height),r.viewport.set(0,0,r.width/2,r.height),e.render(n,s.cameraL),r.scissor.set(r.width/2,0,r.width/2,r.height),r.viewport.set(r.width/2,0,r.width/2,r.height),e.render(n,s.cameraR),r.scissorTest=!1,e.setRenderTarget(l),e.setMRT(c),e.autoClear=o}}const ER=(t,e)=>xg(new wR(t,e)),AR=new ei,NR=new BN;class CR extends yC{static get type(){return"StereoCompositePassNode"}constructor(t,e){super(yC.COLOR,t,e),this.isStereoCompositePassNode=!0,this.stereo=new Hp;const n={minFilter:Mt,magFilter:gt,type:Pt};this._renderTargetL=new Ei(1,1,n),this._renderTargetR=new Ei(1,1,n),this._mapLeft=Ex(this._renderTargetL.texture),this._mapRight=Ex(this._renderTargetR.texture),this._material=null}updateStereoCamera(t){this.stereo.cameraL.coordinateSystem=t,this.stereo.cameraR.coordinateSystem=t,this.stereo.update(this.camera)}setSize(t,e){super.setSize(t,e),this._renderTargetL.setSize(this.renderTarget.width,this.renderTarget.height),this._renderTargetR.setSize(this.renderTarget.width,this.renderTarget.height)}updateBefore(t){const{renderer:e}=t,{scene:n,stereo:i,renderTarget:s}=this;this._pixelRatio=e.getPixelRatio(),this.updateStereoCamera(e.coordinateSystem);const r=e.getSize(AR);this.setSize(r.width,r.height);const a=e.getRenderTarget();e.setRenderTarget(this._renderTargetL),e.render(n,i.cameraL),e.setRenderTarget(this._renderTargetR),e.render(n,i.cameraR),e.setRenderTarget(s),NR.material=this._material,NR.render(e),e.setRenderTarget(a)}dispose(){super.dispose(),this._renderTargetL.dispose(),this._renderTargetR.dispose(),null!==this._material&&this._material.dispose()}}class RR extends CR{static get type(){return"AnaglyphPassNode"}constructor(t,e){super(t,e),this.isAnaglyphPassNode=!0,this._colorMatrixLeft=cv((new ni).fromArray([.4561,-.0400822,-.0152161,.500484,-.0378246,-.0205971,.176381,-.0157589,-.00546856])),this._colorMatrixRight=cv((new ni).fromArray([-.0434706,.378476,-.0721527,-.0879388,.73364,-.112961,-.00155529,-.0184503,1.2264]))}setup(t){const e=xx(),n=wg(()=>{const t=this._mapLeft.uv(e),n=this._mapRight.uv(e),i=v_(this._colorMatrixLeft.mul(t.rgb).add(this._colorMatrixRight.mul(n.rgb)));return Wg(i.rgb,e_(t.a,n.a))}),i=this._material||(this._material=new lS);return i.fragmentNode=n().context(t.getSharedContext()),i.name="Anaglyph",i.needsUpdate=!0,super.setup(t)}}const IR=(t,e)=>xg(new RR(t,e));class LR extends CR{static get type(){return"ParallaxBarrierPassNode"}constructor(t,e){super(t,e),this.isParallaxBarrierPassNode=!0}setup(t){const e=xx(),n=wg(()=>{const t=Wg().toVar();return Cg(n_(zT.y,2).greaterThan(1),()=>{t.assign(this._mapLeft.uv(e))}).Else(()=>{t.assign(this._mapRight.uv(e))}),t}),i=this._material||(this._material=new lS);return i.fragmentNode=n().context(t.getSharedContext()),i.needsUpdate=!0,super.setup(t)}}const PR=(t,e)=>xg(new LR(t,e));class UR extends yC{static get type(){return"ToonOutlinePassNode"}constructor(t,e,n,i,s){super(yC.COLOR,t,e),this.colorNode=n,this.thicknessNode=i,this.alphaNode=s,this._materialCache=new WeakMap}updateBefore(t){const{renderer:e}=t,n=e.getRenderObjectFunction();e.setRenderObjectFunction((t,n,i,s,r,a,o)=>{if((r.isMeshToonMaterial||r.isMeshToonNodeMaterial)&&!1===r.wireframe){const l=this._getOutlineMaterial(r);e.renderObject(t,n,i,s,l,a,o)}e.renderObject(t,n,i,s,r,a,o)}),super.updateBefore(t),e.setRenderObjectFunction(n)}_createMaterial(){const t=new lS;t.isMeshToonOutlineMaterial=!0,t.name="Toon_Outline",t.side=1;const e=dM.negate(),n=Lx.mul(Kx),i=Lg(1),s=n.mul(Wg(nM,1)),r=n.mul(Wg(nM.add(e),1)),a=Ly(s.sub(r));return t.vertexNode=s.add(a.mul(this.thicknessNode).mul(s.w).mul(i)),t.colorNode=Wg(this.colorNode,this.alphaNode),t}_getOutlineMaterial(t){let e=this._materialCache.get(t);return void 0===e&&(e=this._createMaterial(),this._materialCache.set(t,e)),e}}const DR=(t,e,n=new er(0,0,0),i=.003,s=1)=>xg(new UR(t,e,xg(n),xg(i),xg(s)));class OR extends Uf{static get type(){return"ScriptableValueNode"}constructor(t=null){super(),this._value=t,this._cache=null,this.inputType=null,this.outpuType=null,this.events=new Gn,this.isScriptableValueNode=!0}get isScriptableOutputNode(){return null!==this.outputType}set value(t){this._value!==t&&(this._cache&&"URL"===this.inputType&&this.value.value instanceof ArrayBuffer&&(URL.revokeObjectURL(this._cache),this._cache=null),this._value=t,this.events.dispatchEvent({type:"change"}),this.refresh())}get value(){return this._value}refresh(){this.events.dispatchEvent({type:"refresh"})}getValue(){const t=this.value;if(t&&null===this._cache&&"URL"===this.inputType&&t.value instanceof ArrayBuffer)this._cache=URL.createObjectURL(new Blob([t.value]));else if(t&&null!==t.value&&void 0!==t.value&&(("URL"===this.inputType||"String"===this.inputType)&&"string"==typeof t.value||"Number"===this.inputType&&"number"==typeof t.value||"Vector2"===this.inputType&&t.value.isVector2||"Vector3"===this.inputType&&t.value.isVector3||"Vector4"===this.inputType&&t.value.isVector4||"Color"===this.inputType&&t.value.isColor||"Matrix3"===this.inputType&&t.value.isMatrix3||"Matrix4"===this.inputType&&t.value.isMatrix4))return t.value;return this._cache||t}getNodeType(t){return this.value&&this.value.isNode?this.value.getNodeType(t):"float"}setup(){return this.value&&this.value.isNode?this.value:Lg()}serialize(t){super.serialize(t),null!==this.value?"ArrayBuffer"===this.inputType?t.value=Tf(this.value):t.value=this.value?this.value.toJSON(t.meta).uuid:null:t.value=null,t.inputType=this.inputType,t.outputType=this.outputType}deserialize(t){super.deserialize(t);let e=null;null!==t.value&&(e="ArrayBuffer"===t.inputType?Sf(t.value):"Texture"===t.inputType?t.meta.textures[t.value]:t.meta.nodes[t.value]||null),this.value=e,this.inputType=t.inputType,this.outputType=t.outputType}}const zR=Tg(OR);class VR extends Map{get(t,e=null,...n){if(this.has(t))return super.get(t);if(null!==e){const i=e(...n);return this.set(t,i),i}}}class FR{constructor(t){this.scriptableNode=t}get parameters(){return this.scriptableNode.parameters}get layout(){return this.scriptableNode.getLayout()}getInputLayout(t){return this.scriptableNode.getInputLayout(t)}get(t){const e=this.parameters[t];return e?e.getValue():null}}const BR=new VR;class kR extends Uf{static get type(){return"ScriptableNode"}constructor(t=null,e={}){super(),this.codeNode=t,this.parameters=e,this._local=new VR,this._output=zR(),this._outputs={},this._source=this.source,this._method=null,this._object=null,this._value=null,this._needsOutputUpdate=!0,this.onRefresh=this.onRefresh.bind(this),this.isScriptableNode=!0}get source(){return this.codeNode?this.codeNode.code:""}setLocal(t,e){return this._local.set(t,e)}getLocal(t){return this._local.get(t)}onRefresh(){this._refresh()}getInputLayout(t){for(const e of this.getLayout())if(e.inputType&&(e.id===t||e.name===t))return e}getOutputLayout(t){for(const e of this.getLayout())if(e.outputType&&(e.id===t||e.name===t))return e}setOutput(t,e){const n=this._outputs;return void 0===n[t]?n[t]=zR(e):n[t].value=e,this}getOutput(t){return this._outputs[t]}getParameter(t){return this.parameters[t]}setParameter(t,e){const n=this.parameters;return e&&e.isScriptableNode?(this.deleteParameter(t),n[t]=e,n[t].getDefaultOutput().events.addEventListener("refresh",this.onRefresh)):e&&e.isScriptableValueNode?(this.deleteParameter(t),n[t]=e,n[t].events.addEventListener("refresh",this.onRefresh)):void 0===n[t]?(n[t]=zR(e),n[t].events.addEventListener("refresh",this.onRefresh)):n[t].value=e,this}getValue(){return this.getDefaultOutput().getValue()}deleteParameter(t){let e=this.parameters[t];return e&&(e.isScriptableNode&&(e=e.getDefaultOutput()),e.events.removeEventListener("refresh",this.onRefresh)),this}clearParameters(){for(const t of Object.keys(this.parameters))this.deleteParameter(t);return this.needsUpdate=!0,this}call(t,...e){const n=this.getObject()[t];if("function"==typeof n)return n(...e)}async callAsync(t,...e){const n=this.getObject()[t];if("function"==typeof n)return"AsyncFunction"===n.constructor.name?await n(...e):n(...e)}getNodeType(t){return this.getDefaultOutputNode().getNodeType(t)}refresh(t=null){null!==t?this.getOutput(t).refresh():this._refresh()}getObject(){if(this.needsUpdate&&this.dispose(),null!==this._object)return this._object;const t=new FR(this),e=BR.get("THREE"),n=BR.get("TSL"),i=this.getMethod(this.codeNode),s=[t,this._local,BR,()=>this.refresh(),(t,e)=>this.setOutput(t,e),e,n];this._object=i(...s);const r=this._object.layout;if(r&&(!1===r.cache&&this._local.clear(),this._output.outputType=r.outputType||null,Array.isArray(r.elements)))for(const t of r.elements){const e=t.id||t.name;t.inputType&&(void 0===this.getParameter(e)&&this.setParameter(e,null),this.getParameter(e).inputType=t.inputType),t.outputType&&(void 0===this.getOutput(e)&&this.setOutput(e,null),this.getOutput(e).outputType=t.outputType)}return this._object}deserialize(t){super.deserialize(t);for(const t in this.parameters){let e=this.parameters[t];e.isScriptableNode&&(e=e.getDefaultOutput()),e.events.addEventListener("refresh",this.onRefresh)}}getLayout(){return this.getObject().layout}getDefaultOutputNode(){const t=this.getDefaultOutput().value;return t&&t.isNode?t:Lg()}getDefaultOutput(){return this._exec()._output}getMethod(){if(this.needsUpdate&&this.dispose(),null!==this._method)return this._method;const t=["layout","init","main","dispose"].join(", "),e="\nreturn { ...output, "+t+" };",n="var "+t+"; var output = {};\n"+this.codeNode.code+e;return this._method=new Function(...["parameters","local","global","refresh","setOutput","THREE","TSL"],n),this._method}dispose(){null!==this._method&&(this._object&&"function"==typeof this._object.dispose&&this._object.dispose(),this._method=null,this._object=null,this._source=null,this._value=null,this._needsOutputUpdate=!0,this._output.value=null,this._outputs={})}setup(){return this.getDefaultOutputNode()}getCacheKey(t){const e=[gf(this.source),this.getDefaultOutputNode().getCacheKey(t)];for(const n in this.parameters)e.push(this.parameters[n].getCacheKey(t));return vf(e)}set needsUpdate(t){!0===t&&this.dispose()}get needsUpdate(){return this.source!==this._source}_exec(){return null===this.codeNode||(!0===this._needsOutputUpdate&&(this._value=this.call("main"),this._needsOutputUpdate=!1),this._output.value=this._value),this}_refresh(){this.needsUpdate=!0,this._exec(),this._output.refresh()}}const HR=Tg(kR);class GR extends Uf{static get type(){return"FogNode"}constructor(t,e){super("float"),this.isFogNode=!0,this.colorNode=t,this.factorNode=e}getViewZNode(t){let e;const n=t.context.getViewZ;return void 0!==n&&(e=n(this)),(e||aM.z).negate()}setup(){return this.factorNode}}const WR=Tg(GR);class jR extends GR{static get type(){return"FogRangeNode"}constructor(t,e,n){super(t),this.isFogRangeNode=!0,this.nearNode=e,this.farNode=n}setup(t){const e=this.getViewZNode(t);return x_(this.nearNode,this.farNode,e)}}const XR=Tg(jR);class qR extends GR{static get type(){return"FogExp2Node"}constructor(t,e){super(t),this.isFogExp2Node=!0,this.densityNode=e}setup(t){const e=this.getViewZNode(t),n=this.densityNode;return n.mul(n,e,e).negate().exp().oneMinus()}}const YR=Tg(qR);let ZR=null,$R=null;class JR extends Uf{static get type(){return"RangeNode"}constructor(t=Lg(),e=Lg()){super(),this.minNode=t,this.maxNode=e}getVectorLength(t){const e=t.getTypeLength(Mf(this.minNode.value)),n=t.getTypeLength(Mf(this.maxNode.value));return e>n?e:n}getNodeType(t){return t.object.count>1?t.getTypeFromLength(this.getVectorLength(t)):"float"}setup(t){const e=t.object;let n=null;if(e.count>1){const i=this.minNode.value,s=this.maxNode.value,r=t.getTypeLength(Mf(i)),a=t.getTypeLength(Mf(s));ZR=ZR||new wi,$R=$R||new wi,ZR.setScalar(0),$R.setScalar(0),1===r?ZR.setScalar(i):i.isColor?ZR.set(i.r,i.g,i.b):ZR.set(i.x,i.y,i.z||0,i.w||0),1===a?$R.setScalar(s):s.isColor?$R.set(s.r,s.g,s.b):$R.set(s.x,s.y,s.z||0,s.w||0);const o=4,l=o*e.count,c=new Float32Array(l);for(let t=0;t<l;t++){const e=t%o,n=ZR.getComponent(e),i=$R.getComponent(e);c[t]=ti.lerp(n,i,Math.random())}const u=this.getNodeType(t);if(e.count<=4096)n=CM(c,"vec4",e.count).element(tT).convert(u);else{const e=new Zc(c,4);t.geometry.setAttribute("__range"+this.id,e),n=tx(e).convert(u)}}else n=Lg(0);return n}}const KR=Tg(JR),QR=wg(({depthTexture:t,shadowCoord:e})=>Ex(t,e.xy).compare(e.z)),tI=wg(({depthTexture:t,shadowCoord:e,shadow:n})=>{const i=(e,n)=>Ex(t,e).compare(n),s=OM("mapSize","vec2",n).setGroup(av),r=OM("radius","float",n).setGroup(av),a=Og(1).div(s),o=a.x.negate().mul(r),l=a.y.negate().mul(r),c=a.x.mul(r),u=a.y.mul(r),h=o.div(2),d=l.div(2),p=c.div(2),m=u.div(2);return Xv(i(e.xy.add(Og(o,l)),e.z),i(e.xy.add(Og(0,l)),e.z),i(e.xy.add(Og(c,l)),e.z),i(e.xy.add(Og(h,d)),e.z),i(e.xy.add(Og(0,d)),e.z),i(e.xy.add(Og(p,d)),e.z),i(e.xy.add(Og(o,0)),e.z),i(e.xy.add(Og(h,0)),e.z),i(e.xy,e.z),i(e.xy.add(Og(p,0)),e.z),i(e.xy.add(Og(c,0)),e.z),i(e.xy.add(Og(h,m)),e.z),i(e.xy.add(Og(0,m)),e.z),i(e.xy.add(Og(p,m)),e.z),i(e.xy.add(Og(o,u)),e.z),i(e.xy.add(Og(0,u)),e.z),i(e.xy.add(Og(c,u)),e.z)).mul(1/17)}),eI=wg(({depthTexture:t,shadowCoord:e,shadow:n})=>{const i=(e,n)=>Ex(t,e).compare(n),s=OM("mapSize","vec2",n).setGroup(av),r=Og(1).div(s),a=r.x,o=r.y,l=e.xy,c=Py(l.mul(s).add(.5));return l.subAssign(c.mul(r)),Xv(i(l,e.z),i(l.add(Og(a,0)),e.z),i(l.add(Og(0,o)),e.z),i(l.add(r),e.z),g_(i(l.add(Og(a.negate(),0)),e.z),i(l.add(Og(a.mul(2),0)),e.z),c.x),g_(i(l.add(Og(a.negate(),o)),e.z),i(l.add(Og(a.mul(2),o)),e.z),c.x),g_(i(l.add(Og(0,o.negate())),e.z),i(l.add(Og(0,o.mul(2))),e.z),c.y),g_(i(l.add(Og(a,o.negate())),e.z),i(l.add(Og(a,o.mul(2))),e.z),c.y),g_(g_(i(l.add(Og(a.negate(),o.negate())),e.z),i(l.add(Og(a.mul(2),o.negate())),e.z),c.x),g_(i(l.add(Og(a.negate(),o.mul(2))),e.z),i(l.add(Og(a.mul(2),o.mul(2))),e.z),c.x),c.y)).mul(1/9)}),nI=wg(({depthTexture:t,shadowCoord:e})=>{const n=Lg(1).toVar(),i=Ex(t).uv(e.xy).rg,s=i_(e.z,i.x);return Cg(s.notEqual(Lg(1)),()=>{const t=e.z.sub(i.x),r=e_(0,i.y.mul(i.y));let a=r.div(r.add(t.mul(t)));a=v_(qv(a,.3).div(.95-.3)),n.assign(v_(e_(s,a)))}),n}),iI=wg(({samples:t,radius:e,size:n,shadowPass:i})=>{const s=Lg(0).toVar(),r=Lg(0).toVar(),a=t.lessThanEqual(Lg(1)).select(Lg(0),Lg(2).div(t.sub(1))),o=t.lessThanEqual(Lg(1)).select(Lg(0),Lg(-1));mT({start:Pg(0),end:Pg(t),type:"int",condition:"<"},({i:t})=>{const l=o.add(Lg(t).mul(a)),c=i.uv(Xv(zT.xy,Og(0,l).mul(e)).div(n)).x;s.addAssign(c),r.addAssign(c.mul(c))}),s.divAssign(t),r.divAssign(t);const l=Ny(r.sub(s.mul(s)));return Og(s,l)}),sI=wg(({samples:t,radius:e,size:n,shadowPass:i})=>{const s=Lg(0).toVar(),r=Lg(0).toVar(),a=t.lessThanEqual(Lg(1)).select(Lg(0),Lg(2).div(t.sub(1))),o=t.lessThanEqual(Lg(1)).select(Lg(0),Lg(-1));mT({start:Pg(0),end:Pg(t),type:"int",condition:"<"},({i:t})=>{const l=o.add(Lg(t).mul(a)),c=i.uv(Xv(zT.xy,Og(l,0).mul(e)).div(n));s.addAssign(c.x),r.addAssign(Xv(c.y.mul(c.y),c.x.mul(c.x)))}),s.divAssign(t),r.divAssign(t);const l=Ny(r.sub(s.mul(s)));return Og(s,l)}),rI=[QR,tI,eI,nI];let aI=null;const oI=new BN;class lI extends AT{static get type(){return"AnalyticLightNode"}constructor(t=null){super(),this.updateType=Af.FRAME,this.light=t,this.color=new er,this.colorNode=cv(this.color).setGroup(av),this.baseColorNode=null,this.shadowMap=null,this.shadowNode=null,this.shadowColorNode=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this.isAnalyticLightNode=!0}getCacheKey(){return yf(super.getCacheKey(),this.light.id,this.light.castShadow?1:0)}getHash(){return this.light.uuid}setupShadow(t){const{object:e,renderer:n}=t;if(!1===n.shadowMap.enabled)return;let i=this.shadowColorNode;if(null===i){null===aI&&(aI=new lS,aI.fragmentNode=Wg(0,0,0,1),aI.isShadowNodeMaterial=!0,aI.name="ShadowMaterial");const s=n.shadowMap.type,r=this.light.shadow,a=new no;a.compareFunction=513;const o=t.createRenderTarget(r.mapSize.width,r.mapSize.height);if(o.depthTexture=a,r.camera.updateProjectionMatrix(),3===s){a.compareFunction=null,this.vsmShadowMapVertical=t.createRenderTarget(r.mapSize.width,r.mapSize.height,{format:Yt,type:Pt}),this.vsmShadowMapHorizontal=t.createRenderTarget(r.mapSize.width,r.mapSize.height,{format:Yt,type:Pt});const e=Ex(a),n=Ex(this.vsmShadowMapVertical.texture),i=OM("blurSamples","float",r).setGroup(av),s=OM("radius","float",r).setGroup(av),o=OM("mapSize","vec2",r).setGroup(av);let l=this.vsmMaterialVertical||(this.vsmMaterialVertical=new lS);l.fragmentNode=iI({samples:i,radius:s,size:o,shadowPass:e}).context(t.getSharedContext()),l.name="VSMVertical",l=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new lS),l.fragmentNode=sI({samples:i,radius:s,size:o,shadowPass:n}).context(t.getSharedContext()),l.name="VSMHorizontal"}const l=OM("intensity","float",r).setGroup(av),c=OM("bias","float",r).setGroup(av),u=OM("normalBias","float",r).setGroup(av),h=e.material.shadowPositionNode||sM;let d=cv(r.matrix).setGroup(av).mul(h.add(fM.mul(u)));d=d.xyz.div(d.w);let p=d.z.add(c);n.coordinateSystem===Hn&&(p=p.mul(2).sub(1)),d=Bg(d.x,d.y.oneMinus(),p);const m=d.x.greaterThanEqual(0).and(d.x.lessThanEqual(1)).and(d.y.greaterThanEqual(0)).and(d.y.lessThanEqual(1)).and(d.z.lessThanEqual(1)),f=r.filterNode||rI[n.shadowMap.type]||null;if(null===f)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const g=Ex(o.texture,d),v=m.select(f({depthTexture:3===s?this.vsmShadowMapHorizontal.texture:a,shadowCoord:d,shadow:r}),Lg(1));this.shadowMap=o,this.light.shadow.map=o,this.shadowNode=v,this.shadowColorNode=i=this.colorNode.mul(g_(1,v.rgb.mix(g,1),l.mul(g.a))),this.baseColorNode=this.colorNode}this.colorNode=i,this.updateBeforeType=Af.RENDER}setup(t){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?t.object.receiveShadow&&this.setupShadow(t):null!==this.shadowNode&&this.disposeShadow()}updateShadow(t){const{shadowMap:e,light:n}=this,{renderer:i,scene:s,camera:r}=t,a=i.shadowMap.type,o=e.depthTexture.version;this._depthVersionCached=o;const l=s.overrideMaterial;s.overrideMaterial=aI,e.setSize(n.shadow.mapSize.width,n.shadow.mapSize.height),n.shadow.updateMatrices(n),n.shadow.camera.layers.mask=r.layers.mask;const c=i.getRenderTarget(),u=i.getRenderObjectFunction();i.setRenderObjectFunction((t,...e)=>{(!0===t.castShadow||t.receiveShadow&&3===a)&&i.renderObject(t,...e)}),i.setRenderTarget(e),i.render(s,n.shadow.camera),i.setRenderObjectFunction(u),!0!==n.isPointLight&&3===a&&this.vsmPass(t,n),i.setRenderTarget(c),s.overrideMaterial=l}vsmPass(t,e){const{renderer:n}=t;this.vsmShadowMapVertical.setSize(e.shadow.mapSize.width,e.shadow.mapSize.height),this.vsmShadowMapHorizontal.setSize(e.shadow.mapSize.width,e.shadow.mapSize.height),n.setRenderTarget(this.vsmShadowMapVertical),oI.material=this.vsmMaterialVertical,oI.render(n),n.setRenderTarget(this.vsmShadowMapHorizontal),oI.material=this.vsmMaterialHorizontal,oI.render(n)}disposeShadow(){this.shadowMap.dispose(),this.shadowMap=null,null!==this.vsmShadowMapVertical&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),null!==this.vsmShadowMapHorizontal&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null),this.shadowNode=null,this.shadowColorNode=null,this.baseColorNode=null,this.updateBeforeType=Af.NONE}updateBefore(t){const e=this.light.shadow;(e.needsUpdate||e.autoUpdate)&&(this.updateShadow(t),this.shadowMap.depthTexture.version===this._depthVersionCached&&(e.needsUpdate=!1))}update(){const{light:t}=this;this.color.copy(t.color).multiplyScalar(t.intensity)}}const cI=wg(t=>{const{lightDistance:e,cutoffDistance:n,decayExponent:i}=t,s=e.pow(i).max(.01).reciprocal();return n.greaterThan(0).select(s.mul(e.div(n).pow4().oneMinus().clamp().pow2()),s)});let uI;function hI(t){uI=uI||new WeakMap;let e=uI.get(t);return void 0===e&&uI.set(t,e={}),e}function dI(t){const e=hI(t);return e.position||(e.position=cv(new Pi).setGroup(av).onRenderUpdate((e,n)=>n.value.setFromMatrixPosition(t.matrixWorld)))}function pI(t){const e=hI(t);return e.targetPosition||(e.targetPosition=cv(new Pi).setGroup(av).onRenderUpdate((e,n)=>n.value.setFromMatrixPosition(t.target.matrixWorld)))}function mI(t){const e=hI(t);return e.viewPosition||(e.viewPosition=cv(new Pi).setGroup(av).onRenderUpdate(({camera:e},n)=>{n.value=n.value||new Pi,n.value.setFromMatrixPosition(t.matrixWorld),n.value.applyMatrix4(e.matrixWorldInverse)}))}const fI=t=>Ux.transformDirection(dI(t).sub(pI(t))),gI=wg(([t])=>{const e=t.toUint().mul(747796405).add(2891336453),n=e.shiftRight(e.shiftRight(28).add(4)).bitXor(e).mul(277803737);return n.shiftRight(22).bitXor(n).toFloat().mul(1/2**32)}),vI=(t,e)=>c_(Yv(4,t.mul(qv(1,t))),e),yI=(t,e)=>t.lessThan(.5)?vI(t.mul(2),e).div(2):qv(1,vI(Yv(qv(1,t),2),e).div(2)),_I=(t,e,n)=>c_(Zv(c_(t,e),Xv(c_(t,e),c_(qv(1,t),n))),1/e),xI=(t,e)=>Uy(vy.mul(e.mul(t).sub(1))).div(vy.mul(e.mul(t).sub(1))),MI=wg(([t])=>t.fract().sub(.5).abs()).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),bI=wg(([t])=>Bg(MI(t.z.add(MI(t.y.mul(1)))),MI(t.z.add(MI(t.x.mul(1)))),MI(t.y.add(MI(t.x.mul(1)))))).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),TI=wg(([t,e,n])=>{const i=Bg(t).toVar(),s=Lg(1.4).toVar(),r=Lg(0).toVar(),a=Bg(i).toVar();return mT({start:Lg(0),end:Lg(3),type:"float",condition:"<="},()=>{const t=Bg(bI(a.mul(2))).toVar();i.addAssign(t.add(n.mul(Lg(.1).mul(e)))),a.mulAssign(1.8),s.mulAssign(1.5),i.mulAssign(1.2);const o=Lg(MI(i.z.add(MI(i.x.add(MI(i.y)))))).toVar();r.addAssign(o.div(s)),a.addAssign(.14)}),r}).setLayout({name:"triNoise3D",type:"float",inputs:[{name:"p",type:"vec3"},{name:"spd",type:"float"},{name:"time",type:"float"}]}),SI=wg(([t,e,n=Og(.5)])=>wE(t.sub(n),e).add(n)),wI=wg(([t,e,n=Og(.5)])=>{const i=t.sub(n),s=i.dot(i),r=s.mul(s).mul(e);return t.add(i.mul(r))}),EI=wg(({position:t=null,horizontal:e=!0,vertical:n=!1})=>{let i;null!==t?(i=Xx.toVar(),i[3][0]=t.x,i[3][1]=t.y,i[3][2]=t.z):i=Xx;const s=Ux.mul(i);return vg(e)&&(s[0][0]=Xx[0].length(),s[0][1]=0,s[0][2]=0),vg(n)&&(s[1][0]=0,s[1][1]=Xx[1].length(),s[1][2]=0),s[2][0]=0,s[2][1]=0,s[2][2]=1,Lx.mul(s).mul(nM)}),AI=wg(([t=null])=>{const e=rS();return rS(JT(t)).sub(e).lessThan(0).select(DT,t)}),NI=new WeakMap;class CI extends zf{static get type(){return"VelocityNode"}constructor(){super("vec2"),this.updateType=Af.OBJECT,this.updateAfterType=Af.OBJECT,this.previousModelWorldMatrix=cv(new cs),this.previousProjectionMatrix=cv(new cs).setGroup(av),this.previousCameraViewMatrix=cv(new cs)}update({frameId:t,camera:e,object:n}){const i=II(n);this.previousModelWorldMatrix.value.copy(i);const s=RI(e);s.frameId!==t&&(s.frameId=t,void 0===s.previousProjectionMatrix?(s.previousProjectionMatrix=new cs,s.previousCameraViewMatrix=new cs,s.currentProjectionMatrix=new cs,s.currentCameraViewMatrix=new cs,s.previousProjectionMatrix.copy(e.projectionMatrix),s.previousCameraViewMatrix.copy(e.matrixWorldInverse)):(s.previousProjectionMatrix.copy(s.currentProjectionMatrix),s.previousCameraViewMatrix.copy(s.currentCameraViewMatrix)),s.currentProjectionMatrix.copy(e.projectionMatrix),s.currentCameraViewMatrix.copy(e.matrixWorldInverse),this.previousProjectionMatrix.value.copy(s.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(s.previousCameraViewMatrix))}updateAfter({object:t}){II(t).copy(t.matrixWorld)}setup(){const t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),e=Lx.mul(Kx).mul(nM),n=this.previousProjectionMatrix.mul(t).mul(iM),i=e.xy.div(e.w),s=n.xy.div(n.w);return qv(i,s)}}function RI(t){let e=NI.get(t);return void 0===e&&(e={},NI.set(t,e)),e}function II(t,e=0){const n=RI(t);let i=n[e];return void 0===i&&(n[e]=i=new cs),i}const LI=Sg(CI),PI=wg(([t,e])=>t_(1,t.oneMinus().div(e)).oneMinus()).setLayout({name:"burnBlend",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),UI=wg(([t,e])=>t_(t.div(e.oneMinus()),1)).setLayout({name:"dodgeBlend",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),DI=wg(([t,e])=>t.oneMinus().mul(e.oneMinus()).oneMinus()).setLayout({name:"screenBlend",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),OI=wg(([t,e])=>g_(t.mul(2).mul(e),t.oneMinus().mul(2).mul(e.oneMinus()).oneMinus(),i_(.5,t))).setLayout({name:"overlayBlend",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),zI=wg(([t,e,n=Pg(16)])=>{const i=e=>t.uv(e),s=xx(),r=i(s).toVar(),a=Lg(n);return mT({start:Pg(1),end:n,type:"int",condition:"<="},({i:t})=>{const n=e.mul(Lg(t).div(a.sub(1)).sub(.5));r.addAssign(i(s.add(n)))}),r.divAssign(a),r}),VI=wg(([t,e=1])=>{const n=t,i=DC(n.rgb),s=Bg(i),r=t_(1,e_(0,Lg(10).mul(i.sub(.45)))),a=s.mul(n.rgb).mul(2),o=Lg(2).mul(s.oneMinus()).mul(n.rgb.oneMinus()).oneMinus(),l=g_(a,o,r),c=n.a.mul(e),u=c.mul(l.rgb);return u.addAssign(n.rgb.mul(c.oneMinus())),Wg(u,n.a)}),FI=wg(([t])=>{const e=Bg(t);return Wg(o_(e,Bg(.393,.769,.189)),o_(e,Bg(.349,.686,.168)),o_(e,Bg(.272,.534,.131)),t.a)}),BI=wg(([t])=>{const e=t.mul(.9478672986).add(.0521327014).pow(2.4),n=t.mul(.0773993808),i=t.lessThanEqual(.04045);return g_(e,n,i)}).setLayout({name:"sRGBToLinearSRGB",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),kI=wg(([t])=>{const e=t.pow(.41666).mul(1.055).sub(.055),n=t.mul(12.92),i=t.lessThanEqual(.0031308);return g_(e,n,i)}).setLayout({name:"linearSRGBTosRGB",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),HI=wg(([t,e])=>t.mul(e).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),GI=wg(([t,e])=>(t=t.mul(e)).div(t.add(1)).clamp()).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),WI=wg(([t,e])=>{const n=(t=(t=t.mul(e)).sub(.004).max(0)).mul(t.mul(6.2).add(.5)),i=t.mul(t.mul(6.2).add(1.7)).add(.06);return n.div(i).pow(2.2)}).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),jI=wg(([t])=>{const e=t.mul(t.add(.0245786)).sub(90537e-9),n=t.mul(t.add(.432951).mul(.983729)).add(.238081);return e.div(n)}),XI=wg(([t,e])=>{const n=Zg(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),i=Zg(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return t=t.mul(e).div(.6),t=n.mul(t),t=jI(t),(t=i.mul(t)).clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),qI=Zg(Bg(1.6605,-.1246,-.0182),Bg(-.5876,1.1329,-.1006),Bg(-.0728,-.0083,1.1187)),YI=Zg(Bg(.6274,.0691,.0164),Bg(.3293,.9195,.088),Bg(.0433,.0113,.8956)),ZI=wg(([t])=>{const e=Bg(t).toVar(),n=Bg(e.mul(e)).toVar(),i=Bg(n.mul(n)).toVar();return Lg(15.5).mul(i.mul(n)).sub(Yv(40.14,i.mul(e))).add(Yv(31.96,i).sub(Yv(6.868,n.mul(e))).add(Yv(.4298,n).add(Yv(.1191,e).sub(.00232))))}),$I=wg(([t,e])=>{const n=Bg(t).toVar(),i=Zg(Bg(.856627153315983,.137318972929847,.11189821299995),Bg(.0951212405381588,.761241990602591,.0767994186031903),Bg(.0482516061458583,.101439036467562,.811302368396859)),s=Zg(Bg(1.1271005818144368,-.1413297634984383,-.14132976349843826),Bg(-.11060664309660323,1.157823702216272,-.11060664309660294),Bg(-.016493938717834573,-.016493938717834257,1.2519364065950405)),r=Lg(-12.47393),a=Lg(4.026069);return n.mulAssign(e),n.assign(YI.mul(n)),n.assign(i.mul(n)),n.assign(e_(n,1e-10)),n.assign(Ay(n)),n.assign(n.sub(r).div(a.sub(r))),n.assign(v_(n,0,1)),n.assign(ZI(n)),n.assign(s.mul(n)),n.assign(c_(e_(Bg(0),n),Bg(2.2))),n.assign(qI.mul(n)),n.assign(v_(n,0,1)),n}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),JI=wg(([t,e])=>{const n=Lg(.76),i=Lg(.15);t=t.mul(e);const s=t_(t.r,t_(t.g,t.b)),r=E_(s.lessThan(.08),s.sub(Yv(6.25,s.mul(s))),.04);t.subAssign(r);const a=e_(t.r,e_(t.g,t.b));Cg(a.lessThan(n),()=>t);const o=qv(1,n),l=qv(1,o.mul(o).div(a.add(o.sub(n))));t.mulAssign(l.div(a));const c=qv(1,Zv(1,i.mul(a.sub(l)).add(1)));return g_(t,Bg(l),c)}).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class KI extends Uf{static get type(){return"ComputeBuiltinNode"}constructor(t,e){super(e),this._builtinName=t}getHash(t){return this.getBuiltinName(t)}getNodeType(){return this.nodeType}setBuiltinName(t){return this._builtinName=t,this}getBuiltinName(){return this._builtinName}hasBuiltin(t){t.hasBuiltin(this._builtinName)}generate(t,e){const n=this.getBuiltinName(t),i=this.getNodeType(t);return"compute"===t.shaderStage?t.format(n,i,e):(console.warn(`ComputeBuiltinNode: Compute built-in value ${n} can not be accessed in the ${t.shaderStage} stage`),t.generateConst(i))}serialize(t){super.serialize(t),t.global=this.global,t._builtinName=this._builtinName}deserialize(t){super.deserialize(t),this.global=t.global,this._builtinName=t._builtinName}}const QI=(t,e)=>xg(new KI(t,e)),tL=QI("numWorkgroups","uvec3"),eL=QI("workgroupId","uvec3"),nL=QI("localId","uvec3"),iL=QI("subgroupSize","uint");const sL=Tg(class extends Uf{constructor(t){super(),this.scope=t}generate(t){const{scope:e}=this,{renderer:n}=t;!0===n.backend.isWebGLBackend?t.addFlowCode(`\t// ${e}Barrier \n`):t.addLineFlowCode(`${e}Barrier()`,this)}}),rL=()=>sL("workgroup").append(),aL=()=>sL("storage").append(),oL=()=>sL("texture").append();class lL extends Df{constructor(t,e){super(t,e),this.isWorkgroupInfoElementNode=!0}generate(t,e){let n;const i=t.context.assign;if(n=super.generate(t),!0!==i){const i=this.getNodeType(t);n=t.format(n,i,e)}return n}}class cL extends Uf{constructor(t,e,n=0){super(e),this.bufferType=e,this.bufferCount=n,this.isWorkgroupInfoNode=!0,this.scope=t}label(t){return this.name=t,this}getHash(){return this.uuid}setScope(t){return this.scope=t,this}getInputType(){return`${this.scope}Array`}element(t){return xg(new lL(this,t))}generate(t){return t.getScopedArray(this.name||`${this.scope}Array_${this.id}`,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}}const uL=(t,e)=>xg(new cL("Workgroup",t,e));class hL extends zf{static get type(){return"AtomicFunctionNode"}constructor(t,e,n,i=null){super("uint"),this.method=t,this.pointerNode=e,this.valueNode=n,this.storeNode=i}getInputType(t){return this.pointerNode.getNodeType(t)}getNodeType(t){return this.getInputType(t)}generate(t){const e=this.method,n=this.getNodeType(t),i=this.getInputType(t),s=this.pointerNode,r=this.valueNode,a=[];a.push(`&${s.build(t,i)}`),a.push(r.build(t,i));const o=`${t.getMethod(e,n)}( ${a.join(", ")} )`;if(null!==this.storeNode){const e=this.storeNode.build(t,i);t.addLineFlowCode(`${e} = ${o}`,this)}else t.addLineFlowCode(o,this)}}hL.ATOMIC_LOAD="atomicLoad",hL.ATOMIC_STORE="atomicStore",hL.ATOMIC_ADD="atomicAdd",hL.ATOMIC_SUB="atomicSub",hL.ATOMIC_MAX="atomicMax",hL.ATOMIC_MIN="atomicMin",hL.ATOMIC_AND="atomicAnd",hL.ATOMIC_OR="atomicOr",hL.ATOMIC_XOR="atomicXor";const dL=Tg(hL),pL=(t,e,n,i)=>{const s=dL(t,e,n,i);return s.append(),s},mL=(t,e,n=null)=>pL(hL.ATOMIC_STORE,t,e,n),fL=(t,e,n=null)=>pL(hL.ATOMIC_ADD,t,e,n),gL=(t,e,n=null)=>pL(hL.ATOMIC_SUB,t,e,n),vL=(t,e,n=null)=>pL(hL.ATOMIC_MAX,t,e,n),yL=(t,e,n=null)=>pL(hL.ATOMIC_MIN,t,e,n),_L=(t,e,n=null)=>pL(hL.ATOMIC_AND,t,e,n),xL=(t,e,n=null)=>pL(hL.ATOMIC_OR,t,e,n),ML=(t,e,n=null)=>pL(hL.ATOMIC_XOR,t,e,n),bL=wg(([t=e()])=>{const e=t.mul(2),n=e.x.floor(),i=e.y.floor();return n.add(i).mod(2).sign()}),TL=wg(([t,e,n])=>{const i=Lg(n).toVar(),s=Lg(e).toVar(),r=Dg(t).toVar();return E_(r,s,i)}).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),SL=wg(([t,e])=>{const n=Dg(e).toVar(),i=Lg(t).toVar();return E_(n,i.negate(),i)}).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),wL=wg(([t])=>{const e=Lg(t).toVar();return Pg(Ry(e))}).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),EL=wg(([t,e])=>{const n=Lg(t).toVar();return e.assign(wL(n)),n.sub(Lg(e))}),AL=iN([wg(([t,e,n,i,s,r])=>{const a=Lg(r).toVar(),o=Lg(s).toVar(),l=Lg(i).toVar(),c=Lg(n).toVar(),u=Lg(e).toVar(),h=Lg(t).toVar(),d=Lg(qv(1,o)).toVar();return qv(1,a).mul(h.mul(d).add(u.mul(o))).add(a.mul(c.mul(d).add(l.mul(o))))}).setLayout({name:"mx_bilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"}]}),wg(([t,e,n,i,s,r])=>{const a=Lg(r).toVar(),o=Lg(s).toVar(),l=Bg(i).toVar(),c=Bg(n).toVar(),u=Bg(e).toVar(),h=Bg(t).toVar(),d=Lg(qv(1,o)).toVar();return qv(1,a).mul(h.mul(d).add(u.mul(o))).add(a.mul(c.mul(d).add(l.mul(o))))}).setLayout({name:"mx_bilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"}]})]),NL=iN([wg(([t,e,n,i,s,r,a,o,l,c,u])=>{const h=Lg(u).toVar(),d=Lg(c).toVar(),p=Lg(l).toVar(),m=Lg(o).toVar(),f=Lg(a).toVar(),g=Lg(r).toVar(),v=Lg(s).toVar(),y=Lg(i).toVar(),_=Lg(n).toVar(),x=Lg(e).toVar(),M=Lg(t).toVar(),b=Lg(qv(1,p)).toVar(),T=Lg(qv(1,d)).toVar();return Lg(qv(1,h)).toVar().mul(T.mul(M.mul(b).add(x.mul(p))).add(d.mul(_.mul(b).add(y.mul(p))))).add(h.mul(T.mul(v.mul(b).add(g.mul(p))).add(d.mul(f.mul(b).add(m.mul(p))))))}).setLayout({name:"mx_trilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"v4",type:"float"},{name:"v5",type:"float"},{name:"v6",type:"float"},{name:"v7",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]}),wg(([t,e,n,i,s,r,a,o,l,c,u])=>{const h=Lg(u).toVar(),d=Lg(c).toVar(),p=Lg(l).toVar(),m=Bg(o).toVar(),f=Bg(a).toVar(),g=Bg(r).toVar(),v=Bg(s).toVar(),y=Bg(i).toVar(),_=Bg(n).toVar(),x=Bg(e).toVar(),M=Bg(t).toVar(),b=Lg(qv(1,p)).toVar(),T=Lg(qv(1,d)).toVar();return Lg(qv(1,h)).toVar().mul(T.mul(M.mul(b).add(x.mul(p))).add(d.mul(_.mul(b).add(y.mul(p))))).add(h.mul(T.mul(v.mul(b).add(g.mul(p))).add(d.mul(f.mul(b).add(m.mul(p))))))}).setLayout({name:"mx_trilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"v4",type:"vec3"},{name:"v5",type:"vec3"},{name:"v6",type:"vec3"},{name:"v7",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]})]),CL=wg(([t,e,n])=>{const i=Lg(n).toVar(),s=Lg(e).toVar(),r=Ug(t).toVar(),a=Ug(r.bitAnd(Ug(7))).toVar(),o=Lg(TL(a.lessThan(Ug(4)),s,i)).toVar(),l=Lg(Yv(2,TL(a.lessThan(Ug(4)),i,s))).toVar();return SL(o,Dg(a.bitAnd(Ug(1)))).add(SL(l,Dg(a.bitAnd(Ug(2)))))}).setLayout({name:"mx_gradient_float_0",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"}]}),RL=wg(([t,e,n,i])=>{const s=Lg(i).toVar(),r=Lg(n).toVar(),a=Lg(e).toVar(),o=Ug(t).toVar(),l=Ug(o.bitAnd(Ug(15))).toVar(),c=Lg(TL(l.lessThan(Ug(8)),a,r)).toVar(),u=Lg(TL(l.lessThan(Ug(4)),r,TL(l.equal(Ug(12)).or(l.equal(Ug(14))),a,s))).toVar();return SL(c,Dg(l.bitAnd(Ug(1)))).add(SL(u,Dg(l.bitAnd(Ug(2)))))}).setLayout({name:"mx_gradient_float_1",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),IL=iN([CL,RL]),LL=wg(([t,e,n])=>{const i=Lg(n).toVar(),s=Lg(e).toVar(),r=Hg(t).toVar();return Bg(IL(r.x,s,i),IL(r.y,s,i),IL(r.z,s,i))}).setLayout({name:"mx_gradient_vec3_0",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"}]}),PL=wg(([t,e,n,i])=>{const s=Lg(i).toVar(),r=Lg(n).toVar(),a=Lg(e).toVar(),o=Hg(t).toVar();return Bg(IL(o.x,a,r,s),IL(o.y,a,r,s),IL(o.z,a,r,s))}).setLayout({name:"mx_gradient_vec3_1",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),UL=iN([LL,PL]),DL=wg(([t])=>{const e=Lg(t).toVar();return Yv(.6616,e)}).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),OL=wg(([t])=>{const e=Lg(t).toVar();return Yv(.982,e)}).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),zL=iN([DL,wg(([t])=>{const e=Bg(t).toVar();return Yv(.6616,e)}).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),VL=iN([OL,wg(([t])=>{const e=Bg(t).toVar();return Yv(.982,e)}).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),FL=wg(([t,e])=>{const n=Pg(e).toVar(),i=Ug(t).toVar();return i.shiftLeft(n).bitOr(i.shiftRight(Pg(32).sub(n)))}).setLayout({name:"mx_rotl32",type:"uint",inputs:[{name:"x",type:"uint"},{name:"k",type:"int"}]}),BL=wg(([t,e,n])=>{t.subAssign(n),t.bitXorAssign(FL(n,Pg(4))),n.addAssign(e),e.subAssign(t),e.bitXorAssign(FL(t,Pg(6))),t.addAssign(n),n.subAssign(e),n.bitXorAssign(FL(e,Pg(8))),e.addAssign(t),t.subAssign(n),t.bitXorAssign(FL(n,Pg(16))),n.addAssign(e),e.subAssign(t),e.bitXorAssign(FL(t,Pg(19))),t.addAssign(n),n.subAssign(e),n.bitXorAssign(FL(e,Pg(4))),e.addAssign(t)}),kL=wg(([t,e,n])=>{const i=Ug(n).toVar(),s=Ug(e).toVar(),r=Ug(t).toVar();return i.bitXorAssign(s),i.subAssign(FL(s,Pg(14))),r.bitXorAssign(i),r.subAssign(FL(i,Pg(11))),s.bitXorAssign(r),s.subAssign(FL(r,Pg(25))),i.bitXorAssign(s),i.subAssign(FL(s,Pg(16))),r.bitXorAssign(i),r.subAssign(FL(i,Pg(4))),s.bitXorAssign(r),s.subAssign(FL(r,Pg(14))),i.bitXorAssign(s),i.subAssign(FL(s,Pg(24))),i}).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),HL=wg(([t])=>{const e=Ug(t).toVar();return Lg(e).div(Lg(Ug(Pg(4294967295))))}).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),GL=wg(([t])=>{const e=Lg(t).toVar();return e.mul(e).mul(e).mul(e.mul(e.mul(6).sub(15)).add(10))}).setLayout({name:"mx_fade",type:"float",inputs:[{name:"t",type:"float"}]}),WL=iN([wg(([t])=>{const e=Pg(t).toVar(),n=Ug(Ug(1)).toVar(),i=Ug(Ug(Pg(3735928559)).add(n.shiftLeft(Ug(2))).add(Ug(13))).toVar();return kL(i.add(Ug(e)),i,i)}).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),wg(([t,e])=>{const n=Pg(e).toVar(),i=Pg(t).toVar(),s=Ug(Ug(2)).toVar(),r=Ug().toVar(),a=Ug().toVar(),o=Ug().toVar();return r.assign(a.assign(o.assign(Ug(Pg(3735928559)).add(s.shiftLeft(Ug(2))).add(Ug(13))))),r.addAssign(Ug(i)),a.addAssign(Ug(n)),kL(r,a,o)}).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),wg(([t,e,n])=>{const i=Pg(n).toVar(),s=Pg(e).toVar(),r=Pg(t).toVar(),a=Ug(Ug(3)).toVar(),o=Ug().toVar(),l=Ug().toVar(),c=Ug().toVar();return o.assign(l.assign(c.assign(Ug(Pg(3735928559)).add(a.shiftLeft(Ug(2))).add(Ug(13))))),o.addAssign(Ug(r)),l.addAssign(Ug(s)),c.addAssign(Ug(i)),kL(o,l,c)}).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),wg(([t,e,n,i])=>{const s=Pg(i).toVar(),r=Pg(n).toVar(),a=Pg(e).toVar(),o=Pg(t).toVar(),l=Ug(Ug(4)).toVar(),c=Ug().toVar(),u=Ug().toVar(),h=Ug().toVar();return c.assign(u.assign(h.assign(Ug(Pg(3735928559)).add(l.shiftLeft(Ug(2))).add(Ug(13))))),c.addAssign(Ug(o)),u.addAssign(Ug(a)),h.addAssign(Ug(r)),BL(c,u,h),c.addAssign(Ug(s)),kL(c,u,h)}).setLayout({name:"mx_hash_int_3",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"}]}),wg(([t,e,n,i,s])=>{const r=Pg(s).toVar(),a=Pg(i).toVar(),o=Pg(n).toVar(),l=Pg(e).toVar(),c=Pg(t).toVar(),u=Ug(Ug(5)).toVar(),h=Ug().toVar(),d=Ug().toVar(),p=Ug().toVar();return h.assign(d.assign(p.assign(Ug(Pg(3735928559)).add(u.shiftLeft(Ug(2))).add(Ug(13))))),h.addAssign(Ug(c)),d.addAssign(Ug(l)),p.addAssign(Ug(o)),BL(h,d,p),h.addAssign(Ug(a)),d.addAssign(Ug(r)),kL(h,d,p)}).setLayout({name:"mx_hash_int_4",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"},{name:"yy",type:"int"}]})]),jL=iN([wg(([t,e])=>{const n=Pg(e).toVar(),i=Pg(t).toVar(),s=Ug(WL(i,n)).toVar(),r=Hg().toVar();return r.x.assign(s.bitAnd(Pg(255))),r.y.assign(s.shiftRight(Pg(8)).bitAnd(Pg(255))),r.z.assign(s.shiftRight(Pg(16)).bitAnd(Pg(255))),r}).setLayout({name:"mx_hash_vec3_0",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),wg(([t,e,n])=>{const i=Pg(n).toVar(),s=Pg(e).toVar(),r=Pg(t).toVar(),a=Ug(WL(r,s,i)).toVar(),o=Hg().toVar();return o.x.assign(a.bitAnd(Pg(255))),o.y.assign(a.shiftRight(Pg(8)).bitAnd(Pg(255))),o.z.assign(a.shiftRight(Pg(16)).bitAnd(Pg(255))),o}).setLayout({name:"mx_hash_vec3_1",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]})]),XL=iN([wg(([t])=>{const e=Og(t).toVar(),n=Pg().toVar(),i=Pg().toVar(),s=Lg(EL(e.x,n)).toVar(),r=Lg(EL(e.y,i)).toVar(),a=Lg(GL(s)).toVar(),o=Lg(GL(r)).toVar(),l=Lg(AL(IL(WL(n,i),s,r),IL(WL(n.add(Pg(1)),i),s.sub(1),r),IL(WL(n,i.add(Pg(1))),s,r.sub(1)),IL(WL(n.add(Pg(1)),i.add(Pg(1))),s.sub(1),r.sub(1)),a,o)).toVar();return zL(l)}).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),wg(([t])=>{const e=Bg(t).toVar(),n=Pg().toVar(),i=Pg().toVar(),s=Pg().toVar(),r=Lg(EL(e.x,n)).toVar(),a=Lg(EL(e.y,i)).toVar(),o=Lg(EL(e.z,s)).toVar(),l=Lg(GL(r)).toVar(),c=Lg(GL(a)).toVar(),u=Lg(GL(o)).toVar(),h=Lg(NL(IL(WL(n,i,s),r,a,o),IL(WL(n.add(Pg(1)),i,s),r.sub(1),a,o),IL(WL(n,i.add(Pg(1)),s),r,a.sub(1),o),IL(WL(n.add(Pg(1)),i.add(Pg(1)),s),r.sub(1),a.sub(1),o),IL(WL(n,i,s.add(Pg(1))),r,a,o.sub(1)),IL(WL(n.add(Pg(1)),i,s.add(Pg(1))),r.sub(1),a,o.sub(1)),IL(WL(n,i.add(Pg(1)),s.add(Pg(1))),r,a.sub(1),o.sub(1)),IL(WL(n.add(Pg(1)),i.add(Pg(1)),s.add(Pg(1))),r.sub(1),a.sub(1),o.sub(1)),l,c,u)).toVar();return VL(h)}).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]})]),qL=iN([wg(([t])=>{const e=Og(t).toVar(),n=Pg().toVar(),i=Pg().toVar(),s=Lg(EL(e.x,n)).toVar(),r=Lg(EL(e.y,i)).toVar(),a=Lg(GL(s)).toVar(),o=Lg(GL(r)).toVar(),l=Bg(AL(UL(jL(n,i),s,r),UL(jL(n.add(Pg(1)),i),s.sub(1),r),UL(jL(n,i.add(Pg(1))),s,r.sub(1)),UL(jL(n.add(Pg(1)),i.add(Pg(1))),s.sub(1),r.sub(1)),a,o)).toVar();return zL(l)}).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),wg(([t])=>{const e=Bg(t).toVar(),n=Pg().toVar(),i=Pg().toVar(),s=Pg().toVar(),r=Lg(EL(e.x,n)).toVar(),a=Lg(EL(e.y,i)).toVar(),o=Lg(EL(e.z,s)).toVar(),l=Lg(GL(r)).toVar(),c=Lg(GL(a)).toVar(),u=Lg(GL(o)).toVar(),h=Bg(NL(UL(jL(n,i,s),r,a,o),UL(jL(n.add(Pg(1)),i,s),r.sub(1),a,o),UL(jL(n,i.add(Pg(1)),s),r,a.sub(1),o),UL(jL(n.add(Pg(1)),i.add(Pg(1)),s),r.sub(1),a.sub(1),o),UL(jL(n,i,s.add(Pg(1))),r,a,o.sub(1)),UL(jL(n.add(Pg(1)),i,s.add(Pg(1))),r.sub(1),a,o.sub(1)),UL(jL(n,i.add(Pg(1)),s.add(Pg(1))),r,a.sub(1),o.sub(1)),UL(jL(n.add(Pg(1)),i.add(Pg(1)),s.add(Pg(1))),r.sub(1),a.sub(1),o.sub(1)),l,c,u)).toVar();return VL(h)}).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]})]),YL=iN([wg(([t])=>{const e=Lg(t).toVar(),n=Pg(wL(e)).toVar();return HL(WL(n))}).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),wg(([t])=>{const e=Og(t).toVar(),n=Pg(wL(e.x)).toVar(),i=Pg(wL(e.y)).toVar();return HL(WL(n,i))}).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),wg(([t])=>{const e=Bg(t).toVar(),n=Pg(wL(e.x)).toVar(),i=Pg(wL(e.y)).toVar(),s=Pg(wL(e.z)).toVar();return HL(WL(n,i,s))}).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),wg(([t])=>{const e=Wg(t).toVar(),n=Pg(wL(e.x)).toVar(),i=Pg(wL(e.y)).toVar(),s=Pg(wL(e.z)).toVar(),r=Pg(wL(e.w)).toVar();return HL(WL(n,i,s,r))}).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]})]),ZL=iN([wg(([t])=>{const e=Lg(t).toVar(),n=Pg(wL(e)).toVar();return Bg(HL(WL(n,Pg(0))),HL(WL(n,Pg(1))),HL(WL(n,Pg(2))))}).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),wg(([t])=>{const e=Og(t).toVar(),n=Pg(wL(e.x)).toVar(),i=Pg(wL(e.y)).toVar();return Bg(HL(WL(n,i,Pg(0))),HL(WL(n,i,Pg(1))),HL(WL(n,i,Pg(2))))}).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),wg(([t])=>{const e=Bg(t).toVar(),n=Pg(wL(e.x)).toVar(),i=Pg(wL(e.y)).toVar(),s=Pg(wL(e.z)).toVar();return Bg(HL(WL(n,i,s,Pg(0))),HL(WL(n,i,s,Pg(1))),HL(WL(n,i,s,Pg(2))))}).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),wg(([t])=>{const e=Wg(t).toVar(),n=Pg(wL(e.x)).toVar(),i=Pg(wL(e.y)).toVar(),s=Pg(wL(e.z)).toVar(),r=Pg(wL(e.w)).toVar();return Bg(HL(WL(n,i,s,r,Pg(0))),HL(WL(n,i,s,r,Pg(1))),HL(WL(n,i,s,r,Pg(2))))}).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]})]),$L=wg(([t,e,n,i])=>{const s=Lg(i).toVar(),r=Lg(n).toVar(),a=Pg(e).toVar(),o=Bg(t).toVar(),l=Lg(0).toVar(),c=Lg(1).toVar();return mT(a,()=>{l.addAssign(c.mul(XL(o))),c.mulAssign(s),o.mulAssign(r)}),l}).setLayout({name:"mx_fractal_noise_float",type:"float",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),JL=wg(([t,e,n,i])=>{const s=Lg(i).toVar(),r=Lg(n).toVar(),a=Pg(e).toVar(),o=Bg(t).toVar(),l=Bg(0).toVar(),c=Lg(1).toVar();return mT(a,()=>{l.addAssign(c.mul(qL(o))),c.mulAssign(s),o.mulAssign(r)}),l}).setLayout({name:"mx_fractal_noise_vec3",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),KL=wg(([t,e,n,i])=>{const s=Lg(i).toVar(),r=Lg(n).toVar(),a=Pg(e).toVar(),o=Bg(t).toVar();return Og($L(o,a,r,s),$L(o.add(Bg(Pg(19),Pg(193),Pg(17))),a,r,s))}).setLayout({name:"mx_fractal_noise_vec2",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),QL=wg(([t,e,n,i])=>{const s=Lg(i).toVar(),r=Lg(n).toVar(),a=Pg(e).toVar(),o=Bg(t).toVar(),l=Bg(JL(o,a,r,s)).toVar(),c=Lg($L(o.add(Bg(Pg(19),Pg(193),Pg(17))),a,r,s)).toVar();return Wg(l,c)}).setLayout({name:"mx_fractal_noise_vec4",type:"vec4",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),tP=wg(([t,e,n,i,s,r,a])=>{const o=Pg(a).toVar(),l=Lg(r).toVar(),c=Pg(s).toVar(),u=Pg(i).toVar(),h=Pg(n).toVar(),d=Pg(e).toVar(),p=Og(t).toVar(),m=Bg(ZL(Og(d.add(u),h.add(c)))).toVar(),f=Og(m.x,m.y).toVar();f.subAssign(.5),f.mulAssign(l),f.addAssign(.5);const g=Og(Og(Lg(d),Lg(h)).add(f)).toVar(),v=Og(g.sub(p)).toVar();return Cg(o.equal(Pg(2)),()=>By(v.x).add(By(v.y))),Cg(o.equal(Pg(3)),()=>e_(By(v.x),By(v.y))),o_(v,v)}).setLayout({name:"mx_worley_distance_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),eP=iN([tP,wg(([t,e,n,i,s,r,a,o,l])=>{const c=Pg(l).toVar(),u=Lg(o).toVar(),h=Pg(a).toVar(),d=Pg(r).toVar(),p=Pg(s).toVar(),m=Pg(i).toVar(),f=Pg(n).toVar(),g=Pg(e).toVar(),v=Bg(t).toVar(),y=Bg(ZL(Bg(g.add(p),f.add(d),m.add(h)))).toVar();y.subAssign(.5),y.mulAssign(u),y.addAssign(.5);const _=Bg(Bg(Lg(g),Lg(f),Lg(m)).add(y)).toVar(),x=Bg(_.sub(v)).toVar();return Cg(c.equal(Pg(2)),()=>By(x.x).add(By(x.y)).add(By(x.z))),Cg(c.equal(Pg(3)),()=>e_(e_(By(x.x),By(x.y)),By(x.z))),o_(x,x)}).setLayout({name:"mx_worley_distance_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"zoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),nP=wg(([t,e,n])=>{const i=Pg(n).toVar(),s=Lg(e).toVar(),r=Og(t).toVar(),a=Pg().toVar(),o=Pg().toVar(),l=Og(EL(r.x,a),EL(r.y,o)).toVar(),c=Lg(1e6).toVar();return mT({start:-1,end:Pg(1),name:"x",condition:"<="},({x:t})=>{mT({start:-1,end:Pg(1),name:"y",condition:"<="},({y:e})=>{const n=Lg(eP(l,t,e,a,o,s,i)).toVar();c.assign(t_(c,n))})}),Cg(i.equal(Pg(0)),()=>{c.assign(Ny(c))}),c}).setLayout({name:"mx_worley_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),iP=wg(([t,e,n])=>{const i=Pg(n).toVar(),s=Lg(e).toVar(),r=Og(t).toVar(),a=Pg().toVar(),o=Pg().toVar(),l=Og(EL(r.x,a),EL(r.y,o)).toVar(),c=Og(1e6,1e6).toVar();return mT({start:-1,end:Pg(1),name:"x",condition:"<="},({x:t})=>{mT({start:-1,end:Pg(1),name:"y",condition:"<="},({y:e})=>{const n=Lg(eP(l,t,e,a,o,s,i)).toVar();Cg(n.lessThan(c.x),()=>{c.y.assign(c.x),c.x.assign(n)}).ElseIf(n.lessThan(c.y),()=>{c.y.assign(n)})})}),Cg(i.equal(Pg(0)),()=>{c.assign(Ny(c))}),c}).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),sP=wg(([t,e,n])=>{const i=Pg(n).toVar(),s=Lg(e).toVar(),r=Og(t).toVar(),a=Pg().toVar(),o=Pg().toVar(),l=Og(EL(r.x,a),EL(r.y,o)).toVar(),c=Bg(1e6,1e6,1e6).toVar();return mT({start:-1,end:Pg(1),name:"x",condition:"<="},({x:t})=>{mT({start:-1,end:Pg(1),name:"y",condition:"<="},({y:e})=>{const n=Lg(eP(l,t,e,a,o,s,i)).toVar();Cg(n.lessThan(c.x),()=>{c.z.assign(c.y),c.y.assign(c.x),c.x.assign(n)}).ElseIf(n.lessThan(c.y),()=>{c.z.assign(c.y),c.y.assign(n)}).ElseIf(n.lessThan(c.z),()=>{c.z.assign(n)})})}),Cg(i.equal(Pg(0)),()=>{c.assign(Ny(c))}),c}).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),rP=iN([nP,wg(([t,e,n])=>{const i=Pg(n).toVar(),s=Lg(e).toVar(),r=Bg(t).toVar(),a=Pg().toVar(),o=Pg().toVar(),l=Pg().toVar(),c=Bg(EL(r.x,a),EL(r.y,o),EL(r.z,l)).toVar(),u=Lg(1e6).toVar();return mT({start:-1,end:Pg(1),name:"x",condition:"<="},({x:t})=>{mT({start:-1,end:Pg(1),name:"y",condition:"<="},({y:e})=>{mT({start:-1,end:Pg(1),name:"z",condition:"<="},({z:n})=>{const r=Lg(eP(c,t,e,n,a,o,l,s,i)).toVar();u.assign(t_(u,r))})})}),Cg(i.equal(Pg(0)),()=>{u.assign(Ny(u))}),u}).setLayout({name:"mx_worley_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),aP=iN([iP,wg(([t,e,n])=>{const i=Pg(n).toVar(),s=Lg(e).toVar(),r=Bg(t).toVar(),a=Pg().toVar(),o=Pg().toVar(),l=Pg().toVar(),c=Bg(EL(r.x,a),EL(r.y,o),EL(r.z,l)).toVar(),u=Og(1e6,1e6).toVar();return mT({start:-1,end:Pg(1),name:"x",condition:"<="},({x:t})=>{mT({start:-1,end:Pg(1),name:"y",condition:"<="},({y:e})=>{mT({start:-1,end:Pg(1),name:"z",condition:"<="},({z:n})=>{const r=Lg(eP(c,t,e,n,a,o,l,s,i)).toVar();Cg(r.lessThan(u.x),()=>{u.y.assign(u.x),u.x.assign(r)}).ElseIf(r.lessThan(u.y),()=>{u.y.assign(r)})})})}),Cg(i.equal(Pg(0)),()=>{u.assign(Ny(u))}),u}).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),oP=iN([sP,wg(([t,e,n])=>{const i=Pg(n).toVar(),s=Lg(e).toVar(),r=Bg(t).toVar(),a=Pg().toVar(),o=Pg().toVar(),l=Pg().toVar(),c=Bg(EL(r.x,a),EL(r.y,o),EL(r.z,l)).toVar(),u=Bg(1e6,1e6,1e6).toVar();return mT({start:-1,end:Pg(1),name:"x",condition:"<="},({x:t})=>{mT({start:-1,end:Pg(1),name:"y",condition:"<="},({y:e})=>{mT({start:-1,end:Pg(1),name:"z",condition:"<="},({z:n})=>{const r=Lg(eP(c,t,e,n,a,o,l,s,i)).toVar();Cg(r.lessThan(u.x),()=>{u.z.assign(u.y),u.y.assign(u.x),u.x.assign(r)}).ElseIf(r.lessThan(u.y),()=>{u.z.assign(u.y),u.y.assign(r)}).ElseIf(r.lessThan(u.z),()=>{u.z.assign(r)})})})}),Cg(i.equal(Pg(0)),()=>{u.assign(Ny(u))}),u}).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),lP=wg(([t])=>{const e=t.y,n=t.z,i=Bg().toVar();return Cg(e.lessThan(1e-4),()=>{i.assign(Bg(n,n,n))}).Else(()=>{let s=t.x;s=s.sub(Ry(s)).mul(6).toVar();const r=Pg(Zy(s)),a=s.sub(Lg(r)),o=n.mul(e.oneMinus()),l=n.mul(e.mul(a).oneMinus()),c=n.mul(e.mul(a.oneMinus()).oneMinus());Cg(r.equal(Pg(0)),()=>{i.assign(Bg(n,c,o))}).ElseIf(r.equal(Pg(1)),()=>{i.assign(Bg(l,n,o))}).ElseIf(r.equal(Pg(2)),()=>{i.assign(Bg(o,n,c))}).ElseIf(r.equal(Pg(3)),()=>{i.assign(Bg(o,l,n))}).ElseIf(r.equal(Pg(4)),()=>{i.assign(Bg(c,o,n))}).Else(()=>{i.assign(Bg(n,o,l))})}),i}).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),cP=wg(([t])=>{const e=Bg(t).toVar(),n=Lg(e.x).toVar(),i=Lg(e.y).toVar(),s=Lg(e.z).toVar(),r=Lg(t_(n,t_(i,s))).toVar(),a=Lg(e_(n,e_(i,s))).toVar(),o=Lg(a.sub(r)).toVar(),l=Lg().toVar(),c=Lg().toVar(),u=Lg().toVar();return u.assign(a),Cg(a.greaterThan(0),()=>{c.assign(o.div(a))}).Else(()=>{c.assign(0)}),Cg(c.lessThanEqual(0),()=>{l.assign(0)}).Else(()=>{Cg(n.greaterThanEqual(a),()=>{l.assign(i.sub(s).div(o))}).ElseIf(i.greaterThanEqual(a),()=>{l.assign(Xv(2,s.sub(n).div(o)))}).Else(()=>{l.assign(Xv(4,n.sub(i).div(o)))}),l.mulAssign(1/6),Cg(l.lessThan(0),()=>{l.addAssign(1)})}),Bg(l,c,u)}).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),uP=wg(([t])=>{const e=Bg(t).toVar(),n=Gg(ty(e,Bg(.04045))).toVar(),i=Bg(e.div(12.92)).toVar(),s=Bg(c_(e_(e.add(Bg(.055)),Bg(0)).div(1.055),Bg(2.4))).toVar();return g_(i,s,n)}).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),hP=(t,e)=>{t=Lg(t),e=Lg(e);const n=Og(e.dFdx(),e.dFdy()).length().mul(.7071067811865476);return x_(t.sub(n),t.add(n),e)},dP=(t,e,n,i)=>g_(t,e,n[i].clamp()),pP=(t,e,n=xx())=>dP(t,e,n,"x"),mP=(t,e,n=xx())=>dP(t,e,n,"y"),fP=(t,e,n,i,s)=>g_(t,e,hP(n,i[s])),gP=(t,e,n,i=xx())=>fP(t,e,n,i,"x"),vP=(t,e,n,i=xx())=>fP(t,e,n,i,"y"),yP=(t=1,e=0,n=xx())=>n.mul(t).add(e),_P=(t,e=1)=>(t=Lg(t)).abs().pow(e).mul(t.sign()),xP=(t,e=1,n=.5)=>Lg(t).sub(n).mul(e).add(n),MP=(t=xx(),e=1,n=0)=>XL(t.convert("vec2|vec3")).mul(e).add(n),bP=(t=xx(),e=1,n=0)=>qL(t.convert("vec2|vec3")).mul(e).add(n),TP=(t=xx(),e=1,n=0)=>{t=t.convert("vec2|vec3");return Wg(qL(t),XL(t.add(Og(19,73)))).mul(e).add(n)},SP=(t=xx(),e=1)=>rP(t.convert("vec2|vec3"),e,Pg(1)),wP=(t=xx(),e=1)=>aP(t.convert("vec2|vec3"),e,Pg(1)),EP=(t=xx(),e=1)=>oP(t.convert("vec2|vec3"),e,Pg(1)),AP=(t=xx())=>YL(t.convert("vec2|vec3")),NP=(t=xx(),e=3,n=2,i=.5,s=1)=>$L(t,Pg(e),n,i).mul(s),CP=(t=xx(),e=3,n=2,i=.5,s=1)=>KL(t,Pg(e),n,i).mul(s),RP=(t=xx(),e=3,n=2,i=.5,s=1)=>JL(t,Pg(e),n,i).mul(s),IP=(t=xx(),e=3,n=2,i=.5,s=1)=>QL(t,Pg(e),n,i).mul(s),LP=wg(([t,e])=>{const n=t.x,i=t.y,s=t.z;let r=e.element(0).mul(.886227);return r=r.add(e.element(1).mul(1.023328).mul(i)),r=r.add(e.element(2).mul(1.023328).mul(s)),r=r.add(e.element(3).mul(1.023328).mul(n)),r=r.add(e.element(4).mul(.858086).mul(n).mul(i)),r=r.add(e.element(5).mul(.858086).mul(i).mul(s)),r=r.add(e.element(6).mul(s.mul(s).mul(.743125).sub(.247708))),r=r.add(e.element(7).mul(.858086).mul(n).mul(s)),r=r.add(e.element(8).mul(.429043).mul(Yv(n,n).sub(Yv(i,i)))),r});class PP extends lI{static get type(){return"PointLightNode"}constructor(t=null){super(t),this.cutoffDistanceNode=cv(0).setGroup(av),this.decayExponentNode=cv(0).setGroup(av)}update(t){const{light:e}=this;super.update(t),this.cutoffDistanceNode.value=e.distance,this.decayExponentNode.value=e.decay}setup(t){const{colorNode:e,cutoffDistanceNode:n,decayExponentNode:i,light:s}=this,r=t.context.lightingModel,a=mI(s).sub(aM),o=a.normalize(),l=a.length(),c=cI({lightDistance:l,cutoffDistance:n,decayExponent:i}),u=e.mul(c),h=t.context.reflectedLight;r.direct({lightDirection:o,lightColor:u,reflectedLight:h},t.stack,t)}}class UP extends lI{static get type(){return"DirectionalLightNode"}constructor(t=null){super(t)}setup(t){super.setup(t);const e=t.context.lightingModel,n=this.colorNode,i=fI(this.light),s=t.context.reflectedLight;e.direct({lightDirection:i,lightColor:n,reflectedLight:s},t.stack,t)}}const DP=new cs,OP=new cs;let zP=null;class VP extends lI{static get type(){return"RectAreaLightNode"}constructor(t=null){super(t),this.halfHeight=cv(new Pi).setGroup(av),this.halfWidth=cv(new Pi).setGroup(av)}update(t){super.update(t);const{light:e}=this,n=t.camera.matrixWorldInverse;OP.identity(),DP.copy(e.matrixWorld),DP.premultiply(n),OP.extractRotation(DP),this.halfWidth.value.set(.5*e.width,0,0),this.halfHeight.value.set(0,.5*e.height,0),this.halfWidth.value.applyMatrix4(OP),this.halfHeight.value.applyMatrix4(OP)}setup(t){let e,n;super.setup(t),t.isAvailable("float32Filterable")?(e=Ex(zP.LTC_FLOAT_1),n=Ex(zP.LTC_FLOAT_2)):(e=Ex(zP.LTC_HALF_1),n=Ex(zP.LTC_HALF_2));const{colorNode:i,light:s}=this,r=t.context.lightingModel,a=mI(s),o=t.context.reflectedLight;r.directRectArea({lightColor:i,lightPosition:a,halfWidth:this.halfWidth,halfHeight:this.halfHeight,reflectedLight:o,ltc_1:e,ltc_2:n},t.stack,t)}static setLTC(t){zP=t}}class FP extends lI{static get type(){return"SpotLightNode"}constructor(t=null){super(t),this.coneCosNode=cv(0).setGroup(av),this.penumbraCosNode=cv(0).setGroup(av),this.cutoffDistanceNode=cv(0).setGroup(av),this.decayExponentNode=cv(0).setGroup(av)}update(t){super.update(t);const{light:e}=this;this.coneCosNode.value=Math.cos(e.angle),this.penumbraCosNode.value=Math.cos(e.angle*(1-e.penumbra)),this.cutoffDistanceNode.value=e.distance,this.decayExponentNode.value=e.decay}getSpotAttenuation(t){const{coneCosNode:e,penumbraCosNode:n}=this;return x_(e,n,t)}setup(t){super.setup(t);const e=t.context.lightingModel,{colorNode:n,cutoffDistanceNode:i,decayExponentNode:s,light:r}=this,a=mI(r).sub(aM),o=a.normalize(),l=o.dot(fI(r)),c=this.getSpotAttenuation(l),u=a.length(),h=cI({lightDistance:u,cutoffDistance:i,decayExponent:s}),d=n.mul(c).mul(h),p=t.context.reflectedLight;e.direct({lightDirection:o,lightColor:d,reflectedLight:p},t.stack,t)}}class BP extends FP{static get type(){return"IESSpotLightNode"}getSpotAttenuation(t){const e=this.light.iesMap;let n=null;if(e&&!0===e.isTexture){const i=t.acos().mul(1/Math.PI);n=Ex(e,Og(i,0),0).r}else n=super.getSpotAttenuation(t);return n}}class kP extends lI{static get type(){return"AmbientLightNode"}constructor(t=null){super(t)}setup({context:t}){t.irradiance.addAssign(this.colorNode)}}class HP extends lI{static get type(){return"HemisphereLightNode"}constructor(t=null){super(t),this.lightPositionNode=dI(t),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=cv(new er).setGroup(av)}update(t){const{light:e}=this;super.update(t),this.lightPositionNode.object3d=e,this.groundColorNode.value.copy(e.groundColor).multiplyScalar(e.intensity)}setup(t){const{colorNode:e,groundColorNode:n,lightDirectionNode:i}=this,s=mM.dot(i).mul(.5).add(.5),r=g_(n,e,s);t.context.irradiance.addAssign(r)}}class GP extends lI{static get type(){return"LightProbeNode"}constructor(t=null){super(t);const e=[];for(let t=0;t<9;t++)e.push(new Pi);this.lightProbe=LM(e)}update(t){const{light:e}=this;super.update(t);for(let t=0;t<9;t++)this.lightProbe.array[t].copy(e.sh.coefficients[t]).multiplyScalar(e.intensity)}setup(t){const e=LP(fM,this.lightProbe);t.context.irradiance.addAssign(e)}}class WP{parseFunction(){console.warn("Abstract function.")}}class jP{constructor(t,e,n="",i=""){this.type=t,this.inputs=e,this.name=n,this.precision=i}getCode(){console.warn("Abstract function.")}}jP.isNodeFunction=!0;const XP=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,qP=/[a-z_0-9]+/gi,YP="#pragma main";class ZP extends jP{constructor(t){const{type:e,inputs:n,name:i,precision:s,inputsCode:r,blockCode:a,headerCode:o}=(t=>{const e=(t=t.trim()).indexOf(YP),n=-1!==e?t.slice(e+12):t,i=n.match(XP);if(null!==i&&5===i.length){const s=i[4],r=[];let a=null;for(;null!==(a=qP.exec(s));)r.push(a);const o=[];let l=0;for(;l<r.length;){const t="const"===r[l][0];!0===t&&l++;let e=r[l][0];"in"===e||"out"===e||"inout"===e?l++:e="";const n=r[l++][0];let i=Number.parseInt(r[l][0]);!1===Number.isNaN(i)?l++:i=null;const s=r[l++][0];o.push(new YA(n,s,i,e,t))}const c=n.substring(i[0].length),u=void 0!==i[3]?i[3]:"";return{type:i[2],inputs:o,name:u,precision:void 0!==i[1]?i[1]:"",inputsCode:s,blockCode:c,headerCode:-1!==e?t.slice(0,e):""}}throw new Error("FunctionNode: Function is not a GLSL code.")})(t);super(e,n,i,s),this.inputsCode=r,this.blockCode=a,this.headerCode=o}getCode(t=this.name){let e;const n=this.blockCode;if(""!==n){const{type:i,inputsCode:s,headerCode:r,precision:a}=this;let o=`${i} ${t} ( ${s.trim()} )`;""!==a&&(o=`${a} ${o}`),e=r+o+n}else e="";return e}}class $P extends WP{parseFunction(t){return new ZP(t)}}class JP{constructor(){this.lightNodes=new WeakMap,this.materialNodes=new Map,this.toneMappingNodes=new Map,this.colorSpaceNodes=new Map}fromMaterial(t){if(t.isNodeMaterial)return t;let e=null;const n=this.getMaterialNodeClass(t.type);if(null!==n){e=new n;for(const n in t)e[n]=t[n]}return e}addColorSpace(t,e){this.addType(t,e,this.colorSpaceNodes)}getColorSpaceFunction(t){return this.colorSpaceNodes.get(t)||null}addToneMapping(t,e){this.addType(t,e,this.toneMappingNodes)}getToneMappingFunction(t){return this.toneMappingNodes.get(t)||null}getMaterialNodeClass(t){return this.materialNodes.get(t)||null}addMaterial(t,e){this.addType(t,e.name,this.materialNodes)}getLightNodeClass(t){return this.lightNodes.get(t)||null}addLight(t,e){this.addClass(t,e,this.lightNodes)}addType(t,e,n){if(n.has(e))console.warn(`Redefinition of node ${e}`);else{if("function"!=typeof t)throw new Error(`Node class ${t.name} is not a class.`);if("function"==typeof e||"object"==typeof e)throw new Error(`Base class ${e} is not a class.`);n.set(e,t)}}addClass(t,e,n){if(n.has(e))console.warn(`Redefinition of node ${e.name}`);else{if("function"!=typeof t)throw new Error(`Node class ${t.name} is not a class.`);if("function"!=typeof e)throw new Error(`Base class ${e.name} is not a class.`);n.set(e,t)}}}class KP extends fp{constructor(t,e,n,i,s,r){super(t,e,n,i,s,r),this.iesMap=null}copy(t,e){return super.copy(t,e),this.iesMap=t.iesMap,this}}class QP extends JP{constructor(){super(),this.addLight(PP,xp),this.addLight(UP,bp),this.addLight(VP,Sp),this.addLight(FP,fp),this.addLight(kP,Tp),this.addLight(HP,cp),this.addLight(GP,Ep),this.addLight(BP,KP),this.addToneMapping(HI,1),this.addToneMapping(GI,2),this.addToneMapping(WI,3),this.addToneMapping(XI,4),this.addToneMapping($I,6),this.addToneMapping(JI,7),this.addColorSpace(kI,V_(Ke,Je)),this.addColorSpace(BI,V_(Je,Ke))}}if("undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:t}})),"undefined"!=typeof window){try{import.meta&&(window.__THREE__IMPORTS__||(window.__THREE__IMPORTS__=[]),window.__THREE__IMPORTS__.push({url:import.meta.url,revision:t}))}catch{}window.__THREE__?(console.warn("WARNING: Multiple instances of Three.js being imported. Existing: "+window.__THREE__+", new: "+t),console.warn(window.__THREE__IMPORTS__)):window.__THREE__=t}export{et as ACESFilmicToneMapping,NT as AONode,x as AddEquation,$ as AddOperation,Be as AdditiveAnimationBlendMode,g as AdditiveBlending,NC as AfterImageNode,it as AgXToneMapping,Ft as AlphaFormat,Cn as AlwaysCompare,k as AlwaysDepth,Mn as AlwaysStencilFunc,Tp as AmbientLight,kP as AmbientLightNode,RR as AnaglyphPassNode,lI as AnalyticLightNode,VC as AnamorphicNode,dm as AnimationAction,qd as AnimationClip,np as AnimationLoader,mm as AnimationMixer,hm as AnimationObjectGroup,Ud as AnimationUtils,Ku as ArcCurve,Kl as ArrayCamera,Df as ArrayElementNode,lf as ArrowHelper,kv as AssignNode,rt as AttachedBindMode,yx as AttributeNode,$p as Audio,nm as AudioAnalyser,zp as AudioContext,Zp as AudioListener,Vp as AudioLoader,cf as AxesHelper,JS as BRDF_GGX,OS as BRDF_Lambert,d as BackSide,We as BasicDepthPacking,CS as BasicEnvironmentNode,QP as BasicNodeLibrary,o as BasicShadowMap,oT as BatchNode,bu as BatchedMesh,pR as BloomNode,Wc as Bone,Bd as BooleanKeyframeTrack,Nm as Box2,Oi as Box3,nf as Box3Helper,Wr as BoxGeometry,ef as BoxHelper,gT as Break,pr as BufferAttribute,J_ as BufferAttributeNode,Rr as BufferGeometry,Rp as BufferGeometryLoader,NM as BufferNode,lb as BumpMapNode,ax as BypassNode,At as ByteType,Zd as Cache,sx as CacheNode,Qr as Camera,Km as CameraHelper,Zu as CanvasTexture,_h as CapsuleGeometry,sh as CatmullRomCurve3,tt as CineonToneMapping,xh as CircleGeometry,mt as ClampToEdgeWrapping,Gp as Clock,qE as CodeNode,er as Color,kd as ColorKeyframeTrack,fi as ColorManagement,F_ as ColorSpaceNode,qu as CompressedArrayTexture,Yu as CompressedCubeTexture,Xu as CompressedTexture,ip as CompressedTextureLoader,nx as ComputeNode,bh as ConeGeometry,Wf as ConstNode,V as ConstantAlphaFactor,O as ConstantColorFactor,N_ as ContextNode,fT as Continue,hf as Controls,Of as ConvertNode,ra as CubeCamera,lt as CubeReflectionMapping,ct as CubeRefractionMapping,aa as CubeTexture,rp as CubeTextureLoader,EM as CubeTextureNode,dt as CubeUVReflectionMapping,lh as CubicBezierCurve,ch as CubicBezierCurve3,Od as CubicInterpolant,s as CullFaceBack,r as CullFaceFront,a as CullFaceFrontBack,i as CullFaceNone,$u as Curve,gh as CurvePath,_ as CustomBlending,nt as CustomToneMapping,Mh as CylinderGeometry,wm as Cylindrical,KS as DFGApprox,YS as D_GGX,Ri as Data3DTexture,Ni as DataArrayTexture,jc as DataTexture,ap as DataTextureLoader,ur as DataUtils,un as DecrementStencilOp,dn as DecrementWrapStencilOp,Jd as DefaultLoadingManager,iR as DenoiseNode,Wt as DepthFormat,HC as DepthOfFieldNode,jt as DepthStencilFormat,no as DepthTexture,at as DetachedBindMode,bp as DirectionalLight,Zm as DirectionalLightHelper,UP as DirectionalLightNode,px as Discard,Vd as DiscreteInterpolant,Qe as DisplayP3ColorSpace,Sh as DodecahedronGeometry,WC as DotScreenNode,p as DoubleSide,I as DstAlphaFactor,P as DstColorFactor,zn as DynamicCopyUsage,In as DynamicDrawUsage,Un as DynamicReadUsage,fy as EPSILON,Ch as EdgesGeometry,Ju as EllipseCurve,rE as EnvironmentNode,Sn as EqualCompare,W as EqualDepth,gn as EqualStencilFunc,MS as EquirectUVNode,ut as EquirectangularReflectionMapping,ht as EquirectangularRefractionMapping,_s as Euler,Gn as EventDispatcher,hx as ExpressionNode,rd as ExtrudeGeometry,rR as FXAANode,DS as F_Schlick,ep as FileLoader,YC as FilmNode,Mr as Float16BufferAttribute,br as Float32BufferAttribute,Lt as FloatType,wg as Fn,uc as Fog,cc as FogExp2,qR as FogExp2Node,GR as FogNode,jR as FogRangeNode,ju as FramebufferTexture,lM as FrontFacingNode,h as FrontSide,ma as Frustum,Gv as FunctionCallNode,KE as FunctionNode,eN as FunctionOverloadingNode,_m as GLBufferAttribute,Fn as GLSL1,Bn as GLSL3,$P as GLSLNodeParser,eR as GTAONode,SC as GaussianBlurNode,En as GreaterCompare,X as GreaterDepth,Nn as GreaterEqualCompare,j as GreaterEqualDepth,xn as GreaterEqualStencilFunc,yn as GreaterStencilFunc,Wm as GridHelper,Ql as Group,Pt as HalfFloatType,cp as HemisphereLight,Gm as HemisphereLightHelper,HP as HemisphereLightNode,BP as IESSpotLightNode,gy as INFINITY,od as IcosahedronGeometry,Cg as If,Dp as ImageBitmapLoader,sp as ImageLoader,_i as ImageUtils,cn as IncrementStencilOp,hn as IncrementWrapStencilOp,Kb as IndexNode,rT as InstanceNode,Zc as InstancedBufferAttribute,Cp as InstancedBufferGeometry,ym as InstancedInterleavedBuffer,iu as InstancedMesh,uS as InstancedPointsNodeMaterial,vr as Int16BufferAttribute,_r as Int32BufferAttribute,mr as Int8BufferAttribute,Rt as IntType,dc as InterleavedBuffer,mc as InterleavedBufferAttribute,Dd as Interpolant,Pe as InterpolateDiscrete,Ue as InterpolateLinear,De as InterpolateSmooth,pn as InvertStencilOp,IT as IrradianceNode,Vf as JoinNode,on as KeepStencilOp,Fd as KeyframeTrack,Pc as LOD,yh as LatheGeometry,xs as Layers,Tn as LessCompare,H as LessDepth,wn as LessEqualCompare,G as LessEqualDepth,vn as LessEqualStencilFunc,fn as LessStencilFunc,lp as Light,Ep as LightProbe,GP as LightProbeNode,CT as LightingContextNode,IS as LightingModel,AT as LightingNode,wT as LightsNode,Iu as Line,gS as Line2NodeMaterial,Im as Line3,Tu as LineBasicMaterial,dS as LineBasicNodeMaterial,uh as LineCurve,hh as LineCurve3,Nd as LineDashedMaterial,mS as LineDashedNodeMaterial,Ou as LineLoop,Du as LineSegments,tn as LinearDisplayP3ColorSpace,Mt as LinearFilter,zd as LinearInterpolant,wt as LinearMipMapLinearFilter,Tt as LinearMipMapNearestFilter,St as LinearMipmapLinearFilter,bt as LinearMipmapNearestFilter,Ke as LinearSRGBColorSpace,K as LinearToneMapping,en as LinearTransfer,Kd as Loader,Np as LoaderUtils,$d as LoadingManager,mT as Loop,pT as LoopNode,Re as LoopOnce,Le as LoopPingPong,Ie as LoopRepeat,Gt as LuminanceAlphaFormat,Ht as LuminanceFormat,$C as Lut3DNode,e as MOUSE,QA as MRTNode,yE as MatcapUVNode,sr as Material,Ap as MaterialLoader,hb as MaterialNode,VM as MaterialReferenceNode,ti as MathUtils,Em as Matrix2,ni as Matrix3,cs as Matrix4,S as MaxEquation,Tx as MaxMipLevelNode,Hr as Mesh,rr as MeshBasicMaterial,US as MeshBasicNodeMaterial,Gl as MeshDepthMaterial,Wl as MeshDistanceMaterial,Ed as MeshLambertMaterial,kS as MeshLambertNodeMaterial,Ad as MeshMatcapMaterial,ME as MeshMatcapNodeMaterial,wd as MeshNormalMaterial,xS as MeshNormalNodeMaterial,Td as MeshPhongMaterial,GS as MeshPhongNodeMaterial,bd as MeshPhysicalMaterial,hE as MeshPhysicalNodeMaterial,pE as MeshSSSNodeMaterial,Md as MeshStandardMaterial,cE as MeshStandardNodeMaterial,Sd as MeshToonMaterial,vE as MeshToonNodeMaterial,T as MinEquation,ft as MirroredRepeatWrapping,Z as MixOperation,Wx as ModelNode,$b as ModelViewProjectionNode,MT as MorphNode,y as MultiplyBlending,Y as MultiplyOperation,gt as NearestFilter,xt as NearestMipMapLinearFilter,yt as NearestMipMapNearestFilter,_t as NearestMipmapLinearFilter,vt as NearestMipmapNearestFilter,st as NeutralToneMapping,bn as NeverCompare,B as NeverDepth,mn as NeverStencilFunc,m as NoBlending,$e as NoColorSpace,J as NoToneMapping,Uf as Node,VE as NodeAttribute,XA as NodeBuilder,WE as NodeCache,HE as NodeCode,qA as NodeFrame,YA as NodeFunctionInput,DE as NodeLoader,lS as NodeMaterial,OE as NodeMaterialLoader,mf as NodeMaterialObserver,zE as NodeObjectLoader,Ef as NodeShaderStage,Nf as NodeType,FE as NodeUniform,Af as NodeUpdateType,wf as NodeUtils,BE as NodeVar,kE as NodeVarying,Fe as NormalAnimationBlendMode,f as NormalBlending,sb as NormalMapNode,An as NotEqualCompare,q as NotEqualDepth,_n as NotEqualStencilFunc,Hd as NumberKeyframeTrack,Os as Object3D,Vx as Object3DNode,Ip as ObjectLoader,Ze as ObjectSpaceNormalMap,ld as OctahedronGeometry,E as OneFactor,F as OneMinusConstantAlphaFactor,z as OneMinusConstantColorFactor,L as OneMinusDstAlphaFactor,U as OneMinusDstColorFactor,R as OneMinusSrcAlphaFactor,N as OneMinusSrcColorFactor,Ra as OrthographicCamera,cN as OscNode,$A as OutputStructNode,rn as P3Primaries,l as PCFShadowMap,c as PCFSoftShadowMap,vy as PI,yy as PI2,Ha as PMREMGenerator,nE as PMREMNode,LR as ParallaxBarrierPassNode,jE as ParameterNode,yC as PassNode,vh as Path,ia as PerspectiveCamera,FS as PhongLightingModel,Lw as PhysicalLightingModel,yR as PixelationPassNode,ha as Plane,va as PlaneGeometry,sf as PlaneHelper,xp as PointLight,Fm as PointLightHelper,PP as PointLightNode,qN as PointUVNode,Hu as Points,zu as PointsMaterial,TE as PointsNodeMaterial,jm as PolarGridHelper,Th as PolyhedronGeometry,em as PositionalAudio,uC as PosterizeNode,um as PropertyBinding,im as PropertyMixer,uv as PropertyNode,dh as QuadraticBezierCurve,ph as QuadraticBezierCurve3,Li as Quaternion,Wd as QuaternionKeyframeTrack,Gd as QuaternionLinearInterpolant,Ne as RED_GREEN_RGTC2_Format,Ee as RED_RGTC1_Format,t as REVISION,je as RGBADepthPacking,kt as RGBAFormat,Jt as RGBAIntegerFormat,xe as RGBA_ASTC_10x10_Format,ve as RGBA_ASTC_10x5_Format,ye as RGBA_ASTC_10x6_Format,_e as RGBA_ASTC_10x8_Format,Me as RGBA_ASTC_12x10_Format,be as RGBA_ASTC_12x12_Format,ce as RGBA_ASTC_4x4_Format,ue as RGBA_ASTC_5x4_Format,he as RGBA_ASTC_5x5_Format,de as RGBA_ASTC_6x5_Format,pe as RGBA_ASTC_6x6_Format,me as RGBA_ASTC_8x5_Format,fe as RGBA_ASTC_8x6_Format,ge as RGBA_ASTC_8x8_Format,Te as RGBA_BPTC_Format,le as RGBA_ETC2_EAC_Format,re as RGBA_PVRTC_2BPPV1_Format,se as RGBA_PVRTC_4BPPV1_Format,Qt as RGBA_S3TC_DXT1_Format,te as RGBA_S3TC_DXT3_Format,ee as RGBA_S3TC_DXT5_Format,Xe as RGBDepthPacking,Bt as RGBFormat,$t as RGBIntegerFormat,XC as RGBShiftNode,Se as RGB_BPTC_SIGNED_Format,we as RGB_BPTC_UNSIGNED_Format,ae as RGB_ETC1_Format,oe as RGB_ETC2_Format,ie as RGB_PVRTC_2BPPV1_Format,ne as RGB_PVRTC_4BPPV1_Format,Kt as RGB_S3TC_DXT1_Format,qe as RGDepthPacking,Yt as RGFormat,Zt as RGIntegerFormat,HN as RTTNode,JR as RangeNode,xd as RawShaderMaterial,ls as Ray,Mm as Raycaster,sn as Rec709Primaries,Sp as RectAreaLight,VP as RectAreaLightNode,Xt as RedFormat,qt as RedIntegerFormat,DM as ReferenceNode,DN as ReflectorNode,Q as ReinhardToneMapping,lx as RemapNode,fx as RenderOutputNode,Ei as RenderTarget,X_ as RendererReferenceNode,pt as RepeatWrapping,ln as ReplaceStencilOp,mx as Return,b as ReverseSubtractEquation,cd as RingGeometry,SE as RotateNode,Ce as SIGNED_RED_GREEN_RGTC2_Format,Ae as SIGNED_RED_RGTC1_Format,Je as SRGBColorSpace,nn as SRGBTransfer,MR as SSAAPassNode,hc as Scene,ZN as SceneNode,tw as Schlick_to_F0,UT as ScreenNode,kR as ScriptableNode,OR as ScriptableValueNode,kf as SetNode,ya as ShaderChunk,xa as ShaderLib,Zr as ShaderMaterial,_g as ShaderNode,_d as ShadowMaterial,RE as ShadowNodeMaterial,Rh as Shape,ud as ShapeGeometry,uf as ShapePath,nd as ShapeUtils,Nt as ShortType,Yc as Skeleton,zm as SkeletonHelper,Gc as SkinnedMesh,uT as SkinningNode,BC as SobelOperatorNode,Mi as Source,ts as Sphere,hd as SphereGeometry,Sm as Spherical,wp as SphericalHarmonics3,mh as SplineCurve,Bf as SplitNode,fp as SpotLight,Pm as SpotLightHelper,FP as SpotLightNode,Cc as Sprite,fc as SpriteMaterial,AE as SpriteNodeMaterial,mN as SpriteSheetUVNode,C as SrcAlphaFactor,D as SrcAlphaSaturateFactor,A as SrcColorFactor,vA as StackNode,On as StaticCopyUsage,Rn as StaticDrawUsage,Pn as StaticReadUsage,Hp as StereoCamera,wR as StereoPassNode,gN as StorageArrayElementNode,nC as StorageBufferNode,rC as StorageTextureNode,Vn as StreamCopyUsage,Ln as StreamDrawUsage,Dn as StreamReadUsage,jd as StringKeyframeTrack,M as SubtractEquation,v as SubtractiveBlending,QM as TBNViewMatrix,n as TOUCH,Ye as TangentSpaceNormalMap,zf as TempNode,dd as TetrahedronGeometry,Si as Texture,LE as Texture3DNode,op as TextureLoader,wx as TextureNode,Mx as TextureSizeNode,Zl as TextureUtils,sN as TimerNode,Y_ as ToneMappingNode,UR as ToonOutlinePassNode,pd as TorusGeometry,md as TorusKnotGeometry,fR as TransitionNode,$s as Triangle,Ge as TriangleFanDrawMode,He as TriangleStripDrawMode,ke as TrianglesDrawMode,yN as TriplanarTexturesNode,fd as TubeGeometry,ot as UVMapping,yr as Uint16BufferAttribute,xr as Uint32BufferAttribute,fr as Uint8BufferAttribute,gr as Uint8ClampedBufferAttribute,fm as Uniform,IM as UniformArrayNode,nv as UniformGroupNode,lv as UniformNode,vm as UniformsGroup,_a as UniformsLib,Yr as UniformsUtils,Et as UnsignedByteType,Vt as UnsignedInt101111Type,Ot as UnsignedInt248Type,zt as UnsignedInt5999Type,It as UnsignedIntType,Ut as UnsignedShort4444Type,Dt as UnsignedShort5551Type,Ct as UnsignedShortType,lC as UserDataNode,u as VSMShadowMap,XS as V_GGX_SmithCorrelated,I_ as VarNode,P_ as VaryingNode,ei as Vector2,Pi as Vector3,wi as Vector4,Xd as VectorKeyframeTrack,jN as VertexColorNode,Wu as VideoTexture,KT as ViewportDepthNode,$T as ViewportDepthTextureNode,pC as ViewportSharedTextureNode,XT as ViewportTextureNode,UE as VolumeNodeMaterial,Ii as WebGL3DRenderTarget,Ci as WebGLArrayRenderTarget,kn as WebGLCoordinateSystem,oa as WebGLCubeRenderTarget,df as WebGLMultipleRenderTargets,Ai as WebGLRenderTarget,lc as WebGLRenderer,Jl as WebGLUtils,Hn as WebGPUCoordinateSystem,gd as WireframeGeometry,Ve as WrapAroundEnding,Oe as ZeroCurvatureEnding,w as ZeroFactor,ze as ZeroSlopeEnding,an as ZeroStencilOp,By as abs,XI as acesFilmicToneMapping,Vy as acos,Xv as add,qf as addMethodChaining,vx as addNodeElement,CC as afterImage,$I as agxToneMapping,_y as all,Sv as alphaT,IR as anaglyphPass,FC as anamorphic,iy as and,wv as anisotropy,Av as anisotropyB,Ev as anisotropyT,xy as any,nR as ao,Rg as append,Kg as arrayBuffer,zy as asin,Hv as assign,Fy as atan,Qy as atan2,fL as atomicAdd,_L as atomicAnd,pL as atomicFunc,vL as atomicMax,yL as atomicMin,xL as atomicOr,mL as atomicStore,gL as atomicSub,ML as atomicXor,Fv as attenuationColor,Vv as attenuationDistance,_x as attribute,$N as backgroundBlurriness,JN as backgroundIntensity,lT as batch,EI as billboarding,oy as bitAnd,ly as bitNot,cy as bitOr,uy as bitXor,qM as bitangentGeometry,YM as bitangentLocal,ZM as bitangentView,$M as bitangentWorld,Jy as bitcast,VI as bleach,mR as bloom,Kw as blur,Dg as bool,CM as buffer,K_ as bufferAttribute,cb as bumpMap,PI as burn,Fg as bvec2,Gg as bvec3,qg as bvec4,ox as bypass,rx as cache,Wv as call,Rx as cameraFar,Ix as cameraLogDepth,Cx as cameraNear,Ox as cameraNormalMatrix,zx as cameraPosition,Lx as cameraProjectionMatrix,Px as cameraProjectionMatrixInverse,Ux as cameraViewMatrix,Dx as cameraWorldMatrix,m_ as cbrt,Iy as ceil,bL as checker,WI as cineonToneMapping,v_ as clamp,vv as clearcoat,yv as clearcoatRoughness,YE as code,Ig as color,G_ as colorSpaceToWorking,yS as colorToDirection,ix as compute,A_ as cond,C_ as context,tv as convert,WN as convertToTexture,Dy as cos,li as createCanvasElement,l_ as cross,AM as cubeTexture,jy as dFdx,Xy as dFdy,Lv as dashSize,Rf as defaultBuildStages,Cf as defaultShaderStages,vg as defined,Ty as degrees,sR as denoise,YR as densityFog,sS as depth,MC as depthPass,a_ as difference,pv as diffuseColor,vS as directionToColor,Bv as dispersion,r_ as distance,Zv as div,UI as dodge,GC as dof,o_ as dot,jC as dotScreen,sT as drawIndex,Q_ as dynamicBufferAttribute,Qg as element,mv as emissive,Jv as equal,My as equals,bS as equirectUV,Sy as exp,wy as exp2,dx as expression,uM as faceDirection,M_ as faceForward,ZC as film,Lg as float,Ry as floor,WR as fog,Py as fract,rv as frameGroup,lN as frameId,cM as frontFacing,$y as fwidth,aR as fxaa,yI as gain,Pv as gapSize,wC as gaussianBlur,V_ as getColorSpaceMethod,yg as getConstNodeType,Ng as getCurrentStack,Yw as getDirection,cI as getDistanceAttenuation,WS as getGeometryRoughness,jS as getRoughness,LP as getShIrradianceAt,KA as getTextureIndex,BR as global,JE as glsl,tA as glslFn,RC as grayscale,ty as greaterThan,ny as greaterThanEqual,gI as hash,tM as highPrecisionModelNormalViewMatrix,Qx as highPrecisionModelViewMatrix,PC as hue,aT as instance,tT as instanceIndex,tx as instancedBufferAttribute,ex as instancedDynamicBufferAttribute,Pg as int,Cy as inverseSqrt,iT as invocationLocalIndex,nT as invocationSubgroupIndex,Dv as ior,Mv as iridescence,bv as iridescenceIOR,Tv as iridescenceThickness,zg as ivec2,kg as ivec3,jg as ivec4,ZE as js,R_ as label,Hy as length,f_ as lengthSq,Qv as lessThan,ey as lessThanEqual,dI as lightPosition,fI as lightTargetDirection,pI as lightTargetPosition,mI as lightViewPosition,RT as lightingContext,ET as lights,rS as linearDepth,kI as linearSRGBTosRGB,HI as linearToneMapping,nL as localId,Ey as log,Ay as log2,vT as loop,DC as luminance,JC as lut3D,Yg as mat2,Zg as mat3,$g as mat4,_E as matcapUV,Yb as materialAOMap,db as materialAlphaTest,Ib as materialAnisotropy,Zb as materialAnisotropyVector,Fb as materialAttenuationColor,Vb as materialAttenuationDistance,wb as materialClearcoat,Ab as materialClearcoatNormal,Eb as materialClearcoatRoughness,pb as materialColor,Xb as materialDispersion,fb as materialEmissive,zb as materialIOR,Lb as materialIridescence,Pb as materialIridescenceIOR,Ub as materialIridescenceThickness,qb as materialLightMap,Wb as materialLineDashOffset,kb as materialLineDashSize,Hb as materialLineGapSize,Bb as materialLineScale,Gb as materialLineWidth,Tb as materialMetalness,Sb as materialNormal,gb as materialOpacity,jb as materialPointWidth,FM as materialReference,Mb as materialReflectivity,MM as materialRefractionRatio,Nb as materialRotation,bb as materialRoughness,Cb as materialSheen,Rb as materialSheenRoughness,mb as materialShininess,vb as materialSpecular,_b as materialSpecularColor,yb as materialSpecularIntensity,xb as materialSpecularStrength,Ob as materialThickness,Db as materialTransmission,e_ as max,Sx as maxMipLevel,gv as metalness,t_ as min,g_ as mix,T_ as mixElement,n_ as mod,$v as modInt,jx as modelDirection,$x as modelNormalMatrix,qx as modelPosition,Yx as modelScale,Kx as modelViewMatrix,Zx as modelViewPosition,Jb as modelViewProjection,Xx as modelWorldMatrix,Jx as modelWorldMatrixInverse,bT as morphReference,zI as motionBlur,tN as mrt,Yv as mul,hP as mx_aastep,AP as mx_cell_noise_float,xP as mx_contrast,NP as mx_fractal_noise_float,CP as mx_fractal_noise_vec2,RP as mx_fractal_noise_vec3,IP as mx_fractal_noise_vec4,lP as mx_hsvtorgb,MP as mx_noise_float,bP as mx_noise_vec3,TP as mx_noise_vec4,pP as mx_ramplr,mP as mx_ramptb,cP as mx_rgbtohsv,_P as mx_safepower,gP as mx_splitlr,vP as mx_splittb,uP as mx_srgb_texture_to_lin_rec709,yP as mx_transform_uv,SP as mx_worley_noise_float,wP as mx_worley_noise_vec2,EP as mx_worley_noise_vec3,Gy as negate,JI as neutralToneMapping,bg as nodeArray,Sg as nodeImmutable,xg as nodeObject,Mg as nodeObjects,Tg as nodeProxy,pM as normalFlat,hM as normalGeometry,dM as normalLocal,rb as normalMap,mM as normalView,fM as normalWorld,Ly as normalize,ry as not,Kv as notEqual,tL as numWorkgroups,Fx as objectDirection,ov as objectGroup,kx as objectPosition,Hx as objectScale,Gx as objectViewPosition,Bx as objectWorldMatrix,Wy as oneMinus,sy as or,tS as orthographicDepthToViewZ,pN as oscSawtooth,uN as oscSine,hN as oscSquare,dN as oscTriangle,Iv as output,JA as outputStruct,OI as overlay,iN as overloadingFn,vI as parabola,PR as parallaxBarrierPass,tb as parallaxDirection,eb as parallaxUV,XE as parameter,_C as pass,xC as passTexture,_I as pcurve,nS as perspectiveDepthToViewZ,_R as pixelationPass,iE as pmremTexture,YN as pointUV,Uv as pointWidth,eM as positionGeometry,nM as positionLocal,iM as positionPrevious,aM as positionView,oM as positionViewDirection,sM as positionWorld,rM as positionWorldDirection,hC as posterize,c_ as pow,u_ as pow2,h_ as pow3,d_ as pow4,hv as property,by as radians,b_ as rand,KR as range,XR as rangeFog,Yy as reciprocal,OM as reference,zM as referenceBuffer,s_ as reflect,SM as reflectVector,bM as reflectView,ON as reflector,__ as refract,wM as refractVector,TM as refractView,GI as reinhardToneMapping,py as remainder,cx as remap,ux as remapClamp,av as renderGroup,gx as renderOutput,q_ as rendererReference,qC as rgbShift,wE as rotate,SI as rotateUV,fv as roughness,qy as round,GN as rtt,BI as sRGBToLinearSRGB,Nx as sampler,y_ as saturate,IC as saturation,DI as screen,zT as screenCoordinate,OT as screenSize,DT as screenUV,HR as scriptable,zR as scriptableValue,E_ as select,FI as sepia,Ag as setCurrentStack,If as shaderStages,sv as sharedUniformGroup,_v as sheen,xv as sheenRoughness,hy as shiftLeft,dy as shiftRight,Rv as shininess,ky as sign,Uy as sin,xI as sinc,hT as skinning,dT as skinningReference,x_ as smoothstep,S_ as smoothstepElement,kC as sobel,Nv as specularColor,Cv as specularF90,wI as spherizeUV,ev as split,fN as spritesheetUV,Ny as sqrt,TR as ssaaPass,yA as stack,i_ as step,ER as stereoPass,iC as storage,aL as storageBarrier,sC as storageObject,aC as storageTexture,Jg as string,qv as sub,eT as subgroupIndex,iL as subgroupSize,Oy as tan,BM as tangentGeometry,kM as tangentLocal,HM as tangentView,GM as tangentWorld,L_ as temp,Ex as texture,PE as texture3D,oL as textureBarrier,yw as textureBicubic,Zw as textureCubeUV,Ax as textureLoad,bx as textureSize,oC as textureStore,zv as thickness,OC as threshold,oN as timerDelta,aN as timerGlobal,rN as timerLocal,B_ as toOutputColorSpace,k_ as toWorkingColorSpace,Z_ as toneMapping,$_ as toneMappingExposure,DR as toonOutlinePass,p_ as transformDirection,_M as transformNormal,xM as transformNormalToView,nb as transformedBentNormalView,JM as transformedBitangentView,KM as transformedBitangentWorld,yM as transformedClearcoatNormalView,gM as transformedNormalView,vM as transformedNormalWorld,WM as transformedTangentView,jM as transformedTangentWorld,gR as transition,Ov as transmission,Ky as transpose,MI as tri,bI as tri3,TI as triNoise3D,xN as triplanarTexture,_N as triplanarTextures,Zy as trunc,Eg as tslFn,Ug as uint,cv as uniform,LM as uniformArray,iv as uniformGroup,PM as uniforms,cC as userData,xx as uv,Vg as uvec2,Hg as uvec3,Xg as uvec4,U_ as varying,dv as varyingProperty,Og as vec2,Bg as vec3,Wg as vec4,Lf as vectorComponents,LI as velocity,XN as vertexColor,Qb as vertexIndex,LC as vibrance,QT as viewZToOrthographicDepth,eS as viewZToPerspectiveDepth,VT as viewport,WT as viewportBottomLeft,BT as viewportCoordinate,JT as viewportDepthTexture,aS as viewportLinearDepth,YT as viewportMipTexture,HT as viewportResolution,AI as viewportSafeUV,mC as viewportSharedTexture,FT as viewportSize,qT as viewportTexture,GT as viewportTopLeft,kT as viewportUV,$E as wgsl,eA as wgslFn,uL as workgroupArray,rL as workgroupBarrier,eL as workgroupId,H_ as workingToColorSpace,ay as xor};
|
|
6
|
+
import{Matrix3 as e,Vector2 as t,Color as n,mergeUniforms as i,Vector3 as r,CubeUVReflectionMapping as a,Mesh as o,BoxGeometry as s,ShaderMaterial as l,BackSide as c,cloneUniforms as d,Euler as u,Matrix4 as f,ColorManagement as p,SRGBTransfer as m,PlaneGeometry as h,FrontSide as _,getUnlitUniformColorSpace as g,IntType as v,warn as E,HalfFloatType as S,UnsignedByteType as M,FloatType as T,RGBAFormat as x,Plane as A,CubeReflectionMapping as R,CubeRefractionMapping as b,BufferGeometry as C,OrthographicCamera as P,PerspectiveCamera as L,NoToneMapping as U,MeshBasicMaterial as D,error as w,NoBlending as I,WebGLRenderTarget as N,BufferAttribute as y,LinearSRGBColorSpace as F,LinearFilter as O,CubeTexture as B,LinearMipmapLinearFilter as G,CubeCamera as H,EquirectangularReflectionMapping as V,EquirectangularRefractionMapping as W,warnOnce as z,Uint32BufferAttribute as k,Uint16BufferAttribute as X,Vector4 as Y,DataArrayTexture as K,Float32BufferAttribute as q,RawShaderMaterial as j,CustomToneMapping as Z,NeutralToneMapping as $,AgXToneMapping as Q,ACESFilmicToneMapping as J,CineonToneMapping as ee,ReinhardToneMapping as te,LinearToneMapping as ne,Data3DTexture as ie,GreaterEqualCompare as re,LessEqualCompare as ae,DepthTexture as oe,Texture as se,GLSL3 as le,VSMShadowMap as ce,PCFShadowMap as de,AddOperation as ue,MixOperation as fe,MultiplyOperation as pe,LinearTransfer as me,UniformsUtils as he,DoubleSide as _e,NormalBlending as ge,TangentSpaceNormalMap as ve,ObjectSpaceNormalMap as Ee,Layers as Se,RGFormat as Me,Frustum as Te,MeshDepthMaterial as xe,MeshDistanceMaterial as Ae,PCFSoftShadowMap as Re,DepthFormat as be,NearestFilter as Ce,CubeDepthTexture as Pe,UnsignedIntType as Le,LessEqualDepth as Ue,ReverseSubtractEquation as De,SubtractEquation as we,AddEquation as Ie,OneMinusConstantAlphaFactor as Ne,ConstantAlphaFactor as ye,OneMinusConstantColorFactor as Fe,ConstantColorFactor as Oe,OneMinusDstAlphaFactor as Be,OneMinusDstColorFactor as Ge,OneMinusSrcAlphaFactor as He,OneMinusSrcColorFactor as Ve,DstAlphaFactor as We,DstColorFactor as ze,SrcAlphaSaturateFactor as ke,SrcAlphaFactor as Xe,SrcColorFactor as Ye,OneFactor as Ke,ZeroFactor as qe,NotEqualDepth as je,GreaterDepth as Ze,GreaterEqualDepth as $e,EqualDepth as Qe,LessDepth as Je,AlwaysDepth as et,NeverDepth as tt,CullFaceNone as nt,CullFaceBack as it,CullFaceFront as rt,CustomBlending as at,MultiplyBlending as ot,SubtractiveBlending as st,AdditiveBlending as lt,ReversedDepthFuncs as ct,MinEquation as dt,MaxEquation as ut,MirroredRepeatWrapping as ft,ClampToEdgeWrapping as pt,RepeatWrapping as mt,LinearMipmapNearestFilter as ht,NearestMipmapLinearFilter as _t,NearestMipmapNearestFilter as gt,NotEqualCompare as vt,GreaterCompare as Et,EqualCompare as St,LessCompare as Mt,AlwaysCompare as Tt,NeverCompare as xt,NoColorSpace as At,DepthStencilFormat as Rt,getByteLength as bt,UnsignedInt248Type as Ct,UnsignedShortType as Pt,createElementNS as Lt,UnsignedShort4444Type as Ut,UnsignedShort5551Type as Dt,UnsignedInt5999Type as wt,UnsignedInt101111Type as It,ByteType as Nt,ShortType as yt,AlphaFormat as Ft,RGBFormat as Ot,RedFormat as Bt,RedIntegerFormat as Gt,RGIntegerFormat as Ht,RGBAIntegerFormat as Vt,RGB_S3TC_DXT1_Format as Wt,RGBA_S3TC_DXT1_Format as zt,RGBA_S3TC_DXT3_Format as kt,RGBA_S3TC_DXT5_Format as Xt,RGB_PVRTC_4BPPV1_Format as Yt,RGB_PVRTC_2BPPV1_Format as Kt,RGBA_PVRTC_4BPPV1_Format as qt,RGBA_PVRTC_2BPPV1_Format as jt,RGB_ETC1_Format as Zt,RGB_ETC2_Format as $t,RGBA_ETC2_EAC_Format as Qt,R11_EAC_Format as Jt,SIGNED_R11_EAC_Format as en,RG11_EAC_Format as tn,SIGNED_RG11_EAC_Format as nn,RGBA_ASTC_4x4_Format as rn,RGBA_ASTC_5x4_Format as an,RGBA_ASTC_5x5_Format as on,RGBA_ASTC_6x5_Format as sn,RGBA_ASTC_6x6_Format as ln,RGBA_ASTC_8x5_Format as cn,RGBA_ASTC_8x6_Format as dn,RGBA_ASTC_8x8_Format as un,RGBA_ASTC_10x5_Format as fn,RGBA_ASTC_10x6_Format as pn,RGBA_ASTC_10x8_Format as mn,RGBA_ASTC_10x10_Format as hn,RGBA_ASTC_12x10_Format as _n,RGBA_ASTC_12x12_Format as gn,RGBA_BPTC_Format as vn,RGB_BPTC_SIGNED_Format as En,RGB_BPTC_UNSIGNED_Format as Sn,RED_RGTC1_Format as Mn,SIGNED_RED_RGTC1_Format as Tn,RED_GREEN_RGTC2_Format as xn,SIGNED_RED_GREEN_RGTC2_Format as An,ExternalTexture as Rn,EventDispatcher as bn,ArrayCamera as Cn,WebXRController as Pn,RAD2DEG as Ln,DataTexture as Un,createCanvasElement as Dn,SRGBColorSpace as wn,REVISION as In,log as Nn,WebGLCoordinateSystem as yn,probeAsync as Fn}from"./three.core.min.js";export{AdditiveAnimationBlendMode,AlwaysStencilFunc,AmbientLight,AnimationAction,AnimationClip,AnimationLoader,AnimationMixer,AnimationObjectGroup,AnimationUtils,ArcCurve,ArrowHelper,AttachedBindMode,Audio,AudioAnalyser,AudioContext,AudioListener,AudioLoader,AxesHelper,BasicDepthPacking,BasicShadowMap,BatchedMesh,BezierInterpolant,Bone,BooleanKeyframeTrack,Box2,Box3,Box3Helper,BoxHelper,BufferGeometryLoader,Cache,Camera,CameraHelper,CanvasTexture,CapsuleGeometry,CatmullRomCurve3,CircleGeometry,Clock,ColorKeyframeTrack,Compatibility,CompressedArrayTexture,CompressedCubeTexture,CompressedTexture,CompressedTextureLoader,ConeGeometry,Controls,CubeTextureLoader,CubicBezierCurve,CubicBezierCurve3,CubicInterpolant,CullFaceFrontBack,Curve,CurvePath,CylinderGeometry,Cylindrical,DataTextureLoader,DataUtils,DecrementStencilOp,DecrementWrapStencilOp,DefaultLoadingManager,DetachedBindMode,DirectionalLight,DirectionalLightHelper,DiscreteInterpolant,DodecahedronGeometry,DynamicCopyUsage,DynamicDrawUsage,DynamicReadUsage,EdgesGeometry,EllipseCurve,EqualStencilFunc,ExtrudeGeometry,FileLoader,Float16BufferAttribute,Fog,FogExp2,FramebufferTexture,FrustumArray,GLBufferAttribute,GLSL1,GreaterEqualStencilFunc,GreaterStencilFunc,GridHelper,Group,HemisphereLight,HemisphereLightHelper,IcosahedronGeometry,ImageBitmapLoader,ImageLoader,ImageUtils,IncrementStencilOp,IncrementWrapStencilOp,InstancedBufferAttribute,InstancedBufferGeometry,InstancedInterleavedBuffer,InstancedMesh,Int16BufferAttribute,Int32BufferAttribute,Int8BufferAttribute,InterleavedBuffer,InterleavedBufferAttribute,Interpolant,InterpolateBezier,InterpolateDiscrete,InterpolateLinear,InterpolateSmooth,InterpolationSamplingMode,InterpolationSamplingType,InvertStencilOp,KeepStencilOp,KeyframeTrack,LOD,LatheGeometry,LessEqualStencilFunc,LessStencilFunc,Light,LightProbe,Line,Line3,LineBasicMaterial,LineCurve,LineCurve3,LineDashedMaterial,LineLoop,LineSegments,LinearInterpolant,LinearMipMapLinearFilter,LinearMipMapNearestFilter,Loader,LoaderUtils,LoadingManager,LoopOnce,LoopPingPong,LoopRepeat,MOUSE,Material,MaterialBlending,MaterialLoader,MathUtils,Matrix2,MeshLambertMaterial,MeshMatcapMaterial,MeshNormalMaterial,MeshPhongMaterial,MeshPhysicalMaterial,MeshStandardMaterial,MeshToonMaterial,NearestMipMapLinearFilter,NearestMipMapNearestFilter,NeverStencilFunc,NoNormalPacking,NormalAnimationBlendMode,NormalGAPacking,NormalRGPacking,NotEqualStencilFunc,NumberKeyframeTrack,Object3D,ObjectLoader,OctahedronGeometry,Path,PlaneHelper,PointLight,PointLightHelper,Points,PointsMaterial,PolarGridHelper,PolyhedronGeometry,PositionalAudio,PropertyBinding,PropertyMixer,QuadraticBezierCurve,QuadraticBezierCurve3,Quaternion,QuaternionKeyframeTrack,QuaternionLinearInterpolant,RGBADepthPacking,RGBDepthPacking,RGBIntegerFormat,RGDepthPacking,Ray,Raycaster,RectAreaLight,RenderTarget,RenderTarget3D,ReplaceStencilOp,RingGeometry,Scene,ShadowMaterial,Shape,ShapeGeometry,ShapePath,ShapeUtils,Skeleton,SkeletonHelper,SkinnedMesh,Source,Sphere,SphereGeometry,Spherical,SphericalHarmonics3,SplineCurve,SpotLight,SpotLightHelper,Sprite,SpriteMaterial,StaticCopyUsage,StaticDrawUsage,StaticReadUsage,StereoCamera,StreamCopyUsage,StreamDrawUsage,StreamReadUsage,StringKeyframeTrack,TOUCH,TetrahedronGeometry,TextureLoader,TextureUtils,Timer,TimestampQuery,TorusGeometry,TorusKnotGeometry,Triangle,TriangleFanDrawMode,TriangleStripDrawMode,TrianglesDrawMode,TubeGeometry,UVMapping,Uint8BufferAttribute,Uint8ClampedBufferAttribute,Uniform,UniformsGroup,VectorKeyframeTrack,VideoFrameTexture,VideoTexture,WebGL3DRenderTarget,WebGLArrayRenderTarget,WebGPUCoordinateSystem,WireframeGeometry,WrapAroundEnding,ZeroCurvatureEnding,ZeroSlopeEnding,ZeroStencilOp,getConsoleFunction,setConsoleFunction}from"./three.core.min.js";function On(){let e=null,t=!1,n=null,i=null;function r(t,a){n(t,a),i=e.requestAnimationFrame(r)}return{start:function(){!0!==t&&null!==n&&(i=e.requestAnimationFrame(r),t=!0)},stop:function(){e.cancelAnimationFrame(i),t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function Bn(e){const t=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),t.get(e)},remove:function(n){n.isInterleavedBufferAttribute&&(n=n.data);const i=t.get(n);i&&(e.deleteBuffer(i.buffer),t.delete(n))},update:function(n,i){if(n.isInterleavedBufferAttribute&&(n=n.data),n.isGLBufferAttribute){const e=t.get(n);return void((!e||e.version<n.version)&&t.set(n,{buffer:n.buffer,type:n.type,bytesPerElement:n.elementSize,version:n.version}))}const r=t.get(n);if(void 0===r)t.set(n,function(t,n){const i=t.array,r=t.usage,a=i.byteLength,o=e.createBuffer();let s;if(e.bindBuffer(n,o),e.bufferData(n,i,r),t.onUploadCallback(),i instanceof Float32Array)s=e.FLOAT;else if("undefined"!=typeof Float16Array&&i instanceof Float16Array)s=e.HALF_FLOAT;else if(i instanceof Uint16Array)s=t.isFloat16BufferAttribute?e.HALF_FLOAT:e.UNSIGNED_SHORT;else if(i instanceof Int16Array)s=e.SHORT;else if(i instanceof Uint32Array)s=e.UNSIGNED_INT;else if(i instanceof Int32Array)s=e.INT;else if(i instanceof Int8Array)s=e.BYTE;else if(i instanceof Uint8Array)s=e.UNSIGNED_BYTE;else{if(!(i instanceof Uint8ClampedArray))throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+i);s=e.UNSIGNED_BYTE}return{buffer:o,type:s,bytesPerElement:i.BYTES_PER_ELEMENT,version:t.version,size:a}}(n,i));else if(r.version<n.version){if(r.size!==n.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");!function(t,n,i){const r=n.array,a=n.updateRanges;if(e.bindBuffer(i,t),0===a.length)e.bufferSubData(i,0,r);else{a.sort((e,t)=>e.start-t.start);let t=0;for(let e=1;e<a.length;e++){const n=a[t],i=a[e];i.start<=n.start+n.count+1?n.count=Math.max(n.count,i.start+i.count-n.start):(++t,a[t]=i)}a.length=t+1;for(let t=0,n=a.length;t<n;t++){const n=a[t];e.bufferSubData(i,n.start*r.BYTES_PER_ELEMENT,r,n.start,n.count)}n.clearUpdateRanges()}n.onUploadCallback()}(r.buffer,n,i),r.version=n.version}}}}const Gn={alphahash_fragment:"#ifdef USE_ALPHAHASH\n\tif ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;\n#endif",alphahash_pars_fragment:"#ifdef USE_ALPHAHASH\n\tconst float ALPHA_HASH_SCALE = 0.05;\n\tfloat hash2D( vec2 value ) {\n\t\treturn fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );\n\t}\n\tfloat hash3D( vec3 value ) {\n\t\treturn hash2D( vec2( hash2D( value.xy ), value.z ) );\n\t}\n\tfloat getAlphaHashThreshold( vec3 position ) {\n\t\tfloat maxDeriv = max(\n\t\t\tlength( dFdx( position.xyz ) ),\n\t\t\tlength( dFdy( position.xyz ) )\n\t\t);\n\t\tfloat pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );\n\t\tvec2 pixScales = vec2(\n\t\t\texp2( floor( log2( pixScale ) ) ),\n\t\t\texp2( ceil( log2( pixScale ) ) )\n\t\t);\n\t\tvec2 alpha = vec2(\n\t\t\thash3D( floor( pixScales.x * position.xyz ) ),\n\t\t\thash3D( floor( pixScales.y * position.xyz ) )\n\t\t);\n\t\tfloat lerpFactor = fract( log2( pixScale ) );\n\t\tfloat x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;\n\t\tfloat a = min( lerpFactor, 1.0 - lerpFactor );\n\t\tvec3 cases = vec3(\n\t\t\tx * x / ( 2.0 * a * ( 1.0 - a ) ),\n\t\t\t( x - 0.5 * a ) / ( 1.0 - a ),\n\t\t\t1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )\n\t\t);\n\t\tfloat threshold = ( x < ( 1.0 - a ) )\n\t\t\t? ( ( x < a ) ? cases.x : cases.y )\n\t\t\t: cases.z;\n\t\treturn clamp( threshold , 1.0e-6, 1.0 );\n\t}\n#endif",alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef USE_ALPHATEST\n\t#ifdef ALPHA_TO_COVERAGE\n\tdiffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );\n\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\tif ( diffuseColor.a < alphaTest ) discard;\n\t#endif\n#endif",alphatest_pars_fragment:"#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_CLEARCOAT ) \n\t\tclearcoatSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_SHEEN ) \n\t\tsheenSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometryNormal, geometryViewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",batching_pars_vertex:"#ifdef USE_BATCHING\n\t#if ! defined( GL_ANGLE_multi_draw )\n\t#define gl_DrawID _gl_DrawID\n\tuniform int _gl_DrawID;\n\t#endif\n\tuniform highp sampler2D batchingTexture;\n\tuniform highp usampler2D batchingIdTexture;\n\tmat4 getBatchingMatrix( const in float i ) {\n\t\tint size = textureSize( batchingTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n\tfloat getIndirectIndex( const in int i ) {\n\t\tint size = textureSize( batchingIdTexture, 0 ).x;\n\t\tint x = i % size;\n\t\tint y = i / size;\n\t\treturn float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );\n\t}\n#endif\n#ifdef USE_BATCHING_COLOR\n\tuniform sampler2D batchingColorTexture;\n\tvec4 getBatchingColor( const in float i ) {\n\t\tint size = textureSize( batchingColorTexture, 0 ).x;\n\t\tint j = int( i );\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\treturn texelFetch( batchingColorTexture, ivec2( x, y ), 0 );\n\t}\n#endif",batching_vertex:"#ifdef USE_BATCHING\n\tmat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );\n#endif",begin_vertex:"vec3 transformed = vec3( position );\n#ifdef USE_ALPHAHASH\n\tvPosition = vec3( position );\n#endif",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"float G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n} // validated",iridescence_fragment:"#ifdef USE_IRIDESCENCE\n\tconst mat3 XYZ_TO_REC709 = mat3(\n\t\t 3.2404542, -0.9692660, 0.0556434,\n\t\t-1.5371385, 1.8760108, -0.2040259,\n\t\t-0.4985314, 0.0415560, 1.0572252\n\t);\n\tvec3 Fresnel0ToIor( vec3 fresnel0 ) {\n\t\tvec3 sqrtF0 = sqrt( fresnel0 );\n\t\treturn ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n\t}\n\tvec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\n\t}\n\tfloat IorToFresnel0( float transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\n\t}\n\tvec3 evalSensitivity( float OPD, vec3 shift ) {\n\t\tfloat phase = 2.0 * PI * OPD * 1.0e-9;\n\t\tvec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\n\t\tvec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\n\t\tvec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\n\t\tvec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );\n\t\txyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );\n\t\txyz /= 1.0685e-7;\n\t\tvec3 rgb = XYZ_TO_REC709 * xyz;\n\t\treturn rgb;\n\t}\n\tvec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\n\t\tvec3 I;\n\t\tfloat iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\n\t\tfloat sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\n\t\tfloat cosTheta2Sq = 1.0 - sinTheta2Sq;\n\t\tif ( cosTheta2Sq < 0.0 ) {\n\t\t\treturn vec3( 1.0 );\n\t\t}\n\t\tfloat cosTheta2 = sqrt( cosTheta2Sq );\n\t\tfloat R0 = IorToFresnel0( iridescenceIOR, outsideIOR );\n\t\tfloat R12 = F_Schlick( R0, 1.0, cosTheta1 );\n\t\tfloat T121 = 1.0 - R12;\n\t\tfloat phi12 = 0.0;\n\t\tif ( iridescenceIOR < outsideIOR ) phi12 = PI;\n\t\tfloat phi21 = PI - phi12;\n\t\tvec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );\t\tvec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\n\t\tvec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\n\t\tvec3 phi23 = vec3( 0.0 );\n\t\tif ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;\n\t\tif ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;\n\t\tif ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;\n\t\tfloat OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\n\t\tvec3 phi = vec3( phi21 ) + phi23;\n\t\tvec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\n\t\tvec3 r123 = sqrt( R123 );\n\t\tvec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\n\t\tvec3 C0 = R12 + Rs;\n\t\tI = C0;\n\t\tvec3 Cm = Rs - T121;\n\t\tfor ( int m = 1; m <= 2; ++ m ) {\n\t\t\tCm *= r123;\n\t\t\tvec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\n\t\t\tI += Cm * Sm;\n\t\t}\n\t\treturn max( I, vec3( 0.0 ) );\n\t}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vBumpMapUv );\n\t\tvec2 dSTdy = dFdy( vBumpMapUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );\n\t\tvec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#ifdef ALPHA_TO_COVERAGE\n\t\tfloat distanceToPlane, distanceGradient;\n\t\tfloat clipOpacity = 1.0;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\tclipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\tif ( clipOpacity == 0.0 ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tfloat unionClipOpacity = 1.0;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\t\tunionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tclipOpacity *= 1.0 - unionClipOpacity;\n\t\t#endif\n\t\tdiffuseColor.a *= clipOpacity;\n\t\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tbool clipped = true;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tif ( clipped ) discard;\n\t\t#endif\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvarying vec4 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvColor = vec4( 1.0 );\n#endif\n#ifdef USE_COLOR_ALPHA\n\tvColor *= color;\n#elif defined( USE_COLOR )\n\tvColor.rgb *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.rgb *= instanceColor.rgb;\n#endif\n#ifdef USE_BATCHING_COLOR\n\tvColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) );\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = objectTangent;\n#endif\n#ifdef USE_BATCHING\n\tmat3 bm = mat3( batchingMatrix );\n\ttransformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );\n\ttransformedNormal = bm * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = bm * transformedTangent;\n\t#endif\n#endif\n#ifdef USE_INSTANCING\n\tmat3 im = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );\n\ttransformedNormal = im * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = im * transformedTangent;\n\t#endif\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\ttransformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE\n\t\temissiveColor = sRGBTransferEOTF( emissiveColor );\n\t#endif\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",colorspace_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",colorspace_pars_fragment:"vec4 LinearTransferOETF( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBTransferEOTF( in vec4 value ) {\n\treturn 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 );\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n\treturn 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 );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t\t#endif\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform mat3 envMapRotation;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_fragment:"LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",lights_lambert_pars_fragment:"varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid 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 ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid 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 ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n\tuniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif ( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid 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 ) {\n\tvec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid 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 ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid 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 ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid 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 ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.metalness = metalnessFactor;\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor;\n\tmaterial.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = vec3( 0.04 );\n\tmaterial.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_DISPERSION\n\tmaterial.dispersion = dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tif( material.anisotropy == 0.0 ) {\n\t\tanisotropyV = vec2( 1.0, 0.0 );\n\t} else {\n\t\tanisotropyV /= material.anisotropy;\n\t\tmaterial.anisotropy = saturate( material.anisotropy );\n\t}\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif",lights_physical_pars_fragment:"uniform sampler2D dfgLUT;\nstruct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tvec3 diffuseContribution;\n\tvec3 specularColor;\n\tvec3 specularColorBlended;\n\tfloat roughness;\n\tfloat metalness;\n\tfloat specularF90;\n\tfloat dispersion;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t\tvec3 iridescenceFresnelDielectric;\n\t\tvec3 iridescenceFresnelMetallic;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat 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 ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn v;\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColorBlended;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transpose( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat rInv = 1.0 / ( roughness + 0.1 );\n\tfloat a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv;\n\tfloat b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv;\n\tfloat DG = exp( a * dotNV + b );\n\treturn saturate( DG );\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid 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 ) {\n#else\nvoid 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 ) {\n#endif\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\nvec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg;\n\tvec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg;\n\tvec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y;\n\tvec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y;\n\tfloat Ess_V = dfgV.x + dfgV.y;\n\tfloat Ess_L = dfgL.x + dfgL.y;\n\tfloat Ems_V = 1.0 - Ess_V;\n\tfloat Ems_L = 1.0 - Ess_L;\n\tvec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619;\n\tvec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON );\n\tfloat compensationFactor = Ems_V * Ems_L;\n\tvec3 multiScatter = Fms * compensationFactor;\n\treturn singleScatter + multiScatter;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid 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 ) {\n\t\tvec3 normal = geometryNormal;\n\t\tvec3 viewDir = geometryViewDir;\n\t\tvec3 position = geometryPosition;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t\t#ifdef USE_CLEARCOAT\n\t\t\tvec3 Ncc = geometryClearcoatNormal;\n\t\t\tvec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness );\n\t\t\tvec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat );\n\t\t\tvec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat );\n\t\t\tmat3 mInvClearcoat = mat3(\n\t\t\t\tvec3( t1Clearcoat.x, 0, t1Clearcoat.y ),\n\t\t\t\tvec3( 0, 1, 0 ),\n\t\t\t\tvec3( t1Clearcoat.z, 0, t1Clearcoat.w )\n\t\t\t);\n\t\t\tvec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y;\n\t\t\tclearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords );\n\t\t#endif\n\t}\n#endif\nvoid 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 ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n \n \t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n \n \t\tfloat sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n \t\tfloat sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness );\n \n \t\tfloat sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL );\n \n \t\tirradiance *= sheenEnergyComp;\n \n \t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution );\n}\nvoid 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 ) {\n\tvec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution );\n\t#ifdef USE_SHEEN\n\t\tfloat sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t\tfloat sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n\t\tdiffuse *= sheenEnergyComp;\n\t#endif\n\treflectedLight.indirectDiffuse += diffuse;\n}\nvoid 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) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI;\n \t#endif\n\tvec3 singleScatteringDielectric = vec3( 0.0 );\n\tvec3 multiScatteringDielectric = vec3( 0.0 );\n\tvec3 singleScatteringMetallic = vec3( 0.0 );\n\tvec3 multiScatteringMetallic = vec3( 0.0 );\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n\t#endif\n\tvec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness );\n\tvec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness );\n\tvec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric;\n\tvec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tvec3 indirectSpecular = radiance * singleScattering;\n\tindirectSpecular += multiScattering * cosineWeightedIrradiance;\n\tvec3 indirectDiffuse = diffuse * cosineWeightedIrradiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t\tfloat sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n\t\tindirectSpecular *= sheenEnergyComp;\n\t\tindirectDiffuse *= sheenEnergyComp;\n\t#endif\n\treflectedLight.indirectSpecular += indirectSpecular;\n\treflectedLight.indirectDiffuse += indirectDiffuse;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n\tgeometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometryViewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor );\n\t\tmaterial.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if defined( USE_LIGHT_PROBES )\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\t#if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG )\n\t\t\tiblIrradiance += getIBLIrradiance( geometryNormal );\n\t\t#endif\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\t#if defined( LAMBERT ) || defined( PHONG )\n\t\tirradiance += iblIrradiance;\n\t#endif\n\tRE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n\tgl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n\tvFragDepth = 1.0 + gl_Position.w;\n\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n#endif",map_fragment:"#ifdef USE_MAP\n#ifdef USE_MIPMAP_BIAS\n vec4 sampledDiffuseColor = texture2D( map, vMapUv, mipmapBias );\n#else\n\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n#endif\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n \n#ifdef USE_MIPMAP_BIAS\n uniform float mipmapBias;\n#endif\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t#if defined( USE_POINTS_UV )\n\t\tvec2 uv = vUv;\n\t#else\n\t\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_POINTS_UV )\n\tvarying vec2 vUv;\n#else\n\t#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t\tuniform mat3 uvTransform;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphinstance_vertex:"#ifdef USE_INSTANCING_MORPH\n\tfloat morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\tfloat morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tmorphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;\n\t}\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_INSTANCING_MORPH\n\t\tuniform float morphTargetBaseInfluence;\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t#endif\n\tuniform sampler2DArray morphTargetsTexture;\n\tuniform ivec2 morphTargetsTextureSize;\n\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t}\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal,\n\t\t#if defined( USE_NORMALMAP )\n\t\t\tvNormalMapUv\n\t\t#elif defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tvClearcoatNormalMapUv\n\t\t#else\n\t\t\tvUv\n\t\t#endif\n\t\t);\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 nonPerturbedNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n\tmat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\t\treturn mat3( T * scale, B * scale, N );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = nonPerturbedNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\tclearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif",opaque_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;\nconst float Inv255 = 1. / 255.;\nconst vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );\nconst vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );\nconst vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );\nconst vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );\nvec4 packDepthToRGBA( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec4( 0., 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec4( 1., 1., 1., 1. );\n\tfloat vuf;\n\tfloat af = modf( v * PackFactors.a, vuf );\n\tfloat bf = modf( vuf * ShiftRight8, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );\n}\nvec3 packDepthToRGB( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec3( 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec3( 1., 1., 1. );\n\tfloat vuf;\n\tfloat bf = modf( v * PackFactors.b, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec3( vuf * Inv255, gf * PackUpscale, bf );\n}\nvec2 packDepthToRG( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec2( 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec2( 1., 1. );\n\tfloat vuf;\n\tfloat gf = modf( v * 256., vuf );\n\treturn vec2( vuf * Inv255, gf );\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors4 );\n}\nfloat unpackRGBToDepth( const in vec3 v ) {\n\treturn dot( v, UnpackFactors3 );\n}\nfloat unpackRGToDepth( const in vec2 v ) {\n\treturn v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;\n}\nvec4 pack2HalfToRGBA( const in vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( const in vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\n\t\treturn depth * ( far - near ) - far;\n\t#else\n\t\treturn depth * ( near - far ) - near;\n\t#endif\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\t\n\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\treturn ( near * far ) / ( ( near - far ) * depth - near );\n\t#else\n\t\treturn ( near * far ) / ( ( far - near ) * depth - far );\n\t#endif\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_BATCHING\n\tmvPosition = batchingMatrix * mvPosition;\n#endif\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tuniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\t#else\n\t\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\t#endif\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tuniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\t#else\n\t\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\t#endif\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tuniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\t#elif defined( SHADOWMAP_TYPE_BASIC )\n\t\t\tuniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\t#endif\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\tfloat interleavedGradientNoise( vec2 position ) {\n\t\t\treturn fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) );\n\t\t}\n\t\tvec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) {\n\t\t\tconst float goldenAngle = 2.399963229728653;\n\t\t\tfloat r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) );\n\t\t\tfloat theta = float( sampleIndex ) * goldenAngle + phi;\n\t\t\treturn vec2( cos( theta ), sin( theta ) ) * r;\n\t\t}\n\t#endif\n\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\tfloat getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\t\tfloat shadow = 1.0;\n\t\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\t\tshadowCoord.z += shadowBias;\n\t\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\t\tif ( frustumTest ) {\n\t\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\t\tfloat radius = shadowRadius * texelSize.x;\n\t\t\t\tfloat phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;\n\t\t\t\tshadow = (\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) )\n\t\t\t\t) * 0.2;\n\t\t\t}\n\t\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t\t}\n\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\t\tfloat shadow = 1.0;\n\t\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\tshadowCoord.z -= shadowBias;\n\t\t\t#else\n\t\t\t\tshadowCoord.z += shadowBias;\n\t\t\t#endif\n\t\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\t\tif ( frustumTest ) {\n\t\t\t\tvec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg;\n\t\t\t\tfloat mean = distribution.x;\n\t\t\t\tfloat variance = distribution.y * distribution.y;\n\t\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\t\tfloat hard_shadow = step( mean, shadowCoord.z );\n\t\t\t\t#else\n\t\t\t\t\tfloat hard_shadow = step( shadowCoord.z, mean );\n\t\t\t\t#endif\n\t\t\t\t\n\t\t\t\tif ( hard_shadow == 1.0 ) {\n\t\t\t\t\tshadow = 1.0;\n\t\t\t\t} else {\n\t\t\t\t\tvariance = max( variance, 0.0000001 );\n\t\t\t\t\tfloat d = shadowCoord.z - mean;\n\t\t\t\t\tfloat p_max = variance / ( variance + d * d );\n\t\t\t\t\tp_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 );\n\t\t\t\t\tshadow = max( hard_shadow, p_max );\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t\t}\n\t#else\n\t\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\t\tfloat shadow = 1.0;\n\t\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\tshadowCoord.z -= shadowBias;\n\t\t\t#else\n\t\t\t\tshadowCoord.z += shadowBias;\n\t\t\t#endif\n\t\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\t\tif ( frustumTest ) {\n\t\t\t\tfloat depth = texture2D( shadowMap, shadowCoord.xy ).r;\n\t\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\t\tshadow = step( depth, shadowCoord.z );\n\t\t\t\t#else\n\t\t\t\t\tshadow = step( shadowCoord.z, depth );\n\t\t\t\t#endif\n\t\t\t}\n\t\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t\t}\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#if defined( SHADOWMAP_TYPE_PCF )\n\tfloat getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\tvec3 absVec = abs( lightToPosition );\n\t\tfloat viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n\t\tif ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\tfloat dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n\t\t\t\tdp -= shadowBias;\n\t\t\t#else\n\t\t\t\tfloat dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n\t\t\t\tdp += shadowBias;\n\t\t\t#endif\n\t\t\tfloat texelSize = shadowRadius / shadowMapSize.x;\n\t\t\tvec3 absDir = abs( bd3D );\n\t\t\tvec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 );\n\t\t\ttangent = normalize( cross( bd3D, tangent ) );\n\t\t\tvec3 bitangent = cross( bd3D, tangent );\n\t\t\tfloat phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;\n\t\t\tvec2 sample0 = vogelDiskSample( 0, 5, phi );\n\t\t\tvec2 sample1 = vogelDiskSample( 1, 5, phi );\n\t\t\tvec2 sample2 = vogelDiskSample( 2, 5, phi );\n\t\t\tvec2 sample3 = vogelDiskSample( 3, 5, phi );\n\t\t\tvec2 sample4 = vogelDiskSample( 4, 5, phi );\n\t\t\tshadow = (\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.y ) * texelSize, dp ) )\n\t\t\t) * 0.2;\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\t#elif defined( SHADOWMAP_TYPE_BASIC )\n\tfloat getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tvec3 absVec = abs( lightToPosition );\n\t\tfloat viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n\t\tif ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n\t\t\tfloat dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n\t\t\tdp += shadowBias;\n\t\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t\tfloat depth = textureCube( shadowMap, bd3D ).r;\n\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\tdepth = 1.0 - depth;\n\t\t\t#endif\n\t\t\tshadow = step( dp, depth );\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\t#endif\n\t#endif\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\tvec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tint size = textureSize( boneTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 CineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.6605, - 0.1246, - 0.0182 ),\n\tvec3( - 0.5876, 1.1329, - 0.1006 ),\n\tvec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n\tvec3( 0.6274, 0.0691, 0.0164 ),\n\tvec3( 0.3293, 0.9195, 0.0880 ),\n\tvec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n\tvec3 x2 = x * x;\n\tvec3 x4 = x2 * x2;\n\treturn + 15.5 * x4 * x2\n\t\t- 40.14 * x4 * x\n\t\t+ 31.96 * x4\n\t\t- 6.868 * x2 * x\n\t\t+ 0.4298 * x2\n\t\t+ 0.1191 * x\n\t\t- 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n\tconst mat3 AgXInsetMatrix = mat3(\n\t\tvec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n\t\tvec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n\t\tvec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n\t);\n\tconst mat3 AgXOutsetMatrix = mat3(\n\t\tvec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n\t\tvec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n\t\tvec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n\t);\n\tconst float AgxMinEv = - 12.47393;\tconst float AgxMaxEv = 4.026069;\n\tcolor *= toneMappingExposure;\n\tcolor = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n\tcolor = AgXInsetMatrix * color;\n\tcolor = max( color, 1e-10 );\tcolor = log2( color );\n\tcolor = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n\tcolor = clamp( color, 0.0, 1.0 );\n\tcolor = agxDefaultContrastApprox( color );\n\tcolor = AgXOutsetMatrix * color;\n\tcolor = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n\tcolor = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n\tcolor = clamp( color, 0.0, 1.0 );\n\treturn color;\n}\nvec3 NeutralToneMapping( vec3 color ) {\n\tconst float StartCompression = 0.8 - 0.04;\n\tconst float Desaturation = 0.15;\n\tcolor *= toneMappingExposure;\n\tfloat x = min( color.r, min( color.g, color.b ) );\n\tfloat offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\n\tcolor -= offset;\n\tfloat peak = max( color.r, max( color.g, color.b ) );\n\tif ( peak < StartCompression ) return color;\n\tfloat d = 1. - StartCompression;\n\tfloat newPeak = 1. - d * d / ( peak + d - StartCompression );\n\tcolor *= newPeak / peak;\n\tfloat g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );\n\treturn mix( color, vec3( newPeak ), g );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn vec3( 1.0 );\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec4 transmittedLight;\n\t\tvec3 transmittance;\n\t\t#ifdef USE_DISPERSION\n\t\t\tfloat halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;\n\t\t\tvec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );\n\t\t\tfor ( int i = 0; i < 3; i ++ ) {\n\t\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );\n\t\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\t\trefractionCoords += 1.0;\n\t\t\t\trefractionCoords /= 2.0;\n\t\t\t\tvec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );\n\t\t\t\ttransmittedLight[ i ] = transmissionSample[ i ];\n\t\t\t\ttransmittedLight.a += transmissionSample.a;\n\t\t\t\ttransmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];\n\t\t\t}\n\t\t\ttransmittedLight.a /= 3.0;\n\t\t#else\n\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\trefractionCoords += 1.0;\n\t\t\trefractionCoords /= 2.0;\n\t\t\ttransmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\t\ttransmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\t#endif\n\t\tvec3 attenuatedColor = transmittance * transmittedLight.rgb;\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\tfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n\t}\n#endif",uv_pars_fragment:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_pars_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tuniform mat3 anisotropyMapTransform;\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n\tvMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n\tvAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n\tvLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n\tvAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n\tvBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n\tvNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tvDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n\tvMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n\tvSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tvTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n\tvThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_BATCHING\n\t\tworldPosition = batchingMatrix * worldPosition;\n\t#endif\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\ttexColor = 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 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nuniform mat3 backgroundRotation;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",cube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",depth_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <logdepthbuf_fragment>\n\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\tfloat fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];\n\t#else\n\t\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;\n\t#endif\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#elif DEPTH_PACKING == 3202\n\t\tgl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );\n\t#elif DEPTH_PACKING == 3203\n\t\tgl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );\n\t#endif\n}",distance_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}",distance_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",meshbasic_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_lambert_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_lambert_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_DISPERSION\n\tuniform float dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <iridescence_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <iridescence_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n \n\t\toutgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect;\n \n \t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n\t#endif\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n#ifdef USE_POINTS_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",shadow_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <logdepthbuf_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\t#include <logdepthbuf_fragment>\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix[ 3 ];\n\tvec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}"},Hn={common:{diffuse:{value:new n(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new e},alphaMap:{value:null},alphaMapTransform:{value:new e},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new e}},envmap:{envMap:{value:null},envMapRotation:{value:new e},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 e}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new e}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new e},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new e},normalScale:{value:new t(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new e},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new e}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new e}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new e}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new n(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},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 n(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new e},alphaTest:{value:0},uvTransform:{value:new e}},sprite:{diffuse:{value:new n(16777215)},opacity:{value:1},center:{value:new t(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new e},alphaMap:{value:null},alphaMapTransform:{value:new e},alphaTest:{value:0}}},Vn={basic:{uniforms:i([Hn.common,Hn.specularmap,Hn.envmap,Hn.aomap,Hn.lightmap,Hn.fog]),vertexShader:Gn.meshbasic_vert,fragmentShader:Gn.meshbasic_frag},lambert:{uniforms:i([Hn.common,Hn.specularmap,Hn.envmap,Hn.aomap,Hn.lightmap,Hn.emissivemap,Hn.bumpmap,Hn.normalmap,Hn.displacementmap,Hn.fog,Hn.lights,{emissive:{value:new n(0)},envMapIntensity:{value:1}}]),vertexShader:Gn.meshlambert_vert,fragmentShader:Gn.meshlambert_frag},phong:{uniforms:i([Hn.common,Hn.specularmap,Hn.envmap,Hn.aomap,Hn.lightmap,Hn.emissivemap,Hn.bumpmap,Hn.normalmap,Hn.displacementmap,Hn.fog,Hn.lights,{emissive:{value:new n(0)},specular:{value:new n(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Gn.meshphong_vert,fragmentShader:Gn.meshphong_frag},standard:{uniforms:i([Hn.common,Hn.envmap,Hn.aomap,Hn.lightmap,Hn.emissivemap,Hn.bumpmap,Hn.normalmap,Hn.displacementmap,Hn.roughnessmap,Hn.metalnessmap,Hn.fog,Hn.lights,{emissive:{value:new n(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Gn.meshphysical_vert,fragmentShader:Gn.meshphysical_frag},toon:{uniforms:i([Hn.common,Hn.aomap,Hn.lightmap,Hn.emissivemap,Hn.bumpmap,Hn.normalmap,Hn.displacementmap,Hn.gradientmap,Hn.fog,Hn.lights,{emissive:{value:new n(0)}}]),vertexShader:Gn.meshtoon_vert,fragmentShader:Gn.meshtoon_frag},matcap:{uniforms:i([Hn.common,Hn.bumpmap,Hn.normalmap,Hn.displacementmap,Hn.fog,{matcap:{value:null}}]),vertexShader:Gn.meshmatcap_vert,fragmentShader:Gn.meshmatcap_frag},points:{uniforms:i([Hn.points,Hn.fog]),vertexShader:Gn.points_vert,fragmentShader:Gn.points_frag},dashed:{uniforms:i([Hn.common,Hn.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Gn.linedashed_vert,fragmentShader:Gn.linedashed_frag},depth:{uniforms:i([Hn.common,Hn.displacementmap]),vertexShader:Gn.depth_vert,fragmentShader:Gn.depth_frag},normal:{uniforms:i([Hn.common,Hn.bumpmap,Hn.normalmap,Hn.displacementmap,{opacity:{value:1}}]),vertexShader:Gn.meshnormal_vert,fragmentShader:Gn.meshnormal_frag},sprite:{uniforms:i([Hn.sprite,Hn.fog]),vertexShader:Gn.sprite_vert,fragmentShader:Gn.sprite_frag},background:{uniforms:{uvTransform:{value:new e},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Gn.background_vert,fragmentShader:Gn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new e}},vertexShader:Gn.backgroundCube_vert,fragmentShader:Gn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Gn.cube_vert,fragmentShader:Gn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Gn.equirect_vert,fragmentShader:Gn.equirect_frag},distance:{uniforms:i([Hn.common,Hn.displacementmap,{referencePosition:{value:new r},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Gn.distance_vert,fragmentShader:Gn.distance_frag},shadow:{uniforms:i([Hn.lights,Hn.fog,{color:{value:new n(0)},opacity:{value:1}}]),vertexShader:Gn.shadow_vert,fragmentShader:Gn.shadow_frag}};Vn.physical={uniforms:i([Vn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new e},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new e},clearcoatNormalScale:{value:new t(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new e},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new e},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new e},sheen:{value:0},sheenColor:{value:new n(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new e},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new e},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new e},transmissionSamplerSize:{value:new t},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new e},attenuationDistance:{value:0},attenuationColor:{value:new n(0)},specularColor:{value:new n(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new e},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new e},anisotropyVector:{value:new t},anisotropyMap:{value:null},anisotropyMapTransform:{value:new e}}]),vertexShader:Gn.meshphysical_vert,fragmentShader:Gn.meshphysical_frag};const Wn={r:0,b:0,g:0},zn=new u,kn=new f;function Xn(e,t,i,r,u,f){const v=new n(0);let E,S,M=!0===u?0:1,T=null,x=0,A=null;function R(e){let n=!0===e.isScene?e.background:null;if(n&&n.isTexture){const i=e.backgroundBlurriness>0;n=t.get(n,i)}return n}function b(t,n){t.getRGB(Wn,g(e)),i.buffers.color.setClear(Wn.r,Wn.g,Wn.b,n,f)}return{getClearColor:function(){return v},setClearColor:function(e,t=1){v.set(e),M=t,b(v,M)},getClearAlpha:function(){return M},setClearAlpha:function(e){M=e,b(v,M)},render:function(t){let n=!1;const r=R(t);null===r?b(v,M):r&&r.isColor&&(b(r,1),n=!0);const a=e.xr.getEnvironmentBlendMode();"additive"===a?i.buffers.color.setClear(0,0,0,1,f):"alpha-blend"===a&&i.buffers.color.setClear(0,0,0,0,f),(e.autoClear||n)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil))},addToRenderList:function(t,n){const i=R(n);i&&(i.isCubeTexture||i.mapping===a)?(void 0===S&&(S=new o(new s(1,1,1),new l({name:"BackgroundCubeMaterial",uniforms:d(Vn.backgroundCube.uniforms),vertexShader:Vn.backgroundCube.vertexShader,fragmentShader:Vn.backgroundCube.fragmentShader,side:c,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),S.geometry.deleteAttribute("normal"),S.geometry.deleteAttribute("uv"),S.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(S.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(S)),zn.copy(n.backgroundRotation),zn.x*=-1,zn.y*=-1,zn.z*=-1,i.isCubeTexture&&!1===i.isRenderTargetTexture&&(zn.y*=-1,zn.z*=-1),S.material.uniforms.envMap.value=i,S.material.uniforms.flipEnvMap.value=i.isCubeTexture&&!1===i.isRenderTargetTexture?-1:1,S.material.uniforms.backgroundBlurriness.value=n.backgroundBlurriness,S.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,S.material.uniforms.backgroundRotation.value.setFromMatrix4(kn.makeRotationFromEuler(zn)),S.material.toneMapped=p.getTransfer(i.colorSpace)!==m,T===i&&x===i.version&&A===e.toneMapping||(S.material.needsUpdate=!0,T=i,x=i.version,A=e.toneMapping),S.layers.enableAll(),t.unshift(S,S.geometry,S.material,0,0,null)):i&&i.isTexture&&(void 0===E&&(E=new o(new h(2,2),new l({name:"BackgroundMaterial",uniforms:d(Vn.background.uniforms),vertexShader:Vn.background.vertexShader,fragmentShader:Vn.background.fragmentShader,side:_,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),E.geometry.deleteAttribute("normal"),Object.defineProperty(E.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(E)),E.material.uniforms.t2D.value=i,E.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,E.material.toneMapped=p.getTransfer(i.colorSpace)!==m,!0===i.matrixAutoUpdate&&i.updateMatrix(),E.material.uniforms.uvTransform.value.copy(i.matrix),T===i&&x===i.version&&A===e.toneMapping||(E.material.needsUpdate=!0,T=i,x=i.version,A=e.toneMapping),E.layers.enableAll(),t.unshift(E,E.geometry,E.material,0,0,null))},dispose:function(){void 0!==S&&(S.geometry.dispose(),S.material.dispose(),S=void 0),void 0!==E&&(E.geometry.dispose(),E.material.dispose(),E=void 0)}}}function Yn(e,t){const n=e.getParameter(e.MAX_VERTEX_ATTRIBS),i={},r=c(null);let a=r,o=!1;function s(t){return e.bindVertexArray(t)}function l(t){return e.deleteVertexArray(t)}function c(e){const t=[],i=[],r=[];for(let e=0;e<n;e++)t[e]=0,i[e]=0,r[e]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:t,enabledAttributes:i,attributeDivisors:r,object:e,attributes:{},index:null}}function d(){const e=a.newAttributes;for(let t=0,n=e.length;t<n;t++)e[t]=0}function u(e){f(e,0)}function f(t,n){const i=a.newAttributes,r=a.enabledAttributes,o=a.attributeDivisors;i[t]=1,0===r[t]&&(e.enableVertexAttribArray(t),r[t]=1),o[t]!==n&&(e.vertexAttribDivisor(t,n),o[t]=n)}function p(){const t=a.newAttributes,n=a.enabledAttributes;for(let i=0,r=n.length;i<r;i++)n[i]!==t[i]&&(e.disableVertexAttribArray(i),n[i]=0)}function m(t,n,i,r,a,o,s){!0===s?e.vertexAttribIPointer(t,n,i,a,o):e.vertexAttribPointer(t,n,i,r,a,o)}function h(){_(),o=!0,a!==r&&(a=r,s(a.object))}function _(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:function(n,r,l,h,_){let g=!1;const E=function(t,n,r,a){const o=!0===a.wireframe;let s=i[n.id];void 0===s&&(s={},i[n.id]=s);const l=!0===t.isInstancedMesh?t.id:0;let d=s[l];void 0===d&&(d={},s[l]=d);let u=d[r.id];void 0===u&&(u={},d[r.id]=u);let f=u[o];void 0===f&&(f=c(e.createVertexArray()),u[o]=f);return f}(n,h,l,r);a!==E&&(a=E,s(a.object)),g=function(e,t,n,i){const r=a.attributes,o=t.attributes;let s=0;const l=n.getAttributes();for(const t in l){if(l[t].location>=0){const n=r[t];let i=o[t];if(void 0===i&&("instanceMatrix"===t&&e.instanceMatrix&&(i=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(i=e.instanceColor)),void 0===n)return!0;if(n.attribute!==i)return!0;if(i&&n.data!==i.data)return!0;s++}}return a.attributesNum!==s||a.index!==i}(n,h,l,_),g&&function(e,t,n,i){const r={},o=t.attributes;let s=0;const l=n.getAttributes();for(const t in l){if(l[t].location>=0){let n=o[t];void 0===n&&("instanceMatrix"===t&&e.instanceMatrix&&(n=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(n=e.instanceColor));const i={};i.attribute=n,n&&n.data&&(i.data=n.data),r[t]=i,s++}}a.attributes=r,a.attributesNum=s,a.index=i}(n,h,l,_),null!==_&&t.update(_,e.ELEMENT_ARRAY_BUFFER),(g||o)&&(o=!1,function(n,i,r,a){d();const o=a.attributes,s=r.getAttributes(),l=i.defaultAttributeValues;for(const i in s){const r=s[i];if(r.location>=0){let s=o[i];if(void 0===s&&("instanceMatrix"===i&&n.instanceMatrix&&(s=n.instanceMatrix),"instanceColor"===i&&n.instanceColor&&(s=n.instanceColor)),void 0!==s){const i=s.normalized,o=s.itemSize,l=t.get(s);if(void 0===l)continue;const c=l.buffer,d=l.type,p=l.bytesPerElement,h=d===e.INT||d===e.UNSIGNED_INT||s.gpuType===v;if(s.isInterleavedBufferAttribute){const t=s.data,l=t.stride,_=s.offset;if(t.isInstancedInterleavedBuffer){for(let e=0;e<r.locationSize;e++)f(r.location+e,t.meshPerAttribute);!0!==n.isInstancedMesh&&void 0===a._maxInstanceCount&&(a._maxInstanceCount=t.meshPerAttribute*t.count)}else for(let e=0;e<r.locationSize;e++)u(r.location+e);e.bindBuffer(e.ARRAY_BUFFER,c);for(let e=0;e<r.locationSize;e++)m(r.location+e,o/r.locationSize,d,i,l*p,(_+o/r.locationSize*e)*p,h)}else{if(s.isInstancedBufferAttribute){for(let e=0;e<r.locationSize;e++)f(r.location+e,s.meshPerAttribute);!0!==n.isInstancedMesh&&void 0===a._maxInstanceCount&&(a._maxInstanceCount=s.meshPerAttribute*s.count)}else for(let e=0;e<r.locationSize;e++)u(r.location+e);e.bindBuffer(e.ARRAY_BUFFER,c);for(let e=0;e<r.locationSize;e++)m(r.location+e,o/r.locationSize,d,i,o*p,o/r.locationSize*e*p,h)}}else if(void 0!==l){const t=l[i];if(void 0!==t)switch(t.length){case 2:e.vertexAttrib2fv(r.location,t);break;case 3:e.vertexAttrib3fv(r.location,t);break;case 4:e.vertexAttrib4fv(r.location,t);break;default:e.vertexAttrib1fv(r.location,t)}}}}p()}(n,r,l,h),null!==_&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(_).buffer))},reset:h,resetDefaultState:_,dispose:function(){h();for(const e in i){const t=i[e];for(const e in t){const n=t[e];for(const e in n){const t=n[e];for(const e in t)l(t[e].object),delete t[e];delete n[e]}}delete i[e]}},releaseStatesOfGeometry:function(e){if(void 0===i[e.id])return;const t=i[e.id];for(const e in t){const n=t[e];for(const e in n){const t=n[e];for(const e in t)l(t[e].object),delete t[e];delete n[e]}}delete i[e.id]},releaseStatesOfObject:function(e){for(const t in i){const n=i[t],r=!0===e.isInstancedMesh?e.id:0,a=n[r];if(void 0!==a){for(const e in a){const t=a[e];for(const e in t)l(t[e].object),delete t[e];delete a[e]}delete n[r],0===Object.keys(n).length&&delete i[t]}}},releaseStatesOfProgram:function(e){for(const t in i){const n=i[t];for(const t in n){const i=n[t];if(void 0===i[e.id])continue;const r=i[e.id];for(const e in r)l(r[e].object),delete r[e];delete i[e.id]}}},initAttributes:d,enableAttribute:u,disableUnusedAttributes:p}}function Kn(e,t,n){let i;function r(t,r,a){0!==a&&(e.drawArraysInstanced(i,t,r,a),n.update(r,i,a))}this.setMode=function(e){i=e},this.render=function(t,r){e.drawArrays(i,t,r),n.update(r,i,1)},this.renderInstances=r,this.renderMultiDraw=function(e,r,a){if(0===a)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,e,0,r,0,a);let o=0;for(let e=0;e<a;e++)o+=r[e];n.update(o,i,1)},this.renderMultiDrawInstances=function(e,a,o,s){if(0===o)return;const l=t.get("WEBGL_multi_draw");if(null===l)for(let t=0;t<e.length;t++)r(e[t],a[t],s[t]);else{l.multiDrawArraysInstancedWEBGL(i,e,0,a,0,s,0,o);let t=0;for(let e=0;e<o;e++)t+=a[e]*s[e];n.update(t,i,1)}}}function qn(e,t,n,i){let r;function a(t){if("highp"===t){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let o=void 0!==n.precision?n.precision:"highp";const s=a(o);s!==o&&(E("WebGLRenderer:",o,"not supported, using",s,"instead."),o=s);return{isWebGL2:!0,getMaxAnisotropy:function(){if(void 0!==r)return r;if(!0===t.has("EXT_texture_filter_anisotropic")){const n=t.get("EXT_texture_filter_anisotropic");r=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r},getMaxPrecision:a,textureFormatReadable:function(t){return t===x||i.convert(t)===e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT)},textureTypeReadable:function(n){const r=n===S&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(n!==M&&i.convert(n)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE)&&n!==T&&!r)},precision:o,logarithmicDepthBuffer:!0===n.logarithmicDepthBuffer,reversedDepthBuffer:!0===n.reversedDepthBuffer&&t.has("EXT_clip_control"),maxTextures:e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),maxVertexTextures:e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),maxTextureSize:e.getParameter(e.MAX_TEXTURE_SIZE),maxCubemapSize:e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),maxAttributes:e.getParameter(e.MAX_VERTEX_ATTRIBS),maxVertexUniforms:e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),maxVaryings:e.getParameter(e.MAX_VARYING_VECTORS),maxFragmentUniforms:e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),maxSamples:e.getParameter(e.MAX_SAMPLES),samples:e.getParameter(e.SAMPLES)}}function jn(t){const n=this;let i=null,r=0,a=!1,o=!1;const s=new A,l=new e,c={value:null,needsUpdate:!1};function d(e,t,i,r){const a=null!==e?e.length:0;let o=null;if(0!==a){if(o=c.value,!0!==r||null===o){const n=i+4*a,r=t.matrixWorldInverse;l.getNormalMatrix(r),(null===o||o.length<n)&&(o=new Float32Array(n));for(let t=0,n=i;t!==a;++t,n+=4)s.copy(e[t]).applyMatrix4(r,l),s.normal.toArray(o,n),o[n+3]=s.constant}c.value=o,c.needsUpdate=!0}return n.numPlanes=a,n.numIntersection=0,o}this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(e,t){const n=0!==e.length||t||0!==r||a;return a=t,r=e.length,n},this.beginShadows=function(){o=!0,d(null)},this.endShadows=function(){o=!1},this.setGlobalState=function(e,t){i=d(e,t,0)},this.setState=function(e,s,l){const u=e.clippingPlanes,f=e.clipIntersection,p=e.clipShadows,m=t.get(e);if(!a||null===u||0===u.length||o&&!p)o?d(null):function(){c.value!==i&&(c.value=i,c.needsUpdate=r>0);n.numPlanes=r,n.numIntersection=0}();else{const e=o?0:r,t=4*e;let n=m.clippingState||null;c.value=n,n=d(u,s,t,l);for(let e=0;e!==t;++e)n[e]=i[e];m.clippingState=n,this.numIntersection=f?this.numPlanes:0,this.numPlanes+=e}}}const Zn=[.125,.215,.35,.446,.526,.582],$n=20,Qn=new P,Jn=new n;let ei=null,ti=0,ni=0,ii=!1;const ri=new r;class ai{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,n=.1,i=100,r={}){const{size:a=256,position:o=ri}=r;ei=this._renderer.getRenderTarget(),ti=this._renderer.getActiveCubeFace(),ni=this._renderer.getActiveMipmapLevel(),ii=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,n,i,s,o),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=di(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=ci(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose(),null!==this._backgroundBox&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._ggxMaterial&&this._ggxMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(ei,ti,ni),this._renderer.xr.enabled=ii,e.scissorTest=!1,li(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===R||e.mapping===b?this._setSize(0===e.image.length?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),ei=this._renderer.getRenderTarget(),ti=this._renderer.getActiveCubeFace(),ni=this._renderer.getActiveMipmapLevel(),ii=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:O,minFilter:O,generateMipmaps:!1,type:S,format:x,colorSpace:F,depthBuffer:!1},i=si(e,t,n),{_lodMax:a}=this;if(({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=oi(a)),null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=si(e,t,n);const{_lodMax:i}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=oi(i)),this._blurMaterial=function(e,t,n){const i=new Float32Array($n),a=new r(0,1,0),o=new l({name:"SphericalGaussianBlur",defines:{n:$n,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:a}},vertexShader:ui(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include <cube_uv_reflection_fragment>\n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t",blending:I,depthTest:!1,depthWrite:!1});return o}(i,e,t),this._ggxMaterial=function(e,t,n){const i=new l({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:256,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:ui(),fragmentShader:'\n\n\t\t\tprecision highp float;\n\t\t\tprecision highp int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform float roughness;\n\t\t\tuniform float mipInt;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include <cube_uv_reflection_fragment>\n\n\t\t\t#define PI 3.14159265359\n\n\t\t\t// Van der Corput radical inverse\n\t\t\tfloat radicalInverse_VdC(uint bits) {\n\t\t\t\tbits = (bits << 16u) | (bits >> 16u);\n\t\t\t\tbits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);\n\t\t\t\tbits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);\n\t\t\t\tbits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);\n\t\t\t\tbits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);\n\t\t\t\treturn float(bits) * 2.3283064365386963e-10; // / 0x100000000\n\t\t\t}\n\n\t\t\t// Hammersley sequence\n\t\t\tvec2 hammersley(uint i, uint N) {\n\t\t\t\treturn vec2(float(i) / float(N), radicalInverse_VdC(i));\n\t\t\t}\n\n\t\t\t// GGX VNDF importance sampling (Eric Heitz 2018)\n\t\t\t// "Sampling the GGX Distribution of Visible Normals"\n\t\t\t// https://jcgt.org/published/0007/04/01/\n\t\t\tvec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {\n\t\t\t\tfloat alpha = roughness * roughness;\n\n\t\t\t\t// Section 4.1: Orthonormal basis\n\t\t\t\tvec3 T1 = vec3(1.0, 0.0, 0.0);\n\t\t\t\tvec3 T2 = cross(V, T1);\n\n\t\t\t\t// Section 4.2: Parameterization of projected area\n\t\t\t\tfloat r = sqrt(Xi.x);\n\t\t\t\tfloat phi = 2.0 * PI * Xi.y;\n\t\t\t\tfloat t1 = r * cos(phi);\n\t\t\t\tfloat t2 = r * sin(phi);\n\t\t\t\tfloat s = 0.5 * (1.0 + V.z);\n\t\t\t\tt2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;\n\n\t\t\t\t// Section 4.3: Reprojection onto hemisphere\n\t\t\t\tvec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * V;\n\n\t\t\t\t// Section 3.4: Transform back to ellipsoid configuration\n\t\t\t\treturn normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));\n\t\t\t}\n\n\t\t\tvoid main() {\n\t\t\t\tvec3 N = normalize(vOutputDirection);\n\t\t\t\tvec3 V = N; // Assume view direction equals normal for pre-filtering\n\n\t\t\t\tvec3 prefilteredColor = vec3(0.0);\n\t\t\t\tfloat totalWeight = 0.0;\n\n\t\t\t\t// For very low roughness, just sample the environment directly\n\t\t\t\tif (roughness < 0.001) {\n\t\t\t\t\tgl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Tangent space basis for VNDF sampling\n\t\t\t\tvec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);\n\t\t\t\tvec3 tangent = normalize(cross(up, N));\n\t\t\t\tvec3 bitangent = cross(N, tangent);\n\n\t\t\t\tfor(uint i = 0u; i < uint(GGX_SAMPLES); i++) {\n\t\t\t\t\tvec2 Xi = hammersley(i, uint(GGX_SAMPLES));\n\n\t\t\t\t\t// For PMREM, V = N, so in tangent space V is always (0, 0, 1)\n\t\t\t\t\tvec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);\n\n\t\t\t\t\t// Transform H back to world space\n\t\t\t\t\tvec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);\n\t\t\t\t\tvec3 L = normalize(2.0 * dot(V, H) * H - V);\n\n\t\t\t\t\tfloat NdotL = max(dot(N, L), 0.0);\n\n\t\t\t\t\tif(NdotL > 0.0) {\n\t\t\t\t\t\t// Sample environment at fixed mip level\n\t\t\t\t\t\t// VNDF importance sampling handles the distribution filtering\n\t\t\t\t\t\tvec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);\n\n\t\t\t\t\t\t// Weight by NdotL for the split-sum approximation\n\t\t\t\t\t\t// VNDF PDF naturally accounts for the visible microfacet distribution\n\t\t\t\t\t\tprefilteredColor += sampleColor * NdotL;\n\t\t\t\t\t\ttotalWeight += NdotL;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (totalWeight > 0.0) {\n\t\t\t\t\tprefilteredColor = prefilteredColor / totalWeight;\n\t\t\t\t}\n\n\t\t\t\tgl_FragColor = vec4(prefilteredColor, 1.0);\n\t\t\t}\n\t\t',blending:I,depthTest:!1,depthWrite:!1});return i}(i,e,t)}return i}_compileMaterial(e){const t=new o(new C,e);this._renderer.compile(t,Qn)}_sceneToCubeUV(e,t,n,i,r){const a=new L(90,1,t,n),l=[1,-1,1,1,1,1],d=[1,1,1,-1,-1,-1],u=this._renderer,f=u.autoClear,p=u.toneMapping;u.getClearColor(Jn),u.toneMapping=U,u.autoClear=!1;u.state.buffers.depth.getReversed()&&(u.setRenderTarget(i),u.clearDepth(),u.setRenderTarget(null)),null===this._backgroundBox&&(this._backgroundBox=new o(new s,new D({name:"PMREM.Background",side:c,depthWrite:!1,depthTest:!1})));const m=this._backgroundBox,h=m.material;let _=!1;const g=e.background;g?g.isColor&&(h.color.copy(g),e.background=null,_=!0):(h.color.copy(Jn),_=!0);for(let t=0;t<6;t++){const n=t%3;0===n?(a.up.set(0,l[t],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x+d[t],r.y,r.z)):1===n?(a.up.set(0,0,l[t]),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y+d[t],r.z)):(a.up.set(0,l[t],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y,r.z+d[t]));const o=this._cubeSize;li(i,n*o,t>2?o:0,o,o),u.setRenderTarget(i),_&&u.render(m,a),u.render(e,a)}u.toneMapping=p,u.autoClear=f,e.background=g}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===R||e.mapping===b;i?(null===this._cubemapMaterial&&(this._cubemapMaterial=di()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=ci());const r=i?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;r.uniforms.envMap.value=e;const o=this._cubeSize;li(t,0,0,3*o,2*o),n.setRenderTarget(t),n.render(a,Qn)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const i=this._lodMeshes.length;for(let t=1;t<i;t++)this._applyGGXFilter(e,t-1,t);t.autoClear=n}_applyGGXFilter(e,t,n){const i=this._renderer,r=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[n];o.material=a;const s=a.uniforms,l=n/(this._lodMeshes.length-1),c=t/(this._lodMeshes.length-1),d=Math.sqrt(l*l-c*c)*(0+1.25*l),{_lodMax:u}=this,f=this._sizeLods[n],p=3*f*(n>u-4?n-u+4:0),m=4*(this._cubeSize-f);s.envMap.value=e.texture,s.roughness.value=d,s.mipInt.value=u-t,li(r,p,m,3*f,2*f),i.setRenderTarget(r),i.render(o,Qn),s.envMap.value=r.texture,s.roughness.value=0,s.mipInt.value=u-n,li(e,p,m,3*f,2*f),i.setRenderTarget(e),i.render(o,Qn)}_blur(e,t,n,i,r){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,i,"latitudinal",r),this._halfBlur(a,e,n,n,i,"longitudinal",r)}_halfBlur(e,t,n,i,r,a,o){const s=this._renderer,l=this._blurMaterial;"latitudinal"!==a&&"longitudinal"!==a&&w("blur direction must be either latitudinal or longitudinal!");const c=this._lodMeshes[i];c.material=l;const d=l.uniforms,u=this._sizeLods[n]-1,f=isFinite(r)?Math.PI/(2*u):2*Math.PI/39,p=r/f,m=isFinite(r)?1+Math.floor(3*p):$n;m>$n&&E(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to 20`);const h=[];let _=0;for(let e=0;e<$n;++e){const t=e/p,n=Math.exp(-t*t/2);h.push(n),0===e?_+=n:e<m&&(_+=2*n)}for(let e=0;e<h.length;e++)h[e]=h[e]/_;d.envMap.value=e.texture,d.samples.value=m,d.weights.value=h,d.latitudinal.value="latitudinal"===a,o&&(d.poleAxis.value=o);const{_lodMax:g}=this;d.dTheta.value=f,d.mipInt.value=g-n;const v=this._sizeLods[i];li(t,3*v*(i>g-4?i-g+4:0),4*(this._cubeSize-v),3*v,2*v),s.setRenderTarget(t),s.render(c,Qn)}}function oi(e){const t=[],n=[],i=[];let r=e;const a=e-4+1+Zn.length;for(let s=0;s<a;s++){const a=Math.pow(2,r);t.push(a);let l=1/a;s>e-4?l=Zn[s-e+4-1]:0===s&&(l=0),n.push(l);const c=1/(a-2),d=-c,u=1+c,f=[d,d,u,d,u,u,d,d,u,u,d,u],p=6,m=6,h=3,_=2,g=1,v=new Float32Array(h*m*p),E=new Float32Array(_*m*p),S=new Float32Array(g*m*p);for(let e=0;e<p;e++){const t=e%3*2/3-1,n=e>2?0:-1,i=[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];v.set(i,h*m*e),E.set(f,_*m*e);const r=[e,e,e,e,e,e];S.set(r,g*m*e)}const M=new C;M.setAttribute("position",new y(v,h)),M.setAttribute("uv",new y(E,_)),M.setAttribute("faceIndex",new y(S,g)),i.push(new o(M,null)),r>4&&r--}return{lodMeshes:i,sizeLods:t,sigmas:n}}function si(e,t,n){const i=new N(e,t,n);return i.texture.mapping=a,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function li(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function ci(){return new l({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:ui(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\n\t\t\t#include <common>\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n\t\t\t}\n\t\t",blending:I,depthTest:!1,depthWrite:!1})}function di(){return new l({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:ui(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t",blending:I,depthTest:!1,depthWrite:!1})}function ui(){return"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t"}class fi extends N{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];this.texture=new B(i),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include <common>\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t"},i=new s(5,5,5),r=new l({name:"CubemapFromEquirect",uniforms:d(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:c,blending:I});r.uniforms.tEquirect.value=t;const a=new o(i,r),u=t.minFilter;t.minFilter===G&&(t.minFilter=O);return new H(1,10,this).update(e,a),t.minFilter=u,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,n=!0,i=!0){const r=e.getRenderTarget();for(let r=0;r<6;r++)e.setRenderTarget(this,r),e.clear(t,n,i);e.setRenderTarget(r)}}function pi(e){let t=new WeakMap,n=new WeakMap,i=null;function r(e,t){return t===V?e.mapping=R:t===W&&(e.mapping=b),e}function a(e){const n=e.target;n.removeEventListener("dispose",a);const i=t.get(n);void 0!==i&&(t.delete(n),i.dispose())}function o(e){const t=e.target;t.removeEventListener("dispose",o);const i=n.get(t);void 0!==i&&(n.delete(t),i.dispose())}return{get:function(s,l=!1){return null==s?null:l?function(t){if(t&&t.isTexture){const r=t.mapping,a=r===V||r===W,s=r===R||r===b;if(a||s){let r=n.get(t);const l=void 0!==r?r.texture.pmremVersion:0;if(t.isRenderTargetTexture&&t.pmremVersion!==l)return null===i&&(i=new ai(e)),r=a?i.fromEquirectangular(t,r):i.fromCubemap(t,r),r.texture.pmremVersion=t.pmremVersion,n.set(t,r),r.texture;if(void 0!==r)return r.texture;{const l=t.image;return a&&l&&l.height>0||s&&l&&function(e){let t=0;const n=6;for(let i=0;i<n;i++)void 0!==e[i]&&t++;return t===n}(l)?(null===i&&(i=new ai(e)),r=a?i.fromEquirectangular(t):i.fromCubemap(t),r.texture.pmremVersion=t.pmremVersion,n.set(t,r),t.addEventListener("dispose",o),r.texture):null}}}return t}(s):function(n){if(n&&n.isTexture){const i=n.mapping;if(i===V||i===W){if(t.has(n)){return r(t.get(n).texture,n.mapping)}{const i=n.image;if(i&&i.height>0){const o=new fi(i.height);return o.fromEquirectangularTexture(e,n),t.set(n,o),n.addEventListener("dispose",a),r(o.texture,n.mapping)}return null}}}return n}(s)},dispose:function(){t=new WeakMap,n=new WeakMap,null!==i&&(i.dispose(),i=null)}}}function mi(e){const t={};function n(n){if(void 0!==t[n])return t[n];const i=e.getExtension(n);return t[n]=i,i}return{has:function(e){return null!==n(e)},init:function(){n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance"),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture"),n("WEBGL_render_shared_exponent")},get:function(e){const t=n(e);return null===t&&z("WebGLRenderer: "+e+" extension not supported."),t}}}function hi(e,t,n,i){const r={},a=new WeakMap;function o(e){const s=e.target;null!==s.index&&t.remove(s.index);for(const e in s.attributes)t.remove(s.attributes[e]);s.removeEventListener("dispose",o),delete r[s.id];const l=a.get(s);l&&(t.remove(l),a.delete(s)),i.releaseStatesOfGeometry(s),!0===s.isInstancedBufferGeometry&&delete s._maxInstanceCount,n.memory.geometries--}function s(e){const n=[],i=e.index,r=e.attributes.position;let o=0;if(void 0===r)return;if(null!==i){const e=i.array;o=i.version;for(let t=0,i=e.length;t<i;t+=3){const i=e[t+0],r=e[t+1],a=e[t+2];n.push(i,r,r,a,a,i)}}else{const e=r.array;o=r.version;for(let t=0,i=e.length/3-1;t<i;t+=3){const e=t+0,i=t+1,r=t+2;n.push(e,i,i,r,r,e)}}const s=new(r.count>=65535?k:X)(n,1);s.version=o;const l=a.get(e);l&&t.remove(l),a.set(e,s)}return{get:function(e,t){return!0===r[t.id]||(t.addEventListener("dispose",o),r[t.id]=!0,n.memory.geometries++),t},update:function(n){const i=n.attributes;for(const n in i)t.update(i[n],e.ARRAY_BUFFER)},getWireframeAttribute:function(e){const t=a.get(e);if(t){const n=e.index;null!==n&&t.version<n.version&&s(e)}else s(e);return a.get(e)}}}function _i(e,t,n){let i,r,a;function o(t,o,s){0!==s&&(e.drawElementsInstanced(i,o,r,t*a,s),n.update(o,i,s))}this.setMode=function(e){i=e},this.setIndex=function(e){r=e.type,a=e.bytesPerElement},this.render=function(t,o){e.drawElements(i,o,r,t*a),n.update(o,i,1)},this.renderInstances=o,this.renderMultiDraw=function(e,a,o){if(0===o)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,a,0,r,e,0,o);let s=0;for(let e=0;e<o;e++)s+=a[e];n.update(s,i,1)},this.renderMultiDrawInstances=function(e,s,l,c){if(0===l)return;const d=t.get("WEBGL_multi_draw");if(null===d)for(let t=0;t<e.length;t++)o(e[t]/a,s[t],c[t]);else{d.multiDrawElementsInstancedWEBGL(i,s,0,r,e,0,c,0,l);let t=0;for(let e=0;e<l;e++)t+=s[e]*c[e];n.update(t,i,1)}}}function gi(e){const t={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:t,programs:null,autoReset:!0,reset:function(){t.calls=0,t.triangles=0,t.points=0,t.lines=0},update:function(n,i,r){switch(t.calls++,i){case e.TRIANGLES:t.triangles+=r*(n/3);break;case e.LINES:t.lines+=r*(n/2);break;case e.LINE_STRIP:t.lines+=r*(n-1);break;case e.LINE_LOOP:t.lines+=r*n;break;case e.POINTS:t.points+=r*n;break;default:w("WebGLInfo: Unknown draw mode:",i)}}}}function vi(e,n,i){const r=new WeakMap,a=new Y;return{update:function(o,s,l){const c=o.morphTargetInfluences,d=s.morphAttributes.position||s.morphAttributes.normal||s.morphAttributes.color,u=void 0!==d?d.length:0;let f=r.get(s);if(void 0===f||f.count!==u){void 0!==f&&f.texture.dispose();const p=void 0!==s.morphAttributes.position,m=void 0!==s.morphAttributes.normal,h=void 0!==s.morphAttributes.color,_=s.morphAttributes.position||[],g=s.morphAttributes.normal||[],v=s.morphAttributes.color||[];let E=0;!0===p&&(E=1),!0===m&&(E=2),!0===h&&(E=3);let S=s.attributes.position.count*E,M=1;S>n.maxTextureSize&&(M=Math.ceil(S/n.maxTextureSize),S=n.maxTextureSize);const x=new Float32Array(S*M*4*u),A=new K(x,S,M,u);A.type=T,A.needsUpdate=!0;const R=4*E;for(let C=0;C<u;C++){const P=_[C],L=g[C],U=v[C],D=S*M*4*C;for(let w=0;w<P.count;w++){const I=w*R;!0===p&&(a.fromBufferAttribute(P,w),x[D+I+0]=a.x,x[D+I+1]=a.y,x[D+I+2]=a.z,x[D+I+3]=0),!0===m&&(a.fromBufferAttribute(L,w),x[D+I+4]=a.x,x[D+I+5]=a.y,x[D+I+6]=a.z,x[D+I+7]=0),!0===h&&(a.fromBufferAttribute(U,w),x[D+I+8]=a.x,x[D+I+9]=a.y,x[D+I+10]=a.z,x[D+I+11]=4===U.itemSize?a.w:1)}}function b(){A.dispose(),r.delete(s),s.removeEventListener("dispose",b)}f={count:u,texture:A,size:new t(S,M)},r.set(s,f),s.addEventListener("dispose",b)}if(!0===o.isInstancedMesh&&null!==o.morphTexture)l.getUniforms().setValue(e,"morphTexture",o.morphTexture,i);else{let N=0;for(let F=0;F<c.length;F++)N+=c[F];const y=s.morphTargetsRelative?1:1-N;l.getUniforms().setValue(e,"morphTargetBaseInfluence",y),l.getUniforms().setValue(e,"morphTargetInfluences",c)}l.getUniforms().setValue(e,"morphTargetsTexture",f.texture,i),l.getUniforms().setValue(e,"morphTargetsTextureSize",f.size)}}}function Ei(e,t,n,i,r){let a=new WeakMap;function o(e){const t=e.target;t.removeEventListener("dispose",o),i.releaseStatesOfObject(t),n.remove(t.instanceMatrix),null!==t.instanceColor&&n.remove(t.instanceColor)}return{update:function(i){const s=r.render.frame,l=i.geometry,c=t.get(i,l);if(a.get(c)!==s&&(t.update(c),a.set(c,s)),i.isInstancedMesh&&(!1===i.hasEventListener("dispose",o)&&i.addEventListener("dispose",o),a.get(i)!==s&&(n.update(i.instanceMatrix,e.ARRAY_BUFFER),null!==i.instanceColor&&n.update(i.instanceColor,e.ARRAY_BUFFER),a.set(i,s))),i.isSkinnedMesh){const e=i.skeleton;a.get(e)!==s&&(e.update(),a.set(e,s))}return c},dispose:function(){a=new WeakMap}}}const Si={[ne]:"LINEAR_TONE_MAPPING",[te]:"REINHARD_TONE_MAPPING",[ee]:"CINEON_TONE_MAPPING",[J]:"ACES_FILMIC_TONE_MAPPING",[Q]:"AGX_TONE_MAPPING",[$]:"NEUTRAL_TONE_MAPPING",[Z]:"CUSTOM_TONE_MAPPING"};function Mi(e,t,n,i,r){const a=new N(t,n,{type:e,depthBuffer:i,stencilBuffer:r}),s=new N(t,n,{type:S,depthBuffer:!1,stencilBuffer:!1}),l=new C;l.setAttribute("position",new q([-1,3,0,-1,-1,0,3,-1,0],3)),l.setAttribute("uv",new q([0,2,0,0,2,0],2));const c=new j({uniforms:{tDiffuse:{value:null}},vertexShader:"\n\t\t\tprecision highp float;\n\n\t\t\tuniform mat4 modelViewMatrix;\n\t\t\tuniform mat4 projectionMatrix;\n\n\t\t\tattribute vec3 position;\n\t\t\tattribute vec2 uv;\n\n\t\t\tvarying vec2 vUv;\n\n\t\t\tvoid main() {\n\t\t\t\tvUv = uv;\n\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t}",fragmentShader:"\n\t\t\tprecision highp float;\n\n\t\t\tuniform sampler2D tDiffuse;\n\n\t\t\tvarying vec2 vUv;\n\n\t\t\t#include <tonemapping_pars_fragment>\n\t\t\t#include <colorspace_pars_fragment>\n\n\t\t\tvoid main() {\n\t\t\t\tgl_FragColor = texture2D( tDiffuse, vUv );\n\n\t\t\t\t#ifdef LINEAR_TONE_MAPPING\n\t\t\t\t\tgl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( REINHARD_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( CINEON_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( ACES_FILMIC_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( AGX_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( NEUTRAL_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( CUSTOM_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );\n\t\t\t\t#endif\n\n\t\t\t\t#ifdef SRGB_TRANSFER\n\t\t\t\t\tgl_FragColor = sRGBTransferOETF( gl_FragColor );\n\t\t\t\t#endif\n\t\t\t}",depthTest:!1,depthWrite:!1}),d=new o(l,c),u=new P(-1,1,1,-1,0,1);let f,h=null,_=null,g=!1,v=null,E=[],M=!1;this.setSize=function(e,t){a.setSize(e,t),s.setSize(e,t);for(let n=0;n<E.length;n++){const i=E[n];i.setSize&&i.setSize(e,t)}},this.setEffects=function(e){E=e,M=E.length>0&&!0===E[0].isRenderPass;const t=a.width,n=a.height;for(let e=0;e<E.length;e++){const i=E[e];i.setSize&&i.setSize(t,n)}},this.begin=function(e,t){if(g)return!1;if(e.toneMapping===U&&0===E.length)return!1;if(v=t,null!==t){const e=t.width,n=t.height;a.width===e&&a.height===n||this.setSize(e,n)}return!1===M&&e.setRenderTarget(a),f=e.toneMapping,e.toneMapping=U,!0},this.hasRenderPass=function(){return M},this.end=function(e,t){e.toneMapping=f,g=!0;let n=a,i=s;for(let r=0;r<E.length;r++){const a=E[r];if(!1!==a.enabled&&(a.render(e,i,n,t),!1!==a.needsSwap)){const e=n;n=i,i=e}}if(h!==e.outputColorSpace||_!==e.toneMapping){h=e.outputColorSpace,_=e.toneMapping,c.defines={},p.getTransfer(h)===m&&(c.defines.SRGB_TRANSFER="");const t=Si[_];t&&(c.defines[t]=""),c.needsUpdate=!0}c.uniforms.tDiffuse.value=n.texture,e.setRenderTarget(v),e.render(d,u),v=null,g=!1},this.isCompositing=function(){return g},this.dispose=function(){a.dispose(),s.dispose(),l.dispose(),c.dispose()}}const Ti=new se,xi=new oe(1,1),Ai=new K,Ri=new ie,bi=new B,Ci=[],Pi=[],Li=new Float32Array(16),Ui=new Float32Array(9),Di=new Float32Array(4);function wi(e,t,n){const i=e[0];if(i<=0||i>0)return e;const r=t*n;let a=Ci[r];if(void 0===a&&(a=new Float32Array(r),Ci[r]=a),0!==t){i.toArray(a,0);for(let i=1,r=0;i!==t;++i)r+=n,e[i].toArray(a,r)}return a}function Ii(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n<i;n++)if(e[n]!==t[n])return!1;return!0}function Ni(e,t){for(let n=0,i=t.length;n<i;n++)e[n]=t[n]}function yi(e,t){let n=Pi[t];void 0===n&&(n=new Int32Array(t),Pi[t]=n);for(let i=0;i!==t;++i)n[i]=e.allocateTextureUnit();return n}function Fi(e,t){const n=this.cache;n[0]!==t&&(e.uniform1f(this.addr,t),n[0]=t)}function Oi(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y||(e.uniform2f(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(Ii(n,t))return;e.uniform2fv(this.addr,t),Ni(n,t)}}function Bi(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z||(e.uniform3f(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else if(void 0!==t.r)n[0]===t.r&&n[1]===t.g&&n[2]===t.b||(e.uniform3f(this.addr,t.r,t.g,t.b),n[0]=t.r,n[1]=t.g,n[2]=t.b);else{if(Ii(n,t))return;e.uniform3fv(this.addr,t),Ni(n,t)}}function Gi(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z&&n[3]===t.w||(e.uniform4f(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(Ii(n,t))return;e.uniform4fv(this.addr,t),Ni(n,t)}}function Hi(e,t){const n=this.cache,i=t.elements;if(void 0===i){if(Ii(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),Ni(n,t)}else{if(Ii(n,i))return;Di.set(i),e.uniformMatrix2fv(this.addr,!1,Di),Ni(n,i)}}function Vi(e,t){const n=this.cache,i=t.elements;if(void 0===i){if(Ii(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),Ni(n,t)}else{if(Ii(n,i))return;Ui.set(i),e.uniformMatrix3fv(this.addr,!1,Ui),Ni(n,i)}}function Wi(e,t){const n=this.cache,i=t.elements;if(void 0===i){if(Ii(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),Ni(n,t)}else{if(Ii(n,i))return;Li.set(i),e.uniformMatrix4fv(this.addr,!1,Li),Ni(n,i)}}function zi(e,t){const n=this.cache;n[0]!==t&&(e.uniform1i(this.addr,t),n[0]=t)}function ki(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y||(e.uniform2i(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(Ii(n,t))return;e.uniform2iv(this.addr,t),Ni(n,t)}}function Xi(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z||(e.uniform3i(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else{if(Ii(n,t))return;e.uniform3iv(this.addr,t),Ni(n,t)}}function Yi(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z&&n[3]===t.w||(e.uniform4i(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(Ii(n,t))return;e.uniform4iv(this.addr,t),Ni(n,t)}}function Ki(e,t){const n=this.cache;n[0]!==t&&(e.uniform1ui(this.addr,t),n[0]=t)}function qi(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y||(e.uniform2ui(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(Ii(n,t))return;e.uniform2uiv(this.addr,t),Ni(n,t)}}function ji(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z||(e.uniform3ui(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else{if(Ii(n,t))return;e.uniform3uiv(this.addr,t),Ni(n,t)}}function Zi(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z&&n[3]===t.w||(e.uniform4ui(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(Ii(n,t))return;e.uniform4uiv(this.addr,t),Ni(n,t)}}function $i(e,t,n){const i=this.cache,r=n.allocateTextureUnit();let a;i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),this.type===e.SAMPLER_2D_SHADOW?(xi.compareFunction=n.isReversedDepthBuffer()?re:ae,a=xi):a=Ti,n.setTexture2D(t||a,r)}function Qi(e,t,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),n.setTexture3D(t||Ri,r)}function Ji(e,t,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),n.setTextureCube(t||bi,r)}function er(e,t,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),n.setTexture2DArray(t||Ai,r)}function tr(e,t){e.uniform1fv(this.addr,t)}function nr(e,t){const n=wi(t,this.size,2);e.uniform2fv(this.addr,n)}function ir(e,t){const n=wi(t,this.size,3);e.uniform3fv(this.addr,n)}function rr(e,t){const n=wi(t,this.size,4);e.uniform4fv(this.addr,n)}function ar(e,t){const n=wi(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function or(e,t){const n=wi(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function sr(e,t){const n=wi(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function lr(e,t){e.uniform1iv(this.addr,t)}function cr(e,t){e.uniform2iv(this.addr,t)}function dr(e,t){e.uniform3iv(this.addr,t)}function ur(e,t){e.uniform4iv(this.addr,t)}function fr(e,t){e.uniform1uiv(this.addr,t)}function pr(e,t){e.uniform2uiv(this.addr,t)}function mr(e,t){e.uniform3uiv(this.addr,t)}function hr(e,t){e.uniform4uiv(this.addr,t)}function _r(e,t,n){const i=this.cache,r=t.length,a=yi(n,r);let o;Ii(i,a)||(e.uniform1iv(this.addr,a),Ni(i,a)),o=this.type===e.SAMPLER_2D_SHADOW?xi:Ti;for(let e=0;e!==r;++e)n.setTexture2D(t[e]||o,a[e])}function gr(e,t,n){const i=this.cache,r=t.length,a=yi(n,r);Ii(i,a)||(e.uniform1iv(this.addr,a),Ni(i,a));for(let e=0;e!==r;++e)n.setTexture3D(t[e]||Ri,a[e])}function vr(e,t,n){const i=this.cache,r=t.length,a=yi(n,r);Ii(i,a)||(e.uniform1iv(this.addr,a),Ni(i,a));for(let e=0;e!==r;++e)n.setTextureCube(t[e]||bi,a[e])}function Er(e,t,n){const i=this.cache,r=t.length,a=yi(n,r);Ii(i,a)||(e.uniform1iv(this.addr,a),Ni(i,a));for(let e=0;e!==r;++e)n.setTexture2DArray(t[e]||Ai,a[e])}class Sr{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=function(e){switch(e){case 5126:return Fi;case 35664:return Oi;case 35665:return Bi;case 35666:return Gi;case 35674:return Hi;case 35675:return Vi;case 35676:return Wi;case 5124:case 35670:return zi;case 35667:case 35671:return ki;case 35668:case 35672:return Xi;case 35669:case 35673:return Yi;case 5125:return Ki;case 36294:return qi;case 36295:return ji;case 36296:return Zi;case 35678:case 36198:case 36298:case 36306:case 35682:return $i;case 35679:case 36299:case 36307:return Qi;case 35680:case 36300:case 36308:case 36293:return Ji;case 36289:case 36303:case 36311:case 36292:return er}}(t.type)}}class Mr{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=function(e){switch(e){case 5126:return tr;case 35664:return nr;case 35665:return ir;case 35666:return rr;case 35674:return ar;case 35675:return or;case 35676:return sr;case 5124:case 35670:return lr;case 35667:case 35671:return cr;case 35668:case 35672:return dr;case 35669:case 35673:return ur;case 5125:return fr;case 36294:return pr;case 36295:return mr;case 36296:return hr;case 35678:case 36198:case 36298:case 36306:case 35682:return _r;case 35679:case 36299:case 36307:return gr;case 35680:case 36300:case 36308:case 36293:return vr;case 36289:case 36303:case 36311:case 36292:return Er}}(t.type)}}class Tr{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const i=this.seq;for(let r=0,a=i.length;r!==a;++r){const a=i[r];a.setValue(e,t[a.id],n)}}}const xr=/(\w+)(\])?(\[|\.)?/g;function Ar(e,t){e.seq.push(t),e.map[t.id]=t}function Rr(e,t,n){const i=e.name,r=i.length;for(xr.lastIndex=0;;){const a=xr.exec(i),o=xr.lastIndex;let s=a[1];const l="]"===a[2],c=a[3];if(l&&(s|=0),void 0===c||"["===c&&o+2===r){Ar(n,void 0===c?new Sr(s,e,t):new Mr(s,e,t));break}{let e=n.map[s];void 0===e&&(e=new Tr(s),Ar(n,e)),n=e}}}class br{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let i=0;i<n;++i){const n=e.getActiveUniform(t,i);Rr(n,e.getUniformLocation(t,n.name),this)}const i=[],r=[];for(const t of this.seq)t.type===e.SAMPLER_2D_SHADOW||t.type===e.SAMPLER_CUBE_SHADOW||t.type===e.SAMPLER_2D_ARRAY_SHADOW?i.push(t):r.push(t);i.length>0&&(this.seq=i.concat(r))}setValue(e,t,n,i){const r=this.map[t];void 0!==r&&r.setValue(e,n,i)}setOptional(e,t,n){const i=t[n];void 0!==i&&this.setValue(e,n,i)}static upload(e,t,n,i){for(let r=0,a=t.length;r!==a;++r){const a=t[r],o=n[a.id];!1!==o.needsUpdate&&a.setValue(e,o.value,i)}}static seqWithValue(e,t){const n=[];for(let i=0,r=e.length;i!==r;++i){const r=e[i];r.id in t&&n.push(r)}return n}}function Cr(e,t,n){const i=e.createShader(t);return e.shaderSource(i,n),e.compileShader(i),i}let Pr=0;const Lr=new e;function Ur(e,t,n){const i=e.getShaderParameter(t,e.COMPILE_STATUS),r=(e.getShaderInfoLog(t)||"").trim();if(i&&""===r)return"";const a=/ERROR: 0:(\d+)/.exec(r);if(a){const i=parseInt(a[1]);return n.toUpperCase()+"\n\n"+r+"\n\n"+function(e,t){const n=e.split("\n"),i=[],r=Math.max(t-6,0),a=Math.min(t+6,n.length);for(let e=r;e<a;e++){const r=e+1;i.push(`${r===t?">":" "} ${r}: ${n[e]}`)}return i.join("\n")}(e.getShaderSource(t),i)}return r}function Dr(e,t){const n=function(e){p._getMatrix(Lr,p.workingColorSpace,e);const t=`mat3( ${Lr.elements.map(e=>e.toFixed(4))} )`;switch(p.getTransfer(e)){case me:return[t,"LinearTransferOETF"];case m:return[t,"sRGBTransferOETF"];default:return E("WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}(t);return[`vec4 ${e}( vec4 value ) {`,`\treturn ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join("\n")}const wr={[ne]:"Linear",[te]:"Reinhard",[ee]:"Cineon",[J]:"ACESFilmic",[Q]:"AgX",[$]:"Neutral",[Z]:"Custom"};function Ir(e,t){const n=wr[t];return void 0===n?(E("WebGLProgram: Unsupported toneMapping:",t),"vec3 "+e+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const Nr=new r;function yr(){p.getLuminanceCoefficients(Nr);return["float luminance( const in vec3 rgb ) {",`\tconst vec3 weights = vec3( ${Nr.x.toFixed(4)}, ${Nr.y.toFixed(4)}, ${Nr.z.toFixed(4)} );`,"\treturn dot( weights, rgb );","}"].join("\n")}function Fr(e){return""!==e}function Or(e,t){const n=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function Br(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const Gr=/^[ \t]*#include +<([\w\d./]+)>/gm;function Hr(e){return e.replace(Gr,Wr)}const Vr=new Map;function Wr(e,t){let n=Gn[t];if(void 0===n){const e=Vr.get(t);if(void 0===e)throw new Error("Can not resolve #include <"+t+">");n=Gn[e],E('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,e)}return Hr(n)}const zr=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function kr(e){return e.replace(zr,Xr)}function Xr(e,t,n,i){let r="";for(let e=parseInt(t);e<parseInt(n);e++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+e+" ]").replace(/UNROLLED_LOOP_INDEX/g,e);return r}function Yr(e){let t=`precision ${e.precision} float;\n\tprecision ${e.precision} int;\n\tprecision ${e.precision} sampler2D;\n\tprecision ${e.precision} samplerCube;\n\tprecision ${e.precision} sampler3D;\n\tprecision ${e.precision} sampler2DArray;\n\tprecision ${e.precision} sampler2DShadow;\n\tprecision ${e.precision} samplerCubeShadow;\n\tprecision ${e.precision} sampler2DArrayShadow;\n\tprecision ${e.precision} isampler2D;\n\tprecision ${e.precision} isampler3D;\n\tprecision ${e.precision} isamplerCube;\n\tprecision ${e.precision} isampler2DArray;\n\tprecision ${e.precision} usampler2D;\n\tprecision ${e.precision} usampler3D;\n\tprecision ${e.precision} usamplerCube;\n\tprecision ${e.precision} usampler2DArray;\n\t`;return"highp"===e.precision?t+="\n#define HIGH_PRECISION":"mediump"===e.precision?t+="\n#define MEDIUM_PRECISION":"lowp"===e.precision&&(t+="\n#define LOW_PRECISION"),t}const Kr={[de]:"SHADOWMAP_TYPE_PCF",[ce]:"SHADOWMAP_TYPE_VSM"};const qr={[R]:"ENVMAP_TYPE_CUBE",[b]:"ENVMAP_TYPE_CUBE",[a]:"ENVMAP_TYPE_CUBE_UV"};const jr={[b]:"ENVMAP_MODE_REFRACTION"};const Zr={[pe]:"ENVMAP_BLENDING_MULTIPLY",[fe]:"ENVMAP_BLENDING_MIX",[ue]:"ENVMAP_BLENDING_ADD"};function $r(e,t,n,i){const r=e.getContext(),a=n.defines;let o=n.vertexShader,s=n.fragmentShader;const l=function(e){return Kr[e.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}(n),c=function(e){return!1===e.envMap?"ENVMAP_TYPE_CUBE":qr[e.envMapMode]||"ENVMAP_TYPE_CUBE"}(n),d=function(e){return!1===e.envMap?"ENVMAP_MODE_REFLECTION":jr[e.envMapMode]||"ENVMAP_MODE_REFLECTION"}(n),u=function(e){return!1===e.envMap?"ENVMAP_BLENDING_NONE":Zr[e.combine]||"ENVMAP_BLENDING_NONE"}(n),f=function(e){const t=e.envMapCubeUVHeight;if(null===t)return null;const n=Math.log2(t)-2,i=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:i,maxMip:n}}(n),p=function(e){return[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",e.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Fr).join("\n")}(n),m=function(e){const t=[];for(const n in e){const i=e[n];!1!==i&&t.push("#define "+n+" "+i)}return t.join("\n")}(a),h=r.createProgram();let _,g,v=n.glslVersion?"#version "+n.glslVersion+"\n":"";n.isRawShaderMaterial?(_=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m].filter(Fr).join("\n"),_.length>0&&(_+="\n"),g=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m].filter(Fr).join("\n"),g.length>0&&(g+="\n")):(_=[Yr(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","\tuniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(Fr).join("\n"),g=[Yr(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+c:"",n.envMap?"#define "+d:"",n.envMap?"#define "+u:"",f?"#define CUBEUV_TEXEL_WIDTH "+f.texelWidth:"",f?"#define CUBEUV_TEXEL_HEIGHT "+f.texelHeight:"",f?"#define CUBEUV_MAX_MIP "+f.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas||n.batchingColor?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==U?"#define TONE_MAPPING":"",n.toneMapping!==U?Gn.tonemapping_pars_fragment:"",n.toneMapping!==U?Ir("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Gn.colorspace_pars_fragment,Dr("linearToOutputTexel",n.outputColorSpace),yr(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(Fr).join("\n")),o=Hr(o),o=Or(o,n),o=Br(o,n),s=Hr(s),s=Or(s,n),s=Br(s,n),o=kr(o),s=kr(s),!0!==n.isRawShaderMaterial&&(v="#version 300 es\n",_=[p,"#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+_,g=["#define varying in",n.glslVersion===le?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===le?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+g);const S=v+_+o,M=v+g+s,T=Cr(r,r.VERTEX_SHADER,S),x=Cr(r,r.FRAGMENT_SHADER,M);function A(t){if(e.debug.checkShaderErrors){const n=r.getProgramInfoLog(h)||"",i=r.getShaderInfoLog(T)||"",a=r.getShaderInfoLog(x)||"",o=n.trim(),s=i.trim(),l=a.trim();let c=!0,d=!0;if(!1===r.getProgramParameter(h,r.LINK_STATUS))if(c=!1,"function"==typeof e.debug.onShaderError)e.debug.onShaderError(r,h,T,x);else{const e=Ur(r,T,"vertex"),n=Ur(r,x,"fragment");w("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(h,r.VALIDATE_STATUS)+"\n\nMaterial Name: "+t.name+"\nMaterial Type: "+t.type+"\n\nProgram Info Log: "+o+"\n"+e+"\n"+n)}else""!==o?E("WebGLProgram: Program Info Log:",o):""!==s&&""!==l||(d=!1);d&&(t.diagnostics={runnable:c,programLog:o,vertexShader:{log:s,prefix:_},fragmentShader:{log:l,prefix:g}})}r.deleteShader(T),r.deleteShader(x),R=new br(r,h),b=function(e,t){const n={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){const i=e.getActiveAttrib(t,r),a=i.name;let o=1;i.type===e.FLOAT_MAT2&&(o=2),i.type===e.FLOAT_MAT3&&(o=3),i.type===e.FLOAT_MAT4&&(o=4),n[a]={type:i.type,location:e.getAttribLocation(t,a),locationSize:o}}return n}(r,h)}let R,b;r.attachShader(h,T),r.attachShader(h,x),void 0!==n.index0AttributeName?r.bindAttribLocation(h,0,n.index0AttributeName):!0===n.morphTargets&&r.bindAttribLocation(h,0,"position"),r.linkProgram(h),this.getUniforms=function(){return void 0===R&&A(this),R},this.getAttributes=function(){return void 0===b&&A(this),b};let C=!1===n.rendererExtensionParallelShaderCompile;return this.isReady=function(){return!1===C&&(C=r.getProgramParameter(h,37297)),C},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(h),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=Pr++,this.cacheKey=t,this.usedTimes=1,this.program=h,this.vertexShader=T,this.fragmentShader=x,this}let Qr=0;class Jr{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,i=this._getShaderStage(t),r=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return!1===a.has(i)&&(a.add(i),i.usedTimes++),!1===a.has(r)&&(a.add(r),r.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const e of t)e.usedTimes--,0===e.usedTimes&&this.shaderCache.delete(e.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return void 0===n&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return void 0===n&&(n=new ea(e),t.set(e,n)),n}}class ea{constructor(e){this.id=Qr++,this.code=e,this.usedTimes=0}}function ta(e,t,n,i,r,o){const s=new Se,l=new Jr,d=new Set,u=[],f=new Map,h=i.logarithmicDepthBuffer;let _=i.precision;const g={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function v(e){return d.add(e),0===e?"uv":`uv${e}`}return{getParameters:function(r,s,u,f,S){const M=f.fog,T=S.geometry,x=r.isMeshStandardMaterial||r.isMeshLambertMaterial||r.isMeshPhongMaterial?f.environment:null,A=r.isMeshStandardMaterial||r.isMeshLambertMaterial&&!r.envMap||r.isMeshPhongMaterial&&!r.envMap,R=t.get(r.envMap||x,A),b=R&&R.mapping===a?R.image.height:null,C=g[r.type];null!==r.precision&&(_=i.getMaxPrecision(r.precision),_!==r.precision&&E("WebGLProgram.getParameters:",r.precision,"not supported, using",_,"instead."));const P=T.morphAttributes.position||T.morphAttributes.normal||T.morphAttributes.color,L=void 0!==P?P.length:0;let D,w,I,N,y=0;if(void 0!==T.morphAttributes.position&&(y=1),void 0!==T.morphAttributes.normal&&(y=2),void 0!==T.morphAttributes.color&&(y=3),C){const e=Vn[C];D=e.vertexShader,w=e.fragmentShader}else D=r.vertexShader,w=r.fragmentShader,l.update(r),I=l.getVertexShaderID(r),N=l.getFragmentShaderID(r);const O=e.getRenderTarget(),B=e.state.buffers.depth.getReversed(),G=!0===S.isInstancedMesh,H=!0===S.isBatchedMesh,V=!!r.map,W=!!r.matcap,z=!!R,k=!!r.aoMap,X=!!r.lightMap,Y=!!r.bumpMap,K=!!r.normalMap,q=!!r.displacementMap,j=!!r.emissiveMap,Z=!!r.metalnessMap,$=!!r.roughnessMap,Q=r.anisotropy>0,J=r.clearcoat>0,ee=r.dispersion>0,te=r.iridescence>0,ne=r.sheen>0,ie=r.transmission>0,re=Q&&!!r.anisotropyMap,ae=J&&!!r.clearcoatMap,oe=J&&!!r.clearcoatNormalMap,se=J&&!!r.clearcoatRoughnessMap,le=te&&!!r.iridescenceMap,ce=te&&!!r.iridescenceThicknessMap,de=ne&&!!r.sheenColorMap,ue=ne&&!!r.sheenRoughnessMap,fe=!!r.specularMap,pe=!!r.specularColorMap,me=!!r.specularIntensityMap,he=ie&&!!r.transmissionMap,Se=ie&&!!r.thicknessMap,Me=!!r.gradientMap,Te=!!r.alphaMap,xe=r.alphaTest>0,Ae=!!r.alphaHash,Re=!!r.extensions;let be=U;r.toneMapped&&(null!==O&&!0!==O.isXRRenderTarget||(be=e.toneMapping));const Ce={shaderID:C,shaderType:r.type,shaderName:r.name,vertexShader:D,fragmentShader:w,defines:r.defines,customVertexShaderID:I,customFragmentShaderID:N,isRawShaderMaterial:!0===r.isRawShaderMaterial,glslVersion:r.glslVersion,precision:_,batching:H,batchingColor:H&&null!==S._colorsTexture,instancing:G,instancingColor:G&&null!==S.instanceColor,instancingMorph:G&&null!==S.morphTexture,outputColorSpace:null===O?e.outputColorSpace:!0===O.isXRRenderTarget?O.texture.colorSpace:F,alphaToCoverage:!!r.alphaToCoverage,map:V,matcap:W,envMap:z,envMapMode:z&&R.mapping,envMapCubeUVHeight:b,aoMap:k,lightMap:X,bumpMap:Y,normalMap:K,displacementMap:q,emissiveMap:j,normalMapObjectSpace:K&&r.normalMapType===Ee,normalMapTangentSpace:K&&r.normalMapType===ve,metalnessMap:Z,roughnessMap:$,anisotropy:Q,anisotropyMap:re,clearcoat:J,clearcoatMap:ae,clearcoatNormalMap:oe,clearcoatRoughnessMap:se,dispersion:ee,iridescence:te,iridescenceMap:le,iridescenceThicknessMap:ce,sheen:ne,sheenColorMap:de,sheenRoughnessMap:ue,specularMap:fe,specularColorMap:pe,specularIntensityMap:me,transmission:ie,transmissionMap:he,thicknessMap:Se,gradientMap:Me,opaque:!1===r.transparent&&r.blending===ge&&!1===r.alphaToCoverage,alphaMap:Te,alphaTest:xe,alphaHash:Ae,combine:r.combine,mapUv:V&&v(r.map.channel),aoMapUv:k&&v(r.aoMap.channel),lightMapUv:X&&v(r.lightMap.channel),bumpMapUv:Y&&v(r.bumpMap.channel),normalMapUv:K&&v(r.normalMap.channel),displacementMapUv:q&&v(r.displacementMap.channel),emissiveMapUv:j&&v(r.emissiveMap.channel),metalnessMapUv:Z&&v(r.metalnessMap.channel),roughnessMapUv:$&&v(r.roughnessMap.channel),anisotropyMapUv:re&&v(r.anisotropyMap.channel),clearcoatMapUv:ae&&v(r.clearcoatMap.channel),clearcoatNormalMapUv:oe&&v(r.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:se&&v(r.clearcoatRoughnessMap.channel),iridescenceMapUv:le&&v(r.iridescenceMap.channel),iridescenceThicknessMapUv:ce&&v(r.iridescenceThicknessMap.channel),sheenColorMapUv:de&&v(r.sheenColorMap.channel),sheenRoughnessMapUv:ue&&v(r.sheenRoughnessMap.channel),specularMapUv:fe&&v(r.specularMap.channel),specularColorMapUv:pe&&v(r.specularColorMap.channel),specularIntensityMapUv:me&&v(r.specularIntensityMap.channel),transmissionMapUv:he&&v(r.transmissionMap.channel),thicknessMapUv:Se&&v(r.thicknessMap.channel),alphaMapUv:Te&&v(r.alphaMap.channel),vertexTangents:!!T.attributes.tangent&&(K||Q),vertexColors:r.vertexColors,vertexAlphas:!0===r.vertexColors&&!!T.attributes.color&&4===T.attributes.color.itemSize,pointsUvs:!0===S.isPoints&&!!T.attributes.uv&&(V||Te),fog:!!M,useFog:!0===r.fog,fogExp2:!!M&&M.isFogExp2,flatShading:!1===r.wireframe&&(!0===r.flatShading||void 0===T.attributes.normal&&!1===K&&(r.isMeshLambertMaterial||r.isMeshPhongMaterial||r.isMeshStandardMaterial||r.isMeshPhysicalMaterial)),sizeAttenuation:!0===r.sizeAttenuation,logarithmicDepthBuffer:h,reversedDepthBuffer:B,skinning:!0===S.isSkinnedMesh,morphTargets:void 0!==T.morphAttributes.position,morphNormals:void 0!==T.morphAttributes.normal,morphColors:void 0!==T.morphAttributes.color,morphTargetsCount:L,morphTextureStride:y,numDirLights:s.directional.length,numPointLights:s.point.length,numSpotLights:s.spot.length,numSpotLightMaps:s.spotLightMap.length,numRectAreaLights:s.rectArea.length,numHemiLights:s.hemi.length,numDirLightShadows:s.directionalShadowMap.length,numPointLightShadows:s.pointShadowMap.length,numSpotLightShadows:s.spotShadowMap.length,numSpotLightShadowsWithMaps:s.numSpotLightShadowsWithMaps,numLightProbes:s.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:r.dithering,shadowMapEnabled:e.shadowMap.enabled&&u.length>0,shadowMapType:e.shadowMap.type,toneMapping:be,decodeVideoTexture:V&&!0===r.map.isVideoTexture&&p.getTransfer(r.map.colorSpace)===m,decodeVideoTextureEmissive:j&&!0===r.emissiveMap.isVideoTexture&&p.getTransfer(r.emissiveMap.colorSpace)===m,premultipliedAlpha:r.premultipliedAlpha,doubleSided:r.side===_e,flipSided:r.side===c,useDepthPacking:r.depthPacking>=0,depthPacking:r.depthPacking||0,index0AttributeName:r.index0AttributeName,extensionClipCullDistance:Re&&!0===r.extensions.clipCullDistance&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Re&&!0===r.extensions.multiDraw||H)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:r.customProgramCacheKey()};return Ce.vertexUv1s=d.has(1),Ce.vertexUv2s=d.has(2),Ce.vertexUv3s=d.has(3),d.clear(),Ce},getProgramCacheKey:function(t){const n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.customVertexShaderID),n.push(t.customFragmentShaderID)),void 0!==t.defines)for(const e in t.defines)n.push(e),n.push(t.defines[e]);return!1===t.isRawShaderMaterial&&(!function(e,t){e.push(t.precision),e.push(t.outputColorSpace),e.push(t.envMapMode),e.push(t.envMapCubeUVHeight),e.push(t.mapUv),e.push(t.alphaMapUv),e.push(t.lightMapUv),e.push(t.aoMapUv),e.push(t.bumpMapUv),e.push(t.normalMapUv),e.push(t.displacementMapUv),e.push(t.emissiveMapUv),e.push(t.metalnessMapUv),e.push(t.roughnessMapUv),e.push(t.anisotropyMapUv),e.push(t.clearcoatMapUv),e.push(t.clearcoatNormalMapUv),e.push(t.clearcoatRoughnessMapUv),e.push(t.iridescenceMapUv),e.push(t.iridescenceThicknessMapUv),e.push(t.sheenColorMapUv),e.push(t.sheenRoughnessMapUv),e.push(t.specularMapUv),e.push(t.specularColorMapUv),e.push(t.specularIntensityMapUv),e.push(t.transmissionMapUv),e.push(t.thicknessMapUv),e.push(t.combine),e.push(t.fogExp2),e.push(t.sizeAttenuation),e.push(t.morphTargetsCount),e.push(t.morphAttributeCount),e.push(t.numDirLights),e.push(t.numPointLights),e.push(t.numSpotLights),e.push(t.numSpotLightMaps),e.push(t.numHemiLights),e.push(t.numRectAreaLights),e.push(t.numDirLightShadows),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.numSpotLightShadowsWithMaps),e.push(t.numLightProbes),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking)}(n,t),function(e,t){s.disableAll(),t.instancing&&s.enable(0);t.instancingColor&&s.enable(1);t.instancingMorph&&s.enable(2);t.matcap&&s.enable(3);t.envMap&&s.enable(4);t.normalMapObjectSpace&&s.enable(5);t.normalMapTangentSpace&&s.enable(6);t.clearcoat&&s.enable(7);t.iridescence&&s.enable(8);t.alphaTest&&s.enable(9);t.vertexColors&&s.enable(10);t.vertexAlphas&&s.enable(11);t.vertexUv1s&&s.enable(12);t.vertexUv2s&&s.enable(13);t.vertexUv3s&&s.enable(14);t.vertexTangents&&s.enable(15);t.anisotropy&&s.enable(16);t.alphaHash&&s.enable(17);t.batching&&s.enable(18);t.dispersion&&s.enable(19);t.batchingColor&&s.enable(20);t.gradientMap&&s.enable(21);e.push(s.mask),s.disableAll(),t.fog&&s.enable(0);t.useFog&&s.enable(1);t.flatShading&&s.enable(2);t.logarithmicDepthBuffer&&s.enable(3);t.reversedDepthBuffer&&s.enable(4);t.skinning&&s.enable(5);t.morphTargets&&s.enable(6);t.morphNormals&&s.enable(7);t.morphColors&&s.enable(8);t.premultipliedAlpha&&s.enable(9);t.shadowMapEnabled&&s.enable(10);t.doubleSided&&s.enable(11);t.flipSided&&s.enable(12);t.useDepthPacking&&s.enable(13);t.dithering&&s.enable(14);t.transmission&&s.enable(15);t.sheen&&s.enable(16);t.opaque&&s.enable(17);t.pointsUvs&&s.enable(18);t.decodeVideoTexture&&s.enable(19);t.decodeVideoTextureEmissive&&s.enable(20);t.alphaToCoverage&&s.enable(21);e.push(s.mask)}(n,t),n.push(e.outputColorSpace)),n.push(t.customProgramCacheKey),n.join()},getUniforms:function(e){const t=g[e.type];let n;if(t){const e=Vn[t];n=he.clone(e.uniforms)}else n=e.uniforms;return n},acquireProgram:function(t,n){let i=f.get(n);return void 0!==i?++i.usedTimes:(i=new $r(e,n,t,r),u.push(i),f.set(n,i)),i},releaseProgram:function(e){if(0===--e.usedTimes){const t=u.indexOf(e);u[t]=u[u.length-1],u.pop(),f.delete(e.cacheKey),e.destroy()}},releaseShaderCache:function(e){l.remove(e)},programs:u,dispose:function(){l.dispose()}}}function na(){let e=new WeakMap;return{has:function(t){return e.has(t)},get:function(t){let n=e.get(t);return void 0===n&&(n={},e.set(t,n)),n},remove:function(t){e.delete(t)},update:function(t,n,i){e.get(t)[n]=i},dispose:function(){e=new WeakMap}}}function ia(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.material.id!==t.material.id?e.material.id-t.material.id:e.materialVariant!==t.materialVariant?e.materialVariant-t.materialVariant:e.z!==t.z?e.z-t.z:e.id-t.id}function ra(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 aa(){const e=[];let t=0;const n=[],i=[],r=[];function a(e){let t=0;return e.isInstancedMesh&&(t+=2),e.isSkinnedMesh&&(t+=1),t}function o(n,i,r,o,s,l){let c=e[t];return void 0===c?(c={id:n.id,object:n,geometry:i,material:r,materialVariant:a(n),groupOrder:o,renderOrder:n.renderOrder,z:s,group:l},e[t]=c):(c.id=n.id,c.object=n,c.geometry=i,c.material=r,c.materialVariant=a(n),c.groupOrder=o,c.renderOrder=n.renderOrder,c.z=s,c.group=l),t++,c}return{opaque:n,transmissive:i,transparent:r,init:function(){t=0,n.length=0,i.length=0,r.length=0},push:function(e,t,a,s,l,c){const d=o(e,t,a,s,l,c);e.onBeforeRenderListPush?.(e,t,a,c),a.transmission>0?i.push(d):!0===a.transparent?r.push(d):n.push(d),e.onAfterRenderListPush?.(e,t,a,c)},unshift:function(e,t,a,s,l,c){const d=o(e,t,a,s,l,c);a.transmission>0?i.unshift(d):!0===a.transparent?r.unshift(d):n.unshift(d)},finish:function(){for(let n=t,i=e.length;n<i;n++){const t=e[n];if(null===t.id)break;t.id=null,t.object=null,t.geometry=null,t.material=null,t.group=null}},sort:function(e,t){n.length>1&&n.sort(e||ia),i.length>1&&i.sort(t||ra),r.length>1&&r.sort(t||ra)}}}function oa(){let e=new WeakMap;return{get:function(t,n){const i=e.get(t);let r;return void 0===i?(r=new aa,e.set(t,[r])):n>=i.length?(r=new aa,i.push(r)):r=i[n],r},dispose:function(){e=new WeakMap}}}function sa(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let i;switch(t.type){case"DirectionalLight":i={direction:new r,color:new n};break;case"SpotLight":i={position:new r,direction:new r,color:new n,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":i={position:new r,color:new n,distance:0,decay:0};break;case"HemisphereLight":i={direction:new r,skyColor:new n,groundColor:new n};break;case"RectAreaLight":i={color:new n,position:new r,halfWidth:new r,halfHeight:new r}}return e[t.id]=i,i}}}let la=0;function ca(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function da(e){const n=new sa,i=function(){const e={};return{get:function(n){if(void 0!==e[n.id])return e[n.id];let i;switch(n.type){case"DirectionalLight":case"SpotLight":i={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new t};break;case"PointLight":i={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new t,shadowCameraNear:1,shadowCameraFar:1e3}}return e[n.id]=i,i}}}(),a={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let e=0;e<9;e++)a.probe.push(new r);const o=new r,s=new f,l=new f;return{setup:function(t){let r=0,o=0,s=0;for(let e=0;e<9;e++)a.probe[e].set(0,0,0);let l=0,c=0,d=0,u=0,f=0,p=0,m=0,h=0,_=0,g=0,v=0;t.sort(ca);for(let e=0,E=t.length;e<E;e++){const E=t[e],S=E.color,M=E.intensity,T=E.distance;let x=null;if(E.shadow&&E.shadow.map&&(x=E.shadow.map.texture.format===Me?E.shadow.map.texture:E.shadow.map.depthTexture||E.shadow.map.texture),E.isAmbientLight)r+=S.r*M,o+=S.g*M,s+=S.b*M;else if(E.isLightProbe){for(let e=0;e<9;e++)a.probe[e].addScaledVector(E.sh.coefficients[e],M);v++}else if(E.isDirectionalLight){const e=n.get(E);if(e.color.copy(E.color).multiplyScalar(E.intensity),E.castShadow){const e=E.shadow,t=i.get(E);t.shadowIntensity=e.intensity,t.shadowBias=e.bias,t.shadowNormalBias=e.normalBias,t.shadowRadius=e.radius,t.shadowMapSize=e.mapSize,a.directionalShadow[l]=t,a.directionalShadowMap[l]=x,a.directionalShadowMatrix[l]=E.shadow.matrix,p++}a.directional[l]=e,l++}else if(E.isSpotLight){const e=n.get(E);e.position.setFromMatrixPosition(E.matrixWorld),e.color.copy(S).multiplyScalar(M),e.distance=T,e.coneCos=Math.cos(E.angle),e.penumbraCos=Math.cos(E.angle*(1-E.penumbra)),e.decay=E.decay,a.spot[d]=e;const t=E.shadow;if(E.map&&(a.spotLightMap[_]=E.map,_++,t.updateMatrices(E),E.castShadow&&g++),a.spotLightMatrix[d]=t.matrix,E.castShadow){const e=i.get(E);e.shadowIntensity=t.intensity,e.shadowBias=t.bias,e.shadowNormalBias=t.normalBias,e.shadowRadius=t.radius,e.shadowMapSize=t.mapSize,a.spotShadow[d]=e,a.spotShadowMap[d]=x,h++}d++}else if(E.isRectAreaLight){const e=n.get(E);e.color.copy(S).multiplyScalar(M),e.halfWidth.set(.5*E.width,0,0),e.halfHeight.set(0,.5*E.height,0),a.rectArea[u]=e,u++}else if(E.isPointLight){const e=n.get(E);if(e.color.copy(E.color).multiplyScalar(E.intensity),e.distance=E.distance,e.decay=E.decay,E.castShadow){const e=E.shadow,t=i.get(E);t.shadowIntensity=e.intensity,t.shadowBias=e.bias,t.shadowNormalBias=e.normalBias,t.shadowRadius=e.radius,t.shadowMapSize=e.mapSize,t.shadowCameraNear=e.camera.near,t.shadowCameraFar=e.camera.far,a.pointShadow[c]=t,a.pointShadowMap[c]=x,a.pointShadowMatrix[c]=E.shadow.matrix,m++}a.point[c]=e,c++}else if(E.isHemisphereLight){const e=n.get(E);e.skyColor.copy(E.color).multiplyScalar(M),e.groundColor.copy(E.groundColor).multiplyScalar(M),a.hemi[f]=e,f++}}u>0&&(!0===e.has("OES_texture_float_linear")?(a.rectAreaLTC1=Hn.LTC_FLOAT_1,a.rectAreaLTC2=Hn.LTC_FLOAT_2):(a.rectAreaLTC1=Hn.LTC_HALF_1,a.rectAreaLTC2=Hn.LTC_HALF_2)),a.ambient[0]=r,a.ambient[1]=o,a.ambient[2]=s;const E=a.hash;E.directionalLength===l&&E.pointLength===c&&E.spotLength===d&&E.rectAreaLength===u&&E.hemiLength===f&&E.numDirectionalShadows===p&&E.numPointShadows===m&&E.numSpotShadows===h&&E.numSpotMaps===_&&E.numLightProbes===v||(a.directional.length=l,a.spot.length=d,a.rectArea.length=u,a.point.length=c,a.hemi.length=f,a.directionalShadow.length=p,a.directionalShadowMap.length=p,a.pointShadow.length=m,a.pointShadowMap.length=m,a.spotShadow.length=h,a.spotShadowMap.length=h,a.directionalShadowMatrix.length=p,a.pointShadowMatrix.length=m,a.spotLightMatrix.length=h+_-g,a.spotLightMap.length=_,a.numSpotLightShadowsWithMaps=g,a.numLightProbes=v,E.directionalLength=l,E.pointLength=c,E.spotLength=d,E.rectAreaLength=u,E.hemiLength=f,E.numDirectionalShadows=p,E.numPointShadows=m,E.numSpotShadows=h,E.numSpotMaps=_,E.numLightProbes=v,a.version=la++)},setupView:function(e,t){let n=0,i=0,r=0,c=0,d=0;const u=t.matrixWorldInverse;for(let t=0,f=e.length;t<f;t++){const f=e[t];if(f.isDirectionalLight){const e=a.directional[n];e.direction.setFromMatrixPosition(f.matrixWorld),o.setFromMatrixPosition(f.target.matrixWorld),e.direction.sub(o),e.direction.transformDirection(u),n++}else if(f.isSpotLight){const e=a.spot[r];e.position.setFromMatrixPosition(f.matrixWorld),e.position.applyMatrix4(u),e.direction.setFromMatrixPosition(f.matrixWorld),o.setFromMatrixPosition(f.target.matrixWorld),e.direction.sub(o),e.direction.transformDirection(u),r++}else if(f.isRectAreaLight){const e=a.rectArea[c];e.position.setFromMatrixPosition(f.matrixWorld),e.position.applyMatrix4(u),l.identity(),s.copy(f.matrixWorld),s.premultiply(u),l.extractRotation(s),e.halfWidth.set(.5*f.width,0,0),e.halfHeight.set(0,.5*f.height,0),e.halfWidth.applyMatrix4(l),e.halfHeight.applyMatrix4(l),c++}else if(f.isPointLight){const e=a.point[i];e.position.setFromMatrixPosition(f.matrixWorld),e.position.applyMatrix4(u),i++}else if(f.isHemisphereLight){const e=a.hemi[d];e.direction.setFromMatrixPosition(f.matrixWorld),e.direction.transformDirection(u),d++}}},state:a}}function ua(e){const t=new da(e),n=[],i=[];const r={lightsArray:n,shadowsArray:i,camera:null,lights:t,transmissionRenderTarget:{}};return{init:function(e){r.camera=e,n.length=0,i.length=0},state:r,setupLights:function(){t.setup(n)},setupLightsView:function(e){t.setupView(n,e)},pushLight:function(e){n.push(e)},pushShadow:function(e){i.push(e)}}}function fa(e){let t=new WeakMap;return{get:function(n,i=0){const r=t.get(n);let a;return void 0===r?(a=new ua(e),t.set(n,[a])):i>=r.length?(a=new ua(e),r.push(a)):a=r[i],a},dispose:function(){t=new WeakMap}}}const pa=[new r(1,0,0),new r(-1,0,0),new r(0,1,0),new r(0,-1,0),new r(0,0,1),new r(0,0,-1)],ma=[new r(0,-1,0),new r(0,-1,0),new r(0,0,1),new r(0,0,-1),new r(0,-1,0),new r(0,-1,0)],ha=new f,_a=new r,ga=new r;function va(e,n,i){let r=new Te;const a=new t,s=new t,d=new Y,u=new xe,f=new Ae,p={},m=i.maxTextureSize,h={[_]:c,[c]:_,[_e]:_e},g=new l({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new t},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg;\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r;\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );\n\tgl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );\n}"}),v=g.clone();v.defines.HORIZONTAL_PASS=1;const M=new C;M.setAttribute("position",new y(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const x=new o(M,g),A=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=de;let R=this.type;function b(t,i){const r=n.update(x);g.defines.VSM_SAMPLES!==t.blurSamples&&(g.defines.VSM_SAMPLES=t.blurSamples,v.defines.VSM_SAMPLES=t.blurSamples,g.needsUpdate=!0,v.needsUpdate=!0),null===t.mapPass&&(t.mapPass=new N(a.x,a.y,{format:Me,type:S})),g.uniforms.shadow_pass.value=t.map.depthTexture,g.uniforms.resolution.value=t.mapSize,g.uniforms.radius.value=t.radius,e.setRenderTarget(t.mapPass),e.clear(),e.renderBufferDirect(i,null,r,g,x,null),v.uniforms.shadow_pass.value=t.mapPass.texture,v.uniforms.resolution.value=t.mapSize,v.uniforms.radius.value=t.radius,e.setRenderTarget(t.map),e.clear(),e.renderBufferDirect(i,null,r,v,x,null)}function P(t,n,i,r){let a=null;const o=!0===i.isPointLight?t.customDistanceMaterial:t.customDepthMaterial;if(void 0!==o)a=o;else if(a=!0===i.isPointLight?f:u,e.localClippingEnabled&&!0===n.clipShadows&&Array.isArray(n.clippingPlanes)&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0||n.map&&n.alphaTest>0||!0===n.alphaToCoverage){const e=a.uuid,t=n.uuid;let i=p[e];void 0===i&&(i={},p[e]=i);let r=i[t];void 0===r&&(r=a.clone(),i[t]=r,n.addEventListener("dispose",U)),a=r}if(a.visible=n.visible,a.wireframe=n.wireframe,a.side=r===ce?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:h[n.side],a.alphaMap=n.alphaMap,a.alphaTest=!0===n.alphaToCoverage?.5:n.alphaTest,a.map=n.map,a.clipShadows=n.clipShadows,a.clippingPlanes=n.clippingPlanes,a.clipIntersection=n.clipIntersection,a.displacementMap=n.displacementMap,a.displacementScale=n.displacementScale,a.displacementBias=n.displacementBias,a.wireframeLinewidth=n.wireframeLinewidth,a.linewidth=n.linewidth,!0===i.isPointLight&&!0===a.isMeshDistanceMaterial){e.properties.get(a).light=i}return a}function L(t,i,a,o,s){if(!1===t.visible)return;if(t.layers.test(i.layers)&&(t.isMesh||t.isLine||t.isPoints)&&(t.castShadow||t.receiveShadow&&s===ce)&&(!t.frustumCulled||r.intersectsObject(t))){t.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,t.matrixWorld);const r=n.update(t),l=t.material;if(Array.isArray(l)){const n=r.groups;for(let c=0,d=n.length;c<d;c++){const d=n[c],u=l[d.materialIndex];if(u&&u.visible){const n=P(t,u,o,s);t.onBeforeShadow(e,t,i,a,r,n,d),e.renderBufferDirect(a,null,r,n,t,d),t.onAfterShadow(e,t,i,a,r,n,d)}}}else if(l.visible){const n=P(t,l,o,s);t.onBeforeShadow(e,t,i,a,r,n,null),e.renderBufferDirect(a,null,r,n,t,null),t.onAfterShadow(e,t,i,a,r,n,null)}}const l=t.children;for(let e=0,t=l.length;e<t;e++)L(l[e],i,a,o,s)}function U(e){e.target.removeEventListener("dispose",U);for(const t in p){const n=p[t],i=e.target.uuid;if(i in n){n[i].dispose(),delete n[i]}}}this.render=function(t,n,i){if(!1===A.enabled)return;if(!1===A.autoUpdate&&!1===A.needsUpdate)return;if(0===t.length)return;this.type===Re&&(E("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=de);const o=e.getRenderTarget(),l=e.getActiveCubeFace(),c=e.getActiveMipmapLevel(),u=e.state;u.setBlending(I),!0===u.buffers.depth.getReversed()?u.buffers.color.setClear(0,0,0,0):u.buffers.color.setClear(1,1,1,1),u.buffers.depth.setTest(!0),u.setScissorTest(!1);const f=R!==this.type;f&&n.traverse(function(e){e.material&&(Array.isArray(e.material)?e.material.forEach(e=>e.needsUpdate=!0):e.material.needsUpdate=!0)});for(let o=0,l=t.length;o<l;o++){const l=t[o],c=l.shadow;if(void 0===c){E("WebGLShadowMap:",l,"has no shadow.");continue}if(!1===c.autoUpdate&&!1===c.needsUpdate)continue;a.copy(c.mapSize);const p=c.getFrameExtents();a.multiply(p),s.copy(c.mapSize),(a.x>m||a.y>m)&&(a.x>m&&(s.x=Math.floor(m/p.x),a.x=s.x*p.x,c.mapSize.x=s.x),a.y>m&&(s.y=Math.floor(m/p.y),a.y=s.y*p.y,c.mapSize.y=s.y));const h=e.state.buffers.depth.getReversed();if(c.camera._reversedDepth=h,null===c.map||!0===f){if(null!==c.map&&(null!==c.map.depthTexture&&(c.map.depthTexture.dispose(),c.map.depthTexture=null),c.map.dispose()),this.type===ce){if(l.isPointLight){E("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}c.map=new N(a.x,a.y,{format:Me,type:S,minFilter:O,magFilter:O,generateMipmaps:!1}),c.map.texture.name=l.name+".shadowMap",c.map.depthTexture=new oe(a.x,a.y,T),c.map.depthTexture.name=l.name+".shadowMapDepth",c.map.depthTexture.format=be,c.map.depthTexture.compareFunction=null,c.map.depthTexture.minFilter=Ce,c.map.depthTexture.magFilter=Ce}else l.isPointLight?(c.map=new fi(a.x),c.map.depthTexture=new Pe(a.x,Le)):(c.map=new N(a.x,a.y),c.map.depthTexture=new oe(a.x,a.y,Le)),c.map.depthTexture.name=l.name+".shadowMap",c.map.depthTexture.format=be,this.type===de?(c.map.depthTexture.compareFunction=h?re:ae,c.map.depthTexture.minFilter=O,c.map.depthTexture.magFilter=O):(c.map.depthTexture.compareFunction=null,c.map.depthTexture.minFilter=Ce,c.map.depthTexture.magFilter=Ce);c.camera.updateProjectionMatrix()}const _=c.map.isWebGLCubeRenderTarget?6:1;for(let t=0;t<_;t++){if(c.map.isWebGLCubeRenderTarget)e.setRenderTarget(c.map,t),e.clear();else{0===t&&(e.setRenderTarget(c.map),e.clear());const n=c.getViewport(t);d.set(s.x*n.x,s.y*n.y,s.x*n.z,s.y*n.w),u.viewport(d)}if(l.isPointLight){const e=c.camera,n=c.matrix,i=l.distance||e.far;i!==e.far&&(e.far=i,e.updateProjectionMatrix()),_a.setFromMatrixPosition(l.matrixWorld),e.position.copy(_a),ga.copy(e.position),ga.add(pa[t]),e.up.copy(ma[t]),e.lookAt(ga),e.updateMatrixWorld(),n.makeTranslation(-_a.x,-_a.y,-_a.z),ha.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),c._frustum.setFromProjectionMatrix(ha,e.coordinateSystem,e.reversedDepth)}else c.updateMatrices(l);r=c.getFrustum(),L(n,i,c.camera,l,this.type)}!0!==c.isPointLightShadow&&this.type===ce&&b(c,i),c.needsUpdate=!1}R=this.type,A.needsUpdate=!1,e.setRenderTarget(o,l,c)}}function Ea(e,t){const i=new function(){let t=!1;const n=new Y;let i=null;const r=new Y(0,0,0,0);return{setMask:function(n){i===n||t||(e.colorMask(n,n,n,n),i=n)},setLocked:function(e){t=e},setClear:function(t,i,a,o,s){!0===s&&(t*=o,i*=o,a*=o),n.set(t,i,a,o),!1===r.equals(n)&&(e.clearColor(t,i,a,o),r.copy(n))},reset:function(){t=!1,i=null,r.set(-1,0,0,0)}}},r=new function(){let n=!1,i=!1,r=null,a=null,o=null;return{setReversed:function(e){if(i!==e){const n=t.get("EXT_clip_control");e?n.clipControlEXT(n.LOWER_LEFT_EXT,n.ZERO_TO_ONE_EXT):n.clipControlEXT(n.LOWER_LEFT_EXT,n.NEGATIVE_ONE_TO_ONE_EXT),i=e;const r=o;o=null,this.setClear(r)}},getReversed:function(){return i},setTest:function(t){t?k(e.DEPTH_TEST):X(e.DEPTH_TEST)},setMask:function(t){r===t||n||(e.depthMask(t),r=t)},setFunc:function(t){if(i&&(t=ct[t]),a!==t){switch(t){case tt:e.depthFunc(e.NEVER);break;case et:e.depthFunc(e.ALWAYS);break;case Je:e.depthFunc(e.LESS);break;case Ue:e.depthFunc(e.LEQUAL);break;case Qe:e.depthFunc(e.EQUAL);break;case $e:e.depthFunc(e.GEQUAL);break;case Ze:e.depthFunc(e.GREATER);break;case je:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}a=t}},setLocked:function(e){n=e},setClear:function(t){o!==t&&(o=t,i&&(t=1-t),e.clearDepth(t))},reset:function(){n=!1,r=null,a=null,o=null,i=!1}}},a=new function(){let t=!1,n=null,i=null,r=null,a=null,o=null,s=null,l=null,c=null;return{setTest:function(n){t||(n?k(e.STENCIL_TEST):X(e.STENCIL_TEST))},setMask:function(i){n===i||t||(e.stencilMask(i),n=i)},setFunc:function(t,n,o){i===t&&r===n&&a===o||(e.stencilFunc(t,n,o),i=t,r=n,a=o)},setOp:function(t,n,i){o===t&&s===n&&l===i||(e.stencilOp(t,n,i),o=t,s=n,l=i)},setLocked:function(e){t=e},setClear:function(t){c!==t&&(e.clearStencil(t),c=t)},reset:function(){t=!1,n=null,i=null,r=null,a=null,o=null,s=null,l=null,c=null}}},o=new WeakMap,s=new WeakMap;let l={},d={},u=new WeakMap,f=[],p=null,m=!1,h=null,_=null,g=null,v=null,E=null,S=null,M=null,T=new n(0,0,0),x=0,A=!1,R=null,b=null,C=null,P=null,L=null;const U=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let D=!1,N=0;const y=e.getParameter(e.VERSION);-1!==y.indexOf("WebGL")?(N=parseFloat(/^WebGL (\d)/.exec(y)[1]),D=N>=1):-1!==y.indexOf("OpenGL ES")&&(N=parseFloat(/^OpenGL ES (\d)/.exec(y)[1]),D=N>=2);let F=null,O={};const B=e.getParameter(e.SCISSOR_BOX),G=e.getParameter(e.VIEWPORT),H=(new Y).fromArray(B),V=(new Y).fromArray(G);function W(t,n,i,r){const a=new Uint8Array(4),o=e.createTexture();e.bindTexture(t,o),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let o=0;o<i;o++)t===e.TEXTURE_3D||t===e.TEXTURE_2D_ARRAY?e.texImage3D(n,0,e.RGBA,1,1,r,0,e.RGBA,e.UNSIGNED_BYTE,a):e.texImage2D(n+o,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,a);return o}const z={};function k(t){!0!==l[t]&&(e.enable(t),l[t]=!0)}function X(t){!1!==l[t]&&(e.disable(t),l[t]=!1)}z[e.TEXTURE_2D]=W(e.TEXTURE_2D,e.TEXTURE_2D,1),z[e.TEXTURE_CUBE_MAP]=W(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),z[e.TEXTURE_2D_ARRAY]=W(e.TEXTURE_2D_ARRAY,e.TEXTURE_2D_ARRAY,1,1),z[e.TEXTURE_3D]=W(e.TEXTURE_3D,e.TEXTURE_3D,1,1),i.setClear(0,0,0,1),r.setClear(1),a.setClear(0),k(e.DEPTH_TEST),r.setFunc(Ue),Z(!1),$(it),k(e.CULL_FACE),j(I);const K={[Ie]:e.FUNC_ADD,[we]:e.FUNC_SUBTRACT,[De]:e.FUNC_REVERSE_SUBTRACT};K[dt]=e.MIN,K[ut]=e.MAX;const q={[qe]:e.ZERO,[Ke]:e.ONE,[Ye]:e.SRC_COLOR,[Xe]:e.SRC_ALPHA,[ke]:e.SRC_ALPHA_SATURATE,[ze]:e.DST_COLOR,[We]:e.DST_ALPHA,[Ve]:e.ONE_MINUS_SRC_COLOR,[He]:e.ONE_MINUS_SRC_ALPHA,[Ge]:e.ONE_MINUS_DST_COLOR,[Be]:e.ONE_MINUS_DST_ALPHA,[Oe]:e.CONSTANT_COLOR,[Fe]:e.ONE_MINUS_CONSTANT_COLOR,[ye]:e.CONSTANT_ALPHA,[Ne]:e.ONE_MINUS_CONSTANT_ALPHA};function j(t,n,i,r,a,o,s,l,c,d){if(t!==I){if(!1===m&&(k(e.BLEND),m=!0),t===at)a=a||n,o=o||i,s=s||r,n===_&&a===E||(e.blendEquationSeparate(K[n],K[a]),_=n,E=a),i===g&&r===v&&o===S&&s===M||(e.blendFuncSeparate(q[i],q[r],q[o],q[s]),g=i,v=r,S=o,M=s),!1!==l.equals(T)&&c===x||(e.blendColor(l.r,l.g,l.b,c),T.copy(l),x=c),h=t,A=!1;else if(t!==h||d!==A){if(_===Ie&&E===Ie||(e.blendEquation(e.FUNC_ADD),_=Ie,E=Ie),d)switch(t){case ge:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case lt:e.blendFunc(e.ONE,e.ONE);break;case st:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case ot:e.blendFuncSeparate(e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ZERO,e.ONE);break;default:w("WebGLState: Invalid blending: ",t)}else switch(t){case ge:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case lt:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE,e.ONE,e.ONE);break;case st:w("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case ot:w("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:w("WebGLState: Invalid blending: ",t)}g=null,v=null,S=null,M=null,T.set(0,0,0),x=0,h=t,A=d}}else!0===m&&(X(e.BLEND),m=!1)}function Z(t){R!==t&&(t?e.frontFace(e.CW):e.frontFace(e.CCW),R=t)}function $(t){t!==nt?(k(e.CULL_FACE),t!==b&&(t===it?e.cullFace(e.BACK):t===rt?e.cullFace(e.FRONT):e.cullFace(e.FRONT_AND_BACK))):X(e.CULL_FACE),b=t}function Q(t,n,i){t?(k(e.POLYGON_OFFSET_FILL),P===n&&L===i||(P=n,L=i,r.getReversed()&&(n=-n),e.polygonOffset(n,i))):X(e.POLYGON_OFFSET_FILL)}return{buffers:{color:i,depth:r,stencil:a},enable:k,disable:X,bindFramebuffer:function(t,n){return d[t]!==n&&(e.bindFramebuffer(t,n),d[t]=n,t===e.DRAW_FRAMEBUFFER&&(d[e.FRAMEBUFFER]=n),t===e.FRAMEBUFFER&&(d[e.DRAW_FRAMEBUFFER]=n),!0)},drawBuffers:function(t,n){let i=f,r=!1;if(t){i=u.get(n),void 0===i&&(i=[],u.set(n,i));const a=t.textures;if(i.length!==a.length||i[0]!==e.COLOR_ATTACHMENT0){for(let t=0,n=a.length;t<n;t++)i[t]=e.COLOR_ATTACHMENT0+t;i.length=a.length,r=!0}}else i[0]!==e.BACK&&(i[0]=e.BACK,r=!0);r&&e.drawBuffers(i)},useProgram:function(t){return p!==t&&(e.useProgram(t),p=t,!0)},setBlending:j,setMaterial:function(t,n){t.side===_e?X(e.CULL_FACE):k(e.CULL_FACE);let o=t.side===c;n&&(o=!o),Z(o),t.blending===ge&&!1===t.transparent?j(I):j(t.blending,t.blendEquation,t.blendSrc,t.blendDst,t.blendEquationAlpha,t.blendSrcAlpha,t.blendDstAlpha,t.blendColor,t.blendAlpha,t.premultipliedAlpha),r.setFunc(t.depthFunc),r.setTest(t.depthTest),r.setMask(t.depthWrite),i.setMask(t.colorWrite);const s=t.stencilWrite;a.setTest(s),s&&(a.setMask(t.stencilWriteMask),a.setFunc(t.stencilFunc,t.stencilRef,t.stencilFuncMask),a.setOp(t.stencilFail,t.stencilZFail,t.stencilZPass)),Q(t.polygonOffset,t.polygonOffsetFactor,t.polygonOffsetUnits),!0===t.alphaToCoverage?k(e.SAMPLE_ALPHA_TO_COVERAGE):X(e.SAMPLE_ALPHA_TO_COVERAGE)},setFlipSided:Z,setCullFace:$,setLineWidth:function(t){t!==C&&(D&&e.lineWidth(t),C=t)},setPolygonOffset:Q,setScissorTest:function(t){t?k(e.SCISSOR_TEST):X(e.SCISSOR_TEST)},activeTexture:function(t){void 0===t&&(t=e.TEXTURE0+U-1),F!==t&&(e.activeTexture(t),F=t)},bindTexture:function(t,n,i){void 0===i&&(i=null===F?e.TEXTURE0+U-1:F);let r=O[i];void 0===r&&(r={type:void 0,texture:void 0},O[i]=r),r.type===t&&r.texture===n||(F!==i&&(e.activeTexture(i),F=i),e.bindTexture(t,n||z[t]),r.type=t,r.texture=n)},unbindTexture:function(){const t=O[F];void 0!==t&&void 0!==t.type&&(e.bindTexture(t.type,null),t.type=void 0,t.texture=void 0)},compressedTexImage2D:function(){try{e.compressedTexImage2D(...arguments)}catch(e){w("WebGLState:",e)}},compressedTexImage3D:function(){try{e.compressedTexImage3D(...arguments)}catch(e){w("WebGLState:",e)}},texImage2D:function(){try{e.texImage2D(...arguments)}catch(e){w("WebGLState:",e)}},texImage3D:function(){try{e.texImage3D(...arguments)}catch(e){w("WebGLState:",e)}},updateUBOMapping:function(t,n){let i=s.get(n);void 0===i&&(i=new WeakMap,s.set(n,i));let r=i.get(t);void 0===r&&(r=e.getUniformBlockIndex(n,t.name),i.set(t,r))},uniformBlockBinding:function(t,n){const i=s.get(n).get(t);o.get(n)!==i&&(e.uniformBlockBinding(n,i,t.__bindingPointIndex),o.set(n,i))},texStorage2D:function(){try{e.texStorage2D(...arguments)}catch(e){w("WebGLState:",e)}},texStorage3D:function(){try{e.texStorage3D(...arguments)}catch(e){w("WebGLState:",e)}},texSubImage2D:function(){try{e.texSubImage2D(...arguments)}catch(e){w("WebGLState:",e)}},texSubImage3D:function(){try{e.texSubImage3D(...arguments)}catch(e){w("WebGLState:",e)}},compressedTexSubImage2D:function(){try{e.compressedTexSubImage2D(...arguments)}catch(e){w("WebGLState:",e)}},compressedTexSubImage3D:function(){try{e.compressedTexSubImage3D(...arguments)}catch(e){w("WebGLState:",e)}},scissor:function(t){!1===H.equals(t)&&(e.scissor(t.x,t.y,t.z,t.w),H.copy(t))},viewport:function(t){!1===V.equals(t)&&(e.viewport(t.x,t.y,t.z,t.w),V.copy(t))},reset:function(){e.disable(e.BLEND),e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.POLYGON_OFFSET_FILL),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ZERO),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.blendColor(0,0,0,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(e.LESS),r.setReversed(!1),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(e.ALWAYS,0,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.clearStencil(0),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.activeTexture(e.TEXTURE0),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),l={},F=null,O={},d={},u=new WeakMap,f=[],p=null,m=!1,h=null,_=null,g=null,v=null,E=null,S=null,M=null,T=new n(0,0,0),x=0,A=!1,R=null,b=null,C=null,P=null,L=null,H.set(0,0,e.canvas.width,e.canvas.height),V.set(0,0,e.canvas.width,e.canvas.height),i.reset(),r.reset(),a.reset()}}}function Sa(e,n,i,r,a,o,s){const l=n.has("WEBGL_multisampled_render_to_texture")?n.get("WEBGL_multisampled_render_to_texture"):null,c="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),d=new t,u=new WeakMap;let f;const h=new WeakMap;let _=!1;try{_="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(e){}function g(e,t){return _?new OffscreenCanvas(e,t):Lt("canvas")}function v(e,t,n){let i=1;const r=ee(e);if((r.width>n||r.height>n)&&(i=n/Math.max(r.width,r.height)),i<1){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof VideoFrame&&e instanceof VideoFrame){const n=Math.floor(i*r.width),a=Math.floor(i*r.height);void 0===f&&(f=g(n,a));const o=t?g(n,a):f;o.width=n,o.height=a;return o.getContext("2d").drawImage(e,0,0,n,a),E("WebGLRenderer: Texture has been resized from ("+r.width+"x"+r.height+") to ("+n+"x"+a+")."),o}return"data"in e&&E("WebGLRenderer: Image in DataTexture is too big ("+r.width+"x"+r.height+")."),e}return e}function S(e){return e.generateMipmaps}function A(t){e.generateMipmap(t)}function R(t){return t.isWebGLCubeRenderTarget?e.TEXTURE_CUBE_MAP:t.isWebGL3DRenderTarget?e.TEXTURE_3D:t.isWebGLArrayRenderTarget||t.isCompressedArrayTexture?e.TEXTURE_2D_ARRAY:e.TEXTURE_2D}function b(t,i,r,a,o=!1){if(null!==t){if(void 0!==e[t])return e[t];E("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+t+"'")}let s=i;if(i===e.RED&&(r===e.FLOAT&&(s=e.R32F),r===e.HALF_FLOAT&&(s=e.R16F),r===e.UNSIGNED_BYTE&&(s=e.R8)),i===e.RED_INTEGER&&(r===e.UNSIGNED_BYTE&&(s=e.R8UI),r===e.UNSIGNED_SHORT&&(s=e.R16UI),r===e.UNSIGNED_INT&&(s=e.R32UI),r===e.BYTE&&(s=e.R8I),r===e.SHORT&&(s=e.R16I),r===e.INT&&(s=e.R32I)),i===e.RG&&(r===e.FLOAT&&(s=e.RG32F),r===e.HALF_FLOAT&&(s=e.RG16F),r===e.UNSIGNED_BYTE&&(s=e.RG8)),i===e.RG_INTEGER&&(r===e.UNSIGNED_BYTE&&(s=e.RG8UI),r===e.UNSIGNED_SHORT&&(s=e.RG16UI),r===e.UNSIGNED_INT&&(s=e.RG32UI),r===e.BYTE&&(s=e.RG8I),r===e.SHORT&&(s=e.RG16I),r===e.INT&&(s=e.RG32I)),i===e.RGB_INTEGER&&(r===e.UNSIGNED_BYTE&&(s=e.RGB8UI),r===e.UNSIGNED_SHORT&&(s=e.RGB16UI),r===e.UNSIGNED_INT&&(s=e.RGB32UI),r===e.BYTE&&(s=e.RGB8I),r===e.SHORT&&(s=e.RGB16I),r===e.INT&&(s=e.RGB32I)),i===e.RGBA_INTEGER&&(r===e.UNSIGNED_BYTE&&(s=e.RGBA8UI),r===e.UNSIGNED_SHORT&&(s=e.RGBA16UI),r===e.UNSIGNED_INT&&(s=e.RGBA32UI),r===e.BYTE&&(s=e.RGBA8I),r===e.SHORT&&(s=e.RGBA16I),r===e.INT&&(s=e.RGBA32I)),i===e.RGB&&(r===e.UNSIGNED_INT_5_9_9_9_REV&&(s=e.RGB9_E5),r===e.UNSIGNED_INT_10F_11F_11F_REV&&(s=e.R11F_G11F_B10F)),i===e.RGBA){const t=o?me:p.getTransfer(a);r===e.FLOAT&&(s=e.RGBA32F),r===e.HALF_FLOAT&&(s=e.RGBA16F),r===e.UNSIGNED_BYTE&&(s=t===m?e.SRGB8_ALPHA8:e.RGBA8),r===e.UNSIGNED_SHORT_4_4_4_4&&(s=e.RGBA4),r===e.UNSIGNED_SHORT_5_5_5_1&&(s=e.RGB5_A1)}return s!==e.R16F&&s!==e.R32F&&s!==e.RG16F&&s!==e.RG32F&&s!==e.RGBA16F&&s!==e.RGBA32F||n.get("EXT_color_buffer_float"),s}function C(t,n){let i;return t?null===n||n===Le||n===Ct?i=e.DEPTH24_STENCIL8:n===T?i=e.DEPTH32F_STENCIL8:n===Pt&&(i=e.DEPTH24_STENCIL8,E("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):null===n||n===Le||n===Ct?i=e.DEPTH_COMPONENT24:n===T?i=e.DEPTH_COMPONENT32F:n===Pt&&(i=e.DEPTH_COMPONENT16),i}function P(e,t){return!0===S(e)||e.isFramebufferTexture&&e.minFilter!==Ce&&e.minFilter!==O?Math.log2(Math.max(t.width,t.height))+1:void 0!==e.mipmaps&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function L(e){const t=e.target;t.removeEventListener("dispose",L),function(e){const t=r.get(e);if(void 0===t.__webglInit)return;const n=e.source,i=h.get(n);if(i){const r=i[t.__cacheKey];r.usedTimes--,0===r.usedTimes&&D(e),0===Object.keys(i).length&&h.delete(n)}r.remove(e)}(t),t.isVideoTexture&&u.delete(t)}function U(t){const n=t.target;n.removeEventListener("dispose",U),function(t){const n=r.get(t);t.depthTexture&&(t.depthTexture.dispose(),r.remove(t.depthTexture));if(t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++){if(Array.isArray(n.__webglFramebuffer[t]))for(let i=0;i<n.__webglFramebuffer[t].length;i++)e.deleteFramebuffer(n.__webglFramebuffer[t][i]);else e.deleteFramebuffer(n.__webglFramebuffer[t]);n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer[t])}else{if(Array.isArray(n.__webglFramebuffer))for(let t=0;t<n.__webglFramebuffer.length;t++)e.deleteFramebuffer(n.__webglFramebuffer[t]);else e.deleteFramebuffer(n.__webglFramebuffer);if(n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer),n.__webglMultisampledFramebuffer&&e.deleteFramebuffer(n.__webglMultisampledFramebuffer),n.__webglColorRenderbuffer)for(let t=0;t<n.__webglColorRenderbuffer.length;t++)n.__webglColorRenderbuffer[t]&&e.deleteRenderbuffer(n.__webglColorRenderbuffer[t]);n.__webglDepthRenderbuffer&&e.deleteRenderbuffer(n.__webglDepthRenderbuffer)}const i=t.textures;for(let t=0,n=i.length;t<n;t++){const n=r.get(i[t]);n.__webglTexture&&(e.deleteTexture(n.__webglTexture),s.memory.textures--),r.remove(i[t])}r.remove(t)}(n)}function D(t){const n=r.get(t);e.deleteTexture(n.__webglTexture);const i=t.source;delete h.get(i)[n.__cacheKey],s.memory.textures--}let I=0;function N(t,n){const a=r.get(t);if(t.isVideoTexture&&function(e){const t=s.render.frame;u.get(e)!==t&&(u.set(e,t),e.update())}(t),!1===t.isRenderTargetTexture&&!0!==t.isExternalTexture&&t.version>0&&a.__version!==t.version){const e=t.image;if(null===e)E("WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==e.complete)return void k(a,t,n);E("WebGLRenderer: Texture marked for update but image is incomplete")}}else t.isExternalTexture&&(a.__webglTexture=t.sourceTexture?t.sourceTexture:null);i.bindTexture(e.TEXTURE_2D,a.__webglTexture,e.TEXTURE0+n)}const y={[mt]:e.REPEAT,[pt]:e.CLAMP_TO_EDGE,[ft]:e.MIRRORED_REPEAT},B={[Ce]:e.NEAREST,[gt]:e.NEAREST_MIPMAP_NEAREST,[_t]:e.NEAREST_MIPMAP_LINEAR,[O]:e.LINEAR,[ht]:e.LINEAR_MIPMAP_NEAREST,[G]:e.LINEAR_MIPMAP_LINEAR},H={[xt]:e.NEVER,[Tt]:e.ALWAYS,[Mt]:e.LESS,[ae]:e.LEQUAL,[St]:e.EQUAL,[re]:e.GEQUAL,[Et]:e.GREATER,[vt]:e.NOTEQUAL};function V(t,i){if(i.type!==T||!1!==n.has("OES_texture_float_linear")||i.magFilter!==O&&i.magFilter!==ht&&i.magFilter!==_t&&i.magFilter!==G&&i.minFilter!==O&&i.minFilter!==ht&&i.minFilter!==_t&&i.minFilter!==G||E("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),e.texParameteri(t,e.TEXTURE_WRAP_S,y[i.wrapS]),e.texParameteri(t,e.TEXTURE_WRAP_T,y[i.wrapT]),t!==e.TEXTURE_3D&&t!==e.TEXTURE_2D_ARRAY||e.texParameteri(t,e.TEXTURE_WRAP_R,y[i.wrapR]),e.texParameteri(t,e.TEXTURE_MAG_FILTER,B[i.magFilter]),e.texParameteri(t,e.TEXTURE_MIN_FILTER,B[i.minFilter]),i.compareFunction&&(e.texParameteri(t,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(t,e.TEXTURE_COMPARE_FUNC,H[i.compareFunction])),!0===n.has("EXT_texture_filter_anisotropic")){if(i.magFilter===Ce)return;if(i.minFilter!==_t&&i.minFilter!==G)return;if(i.type===T&&!1===n.has("OES_texture_float_linear"))return;if(i.anisotropy>1||r.get(i).__currentAnisotropy){const o=n.get("EXT_texture_filter_anisotropic");e.texParameterf(t,o.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(i.anisotropy,a.getMaxAnisotropy())),r.get(i).__currentAnisotropy=i.anisotropy}}}function W(t,n){let i=!1;void 0===t.__webglInit&&(t.__webglInit=!0,n.addEventListener("dispose",L));const r=n.source;let a=h.get(r);void 0===a&&(a={},h.set(r,a));const o=function(e){const t=[];return t.push(e.wrapS),t.push(e.wrapT),t.push(e.wrapR||0),t.push(e.magFilter),t.push(e.minFilter),t.push(e.anisotropy),t.push(e.internalFormat),t.push(e.format),t.push(e.type),t.push(e.generateMipmaps),t.push(e.premultiplyAlpha),t.push(e.flipY),t.push(e.unpackAlignment),t.push(e.colorSpace),t.join()}(n);if(o!==t.__cacheKey){void 0===a[o]&&(a[o]={texture:e.createTexture(),usedTimes:0},s.memory.textures++,i=!0),a[o].usedTimes++;const r=a[t.__cacheKey];void 0!==r&&(a[t.__cacheKey].usedTimes--,0===r.usedTimes&&D(n)),t.__cacheKey=o,t.__webglTexture=a[o].texture}return i}function z(e,t,n){return Math.floor(Math.floor(e/n)/t)}function k(t,n,s){let l=e.TEXTURE_2D;(n.isDataArrayTexture||n.isCompressedArrayTexture)&&(l=e.TEXTURE_2D_ARRAY),n.isData3DTexture&&(l=e.TEXTURE_3D);const c=W(t,n),d=n.source;i.bindTexture(l,t.__webglTexture,e.TEXTURE0+s);const u=r.get(d);if(d.version!==u.__version||!0===c){i.activeTexture(e.TEXTURE0+s);const t=p.getPrimaries(p.workingColorSpace),r=n.colorSpace===At?null:p.getPrimaries(n.colorSpace),f=n.colorSpace===At||t===r?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,n.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,n.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,f);let m=v(n.image,!1,a.maxTextureSize);m=J(n,m);const h=o.convert(n.format,n.colorSpace),_=o.convert(n.type);let g,M=b(n.internalFormat,h,_,n.colorSpace,n.isVideoTexture);V(l,n);const T=n.mipmaps,R=!0!==n.isVideoTexture,L=void 0===u.__version||!0===c,U=d.dataReady,D=P(n,m);if(n.isDepthTexture)M=C(n.format===Rt,n.type),L&&(R?i.texStorage2D(e.TEXTURE_2D,1,M,m.width,m.height):i.texImage2D(e.TEXTURE_2D,0,M,m.width,m.height,0,h,_,null));else if(n.isDataTexture)if(T.length>0){R&&L&&i.texStorage2D(e.TEXTURE_2D,D,M,T[0].width,T[0].height);for(let t=0,n=T.length;t<n;t++)g=T[t],R?U&&i.texSubImage2D(e.TEXTURE_2D,t,0,0,g.width,g.height,h,_,g.data):i.texImage2D(e.TEXTURE_2D,t,M,g.width,g.height,0,h,_,g.data);n.generateMipmaps=!1}else R?(L&&i.texStorage2D(e.TEXTURE_2D,D,M,m.width,m.height),U&&function(t,n,r,a){const o=t.updateRanges;if(0===o.length)i.texSubImage2D(e.TEXTURE_2D,0,0,0,n.width,n.height,r,a,n.data);else{o.sort((e,t)=>e.start-t.start);let s=0;for(let e=1;e<o.length;e++){const t=o[s],i=o[e],r=t.start+t.count,a=z(i.start,n.width,4),l=z(t.start,n.width,4);i.start<=r+1&&a===l&&z(i.start+i.count-1,n.width,4)===a?t.count=Math.max(t.count,i.start+i.count-t.start):(++s,o[s]=i)}o.length=s+1;const l=e.getParameter(e.UNPACK_ROW_LENGTH),c=e.getParameter(e.UNPACK_SKIP_PIXELS),d=e.getParameter(e.UNPACK_SKIP_ROWS);e.pixelStorei(e.UNPACK_ROW_LENGTH,n.width);for(let t=0,s=o.length;t<s;t++){const s=o[t],l=Math.floor(s.start/4),c=Math.ceil(s.count/4),d=l%n.width,u=Math.floor(l/n.width),f=c,p=1;e.pixelStorei(e.UNPACK_SKIP_PIXELS,d),e.pixelStorei(e.UNPACK_SKIP_ROWS,u),i.texSubImage2D(e.TEXTURE_2D,0,d,u,f,p,r,a,n.data)}t.clearUpdateRanges(),e.pixelStorei(e.UNPACK_ROW_LENGTH,l),e.pixelStorei(e.UNPACK_SKIP_PIXELS,c),e.pixelStorei(e.UNPACK_SKIP_ROWS,d)}}(n,m,h,_)):i.texImage2D(e.TEXTURE_2D,0,M,m.width,m.height,0,h,_,m.data);else if(n.isCompressedTexture)if(n.isCompressedArrayTexture){R&&L&&i.texStorage3D(e.TEXTURE_2D_ARRAY,D,M,T[0].width,T[0].height,m.depth);for(let t=0,r=T.length;t<r;t++)if(g=T[t],n.format!==x)if(null!==h)if(R){if(U)if(n.layerUpdates.size>0){const r=bt(g.width,g.height,n.format,n.type);for(const a of n.layerUpdates){const n=g.data.subarray(a*r/g.data.BYTES_PER_ELEMENT,(a+1)*r/g.data.BYTES_PER_ELEMENT);i.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,t,0,0,a,g.width,g.height,1,h,n)}n.clearLayerUpdates()}else i.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,t,0,0,0,g.width,g.height,m.depth,h,g.data)}else i.compressedTexImage3D(e.TEXTURE_2D_ARRAY,t,M,g.width,g.height,m.depth,0,g.data,0,0);else E("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else R?U&&i.texSubImage3D(e.TEXTURE_2D_ARRAY,t,0,0,0,g.width,g.height,m.depth,h,_,g.data):i.texImage3D(e.TEXTURE_2D_ARRAY,t,M,g.width,g.height,m.depth,0,h,_,g.data)}else{R&&L&&i.texStorage2D(e.TEXTURE_2D,D,M,T[0].width,T[0].height);for(let t=0,r=T.length;t<r;t++)g=T[t],n.format!==x?null!==h?R?U&&i.compressedTexSubImage2D(e.TEXTURE_2D,t,0,0,g.width,g.height,h,g.data):i.compressedTexImage2D(e.TEXTURE_2D,t,M,g.width,g.height,0,g.data):E("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):R?U&&i.texSubImage2D(e.TEXTURE_2D,t,0,0,g.width,g.height,h,_,g.data):i.texImage2D(e.TEXTURE_2D,t,M,g.width,g.height,0,h,_,g.data)}else if(n.isDataArrayTexture)if(R){if(L&&i.texStorage3D(e.TEXTURE_2D_ARRAY,D,M,m.width,m.height,m.depth),U)if(n.layerUpdates.size>0){const t=bt(m.width,m.height,n.format,n.type);for(const r of n.layerUpdates){const n=m.data.subarray(r*t/m.data.BYTES_PER_ELEMENT,(r+1)*t/m.data.BYTES_PER_ELEMENT);i.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,r,m.width,m.height,1,h,_,n)}n.clearLayerUpdates()}else i.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,m.width,m.height,m.depth,h,_,m.data)}else i.texImage3D(e.TEXTURE_2D_ARRAY,0,M,m.width,m.height,m.depth,0,h,_,m.data);else if(n.isData3DTexture)R?(L&&i.texStorage3D(e.TEXTURE_3D,D,M,m.width,m.height,m.depth),U&&i.texSubImage3D(e.TEXTURE_3D,0,0,0,0,m.width,m.height,m.depth,h,_,m.data)):i.texImage3D(e.TEXTURE_3D,0,M,m.width,m.height,m.depth,0,h,_,m.data);else if(n.isFramebufferTexture){if(L)if(R)i.texStorage2D(e.TEXTURE_2D,D,M,m.width,m.height);else{let t=m.width,n=m.height;for(let r=0;r<D;r++)i.texImage2D(e.TEXTURE_2D,r,M,t,n,0,h,_,null),t>>=1,n>>=1}}else if(T.length>0){if(R&&L){const t=ee(T[0]);i.texStorage2D(e.TEXTURE_2D,D,M,t.width,t.height)}for(let t=0,n=T.length;t<n;t++)g=T[t],R?U&&i.texSubImage2D(e.TEXTURE_2D,t,0,0,h,_,g):i.texImage2D(e.TEXTURE_2D,t,M,h,_,g);n.generateMipmaps=!1}else if(R){if(L){const t=ee(m);i.texStorage2D(e.TEXTURE_2D,D,M,t.width,t.height)}U&&i.texSubImage2D(e.TEXTURE_2D,0,0,0,h,_,m)}else i.texImage2D(e.TEXTURE_2D,0,M,h,_,m);S(n)&&A(l),u.__version=d.version,n.onUpdate&&n.onUpdate(n)}t.__version=n.version}function X(t,n,a,s,c,d){const u=o.convert(a.format,a.colorSpace),f=o.convert(a.type),p=b(a.internalFormat,u,f,a.colorSpace),m=r.get(n),h=r.get(a);if(h.__renderTarget=n,!m.__hasExternalTextures){const t=Math.max(1,n.width>>d),r=Math.max(1,n.height>>d);c===e.TEXTURE_3D||c===e.TEXTURE_2D_ARRAY?i.texImage3D(c,d,p,t,r,n.depth,0,u,f,null):i.texImage2D(c,d,p,t,r,0,u,f,null)}i.bindFramebuffer(e.FRAMEBUFFER,t),Q(n)?l.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,s,c,h.__webglTexture,0,$(n)):(c===e.TEXTURE_2D||c>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&c<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,s,c,h.__webglTexture,d),i.bindFramebuffer(e.FRAMEBUFFER,null)}function Y(t,n,i){if(e.bindRenderbuffer(e.RENDERBUFFER,t),n.depthBuffer){const r=n.depthTexture,a=r&&r.isDepthTexture?r.type:null,o=C(n.stencilBuffer,a),s=n.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;Q(n)?l.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,$(n),o,n.width,n.height):i?e.renderbufferStorageMultisample(e.RENDERBUFFER,$(n),o,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,o,n.width,n.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,s,e.RENDERBUFFER,t)}else{const t=n.textures;for(let r=0;r<t.length;r++){const a=t[r],s=o.convert(a.format,a.colorSpace),c=o.convert(a.type),d=b(a.internalFormat,s,c,a.colorSpace);Q(n)?l.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,$(n),d,n.width,n.height):i?e.renderbufferStorageMultisample(e.RENDERBUFFER,$(n),d,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,d,n.width,n.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function K(t,n,a){const s=!0===n.isWebGLCubeRenderTarget;if(i.bindFramebuffer(e.FRAMEBUFFER,t),!n.depthTexture||!n.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const c=r.get(n.depthTexture);if(c.__renderTarget=n,c.__webglTexture&&n.depthTexture.image.width===n.width&&n.depthTexture.image.height===n.height||(n.depthTexture.image.width=n.width,n.depthTexture.image.height=n.height,n.depthTexture.needsUpdate=!0),s){if(void 0===c.__webglInit&&(c.__webglInit=!0,n.depthTexture.addEventListener("dispose",L)),void 0===c.__webglTexture){c.__webglTexture=e.createTexture(),i.bindTexture(e.TEXTURE_CUBE_MAP,c.__webglTexture),V(e.TEXTURE_CUBE_MAP,n.depthTexture);const t=o.convert(n.depthTexture.format),r=o.convert(n.depthTexture.type);let a;n.depthTexture.format===be?a=e.DEPTH_COMPONENT24:n.depthTexture.format===Rt&&(a=e.DEPTH24_STENCIL8);for(let i=0;i<6;i++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+i,0,a,n.width,n.height,0,t,r,null)}}else N(n.depthTexture,0);const d=c.__webglTexture,u=$(n),f=s?e.TEXTURE_CUBE_MAP_POSITIVE_X+a:e.TEXTURE_2D,p=n.depthTexture.format===Rt?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(n.depthTexture.format===be)Q(n)?l.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,p,f,d,0,u):e.framebufferTexture2D(e.FRAMEBUFFER,p,f,d,0);else{if(n.depthTexture.format!==Rt)throw new Error("Unknown depthTexture format");Q(n)?l.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,p,f,d,0,u):e.framebufferTexture2D(e.FRAMEBUFFER,p,f,d,0)}}function q(t){const n=r.get(t),a=!0===t.isWebGLCubeRenderTarget;if(n.__boundDepthTexture!==t.depthTexture){const e=t.depthTexture;if(n.__depthDisposeCallback&&n.__depthDisposeCallback(),e){const t=()=>{delete n.__boundDepthTexture,delete n.__depthDisposeCallback,e.removeEventListener("dispose",t)};e.addEventListener("dispose",t),n.__depthDisposeCallback=t}n.__boundDepthTexture=e}if(t.depthTexture&&!n.__autoAllocateDepthBuffer)if(a)for(let e=0;e<6;e++)K(n.__webglFramebuffer[e],t,e);else{const e=t.texture.mipmaps;e&&e.length>0?K(n.__webglFramebuffer[0],t,0):K(n.__webglFramebuffer,t,0)}else if(a){n.__webglDepthbuffer=[];for(let r=0;r<6;r++)if(i.bindFramebuffer(e.FRAMEBUFFER,n.__webglFramebuffer[r]),void 0===n.__webglDepthbuffer[r])n.__webglDepthbuffer[r]=e.createRenderbuffer(),Y(n.__webglDepthbuffer[r],t,!1);else{const i=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,a=n.__webglDepthbuffer[r];e.bindRenderbuffer(e.RENDERBUFFER,a),e.framebufferRenderbuffer(e.FRAMEBUFFER,i,e.RENDERBUFFER,a)}}else{const r=t.texture.mipmaps;if(r&&r.length>0?i.bindFramebuffer(e.FRAMEBUFFER,n.__webglFramebuffer[0]):i.bindFramebuffer(e.FRAMEBUFFER,n.__webglFramebuffer),void 0===n.__webglDepthbuffer)n.__webglDepthbuffer=e.createRenderbuffer(),Y(n.__webglDepthbuffer,t,!1);else{const i=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,r=n.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,r),e.framebufferRenderbuffer(e.FRAMEBUFFER,i,e.RENDERBUFFER,r)}}i.bindFramebuffer(e.FRAMEBUFFER,null)}const j=[],Z=[];function $(e){return Math.min(a.maxSamples,e.samples)}function Q(e){const t=r.get(e);return e.samples>0&&!0===n.has("WEBGL_multisampled_render_to_texture")&&!1!==t.__useRenderToTexture}function J(e,t){const n=e.colorSpace,i=e.format,r=e.type;return!0===e.isCompressedTexture||!0===e.isVideoTexture||n!==F&&n!==At&&(p.getTransfer(n)===m?i===x&&r===M||E("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):w("WebGLTextures: Unsupported texture color space:",n)),t}function ee(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement?(d.width=e.naturalWidth||e.width,d.height=e.naturalHeight||e.height):"undefined"!=typeof VideoFrame&&e instanceof VideoFrame?(d.width=e.displayWidth,d.height=e.displayHeight):(d.width=e.width,d.height=e.height),d}this.allocateTextureUnit=function(){const e=I;return e>=a.maxTextures&&E("WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+a.maxTextures),I+=1,e},this.resetTextureUnits=function(){I=0},this.setTexture2D=N,this.setTexture2DArray=function(t,n){const a=r.get(t);!1===t.isRenderTargetTexture&&t.version>0&&a.__version!==t.version?k(a,t,n):(t.isExternalTexture&&(a.__webglTexture=t.sourceTexture?t.sourceTexture:null),i.bindTexture(e.TEXTURE_2D_ARRAY,a.__webglTexture,e.TEXTURE0+n))},this.setTexture3D=function(t,n){const a=r.get(t);!1===t.isRenderTargetTexture&&t.version>0&&a.__version!==t.version?k(a,t,n):i.bindTexture(e.TEXTURE_3D,a.__webglTexture,e.TEXTURE0+n)},this.setTextureCube=function(t,n){const s=r.get(t);!0!==t.isCubeDepthTexture&&t.version>0&&s.__version!==t.version?function(t,n,s){if(6!==n.image.length)return;const l=W(t,n),c=n.source;i.bindTexture(e.TEXTURE_CUBE_MAP,t.__webglTexture,e.TEXTURE0+s);const d=r.get(c);if(c.version!==d.__version||!0===l){i.activeTexture(e.TEXTURE0+s);const t=p.getPrimaries(p.workingColorSpace),r=n.colorSpace===At?null:p.getPrimaries(n.colorSpace),u=n.colorSpace===At||t===r?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,n.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,n.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,u);const f=n.isCompressedTexture||n.image[0].isCompressedTexture,m=n.image[0]&&n.image[0].isDataTexture,h=[];for(let e=0;e<6;e++)h[e]=f||m?m?n.image[e].image:n.image[e]:v(n.image[e],!0,a.maxCubemapSize),h[e]=J(n,h[e]);const _=h[0],g=o.convert(n.format,n.colorSpace),M=o.convert(n.type),T=b(n.internalFormat,g,M,n.colorSpace),R=!0!==n.isVideoTexture,C=void 0===d.__version||!0===l,L=c.dataReady;let U,D=P(n,_);if(V(e.TEXTURE_CUBE_MAP,n),f){R&&C&&i.texStorage2D(e.TEXTURE_CUBE_MAP,D,T,_.width,_.height);for(let t=0;t<6;t++){U=h[t].mipmaps;for(let r=0;r<U.length;r++){const a=U[r];n.format!==x?null!==g?R?L&&i.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r,0,0,a.width,a.height,g,a.data):i.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r,T,a.width,a.height,0,a.data):E("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):R?L&&i.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r,0,0,a.width,a.height,g,M,a.data):i.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r,T,a.width,a.height,0,g,M,a.data)}}}else{if(U=n.mipmaps,R&&C){U.length>0&&D++;const t=ee(h[0]);i.texStorage2D(e.TEXTURE_CUBE_MAP,D,T,t.width,t.height)}for(let t=0;t<6;t++)if(m){R?L&&i.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,h[t].width,h[t].height,g,M,h[t].data):i.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,T,h[t].width,h[t].height,0,g,M,h[t].data);for(let n=0;n<U.length;n++){const r=U[n].image[t].image;R?L&&i.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,n+1,0,0,r.width,r.height,g,M,r.data):i.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,n+1,T,r.width,r.height,0,g,M,r.data)}}else{R?L&&i.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,g,M,h[t]):i.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,T,g,M,h[t]);for(let n=0;n<U.length;n++){const r=U[n];R?L&&i.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,n+1,0,0,g,M,r.image[t]):i.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,n+1,T,g,M,r.image[t])}}}S(n)&&A(e.TEXTURE_CUBE_MAP),d.__version=c.version,n.onUpdate&&n.onUpdate(n)}t.__version=n.version}(s,t,n):i.bindTexture(e.TEXTURE_CUBE_MAP,s.__webglTexture,e.TEXTURE0+n)},this.rebindTextures=function(t,n,i){const a=r.get(t);void 0!==n&&X(a.__webglFramebuffer,t,t.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0),void 0!==i&&q(t)},this.setupRenderTarget=function(t){const n=t.texture,a=r.get(t),l=r.get(n);t.addEventListener("dispose",U);const c=t.textures,d=!0===t.isWebGLCubeRenderTarget,u=c.length>1;if(u||(void 0===l.__webglTexture&&(l.__webglTexture=e.createTexture()),l.__version=n.version,s.memory.textures++),d){a.__webglFramebuffer=[];for(let t=0;t<6;t++)if(n.mipmaps&&n.mipmaps.length>0){a.__webglFramebuffer[t]=[];for(let i=0;i<n.mipmaps.length;i++)a.__webglFramebuffer[t][i]=e.createFramebuffer()}else a.__webglFramebuffer[t]=e.createFramebuffer()}else{if(n.mipmaps&&n.mipmaps.length>0){a.__webglFramebuffer=[];for(let t=0;t<n.mipmaps.length;t++)a.__webglFramebuffer[t]=e.createFramebuffer()}else a.__webglFramebuffer=e.createFramebuffer();if(u)for(let t=0,n=c.length;t<n;t++){const n=r.get(c[t]);void 0===n.__webglTexture&&(n.__webglTexture=e.createTexture(),s.memory.textures++)}if(t.samples>0&&!1===Q(t)){a.__webglMultisampledFramebuffer=e.createFramebuffer(),a.__webglColorRenderbuffer=[],i.bindFramebuffer(e.FRAMEBUFFER,a.__webglMultisampledFramebuffer);for(let n=0;n<c.length;n++){const i=c[n];a.__webglColorRenderbuffer[n]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,a.__webglColorRenderbuffer[n]);const r=o.convert(i.format,i.colorSpace),s=o.convert(i.type),l=b(i.internalFormat,r,s,i.colorSpace,!0===t.isXRRenderTarget),d=$(t);e.renderbufferStorageMultisample(e.RENDERBUFFER,d,l,t.width,t.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+n,e.RENDERBUFFER,a.__webglColorRenderbuffer[n])}e.bindRenderbuffer(e.RENDERBUFFER,null),t.depthBuffer&&(a.__webglDepthRenderbuffer=e.createRenderbuffer(),Y(a.__webglDepthRenderbuffer,t,!0)),i.bindFramebuffer(e.FRAMEBUFFER,null)}}if(d){i.bindTexture(e.TEXTURE_CUBE_MAP,l.__webglTexture),V(e.TEXTURE_CUBE_MAP,n);for(let i=0;i<6;i++)if(n.mipmaps&&n.mipmaps.length>0)for(let r=0;r<n.mipmaps.length;r++)X(a.__webglFramebuffer[i][r],t,n,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+i,r);else X(a.__webglFramebuffer[i],t,n,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+i,0);S(n)&&A(e.TEXTURE_CUBE_MAP),i.unbindTexture()}else if(u){for(let n=0,o=c.length;n<o;n++){const o=c[n],s=r.get(o);let l=e.TEXTURE_2D;(t.isWebGL3DRenderTarget||t.isWebGLArrayRenderTarget)&&(l=t.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY),i.bindTexture(l,s.__webglTexture),V(l,o),X(a.__webglFramebuffer,t,o,e.COLOR_ATTACHMENT0+n,l,0),S(o)&&A(l)}i.unbindTexture()}else{let r=e.TEXTURE_2D;if((t.isWebGL3DRenderTarget||t.isWebGLArrayRenderTarget)&&(r=t.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY),i.bindTexture(r,l.__webglTexture),V(r,n),n.mipmaps&&n.mipmaps.length>0)for(let i=0;i<n.mipmaps.length;i++)X(a.__webglFramebuffer[i],t,n,e.COLOR_ATTACHMENT0,r,i);else X(a.__webglFramebuffer,t,n,e.COLOR_ATTACHMENT0,r,0);S(n)&&A(r),i.unbindTexture()}t.depthBuffer&&q(t)},this.updateRenderTargetMipmap=function(e){const t=e.textures;for(let n=0,a=t.length;n<a;n++){const a=t[n];if(S(a)){const t=R(e),n=r.get(a).__webglTexture;i.bindTexture(t,n),A(t),i.unbindTexture()}}},this.updateMultisampleRenderTarget=function(t){if(t.samples>0)if(!1===Q(t)){const n=t.textures,a=t.width,o=t.height;let s=e.COLOR_BUFFER_BIT;const l=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,d=r.get(t),u=n.length>1;if(u)for(let t=0;t<n.length;t++)i.bindFramebuffer(e.FRAMEBUFFER,d.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.RENDERBUFFER,null),i.bindFramebuffer(e.FRAMEBUFFER,d.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.TEXTURE_2D,null,0);i.bindFramebuffer(e.READ_FRAMEBUFFER,d.__webglMultisampledFramebuffer);const f=t.texture.mipmaps;f&&f.length>0?i.bindFramebuffer(e.DRAW_FRAMEBUFFER,d.__webglFramebuffer[0]):i.bindFramebuffer(e.DRAW_FRAMEBUFFER,d.__webglFramebuffer);for(let i=0;i<n.length;i++){if(t.resolveDepthBuffer&&(t.depthBuffer&&(s|=e.DEPTH_BUFFER_BIT),t.stencilBuffer&&t.resolveStencilBuffer&&(s|=e.STENCIL_BUFFER_BIT)),u){e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,d.__webglColorRenderbuffer[i]);const t=r.get(n[i]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0)}e.blitFramebuffer(0,0,a,o,0,0,a,o,s,e.NEAREST),!0===c&&(j.length=0,Z.length=0,j.push(e.COLOR_ATTACHMENT0+i),t.depthBuffer&&!1===t.resolveDepthBuffer&&(j.push(l),Z.push(l),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,Z)),e.invalidateFramebuffer(e.READ_FRAMEBUFFER,j))}if(i.bindFramebuffer(e.READ_FRAMEBUFFER,null),i.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),u)for(let t=0;t<n.length;t++){i.bindFramebuffer(e.FRAMEBUFFER,d.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.RENDERBUFFER,d.__webglColorRenderbuffer[t]);const a=r.get(n[t]).__webglTexture;i.bindFramebuffer(e.FRAMEBUFFER,d.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.TEXTURE_2D,a,0)}i.bindFramebuffer(e.DRAW_FRAMEBUFFER,d.__webglMultisampledFramebuffer)}else if(t.depthBuffer&&!1===t.resolveDepthBuffer&&c){const n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[n])}},this.setupDepthRenderbuffer=q,this.setupFrameBufferTexture=X,this.useMultisampledRTT=Q,this.isReversedDepthBuffer=function(){return i.buffers.depth.getReversed()}}function Ma(e,t){return{convert:function(n,i=At){let r;const a=p.getTransfer(i);if(n===M)return e.UNSIGNED_BYTE;if(n===Ut)return e.UNSIGNED_SHORT_4_4_4_4;if(n===Dt)return e.UNSIGNED_SHORT_5_5_5_1;if(n===wt)return e.UNSIGNED_INT_5_9_9_9_REV;if(n===It)return e.UNSIGNED_INT_10F_11F_11F_REV;if(n===Nt)return e.BYTE;if(n===yt)return e.SHORT;if(n===Pt)return e.UNSIGNED_SHORT;if(n===v)return e.INT;if(n===Le)return e.UNSIGNED_INT;if(n===T)return e.FLOAT;if(n===S)return e.HALF_FLOAT;if(n===Ft)return e.ALPHA;if(n===Ot)return e.RGB;if(n===x)return e.RGBA;if(n===be)return e.DEPTH_COMPONENT;if(n===Rt)return e.DEPTH_STENCIL;if(n===Bt)return e.RED;if(n===Gt)return e.RED_INTEGER;if(n===Me)return e.RG;if(n===Ht)return e.RG_INTEGER;if(n===Vt)return e.RGBA_INTEGER;if(n===Wt||n===zt||n===kt||n===Xt)if(a===m){if(r=t.get("WEBGL_compressed_texture_s3tc_srgb"),null===r)return null;if(n===Wt)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===zt)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===kt)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Xt)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(r=t.get("WEBGL_compressed_texture_s3tc"),null===r)return null;if(n===Wt)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===zt)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===kt)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Xt)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(n===Yt||n===Kt||n===qt||n===jt){if(r=t.get("WEBGL_compressed_texture_pvrtc"),null===r)return null;if(n===Yt)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Kt)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===qt)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===jt)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(n===Zt||n===$t||n===Qt||n===Jt||n===en||n===tn||n===nn){if(r=t.get("WEBGL_compressed_texture_etc"),null===r)return null;if(n===Zt||n===$t)return a===m?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===Qt)return a===m?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===Jt)return r.COMPRESSED_R11_EAC;if(n===en)return r.COMPRESSED_SIGNED_R11_EAC;if(n===tn)return r.COMPRESSED_RG11_EAC;if(n===nn)return r.COMPRESSED_SIGNED_RG11_EAC}if(n===rn||n===an||n===on||n===sn||n===ln||n===cn||n===dn||n===un||n===fn||n===pn||n===mn||n===hn||n===_n||n===gn){if(r=t.get("WEBGL_compressed_texture_astc"),null===r)return null;if(n===rn)return a===m?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===an)return a===m?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===on)return a===m?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===sn)return a===m?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===ln)return a===m?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===cn)return a===m?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===dn)return a===m?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===un)return a===m?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===fn)return a===m?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===pn)return a===m?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===mn)return a===m?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===hn)return a===m?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===_n)return a===m?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===gn)return a===m?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}if(n===vn||n===En||n===Sn){if(r=t.get("EXT_texture_compression_bptc"),null===r)return null;if(n===vn)return a===m?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===En)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Sn)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}if(n===Mn||n===Tn||n===xn||n===An){if(r=t.get("EXT_texture_compression_rgtc"),null===r)return null;if(n===Mn)return r.COMPRESSED_RED_RGTC1_EXT;if(n===Tn)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===xn)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===An)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return n===Ct?e.UNSIGNED_INT_24_8:void 0!==e[n]?e[n]:null}}}class Ta{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(null===this.texture){const n=new Rn(e.texture);e.depthNear===t.depthNear&&e.depthFar===t.depthFar||(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(null!==this.texture&&null===this.mesh){const t=e.cameras[0].viewport,n=new l({vertexShader:"\nvoid main() {\n\n\tgl_Position = vec4( position, 1.0 );\n\n}",fragmentShader:"\nuniform sampler2DArray depthColor;\nuniform float depthWidth;\nuniform float depthHeight;\n\nvoid main() {\n\n\tvec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );\n\n\tif ( coord.x >= 1.0 ) {\n\n\t\tgl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;\n\n\t} else {\n\n\t\tgl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;\n\n\t}\n\n}",uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new o(new h(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class xa extends bn{constructor(e,n){super();const i=this;let a=null,o=1,s=null,l="local-floor",c=1,d=null,u=null,f=null,p=null,m=null,h=null;const _="undefined"!=typeof XRWebGLBinding,g=new Ta,v={},S=n.getContextAttributes();let T=null,A=null;const R=[],b=[],C=new t;let P=null;const U=new L;U.viewport=new Y;const D=new L;D.viewport=new Y;const w=[U,D],I=new Cn;let y=null,F=null;function O(e){const t=b.indexOf(e.inputSource);if(-1===t)return;const n=R[t];void 0!==n&&(n.update(e.inputSource,e.frame,d||s),n.dispatchEvent({type:e.type,data:e.inputSource}))}function B(){a.removeEventListener("select",O),a.removeEventListener("selectstart",O),a.removeEventListener("selectend",O),a.removeEventListener("squeeze",O),a.removeEventListener("squeezestart",O),a.removeEventListener("squeezeend",O),a.removeEventListener("end",B),a.removeEventListener("inputsourceschange",G);for(let e=0;e<R.length;e++){const t=b[e];null!==t&&(b[e]=null,R[e]&&R[e].disconnect(t))}y=null,F=null,g.reset();for(const e in v)delete v[e];e.setRenderTarget(T),m=null,p=null,f=null,a=null,A=null,k.stop(),i.isPresenting=!1,e.setPixelRatio(P),e.setSize(C.width,C.height,!1),i.dispatchEvent({type:"sessionend"})}function G(e){for(let t=0;t<e.removed.length;t++){const n=e.removed[t],i=b.indexOf(n);i>=0&&(b[i]=null,R[i]&&R[i].disconnect(n))}for(let t=0;t<e.added.length;t++){const n=e.added[t];let i=b.indexOf(n);if(-1===i){for(let e=0;e<R.length;e++){if(e>=b.length){b.push(n),i=e;break}if(null===b[e]){b[e]=n,i=e;break}}if(-1===i)break}const r=R[i];r&&r.connect(n)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.controllerAutoUpdate=!0,this.getController=function(e){let t=R[e];return void 0===t&&(t=new Pn,R[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=R[e];return void 0===t&&(t=new Pn,R[e]=t),t.getGripSpace()},this.getHand=function(e){let t=R[e];return void 0===t&&(t=new Pn,R[e]=t),t.getHandSpace()},this.setFramebufferScaleFactor=function(e){o=e,!0===i.isPresenting&&E("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){l=e,!0===i.isPresenting&&E("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return d||s},this.setReferenceSpace=function(e){d=e},this.getBaseLayer=function(){return null!==p?p:m},this.getBinding=function(){return null===f&&_&&(f=new XRWebGLBinding(a,n)),f},this.getFrame=function(){return h},this.getSession=function(){return a},this.setSession=async function(t){if(a=t,null!==a){T=e.getRenderTarget(),a.addEventListener("select",O),a.addEventListener("selectstart",O),a.addEventListener("selectend",O),a.addEventListener("squeeze",O),a.addEventListener("squeezestart",O),a.addEventListener("squeezeend",O),a.addEventListener("end",B),a.addEventListener("inputsourceschange",G),!0!==S.xrCompatible&&await n.makeXRCompatible(),P=e.getPixelRatio(),e.getSize(C);if(_&&"createProjectionLayer"in XRWebGLBinding.prototype){let t=null,i=null,r=null;S.depth&&(r=S.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,t=S.stencil?Rt:be,i=S.stencil?Ct:Le);const s={colorFormat:n.RGBA8,depthFormat:r,scaleFactor:o};f=this.getBinding(),p=f.createProjectionLayer(s),a.updateRenderState({layers:[p]}),e.setPixelRatio(1),e.setSize(p.textureWidth,p.textureHeight,!1),A=new N(p.textureWidth,p.textureHeight,{format:x,type:M,depthTexture:new oe(p.textureWidth,p.textureHeight,i,void 0,void 0,void 0,void 0,void 0,void 0,t),stencilBuffer:S.stencil,colorSpace:e.outputColorSpace,samples:S.antialias?4:0,resolveDepthBuffer:!1===p.ignoreDepthValues,resolveStencilBuffer:!1===p.ignoreDepthValues})}else{const t={antialias:S.antialias,alpha:!0,depth:S.depth,stencil:S.stencil,framebufferScaleFactor:o};m=new XRWebGLLayer(a,n,t),a.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),A=new N(m.framebufferWidth,m.framebufferHeight,{format:x,type:M,colorSpace:e.outputColorSpace,stencilBuffer:S.stencil,resolveDepthBuffer:!1===m.ignoreDepthValues,resolveStencilBuffer:!1===m.ignoreDepthValues})}A.isXRRenderTarget=!0,this.setFoveation(c),d=null,s=await a.requestReferenceSpace(l),k.setContext(a),k.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==a)return a.environmentBlendMode},this.getDepthTexture=function(){return g.getDepthTexture()};const H=new r,V=new r;function W(e,t){null===t?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(null===a)return;let t=e.near,n=e.far;null!==g.texture&&(g.depthNear>0&&(t=g.depthNear),g.depthFar>0&&(n=g.depthFar)),I.near=D.near=U.near=t,I.far=D.far=U.far=n,y===I.near&&F===I.far||(a.updateRenderState({depthNear:I.near,depthFar:I.far}),y=I.near,F=I.far),I.layers.mask=6|e.layers.mask,U.layers.mask=-5&I.layers.mask,D.layers.mask=-3&I.layers.mask;const i=e.parent,r=I.cameras;W(I,i);for(let e=0;e<r.length;e++)W(r[e],i);2===r.length?function(e,t,n){H.setFromMatrixPosition(t.matrixWorld),V.setFromMatrixPosition(n.matrixWorld);const i=H.distanceTo(V),r=t.projectionMatrix.elements,a=n.projectionMatrix.elements,o=r[14]/(r[10]-1),s=r[14]/(r[10]+1),l=(r[9]+1)/r[5],c=(r[9]-1)/r[5],d=(r[8]-1)/r[0],u=(a[8]+1)/a[0],f=o*d,p=o*u,m=i/(-d+u),h=m*-d;if(t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(h),e.translateZ(m),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert(),-1===r[10])e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse);else{const t=o+m,n=s+m,r=f-h,a=p+(i-h),d=l*s/n*t,u=c*s/n*t;e.projectionMatrix.makePerspective(r,a,d,u,t,n),e.projectionMatrixInverse.copy(e.projectionMatrix).invert()}}(I,U,D):I.projectionMatrix.copy(U.projectionMatrix),function(e,t,n){null===n?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=2*Ln*Math.atan(1/e.projectionMatrix.elements[5]),e.zoom=1)}(e,I,i)},this.getCamera=function(){return I},this.getFoveation=function(){if(null!==p||null!==m)return c},this.setFoveation=function(e){c=e,null!==p&&(p.fixedFoveation=e),null!==m&&void 0!==m.fixedFoveation&&(m.fixedFoveation=e)},this.hasDepthSensing=function(){return null!==g.texture},this.getDepthSensingMesh=function(){return g.getMesh(I)},this.getCameraTexture=function(e){return v[e]};let z=null;const k=new On;k.setAnimationLoop(function(t,n){if(u=n.getViewerPose(d||s),h=n,null!==u){const t=u.views;null!==m&&(e.setRenderTargetFramebuffer(A,m.framebuffer),e.setRenderTarget(A));let n=!1;t.length!==I.cameras.length&&(I.cameras.length=0,n=!0);for(let i=0;i<t.length;i++){const r=t[i];let a=null;if(null!==m)a=m.getViewport(r);else{const t=f.getViewSubImage(p,r);a=t.viewport,0===i&&(e.setRenderTargetTextures(A,t.colorTexture,t.depthStencilTexture),e.setRenderTarget(A))}let o=w[i];void 0===o&&(o=new L,o.layers.enable(i),o.viewport=new Y,w[i]=o),o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.quaternion,o.scale),o.projectionMatrix.fromArray(r.projectionMatrix),o.projectionMatrixInverse.copy(o.projectionMatrix).invert(),o.viewport.set(a.x,a.y,a.width,a.height),0===i&&(I.matrix.copy(o.matrix),I.matrix.decompose(I.position,I.quaternion,I.scale)),!0===n&&I.cameras.push(o)}const r=a.enabledFeatures;if(r&&r.includes("depth-sensing")&&"gpu-optimized"==a.depthUsage&&_){f=i.getBinding();const e=f.getDepthInformation(t[0]);e&&e.isValid&&e.texture&&g.init(e,a.renderState)}if(r&&r.includes("camera-access")&&_){e.state.unbindTexture(),f=i.getBinding();for(let e=0;e<t.length;e++){const n=t[e].camera;if(n){let e=v[n];e||(e=new Rn,v[n]=e);const t=f.getCameraImage(n);e.sourceTexture=t}}}}if(i.controllerAutoUpdate)for(let e=0;e<R.length;e++){const t=b[e],i=R[e];null!==t&&void 0!==i&&i.update(t,n,d||s)}z&&z(t,n),n.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:n}),h=null}),this.setAnimationLoop=function(e){z=e},this.dispose=function(){}}}const Aa=new u,Ra=new f;function ba(e,t){function n(e,t){!0===e.matrixAutoUpdate&&e.updateMatrix(),t.value.copy(e.matrix)}function i(e,i){e.opacity.value=i.opacity,i.color&&e.diffuse.value.copy(i.color),i.emissive&&e.emissive.value.copy(i.emissive).multiplyScalar(i.emissiveIntensity),i.map&&(e.map.value=i.map,n(i.map,e.mapTransform)),i.alphaMap&&(e.alphaMap.value=i.alphaMap,n(i.alphaMap,e.alphaMapTransform)),i.bumpMap&&(e.bumpMap.value=i.bumpMap,n(i.bumpMap,e.bumpMapTransform),e.bumpScale.value=i.bumpScale,i.side===c&&(e.bumpScale.value*=-1)),i.normalMap&&(e.normalMap.value=i.normalMap,n(i.normalMap,e.normalMapTransform),e.normalScale.value.copy(i.normalScale),i.side===c&&e.normalScale.value.negate()),i.displacementMap&&(e.displacementMap.value=i.displacementMap,n(i.displacementMap,e.displacementMapTransform),e.displacementScale.value=i.displacementScale,e.displacementBias.value=i.displacementBias),i.emissiveMap&&(e.emissiveMap.value=i.emissiveMap,n(i.emissiveMap,e.emissiveMapTransform)),i.specularMap&&(e.specularMap.value=i.specularMap,n(i.specularMap,e.specularMapTransform)),i.alphaTest>0&&(e.alphaTest.value=i.alphaTest);const r=t.get(i),a=r.envMap,o=r.envMapRotation;a&&(e.envMap.value=a,Aa.copy(o),Aa.x*=-1,Aa.y*=-1,Aa.z*=-1,a.isCubeTexture&&!1===a.isRenderTargetTexture&&(Aa.y*=-1,Aa.z*=-1),e.envMapRotation.value.setFromMatrix4(Ra.makeRotationFromEuler(Aa)),e.flipEnvMap.value=a.isCubeTexture&&!1===a.isRenderTargetTexture?-1:1,e.reflectivity.value=i.reflectivity,e.ior.value=i.ior,e.refractionRatio.value=i.refractionRatio),i.lightMap&&(e.lightMap.value=i.lightMap,e.lightMapIntensity.value=i.lightMapIntensity,n(i.lightMap,e.lightMapTransform)),i.aoMap&&(e.aoMap.value=i.aoMap,e.aoMapIntensity.value=i.aoMapIntensity,n(i.aoMap,e.aoMapTransform))}return{refreshFogUniforms:function(t,n){n.color.getRGB(t.fogColor.value,g(e)),n.isFog?(t.fogNear.value=n.near,t.fogFar.value=n.far):n.isFogExp2&&(t.fogDensity.value=n.density)},refreshMaterialUniforms:function(e,r,a,o,s){r.isMeshBasicMaterial?i(e,r):r.isMeshLambertMaterial?(i(e,r),r.envMap&&(e.envMapIntensity.value=r.envMapIntensity)):r.isMeshToonMaterial?(i(e,r),function(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}(e,r)):r.isMeshPhongMaterial?(i(e,r),function(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}(e,r),r.envMap&&(e.envMapIntensity.value=r.envMapIntensity)):r.isMeshStandardMaterial?(i(e,r),function(e,t){e.metalness.value=t.metalness,t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap,n(t.metalnessMap,e.metalnessMapTransform));e.roughness.value=t.roughness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap,n(t.roughnessMap,e.roughnessMapTransform));t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)}(e,r),r.isMeshPhysicalMaterial&&function(e,t,i){e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap,n(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,n(t.sheenRoughnessMap,e.sheenRoughnessMapTransform)));t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,n(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,n(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,n(t.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),t.side===c&&e.clearcoatNormalScale.value.negate()));t.dispersion>0&&(e.dispersion.value=t.dispersion);t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=t.iridescenceThicknessRange[1],t.iridescenceMap&&(e.iridescenceMap.value=t.iridescenceMap,n(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,n(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform)));t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=i.texture,e.transmissionSamplerSize.value.set(i.width,i.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap,n(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,n(t.thicknessMap,e.thicknessMapTransform)),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor));t.anisotropy>0&&(e.anisotropyVector.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation)),t.anisotropyMap&&(e.anisotropyMap.value=t.anisotropyMap,n(t.anisotropyMap,e.anisotropyMapTransform)));e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,n(t.specularColorMap,e.specularColorMapTransform));t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,n(t.specularIntensityMap,e.specularIntensityMapTransform))}(e,r,s)):r.isMeshMatcapMaterial?(i(e,r),function(e,t){t.matcap&&(e.matcap.value=t.matcap)}(e,r)):r.isMeshDepthMaterial?i(e,r):r.isMeshDistanceMaterial?(i(e,r),function(e,n){const i=t.get(n).light;e.referencePosition.value.setFromMatrixPosition(i.matrixWorld),e.nearDistance.value=i.shadow.camera.near,e.farDistance.value=i.shadow.camera.far}(e,r)):r.isMeshNormalMaterial?i(e,r):r.isLineBasicMaterial?(function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform))}(e,r),r.isLineDashedMaterial&&function(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(e,r)):r.isPointsMaterial?function(e,t,i,r){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*i,e.scale.value=.5*r,t.map&&(e.map.value=t.map,n(t.map,e.uvTransform));t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform));t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,r,a,o):r.isSpriteMaterial?function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform));t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform));t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,r):r.isShadowMaterial?(e.color.value.copy(r.color),e.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function Ca(e,t,n,i){let r={},a={},o=[];const s=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function l(e,t,n,i){const r=e.value,a=t+"_"+n;if(void 0===i[a])return i[a]="number"==typeof r||"boolean"==typeof r?r:r.clone(),!0;{const e=i[a];if("number"==typeof r||"boolean"==typeof r){if(e!==r)return i[a]=r,!0}else if(!1===e.equals(r))return e.copy(r),!0}return!1}function c(e){const t={boundary:0,storage:0};return"number"==typeof e||"boolean"==typeof e?(t.boundary=4,t.storage=4):e.isVector2?(t.boundary=8,t.storage=8):e.isVector3||e.isColor?(t.boundary=16,t.storage=12):e.isVector4?(t.boundary=16,t.storage=16):e.isMatrix3?(t.boundary=48,t.storage=48):e.isMatrix4?(t.boundary=64,t.storage=64):e.isTexture?E("WebGLRenderer: Texture samplers can not be part of an uniforms group."):E("WebGLRenderer: Unsupported uniform value type.",e),t}function d(t){const n=t.target;n.removeEventListener("dispose",d);const i=o.indexOf(n.__bindingPointIndex);o.splice(i,1),e.deleteBuffer(r[n.id]),delete r[n.id],delete a[n.id]}return{bind:function(e,t){const n=t.program;i.uniformBlockBinding(e,n)},update:function(n,u){let f=r[n.id];void 0===f&&(!function(e){const t=e.uniforms;let n=0;const i=16;for(let e=0,r=t.length;e<r;e++){const r=Array.isArray(t[e])?t[e]:[t[e]];for(let e=0,t=r.length;e<t;e++){const t=r[e],a=Array.isArray(t.value)?t.value:[t.value];for(let e=0,r=a.length;e<r;e++){const r=c(a[e]),o=n%i,s=o%r.boundary,l=o+s;n+=s,0!==l&&i-l<r.storage&&(n+=i-l),t.__data=new Float32Array(r.storage/Float32Array.BYTES_PER_ELEMENT),t.__offset=n,n+=r.storage}}}const r=n%i;r>0&&(n+=i-r);e.__size=n,e.__cache={}}(n),f=function(t){const n=function(){for(let e=0;e<s;e++)if(-1===o.indexOf(e))return o.push(e),e;return w("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}();t.__bindingPointIndex=n;const i=e.createBuffer(),r=t.__size,a=t.usage;return e.bindBuffer(e.UNIFORM_BUFFER,i),e.bufferData(e.UNIFORM_BUFFER,r,a),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,n,i),i}(n),r[n.id]=f,n.addEventListener("dispose",d));const p=u.program;i.updateUBOMapping(n,p);const m=t.render.frame;a[n.id]!==m&&(!function(t){const n=r[t.id],i=t.uniforms,a=t.__cache;e.bindBuffer(e.UNIFORM_BUFFER,n);for(let t=0,n=i.length;t<n;t++){const n=Array.isArray(i[t])?i[t]:[i[t]];for(let i=0,r=n.length;i<r;i++){const r=n[i];if(!0===l(r,t,i,a)){const t=r.__offset,n=Array.isArray(r.value)?r.value:[r.value];let i=0;for(let a=0;a<n.length;a++){const o=n[a],s=c(o);"number"==typeof o||"boolean"==typeof o?(r.__data[0]=o,e.bufferSubData(e.UNIFORM_BUFFER,t+i,r.__data)):o.isMatrix3?(r.__data[0]=o.elements[0],r.__data[1]=o.elements[1],r.__data[2]=o.elements[2],r.__data[3]=0,r.__data[4]=o.elements[3],r.__data[5]=o.elements[4],r.__data[6]=o.elements[5],r.__data[7]=0,r.__data[8]=o.elements[6],r.__data[9]=o.elements[7],r.__data[10]=o.elements[8],r.__data[11]=0):(o.toArray(r.__data,i),i+=s.storage/Float32Array.BYTES_PER_ELEMENT)}e.bufferSubData(e.UNIFORM_BUFFER,t,r.__data)}}}e.bindBuffer(e.UNIFORM_BUFFER,null)}(n),a[n.id]=m)},dispose:function(){for(const t in r)e.deleteBuffer(r[t]);o=[],r={},a={}}}}const Pa=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,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]);let La=null;class Ua{constructor(e={}){const{canvas:t=Dn(),context:i=null,depth:a=!0,stencil:o=!1,alpha:s=!1,antialias:l=!1,premultipliedAlpha:d=!0,preserveDrawingBuffer:u=!1,powerPreference:m="default",failIfMajorPerformanceCaveat:h=!1,reversedDepthBuffer:g=!1,outputBufferType:v=M}=e;let T;if(this.isWebGLRenderer=!0,null!==i){if("undefined"!=typeof WebGLRenderingContext&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");T=i.getContextAttributes().alpha}else T=s;const x=v,A=new Set([Vt,Ht,Gt]),R=new Set([M,Le,Pt,Ct,Ut,Dt]),b=new Uint32Array(4),C=new Int32Array(4);let P=null,L=null;const D=[],I=[];let y=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=U,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const B=this;let H=!1;this._outputColorSpace=wn;let V=0,W=0,k=null,X=-1,K=null;const q=new Y,j=new Y;let Z=null;const $=new n(0);let Q=0,J=t.width,ee=t.height,te=1,ne=null,ie=null;const re=new Y(0,0,J,ee),ae=new Y(0,0,J,ee);let oe=!1;const se=new Te;let le=!1,ce=!1;const de=new f,ue=new r,fe=new Y,pe={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let me=!1;function he(){return null===k?te:1}let ge,ve,Ee,Se,xe,Ae,Re,be,Ce,Pe,Ue,De,we,Ie,Ne,ye,Fe,Oe,Be,Ge,He,Ve,We,ze=i;function ke(e,n){return t.getContext(e,n)}try{const e={alpha:!0,depth:a,stencil:o,antialias:l,premultipliedAlpha:d,preserveDrawingBuffer:u,powerPreference:m,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${In}`),t.addEventListener("webglcontextlost",Ke,!1),t.addEventListener("webglcontextrestored",qe,!1),t.addEventListener("webglcontextcreationerror",je,!1),null===ze){const t="webgl2";if(ze=ke(t,e),null===ze)throw ke(t)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(e){throw w("WebGLRenderer: "+e.message),e}function Xe(){ge=new mi(ze),ge.init(),He=new Ma(ze,ge),ve=new qn(ze,ge,e,He),Ee=new Ea(ze,ge),ve.reversedDepthBuffer&&g&&Ee.buffers.depth.setReversed(!0),Se=new gi(ze),xe=new na,Ae=new Sa(ze,ge,Ee,xe,ve,He,Se),Re=new pi(B),be=new Bn(ze),Ve=new Yn(ze,be),Ce=new hi(ze,be,Se,Ve),Pe=new Ei(ze,Ce,be,Ve,Se),Oe=new vi(ze,ve,Ae),Ne=new jn(xe),Ue=new ta(B,Re,ge,ve,Ve,Ne),De=new ba(B,xe),we=new oa,Ie=new fa(ge),Fe=new Xn(B,Re,Ee,Pe,T,d),ye=new va(B,Pe,ve),We=new Ca(ze,Se,ve,Ee),Be=new Kn(ze,ge,Se),Ge=new _i(ze,ge,Se),Se.programs=Ue.programs,B.capabilities=ve,B.extensions=ge,B.properties=xe,B.renderLists=we,B.shadowMap=ye,B.state=Ee,B.info=Se}Xe(),x!==M&&(y=new Mi(x,t.width,t.height,a,o));const Ye=new xa(B,ze);function Ke(e){e.preventDefault(),Nn("WebGLRenderer: Context Lost."),H=!0}function qe(){Nn("WebGLRenderer: Context Restored."),H=!1;const e=Se.autoReset,t=ye.enabled,n=ye.autoUpdate,i=ye.needsUpdate,r=ye.type;Xe(),Se.autoReset=e,ye.enabled=t,ye.autoUpdate=n,ye.needsUpdate=i,ye.type=r}function je(e){w("WebGLRenderer: A WebGL context could not be created. Reason: ",e.statusMessage)}function Ze(e){const t=e.target;t.removeEventListener("dispose",Ze),function(e){(function(e){const t=xe.get(e).programs;void 0!==t&&(t.forEach(function(e){Ue.releaseProgram(e)}),e.isShaderMaterial&&Ue.releaseShaderCache(e))})(e),xe.remove(e)}(t)}function $e(e,t,n){!0===e.transparent&&e.side===_e&&!1===e.forceSinglePass?(e.side=c,e.needsUpdate=!0,st(e,t,n),e.side=_,e.needsUpdate=!0,st(e,t,n),e.side=_e):st(e,t,n)}this.xr=Ye,this.getContext=function(){return ze},this.getContextAttributes=function(){return ze.getContextAttributes()},this.forceContextLoss=function(){const e=ge.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){const e=ge.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return te},this.setPixelRatio=function(e){void 0!==e&&(te=e,this.setSize(J,ee,!1))},this.getSize=function(e){return e.set(J,ee)},this.setSize=function(e,n,i=!0){Ye.isPresenting?E("WebGLRenderer: Can't change size while VR device is presenting."):(J=e,ee=n,t.width=Math.floor(e*te),t.height=Math.floor(n*te),!0===i&&(t.style.width=e+"px",t.style.height=n+"px"),null!==y&&y.setSize(t.width,t.height),this.setViewport(0,0,e,n))},this.getDrawingBufferSize=function(e){return e.set(J*te,ee*te).floor()},this.setDrawingBufferSize=function(e,n,i){J=e,ee=n,te=i,t.width=Math.floor(e*i),t.height=Math.floor(n*i),this.setViewport(0,0,e,n)},this.setEffects=function(e){if(x!==M){if(e)for(let t=0;t<e.length;t++)if(!0===e[t].isOutputPass){console.warn("THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}y.setEffects(e||[])}else console.error("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.")},this.getCurrentViewport=function(e){return e.copy(q)},this.getViewport=function(e){return e.copy(re)},this.setViewport=function(e,t,n,i){e.isVector4?re.set(e.x,e.y,e.z,e.w):re.set(e,t,n,i),Ee.viewport(q.copy(re).multiplyScalar(te).round())},this.getScissor=function(e){return e.copy(ae)},this.setScissor=function(e,t,n,i){e.isVector4?ae.set(e.x,e.y,e.z,e.w):ae.set(e,t,n,i),Ee.scissor(j.copy(ae).multiplyScalar(te).round())},this.getScissorTest=function(){return oe},this.setScissorTest=function(e){Ee.setScissorTest(oe=e)},this.setOpaqueSort=function(e){ne=e},this.setTransparentSort=function(e){ie=e},this.getClearColor=function(e){return e.copy(Fe.getClearColor())},this.setClearColor=function(){Fe.setClearColor(...arguments)},this.getClearAlpha=function(){return Fe.getClearAlpha()},this.setClearAlpha=function(){Fe.setClearAlpha(...arguments)},this.clear=function(e=!0,t=!0,n=!0){let i=0;if(e){let e=!1;if(null!==k){const t=k.texture.format;e=A.has(t)}if(e){const e=k.texture.type,t=R.has(e),n=Fe.getClearColor(),i=Fe.getClearAlpha(),r=n.r,a=n.g,o=n.b;t?(b[0]=r,b[1]=a,b[2]=o,b[3]=i,ze.clearBufferuiv(ze.COLOR,0,b)):(C[0]=r,C[1]=a,C[2]=o,C[3]=i,ze.clearBufferiv(ze.COLOR,0,C))}else i|=ze.COLOR_BUFFER_BIT}t&&(i|=ze.DEPTH_BUFFER_BIT),n&&(i|=ze.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),0!==i&&ze.clear(i)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",Ke,!1),t.removeEventListener("webglcontextrestored",qe,!1),t.removeEventListener("webglcontextcreationerror",je,!1),Fe.dispose(),we.dispose(),Ie.dispose(),xe.dispose(),Re.dispose(),Pe.dispose(),Ve.dispose(),We.dispose(),Ue.dispose(),Ye.dispose(),Ye.removeEventListener("sessionstart",Je),Ye.removeEventListener("sessionend",et),tt.stop()},this.renderBufferDirect=function(e,t,n,i,r,a){null===t&&(t=pe);const o=r.isMesh&&r.matrixWorld.determinant()<0,s=function(e,t,n,i,r){!0!==t.isScene&&(t=pe);Ae.resetTextureUnits();const a=t.fog,o=i.isMeshStandardMaterial||i.isMeshLambertMaterial||i.isMeshPhongMaterial?t.environment:null,s=null===k?B.outputColorSpace:!0===k.isXRRenderTarget?k.texture.colorSpace:F,l=i.isMeshStandardMaterial||i.isMeshLambertMaterial&&!i.envMap||i.isMeshPhongMaterial&&!i.envMap,c=Re.get(i.envMap||o,l),d=!0===i.vertexColors&&!!n.attributes.color&&4===n.attributes.color.itemSize,u=!!n.attributes.tangent&&(!!i.normalMap||i.anisotropy>0),f=!!n.morphAttributes.position,p=!!n.morphAttributes.normal,m=!!n.morphAttributes.color;let h=U;i.toneMapped&&(null!==k&&!0!==k.isXRRenderTarget||(h=B.toneMapping));const _=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,g=void 0!==_?_.length:0,v=xe.get(i),E=L.state.lights;if(!0===le&&(!0===ce||e!==K)){const t=e===K&&i.id===X;Ne.setState(i,e,t)}let M=!1;i.version===v.__version?v.needsLights&&v.lightsStateVersion!==E.state.version||v.outputColorSpace!==s||r.isBatchedMesh&&!1===v.batching?M=!0:r.isBatchedMesh||!0!==v.batching?r.isBatchedMesh&&!0===v.batchingColor&&null===r.colorTexture||r.isBatchedMesh&&!1===v.batchingColor&&null!==r.colorTexture||r.isInstancedMesh&&!1===v.instancing?M=!0:r.isInstancedMesh||!0!==v.instancing?r.isSkinnedMesh&&!1===v.skinning?M=!0:r.isSkinnedMesh||!0!==v.skinning?r.isInstancedMesh&&!0===v.instancingColor&&null===r.instanceColor||r.isInstancedMesh&&!1===v.instancingColor&&null!==r.instanceColor||r.isInstancedMesh&&!0===v.instancingMorph&&null===r.morphTexture||r.isInstancedMesh&&!1===v.instancingMorph&&null!==r.morphTexture||v.envMap!==c||!0===i.fog&&v.fog!==a?M=!0:void 0===v.numClippingPlanes||v.numClippingPlanes===Ne.numPlanes&&v.numIntersection===Ne.numIntersection?(v.vertexAlphas!==d||v.vertexTangents!==u||v.morphTargets!==f||v.morphNormals!==p||v.morphColors!==m||v.toneMapping!==h||v.morphTargetsCount!==g)&&(M=!0):M=!0:M=!0:M=!0:M=!0:(M=!0,v.__version=i.version);let T=v.currentProgram;!0===M&&(T=st(i,t,r));let x=!1,A=!1,R=!1;const b=T.getUniforms(),C=v.uniforms;Ee.useProgram(T.program)&&(x=!0,A=!0,R=!0);(i.id!==X||i._forceRefresh)&&(X=i.id,A=!0,i._forceRefresh=!1);if(x||K!==e){Ee.buffers.depth.getReversed()&&!0!==e.reversedDepth&&(e._reversedDepth=!0,e.updateProjectionMatrix()),b.setValue(ze,"projectionMatrix",e.projectionMatrix),b.setValue(ze,"viewMatrix",e.matrixWorldInverse);const t=b.map.cameraPosition;void 0!==t&&t.setValue(ze,ue.setFromMatrixPosition(e.matrixWorld)),ve.logarithmicDepthBuffer&&b.setValue(ze,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial)&&b.setValue(ze,"isOrthographic",!0===e.isOrthographicCamera),K!==e&&(K=e,A=!0,R=!0)}v.needsLights&&(E.state.directionalShadowMap.length>0&&b.setValue(ze,"directionalShadowMap",E.state.directionalShadowMap,Ae),E.state.spotShadowMap.length>0&&b.setValue(ze,"spotShadowMap",E.state.spotShadowMap,Ae),E.state.pointShadowMap.length>0&&b.setValue(ze,"pointShadowMap",E.state.pointShadowMap,Ae));if(r.isSkinnedMesh){b.setOptional(ze,r,"bindMatrix"),b.setOptional(ze,r,"bindMatrixInverse");const e=r.skeleton;e&&(null===e.boneTexture&&e.computeBoneTexture(),b.setValue(ze,"boneTexture",e.boneTexture,Ae))}r.isBatchedMesh&&(b.setOptional(ze,r,"batchingTexture"),b.setValue(ze,"batchingTexture",r._matricesTexture,Ae),b.setOptional(ze,r,"batchingIdTexture"),b.setValue(ze,"batchingIdTexture",r._indirectTexture,Ae),b.setOptional(ze,r,"batchingColorTexture"),null!==r._colorsTexture&&b.setValue(ze,"batchingColorTexture",r._colorsTexture,Ae));const P=n.morphAttributes;void 0===P.position&&void 0===P.normal&&void 0===P.color||Oe.update(r,n,T);(A||v.receiveShadow!==r.receiveShadow)&&(v.receiveShadow=r.receiveShadow,b.setValue(ze,"receiveShadow",r.receiveShadow));(i.isMeshStandardMaterial||i.isMeshLambertMaterial||i.isMeshPhongMaterial)&&null===i.envMap&&null!==t.environment&&(C.envMapIntensity.value=t.environmentIntensity);void 0!==C.dfgLUT&&(C.dfgLUT.value=(null===La&&(La=new Un(Pa,16,16,Me,S),La.name="DFG_LUT",La.minFilter=O,La.magFilter=O,La.wrapS=pt,La.wrapT=pt,La.generateMipmaps=!1,La.needsUpdate=!0),La));A&&(b.setValue(ze,"toneMappingExposure",B.toneMappingExposure),v.needsLights&&(w=R,(D=C).ambientLightColor.needsUpdate=w,D.lightProbe.needsUpdate=w,D.directionalLights.needsUpdate=w,D.directionalLightShadows.needsUpdate=w,D.pointLights.needsUpdate=w,D.pointLightShadows.needsUpdate=w,D.spotLights.needsUpdate=w,D.spotLightShadows.needsUpdate=w,D.rectAreaLights.needsUpdate=w,D.hemisphereLights.needsUpdate=w),a&&!0===i.fog&&De.refreshFogUniforms(C,a),De.refreshMaterialUniforms(C,i,te,ee,L.state.transmissionRenderTarget[e.id]),br.upload(ze,lt(v),C,Ae));var D,w;i.isShaderMaterial&&!0===i.uniformsNeedUpdate&&(br.upload(ze,lt(v),C,Ae),i.uniformsNeedUpdate=!1);i.isSpriteMaterial&&b.setValue(ze,"center",r.center);if(b.setValue(ze,"modelViewMatrix",r.modelViewMatrix),b.setValue(ze,"normalMatrix",r.normalMatrix),b.setValue(ze,"modelMatrix",r.matrixWorld),i.isShaderMaterial||i.isRawShaderMaterial){const e=i.uniformsGroups;for(let t=0,n=e.length;t<n;t++){const n=e[t];We.update(n,T),We.bind(n,T)}}return T}(e,t,n,i,r);Ee.setMaterial(i,o);let l=n.index,c=1;if(!0===i.wireframe){if(l=Ce.getWireframeAttribute(n),void 0===l)return;c=2}const d=n.drawRange,u=n.attributes.position;let f=d.start*c,p=(d.start+d.count)*c;null!==a&&(f=Math.max(f,a.start*c),p=Math.min(p,(a.start+a.count)*c)),null!==l?(f=Math.max(f,0),p=Math.min(p,l.count)):null!=u&&(f=Math.max(f,0),p=Math.min(p,u.count));const m=p-f;if(m<0||m===1/0)return;let h;Ve.setup(r,i,s,n,l);let _=Be;if(null!==l&&(h=be.get(l),_=Ge,_.setIndex(h)),r.isMesh)!0===i.wireframe?(Ee.setLineWidth(i.wireframeLinewidth*he()),_.setMode(ze.LINES)):_.setMode(ze.TRIANGLES);else if(r.isLine){let e=i.linewidth;void 0===e&&(e=1),Ee.setLineWidth(e*he()),r.isLineSegments?_.setMode(ze.LINES):r.isLineLoop?_.setMode(ze.LINE_LOOP):_.setMode(ze.LINE_STRIP)}else r.isPoints?_.setMode(ze.POINTS):r.isSprite&&_.setMode(ze.TRIANGLES);if(r.isBatchedMesh)if(null!==r._multiDrawInstances)z("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),_.renderMultiDrawInstances(r._multiDrawStarts,r._multiDrawCounts,r._multiDrawCount,r._multiDrawInstances);else if(ge.get("WEBGL_multi_draw"))_.renderMultiDraw(r._multiDrawStarts,r._multiDrawCounts,r._multiDrawCount);else{const e=r._multiDrawStarts,t=r._multiDrawCounts,n=r._multiDrawCount,a=l?be.get(l).bytesPerElement:1,o=xe.get(i).currentProgram.getUniforms();for(let i=0;i<n;i++)o.setValue(ze,"_gl_DrawID",i),_.render(e[i]/a,t[i])}else if(r.isInstancedMesh)_.renderInstances(f,m,r.count);else if(n.isInstancedBufferGeometry){const e=void 0!==n._maxInstanceCount?n._maxInstanceCount:1/0,t=Math.min(n.instanceCount,e);_.renderInstances(f,m,t)}else _.render(f,m)},this.compile=function(e,t,n=null){null===n&&(n=e),L=Ie.get(n),L.init(t),I.push(L),n.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&(L.pushLight(e),e.castShadow&&L.pushShadow(e))}),e!==n&&e.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&(L.pushLight(e),e.castShadow&&L.pushShadow(e))}),L.setupLights();const i=new Set;return e.traverse(function(e){if(!(e.isMesh||e.isPoints||e.isLine||e.isSprite))return;const t=e.material;if(t)if(Array.isArray(t))for(let r=0;r<t.length;r++){const a=t[r];$e(a,n,e),i.add(a)}else $e(t,n,e),i.add(t)}),L=I.pop(),i},this.compileAsync=function(e,t,n=null){const i=this.compile(e,t,n);return new Promise(t=>{function n(){i.forEach(function(e){xe.get(e).currentProgram.isReady()&&i.delete(e)}),0!==i.size?setTimeout(n,10):t(e)}null!==ge.get("KHR_parallel_shader_compile")?n():setTimeout(n,10)})};let Qe=null;function Je(){tt.stop()}function et(){tt.start()}const tt=new On;function nt(e,t,n,i){if(!1===e.visible)return;if(e.layers.test(t.layers))if(e.isGroup)n=e.renderOrder;else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLight)L.pushLight(e),e.castShadow&&L.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||se.intersectsSprite(e)){i&&fe.setFromMatrixPosition(e.matrixWorld).applyMatrix4(de);const t=Pe.update(e),r=e.material;r.visible&&P.push(e,t,r,n,fe.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||se.intersectsObject(e))){const t=Pe.update(e),r=e.material;if(i&&(void 0!==e.boundingSphere?(null===e.boundingSphere&&e.computeBoundingSphere(),fe.copy(e.boundingSphere.center)):(null===t.boundingSphere&&t.computeBoundingSphere(),fe.copy(t.boundingSphere.center)),fe.applyMatrix4(e.matrixWorld).applyMatrix4(de)),Array.isArray(r)){const i=t.groups;for(let a=0,o=i.length;a<o;a++){const o=i[a],s=r[o.materialIndex];s&&s.visible&&P.push(e,t,s,n,fe.z,o)}}else r.visible&&P.push(e,t,r,n,fe.z,null)}const r=e.children;for(let e=0,a=r.length;e<a;e++)nt(r[e],t,n,i)}function it(e,t,n,i){const{opaque:r,transmissive:a,transparent:o}=e;L.setupLightsView(n),!0===le&&Ne.setGlobalState(B.clippingPlanes,n),i&&Ee.viewport(q.copy(i)),r.length>0&&at(r,t,n),a.length>0&&at(a,t,n),o.length>0&&at(o,t,n),Ee.buffers.depth.setTest(!0),Ee.buffers.depth.setMask(!0),Ee.buffers.color.setMask(!0),Ee.setPolygonOffset(!1)}function rt(e,t,n,i){if(null!==(!0===n.isScene?n.overrideMaterial:null))return;if(void 0===L.state.transmissionRenderTarget[i.id]){const e=ge.has("EXT_color_buffer_half_float")||ge.has("EXT_color_buffer_float");L.state.transmissionRenderTarget[i.id]=new N(1,1,{generateMipmaps:!0,type:e?S:M,minFilter:G,samples:Math.max(4,ve.samples),stencilBuffer:o,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:p.workingColorSpace})}const r=L.state.transmissionRenderTarget[i.id],a=i.viewport||q;r.setSize(a.z*B.transmissionResolutionScale,a.w*B.transmissionResolutionScale);const s=B.getRenderTarget(),l=B.getActiveCubeFace(),d=B.getActiveMipmapLevel();B.setRenderTarget(r),B.getClearColor($),Q=B.getClearAlpha(),Q<1&&B.setClearColor(16777215,.5),B.clear(),me&&Fe.render(n);const u=B.toneMapping;B.toneMapping=U;const f=i.viewport;if(void 0!==i.viewport&&(i.viewport=void 0),L.setupLightsView(i),!0===le&&Ne.setGlobalState(B.clippingPlanes,i),at(e,n,i),Ae.updateMultisampleRenderTarget(r),Ae.updateRenderTargetMipmap(r),!1===ge.has("WEBGL_multisampled_render_to_texture")){let e=!1;for(let r=0,a=t.length;r<a;r++){const a=t[r],{object:o,geometry:s,material:l,group:d}=a;if(l.side===_e&&o.layers.test(i.layers)){const t=l.side;l.side=c,l.needsUpdate=!0,ot(o,n,i,s,l,d),l.side=t,l.needsUpdate=!0,e=!0}}!0===e&&(Ae.updateMultisampleRenderTarget(r),Ae.updateRenderTargetMipmap(r))}B.setRenderTarget(s,l,d),B.setClearColor($,Q),void 0!==f&&(i.viewport=f),B.toneMapping=u}function at(e,t,n){const i=!0===t.isScene?t.overrideMaterial:null;for(let r=0,a=e.length;r<a;r++){const a=e[r],{object:o,geometry:s,group:l}=a;let c=a.material;!0===c.allowOverride&&null!==i&&(c=i),o.layers.test(n.layers)&&ot(o,t,n,s,c,l)}}function ot(e,t,n,i,r,a){e.onBeforeRender(B,t,n,i,r,a),e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),r.onBeforeRender(B,t,n,i,e,a),!0===r.transparent&&r.side===_e&&!1===r.forceSinglePass?(r.side=c,r.needsUpdate=!0,B.renderBufferDirect(n,t,i,r,e,a),r.side=_,r.needsUpdate=!0,B.renderBufferDirect(n,t,i,r,e,a),r.side=_e):B.renderBufferDirect(n,t,i,r,e,a),e.onAfterRender(B,t,n,i,r,a)}function st(e,t,n){!0!==t.isScene&&(t=pe);const i=xe.get(e),r=L.state.lights,a=L.state.shadowsArray,o=r.state.version,s=Ue.getParameters(e,r.state,a,t,n),l=Ue.getProgramCacheKey(s);let c=i.programs;i.environment=e.isMeshStandardMaterial||e.isMeshLambertMaterial||e.isMeshPhongMaterial?t.environment:null,i.fog=t.fog;const d=e.isMeshStandardMaterial||e.isMeshLambertMaterial&&!e.envMap||e.isMeshPhongMaterial&&!e.envMap;i.envMap=Re.get(e.envMap||i.environment,d),i.envMapRotation=null!==i.environment&&null===e.envMap?t.environmentRotation:e.envMapRotation,void 0===c&&(e.addEventListener("dispose",Ze),c=new Map,i.programs=c);let u=c.get(l);if(void 0!==u){if(i.currentProgram===u&&i.lightsStateVersion===o)return ct(e,s),u}else s.uniforms=Ue.getUniforms(e),e.onBuild(n,s,B),e.onBeforeCompile(s,B),u=Ue.acquireProgram(s,l),c.set(l,u),i.uniforms=s.uniforms;const f=i.uniforms;return(e.isShaderMaterial||e.isRawShaderMaterial)&&!0!==e.clipping||(f.clippingPlanes=Ne.uniform),ct(e,s),i.needsLights=function(e){return e.isMeshLambertMaterial||e.isMeshToonMaterial||e.isMeshPhongMaterial||e.isMeshStandardMaterial||e.isShadowMaterial||e.isShaderMaterial&&!0===e.lights}(e),i.lightsStateVersion=o,i.needsLights&&(f.ambientLightColor.value=r.state.ambient,f.lightProbe.value=r.state.probe,f.directionalLights.value=r.state.directional,f.directionalLightShadows.value=r.state.directionalShadow,f.spotLights.value=r.state.spot,f.spotLightShadows.value=r.state.spotShadow,f.rectAreaLights.value=r.state.rectArea,f.ltc_1.value=r.state.rectAreaLTC1,f.ltc_2.value=r.state.rectAreaLTC2,f.pointLights.value=r.state.point,f.pointLightShadows.value=r.state.pointShadow,f.hemisphereLights.value=r.state.hemi,f.directionalShadowMatrix.value=r.state.directionalShadowMatrix,f.spotLightMatrix.value=r.state.spotLightMatrix,f.spotLightMap.value=r.state.spotLightMap,f.pointShadowMatrix.value=r.state.pointShadowMatrix),i.currentProgram=u,i.uniformsList=null,u}function lt(e){if(null===e.uniformsList){const t=e.currentProgram.getUniforms();e.uniformsList=br.seqWithValue(t.seq,e.uniforms)}return e.uniformsList}function ct(e,t){const n=xe.get(e);n.outputColorSpace=t.outputColorSpace,n.batching=t.batching,n.batchingColor=t.batchingColor,n.instancing=t.instancing,n.instancingColor=t.instancingColor,n.instancingMorph=t.instancingMorph,n.skinning=t.skinning,n.morphTargets=t.morphTargets,n.morphNormals=t.morphNormals,n.morphColors=t.morphColors,n.morphTargetsCount=t.morphTargetsCount,n.numClippingPlanes=t.numClippingPlanes,n.numIntersection=t.numClipIntersection,n.vertexAlphas=t.vertexAlphas,n.vertexTangents=t.vertexTangents,n.toneMapping=t.toneMapping}tt.setAnimationLoop(function(e){Qe&&Qe(e)}),"undefined"!=typeof self&&tt.setContext(self),this.setAnimationLoop=function(e){Qe=e,Ye.setAnimationLoop(e),null===e?tt.stop():tt.start()},Ye.addEventListener("sessionstart",Je),Ye.addEventListener("sessionend",et),this.render=function(e,t){if(void 0!==t&&!0!==t.isCamera)return void w("WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===H)return;const n=!0===Ye.enabled&&!0===Ye.isPresenting,i=null!==y&&(null===k||n)&&y.begin(B,k);if(!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),!0!==Ye.enabled||!0!==Ye.isPresenting||null!==y&&!1!==y.isCompositing()||(!0===Ye.cameraAutoUpdate&&Ye.updateCamera(t),t=Ye.getCamera()),!0===e.isScene&&e.onBeforeRender(B,e,t,k),L=Ie.get(e,I.length),L.init(t),I.push(L),de.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),se.setFromProjectionMatrix(de,yn,t.reversedDepth),ce=this.localClippingEnabled,le=Ne.init(this.clippingPlanes,ce),P=we.get(e,D.length),P.init(),D.push(P),!0===Ye.enabled&&!0===Ye.isPresenting){const e=B.xr.getDepthSensingMesh();null!==e&&nt(e,t,-1/0,B.sortObjects)}nt(e,t,0,B.sortObjects),P.finish(),!0===B.sortObjects&&P.sort(ne,ie),me=!1===Ye.enabled||!1===Ye.isPresenting||!1===Ye.hasDepthSensing(),me&&Fe.addToRenderList(P,e),this.info.render.frame++,!0===le&&Ne.beginShadows();const r=L.state.shadowsArray;ye.render(r,e,t),!0===le&&Ne.endShadows(),!0===this.info.autoReset&&this.info.reset();if(!1===(i&&y.hasRenderPass())){const n=P.opaque,i=P.transmissive;if(L.setupLights(),t.isArrayCamera){const r=t.cameras;if(i.length>0)for(let t=0,a=r.length;t<a;t++){rt(n,i,e,r[t])}me&&Fe.render(e);for(let t=0,n=r.length;t<n;t++){const n=r[t];it(P,e,n,n.viewport)}}else i.length>0&&rt(n,i,e,t),me&&Fe.render(e),it(P,e,t)}null!==k&&0===W&&(Ae.updateMultisampleRenderTarget(k),Ae.updateRenderTargetMipmap(k)),i&&y.end(B),!0===e.isScene&&e.onAfterRender(B,e,t),Ve.resetDefaultState(),X=-1,K=null,I.pop(),I.length>0?(L=I[I.length-1],!0===le&&Ne.setGlobalState(B.clippingPlanes,L.state.camera)):L=null,D.pop(),P=D.length>0?D[D.length-1]:null},this.getActiveCubeFace=function(){return V},this.getActiveMipmapLevel=function(){return W},this.getRenderTarget=function(){return k},this.setRenderTargetTextures=function(e,t,n){const i=xe.get(e);i.__autoAllocateDepthBuffer=!1===e.resolveDepthBuffer,!1===i.__autoAllocateDepthBuffer&&(i.__useRenderToTexture=!1),xe.get(e.texture).__webglTexture=t,xe.get(e.depthTexture).__webglTexture=i.__autoAllocateDepthBuffer?void 0:n,i.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(e,t){const n=xe.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=void 0===t};const dt=ze.createFramebuffer();this.setRenderTarget=function(e,t=0,n=0){k=e,V=t,W=n;let i=null,r=!1,a=!1;if(e){const o=xe.get(e);if(void 0!==o.__useDefaultFramebuffer)return Ee.bindFramebuffer(ze.FRAMEBUFFER,o.__webglFramebuffer),q.copy(e.viewport),j.copy(e.scissor),Z=e.scissorTest,Ee.viewport(q),Ee.scissor(j),Ee.setScissorTest(Z),void(X=-1);if(void 0===o.__webglFramebuffer)Ae.setupRenderTarget(e);else if(o.__hasExternalTextures)Ae.rebindTextures(e,xe.get(e.texture).__webglTexture,xe.get(e.depthTexture).__webglTexture);else if(e.depthBuffer){const t=e.depthTexture;if(o.__boundDepthTexture!==t){if(null!==t&&xe.has(t)&&(e.width!==t.image.width||e.height!==t.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");Ae.setupDepthRenderbuffer(e)}}const s=e.texture;(s.isData3DTexture||s.isDataArrayTexture||s.isCompressedArrayTexture)&&(a=!0);const l=xe.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(i=Array.isArray(l[t])?l[t][n]:l[t],r=!0):i=e.samples>0&&!1===Ae.useMultisampledRTT(e)?xe.get(e).__webglMultisampledFramebuffer:Array.isArray(l)?l[n]:l,q.copy(e.viewport),j.copy(e.scissor),Z=e.scissorTest}else q.copy(re).multiplyScalar(te).floor(),j.copy(ae).multiplyScalar(te).floor(),Z=oe;0!==n&&(i=dt);if(Ee.bindFramebuffer(ze.FRAMEBUFFER,i)&&Ee.drawBuffers(e,i),Ee.viewport(q),Ee.scissor(j),Ee.setScissorTest(Z),r){const i=xe.get(e.texture);ze.framebufferTexture2D(ze.FRAMEBUFFER,ze.COLOR_ATTACHMENT0,ze.TEXTURE_CUBE_MAP_POSITIVE_X+t,i.__webglTexture,n)}else if(a){const i=t;for(let t=0;t<e.textures.length;t++){const r=xe.get(e.textures[t]);ze.framebufferTextureLayer(ze.FRAMEBUFFER,ze.COLOR_ATTACHMENT0+t,r.__webglTexture,n,i)}}else if(null!==e&&0!==n){const t=xe.get(e.texture);ze.framebufferTexture2D(ze.FRAMEBUFFER,ze.COLOR_ATTACHMENT0,ze.TEXTURE_2D,t.__webglTexture,n)}X=-1},this.readRenderTargetPixels=function(e,t,n,i,r,a,o,s=0){if(!e||!e.isWebGLRenderTarget)return void w("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let l=xe.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==o&&(l=l[o]),l){Ee.bindFramebuffer(ze.FRAMEBUFFER,l);try{const o=e.textures[s],l=o.format,c=o.type;if(e.textures.length>1&&ze.readBuffer(ze.COLOR_ATTACHMENT0+s),!ve.textureFormatReadable(l))return void w("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!ve.textureTypeReadable(c))return void w("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");t>=0&&t<=e.width-i&&n>=0&&n<=e.height-r&&ze.readPixels(t,n,i,r,He.convert(l),He.convert(c),a)}finally{const e=null!==k?xe.get(k).__webglFramebuffer:null;Ee.bindFramebuffer(ze.FRAMEBUFFER,e)}}},this.readRenderTargetPixelsAsync=async function(e,t,n,i,r,a,o,s=0){if(!e||!e.isWebGLRenderTarget)throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let l=xe.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==o&&(l=l[o]),l){if(t>=0&&t<=e.width-i&&n>=0&&n<=e.height-r){Ee.bindFramebuffer(ze.FRAMEBUFFER,l);const o=e.textures[s],c=o.format,d=o.type;if(e.textures.length>1&&ze.readBuffer(ze.COLOR_ATTACHMENT0+s),!ve.textureFormatReadable(c))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!ve.textureTypeReadable(d))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const u=ze.createBuffer();ze.bindBuffer(ze.PIXEL_PACK_BUFFER,u),ze.bufferData(ze.PIXEL_PACK_BUFFER,a.byteLength,ze.STREAM_READ),ze.readPixels(t,n,i,r,He.convert(c),He.convert(d),0);const f=null!==k?xe.get(k).__webglFramebuffer:null;Ee.bindFramebuffer(ze.FRAMEBUFFER,f);const p=ze.fenceSync(ze.SYNC_GPU_COMMANDS_COMPLETE,0);return ze.flush(),await Fn(ze,p,4),ze.bindBuffer(ze.PIXEL_PACK_BUFFER,u),ze.getBufferSubData(ze.PIXEL_PACK_BUFFER,0,a),ze.deleteBuffer(u),ze.deleteSync(p),a}throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(e,t=null,n=0){const i=Math.pow(2,-n),r=Math.floor(e.image.width*i),a=Math.floor(e.image.height*i),o=null!==t?t.x:0,s=null!==t?t.y:0;Ae.setTexture2D(e,0),ze.copyTexSubImage2D(ze.TEXTURE_2D,n,0,0,o,s,r,a),Ee.unbindTexture()};const ut=ze.createFramebuffer(),ft=ze.createFramebuffer();this.copyTextureToTexture=function(e,t,n=null,i=null,r=0,a=0){let o,s,l,c,d,u,f,p,m;const h=e.isCompressedTexture?e.mipmaps[a]:e.image;if(null!==n)o=n.max.x-n.min.x,s=n.max.y-n.min.y,l=n.isBox3?n.max.z-n.min.z:1,c=n.min.x,d=n.min.y,u=n.isBox3?n.min.z:0;else{const t=Math.pow(2,-r);o=Math.floor(h.width*t),s=Math.floor(h.height*t),l=e.isDataArrayTexture?h.depth:e.isData3DTexture?Math.floor(h.depth*t):1,c=0,d=0,u=0}null!==i?(f=i.x,p=i.y,m=i.z):(f=0,p=0,m=0);const _=He.convert(t.format),g=He.convert(t.type);let v;t.isData3DTexture?(Ae.setTexture3D(t,0),v=ze.TEXTURE_3D):t.isDataArrayTexture||t.isCompressedArrayTexture?(Ae.setTexture2DArray(t,0),v=ze.TEXTURE_2D_ARRAY):(Ae.setTexture2D(t,0),v=ze.TEXTURE_2D),ze.pixelStorei(ze.UNPACK_FLIP_Y_WEBGL,t.flipY),ze.pixelStorei(ze.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),ze.pixelStorei(ze.UNPACK_ALIGNMENT,t.unpackAlignment);const E=ze.getParameter(ze.UNPACK_ROW_LENGTH),S=ze.getParameter(ze.UNPACK_IMAGE_HEIGHT),M=ze.getParameter(ze.UNPACK_SKIP_PIXELS),T=ze.getParameter(ze.UNPACK_SKIP_ROWS),x=ze.getParameter(ze.UNPACK_SKIP_IMAGES);ze.pixelStorei(ze.UNPACK_ROW_LENGTH,h.width),ze.pixelStorei(ze.UNPACK_IMAGE_HEIGHT,h.height),ze.pixelStorei(ze.UNPACK_SKIP_PIXELS,c),ze.pixelStorei(ze.UNPACK_SKIP_ROWS,d),ze.pixelStorei(ze.UNPACK_SKIP_IMAGES,u);const A=e.isDataArrayTexture||e.isData3DTexture,R=t.isDataArrayTexture||t.isData3DTexture;if(e.isDepthTexture){const n=xe.get(e),i=xe.get(t),h=xe.get(n.__renderTarget),_=xe.get(i.__renderTarget);Ee.bindFramebuffer(ze.READ_FRAMEBUFFER,h.__webglFramebuffer),Ee.bindFramebuffer(ze.DRAW_FRAMEBUFFER,_.__webglFramebuffer);for(let n=0;n<l;n++)A&&(ze.framebufferTextureLayer(ze.READ_FRAMEBUFFER,ze.COLOR_ATTACHMENT0,xe.get(e).__webglTexture,r,u+n),ze.framebufferTextureLayer(ze.DRAW_FRAMEBUFFER,ze.COLOR_ATTACHMENT0,xe.get(t).__webglTexture,a,m+n)),ze.blitFramebuffer(c,d,o,s,f,p,o,s,ze.DEPTH_BUFFER_BIT,ze.NEAREST);Ee.bindFramebuffer(ze.READ_FRAMEBUFFER,null),Ee.bindFramebuffer(ze.DRAW_FRAMEBUFFER,null)}else if(0!==r||e.isRenderTargetTexture||xe.has(e)){const n=xe.get(e),i=xe.get(t);Ee.bindFramebuffer(ze.READ_FRAMEBUFFER,ut),Ee.bindFramebuffer(ze.DRAW_FRAMEBUFFER,ft);for(let e=0;e<l;e++)A?ze.framebufferTextureLayer(ze.READ_FRAMEBUFFER,ze.COLOR_ATTACHMENT0,n.__webglTexture,r,u+e):ze.framebufferTexture2D(ze.READ_FRAMEBUFFER,ze.COLOR_ATTACHMENT0,ze.TEXTURE_2D,n.__webglTexture,r),R?ze.framebufferTextureLayer(ze.DRAW_FRAMEBUFFER,ze.COLOR_ATTACHMENT0,i.__webglTexture,a,m+e):ze.framebufferTexture2D(ze.DRAW_FRAMEBUFFER,ze.COLOR_ATTACHMENT0,ze.TEXTURE_2D,i.__webglTexture,a),0!==r?ze.blitFramebuffer(c,d,o,s,f,p,o,s,ze.COLOR_BUFFER_BIT,ze.NEAREST):R?ze.copyTexSubImage3D(v,a,f,p,m+e,c,d,o,s):ze.copyTexSubImage2D(v,a,f,p,c,d,o,s);Ee.bindFramebuffer(ze.READ_FRAMEBUFFER,null),Ee.bindFramebuffer(ze.DRAW_FRAMEBUFFER,null)}else R?e.isDataTexture||e.isData3DTexture?ze.texSubImage3D(v,a,f,p,m,o,s,l,_,g,h.data):t.isCompressedArrayTexture?ze.compressedTexSubImage3D(v,a,f,p,m,o,s,l,_,h.data):ze.texSubImage3D(v,a,f,p,m,o,s,l,_,g,h):e.isDataTexture?ze.texSubImage2D(ze.TEXTURE_2D,a,f,p,o,s,_,g,h.data):e.isCompressedTexture?ze.compressedTexSubImage2D(ze.TEXTURE_2D,a,f,p,h.width,h.height,_,h.data):ze.texSubImage2D(ze.TEXTURE_2D,a,f,p,o,s,_,g,h);ze.pixelStorei(ze.UNPACK_ROW_LENGTH,E),ze.pixelStorei(ze.UNPACK_IMAGE_HEIGHT,S),ze.pixelStorei(ze.UNPACK_SKIP_PIXELS,M),ze.pixelStorei(ze.UNPACK_SKIP_ROWS,T),ze.pixelStorei(ze.UNPACK_SKIP_IMAGES,x),0===a&&t.generateMipmaps&&ze.generateMipmap(v),Ee.unbindTexture()},this.initRenderTarget=function(e){void 0===xe.get(e).__webglFramebuffer&&Ae.setupRenderTarget(e)},this.initTexture=function(e){e.isCubeTexture?Ae.setTextureCube(e,0):e.isData3DTexture?Ae.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?Ae.setTexture2DArray(e,0):Ae.setTexture2D(e,0),Ee.unbindTexture()},this.resetState=function(){V=0,W=0,k=null,Ee.reset(),Ve.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return yn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=p._getDrawingBufferColorSpace(e),t.unpackColorSpace=p._getUnpackColorSpace()}}export{J as ACESFilmicToneMapping,Ie as AddEquation,ue as AddOperation,lt as AdditiveBlending,Q as AgXToneMapping,Ft as AlphaFormat,Tt as AlwaysCompare,et as AlwaysDepth,Cn as ArrayCamera,c as BackSide,s as BoxGeometry,y as BufferAttribute,C as BufferGeometry,Nt as ByteType,ee as CineonToneMapping,pt as ClampToEdgeWrapping,n as Color,p as ColorManagement,ye as ConstantAlphaFactor,Oe as ConstantColorFactor,H as CubeCamera,Pe as CubeDepthTexture,R as CubeReflectionMapping,b as CubeRefractionMapping,B as CubeTexture,a as CubeUVReflectionMapping,it as CullFaceBack,rt as CullFaceFront,nt as CullFaceNone,at as CustomBlending,Z as CustomToneMapping,ie as Data3DTexture,K as DataArrayTexture,Un as DataTexture,be as DepthFormat,Rt as DepthStencilFormat,oe as DepthTexture,_e as DoubleSide,We as DstAlphaFactor,ze as DstColorFactor,St as EqualCompare,Qe as EqualDepth,V as EquirectangularReflectionMapping,W as EquirectangularRefractionMapping,u as Euler,bn as EventDispatcher,Rn as ExternalTexture,q as Float32BufferAttribute,T as FloatType,_ as FrontSide,Te as Frustum,le as GLSL3,Et as GreaterCompare,Ze as GreaterDepth,re as GreaterEqualCompare,$e as GreaterEqualDepth,S as HalfFloatType,v as IntType,Se as Layers,Mt as LessCompare,Je as LessDepth,ae as LessEqualCompare,Ue as LessEqualDepth,O as LinearFilter,G as LinearMipmapLinearFilter,ht as LinearMipmapNearestFilter,F as LinearSRGBColorSpace,ne as LinearToneMapping,me as LinearTransfer,e as Matrix3,f as Matrix4,ut as MaxEquation,o as Mesh,D as MeshBasicMaterial,xe as MeshDepthMaterial,Ae as MeshDistanceMaterial,dt as MinEquation,ft as MirroredRepeatWrapping,fe as MixOperation,ot as MultiplyBlending,pe as MultiplyOperation,Ce as NearestFilter,_t as NearestMipmapLinearFilter,gt as NearestMipmapNearestFilter,$ as NeutralToneMapping,xt as NeverCompare,tt as NeverDepth,I as NoBlending,At as NoColorSpace,U as NoToneMapping,ge as NormalBlending,vt as NotEqualCompare,je as NotEqualDepth,Ee as ObjectSpaceNormalMap,Ke as OneFactor,Ne as OneMinusConstantAlphaFactor,Fe as OneMinusConstantColorFactor,Be as OneMinusDstAlphaFactor,Ge as OneMinusDstColorFactor,He as OneMinusSrcAlphaFactor,Ve as OneMinusSrcColorFactor,P as OrthographicCamera,de as PCFShadowMap,Re as PCFSoftShadowMap,ai as PMREMGenerator,L as PerspectiveCamera,A as Plane,h as PlaneGeometry,Jt as R11_EAC_Format,xn as RED_GREEN_RGTC2_Format,Mn as RED_RGTC1_Format,In as REVISION,tn as RG11_EAC_Format,x as RGBAFormat,Vt as RGBAIntegerFormat,hn as RGBA_ASTC_10x10_Format,fn as RGBA_ASTC_10x5_Format,pn as RGBA_ASTC_10x6_Format,mn as RGBA_ASTC_10x8_Format,_n as RGBA_ASTC_12x10_Format,gn as RGBA_ASTC_12x12_Format,rn as RGBA_ASTC_4x4_Format,an as RGBA_ASTC_5x4_Format,on as RGBA_ASTC_5x5_Format,sn as RGBA_ASTC_6x5_Format,ln as RGBA_ASTC_6x6_Format,cn as RGBA_ASTC_8x5_Format,dn as RGBA_ASTC_8x6_Format,un as RGBA_ASTC_8x8_Format,vn as RGBA_BPTC_Format,Qt as RGBA_ETC2_EAC_Format,jt as RGBA_PVRTC_2BPPV1_Format,qt as RGBA_PVRTC_4BPPV1_Format,zt as RGBA_S3TC_DXT1_Format,kt as RGBA_S3TC_DXT3_Format,Xt as RGBA_S3TC_DXT5_Format,Ot as RGBFormat,En as RGB_BPTC_SIGNED_Format,Sn as RGB_BPTC_UNSIGNED_Format,Zt as RGB_ETC1_Format,$t as RGB_ETC2_Format,Kt as RGB_PVRTC_2BPPV1_Format,Yt as RGB_PVRTC_4BPPV1_Format,Wt as RGB_S3TC_DXT1_Format,Me as RGFormat,Ht as RGIntegerFormat,j as RawShaderMaterial,Bt as RedFormat,Gt as RedIntegerFormat,te as ReinhardToneMapping,mt as RepeatWrapping,De as ReverseSubtractEquation,en as SIGNED_R11_EAC_Format,An as SIGNED_RED_GREEN_RGTC2_Format,Tn as SIGNED_RED_RGTC1_Format,nn as SIGNED_RG11_EAC_Format,wn as SRGBColorSpace,m as SRGBTransfer,Gn as ShaderChunk,Vn as ShaderLib,l as ShaderMaterial,yt as ShortType,Xe as SrcAlphaFactor,ke as SrcAlphaSaturateFactor,Ye as SrcColorFactor,we as SubtractEquation,st as SubtractiveBlending,ve as TangentSpaceNormalMap,se as Texture,X as Uint16BufferAttribute,k as Uint32BufferAttribute,Hn as UniformsLib,he as UniformsUtils,M as UnsignedByteType,It as UnsignedInt101111Type,Ct as UnsignedInt248Type,wt as UnsignedInt5999Type,Le as UnsignedIntType,Ut as UnsignedShort4444Type,Dt as UnsignedShort5551Type,Pt as UnsignedShortType,ce as VSMShadowMap,t as Vector2,r as Vector3,Y as Vector4,yn as WebGLCoordinateSystem,fi as WebGLCubeRenderTarget,N as WebGLRenderTarget,Ua as WebGLRenderer,Ma as WebGLUtils,Pn as WebXRController,qe as ZeroFactor,Dn as createCanvasElement,w as error,Nn as log,E as warn,z as warnOnce};
|