@needle-tools/engine 4.7.2-alpha → 4.7.2-next.6f2cd71
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/CHANGELOG.md +3782 -3782
- package/LICENSE.md +10 -10
- package/README.md +64 -64
- package/components.needle.json +1 -1
- package/dist/generateMeshBVH.worker-BaNp_Xtp.js +25 -0
- package/dist/{gltf-progressive-zdhlW609.umd.cjs → gltf-progressive-B9o1T8Vr.umd.cjs} +1 -1
- package/dist/{gltf-progressive-YjtQYFa9.js → gltf-progressive-DO0SisAM.js} +2 -2
- package/dist/{gltf-progressive-yOP1mp5W.min.js → gltf-progressive-DQF10PJE.min.js} +1 -1
- package/dist/{needle-engine.bundle-BhDF-YSv.min.js → needle-engine.bundle-B-NoV0t_.min.js} +64 -64
- package/dist/{needle-engine.bundle-D2myV4E4.umd.cjs → needle-engine.bundle-BMnlxDfi.umd.cjs} +59 -59
- package/dist/{needle-engine.bundle-gp00DTS4.js → needle-engine.bundle-CFi0ugBx.js} +638 -638
- package/dist/needle-engine.d.ts +130 -129
- package/dist/needle-engine.js +4 -4
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/dist/{postprocessing-8AQTeZsr.umd.cjs → postprocessing-CjW23fio.umd.cjs} +2 -2
- package/dist/{postprocessing-BkxN_08g.js → postprocessing-DYLNOL3W.js} +3 -3
- package/dist/{postprocessing-BDScN9yu.min.js → postprocessing-xYQWCHFu.min.js} +2 -2
- package/dist/{three-DMrv-4ar.umd.cjs → three-B_hneGZr.umd.cjs} +4 -4
- package/dist/{three-Bz6X1mrw.js → three-DrqIzZTH.js} +4198 -4198
- package/dist/{three-Boa-jOq-.min.js → three-DuDKwKB8.min.js} +33 -33
- package/dist/{three-examples-GggCDHv0.js → three-examples-B50TT3Iu.js} +5 -5
- package/dist/{three-examples-DuVhxqft.min.js → three-examples-DaDLBuy6.min.js} +14 -14
- package/dist/{three-examples-C7ryg8vN.umd.cjs → three-examples-X3OadjXB.umd.cjs} +3 -3
- package/dist/{three-mesh-ui-CY6Izc7C.min.js → three-mesh-ui-B3p3gyUz.min.js} +1 -1
- package/dist/{three-mesh-ui-CwlN0FUC.umd.cjs → three-mesh-ui-CQiIQIlA.umd.cjs} +1 -1
- package/dist/{three-mesh-ui-CLNOfsWn.js → three-mesh-ui-CxuWt7m-.js} +1 -1
- package/dist/{vendor-zxXa3Dmr.min.js → vendor-BlSxe9JJ.min.js} +3 -3
- package/dist/{vendor-BSD1RQIh.js → vendor-BmYIgaS1.js} +3 -3
- package/dist/{vendor-DHr4aqIZ.umd.cjs → vendor-Cavtu3CP.umd.cjs} +3 -3
- package/lib/asap/needle-asap.d.ts +1 -1
- package/lib/asap/needle-asap.js +95 -95
- package/lib/asap/sessiongranted.d.ts +3 -3
- package/lib/asap/sessiongranted.js +65 -65
- package/lib/asap/utils.d.ts +1 -1
- package/lib/asap/utils.js +3 -3
- package/lib/engine/analytics/index.d.ts +6 -6
- package/lib/engine/analytics/index.js +12 -12
- package/lib/engine/analytics/lcp.d.ts +3 -3
- package/lib/engine/analytics/lcp.js +34 -34
- package/lib/engine/api.d.ts +82 -82
- package/lib/engine/api.js +81 -81
- package/lib/engine/assets/index.d.ts +11 -11
- package/lib/engine/assets/index.js +47 -47
- package/lib/engine/assets/static.d.ts +1 -1
- package/lib/engine/assets/static.js +4 -4
- package/lib/engine/codegen/register_types.d.ts +1 -1
- package/lib/engine/codegen/register_types.js +300 -300
- package/lib/engine/debug/debug.d.ts +15 -15
- package/lib/engine/debug/debug.js +44 -44
- package/lib/engine/debug/debug_console.d.ts +2 -2
- package/lib/engine/debug/debug_console.js +307 -307
- package/lib/engine/debug/debug_overlay.d.ts +22 -22
- package/lib/engine/debug/debug_overlay.js +316 -316
- package/lib/engine/debug/debug_spatial_console.d.ts +2 -2
- package/lib/engine/debug/debug_spatial_console.js +390 -390
- package/lib/engine/debug/index.d.ts +2 -2
- package/lib/engine/debug/index.js +2 -2
- package/lib/engine/engine_addressables.d.ts +164 -164
- package/lib/engine/engine_addressables.js +601 -601
- package/lib/engine/engine_animation.d.ts +43 -43
- package/lib/engine/engine_animation.js +133 -133
- package/lib/engine/engine_application.d.ts +45 -45
- package/lib/engine/engine_application.js +104 -104
- package/lib/engine/engine_assetdatabase.d.ts +25 -25
- package/lib/engine/engine_assetdatabase.js +346 -346
- package/lib/engine/engine_audio.d.ts +4 -4
- package/lib/engine/engine_audio.js +23 -23
- package/lib/engine/engine_camera.d.ts +13 -13
- package/lib/engine/engine_camera.js +30 -30
- package/lib/engine/engine_components.d.ts +110 -110
- package/lib/engine/engine_components.js +374 -374
- package/lib/engine/engine_components_internal.d.ts +9 -9
- package/lib/engine/engine_components_internal.js +36 -36
- package/lib/engine/engine_constants.d.ts +10 -10
- package/lib/engine/engine_constants.js +41 -41
- package/lib/engine/engine_context.d.ts +475 -475
- package/lib/engine/engine_context.js +1673 -1673
- package/lib/engine/engine_context_registry.d.ts +71 -71
- package/lib/engine/engine_context_registry.js +117 -117
- package/lib/engine/engine_coroutine.d.ts +35 -35
- package/lib/engine/engine_coroutine.js +52 -52
- package/lib/engine/engine_create_objects.d.ts +119 -119
- package/lib/engine/engine_create_objects.js +320 -320
- package/lib/engine/engine_default_parameters.d.ts +2 -2
- package/lib/engine/engine_default_parameters.js +3 -3
- package/lib/engine/engine_editor-sync.d.ts +21 -21
- package/lib/engine/engine_editor-sync.js +4 -4
- package/lib/engine/engine_fileloader.d.ts +2 -2
- package/lib/engine/engine_fileloader.js +8 -8
- package/lib/engine/engine_gameobject.d.ts +68 -68
- package/lib/engine/engine_gameobject.js +619 -619
- package/lib/engine/engine_generic_utils.d.ts +1 -1
- package/lib/engine/engine_generic_utils.js +13 -13
- package/lib/engine/engine_gizmos.d.ts +149 -149
- package/lib/engine/engine_gizmos.js +530 -530
- package/lib/engine/engine_gltf.d.ts +12 -12
- package/lib/engine/engine_gltf.js +15 -15
- package/lib/engine/engine_gltf_builtin_components.d.ts +11 -11
- package/lib/engine/engine_gltf_builtin_components.js +341 -341
- package/lib/engine/engine_hot_reload.d.ts +8 -8
- package/lib/engine/engine_hot_reload.js +197 -197
- package/lib/engine/engine_input.d.ts +362 -362
- package/lib/engine/engine_input.js +1294 -1294
- package/lib/engine/engine_input_utils.d.ts +2 -2
- package/lib/engine/engine_input_utils.js +22 -22
- package/lib/engine/engine_instancing.d.ts +19 -19
- package/lib/engine/engine_instancing.js +39 -39
- package/lib/engine/engine_license.d.ts +11 -11
- package/lib/engine/engine_license.js +369 -369
- package/lib/engine/engine_lifecycle_api.d.ts +83 -83
- package/lib/engine/engine_lifecycle_api.js +106 -106
- package/lib/engine/engine_lifecycle_functions_internal.d.ts +32 -32
- package/lib/engine/engine_lifecycle_functions_internal.js +146 -146
- package/lib/engine/engine_lightdata.d.ts +23 -23
- package/lib/engine/engine_lightdata.js +101 -101
- package/lib/engine/engine_loaders.callbacks.d.ts +97 -97
- package/lib/engine/engine_loaders.callbacks.js +86 -86
- package/lib/engine/engine_loaders.d.ts +48 -48
- package/lib/engine/engine_loaders.gltf.d.ts +13 -13
- package/lib/engine/engine_loaders.gltf.js +62 -62
- package/lib/engine/engine_loaders.js +337 -337
- package/lib/engine/engine_lods.d.ts +35 -35
- package/lib/engine/engine_lods.js +160 -160
- package/lib/engine/engine_mainloop_utils.d.ts +32 -32
- package/lib/engine/engine_mainloop_utils.js +466 -466
- package/lib/engine/engine_math.d.ts +114 -114
- package/lib/engine/engine_math.js +247 -247
- package/lib/engine/engine_modules.d.ts +36 -36
- package/lib/engine/engine_modules.js +85 -85
- package/lib/engine/engine_networking.d.ts +260 -260
- package/lib/engine/engine_networking.js +764 -764
- package/lib/engine/engine_networking_auto.d.ts +24 -24
- package/lib/engine/engine_networking_auto.js +310 -310
- package/lib/engine/engine_networking_blob.d.ts +48 -48
- package/lib/engine/engine_networking_blob.js +228 -228
- package/lib/engine/engine_networking_files.d.ts +35 -35
- package/lib/engine/engine_networking_files.js +172 -172
- package/lib/engine/engine_networking_files_default_components.d.ts +6 -6
- package/lib/engine/engine_networking_files_default_components.js +42 -42
- package/lib/engine/engine_networking_instantiate.d.ts +100 -100
- package/lib/engine/engine_networking_instantiate.js +345 -345
- package/lib/engine/engine_networking_peer.d.ts +15 -15
- package/lib/engine/engine_networking_peer.js +132 -132
- package/lib/engine/engine_networking_streams.d.ts +123 -123
- package/lib/engine/engine_networking_streams.js +645 -645
- package/lib/engine/engine_networking_types.d.ts +22 -22
- package/lib/engine/engine_networking_types.js +7 -7
- package/lib/engine/engine_networking_utils.d.ts +2 -2
- package/lib/engine/engine_networking_utils.js +20 -20
- package/lib/engine/engine_networking_websocket.d.ts +1 -1
- package/lib/engine/engine_networking_websocket.js +2 -2
- package/lib/engine/engine_patcher.d.ts +10 -10
- package/lib/engine/engine_patcher.js +142 -142
- package/lib/engine/engine_physics.d.ts +152 -152
- package/lib/engine/engine_physics.js +645 -645
- package/lib/engine/engine_physics.types.d.ts +40 -40
- package/lib/engine/engine_physics.types.js +33 -33
- package/lib/engine/engine_physics_rapier.d.ts +147 -147
- package/lib/engine/engine_physics_rapier.js +1433 -1433
- package/lib/engine/engine_playerview.d.ts +26 -26
- package/lib/engine/engine_playerview.js +64 -64
- package/lib/engine/engine_scenelighting.d.ts +71 -71
- package/lib/engine/engine_scenelighting.js +226 -226
- package/lib/engine/engine_serialization.d.ts +3 -3
- package/lib/engine/engine_serialization.js +3 -3
- package/lib/engine/engine_serialization_builtin_serializer.d.ts +72 -72
- package/lib/engine/engine_serialization_builtin_serializer.js +403 -403
- package/lib/engine/engine_serialization_core.d.ts +94 -94
- package/lib/engine/engine_serialization_core.js +607 -607
- package/lib/engine/engine_serialization_decorator.d.ts +23 -23
- package/lib/engine/engine_serialization_decorator.js +66 -66
- package/lib/engine/engine_setup.d.ts +1 -1
- package/lib/engine/engine_setup.js +2 -2
- package/lib/engine/engine_shaders.d.ts +53 -53
- package/lib/engine/engine_shaders.js +252 -252
- package/lib/engine/engine_shims.d.ts +4 -4
- package/lib/engine/engine_shims.js +24 -24
- package/lib/engine/engine_test_utils.d.ts +39 -39
- package/lib/engine/engine_test_utils.js +83 -83
- package/lib/engine/engine_texture.d.ts +28 -28
- package/lib/engine/engine_texture.js +64 -64
- package/lib/engine/engine_three_utils.d.ts +204 -204
- package/lib/engine/engine_three_utils.js +788 -788
- package/lib/engine/engine_time.d.ts +51 -51
- package/lib/engine/engine_time.js +82 -82
- package/lib/engine/engine_time_utils.d.ts +88 -88
- package/lib/engine/engine_time_utils.js +215 -215
- package/lib/engine/engine_tonemapping.d.ts +6 -6
- package/lib/engine/engine_tonemapping.js +197 -197
- package/lib/engine/engine_types.d.ts +578 -578
- package/lib/engine/engine_types.js +95 -95
- package/lib/engine/engine_typestore.d.ts +28 -28
- package/lib/engine/engine_typestore.js +55 -55
- package/lib/engine/engine_util_decorator.d.ts +13 -13
- package/lib/engine/engine_util_decorator.js +116 -116
- package/lib/engine/engine_utils.d.ts +248 -248
- package/lib/engine/engine_utils.js +1012 -1012
- package/lib/engine/engine_utils_format.d.ts +24 -24
- package/lib/engine/engine_utils_format.js +239 -239
- package/lib/engine/engine_utils_screenshot.d.ts +159 -159
- package/lib/engine/engine_utils_screenshot.js +522 -522
- package/lib/engine/engine_utils_screenshot.xr.d.ts +5 -5
- package/lib/engine/engine_utils_screenshot.xr.js +90 -90
- package/lib/engine/engine_xr.d.ts +1 -1
- package/lib/engine/engine_xr.js +1 -1
- package/lib/engine/export/gltf/Writers.d.ts +19 -19
- package/lib/engine/export/gltf/Writers.js +24 -24
- package/lib/engine/export/gltf/index.d.ts +11 -11
- package/lib/engine/export/gltf/index.js +123 -123
- package/lib/engine/export/index.d.ts +2 -2
- package/lib/engine/export/index.js +2 -2
- package/lib/engine/export/state.d.ts +7 -7
- package/lib/engine/export/state.js +17 -17
- package/lib/engine/export/utils.d.ts +2 -2
- package/lib/engine/export/utils.js +7 -7
- package/lib/engine/extensions/EXT_texture_exr.d.ts +8 -8
- package/lib/engine/extensions/EXT_texture_exr.js +32 -32
- package/lib/engine/extensions/NEEDLE_animator_controller_model.d.ts +122 -122
- package/lib/engine/extensions/NEEDLE_animator_controller_model.js +95 -95
- package/lib/engine/extensions/NEEDLE_components.d.ts +35 -35
- package/lib/engine/extensions/NEEDLE_components.js +220 -220
- package/lib/engine/extensions/NEEDLE_gameobject_data.d.ts +10 -10
- package/lib/engine/extensions/NEEDLE_gameobject_data.js +57 -57
- package/lib/engine/extensions/NEEDLE_lighting_settings.d.ts +37 -37
- package/lib/engine/extensions/NEEDLE_lighting_settings.js +157 -157
- package/lib/engine/extensions/NEEDLE_lightmaps.d.ts +18 -18
- package/lib/engine/extensions/NEEDLE_lightmaps.js +99 -99
- package/lib/engine/extensions/NEEDLE_persistent_assets.d.ts +11 -11
- package/lib/engine/extensions/NEEDLE_persistent_assets.js +63 -63
- package/lib/engine/extensions/NEEDLE_progressive.d.ts +1 -1
- package/lib/engine/extensions/NEEDLE_progressive.js +1 -1
- package/lib/engine/extensions/NEEDLE_render_objects.d.ts +13 -13
- package/lib/engine/extensions/NEEDLE_render_objects.js +159 -159
- package/lib/engine/extensions/NEEDLE_techniques_webgl.d.ts +38 -38
- package/lib/engine/extensions/NEEDLE_techniques_webgl.js +564 -564
- package/lib/engine/extensions/extension_resolver.d.ts +4 -4
- package/lib/engine/extensions/extension_resolver.js +1 -1
- package/lib/engine/extensions/extension_utils.d.ts +12 -12
- package/lib/engine/extensions/extension_utils.js +152 -152
- package/lib/engine/extensions/extensions.d.ts +32 -32
- package/lib/engine/extensions/extensions.js +107 -107
- package/lib/engine/extensions/index.d.ts +6 -6
- package/lib/engine/extensions/index.js +6 -6
- package/lib/engine/extensions/usage_tracker.d.ts +13 -13
- package/lib/engine/extensions/usage_tracker.js +65 -65
- package/lib/engine/js-extensions/Camera.d.ts +1 -1
- package/lib/engine/js-extensions/Camera.js +39 -39
- package/lib/engine/js-extensions/ExtensionUtils.d.ts +9 -9
- package/lib/engine/js-extensions/ExtensionUtils.js +67 -67
- package/lib/engine/js-extensions/Layers.d.ts +6 -6
- package/lib/engine/js-extensions/Layers.js +22 -22
- package/lib/engine/js-extensions/Object3D.d.ts +120 -120
- package/lib/engine/js-extensions/Object3D.js +136 -136
- package/lib/engine/js-extensions/RGBAColor.d.ts +23 -23
- package/lib/engine/js-extensions/RGBAColor.js +111 -111
- package/lib/engine/js-extensions/Vector.d.ts +3 -3
- package/lib/engine/js-extensions/Vector.js +13 -13
- package/lib/engine/js-extensions/index.d.ts +5 -5
- package/lib/engine/js-extensions/index.js +5 -5
- package/lib/engine/physics/workers/mesh-bvh/GenerateMeshBVHWorker.d.ts +4 -4
- package/lib/engine/physics/workers/mesh-bvh/GenerateMeshBVHWorker.js +79 -79
- package/lib/engine/shaders/shaderData.d.ts +55 -55
- package/lib/engine/shaders/shaderData.js +58 -58
- package/lib/engine/tests/test_utils.d.ts +2 -2
- package/lib/engine/tests/test_utils.js +53 -53
- package/lib/engine/webcomponents/WebXRButtons.d.ts +56 -56
- package/lib/engine/webcomponents/WebXRButtons.js +230 -230
- package/lib/engine/webcomponents/api.d.ts +5 -5
- package/lib/engine/webcomponents/api.js +4 -4
- package/lib/engine/webcomponents/buttons.d.ts +51 -51
- package/lib/engine/webcomponents/buttons.js +264 -264
- package/lib/engine/webcomponents/fonts.d.ts +9 -9
- package/lib/engine/webcomponents/fonts.js +32 -32
- package/lib/engine/webcomponents/icons.d.ts +9 -9
- package/lib/engine/webcomponents/icons.js +52 -52
- package/lib/engine/webcomponents/index.d.ts +1 -1
- package/lib/engine/webcomponents/index.js +1 -1
- package/lib/engine/webcomponents/logo-element.d.ts +10 -10
- package/lib/engine/webcomponents/logo-element.js +67 -67
- package/lib/engine/webcomponents/needle menu/needle-menu-spatial.d.ts +37 -37
- package/lib/engine/webcomponents/needle menu/needle-menu-spatial.js +513 -513
- package/lib/engine/webcomponents/needle menu/needle-menu.d.ts +155 -155
- package/lib/engine/webcomponents/needle menu/needle-menu.js +1029 -1029
- package/lib/engine/webcomponents/needle-button.d.ts +34 -34
- package/lib/engine/webcomponents/needle-button.js +161 -161
- package/lib/engine/webcomponents/needle-engine.ar-overlay.d.ts +21 -21
- package/lib/engine/webcomponents/needle-engine.ar-overlay.js +166 -166
- package/lib/engine/webcomponents/needle-engine.attributes.d.ts +69 -69
- package/lib/engine/webcomponents/needle-engine.attributes.js +1 -1
- package/lib/engine/webcomponents/needle-engine.d.ts +116 -116
- package/lib/engine/webcomponents/needle-engine.extras.d.ts +6 -6
- package/lib/engine/webcomponents/needle-engine.extras.js +13 -13
- package/lib/engine/webcomponents/needle-engine.js +821 -821
- package/lib/engine/webcomponents/needle-engine.loading.d.ts +44 -44
- package/lib/engine/webcomponents/needle-engine.loading.js +341 -341
- package/lib/engine/xr/NeedleXRController.d.ts +313 -313
- package/lib/engine/xr/NeedleXRController.js +1007 -1007
- package/lib/engine/xr/NeedleXRSession.d.ts +340 -340
- package/lib/engine/xr/NeedleXRSession.js +1463 -1463
- package/lib/engine/xr/NeedleXRSync.d.ts +22 -22
- package/lib/engine/xr/NeedleXRSync.js +188 -188
- package/lib/engine/xr/SceneTransition.d.ts +18 -18
- package/lib/engine/xr/SceneTransition.js +69 -69
- package/lib/engine/xr/TempXRContext.d.ts +34 -34
- package/lib/engine/xr/TempXRContext.js +187 -187
- package/lib/engine/xr/XRRig.d.ts +7 -7
- package/lib/engine/xr/XRRig.js +1 -1
- package/lib/engine/xr/api.d.ts +6 -6
- package/lib/engine/xr/api.js +6 -6
- package/lib/engine/xr/events.d.ts +66 -66
- package/lib/engine/xr/events.js +93 -93
- package/lib/engine/xr/internal.d.ts +12 -12
- package/lib/engine/xr/internal.js +25 -25
- package/lib/engine/xr/usdz.d.ts +12 -12
- package/lib/engine/xr/usdz.js +29 -29
- package/lib/engine/xr/utils.d.ts +11 -11
- package/lib/engine/xr/utils.js +34 -34
- package/lib/engine-components/AlignmentConstraint.d.ts +10 -10
- package/lib/engine-components/AlignmentConstraint.js +39 -39
- package/lib/engine-components/Animation.d.ts +156 -156
- package/lib/engine-components/Animation.js +508 -508
- package/lib/engine-components/AnimationCurve.d.ts +40 -40
- package/lib/engine-components/AnimationCurve.js +159 -159
- package/lib/engine-components/AnimationUtils.d.ts +8 -8
- package/lib/engine-components/AnimationUtils.js +27 -27
- package/lib/engine-components/AnimationUtilsAutoplay.d.ts +1 -1
- package/lib/engine-components/AnimationUtilsAutoplay.js +39 -39
- package/lib/engine-components/Animator.d.ts +217 -217
- package/lib/engine-components/Animator.js +354 -354
- package/lib/engine-components/AnimatorController.d.ts +227 -227
- package/lib/engine-components/AnimatorController.js +1152 -1152
- package/lib/engine-components/AudioListener.d.ts +33 -33
- package/lib/engine-components/AudioListener.js +86 -86
- package/lib/engine-components/AudioSource.d.ts +217 -217
- package/lib/engine-components/AudioSource.js +635 -635
- package/lib/engine-components/AvatarLoader.d.ts +80 -80
- package/lib/engine-components/AvatarLoader.js +231 -231
- package/lib/engine-components/AxesHelper.d.ts +32 -32
- package/lib/engine-components/AxesHelper.js +67 -67
- package/lib/engine-components/BasicIKConstraint.d.ts +9 -9
- package/lib/engine-components/BasicIKConstraint.js +43 -43
- package/lib/engine-components/BoxCollider.d.ts +2 -2
- package/lib/engine-components/BoxCollider.js +2 -2
- package/lib/engine-components/BoxHelperComponent.d.ts +47 -47
- package/lib/engine-components/BoxHelperComponent.js +102 -102
- package/lib/engine-components/Camera.d.ts +231 -231
- package/lib/engine-components/Camera.js +700 -700
- package/lib/engine-components/CameraUtils.d.ts +1 -1
- package/lib/engine-components/CameraUtils.js +123 -123
- package/lib/engine-components/CharacterController.d.ts +55 -55
- package/lib/engine-components/CharacterController.js +236 -236
- package/lib/engine-components/Collider.d.ts +188 -188
- package/lib/engine-components/Collider.js +369 -369
- package/lib/engine-components/Component.d.ts +792 -792
- package/lib/engine-components/Component.js +920 -920
- package/lib/engine-components/ContactShadows.d.ts +94 -94
- package/lib/engine-components/ContactShadows.js +453 -453
- package/lib/engine-components/DeleteBox.d.ts +19 -19
- package/lib/engine-components/DeleteBox.js +58 -58
- package/lib/engine-components/DeviceFlag.d.ts +16 -16
- package/lib/engine-components/DeviceFlag.js +47 -47
- package/lib/engine-components/DragControls.d.ts +170 -170
- package/lib/engine-components/DragControls.js +1421 -1421
- package/lib/engine-components/DropListener.d.ts +215 -215
- package/lib/engine-components/DropListener.js +642 -642
- package/lib/engine-components/Duplicatable.d.ts +35 -35
- package/lib/engine-components/Duplicatable.js +202 -202
- package/lib/engine-components/EventList.d.ts +54 -54
- package/lib/engine-components/EventList.js +232 -232
- package/lib/engine-components/EventTrigger.d.ts +33 -33
- package/lib/engine-components/EventTrigger.js +75 -75
- package/lib/engine-components/EventType.d.ts +22 -22
- package/lib/engine-components/EventType.js +23 -23
- package/lib/engine-components/Fog.d.ts +22 -22
- package/lib/engine-components/Fog.js +61 -61
- package/lib/engine-components/Gizmos.d.ts +17 -17
- package/lib/engine-components/Gizmos.js +64 -64
- package/lib/engine-components/GridHelper.d.ts +20 -20
- package/lib/engine-components/GridHelper.js +54 -54
- package/lib/engine-components/GroundProjection.d.ts +67 -67
- package/lib/engine-components/GroundProjection.js +343 -343
- package/lib/engine-components/Interactable.d.ts +12 -12
- package/lib/engine-components/Interactable.js +12 -12
- package/lib/engine-components/Joints.d.ts +19 -19
- package/lib/engine-components/Joints.js +51 -51
- package/lib/engine-components/LODGroup.d.ts +35 -35
- package/lib/engine-components/LODGroup.js +152 -152
- package/lib/engine-components/Light.d.ts +180 -180
- package/lib/engine-components/Light.js +535 -535
- package/lib/engine-components/LookAtConstraint.d.ts +19 -19
- package/lib/engine-components/LookAtConstraint.js +35 -35
- package/lib/engine-components/NeedleMenu.d.ts +50 -50
- package/lib/engine-components/NeedleMenu.js +92 -92
- package/lib/engine-components/NestedGltf.d.ts +25 -25
- package/lib/engine-components/NestedGltf.js +88 -88
- package/lib/engine-components/Networking.d.ts +54 -54
- package/lib/engine-components/Networking.js +112 -112
- package/lib/engine-components/OffsetConstraint.d.ts +14 -14
- package/lib/engine-components/OffsetConstraint.js +65 -65
- package/lib/engine-components/OrbitControls.d.ts +268 -268
- package/lib/engine-components/OrbitControls.js +1015 -1015
- package/lib/engine-components/PlayerColor.d.ts +19 -19
- package/lib/engine-components/PlayerColor.js +94 -94
- package/lib/engine-components/ReflectionProbe.d.ts +28 -28
- package/lib/engine-components/ReflectionProbe.js +204 -204
- package/lib/engine-components/Renderer.d.ts +153 -153
- package/lib/engine-components/Renderer.js +834 -834
- package/lib/engine-components/RendererInstancing.d.ts +140 -140
- package/lib/engine-components/RendererInstancing.js +744 -744
- package/lib/engine-components/RendererLightmap.d.ts +24 -24
- package/lib/engine-components/RendererLightmap.js +182 -182
- package/lib/engine-components/RigidBody.d.ts +155 -155
- package/lib/engine-components/RigidBody.js +517 -517
- package/lib/engine-components/SceneSwitcher.d.ts +263 -263
- package/lib/engine-components/SceneSwitcher.js +971 -971
- package/lib/engine-components/ScreenCapture.d.ts +144 -144
- package/lib/engine-components/ScreenCapture.js +547 -547
- package/lib/engine-components/ShadowCatcher.d.ts +33 -33
- package/lib/engine-components/ShadowCatcher.js +166 -166
- package/lib/engine-components/Skybox.d.ts +88 -88
- package/lib/engine-components/Skybox.js +469 -469
- package/lib/engine-components/SmoothFollow.d.ts +34 -34
- package/lib/engine-components/SmoothFollow.js +82 -82
- package/lib/engine-components/SpatialTrigger.d.ts +102 -102
- package/lib/engine-components/SpatialTrigger.js +225 -225
- package/lib/engine-components/SpectatorCamera.d.ts +111 -111
- package/lib/engine-components/SpectatorCamera.js +715 -715
- package/lib/engine-components/SphereCollider.d.ts +2 -2
- package/lib/engine-components/SphereCollider.js +2 -2
- package/lib/engine-components/SpriteRenderer.d.ts +132 -132
- package/lib/engine-components/SpriteRenderer.js +472 -472
- package/lib/engine-components/SyncedCamera.d.ts +41 -41
- package/lib/engine-components/SyncedCamera.js +199 -199
- package/lib/engine-components/SyncedRoom.d.ts +106 -106
- package/lib/engine-components/SyncedRoom.js +371 -371
- package/lib/engine-components/SyncedTransform.d.ts +94 -94
- package/lib/engine-components/SyncedTransform.js +331 -331
- package/lib/engine-components/TestRunner.d.ts +16 -16
- package/lib/engine-components/TestRunner.js +102 -102
- package/lib/engine-components/TransformGizmo.d.ts +75 -75
- package/lib/engine-components/TransformGizmo.js +209 -209
- package/lib/engine-components/VideoPlayer.d.ts +184 -184
- package/lib/engine-components/VideoPlayer.js +978 -978
- package/lib/engine-components/Voip.d.ts +67 -67
- package/lib/engine-components/Voip.js +360 -360
- package/lib/engine-components/api.d.ts +51 -51
- package/lib/engine-components/api.js +50 -50
- package/lib/engine-components/avatar/AvatarBlink_Simple.d.ts +11 -11
- package/lib/engine-components/avatar/AvatarBlink_Simple.js +76 -76
- package/lib/engine-components/avatar/AvatarEyeLook_Rotation.d.ts +14 -14
- package/lib/engine-components/avatar/AvatarEyeLook_Rotation.js +68 -68
- package/lib/engine-components/avatar/Avatar_Brain_LookAt.d.ts +29 -29
- package/lib/engine-components/avatar/Avatar_Brain_LookAt.js +121 -121
- package/lib/engine-components/avatar/Avatar_MouthShapes.d.ts +15 -15
- package/lib/engine-components/avatar/Avatar_MouthShapes.js +79 -79
- package/lib/engine-components/avatar/Avatar_MustacheShake.d.ts +9 -9
- package/lib/engine-components/avatar/Avatar_MustacheShake.js +29 -29
- package/lib/engine-components/codegen/components.d.ts +216 -216
- package/lib/engine-components/codegen/components.js +218 -218
- package/lib/engine-components/debug/LogStats.d.ts +5 -5
- package/lib/engine-components/debug/LogStats.js +18 -18
- package/lib/engine-components/export/gltf/GltfExport.d.ts +30 -30
- package/lib/engine-components/export/gltf/GltfExport.js +246 -246
- package/lib/engine-components/export/gltf/index.d.ts +1 -1
- package/lib/engine-components/export/gltf/index.js +1 -1
- package/lib/engine-components/export/index.d.ts +1 -1
- package/lib/engine-components/export/index.js +1 -1
- package/lib/engine-components/export/usdz/Extension.d.ts +22 -22
- package/lib/engine-components/export/usdz/Extension.js +1 -1
- package/lib/engine-components/export/usdz/ThreeUSDZExporter.d.ts +162 -162
- package/lib/engine-components/export/usdz/ThreeUSDZExporter.js +1789 -1789
- package/lib/engine-components/export/usdz/USDZExporter.d.ts +130 -130
- package/lib/engine-components/export/usdz/USDZExporter.js +663 -663
- package/lib/engine-components/export/usdz/extensions/Animation.d.ts +106 -106
- package/lib/engine-components/export/usdz/extensions/Animation.js +1071 -1071
- package/lib/engine-components/export/usdz/extensions/DocumentExtension.d.ts +5 -5
- package/lib/engine-components/export/usdz/extensions/DocumentExtension.js +6 -6
- package/lib/engine-components/export/usdz/extensions/NodeMaterialConverter.d.ts +10 -10
- package/lib/engine-components/export/usdz/extensions/NodeMaterialConverter.js +451 -451
- package/lib/engine-components/export/usdz/extensions/USDZText.d.ts +54 -54
- package/lib/engine-components/export/usdz/extensions/USDZText.js +203 -203
- package/lib/engine-components/export/usdz/extensions/USDZUI.d.ts +8 -8
- package/lib/engine-components/export/usdz/extensions/USDZUI.js +158 -158
- package/lib/engine-components/export/usdz/extensions/behavior/Actions.d.ts +30 -30
- package/lib/engine-components/export/usdz/extensions/behavior/Actions.js +88 -88
- package/lib/engine-components/export/usdz/extensions/behavior/AudioExtension.d.ts +10 -10
- package/lib/engine-components/export/usdz/extensions/behavior/AudioExtension.js +86 -86
- package/lib/engine-components/export/usdz/extensions/behavior/Behaviour.d.ts +28 -28
- package/lib/engine-components/export/usdz/extensions/behavior/Behaviour.js +290 -290
- package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.d.ts +190 -190
- package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.js +1060 -1060
- package/lib/engine-components/export/usdz/extensions/behavior/BehavioursBuilder.d.ts +135 -135
- package/lib/engine-components/export/usdz/extensions/behavior/BehavioursBuilder.js +548 -548
- package/lib/engine-components/export/usdz/extensions/behavior/PhysicsExtension.d.ts +7 -7
- package/lib/engine-components/export/usdz/extensions/behavior/PhysicsExtension.js +115 -115
- package/lib/engine-components/export/usdz/index.d.ts +3 -3
- package/lib/engine-components/export/usdz/index.js +2 -2
- package/lib/engine-components/export/usdz/utils/animationutils.d.ts +7 -7
- package/lib/engine-components/export/usdz/utils/animationutils.js +163 -163
- package/lib/engine-components/export/usdz/utils/quicklook.d.ts +2 -2
- package/lib/engine-components/export/usdz/utils/quicklook.js +43 -43
- package/lib/engine-components/particlesystem/ParticleSystem.d.ts +177 -177
- package/lib/engine-components/particlesystem/ParticleSystem.js +1176 -1176
- package/lib/engine-components/particlesystem/ParticleSystemModules.d.ts +526 -526
- package/lib/engine-components/particlesystem/ParticleSystemModules.js +1930 -1930
- package/lib/engine-components/particlesystem/ParticleSystemSubEmitter.d.ts +25 -25
- package/lib/engine-components/particlesystem/ParticleSystemSubEmitter.js +87 -87
- package/lib/engine-components/particlesystem/api.d.ts +2 -2
- package/lib/engine-components/particlesystem/api.js +2 -2
- package/lib/engine-components/postprocessing/Effects/Antialiasing.d.ts +17 -17
- package/lib/engine-components/postprocessing/Effects/Antialiasing.js +59 -59
- package/lib/engine-components/postprocessing/Effects/BloomEffect.d.ts +46 -46
- package/lib/engine-components/postprocessing/Effects/BloomEffect.js +113 -113
- package/lib/engine-components/postprocessing/Effects/ChromaticAberration.d.ts +11 -11
- package/lib/engine-components/postprocessing/Effects/ChromaticAberration.js +39 -39
- package/lib/engine-components/postprocessing/Effects/ColorAdjustments.d.ts +23 -23
- package/lib/engine-components/postprocessing/Effects/ColorAdjustments.js +111 -111
- package/lib/engine-components/postprocessing/Effects/DepthOfField.d.ts +25 -25
- package/lib/engine-components/postprocessing/Effects/DepthOfField.js +104 -104
- package/lib/engine-components/postprocessing/Effects/EffectWrapper.d.ts +12 -12
- package/lib/engine-components/postprocessing/Effects/EffectWrapper.js +18 -18
- package/lib/engine-components/postprocessing/Effects/Pixelation.d.ts +11 -11
- package/lib/engine-components/postprocessing/Effects/Pixelation.js +32 -32
- package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusion.d.ts +18 -18
- package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusion.js +91 -91
- package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusionN8.d.ts +70 -70
- package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusionN8.js +176 -176
- package/lib/engine-components/postprocessing/Effects/Sharpening.d.ts +18 -18
- package/lib/engine-components/postprocessing/Effects/Sharpening.js +127 -127
- package/lib/engine-components/postprocessing/Effects/TiltShiftEffect.d.ts +17 -17
- package/lib/engine-components/postprocessing/Effects/TiltShiftEffect.js +70 -70
- package/lib/engine-components/postprocessing/Effects/Tonemapping.d.ts +19 -19
- package/lib/engine-components/postprocessing/Effects/Tonemapping.js +94 -94
- package/lib/engine-components/postprocessing/Effects/Tonemapping.utils.d.ts +13 -13
- package/lib/engine-components/postprocessing/Effects/Tonemapping.utils.js +51 -51
- package/lib/engine-components/postprocessing/Effects/Vignette.d.ts +15 -15
- package/lib/engine-components/postprocessing/Effects/Vignette.js +60 -60
- package/lib/engine-components/postprocessing/PostProcessingEffect.d.ts +90 -90
- package/lib/engine-components/postprocessing/PostProcessingEffect.js +168 -168
- package/lib/engine-components/postprocessing/PostProcessingHandler.d.ts +42 -42
- package/lib/engine-components/postprocessing/PostProcessingHandler.js +494 -494
- package/lib/engine-components/postprocessing/Volume.d.ts +90 -90
- package/lib/engine-components/postprocessing/Volume.js +385 -385
- package/lib/engine-components/postprocessing/VolumeParameter.d.ts +26 -26
- package/lib/engine-components/postprocessing/VolumeParameter.js +136 -136
- package/lib/engine-components/postprocessing/VolumeProfile.d.ts +15 -15
- package/lib/engine-components/postprocessing/VolumeProfile.js +60 -60
- package/lib/engine-components/postprocessing/index.d.ts +6 -6
- package/lib/engine-components/postprocessing/index.js +6 -6
- package/lib/engine-components/postprocessing/utils.d.ts +55 -55
- package/lib/engine-components/postprocessing/utils.js +119 -119
- package/lib/engine-components/timeline/PlayableDirector.d.ts +163 -163
- package/lib/engine-components/timeline/PlayableDirector.js +686 -686
- package/lib/engine-components/timeline/SignalAsset.d.ts +24 -24
- package/lib/engine-components/timeline/SignalAsset.js +130 -130
- package/lib/engine-components/timeline/TimelineModels.d.ts +89 -89
- package/lib/engine-components/timeline/TimelineModels.js +22 -22
- package/lib/engine-components/timeline/TimelineTracks.d.ts +110 -110
- package/lib/engine-components/timeline/TimelineTracks.js +879 -879
- package/lib/engine-components/timeline/index.d.ts +4 -4
- package/lib/engine-components/timeline/index.js +3 -3
- package/lib/engine-components/ui/BaseUIComponent.d.ts +48 -48
- package/lib/engine-components/ui/BaseUIComponent.js +170 -170
- package/lib/engine-components/ui/Button.d.ts +64 -64
- package/lib/engine-components/ui/Button.js +315 -315
- package/lib/engine-components/ui/Canvas.d.ts +74 -74
- package/lib/engine-components/ui/Canvas.js +407 -407
- package/lib/engine-components/ui/CanvasGroup.d.ts +19 -19
- package/lib/engine-components/ui/CanvasGroup.js +58 -58
- package/lib/engine-components/ui/EventSystem.d.ts +125 -125
- package/lib/engine-components/ui/EventSystem.js +765 -765
- package/lib/engine-components/ui/Graphic.d.ts +55 -55
- package/lib/engine-components/ui/Graphic.js +255 -255
- package/lib/engine-components/ui/Image.d.ts +35 -35
- package/lib/engine-components/ui/Image.js +116 -116
- package/lib/engine-components/ui/InputField.d.ts +42 -42
- package/lib/engine-components/ui/InputField.js +268 -268
- package/lib/engine-components/ui/Interfaces.d.ts +38 -38
- package/lib/engine-components/ui/Interfaces.js +12 -12
- package/lib/engine-components/ui/Layout.d.ts +84 -84
- package/lib/engine-components/ui/Layout.js +330 -330
- package/lib/engine-components/ui/Outline.d.ts +7 -7
- package/lib/engine-components/ui/Outline.js +20 -20
- package/lib/engine-components/ui/PointerEvents.d.ts +115 -115
- package/lib/engine-components/ui/PointerEvents.js +145 -145
- package/lib/engine-components/ui/RaycastUtils.d.ts +11 -11
- package/lib/engine-components/ui/RaycastUtils.js +67 -67
- package/lib/engine-components/ui/Raycaster.d.ts +30 -30
- package/lib/engine-components/ui/Raycaster.js +95 -95
- package/lib/engine-components/ui/RectTransform.d.ts +61 -61
- package/lib/engine-components/ui/RectTransform.js +356 -356
- package/lib/engine-components/ui/SpatialHtml.d.ts +8 -8
- package/lib/engine-components/ui/SpatialHtml.js +79 -79
- package/lib/engine-components/ui/Symbols.d.ts +1 -1
- package/lib/engine-components/ui/Symbols.js +1 -1
- package/lib/engine-components/ui/Text.d.ts +78 -78
- package/lib/engine-components/ui/Text.js +539 -539
- package/lib/engine-components/ui/Utils.d.ts +24 -24
- package/lib/engine-components/ui/Utils.js +90 -90
- package/lib/engine-components/ui/index.d.ts +1 -1
- package/lib/engine-components/ui/index.js +1 -1
- package/lib/engine-components/utils/EnvironmentScene.d.ts +5 -5
- package/lib/engine-components/utils/EnvironmentScene.js +205 -205
- package/lib/engine-components/utils/LookAt.d.ts +31 -31
- package/lib/engine-components/utils/LookAt.js +82 -82
- package/lib/engine-components/utils/OpenURL.d.ts +42 -42
- package/lib/engine-components/utils/OpenURL.js +119 -119
- package/lib/engine-components/webxr/Avatar.d.ts +25 -25
- package/lib/engine-components/webxr/Avatar.js +255 -255
- package/lib/engine-components/webxr/TeleportTarget.d.ts +7 -7
- package/lib/engine-components/webxr/TeleportTarget.js +7 -7
- package/lib/engine-components/webxr/WebARCameraBackground.d.ts +30 -30
- package/lib/engine-components/webxr/WebARCameraBackground.js +155 -155
- package/lib/engine-components/webxr/WebARSessionRoot.d.ts +98 -98
- package/lib/engine-components/webxr/WebARSessionRoot.js +770 -770
- package/lib/engine-components/webxr/WebXR.d.ts +232 -232
- package/lib/engine-components/webxr/WebXR.js +561 -561
- package/lib/engine-components/webxr/WebXRAvatar.d.ts +27 -27
- package/lib/engine-components/webxr/WebXRAvatar.js +44 -44
- package/lib/engine-components/webxr/WebXRImageTracking.d.ts +86 -86
- package/lib/engine-components/webxr/WebXRImageTracking.js +471 -471
- package/lib/engine-components/webxr/WebXRPlaneTracking.d.ts +92 -92
- package/lib/engine-components/webxr/WebXRPlaneTracking.js +500 -500
- package/lib/engine-components/webxr/WebXRRig.d.ts +32 -32
- package/lib/engine-components/webxr/WebXRRig.js +72 -72
- package/lib/engine-components/webxr/XRFlag.d.ts +38 -38
- package/lib/engine-components/webxr/XRFlag.js +139 -139
- package/lib/engine-components/webxr/controllers/XRControllerFollow.d.ts +47 -47
- package/lib/engine-components/webxr/controllers/XRControllerFollow.js +120 -120
- package/lib/engine-components/webxr/controllers/XRControllerModel.d.ts +43 -43
- package/lib/engine-components/webxr/controllers/XRControllerModel.js +352 -352
- package/lib/engine-components/webxr/controllers/XRControllerMovement.d.ts +78 -78
- package/lib/engine-components/webxr/controllers/XRControllerMovement.js +506 -506
- package/lib/engine-components/webxr/index.d.ts +3 -3
- package/lib/engine-components/webxr/index.js +3 -3
- package/lib/engine-components/webxr/types.d.ts +3 -3
- package/lib/engine-components/webxr/types.js +1 -1
- package/lib/engine-components-experimental/Presentation.d.ts +6 -6
- package/lib/engine-components-experimental/Presentation.js +9 -9
- package/lib/engine-components-experimental/api.d.ts +4 -4
- package/lib/engine-components-experimental/api.js +4 -4
- package/lib/engine-components-experimental/networking/PlayerSync.d.ts +156 -156
- package/lib/engine-components-experimental/networking/PlayerSync.js +377 -377
- package/lib/engine-schemes/api.d.ts +12 -12
- package/lib/engine-schemes/api.js +12 -12
- package/lib/engine-schemes/schemes.d.ts +7 -7
- package/lib/engine-schemes/schemes.js +19 -19
- package/lib/engine-schemes/synced-camera-model.d.ts +25 -25
- package/lib/engine-schemes/synced-camera-model.js +67 -67
- package/lib/engine-schemes/synced-transform-model.d.ts +31 -31
- package/lib/engine-schemes/synced-transform-model.js +66 -66
- package/lib/engine-schemes/transform.d.ts +12 -12
- package/lib/engine-schemes/transform.js +39 -39
- package/lib/engine-schemes/vec2.d.ts +10 -10
- package/lib/engine-schemes/vec2.js +25 -25
- package/lib/engine-schemes/vec3.d.ts +11 -11
- package/lib/engine-schemes/vec3.js +29 -29
- package/lib/engine-schemes/vec4.d.ts +12 -12
- package/lib/engine-schemes/vec4.js +33 -33
- package/lib/engine-schemes/vr-user-state-buffer.d.ts +37 -37
- package/lib/engine-schemes/vr-user-state-buffer.js +110 -110
- package/lib/include/three/EXT_mesh_gpu_instancing_exporter.d.ts +6 -6
- package/lib/include/three/EXT_mesh_gpu_instancing_exporter.js +45 -45
- package/lib/needle-engine.d.ts +7 -7
- package/lib/needle-engine.js +64 -64
- package/package.json +3 -3
- package/plugins/common/buildinfo.js +64 -64
- package/plugins/common/cloud.js +1 -1
- package/plugins/common/config.cjs +31 -31
- package/plugins/common/config.js +35 -35
- package/plugins/common/files.js +31 -31
- package/plugins/common/generator.js +10 -10
- package/plugins/common/license.js +452 -452
- package/plugins/common/logger.js +327 -327
- package/plugins/common/npm.js +15 -15
- package/plugins/common/timers.js +7 -7
- package/plugins/common/version.js +37 -37
- package/plugins/gltf-packer.mjs +1 -1
- package/plugins/next/alias.cjs +39 -39
- package/plugins/next/license.cjs +24 -24
- package/plugins/next/meshbvhworker.cjs +18 -18
- package/plugins/next/next.js +141 -141
- package/plugins/types/index.d.ts +2 -2
- package/plugins/types/license.d.ts +24 -24
- package/plugins/types/needleConfig.d.ts +27 -27
- package/plugins/types/next.d.ts +2 -2
- package/plugins/types/userconfig.d.ts +124 -124
- package/plugins/types/vite.d.ts +13 -13
- package/plugins/types/webmanifest.d.ts +32 -32
- package/plugins/vite/alias.js +189 -189
- package/plugins/vite/asap.js +251 -251
- package/plugins/vite/build-pipeline.js +371 -371
- package/plugins/vite/build.js +19 -19
- package/plugins/vite/buildinfo.js +41 -41
- package/plugins/vite/config.js +106 -106
- package/plugins/vite/copyfiles.js +138 -138
- package/plugins/vite/defines.js +70 -70
- package/plugins/vite/dependencies.js +232 -232
- package/plugins/vite/dependency-watcher.js +237 -237
- package/plugins/vite/drop-client.js +76 -76
- package/plugins/vite/drop.js +87 -87
- package/plugins/vite/editor-connection.js +124 -124
- package/plugins/vite/facebook-instant-games.js +102 -102
- package/plugins/vite/gzip.js +5 -5
- package/plugins/vite/imports-logger.js +143 -143
- package/plugins/vite/index.js +147 -147
- package/plugins/vite/license.js +56 -56
- package/plugins/vite/local-files.js +440 -440
- package/plugins/vite/logger.client.js +272 -272
- package/plugins/vite/logger.js +100 -100
- package/plugins/vite/materialx.js +31 -31
- package/plugins/vite/meta.js +163 -163
- package/plugins/vite/npm.js +7 -7
- package/plugins/vite/peer.js +29 -29
- package/plugins/vite/poster-client.js +73 -73
- package/plugins/vite/poster.js +79 -79
- package/plugins/vite/pwa.js +604 -604
- package/plugins/vite/reload-client.js +15 -15
- package/plugins/vite/reload.js +351 -351
- package/plugins/vite/server.js +66 -66
- package/plugins/vite/transform-codegen.js +55 -55
- package/plugins/vite/transform.js +32 -32
- package/plugins/vite/vite-4.4-hack.js +31 -31
- package/src/asap/needle-asap.ts +111 -111
- package/src/asap/sessiongranted.ts +75 -75
- package/src/asap/utils.ts +4 -4
- package/src/engine/analytics/index.ts +10 -10
- package/src/engine/analytics/lcp.ts +35 -35
- package/src/engine/api.ts +82 -82
- package/src/engine/assets/index.ts +59 -59
- package/src/engine/assets/static.js +5 -5
- package/src/engine/codegen/register_types.ts +300 -300
- package/src/engine/debug/debug.ts +51 -51
- package/src/engine/debug/debug_console.ts +333 -333
- package/src/engine/debug/debug_overlay.ts +332 -332
- package/src/engine/debug/debug_spatial_console.ts +429 -429
- package/src/engine/debug/index.ts +1 -1
- package/src/engine/engine_addressables.ts +671 -671
- package/src/engine/engine_animation.ts +145 -145
- package/src/engine/engine_application.ts +113 -113
- package/src/engine/engine_assetdatabase.ts +389 -389
- package/src/engine/engine_audio.ts +24 -24
- package/src/engine/engine_camera.ts +39 -39
- package/src/engine/engine_components.ts +366 -366
- package/src/engine/engine_components_internal.ts +40 -40
- package/src/engine/engine_constants.ts +52 -52
- package/src/engine/engine_context.ts +1824 -1824
- package/src/engine/engine_context_registry.ts +129 -129
- package/src/engine/engine_coroutine.ts +54 -54
- package/src/engine/engine_create_objects.ts +411 -411
- package/src/engine/engine_default_parameters.ts +3 -3
- package/src/engine/engine_editor-sync.ts +28 -28
- package/src/engine/engine_fileloader.js +9 -9
- package/src/engine/engine_gameobject.ts +712 -712
- package/src/engine/engine_generic_utils.js +13 -13
- package/src/engine/engine_gizmos.ts +577 -577
- package/src/engine/engine_gltf.ts +29 -29
- package/src/engine/engine_gltf_builtin_components.ts +403 -403
- package/src/engine/engine_hot_reload.ts +210 -210
- package/src/engine/engine_input.ts +1500 -1500
- package/src/engine/engine_input_utils.ts +23 -23
- package/src/engine/engine_instancing.ts +45 -45
- package/src/engine/engine_license.ts +386 -386
- package/src/engine/engine_lifecycle_api.ts +113 -113
- package/src/engine/engine_lifecycle_functions_internal.ts +193 -193
- package/src/engine/engine_lightdata.ts +125 -125
- package/src/engine/engine_loaders.callbacks.ts +136 -136
- package/src/engine/engine_loaders.gltf.ts +82 -82
- package/src/engine/engine_loaders.ts +378 -378
- package/src/engine/engine_lods.ts +186 -186
- package/src/engine/engine_mainloop_utils.ts +472 -472
- package/src/engine/engine_math.ts +282 -282
- package/src/engine/engine_modules.ts +83 -83
- package/src/engine/engine_networking.ts +862 -862
- package/src/engine/engine_networking_auto.ts +352 -352
- package/src/engine/engine_networking_blob.ts +275 -275
- package/src/engine/engine_networking_files.ts +217 -217
- package/src/engine/engine_networking_files_default_components.ts +58 -58
- package/src/engine/engine_networking_instantiate.ts +419 -419
- package/src/engine/engine_networking_peer.ts +159 -159
- package/src/engine/engine_networking_streams.ts +713 -713
- package/src/engine/engine_networking_types.ts +24 -24
- package/src/engine/engine_networking_utils.ts +23 -23
- package/src/engine/engine_networking_websocket.ts +2 -2
- package/src/engine/engine_patcher.ts +199 -199
- package/src/engine/engine_physics.ts +783 -783
- package/src/engine/engine_physics.types.ts +46 -46
- package/src/engine/engine_physics_rapier.ts +1577 -1577
- package/src/engine/engine_playerview.ts +80 -80
- package/src/engine/engine_scenelighting.ts +294 -294
- package/src/engine/engine_serialization.ts +2 -2
- package/src/engine/engine_serialization_builtin_serializer.ts +473 -473
- package/src/engine/engine_serialization_core.ts +720 -720
- package/src/engine/engine_serialization_decorator.ts +80 -80
- package/src/engine/engine_setup.ts +1 -1
- package/src/engine/engine_shaders.ts +267 -267
- package/src/engine/engine_shims.ts +32 -32
- package/src/engine/engine_test_utils.ts +109 -109
- package/src/engine/engine_texture.ts +82 -82
- package/src/engine/engine_three_utils.ts +928 -928
- package/src/engine/engine_time.ts +94 -94
- package/src/engine/engine_time_utils.ts +237 -237
- package/src/engine/engine_tonemapping.ts +208 -208
- package/src/engine/engine_types.ts +730 -730
- package/src/engine/engine_typestore.ts +63 -63
- package/src/engine/engine_util_decorator.ts +136 -136
- package/src/engine/engine_utils.ts +1115 -1115
- package/src/engine/engine_utils_format.ts +273 -273
- package/src/engine/engine_utils_screenshot.ts +708 -708
- package/src/engine/engine_utils_screenshot.xr.ts +103 -103
- package/src/engine/export/gltf/Writers.ts +34 -34
- package/src/engine/export/gltf/index.ts +158 -158
- package/src/engine/export/index.ts +2 -2
- package/src/engine/export/state.ts +19 -19
- package/src/engine/export/utils.ts +9 -9
- package/src/engine/extensions/EXT_texture_exr.ts +50 -50
- package/src/engine/extensions/NEEDLE_animator_controller_model.ts +195 -195
- package/src/engine/extensions/NEEDLE_components.ts +268 -268
- package/src/engine/extensions/NEEDLE_gameobject_data.ts +81 -81
- package/src/engine/extensions/NEEDLE_lighting_settings.ts +185 -185
- package/src/engine/extensions/NEEDLE_lightmaps.ts +119 -119
- package/src/engine/extensions/NEEDLE_persistent_assets.ts +76 -76
- package/src/engine/extensions/NEEDLE_render_objects.ts +209 -209
- package/src/engine/extensions/NEEDLE_techniques_webgl.ts +640 -640
- package/src/engine/extensions/extension_resolver.ts +4 -4
- package/src/engine/extensions/extension_utils.ts +166 -166
- package/src/engine/extensions/extensions.ts +140 -140
- package/src/engine/extensions/index.ts +5 -5
- package/src/engine/extensions/usage_tracker.ts +100 -100
- package/src/engine/js-extensions/Camera.ts +37 -37
- package/src/engine/js-extensions/ExtensionUtils.ts +85 -85
- package/src/engine/js-extensions/Layers.ts +23 -23
- package/src/engine/js-extensions/Object3D.ts +296 -296
- package/src/engine/js-extensions/RGBAColor.ts +126 -126
- package/src/engine/js-extensions/Vector.ts +18 -18
- package/src/engine/js-extensions/index.ts +4 -4
- package/src/engine/physics/workers/mesh-bvh/GenerateMeshBVHWorker.js +125 -125
- package/src/engine/shaders/shaderData.ts +67 -67
- package/src/engine/tests/test_utils.ts +63 -63
- package/src/engine/webcomponents/WebXRButtons.ts +260 -260
- package/src/engine/webcomponents/api.ts +6 -6
- package/src/engine/webcomponents/buttons.ts +292 -292
- package/src/engine/webcomponents/fonts.ts +41 -41
- package/src/engine/webcomponents/icons.ts +57 -57
- package/src/engine/webcomponents/index.ts +1 -1
- package/src/engine/webcomponents/logo-element.ts +78 -78
- package/src/engine/webcomponents/needle menu/needle-menu-spatial.ts +573 -573
- package/src/engine/webcomponents/needle menu/needle-menu.ts +1118 -1118
- package/src/engine/webcomponents/needle-button.ts +181 -181
- package/src/engine/webcomponents/needle-engine.ar-overlay.ts +186 -186
- package/src/engine/webcomponents/needle-engine.attributes.ts +82 -82
- package/src/engine/webcomponents/needle-engine.extras.ts +16 -16
- package/src/engine/webcomponents/needle-engine.loading.ts +373 -373
- package/src/engine/webcomponents/needle-engine.ts +860 -860
- package/src/engine/xr/NeedleXRController.ts +1125 -1125
- package/src/engine/xr/NeedleXRSession.ts +1624 -1624
- package/src/engine/xr/NeedleXRSync.ts +220 -220
- package/src/engine/xr/SceneTransition.ts +78 -78
- package/src/engine/xr/TempXRContext.ts +216 -216
- package/src/engine/xr/XRRig.ts +9 -9
- package/src/engine/xr/api.ts +5 -5
- package/src/engine/xr/events.ts +102 -102
- package/src/engine/xr/internal.ts +34 -34
- package/src/engine/xr/usdz.ts +30 -30
- package/src/engine/xr/utils.ts +39 -39
- package/src/engine-components/AlignmentConstraint.ts +36 -36
- package/src/engine-components/Animation.ts +557 -557
- package/src/engine-components/AnimationCurve.ts +150 -150
- package/src/engine-components/AnimationUtils.ts +28 -28
- package/src/engine-components/AnimationUtilsAutoplay.ts +43 -43
- package/src/engine-components/Animator.ts +397 -397
- package/src/engine-components/AnimatorController.ts +1293 -1293
- package/src/engine-components/AudioListener.ts +92 -92
- package/src/engine-components/AudioSource.ts +644 -644
- package/src/engine-components/AvatarLoader.ts +263 -263
- package/src/engine-components/AxesHelper.ts +59 -59
- package/src/engine-components/BasicIKConstraint.ts +54 -54
- package/src/engine-components/BoxCollider.ts +1 -1
- package/src/engine-components/BoxHelperComponent.ts +114 -114
- package/src/engine-components/Camera.ts +719 -719
- package/src/engine-components/CameraUtils.ts +138 -138
- package/src/engine-components/CharacterController.ts +253 -253
- package/src/engine-components/Collider.ts +374 -374
- package/src/engine-components/Component.ts +1297 -1297
- package/src/engine-components/ContactShadows.ts +506 -506
- package/src/engine-components/DeleteBox.ts +62 -62
- package/src/engine-components/DeviceFlag.ts +46 -46
- package/src/engine-components/DragControls.ts +1623 -1623
- package/src/engine-components/DropListener.ts +713 -713
- package/src/engine-components/Duplicatable.ts +198 -198
- package/src/engine-components/EventList.ts +266 -266
- package/src/engine-components/EventTrigger.ts +74 -74
- package/src/engine-components/EventType.ts +22 -22
- package/src/engine-components/Fog.ts +60 -60
- package/src/engine-components/Gizmos.ts +56 -56
- package/src/engine-components/GridHelper.ts +48 -48
- package/src/engine-components/GroundProjection.ts +356 -356
- package/src/engine-components/Interactable.ts +14 -14
- package/src/engine-components/Joints.ts +52 -52
- package/src/engine-components/LODGroup.ts +153 -153
- package/src/engine-components/Light.ts +558 -558
- package/src/engine-components/LookAtConstraint.ts +25 -25
- package/src/engine-components/NeedleMenu.ts +84 -84
- package/src/engine-components/NestedGltf.ts +86 -86
- package/src/engine-components/Networking.ts +114 -114
- package/src/engine-components/OffsetConstraint.ts +60 -60
- package/src/engine-components/OrbitControls.ts +1074 -1074
- package/src/engine-components/PlayerColor.ts +103 -103
- package/src/engine-components/ReflectionProbe.ts +220 -220
- package/src/engine-components/Renderer.ts +903 -903
- package/src/engine-components/RendererInstancing.ts +855 -855
- package/src/engine-components/RendererLightmap.ts +198 -198
- package/src/engine-components/RigidBody.ts +526 -526
- package/src/engine-components/SceneSwitcher.ts +1030 -1030
- package/src/engine-components/ScreenCapture.ts +592 -592
- package/src/engine-components/ShadowCatcher.ts +172 -172
- package/src/engine-components/Skybox.ts +475 -475
- package/src/engine-components/SmoothFollow.ts +76 -76
- package/src/engine-components/SpatialTrigger.ts +229 -229
- package/src/engine-components/SpectatorCamera.ts +787 -787
- package/src/engine-components/SphereCollider.ts +1 -1
- package/src/engine-components/SpriteRenderer.ts +468 -468
- package/src/engine-components/SyncedCamera.ts +220 -220
- package/src/engine-components/SyncedRoom.ts +380 -380
- package/src/engine-components/SyncedTransform.ts +383 -383
- package/src/engine-components/TestRunner.ts +118 -118
- package/src/engine-components/TransformGizmo.ts +219 -219
- package/src/engine-components/VideoPlayer.ts +1025 -1025
- package/src/engine-components/Voip.ts +363 -363
- package/src/engine-components/api.ts +60 -60
- package/src/engine-components/avatar/AvatarBlink_Simple.ts +69 -69
- package/src/engine-components/avatar/AvatarEyeLook_Rotation.ts +63 -63
- package/src/engine-components/avatar/Avatar_Brain_LookAt.ts +139 -139
- package/src/engine-components/avatar/Avatar_MouthShapes.ts +83 -83
- package/src/engine-components/avatar/Avatar_MustacheShake.ts +31 -31
- package/src/engine-components/codegen/components.ts +217 -217
- package/src/engine-components/debug/LogStats.ts +21 -21
- package/src/engine-components/export/gltf/GltfExport.ts +265 -265
- package/src/engine-components/export/usdz/Extension.ts +24 -24
- package/src/engine-components/export/usdz/ThreeUSDZExporter.ts +2426 -2426
- package/src/engine-components/export/usdz/USDZExporter.ts +705 -705
- package/src/engine-components/export/usdz/extensions/Animation.ts +1204 -1204
- package/src/engine-components/export/usdz/extensions/DocumentExtension.ts +9 -9
- package/src/engine-components/export/usdz/extensions/NodeMaterialConverter.ts +532 -532
- package/src/engine-components/export/usdz/extensions/USDZText.ts +240 -240
- package/src/engine-components/export/usdz/extensions/USDZUI.ts +189 -189
- package/src/engine-components/export/usdz/extensions/behavior/Actions.ts +99 -99
- package/src/engine-components/export/usdz/extensions/behavior/AudioExtension.ts +102 -102
- package/src/engine-components/export/usdz/extensions/behavior/Behaviour.ts +320 -320
- package/src/engine-components/export/usdz/extensions/behavior/BehaviourComponents.ts +1225 -1225
- package/src/engine-components/export/usdz/extensions/behavior/BehavioursBuilder.ts +646 -646
- package/src/engine-components/export/usdz/extensions/behavior/PhysicsExtension.ts +132 -132
- package/src/engine-components/export/usdz/index.ts +2 -2
- package/src/engine-components/export/usdz/utils/animationutils.ts +191 -191
- package/src/engine-components/export/usdz/utils/quicklook.ts +50 -50
- package/src/engine-components/particlesystem/ParticleSystem.ts +1287 -1287
- package/src/engine-components/particlesystem/ParticleSystemModules.ts +1765 -1765
- package/src/engine-components/particlesystem/ParticleSystemSubEmitter.ts +111 -111
- package/src/engine-components/particlesystem/api.ts +1 -1
- package/src/engine-components/postprocessing/Effects/Antialiasing.ts +64 -64
- package/src/engine-components/postprocessing/Effects/BloomEffect.ts +116 -116
- package/src/engine-components/postprocessing/Effects/ChromaticAberration.ts +37 -37
- package/src/engine-components/postprocessing/Effects/ColorAdjustments.ts +106 -106
- package/src/engine-components/postprocessing/Effects/DepthOfField.ts +103 -103
- package/src/engine-components/postprocessing/Effects/EffectWrapper.ts +25 -25
- package/src/engine-components/postprocessing/Effects/Pixelation.ts +32 -32
- package/src/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusion.ts +90 -90
- package/src/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusionN8.ts +192 -192
- package/src/engine-components/postprocessing/Effects/Sharpening.ts +143 -143
- package/src/engine-components/postprocessing/Effects/TiltShiftEffect.ts +61 -61
- package/src/engine-components/postprocessing/Effects/Tonemapping.ts +103 -103
- package/src/engine-components/postprocessing/Effects/Tonemapping.utils.ts +60 -60
- package/src/engine-components/postprocessing/Effects/Vignette.ts +59 -59
- package/src/engine-components/postprocessing/PostProcessingEffect.ts +192 -192
- package/src/engine-components/postprocessing/PostProcessingHandler.ts +572 -572
- package/src/engine-components/postprocessing/Volume.ts +426 -426
- package/src/engine-components/postprocessing/VolumeParameter.ts +158 -158
- package/src/engine-components/postprocessing/VolumeProfile.ts +61 -61
- package/src/engine-components/postprocessing/index.ts +5 -5
- package/src/engine-components/postprocessing/utils.ts +154 -154
- package/src/engine-components/timeline/PlayableDirector.ts +722 -722
- package/src/engine-components/timeline/SignalAsset.ts +144 -144
- package/src/engine-components/timeline/TimelineModels.ts +92 -92
- package/src/engine-components/timeline/TimelineTracks.ts +967 -967
- package/src/engine-components/timeline/index.ts +3 -3
- package/src/engine-components/ui/BaseUIComponent.ts +203 -203
- package/src/engine-components/ui/Button.ts +307 -307
- package/src/engine-components/ui/Canvas.ts +419 -419
- package/src/engine-components/ui/CanvasGroup.ts +54 -54
- package/src/engine-components/ui/EventSystem.ts +854 -854
- package/src/engine-components/ui/Graphic.ts +275 -275
- package/src/engine-components/ui/Image.ts +112 -112
- package/src/engine-components/ui/InputField.ts +321 -321
- package/src/engine-components/ui/Interfaces.ts +57 -57
- package/src/engine-components/ui/Layout.ts +334 -334
- package/src/engine-components/ui/Outline.ts +13 -13
- package/src/engine-components/ui/PointerEvents.ts +206 -206
- package/src/engine-components/ui/RaycastUtils.ts +69 -69
- package/src/engine-components/ui/Raycaster.ts +102 -102
- package/src/engine-components/ui/RectTransform.ts +375 -375
- package/src/engine-components/ui/SpatialHtml.ts +79 -79
- package/src/engine-components/ui/Symbols.ts +1 -1
- package/src/engine-components/ui/Text.ts +578 -578
- package/src/engine-components/ui/Utils.ts +113 -113
- package/src/engine-components/utils/EnvironmentScene.ts +245 -245
- package/src/engine-components/utils/LookAt.ts +88 -88
- package/src/engine-components/utils/OpenURL.ts +114 -114
- package/src/engine-components/webxr/Avatar.ts +265 -265
- package/src/engine-components/webxr/TeleportTarget.ts +9 -9
- package/src/engine-components/webxr/WebARCameraBackground.ts +175 -175
- package/src/engine-components/webxr/WebARSessionRoot.ts +880 -880
- package/src/engine-components/webxr/WebXR.ts +585 -585
- package/src/engine-components/webxr/WebXRAvatar.ts +66 -66
- package/src/engine-components/webxr/WebXRImageTracking.ts +519 -519
- package/src/engine-components/webxr/WebXRPlaneTracking.ts +570 -570
- package/src/engine-components/webxr/WebXRRig.ts +77 -77
- package/src/engine-components/webxr/XRFlag.ts +147 -147
- package/src/engine-components/webxr/controllers/XRControllerFollow.ts +118 -118
- package/src/engine-components/webxr/controllers/XRControllerModel.ts +373 -373
- package/src/engine-components/webxr/controllers/XRControllerMovement.ts +550 -550
- package/src/engine-components/webxr/index.ts +2 -2
- package/src/engine-components/webxr/types.ts +3 -3
- package/src/engine-components-experimental/Presentation.ts +12 -12
- package/src/engine-components-experimental/api.ts +4 -4
- package/src/engine-components-experimental/networking/PlayerSync.ts +401 -401
- package/src/engine-schemes/COMPILE_SCHEMES.bat +3 -3
- package/src/engine-schemes/COMPILE_TS.bat +11 -11
- package/src/engine-schemes/README.md +1 -1
- package/src/engine-schemes/api.ts +12 -12
- package/src/engine-schemes/schemes.ts +28 -28
- package/src/engine-schemes/synced-camera-model.ts +92 -92
- package/src/engine-schemes/synced-transform-model.ts +90 -90
- package/src/engine-schemes/syncedCamera.fbs +10 -10
- package/src/engine-schemes/transform.ts +50 -50
- package/src/engine-schemes/transforms.fbs +25 -25
- package/src/engine-schemes/vec.fbs +19 -19
- package/src/engine-schemes/vec2.ts +33 -33
- package/src/engine-schemes/vec3.ts +38 -38
- package/src/engine-schemes/vec4.ts +43 -43
- package/src/engine-schemes/vr-user-state-buffer.ts +145 -145
- package/src/engine-schemes/vrUserStateBuffer.fbs +17 -17
- package/src/include/draco/draco_decoder.js +34 -34
- package/src/include/ktx2/basis_transcoder.js +21 -21
- package/src/include/needle/arial-msdf.json +1471 -1471
- package/src/include/three/DragControls.js +231 -231
- package/src/include/three/EXT_mesh_gpu_instancing_exporter.js +66 -66
- package/src/needle-engine.ts +70 -70
- package/dist/generateMeshBVH.worker-Cdfpaq5W.js +0 -25
- package/src/engine-schemes/dist/api.js +0 -17
- package/src/engine-schemes/dist/api.js.meta +0 -7
- package/src/engine-schemes/dist/schemes.js +0 -25
- package/src/engine-schemes/dist/schemes.js.meta +0 -7
- package/src/engine-schemes/dist/synced-camera-model.js +0 -74
- package/src/engine-schemes/dist/synced-camera-model.js.meta +0 -7
- package/src/engine-schemes/dist/synced-transform-model.js +0 -73
- package/src/engine-schemes/dist/synced-transform-model.js.meta +0 -7
- package/src/engine-schemes/dist/transform.js +0 -46
- package/src/engine-schemes/dist/transform.js.meta +0 -7
- package/src/engine-schemes/dist/vec2.js +0 -32
- package/src/engine-schemes/dist/vec2.js.meta +0 -7
- package/src/engine-schemes/dist/vec3.js +0 -36
- package/src/engine-schemes/dist/vec3.js.meta +0 -7
- package/src/engine-schemes/dist/vec4.js +0 -40
- package/src/engine-schemes/dist/vec4.js.meta +0 -7
- package/src/engine-schemes/dist/vr-user-state-buffer.js +0 -110
- package/src/engine-schemes/dist/vr-user-state-buffer.js.meta +0 -7
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* @license
|
|
3
3
|
* Copyright 2010-2024 Three.js Authors
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
|
-
*/const Vn="169",f0={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},g0={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},v0=0,Hd=1,y0=2,QS=3,ew=0,Gd=1,Wd=2,rr=3,an=0,si=1,Gr=2,Er=0,_n=1,Ao=2,jd=3,Xd=4,qd=5,Bn=100,x0=101,_0=102,M0=103,Yd=104,b0=200,T0=201,S0=202,w0=203,Sc=204,wc=205,E0=206,A0=207,N0=208,C0=209,R0=210,I0=211,L0=212,P0=213,D0=214,No=0,Co=1,Ro=2,zn=3,Io=4,Lo=5,Po=6,Do=7,ma=0,$d=1,Jd=2,mr=0,Ec=1,Ac=2,Kd=3,Nc=4,U0=5,Cc=6,Rc=7,Zd="attached",O0="detached",Ic=300,fr=301,Ar=302,kn=303,Hn=304,xs=306,Gn=1e3,gr=1001,fa=1002,$t=1003,Lc=1004,tw=1004,Mn=1005,iw=1005,Lt=1006,Wn=1007,rw=1007,ji=1008,F0=1008,Wr=1009,Qd=1010,ep=1011,ga=1012,va=1013,Nr=1014,Oi=1015,wi=1016,Pc=1017,Dc=1018,jn=1020,tp=35902,ip=1021,rp=1022,Ei=1023,np=1024,sp=1025,Xn=1026,qn=1027,Uo=1028,Oo=1029,ya=1030,Uc=1031,nw=1032,Oc=1033,Fo=33776,xa=33777,Vo=33778,_a=33779,Bo=35840,Fc=35841,zo=35842,Vc=35843,ko=36196,Ho=37492,Go=37496,Wo=37808,Bc=37809,zc=37810,kc=37811,jo=37812,Hc=37813,Gc=37814,Wc=37815,jc=37816,Xc=37817,qc=37818,Yc=37819,$c=37820,Jc=37821,Ma=36492,Kc=36494,Zc=36495,ap=36283,Qc=36284,eu=36285,tu=36286,op=2200,lp=2201,V0=2202,ba=2300,Xo=2301,iu=2302,_s=2400,Ms=2401,qo=2402,ru=2500,cp=2501,B0=0,z0=1,k0=2,up=3200,hp=3201,sw=3202,aw=3203,on=0,dp=1,Cr="",Fi="srgb",nr="srgb-linear",Yo="display-p3",Ta="display-p3-linear",$o="linear",Ot="srgb",Jo="rec709",Ko="p3",H0=0,Yn=7680,G0=7681,W0=7682,j0=7683,X0=34055,q0=34056,Y0=5386,$0=512,J0=513,K0=514,Z0=515,Q0=516,ev=517,tv=518,nu=519,iv=512,pp=513,rv=514,mp=515,nv=516,sv=517,av=518,ov=519,Sa=35044,bs=35048,ow=35040,lw=35045,cw=35049,uw=35041,hw=35046,dw=35050,pw=35042,mw="100",su="300 es",Rr=2e3,Ts=2001;class vr{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;const i=this._listeners;return i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const i=this._listeners[e];if(i!==void 0){const r=i.indexOf(t);r!==-1&&i.splice(r,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const t=this._listeners[e.type];if(t!==void 0){e.target=this;const i=t.slice(0);for(let r=0,s=i.length;r<s;r++)i[r].call(this,e);e.target=null}}}const Vi=["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 lv=1234567;const Ss=Math.PI/180,wa=180/Math.PI;function yr(){const n=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Vi[n&255]+Vi[n>>8&255]+Vi[n>>16&255]+Vi[n>>24&255]+"-"+Vi[e&255]+Vi[e>>8&255]+"-"+Vi[e>>16&15|64]+Vi[e>>24&255]+"-"+Vi[t&63|128]+Vi[t>>8&255]+"-"+Vi[t>>16&255]+Vi[t>>24&255]+Vi[i&255]+Vi[i>>8&255]+Vi[i>>16&255]+Vi[i>>24&255]).toLowerCase()}function Jt(n,e,t){return Math.max(e,Math.min(t,n))}function fp(n,e){return(n%e+e)%e}function fw(n,e,t,i,r){return i+(n-e)*(r-i)/(t-e)}function gw(n,e,t){return n!==e?(t-n)/(e-n):0}function Zo(n,e,t){return(1-t)*n+t*e}function vw(n,e,t,i){return Zo(n,e,1-Math.exp(-t*i))}function yw(n,e=1){return e-Math.abs(fp(n,e*2)-e)}function xw(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*(3-2*n))}function _w(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*n*(n*(n*6-15)+10))}function Mw(n,e){return n+Math.floor(Math.random()*(e-n+1))}function bw(n,e){return n+Math.random()*(e-n)}function Tw(n){return n*(.5-Math.random())}function Sw(n){n!==void 0&&(lv=n);let e=lv+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function ww(n){return n*Ss}function Ew(n){return n*wa}function Aw(n){return(n&n-1)===0&&n!==0}function Nw(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function Cw(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function Rw(n,e,t,i,r){const s=Math.cos,a=Math.sin,o=s(t/2),l=a(t/2),c=s((e+i)/2),u=a((e+i)/2),h=s((e-i)/2),d=a((e-i)/2),p=s((i-e)/2),m=a((i-e)/2);switch(r){case"XYX":n.set(o*u,l*h,l*d,o*c);break;case"YZY":n.set(l*d,o*u,l*h,o*c);break;case"ZXZ":n.set(l*h,l*d,o*u,o*c);break;case"XZX":n.set(o*u,l*m,l*p,o*c);break;case"YXY":n.set(l*p,o*u,l*m,o*c);break;case"ZYZ":n.set(l*m,l*p,o*u,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function Xi(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("Invalid component type.")}}function ht(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("Invalid component type.")}}const au={DEG2RAD:Ss,RAD2DEG:wa,generateUUID:yr,clamp:Jt,euclideanModulo:fp,mapLinear:fw,inverseLerp:gw,lerp:Zo,damp:vw,pingpong:yw,smoothstep:xw,smootherstep:_w,randInt:Mw,randFloat:bw,randFloatSpread:Tw,seededRandom:Sw,degToRad:ww,radToDeg:Ew,isPowerOfTwo:Aw,ceilPowerOfTwo:Nw,floorPowerOfTwo:Cw,setQuaternionFromProperEuler:Rw,normalize:ht,denormalize:Xi};class J{constructor(e=0,t=0){J.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,i=this.y,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6],this.y=r[1]*t+r[4]*i+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(Jt(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const i=Math.cos(t),r=Math.sin(t),s=this.x-e.x,a=this.y-e.y;return this.x=s*i-a*r+e.x,this.y=s*r+a*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Ke{constructor(e,t,i,r,s,a,o,l,c){Ke.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,r,s,a,o,l,c)}set(e,t,i,r,s,a,o,l,c){const u=this.elements;return u[0]=e,u[1]=r,u[2]=o,u[3]=t,u[4]=s,u[5]=l,u[6]=i,u[7]=a,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,r=t.elements,s=this.elements,a=i[0],o=i[3],l=i[6],c=i[1],u=i[4],h=i[7],d=i[2],p=i[5],m=i[8],v=r[0],f=r[3],g=r[6],x=r[1],y=r[4],_=r[7],I=r[2],b=r[5],w=r[8];return s[0]=a*v+o*x+l*I,s[3]=a*f+o*y+l*b,s[6]=a*g+o*_+l*w,s[1]=c*v+u*x+h*I,s[4]=c*f+u*y+h*b,s[7]=c*g+u*_+h*w,s[2]=d*v+p*x+m*I,s[5]=d*f+p*y+m*b,s[8]=d*g+p*_+m*w,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8];return t*a*u-t*o*c-i*s*u+i*o*l+r*s*c-r*a*l}invert(){const e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8],h=u*a-o*c,d=o*l-u*s,p=c*s-a*l,m=t*h+i*d+r*p;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/m;return e[0]=h*v,e[1]=(r*c-u*i)*v,e[2]=(o*i-r*a)*v,e[3]=d*v,e[4]=(u*t-r*l)*v,e[5]=(r*s-o*t)*v,e[6]=p*v,e[7]=(i*l-c*t)*v,e[8]=(a*t-i*s)*v,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,r,s,a,o){const l=Math.cos(s),c=Math.sin(s);return this.set(i*l,i*c,-i*(l*a+c*o)+a+e,-r*c,r*l,-r*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(gp.makeScale(e,t)),this}rotate(e){return this.premultiply(gp.makeRotation(-e)),this}translate(e,t){return this.premultiply(gp.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,i=e.elements;for(let r=0;r<9;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const gp=new Ke;function cv(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}const Iw={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Ea(n,e){return new Iw[n](e)}function Qo(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function uv(){const n=Qo("canvas");return n.style.display="block",n}const hv={};function ou(n){n in hv||(hv[n]=!0,console.warn(n))}function Lw(n,e,t){return new Promise(function(i,r){function s(){switch(n.clientWaitSync(e,n.SYNC_FLUSH_COMMANDS_BIT,0)){case n.WAIT_FAILED:r();break;case n.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:i()}}setTimeout(s,t)})}function Pw(n){const e=n.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]}function Dw(n){const e=n.elements;e[11]===-1?(e[10]=-e[10]-1,e[14]=-e[14]):(e[10]=-e[10],e[14]=-e[14]+1)}const dv=new Ke().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),pv=new Ke().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),el={[nr]:{transfer:$o,primaries:Jo,luminanceCoefficients:[.2126,.7152,.0722],toReference:n=>n,fromReference:n=>n},[Fi]:{transfer:Ot,primaries:Jo,luminanceCoefficients:[.2126,.7152,.0722],toReference:n=>n.convertSRGBToLinear(),fromReference:n=>n.convertLinearToSRGB()},[Ta]:{transfer:$o,primaries:Ko,luminanceCoefficients:[.2289,.6917,.0793],toReference:n=>n.applyMatrix3(pv),fromReference:n=>n.applyMatrix3(dv)},[Yo]:{transfer:Ot,primaries:Ko,luminanceCoefficients:[.2289,.6917,.0793],toReference:n=>n.convertSRGBToLinear().applyMatrix3(pv),fromReference:n=>n.applyMatrix3(dv).convertLinearToSRGB()}},Uw=new Set([nr,Ta]),vt={enabled:!0,_workingColorSpace:nr,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(n){if(!Uw.has(n))throw new Error(`Unsupported working color space, "${n}".`);this._workingColorSpace=n},convert:function(n,e,t){if(this.enabled===!1||e===t||!e||!t)return n;const i=el[e].toReference,r=el[t].fromReference;return r(i(n))},fromWorkingColorSpace:function(n,e){return this.convert(n,this._workingColorSpace,e)},toWorkingColorSpace:function(n,e){return this.convert(n,e,this._workingColorSpace)},getPrimaries:function(n){return el[n].primaries},getTransfer:function(n){return n===Cr?$o:el[n].transfer},getLuminanceCoefficients:function(n,e=this._workingColorSpace){return n.fromArray(el[e].luminanceCoefficients)}};function Aa(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function vp(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}let Na;class mv{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{Na===void 0&&(Na=Qo("canvas")),Na.width=e.width,Na.height=e.height;const i=Na.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),t=Na}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=Qo("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const r=i.getImageData(0,0,e.width,e.height),s=r.data;for(let a=0;a<s.length;a++)s[a]=Aa(s[a]/255)*255;return i.putImageData(r,0,0),t}else if(e.data){const t=e.data.slice(0);for(let i=0;i<t.length;i++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[i]=Math.floor(Aa(t[i]/255)*255):t[i]=Aa(t[i]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let Ow=0;class $n{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Ow++}),this.uuid=yr(),this.data=e,this.dataReady=!0,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const i={uuid:this.uuid,url:""},r=this.data;if(r!==null){let s;if(Array.isArray(r)){s=[];for(let a=0,o=r.length;a<o;a++)r[a].isDataTexture?s.push(yp(r[a].image)):s.push(yp(r[a]))}else s=yp(r);i.url=s}return t||(e.images[this.uuid]=i),i}}function yp(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?mv.getDataURL(n):n.data?{data:Array.from(n.data),width:n.width,height:n.height,type:n.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let Fw=0;class Wt extends vr{constructor(e=Wt.DEFAULT_IMAGE,t=Wt.DEFAULT_MAPPING,i=gr,r=gr,s=Lt,a=ji,o=Ei,l=Wr,c=Wt.DEFAULT_ANISOTROPY,u=Cr){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Fw++}),this.uuid=yr(),this.name="",this.source=new $n(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=r,this.magFilter=s,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new J(0,0),this.repeat=new J(1,1),this.center=new J(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ke,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Ic)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Gn:e.x=e.x-Math.floor(e.x);break;case gr:e.x=e.x<0?0:1;break;case fa:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Gn:e.y=e.y-Math.floor(e.y);break;case gr:e.y=e.y<0?0:1;break;case fa:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}Wt.DEFAULT_IMAGE=null,Wt.DEFAULT_MAPPING=Ic,Wt.DEFAULT_ANISOTROPY=4;class st{constructor(e=0,t=0,i=0,r=1){st.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,i=this.y,r=this.z,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*r+a[12]*s,this.y=a[1]*t+a[5]*i+a[9]*r+a[13]*s,this.z=a[2]*t+a[6]*i+a[10]*r+a[14]*s,this.w=a[3]*t+a[7]*i+a[11]*r+a[15]*s,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,r,s;const a=e.elements,o=a[0],l=a[4],c=a[8],u=a[1],h=a[5],d=a[9],p=a[2],m=a[6],v=a[10];if(Math.abs(l-u)<.01&&Math.abs(c-p)<.01&&Math.abs(d-m)<.01){if(Math.abs(l+u)<.1&&Math.abs(c+p)<.1&&Math.abs(d+m)<.1&&Math.abs(o+h+v-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const g=(o+1)/2,x=(h+1)/2,y=(v+1)/2,_=(l+u)/4,I=(c+p)/4,b=(d+m)/4;return g>x&&g>y?g<.01?(i=0,r=.707106781,s=.707106781):(i=Math.sqrt(g),r=_/i,s=I/i):x>y?x<.01?(i=.707106781,r=0,s=.707106781):(r=Math.sqrt(x),i=_/r,s=b/r):y<.01?(i=.707106781,r=.707106781,s=0):(s=Math.sqrt(y),i=I/s,r=b/s),this.set(i,r,s,t),this}let f=Math.sqrt((m-d)*(m-d)+(c-p)*(c-p)+(u-l)*(u-l));return Math.abs(f)<.001&&(f=1),this.x=(m-d)/f,this.y=(c-p)/f,this.z=(u-l)/f,this.w=Math.acos((o+h+v-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class ui extends vr{constructor(e=1,t=1,i={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new st(0,0,e,t),this.scissorTest=!1,this.viewport=new st(0,0,e,t);const r={width:e,height:t,depth:1};i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Lt,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},i);const s=new Wt(r,i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.colorSpace);s.flipY=!1,s.generateMipmaps=i.generateMipmaps,s.internalFormat=i.internalFormat,this.textures=[];const a=i.count;for(let o=0;o<a;o++)this.textures[o]=s.clone(),this.textures[o].isRenderTargetTexture=!0;this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this.depthTexture=i.depthTexture,this.samples=i.samples}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}setSize(e,t,i=1){if(this.width!==e||this.height!==t||this.depth!==i){this.width=e,this.height=t,this.depth=i;for(let r=0,s=this.textures.length;r<s;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=i;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let i=0,r=e.textures.length;i<r;i++)this.textures[i]=e.textures[i].clone(),this.textures[i].isRenderTargetTexture=!0;const t=Object.assign({},e.texture.image);return this.texture.source=new $n(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Ir extends ui{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}}class tl extends Wt{constructor(e=null,t=1,i=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=$t,this.minFilter=$t,this.wrapR=gr,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Vw extends Ir{constructor(e=1,t=1,i=1,r={}){super(e,t,r),this.isWebGLArrayRenderTarget=!0,this.depth=i,this.texture=new tl(null,e,t,i),this.texture.isRenderTargetTexture=!0}}class lu extends Wt{constructor(e=null,t=1,i=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=$t,this.minFilter=$t,this.wrapR=gr,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Bw extends Ir{constructor(e=1,t=1,i=1,r={}){super(e,t,r),this.isWebGL3DRenderTarget=!0,this.depth=i,this.texture=new lu(null,e,t,i),this.texture.isRenderTargetTexture=!0}}class qi{constructor(e=0,t=0,i=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=r}static slerpFlat(e,t,i,r,s,a,o){let l=i[r+0],c=i[r+1],u=i[r+2],h=i[r+3];const d=s[a+0],p=s[a+1],m=s[a+2],v=s[a+3];if(o===0){e[t+0]=l,e[t+1]=c,e[t+2]=u,e[t+3]=h;return}if(o===1){e[t+0]=d,e[t+1]=p,e[t+2]=m,e[t+3]=v;return}if(h!==v||l!==d||c!==p||u!==m){let f=1-o;const g=l*d+c*p+u*m+h*v,x=g>=0?1:-1,y=1-g*g;if(y>Number.EPSILON){const I=Math.sqrt(y),b=Math.atan2(I,g*x);f=Math.sin(f*b)/I,o=Math.sin(o*b)/I}const _=o*x;if(l=l*f+d*_,c=c*f+p*_,u=u*f+m*_,h=h*f+v*_,f===1-o){const I=1/Math.sqrt(l*l+c*c+u*u+h*h);l*=I,c*=I,u*=I,h*=I}}e[t]=l,e[t+1]=c,e[t+2]=u,e[t+3]=h}static multiplyQuaternionsFlat(e,t,i,r,s,a){const o=i[r],l=i[r+1],c=i[r+2],u=i[r+3],h=s[a],d=s[a+1],p=s[a+2],m=s[a+3];return e[t]=o*m+u*h+l*p-c*d,e[t+1]=l*m+u*d+c*h-o*p,e[t+2]=c*m+u*p+o*d-l*h,e[t+3]=u*m-o*h-l*d-c*p,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const i=e._x,r=e._y,s=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(i/2),u=o(r/2),h=o(s/2),d=l(i/2),p=l(r/2),m=l(s/2);switch(a){case"XYZ":this._x=d*u*h+c*p*m,this._y=c*p*h-d*u*m,this._z=c*u*m+d*p*h,this._w=c*u*h-d*p*m;break;case"YXZ":this._x=d*u*h+c*p*m,this._y=c*p*h-d*u*m,this._z=c*u*m-d*p*h,this._w=c*u*h+d*p*m;break;case"ZXY":this._x=d*u*h-c*p*m,this._y=c*p*h+d*u*m,this._z=c*u*m+d*p*h,this._w=c*u*h-d*p*m;break;case"ZYX":this._x=d*u*h-c*p*m,this._y=c*p*h+d*u*m,this._z=c*u*m-d*p*h,this._w=c*u*h+d*p*m;break;case"YZX":this._x=d*u*h+c*p*m,this._y=c*p*h+d*u*m,this._z=c*u*m-d*p*h,this._w=c*u*h-d*p*m;break;case"XZY":this._x=d*u*h-c*p*m,this._y=c*p*h-d*u*m,this._z=c*u*m+d*p*h,this._w=c*u*h+d*p*m;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],r=t[4],s=t[8],a=t[1],o=t[5],l=t[9],c=t[2],u=t[6],h=t[10],d=i+o+h;if(d>0){const p=.5/Math.sqrt(d+1);this._w=.25/p,this._x=(u-l)*p,this._y=(s-c)*p,this._z=(a-r)*p}else if(i>o&&i>h){const p=2*Math.sqrt(1+i-o-h);this._w=(u-l)/p,this._x=.25*p,this._y=(r+a)/p,this._z=(s+c)/p}else if(o>h){const p=2*Math.sqrt(1+o-i-h);this._w=(s-c)/p,this._x=(r+a)/p,this._y=.25*p,this._z=(l+u)/p}else{const p=2*Math.sqrt(1+h-i-o);this._w=(a-r)/p,this._x=(s+c)/p,this._y=(l+u)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<Number.EPSILON?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Jt(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(i===0)return this;const r=Math.min(1,t/i);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const i=e._x,r=e._y,s=e._z,a=e._w,o=t._x,l=t._y,c=t._z,u=t._w;return this._x=i*u+a*o+r*c-s*l,this._y=r*u+a*l+s*o-i*c,this._z=s*u+a*c+i*l-r*o,this._w=a*u-i*o-r*l-s*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const i=this._x,r=this._y,s=this._z,a=this._w;let o=a*e._w+i*e._x+r*e._y+s*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=i,this._y=r,this._z=s,this;const l=1-o*o;if(l<=Number.EPSILON){const p=1-t;return this._w=p*a+t*this._w,this._x=p*i+t*this._x,this._y=p*r+t*this._y,this._z=p*s+t*this._z,this.normalize(),this}const c=Math.sqrt(l),u=Math.atan2(c,o),h=Math.sin((1-t)*u)/c,d=Math.sin(t*u)/c;return this._w=a*h+this._w*d,this._x=i*h+this._x*d,this._y=r*h+this._y*d,this._z=s*h+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),r=Math.sqrt(1-i),s=Math.sqrt(i);return this.set(r*Math.sin(e),r*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class N{constructor(e=0,t=0,i=0){N.prototype.isVector3=!0,this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(fv.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(fv.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6]*r,this.y=s[1]*t+s[4]*i+s[7]*r,this.z=s[2]*t+s[5]*i+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,r=this.z,s=e.elements,a=1/(s[3]*t+s[7]*i+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*i+s[8]*r+s[12])*a,this.y=(s[1]*t+s[5]*i+s[9]*r+s[13])*a,this.z=(s[2]*t+s[6]*i+s[10]*r+s[14])*a,this}applyQuaternion(e){const t=this.x,i=this.y,r=this.z,s=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*r-o*i),u=2*(o*t-s*r),h=2*(s*i-a*t);return this.x=t+l*c+a*h-o*u,this.y=i+l*u+o*c-s*h,this.z=r+l*h+s*u-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*i+s[8]*r,this.y=s[1]*t+s[5]*i+s[9]*r,this.z=s[2]*t+s[6]*i+s[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,r=e.y,s=e.z,a=t.x,o=t.y,l=t.z;return this.x=r*l-s*o,this.y=s*a-i*l,this.z=i*o-r*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return xp.copy(this).projectOnVector(e),this.sub(xp)}reflect(e){return this.sub(xp.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(Jt(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return t*t+i*i+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){const r=Math.sin(t)*e;return this.x=r*Math.sin(i),this.y=Math.cos(t)*e,this.z=r*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const xp=new N,fv=new qi;class Bi{constructor(e=new N(1/0,1/0,1/0),t=new N(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t+=3)this.expandByPoint(jr.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(jr.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const i=jr.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const i=e.geometry;if(i!==void 0){const s=i.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=s.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,jr):jr.fromBufferAttribute(s,a),jr.applyMatrix4(e.matrixWorld),this.expandByPoint(jr);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),cu.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),cu.copy(i.boundingBox)),cu.applyMatrix4(e.matrixWorld),this.union(cu)}const r=e.children;for(let s=0,a=r.length;s<a;s++)this.expandByObject(r[s],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,jr),jr.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(il),uu.subVectors(this.max,il),Ca.subVectors(e.a,il),Ra.subVectors(e.b,il),Ia.subVectors(e.c,il),Jn.subVectors(Ra,Ca),Kn.subVectors(Ia,Ra),ws.subVectors(Ca,Ia);let t=[0,-Jn.z,Jn.y,0,-Kn.z,Kn.y,0,-ws.z,ws.y,Jn.z,0,-Jn.x,Kn.z,0,-Kn.x,ws.z,0,-ws.x,-Jn.y,Jn.x,0,-Kn.y,Kn.x,0,-ws.y,ws.x,0];return!_p(t,Ca,Ra,Ia,uu)||(t=[1,0,0,0,1,0,0,0,1],!_p(t,Ca,Ra,Ia,uu))?!1:(hu.crossVectors(Jn,Kn),t=[hu.x,hu.y,hu.z],_p(t,Ca,Ra,Ia,uu))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,jr).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(jr).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(bn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),bn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),bn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),bn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),bn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),bn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),bn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),bn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(bn),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const bn=[new N,new N,new N,new N,new N,new N,new N,new N],jr=new N,cu=new Bi,Ca=new N,Ra=new N,Ia=new N,Jn=new N,Kn=new N,ws=new N,il=new N,uu=new N,hu=new N,Es=new N;function _p(n,e,t,i,r){for(let s=0,a=n.length-3;s<=a;s+=3){Es.fromArray(n,s);const o=r.x*Math.abs(Es.x)+r.y*Math.abs(Es.y)+r.z*Math.abs(Es.z),l=e.dot(Es),c=t.dot(Es),u=i.dot(Es);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>o)return!1}return!0}const zw=new Bi,rl=new N,Mp=new N;class Ai{constructor(e=new N,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const i=this.center;t!==void 0?i.copy(t):zw.setFromPoints(e).getCenter(i);let r=0;for(let s=0,a=e.length;s<a;s++)r=Math.max(r,i.distanceToSquared(e[s]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const i=this.center.distanceToSquared(e);return t.copy(e),i>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;rl.subVectors(e,this.center);const t=rl.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),r=(i-this.radius)*.5;this.center.addScaledVector(rl,r/i),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Mp.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(rl.copy(e.center).add(Mp)),this.expandByPoint(rl.copy(e.center).sub(Mp))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const Tn=new N,bp=new N,du=new N,Zn=new N,Tp=new N,pu=new N,Sp=new N;class As{constructor(e=new N,t=new N(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Tn)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Tn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Tn.copy(this.origin).addScaledVector(this.direction,t),Tn.distanceToSquared(e))}distanceSqToSegment(e,t,i,r){bp.copy(e).add(t).multiplyScalar(.5),du.copy(t).sub(e).normalize(),Zn.copy(this.origin).sub(bp);const s=e.distanceTo(t)*.5,a=-this.direction.dot(du),o=Zn.dot(this.direction),l=-Zn.dot(du),c=Zn.lengthSq(),u=Math.abs(1-a*a);let h,d,p,m;if(u>0)if(h=a*l-o,d=a*o-l,m=s*u,h>=0)if(d>=-m)if(d<=m){const v=1/u;h*=v,d*=v,p=h*(h+a*d+2*o)+d*(a*h+d+2*l)+c}else d=s,h=Math.max(0,-(a*d+o)),p=-h*h+d*(d+2*l)+c;else d=-s,h=Math.max(0,-(a*d+o)),p=-h*h+d*(d+2*l)+c;else d<=-m?(h=Math.max(0,-(-a*s+o)),d=h>0?-s:Math.min(Math.max(-s,-l),s),p=-h*h+d*(d+2*l)+c):d<=m?(h=0,d=Math.min(Math.max(-s,-l),s),p=d*(d+2*l)+c):(h=Math.max(0,-(a*s+o)),d=h>0?s:Math.min(Math.max(-s,-l),s),p=-h*h+d*(d+2*l)+c);else d=a>0?-s:s,h=Math.max(0,-(a*d+o)),p=-h*h+d*(d+2*l)+c;return i&&i.copy(this.origin).addScaledVector(this.direction,h),r&&r.copy(bp).addScaledVector(du,d),p}intersectSphere(e,t){Tn.subVectors(e.center,this.origin);const i=Tn.dot(this.direction),r=Tn.dot(Tn)-i*i,s=e.radius*e.radius;if(r>s)return null;const a=Math.sqrt(s-r),o=i-a,l=i+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,r,s,a,o,l;const c=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,d=this.origin;return c>=0?(i=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(i=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),u>=0?(s=(e.min.y-d.y)*u,a=(e.max.y-d.y)*u):(s=(e.max.y-d.y)*u,a=(e.min.y-d.y)*u),i>a||s>r||((s>i||isNaN(i))&&(i=s),(a<r||isNaN(r))&&(r=a),h>=0?(o=(e.min.z-d.z)*h,l=(e.max.z-d.z)*h):(o=(e.max.z-d.z)*h,l=(e.min.z-d.z)*h),i>l||o>r)||((o>i||i!==i)&&(i=o),(l<r||r!==r)&&(r=l),r<0)?null:this.at(i>=0?i:r,t)}intersectsBox(e){return this.intersectBox(e,Tn)!==null}intersectTriangle(e,t,i,r,s){Tp.subVectors(t,e),pu.subVectors(i,e),Sp.crossVectors(Tp,pu);let a=this.direction.dot(Sp),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Zn.subVectors(this.origin,e);const l=o*this.direction.dot(pu.crossVectors(Zn,pu));if(l<0)return null;const c=o*this.direction.dot(Tp.cross(Zn));if(c<0||l+c>a)return null;const u=-o*Zn.dot(Sp);return u<0?null:this.at(u/a,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Re{constructor(e,t,i,r,s,a,o,l,c,u,h,d,p,m,v,f){Re.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,i,r,s,a,o,l,c,u,h,d,p,m,v,f)}set(e,t,i,r,s,a,o,l,c,u,h,d,p,m,v,f){const g=this.elements;return g[0]=e,g[4]=t,g[8]=i,g[12]=r,g[1]=s,g[5]=a,g[9]=o,g[13]=l,g[2]=c,g[6]=u,g[10]=h,g[14]=d,g[3]=p,g[7]=m,g[11]=v,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 Re().fromArray(this.elements)}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){const t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,i=e.elements,r=1/La.setFromMatrixColumn(e,0).length(),s=1/La.setFromMatrixColumn(e,1).length(),a=1/La.setFromMatrixColumn(e,2).length();return t[0]=i[0]*r,t[1]=i[1]*r,t[2]=i[2]*r,t[3]=0,t[4]=i[4]*s,t[5]=i[5]*s,t[6]=i[6]*s,t[7]=0,t[8]=i[8]*a,t[9]=i[9]*a,t[10]=i[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,i=e.x,r=e.y,s=e.z,a=Math.cos(i),o=Math.sin(i),l=Math.cos(r),c=Math.sin(r),u=Math.cos(s),h=Math.sin(s);if(e.order==="XYZ"){const d=a*u,p=a*h,m=o*u,v=o*h;t[0]=l*u,t[4]=-l*h,t[8]=c,t[1]=p+m*c,t[5]=d-v*c,t[9]=-o*l,t[2]=v-d*c,t[6]=m+p*c,t[10]=a*l}else if(e.order==="YXZ"){const d=l*u,p=l*h,m=c*u,v=c*h;t[0]=d+v*o,t[4]=m*o-p,t[8]=a*c,t[1]=a*h,t[5]=a*u,t[9]=-o,t[2]=p*o-m,t[6]=v+d*o,t[10]=a*l}else if(e.order==="ZXY"){const d=l*u,p=l*h,m=c*u,v=c*h;t[0]=d-v*o,t[4]=-a*h,t[8]=m+p*o,t[1]=p+m*o,t[5]=a*u,t[9]=v-d*o,t[2]=-a*c,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){const d=a*u,p=a*h,m=o*u,v=o*h;t[0]=l*u,t[4]=m*c-p,t[8]=d*c+v,t[1]=l*h,t[5]=v*c+d,t[9]=p*c-m,t[2]=-c,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){const d=a*l,p=a*c,m=o*l,v=o*c;t[0]=l*u,t[4]=v-d*h,t[8]=m*h+p,t[1]=h,t[5]=a*u,t[9]=-o*u,t[2]=-c*u,t[6]=p*h+m,t[10]=d-v*h}else if(e.order==="XZY"){const d=a*l,p=a*c,m=o*l,v=o*c;t[0]=l*u,t[4]=-h,t[8]=c*u,t[1]=d*h+v,t[5]=a*u,t[9]=p*h-m,t[2]=m*h-p,t[6]=o*u,t[10]=v*h+d}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(kw,e,Hw)}lookAt(e,t,i){const r=this.elements;return xr.subVectors(e,t),xr.lengthSq()===0&&(xr.z=1),xr.normalize(),Qn.crossVectors(i,xr),Qn.lengthSq()===0&&(Math.abs(i.z)===1?xr.x+=1e-4:xr.z+=1e-4,xr.normalize(),Qn.crossVectors(i,xr)),Qn.normalize(),mu.crossVectors(xr,Qn),r[0]=Qn.x,r[4]=mu.x,r[8]=xr.x,r[1]=Qn.y,r[5]=mu.y,r[9]=xr.y,r[2]=Qn.z,r[6]=mu.z,r[10]=xr.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,r=t.elements,s=this.elements,a=i[0],o=i[4],l=i[8],c=i[12],u=i[1],h=i[5],d=i[9],p=i[13],m=i[2],v=i[6],f=i[10],g=i[14],x=i[3],y=i[7],_=i[11],I=i[15],b=r[0],w=r[4],C=r[8],H=r[12],M=r[1],T=r[5],k=r[9],j=r[13],Y=r[2],re=r[6],$=r[10],he=r[14],Q=r[3],ye=r[7],be=r[11],Ve=r[15];return s[0]=a*b+o*M+l*Y+c*Q,s[4]=a*w+o*T+l*re+c*ye,s[8]=a*C+o*k+l*$+c*be,s[12]=a*H+o*j+l*he+c*Ve,s[1]=u*b+h*M+d*Y+p*Q,s[5]=u*w+h*T+d*re+p*ye,s[9]=u*C+h*k+d*$+p*be,s[13]=u*H+h*j+d*he+p*Ve,s[2]=m*b+v*M+f*Y+g*Q,s[6]=m*w+v*T+f*re+g*ye,s[10]=m*C+v*k+f*$+g*be,s[14]=m*H+v*j+f*he+g*Ve,s[3]=x*b+y*M+_*Y+I*Q,s[7]=x*w+y*T+_*re+I*ye,s[11]=x*C+y*k+_*$+I*be,s[15]=x*H+y*j+_*he+I*Ve,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[4],r=e[8],s=e[12],a=e[1],o=e[5],l=e[9],c=e[13],u=e[2],h=e[6],d=e[10],p=e[14],m=e[3],v=e[7],f=e[11],g=e[15];return m*(+s*l*h-r*c*h-s*o*d+i*c*d+r*o*p-i*l*p)+v*(+t*l*p-t*c*d+s*a*d-r*a*p+r*c*u-s*l*u)+f*(+t*c*h-t*o*p-s*a*h+i*a*p+s*o*u-i*c*u)+g*(-r*o*u-t*l*h+t*o*d+r*a*h-i*a*d+i*l*u)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=i),this}invert(){const e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8],h=e[9],d=e[10],p=e[11],m=e[12],v=e[13],f=e[14],g=e[15],x=h*f*c-v*d*c+v*l*p-o*f*p-h*l*g+o*d*g,y=m*d*c-u*f*c-m*l*p+a*f*p+u*l*g-a*d*g,_=u*v*c-m*h*c+m*o*p-a*v*p-u*o*g+a*h*g,I=m*h*l-u*v*l-m*o*d+a*v*d+u*o*f-a*h*f,b=t*x+i*y+r*_+s*I;if(b===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const w=1/b;return e[0]=x*w,e[1]=(v*d*s-h*f*s-v*r*p+i*f*p+h*r*g-i*d*g)*w,e[2]=(o*f*s-v*l*s+v*r*c-i*f*c-o*r*g+i*l*g)*w,e[3]=(h*l*s-o*d*s-h*r*c+i*d*c+o*r*p-i*l*p)*w,e[4]=y*w,e[5]=(u*f*s-m*d*s+m*r*p-t*f*p-u*r*g+t*d*g)*w,e[6]=(m*l*s-a*f*s-m*r*c+t*f*c+a*r*g-t*l*g)*w,e[7]=(a*d*s-u*l*s+u*r*c-t*d*c-a*r*p+t*l*p)*w,e[8]=_*w,e[9]=(m*h*s-u*v*s-m*i*p+t*v*p+u*i*g-t*h*g)*w,e[10]=(a*v*s-m*o*s+m*i*c-t*v*c-a*i*g+t*o*g)*w,e[11]=(u*o*s-a*h*s-u*i*c+t*h*c+a*i*p-t*o*p)*w,e[12]=I*w,e[13]=(u*v*r-m*h*r+m*i*d-t*v*d-u*i*f+t*h*f)*w,e[14]=(m*o*r-a*v*r-m*i*l+t*v*l+a*i*f-t*o*f)*w,e[15]=(a*h*r-u*o*r+u*i*l-t*h*l-a*i*d+t*o*d)*w,this}scale(e){const t=this.elements,i=e.x,r=e.y,s=e.z;return t[0]*=i,t[4]*=r,t[8]*=s,t[1]*=i,t[5]*=r,t[9]*=s,t[2]*=i,t[6]*=r,t[10]*=s,t[3]*=i,t[7]*=r,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,r))}makeTranslation(e,t,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const i=Math.cos(t),r=Math.sin(t),s=1-i,a=e.x,o=e.y,l=e.z,c=s*a,u=s*o;return this.set(c*a+i,c*o-r*l,c*l+r*o,0,c*o+r*l,u*o+i,u*l-r*a,0,c*l-r*o,u*l+r*a,s*l*l+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,r,s,a){return this.set(1,i,s,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,i){const r=this.elements,s=t._x,a=t._y,o=t._z,l=t._w,c=s+s,u=a+a,h=o+o,d=s*c,p=s*u,m=s*h,v=a*u,f=a*h,g=o*h,x=l*c,y=l*u,_=l*h,I=i.x,b=i.y,w=i.z;return r[0]=(1-(v+g))*I,r[1]=(p+_)*I,r[2]=(m-y)*I,r[3]=0,r[4]=(p-_)*b,r[5]=(1-(d+g))*b,r[6]=(f+x)*b,r[7]=0,r[8]=(m+y)*w,r[9]=(f-x)*w,r[10]=(1-(d+v))*w,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,i){const r=this.elements;let s=La.set(r[0],r[1],r[2]).length();const a=La.set(r[4],r[5],r[6]).length(),o=La.set(r[8],r[9],r[10]).length();this.determinant()<0&&(s=-s),e.x=r[12],e.y=r[13],e.z=r[14],Xr.copy(this);const l=1/s,c=1/a,u=1/o;return Xr.elements[0]*=l,Xr.elements[1]*=l,Xr.elements[2]*=l,Xr.elements[4]*=c,Xr.elements[5]*=c,Xr.elements[6]*=c,Xr.elements[8]*=u,Xr.elements[9]*=u,Xr.elements[10]*=u,t.setFromRotationMatrix(Xr),i.x=s,i.y=a,i.z=o,this}makePerspective(e,t,i,r,s,a,o=Rr){const l=this.elements,c=2*s/(t-e),u=2*s/(i-r),h=(t+e)/(t-e),d=(i+r)/(i-r);let p,m;if(o===Rr)p=-(a+s)/(a-s),m=-2*a*s/(a-s);else if(o===Ts)p=-a/(a-s),m=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=c,l[4]=0,l[8]=h,l[12]=0,l[1]=0,l[5]=u,l[9]=d,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=m,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,i,r,s,a,o=Rr){const l=this.elements,c=1/(t-e),u=1/(i-r),h=1/(a-s),d=(t+e)*c,p=(i+r)*u;let m,v;if(o===Rr)m=(a+s)*h,v=-2*h;else if(o===Ts)m=s*h,v=-1*h;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-d,l[1]=0,l[5]=2*u,l[9]=0,l[13]=-p,l[2]=0,l[6]=0,l[10]=v,l[14]=-m,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){const t=this.elements,i=e.elements;for(let r=0;r<16;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}}const La=new N,Xr=new Re,kw=new N(0,0,0),Hw=new N(1,1,1),Qn=new N,mu=new N,xr=new N,gv=new Re,vv=new qi;class dr{constructor(e=0,t=0,i=0,r=dr.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,r=this._order){return this._x=e,this._y=t,this._z=i,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){const r=e.elements,s=r[0],a=r[4],o=r[8],l=r[1],c=r[5],u=r[9],h=r[2],d=r[6],p=r[10];switch(t){case"XYZ":this._y=Math.asin(Jt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,p),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Jt(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(o,p),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(Jt(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-h,p),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-Jt(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(d,p),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(Jt(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(o,p));break;case"XZY":this._z=Math.asin(-Jt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-u,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return gv.makeRotationFromQuaternion(e),this.setFromRotationMatrix(gv,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return vv.setFromEuler(this),this.setFromQuaternion(vv,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}dr.DEFAULT_ORDER="XYZ";class nl{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let Gw=0;const yv=new N,Pa=new qi,Sn=new Re,fu=new N,sl=new N,Ww=new N,jw=new qi,xv=new N(1,0,0),_v=new N(0,1,0),Mv=new N(0,0,1),bv={type:"added"},Xw={type:"removed"},Da={type:"childadded",child:null},wp={type:"childremoved",child:null};class _t extends vr{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Gw++}),this.uuid=yr(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=_t.DEFAULT_UP.clone();const e=new N,t=new dr,i=new qi,r=new N(1,1,1);function s(){i.setFromEuler(t,!1)}function a(){t.setFromQuaternion(i,void 0,!1)}t._onChange(s),i._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new Re},normalMatrix:{value:new Ke}}),this.matrix=new Re,this.matrixWorld=new Re,this.matrixAutoUpdate=_t.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=_t.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new nl,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Pa.setFromAxisAngle(e,t),this.quaternion.multiply(Pa),this}rotateOnWorldAxis(e,t){return Pa.setFromAxisAngle(e,t),this.quaternion.premultiply(Pa),this}rotateX(e){return this.rotateOnAxis(xv,e)}rotateY(e){return this.rotateOnAxis(_v,e)}rotateZ(e){return this.rotateOnAxis(Mv,e)}translateOnAxis(e,t){return yv.copy(e).applyQuaternion(this.quaternion),this.position.add(yv.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(xv,e)}translateY(e){return this.translateOnAxis(_v,e)}translateZ(e){return this.translateOnAxis(Mv,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Sn.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?fu.copy(e):fu.set(e,t,i);const r=this.parent;this.updateWorldMatrix(!0,!1),sl.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Sn.lookAt(sl,fu,this.up):Sn.lookAt(fu,sl,this.up),this.quaternion.setFromRotationMatrix(Sn),r&&(Sn.extractRotation(r.matrixWorld),Pa.setFromRotationMatrix(Sn),this.quaternion.premultiply(Pa.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(bv),Da.child=e,this.dispatchEvent(Da),Da.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Xw),wp.child=e,this.dispatchEvent(wp),wp.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Sn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Sn.multiply(e.parent.matrixWorld)),e.applyMatrix4(Sn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(bv),Da.child=e,this.dispatchEvent(Da),Da.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let i=0,r=this.children.length;i<r;i++){const s=this.children[i].getObjectByProperty(e,t);if(s!==void 0)return s}}getObjectsByProperty(e,t,i=[]){this[e]===t&&i.push(this);const r=this.children;for(let s=0,a=r.length;s<a;s++)r[s].getObjectsByProperty(e,t,i);return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(sl,e,Ww),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(sl,jw,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].updateMatrixWorld(e)}updateWorldMatrix(e,t){const i=this.parent;if(e===!0&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){const r=this.children;for(let s=0,a=r.length;s<a;s++)r[s].updateWorldMatrix(!1,!0)}}toJSON(e){const t=e===void 0||typeof e=="string",i={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.visibility=this._visibility,r.active=this._active,r.bounds=this._bounds.map(o=>({boxInitialized:o.boxInitialized,boxMin:o.box.min.toArray(),boxMax:o.box.max.toArray(),sphereInitialized:o.sphereInitialized,sphereRadius:o.sphere.radius,sphereCenter:o.sphere.center.toArray()})),r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.geometryCount=this._geometryCount,r.matricesTexture=this._matricesTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere={center:r.boundingSphere.center.toArray(),radius:r.boundingSphere.radius}),this.boundingBox!==null&&(r.boundingBox={min:r.boundingBox.min.toArray(),max:r.boundingBox.max.toArray()}));function s(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,u=l.length;c<u;c++){const h=l[c];s(e.shapes,h)}else s(e.shapes,l)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(s(e.materials,this.material[l]));r.material=o}else r.material=s(e.materials,this.material);if(this.children.length>0){r.children=[];for(let o=0;o<this.children.length;o++)r.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];r.animations.push(s(e.animations,l))}}if(t){const o=a(e.geometries),l=a(e.materials),c=a(e.textures),u=a(e.images),h=a(e.shapes),d=a(e.skeletons),p=a(e.animations),m=a(e.nodes);o.length>0&&(i.geometries=o),l.length>0&&(i.materials=l),c.length>0&&(i.textures=c),u.length>0&&(i.images=u),h.length>0&&(i.shapes=h),d.length>0&&(i.skeletons=d),p.length>0&&(i.animations=p),m.length>0&&(i.nodes=m)}return i.object=r,i;function a(o){const l=[];for(const c in o){const u=o[c];delete u.metadata,l.push(u)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i<e.children.length;i++){const r=e.children[i];this.add(r.clone())}return this}}_t.DEFAULT_UP=new N(0,1,0),_t.DEFAULT_MATRIX_AUTO_UPDATE=!0,_t.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const qr=new N,wn=new N,Ep=new N,En=new N,Ua=new N,Oa=new N,Tv=new N,Ap=new N,Np=new N,Cp=new N,Rp=new st,Ip=new st,Lp=new st;class er{constructor(e=new N,t=new N,i=new N){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,r){r.subVectors(i,t),qr.subVectors(e,t),r.cross(qr);const s=r.lengthSq();return s>0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,i,r,s){qr.subVectors(r,t),wn.subVectors(i,t),Ep.subVectors(e,t);const a=qr.dot(qr),o=qr.dot(wn),l=qr.dot(Ep),c=wn.dot(wn),u=wn.dot(Ep),h=a*c-o*o;if(h===0)return s.set(0,0,0),null;const d=1/h,p=(c*l-o*u)*d,m=(a*u-o*l)*d;return s.set(1-p-m,m,p)}static containsPoint(e,t,i,r){return this.getBarycoord(e,t,i,r,En)===null?!1:En.x>=0&&En.y>=0&&En.x+En.y<=1}static getInterpolation(e,t,i,r,s,a,o,l){return this.getBarycoord(e,t,i,r,En)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(s,En.x),l.addScaledVector(a,En.y),l.addScaledVector(o,En.z),l)}static getInterpolatedAttribute(e,t,i,r,s,a){return Rp.setScalar(0),Ip.setScalar(0),Lp.setScalar(0),Rp.fromBufferAttribute(e,t),Ip.fromBufferAttribute(e,i),Lp.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(Rp,s.x),a.addScaledVector(Ip,s.y),a.addScaledVector(Lp,s.z),a}static isFrontFacing(e,t,i,r){return qr.subVectors(i,t),wn.subVectors(e,t),qr.cross(wn).dot(r)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,r){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,i,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return qr.subVectors(this.c,this.b),wn.subVectors(this.a,this.b),qr.cross(wn).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return er.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return er.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,r,s){return er.getInterpolation(e,this.a,this.b,this.c,t,i,r,s)}containsPoint(e){return er.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return er.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,r=this.b,s=this.c;let a,o;Ua.subVectors(r,i),Oa.subVectors(s,i),Ap.subVectors(e,i);const l=Ua.dot(Ap),c=Oa.dot(Ap);if(l<=0&&c<=0)return t.copy(i);Np.subVectors(e,r);const u=Ua.dot(Np),h=Oa.dot(Np);if(u>=0&&h<=u)return t.copy(r);const d=l*h-u*c;if(d<=0&&l>=0&&u<=0)return a=l/(l-u),t.copy(i).addScaledVector(Ua,a);Cp.subVectors(e,s);const p=Ua.dot(Cp),m=Oa.dot(Cp);if(m>=0&&p<=m)return t.copy(s);const v=p*c-l*m;if(v<=0&&c>=0&&m<=0)return o=c/(c-m),t.copy(i).addScaledVector(Oa,o);const f=u*m-p*h;if(f<=0&&h-u>=0&&p-m>=0)return Tv.subVectors(s,r),o=(h-u)/(h-u+(p-m)),t.copy(r).addScaledVector(Tv,o);const g=1/(f+v+d);return a=v*g,o=d*g,t.copy(i).addScaledVector(Ua,a).addScaledVector(Oa,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const Sv={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},es={h:0,s:0,l:0},gu={h:0,s:0,l:0};function Pp(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}class xe{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){const r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Fi){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,vt.toWorkingColorSpace(this,t),this}setRGB(e,t,i,r=vt.workingColorSpace){return this.r=e,this.g=t,this.b=i,vt.toWorkingColorSpace(this,r),this}setHSL(e,t,i,r=vt.workingColorSpace){if(e=fp(e,1),t=Jt(t,0,1),i=Jt(i,0,1),t===0)this.r=this.g=this.b=i;else{const s=i<=.5?i*(1+t):i+t-i*t,a=2*i-s;this.r=Pp(a,s,e+1/3),this.g=Pp(a,s,e),this.b=Pp(a,s,e-1/3)}return vt.toWorkingColorSpace(this,r),this}setStyle(e,t=Fi){function i(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const a=r[1],o=r[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=r[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(s,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Fi){const i=Sv[e.toLowerCase()];return i!==void 0?this.setHex(i,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Aa(e.r),this.g=Aa(e.g),this.b=Aa(e.b),this}copyLinearToSRGB(e){return this.r=vp(e.r),this.g=vp(e.g),this.b=vp(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Fi){return vt.fromWorkingColorSpace(zi.copy(this),e),Math.round(Jt(zi.r*255,0,255))*65536+Math.round(Jt(zi.g*255,0,255))*256+Math.round(Jt(zi.b*255,0,255))}getHexString(e=Fi){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=vt.workingColorSpace){vt.fromWorkingColorSpace(zi.copy(this),t);const i=zi.r,r=zi.g,s=zi.b,a=Math.max(i,r,s),o=Math.min(i,r,s);let l,c;const u=(o+a)/2;if(o===a)l=0,c=0;else{const h=a-o;switch(c=u<=.5?h/(a+o):h/(2-a-o),a){case i:l=(r-s)/h+(r<s?6:0);break;case r:l=(s-i)/h+2;break;case s:l=(i-r)/h+4;break}l/=6}return e.h=l,e.s=c,e.l=u,e}getRGB(e,t=vt.workingColorSpace){return vt.fromWorkingColorSpace(zi.copy(this),t),e.r=zi.r,e.g=zi.g,e.b=zi.b,e}getStyle(e=Fi){vt.fromWorkingColorSpace(zi.copy(this),e);const t=zi.r,i=zi.g,r=zi.b;return e!==Fi?`color(${e} ${t.toFixed(3)} ${i.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(i*255)},${Math.round(r*255)})`}offsetHSL(e,t,i){return this.getHSL(es),this.setHSL(es.h+e,es.s+t,es.l+i)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,i){return this.r=e.r+(t.r-e.r)*i,this.g=e.g+(t.g-e.g)*i,this.b=e.b+(t.b-e.b)*i,this}lerpHSL(e,t){this.getHSL(es),e.getHSL(gu);const i=Zo(es.h,gu.h,t),r=Zo(es.s,gu.s,t),s=Zo(es.l,gu.l,t);return this.setHSL(i,r,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,i=this.g,r=this.b,s=e.elements;return this.r=s[0]*t+s[3]*i+s[6]*r,this.g=s[1]*t+s[4]*i+s[7]*r,this.b=s[2]*t+s[5]*i+s[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const zi=new xe;xe.NAMES=Sv;let qw=0;class hi extends vr{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:qw++}),this.uuid=yr(),this.name="",this.type="Material",this.blending=_n,this.side=an,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Sc,this.blendDst=wc,this.blendEquation=Bn,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new xe(0,0,0),this.blendAlpha=0,this.depthFunc=zn,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=nu,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Yn,this.stencilZFail=Yn,this.stencilZPass=Yn,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const i=e[t];if(i===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(i):r&&r.isVector3&&i&&i.isVector3?r.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const i={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==_n&&(i.blending=this.blending),this.side!==an&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==Sc&&(i.blendSrc=this.blendSrc),this.blendDst!==wc&&(i.blendDst=this.blendDst),this.blendEquation!==Bn&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==zn&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==nu&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Yn&&(i.stencilFail=this.stencilFail),this.stencilZFail!==Yn&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==Yn&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function r(s){const a=[];for(const o in s){const l=s[o];delete l.metadata,a.push(l)}return a}if(t){const s=r(e.textures),a=r(e.images);s.length>0&&(i.textures=s),a.length>0&&(i.images=a)}return i}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let i=null;if(t!==null){const r=t.length;i=new Array(r);for(let s=0;s!==r;++s)i[s]=t[s].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class Yr extends hi{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new xe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new dr,this.combine=ma,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const An=Yw();function Yw(){const n=new ArrayBuffer(4),e=new Float32Array(n),t=new Uint32Array(n),i=new Uint32Array(512),r=new Uint32Array(512);for(let l=0;l<256;++l){const c=l-127;c<-27?(i[l]=0,i[l|256]=32768,r[l]=24,r[l|256]=24):c<-14?(i[l]=1024>>-c-14,i[l|256]=1024>>-c-14|32768,r[l]=-c-1,r[l|256]=-c-1):c<=15?(i[l]=c+15<<10,i[l|256]=c+15<<10|32768,r[l]=13,r[l|256]=13):c<128?(i[l]=31744,i[l|256]=64512,r[l]=24,r[l|256]=24):(i[l]=31744,i[l|256]=64512,r[l]=13,r[l|256]=13)}const s=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let l=1;l<1024;++l){let c=l<<13,u=0;for(;(c&8388608)===0;)c<<=1,u-=8388608;c&=-8388609,u+=947912704,s[l]=c|u}for(let l=1024;l<2048;++l)s[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)a[l]=l<<23;a[31]=1199570944,a[32]=2147483648;for(let l=33;l<63;++l)a[l]=2147483648+(l-32<<23);a[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(o[l]=1024);return{floatView:e,uint32View:t,baseTable:i,shiftTable:r,mantissaTable:s,exponentTable:a,offsetTable:o}}function sr(n){Math.abs(n)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),n=Jt(n,-65504,65504),An.floatView[0]=n;const e=An.uint32View[0],t=e>>23&511;return An.baseTable[t]+((e&8388607)>>An.shiftTable[t])}function al(n){const e=n>>10;return An.uint32View[0]=An.mantissaTable[An.offsetTable[e]+(n&1023)]+An.exponentTable[e],An.floatView[0]}const wv={toHalfFloat:sr,fromHalfFloat:al},ai=new N,vu=new J;class wt{constructor(e,t,i=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=Sa,this.updateRanges=[],this.gpuType=Oi,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let r=0,s=this.itemSize;r<s;r++)this.array[e+r]=t.array[i+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,i=this.count;t<i;t++)vu.fromBufferAttribute(this,t),vu.applyMatrix3(e),this.setXY(t,vu.x,vu.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)ai.fromBufferAttribute(this,t),ai.applyMatrix3(e),this.setXYZ(t,ai.x,ai.y,ai.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)ai.fromBufferAttribute(this,t),ai.applyMatrix4(e),this.setXYZ(t,ai.x,ai.y,ai.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)ai.fromBufferAttribute(this,t),ai.applyNormalMatrix(e),this.setXYZ(t,ai.x,ai.y,ai.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)ai.fromBufferAttribute(this,t),ai.transformDirection(e),this.setXYZ(t,ai.x,ai.y,ai.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let i=this.array[e*this.itemSize+t];return this.normalized&&(i=Xi(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=ht(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Xi(t,this.array)),t}setX(e,t){return this.normalized&&(t=ht(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Xi(t,this.array)),t}setY(e,t){return this.normalized&&(t=ht(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=Xi(t,this.array)),t}setZ(e,t){return this.normalized&&(t=ht(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=Xi(t,this.array)),t}setW(e,t){return this.normalized&&(t=ht(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=ht(t,this.array),i=ht(i,this.array)),this.array[e+0]=t,this.array[e+1]=i,this}setXYZ(e,t,i,r){return e*=this.itemSize,this.normalized&&(t=ht(t,this.array),i=ht(i,this.array),r=ht(r,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this}setXYZW(e,t,i,r,s){return e*=this.itemSize,this.normalized&&(t=ht(t,this.array),i=ht(i,this.array),r=ht(r,this.array),s=ht(s,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==Sa&&(e.usage=this.usage),e}}class $w extends wt{constructor(e,t,i){super(new Int8Array(e),t,i)}}class Jw extends wt{constructor(e,t,i){super(new Uint8Array(e),t,i)}}class Kw extends wt{constructor(e,t,i){super(new Uint8ClampedArray(e),t,i)}}class Zw extends wt{constructor(e,t,i){super(new Int16Array(e),t,i)}}class yu extends wt{constructor(e,t,i){super(new Uint16Array(e),t,i)}}class Qw extends wt{constructor(e,t,i){super(new Int32Array(e),t,i)}}class Dp extends wt{constructor(e,t,i){super(new Uint32Array(e),t,i)}}class Ev extends wt{constructor(e,t,i){super(new Uint16Array(e),t,i),this.isFloat16BufferAttribute=!0}getX(e){let t=al(this.array[e*this.itemSize]);return this.normalized&&(t=Xi(t,this.array)),t}setX(e,t){return this.normalized&&(t=ht(t,this.array)),this.array[e*this.itemSize]=sr(t),this}getY(e){let t=al(this.array[e*this.itemSize+1]);return this.normalized&&(t=Xi(t,this.array)),t}setY(e,t){return this.normalized&&(t=ht(t,this.array)),this.array[e*this.itemSize+1]=sr(t),this}getZ(e){let t=al(this.array[e*this.itemSize+2]);return this.normalized&&(t=Xi(t,this.array)),t}setZ(e,t){return this.normalized&&(t=ht(t,this.array)),this.array[e*this.itemSize+2]=sr(t),this}getW(e){let t=al(this.array[e*this.itemSize+3]);return this.normalized&&(t=Xi(t,this.array)),t}setW(e,t){return this.normalized&&(t=ht(t,this.array)),this.array[e*this.itemSize+3]=sr(t),this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=ht(t,this.array),i=ht(i,this.array)),this.array[e+0]=sr(t),this.array[e+1]=sr(i),this}setXYZ(e,t,i,r){return e*=this.itemSize,this.normalized&&(t=ht(t,this.array),i=ht(i,this.array),r=ht(r,this.array)),this.array[e+0]=sr(t),this.array[e+1]=sr(i),this.array[e+2]=sr(r),this}setXYZW(e,t,i,r,s){return e*=this.itemSize,this.normalized&&(t=ht(t,this.array),i=ht(i,this.array),r=ht(r,this.array),s=ht(s,this.array)),this.array[e+0]=sr(t),this.array[e+1]=sr(i),this.array[e+2]=sr(r),this.array[e+3]=sr(s),this}}class De extends wt{constructor(e,t,i){super(new Float32Array(e),t,i)}}let eE=0;const Lr=new Re,Up=new _t,Fa=new N,_r=new Bi,ol=new Bi,vi=new N;class ct extends vr{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:eE++}),this.uuid=yr(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(cv(e)?Dp:yu)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const s=new Ke().getNormalMatrix(e);i.applyNormalMatrix(s),i.needsUpdate=!0}const r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Lr.makeRotationFromQuaternion(e),this.applyMatrix4(Lr),this}rotateX(e){return Lr.makeRotationX(e),this.applyMatrix4(Lr),this}rotateY(e){return Lr.makeRotationY(e),this.applyMatrix4(Lr),this}rotateZ(e){return Lr.makeRotationZ(e),this.applyMatrix4(Lr),this}translate(e,t,i){return Lr.makeTranslation(e,t,i),this.applyMatrix4(Lr),this}scale(e,t,i){return Lr.makeScale(e,t,i),this.applyMatrix4(Lr),this}lookAt(e){return Up.lookAt(e),Up.updateMatrix(),this.applyMatrix4(Up.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Fa).negate(),this.translate(Fa.x,Fa.y,Fa.z),this}setFromPoints(e){const t=[];for(let i=0,r=e.length;i<r;i++){const s=e[i];t.push(s.x,s.y,s.z||0)}return this.setAttribute("position",new De(t,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Bi);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new N(-1/0,-1/0,-1/0),new N(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,r=t.length;i<r;i++){const s=t[i];_r.setFromBufferAttribute(s),this.morphTargetsRelative?(vi.addVectors(this.boundingBox.min,_r.min),this.boundingBox.expandByPoint(vi),vi.addVectors(this.boundingBox.max,_r.max),this.boundingBox.expandByPoint(vi)):(this.boundingBox.expandByPoint(_r.min),this.boundingBox.expandByPoint(_r.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Ai);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new N,1/0);return}if(e){const i=this.boundingSphere.center;if(_r.setFromBufferAttribute(e),t)for(let s=0,a=t.length;s<a;s++){const o=t[s];ol.setFromBufferAttribute(o),this.morphTargetsRelative?(vi.addVectors(_r.min,ol.min),_r.expandByPoint(vi),vi.addVectors(_r.max,ol.max),_r.expandByPoint(vi)):(_r.expandByPoint(ol.min),_r.expandByPoint(ol.max))}_r.getCenter(i);let r=0;for(let s=0,a=e.count;s<a;s++)vi.fromBufferAttribute(e,s),r=Math.max(r,i.distanceToSquared(vi));if(t)for(let s=0,a=t.length;s<a;s++){const o=t[s],l=this.morphTargetsRelative;for(let c=0,u=o.count;c<u;c++)vi.fromBufferAttribute(o,c),l&&(Fa.fromBufferAttribute(e,c),vi.add(Fa)),r=Math.max(r,i.distanceToSquared(vi))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=t.position,r=t.normal,s=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new wt(new Float32Array(4*i.count),4));const a=this.getAttribute("tangent"),o=[],l=[];for(let C=0;C<i.count;C++)o[C]=new N,l[C]=new N;const c=new N,u=new N,h=new N,d=new J,p=new J,m=new J,v=new N,f=new N;function g(C,H,M){c.fromBufferAttribute(i,C),u.fromBufferAttribute(i,H),h.fromBufferAttribute(i,M),d.fromBufferAttribute(s,C),p.fromBufferAttribute(s,H),m.fromBufferAttribute(s,M),u.sub(c),h.sub(c),p.sub(d),m.sub(d);const T=1/(p.x*m.y-m.x*p.y);isFinite(T)&&(v.copy(u).multiplyScalar(m.y).addScaledVector(h,-p.y).multiplyScalar(T),f.copy(h).multiplyScalar(p.x).addScaledVector(u,-m.x).multiplyScalar(T),o[C].add(v),o[H].add(v),o[M].add(v),l[C].add(f),l[H].add(f),l[M].add(f))}let x=this.groups;x.length===0&&(x=[{start:0,count:e.count}]);for(let C=0,H=x.length;C<H;++C){const M=x[C],T=M.start,k=M.count;for(let j=T,Y=T+k;j<Y;j+=3)g(e.getX(j+0),e.getX(j+1),e.getX(j+2))}const y=new N,_=new N,I=new N,b=new N;function w(C){I.fromBufferAttribute(r,C),b.copy(I);const H=o[C];y.copy(H),y.sub(I.multiplyScalar(I.dot(H))).normalize(),_.crossVectors(b,H);const M=_.dot(l[C])<0?-1:1;a.setXYZW(C,y.x,y.y,y.z,M)}for(let C=0,H=x.length;C<H;++C){const M=x[C],T=M.start,k=M.count;for(let j=T,Y=T+k;j<Y;j+=3)w(e.getX(j+0)),w(e.getX(j+1)),w(e.getX(j+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let i=this.getAttribute("normal");if(i===void 0)i=new wt(new Float32Array(t.count*3),3),this.setAttribute("normal",i);else for(let d=0,p=i.count;d<p;d++)i.setXYZ(d,0,0,0);const r=new N,s=new N,a=new N,o=new N,l=new N,c=new N,u=new N,h=new N;if(e)for(let d=0,p=e.count;d<p;d+=3){const m=e.getX(d+0),v=e.getX(d+1),f=e.getX(d+2);r.fromBufferAttribute(t,m),s.fromBufferAttribute(t,v),a.fromBufferAttribute(t,f),u.subVectors(a,s),h.subVectors(r,s),u.cross(h),o.fromBufferAttribute(i,m),l.fromBufferAttribute(i,v),c.fromBufferAttribute(i,f),o.add(u),l.add(u),c.add(u),i.setXYZ(m,o.x,o.y,o.z),i.setXYZ(v,l.x,l.y,l.z),i.setXYZ(f,c.x,c.y,c.z)}else for(let d=0,p=t.count;d<p;d+=3)r.fromBufferAttribute(t,d+0),s.fromBufferAttribute(t,d+1),a.fromBufferAttribute(t,d+2),u.subVectors(a,s),h.subVectors(r,s),u.cross(h),i.setXYZ(d+0,u.x,u.y,u.z),i.setXYZ(d+1,u.x,u.y,u.z),i.setXYZ(d+2,u.x,u.y,u.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)vi.fromBufferAttribute(e,t),vi.normalize(),e.setXYZ(t,vi.x,vi.y,vi.z)}toNonIndexed(){function e(o,l){const c=o.array,u=o.itemSize,h=o.normalized,d=new c.constructor(l.length*u);let p=0,m=0;for(let v=0,f=l.length;v<f;v++){o.isInterleavedBufferAttribute?p=l[v]*o.data.stride+o.offset:p=l[v]*u;for(let g=0;g<u;g++)d[m++]=c[p++]}return new wt(d,u,h)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new ct,i=this.index.array,r=this.attributes;for(const o in r){const l=r[o],c=e(l,i);t.setAttribute(o,c)}const s=this.morphAttributes;for(const o in s){const l=[],c=s[o];for(let u=0,h=c.length;u<h;u++){const d=c[u],p=e(d,i);l.push(p)}t.morphAttributes[o]=l}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const c=a[o];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){const e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const l in i){const c=i[l];e.data.attributes[l]=c.toJSON(e.data)}const r={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],u=[];for(let h=0,d=c.length;h<d;h++){const p=c[h];u.push(p.toJSON(e.data))}u.length>0&&(r[l]=u,s=!0)}s&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const i=e.index;i!==null&&this.setIndex(i.clone(t));const r=e.attributes;for(const c in r){const u=r[c];this.setAttribute(c,u.clone(t))}const s=e.morphAttributes;for(const c in s){const u=[],h=s[c];for(let d=0,p=h.length;d<p;d++)u.push(h[d].clone(t));this.morphAttributes[c]=u}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let c=0,u=a.length;c<u;c++){const h=a[c];this.addGroup(h.start,h.count,h.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const Av=new Re,Ns=new As,xu=new Ai,Nv=new N,_u=new N,Mu=new N,bu=new N,Op=new N,Tu=new N,Cv=new N,Su=new N;class Ft extends _t{constructor(e=new ct,t=new Yr){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){const a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}getVertexPosition(e,t){const i=this.geometry,r=i.attributes.position,s=i.morphAttributes.position,a=i.morphTargetsRelative;t.fromBufferAttribute(r,e);const o=this.morphTargetInfluences;if(s&&o){Tu.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const u=o[l],h=s[l];u!==0&&(Op.fromBufferAttribute(h,e),a?Tu.addScaledVector(Op,u):Tu.addScaledVector(Op.sub(t),u))}t.add(Tu)}return t}raycast(e,t){const i=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),xu.copy(i.boundingSphere),xu.applyMatrix4(s),Ns.copy(e.ray).recast(e.near),!(xu.containsPoint(Ns.origin)===!1&&(Ns.intersectSphere(xu,Nv)===null||Ns.origin.distanceToSquared(Nv)>(e.far-e.near)**2))&&(Av.copy(s).invert(),Ns.copy(e.ray).applyMatrix4(Av),!(i.boundingBox!==null&&Ns.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,Ns)))}_computeIntersections(e,t,i){let r;const s=this.geometry,a=this.material,o=s.index,l=s.attributes.position,c=s.attributes.uv,u=s.attributes.uv1,h=s.attributes.normal,d=s.groups,p=s.drawRange;if(o!==null)if(Array.isArray(a))for(let m=0,v=d.length;m<v;m++){const f=d[m],g=a[f.materialIndex],x=Math.max(f.start,p.start),y=Math.min(o.count,Math.min(f.start+f.count,p.start+p.count));for(let _=x,I=y;_<I;_+=3){const b=o.getX(_),w=o.getX(_+1),C=o.getX(_+2);r=wu(this,g,e,i,c,u,h,b,w,C),r&&(r.faceIndex=Math.floor(_/3),r.face.materialIndex=f.materialIndex,t.push(r))}}else{const m=Math.max(0,p.start),v=Math.min(o.count,p.start+p.count);for(let f=m,g=v;f<g;f+=3){const x=o.getX(f),y=o.getX(f+1),_=o.getX(f+2);r=wu(this,a,e,i,c,u,h,x,y,_),r&&(r.faceIndex=Math.floor(f/3),t.push(r))}}else if(l!==void 0)if(Array.isArray(a))for(let m=0,v=d.length;m<v;m++){const f=d[m],g=a[f.materialIndex],x=Math.max(f.start,p.start),y=Math.min(l.count,Math.min(f.start+f.count,p.start+p.count));for(let _=x,I=y;_<I;_+=3){const b=_,w=_+1,C=_+2;r=wu(this,g,e,i,c,u,h,b,w,C),r&&(r.faceIndex=Math.floor(_/3),r.face.materialIndex=f.materialIndex,t.push(r))}}else{const m=Math.max(0,p.start),v=Math.min(l.count,p.start+p.count);for(let f=m,g=v;f<g;f+=3){const x=f,y=f+1,_=f+2;r=wu(this,a,e,i,c,u,h,x,y,_),r&&(r.faceIndex=Math.floor(f/3),t.push(r))}}}}function tE(n,e,t,i,r,s,a,o){let l;if(e.side===si?l=i.intersectTriangle(a,s,r,!0,o):l=i.intersectTriangle(r,s,a,e.side===an,o),l===null)return null;Su.copy(o),Su.applyMatrix4(n.matrixWorld);const c=t.ray.origin.distanceTo(Su);return c<t.near||c>t.far?null:{distance:c,point:Su.clone(),object:n}}function wu(n,e,t,i,r,s,a,o,l,c){n.getVertexPosition(o,_u),n.getVertexPosition(l,Mu),n.getVertexPosition(c,bu);const u=tE(n,e,t,i,_u,Mu,bu,Cv);if(u){const h=new N;er.getBarycoord(Cv,_u,Mu,bu,h),r&&(u.uv=er.getInterpolatedAttribute(r,o,l,c,h,new J)),s&&(u.uv1=er.getInterpolatedAttribute(s,o,l,c,h,new J)),a&&(u.normal=er.getInterpolatedAttribute(a,o,l,c,h,new N),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));const d={a:o,b:l,c,normal:new N,materialIndex:0};er.getNormal(_u,Mu,bu,d.normal),u.face=d,u.barycoord=h}return u}class yn extends ct{constructor(e=1,t=1,i=1,r=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:r,heightSegments:s,depthSegments:a};const o=this;r=Math.floor(r),s=Math.floor(s),a=Math.floor(a);const l=[],c=[],u=[],h=[];let d=0,p=0;m("z","y","x",-1,-1,i,t,e,a,s,0),m("z","y","x",1,-1,i,t,-e,a,s,1),m("x","z","y",1,1,e,i,t,r,a,2),m("x","z","y",1,-1,e,i,-t,r,a,3),m("x","y","z",1,-1,e,t,i,r,s,4),m("x","y","z",-1,-1,e,t,-i,r,s,5),this.setIndex(l),this.setAttribute("position",new De(c,3)),this.setAttribute("normal",new De(u,3)),this.setAttribute("uv",new De(h,2));function m(v,f,g,x,y,_,I,b,w,C,H){const M=_/w,T=I/C,k=_/2,j=I/2,Y=b/2,re=w+1,$=C+1;let he=0,Q=0;const ye=new N;for(let be=0;be<$;be++){const Ve=be*T-j;for(let at=0;at<re;at++){const et=at*M-k;ye[v]=et*x,ye[f]=Ve*y,ye[g]=Y,c.push(ye.x,ye.y,ye.z),ye[v]=0,ye[f]=0,ye[g]=b>0?1:-1,u.push(ye.x,ye.y,ye.z),h.push(at/w),h.push(1-be/C),he+=1}}for(let be=0;be<C;be++)for(let Ve=0;Ve<w;Ve++){const at=d+Ve+re*be,et=d+Ve+re*(be+1),ie=d+(Ve+1)+re*(be+1),le=d+(Ve+1)+re*be;l.push(at,et,le),l.push(et,ie,le),Q+=6}o.addGroup(p,Q,H),p+=Q,d+=he}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new yn(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Va(n){const e={};for(const t in n){e[t]={};for(const i in n[t]){const r=n[t][i];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][i]=null):e[t][i]=r.clone():Array.isArray(r)?e[t][i]=r.slice():e[t][i]=r}}return e}function Yi(n){const e={};for(let t=0;t<n.length;t++){const i=Va(n[t]);for(const r in i)e[r]=i[r]}return e}function iE(n){const e=[];for(let t=0;t<n.length;t++)e.push(n[t].clone());return e}function Rv(n){const e=n.getRenderTarget();return e===null?n.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:vt.workingColorSpace}const Fp={clone:Va,merge:Yi};var rE=`void main() {
|
|
5
|
+
*/const ZS="169",m0={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},f0={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},g0=0,kd=1,v0=2,QS=3,ew=0,Hd=1,Gd=2,rr=3,an=0,si=1,Gr=2,Er=0,_n=1,Eo=2,Wd=3,jd=4,Xd=5,Vn=100,y0=101,x0=102,_0=103,qd=104,M0=200,b0=201,T0=202,S0=203,Tc=204,Sc=205,w0=206,E0=207,A0=208,N0=209,C0=210,R0=211,I0=212,L0=213,P0=214,Ao=0,No=1,Co=2,Bn=3,Ro=4,Io=5,Lo=6,Po=7,pa=0,Yd=1,$d=2,mr=0,wc=1,Ec=2,Jd=3,Ac=4,D0=5,Nc=6,Cc=7,Kd="attached",U0="detached",Rc=300,fr=301,Ar=302,zn=303,kn=304,ys=306,Hn=1e3,gr=1001,ma=1002,$t=1003,Ic=1004,tw=1004,Mn=1005,iw=1005,Lt=1006,Gn=1007,rw=1007,ji=1008,O0=1008,Wr=1009,Zd=1010,Qd=1011,fa=1012,ga=1013,Nr=1014,Oi=1015,wi=1016,Lc=1017,Pc=1018,Wn=1020,ep=35902,tp=1021,ip=1022,Ei=1023,rp=1024,np=1025,jn=1026,Xn=1027,Do=1028,Uo=1029,va=1030,Dc=1031,nw=1032,Uc=1033,Oo=33776,ya=33777,Fo=33778,xa=33779,Vo=35840,Oc=35841,Bo=35842,Fc=35843,zo=36196,ko=37492,Ho=37496,Go=37808,Vc=37809,Bc=37810,zc=37811,Wo=37812,kc=37813,Hc=37814,Gc=37815,Wc=37816,jc=37817,Xc=37818,qc=37819,Yc=37820,$c=37821,_a=36492,Jc=36494,Kc=36495,sp=36283,Zc=36284,Qc=36285,eu=36286,ap=2200,op=2201,F0=2202,Ma=2300,jo=2301,tu=2302,xs=2400,_s=2401,Xo=2402,iu=2500,lp=2501,V0=0,B0=1,z0=2,cp=3200,up=3201,sw=3202,aw=3203,on=0,hp=1,Cr="",Fi="srgb",nr="srgb-linear",qo="display-p3",ba="display-p3-linear",Yo="linear",Ot="srgb",$o="rec709",Jo="p3",k0=0,qn=7680,H0=7681,G0=7682,W0=7683,j0=34055,X0=34056,q0=5386,Y0=512,$0=513,J0=514,K0=515,Z0=516,Q0=517,ev=518,ru=519,tv=512,dp=513,iv=514,pp=515,rv=516,nv=517,sv=518,av=519,Ta=35044,Ms=35048,ow=35040,lw=35045,cw=35049,uw=35041,hw=35046,dw=35050,pw=35042,mw="100",nu="300 es",Rr=2e3,bs=2001;class vr{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;const i=this._listeners;return i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const i=this._listeners[e];if(i!==void 0){const r=i.indexOf(t);r!==-1&&i.splice(r,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const t=this._listeners[e.type];if(t!==void 0){e.target=this;const i=t.slice(0);for(let r=0,s=i.length;r<s;r++)i[r].call(this,e);e.target=null}}}const Vi=["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 ov=1234567;const Ts=Math.PI/180,Sa=180/Math.PI;function yr(){const n=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Vi[n&255]+Vi[n>>8&255]+Vi[n>>16&255]+Vi[n>>24&255]+"-"+Vi[e&255]+Vi[e>>8&255]+"-"+Vi[e>>16&15|64]+Vi[e>>24&255]+"-"+Vi[t&63|128]+Vi[t>>8&255]+"-"+Vi[t>>16&255]+Vi[t>>24&255]+Vi[i&255]+Vi[i>>8&255]+Vi[i>>16&255]+Vi[i>>24&255]).toLowerCase()}function Jt(n,e,t){return Math.max(e,Math.min(t,n))}function mp(n,e){return(n%e+e)%e}function fw(n,e,t,i,r){return i+(n-e)*(r-i)/(t-e)}function gw(n,e,t){return n!==e?(t-n)/(e-n):0}function Ko(n,e,t){return(1-t)*n+t*e}function vw(n,e,t,i){return Ko(n,e,1-Math.exp(-t*i))}function yw(n,e=1){return e-Math.abs(mp(n,e*2)-e)}function xw(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*(3-2*n))}function _w(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*n*(n*(n*6-15)+10))}function Mw(n,e){return n+Math.floor(Math.random()*(e-n+1))}function bw(n,e){return n+Math.random()*(e-n)}function Tw(n){return n*(.5-Math.random())}function Sw(n){n!==void 0&&(ov=n);let e=ov+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function ww(n){return n*Ts}function Ew(n){return n*Sa}function Aw(n){return(n&n-1)===0&&n!==0}function Nw(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function Cw(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function Rw(n,e,t,i,r){const s=Math.cos,a=Math.sin,o=s(t/2),l=a(t/2),c=s((e+i)/2),u=a((e+i)/2),h=s((e-i)/2),d=a((e-i)/2),p=s((i-e)/2),m=a((i-e)/2);switch(r){case"XYX":n.set(o*u,l*h,l*d,o*c);break;case"YZY":n.set(l*d,o*u,l*h,o*c);break;case"ZXZ":n.set(l*h,l*d,o*u,o*c);break;case"XZX":n.set(o*u,l*m,l*p,o*c);break;case"YXY":n.set(l*p,o*u,l*m,o*c);break;case"ZYZ":n.set(l*m,l*p,o*u,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function Xi(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("Invalid component type.")}}function ht(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("Invalid component type.")}}const su={DEG2RAD:Ts,RAD2DEG:Sa,generateUUID:yr,clamp:Jt,euclideanModulo:mp,mapLinear:fw,inverseLerp:gw,lerp:Ko,damp:vw,pingpong:yw,smoothstep:xw,smootherstep:_w,randInt:Mw,randFloat:bw,randFloatSpread:Tw,seededRandom:Sw,degToRad:ww,radToDeg:Ew,isPowerOfTwo:Aw,ceilPowerOfTwo:Nw,floorPowerOfTwo:Cw,setQuaternionFromProperEuler:Rw,normalize:ht,denormalize:Xi};class J{constructor(e=0,t=0){J.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,i=this.y,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6],this.y=r[1]*t+r[4]*i+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(Jt(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const i=Math.cos(t),r=Math.sin(t),s=this.x-e.x,a=this.y-e.y;return this.x=s*i-a*r+e.x,this.y=s*r+a*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Ke{constructor(e,t,i,r,s,a,o,l,c){Ke.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,r,s,a,o,l,c)}set(e,t,i,r,s,a,o,l,c){const u=this.elements;return u[0]=e,u[1]=r,u[2]=o,u[3]=t,u[4]=s,u[5]=l,u[6]=i,u[7]=a,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,r=t.elements,s=this.elements,a=i[0],o=i[3],l=i[6],c=i[1],u=i[4],h=i[7],d=i[2],p=i[5],m=i[8],v=r[0],f=r[3],g=r[6],x=r[1],y=r[4],_=r[7],I=r[2],b=r[5],w=r[8];return s[0]=a*v+o*x+l*I,s[3]=a*f+o*y+l*b,s[6]=a*g+o*_+l*w,s[1]=c*v+u*x+h*I,s[4]=c*f+u*y+h*b,s[7]=c*g+u*_+h*w,s[2]=d*v+p*x+m*I,s[5]=d*f+p*y+m*b,s[8]=d*g+p*_+m*w,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8];return t*a*u-t*o*c-i*s*u+i*o*l+r*s*c-r*a*l}invert(){const e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8],h=u*a-o*c,d=o*l-u*s,p=c*s-a*l,m=t*h+i*d+r*p;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/m;return e[0]=h*v,e[1]=(r*c-u*i)*v,e[2]=(o*i-r*a)*v,e[3]=d*v,e[4]=(u*t-r*l)*v,e[5]=(r*s-o*t)*v,e[6]=p*v,e[7]=(i*l-c*t)*v,e[8]=(a*t-i*s)*v,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,r,s,a,o){const l=Math.cos(s),c=Math.sin(s);return this.set(i*l,i*c,-i*(l*a+c*o)+a+e,-r*c,r*l,-r*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(fp.makeScale(e,t)),this}rotate(e){return this.premultiply(fp.makeRotation(-e)),this}translate(e,t){return this.premultiply(fp.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,i=e.elements;for(let r=0;r<9;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const fp=new Ke;function lv(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}const Iw={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function wa(n,e){return new Iw[n](e)}function Zo(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function cv(){const n=Zo("canvas");return n.style.display="block",n}const uv={};function au(n){n in uv||(uv[n]=!0,console.warn(n))}function Lw(n,e,t){return new Promise(function(i,r){function s(){switch(n.clientWaitSync(e,n.SYNC_FLUSH_COMMANDS_BIT,0)){case n.WAIT_FAILED:r();break;case n.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:i()}}setTimeout(s,t)})}function Pw(n){const e=n.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]}function Dw(n){const e=n.elements;e[11]===-1?(e[10]=-e[10]-1,e[14]=-e[14]):(e[10]=-e[10],e[14]=-e[14]+1)}const hv=new Ke().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),dv=new Ke().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),Qo={[nr]:{transfer:Yo,primaries:$o,luminanceCoefficients:[.2126,.7152,.0722],toReference:n=>n,fromReference:n=>n},[Fi]:{transfer:Ot,primaries:$o,luminanceCoefficients:[.2126,.7152,.0722],toReference:n=>n.convertSRGBToLinear(),fromReference:n=>n.convertLinearToSRGB()},[ba]:{transfer:Yo,primaries:Jo,luminanceCoefficients:[.2289,.6917,.0793],toReference:n=>n.applyMatrix3(dv),fromReference:n=>n.applyMatrix3(hv)},[qo]:{transfer:Ot,primaries:Jo,luminanceCoefficients:[.2289,.6917,.0793],toReference:n=>n.convertSRGBToLinear().applyMatrix3(dv),fromReference:n=>n.applyMatrix3(hv).convertLinearToSRGB()}},Uw=new Set([nr,ba]),vt={enabled:!0,_workingColorSpace:nr,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(n){if(!Uw.has(n))throw new Error(`Unsupported working color space, "${n}".`);this._workingColorSpace=n},convert:function(n,e,t){if(this.enabled===!1||e===t||!e||!t)return n;const i=Qo[e].toReference,r=Qo[t].fromReference;return r(i(n))},fromWorkingColorSpace:function(n,e){return this.convert(n,this._workingColorSpace,e)},toWorkingColorSpace:function(n,e){return this.convert(n,e,this._workingColorSpace)},getPrimaries:function(n){return Qo[n].primaries},getTransfer:function(n){return n===Cr?Yo:Qo[n].transfer},getLuminanceCoefficients:function(n,e=this._workingColorSpace){return n.fromArray(Qo[e].luminanceCoefficients)}};function Ea(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function gp(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}let Aa;class pv{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{Aa===void 0&&(Aa=Zo("canvas")),Aa.width=e.width,Aa.height=e.height;const i=Aa.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),t=Aa}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=Zo("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const r=i.getImageData(0,0,e.width,e.height),s=r.data;for(let a=0;a<s.length;a++)s[a]=Ea(s[a]/255)*255;return i.putImageData(r,0,0),t}else if(e.data){const t=e.data.slice(0);for(let i=0;i<t.length;i++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[i]=Math.floor(Ea(t[i]/255)*255):t[i]=Ea(t[i]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let Ow=0;class Yn{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Ow++}),this.uuid=yr(),this.data=e,this.dataReady=!0,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const i={uuid:this.uuid,url:""},r=this.data;if(r!==null){let s;if(Array.isArray(r)){s=[];for(let a=0,o=r.length;a<o;a++)r[a].isDataTexture?s.push(vp(r[a].image)):s.push(vp(r[a]))}else s=vp(r);i.url=s}return t||(e.images[this.uuid]=i),i}}function vp(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?pv.getDataURL(n):n.data?{data:Array.from(n.data),width:n.width,height:n.height,type:n.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let Fw=0;class Wt extends vr{constructor(e=Wt.DEFAULT_IMAGE,t=Wt.DEFAULT_MAPPING,i=gr,r=gr,s=Lt,a=ji,o=Ei,l=Wr,c=Wt.DEFAULT_ANISOTROPY,u=Cr){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Fw++}),this.uuid=yr(),this.name="",this.source=new Yn(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=r,this.magFilter=s,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new J(0,0),this.repeat=new J(1,1),this.center=new J(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ke,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Rc)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Hn:e.x=e.x-Math.floor(e.x);break;case gr:e.x=e.x<0?0:1;break;case ma:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Hn:e.y=e.y-Math.floor(e.y);break;case gr:e.y=e.y<0?0:1;break;case ma:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}Wt.DEFAULT_IMAGE=null,Wt.DEFAULT_MAPPING=Rc,Wt.DEFAULT_ANISOTROPY=4;class st{constructor(e=0,t=0,i=0,r=1){st.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,i=this.y,r=this.z,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*r+a[12]*s,this.y=a[1]*t+a[5]*i+a[9]*r+a[13]*s,this.z=a[2]*t+a[6]*i+a[10]*r+a[14]*s,this.w=a[3]*t+a[7]*i+a[11]*r+a[15]*s,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,r,s;const a=e.elements,o=a[0],l=a[4],c=a[8],u=a[1],h=a[5],d=a[9],p=a[2],m=a[6],v=a[10];if(Math.abs(l-u)<.01&&Math.abs(c-p)<.01&&Math.abs(d-m)<.01){if(Math.abs(l+u)<.1&&Math.abs(c+p)<.1&&Math.abs(d+m)<.1&&Math.abs(o+h+v-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const g=(o+1)/2,x=(h+1)/2,y=(v+1)/2,_=(l+u)/4,I=(c+p)/4,b=(d+m)/4;return g>x&&g>y?g<.01?(i=0,r=.707106781,s=.707106781):(i=Math.sqrt(g),r=_/i,s=I/i):x>y?x<.01?(i=.707106781,r=0,s=.707106781):(r=Math.sqrt(x),i=_/r,s=b/r):y<.01?(i=.707106781,r=.707106781,s=0):(s=Math.sqrt(y),i=I/s,r=b/s),this.set(i,r,s,t),this}let f=Math.sqrt((m-d)*(m-d)+(c-p)*(c-p)+(u-l)*(u-l));return Math.abs(f)<.001&&(f=1),this.x=(m-d)/f,this.y=(c-p)/f,this.z=(u-l)/f,this.w=Math.acos((o+h+v-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class ui extends vr{constructor(e=1,t=1,i={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new st(0,0,e,t),this.scissorTest=!1,this.viewport=new st(0,0,e,t);const r={width:e,height:t,depth:1};i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Lt,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},i);const s=new Wt(r,i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.colorSpace);s.flipY=!1,s.generateMipmaps=i.generateMipmaps,s.internalFormat=i.internalFormat,this.textures=[];const a=i.count;for(let o=0;o<a;o++)this.textures[o]=s.clone(),this.textures[o].isRenderTargetTexture=!0;this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this.depthTexture=i.depthTexture,this.samples=i.samples}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}setSize(e,t,i=1){if(this.width!==e||this.height!==t||this.depth!==i){this.width=e,this.height=t,this.depth=i;for(let r=0,s=this.textures.length;r<s;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=i;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let i=0,r=e.textures.length;i<r;i++)this.textures[i]=e.textures[i].clone(),this.textures[i].isRenderTargetTexture=!0;const t=Object.assign({},e.texture.image);return this.texture.source=new Yn(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Ir extends ui{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}}class el extends Wt{constructor(e=null,t=1,i=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=$t,this.minFilter=$t,this.wrapR=gr,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Vw extends Ir{constructor(e=1,t=1,i=1,r={}){super(e,t,r),this.isWebGLArrayRenderTarget=!0,this.depth=i,this.texture=new el(null,e,t,i),this.texture.isRenderTargetTexture=!0}}class ou extends Wt{constructor(e=null,t=1,i=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=$t,this.minFilter=$t,this.wrapR=gr,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Bw extends Ir{constructor(e=1,t=1,i=1,r={}){super(e,t,r),this.isWebGL3DRenderTarget=!0,this.depth=i,this.texture=new ou(null,e,t,i),this.texture.isRenderTargetTexture=!0}}class qi{constructor(e=0,t=0,i=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=r}static slerpFlat(e,t,i,r,s,a,o){let l=i[r+0],c=i[r+1],u=i[r+2],h=i[r+3];const d=s[a+0],p=s[a+1],m=s[a+2],v=s[a+3];if(o===0){e[t+0]=l,e[t+1]=c,e[t+2]=u,e[t+3]=h;return}if(o===1){e[t+0]=d,e[t+1]=p,e[t+2]=m,e[t+3]=v;return}if(h!==v||l!==d||c!==p||u!==m){let f=1-o;const g=l*d+c*p+u*m+h*v,x=g>=0?1:-1,y=1-g*g;if(y>Number.EPSILON){const I=Math.sqrt(y),b=Math.atan2(I,g*x);f=Math.sin(f*b)/I,o=Math.sin(o*b)/I}const _=o*x;if(l=l*f+d*_,c=c*f+p*_,u=u*f+m*_,h=h*f+v*_,f===1-o){const I=1/Math.sqrt(l*l+c*c+u*u+h*h);l*=I,c*=I,u*=I,h*=I}}e[t]=l,e[t+1]=c,e[t+2]=u,e[t+3]=h}static multiplyQuaternionsFlat(e,t,i,r,s,a){const o=i[r],l=i[r+1],c=i[r+2],u=i[r+3],h=s[a],d=s[a+1],p=s[a+2],m=s[a+3];return e[t]=o*m+u*h+l*p-c*d,e[t+1]=l*m+u*d+c*h-o*p,e[t+2]=c*m+u*p+o*d-l*h,e[t+3]=u*m-o*h-l*d-c*p,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const i=e._x,r=e._y,s=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(i/2),u=o(r/2),h=o(s/2),d=l(i/2),p=l(r/2),m=l(s/2);switch(a){case"XYZ":this._x=d*u*h+c*p*m,this._y=c*p*h-d*u*m,this._z=c*u*m+d*p*h,this._w=c*u*h-d*p*m;break;case"YXZ":this._x=d*u*h+c*p*m,this._y=c*p*h-d*u*m,this._z=c*u*m-d*p*h,this._w=c*u*h+d*p*m;break;case"ZXY":this._x=d*u*h-c*p*m,this._y=c*p*h+d*u*m,this._z=c*u*m+d*p*h,this._w=c*u*h-d*p*m;break;case"ZYX":this._x=d*u*h-c*p*m,this._y=c*p*h+d*u*m,this._z=c*u*m-d*p*h,this._w=c*u*h+d*p*m;break;case"YZX":this._x=d*u*h+c*p*m,this._y=c*p*h+d*u*m,this._z=c*u*m-d*p*h,this._w=c*u*h-d*p*m;break;case"XZY":this._x=d*u*h-c*p*m,this._y=c*p*h-d*u*m,this._z=c*u*m+d*p*h,this._w=c*u*h+d*p*m;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],r=t[4],s=t[8],a=t[1],o=t[5],l=t[9],c=t[2],u=t[6],h=t[10],d=i+o+h;if(d>0){const p=.5/Math.sqrt(d+1);this._w=.25/p,this._x=(u-l)*p,this._y=(s-c)*p,this._z=(a-r)*p}else if(i>o&&i>h){const p=2*Math.sqrt(1+i-o-h);this._w=(u-l)/p,this._x=.25*p,this._y=(r+a)/p,this._z=(s+c)/p}else if(o>h){const p=2*Math.sqrt(1+o-i-h);this._w=(s-c)/p,this._x=(r+a)/p,this._y=.25*p,this._z=(l+u)/p}else{const p=2*Math.sqrt(1+h-i-o);this._w=(a-r)/p,this._x=(s+c)/p,this._y=(l+u)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<Number.EPSILON?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Jt(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(i===0)return this;const r=Math.min(1,t/i);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const i=e._x,r=e._y,s=e._z,a=e._w,o=t._x,l=t._y,c=t._z,u=t._w;return this._x=i*u+a*o+r*c-s*l,this._y=r*u+a*l+s*o-i*c,this._z=s*u+a*c+i*l-r*o,this._w=a*u-i*o-r*l-s*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const i=this._x,r=this._y,s=this._z,a=this._w;let o=a*e._w+i*e._x+r*e._y+s*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=i,this._y=r,this._z=s,this;const l=1-o*o;if(l<=Number.EPSILON){const p=1-t;return this._w=p*a+t*this._w,this._x=p*i+t*this._x,this._y=p*r+t*this._y,this._z=p*s+t*this._z,this.normalize(),this}const c=Math.sqrt(l),u=Math.atan2(c,o),h=Math.sin((1-t)*u)/c,d=Math.sin(t*u)/c;return this._w=a*h+this._w*d,this._x=i*h+this._x*d,this._y=r*h+this._y*d,this._z=s*h+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),r=Math.sqrt(1-i),s=Math.sqrt(i);return this.set(r*Math.sin(e),r*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class N{constructor(e=0,t=0,i=0){N.prototype.isVector3=!0,this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(mv.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(mv.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6]*r,this.y=s[1]*t+s[4]*i+s[7]*r,this.z=s[2]*t+s[5]*i+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,r=this.z,s=e.elements,a=1/(s[3]*t+s[7]*i+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*i+s[8]*r+s[12])*a,this.y=(s[1]*t+s[5]*i+s[9]*r+s[13])*a,this.z=(s[2]*t+s[6]*i+s[10]*r+s[14])*a,this}applyQuaternion(e){const t=this.x,i=this.y,r=this.z,s=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*r-o*i),u=2*(o*t-s*r),h=2*(s*i-a*t);return this.x=t+l*c+a*h-o*u,this.y=i+l*u+o*c-s*h,this.z=r+l*h+s*u-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*i+s[8]*r,this.y=s[1]*t+s[5]*i+s[9]*r,this.z=s[2]*t+s[6]*i+s[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,r=e.y,s=e.z,a=t.x,o=t.y,l=t.z;return this.x=r*l-s*o,this.y=s*a-i*l,this.z=i*o-r*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return yp.copy(this).projectOnVector(e),this.sub(yp)}reflect(e){return this.sub(yp.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(Jt(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return t*t+i*i+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){const r=Math.sin(t)*e;return this.x=r*Math.sin(i),this.y=Math.cos(t)*e,this.z=r*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const yp=new N,mv=new qi;class Bi{constructor(e=new N(1/0,1/0,1/0),t=new N(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t+=3)this.expandByPoint(jr.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(jr.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const i=jr.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const i=e.geometry;if(i!==void 0){const s=i.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=s.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,jr):jr.fromBufferAttribute(s,a),jr.applyMatrix4(e.matrixWorld),this.expandByPoint(jr);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),lu.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),lu.copy(i.boundingBox)),lu.applyMatrix4(e.matrixWorld),this.union(lu)}const r=e.children;for(let s=0,a=r.length;s<a;s++)this.expandByObject(r[s],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,jr),jr.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(tl),cu.subVectors(this.max,tl),Na.subVectors(e.a,tl),Ca.subVectors(e.b,tl),Ra.subVectors(e.c,tl),$n.subVectors(Ca,Na),Jn.subVectors(Ra,Ca),Ss.subVectors(Na,Ra);let t=[0,-$n.z,$n.y,0,-Jn.z,Jn.y,0,-Ss.z,Ss.y,$n.z,0,-$n.x,Jn.z,0,-Jn.x,Ss.z,0,-Ss.x,-$n.y,$n.x,0,-Jn.y,Jn.x,0,-Ss.y,Ss.x,0];return!xp(t,Na,Ca,Ra,cu)||(t=[1,0,0,0,1,0,0,0,1],!xp(t,Na,Ca,Ra,cu))?!1:(uu.crossVectors($n,Jn),t=[uu.x,uu.y,uu.z],xp(t,Na,Ca,Ra,cu))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,jr).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(jr).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(bn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),bn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),bn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),bn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),bn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),bn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),bn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),bn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(bn),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const bn=[new N,new N,new N,new N,new N,new N,new N,new N],jr=new N,lu=new Bi,Na=new N,Ca=new N,Ra=new N,$n=new N,Jn=new N,Ss=new N,tl=new N,cu=new N,uu=new N,ws=new N;function xp(n,e,t,i,r){for(let s=0,a=n.length-3;s<=a;s+=3){ws.fromArray(n,s);const o=r.x*Math.abs(ws.x)+r.y*Math.abs(ws.y)+r.z*Math.abs(ws.z),l=e.dot(ws),c=t.dot(ws),u=i.dot(ws);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>o)return!1}return!0}const zw=new Bi,il=new N,_p=new N;class Ai{constructor(e=new N,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const i=this.center;t!==void 0?i.copy(t):zw.setFromPoints(e).getCenter(i);let r=0;for(let s=0,a=e.length;s<a;s++)r=Math.max(r,i.distanceToSquared(e[s]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const i=this.center.distanceToSquared(e);return t.copy(e),i>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;il.subVectors(e,this.center);const t=il.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),r=(i-this.radius)*.5;this.center.addScaledVector(il,r/i),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(_p.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(il.copy(e.center).add(_p)),this.expandByPoint(il.copy(e.center).sub(_p))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const Tn=new N,Mp=new N,hu=new N,Kn=new N,bp=new N,du=new N,Tp=new N;class Es{constructor(e=new N,t=new N(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Tn)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Tn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Tn.copy(this.origin).addScaledVector(this.direction,t),Tn.distanceToSquared(e))}distanceSqToSegment(e,t,i,r){Mp.copy(e).add(t).multiplyScalar(.5),hu.copy(t).sub(e).normalize(),Kn.copy(this.origin).sub(Mp);const s=e.distanceTo(t)*.5,a=-this.direction.dot(hu),o=Kn.dot(this.direction),l=-Kn.dot(hu),c=Kn.lengthSq(),u=Math.abs(1-a*a);let h,d,p,m;if(u>0)if(h=a*l-o,d=a*o-l,m=s*u,h>=0)if(d>=-m)if(d<=m){const v=1/u;h*=v,d*=v,p=h*(h+a*d+2*o)+d*(a*h+d+2*l)+c}else d=s,h=Math.max(0,-(a*d+o)),p=-h*h+d*(d+2*l)+c;else d=-s,h=Math.max(0,-(a*d+o)),p=-h*h+d*(d+2*l)+c;else d<=-m?(h=Math.max(0,-(-a*s+o)),d=h>0?-s:Math.min(Math.max(-s,-l),s),p=-h*h+d*(d+2*l)+c):d<=m?(h=0,d=Math.min(Math.max(-s,-l),s),p=d*(d+2*l)+c):(h=Math.max(0,-(a*s+o)),d=h>0?s:Math.min(Math.max(-s,-l),s),p=-h*h+d*(d+2*l)+c);else d=a>0?-s:s,h=Math.max(0,-(a*d+o)),p=-h*h+d*(d+2*l)+c;return i&&i.copy(this.origin).addScaledVector(this.direction,h),r&&r.copy(Mp).addScaledVector(hu,d),p}intersectSphere(e,t){Tn.subVectors(e.center,this.origin);const i=Tn.dot(this.direction),r=Tn.dot(Tn)-i*i,s=e.radius*e.radius;if(r>s)return null;const a=Math.sqrt(s-r),o=i-a,l=i+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,r,s,a,o,l;const c=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,d=this.origin;return c>=0?(i=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(i=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),u>=0?(s=(e.min.y-d.y)*u,a=(e.max.y-d.y)*u):(s=(e.max.y-d.y)*u,a=(e.min.y-d.y)*u),i>a||s>r||((s>i||isNaN(i))&&(i=s),(a<r||isNaN(r))&&(r=a),h>=0?(o=(e.min.z-d.z)*h,l=(e.max.z-d.z)*h):(o=(e.max.z-d.z)*h,l=(e.min.z-d.z)*h),i>l||o>r)||((o>i||i!==i)&&(i=o),(l<r||r!==r)&&(r=l),r<0)?null:this.at(i>=0?i:r,t)}intersectsBox(e){return this.intersectBox(e,Tn)!==null}intersectTriangle(e,t,i,r,s){bp.subVectors(t,e),du.subVectors(i,e),Tp.crossVectors(bp,du);let a=this.direction.dot(Tp),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Kn.subVectors(this.origin,e);const l=o*this.direction.dot(du.crossVectors(Kn,du));if(l<0)return null;const c=o*this.direction.dot(bp.cross(Kn));if(c<0||l+c>a)return null;const u=-o*Kn.dot(Tp);return u<0?null:this.at(u/a,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Re{constructor(e,t,i,r,s,a,o,l,c,u,h,d,p,m,v,f){Re.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,i,r,s,a,o,l,c,u,h,d,p,m,v,f)}set(e,t,i,r,s,a,o,l,c,u,h,d,p,m,v,f){const g=this.elements;return g[0]=e,g[4]=t,g[8]=i,g[12]=r,g[1]=s,g[5]=a,g[9]=o,g[13]=l,g[2]=c,g[6]=u,g[10]=h,g[14]=d,g[3]=p,g[7]=m,g[11]=v,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 Re().fromArray(this.elements)}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){const t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,i=e.elements,r=1/Ia.setFromMatrixColumn(e,0).length(),s=1/Ia.setFromMatrixColumn(e,1).length(),a=1/Ia.setFromMatrixColumn(e,2).length();return t[0]=i[0]*r,t[1]=i[1]*r,t[2]=i[2]*r,t[3]=0,t[4]=i[4]*s,t[5]=i[5]*s,t[6]=i[6]*s,t[7]=0,t[8]=i[8]*a,t[9]=i[9]*a,t[10]=i[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,i=e.x,r=e.y,s=e.z,a=Math.cos(i),o=Math.sin(i),l=Math.cos(r),c=Math.sin(r),u=Math.cos(s),h=Math.sin(s);if(e.order==="XYZ"){const d=a*u,p=a*h,m=o*u,v=o*h;t[0]=l*u,t[4]=-l*h,t[8]=c,t[1]=p+m*c,t[5]=d-v*c,t[9]=-o*l,t[2]=v-d*c,t[6]=m+p*c,t[10]=a*l}else if(e.order==="YXZ"){const d=l*u,p=l*h,m=c*u,v=c*h;t[0]=d+v*o,t[4]=m*o-p,t[8]=a*c,t[1]=a*h,t[5]=a*u,t[9]=-o,t[2]=p*o-m,t[6]=v+d*o,t[10]=a*l}else if(e.order==="ZXY"){const d=l*u,p=l*h,m=c*u,v=c*h;t[0]=d-v*o,t[4]=-a*h,t[8]=m+p*o,t[1]=p+m*o,t[5]=a*u,t[9]=v-d*o,t[2]=-a*c,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){const d=a*u,p=a*h,m=o*u,v=o*h;t[0]=l*u,t[4]=m*c-p,t[8]=d*c+v,t[1]=l*h,t[5]=v*c+d,t[9]=p*c-m,t[2]=-c,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){const d=a*l,p=a*c,m=o*l,v=o*c;t[0]=l*u,t[4]=v-d*h,t[8]=m*h+p,t[1]=h,t[5]=a*u,t[9]=-o*u,t[2]=-c*u,t[6]=p*h+m,t[10]=d-v*h}else if(e.order==="XZY"){const d=a*l,p=a*c,m=o*l,v=o*c;t[0]=l*u,t[4]=-h,t[8]=c*u,t[1]=d*h+v,t[5]=a*u,t[9]=p*h-m,t[2]=m*h-p,t[6]=o*u,t[10]=v*h+d}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(kw,e,Hw)}lookAt(e,t,i){const r=this.elements;return xr.subVectors(e,t),xr.lengthSq()===0&&(xr.z=1),xr.normalize(),Zn.crossVectors(i,xr),Zn.lengthSq()===0&&(Math.abs(i.z)===1?xr.x+=1e-4:xr.z+=1e-4,xr.normalize(),Zn.crossVectors(i,xr)),Zn.normalize(),pu.crossVectors(xr,Zn),r[0]=Zn.x,r[4]=pu.x,r[8]=xr.x,r[1]=Zn.y,r[5]=pu.y,r[9]=xr.y,r[2]=Zn.z,r[6]=pu.z,r[10]=xr.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,r=t.elements,s=this.elements,a=i[0],o=i[4],l=i[8],c=i[12],u=i[1],h=i[5],d=i[9],p=i[13],m=i[2],v=i[6],f=i[10],g=i[14],x=i[3],y=i[7],_=i[11],I=i[15],b=r[0],w=r[4],C=r[8],H=r[12],M=r[1],T=r[5],k=r[9],j=r[13],Y=r[2],re=r[6],$=r[10],he=r[14],Q=r[3],ye=r[7],be=r[11],Ve=r[15];return s[0]=a*b+o*M+l*Y+c*Q,s[4]=a*w+o*T+l*re+c*ye,s[8]=a*C+o*k+l*$+c*be,s[12]=a*H+o*j+l*he+c*Ve,s[1]=u*b+h*M+d*Y+p*Q,s[5]=u*w+h*T+d*re+p*ye,s[9]=u*C+h*k+d*$+p*be,s[13]=u*H+h*j+d*he+p*Ve,s[2]=m*b+v*M+f*Y+g*Q,s[6]=m*w+v*T+f*re+g*ye,s[10]=m*C+v*k+f*$+g*be,s[14]=m*H+v*j+f*he+g*Ve,s[3]=x*b+y*M+_*Y+I*Q,s[7]=x*w+y*T+_*re+I*ye,s[11]=x*C+y*k+_*$+I*be,s[15]=x*H+y*j+_*he+I*Ve,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[4],r=e[8],s=e[12],a=e[1],o=e[5],l=e[9],c=e[13],u=e[2],h=e[6],d=e[10],p=e[14],m=e[3],v=e[7],f=e[11],g=e[15];return m*(+s*l*h-r*c*h-s*o*d+i*c*d+r*o*p-i*l*p)+v*(+t*l*p-t*c*d+s*a*d-r*a*p+r*c*u-s*l*u)+f*(+t*c*h-t*o*p-s*a*h+i*a*p+s*o*u-i*c*u)+g*(-r*o*u-t*l*h+t*o*d+r*a*h-i*a*d+i*l*u)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=i),this}invert(){const e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8],h=e[9],d=e[10],p=e[11],m=e[12],v=e[13],f=e[14],g=e[15],x=h*f*c-v*d*c+v*l*p-o*f*p-h*l*g+o*d*g,y=m*d*c-u*f*c-m*l*p+a*f*p+u*l*g-a*d*g,_=u*v*c-m*h*c+m*o*p-a*v*p-u*o*g+a*h*g,I=m*h*l-u*v*l-m*o*d+a*v*d+u*o*f-a*h*f,b=t*x+i*y+r*_+s*I;if(b===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const w=1/b;return e[0]=x*w,e[1]=(v*d*s-h*f*s-v*r*p+i*f*p+h*r*g-i*d*g)*w,e[2]=(o*f*s-v*l*s+v*r*c-i*f*c-o*r*g+i*l*g)*w,e[3]=(h*l*s-o*d*s-h*r*c+i*d*c+o*r*p-i*l*p)*w,e[4]=y*w,e[5]=(u*f*s-m*d*s+m*r*p-t*f*p-u*r*g+t*d*g)*w,e[6]=(m*l*s-a*f*s-m*r*c+t*f*c+a*r*g-t*l*g)*w,e[7]=(a*d*s-u*l*s+u*r*c-t*d*c-a*r*p+t*l*p)*w,e[8]=_*w,e[9]=(m*h*s-u*v*s-m*i*p+t*v*p+u*i*g-t*h*g)*w,e[10]=(a*v*s-m*o*s+m*i*c-t*v*c-a*i*g+t*o*g)*w,e[11]=(u*o*s-a*h*s-u*i*c+t*h*c+a*i*p-t*o*p)*w,e[12]=I*w,e[13]=(u*v*r-m*h*r+m*i*d-t*v*d-u*i*f+t*h*f)*w,e[14]=(m*o*r-a*v*r-m*i*l+t*v*l+a*i*f-t*o*f)*w,e[15]=(a*h*r-u*o*r+u*i*l-t*h*l-a*i*d+t*o*d)*w,this}scale(e){const t=this.elements,i=e.x,r=e.y,s=e.z;return t[0]*=i,t[4]*=r,t[8]*=s,t[1]*=i,t[5]*=r,t[9]*=s,t[2]*=i,t[6]*=r,t[10]*=s,t[3]*=i,t[7]*=r,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,r))}makeTranslation(e,t,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const i=Math.cos(t),r=Math.sin(t),s=1-i,a=e.x,o=e.y,l=e.z,c=s*a,u=s*o;return this.set(c*a+i,c*o-r*l,c*l+r*o,0,c*o+r*l,u*o+i,u*l-r*a,0,c*l-r*o,u*l+r*a,s*l*l+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,r,s,a){return this.set(1,i,s,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,i){const r=this.elements,s=t._x,a=t._y,o=t._z,l=t._w,c=s+s,u=a+a,h=o+o,d=s*c,p=s*u,m=s*h,v=a*u,f=a*h,g=o*h,x=l*c,y=l*u,_=l*h,I=i.x,b=i.y,w=i.z;return r[0]=(1-(v+g))*I,r[1]=(p+_)*I,r[2]=(m-y)*I,r[3]=0,r[4]=(p-_)*b,r[5]=(1-(d+g))*b,r[6]=(f+x)*b,r[7]=0,r[8]=(m+y)*w,r[9]=(f-x)*w,r[10]=(1-(d+v))*w,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,i){const r=this.elements;let s=Ia.set(r[0],r[1],r[2]).length();const a=Ia.set(r[4],r[5],r[6]).length(),o=Ia.set(r[8],r[9],r[10]).length();this.determinant()<0&&(s=-s),e.x=r[12],e.y=r[13],e.z=r[14],Xr.copy(this);const l=1/s,c=1/a,u=1/o;return Xr.elements[0]*=l,Xr.elements[1]*=l,Xr.elements[2]*=l,Xr.elements[4]*=c,Xr.elements[5]*=c,Xr.elements[6]*=c,Xr.elements[8]*=u,Xr.elements[9]*=u,Xr.elements[10]*=u,t.setFromRotationMatrix(Xr),i.x=s,i.y=a,i.z=o,this}makePerspective(e,t,i,r,s,a,o=Rr){const l=this.elements,c=2*s/(t-e),u=2*s/(i-r),h=(t+e)/(t-e),d=(i+r)/(i-r);let p,m;if(o===Rr)p=-(a+s)/(a-s),m=-2*a*s/(a-s);else if(o===bs)p=-a/(a-s),m=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=c,l[4]=0,l[8]=h,l[12]=0,l[1]=0,l[5]=u,l[9]=d,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=m,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,i,r,s,a,o=Rr){const l=this.elements,c=1/(t-e),u=1/(i-r),h=1/(a-s),d=(t+e)*c,p=(i+r)*u;let m,v;if(o===Rr)m=(a+s)*h,v=-2*h;else if(o===bs)m=s*h,v=-1*h;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-d,l[1]=0,l[5]=2*u,l[9]=0,l[13]=-p,l[2]=0,l[6]=0,l[10]=v,l[14]=-m,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){const t=this.elements,i=e.elements;for(let r=0;r<16;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}}const Ia=new N,Xr=new Re,kw=new N(0,0,0),Hw=new N(1,1,1),Zn=new N,pu=new N,xr=new N,fv=new Re,gv=new qi;class dr{constructor(e=0,t=0,i=0,r=dr.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,r=this._order){return this._x=e,this._y=t,this._z=i,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){const r=e.elements,s=r[0],a=r[4],o=r[8],l=r[1],c=r[5],u=r[9],h=r[2],d=r[6],p=r[10];switch(t){case"XYZ":this._y=Math.asin(Jt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,p),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Jt(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(o,p),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(Jt(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-h,p),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-Jt(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(d,p),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(Jt(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(o,p));break;case"XZY":this._z=Math.asin(-Jt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-u,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return fv.makeRotationFromQuaternion(e),this.setFromRotationMatrix(fv,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return gv.setFromEuler(this),this.setFromQuaternion(gv,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}dr.DEFAULT_ORDER="XYZ";class rl{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let Gw=0;const vv=new N,La=new qi,Sn=new Re,mu=new N,nl=new N,Ww=new N,jw=new qi,yv=new N(1,0,0),xv=new N(0,1,0),_v=new N(0,0,1),Mv={type:"added"},Xw={type:"removed"},Pa={type:"childadded",child:null},Sp={type:"childremoved",child:null};class _t extends vr{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Gw++}),this.uuid=yr(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=_t.DEFAULT_UP.clone();const e=new N,t=new dr,i=new qi,r=new N(1,1,1);function s(){i.setFromEuler(t,!1)}function a(){t.setFromQuaternion(i,void 0,!1)}t._onChange(s),i._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new Re},normalMatrix:{value:new Ke}}),this.matrix=new Re,this.matrixWorld=new Re,this.matrixAutoUpdate=_t.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=_t.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new rl,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return La.setFromAxisAngle(e,t),this.quaternion.multiply(La),this}rotateOnWorldAxis(e,t){return La.setFromAxisAngle(e,t),this.quaternion.premultiply(La),this}rotateX(e){return this.rotateOnAxis(yv,e)}rotateY(e){return this.rotateOnAxis(xv,e)}rotateZ(e){return this.rotateOnAxis(_v,e)}translateOnAxis(e,t){return vv.copy(e).applyQuaternion(this.quaternion),this.position.add(vv.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(yv,e)}translateY(e){return this.translateOnAxis(xv,e)}translateZ(e){return this.translateOnAxis(_v,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Sn.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?mu.copy(e):mu.set(e,t,i);const r=this.parent;this.updateWorldMatrix(!0,!1),nl.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Sn.lookAt(nl,mu,this.up):Sn.lookAt(mu,nl,this.up),this.quaternion.setFromRotationMatrix(Sn),r&&(Sn.extractRotation(r.matrixWorld),La.setFromRotationMatrix(Sn),this.quaternion.premultiply(La.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Mv),Pa.child=e,this.dispatchEvent(Pa),Pa.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Xw),Sp.child=e,this.dispatchEvent(Sp),Sp.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Sn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Sn.multiply(e.parent.matrixWorld)),e.applyMatrix4(Sn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Mv),Pa.child=e,this.dispatchEvent(Pa),Pa.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let i=0,r=this.children.length;i<r;i++){const s=this.children[i].getObjectByProperty(e,t);if(s!==void 0)return s}}getObjectsByProperty(e,t,i=[]){this[e]===t&&i.push(this);const r=this.children;for(let s=0,a=r.length;s<a;s++)r[s].getObjectsByProperty(e,t,i);return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(nl,e,Ww),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(nl,jw,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].updateMatrixWorld(e)}updateWorldMatrix(e,t){const i=this.parent;if(e===!0&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){const r=this.children;for(let s=0,a=r.length;s<a;s++)r[s].updateWorldMatrix(!1,!0)}}toJSON(e){const t=e===void 0||typeof e=="string",i={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.visibility=this._visibility,r.active=this._active,r.bounds=this._bounds.map(o=>({boxInitialized:o.boxInitialized,boxMin:o.box.min.toArray(),boxMax:o.box.max.toArray(),sphereInitialized:o.sphereInitialized,sphereRadius:o.sphere.radius,sphereCenter:o.sphere.center.toArray()})),r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.geometryCount=this._geometryCount,r.matricesTexture=this._matricesTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere={center:r.boundingSphere.center.toArray(),radius:r.boundingSphere.radius}),this.boundingBox!==null&&(r.boundingBox={min:r.boundingBox.min.toArray(),max:r.boundingBox.max.toArray()}));function s(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,u=l.length;c<u;c++){const h=l[c];s(e.shapes,h)}else s(e.shapes,l)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(s(e.materials,this.material[l]));r.material=o}else r.material=s(e.materials,this.material);if(this.children.length>0){r.children=[];for(let o=0;o<this.children.length;o++)r.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];r.animations.push(s(e.animations,l))}}if(t){const o=a(e.geometries),l=a(e.materials),c=a(e.textures),u=a(e.images),h=a(e.shapes),d=a(e.skeletons),p=a(e.animations),m=a(e.nodes);o.length>0&&(i.geometries=o),l.length>0&&(i.materials=l),c.length>0&&(i.textures=c),u.length>0&&(i.images=u),h.length>0&&(i.shapes=h),d.length>0&&(i.skeletons=d),p.length>0&&(i.animations=p),m.length>0&&(i.nodes=m)}return i.object=r,i;function a(o){const l=[];for(const c in o){const u=o[c];delete u.metadata,l.push(u)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i<e.children.length;i++){const r=e.children[i];this.add(r.clone())}return this}}_t.DEFAULT_UP=new N(0,1,0),_t.DEFAULT_MATRIX_AUTO_UPDATE=!0,_t.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const qr=new N,wn=new N,wp=new N,En=new N,Da=new N,Ua=new N,bv=new N,Ep=new N,Ap=new N,Np=new N,Cp=new st,Rp=new st,Ip=new st;class er{constructor(e=new N,t=new N,i=new N){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,r){r.subVectors(i,t),qr.subVectors(e,t),r.cross(qr);const s=r.lengthSq();return s>0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,i,r,s){qr.subVectors(r,t),wn.subVectors(i,t),wp.subVectors(e,t);const a=qr.dot(qr),o=qr.dot(wn),l=qr.dot(wp),c=wn.dot(wn),u=wn.dot(wp),h=a*c-o*o;if(h===0)return s.set(0,0,0),null;const d=1/h,p=(c*l-o*u)*d,m=(a*u-o*l)*d;return s.set(1-p-m,m,p)}static containsPoint(e,t,i,r){return this.getBarycoord(e,t,i,r,En)===null?!1:En.x>=0&&En.y>=0&&En.x+En.y<=1}static getInterpolation(e,t,i,r,s,a,o,l){return this.getBarycoord(e,t,i,r,En)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(s,En.x),l.addScaledVector(a,En.y),l.addScaledVector(o,En.z),l)}static getInterpolatedAttribute(e,t,i,r,s,a){return Cp.setScalar(0),Rp.setScalar(0),Ip.setScalar(0),Cp.fromBufferAttribute(e,t),Rp.fromBufferAttribute(e,i),Ip.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(Cp,s.x),a.addScaledVector(Rp,s.y),a.addScaledVector(Ip,s.z),a}static isFrontFacing(e,t,i,r){return qr.subVectors(i,t),wn.subVectors(e,t),qr.cross(wn).dot(r)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,r){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,i,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return qr.subVectors(this.c,this.b),wn.subVectors(this.a,this.b),qr.cross(wn).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return er.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return er.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,r,s){return er.getInterpolation(e,this.a,this.b,this.c,t,i,r,s)}containsPoint(e){return er.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return er.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,r=this.b,s=this.c;let a,o;Da.subVectors(r,i),Ua.subVectors(s,i),Ep.subVectors(e,i);const l=Da.dot(Ep),c=Ua.dot(Ep);if(l<=0&&c<=0)return t.copy(i);Ap.subVectors(e,r);const u=Da.dot(Ap),h=Ua.dot(Ap);if(u>=0&&h<=u)return t.copy(r);const d=l*h-u*c;if(d<=0&&l>=0&&u<=0)return a=l/(l-u),t.copy(i).addScaledVector(Da,a);Np.subVectors(e,s);const p=Da.dot(Np),m=Ua.dot(Np);if(m>=0&&p<=m)return t.copy(s);const v=p*c-l*m;if(v<=0&&c>=0&&m<=0)return o=c/(c-m),t.copy(i).addScaledVector(Ua,o);const f=u*m-p*h;if(f<=0&&h-u>=0&&p-m>=0)return bv.subVectors(s,r),o=(h-u)/(h-u+(p-m)),t.copy(r).addScaledVector(bv,o);const g=1/(f+v+d);return a=v*g,o=d*g,t.copy(i).addScaledVector(Da,a).addScaledVector(Ua,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const Tv={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},Qn={h:0,s:0,l:0},fu={h:0,s:0,l:0};function Lp(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}class xe{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){const r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Fi){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,vt.toWorkingColorSpace(this,t),this}setRGB(e,t,i,r=vt.workingColorSpace){return this.r=e,this.g=t,this.b=i,vt.toWorkingColorSpace(this,r),this}setHSL(e,t,i,r=vt.workingColorSpace){if(e=mp(e,1),t=Jt(t,0,1),i=Jt(i,0,1),t===0)this.r=this.g=this.b=i;else{const s=i<=.5?i*(1+t):i+t-i*t,a=2*i-s;this.r=Lp(a,s,e+1/3),this.g=Lp(a,s,e),this.b=Lp(a,s,e-1/3)}return vt.toWorkingColorSpace(this,r),this}setStyle(e,t=Fi){function i(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const a=r[1],o=r[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=r[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(s,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Fi){const i=Tv[e.toLowerCase()];return i!==void 0?this.setHex(i,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Ea(e.r),this.g=Ea(e.g),this.b=Ea(e.b),this}copyLinearToSRGB(e){return this.r=gp(e.r),this.g=gp(e.g),this.b=gp(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Fi){return vt.fromWorkingColorSpace(zi.copy(this),e),Math.round(Jt(zi.r*255,0,255))*65536+Math.round(Jt(zi.g*255,0,255))*256+Math.round(Jt(zi.b*255,0,255))}getHexString(e=Fi){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=vt.workingColorSpace){vt.fromWorkingColorSpace(zi.copy(this),t);const i=zi.r,r=zi.g,s=zi.b,a=Math.max(i,r,s),o=Math.min(i,r,s);let l,c;const u=(o+a)/2;if(o===a)l=0,c=0;else{const h=a-o;switch(c=u<=.5?h/(a+o):h/(2-a-o),a){case i:l=(r-s)/h+(r<s?6:0);break;case r:l=(s-i)/h+2;break;case s:l=(i-r)/h+4;break}l/=6}return e.h=l,e.s=c,e.l=u,e}getRGB(e,t=vt.workingColorSpace){return vt.fromWorkingColorSpace(zi.copy(this),t),e.r=zi.r,e.g=zi.g,e.b=zi.b,e}getStyle(e=Fi){vt.fromWorkingColorSpace(zi.copy(this),e);const t=zi.r,i=zi.g,r=zi.b;return e!==Fi?`color(${e} ${t.toFixed(3)} ${i.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(i*255)},${Math.round(r*255)})`}offsetHSL(e,t,i){return this.getHSL(Qn),this.setHSL(Qn.h+e,Qn.s+t,Qn.l+i)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,i){return this.r=e.r+(t.r-e.r)*i,this.g=e.g+(t.g-e.g)*i,this.b=e.b+(t.b-e.b)*i,this}lerpHSL(e,t){this.getHSL(Qn),e.getHSL(fu);const i=Ko(Qn.h,fu.h,t),r=Ko(Qn.s,fu.s,t),s=Ko(Qn.l,fu.l,t);return this.setHSL(i,r,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,i=this.g,r=this.b,s=e.elements;return this.r=s[0]*t+s[3]*i+s[6]*r,this.g=s[1]*t+s[4]*i+s[7]*r,this.b=s[2]*t+s[5]*i+s[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const zi=new xe;xe.NAMES=Tv;let qw=0;class hi extends vr{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:qw++}),this.uuid=yr(),this.name="",this.type="Material",this.blending=_n,this.side=an,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Tc,this.blendDst=Sc,this.blendEquation=Vn,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new xe(0,0,0),this.blendAlpha=0,this.depthFunc=Bn,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=ru,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=qn,this.stencilZFail=qn,this.stencilZPass=qn,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const i=e[t];if(i===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(i):r&&r.isVector3&&i&&i.isVector3?r.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const i={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==_n&&(i.blending=this.blending),this.side!==an&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==Tc&&(i.blendSrc=this.blendSrc),this.blendDst!==Sc&&(i.blendDst=this.blendDst),this.blendEquation!==Vn&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==Bn&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==ru&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==qn&&(i.stencilFail=this.stencilFail),this.stencilZFail!==qn&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==qn&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function r(s){const a=[];for(const o in s){const l=s[o];delete l.metadata,a.push(l)}return a}if(t){const s=r(e.textures),a=r(e.images);s.length>0&&(i.textures=s),a.length>0&&(i.images=a)}return i}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let i=null;if(t!==null){const r=t.length;i=new Array(r);for(let s=0;s!==r;++s)i[s]=t[s].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class Yr extends hi{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new xe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new dr,this.combine=pa,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const An=Yw();function Yw(){const n=new ArrayBuffer(4),e=new Float32Array(n),t=new Uint32Array(n),i=new Uint32Array(512),r=new Uint32Array(512);for(let l=0;l<256;++l){const c=l-127;c<-27?(i[l]=0,i[l|256]=32768,r[l]=24,r[l|256]=24):c<-14?(i[l]=1024>>-c-14,i[l|256]=1024>>-c-14|32768,r[l]=-c-1,r[l|256]=-c-1):c<=15?(i[l]=c+15<<10,i[l|256]=c+15<<10|32768,r[l]=13,r[l|256]=13):c<128?(i[l]=31744,i[l|256]=64512,r[l]=24,r[l|256]=24):(i[l]=31744,i[l|256]=64512,r[l]=13,r[l|256]=13)}const s=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let l=1;l<1024;++l){let c=l<<13,u=0;for(;(c&8388608)===0;)c<<=1,u-=8388608;c&=-8388609,u+=947912704,s[l]=c|u}for(let l=1024;l<2048;++l)s[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)a[l]=l<<23;a[31]=1199570944,a[32]=2147483648;for(let l=33;l<63;++l)a[l]=2147483648+(l-32<<23);a[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(o[l]=1024);return{floatView:e,uint32View:t,baseTable:i,shiftTable:r,mantissaTable:s,exponentTable:a,offsetTable:o}}function sr(n){Math.abs(n)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),n=Jt(n,-65504,65504),An.floatView[0]=n;const e=An.uint32View[0],t=e>>23&511;return An.baseTable[t]+((e&8388607)>>An.shiftTable[t])}function sl(n){const e=n>>10;return An.uint32View[0]=An.mantissaTable[An.offsetTable[e]+(n&1023)]+An.exponentTable[e],An.floatView[0]}const Sv={toHalfFloat:sr,fromHalfFloat:sl},ai=new N,gu=new J;class wt{constructor(e,t,i=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=Ta,this.updateRanges=[],this.gpuType=Oi,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let r=0,s=this.itemSize;r<s;r++)this.array[e+r]=t.array[i+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,i=this.count;t<i;t++)gu.fromBufferAttribute(this,t),gu.applyMatrix3(e),this.setXY(t,gu.x,gu.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)ai.fromBufferAttribute(this,t),ai.applyMatrix3(e),this.setXYZ(t,ai.x,ai.y,ai.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)ai.fromBufferAttribute(this,t),ai.applyMatrix4(e),this.setXYZ(t,ai.x,ai.y,ai.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)ai.fromBufferAttribute(this,t),ai.applyNormalMatrix(e),this.setXYZ(t,ai.x,ai.y,ai.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)ai.fromBufferAttribute(this,t),ai.transformDirection(e),this.setXYZ(t,ai.x,ai.y,ai.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let i=this.array[e*this.itemSize+t];return this.normalized&&(i=Xi(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=ht(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Xi(t,this.array)),t}setX(e,t){return this.normalized&&(t=ht(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Xi(t,this.array)),t}setY(e,t){return this.normalized&&(t=ht(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=Xi(t,this.array)),t}setZ(e,t){return this.normalized&&(t=ht(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=Xi(t,this.array)),t}setW(e,t){return this.normalized&&(t=ht(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=ht(t,this.array),i=ht(i,this.array)),this.array[e+0]=t,this.array[e+1]=i,this}setXYZ(e,t,i,r){return e*=this.itemSize,this.normalized&&(t=ht(t,this.array),i=ht(i,this.array),r=ht(r,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this}setXYZW(e,t,i,r,s){return e*=this.itemSize,this.normalized&&(t=ht(t,this.array),i=ht(i,this.array),r=ht(r,this.array),s=ht(s,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==Ta&&(e.usage=this.usage),e}}class $w extends wt{constructor(e,t,i){super(new Int8Array(e),t,i)}}class Jw extends wt{constructor(e,t,i){super(new Uint8Array(e),t,i)}}class Kw extends wt{constructor(e,t,i){super(new Uint8ClampedArray(e),t,i)}}class Zw extends wt{constructor(e,t,i){super(new Int16Array(e),t,i)}}class vu extends wt{constructor(e,t,i){super(new Uint16Array(e),t,i)}}class Qw extends wt{constructor(e,t,i){super(new Int32Array(e),t,i)}}class Pp extends wt{constructor(e,t,i){super(new Uint32Array(e),t,i)}}class wv extends wt{constructor(e,t,i){super(new Uint16Array(e),t,i),this.isFloat16BufferAttribute=!0}getX(e){let t=sl(this.array[e*this.itemSize]);return this.normalized&&(t=Xi(t,this.array)),t}setX(e,t){return this.normalized&&(t=ht(t,this.array)),this.array[e*this.itemSize]=sr(t),this}getY(e){let t=sl(this.array[e*this.itemSize+1]);return this.normalized&&(t=Xi(t,this.array)),t}setY(e,t){return this.normalized&&(t=ht(t,this.array)),this.array[e*this.itemSize+1]=sr(t),this}getZ(e){let t=sl(this.array[e*this.itemSize+2]);return this.normalized&&(t=Xi(t,this.array)),t}setZ(e,t){return this.normalized&&(t=ht(t,this.array)),this.array[e*this.itemSize+2]=sr(t),this}getW(e){let t=sl(this.array[e*this.itemSize+3]);return this.normalized&&(t=Xi(t,this.array)),t}setW(e,t){return this.normalized&&(t=ht(t,this.array)),this.array[e*this.itemSize+3]=sr(t),this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=ht(t,this.array),i=ht(i,this.array)),this.array[e+0]=sr(t),this.array[e+1]=sr(i),this}setXYZ(e,t,i,r){return e*=this.itemSize,this.normalized&&(t=ht(t,this.array),i=ht(i,this.array),r=ht(r,this.array)),this.array[e+0]=sr(t),this.array[e+1]=sr(i),this.array[e+2]=sr(r),this}setXYZW(e,t,i,r,s){return e*=this.itemSize,this.normalized&&(t=ht(t,this.array),i=ht(i,this.array),r=ht(r,this.array),s=ht(s,this.array)),this.array[e+0]=sr(t),this.array[e+1]=sr(i),this.array[e+2]=sr(r),this.array[e+3]=sr(s),this}}class De extends wt{constructor(e,t,i){super(new Float32Array(e),t,i)}}let eE=0;const Lr=new Re,Dp=new _t,Oa=new N,_r=new Bi,al=new Bi,vi=new N;class ct extends vr{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:eE++}),this.uuid=yr(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(lv(e)?Pp:vu)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const s=new Ke().getNormalMatrix(e);i.applyNormalMatrix(s),i.needsUpdate=!0}const r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Lr.makeRotationFromQuaternion(e),this.applyMatrix4(Lr),this}rotateX(e){return Lr.makeRotationX(e),this.applyMatrix4(Lr),this}rotateY(e){return Lr.makeRotationY(e),this.applyMatrix4(Lr),this}rotateZ(e){return Lr.makeRotationZ(e),this.applyMatrix4(Lr),this}translate(e,t,i){return Lr.makeTranslation(e,t,i),this.applyMatrix4(Lr),this}scale(e,t,i){return Lr.makeScale(e,t,i),this.applyMatrix4(Lr),this}lookAt(e){return Dp.lookAt(e),Dp.updateMatrix(),this.applyMatrix4(Dp.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Oa).negate(),this.translate(Oa.x,Oa.y,Oa.z),this}setFromPoints(e){const t=[];for(let i=0,r=e.length;i<r;i++){const s=e[i];t.push(s.x,s.y,s.z||0)}return this.setAttribute("position",new De(t,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Bi);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new N(-1/0,-1/0,-1/0),new N(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,r=t.length;i<r;i++){const s=t[i];_r.setFromBufferAttribute(s),this.morphTargetsRelative?(vi.addVectors(this.boundingBox.min,_r.min),this.boundingBox.expandByPoint(vi),vi.addVectors(this.boundingBox.max,_r.max),this.boundingBox.expandByPoint(vi)):(this.boundingBox.expandByPoint(_r.min),this.boundingBox.expandByPoint(_r.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Ai);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new N,1/0);return}if(e){const i=this.boundingSphere.center;if(_r.setFromBufferAttribute(e),t)for(let s=0,a=t.length;s<a;s++){const o=t[s];al.setFromBufferAttribute(o),this.morphTargetsRelative?(vi.addVectors(_r.min,al.min),_r.expandByPoint(vi),vi.addVectors(_r.max,al.max),_r.expandByPoint(vi)):(_r.expandByPoint(al.min),_r.expandByPoint(al.max))}_r.getCenter(i);let r=0;for(let s=0,a=e.count;s<a;s++)vi.fromBufferAttribute(e,s),r=Math.max(r,i.distanceToSquared(vi));if(t)for(let s=0,a=t.length;s<a;s++){const o=t[s],l=this.morphTargetsRelative;for(let c=0,u=o.count;c<u;c++)vi.fromBufferAttribute(o,c),l&&(Oa.fromBufferAttribute(e,c),vi.add(Oa)),r=Math.max(r,i.distanceToSquared(vi))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=t.position,r=t.normal,s=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new wt(new Float32Array(4*i.count),4));const a=this.getAttribute("tangent"),o=[],l=[];for(let C=0;C<i.count;C++)o[C]=new N,l[C]=new N;const c=new N,u=new N,h=new N,d=new J,p=new J,m=new J,v=new N,f=new N;function g(C,H,M){c.fromBufferAttribute(i,C),u.fromBufferAttribute(i,H),h.fromBufferAttribute(i,M),d.fromBufferAttribute(s,C),p.fromBufferAttribute(s,H),m.fromBufferAttribute(s,M),u.sub(c),h.sub(c),p.sub(d),m.sub(d);const T=1/(p.x*m.y-m.x*p.y);isFinite(T)&&(v.copy(u).multiplyScalar(m.y).addScaledVector(h,-p.y).multiplyScalar(T),f.copy(h).multiplyScalar(p.x).addScaledVector(u,-m.x).multiplyScalar(T),o[C].add(v),o[H].add(v),o[M].add(v),l[C].add(f),l[H].add(f),l[M].add(f))}let x=this.groups;x.length===0&&(x=[{start:0,count:e.count}]);for(let C=0,H=x.length;C<H;++C){const M=x[C],T=M.start,k=M.count;for(let j=T,Y=T+k;j<Y;j+=3)g(e.getX(j+0),e.getX(j+1),e.getX(j+2))}const y=new N,_=new N,I=new N,b=new N;function w(C){I.fromBufferAttribute(r,C),b.copy(I);const H=o[C];y.copy(H),y.sub(I.multiplyScalar(I.dot(H))).normalize(),_.crossVectors(b,H);const M=_.dot(l[C])<0?-1:1;a.setXYZW(C,y.x,y.y,y.z,M)}for(let C=0,H=x.length;C<H;++C){const M=x[C],T=M.start,k=M.count;for(let j=T,Y=T+k;j<Y;j+=3)w(e.getX(j+0)),w(e.getX(j+1)),w(e.getX(j+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let i=this.getAttribute("normal");if(i===void 0)i=new wt(new Float32Array(t.count*3),3),this.setAttribute("normal",i);else for(let d=0,p=i.count;d<p;d++)i.setXYZ(d,0,0,0);const r=new N,s=new N,a=new N,o=new N,l=new N,c=new N,u=new N,h=new N;if(e)for(let d=0,p=e.count;d<p;d+=3){const m=e.getX(d+0),v=e.getX(d+1),f=e.getX(d+2);r.fromBufferAttribute(t,m),s.fromBufferAttribute(t,v),a.fromBufferAttribute(t,f),u.subVectors(a,s),h.subVectors(r,s),u.cross(h),o.fromBufferAttribute(i,m),l.fromBufferAttribute(i,v),c.fromBufferAttribute(i,f),o.add(u),l.add(u),c.add(u),i.setXYZ(m,o.x,o.y,o.z),i.setXYZ(v,l.x,l.y,l.z),i.setXYZ(f,c.x,c.y,c.z)}else for(let d=0,p=t.count;d<p;d+=3)r.fromBufferAttribute(t,d+0),s.fromBufferAttribute(t,d+1),a.fromBufferAttribute(t,d+2),u.subVectors(a,s),h.subVectors(r,s),u.cross(h),i.setXYZ(d+0,u.x,u.y,u.z),i.setXYZ(d+1,u.x,u.y,u.z),i.setXYZ(d+2,u.x,u.y,u.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)vi.fromBufferAttribute(e,t),vi.normalize(),e.setXYZ(t,vi.x,vi.y,vi.z)}toNonIndexed(){function e(o,l){const c=o.array,u=o.itemSize,h=o.normalized,d=new c.constructor(l.length*u);let p=0,m=0;for(let v=0,f=l.length;v<f;v++){o.isInterleavedBufferAttribute?p=l[v]*o.data.stride+o.offset:p=l[v]*u;for(let g=0;g<u;g++)d[m++]=c[p++]}return new wt(d,u,h)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new ct,i=this.index.array,r=this.attributes;for(const o in r){const l=r[o],c=e(l,i);t.setAttribute(o,c)}const s=this.morphAttributes;for(const o in s){const l=[],c=s[o];for(let u=0,h=c.length;u<h;u++){const d=c[u],p=e(d,i);l.push(p)}t.morphAttributes[o]=l}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const c=a[o];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){const e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const l in i){const c=i[l];e.data.attributes[l]=c.toJSON(e.data)}const r={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],u=[];for(let h=0,d=c.length;h<d;h++){const p=c[h];u.push(p.toJSON(e.data))}u.length>0&&(r[l]=u,s=!0)}s&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const i=e.index;i!==null&&this.setIndex(i.clone(t));const r=e.attributes;for(const c in r){const u=r[c];this.setAttribute(c,u.clone(t))}const s=e.morphAttributes;for(const c in s){const u=[],h=s[c];for(let d=0,p=h.length;d<p;d++)u.push(h[d].clone(t));this.morphAttributes[c]=u}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let c=0,u=a.length;c<u;c++){const h=a[c];this.addGroup(h.start,h.count,h.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const Ev=new Re,As=new Es,yu=new Ai,Av=new N,xu=new N,_u=new N,Mu=new N,Up=new N,bu=new N,Nv=new N,Tu=new N;class Ft extends _t{constructor(e=new ct,t=new Yr){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){const a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}getVertexPosition(e,t){const i=this.geometry,r=i.attributes.position,s=i.morphAttributes.position,a=i.morphTargetsRelative;t.fromBufferAttribute(r,e);const o=this.morphTargetInfluences;if(s&&o){bu.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const u=o[l],h=s[l];u!==0&&(Up.fromBufferAttribute(h,e),a?bu.addScaledVector(Up,u):bu.addScaledVector(Up.sub(t),u))}t.add(bu)}return t}raycast(e,t){const i=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),yu.copy(i.boundingSphere),yu.applyMatrix4(s),As.copy(e.ray).recast(e.near),!(yu.containsPoint(As.origin)===!1&&(As.intersectSphere(yu,Av)===null||As.origin.distanceToSquared(Av)>(e.far-e.near)**2))&&(Ev.copy(s).invert(),As.copy(e.ray).applyMatrix4(Ev),!(i.boundingBox!==null&&As.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,As)))}_computeIntersections(e,t,i){let r;const s=this.geometry,a=this.material,o=s.index,l=s.attributes.position,c=s.attributes.uv,u=s.attributes.uv1,h=s.attributes.normal,d=s.groups,p=s.drawRange;if(o!==null)if(Array.isArray(a))for(let m=0,v=d.length;m<v;m++){const f=d[m],g=a[f.materialIndex],x=Math.max(f.start,p.start),y=Math.min(o.count,Math.min(f.start+f.count,p.start+p.count));for(let _=x,I=y;_<I;_+=3){const b=o.getX(_),w=o.getX(_+1),C=o.getX(_+2);r=Su(this,g,e,i,c,u,h,b,w,C),r&&(r.faceIndex=Math.floor(_/3),r.face.materialIndex=f.materialIndex,t.push(r))}}else{const m=Math.max(0,p.start),v=Math.min(o.count,p.start+p.count);for(let f=m,g=v;f<g;f+=3){const x=o.getX(f),y=o.getX(f+1),_=o.getX(f+2);r=Su(this,a,e,i,c,u,h,x,y,_),r&&(r.faceIndex=Math.floor(f/3),t.push(r))}}else if(l!==void 0)if(Array.isArray(a))for(let m=0,v=d.length;m<v;m++){const f=d[m],g=a[f.materialIndex],x=Math.max(f.start,p.start),y=Math.min(l.count,Math.min(f.start+f.count,p.start+p.count));for(let _=x,I=y;_<I;_+=3){const b=_,w=_+1,C=_+2;r=Su(this,g,e,i,c,u,h,b,w,C),r&&(r.faceIndex=Math.floor(_/3),r.face.materialIndex=f.materialIndex,t.push(r))}}else{const m=Math.max(0,p.start),v=Math.min(l.count,p.start+p.count);for(let f=m,g=v;f<g;f+=3){const x=f,y=f+1,_=f+2;r=Su(this,a,e,i,c,u,h,x,y,_),r&&(r.faceIndex=Math.floor(f/3),t.push(r))}}}}function tE(n,e,t,i,r,s,a,o){let l;if(e.side===si?l=i.intersectTriangle(a,s,r,!0,o):l=i.intersectTriangle(r,s,a,e.side===an,o),l===null)return null;Tu.copy(o),Tu.applyMatrix4(n.matrixWorld);const c=t.ray.origin.distanceTo(Tu);return c<t.near||c>t.far?null:{distance:c,point:Tu.clone(),object:n}}function Su(n,e,t,i,r,s,a,o,l,c){n.getVertexPosition(o,xu),n.getVertexPosition(l,_u),n.getVertexPosition(c,Mu);const u=tE(n,e,t,i,xu,_u,Mu,Nv);if(u){const h=new N;er.getBarycoord(Nv,xu,_u,Mu,h),r&&(u.uv=er.getInterpolatedAttribute(r,o,l,c,h,new J)),s&&(u.uv1=er.getInterpolatedAttribute(s,o,l,c,h,new J)),a&&(u.normal=er.getInterpolatedAttribute(a,o,l,c,h,new N),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));const d={a:o,b:l,c,normal:new N,materialIndex:0};er.getNormal(xu,_u,Mu,d.normal),u.face=d,u.barycoord=h}return u}class yn extends ct{constructor(e=1,t=1,i=1,r=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:r,heightSegments:s,depthSegments:a};const o=this;r=Math.floor(r),s=Math.floor(s),a=Math.floor(a);const l=[],c=[],u=[],h=[];let d=0,p=0;m("z","y","x",-1,-1,i,t,e,a,s,0),m("z","y","x",1,-1,i,t,-e,a,s,1),m("x","z","y",1,1,e,i,t,r,a,2),m("x","z","y",1,-1,e,i,-t,r,a,3),m("x","y","z",1,-1,e,t,i,r,s,4),m("x","y","z",-1,-1,e,t,-i,r,s,5),this.setIndex(l),this.setAttribute("position",new De(c,3)),this.setAttribute("normal",new De(u,3)),this.setAttribute("uv",new De(h,2));function m(v,f,g,x,y,_,I,b,w,C,H){const M=_/w,T=I/C,k=_/2,j=I/2,Y=b/2,re=w+1,$=C+1;let he=0,Q=0;const ye=new N;for(let be=0;be<$;be++){const Ve=be*T-j;for(let at=0;at<re;at++){const et=at*M-k;ye[v]=et*x,ye[f]=Ve*y,ye[g]=Y,c.push(ye.x,ye.y,ye.z),ye[v]=0,ye[f]=0,ye[g]=b>0?1:-1,u.push(ye.x,ye.y,ye.z),h.push(at/w),h.push(1-be/C),he+=1}}for(let be=0;be<C;be++)for(let Ve=0;Ve<w;Ve++){const at=d+Ve+re*be,et=d+Ve+re*(be+1),ie=d+(Ve+1)+re*(be+1),le=d+(Ve+1)+re*be;l.push(at,et,le),l.push(et,ie,le),Q+=6}o.addGroup(p,Q,H),p+=Q,d+=he}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new yn(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Fa(n){const e={};for(const t in n){e[t]={};for(const i in n[t]){const r=n[t][i];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][i]=null):e[t][i]=r.clone():Array.isArray(r)?e[t][i]=r.slice():e[t][i]=r}}return e}function Yi(n){const e={};for(let t=0;t<n.length;t++){const i=Fa(n[t]);for(const r in i)e[r]=i[r]}return e}function iE(n){const e=[];for(let t=0;t<n.length;t++)e.push(n[t].clone());return e}function Cv(n){const e=n.getRenderTarget();return e===null?n.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:vt.workingColorSpace}const Op={clone:Fa,merge:Yi};var rE=`void main() {
|
|
6
6
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
7
7
|
}`,nE=`void main() {
|
|
8
8
|
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
|
9
|
-
}`;class Pr extends hi{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=rE,this.fragmentShader=nE,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=
|
|
9
|
+
}`;class Pr extends hi{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=rE,this.fragmentShader=nE,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Fa(e.uniforms),this.uniformsGroups=iE(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const r in this.uniforms){const s=this.uniforms[r].value;s&&s.isTexture?t.uniforms[r]={type:"t",value:s.toJSON(e).uuid}:s&&s.isColor?t.uniforms[r]={type:"c",value:s.getHex()}:s&&s.isVector2?t.uniforms[r]={type:"v2",value:s.toArray()}:s&&s.isVector3?t.uniforms[r]={type:"v3",value:s.toArray()}:s&&s.isVector4?t.uniforms[r]={type:"v4",value:s.toArray()}:s&&s.isMatrix3?t.uniforms[r]={type:"m3",value:s.toArray()}:s&&s.isMatrix4?t.uniforms[r]={type:"m4",value:s.toArray()}:t.uniforms[r]={value:s}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const i={};for(const r in this.extensions)this.extensions[r]===!0&&(i[r]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}}class ol extends _t{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Re,this.projectionMatrix=new Re,this.projectionMatrixInverse=new Re,this.coordinateSystem=Rr}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const es=new N,Rv=new J,Iv=new J;class di extends ol{constructor(e=50,t=1,i=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=Sa*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Ts*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Sa*2*Math.atan(Math.tan(Ts*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,i){es.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(es.x,es.y).multiplyScalar(-e/es.z),es.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(es.x,es.y).multiplyScalar(-e/es.z)}getViewSize(e,t){return this.getViewBounds(e,Rv,Iv),t.subVectors(Iv,Rv)}setViewOffset(e,t,i,r,s,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(Ts*.5*this.fov)/this.zoom,i=2*t,r=this.aspect*i,s=-.5*r;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;s+=a.offsetX*r/l,t-=a.offsetY*i/c,r*=a.width/l,i*=a.height/c}const o=this.filmOffset;o!==0&&(s+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,t,t-i,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const Va=-90,Ba=1;class wu extends _t{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new di(Va,Ba,e,t);r.layers=this.layers,this.add(r);const s=new di(Va,Ba,e,t);s.layers=this.layers,this.add(s);const a=new di(Va,Ba,e,t);a.layers=this.layers,this.add(a);const o=new di(Va,Ba,e,t);o.layers=this.layers,this.add(o);const l=new di(Va,Ba,e,t);l.layers=this.layers,this.add(l);const c=new di(Va,Ba,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,r,s,a,o,l]=t;for(const c of t)this.remove(c);if(e===Rr)i.up.set(0,1,0),i.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===bs)i.up.set(0,-1,0),i.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,a,o,l,c,u]=this.children,h=e.getRenderTarget(),d=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),m=e.xr.enabled;e.xr.enabled=!1;const v=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0,r),e.render(t,s),e.setRenderTarget(i,1,r),e.render(t,a),e.setRenderTarget(i,2,r),e.render(t,o),e.setRenderTarget(i,3,r),e.render(t,l),e.setRenderTarget(i,4,r),e.render(t,c),i.texture.generateMipmaps=v,e.setRenderTarget(i,5,r),e.render(t,u),e.setRenderTarget(h,d,p),e.xr.enabled=m,i.texture.needsPMREMUpdate=!0}}class Ns extends Wt{constructor(e,t,i,r,s,a,o,l,c,u){e=e!==void 0?e:[],t=t!==void 0?t:fr,super(e,t,i,r,s,a,o,l,c,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Eu extends Ir{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const i={width:e,height:e,depth:1},r=[i,i,i,i,i,i];this.texture=new Ns(r,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:Lt}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 i={uniforms:{tEquirect:{value:null}},vertexShader:`
|
|
10
10
|
|
|
11
11
|
varying vec3 vWorldDirection;
|
|
12
12
|
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
42
42
|
|
|
43
43
|
}
|
|
44
|
-
`},r=new yn(5,5,5),s=new Pr({name:"CubemapFromEquirect",uniforms:
|
|
44
|
+
`},r=new yn(5,5,5),s=new Pr({name:"CubemapFromEquirect",uniforms:Fa(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:si,blending:Er});s.uniforms.tEquirect.value=t;const a=new Ft(r,s),o=t.minFilter;return t.minFilter===ji&&(t.minFilter=Lt),new wu(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t,i,r){const s=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,i,r);e.setRenderTarget(s)}}const Fp=new N,sE=new N,aE=new Ke;class ln{constructor(e=new N(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,r){return this.normal.set(e,t,i),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){const r=Fp.subVectors(i,t).cross(sE.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const i=e.delta(Fp),r=this.normal.dot(i);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/r;return s<0||s>1?null:t.copy(e.start).addScaledVector(i,s)}intersectsLine(e){const t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const i=t||aE.getNormalMatrix(e),r=this.coplanarPoint(Fp).applyMatrix4(e),s=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Cs=new Ai,Au=new N;class za{constructor(e=new ln,t=new ln,i=new ln,r=new ln,s=new ln,a=new ln){this.planes=[e,t,i,r,s,a]}set(e,t,i,r,s,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(i),o[3].copy(r),o[4].copy(s),o[5].copy(a),this}copy(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=Rr){const i=this.planes,r=e.elements,s=r[0],a=r[1],o=r[2],l=r[3],c=r[4],u=r[5],h=r[6],d=r[7],p=r[8],m=r[9],v=r[10],f=r[11],g=r[12],x=r[13],y=r[14],_=r[15];if(i[0].setComponents(l-s,d-c,f-p,_-g).normalize(),i[1].setComponents(l+s,d+c,f+p,_+g).normalize(),i[2].setComponents(l+a,d+u,f+m,_+x).normalize(),i[3].setComponents(l-a,d-u,f-m,_-x).normalize(),i[4].setComponents(l-o,d-h,f-v,_-y).normalize(),t===Rr)i[5].setComponents(l+o,d+h,f+v,_+y).normalize();else if(t===bs)i[5].setComponents(o,h,v,y).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Cs.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Cs.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Cs)}intersectsSprite(e){return Cs.center.set(0,0,0),Cs.radius=.7071067811865476,Cs.applyMatrix4(e.matrixWorld),this.intersectsSphere(Cs)}intersectsSphere(e){const t=this.planes,i=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(i)<r)return!1;return!0}intersectsBox(e){const t=this.planes;for(let i=0;i<6;i++){const r=t[i];if(Au.x=r.normal.x>0?e.max.x:e.min.x,Au.y=r.normal.y>0?e.max.y:e.min.y,Au.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Au)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function Lv(){let n=null,e=!1,t=null,i=null;function r(s,a){t(s,a),i=n.requestAnimationFrame(r)}return{start:function(){e!==!0&&t!==null&&(i=n.requestAnimationFrame(r),e=!0)},stop:function(){n.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){n=s}}}function oE(n){const e=new WeakMap;function t(o,l){const c=o.array,u=o.usage,h=c.byteLength,d=n.createBuffer();n.bindBuffer(l,d),n.bufferData(l,c,u),o.onUploadCallback();let p;if(c instanceof Float32Array)p=n.FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?p=n.HALF_FLOAT:p=n.UNSIGNED_SHORT;else if(c instanceof Int16Array)p=n.SHORT;else if(c instanceof Uint32Array)p=n.UNSIGNED_INT;else if(c instanceof Int32Array)p=n.INT;else if(c instanceof Int8Array)p=n.BYTE;else if(c instanceof Uint8Array)p=n.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)p=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:d,type:p,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:h}}function i(o,l,c){const u=l.array,h=l.updateRanges;if(n.bindBuffer(c,o),h.length===0)n.bufferSubData(c,0,u);else{h.sort((p,m)=>p.start-m.start);let d=0;for(let p=1;p<h.length;p++){const m=h[d],v=h[p];v.start<=m.start+m.count+1?m.count=Math.max(m.count,v.start+v.count-m.start):(++d,h[d]=v)}h.length=d+1;for(let p=0,m=h.length;p<m;p++){const v=h[p];n.bufferSubData(c,v.start*u.BYTES_PER_ELEMENT,u,v.start,v.count)}l.clearUpdateRanges()}l.onUploadCallback()}function r(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function s(o){o.isInterleavedBufferAttribute&&(o=o.data);const l=e.get(o);l&&(n.deleteBuffer(l.buffer),e.delete(o))}function a(o,l){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const u=e.get(o);(!u||u.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const c=e.get(o);if(c===void 0)e.set(o,t(o,l));else if(c.version<o.version){if(c.size!==o.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.");i(c.buffer,o,l),c.version=o.version}}return{get:r,remove:s,update:a}}class ua extends ct{constructor(e=1,t=1,i=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:r};const s=e/2,a=t/2,o=Math.floor(i),l=Math.floor(r),c=o+1,u=l+1,h=e/o,d=t/l,p=[],m=[],v=[],f=[];for(let g=0;g<u;g++){const x=g*d-a;for(let y=0;y<c;y++){const _=y*h-s;m.push(_,-x,0),v.push(0,0,1),f.push(y/o),f.push(1-g/l)}}for(let g=0;g<l;g++)for(let x=0;x<o;x++){const y=x+c*g,_=x+c*(g+1),I=x+1+c*(g+1),b=x+1+c*g;p.push(y,_,b),p.push(_,I,b)}this.setIndex(p),this.setAttribute("position",new De(m,3)),this.setAttribute("normal",new De(v,3)),this.setAttribute("uv",new De(f,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ua(e.width,e.height,e.widthSegments,e.heightSegments)}}var lE=`#ifdef USE_ALPHAHASH
|
|
45
45
|
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
|
|
46
46
|
#endif`,cE=`#ifdef USE_ALPHAHASH
|
|
47
47
|
const float ALPHA_HASH_SCALE = 0.05;
|
|
@@ -3592,7 +3592,7 @@ void main() {
|
|
|
3592
3592
|
#include <tonemapping_fragment>
|
|
3593
3593
|
#include <colorspace_fragment>
|
|
3594
3594
|
#include <fog_fragment>
|
|
3595
|
-
}`,dt={alphahash_fragment:lE,alphahash_pars_fragment:cE,alphamap_fragment:uE,alphamap_pars_fragment:hE,alphatest_fragment:dE,alphatest_pars_fragment:pE,aomap_fragment:mE,aomap_pars_fragment:fE,batching_pars_vertex:gE,batching_vertex:vE,begin_vertex:yE,beginnormal_vertex:xE,bsdfs:_E,iridescence_fragment:ME,bumpmap_pars_fragment:bE,clipping_planes_fragment:TE,clipping_planes_pars_fragment:SE,clipping_planes_pars_vertex:wE,clipping_planes_vertex:EE,color_fragment:AE,color_pars_fragment:NE,color_pars_vertex:CE,color_vertex:RE,common:IE,cube_uv_reflection_fragment:LE,defaultnormal_vertex:PE,displacementmap_pars_vertex:DE,displacementmap_vertex:UE,emissivemap_fragment:OE,emissivemap_pars_fragment:FE,colorspace_fragment:VE,colorspace_pars_fragment:BE,envmap_fragment:zE,envmap_common_pars_fragment:kE,envmap_pars_fragment:HE,envmap_pars_vertex:GE,envmap_physical_pars_fragment:eA,envmap_vertex:WE,fog_vertex:jE,fog_pars_vertex:XE,fog_fragment:qE,fog_pars_fragment:YE,gradientmap_pars_fragment:$E,lightmap_pars_fragment:JE,lights_lambert_fragment:KE,lights_lambert_pars_fragment:ZE,lights_pars_begin:QE,lights_toon_fragment:tA,lights_toon_pars_fragment:iA,lights_phong_fragment:rA,lights_phong_pars_fragment:nA,lights_physical_fragment:sA,lights_physical_pars_fragment:aA,lights_fragment_begin:oA,lights_fragment_maps:lA,lights_fragment_end:cA,logdepthbuf_fragment:uA,logdepthbuf_pars_fragment:hA,logdepthbuf_pars_vertex:dA,logdepthbuf_vertex:pA,map_fragment:mA,map_pars_fragment:fA,map_particle_fragment:gA,map_particle_pars_fragment:vA,metalnessmap_fragment:yA,metalnessmap_pars_fragment:xA,morphinstance_vertex:_A,morphcolor_vertex:MA,morphnormal_vertex:bA,morphtarget_pars_vertex:TA,morphtarget_vertex:SA,normal_fragment_begin:wA,normal_fragment_maps:EA,normal_pars_fragment:AA,normal_pars_vertex:NA,normal_vertex:CA,normalmap_pars_fragment:RA,clearcoat_normal_fragment_begin:IA,clearcoat_normal_fragment_maps:LA,clearcoat_pars_fragment:PA,iridescence_pars_fragment:DA,opaque_fragment:UA,packing:OA,premultiplied_alpha_fragment:FA,project_vertex:VA,dithering_fragment:BA,dithering_pars_fragment:zA,roughnessmap_fragment:kA,roughnessmap_pars_fragment:HA,shadowmap_pars_fragment:GA,shadowmap_pars_vertex:WA,shadowmap_vertex:jA,shadowmask_pars_fragment:XA,skinbase_vertex:qA,skinning_pars_vertex:YA,skinning_vertex:$A,skinnormal_vertex:JA,specularmap_fragment:KA,specularmap_pars_fragment:ZA,tonemapping_fragment:QA,tonemapping_pars_fragment:eN,transmission_fragment:tN,transmission_pars_fragment:iN,uv_pars_fragment:rN,uv_pars_vertex:nN,uv_vertex:sN,worldpos_vertex:aN,background_vert:oN,background_frag:lN,backgroundCube_vert:cN,backgroundCube_frag:uN,cube_vert:hN,cube_frag:dN,depth_vert:pN,depth_frag:mN,distanceRGBA_vert:fN,distanceRGBA_frag:gN,equirect_vert:vN,equirect_frag:yN,linedashed_vert:xN,linedashed_frag:_N,meshbasic_vert:MN,meshbasic_frag:bN,meshlambert_vert:TN,meshlambert_frag:SN,meshmatcap_vert:wN,meshmatcap_frag:EN,meshnormal_vert:AN,meshnormal_frag:NN,meshphong_vert:CN,meshphong_frag:RN,meshphysical_vert:IN,meshphysical_frag:LN,meshtoon_vert:PN,meshtoon_frag:DN,points_vert:UN,points_frag:ON,shadow_vert:FN,shadow_frag:VN,sprite_vert:BN,sprite_frag:zN},Me={common:{diffuse:{value:new xe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ke},alphaMap:{value:null},alphaMapTransform:{value:new Ke},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ke}},envmap:{envMap:{value:null},envMapRotation:{value:new Ke},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ke}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ke}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ke},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ke},normalScale:{value:new J(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ke},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ke}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ke}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ke}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new xe(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 xe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ke},alphaTest:{value:0},uvTransform:{value:new Ke}},sprite:{diffuse:{value:new xe(16777215)},opacity:{value:1},center:{value:new J(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ke},alphaMap:{value:null},alphaMapTransform:{value:new Ke},alphaTest:{value:0}}},Dr={basic:{uniforms:Yi([Me.common,Me.specularmap,Me.envmap,Me.aomap,Me.lightmap,Me.fog]),vertexShader:dt.meshbasic_vert,fragmentShader:dt.meshbasic_frag},lambert:{uniforms:Yi([Me.common,Me.specularmap,Me.envmap,Me.aomap,Me.lightmap,Me.emissivemap,Me.bumpmap,Me.normalmap,Me.displacementmap,Me.fog,Me.lights,{emissive:{value:new xe(0)}}]),vertexShader:dt.meshlambert_vert,fragmentShader:dt.meshlambert_frag},phong:{uniforms:Yi([Me.common,Me.specularmap,Me.envmap,Me.aomap,Me.lightmap,Me.emissivemap,Me.bumpmap,Me.normalmap,Me.displacementmap,Me.fog,Me.lights,{emissive:{value:new xe(0)},specular:{value:new xe(1118481)},shininess:{value:30}}]),vertexShader:dt.meshphong_vert,fragmentShader:dt.meshphong_frag},standard:{uniforms:Yi([Me.common,Me.envmap,Me.aomap,Me.lightmap,Me.emissivemap,Me.bumpmap,Me.normalmap,Me.displacementmap,Me.roughnessmap,Me.metalnessmap,Me.fog,Me.lights,{emissive:{value:new xe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:dt.meshphysical_vert,fragmentShader:dt.meshphysical_frag},toon:{uniforms:Yi([Me.common,Me.aomap,Me.lightmap,Me.emissivemap,Me.bumpmap,Me.normalmap,Me.displacementmap,Me.gradientmap,Me.fog,Me.lights,{emissive:{value:new xe(0)}}]),vertexShader:dt.meshtoon_vert,fragmentShader:dt.meshtoon_frag},matcap:{uniforms:Yi([Me.common,Me.bumpmap,Me.normalmap,Me.displacementmap,Me.fog,{matcap:{value:null}}]),vertexShader:dt.meshmatcap_vert,fragmentShader:dt.meshmatcap_frag},points:{uniforms:Yi([Me.points,Me.fog]),vertexShader:dt.points_vert,fragmentShader:dt.points_frag},dashed:{uniforms:Yi([Me.common,Me.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:dt.linedashed_vert,fragmentShader:dt.linedashed_frag},depth:{uniforms:Yi([Me.common,Me.displacementmap]),vertexShader:dt.depth_vert,fragmentShader:dt.depth_frag},normal:{uniforms:Yi([Me.common,Me.bumpmap,Me.normalmap,Me.displacementmap,{opacity:{value:1}}]),vertexShader:dt.meshnormal_vert,fragmentShader:dt.meshnormal_frag},sprite:{uniforms:Yi([Me.sprite,Me.fog]),vertexShader:dt.sprite_vert,fragmentShader:dt.sprite_frag},background:{uniforms:{uvTransform:{value:new Ke},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:dt.background_vert,fragmentShader:dt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Ke}},vertexShader:dt.backgroundCube_vert,fragmentShader:dt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:dt.cube_vert,fragmentShader:dt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:dt.equirect_vert,fragmentShader:dt.equirect_frag},distanceRGBA:{uniforms:Yi([Me.common,Me.displacementmap,{referencePosition:{value:new N},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:dt.distanceRGBA_vert,fragmentShader:dt.distanceRGBA_frag},shadow:{uniforms:Yi([Me.lights,Me.fog,{color:{value:new xe(0)},opacity:{value:1}}]),vertexShader:dt.shadow_vert,fragmentShader:dt.shadow_frag}};Dr.physical={uniforms:Yi([Dr.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ke},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ke},clearcoatNormalScale:{value:new J(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ke},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ke},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ke},sheen:{value:0},sheenColor:{value:new xe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ke},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ke},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ke},transmissionSamplerSize:{value:new J},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ke},attenuationDistance:{value:0},attenuationColor:{value:new xe(0)},specularColor:{value:new xe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ke},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ke},anisotropyVector:{value:new J},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ke}}]),vertexShader:dt.meshphysical_vert,fragmentShader:dt.meshphysical_frag};const Cu={r:0,b:0,g:0},Is=new dr,kN=new Re;function HN(n,e,t,i,r,s,a){const o=new xe(0);let l=s===!0?0:1,c,u,h=null,d=0,p=null;function m(x){let y=x.isScene===!0?x.background:null;return y&&y.isTexture&&(y=(x.backgroundBlurriness>0?t:e).get(y)),y}function v(x){let y=!1;const _=m(x);_===null?g(o,l):_&&_.isColor&&(g(_,1),y=!0);const I=n.xr.getEnvironmentBlendMode();I==="additive"?i.buffers.color.setClear(0,0,0,1,a):I==="alpha-blend"&&i.buffers.color.setClear(0,0,0,0,a),(n.autoClear||y)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil))}function f(x,y){const _=m(y);_&&(_.isCubeTexture||_.mapping===xs)?(u===void 0&&(u=new Ft(new yn(1,1,1),new Pr({name:"BackgroundCubeMaterial",uniforms:Va(Dr.backgroundCube.uniforms),vertexShader:Dr.backgroundCube.vertexShader,fragmentShader:Dr.backgroundCube.fragmentShader,side:si,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(I,b,w){this.matrixWorld.copyPosition(w.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(u)),Is.copy(y.backgroundRotation),Is.x*=-1,Is.y*=-1,Is.z*=-1,_.isCubeTexture&&_.isRenderTargetTexture===!1&&(Is.y*=-1,Is.z*=-1),u.material.uniforms.envMap.value=_,u.material.uniforms.flipEnvMap.value=_.isCubeTexture&&_.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=y.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=y.backgroundIntensity,u.material.uniforms.backgroundRotation.value.setFromMatrix4(kN.makeRotationFromEuler(Is)),u.material.toneMapped=vt.getTransfer(_.colorSpace)!==Ot,(h!==_||d!==_.version||p!==n.toneMapping)&&(u.material.needsUpdate=!0,h=_,d=_.version,p=n.toneMapping),u.layers.enableAll(),x.unshift(u,u.geometry,u.material,0,0,null)):_&&_.isTexture&&(c===void 0&&(c=new Ft(new ha(2,2),new Pr({name:"BackgroundMaterial",uniforms:Va(Dr.background.uniforms),vertexShader:Dr.background.vertexShader,fragmentShader:Dr.background.fragmentShader,side:an,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(c)),c.material.uniforms.t2D.value=_,c.material.uniforms.backgroundIntensity.value=y.backgroundIntensity,c.material.toneMapped=vt.getTransfer(_.colorSpace)!==Ot,_.matrixAutoUpdate===!0&&_.updateMatrix(),c.material.uniforms.uvTransform.value.copy(_.matrix),(h!==_||d!==_.version||p!==n.toneMapping)&&(c.material.needsUpdate=!0,h=_,d=_.version,p=n.toneMapping),c.layers.enableAll(),x.unshift(c,c.geometry,c.material,0,0,null))}function g(x,y){x.getRGB(Cu,Rv(n)),i.buffers.color.setClear(Cu.r,Cu.g,Cu.b,y,a)}return{getClearColor:function(){return o},setClearColor:function(x,y=1){o.set(x),l=y,g(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(x){l=x,g(o,l)},render:v,addToRenderList:f}}function GN(n,e){const t=n.getParameter(n.MAX_VERTEX_ATTRIBS),i={},r=d(null);let s=r,a=!1;function o(M,T,k,j,Y){let re=!1;const $=h(j,k,T);s!==$&&(s=$,c(s.object)),re=p(M,j,k,Y),re&&m(M,j,k,Y),Y!==null&&e.update(Y,n.ELEMENT_ARRAY_BUFFER),(re||a)&&(a=!1,_(M,T,k,j),Y!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(Y).buffer))}function l(){return n.createVertexArray()}function c(M){return n.bindVertexArray(M)}function u(M){return n.deleteVertexArray(M)}function h(M,T,k){const j=k.wireframe===!0;let Y=i[M.id];Y===void 0&&(Y={},i[M.id]=Y);let re=Y[T.id];re===void 0&&(re={},Y[T.id]=re);let $=re[j];return $===void 0&&($=d(l()),re[j]=$),$}function d(M){const T=[],k=[],j=[];for(let Y=0;Y<t;Y++)T[Y]=0,k[Y]=0,j[Y]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:T,enabledAttributes:k,attributeDivisors:j,object:M,attributes:{},index:null}}function p(M,T,k,j){const Y=s.attributes,re=T.attributes;let $=0;const he=k.getAttributes();for(const Q in he)if(he[Q].location>=0){const ye=Y[Q];let be=re[Q];if(be===void 0&&(Q==="instanceMatrix"&&M.instanceMatrix&&(be=M.instanceMatrix),Q==="instanceColor"&&M.instanceColor&&(be=M.instanceColor)),ye===void 0||ye.attribute!==be||be&&ye.data!==be.data)return!0;$++}return s.attributesNum!==$||s.index!==j}function m(M,T,k,j){const Y={},re=T.attributes;let $=0;const he=k.getAttributes();for(const Q in he)if(he[Q].location>=0){let ye=re[Q];ye===void 0&&(Q==="instanceMatrix"&&M.instanceMatrix&&(ye=M.instanceMatrix),Q==="instanceColor"&&M.instanceColor&&(ye=M.instanceColor));const be={};be.attribute=ye,ye&&ye.data&&(be.data=ye.data),Y[Q]=be,$++}s.attributes=Y,s.attributesNum=$,s.index=j}function v(){const M=s.newAttributes;for(let T=0,k=M.length;T<k;T++)M[T]=0}function f(M){g(M,0)}function g(M,T){const k=s.newAttributes,j=s.enabledAttributes,Y=s.attributeDivisors;k[M]=1,j[M]===0&&(n.enableVertexAttribArray(M),j[M]=1),Y[M]!==T&&(n.vertexAttribDivisor(M,T),Y[M]=T)}function x(){const M=s.newAttributes,T=s.enabledAttributes;for(let k=0,j=T.length;k<j;k++)T[k]!==M[k]&&(n.disableVertexAttribArray(k),T[k]=0)}function y(M,T,k,j,Y,re,$){$===!0?n.vertexAttribIPointer(M,T,k,Y,re):n.vertexAttribPointer(M,T,k,j,Y,re)}function _(M,T,k,j){v();const Y=j.attributes,re=k.getAttributes(),$=T.defaultAttributeValues;for(const he in re){const Q=re[he];if(Q.location>=0){let ye=Y[he];if(ye===void 0&&(he==="instanceMatrix"&&M.instanceMatrix&&(ye=M.instanceMatrix),he==="instanceColor"&&M.instanceColor&&(ye=M.instanceColor)),ye!==void 0){const be=ye.normalized,Ve=ye.itemSize,at=e.get(ye);if(at===void 0)continue;const et=at.buffer,ie=at.type,le=at.bytesPerElement,Te=ie===n.INT||ie===n.UNSIGNED_INT||ye.gpuType===va;if(ye.isInterleavedBufferAttribute){const Se=ye.data,Ye=Se.stride,We=ye.offset;if(Se.isInstancedInterleavedBuffer){for(let ot=0;ot<Q.locationSize;ot++)g(Q.location+ot,Se.meshPerAttribute);M.isInstancedMesh!==!0&&j._maxInstanceCount===void 0&&(j._maxInstanceCount=Se.meshPerAttribute*Se.count)}else for(let ot=0;ot<Q.locationSize;ot++)f(Q.location+ot);n.bindBuffer(n.ARRAY_BUFFER,et);for(let ot=0;ot<Q.locationSize;ot++)y(Q.location+ot,Ve/Q.locationSize,ie,be,Ye*le,(We+Ve/Q.locationSize*ot)*le,Te)}else{if(ye.isInstancedBufferAttribute){for(let Se=0;Se<Q.locationSize;Se++)g(Q.location+Se,ye.meshPerAttribute);M.isInstancedMesh!==!0&&j._maxInstanceCount===void 0&&(j._maxInstanceCount=ye.meshPerAttribute*ye.count)}else for(let Se=0;Se<Q.locationSize;Se++)f(Q.location+Se);n.bindBuffer(n.ARRAY_BUFFER,et);for(let Se=0;Se<Q.locationSize;Se++)y(Q.location+Se,Ve/Q.locationSize,ie,be,Ve*le,Ve/Q.locationSize*Se*le,Te)}}else if($!==void 0){const be=$[he];if(be!==void 0)switch(be.length){case 2:n.vertexAttrib2fv(Q.location,be);break;case 3:n.vertexAttrib3fv(Q.location,be);break;case 4:n.vertexAttrib4fv(Q.location,be);break;default:n.vertexAttrib1fv(Q.location,be)}}}}x()}function I(){C();for(const M in i){const T=i[M];for(const k in T){const j=T[k];for(const Y in j)u(j[Y].object),delete j[Y];delete T[k]}delete i[M]}}function b(M){if(i[M.id]===void 0)return;const T=i[M.id];for(const k in T){const j=T[k];for(const Y in j)u(j[Y].object),delete j[Y];delete T[k]}delete i[M.id]}function w(M){for(const T in i){const k=i[T];if(k[M.id]===void 0)continue;const j=k[M.id];for(const Y in j)u(j[Y].object),delete j[Y];delete k[M.id]}}function C(){H(),a=!0,s!==r&&(s=r,c(s.object))}function H(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:o,reset:C,resetDefaultState:H,dispose:I,releaseStatesOfGeometry:b,releaseStatesOfProgram:w,initAttributes:v,enableAttribute:f,disableUnusedAttributes:x}}function WN(n,e,t){let i;function r(c){i=c}function s(c,u){n.drawArrays(i,c,u),t.update(u,i,1)}function a(c,u,h){h!==0&&(n.drawArraysInstanced(i,c,u,h),t.update(u,i,h))}function o(c,u,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,c,0,u,0,h);let d=0;for(let p=0;p<h;p++)d+=u[p];t.update(d,i,1)}function l(c,u,h,d){if(h===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let m=0;m<c.length;m++)a(c[m],u[m],d[m]);else{p.multiDrawArraysInstancedWEBGL(i,c,0,u,0,d,0,h);let m=0;for(let v=0;v<h;v++)m+=u[v];for(let v=0;v<d.length;v++)t.update(m,i,d[v])}}this.setMode=r,this.render=s,this.renderInstances=a,this.renderMultiDraw=o,this.renderMultiDrawInstances=l}function jN(n,e,t,i){let r;function s(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const w=e.get("EXT_texture_filter_anisotropic");r=n.getParameter(w.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(w){return!(w!==Ei&&i.convert(w)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(w){const C=w===wi&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(w!==Wr&&i.convert(w)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_TYPE)&&w!==Oi&&!C)}function l(w){if(w==="highp"){if(n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.HIGH_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";w="mediump"}return w==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const u=l(c);u!==c&&(console.warn("THREE.WebGLRenderer:",c,"not supported, using",u,"instead."),c=u);const h=t.logarithmicDepthBuffer===!0,d=t.reverseDepthBuffer===!0&&e.has("EXT_clip_control");if(d===!0){const w=e.get("EXT_clip_control");w.clipControlEXT(w.LOWER_LEFT_EXT,w.ZERO_TO_ONE_EXT)}const p=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),m=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=n.getParameter(n.MAX_TEXTURE_SIZE),f=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),g=n.getParameter(n.MAX_VERTEX_ATTRIBS),x=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),y=n.getParameter(n.MAX_VARYING_VECTORS),_=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),I=m>0,b=n.getParameter(n.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:h,reverseDepthBuffer:d,maxTextures:p,maxVertexTextures:m,maxTextureSize:v,maxCubemapSize:f,maxAttributes:g,maxVertexUniforms:x,maxVaryings:y,maxFragmentUniforms:_,vertexTextures:I,maxSamples:b}}function XN(n){const e=this;let t=null,i=0,r=!1,s=!1;const a=new ln,o=new Ke,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(h,d){const p=h.length!==0||d||i!==0||r;return r=d,i=h.length,p},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(h,d){t=u(h,d,0)},this.setState=function(h,d,p){const m=h.clippingPlanes,v=h.clipIntersection,f=h.clipShadows,g=n.get(h);if(!r||m===null||m.length===0||s&&!f)s?u(null):c();else{const x=s?0:i,y=x*4;let _=g.clippingState||null;l.value=_,_=u(m,d,y,p);for(let I=0;I!==y;++I)_[I]=t[I];g.clippingState=_,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=x}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function u(h,d,p,m){const v=h!==null?h.length:0;let f=null;if(v!==0){if(f=l.value,m!==!0||f===null){const g=p+v*4,x=d.matrixWorldInverse;o.getNormalMatrix(x),(f===null||f.length<g)&&(f=new Float32Array(g));for(let y=0,_=p;y!==v;++y,_+=4)a.copy(h[y]).applyMatrix4(x,o),a.normal.toArray(f,_),f[_+3]=a.constant}l.value=f,l.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,f}}function qN(n){let e=new WeakMap;function t(a,o){return o===kn?a.mapping=fr:o===Hn&&(a.mapping=Ar),a}function i(a){if(a&&a.isTexture){const o=a.mapping;if(o===kn||o===Hn)if(e.has(a)){const l=e.get(a).texture;return t(l,a.mapping)}else{const l=a.image;if(l&&l.height>0){const c=new Au(l.height);return c.fromEquirectangularTexture(n,a),e.set(a,c),a.addEventListener("dispose",r),t(c.texture,a.mapping)}else return null}}return a}function r(a){const o=a.target;o.removeEventListener("dispose",r);const l=e.get(o);l!==void 0&&(e.delete(o),l.dispose())}function s(){e=new WeakMap}return{get:i,dispose:s}}class Ls extends ll{constructor(e=-1,t=1,i=1,r=-1,s=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=r,this.near=s,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,r,s,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let s=i-e,a=i+e,o=r+t,l=r-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,a=s+c*this.view.width,o-=u*this.view.offsetY,l=o-u*this.view.height}this.projectionMatrix.makeOrthographic(s,a,o,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}const Ha=4,Dv=[.125,.215,.35,.446,.526,.582],Ps=20,Bp=new Ls,Uv=new xe;let zp=null,kp=0,Hp=0,Gp=!1;const Ds=(1+Math.sqrt(5))/2,Ga=1/Ds,Ov=[new N(-Ds,Ga,0),new N(Ds,Ga,0),new N(-Ga,0,Ds),new N(Ga,0,Ds),new N(0,Ds,-Ga),new N(0,Ds,Ga),new N(-1,1,-1),new N(1,1,-1),new N(-1,1,1),new N(1,1,1)];let Ru=class{constructor(n){this._renderer=n,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(n,e=0,t=.1,i=100){zp=this._renderer.getRenderTarget(),kp=this._renderer.getActiveCubeFace(),Hp=this._renderer.getActiveMipmapLevel(),Gp=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(n,t,i,r),e>0&&this._blur(r,0,0,e),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(n,e=null){return this._fromTexture(n,e)}fromCubemap(n,e=null){return this._fromTexture(n,e)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=zv(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Bv(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(n){this._lodMax=Math.floor(Math.log2(n)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let n=0;n<this._lodPlanes.length;n++)this._lodPlanes[n].dispose()}_cleanup(n){this._renderer.setRenderTarget(zp,kp,Hp),this._renderer.xr.enabled=Gp,n.scissorTest=!1,Iu(n,0,0,n.width,n.height)}_fromTexture(n,e){n.mapping===fr||n.mapping===Ar?this._setSize(n.image.length===0?16:n.image[0].width||n.image[0].image.width):this._setSize(n.image.width/4),zp=this._renderer.getRenderTarget(),kp=this._renderer.getActiveCubeFace(),Hp=this._renderer.getActiveMipmapLevel(),Gp=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const t=e||this._allocateTargets();return this._textureToCubeUV(n,t),this._applyPMREM(t),this._cleanup(t),t}_allocateTargets(){const n=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,t={magFilter:Lt,minFilter:Lt,generateMipmaps:!1,type:wi,format:Ei,colorSpace:nr,depthBuffer:!1},i=Vv(n,e,t),{_lodMax:r}=this;if({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=Fv(r),this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==n||this._pingPongRenderTarget.height!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Vv(n,e,t);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=Fv(s)),this._blurMaterial=YN(s,n,e)}return i}_compileMaterial(n){const e=new Ft(this._lodPlanes[0],n);this._renderer.compile(e,Bp)}_sceneToCubeUV(n,e,t,i){const r=new di(90,1,e,t),s=[1,-1,1,1,1,1],a=[1,1,1,-1,-1,-1],o=this._renderer,l=o.autoClear,c=o.toneMapping;o.getClearColor(Uv),o.toneMapping=mr,o.autoClear=!1;const u=new Yr({name:"PMREM.Background",side:si,depthWrite:!1,depthTest:!1}),h=new Ft(new yn,u);let d=!1;const p=n.background;p?p.isColor&&(u.color.copy(p),n.background=null,d=!0):(u.color.copy(Uv),d=!0);for(let m=0;m<6;m++){const v=m%3;v===0?(r.up.set(0,s[m],0),r.lookAt(a[m],0,0)):v===1?(r.up.set(0,0,s[m]),r.lookAt(0,a[m],0)):(r.up.set(0,s[m],0),r.lookAt(0,0,a[m]));const f=this._cubeSize;Iu(i,v*f,m>2?f:0,f,f),o.setRenderTarget(i),d&&o.render(h,r),o.render(n,r)}h.geometry.dispose(),h.material.dispose(),o.toneMapping=c,o.autoClear=l,n.background=p}_textureToCubeUV(n,e){const t=this._renderer,i=n.mapping===fr||n.mapping===Ar;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=zv()),this._cubemapMaterial.uniforms.flipEnvMap.value=n.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Bv());const r=i?this._cubemapMaterial:this._equirectMaterial,s=new Ft(this._lodPlanes[0],r),a=r.uniforms;a.envMap.value=n;const o=this._cubeSize;Iu(e,0,0,3*o,2*o),t.setRenderTarget(e),t.render(s,Bp)}_applyPMREM(n){const e=this._renderer,t=e.autoClear;e.autoClear=!1;const i=this._lodPlanes.length;for(let r=1;r<i;r++){const s=Math.sqrt(this._sigmas[r]*this._sigmas[r]-this._sigmas[r-1]*this._sigmas[r-1]),a=Ov[(i-r-1)%Ov.length];this._blur(n,r-1,r,s,a)}e.autoClear=t}_blur(n,e,t,i,r){const s=this._pingPongRenderTarget;this._halfBlur(n,s,e,t,i,"latitudinal",r),this._halfBlur(s,n,t,t,i,"longitudinal",r)}_halfBlur(n,e,t,i,r,s,a){const o=this._renderer,l=this._blurMaterial;s!=="latitudinal"&&s!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const c=3,u=new Ft(this._lodPlanes[i],l),h=l.uniforms,d=this._sizeLods[t]-1,p=isFinite(r)?Math.PI/(2*d):2*Math.PI/(2*Ps-1),m=r/p,v=isFinite(r)?1+Math.floor(c*m):Ps;v>Ps&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${v} samples when the maximum is set to ${Ps}`);const f=[];let g=0;for(let b=0;b<Ps;++b){const w=b/m,C=Math.exp(-w*w/2);f.push(C),b===0?g+=C:b<v&&(g+=2*C)}for(let b=0;b<f.length;b++)f[b]=f[b]/g;h.envMap.value=n.texture,h.samples.value=v,h.weights.value=f,h.latitudinal.value=s==="latitudinal",a&&(h.poleAxis.value=a);const{_lodMax:x}=this;h.dTheta.value=p,h.mipInt.value=x-t;const y=this._sizeLods[i],_=3*y*(i>x-Ha?i-x+Ha:0),I=4*(this._cubeSize-y);Iu(e,_,I,3*y,2*y),o.setRenderTarget(e),o.render(u,Bp)}};function Fv(n){const e=[],t=[],i=[];let r=n;const s=n-Ha+1+Dv.length;for(let a=0;a<s;a++){const o=Math.pow(2,r);t.push(o);let l=1/o;a>n-Ha?l=Dv[a-n+Ha-1]:a===0&&(l=0),i.push(l);const c=1/(o-2),u=-c,h=1+c,d=[u,u,h,u,h,h,u,u,h,h,u,h],p=6,m=6,v=3,f=2,g=1,x=new Float32Array(v*m*p),y=new Float32Array(f*m*p),_=new Float32Array(g*m*p);for(let b=0;b<p;b++){const w=b%3*2/3-1,C=b>2?0:-1,H=[w,C,0,w+2/3,C,0,w+2/3,C+1,0,w,C,0,w+2/3,C+1,0,w,C+1,0];x.set(H,v*m*b),y.set(d,f*m*b);const M=[b,b,b,b,b,b];_.set(M,g*m*b)}const I=new ct;I.setAttribute("position",new wt(x,v)),I.setAttribute("uv",new wt(y,f)),I.setAttribute("faceIndex",new wt(_,g)),e.push(I),r>Ha&&r--}return{lodPlanes:e,sizeLods:t,sigmas:i}}function Vv(n,e,t){const i=new Ir(n,e,t);return i.texture.mapping=xs,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Iu(n,e,t,i,r){n.viewport.set(e,t,i,r),n.scissor.set(e,t,i,r)}function YN(n,e,t){const i=new Float32Array(Ps),r=new N(0,1,0);return new Pr({name:"SphericalGaussianBlur",defines:{n:Ps,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:Wp(),fragmentShader:`
|
|
3595
|
+
}`,dt={alphahash_fragment:lE,alphahash_pars_fragment:cE,alphamap_fragment:uE,alphamap_pars_fragment:hE,alphatest_fragment:dE,alphatest_pars_fragment:pE,aomap_fragment:mE,aomap_pars_fragment:fE,batching_pars_vertex:gE,batching_vertex:vE,begin_vertex:yE,beginnormal_vertex:xE,bsdfs:_E,iridescence_fragment:ME,bumpmap_pars_fragment:bE,clipping_planes_fragment:TE,clipping_planes_pars_fragment:SE,clipping_planes_pars_vertex:wE,clipping_planes_vertex:EE,color_fragment:AE,color_pars_fragment:NE,color_pars_vertex:CE,color_vertex:RE,common:IE,cube_uv_reflection_fragment:LE,defaultnormal_vertex:PE,displacementmap_pars_vertex:DE,displacementmap_vertex:UE,emissivemap_fragment:OE,emissivemap_pars_fragment:FE,colorspace_fragment:VE,colorspace_pars_fragment:BE,envmap_fragment:zE,envmap_common_pars_fragment:kE,envmap_pars_fragment:HE,envmap_pars_vertex:GE,envmap_physical_pars_fragment:eA,envmap_vertex:WE,fog_vertex:jE,fog_pars_vertex:XE,fog_fragment:qE,fog_pars_fragment:YE,gradientmap_pars_fragment:$E,lightmap_pars_fragment:JE,lights_lambert_fragment:KE,lights_lambert_pars_fragment:ZE,lights_pars_begin:QE,lights_toon_fragment:tA,lights_toon_pars_fragment:iA,lights_phong_fragment:rA,lights_phong_pars_fragment:nA,lights_physical_fragment:sA,lights_physical_pars_fragment:aA,lights_fragment_begin:oA,lights_fragment_maps:lA,lights_fragment_end:cA,logdepthbuf_fragment:uA,logdepthbuf_pars_fragment:hA,logdepthbuf_pars_vertex:dA,logdepthbuf_vertex:pA,map_fragment:mA,map_pars_fragment:fA,map_particle_fragment:gA,map_particle_pars_fragment:vA,metalnessmap_fragment:yA,metalnessmap_pars_fragment:xA,morphinstance_vertex:_A,morphcolor_vertex:MA,morphnormal_vertex:bA,morphtarget_pars_vertex:TA,morphtarget_vertex:SA,normal_fragment_begin:wA,normal_fragment_maps:EA,normal_pars_fragment:AA,normal_pars_vertex:NA,normal_vertex:CA,normalmap_pars_fragment:RA,clearcoat_normal_fragment_begin:IA,clearcoat_normal_fragment_maps:LA,clearcoat_pars_fragment:PA,iridescence_pars_fragment:DA,opaque_fragment:UA,packing:OA,premultiplied_alpha_fragment:FA,project_vertex:VA,dithering_fragment:BA,dithering_pars_fragment:zA,roughnessmap_fragment:kA,roughnessmap_pars_fragment:HA,shadowmap_pars_fragment:GA,shadowmap_pars_vertex:WA,shadowmap_vertex:jA,shadowmask_pars_fragment:XA,skinbase_vertex:qA,skinning_pars_vertex:YA,skinning_vertex:$A,skinnormal_vertex:JA,specularmap_fragment:KA,specularmap_pars_fragment:ZA,tonemapping_fragment:QA,tonemapping_pars_fragment:eN,transmission_fragment:tN,transmission_pars_fragment:iN,uv_pars_fragment:rN,uv_pars_vertex:nN,uv_vertex:sN,worldpos_vertex:aN,background_vert:oN,background_frag:lN,backgroundCube_vert:cN,backgroundCube_frag:uN,cube_vert:hN,cube_frag:dN,depth_vert:pN,depth_frag:mN,distanceRGBA_vert:fN,distanceRGBA_frag:gN,equirect_vert:vN,equirect_frag:yN,linedashed_vert:xN,linedashed_frag:_N,meshbasic_vert:MN,meshbasic_frag:bN,meshlambert_vert:TN,meshlambert_frag:SN,meshmatcap_vert:wN,meshmatcap_frag:EN,meshnormal_vert:AN,meshnormal_frag:NN,meshphong_vert:CN,meshphong_frag:RN,meshphysical_vert:IN,meshphysical_frag:LN,meshtoon_vert:PN,meshtoon_frag:DN,points_vert:UN,points_frag:ON,shadow_vert:FN,shadow_frag:VN,sprite_vert:BN,sprite_frag:zN},Me={common:{diffuse:{value:new xe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ke},alphaMap:{value:null},alphaMapTransform:{value:new Ke},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ke}},envmap:{envMap:{value:null},envMapRotation:{value:new Ke},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ke}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ke}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ke},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ke},normalScale:{value:new J(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ke},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ke}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ke}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ke}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new xe(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 xe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ke},alphaTest:{value:0},uvTransform:{value:new Ke}},sprite:{diffuse:{value:new xe(16777215)},opacity:{value:1},center:{value:new J(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ke},alphaMap:{value:null},alphaMapTransform:{value:new Ke},alphaTest:{value:0}}},Dr={basic:{uniforms:Yi([Me.common,Me.specularmap,Me.envmap,Me.aomap,Me.lightmap,Me.fog]),vertexShader:dt.meshbasic_vert,fragmentShader:dt.meshbasic_frag},lambert:{uniforms:Yi([Me.common,Me.specularmap,Me.envmap,Me.aomap,Me.lightmap,Me.emissivemap,Me.bumpmap,Me.normalmap,Me.displacementmap,Me.fog,Me.lights,{emissive:{value:new xe(0)}}]),vertexShader:dt.meshlambert_vert,fragmentShader:dt.meshlambert_frag},phong:{uniforms:Yi([Me.common,Me.specularmap,Me.envmap,Me.aomap,Me.lightmap,Me.emissivemap,Me.bumpmap,Me.normalmap,Me.displacementmap,Me.fog,Me.lights,{emissive:{value:new xe(0)},specular:{value:new xe(1118481)},shininess:{value:30}}]),vertexShader:dt.meshphong_vert,fragmentShader:dt.meshphong_frag},standard:{uniforms:Yi([Me.common,Me.envmap,Me.aomap,Me.lightmap,Me.emissivemap,Me.bumpmap,Me.normalmap,Me.displacementmap,Me.roughnessmap,Me.metalnessmap,Me.fog,Me.lights,{emissive:{value:new xe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:dt.meshphysical_vert,fragmentShader:dt.meshphysical_frag},toon:{uniforms:Yi([Me.common,Me.aomap,Me.lightmap,Me.emissivemap,Me.bumpmap,Me.normalmap,Me.displacementmap,Me.gradientmap,Me.fog,Me.lights,{emissive:{value:new xe(0)}}]),vertexShader:dt.meshtoon_vert,fragmentShader:dt.meshtoon_frag},matcap:{uniforms:Yi([Me.common,Me.bumpmap,Me.normalmap,Me.displacementmap,Me.fog,{matcap:{value:null}}]),vertexShader:dt.meshmatcap_vert,fragmentShader:dt.meshmatcap_frag},points:{uniforms:Yi([Me.points,Me.fog]),vertexShader:dt.points_vert,fragmentShader:dt.points_frag},dashed:{uniforms:Yi([Me.common,Me.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:dt.linedashed_vert,fragmentShader:dt.linedashed_frag},depth:{uniforms:Yi([Me.common,Me.displacementmap]),vertexShader:dt.depth_vert,fragmentShader:dt.depth_frag},normal:{uniforms:Yi([Me.common,Me.bumpmap,Me.normalmap,Me.displacementmap,{opacity:{value:1}}]),vertexShader:dt.meshnormal_vert,fragmentShader:dt.meshnormal_frag},sprite:{uniforms:Yi([Me.sprite,Me.fog]),vertexShader:dt.sprite_vert,fragmentShader:dt.sprite_frag},background:{uniforms:{uvTransform:{value:new Ke},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:dt.background_vert,fragmentShader:dt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Ke}},vertexShader:dt.backgroundCube_vert,fragmentShader:dt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:dt.cube_vert,fragmentShader:dt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:dt.equirect_vert,fragmentShader:dt.equirect_frag},distanceRGBA:{uniforms:Yi([Me.common,Me.displacementmap,{referencePosition:{value:new N},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:dt.distanceRGBA_vert,fragmentShader:dt.distanceRGBA_frag},shadow:{uniforms:Yi([Me.lights,Me.fog,{color:{value:new xe(0)},opacity:{value:1}}]),vertexShader:dt.shadow_vert,fragmentShader:dt.shadow_frag}};Dr.physical={uniforms:Yi([Dr.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ke},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ke},clearcoatNormalScale:{value:new J(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ke},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ke},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ke},sheen:{value:0},sheenColor:{value:new xe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ke},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ke},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ke},transmissionSamplerSize:{value:new J},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ke},attenuationDistance:{value:0},attenuationColor:{value:new xe(0)},specularColor:{value:new xe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ke},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ke},anisotropyVector:{value:new J},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ke}}]),vertexShader:dt.meshphysical_vert,fragmentShader:dt.meshphysical_frag};const Nu={r:0,b:0,g:0},Rs=new dr,kN=new Re;function HN(n,e,t,i,r,s,a){const o=new xe(0);let l=s===!0?0:1,c,u,h=null,d=0,p=null;function m(x){let y=x.isScene===!0?x.background:null;return y&&y.isTexture&&(y=(x.backgroundBlurriness>0?t:e).get(y)),y}function v(x){let y=!1;const _=m(x);_===null?g(o,l):_&&_.isColor&&(g(_,1),y=!0);const I=n.xr.getEnvironmentBlendMode();I==="additive"?i.buffers.color.setClear(0,0,0,1,a):I==="alpha-blend"&&i.buffers.color.setClear(0,0,0,0,a),(n.autoClear||y)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil))}function f(x,y){const _=m(y);_&&(_.isCubeTexture||_.mapping===ys)?(u===void 0&&(u=new Ft(new yn(1,1,1),new Pr({name:"BackgroundCubeMaterial",uniforms:Fa(Dr.backgroundCube.uniforms),vertexShader:Dr.backgroundCube.vertexShader,fragmentShader:Dr.backgroundCube.fragmentShader,side:si,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(I,b,w){this.matrixWorld.copyPosition(w.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(u)),Rs.copy(y.backgroundRotation),Rs.x*=-1,Rs.y*=-1,Rs.z*=-1,_.isCubeTexture&&_.isRenderTargetTexture===!1&&(Rs.y*=-1,Rs.z*=-1),u.material.uniforms.envMap.value=_,u.material.uniforms.flipEnvMap.value=_.isCubeTexture&&_.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=y.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=y.backgroundIntensity,u.material.uniforms.backgroundRotation.value.setFromMatrix4(kN.makeRotationFromEuler(Rs)),u.material.toneMapped=vt.getTransfer(_.colorSpace)!==Ot,(h!==_||d!==_.version||p!==n.toneMapping)&&(u.material.needsUpdate=!0,h=_,d=_.version,p=n.toneMapping),u.layers.enableAll(),x.unshift(u,u.geometry,u.material,0,0,null)):_&&_.isTexture&&(c===void 0&&(c=new Ft(new ua(2,2),new Pr({name:"BackgroundMaterial",uniforms:Fa(Dr.background.uniforms),vertexShader:Dr.background.vertexShader,fragmentShader:Dr.background.fragmentShader,side:an,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(c)),c.material.uniforms.t2D.value=_,c.material.uniforms.backgroundIntensity.value=y.backgroundIntensity,c.material.toneMapped=vt.getTransfer(_.colorSpace)!==Ot,_.matrixAutoUpdate===!0&&_.updateMatrix(),c.material.uniforms.uvTransform.value.copy(_.matrix),(h!==_||d!==_.version||p!==n.toneMapping)&&(c.material.needsUpdate=!0,h=_,d=_.version,p=n.toneMapping),c.layers.enableAll(),x.unshift(c,c.geometry,c.material,0,0,null))}function g(x,y){x.getRGB(Nu,Cv(n)),i.buffers.color.setClear(Nu.r,Nu.g,Nu.b,y,a)}return{getClearColor:function(){return o},setClearColor:function(x,y=1){o.set(x),l=y,g(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(x){l=x,g(o,l)},render:v,addToRenderList:f}}function GN(n,e){const t=n.getParameter(n.MAX_VERTEX_ATTRIBS),i={},r=d(null);let s=r,a=!1;function o(M,T,k,j,Y){let re=!1;const $=h(j,k,T);s!==$&&(s=$,c(s.object)),re=p(M,j,k,Y),re&&m(M,j,k,Y),Y!==null&&e.update(Y,n.ELEMENT_ARRAY_BUFFER),(re||a)&&(a=!1,_(M,T,k,j),Y!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(Y).buffer))}function l(){return n.createVertexArray()}function c(M){return n.bindVertexArray(M)}function u(M){return n.deleteVertexArray(M)}function h(M,T,k){const j=k.wireframe===!0;let Y=i[M.id];Y===void 0&&(Y={},i[M.id]=Y);let re=Y[T.id];re===void 0&&(re={},Y[T.id]=re);let $=re[j];return $===void 0&&($=d(l()),re[j]=$),$}function d(M){const T=[],k=[],j=[];for(let Y=0;Y<t;Y++)T[Y]=0,k[Y]=0,j[Y]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:T,enabledAttributes:k,attributeDivisors:j,object:M,attributes:{},index:null}}function p(M,T,k,j){const Y=s.attributes,re=T.attributes;let $=0;const he=k.getAttributes();for(const Q in he)if(he[Q].location>=0){const ye=Y[Q];let be=re[Q];if(be===void 0&&(Q==="instanceMatrix"&&M.instanceMatrix&&(be=M.instanceMatrix),Q==="instanceColor"&&M.instanceColor&&(be=M.instanceColor)),ye===void 0||ye.attribute!==be||be&&ye.data!==be.data)return!0;$++}return s.attributesNum!==$||s.index!==j}function m(M,T,k,j){const Y={},re=T.attributes;let $=0;const he=k.getAttributes();for(const Q in he)if(he[Q].location>=0){let ye=re[Q];ye===void 0&&(Q==="instanceMatrix"&&M.instanceMatrix&&(ye=M.instanceMatrix),Q==="instanceColor"&&M.instanceColor&&(ye=M.instanceColor));const be={};be.attribute=ye,ye&&ye.data&&(be.data=ye.data),Y[Q]=be,$++}s.attributes=Y,s.attributesNum=$,s.index=j}function v(){const M=s.newAttributes;for(let T=0,k=M.length;T<k;T++)M[T]=0}function f(M){g(M,0)}function g(M,T){const k=s.newAttributes,j=s.enabledAttributes,Y=s.attributeDivisors;k[M]=1,j[M]===0&&(n.enableVertexAttribArray(M),j[M]=1),Y[M]!==T&&(n.vertexAttribDivisor(M,T),Y[M]=T)}function x(){const M=s.newAttributes,T=s.enabledAttributes;for(let k=0,j=T.length;k<j;k++)T[k]!==M[k]&&(n.disableVertexAttribArray(k),T[k]=0)}function y(M,T,k,j,Y,re,$){$===!0?n.vertexAttribIPointer(M,T,k,Y,re):n.vertexAttribPointer(M,T,k,j,Y,re)}function _(M,T,k,j){v();const Y=j.attributes,re=k.getAttributes(),$=T.defaultAttributeValues;for(const he in re){const Q=re[he];if(Q.location>=0){let ye=Y[he];if(ye===void 0&&(he==="instanceMatrix"&&M.instanceMatrix&&(ye=M.instanceMatrix),he==="instanceColor"&&M.instanceColor&&(ye=M.instanceColor)),ye!==void 0){const be=ye.normalized,Ve=ye.itemSize,at=e.get(ye);if(at===void 0)continue;const et=at.buffer,ie=at.type,le=at.bytesPerElement,Te=ie===n.INT||ie===n.UNSIGNED_INT||ye.gpuType===ga;if(ye.isInterleavedBufferAttribute){const Se=ye.data,Ye=Se.stride,We=ye.offset;if(Se.isInstancedInterleavedBuffer){for(let ot=0;ot<Q.locationSize;ot++)g(Q.location+ot,Se.meshPerAttribute);M.isInstancedMesh!==!0&&j._maxInstanceCount===void 0&&(j._maxInstanceCount=Se.meshPerAttribute*Se.count)}else for(let ot=0;ot<Q.locationSize;ot++)f(Q.location+ot);n.bindBuffer(n.ARRAY_BUFFER,et);for(let ot=0;ot<Q.locationSize;ot++)y(Q.location+ot,Ve/Q.locationSize,ie,be,Ye*le,(We+Ve/Q.locationSize*ot)*le,Te)}else{if(ye.isInstancedBufferAttribute){for(let Se=0;Se<Q.locationSize;Se++)g(Q.location+Se,ye.meshPerAttribute);M.isInstancedMesh!==!0&&j._maxInstanceCount===void 0&&(j._maxInstanceCount=ye.meshPerAttribute*ye.count)}else for(let Se=0;Se<Q.locationSize;Se++)f(Q.location+Se);n.bindBuffer(n.ARRAY_BUFFER,et);for(let Se=0;Se<Q.locationSize;Se++)y(Q.location+Se,Ve/Q.locationSize,ie,be,Ve*le,Ve/Q.locationSize*Se*le,Te)}}else if($!==void 0){const be=$[he];if(be!==void 0)switch(be.length){case 2:n.vertexAttrib2fv(Q.location,be);break;case 3:n.vertexAttrib3fv(Q.location,be);break;case 4:n.vertexAttrib4fv(Q.location,be);break;default:n.vertexAttrib1fv(Q.location,be)}}}}x()}function I(){C();for(const M in i){const T=i[M];for(const k in T){const j=T[k];for(const Y in j)u(j[Y].object),delete j[Y];delete T[k]}delete i[M]}}function b(M){if(i[M.id]===void 0)return;const T=i[M.id];for(const k in T){const j=T[k];for(const Y in j)u(j[Y].object),delete j[Y];delete T[k]}delete i[M.id]}function w(M){for(const T in i){const k=i[T];if(k[M.id]===void 0)continue;const j=k[M.id];for(const Y in j)u(j[Y].object),delete j[Y];delete k[M.id]}}function C(){H(),a=!0,s!==r&&(s=r,c(s.object))}function H(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:o,reset:C,resetDefaultState:H,dispose:I,releaseStatesOfGeometry:b,releaseStatesOfProgram:w,initAttributes:v,enableAttribute:f,disableUnusedAttributes:x}}function WN(n,e,t){let i;function r(c){i=c}function s(c,u){n.drawArrays(i,c,u),t.update(u,i,1)}function a(c,u,h){h!==0&&(n.drawArraysInstanced(i,c,u,h),t.update(u,i,h))}function o(c,u,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,c,0,u,0,h);let d=0;for(let p=0;p<h;p++)d+=u[p];t.update(d,i,1)}function l(c,u,h,d){if(h===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let m=0;m<c.length;m++)a(c[m],u[m],d[m]);else{p.multiDrawArraysInstancedWEBGL(i,c,0,u,0,d,0,h);let m=0;for(let v=0;v<h;v++)m+=u[v];for(let v=0;v<d.length;v++)t.update(m,i,d[v])}}this.setMode=r,this.render=s,this.renderInstances=a,this.renderMultiDraw=o,this.renderMultiDrawInstances=l}function jN(n,e,t,i){let r;function s(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const w=e.get("EXT_texture_filter_anisotropic");r=n.getParameter(w.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(w){return!(w!==Ei&&i.convert(w)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(w){const C=w===wi&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(w!==Wr&&i.convert(w)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_TYPE)&&w!==Oi&&!C)}function l(w){if(w==="highp"){if(n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.HIGH_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";w="mediump"}return w==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const u=l(c);u!==c&&(console.warn("THREE.WebGLRenderer:",c,"not supported, using",u,"instead."),c=u);const h=t.logarithmicDepthBuffer===!0,d=t.reverseDepthBuffer===!0&&e.has("EXT_clip_control");if(d===!0){const w=e.get("EXT_clip_control");w.clipControlEXT(w.LOWER_LEFT_EXT,w.ZERO_TO_ONE_EXT)}const p=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),m=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=n.getParameter(n.MAX_TEXTURE_SIZE),f=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),g=n.getParameter(n.MAX_VERTEX_ATTRIBS),x=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),y=n.getParameter(n.MAX_VARYING_VECTORS),_=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),I=m>0,b=n.getParameter(n.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:h,reverseDepthBuffer:d,maxTextures:p,maxVertexTextures:m,maxTextureSize:v,maxCubemapSize:f,maxAttributes:g,maxVertexUniforms:x,maxVaryings:y,maxFragmentUniforms:_,vertexTextures:I,maxSamples:b}}function XN(n){const e=this;let t=null,i=0,r=!1,s=!1;const a=new ln,o=new Ke,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(h,d){const p=h.length!==0||d||i!==0||r;return r=d,i=h.length,p},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(h,d){t=u(h,d,0)},this.setState=function(h,d,p){const m=h.clippingPlanes,v=h.clipIntersection,f=h.clipShadows,g=n.get(h);if(!r||m===null||m.length===0||s&&!f)s?u(null):c();else{const x=s?0:i,y=x*4;let _=g.clippingState||null;l.value=_,_=u(m,d,y,p);for(let I=0;I!==y;++I)_[I]=t[I];g.clippingState=_,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=x}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function u(h,d,p,m){const v=h!==null?h.length:0;let f=null;if(v!==0){if(f=l.value,m!==!0||f===null){const g=p+v*4,x=d.matrixWorldInverse;o.getNormalMatrix(x),(f===null||f.length<g)&&(f=new Float32Array(g));for(let y=0,_=p;y!==v;++y,_+=4)a.copy(h[y]).applyMatrix4(x,o),a.normal.toArray(f,_),f[_+3]=a.constant}l.value=f,l.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,f}}function qN(n){let e=new WeakMap;function t(a,o){return o===zn?a.mapping=fr:o===kn&&(a.mapping=Ar),a}function i(a){if(a&&a.isTexture){const o=a.mapping;if(o===zn||o===kn)if(e.has(a)){const l=e.get(a).texture;return t(l,a.mapping)}else{const l=a.image;if(l&&l.height>0){const c=new Eu(l.height);return c.fromEquirectangularTexture(n,a),e.set(a,c),a.addEventListener("dispose",r),t(c.texture,a.mapping)}else return null}}return a}function r(a){const o=a.target;o.removeEventListener("dispose",r);const l=e.get(o);l!==void 0&&(e.delete(o),l.dispose())}function s(){e=new WeakMap}return{get:i,dispose:s}}class Is extends ol{constructor(e=-1,t=1,i=1,r=-1,s=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=r,this.near=s,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,r,s,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let s=i-e,a=i+e,o=r+t,l=r-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,a=s+c*this.view.width,o-=u*this.view.offsetY,l=o-u*this.view.height}this.projectionMatrix.makeOrthographic(s,a,o,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}const ka=4,Pv=[.125,.215,.35,.446,.526,.582],Ls=20,Vp=new Is,Dv=new xe;let Bp=null,zp=0,kp=0,Hp=!1;const Ps=(1+Math.sqrt(5))/2,Ha=1/Ps,Uv=[new N(-Ps,Ha,0),new N(Ps,Ha,0),new N(-Ha,0,Ps),new N(Ha,0,Ps),new N(0,Ps,-Ha),new N(0,Ps,Ha),new N(-1,1,-1),new N(1,1,-1),new N(-1,1,1),new N(1,1,1)];let Cu=class{constructor(n){this._renderer=n,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(n,e=0,t=.1,i=100){Bp=this._renderer.getRenderTarget(),zp=this._renderer.getActiveCubeFace(),kp=this._renderer.getActiveMipmapLevel(),Hp=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(n,t,i,r),e>0&&this._blur(r,0,0,e),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(n,e=null){return this._fromTexture(n,e)}fromCubemap(n,e=null){return this._fromTexture(n,e)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Bv(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Vv(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(n){this._lodMax=Math.floor(Math.log2(n)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let n=0;n<this._lodPlanes.length;n++)this._lodPlanes[n].dispose()}_cleanup(n){this._renderer.setRenderTarget(Bp,zp,kp),this._renderer.xr.enabled=Hp,n.scissorTest=!1,Ru(n,0,0,n.width,n.height)}_fromTexture(n,e){n.mapping===fr||n.mapping===Ar?this._setSize(n.image.length===0?16:n.image[0].width||n.image[0].image.width):this._setSize(n.image.width/4),Bp=this._renderer.getRenderTarget(),zp=this._renderer.getActiveCubeFace(),kp=this._renderer.getActiveMipmapLevel(),Hp=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const t=e||this._allocateTargets();return this._textureToCubeUV(n,t),this._applyPMREM(t),this._cleanup(t),t}_allocateTargets(){const n=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,t={magFilter:Lt,minFilter:Lt,generateMipmaps:!1,type:wi,format:Ei,colorSpace:nr,depthBuffer:!1},i=Fv(n,e,t),{_lodMax:r}=this;if({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=Ov(r),this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==n||this._pingPongRenderTarget.height!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Fv(n,e,t);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=Ov(s)),this._blurMaterial=YN(s,n,e)}return i}_compileMaterial(n){const e=new Ft(this._lodPlanes[0],n);this._renderer.compile(e,Vp)}_sceneToCubeUV(n,e,t,i){const r=new di(90,1,e,t),s=[1,-1,1,1,1,1],a=[1,1,1,-1,-1,-1],o=this._renderer,l=o.autoClear,c=o.toneMapping;o.getClearColor(Dv),o.toneMapping=mr,o.autoClear=!1;const u=new Yr({name:"PMREM.Background",side:si,depthWrite:!1,depthTest:!1}),h=new Ft(new yn,u);let d=!1;const p=n.background;p?p.isColor&&(u.color.copy(p),n.background=null,d=!0):(u.color.copy(Dv),d=!0);for(let m=0;m<6;m++){const v=m%3;v===0?(r.up.set(0,s[m],0),r.lookAt(a[m],0,0)):v===1?(r.up.set(0,0,s[m]),r.lookAt(0,a[m],0)):(r.up.set(0,s[m],0),r.lookAt(0,0,a[m]));const f=this._cubeSize;Ru(i,v*f,m>2?f:0,f,f),o.setRenderTarget(i),d&&o.render(h,r),o.render(n,r)}h.geometry.dispose(),h.material.dispose(),o.toneMapping=c,o.autoClear=l,n.background=p}_textureToCubeUV(n,e){const t=this._renderer,i=n.mapping===fr||n.mapping===Ar;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=Bv()),this._cubemapMaterial.uniforms.flipEnvMap.value=n.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Vv());const r=i?this._cubemapMaterial:this._equirectMaterial,s=new Ft(this._lodPlanes[0],r),a=r.uniforms;a.envMap.value=n;const o=this._cubeSize;Ru(e,0,0,3*o,2*o),t.setRenderTarget(e),t.render(s,Vp)}_applyPMREM(n){const e=this._renderer,t=e.autoClear;e.autoClear=!1;const i=this._lodPlanes.length;for(let r=1;r<i;r++){const s=Math.sqrt(this._sigmas[r]*this._sigmas[r]-this._sigmas[r-1]*this._sigmas[r-1]),a=Uv[(i-r-1)%Uv.length];this._blur(n,r-1,r,s,a)}e.autoClear=t}_blur(n,e,t,i,r){const s=this._pingPongRenderTarget;this._halfBlur(n,s,e,t,i,"latitudinal",r),this._halfBlur(s,n,t,t,i,"longitudinal",r)}_halfBlur(n,e,t,i,r,s,a){const o=this._renderer,l=this._blurMaterial;s!=="latitudinal"&&s!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const c=3,u=new Ft(this._lodPlanes[i],l),h=l.uniforms,d=this._sizeLods[t]-1,p=isFinite(r)?Math.PI/(2*d):2*Math.PI/(2*Ls-1),m=r/p,v=isFinite(r)?1+Math.floor(c*m):Ls;v>Ls&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${v} samples when the maximum is set to ${Ls}`);const f=[];let g=0;for(let b=0;b<Ls;++b){const w=b/m,C=Math.exp(-w*w/2);f.push(C),b===0?g+=C:b<v&&(g+=2*C)}for(let b=0;b<f.length;b++)f[b]=f[b]/g;h.envMap.value=n.texture,h.samples.value=v,h.weights.value=f,h.latitudinal.value=s==="latitudinal",a&&(h.poleAxis.value=a);const{_lodMax:x}=this;h.dTheta.value=p,h.mipInt.value=x-t;const y=this._sizeLods[i],_=3*y*(i>x-ka?i-x+ka:0),I=4*(this._cubeSize-y);Ru(e,_,I,3*y,2*y),o.setRenderTarget(e),o.render(u,Vp)}};function Ov(n){const e=[],t=[],i=[];let r=n;const s=n-ka+1+Pv.length;for(let a=0;a<s;a++){const o=Math.pow(2,r);t.push(o);let l=1/o;a>n-ka?l=Pv[a-n+ka-1]:a===0&&(l=0),i.push(l);const c=1/(o-2),u=-c,h=1+c,d=[u,u,h,u,h,h,u,u,h,h,u,h],p=6,m=6,v=3,f=2,g=1,x=new Float32Array(v*m*p),y=new Float32Array(f*m*p),_=new Float32Array(g*m*p);for(let b=0;b<p;b++){const w=b%3*2/3-1,C=b>2?0:-1,H=[w,C,0,w+2/3,C,0,w+2/3,C+1,0,w,C,0,w+2/3,C+1,0,w,C+1,0];x.set(H,v*m*b),y.set(d,f*m*b);const M=[b,b,b,b,b,b];_.set(M,g*m*b)}const I=new ct;I.setAttribute("position",new wt(x,v)),I.setAttribute("uv",new wt(y,f)),I.setAttribute("faceIndex",new wt(_,g)),e.push(I),r>ka&&r--}return{lodPlanes:e,sizeLods:t,sigmas:i}}function Fv(n,e,t){const i=new Ir(n,e,t);return i.texture.mapping=ys,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Ru(n,e,t,i,r){n.viewport.set(e,t,i,r),n.scissor.set(e,t,i,r)}function YN(n,e,t){const i=new Float32Array(Ls),r=new N(0,1,0);return new Pr({name:"SphericalGaussianBlur",defines:{n:Ls,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:Gp(),fragmentShader:`
|
|
3596
3596
|
|
|
3597
3597
|
precision mediump float;
|
|
3598
3598
|
precision mediump int;
|
|
@@ -3652,7 +3652,7 @@ void main() {
|
|
|
3652
3652
|
}
|
|
3653
3653
|
|
|
3654
3654
|
}
|
|
3655
|
-
`,blending:Er,depthTest:!1,depthWrite:!1})}function
|
|
3655
|
+
`,blending:Er,depthTest:!1,depthWrite:!1})}function Vv(){return new Pr({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Gp(),fragmentShader:`
|
|
3656
3656
|
|
|
3657
3657
|
precision mediump float;
|
|
3658
3658
|
precision mediump int;
|
|
@@ -3671,7 +3671,7 @@ void main() {
|
|
|
3671
3671
|
gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
|
|
3672
3672
|
|
|
3673
3673
|
}
|
|
3674
|
-
`,blending:Er,depthTest:!1,depthWrite:!1})}function
|
|
3674
|
+
`,blending:Er,depthTest:!1,depthWrite:!1})}function Bv(){return new Pr({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Gp(),fragmentShader:`
|
|
3675
3675
|
|
|
3676
3676
|
precision mediump float;
|
|
3677
3677
|
precision mediump int;
|
|
@@ -3687,7 +3687,7 @@ void main() {
|
|
|
3687
3687
|
gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
|
|
3688
3688
|
|
|
3689
3689
|
}
|
|
3690
|
-
`,blending:Er,depthTest:!1,depthWrite:!1})}function
|
|
3690
|
+
`,blending:Er,depthTest:!1,depthWrite:!1})}function Gp(){return`
|
|
3691
3691
|
|
|
3692
3692
|
precision mediump float;
|
|
3693
3693
|
precision mediump int;
|
|
@@ -3742,16 +3742,16 @@ void main() {
|
|
|
3742
3742
|
gl_Position = vec4( position, 1.0 );
|
|
3743
3743
|
|
|
3744
3744
|
}
|
|
3745
|
-
`}function $N(n){let e=new WeakMap,t=null;function i(o){if(o&&o.isTexture){const l=o.mapping,c=l===kn||l===Hn,u=l===fr||l===Ar;if(c||u){let h=e.get(o);const d=h!==void 0?h.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==d)return t===null&&(t=new Ru(n)),h=c?t.fromEquirectangular(o,h):t.fromCubemap(o,h),h.texture.pmremVersion=o.pmremVersion,e.set(o,h),h.texture;if(h!==void 0)return h.texture;{const p=o.image;return c&&p&&p.height>0||u&&p&&r(p)?(t=new Ru(n),h=c?t.fromEquirectangular(o):t.fromCubemap(o),h.texture.pmremVersion=o.pmremVersion,e.set(o,h),o.addEventListener("dispose",s),h.texture):null}}}return o}function r(o){let l=0;const c=6;for(let u=0;u<c;u++)o[u]!==void 0&&l++;return l===c}function s(o){const l=o.target;l.removeEventListener("dispose",s);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function a(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:i,dispose:a}}function JN(n){const e={};function t(i){if(e[i]!==void 0)return e[i];let r;switch(i){case"WEBGL_depth_texture":r=n.getExtension("WEBGL_depth_texture")||n.getExtension("MOZ_WEBGL_depth_texture")||n.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=n.getExtension("EXT_texture_filter_anisotropic")||n.getExtension("MOZ_EXT_texture_filter_anisotropic")||n.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=n.getExtension("WEBGL_compressed_texture_s3tc")||n.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||n.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=n.getExtension("WEBGL_compressed_texture_pvrtc")||n.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=n.getExtension(i)}return e[i]=r,r}return{has:function(i){return t(i)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(i){const r=t(i);return r===null&&ou("THREE.WebGLRenderer: "+i+" extension not supported."),r}}}function KN(n,e,t,i){const r={},s=new WeakMap;function a(h){const d=h.target;d.index!==null&&e.remove(d.index);for(const m in d.attributes)e.remove(d.attributes[m]);for(const m in d.morphAttributes){const v=d.morphAttributes[m];for(let f=0,g=v.length;f<g;f++)e.remove(v[f])}d.removeEventListener("dispose",a),delete r[d.id];const p=s.get(d);p&&(e.remove(p),s.delete(d)),i.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,t.memory.geometries--}function o(h,d){return r[d.id]===!0||(d.addEventListener("dispose",a),r[d.id]=!0,t.memory.geometries++),d}function l(h){const d=h.attributes;for(const m in d)e.update(d[m],n.ARRAY_BUFFER);const p=h.morphAttributes;for(const m in p){const v=p[m];for(let f=0,g=v.length;f<g;f++)e.update(v[f],n.ARRAY_BUFFER)}}function c(h){const d=[],p=h.index,m=h.attributes.position;let v=0;if(p!==null){const x=p.array;v=p.version;for(let y=0,_=x.length;y<_;y+=3){const I=x[y+0],b=x[y+1],w=x[y+2];d.push(I,b,b,w,w,I)}}else if(m!==void 0){const x=m.array;v=m.version;for(let y=0,_=x.length/3-1;y<_;y+=3){const I=y+0,b=y+1,w=y+2;d.push(I,b,b,w,w,I)}}else return;const f=new(cv(d)?Dp:yu)(d,1);f.version=v;const g=s.get(h);g&&e.remove(g),s.set(h,f)}function u(h){const d=s.get(h);if(d){const p=h.index;p!==null&&d.version<p.version&&c(h)}else c(h);return s.get(h)}return{get:o,update:l,getWireframeAttribute:u}}function ZN(n,e,t){let i;function r(d){i=d}let s,a;function o(d){s=d.type,a=d.bytesPerElement}function l(d,p){n.drawElements(i,p,s,d*a),t.update(p,i,1)}function c(d,p,m){m!==0&&(n.drawElementsInstanced(i,p,s,d*a,m),t.update(p,i,m))}function u(d,p,m){if(m===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,p,0,s,d,0,m);let v=0;for(let f=0;f<m;f++)v+=p[f];t.update(v,i,1)}function h(d,p,m,v){if(m===0)return;const f=e.get("WEBGL_multi_draw");if(f===null)for(let g=0;g<d.length;g++)c(d[g]/a,p[g],v[g]);else{f.multiDrawElementsInstancedWEBGL(i,p,0,s,d,0,v,0,m);let g=0;for(let x=0;x<m;x++)g+=p[x];for(let x=0;x<v.length;x++)t.update(g,i,v[x])}}this.setMode=r,this.setIndex=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=u,this.renderMultiDrawInstances=h}function QN(n){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function i(s,a,o){switch(t.calls++,a){case n.TRIANGLES:t.triangles+=o*(s/3);break;case n.LINES:t.lines+=o*(s/2);break;case n.LINE_STRIP:t.lines+=o*(s-1);break;case n.LINE_LOOP:t.lines+=o*s;break;case n.POINTS:t.points+=o*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",a);break}}function r(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:r,update:i}}function eC(n,e,t){const i=new WeakMap,r=new st;function s(a,o,l){const c=a.morphTargetInfluences,u=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,h=u!==void 0?u.length:0;let d=i.get(o);if(d===void 0||d.count!==h){let p=function(){C.dispose(),i.delete(o),o.removeEventListener("dispose",p)};d!==void 0&&d.texture.dispose();const m=o.morphAttributes.position!==void 0,v=o.morphAttributes.normal!==void 0,f=o.morphAttributes.color!==void 0,g=o.morphAttributes.position||[],x=o.morphAttributes.normal||[],y=o.morphAttributes.color||[];let _=0;m===!0&&(_=1),v===!0&&(_=2),f===!0&&(_=3);let I=o.attributes.position.count*_,b=1;I>e.maxTextureSize&&(b=Math.ceil(I/e.maxTextureSize),I=e.maxTextureSize);const w=new Float32Array(I*b*4*h),C=new tl(w,I,b,h);C.type=Oi,C.needsUpdate=!0;const H=_*4;for(let M=0;M<h;M++){const T=g[M],k=x[M],j=y[M],Y=I*b*4*M;for(let re=0;re<T.count;re++){const $=re*H;m===!0&&(r.fromBufferAttribute(T,re),w[Y+$+0]=r.x,w[Y+$+1]=r.y,w[Y+$+2]=r.z,w[Y+$+3]=0),v===!0&&(r.fromBufferAttribute(k,re),w[Y+$+4]=r.x,w[Y+$+5]=r.y,w[Y+$+6]=r.z,w[Y+$+7]=0),f===!0&&(r.fromBufferAttribute(j,re),w[Y+$+8]=r.x,w[Y+$+9]=r.y,w[Y+$+10]=r.z,w[Y+$+11]=j.itemSize===4?r.w:1)}}d={count:h,texture:C,size:new J(I,b)},i.set(o,d),o.addEventListener("dispose",p)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)l.getUniforms().setValue(n,"morphTexture",a.morphTexture,t);else{let p=0;for(let v=0;v<c.length;v++)p+=c[v];const m=o.morphTargetsRelative?1:1-p;l.getUniforms().setValue(n,"morphTargetBaseInfluence",m),l.getUniforms().setValue(n,"morphTargetInfluences",c)}l.getUniforms().setValue(n,"morphTargetsTexture",d.texture,t),l.getUniforms().setValue(n,"morphTargetsTextureSize",d.size)}return{update:s}}function tC(n,e,t,i){let r=new WeakMap;function s(l){const c=i.render.frame,u=l.geometry,h=e.get(l,u);if(r.get(h)!==c&&(e.update(h),r.set(h,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",o)===!1&&l.addEventListener("dispose",o),r.get(l)!==c&&(t.update(l.instanceMatrix,n.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,n.ARRAY_BUFFER),r.set(l,c))),l.isSkinnedMesh){const d=l.skeleton;r.get(d)!==c&&(d.update(),r.set(d,c))}return h}function a(){r=new WeakMap}function o(l){const c=l.target;c.removeEventListener("dispose",o),t.remove(c.instanceMatrix),c.instanceColor!==null&&t.remove(c.instanceColor)}return{update:s,dispose:a}}class Us extends Wt{constructor(e,t,i,r,s,a,o,l,c,u=Xn){if(u!==Xn&&u!==qn)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&u===Xn&&(i=Nr),i===void 0&&u===qn&&(i=jn),super(null,r,s,a,o,l,u,i,c),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=o!==void 0?o:$t,this.minFilter=l!==void 0?l:$t,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}const kv=new Wt,Hv=new Us(1,1),Gv=new tl,Wv=new lu,jv=new Cs,Xv=[],qv=[],Yv=new Float32Array(16),$v=new Float32Array(9),Jv=new Float32Array(4);function Wa(n,e,t){const i=n[0];if(i<=0||i>0)return n;const r=e*t;let s=Xv[r];if(s===void 0&&(s=new Float32Array(r),Xv[r]=s),e!==0){i.toArray(s,0);for(let a=1,o=0;a!==e;++a)o+=t,n[a].toArray(s,o)}return s}function pi(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t<i;t++)if(n[t]!==e[t])return!1;return!0}function mi(n,e){for(let t=0,i=e.length;t<i;t++)n[t]=e[t]}function Lu(n,e){let t=qv[e];t===void 0&&(t=new Int32Array(e),qv[e]=t);for(let i=0;i!==e;++i)t[i]=n.allocateTextureUnit();return t}function iC(n,e){const t=this.cache;t[0]!==e&&(n.uniform1f(this.addr,e),t[0]=e)}function rC(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(pi(t,e))return;n.uniform2fv(this.addr,e),mi(t,e)}}function nC(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(n.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(pi(t,e))return;n.uniform3fv(this.addr,e),mi(t,e)}}function sC(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(pi(t,e))return;n.uniform4fv(this.addr,e),mi(t,e)}}function aC(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(pi(t,e))return;n.uniformMatrix2fv(this.addr,!1,e),mi(t,e)}else{if(pi(t,i))return;Jv.set(i),n.uniformMatrix2fv(this.addr,!1,Jv),mi(t,i)}}function oC(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(pi(t,e))return;n.uniformMatrix3fv(this.addr,!1,e),mi(t,e)}else{if(pi(t,i))return;$v.set(i),n.uniformMatrix3fv(this.addr,!1,$v),mi(t,i)}}function lC(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(pi(t,e))return;n.uniformMatrix4fv(this.addr,!1,e),mi(t,e)}else{if(pi(t,i))return;Yv.set(i),n.uniformMatrix4fv(this.addr,!1,Yv),mi(t,i)}}function cC(n,e){const t=this.cache;t[0]!==e&&(n.uniform1i(this.addr,e),t[0]=e)}function uC(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(pi(t,e))return;n.uniform2iv(this.addr,e),mi(t,e)}}function hC(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(pi(t,e))return;n.uniform3iv(this.addr,e),mi(t,e)}}function dC(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(pi(t,e))return;n.uniform4iv(this.addr,e),mi(t,e)}}function pC(n,e){const t=this.cache;t[0]!==e&&(n.uniform1ui(this.addr,e),t[0]=e)}function mC(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(pi(t,e))return;n.uniform2uiv(this.addr,e),mi(t,e)}}function fC(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(pi(t,e))return;n.uniform3uiv(this.addr,e),mi(t,e)}}function gC(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(pi(t,e))return;n.uniform4uiv(this.addr,e),mi(t,e)}}function vC(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r);let s;this.type===n.SAMPLER_2D_SHADOW?(Hv.compareFunction=mp,s=Hv):s=kv,t.setTexture2D(e||s,r)}function yC(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture3D(e||Wv,r)}function xC(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTextureCube(e||jv,r)}function _C(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture2DArray(e||Gv,r)}function MC(n){switch(n){case 5126:return iC;case 35664:return rC;case 35665:return nC;case 35666:return sC;case 35674:return aC;case 35675:return oC;case 35676:return lC;case 5124:case 35670:return cC;case 35667:case 35671:return uC;case 35668:case 35672:return hC;case 35669:case 35673:return dC;case 5125:return pC;case 36294:return mC;case 36295:return fC;case 36296:return gC;case 35678:case 36198:case 36298:case 36306:case 35682:return vC;case 35679:case 36299:case 36307:return yC;case 35680:case 36300:case 36308:case 36293:return xC;case 36289:case 36303:case 36311:case 36292:return _C}}function bC(n,e){n.uniform1fv(this.addr,e)}function TC(n,e){const t=Wa(e,this.size,2);n.uniform2fv(this.addr,t)}function SC(n,e){const t=Wa(e,this.size,3);n.uniform3fv(this.addr,t)}function wC(n,e){const t=Wa(e,this.size,4);n.uniform4fv(this.addr,t)}function EC(n,e){const t=Wa(e,this.size,4);n.uniformMatrix2fv(this.addr,!1,t)}function AC(n,e){const t=Wa(e,this.size,9);n.uniformMatrix3fv(this.addr,!1,t)}function NC(n,e){const t=Wa(e,this.size,16);n.uniformMatrix4fv(this.addr,!1,t)}function CC(n,e){n.uniform1iv(this.addr,e)}function RC(n,e){n.uniform2iv(this.addr,e)}function IC(n,e){n.uniform3iv(this.addr,e)}function LC(n,e){n.uniform4iv(this.addr,e)}function PC(n,e){n.uniform1uiv(this.addr,e)}function DC(n,e){n.uniform2uiv(this.addr,e)}function UC(n,e){n.uniform3uiv(this.addr,e)}function OC(n,e){n.uniform4uiv(this.addr,e)}function FC(n,e,t){const i=this.cache,r=e.length,s=Lu(t,r);pi(i,s)||(n.uniform1iv(this.addr,s),mi(i,s));for(let a=0;a!==r;++a)t.setTexture2D(e[a]||kv,s[a])}function VC(n,e,t){const i=this.cache,r=e.length,s=Lu(t,r);pi(i,s)||(n.uniform1iv(this.addr,s),mi(i,s));for(let a=0;a!==r;++a)t.setTexture3D(e[a]||Wv,s[a])}function BC(n,e,t){const i=this.cache,r=e.length,s=Lu(t,r);pi(i,s)||(n.uniform1iv(this.addr,s),mi(i,s));for(let a=0;a!==r;++a)t.setTextureCube(e[a]||jv,s[a])}function zC(n,e,t){const i=this.cache,r=e.length,s=Lu(t,r);pi(i,s)||(n.uniform1iv(this.addr,s),mi(i,s));for(let a=0;a!==r;++a)t.setTexture2DArray(e[a]||Gv,s[a])}function kC(n){switch(n){case 5126:return bC;case 35664:return TC;case 35665:return SC;case 35666:return wC;case 35674:return EC;case 35675:return AC;case 35676:return NC;case 5124:case 35670:return CC;case 35667:case 35671:return RC;case 35668:case 35672:return IC;case 35669:case 35673:return LC;case 5125:return PC;case 36294:return DC;case 36295:return UC;case 36296:return OC;case 35678:case 36198:case 36298:case 36306:case 35682:return FC;case 35679:case 36299:case 36307:return VC;case 35680:case 36300:case 36308:case 36293:return BC;case 36289:case 36303:case 36311:case 36292:return zC}}class HC{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.setValue=MC(t.type)}}class GC{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=kC(t.type)}}class WC{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,i){const r=this.seq;for(let s=0,a=r.length;s!==a;++s){const o=r[s];o.setValue(e,t[o.id],i)}}}const jp=/(\w+)(\])?(\[|\.)?/g;function Kv(n,e){n.seq.push(e),n.map[e.id]=e}function jC(n,e,t){const i=n.name,r=i.length;for(jp.lastIndex=0;;){const s=jp.exec(i),a=jp.lastIndex;let o=s[1];const l=s[2]==="]",c=s[3];if(l&&(o=o|0),c===void 0||c==="["&&a+2===r){Kv(t,c===void 0?new HC(o,n,e):new GC(o,n,e));break}else{let u=t.map[o];u===void 0&&(u=new WC(o),Kv(t,u)),t=u}}}class Pu{constructor(e,t){this.seq=[],this.map={};const i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let r=0;r<i;++r){const s=e.getActiveUniform(t,r),a=e.getUniformLocation(t,s.name);jC(s,a,this)}}setValue(e,t,i,r){const s=this.map[t];s!==void 0&&s.setValue(e,i,r)}setOptional(e,t,i){const r=t[i];r!==void 0&&this.setValue(e,i,r)}static upload(e,t,i,r){for(let s=0,a=t.length;s!==a;++s){const o=t[s],l=i[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,r)}}static seqWithValue(e,t){const i=[];for(let r=0,s=e.length;r!==s;++r){const a=e[r];a.id in t&&i.push(a)}return i}}function Zv(n,e,t){const i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}const XC=37297;let qC=0;function YC(n,e){const t=n.split(`
|
|
3745
|
+
`}function $N(n){let e=new WeakMap,t=null;function i(o){if(o&&o.isTexture){const l=o.mapping,c=l===zn||l===kn,u=l===fr||l===Ar;if(c||u){let h=e.get(o);const d=h!==void 0?h.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==d)return t===null&&(t=new Cu(n)),h=c?t.fromEquirectangular(o,h):t.fromCubemap(o,h),h.texture.pmremVersion=o.pmremVersion,e.set(o,h),h.texture;if(h!==void 0)return h.texture;{const p=o.image;return c&&p&&p.height>0||u&&p&&r(p)?(t=new Cu(n),h=c?t.fromEquirectangular(o):t.fromCubemap(o),h.texture.pmremVersion=o.pmremVersion,e.set(o,h),o.addEventListener("dispose",s),h.texture):null}}}return o}function r(o){let l=0;const c=6;for(let u=0;u<c;u++)o[u]!==void 0&&l++;return l===c}function s(o){const l=o.target;l.removeEventListener("dispose",s);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function a(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:i,dispose:a}}function JN(n){const e={};function t(i){if(e[i]!==void 0)return e[i];let r;switch(i){case"WEBGL_depth_texture":r=n.getExtension("WEBGL_depth_texture")||n.getExtension("MOZ_WEBGL_depth_texture")||n.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=n.getExtension("EXT_texture_filter_anisotropic")||n.getExtension("MOZ_EXT_texture_filter_anisotropic")||n.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=n.getExtension("WEBGL_compressed_texture_s3tc")||n.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||n.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=n.getExtension("WEBGL_compressed_texture_pvrtc")||n.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=n.getExtension(i)}return e[i]=r,r}return{has:function(i){return t(i)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(i){const r=t(i);return r===null&&au("THREE.WebGLRenderer: "+i+" extension not supported."),r}}}function KN(n,e,t,i){const r={},s=new WeakMap;function a(h){const d=h.target;d.index!==null&&e.remove(d.index);for(const m in d.attributes)e.remove(d.attributes[m]);for(const m in d.morphAttributes){const v=d.morphAttributes[m];for(let f=0,g=v.length;f<g;f++)e.remove(v[f])}d.removeEventListener("dispose",a),delete r[d.id];const p=s.get(d);p&&(e.remove(p),s.delete(d)),i.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,t.memory.geometries--}function o(h,d){return r[d.id]===!0||(d.addEventListener("dispose",a),r[d.id]=!0,t.memory.geometries++),d}function l(h){const d=h.attributes;for(const m in d)e.update(d[m],n.ARRAY_BUFFER);const p=h.morphAttributes;for(const m in p){const v=p[m];for(let f=0,g=v.length;f<g;f++)e.update(v[f],n.ARRAY_BUFFER)}}function c(h){const d=[],p=h.index,m=h.attributes.position;let v=0;if(p!==null){const x=p.array;v=p.version;for(let y=0,_=x.length;y<_;y+=3){const I=x[y+0],b=x[y+1],w=x[y+2];d.push(I,b,b,w,w,I)}}else if(m!==void 0){const x=m.array;v=m.version;for(let y=0,_=x.length/3-1;y<_;y+=3){const I=y+0,b=y+1,w=y+2;d.push(I,b,b,w,w,I)}}else return;const f=new(lv(d)?Pp:vu)(d,1);f.version=v;const g=s.get(h);g&&e.remove(g),s.set(h,f)}function u(h){const d=s.get(h);if(d){const p=h.index;p!==null&&d.version<p.version&&c(h)}else c(h);return s.get(h)}return{get:o,update:l,getWireframeAttribute:u}}function ZN(n,e,t){let i;function r(d){i=d}let s,a;function o(d){s=d.type,a=d.bytesPerElement}function l(d,p){n.drawElements(i,p,s,d*a),t.update(p,i,1)}function c(d,p,m){m!==0&&(n.drawElementsInstanced(i,p,s,d*a,m),t.update(p,i,m))}function u(d,p,m){if(m===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,p,0,s,d,0,m);let v=0;for(let f=0;f<m;f++)v+=p[f];t.update(v,i,1)}function h(d,p,m,v){if(m===0)return;const f=e.get("WEBGL_multi_draw");if(f===null)for(let g=0;g<d.length;g++)c(d[g]/a,p[g],v[g]);else{f.multiDrawElementsInstancedWEBGL(i,p,0,s,d,0,v,0,m);let g=0;for(let x=0;x<m;x++)g+=p[x];for(let x=0;x<v.length;x++)t.update(g,i,v[x])}}this.setMode=r,this.setIndex=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=u,this.renderMultiDrawInstances=h}function QN(n){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function i(s,a,o){switch(t.calls++,a){case n.TRIANGLES:t.triangles+=o*(s/3);break;case n.LINES:t.lines+=o*(s/2);break;case n.LINE_STRIP:t.lines+=o*(s-1);break;case n.LINE_LOOP:t.lines+=o*s;break;case n.POINTS:t.points+=o*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",a);break}}function r(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:r,update:i}}function eC(n,e,t){const i=new WeakMap,r=new st;function s(a,o,l){const c=a.morphTargetInfluences,u=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,h=u!==void 0?u.length:0;let d=i.get(o);if(d===void 0||d.count!==h){let p=function(){C.dispose(),i.delete(o),o.removeEventListener("dispose",p)};d!==void 0&&d.texture.dispose();const m=o.morphAttributes.position!==void 0,v=o.morphAttributes.normal!==void 0,f=o.morphAttributes.color!==void 0,g=o.morphAttributes.position||[],x=o.morphAttributes.normal||[],y=o.morphAttributes.color||[];let _=0;m===!0&&(_=1),v===!0&&(_=2),f===!0&&(_=3);let I=o.attributes.position.count*_,b=1;I>e.maxTextureSize&&(b=Math.ceil(I/e.maxTextureSize),I=e.maxTextureSize);const w=new Float32Array(I*b*4*h),C=new el(w,I,b,h);C.type=Oi,C.needsUpdate=!0;const H=_*4;for(let M=0;M<h;M++){const T=g[M],k=x[M],j=y[M],Y=I*b*4*M;for(let re=0;re<T.count;re++){const $=re*H;m===!0&&(r.fromBufferAttribute(T,re),w[Y+$+0]=r.x,w[Y+$+1]=r.y,w[Y+$+2]=r.z,w[Y+$+3]=0),v===!0&&(r.fromBufferAttribute(k,re),w[Y+$+4]=r.x,w[Y+$+5]=r.y,w[Y+$+6]=r.z,w[Y+$+7]=0),f===!0&&(r.fromBufferAttribute(j,re),w[Y+$+8]=r.x,w[Y+$+9]=r.y,w[Y+$+10]=r.z,w[Y+$+11]=j.itemSize===4?r.w:1)}}d={count:h,texture:C,size:new J(I,b)},i.set(o,d),o.addEventListener("dispose",p)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)l.getUniforms().setValue(n,"morphTexture",a.morphTexture,t);else{let p=0;for(let v=0;v<c.length;v++)p+=c[v];const m=o.morphTargetsRelative?1:1-p;l.getUniforms().setValue(n,"morphTargetBaseInfluence",m),l.getUniforms().setValue(n,"morphTargetInfluences",c)}l.getUniforms().setValue(n,"morphTargetsTexture",d.texture,t),l.getUniforms().setValue(n,"morphTargetsTextureSize",d.size)}return{update:s}}function tC(n,e,t,i){let r=new WeakMap;function s(l){const c=i.render.frame,u=l.geometry,h=e.get(l,u);if(r.get(h)!==c&&(e.update(h),r.set(h,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",o)===!1&&l.addEventListener("dispose",o),r.get(l)!==c&&(t.update(l.instanceMatrix,n.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,n.ARRAY_BUFFER),r.set(l,c))),l.isSkinnedMesh){const d=l.skeleton;r.get(d)!==c&&(d.update(),r.set(d,c))}return h}function a(){r=new WeakMap}function o(l){const c=l.target;c.removeEventListener("dispose",o),t.remove(c.instanceMatrix),c.instanceColor!==null&&t.remove(c.instanceColor)}return{update:s,dispose:a}}class Ds extends Wt{constructor(e,t,i,r,s,a,o,l,c,u=jn){if(u!==jn&&u!==Xn)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&u===jn&&(i=Nr),i===void 0&&u===Xn&&(i=Wn),super(null,r,s,a,o,l,u,i,c),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=o!==void 0?o:$t,this.minFilter=l!==void 0?l:$t,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}const zv=new Wt,kv=new Ds(1,1),Hv=new el,Gv=new ou,Wv=new Ns,jv=[],Xv=[],qv=new Float32Array(16),Yv=new Float32Array(9),$v=new Float32Array(4);function Ga(n,e,t){const i=n[0];if(i<=0||i>0)return n;const r=e*t;let s=jv[r];if(s===void 0&&(s=new Float32Array(r),jv[r]=s),e!==0){i.toArray(s,0);for(let a=1,o=0;a!==e;++a)o+=t,n[a].toArray(s,o)}return s}function pi(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t<i;t++)if(n[t]!==e[t])return!1;return!0}function mi(n,e){for(let t=0,i=e.length;t<i;t++)n[t]=e[t]}function Iu(n,e){let t=Xv[e];t===void 0&&(t=new Int32Array(e),Xv[e]=t);for(let i=0;i!==e;++i)t[i]=n.allocateTextureUnit();return t}function iC(n,e){const t=this.cache;t[0]!==e&&(n.uniform1f(this.addr,e),t[0]=e)}function rC(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(pi(t,e))return;n.uniform2fv(this.addr,e),mi(t,e)}}function nC(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(n.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(pi(t,e))return;n.uniform3fv(this.addr,e),mi(t,e)}}function sC(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(pi(t,e))return;n.uniform4fv(this.addr,e),mi(t,e)}}function aC(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(pi(t,e))return;n.uniformMatrix2fv(this.addr,!1,e),mi(t,e)}else{if(pi(t,i))return;$v.set(i),n.uniformMatrix2fv(this.addr,!1,$v),mi(t,i)}}function oC(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(pi(t,e))return;n.uniformMatrix3fv(this.addr,!1,e),mi(t,e)}else{if(pi(t,i))return;Yv.set(i),n.uniformMatrix3fv(this.addr,!1,Yv),mi(t,i)}}function lC(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(pi(t,e))return;n.uniformMatrix4fv(this.addr,!1,e),mi(t,e)}else{if(pi(t,i))return;qv.set(i),n.uniformMatrix4fv(this.addr,!1,qv),mi(t,i)}}function cC(n,e){const t=this.cache;t[0]!==e&&(n.uniform1i(this.addr,e),t[0]=e)}function uC(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(pi(t,e))return;n.uniform2iv(this.addr,e),mi(t,e)}}function hC(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(pi(t,e))return;n.uniform3iv(this.addr,e),mi(t,e)}}function dC(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(pi(t,e))return;n.uniform4iv(this.addr,e),mi(t,e)}}function pC(n,e){const t=this.cache;t[0]!==e&&(n.uniform1ui(this.addr,e),t[0]=e)}function mC(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(pi(t,e))return;n.uniform2uiv(this.addr,e),mi(t,e)}}function fC(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(pi(t,e))return;n.uniform3uiv(this.addr,e),mi(t,e)}}function gC(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(pi(t,e))return;n.uniform4uiv(this.addr,e),mi(t,e)}}function vC(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r);let s;this.type===n.SAMPLER_2D_SHADOW?(kv.compareFunction=pp,s=kv):s=zv,t.setTexture2D(e||s,r)}function yC(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture3D(e||Gv,r)}function xC(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTextureCube(e||Wv,r)}function _C(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture2DArray(e||Hv,r)}function MC(n){switch(n){case 5126:return iC;case 35664:return rC;case 35665:return nC;case 35666:return sC;case 35674:return aC;case 35675:return oC;case 35676:return lC;case 5124:case 35670:return cC;case 35667:case 35671:return uC;case 35668:case 35672:return hC;case 35669:case 35673:return dC;case 5125:return pC;case 36294:return mC;case 36295:return fC;case 36296:return gC;case 35678:case 36198:case 36298:case 36306:case 35682:return vC;case 35679:case 36299:case 36307:return yC;case 35680:case 36300:case 36308:case 36293:return xC;case 36289:case 36303:case 36311:case 36292:return _C}}function bC(n,e){n.uniform1fv(this.addr,e)}function TC(n,e){const t=Ga(e,this.size,2);n.uniform2fv(this.addr,t)}function SC(n,e){const t=Ga(e,this.size,3);n.uniform3fv(this.addr,t)}function wC(n,e){const t=Ga(e,this.size,4);n.uniform4fv(this.addr,t)}function EC(n,e){const t=Ga(e,this.size,4);n.uniformMatrix2fv(this.addr,!1,t)}function AC(n,e){const t=Ga(e,this.size,9);n.uniformMatrix3fv(this.addr,!1,t)}function NC(n,e){const t=Ga(e,this.size,16);n.uniformMatrix4fv(this.addr,!1,t)}function CC(n,e){n.uniform1iv(this.addr,e)}function RC(n,e){n.uniform2iv(this.addr,e)}function IC(n,e){n.uniform3iv(this.addr,e)}function LC(n,e){n.uniform4iv(this.addr,e)}function PC(n,e){n.uniform1uiv(this.addr,e)}function DC(n,e){n.uniform2uiv(this.addr,e)}function UC(n,e){n.uniform3uiv(this.addr,e)}function OC(n,e){n.uniform4uiv(this.addr,e)}function FC(n,e,t){const i=this.cache,r=e.length,s=Iu(t,r);pi(i,s)||(n.uniform1iv(this.addr,s),mi(i,s));for(let a=0;a!==r;++a)t.setTexture2D(e[a]||zv,s[a])}function VC(n,e,t){const i=this.cache,r=e.length,s=Iu(t,r);pi(i,s)||(n.uniform1iv(this.addr,s),mi(i,s));for(let a=0;a!==r;++a)t.setTexture3D(e[a]||Gv,s[a])}function BC(n,e,t){const i=this.cache,r=e.length,s=Iu(t,r);pi(i,s)||(n.uniform1iv(this.addr,s),mi(i,s));for(let a=0;a!==r;++a)t.setTextureCube(e[a]||Wv,s[a])}function zC(n,e,t){const i=this.cache,r=e.length,s=Iu(t,r);pi(i,s)||(n.uniform1iv(this.addr,s),mi(i,s));for(let a=0;a!==r;++a)t.setTexture2DArray(e[a]||Hv,s[a])}function kC(n){switch(n){case 5126:return bC;case 35664:return TC;case 35665:return SC;case 35666:return wC;case 35674:return EC;case 35675:return AC;case 35676:return NC;case 5124:case 35670:return CC;case 35667:case 35671:return RC;case 35668:case 35672:return IC;case 35669:case 35673:return LC;case 5125:return PC;case 36294:return DC;case 36295:return UC;case 36296:return OC;case 35678:case 36198:case 36298:case 36306:case 35682:return FC;case 35679:case 36299:case 36307:return VC;case 35680:case 36300:case 36308:case 36293:return BC;case 36289:case 36303:case 36311:case 36292:return zC}}class HC{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.setValue=MC(t.type)}}class GC{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=kC(t.type)}}class WC{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,i){const r=this.seq;for(let s=0,a=r.length;s!==a;++s){const o=r[s];o.setValue(e,t[o.id],i)}}}const Wp=/(\w+)(\])?(\[|\.)?/g;function Jv(n,e){n.seq.push(e),n.map[e.id]=e}function jC(n,e,t){const i=n.name,r=i.length;for(Wp.lastIndex=0;;){const s=Wp.exec(i),a=Wp.lastIndex;let o=s[1];const l=s[2]==="]",c=s[3];if(l&&(o=o|0),c===void 0||c==="["&&a+2===r){Jv(t,c===void 0?new HC(o,n,e):new GC(o,n,e));break}else{let u=t.map[o];u===void 0&&(u=new WC(o),Jv(t,u)),t=u}}}class Lu{constructor(e,t){this.seq=[],this.map={};const i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let r=0;r<i;++r){const s=e.getActiveUniform(t,r),a=e.getUniformLocation(t,s.name);jC(s,a,this)}}setValue(e,t,i,r){const s=this.map[t];s!==void 0&&s.setValue(e,i,r)}setOptional(e,t,i){const r=t[i];r!==void 0&&this.setValue(e,i,r)}static upload(e,t,i,r){for(let s=0,a=t.length;s!==a;++s){const o=t[s],l=i[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,r)}}static seqWithValue(e,t){const i=[];for(let r=0,s=e.length;r!==s;++r){const a=e[r];a.id in t&&i.push(a)}return i}}function Kv(n,e,t){const i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}const XC=37297;let qC=0;function YC(n,e){const t=n.split(`
|
|
3746
3746
|
`),i=[],r=Math.max(e-6,0),s=Math.min(e+6,t.length);for(let a=r;a<s;a++){const o=a+1;i.push(`${o===e?">":" "} ${o}: ${t[a]}`)}return i.join(`
|
|
3747
|
-
`)}function $C(n){const e=vt.getPrimaries(vt.workingColorSpace),t=vt.getPrimaries(n);let i;switch(e===t?i="":e===
|
|
3747
|
+
`)}function $C(n){const e=vt.getPrimaries(vt.workingColorSpace),t=vt.getPrimaries(n);let i;switch(e===t?i="":e===Jo&&t===$o?i="LinearDisplayP3ToLinearSRGB":e===$o&&t===Jo&&(i="LinearSRGBToLinearDisplayP3"),n){case nr:case ba:return[i,"LinearTransferOETF"];case Fi:case qo:return[i,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",n),[i,"LinearTransferOETF"]}}function Zv(n,e,t){const i=n.getShaderParameter(e,n.COMPILE_STATUS),r=n.getShaderInfoLog(e).trim();if(i&&r==="")return"";const s=/ERROR: 0:(\d+)/.exec(r);if(s){const a=parseInt(s[1]);return t.toUpperCase()+`
|
|
3748
3748
|
|
|
3749
3749
|
`+r+`
|
|
3750
3750
|
|
|
3751
|
-
`+YC(n.getShaderSource(e),a)}else return r}function JC(n,e){const t=$C(e);return`vec4 ${n}( vec4 value ) { return ${t[0]}( ${t[1]}( value ) ); }`}function KC(n,e){let t;switch(e){case
|
|
3752
|
-
`)}function QC(n){return[n.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",n.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(
|
|
3751
|
+
`+YC(n.getShaderSource(e),a)}else return r}function JC(n,e){const t=$C(e);return`vec4 ${n}( vec4 value ) { return ${t[0]}( ${t[1]}( value ) ); }`}function KC(n,e){let t;switch(e){case wc:t="Linear";break;case Ec:t="Reinhard";break;case Jd:t="Cineon";break;case Ac:t="ACESFilmic";break;case Nc:t="AgX";break;case Cc:t="Neutral";break;case D0:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+n+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const Pu=new N;function ZC(){vt.getLuminanceCoefficients(Pu);const n=Pu.x.toFixed(4),e=Pu.y.toFixed(4),t=Pu.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${n}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
|
|
3752
|
+
`)}function QC(n){return[n.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",n.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(ll).join(`
|
|
3753
3753
|
`)}function eR(n){const e=[];for(const t in n){const i=n[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(`
|
|
3754
|
-
`)}function tR(n,e){const t={},i=n.getProgramParameter(e,n.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){const s=n.getActiveAttrib(e,r),a=s.name;let o=1;s.type===n.FLOAT_MAT2&&(o=2),s.type===n.FLOAT_MAT3&&(o=3),s.type===n.FLOAT_MAT4&&(o=4),t[a]={type:s.type,location:n.getAttribLocation(e,a),locationSize:o}}return t}function
|
|
3754
|
+
`)}function tR(n,e){const t={},i=n.getProgramParameter(e,n.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){const s=n.getActiveAttrib(e,r),a=s.name;let o=1;s.type===n.FLOAT_MAT2&&(o=2),s.type===n.FLOAT_MAT3&&(o=3),s.type===n.FLOAT_MAT4&&(o=4),t[a]={type:s.type,location:n.getAttribLocation(e,a),locationSize:o}}return t}function ll(n){return n!==""}function Qv(n,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return n.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function ey(n,e){return n.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const iR=/^[ \t]*#include +<([\w\d./]+)>/gm;function jp(n){return n.replace(iR,nR)}const rR=new Map;function nR(n,e){let t=dt[e];if(t===void 0){const i=rR.get(e);if(i!==void 0)t=dt[i],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("Can not resolve #include <"+e+">")}return jp(t)}const sR=/#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 ty(n){return n.replace(sR,aR)}function aR(n,e,t,i){let r="";for(let s=parseInt(e);s<parseInt(t);s++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function iy(n){let e=`precision ${n.precision} float;
|
|
3755
3755
|
precision ${n.precision} int;
|
|
3756
3756
|
precision ${n.precision} sampler2D;
|
|
3757
3757
|
precision ${n.precision} samplerCube;
|
|
@@ -3771,28 +3771,28 @@ void main() {
|
|
|
3771
3771
|
`;return n.precision==="highp"?e+=`
|
|
3772
3772
|
#define HIGH_PRECISION`:n.precision==="mediump"?e+=`
|
|
3773
3773
|
#define MEDIUM_PRECISION`:n.precision==="lowp"&&(e+=`
|
|
3774
|
-
#define LOW_PRECISION`),e}function oR(n){let e="SHADOWMAP_TYPE_BASIC";return n.shadowMapType===
|
|
3775
|
-
`:"";t.isRawShaderMaterial?(f=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m].filter(
|
|
3774
|
+
#define LOW_PRECISION`),e}function oR(n){let e="SHADOWMAP_TYPE_BASIC";return n.shadowMapType===Hd?e="SHADOWMAP_TYPE_PCF":n.shadowMapType===Gd?e="SHADOWMAP_TYPE_PCF_SOFT":n.shadowMapType===rr&&(e="SHADOWMAP_TYPE_VSM"),e}function lR(n){let e="ENVMAP_TYPE_CUBE";if(n.envMap)switch(n.envMapMode){case fr:case Ar:e="ENVMAP_TYPE_CUBE";break;case ys:e="ENVMAP_TYPE_CUBE_UV";break}return e}function cR(n){let e="ENVMAP_MODE_REFLECTION";if(n.envMap)switch(n.envMapMode){case Ar:e="ENVMAP_MODE_REFRACTION";break}return e}function uR(n){let e="ENVMAP_BLENDING_NONE";if(n.envMap)switch(n.combine){case pa:e="ENVMAP_BLENDING_MULTIPLY";break;case Yd:e="ENVMAP_BLENDING_MIX";break;case $d:e="ENVMAP_BLENDING_ADD";break}return e}function hR(n){const e=n.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,i=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:i,maxMip:t}}function dR(n,e,t,i){const r=n.getContext(),s=t.defines;let a=t.vertexShader,o=t.fragmentShader;const l=oR(t),c=lR(t),u=cR(t),h=uR(t),d=hR(t),p=QC(t),m=eR(s),v=r.createProgram();let f,g,x=t.glslVersion?"#version "+t.glslVersion+`
|
|
3775
|
+
`:"";t.isRawShaderMaterial?(f=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m].filter(ll).join(`
|
|
3776
3776
|
`),f.length>0&&(f+=`
|
|
3777
|
-
`),g=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m].filter(
|
|
3777
|
+
`),g=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m].filter(ll).join(`
|
|
3778
3778
|
`),g.length>0&&(g+=`
|
|
3779
|
-
`)):(f=[
|
|
3780
|
-
`].filter(
|
|
3781
|
-
`),g=[
|
|
3782
|
-
`].filter(
|
|
3783
|
-
`)),a=
|
|
3779
|
+
`)):(f=[iy(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+u:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
|
|
3780
|
+
`].filter(ll).join(`
|
|
3781
|
+
`),g=[iy(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+u:"",t.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":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor||t.batchingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==mr?"#define TONE_MAPPING":"",t.toneMapping!==mr?dt.tonemapping_pars_fragment:"",t.toneMapping!==mr?KC("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",dt.colorspace_pars_fragment,JC("linearToOutputTexel",t.outputColorSpace),ZC(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
|
|
3782
|
+
`].filter(ll).join(`
|
|
3783
|
+
`)),a=jp(a),a=Qv(a,t),a=ey(a,t),o=jp(o),o=Qv(o,t),o=ey(o,t),a=ty(a),o=ty(o),t.isRawShaderMaterial!==!0&&(x=`#version 300 es
|
|
3784
3784
|
`,f=[p,"#define attribute in","#define varying out","#define texture2D texture"].join(`
|
|
3785
3785
|
`)+`
|
|
3786
|
-
`+f,g=["#define varying in",t.glslVersion===
|
|
3786
|
+
`+f,g=["#define varying in",t.glslVersion===nu?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===nu?"":"#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(`
|
|
3787
3787
|
`)+`
|
|
3788
|
-
`+g);const y=x+f+a,_=x+g+o,I=
|
|
3788
|
+
`+g);const y=x+f+a,_=x+g+o,I=Kv(r,r.VERTEX_SHADER,y),b=Kv(r,r.FRAGMENT_SHADER,_);r.attachShader(v,I),r.attachShader(v,b),t.index0AttributeName!==void 0?r.bindAttribLocation(v,0,t.index0AttributeName):t.morphTargets===!0&&r.bindAttribLocation(v,0,"position"),r.linkProgram(v);function w(T){if(n.debug.checkShaderErrors){const k=r.getProgramInfoLog(v).trim(),j=r.getShaderInfoLog(I).trim(),Y=r.getShaderInfoLog(b).trim();let re=!0,$=!0;if(r.getProgramParameter(v,r.LINK_STATUS)===!1)if(re=!1,typeof n.debug.onShaderError=="function")n.debug.onShaderError(r,v,I,b);else{const he=Zv(r,I,"vertex"),Q=Zv(r,b,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(v,r.VALIDATE_STATUS)+`
|
|
3789
3789
|
|
|
3790
3790
|
Material Name: `+T.name+`
|
|
3791
3791
|
Material Type: `+T.type+`
|
|
3792
3792
|
|
|
3793
3793
|
Program Info Log: `+k+`
|
|
3794
3794
|
`+he+`
|
|
3795
|
-
`+Q)}else k!==""?console.warn("THREE.WebGLProgram: Program Info Log:",k):(j===""||Y==="")&&($=!1);$&&(T.diagnostics={runnable:re,programLog:k,vertexShader:{log:j,prefix:f},fragmentShader:{log:Y,prefix:g}})}r.deleteShader(I),r.deleteShader(b),C=new Pu(r,v),H=tR(r,v)}let C;this.getUniforms=function(){return C===void 0&&w(this),C};let H;this.getAttributes=function(){return H===void 0&&w(this),H};let M=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return M===!1&&(M=r.getProgramParameter(v,XC)),M},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(v),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=qC++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=I,this.fragmentShader=b,this}let pR=0;class mR{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,i=e.fragmentShader,r=this._getShaderStage(t),s=this._getShaderStage(i),a=this._getShaderCacheForMaterial(e);return a.has(r)===!1&&(a.add(r),r.usedTimes++),a.has(s)===!1&&(a.add(s),s.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){const t=this.shaderCache;let i=t.get(e);return i===void 0&&(i=new fR(e),t.set(e,i)),i}}class fR{constructor(e){this.id=pR++,this.code=e,this.usedTimes=0}}function gR(n,e,t,i,r,s,a){const o=new nl,l=new mR,c=new Set,u=[],h=r.logarithmicDepthBuffer,d=r.reverseDepthBuffer,p=r.vertexTextures;let m=r.precision;const v={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 f(M){return c.add(M),M===0?"uv":`uv${M}`}function g(M,T,k,j,Y){const re=j.fog,$=Y.geometry,he=M.isMeshStandardMaterial?j.environment:null,Q=(M.isMeshStandardMaterial?t:e).get(M.envMap||he),ye=Q&&Q.mapping===xs?Q.image.height:null,be=v[M.type];M.precision!==null&&(m=r.getMaxPrecision(M.precision),m!==M.precision&&console.warn("THREE.WebGLProgram.getParameters:",M.precision,"not supported, using",m,"instead."));const Ve=$.morphAttributes.position||$.morphAttributes.normal||$.morphAttributes.color,at=Ve!==void 0?Ve.length:0;let et=0;$.morphAttributes.position!==void 0&&(et=1),$.morphAttributes.normal!==void 0&&(et=2),$.morphAttributes.color!==void 0&&(et=3);let ie,le,Te,Se;if(be){const ir=Dr[be];ie=ir.vertexShader,le=ir.fragmentShader}else ie=M.vertexShader,le=M.fragmentShader,l.update(M),Te=l.getVertexShaderID(M),Se=l.getFragmentShaderID(M);const Ye=n.getRenderTarget(),We=Y.isInstancedMesh===!0,ot=Y.isBatchedMesh===!0,ce=!!M.map,ue=!!M.matcap,L=!!Q,He=!!M.aoMap,pe=!!M.lightMap,Ue=!!M.bumpMap,we=!!M.normalMap,$e=!!M.displacementMap,Be=!!M.emissiveMap,R=!!M.metalnessMap,S=!!M.roughnessMap,W=M.anisotropy>0,ne=M.clearcoat>0,de=M.dispersion>0,se=M.iridescence>0,ke=M.sheen>0,Ee=M.transmission>0,Pe=W&&!!M.anisotropyMap,mt=ne&&!!M.clearcoatMap,ve=ne&&!!M.clearcoatNormalMap,ze=ne&&!!M.clearcoatRoughnessMap,tt=se&&!!M.iridescenceMap,it=se&&!!M.iridescenceThicknessMap,Oe=ke&&!!M.sheenColorMap,Mt=ke&&!!M.sheenRoughnessMap,ut=!!M.specularMap,Dt=!!M.specularColorMap,O=!!M.specularIntensityMap,Ce=Ee&&!!M.transmissionMap,ee=Ee&&!!M.thicknessMap,oe=!!M.gradientMap,Ne=!!M.alphaMap,Ae=M.alphaTest>0,Ut=!!M.alphaHash,ni=!!M.extensions;let tr=mr;M.toneMapped&&(Ye===null||Ye.isXRRenderTarget===!0)&&(tr=n.toneMapping);const At={shaderID:be,shaderType:M.type,shaderName:M.name,vertexShader:ie,fragmentShader:le,defines:M.defines,customVertexShaderID:Te,customFragmentShaderID:Se,isRawShaderMaterial:M.isRawShaderMaterial===!0,glslVersion:M.glslVersion,precision:m,batching:ot,batchingColor:ot&&Y._colorsTexture!==null,instancing:We,instancingColor:We&&Y.instanceColor!==null,instancingMorph:We&&Y.morphTexture!==null,supportsVertexTextures:p,outputColorSpace:Ye===null?n.outputColorSpace:Ye.isXRRenderTarget===!0?Ye.texture.colorSpace:nr,alphaToCoverage:!!M.alphaToCoverage,map:ce,matcap:ue,envMap:L,envMapMode:L&&Q.mapping,envMapCubeUVHeight:ye,aoMap:He,lightMap:pe,bumpMap:Ue,normalMap:we,displacementMap:p&&$e,emissiveMap:Be,normalMapObjectSpace:we&&M.normalMapType===dp,normalMapTangentSpace:we&&M.normalMapType===on,metalnessMap:R,roughnessMap:S,anisotropy:W,anisotropyMap:Pe,clearcoat:ne,clearcoatMap:mt,clearcoatNormalMap:ve,clearcoatRoughnessMap:ze,dispersion:de,iridescence:se,iridescenceMap:tt,iridescenceThicknessMap:it,sheen:ke,sheenColorMap:Oe,sheenRoughnessMap:Mt,specularMap:ut,specularColorMap:Dt,specularIntensityMap:O,transmission:Ee,transmissionMap:Ce,thicknessMap:ee,gradientMap:oe,opaque:M.transparent===!1&&M.blending===_n&&M.alphaToCoverage===!1,alphaMap:Ne,alphaTest:Ae,alphaHash:Ut,combine:M.combine,mapUv:ce&&f(M.map.channel),aoMapUv:He&&f(M.aoMap.channel),lightMapUv:pe&&f(M.lightMap.channel),bumpMapUv:Ue&&f(M.bumpMap.channel),normalMapUv:we&&f(M.normalMap.channel),displacementMapUv:$e&&f(M.displacementMap.channel),emissiveMapUv:Be&&f(M.emissiveMap.channel),metalnessMapUv:R&&f(M.metalnessMap.channel),roughnessMapUv:S&&f(M.roughnessMap.channel),anisotropyMapUv:Pe&&f(M.anisotropyMap.channel),clearcoatMapUv:mt&&f(M.clearcoatMap.channel),clearcoatNormalMapUv:ve&&f(M.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ze&&f(M.clearcoatRoughnessMap.channel),iridescenceMapUv:tt&&f(M.iridescenceMap.channel),iridescenceThicknessMapUv:it&&f(M.iridescenceThicknessMap.channel),sheenColorMapUv:Oe&&f(M.sheenColorMap.channel),sheenRoughnessMapUv:Mt&&f(M.sheenRoughnessMap.channel),specularMapUv:ut&&f(M.specularMap.channel),specularColorMapUv:Dt&&f(M.specularColorMap.channel),specularIntensityMapUv:O&&f(M.specularIntensityMap.channel),transmissionMapUv:Ce&&f(M.transmissionMap.channel),thicknessMapUv:ee&&f(M.thicknessMap.channel),alphaMapUv:Ne&&f(M.alphaMap.channel),vertexTangents:!!$.attributes.tangent&&(we||W),vertexColors:M.vertexColors,vertexAlphas:M.vertexColors===!0&&!!$.attributes.color&&$.attributes.color.itemSize===4,pointsUvs:Y.isPoints===!0&&!!$.attributes.uv&&(ce||Ne),fog:!!re,useFog:M.fog===!0,fogExp2:!!re&&re.isFogExp2,flatShading:M.flatShading===!0,sizeAttenuation:M.sizeAttenuation===!0,logarithmicDepthBuffer:h,reverseDepthBuffer:d,skinning:Y.isSkinnedMesh===!0,morphTargets:$.morphAttributes.position!==void 0,morphNormals:$.morphAttributes.normal!==void 0,morphColors:$.morphAttributes.color!==void 0,morphTargetsCount:at,morphTextureStride:et,numDirLights:T.directional.length,numPointLights:T.point.length,numSpotLights:T.spot.length,numSpotLightMaps:T.spotLightMap.length,numRectAreaLights:T.rectArea.length,numHemiLights:T.hemi.length,numDirLightShadows:T.directionalShadowMap.length,numPointLightShadows:T.pointShadowMap.length,numSpotLightShadows:T.spotShadowMap.length,numSpotLightShadowsWithMaps:T.numSpotLightShadowsWithMaps,numLightProbes:T.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:M.dithering,shadowMapEnabled:n.shadowMap.enabled&&k.length>0,shadowMapType:n.shadowMap.type,toneMapping:tr,decodeVideoTexture:ce&&M.map.isVideoTexture===!0&&vt.getTransfer(M.map.colorSpace)===Ot,premultipliedAlpha:M.premultipliedAlpha,doubleSided:M.side===Gr,flipSided:M.side===si,useDepthPacking:M.depthPacking>=0,depthPacking:M.depthPacking||0,index0AttributeName:M.index0AttributeName,extensionClipCullDistance:ni&&M.extensions.clipCullDistance===!0&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ni&&M.extensions.multiDraw===!0||ot)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:M.customProgramCacheKey()};return At.vertexUv1s=c.has(1),At.vertexUv2s=c.has(2),At.vertexUv3s=c.has(3),c.clear(),At}function x(M){const T=[];if(M.shaderID?T.push(M.shaderID):(T.push(M.customVertexShaderID),T.push(M.customFragmentShaderID)),M.defines!==void 0)for(const k in M.defines)T.push(k),T.push(M.defines[k]);return M.isRawShaderMaterial===!1&&(y(T,M),_(T,M),T.push(n.outputColorSpace)),T.push(M.customProgramCacheKey),T.join()}function y(M,T){M.push(T.precision),M.push(T.outputColorSpace),M.push(T.envMapMode),M.push(T.envMapCubeUVHeight),M.push(T.mapUv),M.push(T.alphaMapUv),M.push(T.lightMapUv),M.push(T.aoMapUv),M.push(T.bumpMapUv),M.push(T.normalMapUv),M.push(T.displacementMapUv),M.push(T.emissiveMapUv),M.push(T.metalnessMapUv),M.push(T.roughnessMapUv),M.push(T.anisotropyMapUv),M.push(T.clearcoatMapUv),M.push(T.clearcoatNormalMapUv),M.push(T.clearcoatRoughnessMapUv),M.push(T.iridescenceMapUv),M.push(T.iridescenceThicknessMapUv),M.push(T.sheenColorMapUv),M.push(T.sheenRoughnessMapUv),M.push(T.specularMapUv),M.push(T.specularColorMapUv),M.push(T.specularIntensityMapUv),M.push(T.transmissionMapUv),M.push(T.thicknessMapUv),M.push(T.combine),M.push(T.fogExp2),M.push(T.sizeAttenuation),M.push(T.morphTargetsCount),M.push(T.morphAttributeCount),M.push(T.numDirLights),M.push(T.numPointLights),M.push(T.numSpotLights),M.push(T.numSpotLightMaps),M.push(T.numHemiLights),M.push(T.numRectAreaLights),M.push(T.numDirLightShadows),M.push(T.numPointLightShadows),M.push(T.numSpotLightShadows),M.push(T.numSpotLightShadowsWithMaps),M.push(T.numLightProbes),M.push(T.shadowMapType),M.push(T.toneMapping),M.push(T.numClippingPlanes),M.push(T.numClipIntersection),M.push(T.depthPacking)}function _(M,T){o.disableAll(),T.supportsVertexTextures&&o.enable(0),T.instancing&&o.enable(1),T.instancingColor&&o.enable(2),T.instancingMorph&&o.enable(3),T.matcap&&o.enable(4),T.envMap&&o.enable(5),T.normalMapObjectSpace&&o.enable(6),T.normalMapTangentSpace&&o.enable(7),T.clearcoat&&o.enable(8),T.iridescence&&o.enable(9),T.alphaTest&&o.enable(10),T.vertexColors&&o.enable(11),T.vertexAlphas&&o.enable(12),T.vertexUv1s&&o.enable(13),T.vertexUv2s&&o.enable(14),T.vertexUv3s&&o.enable(15),T.vertexTangents&&o.enable(16),T.anisotropy&&o.enable(17),T.alphaHash&&o.enable(18),T.batching&&o.enable(19),T.dispersion&&o.enable(20),T.batchingColor&&o.enable(21),M.push(o.mask),o.disableAll(),T.fog&&o.enable(0),T.useFog&&o.enable(1),T.flatShading&&o.enable(2),T.logarithmicDepthBuffer&&o.enable(3),T.reverseDepthBuffer&&o.enable(4),T.skinning&&o.enable(5),T.morphTargets&&o.enable(6),T.morphNormals&&o.enable(7),T.morphColors&&o.enable(8),T.premultipliedAlpha&&o.enable(9),T.shadowMapEnabled&&o.enable(10),T.doubleSided&&o.enable(11),T.flipSided&&o.enable(12),T.useDepthPacking&&o.enable(13),T.dithering&&o.enable(14),T.transmission&&o.enable(15),T.sheen&&o.enable(16),T.opaque&&o.enable(17),T.pointsUvs&&o.enable(18),T.decodeVideoTexture&&o.enable(19),T.alphaToCoverage&&o.enable(20),M.push(o.mask)}function I(M){const T=v[M.type];let k;if(T){const j=Dr[T];k=Fp.clone(j.uniforms)}else k=M.uniforms;return k}function b(M,T){let k;for(let j=0,Y=u.length;j<Y;j++){const re=u[j];if(re.cacheKey===T){k=re,++k.usedTimes;break}}return k===void 0&&(k=new dR(n,T,M,s),u.push(k)),k}function w(M){if(--M.usedTimes===0){const T=u.indexOf(M);u[T]=u[u.length-1],u.pop(),M.destroy()}}function C(M){l.remove(M)}function H(){l.dispose()}return{getParameters:g,getProgramCacheKey:x,getUniforms:I,acquireProgram:b,releaseProgram:w,releaseShaderCache:C,programs:u,dispose:H}}function vR(){let n=new WeakMap;function e(a){return n.has(a)}function t(a){let o=n.get(a);return o===void 0&&(o={},n.set(a,o)),o}function i(a){n.delete(a)}function r(a,o,l){n.get(a)[o]=l}function s(){n=new WeakMap}return{has:e,get:t,remove:i,update:r,dispose:s}}function yR(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.material.id!==e.material.id?n.material.id-e.material.id:n.z!==e.z?n.z-e.z:n.id-e.id}function ny(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.z!==e.z?e.z-n.z:n.id-e.id}function sy(){const n=[];let e=0;const t=[],i=[],r=[];function s(){e=0,t.length=0,i.length=0,r.length=0}function a(h,d,p,m,v,f){let g=n[e];return g===void 0?(g={id:h.id,object:h,geometry:d,material:p,groupOrder:m,renderOrder:h.renderOrder,z:v,group:f},n[e]=g):(g.id=h.id,g.object=h,g.geometry=d,g.material=p,g.groupOrder=m,g.renderOrder=h.renderOrder,g.z=v,g.group=f),e++,g}function o(h,d,p,m,v,f){const g=a(h,d,p,m,v,f);p.transmission>0?i.push(g):p.transparent===!0?r.push(g):t.push(g)}function l(h,d,p,m,v,f){const g=a(h,d,p,m,v,f);p.transmission>0?i.unshift(g):p.transparent===!0?r.unshift(g):t.unshift(g)}function c(h,d){t.length>1&&t.sort(h||yR),i.length>1&&i.sort(d||ny),r.length>1&&r.sort(d||ny)}function u(){for(let h=e,d=n.length;h<d;h++){const p=n[h];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:t,transmissive:i,transparent:r,init:s,push:o,unshift:l,finish:u,sort:c}}function xR(){let n=new WeakMap;function e(i,r){const s=n.get(i);let a;return s===void 0?(a=new sy,n.set(i,[a])):r>=s.length?(a=new sy,s.push(a)):a=s[r],a}function t(){n=new WeakMap}return{get:e,dispose:t}}function _R(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new N,color:new xe};break;case"SpotLight":t={position:new N,direction:new N,color:new xe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new N,color:new xe,distance:0,decay:0};break;case"HemisphereLight":t={direction:new N,skyColor:new xe,groundColor:new xe};break;case"RectAreaLight":t={color:new xe,position:new N,halfWidth:new N,halfHeight:new N};break}return n[e.id]=t,t}}}function MR(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new J};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new J};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new J,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}let bR=0;function TR(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function SR(n){const e=new _R,t=MR(),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 c=0;c<9;c++)i.probe.push(new N);const r=new N,s=new Re,a=new Re;function o(c){let u=0,h=0,d=0;for(let H=0;H<9;H++)i.probe[H].set(0,0,0);let p=0,m=0,v=0,f=0,g=0,x=0,y=0,_=0,I=0,b=0,w=0;c.sort(TR);for(let H=0,M=c.length;H<M;H++){const T=c[H],k=T.color,j=T.intensity,Y=T.distance,re=T.shadow&&T.shadow.map?T.shadow.map.texture:null;if(T.isAmbientLight)u+=k.r*j,h+=k.g*j,d+=k.b*j;else if(T.isLightProbe){for(let $=0;$<9;$++)i.probe[$].addScaledVector(T.sh.coefficients[$],j);w++}else if(T.isDirectionalLight){const $=e.get(T);if($.color.copy(T.color).multiplyScalar(T.intensity),T.castShadow){const he=T.shadow,Q=t.get(T);Q.shadowIntensity=he.intensity,Q.shadowBias=he.bias,Q.shadowNormalBias=he.normalBias,Q.shadowRadius=he.radius,Q.shadowMapSize=he.mapSize,i.directionalShadow[p]=Q,i.directionalShadowMap[p]=re,i.directionalShadowMatrix[p]=T.shadow.matrix,x++}i.directional[p]=$,p++}else if(T.isSpotLight){const $=e.get(T);$.position.setFromMatrixPosition(T.matrixWorld),$.color.copy(k).multiplyScalar(j),$.distance=Y,$.coneCos=Math.cos(T.angle),$.penumbraCos=Math.cos(T.angle*(1-T.penumbra)),$.decay=T.decay,i.spot[v]=$;const he=T.shadow;if(T.map&&(i.spotLightMap[I]=T.map,I++,he.updateMatrices(T),T.castShadow&&b++),i.spotLightMatrix[v]=he.matrix,T.castShadow){const Q=t.get(T);Q.shadowIntensity=he.intensity,Q.shadowBias=he.bias,Q.shadowNormalBias=he.normalBias,Q.shadowRadius=he.radius,Q.shadowMapSize=he.mapSize,i.spotShadow[v]=Q,i.spotShadowMap[v]=re,_++}v++}else if(T.isRectAreaLight){const $=e.get(T);$.color.copy(k).multiplyScalar(j),$.halfWidth.set(T.width*.5,0,0),$.halfHeight.set(0,T.height*.5,0),i.rectArea[f]=$,f++}else if(T.isPointLight){const $=e.get(T);if($.color.copy(T.color).multiplyScalar(T.intensity),$.distance=T.distance,$.decay=T.decay,T.castShadow){const he=T.shadow,Q=t.get(T);Q.shadowIntensity=he.intensity,Q.shadowBias=he.bias,Q.shadowNormalBias=he.normalBias,Q.shadowRadius=he.radius,Q.shadowMapSize=he.mapSize,Q.shadowCameraNear=he.camera.near,Q.shadowCameraFar=he.camera.far,i.pointShadow[m]=Q,i.pointShadowMap[m]=re,i.pointShadowMatrix[m]=T.shadow.matrix,y++}i.point[m]=$,m++}else if(T.isHemisphereLight){const $=e.get(T);$.skyColor.copy(T.color).multiplyScalar(j),$.groundColor.copy(T.groundColor).multiplyScalar(j),i.hemi[g]=$,g++}}f>0&&(n.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=Me.LTC_FLOAT_1,i.rectAreaLTC2=Me.LTC_FLOAT_2):(i.rectAreaLTC1=Me.LTC_HALF_1,i.rectAreaLTC2=Me.LTC_HALF_2)),i.ambient[0]=u,i.ambient[1]=h,i.ambient[2]=d;const C=i.hash;(C.directionalLength!==p||C.pointLength!==m||C.spotLength!==v||C.rectAreaLength!==f||C.hemiLength!==g||C.numDirectionalShadows!==x||C.numPointShadows!==y||C.numSpotShadows!==_||C.numSpotMaps!==I||C.numLightProbes!==w)&&(i.directional.length=p,i.spot.length=v,i.rectArea.length=f,i.point.length=m,i.hemi.length=g,i.directionalShadow.length=x,i.directionalShadowMap.length=x,i.pointShadow.length=y,i.pointShadowMap.length=y,i.spotShadow.length=_,i.spotShadowMap.length=_,i.directionalShadowMatrix.length=x,i.pointShadowMatrix.length=y,i.spotLightMatrix.length=_+I-b,i.spotLightMap.length=I,i.numSpotLightShadowsWithMaps=b,i.numLightProbes=w,C.directionalLength=p,C.pointLength=m,C.spotLength=v,C.rectAreaLength=f,C.hemiLength=g,C.numDirectionalShadows=x,C.numPointShadows=y,C.numSpotShadows=_,C.numSpotMaps=I,C.numLightProbes=w,i.version=bR++)}function l(c,u){let h=0,d=0,p=0,m=0,v=0;const f=u.matrixWorldInverse;for(let g=0,x=c.length;g<x;g++){const y=c[g];if(y.isDirectionalLight){const _=i.directional[h];_.direction.setFromMatrixPosition(y.matrixWorld),r.setFromMatrixPosition(y.target.matrixWorld),_.direction.sub(r),_.direction.transformDirection(f),h++}else if(y.isSpotLight){const _=i.spot[p];_.position.setFromMatrixPosition(y.matrixWorld),_.position.applyMatrix4(f),_.direction.setFromMatrixPosition(y.matrixWorld),r.setFromMatrixPosition(y.target.matrixWorld),_.direction.sub(r),_.direction.transformDirection(f),p++}else if(y.isRectAreaLight){const _=i.rectArea[m];_.position.setFromMatrixPosition(y.matrixWorld),_.position.applyMatrix4(f),a.identity(),s.copy(y.matrixWorld),s.premultiply(f),a.extractRotation(s),_.halfWidth.set(y.width*.5,0,0),_.halfHeight.set(0,y.height*.5,0),_.halfWidth.applyMatrix4(a),_.halfHeight.applyMatrix4(a),m++}else if(y.isPointLight){const _=i.point[d];_.position.setFromMatrixPosition(y.matrixWorld),_.position.applyMatrix4(f),d++}else if(y.isHemisphereLight){const _=i.hemi[v];_.direction.setFromMatrixPosition(y.matrixWorld),_.direction.transformDirection(f),v++}}}return{setup:o,setupView:l,state:i}}function ay(n){const e=new SR(n),t=[],i=[];function r(u){c.camera=u,t.length=0,i.length=0}function s(u){t.push(u)}function a(u){i.push(u)}function o(){e.setup(t)}function l(u){e.setupView(t,u)}const c={lightsArray:t,shadowsArray:i,camera:null,lights:e,transmissionRenderTarget:{}};return{init:r,state:c,setupLights:o,setupLightsView:l,pushLight:s,pushShadow:a}}function wR(n){let e=new WeakMap;function t(r,s=0){const a=e.get(r);let o;return a===void 0?(o=new ay(n),e.set(r,[o])):s>=a.length?(o=new ay(n),a.push(o)):o=a[s],o}function i(){e=new WeakMap}return{get:t,dispose:i}}class Uu extends hi{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=up,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class qp extends hi{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}const ER=`void main() {
|
|
3795
|
+
`+Q)}else k!==""?console.warn("THREE.WebGLProgram: Program Info Log:",k):(j===""||Y==="")&&($=!1);$&&(T.diagnostics={runnable:re,programLog:k,vertexShader:{log:j,prefix:f},fragmentShader:{log:Y,prefix:g}})}r.deleteShader(I),r.deleteShader(b),C=new Lu(r,v),H=tR(r,v)}let C;this.getUniforms=function(){return C===void 0&&w(this),C};let H;this.getAttributes=function(){return H===void 0&&w(this),H};let M=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return M===!1&&(M=r.getProgramParameter(v,XC)),M},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(v),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=qC++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=I,this.fragmentShader=b,this}let pR=0;class mR{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,i=e.fragmentShader,r=this._getShaderStage(t),s=this._getShaderStage(i),a=this._getShaderCacheForMaterial(e);return a.has(r)===!1&&(a.add(r),r.usedTimes++),a.has(s)===!1&&(a.add(s),s.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){const t=this.shaderCache;let i=t.get(e);return i===void 0&&(i=new fR(e),t.set(e,i)),i}}class fR{constructor(e){this.id=pR++,this.code=e,this.usedTimes=0}}function gR(n,e,t,i,r,s,a){const o=new rl,l=new mR,c=new Set,u=[],h=r.logarithmicDepthBuffer,d=r.reverseDepthBuffer,p=r.vertexTextures;let m=r.precision;const v={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 f(M){return c.add(M),M===0?"uv":`uv${M}`}function g(M,T,k,j,Y){const re=j.fog,$=Y.geometry,he=M.isMeshStandardMaterial?j.environment:null,Q=(M.isMeshStandardMaterial?t:e).get(M.envMap||he),ye=Q&&Q.mapping===ys?Q.image.height:null,be=v[M.type];M.precision!==null&&(m=r.getMaxPrecision(M.precision),m!==M.precision&&console.warn("THREE.WebGLProgram.getParameters:",M.precision,"not supported, using",m,"instead."));const Ve=$.morphAttributes.position||$.morphAttributes.normal||$.morphAttributes.color,at=Ve!==void 0?Ve.length:0;let et=0;$.morphAttributes.position!==void 0&&(et=1),$.morphAttributes.normal!==void 0&&(et=2),$.morphAttributes.color!==void 0&&(et=3);let ie,le,Te,Se;if(be){const ir=Dr[be];ie=ir.vertexShader,le=ir.fragmentShader}else ie=M.vertexShader,le=M.fragmentShader,l.update(M),Te=l.getVertexShaderID(M),Se=l.getFragmentShaderID(M);const Ye=n.getRenderTarget(),We=Y.isInstancedMesh===!0,ot=Y.isBatchedMesh===!0,ce=!!M.map,ue=!!M.matcap,L=!!Q,He=!!M.aoMap,pe=!!M.lightMap,Ue=!!M.bumpMap,we=!!M.normalMap,$e=!!M.displacementMap,Be=!!M.emissiveMap,R=!!M.metalnessMap,S=!!M.roughnessMap,W=M.anisotropy>0,ne=M.clearcoat>0,de=M.dispersion>0,se=M.iridescence>0,ke=M.sheen>0,Ee=M.transmission>0,Pe=W&&!!M.anisotropyMap,mt=ne&&!!M.clearcoatMap,ve=ne&&!!M.clearcoatNormalMap,ze=ne&&!!M.clearcoatRoughnessMap,tt=se&&!!M.iridescenceMap,it=se&&!!M.iridescenceThicknessMap,Oe=ke&&!!M.sheenColorMap,Mt=ke&&!!M.sheenRoughnessMap,ut=!!M.specularMap,Dt=!!M.specularColorMap,O=!!M.specularIntensityMap,Ce=Ee&&!!M.transmissionMap,ee=Ee&&!!M.thicknessMap,oe=!!M.gradientMap,Ne=!!M.alphaMap,Ae=M.alphaTest>0,Ut=!!M.alphaHash,ni=!!M.extensions;let tr=mr;M.toneMapped&&(Ye===null||Ye.isXRRenderTarget===!0)&&(tr=n.toneMapping);const At={shaderID:be,shaderType:M.type,shaderName:M.name,vertexShader:ie,fragmentShader:le,defines:M.defines,customVertexShaderID:Te,customFragmentShaderID:Se,isRawShaderMaterial:M.isRawShaderMaterial===!0,glslVersion:M.glslVersion,precision:m,batching:ot,batchingColor:ot&&Y._colorsTexture!==null,instancing:We,instancingColor:We&&Y.instanceColor!==null,instancingMorph:We&&Y.morphTexture!==null,supportsVertexTextures:p,outputColorSpace:Ye===null?n.outputColorSpace:Ye.isXRRenderTarget===!0?Ye.texture.colorSpace:nr,alphaToCoverage:!!M.alphaToCoverage,map:ce,matcap:ue,envMap:L,envMapMode:L&&Q.mapping,envMapCubeUVHeight:ye,aoMap:He,lightMap:pe,bumpMap:Ue,normalMap:we,displacementMap:p&&$e,emissiveMap:Be,normalMapObjectSpace:we&&M.normalMapType===hp,normalMapTangentSpace:we&&M.normalMapType===on,metalnessMap:R,roughnessMap:S,anisotropy:W,anisotropyMap:Pe,clearcoat:ne,clearcoatMap:mt,clearcoatNormalMap:ve,clearcoatRoughnessMap:ze,dispersion:de,iridescence:se,iridescenceMap:tt,iridescenceThicknessMap:it,sheen:ke,sheenColorMap:Oe,sheenRoughnessMap:Mt,specularMap:ut,specularColorMap:Dt,specularIntensityMap:O,transmission:Ee,transmissionMap:Ce,thicknessMap:ee,gradientMap:oe,opaque:M.transparent===!1&&M.blending===_n&&M.alphaToCoverage===!1,alphaMap:Ne,alphaTest:Ae,alphaHash:Ut,combine:M.combine,mapUv:ce&&f(M.map.channel),aoMapUv:He&&f(M.aoMap.channel),lightMapUv:pe&&f(M.lightMap.channel),bumpMapUv:Ue&&f(M.bumpMap.channel),normalMapUv:we&&f(M.normalMap.channel),displacementMapUv:$e&&f(M.displacementMap.channel),emissiveMapUv:Be&&f(M.emissiveMap.channel),metalnessMapUv:R&&f(M.metalnessMap.channel),roughnessMapUv:S&&f(M.roughnessMap.channel),anisotropyMapUv:Pe&&f(M.anisotropyMap.channel),clearcoatMapUv:mt&&f(M.clearcoatMap.channel),clearcoatNormalMapUv:ve&&f(M.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ze&&f(M.clearcoatRoughnessMap.channel),iridescenceMapUv:tt&&f(M.iridescenceMap.channel),iridescenceThicknessMapUv:it&&f(M.iridescenceThicknessMap.channel),sheenColorMapUv:Oe&&f(M.sheenColorMap.channel),sheenRoughnessMapUv:Mt&&f(M.sheenRoughnessMap.channel),specularMapUv:ut&&f(M.specularMap.channel),specularColorMapUv:Dt&&f(M.specularColorMap.channel),specularIntensityMapUv:O&&f(M.specularIntensityMap.channel),transmissionMapUv:Ce&&f(M.transmissionMap.channel),thicknessMapUv:ee&&f(M.thicknessMap.channel),alphaMapUv:Ne&&f(M.alphaMap.channel),vertexTangents:!!$.attributes.tangent&&(we||W),vertexColors:M.vertexColors,vertexAlphas:M.vertexColors===!0&&!!$.attributes.color&&$.attributes.color.itemSize===4,pointsUvs:Y.isPoints===!0&&!!$.attributes.uv&&(ce||Ne),fog:!!re,useFog:M.fog===!0,fogExp2:!!re&&re.isFogExp2,flatShading:M.flatShading===!0,sizeAttenuation:M.sizeAttenuation===!0,logarithmicDepthBuffer:h,reverseDepthBuffer:d,skinning:Y.isSkinnedMesh===!0,morphTargets:$.morphAttributes.position!==void 0,morphNormals:$.morphAttributes.normal!==void 0,morphColors:$.morphAttributes.color!==void 0,morphTargetsCount:at,morphTextureStride:et,numDirLights:T.directional.length,numPointLights:T.point.length,numSpotLights:T.spot.length,numSpotLightMaps:T.spotLightMap.length,numRectAreaLights:T.rectArea.length,numHemiLights:T.hemi.length,numDirLightShadows:T.directionalShadowMap.length,numPointLightShadows:T.pointShadowMap.length,numSpotLightShadows:T.spotShadowMap.length,numSpotLightShadowsWithMaps:T.numSpotLightShadowsWithMaps,numLightProbes:T.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:M.dithering,shadowMapEnabled:n.shadowMap.enabled&&k.length>0,shadowMapType:n.shadowMap.type,toneMapping:tr,decodeVideoTexture:ce&&M.map.isVideoTexture===!0&&vt.getTransfer(M.map.colorSpace)===Ot,premultipliedAlpha:M.premultipliedAlpha,doubleSided:M.side===Gr,flipSided:M.side===si,useDepthPacking:M.depthPacking>=0,depthPacking:M.depthPacking||0,index0AttributeName:M.index0AttributeName,extensionClipCullDistance:ni&&M.extensions.clipCullDistance===!0&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ni&&M.extensions.multiDraw===!0||ot)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:M.customProgramCacheKey()};return At.vertexUv1s=c.has(1),At.vertexUv2s=c.has(2),At.vertexUv3s=c.has(3),c.clear(),At}function x(M){const T=[];if(M.shaderID?T.push(M.shaderID):(T.push(M.customVertexShaderID),T.push(M.customFragmentShaderID)),M.defines!==void 0)for(const k in M.defines)T.push(k),T.push(M.defines[k]);return M.isRawShaderMaterial===!1&&(y(T,M),_(T,M),T.push(n.outputColorSpace)),T.push(M.customProgramCacheKey),T.join()}function y(M,T){M.push(T.precision),M.push(T.outputColorSpace),M.push(T.envMapMode),M.push(T.envMapCubeUVHeight),M.push(T.mapUv),M.push(T.alphaMapUv),M.push(T.lightMapUv),M.push(T.aoMapUv),M.push(T.bumpMapUv),M.push(T.normalMapUv),M.push(T.displacementMapUv),M.push(T.emissiveMapUv),M.push(T.metalnessMapUv),M.push(T.roughnessMapUv),M.push(T.anisotropyMapUv),M.push(T.clearcoatMapUv),M.push(T.clearcoatNormalMapUv),M.push(T.clearcoatRoughnessMapUv),M.push(T.iridescenceMapUv),M.push(T.iridescenceThicknessMapUv),M.push(T.sheenColorMapUv),M.push(T.sheenRoughnessMapUv),M.push(T.specularMapUv),M.push(T.specularColorMapUv),M.push(T.specularIntensityMapUv),M.push(T.transmissionMapUv),M.push(T.thicknessMapUv),M.push(T.combine),M.push(T.fogExp2),M.push(T.sizeAttenuation),M.push(T.morphTargetsCount),M.push(T.morphAttributeCount),M.push(T.numDirLights),M.push(T.numPointLights),M.push(T.numSpotLights),M.push(T.numSpotLightMaps),M.push(T.numHemiLights),M.push(T.numRectAreaLights),M.push(T.numDirLightShadows),M.push(T.numPointLightShadows),M.push(T.numSpotLightShadows),M.push(T.numSpotLightShadowsWithMaps),M.push(T.numLightProbes),M.push(T.shadowMapType),M.push(T.toneMapping),M.push(T.numClippingPlanes),M.push(T.numClipIntersection),M.push(T.depthPacking)}function _(M,T){o.disableAll(),T.supportsVertexTextures&&o.enable(0),T.instancing&&o.enable(1),T.instancingColor&&o.enable(2),T.instancingMorph&&o.enable(3),T.matcap&&o.enable(4),T.envMap&&o.enable(5),T.normalMapObjectSpace&&o.enable(6),T.normalMapTangentSpace&&o.enable(7),T.clearcoat&&o.enable(8),T.iridescence&&o.enable(9),T.alphaTest&&o.enable(10),T.vertexColors&&o.enable(11),T.vertexAlphas&&o.enable(12),T.vertexUv1s&&o.enable(13),T.vertexUv2s&&o.enable(14),T.vertexUv3s&&o.enable(15),T.vertexTangents&&o.enable(16),T.anisotropy&&o.enable(17),T.alphaHash&&o.enable(18),T.batching&&o.enable(19),T.dispersion&&o.enable(20),T.batchingColor&&o.enable(21),M.push(o.mask),o.disableAll(),T.fog&&o.enable(0),T.useFog&&o.enable(1),T.flatShading&&o.enable(2),T.logarithmicDepthBuffer&&o.enable(3),T.reverseDepthBuffer&&o.enable(4),T.skinning&&o.enable(5),T.morphTargets&&o.enable(6),T.morphNormals&&o.enable(7),T.morphColors&&o.enable(8),T.premultipliedAlpha&&o.enable(9),T.shadowMapEnabled&&o.enable(10),T.doubleSided&&o.enable(11),T.flipSided&&o.enable(12),T.useDepthPacking&&o.enable(13),T.dithering&&o.enable(14),T.transmission&&o.enable(15),T.sheen&&o.enable(16),T.opaque&&o.enable(17),T.pointsUvs&&o.enable(18),T.decodeVideoTexture&&o.enable(19),T.alphaToCoverage&&o.enable(20),M.push(o.mask)}function I(M){const T=v[M.type];let k;if(T){const j=Dr[T];k=Op.clone(j.uniforms)}else k=M.uniforms;return k}function b(M,T){let k;for(let j=0,Y=u.length;j<Y;j++){const re=u[j];if(re.cacheKey===T){k=re,++k.usedTimes;break}}return k===void 0&&(k=new dR(n,T,M,s),u.push(k)),k}function w(M){if(--M.usedTimes===0){const T=u.indexOf(M);u[T]=u[u.length-1],u.pop(),M.destroy()}}function C(M){l.remove(M)}function H(){l.dispose()}return{getParameters:g,getProgramCacheKey:x,getUniforms:I,acquireProgram:b,releaseProgram:w,releaseShaderCache:C,programs:u,dispose:H}}function vR(){let n=new WeakMap;function e(a){return n.has(a)}function t(a){let o=n.get(a);return o===void 0&&(o={},n.set(a,o)),o}function i(a){n.delete(a)}function r(a,o,l){n.get(a)[o]=l}function s(){n=new WeakMap}return{has:e,get:t,remove:i,update:r,dispose:s}}function yR(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.material.id!==e.material.id?n.material.id-e.material.id:n.z!==e.z?n.z-e.z:n.id-e.id}function ry(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.z!==e.z?e.z-n.z:n.id-e.id}function ny(){const n=[];let e=0;const t=[],i=[],r=[];function s(){e=0,t.length=0,i.length=0,r.length=0}function a(h,d,p,m,v,f){let g=n[e];return g===void 0?(g={id:h.id,object:h,geometry:d,material:p,groupOrder:m,renderOrder:h.renderOrder,z:v,group:f},n[e]=g):(g.id=h.id,g.object=h,g.geometry=d,g.material=p,g.groupOrder=m,g.renderOrder=h.renderOrder,g.z=v,g.group=f),e++,g}function o(h,d,p,m,v,f){const g=a(h,d,p,m,v,f);p.transmission>0?i.push(g):p.transparent===!0?r.push(g):t.push(g)}function l(h,d,p,m,v,f){const g=a(h,d,p,m,v,f);p.transmission>0?i.unshift(g):p.transparent===!0?r.unshift(g):t.unshift(g)}function c(h,d){t.length>1&&t.sort(h||yR),i.length>1&&i.sort(d||ry),r.length>1&&r.sort(d||ry)}function u(){for(let h=e,d=n.length;h<d;h++){const p=n[h];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:t,transmissive:i,transparent:r,init:s,push:o,unshift:l,finish:u,sort:c}}function xR(){let n=new WeakMap;function e(i,r){const s=n.get(i);let a;return s===void 0?(a=new ny,n.set(i,[a])):r>=s.length?(a=new ny,s.push(a)):a=s[r],a}function t(){n=new WeakMap}return{get:e,dispose:t}}function _R(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new N,color:new xe};break;case"SpotLight":t={position:new N,direction:new N,color:new xe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new N,color:new xe,distance:0,decay:0};break;case"HemisphereLight":t={direction:new N,skyColor:new xe,groundColor:new xe};break;case"RectAreaLight":t={color:new xe,position:new N,halfWidth:new N,halfHeight:new N};break}return n[e.id]=t,t}}}function MR(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new J};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new J};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new J,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}let bR=0;function TR(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function SR(n){const e=new _R,t=MR(),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 c=0;c<9;c++)i.probe.push(new N);const r=new N,s=new Re,a=new Re;function o(c){let u=0,h=0,d=0;for(let H=0;H<9;H++)i.probe[H].set(0,0,0);let p=0,m=0,v=0,f=0,g=0,x=0,y=0,_=0,I=0,b=0,w=0;c.sort(TR);for(let H=0,M=c.length;H<M;H++){const T=c[H],k=T.color,j=T.intensity,Y=T.distance,re=T.shadow&&T.shadow.map?T.shadow.map.texture:null;if(T.isAmbientLight)u+=k.r*j,h+=k.g*j,d+=k.b*j;else if(T.isLightProbe){for(let $=0;$<9;$++)i.probe[$].addScaledVector(T.sh.coefficients[$],j);w++}else if(T.isDirectionalLight){const $=e.get(T);if($.color.copy(T.color).multiplyScalar(T.intensity),T.castShadow){const he=T.shadow,Q=t.get(T);Q.shadowIntensity=he.intensity,Q.shadowBias=he.bias,Q.shadowNormalBias=he.normalBias,Q.shadowRadius=he.radius,Q.shadowMapSize=he.mapSize,i.directionalShadow[p]=Q,i.directionalShadowMap[p]=re,i.directionalShadowMatrix[p]=T.shadow.matrix,x++}i.directional[p]=$,p++}else if(T.isSpotLight){const $=e.get(T);$.position.setFromMatrixPosition(T.matrixWorld),$.color.copy(k).multiplyScalar(j),$.distance=Y,$.coneCos=Math.cos(T.angle),$.penumbraCos=Math.cos(T.angle*(1-T.penumbra)),$.decay=T.decay,i.spot[v]=$;const he=T.shadow;if(T.map&&(i.spotLightMap[I]=T.map,I++,he.updateMatrices(T),T.castShadow&&b++),i.spotLightMatrix[v]=he.matrix,T.castShadow){const Q=t.get(T);Q.shadowIntensity=he.intensity,Q.shadowBias=he.bias,Q.shadowNormalBias=he.normalBias,Q.shadowRadius=he.radius,Q.shadowMapSize=he.mapSize,i.spotShadow[v]=Q,i.spotShadowMap[v]=re,_++}v++}else if(T.isRectAreaLight){const $=e.get(T);$.color.copy(k).multiplyScalar(j),$.halfWidth.set(T.width*.5,0,0),$.halfHeight.set(0,T.height*.5,0),i.rectArea[f]=$,f++}else if(T.isPointLight){const $=e.get(T);if($.color.copy(T.color).multiplyScalar(T.intensity),$.distance=T.distance,$.decay=T.decay,T.castShadow){const he=T.shadow,Q=t.get(T);Q.shadowIntensity=he.intensity,Q.shadowBias=he.bias,Q.shadowNormalBias=he.normalBias,Q.shadowRadius=he.radius,Q.shadowMapSize=he.mapSize,Q.shadowCameraNear=he.camera.near,Q.shadowCameraFar=he.camera.far,i.pointShadow[m]=Q,i.pointShadowMap[m]=re,i.pointShadowMatrix[m]=T.shadow.matrix,y++}i.point[m]=$,m++}else if(T.isHemisphereLight){const $=e.get(T);$.skyColor.copy(T.color).multiplyScalar(j),$.groundColor.copy(T.groundColor).multiplyScalar(j),i.hemi[g]=$,g++}}f>0&&(n.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=Me.LTC_FLOAT_1,i.rectAreaLTC2=Me.LTC_FLOAT_2):(i.rectAreaLTC1=Me.LTC_HALF_1,i.rectAreaLTC2=Me.LTC_HALF_2)),i.ambient[0]=u,i.ambient[1]=h,i.ambient[2]=d;const C=i.hash;(C.directionalLength!==p||C.pointLength!==m||C.spotLength!==v||C.rectAreaLength!==f||C.hemiLength!==g||C.numDirectionalShadows!==x||C.numPointShadows!==y||C.numSpotShadows!==_||C.numSpotMaps!==I||C.numLightProbes!==w)&&(i.directional.length=p,i.spot.length=v,i.rectArea.length=f,i.point.length=m,i.hemi.length=g,i.directionalShadow.length=x,i.directionalShadowMap.length=x,i.pointShadow.length=y,i.pointShadowMap.length=y,i.spotShadow.length=_,i.spotShadowMap.length=_,i.directionalShadowMatrix.length=x,i.pointShadowMatrix.length=y,i.spotLightMatrix.length=_+I-b,i.spotLightMap.length=I,i.numSpotLightShadowsWithMaps=b,i.numLightProbes=w,C.directionalLength=p,C.pointLength=m,C.spotLength=v,C.rectAreaLength=f,C.hemiLength=g,C.numDirectionalShadows=x,C.numPointShadows=y,C.numSpotShadows=_,C.numSpotMaps=I,C.numLightProbes=w,i.version=bR++)}function l(c,u){let h=0,d=0,p=0,m=0,v=0;const f=u.matrixWorldInverse;for(let g=0,x=c.length;g<x;g++){const y=c[g];if(y.isDirectionalLight){const _=i.directional[h];_.direction.setFromMatrixPosition(y.matrixWorld),r.setFromMatrixPosition(y.target.matrixWorld),_.direction.sub(r),_.direction.transformDirection(f),h++}else if(y.isSpotLight){const _=i.spot[p];_.position.setFromMatrixPosition(y.matrixWorld),_.position.applyMatrix4(f),_.direction.setFromMatrixPosition(y.matrixWorld),r.setFromMatrixPosition(y.target.matrixWorld),_.direction.sub(r),_.direction.transformDirection(f),p++}else if(y.isRectAreaLight){const _=i.rectArea[m];_.position.setFromMatrixPosition(y.matrixWorld),_.position.applyMatrix4(f),a.identity(),s.copy(y.matrixWorld),s.premultiply(f),a.extractRotation(s),_.halfWidth.set(y.width*.5,0,0),_.halfHeight.set(0,y.height*.5,0),_.halfWidth.applyMatrix4(a),_.halfHeight.applyMatrix4(a),m++}else if(y.isPointLight){const _=i.point[d];_.position.setFromMatrixPosition(y.matrixWorld),_.position.applyMatrix4(f),d++}else if(y.isHemisphereLight){const _=i.hemi[v];_.direction.setFromMatrixPosition(y.matrixWorld),_.direction.transformDirection(f),v++}}}return{setup:o,setupView:l,state:i}}function sy(n){const e=new SR(n),t=[],i=[];function r(u){c.camera=u,t.length=0,i.length=0}function s(u){t.push(u)}function a(u){i.push(u)}function o(){e.setup(t)}function l(u){e.setupView(t,u)}const c={lightsArray:t,shadowsArray:i,camera:null,lights:e,transmissionRenderTarget:{}};return{init:r,state:c,setupLights:o,setupLightsView:l,pushLight:s,pushShadow:a}}function wR(n){let e=new WeakMap;function t(r,s=0){const a=e.get(r);let o;return a===void 0?(o=new sy(n),e.set(r,[o])):s>=a.length?(o=new sy(n),a.push(o)):o=a[s],o}function i(){e=new WeakMap}return{get:t,dispose:i}}class Du extends hi{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=cp,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Xp extends hi{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}const ER=`void main() {
|
|
3796
3796
|
gl_Position = vec4( position, 1.0 );
|
|
3797
3797
|
}`,AR=`uniform sampler2D shadow_pass;
|
|
3798
3798
|
uniform vec2 resolution;
|
|
@@ -3820,7 +3820,7 @@ void main() {
|
|
|
3820
3820
|
squared_mean = squared_mean / samples;
|
|
3821
3821
|
float std_dev = sqrt( squared_mean - mean * mean );
|
|
3822
3822
|
gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
|
|
3823
|
-
}`;function NR(n,e,t){let i=new ka;const r=new J,s=new J,a=new st,o=new Uu({depthPacking:hp}),l=new qp,c={},u=t.maxTextureSize,h={[an]:si,[si]:an,[Gr]:Gr},d=new Pr({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new J},radius:{value:4}},vertexShader:ER,fragmentShader:AR}),p=d.clone();p.defines.HORIZONTAL_PASS=1;const m=new ct;m.setAttribute("position",new wt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new Ft(m,d),f=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Gd;let g=this.type;this.render=function(b,w,C){if(f.enabled===!1||f.autoUpdate===!1&&f.needsUpdate===!1||b.length===0)return;const H=n.getRenderTarget(),M=n.getActiveCubeFace(),T=n.getActiveMipmapLevel(),k=n.state;k.setBlending(Er),k.buffers.color.setClear(1,1,1,1),k.buffers.depth.setTest(!0),k.setScissorTest(!1);const j=g!==rr&&this.type===rr,Y=g===rr&&this.type!==rr;for(let re=0,$=b.length;re<$;re++){const he=b[re],Q=he.shadow;if(Q===void 0){console.warn("THREE.WebGLShadowMap:",he,"has no shadow.");continue}if(Q.autoUpdate===!1&&Q.needsUpdate===!1)continue;r.copy(Q.mapSize);const ye=Q.getFrameExtents();if(r.multiply(ye),s.copy(Q.mapSize),(r.x>u||r.y>u)&&(r.x>u&&(s.x=Math.floor(u/ye.x),r.x=s.x*ye.x,Q.mapSize.x=s.x),r.y>u&&(s.y=Math.floor(u/ye.y),r.y=s.y*ye.y,Q.mapSize.y=s.y)),Q.map===null||j===!0||Y===!0){const Ve=this.type!==rr?{minFilter:$t,magFilter:$t}:{};Q.map!==null&&Q.map.dispose(),Q.map=new Ir(r.x,r.y,Ve),Q.map.texture.name=he.name+".shadowMap",Q.camera.updateProjectionMatrix()}n.setRenderTarget(Q.map),n.clear();const be=Q.getViewportCount();for(let Ve=0;Ve<be;Ve++){const at=Q.getViewport(Ve);a.set(s.x*at.x,s.y*at.y,s.x*at.z,s.y*at.w),k.viewport(a),Q.updateMatrices(he,Ve),i=Q.getFrustum(),_(w,C,Q.camera,he,this.type)}Q.isPointLightShadow!==!0&&this.type===rr&&x(Q,C),Q.needsUpdate=!1}g=this.type,f.needsUpdate=!1,n.setRenderTarget(H,M,T)};function x(b,w){const C=e.update(v);d.defines.VSM_SAMPLES!==b.blurSamples&&(d.defines.VSM_SAMPLES=b.blurSamples,p.defines.VSM_SAMPLES=b.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),b.mapPass===null&&(b.mapPass=new Ir(r.x,r.y)),d.uniforms.shadow_pass.value=b.map.texture,d.uniforms.resolution.value=b.mapSize,d.uniforms.radius.value=b.radius,n.setRenderTarget(b.mapPass),n.clear(),n.renderBufferDirect(w,null,C,d,v,null),p.uniforms.shadow_pass.value=b.mapPass.texture,p.uniforms.resolution.value=b.mapSize,p.uniforms.radius.value=b.radius,n.setRenderTarget(b.map),n.clear(),n.renderBufferDirect(w,null,C,p,v,null)}function y(b,w,C,H){let M=null;const T=C.isPointLight===!0?b.customDistanceMaterial:b.customDepthMaterial;if(T!==void 0)M=T;else if(M=C.isPointLight===!0?l:o,n.localClippingEnabled&&w.clipShadows===!0&&Array.isArray(w.clippingPlanes)&&w.clippingPlanes.length!==0||w.displacementMap&&w.displacementScale!==0||w.alphaMap&&w.alphaTest>0||w.map&&w.alphaTest>0){const k=M.uuid,j=w.uuid;let Y=c[k];Y===void 0&&(Y={},c[k]=Y);let re=Y[j];re===void 0&&(re=M.clone(),Y[j]=re,w.addEventListener("dispose",I)),M=re}if(M.visible=w.visible,M.wireframe=w.wireframe,H===rr?M.side=w.shadowSide!==null?w.shadowSide:w.side:M.side=w.shadowSide!==null?w.shadowSide:h[w.side],M.alphaMap=w.alphaMap,M.alphaTest=w.alphaTest,M.map=w.map,M.clipShadows=w.clipShadows,M.clippingPlanes=w.clippingPlanes,M.clipIntersection=w.clipIntersection,M.displacementMap=w.displacementMap,M.displacementScale=w.displacementScale,M.displacementBias=w.displacementBias,M.wireframeLinewidth=w.wireframeLinewidth,M.linewidth=w.linewidth,C.isPointLight===!0&&M.isMeshDistanceMaterial===!0){const k=n.properties.get(M);k.light=C}return M}function _(b,w,C,H,M){if(b.visible===!1)return;if(b.layers.test(w.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&M===rr)&&(!b.frustumCulled||i.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(C.matrixWorldInverse,b.matrixWorld);const k=e.update(b),j=b.material;if(Array.isArray(j)){const Y=k.groups;for(let re=0,$=Y.length;re<$;re++){const he=Y[re],Q=j[he.materialIndex];if(Q&&Q.visible){const ye=y(b,Q,H,M);b.onBeforeShadow(n,b,w,C,k,ye,he),n.renderBufferDirect(C,null,k,ye,b,he),b.onAfterShadow(n,b,w,C,k,ye,he)}}}else if(j.visible){const Y=y(b,j,H,M);b.onBeforeShadow(n,b,w,C,k,Y,null),n.renderBufferDirect(C,null,k,Y,b,null),b.onAfterShadow(n,b,w,C,k,Y,null)}}const T=b.children;for(let k=0,j=T.length;k<j;k++)_(T[k],w,C,H,M)}function I(b){b.target.removeEventListener("dispose",I);for(const w in c){const C=c[w],H=b.target.uuid;H in C&&(C[H].dispose(),delete C[H])}}}const CR={[No]:Co,[Ro]:Po,[Io]:Do,[zn]:Lo,[Co]:No,[Po]:Ro,[Do]:Io,[Lo]:zn};function RR(n){function e(){let O=!1;const Ce=new st;let ee=null;const oe=new st(0,0,0,0);return{setMask:function(Ne){ee!==Ne&&!O&&(n.colorMask(Ne,Ne,Ne,Ne),ee=Ne)},setLocked:function(Ne){O=Ne},setClear:function(Ne,Ae,Ut,ni,tr){tr===!0&&(Ne*=ni,Ae*=ni,Ut*=ni),Ce.set(Ne,Ae,Ut,ni),oe.equals(Ce)===!1&&(n.clearColor(Ne,Ae,Ut,ni),oe.copy(Ce))},reset:function(){O=!1,ee=null,oe.set(-1,0,0,0)}}}function t(){let O=!1,Ce=!1,ee=null,oe=null,Ne=null;return{setReversed:function(Ae){Ce=Ae},setTest:function(Ae){Ae?Te(n.DEPTH_TEST):Se(n.DEPTH_TEST)},setMask:function(Ae){ee!==Ae&&!O&&(n.depthMask(Ae),ee=Ae)},setFunc:function(Ae){if(Ce&&(Ae=CR[Ae]),oe!==Ae){switch(Ae){case No:n.depthFunc(n.NEVER);break;case Co:n.depthFunc(n.ALWAYS);break;case Ro:n.depthFunc(n.LESS);break;case zn:n.depthFunc(n.LEQUAL);break;case Io:n.depthFunc(n.EQUAL);break;case Lo:n.depthFunc(n.GEQUAL);break;case Po:n.depthFunc(n.GREATER);break;case Do:n.depthFunc(n.NOTEQUAL);break;default:n.depthFunc(n.LEQUAL)}oe=Ae}},setLocked:function(Ae){O=Ae},setClear:function(Ae){Ne!==Ae&&(n.clearDepth(Ae),Ne=Ae)},reset:function(){O=!1,ee=null,oe=null,Ne=null}}}function i(){let O=!1,Ce=null,ee=null,oe=null,Ne=null,Ae=null,Ut=null,ni=null,tr=null;return{setTest:function(At){O||(At?Te(n.STENCIL_TEST):Se(n.STENCIL_TEST))},setMask:function(At){Ce!==At&&!O&&(n.stencilMask(At),Ce=At)},setFunc:function(At,ir,xn){(ee!==At||oe!==ir||Ne!==xn)&&(n.stencilFunc(At,ir,xn),ee=At,oe=ir,Ne=xn)},setOp:function(At,ir,xn){(Ae!==At||Ut!==ir||ni!==xn)&&(n.stencilOp(At,ir,xn),Ae=At,Ut=ir,ni=xn)},setLocked:function(At){O=At},setClear:function(At){tr!==At&&(n.clearStencil(At),tr=At)},reset:function(){O=!1,Ce=null,ee=null,oe=null,Ne=null,Ae=null,Ut=null,ni=null,tr=null}}}const r=new e,s=new t,a=new i,o=new WeakMap,l=new WeakMap;let c={},u={},h=new WeakMap,d=[],p=null,m=!1,v=null,f=null,g=null,x=null,y=null,_=null,I=null,b=new xe(0,0,0),w=0,C=!1,H=null,M=null,T=null,k=null,j=null;const Y=n.getParameter(n.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let re=!1,$=0;const he=n.getParameter(n.VERSION);he.indexOf("WebGL")!==-1?($=parseFloat(/^WebGL (\d)/.exec(he)[1]),re=$>=1):he.indexOf("OpenGL ES")!==-1&&($=parseFloat(/^OpenGL ES (\d)/.exec(he)[1]),re=$>=2);let Q=null,ye={};const be=n.getParameter(n.SCISSOR_BOX),Ve=n.getParameter(n.VIEWPORT),at=new st().fromArray(be),et=new st().fromArray(Ve);function ie(O,Ce,ee,oe){const Ne=new Uint8Array(4),Ae=n.createTexture();n.bindTexture(O,Ae),n.texParameteri(O,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(O,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let Ut=0;Ut<ee;Ut++)O===n.TEXTURE_3D||O===n.TEXTURE_2D_ARRAY?n.texImage3D(Ce,0,n.RGBA,1,1,oe,0,n.RGBA,n.UNSIGNED_BYTE,Ne):n.texImage2D(Ce+Ut,0,n.RGBA,1,1,0,n.RGBA,n.UNSIGNED_BYTE,Ne);return Ae}const le={};le[n.TEXTURE_2D]=ie(n.TEXTURE_2D,n.TEXTURE_2D,1),le[n.TEXTURE_CUBE_MAP]=ie(n.TEXTURE_CUBE_MAP,n.TEXTURE_CUBE_MAP_POSITIVE_X,6),le[n.TEXTURE_2D_ARRAY]=ie(n.TEXTURE_2D_ARRAY,n.TEXTURE_2D_ARRAY,1,1),le[n.TEXTURE_3D]=ie(n.TEXTURE_3D,n.TEXTURE_3D,1,1),r.setClear(0,0,0,1),s.setClear(1),a.setClear(0),Te(n.DEPTH_TEST),s.setFunc(zn),pe(!1),Ue(Hd),Te(n.CULL_FACE),L(Er);function Te(O){c[O]!==!0&&(n.enable(O),c[O]=!0)}function Se(O){c[O]!==!1&&(n.disable(O),c[O]=!1)}function Ye(O,Ce){return u[O]!==Ce?(n.bindFramebuffer(O,Ce),u[O]=Ce,O===n.DRAW_FRAMEBUFFER&&(u[n.FRAMEBUFFER]=Ce),O===n.FRAMEBUFFER&&(u[n.DRAW_FRAMEBUFFER]=Ce),!0):!1}function We(O,Ce){let ee=d,oe=!1;if(O){ee=h.get(Ce),ee===void 0&&(ee=[],h.set(Ce,ee));const Ne=O.textures;if(ee.length!==Ne.length||ee[0]!==n.COLOR_ATTACHMENT0){for(let Ae=0,Ut=Ne.length;Ae<Ut;Ae++)ee[Ae]=n.COLOR_ATTACHMENT0+Ae;ee.length=Ne.length,oe=!0}}else ee[0]!==n.BACK&&(ee[0]=n.BACK,oe=!0);oe&&n.drawBuffers(ee)}function ot(O){return p!==O?(n.useProgram(O),p=O,!0):!1}const ce={[Bn]:n.FUNC_ADD,[x0]:n.FUNC_SUBTRACT,[_0]:n.FUNC_REVERSE_SUBTRACT};ce[M0]=n.MIN,ce[Yd]=n.MAX;const ue={[b0]:n.ZERO,[T0]:n.ONE,[S0]:n.SRC_COLOR,[Sc]:n.SRC_ALPHA,[R0]:n.SRC_ALPHA_SATURATE,[N0]:n.DST_COLOR,[E0]:n.DST_ALPHA,[w0]:n.ONE_MINUS_SRC_COLOR,[wc]:n.ONE_MINUS_SRC_ALPHA,[C0]:n.ONE_MINUS_DST_COLOR,[A0]:n.ONE_MINUS_DST_ALPHA,[I0]:n.CONSTANT_COLOR,[L0]:n.ONE_MINUS_CONSTANT_COLOR,[P0]:n.CONSTANT_ALPHA,[D0]:n.ONE_MINUS_CONSTANT_ALPHA};function L(O,Ce,ee,oe,Ne,Ae,Ut,ni,tr,At){if(O===Er){m===!0&&(Se(n.BLEND),m=!1);return}if(m===!1&&(Te(n.BLEND),m=!0),O!==qd){if(O!==v||At!==C){if((f!==Bn||y!==Bn)&&(n.blendEquation(n.FUNC_ADD),f=Bn,y=Bn),At)switch(O){case _n:n.blendFuncSeparate(n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case Ao:n.blendFunc(n.ONE,n.ONE);break;case jd:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case Xd:n.blendFuncSeparate(n.ZERO,n.SRC_COLOR,n.ZERO,n.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",O);break}else switch(O){case _n:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case Ao:n.blendFunc(n.SRC_ALPHA,n.ONE);break;case jd:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case Xd:n.blendFunc(n.ZERO,n.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",O);break}g=null,x=null,_=null,I=null,b.set(0,0,0),w=0,v=O,C=At}return}Ne=Ne||Ce,Ae=Ae||ee,Ut=Ut||oe,(Ce!==f||Ne!==y)&&(n.blendEquationSeparate(ce[Ce],ce[Ne]),f=Ce,y=Ne),(ee!==g||oe!==x||Ae!==_||Ut!==I)&&(n.blendFuncSeparate(ue[ee],ue[oe],ue[Ae],ue[Ut]),g=ee,x=oe,_=Ae,I=Ut),(ni.equals(b)===!1||tr!==w)&&(n.blendColor(ni.r,ni.g,ni.b,tr),b.copy(ni),w=tr),v=O,C=!1}function He(O,Ce){O.side===Gr?Se(n.CULL_FACE):Te(n.CULL_FACE);let ee=O.side===si;Ce&&(ee=!ee),pe(ee),O.blending===_n&&O.transparent===!1?L(Er):L(O.blending,O.blendEquation,O.blendSrc,O.blendDst,O.blendEquationAlpha,O.blendSrcAlpha,O.blendDstAlpha,O.blendColor,O.blendAlpha,O.premultipliedAlpha),s.setFunc(O.depthFunc),s.setTest(O.depthTest),s.setMask(O.depthWrite),r.setMask(O.colorWrite);const oe=O.stencilWrite;a.setTest(oe),oe&&(a.setMask(O.stencilWriteMask),a.setFunc(O.stencilFunc,O.stencilRef,O.stencilFuncMask),a.setOp(O.stencilFail,O.stencilZFail,O.stencilZPass)),$e(O.polygonOffset,O.polygonOffsetFactor,O.polygonOffsetUnits),O.alphaToCoverage===!0?Te(n.SAMPLE_ALPHA_TO_COVERAGE):Se(n.SAMPLE_ALPHA_TO_COVERAGE)}function pe(O){H!==O&&(O?n.frontFace(n.CW):n.frontFace(n.CCW),H=O)}function Ue(O){O!==v0?(Te(n.CULL_FACE),O!==M&&(O===Hd?n.cullFace(n.BACK):O===y0?n.cullFace(n.FRONT):n.cullFace(n.FRONT_AND_BACK))):Se(n.CULL_FACE),M=O}function we(O){O!==T&&(re&&n.lineWidth(O),T=O)}function $e(O,Ce,ee){O?(Te(n.POLYGON_OFFSET_FILL),(k!==Ce||j!==ee)&&(n.polygonOffset(Ce,ee),k=Ce,j=ee)):Se(n.POLYGON_OFFSET_FILL)}function Be(O){O?Te(n.SCISSOR_TEST):Se(n.SCISSOR_TEST)}function R(O){O===void 0&&(O=n.TEXTURE0+Y-1),Q!==O&&(n.activeTexture(O),Q=O)}function S(O,Ce,ee){ee===void 0&&(Q===null?ee=n.TEXTURE0+Y-1:ee=Q);let oe=ye[ee];oe===void 0&&(oe={type:void 0,texture:void 0},ye[ee]=oe),(oe.type!==O||oe.texture!==Ce)&&(Q!==ee&&(n.activeTexture(ee),Q=ee),n.bindTexture(O,Ce||le[O]),oe.type=O,oe.texture=Ce)}function W(){const O=ye[Q];O!==void 0&&O.type!==void 0&&(n.bindTexture(O.type,null),O.type=void 0,O.texture=void 0)}function ne(){try{n.compressedTexImage2D.apply(n,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function de(){try{n.compressedTexImage3D.apply(n,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function se(){try{n.texSubImage2D.apply(n,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function ke(){try{n.texSubImage3D.apply(n,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function Ee(){try{n.compressedTexSubImage2D.apply(n,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function Pe(){try{n.compressedTexSubImage3D.apply(n,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function mt(){try{n.texStorage2D.apply(n,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function ve(){try{n.texStorage3D.apply(n,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function ze(){try{n.texImage2D.apply(n,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function tt(){try{n.texImage3D.apply(n,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function it(O){at.equals(O)===!1&&(n.scissor(O.x,O.y,O.z,O.w),at.copy(O))}function Oe(O){et.equals(O)===!1&&(n.viewport(O.x,O.y,O.z,O.w),et.copy(O))}function Mt(O,Ce){let ee=l.get(Ce);ee===void 0&&(ee=new WeakMap,l.set(Ce,ee));let oe=ee.get(O);oe===void 0&&(oe=n.getUniformBlockIndex(Ce,O.name),ee.set(O,oe))}function ut(O,Ce){const ee=l.get(Ce).get(O);o.get(Ce)!==ee&&(n.uniformBlockBinding(Ce,ee,O.__bindingPointIndex),o.set(Ce,ee))}function Dt(){n.disable(n.BLEND),n.disable(n.CULL_FACE),n.disable(n.DEPTH_TEST),n.disable(n.POLYGON_OFFSET_FILL),n.disable(n.SCISSOR_TEST),n.disable(n.STENCIL_TEST),n.disable(n.SAMPLE_ALPHA_TO_COVERAGE),n.blendEquation(n.FUNC_ADD),n.blendFunc(n.ONE,n.ZERO),n.blendFuncSeparate(n.ONE,n.ZERO,n.ONE,n.ZERO),n.blendColor(0,0,0,0),n.colorMask(!0,!0,!0,!0),n.clearColor(0,0,0,0),n.depthMask(!0),n.depthFunc(n.LESS),n.clearDepth(1),n.stencilMask(4294967295),n.stencilFunc(n.ALWAYS,0,4294967295),n.stencilOp(n.KEEP,n.KEEP,n.KEEP),n.clearStencil(0),n.cullFace(n.BACK),n.frontFace(n.CCW),n.polygonOffset(0,0),n.activeTexture(n.TEXTURE0),n.bindFramebuffer(n.FRAMEBUFFER,null),n.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),n.bindFramebuffer(n.READ_FRAMEBUFFER,null),n.useProgram(null),n.lineWidth(1),n.scissor(0,0,n.canvas.width,n.canvas.height),n.viewport(0,0,n.canvas.width,n.canvas.height),c={},Q=null,ye={},u={},h=new WeakMap,d=[],p=null,m=!1,v=null,f=null,g=null,x=null,y=null,_=null,I=null,b=new xe(0,0,0),w=0,C=!1,H=null,M=null,T=null,k=null,j=null,at.set(0,0,n.canvas.width,n.canvas.height),et.set(0,0,n.canvas.width,n.canvas.height),r.reset(),s.reset(),a.reset()}return{buffers:{color:r,depth:s,stencil:a},enable:Te,disable:Se,bindFramebuffer:Ye,drawBuffers:We,useProgram:ot,setBlending:L,setMaterial:He,setFlipSided:pe,setCullFace:Ue,setLineWidth:we,setPolygonOffset:$e,setScissorTest:Be,activeTexture:R,bindTexture:S,unbindTexture:W,compressedTexImage2D:ne,compressedTexImage3D:de,texImage2D:ze,texImage3D:tt,updateUBOMapping:Mt,uniformBlockBinding:ut,texStorage2D:mt,texStorage3D:ve,texSubImage2D:se,texSubImage3D:ke,compressedTexSubImage2D:Ee,compressedTexSubImage3D:Pe,scissor:it,viewport:Oe,reset:Dt}}function IR(n,e){const t=n.image&&n.image.width?n.image.width/n.image.height:1;return t>e?(n.repeat.x=1,n.repeat.y=t/e,n.offset.x=0,n.offset.y=(1-n.repeat.y)/2):(n.repeat.x=e/t,n.repeat.y=1,n.offset.x=(1-n.repeat.x)/2,n.offset.y=0),n}function LR(n,e){const t=n.image&&n.image.width?n.image.width/n.image.height:1;return t>e?(n.repeat.x=e/t,n.repeat.y=1,n.offset.x=(1-n.repeat.x)/2,n.offset.y=0):(n.repeat.x=1,n.repeat.y=t/e,n.offset.x=0,n.offset.y=(1-n.repeat.y)/2),n}function PR(n){return n.repeat.x=1,n.repeat.y=1,n.offset.x=0,n.offset.y=0,n}function Yp(n,e,t,i){const r=DR(i);switch(t){case ip:return n*e;case np:return n*e;case sp:return n*e*2;case Uo:return n*e/r.components*r.byteLength;case Oo:return n*e/r.components*r.byteLength;case ya:return n*e*2/r.components*r.byteLength;case Uc:return n*e*2/r.components*r.byteLength;case rp:return n*e*3/r.components*r.byteLength;case Ei:return n*e*4/r.components*r.byteLength;case Oc:return n*e*4/r.components*r.byteLength;case Fo:case xa:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Vo:case _a:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Fc:case Vc:return Math.max(n,16)*Math.max(e,8)/4;case Bo:case zo:return Math.max(n,8)*Math.max(e,8)/2;case ko:case Ho:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Go:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Wo:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Bc:return Math.floor((n+4)/5)*Math.floor((e+3)/4)*16;case zc:return Math.floor((n+4)/5)*Math.floor((e+4)/5)*16;case kc:return Math.floor((n+5)/6)*Math.floor((e+4)/5)*16;case jo:return Math.floor((n+5)/6)*Math.floor((e+5)/6)*16;case Hc:return Math.floor((n+7)/8)*Math.floor((e+4)/5)*16;case Gc:return Math.floor((n+7)/8)*Math.floor((e+5)/6)*16;case Wc:return Math.floor((n+7)/8)*Math.floor((e+7)/8)*16;case jc:return Math.floor((n+9)/10)*Math.floor((e+4)/5)*16;case Xc:return Math.floor((n+9)/10)*Math.floor((e+5)/6)*16;case qc:return Math.floor((n+9)/10)*Math.floor((e+7)/8)*16;case Yc:return Math.floor((n+9)/10)*Math.floor((e+9)/10)*16;case $c:return Math.floor((n+11)/12)*Math.floor((e+9)/10)*16;case Jc:return Math.floor((n+11)/12)*Math.floor((e+11)/12)*16;case Ma:case Kc:case Zc:return Math.ceil(n/4)*Math.ceil(e/4)*16;case ap:case Qc:return Math.ceil(n/4)*Math.ceil(e/4)*8;case eu:case tu:return Math.ceil(n/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function DR(n){switch(n){case Wr:case Qd:return{byteLength:1,components:1};case ga:case ep:case wi:return{byteLength:2,components:1};case Pc:case Dc:return{byteLength:2,components:4};case Nr:case va:case Oi:return{byteLength:4,components:1};case tp:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${n}.`)}const UR={contain:IR,cover:LR,fill:PR,getByteLength:Yp};function OR(n,e,t,i,r,s,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new J,u=new WeakMap;let h;const d=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function m(R,S){return p?new OffscreenCanvas(R,S):Qo("canvas")}function v(R,S,W){let ne=1;const de=Be(R);if((de.width>W||de.height>W)&&(ne=W/Math.max(de.width,de.height)),ne<1)if(typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&R instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&R instanceof ImageBitmap||typeof VideoFrame<"u"&&R instanceof VideoFrame){const se=Math.floor(ne*de.width),ke=Math.floor(ne*de.height);h===void 0&&(h=m(se,ke));const Ee=S?m(se,ke):h;return Ee.width=se,Ee.height=ke,Ee.getContext("2d").drawImage(R,0,0,se,ke),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+de.width+"x"+de.height+") to ("+se+"x"+ke+")."),Ee}else return"data"in R&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+de.width+"x"+de.height+")."),R;return R}function f(R){return R.generateMipmaps&&R.minFilter!==$t&&R.minFilter!==Lt}function g(R){n.generateMipmap(R)}function x(R,S,W,ne,de=!1){if(R!==null){if(n[R]!==void 0)return n[R];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+R+"'")}let se=S;if(S===n.RED&&(W===n.FLOAT&&(se=n.R32F),W===n.HALF_FLOAT&&(se=n.R16F),W===n.UNSIGNED_BYTE&&(se=n.R8)),S===n.RED_INTEGER&&(W===n.UNSIGNED_BYTE&&(se=n.R8UI),W===n.UNSIGNED_SHORT&&(se=n.R16UI),W===n.UNSIGNED_INT&&(se=n.R32UI),W===n.BYTE&&(se=n.R8I),W===n.SHORT&&(se=n.R16I),W===n.INT&&(se=n.R32I)),S===n.RG&&(W===n.FLOAT&&(se=n.RG32F),W===n.HALF_FLOAT&&(se=n.RG16F),W===n.UNSIGNED_BYTE&&(se=n.RG8)),S===n.RG_INTEGER&&(W===n.UNSIGNED_BYTE&&(se=n.RG8UI),W===n.UNSIGNED_SHORT&&(se=n.RG16UI),W===n.UNSIGNED_INT&&(se=n.RG32UI),W===n.BYTE&&(se=n.RG8I),W===n.SHORT&&(se=n.RG16I),W===n.INT&&(se=n.RG32I)),S===n.RGB_INTEGER&&(W===n.UNSIGNED_BYTE&&(se=n.RGB8UI),W===n.UNSIGNED_SHORT&&(se=n.RGB16UI),W===n.UNSIGNED_INT&&(se=n.RGB32UI),W===n.BYTE&&(se=n.RGB8I),W===n.SHORT&&(se=n.RGB16I),W===n.INT&&(se=n.RGB32I)),S===n.RGBA_INTEGER&&(W===n.UNSIGNED_BYTE&&(se=n.RGBA8UI),W===n.UNSIGNED_SHORT&&(se=n.RGBA16UI),W===n.UNSIGNED_INT&&(se=n.RGBA32UI),W===n.BYTE&&(se=n.RGBA8I),W===n.SHORT&&(se=n.RGBA16I),W===n.INT&&(se=n.RGBA32I)),S===n.RGB&&W===n.UNSIGNED_INT_5_9_9_9_REV&&(se=n.RGB9_E5),S===n.RGBA){const ke=de?$o:vt.getTransfer(ne);W===n.FLOAT&&(se=n.RGBA32F),W===n.HALF_FLOAT&&(se=n.RGBA16F),W===n.UNSIGNED_BYTE&&(se=ke===Ot?n.SRGB8_ALPHA8:n.RGBA8),W===n.UNSIGNED_SHORT_4_4_4_4&&(se=n.RGBA4),W===n.UNSIGNED_SHORT_5_5_5_1&&(se=n.RGB5_A1)}return(se===n.R16F||se===n.R32F||se===n.RG16F||se===n.RG32F||se===n.RGBA16F||se===n.RGBA32F)&&e.get("EXT_color_buffer_float"),se}function y(R,S){let W;return R?S===null||S===Nr||S===jn?W=n.DEPTH24_STENCIL8:S===Oi?W=n.DEPTH32F_STENCIL8:S===ga&&(W=n.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):S===null||S===Nr||S===jn?W=n.DEPTH_COMPONENT24:S===Oi?W=n.DEPTH_COMPONENT32F:S===ga&&(W=n.DEPTH_COMPONENT16),W}function _(R,S){return f(R)===!0||R.isFramebufferTexture&&R.minFilter!==$t&&R.minFilter!==Lt?Math.log2(Math.max(S.width,S.height))+1:R.mipmaps!==void 0&&R.mipmaps.length>0?R.mipmaps.length:R.isCompressedTexture&&Array.isArray(R.image)?S.mipmaps.length:1}function I(R){const S=R.target;S.removeEventListener("dispose",I),w(S),S.isVideoTexture&&u.delete(S)}function b(R){const S=R.target;S.removeEventListener("dispose",b),H(S)}function w(R){const S=i.get(R);if(S.__webglInit===void 0)return;const W=R.source,ne=d.get(W);if(ne){const de=ne[S.__cacheKey];de.usedTimes--,de.usedTimes===0&&C(R),Object.keys(ne).length===0&&d.delete(W)}i.remove(R)}function C(R){const S=i.get(R);n.deleteTexture(S.__webglTexture);const W=R.source,ne=d.get(W);delete ne[S.__cacheKey],a.memory.textures--}function H(R){const S=i.get(R);if(R.depthTexture&&R.depthTexture.dispose(),R.isWebGLCubeRenderTarget)for(let ne=0;ne<6;ne++){if(Array.isArray(S.__webglFramebuffer[ne]))for(let de=0;de<S.__webglFramebuffer[ne].length;de++)n.deleteFramebuffer(S.__webglFramebuffer[ne][de]);else n.deleteFramebuffer(S.__webglFramebuffer[ne]);S.__webglDepthbuffer&&n.deleteRenderbuffer(S.__webglDepthbuffer[ne])}else{if(Array.isArray(S.__webglFramebuffer))for(let ne=0;ne<S.__webglFramebuffer.length;ne++)n.deleteFramebuffer(S.__webglFramebuffer[ne]);else n.deleteFramebuffer(S.__webglFramebuffer);if(S.__webglDepthbuffer&&n.deleteRenderbuffer(S.__webglDepthbuffer),S.__webglMultisampledFramebuffer&&n.deleteFramebuffer(S.__webglMultisampledFramebuffer),S.__webglColorRenderbuffer)for(let ne=0;ne<S.__webglColorRenderbuffer.length;ne++)S.__webglColorRenderbuffer[ne]&&n.deleteRenderbuffer(S.__webglColorRenderbuffer[ne]);S.__webglDepthRenderbuffer&&n.deleteRenderbuffer(S.__webglDepthRenderbuffer)}const W=R.textures;for(let ne=0,de=W.length;ne<de;ne++){const se=i.get(W[ne]);se.__webglTexture&&(n.deleteTexture(se.__webglTexture),a.memory.textures--),i.remove(W[ne])}i.remove(R)}let M=0;function T(){M=0}function k(){const R=M;return R>=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+r.maxTextures),M+=1,R}function j(R){const S=[];return S.push(R.wrapS),S.push(R.wrapT),S.push(R.wrapR||0),S.push(R.magFilter),S.push(R.minFilter),S.push(R.anisotropy),S.push(R.internalFormat),S.push(R.format),S.push(R.type),S.push(R.generateMipmaps),S.push(R.premultiplyAlpha),S.push(R.flipY),S.push(R.unpackAlignment),S.push(R.colorSpace),S.join()}function Y(R,S){const W=i.get(R);if(R.isVideoTexture&&we(R),R.isRenderTargetTexture===!1&&R.version>0&&W.__version!==R.version){const ne=R.image;if(ne===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ne.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{et(W,R,S);return}}t.bindTexture(n.TEXTURE_2D,W.__webglTexture,n.TEXTURE0+S)}function re(R,S){const W=i.get(R);if(R.version>0&&W.__version!==R.version){et(W,R,S);return}t.bindTexture(n.TEXTURE_2D_ARRAY,W.__webglTexture,n.TEXTURE0+S)}function $(R,S){const W=i.get(R);if(R.version>0&&W.__version!==R.version){et(W,R,S);return}t.bindTexture(n.TEXTURE_3D,W.__webglTexture,n.TEXTURE0+S)}function he(R,S){const W=i.get(R);if(R.version>0&&W.__version!==R.version){ie(W,R,S);return}t.bindTexture(n.TEXTURE_CUBE_MAP,W.__webglTexture,n.TEXTURE0+S)}const Q={[Gn]:n.REPEAT,[gr]:n.CLAMP_TO_EDGE,[fa]:n.MIRRORED_REPEAT},ye={[$t]:n.NEAREST,[Lc]:n.NEAREST_MIPMAP_NEAREST,[Mn]:n.NEAREST_MIPMAP_LINEAR,[Lt]:n.LINEAR,[Wn]:n.LINEAR_MIPMAP_NEAREST,[ji]:n.LINEAR_MIPMAP_LINEAR},be={[iv]:n.NEVER,[ov]:n.ALWAYS,[pp]:n.LESS,[mp]:n.LEQUAL,[rv]:n.EQUAL,[av]:n.GEQUAL,[nv]:n.GREATER,[sv]:n.NOTEQUAL};function Ve(R,S){if(S.type===Oi&&e.has("OES_texture_float_linear")===!1&&(S.magFilter===Lt||S.magFilter===Wn||S.magFilter===Mn||S.magFilter===ji||S.minFilter===Lt||S.minFilter===Wn||S.minFilter===Mn||S.minFilter===ji)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(R,n.TEXTURE_WRAP_S,Q[S.wrapS]),n.texParameteri(R,n.TEXTURE_WRAP_T,Q[S.wrapT]),(R===n.TEXTURE_3D||R===n.TEXTURE_2D_ARRAY)&&n.texParameteri(R,n.TEXTURE_WRAP_R,Q[S.wrapR]),n.texParameteri(R,n.TEXTURE_MAG_FILTER,ye[S.magFilter]),n.texParameteri(R,n.TEXTURE_MIN_FILTER,ye[S.minFilter]),S.compareFunction&&(n.texParameteri(R,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(R,n.TEXTURE_COMPARE_FUNC,be[S.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(S.magFilter===$t||S.minFilter!==Mn&&S.minFilter!==ji||S.type===Oi&&e.has("OES_texture_float_linear")===!1)return;if(S.anisotropy>1||i.get(S).__currentAnisotropy){const W=e.get("EXT_texture_filter_anisotropic");n.texParameterf(R,W.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(S.anisotropy,r.getMaxAnisotropy())),i.get(S).__currentAnisotropy=S.anisotropy}}}function at(R,S){let W=!1;R.__webglInit===void 0&&(R.__webglInit=!0,S.addEventListener("dispose",I));const ne=S.source;let de=d.get(ne);de===void 0&&(de={},d.set(ne,de));const se=j(S);if(se!==R.__cacheKey){de[se]===void 0&&(de[se]={texture:n.createTexture(),usedTimes:0},a.memory.textures++,W=!0),de[se].usedTimes++;const ke=de[R.__cacheKey];ke!==void 0&&(de[R.__cacheKey].usedTimes--,ke.usedTimes===0&&C(S)),R.__cacheKey=se,R.__webglTexture=de[se].texture}return W}function et(R,S,W){let ne=n.TEXTURE_2D;(S.isDataArrayTexture||S.isCompressedArrayTexture)&&(ne=n.TEXTURE_2D_ARRAY),S.isData3DTexture&&(ne=n.TEXTURE_3D);const de=at(R,S),se=S.source;t.bindTexture(ne,R.__webglTexture,n.TEXTURE0+W);const ke=i.get(se);if(se.version!==ke.__version||de===!0){t.activeTexture(n.TEXTURE0+W);const Ee=vt.getPrimaries(vt.workingColorSpace),Pe=S.colorSpace===Cr?null:vt.getPrimaries(S.colorSpace),mt=S.colorSpace===Cr||Ee===Pe?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,S.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,S.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,S.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,mt);let ve=v(S.image,!1,r.maxTextureSize);ve=$e(S,ve);const ze=s.convert(S.format,S.colorSpace),tt=s.convert(S.type);let it=x(S.internalFormat,ze,tt,S.colorSpace,S.isVideoTexture);Ve(ne,S);let Oe;const Mt=S.mipmaps,ut=S.isVideoTexture!==!0,Dt=ke.__version===void 0||de===!0,O=se.dataReady,Ce=_(S,ve);if(S.isDepthTexture)it=y(S.format===qn,S.type),Dt&&(ut?t.texStorage2D(n.TEXTURE_2D,1,it,ve.width,ve.height):t.texImage2D(n.TEXTURE_2D,0,it,ve.width,ve.height,0,ze,tt,null));else if(S.isDataTexture)if(Mt.length>0){ut&&Dt&&t.texStorage2D(n.TEXTURE_2D,Ce,it,Mt[0].width,Mt[0].height);for(let ee=0,oe=Mt.length;ee<oe;ee++)Oe=Mt[ee],ut?O&&t.texSubImage2D(n.TEXTURE_2D,ee,0,0,Oe.width,Oe.height,ze,tt,Oe.data):t.texImage2D(n.TEXTURE_2D,ee,it,Oe.width,Oe.height,0,ze,tt,Oe.data);S.generateMipmaps=!1}else ut?(Dt&&t.texStorage2D(n.TEXTURE_2D,Ce,it,ve.width,ve.height),O&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,ve.width,ve.height,ze,tt,ve.data)):t.texImage2D(n.TEXTURE_2D,0,it,ve.width,ve.height,0,ze,tt,ve.data);else if(S.isCompressedTexture)if(S.isCompressedArrayTexture){ut&&Dt&&t.texStorage3D(n.TEXTURE_2D_ARRAY,Ce,it,Mt[0].width,Mt[0].height,ve.depth);for(let ee=0,oe=Mt.length;ee<oe;ee++)if(Oe=Mt[ee],S.format!==Ei)if(ze!==null)if(ut){if(O)if(S.layerUpdates.size>0){const Ne=Yp(Oe.width,Oe.height,S.format,S.type);for(const Ae of S.layerUpdates){const Ut=Oe.data.subarray(Ae*Ne/Oe.data.BYTES_PER_ELEMENT,(Ae+1)*Ne/Oe.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,ee,0,0,Ae,Oe.width,Oe.height,1,ze,Ut,0,0)}S.clearLayerUpdates()}else t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,ee,0,0,0,Oe.width,Oe.height,ve.depth,ze,Oe.data,0,0)}else t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,ee,it,Oe.width,Oe.height,ve.depth,0,Oe.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else ut?O&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,ee,0,0,0,Oe.width,Oe.height,ve.depth,ze,tt,Oe.data):t.texImage3D(n.TEXTURE_2D_ARRAY,ee,it,Oe.width,Oe.height,ve.depth,0,ze,tt,Oe.data)}else{ut&&Dt&&t.texStorage2D(n.TEXTURE_2D,Ce,it,Mt[0].width,Mt[0].height);for(let ee=0,oe=Mt.length;ee<oe;ee++)Oe=Mt[ee],S.format!==Ei?ze!==null?ut?O&&t.compressedTexSubImage2D(n.TEXTURE_2D,ee,0,0,Oe.width,Oe.height,ze,Oe.data):t.compressedTexImage2D(n.TEXTURE_2D,ee,it,Oe.width,Oe.height,0,Oe.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ut?O&&t.texSubImage2D(n.TEXTURE_2D,ee,0,0,Oe.width,Oe.height,ze,tt,Oe.data):t.texImage2D(n.TEXTURE_2D,ee,it,Oe.width,Oe.height,0,ze,tt,Oe.data)}else if(S.isDataArrayTexture)if(ut){if(Dt&&t.texStorage3D(n.TEXTURE_2D_ARRAY,Ce,it,ve.width,ve.height,ve.depth),O)if(S.layerUpdates.size>0){const ee=Yp(ve.width,ve.height,S.format,S.type);for(const oe of S.layerUpdates){const Ne=ve.data.subarray(oe*ee/ve.data.BYTES_PER_ELEMENT,(oe+1)*ee/ve.data.BYTES_PER_ELEMENT);t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,oe,ve.width,ve.height,1,ze,tt,Ne)}S.clearLayerUpdates()}else t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,ve.width,ve.height,ve.depth,ze,tt,ve.data)}else t.texImage3D(n.TEXTURE_2D_ARRAY,0,it,ve.width,ve.height,ve.depth,0,ze,tt,ve.data);else if(S.isData3DTexture)ut?(Dt&&t.texStorage3D(n.TEXTURE_3D,Ce,it,ve.width,ve.height,ve.depth),O&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,ve.width,ve.height,ve.depth,ze,tt,ve.data)):t.texImage3D(n.TEXTURE_3D,0,it,ve.width,ve.height,ve.depth,0,ze,tt,ve.data);else if(S.isFramebufferTexture){if(Dt)if(ut)t.texStorage2D(n.TEXTURE_2D,Ce,it,ve.width,ve.height);else{let ee=ve.width,oe=ve.height;for(let Ne=0;Ne<Ce;Ne++)t.texImage2D(n.TEXTURE_2D,Ne,it,ee,oe,0,ze,tt,null),ee>>=1,oe>>=1}}else if(Mt.length>0){if(ut&&Dt){const ee=Be(Mt[0]);t.texStorage2D(n.TEXTURE_2D,Ce,it,ee.width,ee.height)}for(let ee=0,oe=Mt.length;ee<oe;ee++)Oe=Mt[ee],ut?O&&t.texSubImage2D(n.TEXTURE_2D,ee,0,0,ze,tt,Oe):t.texImage2D(n.TEXTURE_2D,ee,it,ze,tt,Oe);S.generateMipmaps=!1}else if(ut){if(Dt){const ee=Be(ve);t.texStorage2D(n.TEXTURE_2D,Ce,it,ee.width,ee.height)}O&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,ze,tt,ve)}else t.texImage2D(n.TEXTURE_2D,0,it,ze,tt,ve);f(S)&&g(ne),ke.__version=se.version,S.onUpdate&&S.onUpdate(S)}R.__version=S.version}function ie(R,S,W){if(S.image.length!==6)return;const ne=at(R,S),de=S.source;t.bindTexture(n.TEXTURE_CUBE_MAP,R.__webglTexture,n.TEXTURE0+W);const se=i.get(de);if(de.version!==se.__version||ne===!0){t.activeTexture(n.TEXTURE0+W);const ke=vt.getPrimaries(vt.workingColorSpace),Ee=S.colorSpace===Cr?null:vt.getPrimaries(S.colorSpace),Pe=S.colorSpace===Cr||ke===Ee?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,S.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,S.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,S.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,Pe);const mt=S.isCompressedTexture||S.image[0].isCompressedTexture,ve=S.image[0]&&S.image[0].isDataTexture,ze=[];for(let oe=0;oe<6;oe++)!mt&&!ve?ze[oe]=v(S.image[oe],!0,r.maxCubemapSize):ze[oe]=ve?S.image[oe].image:S.image[oe],ze[oe]=$e(S,ze[oe]);const tt=ze[0],it=s.convert(S.format,S.colorSpace),Oe=s.convert(S.type),Mt=x(S.internalFormat,it,Oe,S.colorSpace),ut=S.isVideoTexture!==!0,Dt=se.__version===void 0||ne===!0,O=de.dataReady;let Ce=_(S,tt);Ve(n.TEXTURE_CUBE_MAP,S);let ee;if(mt){ut&&Dt&&t.texStorage2D(n.TEXTURE_CUBE_MAP,Ce,Mt,tt.width,tt.height);for(let oe=0;oe<6;oe++){ee=ze[oe].mipmaps;for(let Ne=0;Ne<ee.length;Ne++){const Ae=ee[Ne];S.format!==Ei?it!==null?ut?O&&t.compressedTexSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+oe,Ne,0,0,Ae.width,Ae.height,it,Ae.data):t.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+oe,Ne,Mt,Ae.width,Ae.height,0,Ae.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):ut?O&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+oe,Ne,0,0,Ae.width,Ae.height,it,Oe,Ae.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+oe,Ne,Mt,Ae.width,Ae.height,0,it,Oe,Ae.data)}}}else{if(ee=S.mipmaps,ut&&Dt){ee.length>0&&Ce++;const oe=Be(ze[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,Ce,Mt,oe.width,oe.height)}for(let oe=0;oe<6;oe++)if(ve){ut?O&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+oe,0,0,0,ze[oe].width,ze[oe].height,it,Oe,ze[oe].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+oe,0,Mt,ze[oe].width,ze[oe].height,0,it,Oe,ze[oe].data);for(let Ne=0;Ne<ee.length;Ne++){const Ae=ee[Ne].image[oe].image;ut?O&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+oe,Ne+1,0,0,Ae.width,Ae.height,it,Oe,Ae.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+oe,Ne+1,Mt,Ae.width,Ae.height,0,it,Oe,Ae.data)}}else{ut?O&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+oe,0,0,0,it,Oe,ze[oe]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+oe,0,Mt,it,Oe,ze[oe]);for(let Ne=0;Ne<ee.length;Ne++){const Ae=ee[Ne];ut?O&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+oe,Ne+1,0,0,it,Oe,Ae.image[oe]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+oe,Ne+1,Mt,it,Oe,Ae.image[oe])}}}f(S)&&g(n.TEXTURE_CUBE_MAP),se.__version=de.version,S.onUpdate&&S.onUpdate(S)}R.__version=S.version}function le(R,S,W,ne,de,se){const ke=s.convert(W.format,W.colorSpace),Ee=s.convert(W.type),Pe=x(W.internalFormat,ke,Ee,W.colorSpace);if(!i.get(S).__hasExternalTextures){const mt=Math.max(1,S.width>>se),ve=Math.max(1,S.height>>se);de===n.TEXTURE_3D||de===n.TEXTURE_2D_ARRAY?t.texImage3D(de,se,Pe,mt,ve,S.depth,0,ke,Ee,null):t.texImage2D(de,se,Pe,mt,ve,0,ke,Ee,null)}t.bindFramebuffer(n.FRAMEBUFFER,R),Ue(S)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,ne,de,i.get(W).__webglTexture,0,pe(S)):(de===n.TEXTURE_2D||de>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&de<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,ne,de,i.get(W).__webglTexture,se),t.bindFramebuffer(n.FRAMEBUFFER,null)}function Te(R,S,W){if(n.bindRenderbuffer(n.RENDERBUFFER,R),S.depthBuffer){const ne=S.depthTexture,de=ne&&ne.isDepthTexture?ne.type:null,se=y(S.stencilBuffer,de),ke=S.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,Ee=pe(S);Ue(S)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,Ee,se,S.width,S.height):W?n.renderbufferStorageMultisample(n.RENDERBUFFER,Ee,se,S.width,S.height):n.renderbufferStorage(n.RENDERBUFFER,se,S.width,S.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,ke,n.RENDERBUFFER,R)}else{const ne=S.textures;for(let de=0;de<ne.length;de++){const se=ne[de],ke=s.convert(se.format,se.colorSpace),Ee=s.convert(se.type),Pe=x(se.internalFormat,ke,Ee,se.colorSpace),mt=pe(S);W&&Ue(S)===!1?n.renderbufferStorageMultisample(n.RENDERBUFFER,mt,Pe,S.width,S.height):Ue(S)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,mt,Pe,S.width,S.height):n.renderbufferStorage(n.RENDERBUFFER,Pe,S.width,S.height)}}n.bindRenderbuffer(n.RENDERBUFFER,null)}function Se(R,S){if(S&&S.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(n.FRAMEBUFFER,R),!(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),Y(S.depthTexture,0);const W=i.get(S.depthTexture).__webglTexture,ne=pe(S);if(S.depthTexture.format===Xn)Ue(S)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,W,0,ne):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,W,0);else if(S.depthTexture.format===qn)Ue(S)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,W,0,ne):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,W,0);else throw new Error("Unknown depthTexture format")}function Ye(R){const S=i.get(R),W=R.isWebGLCubeRenderTarget===!0;if(S.__boundDepthTexture!==R.depthTexture){const ne=R.depthTexture;if(S.__depthDisposeCallback&&S.__depthDisposeCallback(),ne){const de=()=>{delete S.__boundDepthTexture,delete S.__depthDisposeCallback,ne.removeEventListener("dispose",de)};ne.addEventListener("dispose",de),S.__depthDisposeCallback=de}S.__boundDepthTexture=ne}if(R.depthTexture&&!S.__autoAllocateDepthBuffer){if(W)throw new Error("target.depthTexture not supported in Cube render targets");Se(S.__webglFramebuffer,R)}else if(W){S.__webglDepthbuffer=[];for(let ne=0;ne<6;ne++)if(t.bindFramebuffer(n.FRAMEBUFFER,S.__webglFramebuffer[ne]),S.__webglDepthbuffer[ne]===void 0)S.__webglDepthbuffer[ne]=n.createRenderbuffer(),Te(S.__webglDepthbuffer[ne],R,!1);else{const de=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,se=S.__webglDepthbuffer[ne];n.bindRenderbuffer(n.RENDERBUFFER,se),n.framebufferRenderbuffer(n.FRAMEBUFFER,de,n.RENDERBUFFER,se)}}else if(t.bindFramebuffer(n.FRAMEBUFFER,S.__webglFramebuffer),S.__webglDepthbuffer===void 0)S.__webglDepthbuffer=n.createRenderbuffer(),Te(S.__webglDepthbuffer,R,!1);else{const ne=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,de=S.__webglDepthbuffer;n.bindRenderbuffer(n.RENDERBUFFER,de),n.framebufferRenderbuffer(n.FRAMEBUFFER,ne,n.RENDERBUFFER,de)}t.bindFramebuffer(n.FRAMEBUFFER,null)}function We(R,S,W){const ne=i.get(R);S!==void 0&&le(ne.__webglFramebuffer,R,R.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),W!==void 0&&Ye(R)}function ot(R){const S=R.texture,W=i.get(R),ne=i.get(S);R.addEventListener("dispose",b);const de=R.textures,se=R.isWebGLCubeRenderTarget===!0,ke=de.length>1;if(ke||(ne.__webglTexture===void 0&&(ne.__webglTexture=n.createTexture()),ne.__version=S.version,a.memory.textures++),se){W.__webglFramebuffer=[];for(let Ee=0;Ee<6;Ee++)if(S.mipmaps&&S.mipmaps.length>0){W.__webglFramebuffer[Ee]=[];for(let Pe=0;Pe<S.mipmaps.length;Pe++)W.__webglFramebuffer[Ee][Pe]=n.createFramebuffer()}else W.__webglFramebuffer[Ee]=n.createFramebuffer()}else{if(S.mipmaps&&S.mipmaps.length>0){W.__webglFramebuffer=[];for(let Ee=0;Ee<S.mipmaps.length;Ee++)W.__webglFramebuffer[Ee]=n.createFramebuffer()}else W.__webglFramebuffer=n.createFramebuffer();if(ke)for(let Ee=0,Pe=de.length;Ee<Pe;Ee++){const mt=i.get(de[Ee]);mt.__webglTexture===void 0&&(mt.__webglTexture=n.createTexture(),a.memory.textures++)}if(R.samples>0&&Ue(R)===!1){W.__webglMultisampledFramebuffer=n.createFramebuffer(),W.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,W.__webglMultisampledFramebuffer);for(let Ee=0;Ee<de.length;Ee++){const Pe=de[Ee];W.__webglColorRenderbuffer[Ee]=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,W.__webglColorRenderbuffer[Ee]);const mt=s.convert(Pe.format,Pe.colorSpace),ve=s.convert(Pe.type),ze=x(Pe.internalFormat,mt,ve,Pe.colorSpace,R.isXRRenderTarget===!0),tt=pe(R);n.renderbufferStorageMultisample(n.RENDERBUFFER,tt,ze,R.width,R.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+Ee,n.RENDERBUFFER,W.__webglColorRenderbuffer[Ee])}n.bindRenderbuffer(n.RENDERBUFFER,null),R.depthBuffer&&(W.__webglDepthRenderbuffer=n.createRenderbuffer(),Te(W.__webglDepthRenderbuffer,R,!0)),t.bindFramebuffer(n.FRAMEBUFFER,null)}}if(se){t.bindTexture(n.TEXTURE_CUBE_MAP,ne.__webglTexture),Ve(n.TEXTURE_CUBE_MAP,S);for(let Ee=0;Ee<6;Ee++)if(S.mipmaps&&S.mipmaps.length>0)for(let Pe=0;Pe<S.mipmaps.length;Pe++)le(W.__webglFramebuffer[Ee][Pe],R,S,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+Ee,Pe);else le(W.__webglFramebuffer[Ee],R,S,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+Ee,0);f(S)&&g(n.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(ke){for(let Ee=0,Pe=de.length;Ee<Pe;Ee++){const mt=de[Ee],ve=i.get(mt);t.bindTexture(n.TEXTURE_2D,ve.__webglTexture),Ve(n.TEXTURE_2D,mt),le(W.__webglFramebuffer,R,mt,n.COLOR_ATTACHMENT0+Ee,n.TEXTURE_2D,0),f(mt)&&g(n.TEXTURE_2D)}t.unbindTexture()}else{let Ee=n.TEXTURE_2D;if((R.isWebGL3DRenderTarget||R.isWebGLArrayRenderTarget)&&(Ee=R.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(Ee,ne.__webglTexture),Ve(Ee,S),S.mipmaps&&S.mipmaps.length>0)for(let Pe=0;Pe<S.mipmaps.length;Pe++)le(W.__webglFramebuffer[Pe],R,S,n.COLOR_ATTACHMENT0,Ee,Pe);else le(W.__webglFramebuffer,R,S,n.COLOR_ATTACHMENT0,Ee,0);f(S)&&g(Ee),t.unbindTexture()}R.depthBuffer&&Ye(R)}function ce(R){const S=R.textures;for(let W=0,ne=S.length;W<ne;W++){const de=S[W];if(f(de)){const se=R.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:n.TEXTURE_2D,ke=i.get(de).__webglTexture;t.bindTexture(se,ke),g(se),t.unbindTexture()}}}const ue=[],L=[];function He(R){if(R.samples>0){if(Ue(R)===!1){const S=R.textures,W=R.width,ne=R.height;let de=n.COLOR_BUFFER_BIT;const se=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,ke=i.get(R),Ee=S.length>1;if(Ee)for(let Pe=0;Pe<S.length;Pe++)t.bindFramebuffer(n.FRAMEBUFFER,ke.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+Pe,n.RENDERBUFFER,null),t.bindFramebuffer(n.FRAMEBUFFER,ke.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+Pe,n.TEXTURE_2D,null,0);t.bindFramebuffer(n.READ_FRAMEBUFFER,ke.__webglMultisampledFramebuffer),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,ke.__webglFramebuffer);for(let Pe=0;Pe<S.length;Pe++){if(R.resolveDepthBuffer&&(R.depthBuffer&&(de|=n.DEPTH_BUFFER_BIT),R.stencilBuffer&&R.resolveStencilBuffer&&(de|=n.STENCIL_BUFFER_BIT)),Ee){n.framebufferRenderbuffer(n.READ_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,ke.__webglColorRenderbuffer[Pe]);const mt=i.get(S[Pe]).__webglTexture;n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,mt,0)}n.blitFramebuffer(0,0,W,ne,0,0,W,ne,de,n.NEAREST),l===!0&&(ue.length=0,L.length=0,ue.push(n.COLOR_ATTACHMENT0+Pe),R.depthBuffer&&R.resolveDepthBuffer===!1&&(ue.push(se),L.push(se),n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,L)),n.invalidateFramebuffer(n.READ_FRAMEBUFFER,ue))}if(t.bindFramebuffer(n.READ_FRAMEBUFFER,null),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),Ee)for(let Pe=0;Pe<S.length;Pe++){t.bindFramebuffer(n.FRAMEBUFFER,ke.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+Pe,n.RENDERBUFFER,ke.__webglColorRenderbuffer[Pe]);const mt=i.get(S[Pe]).__webglTexture;t.bindFramebuffer(n.FRAMEBUFFER,ke.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+Pe,n.TEXTURE_2D,mt,0)}t.bindFramebuffer(n.DRAW_FRAMEBUFFER,ke.__webglMultisampledFramebuffer)}else if(R.depthBuffer&&R.resolveDepthBuffer===!1&&l){const S=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,[S])}}}function pe(R){return Math.min(r.maxSamples,R.samples)}function Ue(R){const S=i.get(R);return R.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&S.__useRenderToTexture!==!1}function we(R){const S=a.render.frame;u.get(R)!==S&&(u.set(R,S),R.update())}function $e(R,S){const W=R.colorSpace,ne=R.format,de=R.type;return R.isCompressedTexture===!0||R.isVideoTexture===!0||W!==nr&&W!==Cr&&(vt.getTransfer(W)===Ot?(ne!==Ei||de!==Wr)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",W)),S}function Be(R){return typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement?(c.width=R.naturalWidth||R.width,c.height=R.naturalHeight||R.height):typeof VideoFrame<"u"&&R instanceof VideoFrame?(c.width=R.displayWidth,c.height=R.displayHeight):(c.width=R.width,c.height=R.height),c}this.allocateTextureUnit=k,this.resetTextureUnits=T,this.setTexture2D=Y,this.setTexture2DArray=re,this.setTexture3D=$,this.setTextureCube=he,this.rebindTextures=We,this.setupRenderTarget=ot,this.updateRenderTargetMipmap=ce,this.updateMultisampleRenderTarget=He,this.setupDepthRenderbuffer=Ye,this.setupFrameBufferTexture=le,this.useMultisampledRTT=Ue}function oy(n,e){function t(i,r=Cr){let s;const a=vt.getTransfer(r);if(i===Wr)return n.UNSIGNED_BYTE;if(i===Pc)return n.UNSIGNED_SHORT_4_4_4_4;if(i===Dc)return n.UNSIGNED_SHORT_5_5_5_1;if(i===tp)return n.UNSIGNED_INT_5_9_9_9_REV;if(i===Qd)return n.BYTE;if(i===ep)return n.SHORT;if(i===ga)return n.UNSIGNED_SHORT;if(i===va)return n.INT;if(i===Nr)return n.UNSIGNED_INT;if(i===Oi)return n.FLOAT;if(i===wi)return n.HALF_FLOAT;if(i===ip)return n.ALPHA;if(i===rp)return n.RGB;if(i===Ei)return n.RGBA;if(i===np)return n.LUMINANCE;if(i===sp)return n.LUMINANCE_ALPHA;if(i===Xn)return n.DEPTH_COMPONENT;if(i===qn)return n.DEPTH_STENCIL;if(i===Uo)return n.RED;if(i===Oo)return n.RED_INTEGER;if(i===ya)return n.RG;if(i===Uc)return n.RG_INTEGER;if(i===Oc)return n.RGBA_INTEGER;if(i===Fo||i===xa||i===Vo||i===_a)if(a===Ot)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===Fo)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===xa)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Vo)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===_a)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===Fo)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===xa)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Vo)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===_a)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Bo||i===Fc||i===zo||i===Vc)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===Bo)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Fc)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===zo)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Vc)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===ko||i===Ho||i===Go)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(i===ko||i===Ho)return a===Ot?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===Go)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(i===Wo||i===Bc||i===zc||i===kc||i===jo||i===Hc||i===Gc||i===Wc||i===jc||i===Xc||i===qc||i===Yc||i===$c||i===Jc)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(i===Wo)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Bc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===zc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===kc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===jo)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===Hc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Gc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Wc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===jc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Xc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===qc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Yc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===$c)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Jc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===Ma||i===Kc||i===Zc)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(i===Ma)return a===Ot?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===Kc)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===Zc)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===ap||i===Qc||i===eu||i===tu)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(i===Ma)return s.COMPRESSED_RED_RGTC1_EXT;if(i===Qc)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===eu)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===tu)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===jn?n.UNSIGNED_INT_24_8:n[i]!==void 0?n[i]:null}return{convert:t}}class $p extends di{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class Os extends _t{constructor(){super(),this.isGroup=!0,this.type="Group"}}const FR={type:"move"};class Jp{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Os,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Os,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new N,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new N),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Os,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new N,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new N),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let r=null,s=null,a=null;const o=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){a=!0;for(const v of e.hand.values()){const f=t.getJointPose(v,i),g=this._getHandJoint(c,v);f!==null&&(g.matrix.fromArray(f.transform.matrix),g.matrix.decompose(g.position,g.rotation,g.scale),g.matrixWorldNeedsUpdate=!0,g.jointRadius=f.radius),g.visible=f!==null}const u=c.joints["index-finger-tip"],h=c.joints["thumb-tip"],d=u.position.distanceTo(h.position),p=.02,m=.005;c.inputState.pinching&&d>p+m?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&d<=p-m&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&s!==null&&(r=s),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(FR)))}return o!==null&&(o.visible=r!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new Os;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}const VR=`
|
|
3823
|
+
}`;function NR(n,e,t){let i=new za;const r=new J,s=new J,a=new st,o=new Du({depthPacking:up}),l=new Xp,c={},u=t.maxTextureSize,h={[an]:si,[si]:an,[Gr]:Gr},d=new Pr({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new J},radius:{value:4}},vertexShader:ER,fragmentShader:AR}),p=d.clone();p.defines.HORIZONTAL_PASS=1;const m=new ct;m.setAttribute("position",new wt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new Ft(m,d),f=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Hd;let g=this.type;this.render=function(b,w,C){if(f.enabled===!1||f.autoUpdate===!1&&f.needsUpdate===!1||b.length===0)return;const H=n.getRenderTarget(),M=n.getActiveCubeFace(),T=n.getActiveMipmapLevel(),k=n.state;k.setBlending(Er),k.buffers.color.setClear(1,1,1,1),k.buffers.depth.setTest(!0),k.setScissorTest(!1);const j=g!==rr&&this.type===rr,Y=g===rr&&this.type!==rr;for(let re=0,$=b.length;re<$;re++){const he=b[re],Q=he.shadow;if(Q===void 0){console.warn("THREE.WebGLShadowMap:",he,"has no shadow.");continue}if(Q.autoUpdate===!1&&Q.needsUpdate===!1)continue;r.copy(Q.mapSize);const ye=Q.getFrameExtents();if(r.multiply(ye),s.copy(Q.mapSize),(r.x>u||r.y>u)&&(r.x>u&&(s.x=Math.floor(u/ye.x),r.x=s.x*ye.x,Q.mapSize.x=s.x),r.y>u&&(s.y=Math.floor(u/ye.y),r.y=s.y*ye.y,Q.mapSize.y=s.y)),Q.map===null||j===!0||Y===!0){const Ve=this.type!==rr?{minFilter:$t,magFilter:$t}:{};Q.map!==null&&Q.map.dispose(),Q.map=new Ir(r.x,r.y,Ve),Q.map.texture.name=he.name+".shadowMap",Q.camera.updateProjectionMatrix()}n.setRenderTarget(Q.map),n.clear();const be=Q.getViewportCount();for(let Ve=0;Ve<be;Ve++){const at=Q.getViewport(Ve);a.set(s.x*at.x,s.y*at.y,s.x*at.z,s.y*at.w),k.viewport(a),Q.updateMatrices(he,Ve),i=Q.getFrustum(),_(w,C,Q.camera,he,this.type)}Q.isPointLightShadow!==!0&&this.type===rr&&x(Q,C),Q.needsUpdate=!1}g=this.type,f.needsUpdate=!1,n.setRenderTarget(H,M,T)};function x(b,w){const C=e.update(v);d.defines.VSM_SAMPLES!==b.blurSamples&&(d.defines.VSM_SAMPLES=b.blurSamples,p.defines.VSM_SAMPLES=b.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),b.mapPass===null&&(b.mapPass=new Ir(r.x,r.y)),d.uniforms.shadow_pass.value=b.map.texture,d.uniforms.resolution.value=b.mapSize,d.uniforms.radius.value=b.radius,n.setRenderTarget(b.mapPass),n.clear(),n.renderBufferDirect(w,null,C,d,v,null),p.uniforms.shadow_pass.value=b.mapPass.texture,p.uniforms.resolution.value=b.mapSize,p.uniforms.radius.value=b.radius,n.setRenderTarget(b.map),n.clear(),n.renderBufferDirect(w,null,C,p,v,null)}function y(b,w,C,H){let M=null;const T=C.isPointLight===!0?b.customDistanceMaterial:b.customDepthMaterial;if(T!==void 0)M=T;else if(M=C.isPointLight===!0?l:o,n.localClippingEnabled&&w.clipShadows===!0&&Array.isArray(w.clippingPlanes)&&w.clippingPlanes.length!==0||w.displacementMap&&w.displacementScale!==0||w.alphaMap&&w.alphaTest>0||w.map&&w.alphaTest>0){const k=M.uuid,j=w.uuid;let Y=c[k];Y===void 0&&(Y={},c[k]=Y);let re=Y[j];re===void 0&&(re=M.clone(),Y[j]=re,w.addEventListener("dispose",I)),M=re}if(M.visible=w.visible,M.wireframe=w.wireframe,H===rr?M.side=w.shadowSide!==null?w.shadowSide:w.side:M.side=w.shadowSide!==null?w.shadowSide:h[w.side],M.alphaMap=w.alphaMap,M.alphaTest=w.alphaTest,M.map=w.map,M.clipShadows=w.clipShadows,M.clippingPlanes=w.clippingPlanes,M.clipIntersection=w.clipIntersection,M.displacementMap=w.displacementMap,M.displacementScale=w.displacementScale,M.displacementBias=w.displacementBias,M.wireframeLinewidth=w.wireframeLinewidth,M.linewidth=w.linewidth,C.isPointLight===!0&&M.isMeshDistanceMaterial===!0){const k=n.properties.get(M);k.light=C}return M}function _(b,w,C,H,M){if(b.visible===!1)return;if(b.layers.test(w.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&M===rr)&&(!b.frustumCulled||i.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(C.matrixWorldInverse,b.matrixWorld);const k=e.update(b),j=b.material;if(Array.isArray(j)){const Y=k.groups;for(let re=0,$=Y.length;re<$;re++){const he=Y[re],Q=j[he.materialIndex];if(Q&&Q.visible){const ye=y(b,Q,H,M);b.onBeforeShadow(n,b,w,C,k,ye,he),n.renderBufferDirect(C,null,k,ye,b,he),b.onAfterShadow(n,b,w,C,k,ye,he)}}}else if(j.visible){const Y=y(b,j,H,M);b.onBeforeShadow(n,b,w,C,k,Y,null),n.renderBufferDirect(C,null,k,Y,b,null),b.onAfterShadow(n,b,w,C,k,Y,null)}}const T=b.children;for(let k=0,j=T.length;k<j;k++)_(T[k],w,C,H,M)}function I(b){b.target.removeEventListener("dispose",I);for(const w in c){const C=c[w],H=b.target.uuid;H in C&&(C[H].dispose(),delete C[H])}}}const CR={[Ao]:No,[Co]:Lo,[Ro]:Po,[Bn]:Io,[No]:Ao,[Lo]:Co,[Po]:Ro,[Io]:Bn};function RR(n){function e(){let O=!1;const Ce=new st;let ee=null;const oe=new st(0,0,0,0);return{setMask:function(Ne){ee!==Ne&&!O&&(n.colorMask(Ne,Ne,Ne,Ne),ee=Ne)},setLocked:function(Ne){O=Ne},setClear:function(Ne,Ae,Ut,ni,tr){tr===!0&&(Ne*=ni,Ae*=ni,Ut*=ni),Ce.set(Ne,Ae,Ut,ni),oe.equals(Ce)===!1&&(n.clearColor(Ne,Ae,Ut,ni),oe.copy(Ce))},reset:function(){O=!1,ee=null,oe.set(-1,0,0,0)}}}function t(){let O=!1,Ce=!1,ee=null,oe=null,Ne=null;return{setReversed:function(Ae){Ce=Ae},setTest:function(Ae){Ae?Te(n.DEPTH_TEST):Se(n.DEPTH_TEST)},setMask:function(Ae){ee!==Ae&&!O&&(n.depthMask(Ae),ee=Ae)},setFunc:function(Ae){if(Ce&&(Ae=CR[Ae]),oe!==Ae){switch(Ae){case Ao:n.depthFunc(n.NEVER);break;case No:n.depthFunc(n.ALWAYS);break;case Co:n.depthFunc(n.LESS);break;case Bn:n.depthFunc(n.LEQUAL);break;case Ro:n.depthFunc(n.EQUAL);break;case Io:n.depthFunc(n.GEQUAL);break;case Lo:n.depthFunc(n.GREATER);break;case Po:n.depthFunc(n.NOTEQUAL);break;default:n.depthFunc(n.LEQUAL)}oe=Ae}},setLocked:function(Ae){O=Ae},setClear:function(Ae){Ne!==Ae&&(n.clearDepth(Ae),Ne=Ae)},reset:function(){O=!1,ee=null,oe=null,Ne=null}}}function i(){let O=!1,Ce=null,ee=null,oe=null,Ne=null,Ae=null,Ut=null,ni=null,tr=null;return{setTest:function(At){O||(At?Te(n.STENCIL_TEST):Se(n.STENCIL_TEST))},setMask:function(At){Ce!==At&&!O&&(n.stencilMask(At),Ce=At)},setFunc:function(At,ir,xn){(ee!==At||oe!==ir||Ne!==xn)&&(n.stencilFunc(At,ir,xn),ee=At,oe=ir,Ne=xn)},setOp:function(At,ir,xn){(Ae!==At||Ut!==ir||ni!==xn)&&(n.stencilOp(At,ir,xn),Ae=At,Ut=ir,ni=xn)},setLocked:function(At){O=At},setClear:function(At){tr!==At&&(n.clearStencil(At),tr=At)},reset:function(){O=!1,Ce=null,ee=null,oe=null,Ne=null,Ae=null,Ut=null,ni=null,tr=null}}}const r=new e,s=new t,a=new i,o=new WeakMap,l=new WeakMap;let c={},u={},h=new WeakMap,d=[],p=null,m=!1,v=null,f=null,g=null,x=null,y=null,_=null,I=null,b=new xe(0,0,0),w=0,C=!1,H=null,M=null,T=null,k=null,j=null;const Y=n.getParameter(n.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let re=!1,$=0;const he=n.getParameter(n.VERSION);he.indexOf("WebGL")!==-1?($=parseFloat(/^WebGL (\d)/.exec(he)[1]),re=$>=1):he.indexOf("OpenGL ES")!==-1&&($=parseFloat(/^OpenGL ES (\d)/.exec(he)[1]),re=$>=2);let Q=null,ye={};const be=n.getParameter(n.SCISSOR_BOX),Ve=n.getParameter(n.VIEWPORT),at=new st().fromArray(be),et=new st().fromArray(Ve);function ie(O,Ce,ee,oe){const Ne=new Uint8Array(4),Ae=n.createTexture();n.bindTexture(O,Ae),n.texParameteri(O,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(O,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let Ut=0;Ut<ee;Ut++)O===n.TEXTURE_3D||O===n.TEXTURE_2D_ARRAY?n.texImage3D(Ce,0,n.RGBA,1,1,oe,0,n.RGBA,n.UNSIGNED_BYTE,Ne):n.texImage2D(Ce+Ut,0,n.RGBA,1,1,0,n.RGBA,n.UNSIGNED_BYTE,Ne);return Ae}const le={};le[n.TEXTURE_2D]=ie(n.TEXTURE_2D,n.TEXTURE_2D,1),le[n.TEXTURE_CUBE_MAP]=ie(n.TEXTURE_CUBE_MAP,n.TEXTURE_CUBE_MAP_POSITIVE_X,6),le[n.TEXTURE_2D_ARRAY]=ie(n.TEXTURE_2D_ARRAY,n.TEXTURE_2D_ARRAY,1,1),le[n.TEXTURE_3D]=ie(n.TEXTURE_3D,n.TEXTURE_3D,1,1),r.setClear(0,0,0,1),s.setClear(1),a.setClear(0),Te(n.DEPTH_TEST),s.setFunc(Bn),pe(!1),Ue(kd),Te(n.CULL_FACE),L(Er);function Te(O){c[O]!==!0&&(n.enable(O),c[O]=!0)}function Se(O){c[O]!==!1&&(n.disable(O),c[O]=!1)}function Ye(O,Ce){return u[O]!==Ce?(n.bindFramebuffer(O,Ce),u[O]=Ce,O===n.DRAW_FRAMEBUFFER&&(u[n.FRAMEBUFFER]=Ce),O===n.FRAMEBUFFER&&(u[n.DRAW_FRAMEBUFFER]=Ce),!0):!1}function We(O,Ce){let ee=d,oe=!1;if(O){ee=h.get(Ce),ee===void 0&&(ee=[],h.set(Ce,ee));const Ne=O.textures;if(ee.length!==Ne.length||ee[0]!==n.COLOR_ATTACHMENT0){for(let Ae=0,Ut=Ne.length;Ae<Ut;Ae++)ee[Ae]=n.COLOR_ATTACHMENT0+Ae;ee.length=Ne.length,oe=!0}}else ee[0]!==n.BACK&&(ee[0]=n.BACK,oe=!0);oe&&n.drawBuffers(ee)}function ot(O){return p!==O?(n.useProgram(O),p=O,!0):!1}const ce={[Vn]:n.FUNC_ADD,[y0]:n.FUNC_SUBTRACT,[x0]:n.FUNC_REVERSE_SUBTRACT};ce[_0]=n.MIN,ce[qd]=n.MAX;const ue={[M0]:n.ZERO,[b0]:n.ONE,[T0]:n.SRC_COLOR,[Tc]:n.SRC_ALPHA,[C0]:n.SRC_ALPHA_SATURATE,[A0]:n.DST_COLOR,[w0]:n.DST_ALPHA,[S0]:n.ONE_MINUS_SRC_COLOR,[Sc]:n.ONE_MINUS_SRC_ALPHA,[N0]:n.ONE_MINUS_DST_COLOR,[E0]:n.ONE_MINUS_DST_ALPHA,[R0]:n.CONSTANT_COLOR,[I0]:n.ONE_MINUS_CONSTANT_COLOR,[L0]:n.CONSTANT_ALPHA,[P0]:n.ONE_MINUS_CONSTANT_ALPHA};function L(O,Ce,ee,oe,Ne,Ae,Ut,ni,tr,At){if(O===Er){m===!0&&(Se(n.BLEND),m=!1);return}if(m===!1&&(Te(n.BLEND),m=!0),O!==Xd){if(O!==v||At!==C){if((f!==Vn||y!==Vn)&&(n.blendEquation(n.FUNC_ADD),f=Vn,y=Vn),At)switch(O){case _n:n.blendFuncSeparate(n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case Eo:n.blendFunc(n.ONE,n.ONE);break;case Wd:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case jd:n.blendFuncSeparate(n.ZERO,n.SRC_COLOR,n.ZERO,n.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",O);break}else switch(O){case _n:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case Eo:n.blendFunc(n.SRC_ALPHA,n.ONE);break;case Wd:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case jd:n.blendFunc(n.ZERO,n.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",O);break}g=null,x=null,_=null,I=null,b.set(0,0,0),w=0,v=O,C=At}return}Ne=Ne||Ce,Ae=Ae||ee,Ut=Ut||oe,(Ce!==f||Ne!==y)&&(n.blendEquationSeparate(ce[Ce],ce[Ne]),f=Ce,y=Ne),(ee!==g||oe!==x||Ae!==_||Ut!==I)&&(n.blendFuncSeparate(ue[ee],ue[oe],ue[Ae],ue[Ut]),g=ee,x=oe,_=Ae,I=Ut),(ni.equals(b)===!1||tr!==w)&&(n.blendColor(ni.r,ni.g,ni.b,tr),b.copy(ni),w=tr),v=O,C=!1}function He(O,Ce){O.side===Gr?Se(n.CULL_FACE):Te(n.CULL_FACE);let ee=O.side===si;Ce&&(ee=!ee),pe(ee),O.blending===_n&&O.transparent===!1?L(Er):L(O.blending,O.blendEquation,O.blendSrc,O.blendDst,O.blendEquationAlpha,O.blendSrcAlpha,O.blendDstAlpha,O.blendColor,O.blendAlpha,O.premultipliedAlpha),s.setFunc(O.depthFunc),s.setTest(O.depthTest),s.setMask(O.depthWrite),r.setMask(O.colorWrite);const oe=O.stencilWrite;a.setTest(oe),oe&&(a.setMask(O.stencilWriteMask),a.setFunc(O.stencilFunc,O.stencilRef,O.stencilFuncMask),a.setOp(O.stencilFail,O.stencilZFail,O.stencilZPass)),$e(O.polygonOffset,O.polygonOffsetFactor,O.polygonOffsetUnits),O.alphaToCoverage===!0?Te(n.SAMPLE_ALPHA_TO_COVERAGE):Se(n.SAMPLE_ALPHA_TO_COVERAGE)}function pe(O){H!==O&&(O?n.frontFace(n.CW):n.frontFace(n.CCW),H=O)}function Ue(O){O!==g0?(Te(n.CULL_FACE),O!==M&&(O===kd?n.cullFace(n.BACK):O===v0?n.cullFace(n.FRONT):n.cullFace(n.FRONT_AND_BACK))):Se(n.CULL_FACE),M=O}function we(O){O!==T&&(re&&n.lineWidth(O),T=O)}function $e(O,Ce,ee){O?(Te(n.POLYGON_OFFSET_FILL),(k!==Ce||j!==ee)&&(n.polygonOffset(Ce,ee),k=Ce,j=ee)):Se(n.POLYGON_OFFSET_FILL)}function Be(O){O?Te(n.SCISSOR_TEST):Se(n.SCISSOR_TEST)}function R(O){O===void 0&&(O=n.TEXTURE0+Y-1),Q!==O&&(n.activeTexture(O),Q=O)}function S(O,Ce,ee){ee===void 0&&(Q===null?ee=n.TEXTURE0+Y-1:ee=Q);let oe=ye[ee];oe===void 0&&(oe={type:void 0,texture:void 0},ye[ee]=oe),(oe.type!==O||oe.texture!==Ce)&&(Q!==ee&&(n.activeTexture(ee),Q=ee),n.bindTexture(O,Ce||le[O]),oe.type=O,oe.texture=Ce)}function W(){const O=ye[Q];O!==void 0&&O.type!==void 0&&(n.bindTexture(O.type,null),O.type=void 0,O.texture=void 0)}function ne(){try{n.compressedTexImage2D.apply(n,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function de(){try{n.compressedTexImage3D.apply(n,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function se(){try{n.texSubImage2D.apply(n,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function ke(){try{n.texSubImage3D.apply(n,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function Ee(){try{n.compressedTexSubImage2D.apply(n,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function Pe(){try{n.compressedTexSubImage3D.apply(n,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function mt(){try{n.texStorage2D.apply(n,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function ve(){try{n.texStorage3D.apply(n,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function ze(){try{n.texImage2D.apply(n,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function tt(){try{n.texImage3D.apply(n,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function it(O){at.equals(O)===!1&&(n.scissor(O.x,O.y,O.z,O.w),at.copy(O))}function Oe(O){et.equals(O)===!1&&(n.viewport(O.x,O.y,O.z,O.w),et.copy(O))}function Mt(O,Ce){let ee=l.get(Ce);ee===void 0&&(ee=new WeakMap,l.set(Ce,ee));let oe=ee.get(O);oe===void 0&&(oe=n.getUniformBlockIndex(Ce,O.name),ee.set(O,oe))}function ut(O,Ce){const ee=l.get(Ce).get(O);o.get(Ce)!==ee&&(n.uniformBlockBinding(Ce,ee,O.__bindingPointIndex),o.set(Ce,ee))}function Dt(){n.disable(n.BLEND),n.disable(n.CULL_FACE),n.disable(n.DEPTH_TEST),n.disable(n.POLYGON_OFFSET_FILL),n.disable(n.SCISSOR_TEST),n.disable(n.STENCIL_TEST),n.disable(n.SAMPLE_ALPHA_TO_COVERAGE),n.blendEquation(n.FUNC_ADD),n.blendFunc(n.ONE,n.ZERO),n.blendFuncSeparate(n.ONE,n.ZERO,n.ONE,n.ZERO),n.blendColor(0,0,0,0),n.colorMask(!0,!0,!0,!0),n.clearColor(0,0,0,0),n.depthMask(!0),n.depthFunc(n.LESS),n.clearDepth(1),n.stencilMask(4294967295),n.stencilFunc(n.ALWAYS,0,4294967295),n.stencilOp(n.KEEP,n.KEEP,n.KEEP),n.clearStencil(0),n.cullFace(n.BACK),n.frontFace(n.CCW),n.polygonOffset(0,0),n.activeTexture(n.TEXTURE0),n.bindFramebuffer(n.FRAMEBUFFER,null),n.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),n.bindFramebuffer(n.READ_FRAMEBUFFER,null),n.useProgram(null),n.lineWidth(1),n.scissor(0,0,n.canvas.width,n.canvas.height),n.viewport(0,0,n.canvas.width,n.canvas.height),c={},Q=null,ye={},u={},h=new WeakMap,d=[],p=null,m=!1,v=null,f=null,g=null,x=null,y=null,_=null,I=null,b=new xe(0,0,0),w=0,C=!1,H=null,M=null,T=null,k=null,j=null,at.set(0,0,n.canvas.width,n.canvas.height),et.set(0,0,n.canvas.width,n.canvas.height),r.reset(),s.reset(),a.reset()}return{buffers:{color:r,depth:s,stencil:a},enable:Te,disable:Se,bindFramebuffer:Ye,drawBuffers:We,useProgram:ot,setBlending:L,setMaterial:He,setFlipSided:pe,setCullFace:Ue,setLineWidth:we,setPolygonOffset:$e,setScissorTest:Be,activeTexture:R,bindTexture:S,unbindTexture:W,compressedTexImage2D:ne,compressedTexImage3D:de,texImage2D:ze,texImage3D:tt,updateUBOMapping:Mt,uniformBlockBinding:ut,texStorage2D:mt,texStorage3D:ve,texSubImage2D:se,texSubImage3D:ke,compressedTexSubImage2D:Ee,compressedTexSubImage3D:Pe,scissor:it,viewport:Oe,reset:Dt}}function IR(n,e){const t=n.image&&n.image.width?n.image.width/n.image.height:1;return t>e?(n.repeat.x=1,n.repeat.y=t/e,n.offset.x=0,n.offset.y=(1-n.repeat.y)/2):(n.repeat.x=e/t,n.repeat.y=1,n.offset.x=(1-n.repeat.x)/2,n.offset.y=0),n}function LR(n,e){const t=n.image&&n.image.width?n.image.width/n.image.height:1;return t>e?(n.repeat.x=e/t,n.repeat.y=1,n.offset.x=(1-n.repeat.x)/2,n.offset.y=0):(n.repeat.x=1,n.repeat.y=t/e,n.offset.x=0,n.offset.y=(1-n.repeat.y)/2),n}function PR(n){return n.repeat.x=1,n.repeat.y=1,n.offset.x=0,n.offset.y=0,n}function qp(n,e,t,i){const r=DR(i);switch(t){case tp:return n*e;case rp:return n*e;case np:return n*e*2;case Do:return n*e/r.components*r.byteLength;case Uo:return n*e/r.components*r.byteLength;case va:return n*e*2/r.components*r.byteLength;case Dc:return n*e*2/r.components*r.byteLength;case ip:return n*e*3/r.components*r.byteLength;case Ei:return n*e*4/r.components*r.byteLength;case Uc:return n*e*4/r.components*r.byteLength;case Oo:case ya:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Fo:case xa:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Oc:case Fc:return Math.max(n,16)*Math.max(e,8)/4;case Vo:case Bo:return Math.max(n,8)*Math.max(e,8)/2;case zo:case ko:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Ho:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Go:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Vc:return Math.floor((n+4)/5)*Math.floor((e+3)/4)*16;case Bc:return Math.floor((n+4)/5)*Math.floor((e+4)/5)*16;case zc:return Math.floor((n+5)/6)*Math.floor((e+4)/5)*16;case Wo:return Math.floor((n+5)/6)*Math.floor((e+5)/6)*16;case kc:return Math.floor((n+7)/8)*Math.floor((e+4)/5)*16;case Hc:return Math.floor((n+7)/8)*Math.floor((e+5)/6)*16;case Gc:return Math.floor((n+7)/8)*Math.floor((e+7)/8)*16;case Wc:return Math.floor((n+9)/10)*Math.floor((e+4)/5)*16;case jc:return Math.floor((n+9)/10)*Math.floor((e+5)/6)*16;case Xc:return Math.floor((n+9)/10)*Math.floor((e+7)/8)*16;case qc:return Math.floor((n+9)/10)*Math.floor((e+9)/10)*16;case Yc:return Math.floor((n+11)/12)*Math.floor((e+9)/10)*16;case $c:return Math.floor((n+11)/12)*Math.floor((e+11)/12)*16;case _a:case Jc:case Kc:return Math.ceil(n/4)*Math.ceil(e/4)*16;case sp:case Zc:return Math.ceil(n/4)*Math.ceil(e/4)*8;case Qc:case eu:return Math.ceil(n/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function DR(n){switch(n){case Wr:case Zd:return{byteLength:1,components:1};case fa:case Qd:case wi:return{byteLength:2,components:1};case Lc:case Pc:return{byteLength:2,components:4};case Nr:case ga:case Oi:return{byteLength:4,components:1};case ep:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${n}.`)}const UR={contain:IR,cover:LR,fill:PR,getByteLength:qp};function OR(n,e,t,i,r,s,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new J,u=new WeakMap;let h;const d=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function m(R,S){return p?new OffscreenCanvas(R,S):Zo("canvas")}function v(R,S,W){let ne=1;const de=Be(R);if((de.width>W||de.height>W)&&(ne=W/Math.max(de.width,de.height)),ne<1)if(typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&R instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&R instanceof ImageBitmap||typeof VideoFrame<"u"&&R instanceof VideoFrame){const se=Math.floor(ne*de.width),ke=Math.floor(ne*de.height);h===void 0&&(h=m(se,ke));const Ee=S?m(se,ke):h;return Ee.width=se,Ee.height=ke,Ee.getContext("2d").drawImage(R,0,0,se,ke),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+de.width+"x"+de.height+") to ("+se+"x"+ke+")."),Ee}else return"data"in R&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+de.width+"x"+de.height+")."),R;return R}function f(R){return R.generateMipmaps&&R.minFilter!==$t&&R.minFilter!==Lt}function g(R){n.generateMipmap(R)}function x(R,S,W,ne,de=!1){if(R!==null){if(n[R]!==void 0)return n[R];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+R+"'")}let se=S;if(S===n.RED&&(W===n.FLOAT&&(se=n.R32F),W===n.HALF_FLOAT&&(se=n.R16F),W===n.UNSIGNED_BYTE&&(se=n.R8)),S===n.RED_INTEGER&&(W===n.UNSIGNED_BYTE&&(se=n.R8UI),W===n.UNSIGNED_SHORT&&(se=n.R16UI),W===n.UNSIGNED_INT&&(se=n.R32UI),W===n.BYTE&&(se=n.R8I),W===n.SHORT&&(se=n.R16I),W===n.INT&&(se=n.R32I)),S===n.RG&&(W===n.FLOAT&&(se=n.RG32F),W===n.HALF_FLOAT&&(se=n.RG16F),W===n.UNSIGNED_BYTE&&(se=n.RG8)),S===n.RG_INTEGER&&(W===n.UNSIGNED_BYTE&&(se=n.RG8UI),W===n.UNSIGNED_SHORT&&(se=n.RG16UI),W===n.UNSIGNED_INT&&(se=n.RG32UI),W===n.BYTE&&(se=n.RG8I),W===n.SHORT&&(se=n.RG16I),W===n.INT&&(se=n.RG32I)),S===n.RGB_INTEGER&&(W===n.UNSIGNED_BYTE&&(se=n.RGB8UI),W===n.UNSIGNED_SHORT&&(se=n.RGB16UI),W===n.UNSIGNED_INT&&(se=n.RGB32UI),W===n.BYTE&&(se=n.RGB8I),W===n.SHORT&&(se=n.RGB16I),W===n.INT&&(se=n.RGB32I)),S===n.RGBA_INTEGER&&(W===n.UNSIGNED_BYTE&&(se=n.RGBA8UI),W===n.UNSIGNED_SHORT&&(se=n.RGBA16UI),W===n.UNSIGNED_INT&&(se=n.RGBA32UI),W===n.BYTE&&(se=n.RGBA8I),W===n.SHORT&&(se=n.RGBA16I),W===n.INT&&(se=n.RGBA32I)),S===n.RGB&&W===n.UNSIGNED_INT_5_9_9_9_REV&&(se=n.RGB9_E5),S===n.RGBA){const ke=de?Yo:vt.getTransfer(ne);W===n.FLOAT&&(se=n.RGBA32F),W===n.HALF_FLOAT&&(se=n.RGBA16F),W===n.UNSIGNED_BYTE&&(se=ke===Ot?n.SRGB8_ALPHA8:n.RGBA8),W===n.UNSIGNED_SHORT_4_4_4_4&&(se=n.RGBA4),W===n.UNSIGNED_SHORT_5_5_5_1&&(se=n.RGB5_A1)}return(se===n.R16F||se===n.R32F||se===n.RG16F||se===n.RG32F||se===n.RGBA16F||se===n.RGBA32F)&&e.get("EXT_color_buffer_float"),se}function y(R,S){let W;return R?S===null||S===Nr||S===Wn?W=n.DEPTH24_STENCIL8:S===Oi?W=n.DEPTH32F_STENCIL8:S===fa&&(W=n.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):S===null||S===Nr||S===Wn?W=n.DEPTH_COMPONENT24:S===Oi?W=n.DEPTH_COMPONENT32F:S===fa&&(W=n.DEPTH_COMPONENT16),W}function _(R,S){return f(R)===!0||R.isFramebufferTexture&&R.minFilter!==$t&&R.minFilter!==Lt?Math.log2(Math.max(S.width,S.height))+1:R.mipmaps!==void 0&&R.mipmaps.length>0?R.mipmaps.length:R.isCompressedTexture&&Array.isArray(R.image)?S.mipmaps.length:1}function I(R){const S=R.target;S.removeEventListener("dispose",I),w(S),S.isVideoTexture&&u.delete(S)}function b(R){const S=R.target;S.removeEventListener("dispose",b),H(S)}function w(R){const S=i.get(R);if(S.__webglInit===void 0)return;const W=R.source,ne=d.get(W);if(ne){const de=ne[S.__cacheKey];de.usedTimes--,de.usedTimes===0&&C(R),Object.keys(ne).length===0&&d.delete(W)}i.remove(R)}function C(R){const S=i.get(R);n.deleteTexture(S.__webglTexture);const W=R.source,ne=d.get(W);delete ne[S.__cacheKey],a.memory.textures--}function H(R){const S=i.get(R);if(R.depthTexture&&R.depthTexture.dispose(),R.isWebGLCubeRenderTarget)for(let ne=0;ne<6;ne++){if(Array.isArray(S.__webglFramebuffer[ne]))for(let de=0;de<S.__webglFramebuffer[ne].length;de++)n.deleteFramebuffer(S.__webglFramebuffer[ne][de]);else n.deleteFramebuffer(S.__webglFramebuffer[ne]);S.__webglDepthbuffer&&n.deleteRenderbuffer(S.__webglDepthbuffer[ne])}else{if(Array.isArray(S.__webglFramebuffer))for(let ne=0;ne<S.__webglFramebuffer.length;ne++)n.deleteFramebuffer(S.__webglFramebuffer[ne]);else n.deleteFramebuffer(S.__webglFramebuffer);if(S.__webglDepthbuffer&&n.deleteRenderbuffer(S.__webglDepthbuffer),S.__webglMultisampledFramebuffer&&n.deleteFramebuffer(S.__webglMultisampledFramebuffer),S.__webglColorRenderbuffer)for(let ne=0;ne<S.__webglColorRenderbuffer.length;ne++)S.__webglColorRenderbuffer[ne]&&n.deleteRenderbuffer(S.__webglColorRenderbuffer[ne]);S.__webglDepthRenderbuffer&&n.deleteRenderbuffer(S.__webglDepthRenderbuffer)}const W=R.textures;for(let ne=0,de=W.length;ne<de;ne++){const se=i.get(W[ne]);se.__webglTexture&&(n.deleteTexture(se.__webglTexture),a.memory.textures--),i.remove(W[ne])}i.remove(R)}let M=0;function T(){M=0}function k(){const R=M;return R>=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+r.maxTextures),M+=1,R}function j(R){const S=[];return S.push(R.wrapS),S.push(R.wrapT),S.push(R.wrapR||0),S.push(R.magFilter),S.push(R.minFilter),S.push(R.anisotropy),S.push(R.internalFormat),S.push(R.format),S.push(R.type),S.push(R.generateMipmaps),S.push(R.premultiplyAlpha),S.push(R.flipY),S.push(R.unpackAlignment),S.push(R.colorSpace),S.join()}function Y(R,S){const W=i.get(R);if(R.isVideoTexture&&we(R),R.isRenderTargetTexture===!1&&R.version>0&&W.__version!==R.version){const ne=R.image;if(ne===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ne.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{et(W,R,S);return}}t.bindTexture(n.TEXTURE_2D,W.__webglTexture,n.TEXTURE0+S)}function re(R,S){const W=i.get(R);if(R.version>0&&W.__version!==R.version){et(W,R,S);return}t.bindTexture(n.TEXTURE_2D_ARRAY,W.__webglTexture,n.TEXTURE0+S)}function $(R,S){const W=i.get(R);if(R.version>0&&W.__version!==R.version){et(W,R,S);return}t.bindTexture(n.TEXTURE_3D,W.__webglTexture,n.TEXTURE0+S)}function he(R,S){const W=i.get(R);if(R.version>0&&W.__version!==R.version){ie(W,R,S);return}t.bindTexture(n.TEXTURE_CUBE_MAP,W.__webglTexture,n.TEXTURE0+S)}const Q={[Hn]:n.REPEAT,[gr]:n.CLAMP_TO_EDGE,[ma]:n.MIRRORED_REPEAT},ye={[$t]:n.NEAREST,[Ic]:n.NEAREST_MIPMAP_NEAREST,[Mn]:n.NEAREST_MIPMAP_LINEAR,[Lt]:n.LINEAR,[Gn]:n.LINEAR_MIPMAP_NEAREST,[ji]:n.LINEAR_MIPMAP_LINEAR},be={[tv]:n.NEVER,[av]:n.ALWAYS,[dp]:n.LESS,[pp]:n.LEQUAL,[iv]:n.EQUAL,[sv]:n.GEQUAL,[rv]:n.GREATER,[nv]:n.NOTEQUAL};function Ve(R,S){if(S.type===Oi&&e.has("OES_texture_float_linear")===!1&&(S.magFilter===Lt||S.magFilter===Gn||S.magFilter===Mn||S.magFilter===ji||S.minFilter===Lt||S.minFilter===Gn||S.minFilter===Mn||S.minFilter===ji)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(R,n.TEXTURE_WRAP_S,Q[S.wrapS]),n.texParameteri(R,n.TEXTURE_WRAP_T,Q[S.wrapT]),(R===n.TEXTURE_3D||R===n.TEXTURE_2D_ARRAY)&&n.texParameteri(R,n.TEXTURE_WRAP_R,Q[S.wrapR]),n.texParameteri(R,n.TEXTURE_MAG_FILTER,ye[S.magFilter]),n.texParameteri(R,n.TEXTURE_MIN_FILTER,ye[S.minFilter]),S.compareFunction&&(n.texParameteri(R,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(R,n.TEXTURE_COMPARE_FUNC,be[S.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(S.magFilter===$t||S.minFilter!==Mn&&S.minFilter!==ji||S.type===Oi&&e.has("OES_texture_float_linear")===!1)return;if(S.anisotropy>1||i.get(S).__currentAnisotropy){const W=e.get("EXT_texture_filter_anisotropic");n.texParameterf(R,W.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(S.anisotropy,r.getMaxAnisotropy())),i.get(S).__currentAnisotropy=S.anisotropy}}}function at(R,S){let W=!1;R.__webglInit===void 0&&(R.__webglInit=!0,S.addEventListener("dispose",I));const ne=S.source;let de=d.get(ne);de===void 0&&(de={},d.set(ne,de));const se=j(S);if(se!==R.__cacheKey){de[se]===void 0&&(de[se]={texture:n.createTexture(),usedTimes:0},a.memory.textures++,W=!0),de[se].usedTimes++;const ke=de[R.__cacheKey];ke!==void 0&&(de[R.__cacheKey].usedTimes--,ke.usedTimes===0&&C(S)),R.__cacheKey=se,R.__webglTexture=de[se].texture}return W}function et(R,S,W){let ne=n.TEXTURE_2D;(S.isDataArrayTexture||S.isCompressedArrayTexture)&&(ne=n.TEXTURE_2D_ARRAY),S.isData3DTexture&&(ne=n.TEXTURE_3D);const de=at(R,S),se=S.source;t.bindTexture(ne,R.__webglTexture,n.TEXTURE0+W);const ke=i.get(se);if(se.version!==ke.__version||de===!0){t.activeTexture(n.TEXTURE0+W);const Ee=vt.getPrimaries(vt.workingColorSpace),Pe=S.colorSpace===Cr?null:vt.getPrimaries(S.colorSpace),mt=S.colorSpace===Cr||Ee===Pe?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,S.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,S.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,S.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,mt);let ve=v(S.image,!1,r.maxTextureSize);ve=$e(S,ve);const ze=s.convert(S.format,S.colorSpace),tt=s.convert(S.type);let it=x(S.internalFormat,ze,tt,S.colorSpace,S.isVideoTexture);Ve(ne,S);let Oe;const Mt=S.mipmaps,ut=S.isVideoTexture!==!0,Dt=ke.__version===void 0||de===!0,O=se.dataReady,Ce=_(S,ve);if(S.isDepthTexture)it=y(S.format===Xn,S.type),Dt&&(ut?t.texStorage2D(n.TEXTURE_2D,1,it,ve.width,ve.height):t.texImage2D(n.TEXTURE_2D,0,it,ve.width,ve.height,0,ze,tt,null));else if(S.isDataTexture)if(Mt.length>0){ut&&Dt&&t.texStorage2D(n.TEXTURE_2D,Ce,it,Mt[0].width,Mt[0].height);for(let ee=0,oe=Mt.length;ee<oe;ee++)Oe=Mt[ee],ut?O&&t.texSubImage2D(n.TEXTURE_2D,ee,0,0,Oe.width,Oe.height,ze,tt,Oe.data):t.texImage2D(n.TEXTURE_2D,ee,it,Oe.width,Oe.height,0,ze,tt,Oe.data);S.generateMipmaps=!1}else ut?(Dt&&t.texStorage2D(n.TEXTURE_2D,Ce,it,ve.width,ve.height),O&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,ve.width,ve.height,ze,tt,ve.data)):t.texImage2D(n.TEXTURE_2D,0,it,ve.width,ve.height,0,ze,tt,ve.data);else if(S.isCompressedTexture)if(S.isCompressedArrayTexture){ut&&Dt&&t.texStorage3D(n.TEXTURE_2D_ARRAY,Ce,it,Mt[0].width,Mt[0].height,ve.depth);for(let ee=0,oe=Mt.length;ee<oe;ee++)if(Oe=Mt[ee],S.format!==Ei)if(ze!==null)if(ut){if(O)if(S.layerUpdates.size>0){const Ne=qp(Oe.width,Oe.height,S.format,S.type);for(const Ae of S.layerUpdates){const Ut=Oe.data.subarray(Ae*Ne/Oe.data.BYTES_PER_ELEMENT,(Ae+1)*Ne/Oe.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,ee,0,0,Ae,Oe.width,Oe.height,1,ze,Ut,0,0)}S.clearLayerUpdates()}else t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,ee,0,0,0,Oe.width,Oe.height,ve.depth,ze,Oe.data,0,0)}else t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,ee,it,Oe.width,Oe.height,ve.depth,0,Oe.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else ut?O&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,ee,0,0,0,Oe.width,Oe.height,ve.depth,ze,tt,Oe.data):t.texImage3D(n.TEXTURE_2D_ARRAY,ee,it,Oe.width,Oe.height,ve.depth,0,ze,tt,Oe.data)}else{ut&&Dt&&t.texStorage2D(n.TEXTURE_2D,Ce,it,Mt[0].width,Mt[0].height);for(let ee=0,oe=Mt.length;ee<oe;ee++)Oe=Mt[ee],S.format!==Ei?ze!==null?ut?O&&t.compressedTexSubImage2D(n.TEXTURE_2D,ee,0,0,Oe.width,Oe.height,ze,Oe.data):t.compressedTexImage2D(n.TEXTURE_2D,ee,it,Oe.width,Oe.height,0,Oe.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ut?O&&t.texSubImage2D(n.TEXTURE_2D,ee,0,0,Oe.width,Oe.height,ze,tt,Oe.data):t.texImage2D(n.TEXTURE_2D,ee,it,Oe.width,Oe.height,0,ze,tt,Oe.data)}else if(S.isDataArrayTexture)if(ut){if(Dt&&t.texStorage3D(n.TEXTURE_2D_ARRAY,Ce,it,ve.width,ve.height,ve.depth),O)if(S.layerUpdates.size>0){const ee=qp(ve.width,ve.height,S.format,S.type);for(const oe of S.layerUpdates){const Ne=ve.data.subarray(oe*ee/ve.data.BYTES_PER_ELEMENT,(oe+1)*ee/ve.data.BYTES_PER_ELEMENT);t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,oe,ve.width,ve.height,1,ze,tt,Ne)}S.clearLayerUpdates()}else t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,ve.width,ve.height,ve.depth,ze,tt,ve.data)}else t.texImage3D(n.TEXTURE_2D_ARRAY,0,it,ve.width,ve.height,ve.depth,0,ze,tt,ve.data);else if(S.isData3DTexture)ut?(Dt&&t.texStorage3D(n.TEXTURE_3D,Ce,it,ve.width,ve.height,ve.depth),O&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,ve.width,ve.height,ve.depth,ze,tt,ve.data)):t.texImage3D(n.TEXTURE_3D,0,it,ve.width,ve.height,ve.depth,0,ze,tt,ve.data);else if(S.isFramebufferTexture){if(Dt)if(ut)t.texStorage2D(n.TEXTURE_2D,Ce,it,ve.width,ve.height);else{let ee=ve.width,oe=ve.height;for(let Ne=0;Ne<Ce;Ne++)t.texImage2D(n.TEXTURE_2D,Ne,it,ee,oe,0,ze,tt,null),ee>>=1,oe>>=1}}else if(Mt.length>0){if(ut&&Dt){const ee=Be(Mt[0]);t.texStorage2D(n.TEXTURE_2D,Ce,it,ee.width,ee.height)}for(let ee=0,oe=Mt.length;ee<oe;ee++)Oe=Mt[ee],ut?O&&t.texSubImage2D(n.TEXTURE_2D,ee,0,0,ze,tt,Oe):t.texImage2D(n.TEXTURE_2D,ee,it,ze,tt,Oe);S.generateMipmaps=!1}else if(ut){if(Dt){const ee=Be(ve);t.texStorage2D(n.TEXTURE_2D,Ce,it,ee.width,ee.height)}O&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,ze,tt,ve)}else t.texImage2D(n.TEXTURE_2D,0,it,ze,tt,ve);f(S)&&g(ne),ke.__version=se.version,S.onUpdate&&S.onUpdate(S)}R.__version=S.version}function ie(R,S,W){if(S.image.length!==6)return;const ne=at(R,S),de=S.source;t.bindTexture(n.TEXTURE_CUBE_MAP,R.__webglTexture,n.TEXTURE0+W);const se=i.get(de);if(de.version!==se.__version||ne===!0){t.activeTexture(n.TEXTURE0+W);const ke=vt.getPrimaries(vt.workingColorSpace),Ee=S.colorSpace===Cr?null:vt.getPrimaries(S.colorSpace),Pe=S.colorSpace===Cr||ke===Ee?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,S.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,S.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,S.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,Pe);const mt=S.isCompressedTexture||S.image[0].isCompressedTexture,ve=S.image[0]&&S.image[0].isDataTexture,ze=[];for(let oe=0;oe<6;oe++)!mt&&!ve?ze[oe]=v(S.image[oe],!0,r.maxCubemapSize):ze[oe]=ve?S.image[oe].image:S.image[oe],ze[oe]=$e(S,ze[oe]);const tt=ze[0],it=s.convert(S.format,S.colorSpace),Oe=s.convert(S.type),Mt=x(S.internalFormat,it,Oe,S.colorSpace),ut=S.isVideoTexture!==!0,Dt=se.__version===void 0||ne===!0,O=de.dataReady;let Ce=_(S,tt);Ve(n.TEXTURE_CUBE_MAP,S);let ee;if(mt){ut&&Dt&&t.texStorage2D(n.TEXTURE_CUBE_MAP,Ce,Mt,tt.width,tt.height);for(let oe=0;oe<6;oe++){ee=ze[oe].mipmaps;for(let Ne=0;Ne<ee.length;Ne++){const Ae=ee[Ne];S.format!==Ei?it!==null?ut?O&&t.compressedTexSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+oe,Ne,0,0,Ae.width,Ae.height,it,Ae.data):t.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+oe,Ne,Mt,Ae.width,Ae.height,0,Ae.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):ut?O&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+oe,Ne,0,0,Ae.width,Ae.height,it,Oe,Ae.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+oe,Ne,Mt,Ae.width,Ae.height,0,it,Oe,Ae.data)}}}else{if(ee=S.mipmaps,ut&&Dt){ee.length>0&&Ce++;const oe=Be(ze[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,Ce,Mt,oe.width,oe.height)}for(let oe=0;oe<6;oe++)if(ve){ut?O&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+oe,0,0,0,ze[oe].width,ze[oe].height,it,Oe,ze[oe].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+oe,0,Mt,ze[oe].width,ze[oe].height,0,it,Oe,ze[oe].data);for(let Ne=0;Ne<ee.length;Ne++){const Ae=ee[Ne].image[oe].image;ut?O&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+oe,Ne+1,0,0,Ae.width,Ae.height,it,Oe,Ae.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+oe,Ne+1,Mt,Ae.width,Ae.height,0,it,Oe,Ae.data)}}else{ut?O&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+oe,0,0,0,it,Oe,ze[oe]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+oe,0,Mt,it,Oe,ze[oe]);for(let Ne=0;Ne<ee.length;Ne++){const Ae=ee[Ne];ut?O&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+oe,Ne+1,0,0,it,Oe,Ae.image[oe]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+oe,Ne+1,Mt,it,Oe,Ae.image[oe])}}}f(S)&&g(n.TEXTURE_CUBE_MAP),se.__version=de.version,S.onUpdate&&S.onUpdate(S)}R.__version=S.version}function le(R,S,W,ne,de,se){const ke=s.convert(W.format,W.colorSpace),Ee=s.convert(W.type),Pe=x(W.internalFormat,ke,Ee,W.colorSpace);if(!i.get(S).__hasExternalTextures){const mt=Math.max(1,S.width>>se),ve=Math.max(1,S.height>>se);de===n.TEXTURE_3D||de===n.TEXTURE_2D_ARRAY?t.texImage3D(de,se,Pe,mt,ve,S.depth,0,ke,Ee,null):t.texImage2D(de,se,Pe,mt,ve,0,ke,Ee,null)}t.bindFramebuffer(n.FRAMEBUFFER,R),Ue(S)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,ne,de,i.get(W).__webglTexture,0,pe(S)):(de===n.TEXTURE_2D||de>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&de<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,ne,de,i.get(W).__webglTexture,se),t.bindFramebuffer(n.FRAMEBUFFER,null)}function Te(R,S,W){if(n.bindRenderbuffer(n.RENDERBUFFER,R),S.depthBuffer){const ne=S.depthTexture,de=ne&&ne.isDepthTexture?ne.type:null,se=y(S.stencilBuffer,de),ke=S.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,Ee=pe(S);Ue(S)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,Ee,se,S.width,S.height):W?n.renderbufferStorageMultisample(n.RENDERBUFFER,Ee,se,S.width,S.height):n.renderbufferStorage(n.RENDERBUFFER,se,S.width,S.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,ke,n.RENDERBUFFER,R)}else{const ne=S.textures;for(let de=0;de<ne.length;de++){const se=ne[de],ke=s.convert(se.format,se.colorSpace),Ee=s.convert(se.type),Pe=x(se.internalFormat,ke,Ee,se.colorSpace),mt=pe(S);W&&Ue(S)===!1?n.renderbufferStorageMultisample(n.RENDERBUFFER,mt,Pe,S.width,S.height):Ue(S)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,mt,Pe,S.width,S.height):n.renderbufferStorage(n.RENDERBUFFER,Pe,S.width,S.height)}}n.bindRenderbuffer(n.RENDERBUFFER,null)}function Se(R,S){if(S&&S.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(n.FRAMEBUFFER,R),!(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),Y(S.depthTexture,0);const W=i.get(S.depthTexture).__webglTexture,ne=pe(S);if(S.depthTexture.format===jn)Ue(S)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,W,0,ne):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,W,0);else if(S.depthTexture.format===Xn)Ue(S)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,W,0,ne):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,W,0);else throw new Error("Unknown depthTexture format")}function Ye(R){const S=i.get(R),W=R.isWebGLCubeRenderTarget===!0;if(S.__boundDepthTexture!==R.depthTexture){const ne=R.depthTexture;if(S.__depthDisposeCallback&&S.__depthDisposeCallback(),ne){const de=()=>{delete S.__boundDepthTexture,delete S.__depthDisposeCallback,ne.removeEventListener("dispose",de)};ne.addEventListener("dispose",de),S.__depthDisposeCallback=de}S.__boundDepthTexture=ne}if(R.depthTexture&&!S.__autoAllocateDepthBuffer){if(W)throw new Error("target.depthTexture not supported in Cube render targets");Se(S.__webglFramebuffer,R)}else if(W){S.__webglDepthbuffer=[];for(let ne=0;ne<6;ne++)if(t.bindFramebuffer(n.FRAMEBUFFER,S.__webglFramebuffer[ne]),S.__webglDepthbuffer[ne]===void 0)S.__webglDepthbuffer[ne]=n.createRenderbuffer(),Te(S.__webglDepthbuffer[ne],R,!1);else{const de=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,se=S.__webglDepthbuffer[ne];n.bindRenderbuffer(n.RENDERBUFFER,se),n.framebufferRenderbuffer(n.FRAMEBUFFER,de,n.RENDERBUFFER,se)}}else if(t.bindFramebuffer(n.FRAMEBUFFER,S.__webglFramebuffer),S.__webglDepthbuffer===void 0)S.__webglDepthbuffer=n.createRenderbuffer(),Te(S.__webglDepthbuffer,R,!1);else{const ne=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,de=S.__webglDepthbuffer;n.bindRenderbuffer(n.RENDERBUFFER,de),n.framebufferRenderbuffer(n.FRAMEBUFFER,ne,n.RENDERBUFFER,de)}t.bindFramebuffer(n.FRAMEBUFFER,null)}function We(R,S,W){const ne=i.get(R);S!==void 0&&le(ne.__webglFramebuffer,R,R.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),W!==void 0&&Ye(R)}function ot(R){const S=R.texture,W=i.get(R),ne=i.get(S);R.addEventListener("dispose",b);const de=R.textures,se=R.isWebGLCubeRenderTarget===!0,ke=de.length>1;if(ke||(ne.__webglTexture===void 0&&(ne.__webglTexture=n.createTexture()),ne.__version=S.version,a.memory.textures++),se){W.__webglFramebuffer=[];for(let Ee=0;Ee<6;Ee++)if(S.mipmaps&&S.mipmaps.length>0){W.__webglFramebuffer[Ee]=[];for(let Pe=0;Pe<S.mipmaps.length;Pe++)W.__webglFramebuffer[Ee][Pe]=n.createFramebuffer()}else W.__webglFramebuffer[Ee]=n.createFramebuffer()}else{if(S.mipmaps&&S.mipmaps.length>0){W.__webglFramebuffer=[];for(let Ee=0;Ee<S.mipmaps.length;Ee++)W.__webglFramebuffer[Ee]=n.createFramebuffer()}else W.__webglFramebuffer=n.createFramebuffer();if(ke)for(let Ee=0,Pe=de.length;Ee<Pe;Ee++){const mt=i.get(de[Ee]);mt.__webglTexture===void 0&&(mt.__webglTexture=n.createTexture(),a.memory.textures++)}if(R.samples>0&&Ue(R)===!1){W.__webglMultisampledFramebuffer=n.createFramebuffer(),W.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,W.__webglMultisampledFramebuffer);for(let Ee=0;Ee<de.length;Ee++){const Pe=de[Ee];W.__webglColorRenderbuffer[Ee]=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,W.__webglColorRenderbuffer[Ee]);const mt=s.convert(Pe.format,Pe.colorSpace),ve=s.convert(Pe.type),ze=x(Pe.internalFormat,mt,ve,Pe.colorSpace,R.isXRRenderTarget===!0),tt=pe(R);n.renderbufferStorageMultisample(n.RENDERBUFFER,tt,ze,R.width,R.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+Ee,n.RENDERBUFFER,W.__webglColorRenderbuffer[Ee])}n.bindRenderbuffer(n.RENDERBUFFER,null),R.depthBuffer&&(W.__webglDepthRenderbuffer=n.createRenderbuffer(),Te(W.__webglDepthRenderbuffer,R,!0)),t.bindFramebuffer(n.FRAMEBUFFER,null)}}if(se){t.bindTexture(n.TEXTURE_CUBE_MAP,ne.__webglTexture),Ve(n.TEXTURE_CUBE_MAP,S);for(let Ee=0;Ee<6;Ee++)if(S.mipmaps&&S.mipmaps.length>0)for(let Pe=0;Pe<S.mipmaps.length;Pe++)le(W.__webglFramebuffer[Ee][Pe],R,S,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+Ee,Pe);else le(W.__webglFramebuffer[Ee],R,S,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+Ee,0);f(S)&&g(n.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(ke){for(let Ee=0,Pe=de.length;Ee<Pe;Ee++){const mt=de[Ee],ve=i.get(mt);t.bindTexture(n.TEXTURE_2D,ve.__webglTexture),Ve(n.TEXTURE_2D,mt),le(W.__webglFramebuffer,R,mt,n.COLOR_ATTACHMENT0+Ee,n.TEXTURE_2D,0),f(mt)&&g(n.TEXTURE_2D)}t.unbindTexture()}else{let Ee=n.TEXTURE_2D;if((R.isWebGL3DRenderTarget||R.isWebGLArrayRenderTarget)&&(Ee=R.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(Ee,ne.__webglTexture),Ve(Ee,S),S.mipmaps&&S.mipmaps.length>0)for(let Pe=0;Pe<S.mipmaps.length;Pe++)le(W.__webglFramebuffer[Pe],R,S,n.COLOR_ATTACHMENT0,Ee,Pe);else le(W.__webglFramebuffer,R,S,n.COLOR_ATTACHMENT0,Ee,0);f(S)&&g(Ee),t.unbindTexture()}R.depthBuffer&&Ye(R)}function ce(R){const S=R.textures;for(let W=0,ne=S.length;W<ne;W++){const de=S[W];if(f(de)){const se=R.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:n.TEXTURE_2D,ke=i.get(de).__webglTexture;t.bindTexture(se,ke),g(se),t.unbindTexture()}}}const ue=[],L=[];function He(R){if(R.samples>0){if(Ue(R)===!1){const S=R.textures,W=R.width,ne=R.height;let de=n.COLOR_BUFFER_BIT;const se=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,ke=i.get(R),Ee=S.length>1;if(Ee)for(let Pe=0;Pe<S.length;Pe++)t.bindFramebuffer(n.FRAMEBUFFER,ke.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+Pe,n.RENDERBUFFER,null),t.bindFramebuffer(n.FRAMEBUFFER,ke.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+Pe,n.TEXTURE_2D,null,0);t.bindFramebuffer(n.READ_FRAMEBUFFER,ke.__webglMultisampledFramebuffer),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,ke.__webglFramebuffer);for(let Pe=0;Pe<S.length;Pe++){if(R.resolveDepthBuffer&&(R.depthBuffer&&(de|=n.DEPTH_BUFFER_BIT),R.stencilBuffer&&R.resolveStencilBuffer&&(de|=n.STENCIL_BUFFER_BIT)),Ee){n.framebufferRenderbuffer(n.READ_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,ke.__webglColorRenderbuffer[Pe]);const mt=i.get(S[Pe]).__webglTexture;n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,mt,0)}n.blitFramebuffer(0,0,W,ne,0,0,W,ne,de,n.NEAREST),l===!0&&(ue.length=0,L.length=0,ue.push(n.COLOR_ATTACHMENT0+Pe),R.depthBuffer&&R.resolveDepthBuffer===!1&&(ue.push(se),L.push(se),n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,L)),n.invalidateFramebuffer(n.READ_FRAMEBUFFER,ue))}if(t.bindFramebuffer(n.READ_FRAMEBUFFER,null),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),Ee)for(let Pe=0;Pe<S.length;Pe++){t.bindFramebuffer(n.FRAMEBUFFER,ke.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+Pe,n.RENDERBUFFER,ke.__webglColorRenderbuffer[Pe]);const mt=i.get(S[Pe]).__webglTexture;t.bindFramebuffer(n.FRAMEBUFFER,ke.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+Pe,n.TEXTURE_2D,mt,0)}t.bindFramebuffer(n.DRAW_FRAMEBUFFER,ke.__webglMultisampledFramebuffer)}else if(R.depthBuffer&&R.resolveDepthBuffer===!1&&l){const S=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,[S])}}}function pe(R){return Math.min(r.maxSamples,R.samples)}function Ue(R){const S=i.get(R);return R.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&S.__useRenderToTexture!==!1}function we(R){const S=a.render.frame;u.get(R)!==S&&(u.set(R,S),R.update())}function $e(R,S){const W=R.colorSpace,ne=R.format,de=R.type;return R.isCompressedTexture===!0||R.isVideoTexture===!0||W!==nr&&W!==Cr&&(vt.getTransfer(W)===Ot?(ne!==Ei||de!==Wr)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",W)),S}function Be(R){return typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement?(c.width=R.naturalWidth||R.width,c.height=R.naturalHeight||R.height):typeof VideoFrame<"u"&&R instanceof VideoFrame?(c.width=R.displayWidth,c.height=R.displayHeight):(c.width=R.width,c.height=R.height),c}this.allocateTextureUnit=k,this.resetTextureUnits=T,this.setTexture2D=Y,this.setTexture2DArray=re,this.setTexture3D=$,this.setTextureCube=he,this.rebindTextures=We,this.setupRenderTarget=ot,this.updateRenderTargetMipmap=ce,this.updateMultisampleRenderTarget=He,this.setupDepthRenderbuffer=Ye,this.setupFrameBufferTexture=le,this.useMultisampledRTT=Ue}function ay(n,e){function t(i,r=Cr){let s;const a=vt.getTransfer(r);if(i===Wr)return n.UNSIGNED_BYTE;if(i===Lc)return n.UNSIGNED_SHORT_4_4_4_4;if(i===Pc)return n.UNSIGNED_SHORT_5_5_5_1;if(i===ep)return n.UNSIGNED_INT_5_9_9_9_REV;if(i===Zd)return n.BYTE;if(i===Qd)return n.SHORT;if(i===fa)return n.UNSIGNED_SHORT;if(i===ga)return n.INT;if(i===Nr)return n.UNSIGNED_INT;if(i===Oi)return n.FLOAT;if(i===wi)return n.HALF_FLOAT;if(i===tp)return n.ALPHA;if(i===ip)return n.RGB;if(i===Ei)return n.RGBA;if(i===rp)return n.LUMINANCE;if(i===np)return n.LUMINANCE_ALPHA;if(i===jn)return n.DEPTH_COMPONENT;if(i===Xn)return n.DEPTH_STENCIL;if(i===Do)return n.RED;if(i===Uo)return n.RED_INTEGER;if(i===va)return n.RG;if(i===Dc)return n.RG_INTEGER;if(i===Uc)return n.RGBA_INTEGER;if(i===Oo||i===ya||i===Fo||i===xa)if(a===Ot)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===Oo)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===ya)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Fo)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===xa)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===Oo)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===ya)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Fo)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===xa)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Vo||i===Oc||i===Bo||i===Fc)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===Vo)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Oc)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Bo)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Fc)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===zo||i===ko||i===Ho)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(i===zo||i===ko)return a===Ot?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===Ho)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(i===Go||i===Vc||i===Bc||i===zc||i===Wo||i===kc||i===Hc||i===Gc||i===Wc||i===jc||i===Xc||i===qc||i===Yc||i===$c)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(i===Go)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Vc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Bc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===zc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Wo)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===kc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Hc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Gc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Wc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===jc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Xc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===qc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Yc)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===$c)return a===Ot?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===_a||i===Jc||i===Kc)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(i===_a)return a===Ot?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===Jc)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===Kc)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===sp||i===Zc||i===Qc||i===eu)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(i===_a)return s.COMPRESSED_RED_RGTC1_EXT;if(i===Zc)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===Qc)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===eu)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===Wn?n.UNSIGNED_INT_24_8:n[i]!==void 0?n[i]:null}return{convert:t}}class Yp extends di{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class Us extends _t{constructor(){super(),this.isGroup=!0,this.type="Group"}}const FR={type:"move"};class $p{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Us,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Us,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new N,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new N),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Us,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new N,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new N),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let r=null,s=null,a=null;const o=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){a=!0;for(const v of e.hand.values()){const f=t.getJointPose(v,i),g=this._getHandJoint(c,v);f!==null&&(g.matrix.fromArray(f.transform.matrix),g.matrix.decompose(g.position,g.rotation,g.scale),g.matrixWorldNeedsUpdate=!0,g.jointRadius=f.radius),g.visible=f!==null}const u=c.joints["index-finger-tip"],h=c.joints["thumb-tip"],d=u.position.distanceTo(h.position),p=.02,m=.005;c.inputState.pinching&&d>p+m?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&d<=p-m&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&s!==null&&(r=s),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(FR)))}return o!==null&&(o.visible=r!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new Us;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}const VR=`
|
|
3824
3824
|
void main() {
|
|
3825
3825
|
|
|
3826
3826
|
gl_Position = vec4( position, 1.0 );
|
|
@@ -3844,7 +3844,7 @@ void main() {
|
|
|
3844
3844
|
|
|
3845
3845
|
}
|
|
3846
3846
|
|
|
3847
|
-
}`;class zR{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,i){if(this.texture===null){const r=new Wt,s=e.properties.get(r);s.__webglTexture=t.texture,(t.depthNear!=i.depthNear||t.depthFar!=i.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=r}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,i=new Pr({vertexShader:VR,fragmentShader:BR,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Ft(new ha(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class kR extends vr{constructor(e,t){super();const i=this;let r=null,s=1,a=null,o="local-floor",l=1,c=null,u=null,h=null,d=null,p=null,m=null;const v=new zR,f=t.getContextAttributes();let g=null,x=null;const y=[],_=[],I=new J;let b=null;const w=new di;w.layers.enable(1),w.viewport=new st;const C=new di;C.layers.enable(2),C.viewport=new st;const H=[w,C],M=new $p;M.layers.enable(1),M.layers.enable(2);let T=null,k=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.controllerAutoUpdate=!0,this.getController=function(ie){let le=y[ie];return le===void 0&&(le=new Jp,y[ie]=le),le.getTargetRaySpace()},this.getControllerGrip=function(ie){let le=y[ie];return le===void 0&&(le=new Jp,y[ie]=le),le.getGripSpace()},this.getHand=function(ie){let le=y[ie];return le===void 0&&(le=new Jp,y[ie]=le),le.getHandSpace()};function j(ie){const le=_.indexOf(ie.inputSource);if(le===-1)return;const Te=y[le];Te!==void 0&&(Te.update(ie.inputSource,ie.frame,c||a),Te.dispatchEvent({type:ie.type,data:ie.inputSource}))}function Y(){r.removeEventListener("select",j),r.removeEventListener("selectstart",j),r.removeEventListener("selectend",j),r.removeEventListener("squeeze",j),r.removeEventListener("squeezestart",j),r.removeEventListener("squeezeend",j),r.removeEventListener("end",Y),r.removeEventListener("inputsourceschange",re);for(let ie=0;ie<y.length;ie++){const le=_[ie];le!==null&&(_[ie]=null,y[ie]&&y[ie].disconnect(le))}T=null,k=null,v.reset(),e.setRenderTarget(g),p=null,d=null,h=null,r=null,x=null,et.stop(),i.isPresenting=!1,e.setPixelRatio(b),e.setSize(I.width,I.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(ie){s=ie,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(ie){o=ie,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(ie){c=ie},this.getBaseLayer=function(){return d!==null?d:p},this.getBinding=function(){return h},this.getFrame=function(){return m},this.getSession=function(){return r},this.setSession=async function(ie){if(r=ie,r!==null){if(g=e.getRenderTarget(),r.addEventListener("select",j),r.addEventListener("selectstart",j),r.addEventListener("selectend",j),r.addEventListener("squeeze",j),r.addEventListener("squeezestart",j),r.addEventListener("squeezeend",j),r.addEventListener("end",Y),r.addEventListener("inputsourceschange",re),f.xrCompatible!==!0&&await t.makeXRCompatible(),b=e.getPixelRatio(),e.getSize(I),typeof XRWebGLBinding<"u"&&"createProjectionLayer"in XRWebGLBinding.prototype){let le=null,Te=null,Se=null;f.depth&&(Se=f.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,le=f.stencil?qn:Xn,Te=f.stencil?jn:Nr);const Ye={colorFormat:t.RGBA8,depthFormat:Se,scaleFactor:s};h=new XRWebGLBinding(r,t),d=h.createProjectionLayer(Ye),r.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),x=new Ir(d.textureWidth,d.textureHeight,{format:Ei,type:Wr,depthTexture:new Us(d.textureWidth,d.textureHeight,Te,void 0,void 0,void 0,void 0,void 0,void 0,le),stencilBuffer:f.stencil,colorSpace:e.outputColorSpace,samples:f.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1})}else{const le={antialias:f.antialias,alpha:!0,depth:f.depth,stencil:f.stencil,framebufferScaleFactor:s};p=new XRWebGLLayer(r,t,le),r.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),x=new Ir(p.framebufferWidth,p.framebufferHeight,{format:Ei,type:Wr,colorSpace:e.outputColorSpace,stencilBuffer:f.stencil})}x.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await r.requestReferenceSpace(o),et.setContext(r),et.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return v.getDepthTexture()};function re(ie){for(let le=0;le<ie.removed.length;le++){const Te=ie.removed[le],Se=_.indexOf(Te);Se>=0&&(_[Se]=null,y[Se]&&y[Se].disconnect(Te))}for(let le=0;le<ie.added.length;le++){const Te=ie.added[le];let Se=_.indexOf(Te);if(Se===-1){for(let We=0;We<y.length;We++)if(We>=_.length){_.push(Te),Se=We;break}else if(_[We]===null){_[We]=Te,Se=We;break}if(Se===-1)break}const Ye=y[Se];Ye&&Ye.connect(Te)}}const $=new N,he=new N;function Q(ie,le,Te){$.setFromMatrixPosition(le.matrixWorld),he.setFromMatrixPosition(Te.matrixWorld);const Se=$.distanceTo(he),Ye=le.projectionMatrix.elements,We=Te.projectionMatrix.elements,ot=Ye[14]/(Ye[10]-1),ce=Ye[14]/(Ye[10]+1),ue=(Ye[9]+1)/Ye[5],L=(Ye[9]-1)/Ye[5],He=(Ye[8]-1)/Ye[0],pe=(We[8]+1)/We[0],Ue=ot*He,we=ot*pe,$e=Se/(-He+pe),Be=$e*-He;if(le.matrixWorld.decompose(ie.position,ie.quaternion,ie.scale),ie.translateX(Be),ie.translateZ($e),ie.matrixWorld.compose(ie.position,ie.quaternion,ie.scale),ie.matrixWorldInverse.copy(ie.matrixWorld).invert(),Ye[10]===-1)ie.projectionMatrix.copy(le.projectionMatrix),ie.projectionMatrixInverse.copy(le.projectionMatrixInverse);else{const R=ot+$e,S=ce+$e,W=Ue-Be,ne=we+(Se-Be),de=ue*ce/S*R,se=L*ce/S*R;ie.projectionMatrix.makePerspective(W,ne,de,se,R,S),ie.projectionMatrixInverse.copy(ie.projectionMatrix).invert()}}function ye(ie,le){le===null?ie.matrixWorld.copy(ie.matrix):ie.matrixWorld.multiplyMatrices(le.matrixWorld,ie.matrix),ie.matrixWorldInverse.copy(ie.matrixWorld).invert()}this.updateCamera=function(ie){if(r===null)return;let le=ie.near,Te=ie.far;v.texture!==null&&(v.depthNear>0&&(le=v.depthNear),v.depthFar>0&&(Te=v.depthFar)),M.near=C.near=w.near=le,M.far=C.far=w.far=Te,(T!==M.near||k!==M.far)&&(r.updateRenderState({depthNear:M.near,depthFar:M.far}),T=M.near,k=M.far);const Se=ie.parent,Ye=M.cameras;ye(M,Se);for(let We=0;We<Ye.length;We++)ye(Ye[We],Se);Ye.length===2?Q(M,w,C):M.projectionMatrix.copy(w.projectionMatrix),be(ie,M,Se)};function be(ie,le,Te){Te===null?ie.matrix.copy(le.matrixWorld):(ie.matrix.copy(Te.matrixWorld),ie.matrix.invert(),ie.matrix.multiply(le.matrixWorld)),ie.matrix.decompose(ie.position,ie.quaternion,ie.scale),ie.updateMatrixWorld(!0),ie.projectionMatrix.copy(le.projectionMatrix),ie.projectionMatrixInverse.copy(le.projectionMatrixInverse),ie.isPerspectiveCamera&&(ie.fov=wa*2*Math.atan(1/ie.projectionMatrix.elements[5]),ie.zoom=1)}this.getCamera=function(){return M},this.getFoveation=function(){if(!(d===null&&p===null))return l},this.setFoveation=function(ie){l=ie,d!==null&&(d.fixedFoveation=ie),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=ie)},this.hasDepthSensing=function(){return v.texture!==null},this.getDepthSensingMesh=function(){return v.getMesh(M)};let Ve=null;function at(ie,le){if(u=le.getViewerPose(c||a),m=le,u!==null){const Te=u.views;p!==null&&(e.setRenderTargetFramebuffer(x,p.framebuffer),e.setRenderTarget(x));let Se=!1;Te.length!==M.cameras.length&&(M.cameras.length=0,Se=!0);for(let We=0;We<Te.length;We++){const ot=Te[We];let ce=null;if(p!==null)ce=p.getViewport(ot);else{const L=h.getViewSubImage(d,ot);ce=L.viewport,We===0&&(e.setRenderTargetTextures(x,L.colorTexture,d.ignoreDepthValues?void 0:L.depthStencilTexture),e.setRenderTarget(x))}let ue=H[We];ue===void 0&&(ue=new di,ue.layers.enable(We),ue.viewport=new st,H[We]=ue),ue.matrix.fromArray(ot.transform.matrix),ue.matrix.decompose(ue.position,ue.quaternion,ue.scale),ue.projectionMatrix.fromArray(ot.projectionMatrix),ue.projectionMatrixInverse.copy(ue.projectionMatrix).invert(),ue.viewport.set(ce.x,ce.y,ce.width,ce.height),We===0&&(M.matrix.copy(ue.matrix),M.matrix.decompose(M.position,M.quaternion,M.scale)),Se===!0&&M.cameras.push(ue)}const Ye=r.enabledFeatures;if(Ye&&Ye.includes("depth-sensing")){const We=h.getDepthInformation(Te[0]);We&&We.isValid&&We.texture&&v.init(e,We,r.renderState)}}if(i.controllerAutoUpdate)for(let Te=0;Te<y.length;Te++){const Se=_[Te],Ye=y[Te];Se!==null&&Ye!==void 0&&Ye.update(Se,le,c||a)}Ve&&Ve(ie,le),le.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:le}),m=null}const et=new Pv;et.setAnimationLoop(at),this.setAnimationLoop=function(ie){Ve=ie},this.dispose=function(){}}}const Fs=new dr,HR=new Re;function GR(n,e){function t(f,g){f.matrixAutoUpdate===!0&&f.updateMatrix(),g.value.copy(f.matrix)}function i(f,g){g.color.getRGB(f.fogColor.value,Rv(n)),g.isFog?(f.fogNear.value=g.near,f.fogFar.value=g.far):g.isFogExp2&&(f.fogDensity.value=g.density)}function r(f,g,x,y,_){g.isMeshBasicMaterial||g.isMeshLambertMaterial?s(f,g):g.isMeshToonMaterial?(s(f,g),h(f,g)):g.isMeshPhongMaterial?(s(f,g),u(f,g)):g.isMeshStandardMaterial?(s(f,g),d(f,g),g.isMeshPhysicalMaterial&&p(f,g,_)):g.isMeshMatcapMaterial?(s(f,g),m(f,g)):g.isMeshDepthMaterial?s(f,g):g.isMeshDistanceMaterial?(s(f,g),v(f,g)):g.isMeshNormalMaterial?s(f,g):g.isLineBasicMaterial?(a(f,g),g.isLineDashedMaterial&&o(f,g)):g.isPointsMaterial?l(f,g,x,y):g.isSpriteMaterial?c(f,g):g.isShadowMaterial?(f.color.value.copy(g.color),f.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function s(f,g){f.opacity.value=g.opacity,g.color&&f.diffuse.value.copy(g.color),g.emissive&&f.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(f.map.value=g.map,t(g.map,f.mapTransform)),g.alphaMap&&(f.alphaMap.value=g.alphaMap,t(g.alphaMap,f.alphaMapTransform)),g.bumpMap&&(f.bumpMap.value=g.bumpMap,t(g.bumpMap,f.bumpMapTransform),f.bumpScale.value=g.bumpScale,g.side===si&&(f.bumpScale.value*=-1)),g.normalMap&&(f.normalMap.value=g.normalMap,t(g.normalMap,f.normalMapTransform),f.normalScale.value.copy(g.normalScale),g.side===si&&f.normalScale.value.negate()),g.displacementMap&&(f.displacementMap.value=g.displacementMap,t(g.displacementMap,f.displacementMapTransform),f.displacementScale.value=g.displacementScale,f.displacementBias.value=g.displacementBias),g.emissiveMap&&(f.emissiveMap.value=g.emissiveMap,t(g.emissiveMap,f.emissiveMapTransform)),g.specularMap&&(f.specularMap.value=g.specularMap,t(g.specularMap,f.specularMapTransform)),g.alphaTest>0&&(f.alphaTest.value=g.alphaTest);const x=e.get(g),y=x.envMap,_=x.envMapRotation;y&&(f.envMap.value=y,Fs.copy(_),Fs.x*=-1,Fs.y*=-1,Fs.z*=-1,y.isCubeTexture&&y.isRenderTargetTexture===!1&&(Fs.y*=-1,Fs.z*=-1),f.envMapRotation.value.setFromMatrix4(HR.makeRotationFromEuler(Fs)),f.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,f.reflectivity.value=g.reflectivity,f.ior.value=g.ior,f.refractionRatio.value=g.refractionRatio),g.lightMap&&(f.lightMap.value=g.lightMap,f.lightMapIntensity.value=g.lightMapIntensity,t(g.lightMap,f.lightMapTransform)),g.aoMap&&(f.aoMap.value=g.aoMap,f.aoMapIntensity.value=g.aoMapIntensity,t(g.aoMap,f.aoMapTransform))}function a(f,g){f.diffuse.value.copy(g.color),f.opacity.value=g.opacity,g.map&&(f.map.value=g.map,t(g.map,f.mapTransform))}function o(f,g){f.dashSize.value=g.dashSize,f.totalSize.value=g.dashSize+g.gapSize,f.scale.value=g.scale}function l(f,g,x,y){f.diffuse.value.copy(g.color),f.opacity.value=g.opacity,f.size.value=g.size*x,f.scale.value=y*.5,g.map&&(f.map.value=g.map,t(g.map,f.uvTransform)),g.alphaMap&&(f.alphaMap.value=g.alphaMap,t(g.alphaMap,f.alphaMapTransform)),g.alphaTest>0&&(f.alphaTest.value=g.alphaTest)}function c(f,g){f.diffuse.value.copy(g.color),f.opacity.value=g.opacity,f.rotation.value=g.rotation,g.map&&(f.map.value=g.map,t(g.map,f.mapTransform)),g.alphaMap&&(f.alphaMap.value=g.alphaMap,t(g.alphaMap,f.alphaMapTransform)),g.alphaTest>0&&(f.alphaTest.value=g.alphaTest)}function u(f,g){f.specular.value.copy(g.specular),f.shininess.value=Math.max(g.shininess,1e-4)}function h(f,g){g.gradientMap&&(f.gradientMap.value=g.gradientMap)}function d(f,g){f.metalness.value=g.metalness,g.metalnessMap&&(f.metalnessMap.value=g.metalnessMap,t(g.metalnessMap,f.metalnessMapTransform)),f.roughness.value=g.roughness,g.roughnessMap&&(f.roughnessMap.value=g.roughnessMap,t(g.roughnessMap,f.roughnessMapTransform)),g.envMap&&(f.envMapIntensity.value=g.envMapIntensity)}function p(f,g,x){f.ior.value=g.ior,g.sheen>0&&(f.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),f.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(f.sheenColorMap.value=g.sheenColorMap,t(g.sheenColorMap,f.sheenColorMapTransform)),g.sheenRoughnessMap&&(f.sheenRoughnessMap.value=g.sheenRoughnessMap,t(g.sheenRoughnessMap,f.sheenRoughnessMapTransform))),g.clearcoat>0&&(f.clearcoat.value=g.clearcoat,f.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(f.clearcoatMap.value=g.clearcoatMap,t(g.clearcoatMap,f.clearcoatMapTransform)),g.clearcoatRoughnessMap&&(f.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,t(g.clearcoatRoughnessMap,f.clearcoatRoughnessMapTransform)),g.clearcoatNormalMap&&(f.clearcoatNormalMap.value=g.clearcoatNormalMap,t(g.clearcoatNormalMap,f.clearcoatNormalMapTransform),f.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===si&&f.clearcoatNormalScale.value.negate())),g.dispersion>0&&(f.dispersion.value=g.dispersion),g.iridescence>0&&(f.iridescence.value=g.iridescence,f.iridescenceIOR.value=g.iridescenceIOR,f.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],f.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(f.iridescenceMap.value=g.iridescenceMap,t(g.iridescenceMap,f.iridescenceMapTransform)),g.iridescenceThicknessMap&&(f.iridescenceThicknessMap.value=g.iridescenceThicknessMap,t(g.iridescenceThicknessMap,f.iridescenceThicknessMapTransform))),g.transmission>0&&(f.transmission.value=g.transmission,f.transmissionSamplerMap.value=x.texture,f.transmissionSamplerSize.value.set(x.width,x.height),g.transmissionMap&&(f.transmissionMap.value=g.transmissionMap,t(g.transmissionMap,f.transmissionMapTransform)),f.thickness.value=g.thickness,g.thicknessMap&&(f.thicknessMap.value=g.thicknessMap,t(g.thicknessMap,f.thicknessMapTransform)),f.attenuationDistance.value=g.attenuationDistance,f.attenuationColor.value.copy(g.attenuationColor)),g.anisotropy>0&&(f.anisotropyVector.value.set(g.anisotropy*Math.cos(g.anisotropyRotation),g.anisotropy*Math.sin(g.anisotropyRotation)),g.anisotropyMap&&(f.anisotropyMap.value=g.anisotropyMap,t(g.anisotropyMap,f.anisotropyMapTransform))),f.specularIntensity.value=g.specularIntensity,f.specularColor.value.copy(g.specularColor),g.specularColorMap&&(f.specularColorMap.value=g.specularColorMap,t(g.specularColorMap,f.specularColorMapTransform)),g.specularIntensityMap&&(f.specularIntensityMap.value=g.specularIntensityMap,t(g.specularIntensityMap,f.specularIntensityMapTransform))}function m(f,g){g.matcap&&(f.matcap.value=g.matcap)}function v(f,g){const x=e.get(g).light;f.referencePosition.value.setFromMatrixPosition(x.matrixWorld),f.nearDistance.value=x.shadow.camera.near,f.farDistance.value=x.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function WR(n,e,t,i){let r={},s={},a=[];const o=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function l(x,y){const _=y.program;i.uniformBlockBinding(x,_)}function c(x,y){let _=r[x.id];_===void 0&&(m(x),_=u(x),r[x.id]=_,x.addEventListener("dispose",f));const I=y.program;i.updateUBOMapping(x,I);const b=e.render.frame;s[x.id]!==b&&(d(x),s[x.id]=b)}function u(x){const y=h();x.__bindingPointIndex=y;const _=n.createBuffer(),I=x.__size,b=x.usage;return n.bindBuffer(n.UNIFORM_BUFFER,_),n.bufferData(n.UNIFORM_BUFFER,I,b),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,y,_),_}function h(){for(let x=0;x<o;x++)if(a.indexOf(x)===-1)return a.push(x),x;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(x){const y=r[x.id],_=x.uniforms,I=x.__cache;n.bindBuffer(n.UNIFORM_BUFFER,y);for(let b=0,w=_.length;b<w;b++){const C=Array.isArray(_[b])?_[b]:[_[b]];for(let H=0,M=C.length;H<M;H++){const T=C[H];if(p(T,b,H,I)===!0){const k=T.__offset,j=Array.isArray(T.value)?T.value:[T.value];let Y=0;for(let re=0;re<j.length;re++){const $=j[re],he=v($);typeof $=="number"||typeof $=="boolean"?(T.__data[0]=$,n.bufferSubData(n.UNIFORM_BUFFER,k+Y,T.__data)):$.isMatrix3?(T.__data[0]=$.elements[0],T.__data[1]=$.elements[1],T.__data[2]=$.elements[2],T.__data[3]=0,T.__data[4]=$.elements[3],T.__data[5]=$.elements[4],T.__data[6]=$.elements[5],T.__data[7]=0,T.__data[8]=$.elements[6],T.__data[9]=$.elements[7],T.__data[10]=$.elements[8],T.__data[11]=0):($.toArray(T.__data,Y),Y+=he.storage/Float32Array.BYTES_PER_ELEMENT)}n.bufferSubData(n.UNIFORM_BUFFER,k,T.__data)}}}n.bindBuffer(n.UNIFORM_BUFFER,null)}function p(x,y,_,I){const b=x.value,w=y+"_"+_;if(I[w]===void 0)return typeof b=="number"||typeof b=="boolean"?I[w]=b:I[w]=b.clone(),!0;{const C=I[w];if(typeof b=="number"||typeof b=="boolean"){if(C!==b)return I[w]=b,!0}else if(C.equals(b)===!1)return C.copy(b),!0}return!1}function m(x){const y=x.uniforms;let _=0;const I=16;for(let w=0,C=y.length;w<C;w++){const H=Array.isArray(y[w])?y[w]:[y[w]];for(let M=0,T=H.length;M<T;M++){const k=H[M],j=Array.isArray(k.value)?k.value:[k.value];for(let Y=0,re=j.length;Y<re;Y++){const $=j[Y],he=v($),Q=_%I,ye=Q%he.boundary,be=Q+ye;_+=ye,be!==0&&I-be<he.storage&&(_+=I-be),k.__data=new Float32Array(he.storage/Float32Array.BYTES_PER_ELEMENT),k.__offset=_,_+=he.storage}}}const b=_%I;return b>0&&(_+=I-b),x.__size=_,x.__cache={},this}function v(x){const y={boundary:0,storage:0};return typeof x=="number"||typeof x=="boolean"?(y.boundary=4,y.storage=4):x.isVector2?(y.boundary=8,y.storage=8):x.isVector3||x.isColor?(y.boundary=16,y.storage=12):x.isVector4?(y.boundary=16,y.storage=16):x.isMatrix3?(y.boundary=48,y.storage=48):x.isMatrix4?(y.boundary=64,y.storage=64):x.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",x),y}function f(x){const y=x.target;y.removeEventListener("dispose",f);const _=a.indexOf(y.__bindingPointIndex);a.splice(_,1),n.deleteBuffer(r[y.id]),delete r[y.id],delete s[y.id]}function g(){for(const x in r)n.deleteBuffer(r[x]);a=[],r={},s={}}return{bind:l,update:c,dispose:g}}class ly{constructor(e={}){const{canvas:t=uv(),context:i=null,depth:r=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:h=!1}=e;this.isWebGLRenderer=!0;let d;if(i!==null){if(typeof WebGLRenderingContext<"u"&&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 v=null,f=null;const g=[],x=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Fi,this.toneMapping=mr,this.toneMappingExposure=1;const y=this;let _=!1,I=0,b=0,w=null,C=-1,H=null;const M=new st,T=new st;let k=null;const j=new xe(0);let Y=0,re=t.width,$=t.height,he=1,Q=null,ye=null;const be=new st(0,0,re,$),Ve=new st(0,0,re,$);let at=!1;const et=new ka;let ie=!1,le=!1;const Te=new Re,Se=new Re,Ye=new N,We=new st,ot={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ce=!1;function ue(){return w===null?he:1}let L=i;function He(A,B){return t.getContext(A,B)}try{const A={alpha:!0,depth:r,stencil:s,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Vn}`),t.addEventListener("webglcontextlost",oe,!1),t.addEventListener("webglcontextrestored",Ne,!1),t.addEventListener("webglcontextcreationerror",Ae,!1),L===null){const B="webgl2";if(L=He(B,A),L===null)throw He(B)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(A){throw console.error("THREE.WebGLRenderer: "+A.message),A}let pe,Ue,we,$e,Be,R,S,W,ne,de,se,ke,Ee,Pe,mt,ve,ze,tt,it,Oe,Mt,ut,Dt,O;function Ce(){pe=new JN(L),pe.init(),ut=new oy(L,pe),Ue=new jN(L,pe,e,ut),we=new RR(L),Ue.reverseDepthBuffer&&we.buffers.depth.setReversed(!0),$e=new QN(L),Be=new vR,R=new OR(L,pe,we,Be,Ue,ut,$e),S=new qN(y),W=new $N(y),ne=new oE(L),Dt=new GN(L,ne),de=new KN(L,ne,$e,Dt),se=new tC(L,de,ne,$e),it=new eC(L,Ue,R),ve=new XN(Be),ke=new gR(y,S,W,pe,Ue,Dt,ve),Ee=new GR(y,Be),Pe=new xR,mt=new wR(pe),tt=new HN(y,S,W,we,se,d,l),ze=new NR(y,se,Ue),O=new WR(L,$e,Ue,we),Oe=new WN(L,pe,$e),Mt=new ZN(L,pe,$e),$e.programs=ke.programs,y.capabilities=Ue,y.extensions=pe,y.properties=Be,y.renderLists=Pe,y.shadowMap=ze,y.state=we,y.info=$e}Ce();const ee=new kR(y,L);this.xr=ee,this.getContext=function(){return L},this.getContextAttributes=function(){return L.getContextAttributes()},this.forceContextLoss=function(){const A=pe.get("WEBGL_lose_context");A&&A.loseContext()},this.forceContextRestore=function(){const A=pe.get("WEBGL_lose_context");A&&A.restoreContext()},this.getPixelRatio=function(){return he},this.setPixelRatio=function(A){A!==void 0&&(he=A,this.setSize(re,$,!1))},this.getSize=function(A){return A.set(re,$)},this.setSize=function(A,B,X=!0){if(ee.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}re=A,$=B,t.width=Math.floor(A*he),t.height=Math.floor(B*he),X===!0&&(t.style.width=A+"px",t.style.height=B+"px"),this.setViewport(0,0,A,B)},this.getDrawingBufferSize=function(A){return A.set(re*he,$*he).floor()},this.setDrawingBufferSize=function(A,B,X){re=A,$=B,he=X,t.width=Math.floor(A*X),t.height=Math.floor(B*X),this.setViewport(0,0,A,B)},this.getCurrentViewport=function(A){return A.copy(M)},this.getViewport=function(A){return A.copy(be)},this.setViewport=function(A,B,X,q){A.isVector4?be.set(A.x,A.y,A.z,A.w):be.set(A,B,X,q),we.viewport(M.copy(be).multiplyScalar(he).round())},this.getScissor=function(A){return A.copy(Ve)},this.setScissor=function(A,B,X,q){A.isVector4?Ve.set(A.x,A.y,A.z,A.w):Ve.set(A,B,X,q),we.scissor(T.copy(Ve).multiplyScalar(he).round())},this.getScissorTest=function(){return at},this.setScissorTest=function(A){we.setScissorTest(at=A)},this.setOpaqueSort=function(A){Q=A},this.setTransparentSort=function(A){ye=A},this.getClearColor=function(A){return A.copy(tt.getClearColor())},this.setClearColor=function(){tt.setClearColor.apply(tt,arguments)},this.getClearAlpha=function(){return tt.getClearAlpha()},this.setClearAlpha=function(){tt.setClearAlpha.apply(tt,arguments)},this.clear=function(A=!0,B=!0,X=!0){let q=0;if(A){let F=!1;if(w!==null){const me=w.texture.format;F=me===Oc||me===Uc||me===Oo}if(F){const me=w.texture.type,Ie=me===Wr||me===Nr||me===ga||me===jn||me===Pc||me===Dc,Fe=tt.getClearColor(),Ge=tt.getClearAlpha(),Qe=Fe.r,Ze=Fe.g,Je=Fe.b;Ie?(p[0]=Qe,p[1]=Ze,p[2]=Je,p[3]=Ge,L.clearBufferuiv(L.COLOR,0,p)):(m[0]=Qe,m[1]=Ze,m[2]=Je,m[3]=Ge,L.clearBufferiv(L.COLOR,0,m))}else q|=L.COLOR_BUFFER_BIT}B&&(q|=L.DEPTH_BUFFER_BIT,L.clearDepth(this.capabilities.reverseDepthBuffer?0:1)),X&&(q|=L.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),L.clear(q)},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",oe,!1),t.removeEventListener("webglcontextrestored",Ne,!1),t.removeEventListener("webglcontextcreationerror",Ae,!1),Pe.dispose(),mt.dispose(),Be.dispose(),S.dispose(),W.dispose(),se.dispose(),Dt.dispose(),O.dispose(),ke.dispose(),ee.dispose(),ee.removeEventListener("sessionstart",o0),ee.removeEventListener("sessionend",l0),vs.stop()};function oe(A){A.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),_=!0}function Ne(){console.log("THREE.WebGLRenderer: Context Restored."),_=!1;const A=$e.autoReset,B=ze.enabled,X=ze.autoUpdate,q=ze.needsUpdate,F=ze.type;Ce(),$e.autoReset=A,ze.enabled=B,ze.autoUpdate=X,ze.needsUpdate=q,ze.type=F}function Ae(A){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",A.statusMessage)}function Ut(A){const B=A.target;B.removeEventListener("dispose",Ut),ni(B)}function ni(A){tr(A),Be.remove(A)}function tr(A){const B=Be.get(A).programs;B!==void 0&&(B.forEach(function(X){ke.releaseProgram(X)}),A.isShaderMaterial&&ke.releaseShaderCache(A))}this.renderBufferDirect=function(A,B,X,q,F,me){B===null&&(B=ot);const Ie=F.isMesh&&F.matrixWorld.determinant()<0,Fe=$S(A,B,X,q,F);we.setMaterial(q,Ie);let Ge=X.index,Qe=1;if(q.wireframe===!0){if(Ge=de.getWireframeAttribute(X),Ge===void 0)return;Qe=2}const Ze=X.drawRange,Je=X.attributes.position;let Rt=Ze.start*Qe,jt=(Ze.start+Ze.count)*Qe;me!==null&&(Rt=Math.max(Rt,me.start*Qe),jt=Math.min(jt,(me.start+me.count)*Qe)),Ge!==null?(Rt=Math.max(Rt,0),jt=Math.min(jt,Ge.count)):Je!=null&&(Rt=Math.max(Rt,0),jt=Math.min(jt,Je.count));const Qt=jt-Rt;if(Qt<0||Qt===1/0)return;Dt.setup(F,q,Fe,X,Ge);let ci,Ht=Oe;if(Ge!==null&&(ci=ne.get(Ge),Ht=Mt,Ht.setIndex(ci)),F.isMesh)q.wireframe===!0?(we.setLineWidth(q.wireframeLinewidth*ue()),Ht.setMode(L.LINES)):Ht.setMode(L.TRIANGLES);else if(F.isLine){let Xe=q.linewidth;Xe===void 0&&(Xe=1),we.setLineWidth(Xe*ue()),F.isLineSegments?Ht.setMode(L.LINES):F.isLineLoop?Ht.setMode(L.LINE_LOOP):Ht.setMode(L.LINE_STRIP)}else F.isPoints?Ht.setMode(L.POINTS):F.isSprite&&Ht.setMode(L.TRIANGLES);if(F.isBatchedMesh)if(F._multiDrawInstances!==null)Ht.renderMultiDrawInstances(F._multiDrawStarts,F._multiDrawCounts,F._multiDrawCount,F._multiDrawInstances);else if(pe.get("WEBGL_multi_draw"))Ht.renderMultiDraw(F._multiDrawStarts,F._multiDrawCounts,F._multiDrawCount);else{const Xe=F._multiDrawStarts,Wi=F._multiDrawCounts,ys=F._multiDrawCount,Hr=Ge?ne.get(Ge).bytesPerElement:1,pa=Be.get(q).currentProgram.getUniforms();for(let pr=0;pr<ys;pr++)pa.setValue(L,"_gl_DrawID",pr),Ht.render(Xe[pr]/Hr,Wi[pr])}else if(F.isInstancedMesh)Ht.renderInstances(Rt,Qt,F.count);else if(X.isInstancedBufferGeometry){const Xe=X._maxInstanceCount!==void 0?X._maxInstanceCount:1/0,Wi=Math.min(X.instanceCount,Xe);Ht.renderInstances(Rt,Qt,Wi)}else Ht.render(Rt,Qt)};function At(A,B,X){A.transparent===!0&&A.side===Gr&&A.forceSinglePass===!1?(A.side=si,A.needsUpdate=!0,Tc(A,B,X),A.side=an,A.needsUpdate=!0,Tc(A,B,X),A.side=Gr):Tc(A,B,X)}this.compile=function(A,B,X=null){X===null&&(X=A),f=mt.get(X),f.init(B),x.push(f),X.traverseVisible(function(F){F.isLight&&F.layers.test(B.layers)&&(f.pushLight(F),F.castShadow&&f.pushShadow(F))}),A!==X&&A.traverseVisible(function(F){F.isLight&&F.layers.test(B.layers)&&(f.pushLight(F),F.castShadow&&f.pushShadow(F))}),f.setupLights();const q=new Set;return A.traverse(function(F){if(!(F.isMesh||F.isPoints||F.isLine||F.isSprite))return;const me=F.material;if(me)if(Array.isArray(me))for(let Ie=0;Ie<me.length;Ie++){const Fe=me[Ie];At(Fe,X,F),q.add(Fe)}else At(me,X,F),q.add(me)}),x.pop(),f=null,q},this.compileAsync=function(A,B,X=null){const q=this.compile(A,B,X);return new Promise(F=>{function me(){if(q.forEach(function(Ie){Be.get(Ie).currentProgram.isReady()&&q.delete(Ie)}),q.size===0){F(A);return}setTimeout(me,10)}pe.get("KHR_parallel_shader_compile")!==null?me():setTimeout(me,10)})};let ir=null;function xn(A){ir&&ir(A)}function o0(){vs.stop()}function l0(){vs.start()}const vs=new Pv;vs.setAnimationLoop(xn),typeof self<"u"&&vs.setContext(self),this.setAnimationLoop=function(A){ir=A,ee.setAnimationLoop(A),A===null?vs.stop():vs.start()},ee.addEventListener("sessionstart",o0),ee.addEventListener("sessionend",l0),this.render=function(A,B){if(B!==void 0&&B.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(_===!0)return;if(A.matrixWorldAutoUpdate===!0&&A.updateMatrixWorld(),B.parent===null&&B.matrixWorldAutoUpdate===!0&&B.updateMatrixWorld(),ee.enabled===!0&&ee.isPresenting===!0&&(ee.cameraAutoUpdate===!0&&ee.updateCamera(B),B=ee.getCamera()),A.isScene===!0&&A.onBeforeRender(y,A,B,w),f=mt.get(A,x.length),f.init(B),x.push(f),Se.multiplyMatrices(B.projectionMatrix,B.matrixWorldInverse),et.setFromProjectionMatrix(Se),le=this.localClippingEnabled,ie=ve.init(this.clippingPlanes,le),v=Pe.get(A,g.length),v.init(),g.push(v),ee.enabled===!0&&ee.isPresenting===!0){const me=y.xr.getDepthSensingMesh();me!==null&&Vd(me,B,-1/0,y.sortObjects)}Vd(A,B,0,y.sortObjects),v.finish(),y.sortObjects===!0&&v.sort(Q,ye),ce=ee.enabled===!1||ee.isPresenting===!1||ee.hasDepthSensing()===!1,ce&&tt.addToRenderList(v,A),this.info.render.frame++,ie===!0&&ve.beginShadows();const X=f.state.shadowsArray;ze.render(X,A,B),ie===!0&&ve.endShadows(),this.info.autoReset===!0&&this.info.reset();const q=v.opaque,F=v.transmissive;if(f.setupLights(),B.isArrayCamera){const me=B.cameras;if(F.length>0)for(let Ie=0,Fe=me.length;Ie<Fe;Ie++){const Ge=me[Ie];u0(q,F,A,Ge)}ce&&tt.render(A);for(let Ie=0,Fe=me.length;Ie<Fe;Ie++){const Ge=me[Ie];c0(v,A,Ge,Ge.viewport)}}else F.length>0&&u0(q,F,A,B),ce&&tt.render(A),c0(v,A,B);w!==null&&(R.updateMultisampleRenderTarget(w),R.updateRenderTargetMipmap(w)),A.isScene===!0&&A.onAfterRender(y,A,B),Dt.resetDefaultState(),C=-1,H=null,x.pop(),x.length>0?(f=x[x.length-1],ie===!0&&ve.setGlobalState(y.clippingPlanes,f.state.camera)):f=null,g.pop(),g.length>0?v=g[g.length-1]:v=null};function Vd(A,B,X,q){if(A.visible===!1)return;if(A.layers.test(B.layers)){if(A.isGroup)X=A.renderOrder;else if(A.isLOD)A.autoUpdate===!0&&A.update(B);else if(A.isLight)f.pushLight(A),A.castShadow&&f.pushShadow(A);else if(A.isSprite){if(!A.frustumCulled||et.intersectsSprite(A)){q&&We.setFromMatrixPosition(A.matrixWorld).applyMatrix4(Se);const me=se.update(A),Ie=A.material;Ie.visible&&v.push(A,me,Ie,X,We.z,null)}}else if((A.isMesh||A.isLine||A.isPoints)&&(!A.frustumCulled||et.intersectsObject(A))){const me=se.update(A),Ie=A.material;if(q&&(A.boundingSphere!==void 0?(A.boundingSphere===null&&A.computeBoundingSphere(),We.copy(A.boundingSphere.center)):(me.boundingSphere===null&&me.computeBoundingSphere(),We.copy(me.boundingSphere.center)),We.applyMatrix4(A.matrixWorld).applyMatrix4(Se)),Array.isArray(Ie)){const Fe=me.groups;for(let Ge=0,Qe=Fe.length;Ge<Qe;Ge++){const Ze=Fe[Ge],Je=Ie[Ze.materialIndex];Je&&Je.visible&&v.push(A,me,Je,X,We.z,Ze)}}else Ie.visible&&v.push(A,me,Ie,X,We.z,null)}}const F=A.children;for(let me=0,Ie=F.length;me<Ie;me++)Vd(F[me],B,X,q)}function c0(A,B,X,q){const F=A.opaque,me=A.transmissive,Ie=A.transparent;f.setupLightsView(X),ie===!0&&ve.setGlobalState(y.clippingPlanes,X),q&&we.viewport(M.copy(q)),F.length>0&&bc(F,B,X),me.length>0&&bc(me,B,X),Ie.length>0&&bc(Ie,B,X),we.buffers.depth.setTest(!0),we.buffers.depth.setMask(!0),we.buffers.color.setMask(!0),we.setPolygonOffset(!1)}function u0(A,B,X,q){if((X.isScene===!0?X.overrideMaterial:null)!==null)return;f.state.transmissionRenderTarget[q.id]===void 0&&(f.state.transmissionRenderTarget[q.id]=new Ir(1,1,{generateMipmaps:!0,type:pe.has("EXT_color_buffer_half_float")||pe.has("EXT_color_buffer_float")?wi:Wr,minFilter:ji,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:vt.workingColorSpace}));const F=f.state.transmissionRenderTarget[q.id],me=q.viewport||M;F.setSize(me.z,me.w);const Ie=y.getRenderTarget();y.setRenderTarget(F),y.getClearColor(j),Y=y.getClearAlpha(),Y<1&&y.setClearColor(16777215,.5),y.clear(),ce&&tt.render(X);const Fe=y.toneMapping;y.toneMapping=mr;const Ge=q.viewport;if(q.viewport!==void 0&&(q.viewport=void 0),f.setupLightsView(q),ie===!0&&ve.setGlobalState(y.clippingPlanes,q),bc(A,X,q),R.updateMultisampleRenderTarget(F),R.updateRenderTargetMipmap(F),pe.has("WEBGL_multisampled_render_to_texture")===!1){let Qe=!1;for(let Ze=0,Je=B.length;Ze<Je;Ze++){const Rt=B[Ze],jt=Rt.object,Qt=Rt.geometry,ci=Rt.material,Ht=Rt.group;if(ci.side===Gr&&jt.layers.test(q.layers)){const Xe=ci.side;ci.side=si,ci.needsUpdate=!0,h0(jt,X,q,Qt,ci,Ht),ci.side=Xe,ci.needsUpdate=!0,Qe=!0}}Qe===!0&&(R.updateMultisampleRenderTarget(F),R.updateRenderTargetMipmap(F))}y.setRenderTarget(Ie),y.setClearColor(j,Y),Ge!==void 0&&(q.viewport=Ge),y.toneMapping=Fe}function bc(A,B,X){const q=B.isScene===!0?B.overrideMaterial:null;for(let F=0,me=A.length;F<me;F++){const Ie=A[F],Fe=Ie.object,Ge=Ie.geometry,Qe=q===null?Ie.material:q,Ze=Ie.group;Fe.layers.test(X.layers)&&h0(Fe,B,X,Ge,Qe,Ze)}}function h0(A,B,X,q,F,me){A.onBeforeRender(y,B,X,q,F,me),A.modelViewMatrix.multiplyMatrices(X.matrixWorldInverse,A.matrixWorld),A.normalMatrix.getNormalMatrix(A.modelViewMatrix),F.onBeforeRender(y,B,X,q,A,me),F.transparent===!0&&F.side===Gr&&F.forceSinglePass===!1?(F.side=si,F.needsUpdate=!0,y.renderBufferDirect(X,B,q,F,A,me),F.side=an,F.needsUpdate=!0,y.renderBufferDirect(X,B,q,F,A,me),F.side=Gr):y.renderBufferDirect(X,B,q,F,A,me),A.onAfterRender(y,B,X,q,F,me)}function Tc(A,B,X){B.isScene!==!0&&(B=ot);const q=Be.get(A),F=f.state.lights,me=f.state.shadowsArray,Ie=F.state.version,Fe=ke.getParameters(A,F.state,me,B,X),Ge=ke.getProgramCacheKey(Fe);let Qe=q.programs;q.environment=A.isMeshStandardMaterial?B.environment:null,q.fog=B.fog,q.envMap=(A.isMeshStandardMaterial?W:S).get(A.envMap||q.environment),q.envMapRotation=q.environment!==null&&A.envMap===null?B.environmentRotation:A.envMapRotation,Qe===void 0&&(A.addEventListener("dispose",Ut),Qe=new Map,q.programs=Qe);let Ze=Qe.get(Ge);if(Ze!==void 0){if(q.currentProgram===Ze&&q.lightsStateVersion===Ie)return p0(A,Fe),Ze}else Fe.uniforms=ke.getUniforms(A),A.onBuild(X,Fe,y),A.onBeforeCompile(Fe,y),Ze=ke.acquireProgram(Fe,Ge),Qe.set(Ge,Ze),q.uniforms=Fe.uniforms;const Je=q.uniforms;return(!A.isShaderMaterial&&!A.isRawShaderMaterial||A.clipping===!0)&&(Je.clippingPlanes=ve.uniform),p0(A,Fe),q.needsLights=KS(A),q.lightsStateVersion=Ie,q.needsLights&&(Je.ambientLightColor.value=F.state.ambient,Je.lightProbe.value=F.state.probe,Je.directionalLights.value=F.state.directional,Je.directionalLightShadows.value=F.state.directionalShadow,Je.spotLights.value=F.state.spot,Je.spotLightShadows.value=F.state.spotShadow,Je.rectAreaLights.value=F.state.rectArea,Je.ltc_1.value=F.state.rectAreaLTC1,Je.ltc_2.value=F.state.rectAreaLTC2,Je.pointLights.value=F.state.point,Je.pointLightShadows.value=F.state.pointShadow,Je.hemisphereLights.value=F.state.hemi,Je.directionalShadowMap.value=F.state.directionalShadowMap,Je.directionalShadowMatrix.value=F.state.directionalShadowMatrix,Je.spotShadowMap.value=F.state.spotShadowMap,Je.spotLightMatrix.value=F.state.spotLightMatrix,Je.spotLightMap.value=F.state.spotLightMap,Je.pointShadowMap.value=F.state.pointShadowMap,Je.pointShadowMatrix.value=F.state.pointShadowMatrix),q.currentProgram=Ze,q.uniformsList=null,Ze}function d0(A){if(A.uniformsList===null){const B=A.currentProgram.getUniforms();A.uniformsList=Pu.seqWithValue(B.seq,A.uniforms)}return A.uniformsList}function p0(A,B){const X=Be.get(A);X.outputColorSpace=B.outputColorSpace,X.batching=B.batching,X.batchingColor=B.batchingColor,X.instancing=B.instancing,X.instancingColor=B.instancingColor,X.instancingMorph=B.instancingMorph,X.skinning=B.skinning,X.morphTargets=B.morphTargets,X.morphNormals=B.morphNormals,X.morphColors=B.morphColors,X.morphTargetsCount=B.morphTargetsCount,X.numClippingPlanes=B.numClippingPlanes,X.numIntersection=B.numClipIntersection,X.vertexAlphas=B.vertexAlphas,X.vertexTangents=B.vertexTangents,X.toneMapping=B.toneMapping}function $S(A,B,X,q,F){B.isScene!==!0&&(B=ot),R.resetTextureUnits();const me=B.fog,Ie=q.isMeshStandardMaterial?B.environment:null,Fe=w===null?y.outputColorSpace:w.isXRRenderTarget===!0?w.texture.colorSpace:nr,Ge=(q.isMeshStandardMaterial?W:S).get(q.envMap||Ie),Qe=q.vertexColors===!0&&!!X.attributes.color&&X.attributes.color.itemSize===4,Ze=!!X.attributes.tangent&&(!!q.normalMap||q.anisotropy>0),Je=!!X.morphAttributes.position,Rt=!!X.morphAttributes.normal,jt=!!X.morphAttributes.color;let Qt=mr;q.toneMapped&&(w===null||w.isXRRenderTarget===!0)&&(Qt=y.toneMapping);const ci=X.morphAttributes.position||X.morphAttributes.normal||X.morphAttributes.color,Ht=ci!==void 0?ci.length:0,Xe=Be.get(q),Wi=f.state.lights;if(ie===!0&&(le===!0||A!==H)){const wr=A===H&&q.id===C;ve.setState(q,A,wr)}let ys=!1;q.version===Xe.__version?(Xe.needsLights&&Xe.lightsStateVersion!==Wi.state.version||Xe.outputColorSpace!==Fe||F.isBatchedMesh&&Xe.batching===!1||!F.isBatchedMesh&&Xe.batching===!0||F.isBatchedMesh&&Xe.batchingColor===!0&&F.colorTexture===null||F.isBatchedMesh&&Xe.batchingColor===!1&&F.colorTexture!==null||F.isInstancedMesh&&Xe.instancing===!1||!F.isInstancedMesh&&Xe.instancing===!0||F.isSkinnedMesh&&Xe.skinning===!1||!F.isSkinnedMesh&&Xe.skinning===!0||F.isInstancedMesh&&Xe.instancingColor===!0&&F.instanceColor===null||F.isInstancedMesh&&Xe.instancingColor===!1&&F.instanceColor!==null||F.isInstancedMesh&&Xe.instancingMorph===!0&&F.morphTexture===null||F.isInstancedMesh&&Xe.instancingMorph===!1&&F.morphTexture!==null||Xe.envMap!==Ge||q.fog===!0&&Xe.fog!==me||Xe.numClippingPlanes!==void 0&&(Xe.numClippingPlanes!==ve.numPlanes||Xe.numIntersection!==ve.numIntersection)||Xe.vertexAlphas!==Qe||Xe.vertexTangents!==Ze||Xe.morphTargets!==Je||Xe.morphNormals!==Rt||Xe.morphColors!==jt||Xe.toneMapping!==Qt||Xe.morphTargetsCount!==Ht)&&(ys=!0):(ys=!0,Xe.__version=q.version);let Hr=Xe.currentProgram;ys===!0&&(Hr=Tc(q,B,F));let pa=!1,pr=!1,Bd=!1;const ei=Hr.getUniforms(),Fn=Xe.uniforms;if(we.useProgram(Hr.program)&&(pa=!0,pr=!0,Bd=!0),q.id!==C&&(C=q.id,pr=!0),pa||H!==A){Ue.reverseDepthBuffer?(Te.copy(A.projectionMatrix),Pw(Te),Dw(Te),ei.setValue(L,"projectionMatrix",Te)):ei.setValue(L,"projectionMatrix",A.projectionMatrix),ei.setValue(L,"viewMatrix",A.matrixWorldInverse);const wr=ei.map.cameraPosition;wr!==void 0&&wr.setValue(L,Ye.setFromMatrixPosition(A.matrixWorld)),Ue.logarithmicDepthBuffer&&ei.setValue(L,"logDepthBufFC",2/(Math.log(A.far+1)/Math.LN2)),(q.isMeshPhongMaterial||q.isMeshToonMaterial||q.isMeshLambertMaterial||q.isMeshBasicMaterial||q.isMeshStandardMaterial||q.isShaderMaterial)&&ei.setValue(L,"isOrthographic",A.isOrthographicCamera===!0),H!==A&&(H=A,pr=!0,Bd=!0)}if(F.isSkinnedMesh){ei.setOptional(L,F,"bindMatrix"),ei.setOptional(L,F,"bindMatrixInverse");const wr=F.skeleton;wr&&(wr.boneTexture===null&&wr.computeBoneTexture(),ei.setValue(L,"boneTexture",wr.boneTexture,R))}F.isBatchedMesh&&(ei.setOptional(L,F,"batchingTexture"),ei.setValue(L,"batchingTexture",F._matricesTexture,R),ei.setOptional(L,F,"batchingIdTexture"),ei.setValue(L,"batchingIdTexture",F._indirectTexture,R),ei.setOptional(L,F,"batchingColorTexture"),F._colorsTexture!==null&&ei.setValue(L,"batchingColorTexture",F._colorsTexture,R));const zd=X.morphAttributes;if((zd.position!==void 0||zd.normal!==void 0||zd.color!==void 0)&&it.update(F,X,Hr),(pr||Xe.receiveShadow!==F.receiveShadow)&&(Xe.receiveShadow=F.receiveShadow,ei.setValue(L,"receiveShadow",F.receiveShadow)),q.isMeshGouraudMaterial&&q.envMap!==null&&(Fn.envMap.value=Ge,Fn.flipEnvMap.value=Ge.isCubeTexture&&Ge.isRenderTargetTexture===!1?-1:1),q.isMeshStandardMaterial&&q.envMap===null&&B.environment!==null&&(Fn.envMapIntensity.value=B.environmentIntensity),pr&&(ei.setValue(L,"toneMappingExposure",y.toneMappingExposure),Xe.needsLights&&JS(Fn,Bd),me&&q.fog===!0&&Ee.refreshFogUniforms(Fn,me),Ee.refreshMaterialUniforms(Fn,q,he,$,f.state.transmissionRenderTarget[A.id]),Pu.upload(L,d0(Xe),Fn,R)),q.isShaderMaterial&&q.uniformsNeedUpdate===!0&&(Pu.upload(L,d0(Xe),Fn,R),q.uniformsNeedUpdate=!1),q.isSpriteMaterial&&ei.setValue(L,"center",F.center),ei.setValue(L,"modelViewMatrix",F.modelViewMatrix),ei.setValue(L,"normalMatrix",F.normalMatrix),ei.setValue(L,"modelMatrix",F.matrixWorld),q.isShaderMaterial||q.isRawShaderMaterial){const wr=q.uniformsGroups;for(let kd=0,ZS=wr.length;kd<ZS;kd++){const m0=wr[kd];O.update(m0,Hr),O.bind(m0,Hr)}}return Hr}function JS(A,B){A.ambientLightColor.needsUpdate=B,A.lightProbe.needsUpdate=B,A.directionalLights.needsUpdate=B,A.directionalLightShadows.needsUpdate=B,A.pointLights.needsUpdate=B,A.pointLightShadows.needsUpdate=B,A.spotLights.needsUpdate=B,A.spotLightShadows.needsUpdate=B,A.rectAreaLights.needsUpdate=B,A.hemisphereLights.needsUpdate=B}function KS(A){return A.isMeshLambertMaterial||A.isMeshToonMaterial||A.isMeshPhongMaterial||A.isMeshStandardMaterial||A.isShadowMaterial||A.isShaderMaterial&&A.lights===!0}this.getActiveCubeFace=function(){return I},this.getActiveMipmapLevel=function(){return b},this.getRenderTarget=function(){return w},this.setRenderTargetTextures=function(A,B,X){Be.get(A.texture).__webglTexture=B,Be.get(A.depthTexture).__webglTexture=X;const q=Be.get(A);q.__hasExternalTextures=!0,q.__autoAllocateDepthBuffer=X===void 0,q.__autoAllocateDepthBuffer||pe.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),q.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(A,B){const X=Be.get(A);X.__webglFramebuffer=B,X.__useDefaultFramebuffer=B===void 0},this.setRenderTarget=function(A,B=0,X=0){w=A,I=B,b=X;let q=!0,F=null,me=!1,Ie=!1;if(A){const Fe=Be.get(A);if(Fe.__useDefaultFramebuffer!==void 0)we.bindFramebuffer(L.FRAMEBUFFER,null),q=!1;else if(Fe.__webglFramebuffer===void 0)R.setupRenderTarget(A);else if(Fe.__hasExternalTextures)R.rebindTextures(A,Be.get(A.texture).__webglTexture,Be.get(A.depthTexture).__webglTexture);else if(A.depthBuffer){const Ze=A.depthTexture;if(Fe.__boundDepthTexture!==Ze){if(Ze!==null&&Be.has(Ze)&&(A.width!==Ze.image.width||A.height!==Ze.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");R.setupDepthRenderbuffer(A)}}const Ge=A.texture;(Ge.isData3DTexture||Ge.isDataArrayTexture||Ge.isCompressedArrayTexture)&&(Ie=!0);const Qe=Be.get(A).__webglFramebuffer;A.isWebGLCubeRenderTarget?(Array.isArray(Qe[B])?F=Qe[B][X]:F=Qe[B],me=!0):A.samples>0&&R.useMultisampledRTT(A)===!1?F=Be.get(A).__webglMultisampledFramebuffer:Array.isArray(Qe)?F=Qe[X]:F=Qe,M.copy(A.viewport),T.copy(A.scissor),k=A.scissorTest}else M.copy(be).multiplyScalar(he).floor(),T.copy(Ve).multiplyScalar(he).floor(),k=at;if(we.bindFramebuffer(L.FRAMEBUFFER,F)&&q&&we.drawBuffers(A,F),we.viewport(M),we.scissor(T),we.setScissorTest(k),me){const Fe=Be.get(A.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_CUBE_MAP_POSITIVE_X+B,Fe.__webglTexture,X)}else if(Ie){const Fe=Be.get(A.texture),Ge=B||0;L.framebufferTextureLayer(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,Fe.__webglTexture,X||0,Ge)}C=-1},this.readRenderTargetPixels=function(A,B,X,q,F,me,Ie){if(!(A&&A.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Fe=Be.get(A).__webglFramebuffer;if(A.isWebGLCubeRenderTarget&&Ie!==void 0&&(Fe=Fe[Ie]),Fe){we.bindFramebuffer(L.FRAMEBUFFER,Fe);try{const Ge=A.texture,Qe=Ge.format,Ze=Ge.type;if(!Ue.textureFormatReadable(Qe)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Ue.textureTypeReadable(Ze)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}B>=0&&B<=A.width-q&&X>=0&&X<=A.height-F&&L.readPixels(B,X,q,F,ut.convert(Qe),ut.convert(Ze),me)}finally{const Ge=w!==null?Be.get(w).__webglFramebuffer:null;we.bindFramebuffer(L.FRAMEBUFFER,Ge)}}},this.readRenderTargetPixelsAsync=async function(A,B,X,q,F,me,Ie){if(!(A&&A.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Fe=Be.get(A).__webglFramebuffer;if(A.isWebGLCubeRenderTarget&&Ie!==void 0&&(Fe=Fe[Ie]),Fe){const Ge=A.texture,Qe=Ge.format,Ze=Ge.type;if(!Ue.textureFormatReadable(Qe))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Ue.textureTypeReadable(Ze))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(B>=0&&B<=A.width-q&&X>=0&&X<=A.height-F){we.bindFramebuffer(L.FRAMEBUFFER,Fe);const Je=L.createBuffer();L.bindBuffer(L.PIXEL_PACK_BUFFER,Je),L.bufferData(L.PIXEL_PACK_BUFFER,me.byteLength,L.STREAM_READ),L.readPixels(B,X,q,F,ut.convert(Qe),ut.convert(Ze),0);const Rt=w!==null?Be.get(w).__webglFramebuffer:null;we.bindFramebuffer(L.FRAMEBUFFER,Rt);const jt=L.fenceSync(L.SYNC_GPU_COMMANDS_COMPLETE,0);return L.flush(),await Lw(L,jt,4),L.bindBuffer(L.PIXEL_PACK_BUFFER,Je),L.getBufferSubData(L.PIXEL_PACK_BUFFER,0,me),L.deleteBuffer(Je),L.deleteSync(jt),me}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(A,B=null,X=0){A.isTexture!==!0&&(ou("WebGLRenderer: copyFramebufferToTexture function signature has changed."),B=arguments[0]||null,A=arguments[1]);const q=Math.pow(2,-X),F=Math.floor(A.image.width*q),me=Math.floor(A.image.height*q),Ie=B!==null?B.x:0,Fe=B!==null?B.y:0;R.setTexture2D(A,0),L.copyTexSubImage2D(L.TEXTURE_2D,X,0,0,Ie,Fe,F,me),we.unbindTexture()},this.copyTextureToTexture=function(A,B,X=null,q=null,F=0){A.isTexture!==!0&&(ou("WebGLRenderer: copyTextureToTexture function signature has changed."),q=arguments[0]||null,A=arguments[1],B=arguments[2],F=arguments[3]||0,X=null);let me,Ie,Fe,Ge,Qe,Ze;X!==null?(me=X.max.x-X.min.x,Ie=X.max.y-X.min.y,Fe=X.min.x,Ge=X.min.y):(me=A.image.width,Ie=A.image.height,Fe=0,Ge=0),q!==null?(Qe=q.x,Ze=q.y):(Qe=0,Ze=0);const Je=ut.convert(B.format),Rt=ut.convert(B.type);R.setTexture2D(B,0),L.pixelStorei(L.UNPACK_FLIP_Y_WEBGL,B.flipY),L.pixelStorei(L.UNPACK_PREMULTIPLY_ALPHA_WEBGL,B.premultiplyAlpha),L.pixelStorei(L.UNPACK_ALIGNMENT,B.unpackAlignment);const jt=L.getParameter(L.UNPACK_ROW_LENGTH),Qt=L.getParameter(L.UNPACK_IMAGE_HEIGHT),ci=L.getParameter(L.UNPACK_SKIP_PIXELS),Ht=L.getParameter(L.UNPACK_SKIP_ROWS),Xe=L.getParameter(L.UNPACK_SKIP_IMAGES),Wi=A.isCompressedTexture?A.mipmaps[F]:A.image;L.pixelStorei(L.UNPACK_ROW_LENGTH,Wi.width),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,Wi.height),L.pixelStorei(L.UNPACK_SKIP_PIXELS,Fe),L.pixelStorei(L.UNPACK_SKIP_ROWS,Ge),A.isDataTexture?L.texSubImage2D(L.TEXTURE_2D,F,Qe,Ze,me,Ie,Je,Rt,Wi.data):A.isCompressedTexture?L.compressedTexSubImage2D(L.TEXTURE_2D,F,Qe,Ze,Wi.width,Wi.height,Je,Wi.data):L.texSubImage2D(L.TEXTURE_2D,F,Qe,Ze,me,Ie,Je,Rt,Wi),L.pixelStorei(L.UNPACK_ROW_LENGTH,jt),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,Qt),L.pixelStorei(L.UNPACK_SKIP_PIXELS,ci),L.pixelStorei(L.UNPACK_SKIP_ROWS,Ht),L.pixelStorei(L.UNPACK_SKIP_IMAGES,Xe),F===0&&B.generateMipmaps&&L.generateMipmap(L.TEXTURE_2D),we.unbindTexture()},this.copyTextureToTexture3D=function(A,B,X=null,q=null,F=0){A.isTexture!==!0&&(ou("WebGLRenderer: copyTextureToTexture3D function signature has changed."),X=arguments[0]||null,q=arguments[1]||null,A=arguments[2],B=arguments[3],F=arguments[4]||0);let me,Ie,Fe,Ge,Qe,Ze,Je,Rt,jt;const Qt=A.isCompressedTexture?A.mipmaps[F]:A.image;X!==null?(me=X.max.x-X.min.x,Ie=X.max.y-X.min.y,Fe=X.max.z-X.min.z,Ge=X.min.x,Qe=X.min.y,Ze=X.min.z):(me=Qt.width,Ie=Qt.height,Fe=Qt.depth,Ge=0,Qe=0,Ze=0),q!==null?(Je=q.x,Rt=q.y,jt=q.z):(Je=0,Rt=0,jt=0);const ci=ut.convert(B.format),Ht=ut.convert(B.type);let Xe;if(B.isData3DTexture)R.setTexture3D(B,0),Xe=L.TEXTURE_3D;else if(B.isDataArrayTexture||B.isCompressedArrayTexture)R.setTexture2DArray(B,0),Xe=L.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}L.pixelStorei(L.UNPACK_FLIP_Y_WEBGL,B.flipY),L.pixelStorei(L.UNPACK_PREMULTIPLY_ALPHA_WEBGL,B.premultiplyAlpha),L.pixelStorei(L.UNPACK_ALIGNMENT,B.unpackAlignment);const Wi=L.getParameter(L.UNPACK_ROW_LENGTH),ys=L.getParameter(L.UNPACK_IMAGE_HEIGHT),Hr=L.getParameter(L.UNPACK_SKIP_PIXELS),pa=L.getParameter(L.UNPACK_SKIP_ROWS),pr=L.getParameter(L.UNPACK_SKIP_IMAGES);L.pixelStorei(L.UNPACK_ROW_LENGTH,Qt.width),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,Qt.height),L.pixelStorei(L.UNPACK_SKIP_PIXELS,Ge),L.pixelStorei(L.UNPACK_SKIP_ROWS,Qe),L.pixelStorei(L.UNPACK_SKIP_IMAGES,Ze),A.isDataTexture||A.isData3DTexture?L.texSubImage3D(Xe,F,Je,Rt,jt,me,Ie,Fe,ci,Ht,Qt.data):B.isCompressedArrayTexture?L.compressedTexSubImage3D(Xe,F,Je,Rt,jt,me,Ie,Fe,ci,Qt.data):L.texSubImage3D(Xe,F,Je,Rt,jt,me,Ie,Fe,ci,Ht,Qt),L.pixelStorei(L.UNPACK_ROW_LENGTH,Wi),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,ys),L.pixelStorei(L.UNPACK_SKIP_PIXELS,Hr),L.pixelStorei(L.UNPACK_SKIP_ROWS,pa),L.pixelStorei(L.UNPACK_SKIP_IMAGES,pr),F===0&&B.generateMipmaps&&L.generateMipmap(Xe),we.unbindTexture()},this.initRenderTarget=function(A){Be.get(A).__webglFramebuffer===void 0&&R.setupRenderTarget(A)},this.initTexture=function(A){A.isCubeTexture?R.setTextureCube(A,0):A.isData3DTexture?R.setTexture3D(A,0):A.isDataArrayTexture||A.isCompressedArrayTexture?R.setTexture2DArray(A,0):R.setTexture2D(A,0),we.unbindTexture()},this.resetState=function(){I=0,b=0,w=null,we.reset(),Dt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Rr}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=e===Yo?"display-p3":"srgb",t.unpackColorSpace=vt.workingColorSpace===Ta?"display-p3":"srgb"}}class Nd{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new xe(e),this.density=t}clone(){return new Nd(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}let Kp=class qS{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new xe(e),this.near=t,this.far=i}clone(){return new qS(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}};class Ou extends _t{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new dr,this.environmentIntensity=1,this.environmentRotation=new dr,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class ja{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Sa,this.updateRanges=[],this.version=0,this.uuid=yr()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let r=0,s=this.stride;r<s;r++)this.array[e+r]=t.array[i+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=yr()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=yr()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const $i=new N;class On{constructor(e,t,i,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,i=this.data.count;t<i;t++)$i.fromBufferAttribute(this,t),$i.applyMatrix4(e),this.setXYZ(t,$i.x,$i.y,$i.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)$i.fromBufferAttribute(this,t),$i.applyNormalMatrix(e),this.setXYZ(t,$i.x,$i.y,$i.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)$i.fromBufferAttribute(this,t),$i.transformDirection(e),this.setXYZ(t,$i.x,$i.y,$i.z);return this}getComponent(e,t){let i=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(i=Xi(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=ht(i,this.array)),this.data.array[e*this.data.stride+this.offset+t]=i,this}setX(e,t){return this.normalized&&(t=ht(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=ht(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=ht(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=ht(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=Xi(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Xi(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Xi(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Xi(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=ht(t,this.array),i=ht(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=ht(t,this.array),i=ht(i,this.array),r=ht(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this}setXYZW(e,t,i,r,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=ht(t,this.array),i=ht(i,this.array),r=ht(r,this.array),s=ht(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return new wt(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new On(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class ul extends hi{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new xe(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let Xa;const hl=new N,qa=new N,Ya=new N,$a=new J,dl=new J,cy=new Re,Fu=new N,pl=new N,Vu=new N,uy=new J,Zp=new J,hy=new J;class Qp extends _t{constructor(e=new ul){if(super(),this.isSprite=!0,this.type="Sprite",Xa===void 0){Xa=new ct;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new ja(t,5);Xa.setIndex([0,1,2,0,2,3]),Xa.setAttribute("position",new On(i,3,0,!1)),Xa.setAttribute("uv",new On(i,2,3,!1))}this.geometry=Xa,this.material=e,this.center=new J(.5,.5)}raycast(e,t){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),qa.setFromMatrixScale(this.matrixWorld),cy.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Ya.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&qa.multiplyScalar(-Ya.z);const i=this.material.rotation;let r,s;i!==0&&(s=Math.cos(i),r=Math.sin(i));const a=this.center;Bu(Fu.set(-.5,-.5,0),Ya,a,qa,r,s),Bu(pl.set(.5,-.5,0),Ya,a,qa,r,s),Bu(Vu.set(.5,.5,0),Ya,a,qa,r,s),uy.set(0,0),Zp.set(1,0),hy.set(1,1);let o=e.ray.intersectTriangle(Fu,pl,Vu,!1,hl);if(o===null&&(Bu(pl.set(-.5,.5,0),Ya,a,qa,r,s),Zp.set(0,1),o=e.ray.intersectTriangle(Fu,Vu,pl,!1,hl),o===null))return;const l=e.ray.origin.distanceTo(hl);l<e.near||l>e.far||t.push({distance:l,point:hl.clone(),uv:er.getInterpolation(hl,Fu,pl,Vu,uy,Zp,hy,new J),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function Bu(n,e,t,i,r,s){$a.subVectors(n,t).addScalar(.5).multiply(i),r!==void 0?(dl.x=s*$a.x-r*$a.y,dl.y=r*$a.x+s*$a.y):dl.copy($a),n.copy(e),n.x+=dl.x,n.y+=dl.y,n.applyMatrix4(cy)}const zu=new N,dy=new N;class em extends _t{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let i=0,r=t.length;i<r;i++){const s=t[i];this.addLevel(s.object.clone(),s.distance,s.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,i=0){t=Math.abs(t);const r=this.levels;let s;for(s=0;s<r.length&&!(t<r[s].distance);s++);return r.splice(s,0,{distance:t,hysteresis:i,object:e}),this.add(e),this}removeLevel(e){const t=this.levels;for(let i=0;i<t.length;i++)if(t[i].distance===e){const r=t.splice(i,1);return this.remove(r[0].object),!0}return!1}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){const t=this.levels;if(t.length>0){let i,r;for(i=1,r=t.length;i<r;i++){let s=t[i].distance;if(t[i].object.visible&&(s-=s*t[i].hysteresis),e<s)break}return t[i-1].object}return null}raycast(e,t){if(this.levels.length>0){zu.setFromMatrixPosition(this.matrixWorld);const i=e.ray.origin.distanceTo(zu);this.getObjectForDistance(i).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){zu.setFromMatrixPosition(e.matrixWorld),dy.setFromMatrixPosition(this.matrixWorld);const i=zu.distanceTo(dy)/e.zoom;t[0].object.visible=!0;let r,s;for(r=1,s=t.length;r<s;r++){let a=t[r].distance;if(t[r].object.visible&&(a-=a*t[r].hysteresis),i>=a)t[r-1].object.visible=!1,t[r].object.visible=!0;else break}for(this._currentLevel=r-1;r<s;r++)t[r].object.visible=!1}}toJSON(e){const t=super.toJSON(e);this.autoUpdate===!1&&(t.object.autoUpdate=!1),t.object.levels=[];const i=this.levels;for(let r=0,s=i.length;r<s;r++){const a=i[r];t.object.levels.push({object:a.object.uuid,distance:a.distance,hysteresis:a.hysteresis})}return t}}const py=new N,my=new st,fy=new st,jR=new N,gy=new Re,ku=new N,tm=new Ai,vy=new Re,im=new As;class rm extends Ft{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=Zd,this.bindMatrix=new Re,this.bindMatrixInverse=new Re,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new Bi),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,ku),this.boundingBox.expandByPoint(ku)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Ai),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,ku),this.boundingSphere.expandByPoint(ku)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const i=this.material,r=this.matrixWorld;i!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),tm.copy(this.boundingSphere),tm.applyMatrix4(r),e.ray.intersectsSphere(tm)!==!1&&(vy.copy(r).invert(),im.copy(e.ray).applyMatrix4(vy),!(this.boundingBox!==null&&im.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,im)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new st,t=this.geometry.attributes.skinWeight;for(let i=0,r=t.count;i<r;i++){e.fromBufferAttribute(t,i);const s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(i,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===Zd?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===O0?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const i=this.skeleton,r=this.geometry;my.fromBufferAttribute(r.attributes.skinIndex,e),fy.fromBufferAttribute(r.attributes.skinWeight,e),py.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){const a=fy.getComponent(s);if(a!==0){const o=my.getComponent(s);gy.multiplyMatrices(i.bones[o].matrixWorld,i.boneInverses[o]),t.addScaledVector(jR.copy(py).applyMatrix4(gy),a)}}return t.applyMatrix4(this.bindMatrixInverse)}}class Hu extends _t{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Ur extends Wt{constructor(e=null,t=1,i=1,r,s,a,o,l,c=$t,u=$t,h,d){super(null,a,o,l,c,u,r,s,h,d),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const yy=new Re,XR=new Re;class gc{constructor(e=[],t=[]){this.uuid=yr(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,r=this.bones.length;i<r;i++)this.boneInverses.push(new Re)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const i=new Re;this.bones[e]&&i.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const i=this.bones[e];i&&i.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const i=this.bones[e];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){const e=this.bones,t=this.boneInverses,i=this.boneMatrices,r=this.boneTexture;for(let s=0,a=e.length;s<a;s++){const o=e[s]?e[s].matrixWorld:XR;yy.multiplyMatrices(o,t[s]),yy.toArray(i,s*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new gc(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const i=new Ur(t,e,e,Ei,Oi);return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){const r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,r=e.bones.length;i<r;i++){const s=e.bones[i];let a=t[s];a===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),a=new Hu),this.bones.push(a),this.boneInverses.push(new Re().fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){const e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,i=this.boneInverses;for(let r=0,s=t.length;r<s;r++){const a=t[r];e.bones.push(a.uuid);const o=i[r];e.boneInverses.push(o.toArray())}return e}}class Nn extends wt{constructor(e,t,i,r=1){super(e,t,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const Ja=new Re,xy=new Re,Gu=[],_y=new Bi,qR=new Re,ml=new Ft,fl=new Ai;class nm extends Ft{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Nn(new Float32Array(i*16),16),this.instanceColor=null,this.morphTexture=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let r=0;r<i;r++)this.setMatrixAt(r,qR)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new Bi),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Ja),_y.copy(e.boundingBox).applyMatrix4(Ja),this.boundingBox.union(_y)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new Ai),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Ja),fl.copy(e.boundingSphere).applyMatrix4(Ja),this.boundingSphere.union(fl)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const i=t.morphTargetInfluences,r=this.morphTexture.source.data.data,s=i.length+1,a=e*s+1;for(let o=0;o<i.length;o++)i[o]=r[a+o]}raycast(e,t){const i=this.matrixWorld,r=this.count;if(ml.geometry=this.geometry,ml.material=this.material,ml.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),fl.copy(this.boundingSphere),fl.applyMatrix4(i),e.ray.intersectsSphere(fl)!==!1))for(let s=0;s<r;s++){this.getMatrixAt(s,Ja),xy.multiplyMatrices(i,Ja),ml.matrixWorld=xy,ml.raycast(e,Gu);for(let a=0,o=Gu.length;a<o;a++){const l=Gu[a];l.instanceId=s,l.object=this,t.push(l)}Gu.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Nn(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){const i=t.morphTargetInfluences,r=i.length+1;this.morphTexture===null&&(this.morphTexture=new Ur(new Float32Array(r*this.count),r,this.count,Uo,Oi));const s=this.morphTexture.source.data.data;let a=0;for(let c=0;c<i.length;c++)a+=i[c];const o=this.geometry.morphTargetsRelative?1:1-a,l=r*e;s[l]=o,s.set(i,l+1)}updateMorphTargets(){}dispose(){return this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null),this}}function YR(n,e){return n.z-e.z}function $R(n,e){return e.z-n.z}class JR{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t,i){const r=this.pool,s=this.list;this.index>=r.length&&r.push({start:-1,count:-1,z:-1,index:-1});const a=r[this.index];s.push(a),this.index++,a.start=e.start,a.count=e.count,a.z=t,a.index=i}reset(){this.list.length=0,this.index=0}}const is=new Re,sm=new Re,KR=new Re,ZR=new xe(1,1,1),My=new Re,am=new ka,Wu=new Bi,Vs=new Ai,gl=new N,by=new N,QR=new N,om=new JR,ki=new Ft,ju=[];function eI(n,e,t=0){const i=e.itemSize;if(n.isInterleavedBufferAttribute||n.array.constructor!==e.array.constructor){const r=n.count;for(let s=0;s<r;s++)for(let a=0;a<i;a++)e.setComponent(s+t,a,n.getComponent(s,a))}else e.array.set(n.array,t*i);e.needsUpdate=!0}class lm extends Ft{get maxInstanceCount(){return this._maxInstanceCount}constructor(e,t,i=t*2,r){super(new ct,r),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._drawInfo=[],this._availableInstanceIds=[],this._drawRanges=[],this._reservedRanges=[],this._bounds=[],this._maxInstanceCount=e,this._maxVertexCount=t,this._maxIndexCount=i,this._geometryInitialized=!1,this._geometryCount=0,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),this._multiDrawCount=0,this._multiDrawInstances=null,this._visibilityChanged=!0,this._matricesTexture=null,this._indirectTexture=null,this._colorsTexture=null,this._initMatricesTexture(),this._initIndirectTexture()}_initMatricesTexture(){let e=Math.sqrt(this._maxInstanceCount*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4),i=new Ur(t,e,e,Ei,Oi);this._matricesTexture=i}_initIndirectTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Uint32Array(e*e),i=new Ur(t,e,e,Oo,Nr);this._indirectTexture=i}_initColorsTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Float32Array(e*e*4).fill(1),i=new Ur(t,e,e,Ei,Oi);i.colorSpace=vt.workingColorSpace,this._colorsTexture=i}_initializeGeometry(e){const t=this.geometry,i=this._maxVertexCount,r=this._maxIndexCount;if(this._geometryInitialized===!1){for(const s in e.attributes){const a=e.getAttribute(s),{array:o,itemSize:l,normalized:c}=a,u=new o.constructor(i*l),h=new wt(u,l,c);t.setAttribute(s,h)}if(e.getIndex()!==null){const s=i>65535?new Uint32Array(r):new Uint16Array(r);t.setIndex(new wt(s,1))}this._geometryInitialized=!0}}_validateGeometry(e){const t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('BatchedMesh: All geometries must consistently have "index".');for(const i in t.attributes){if(!e.hasAttribute(i))throw new Error(`BatchedMesh: Added geometry missing "${i}". All geometries must have consistent attributes.`);const r=e.getAttribute(i),s=t.getAttribute(i);if(r.itemSize!==s.itemSize||r.normalized!==s.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Bi);const e=this.boundingBox,t=this._drawInfo;e.makeEmpty();for(let i=0,r=t.length;i<r;i++){if(t[i].active===!1)continue;const s=t[i].geometryIndex;this.getMatrixAt(i,is),this.getBoundingBoxAt(s,Wu).applyMatrix4(is),e.union(Wu)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Ai);const e=this.boundingSphere,t=this._drawInfo;e.makeEmpty();for(let i=0,r=t.length;i<r;i++){if(t[i].active===!1)continue;const s=t[i].geometryIndex;this.getMatrixAt(i,is),this.getBoundingSphereAt(s,Vs).applyMatrix4(is),e.union(Vs)}}addInstance(e){if(this._drawInfo.length>=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("BatchedMesh: Maximum item count reached.");const t={visible:!0,active:!0,geometryIndex:e};let i=null;this._availableInstanceIds.length>0?(i=this._availableInstanceIds.pop(),this._drawInfo[i]=t):(i=this._drawInfo.length,this._drawInfo.push(t));const r=this._matricesTexture,s=r.image.data;KR.toArray(s,i*16),r.needsUpdate=!0;const a=this._colorsTexture;return a&&(ZR.toArray(a.image.data,i*4),a.needsUpdate=!0),i}addGeometry(e,t=-1,i=-1){if(this._initializeGeometry(e),this._validateGeometry(e),this._drawInfo.length>=this._maxInstanceCount)throw new Error("BatchedMesh: Maximum item count reached.");const r={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1};let s=null;const a=this._reservedRanges,o=this._drawRanges,l=this._bounds;this._geometryCount!==0&&(s=a[a.length-1]),t===-1?r.vertexCount=e.getAttribute("position").count:r.vertexCount=t,s===null?r.vertexStart=0:r.vertexStart=s.vertexStart+s.vertexCount;const c=e.getIndex(),u=c!==null;if(u&&(i===-1?r.indexCount=c.count:r.indexCount=i,s===null?r.indexStart=0:r.indexStart=s.indexStart+s.indexCount),r.indexStart!==-1&&r.indexStart+r.indexCount>this._maxIndexCount||r.vertexStart+r.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");const h=this._geometryCount;return this._geometryCount++,a.push(r),o.push({start:u?r.indexStart:r.vertexStart,count:-1}),l.push({boxInitialized:!1,box:new Bi,sphereInitialized:!1,sphere:new Ai}),this.setGeometryAt(h,e),h}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const i=this.geometry,r=i.getIndex()!==null,s=i.getIndex(),a=t.getIndex(),o=this._reservedRanges[e];if(r&&a.count>o.indexCount||t.attributes.position.count>o.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const l=o.vertexStart,c=o.vertexCount;for(const p in i.attributes){const m=t.getAttribute(p),v=i.getAttribute(p);eI(m,v,l);const f=m.itemSize;for(let g=m.count,x=c;g<x;g++){const y=l+g;for(let _=0;_<f;_++)v.setComponent(y,_,0)}v.needsUpdate=!0,v.addUpdateRange(l*f,c*f)}if(r){const p=o.indexStart;for(let m=0;m<a.count;m++)s.setX(p+m,l+a.getX(m));for(let m=a.count,v=o.indexCount;m<v;m++)s.setX(p+m,l);s.needsUpdate=!0,s.addUpdateRange(p,o.indexCount)}const u=this._bounds[e];t.boundingBox!==null?(u.box.copy(t.boundingBox),u.boxInitialized=!0):u.boxInitialized=!1,t.boundingSphere!==null?(u.sphere.copy(t.boundingSphere),u.sphereInitialized=!0):u.sphereInitialized=!1;const h=this._drawRanges[e],d=t.getAttribute("position");return h.count=r?a.count:d.count,this._visibilityChanged=!0,e}deleteInstance(e){const t=this._drawInfo;return e>=t.length||t[e].active===!1?this:(t[e].active=!1,this._availableInstanceIds.push(e),this._visibilityChanged=!0,this)}getBoundingBoxAt(e,t){if(e>=this._geometryCount)return null;const i=this._bounds[e],r=i.box,s=this.geometry;if(i.boxInitialized===!1){r.makeEmpty();const a=s.index,o=s.attributes.position,l=this._drawRanges[e];for(let c=l.start,u=l.start+l.count;c<u;c++){let h=c;a&&(h=a.getX(h)),r.expandByPoint(gl.fromBufferAttribute(o,h))}i.boxInitialized=!0}return t.copy(r),t}getBoundingSphereAt(e,t){if(e>=this._geometryCount)return null;const i=this._bounds[e],r=i.sphere,s=this.geometry;if(i.sphereInitialized===!1){r.makeEmpty(),this.getBoundingBoxAt(e,Wu),Wu.getCenter(r.center);const a=s.index,o=s.attributes.position,l=this._drawRanges[e];let c=0;for(let u=l.start,h=l.start+l.count;u<h;u++){let d=u;a&&(d=a.getX(d)),gl.fromBufferAttribute(o,d),c=Math.max(c,r.center.distanceToSquared(gl))}r.radius=Math.sqrt(c),i.sphereInitialized=!0}return t.copy(r),t}setMatrixAt(e,t){const i=this._drawInfo,r=this._matricesTexture,s=this._matricesTexture.image.data;return e>=i.length||i[e].active===!1?this:(t.toArray(s,e*16),r.needsUpdate=!0,this)}getMatrixAt(e,t){const i=this._drawInfo,r=this._matricesTexture.image.data;return e>=i.length||i[e].active===!1?null:t.fromArray(r,e*16)}setColorAt(e,t){this._colorsTexture===null&&this._initColorsTexture();const i=this._colorsTexture,r=this._colorsTexture.image.data,s=this._drawInfo;return e>=s.length||s[e].active===!1?this:(t.toArray(r,e*4),i.needsUpdate=!0,this)}getColorAt(e,t){const i=this._colorsTexture.image.data,r=this._drawInfo;return e>=r.length||r[e].active===!1?null:t.fromArray(i,e*4)}setVisibleAt(e,t){const i=this._drawInfo;return e>=i.length||i[e].active===!1||i[e].visible===t?this:(i[e].visible=t,this._visibilityChanged=!0,this)}getVisibleAt(e){const t=this._drawInfo;return e>=t.length||t[e].active===!1?!1:t[e].visible}setGeometryIdAt(e,t){const i=this._drawInfo;return e>=i.length||i[e].active===!1||t<0||t>=this._geometryCount?null:(i[e].geometryIndex=t,this)}getGeometryIdAt(e){const t=this._drawInfo;return e>=t.length||t[e].active===!1?-1:t[e].geometryIndex}getGeometryRangeAt(e,t={}){if(e<0||e>=this._geometryCount)return null;const i=this._drawRanges[e];return t.start=i.start,t.count=i.count,t}raycast(e,t){const i=this._drawInfo,r=this._drawRanges,s=this.matrixWorld,a=this.geometry;ki.material=this.material,ki.geometry.index=a.index,ki.geometry.attributes=a.attributes,ki.geometry.boundingBox===null&&(ki.geometry.boundingBox=new Bi),ki.geometry.boundingSphere===null&&(ki.geometry.boundingSphere=new Ai);for(let o=0,l=i.length;o<l;o++){if(!i[o].visible||!i[o].active)continue;const c=i[o].geometryIndex,u=r[c];ki.geometry.setDrawRange(u.start,u.count),this.getMatrixAt(o,ki.matrixWorld).premultiply(s),this.getBoundingBoxAt(c,ki.geometry.boundingBox),this.getBoundingSphereAt(c,ki.geometry.boundingSphere),ki.raycast(e,ju);for(let h=0,d=ju.length;h<d;h++){const p=ju[h];p.object=this,p.batchId=o,t.push(p)}ju.length=0}ki.material=null,ki.geometry.index=null,ki.geometry.attributes={},ki.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._drawRanges=e._drawRanges.map(t=>({...t})),this._reservedRanges=e._reservedRanges.map(t=>({...t})),this._drawInfo=e._drawInfo.map(t=>({...t})),this._bounds=e._bounds.map(t=>({boxInitialized:t.boxInitialized,box:t.box.clone(),sphereInitialized:t.sphereInitialized,sphere:t.sphere.clone()})),this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=e._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null),this}onBeforeRender(e,t,i,r,s){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const a=r.getIndex(),o=a===null?1:a.array.BYTES_PER_ELEMENT,l=this._drawInfo,c=this._multiDrawStarts,u=this._multiDrawCounts,h=this._drawRanges,d=this.perObjectFrustumCulled,p=this._indirectTexture,m=p.image.data;d&&(My.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),am.setFromProjectionMatrix(My,e.coordinateSystem));let v=0;if(this.sortObjects){sm.copy(this.matrixWorld).invert(),gl.setFromMatrixPosition(i.matrixWorld).applyMatrix4(sm),by.set(0,0,-1).transformDirection(i.matrixWorld).transformDirection(sm);for(let x=0,y=l.length;x<y;x++)if(l[x].visible&&l[x].active){const _=l[x].geometryIndex;this.getMatrixAt(x,is),this.getBoundingSphereAt(_,Vs).applyMatrix4(is);let I=!1;if(d&&(I=!am.intersectsSphere(Vs)),!I){const b=QR.subVectors(Vs.center,gl).dot(by);om.push(h[_],b,x)}}const f=om.list,g=this.customSort;g===null?f.sort(s.transparent?$R:YR):g.call(this,f,i);for(let x=0,y=f.length;x<y;x++){const _=f[x];c[v]=_.start*o,u[v]=_.count,m[v]=_.index,v++}om.reset()}else for(let f=0,g=l.length;f<g;f++)if(l[f].visible&&l[f].active){const x=l[f].geometryIndex;let y=!1;if(d&&(this.getMatrixAt(f,is),this.getBoundingSphereAt(x,Vs).applyMatrix4(is),y=!am.intersectsSphere(Vs)),!y){const _=h[x];c[v]=_.start*o,u[v]=_.count,m[v]=f,v++}}p.needsUpdate=!0,this._multiDrawCount=v,this._visibilityChanged=!1}onBeforeShadow(e,t,i,r,s,a){this.onBeforeRender(e,null,r,s,a)}}class Ni extends hi{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new xe(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const Xu=new N,qu=new N,Ty=new Re,vl=new As,Yu=new Ai,cm=new N,Sy=new N;class Cn extends _t{constructor(e=new ct,t=new Ni){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[0];for(let r=1,s=t.count;r<s;r++)Xu.fromBufferAttribute(t,r-1),qu.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=Xu.distanceTo(qu);e.setAttribute("lineDistance",new De(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const i=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,a=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Yu.copy(i.boundingSphere),Yu.applyMatrix4(r),Yu.radius+=s,e.ray.intersectsSphere(Yu)===!1)return;Ty.copy(r).invert(),vl.copy(e.ray).applyMatrix4(Ty);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=this.isLineSegments?2:1,u=i.index,h=i.attributes.position;if(u!==null){const d=Math.max(0,a.start),p=Math.min(u.count,a.start+a.count);for(let m=d,v=p-1;m<v;m+=c){const f=u.getX(m),g=u.getX(m+1),x=$u(this,e,vl,l,f,g);x&&t.push(x)}if(this.isLineLoop){const m=u.getX(p-1),v=u.getX(d),f=$u(this,e,vl,l,m,v);f&&t.push(f)}}else{const d=Math.max(0,a.start),p=Math.min(h.count,a.start+a.count);for(let m=d,v=p-1;m<v;m+=c){const f=$u(this,e,vl,l,m,m+1);f&&t.push(f)}if(this.isLineLoop){const m=$u(this,e,vl,l,p-1,d);m&&t.push(m)}}}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){const a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}}function $u(n,e,t,i,r,s){const a=n.geometry.attributes.position;if(Xu.fromBufferAttribute(a,r),qu.fromBufferAttribute(a,s),t.distanceSqToSegment(Xu,qu,cm,Sy)>i)return;cm.applyMatrix4(n.matrixWorld);const o=e.ray.origin.distanceTo(cm);if(!(o<e.near||o>e.far))return{distance:o,point:Sy.clone().applyMatrix4(n.matrixWorld),index:r,face:null,faceIndex:null,barycoord:null,object:n}}const wy=new N,Ey=new N;class $r extends Cn{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[];for(let r=0,s=t.count;r<s;r+=2)wy.fromBufferAttribute(t,r),Ey.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+wy.distanceTo(Ey);e.setAttribute("lineDistance",new De(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class um extends Cn{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class Ka extends hi{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new xe(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const Ay=new Re,hm=new As,Ju=new Ai,Ku=new N;class dm extends _t{constructor(e=new ct,t=new Ka){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const i=this.geometry,r=this.matrixWorld,s=e.params.Points.threshold,a=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Ju.copy(i.boundingSphere),Ju.applyMatrix4(r),Ju.radius+=s,e.ray.intersectsSphere(Ju)===!1)return;Ay.copy(r).invert(),hm.copy(e.ray).applyMatrix4(Ay);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=i.index,u=i.attributes.position;if(c!==null){const h=Math.max(0,a.start),d=Math.min(c.count,a.start+a.count);for(let p=h,m=d;p<m;p++){const v=c.getX(p);Ku.fromBufferAttribute(u,v),Ny(Ku,v,l,r,e,t,this)}}else{const h=Math.max(0,a.start),d=Math.min(u.count,a.start+a.count);for(let p=h,m=d;p<m;p++)Ku.fromBufferAttribute(u,p),Ny(Ku,p,l,r,e,t,this)}}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){const a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}}function Ny(n,e,t,i,r,s,a){const o=hm.distanceSqToPoint(n);if(o<t){const l=new N;hm.closestPointToPoint(n,l),l.applyMatrix4(i);const c=r.ray.origin.distanceTo(l);if(c<r.near||c>r.far)return;s.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class Cy extends Wt{constructor(e,t,i,r,s,a,o,l,c){super(e,t,i,r,s,a,o,l,c),this.isVideoTexture=!0,this.minFilter=a!==void 0?a:Lt,this.magFilter=s!==void 0?s:Lt,this.generateMipmaps=!1;const u=this;function h(){u.needsUpdate=!0,e.requestVideoFrameCallback(h)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(h)}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;!("requestVideoFrameCallback"in e)&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class pm extends Wt{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=$t,this.minFilter=$t,this.generateMipmaps=!1,this.needsUpdate=!0}}class yl extends Wt{constructor(e,t,i,r,s,a,o,l,c,u,h,d){super(null,a,o,l,c,u,r,s,h,d),this.isCompressedTexture=!0,this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class Ry extends yl{constructor(e,t,i,r,s,a){super(e,t,i,s,a),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=gr,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Iy extends yl{constructor(e,t,i){super(void 0,e[0].width,e[0].height,t,i,fr),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class Ly extends Wt{constructor(e,t,i,r,s,a,o,l,c){super(e,t,i,r,s,a,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Or{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let i,r=this.getPoint(0),s=0;t.push(0);for(let a=1;a<=e;a++)i=this.getPoint(a/e),s+=i.distanceTo(r),t.push(s),r=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const i=this.getLengths();let r=0;const s=i.length;let a;t?a=t:a=e*i[s-1];let o=0,l=s-1,c;for(;o<=l;)if(r=Math.floor(o+(l-o)/2),c=i[r]-a,c<0)o=r+1;else if(c>0)l=r-1;else{l=r;break}if(r=l,i[r]===a)return r/(s-1);const u=i[r],h=i[r+1]-u,d=(a-u)/h;return(r+d)/(s-1)}getTangent(e,t){let i=e-1e-4,r=e+1e-4;i<0&&(i=0),r>1&&(r=1);const s=this.getPoint(i),a=this.getPoint(r),o=t||(s.isVector2?new J:new N);return o.copy(a).sub(s).normalize(),o}getTangentAt(e,t){const i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){const i=new N,r=[],s=[],a=[],o=new N,l=new Re;for(let p=0;p<=e;p++){const m=p/e;r[p]=this.getTangentAt(m,new N)}s[0]=new N,a[0]=new N;let c=Number.MAX_VALUE;const u=Math.abs(r[0].x),h=Math.abs(r[0].y),d=Math.abs(r[0].z);u<=c&&(c=u,i.set(1,0,0)),h<=c&&(c=h,i.set(0,1,0)),d<=c&&i.set(0,0,1),o.crossVectors(r[0],i).normalize(),s[0].crossVectors(r[0],o),a[0].crossVectors(r[0],s[0]);for(let p=1;p<=e;p++){if(s[p]=s[p-1].clone(),a[p]=a[p-1].clone(),o.crossVectors(r[p-1],r[p]),o.length()>Number.EPSILON){o.normalize();const m=Math.acos(Jt(r[p-1].dot(r[p]),-1,1));s[p].applyMatrix4(l.makeRotationAxis(o,m))}a[p].crossVectors(r[p],s[p])}if(t===!0){let p=Math.acos(Jt(s[0].dot(s[e]),-1,1));p/=e,r[0].dot(o.crossVectors(s[0],s[e]))>0&&(p=-p);for(let m=1;m<=e;m++)s[m].applyMatrix4(l.makeRotationAxis(r[m],p*m)),a[m].crossVectors(r[m],s[m])}return{tangents:r,normals:s,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Zu extends Or{constructor(e=0,t=0,i=1,r=1,s=0,a=Math.PI*2,o=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=a,this.aClockwise=o,this.aRotation=l}getPoint(e,t=new J){const i=t,r=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const a=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(a?s=0:s=r),this.aClockwise===!0&&!a&&(s===r?s=-r:s=s-r);const o=this.aStartAngle+e*s;let l=this.aX+this.xRadius*Math.cos(o),c=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){const u=Math.cos(this.aRotation),h=Math.sin(this.aRotation),d=l-this.aX,p=c-this.aY;l=d*u-p*h+this.aX,c=d*h+p*u+this.aY}return i.set(l,c)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){const e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}}class Py extends Zu{constructor(e,t,i,r,s,a){super(e,t,i,i,r,s,a),this.isArcCurve=!0,this.type="ArcCurve"}}function mm(){let n=0,e=0,t=0,i=0;function r(s,a,o,l){n=s,e=o,t=-3*s+3*a-2*o-l,i=2*s-2*a+o+l}return{initCatmullRom:function(s,a,o,l,c){r(a,o,c*(o-s),c*(l-a))},initNonuniformCatmullRom:function(s,a,o,l,c,u,h){let d=(a-s)/c-(o-s)/(c+u)+(o-a)/u,p=(o-a)/u-(l-a)/(u+h)+(l-o)/h;d*=u,p*=u,r(a,o,d,p)},calc:function(s){const a=s*s,o=a*s;return n+e*s+t*a+i*o}}}const Qu=new N,fm=new mm,gm=new mm,vm=new mm;class Dy extends Or{constructor(e=[],t=!1,i="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=r}getPoint(e,t=new N){const i=t,r=this.points,s=r.length,a=(s-(this.closed?0:1))*e;let o=Math.floor(a),l=a-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/s)+1)*s:l===0&&o===s-1&&(o=s-2,l=1);let c,u;this.closed||o>0?c=r[(o-1)%s]:(Qu.subVectors(r[0],r[1]).add(r[0]),c=Qu);const h=r[o%s],d=r[(o+1)%s];if(this.closed||o+2<s?u=r[(o+2)%s]:(Qu.subVectors(r[s-1],r[s-2]).add(r[s-1]),u=Qu),this.curveType==="centripetal"||this.curveType==="chordal"){const p=this.curveType==="chordal"?.5:.25;let m=Math.pow(c.distanceToSquared(h),p),v=Math.pow(h.distanceToSquared(d),p),f=Math.pow(d.distanceToSquared(u),p);v<1e-4&&(v=1),m<1e-4&&(m=v),f<1e-4&&(f=v),fm.initNonuniformCatmullRom(c.x,h.x,d.x,u.x,m,v,f),gm.initNonuniformCatmullRom(c.y,h.y,d.y,u.y,m,v,f),vm.initNonuniformCatmullRom(c.z,h.z,d.z,u.z,m,v,f)}else this.curveType==="catmullrom"&&(fm.initCatmullRom(c.x,h.x,d.x,u.x,this.tension),gm.initCatmullRom(c.y,h.y,d.y,u.y,this.tension),vm.initCatmullRom(c.z,h.z,d.z,u.z,this.tension));return i.set(fm.calc(l),gm.calc(l),vm.calc(l)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(r.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){const r=this.points[t];e.points.push(r.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(new N().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function Uy(n,e,t,i,r){const s=(i-e)*.5,a=(r-t)*.5,o=n*n,l=n*o;return(2*t-2*i+s+a)*l+(-3*t+3*i-2*s-a)*o+s*n+t}function tI(n,e){const t=1-n;return t*t*e}function iI(n,e){return 2*(1-n)*n*e}function rI(n,e){return n*n*e}function xl(n,e,t,i){return tI(n,e)+iI(n,t)+rI(n,i)}function nI(n,e){const t=1-n;return t*t*t*e}function sI(n,e){const t=1-n;return 3*t*t*n*e}function aI(n,e){return 3*(1-n)*n*n*e}function oI(n,e){return n*n*n*e}function _l(n,e,t,i,r){return nI(n,e)+sI(n,t)+aI(n,i)+oI(n,r)}class ym extends Or{constructor(e=new J,t=new J,i=new J,r=new J){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new J){const i=t,r=this.v0,s=this.v1,a=this.v2,o=this.v3;return i.set(_l(e,r.x,s.x,a.x,o.x),_l(e,r.y,s.y,a.y,o.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class Oy extends Or{constructor(e=new N,t=new N,i=new N,r=new N){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new N){const i=t,r=this.v0,s=this.v1,a=this.v2,o=this.v3;return i.set(_l(e,r.x,s.x,a.x,o.x),_l(e,r.y,s.y,a.y,o.y),_l(e,r.z,s.z,a.z,o.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class xm extends Or{constructor(e=new J,t=new J){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new J){const i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new J){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Fy extends Or{constructor(e=new N,t=new N){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new N){const i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new N){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class _m extends Or{constructor(e=new J,t=new J,i=new J){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new J){const i=t,r=this.v0,s=this.v1,a=this.v2;return i.set(xl(e,r.x,s.x,a.x),xl(e,r.y,s.y,a.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Mm extends Or{constructor(e=new N,t=new N,i=new N){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new N){const i=t,r=this.v0,s=this.v1,a=this.v2;return i.set(xl(e,r.x,s.x,a.x),xl(e,r.y,s.y,a.y),xl(e,r.z,s.z,a.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class bm extends Or{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new J){const i=t,r=this.points,s=(r.length-1)*e,a=Math.floor(s),o=s-a,l=r[a===0?a:a-1],c=r[a],u=r[a>r.length-2?r.length-1:a+1],h=r[a>r.length-3?r.length-1:a+2];return i.set(Uy(o,l.x,c.x,u.x,h.x),Uy(o,l.y,c.y,u.y,h.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(r.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){const r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(new J().fromArray(r))}return this}}var eh=Object.freeze({__proto__:null,ArcCurve:Py,CatmullRomCurve3:Dy,CubicBezierCurve:ym,CubicBezierCurve3:Oy,EllipseCurve:Zu,LineCurve:xm,LineCurve3:Fy,QuadraticBezierCurve:_m,QuadraticBezierCurve3:Mm,SplineCurve:bm});class Vy extends Or{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){const i=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new eh[i](t,e))}return this}getPoint(e,t){const i=e*this.getLength(),r=this.getCurveLengths();let s=0;for(;s<r.length;){if(r[s]>=i){const a=r[s]-i,o=this.curves[s],l=o.getLength(),c=l===0?0:1-a/l;return o.getPointAt(c,t)}s++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let i=0,r=this.curves.length;i<r;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let i;for(let r=0,s=this.curves;r<s.length;r++){const a=s[r],o=a.isEllipseCurve?e*2:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?e*a.points.length:e,l=a.getPoints(o);for(let c=0;c<l.length;c++){const u=l[c];i&&i.equals(u)||(t.push(u),i=u)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){const r=e.curves[t];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){const r=this.curves[t];e.curves.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){const r=e.curves[t];this.curves.push(new eh[r.type]().fromJSON(r))}return this}}class Ml extends Vy{constructor(e){super(),this.type="Path",this.currentPoint=new J,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){const i=new xm(this.currentPoint.clone(),new J(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){const s=new _m(this.currentPoint.clone(),new J(e,t),new J(i,r));return this.curves.push(s),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,s,a){const o=new ym(this.currentPoint.clone(),new J(e,t),new J(i,r),new J(s,a));return this.curves.push(o),this.currentPoint.set(s,a),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),i=new bm(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,r,s,a){const o=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(e+o,t+l,i,r,s,a),this}absarc(e,t,i,r,s,a){return this.absellipse(e,t,i,i,r,s,a),this}ellipse(e,t,i,r,s,a,o,l){const c=this.currentPoint.x,u=this.currentPoint.y;return this.absellipse(e+c,t+u,i,r,s,a,o,l),this}absellipse(e,t,i,r,s,a,o,l){const c=new Zu(e,t,i,r,s,a,o,l);if(this.curves.length>0){const h=c.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(c);const u=c.getPoint(1);return this.currentPoint.copy(u),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class vc extends ct{constructor(e=[new J(0,-.5),new J(.5,0),new J(0,.5)],t=12,i=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:r},t=Math.floor(t),r=Jt(r,0,Math.PI*2);const s=[],a=[],o=[],l=[],c=[],u=1/t,h=new N,d=new J,p=new N,m=new N,v=new N;let f=0,g=0;for(let x=0;x<=e.length-1;x++)switch(x){case 0:f=e[x+1].x-e[x].x,g=e[x+1].y-e[x].y,p.x=g*1,p.y=-f,p.z=g*0,v.copy(p),p.normalize(),l.push(p.x,p.y,p.z);break;case e.length-1:l.push(v.x,v.y,v.z);break;default:f=e[x+1].x-e[x].x,g=e[x+1].y-e[x].y,p.x=g*1,p.y=-f,p.z=g*0,m.copy(p),p.x+=v.x,p.y+=v.y,p.z+=v.z,p.normalize(),l.push(p.x,p.y,p.z),v.copy(m)}for(let x=0;x<=t;x++){const y=i+x*u*r,_=Math.sin(y),I=Math.cos(y);for(let b=0;b<=e.length-1;b++){h.x=e[b].x*_,h.y=e[b].y,h.z=e[b].x*I,a.push(h.x,h.y,h.z),d.x=x/t,d.y=b/(e.length-1),o.push(d.x,d.y);const w=l[3*b+0]*_,C=l[3*b+1],H=l[3*b+0]*I;c.push(w,C,H)}}for(let x=0;x<t;x++)for(let y=0;y<e.length-1;y++){const _=y+x*e.length,I=_,b=_+e.length,w=_+e.length+1,C=_+1;s.push(I,b,C),s.push(w,C,b)}this.setIndex(s),this.setAttribute("position",new De(a,3)),this.setAttribute("uv",new De(o,2)),this.setAttribute("normal",new De(c,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new vc(e.points,e.segments,e.phiStart,e.phiLength)}}class Cd extends vc{constructor(e=1,t=1,i=4,r=8){const s=new Ml;s.absarc(0,-t/2,e,Math.PI*1.5,0),s.absarc(0,t/2,e,0,Math.PI*.5),super(s.getPoints(i),r),this.type="CapsuleGeometry",this.parameters={radius:e,length:t,capSegments:i,radialSegments:r}}static fromJSON(e){return new Cd(e.radius,e.length,e.capSegments,e.radialSegments)}}class Rd extends ct{constructor(e=1,t=32,i=0,r=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:r},t=Math.max(3,t);const s=[],a=[],o=[],l=[],c=new N,u=new J;a.push(0,0,0),o.push(0,0,1),l.push(.5,.5);for(let h=0,d=3;h<=t;h++,d+=3){const p=i+h/t*r;c.x=e*Math.cos(p),c.y=e*Math.sin(p),a.push(c.x,c.y,c.z),o.push(0,0,1),u.x=(a[d]/e+1)/2,u.y=(a[d+1]/e+1)/2,l.push(u.x,u.y)}for(let h=1;h<=t;h++)s.push(h,h+1,0);this.setIndex(s),this.setAttribute("position",new De(a,3)),this.setAttribute("normal",new De(o,3)),this.setAttribute("uv",new De(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Rd(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class da extends ct{constructor(e=1,t=1,i=1,r=32,s=1,a=!1,o=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:s,openEnded:a,thetaStart:o,thetaLength:l};const c=this;r=Math.floor(r),s=Math.floor(s);const u=[],h=[],d=[],p=[];let m=0;const v=[],f=i/2;let g=0;x(),a===!1&&(e>0&&y(!0),t>0&&y(!1)),this.setIndex(u),this.setAttribute("position",new De(h,3)),this.setAttribute("normal",new De(d,3)),this.setAttribute("uv",new De(p,2));function x(){const _=new N,I=new N;let b=0;const w=(t-e)/i;for(let C=0;C<=s;C++){const H=[],M=C/s,T=M*(t-e)+e;for(let k=0;k<=r;k++){const j=k/r,Y=j*l+o,re=Math.sin(Y),$=Math.cos(Y);I.x=T*re,I.y=-M*i+f,I.z=T*$,h.push(I.x,I.y,I.z),_.set(re,w,$).normalize(),d.push(_.x,_.y,_.z),p.push(j,1-M),H.push(m++)}v.push(H)}for(let C=0;C<r;C++)for(let H=0;H<s;H++){const M=v[H][C],T=v[H+1][C],k=v[H+1][C+1],j=v[H][C+1];e>0&&(u.push(M,T,j),b+=3),t>0&&(u.push(T,k,j),b+=3)}c.addGroup(g,b,0),g+=b}function y(_){const I=m,b=new J,w=new N;let C=0;const H=_===!0?e:t,M=_===!0?1:-1;for(let k=1;k<=r;k++)h.push(0,f*M,0),d.push(0,M,0),p.push(.5,.5),m++;const T=m;for(let k=0;k<=r;k++){const j=k/r*l+o,Y=Math.cos(j),re=Math.sin(j);w.x=H*re,w.y=f*M,w.z=H*Y,h.push(w.x,w.y,w.z),d.push(0,M,0),b.x=Y*.5+.5,b.y=re*.5*M+.5,p.push(b.x,b.y),m++}for(let k=0;k<r;k++){const j=I+k,Y=T+k;_===!0?u.push(Y,Y+1,j):u.push(Y+1,Y,j),C+=3}c.addGroup(g,C,_===!0?1:2),g+=C}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new da(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Id extends da{constructor(e=1,t=1,i=32,r=1,s=!1,a=0,o=Math.PI*2){super(0,e,t,i,r,s,a,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:s,thetaStart:a,thetaLength:o}}static fromJSON(e){return new Id(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class fs extends ct{constructor(e=[],t=[],i=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:r};const s=[],a=[];o(r),c(i),u(),this.setAttribute("position",new De(s,3)),this.setAttribute("normal",new De(s.slice(),3)),this.setAttribute("uv",new De(a,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function o(x){const y=new N,_=new N,I=new N;for(let b=0;b<t.length;b+=3)p(t[b+0],y),p(t[b+1],_),p(t[b+2],I),l(y,_,I,x)}function l(x,y,_,I){const b=I+1,w=[];for(let C=0;C<=b;C++){w[C]=[];const H=x.clone().lerp(_,C/b),M=y.clone().lerp(_,C/b),T=b-C;for(let k=0;k<=T;k++)k===0&&C===b?w[C][k]=H:w[C][k]=H.clone().lerp(M,k/T)}for(let C=0;C<b;C++)for(let H=0;H<2*(b-C)-1;H++){const M=Math.floor(H/2);H%2===0?(d(w[C][M+1]),d(w[C+1][M]),d(w[C][M])):(d(w[C][M+1]),d(w[C+1][M+1]),d(w[C+1][M]))}}function c(x){const y=new N;for(let _=0;_<s.length;_+=3)y.x=s[_+0],y.y=s[_+1],y.z=s[_+2],y.normalize().multiplyScalar(x),s[_+0]=y.x,s[_+1]=y.y,s[_+2]=y.z}function u(){const x=new N;for(let y=0;y<s.length;y+=3){x.x=s[y+0],x.y=s[y+1],x.z=s[y+2];const _=f(x)/2/Math.PI+.5,I=g(x)/Math.PI+.5;a.push(_,1-I)}m(),h()}function h(){for(let x=0;x<a.length;x+=6){const y=a[x+0],_=a[x+2],I=a[x+4],b=Math.max(y,_,I),w=Math.min(y,_,I);b>.9&&w<.1&&(y<.2&&(a[x+0]+=1),_<.2&&(a[x+2]+=1),I<.2&&(a[x+4]+=1))}}function d(x){s.push(x.x,x.y,x.z)}function p(x,y){const _=x*3;y.x=e[_+0],y.y=e[_+1],y.z=e[_+2]}function m(){const x=new N,y=new N,_=new N,I=new N,b=new J,w=new J,C=new J;for(let H=0,M=0;H<s.length;H+=9,M+=6){x.set(s[H+0],s[H+1],s[H+2]),y.set(s[H+3],s[H+4],s[H+5]),_.set(s[H+6],s[H+7],s[H+8]),b.set(a[M+0],a[M+1]),w.set(a[M+2],a[M+3]),C.set(a[M+4],a[M+5]),I.copy(x).add(y).add(_).divideScalar(3);const T=f(I);v(b,M+0,x,T),v(w,M+2,y,T),v(C,M+4,_,T)}}function v(x,y,_,I){I<0&&x.x===1&&(a[y]=x.x-1),_.x===0&&_.z===0&&(a[y]=I/2/Math.PI+.5)}function f(x){return Math.atan2(x.z,-x.x)}function g(x){return Math.atan2(-x.y,Math.sqrt(x.x*x.x+x.z*x.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new fs(e.vertices,e.indices,e.radius,e.details)}}class Ld extends fs{constructor(e=1,t=0){const i=(1+Math.sqrt(5))/2,r=1/i,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-i,0,-r,i,0,r,-i,0,r,i,-r,-i,0,-r,i,0,r,-i,0,r,i,0,-i,0,-r,i,0,-r,-i,0,r,i,0,r],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,a,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Ld(e.radius,e.detail)}}const th=new N,ih=new N,Tm=new N,rh=new er;class Sm extends ct{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){const i=Math.pow(10,4),r=Math.cos(Ss*t),s=e.getIndex(),a=e.getAttribute("position"),o=s?s.count:a.count,l=[0,0,0],c=["a","b","c"],u=new Array(3),h={},d=[];for(let p=0;p<o;p+=3){s?(l[0]=s.getX(p),l[1]=s.getX(p+1),l[2]=s.getX(p+2)):(l[0]=p,l[1]=p+1,l[2]=p+2);const{a:m,b:v,c:f}=rh;if(m.fromBufferAttribute(a,l[0]),v.fromBufferAttribute(a,l[1]),f.fromBufferAttribute(a,l[2]),rh.getNormal(Tm),u[0]=`${Math.round(m.x*i)},${Math.round(m.y*i)},${Math.round(m.z*i)}`,u[1]=`${Math.round(v.x*i)},${Math.round(v.y*i)},${Math.round(v.z*i)}`,u[2]=`${Math.round(f.x*i)},${Math.round(f.y*i)},${Math.round(f.z*i)}`,!(u[0]===u[1]||u[1]===u[2]||u[2]===u[0]))for(let g=0;g<3;g++){const x=(g+1)%3,y=u[g],_=u[x],I=rh[c[g]],b=rh[c[x]],w=`${y}_${_}`,C=`${_}_${y}`;C in h&&h[C]?(Tm.dot(h[C].normal)<=r&&(d.push(I.x,I.y,I.z),d.push(b.x,b.y,b.z)),h[C]=null):w in h||(h[w]={index0:l[g],index1:l[x],normal:Tm.clone()})}}for(const p in h)if(h[p]){const{index0:m,index1:v}=h[p];th.fromBufferAttribute(a,m),ih.fromBufferAttribute(a,v),d.push(th.x,th.y,th.z),d.push(ih.x,ih.y,ih.z)}this.setAttribute("position",new De(d,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class rs extends Ml{constructor(e){super(e),this.uuid=yr(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let i=0,r=this.holes.length;i<r;i++)t[i]=this.holes[i].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){const r=e.holes[t];this.holes.push(r.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){const r=this.holes[t];e.holes.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){const r=e.holes[t];this.holes.push(new Ml().fromJSON(r))}return this}}const lI={triangulate:function(n,e,t=2){const i=e&&e.length,r=i?e[0]*t:n.length;let s=By(n,0,r,t,!0);const a=[];if(!s||s.next===s.prev)return a;let o,l,c,u,h,d,p;if(i&&(s=pI(n,e,s,t)),n.length>80*t){o=c=n[0],l=u=n[1];for(let m=t;m<r;m+=t)h=n[m],d=n[m+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=p!==0?32767/p:0}return bl(s,a,t,o,l,p,0),a}};function By(n,e,t,i,r){let s,a;if(r===SI(n,e,t,i)>0)for(s=e;s<t;s+=i)a=Hy(s,n[s],n[s+1],a);else for(s=t-i;s>=e;s-=i)a=Hy(s,n[s],n[s+1],a);return a&&nh(a,a.next)&&(Sl(a),a=a.next),a}function Bs(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&(nh(t,t.next)||Xt(t.prev,t,t.next)===0)){if(Sl(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function bl(n,e,t,i,r,s,a){if(!n)return;!a&&s&&yI(n,i,r,s);let o=n,l,c;for(;n.prev!==n.next;){if(l=n.prev,c=n.next,s?uI(n,i,r,s):cI(n)){e.push(l.i/t|0),e.push(n.i/t|0),e.push(c.i/t|0),Sl(n),n=c.next,o=c.next;continue}if(n=c,n===o){a?a===1?(n=hI(Bs(n),e,t),bl(n,e,t,i,r,s,2)):a===2&&dI(n,e,t,i,r,s):bl(Bs(n),e,t,i,r,s,1);break}}}function cI(n){const e=n.prev,t=n,i=n.next;if(Xt(e,t,i)>=0)return!1;const r=e.x,s=t.x,a=i.x,o=e.y,l=t.y,c=i.y,u=r<s?r<a?r:a:s<a?s:a,h=o<l?o<c?o:c:l<c?l:c,d=r>s?r>a?r:a:s>a?s: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&&Za(r,o,s,l,a,c,m.x,m.y)&&Xt(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function uI(n,e,t,i){const r=n.prev,s=n,a=n.next;if(Xt(r,s,a)>=0)return!1;const o=r.x,l=s.x,c=a.x,u=r.y,h=s.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,v=o>l?o>c?o:c:l>c?l:c,f=u>h?u>d?u:d:h>d?h:d,g=wm(p,m,e,t,i),x=wm(v,f,e,t,i);let y=n.prevZ,_=n.nextZ;for(;y&&y.z>=g&&_&&_.z<=x;){if(y.x>=p&&y.x<=v&&y.y>=m&&y.y<=f&&y!==r&&y!==a&&Za(o,u,l,h,c,d,y.x,y.y)&&Xt(y.prev,y,y.next)>=0||(y=y.prevZ,_.x>=p&&_.x<=v&&_.y>=m&&_.y<=f&&_!==r&&_!==a&&Za(o,u,l,h,c,d,_.x,_.y)&&Xt(_.prev,_,_.next)>=0))return!1;_=_.nextZ}for(;y&&y.z>=g;){if(y.x>=p&&y.x<=v&&y.y>=m&&y.y<=f&&y!==r&&y!==a&&Za(o,u,l,h,c,d,y.x,y.y)&&Xt(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;_&&_.z<=x;){if(_.x>=p&&_.x<=v&&_.y>=m&&_.y<=f&&_!==r&&_!==a&&Za(o,u,l,h,c,d,_.x,_.y)&&Xt(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function hI(n,e,t){let i=n;do{const r=i.prev,s=i.next.next;!nh(r,s)&&zy(r,i,i.next,s)&&Tl(r,s)&&Tl(s,r)&&(e.push(r.i/t|0),e.push(i.i/t|0),e.push(s.i/t|0),Sl(i),Sl(i.next),i=n=s),i=i.next}while(i!==n);return Bs(i)}function dI(n,e,t,i,r,s){let a=n;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&MI(a,o)){let l=ky(a,o);a=Bs(a,a.next),l=Bs(l,l.next),bl(a,e,t,i,r,s,0),bl(l,e,t,i,r,s,0);return}o=o.next}a=a.next}while(a!==n)}function pI(n,e,t,i){const r=[];let s,a,o,l,c;for(s=0,a=e.length;s<a;s++)o=e[s]*i,l=s<a-1?e[s+1]*i:n.length,c=By(n,o,l,i,!1),c===c.next&&(c.steiner=!0),r.push(_I(c));for(r.sort(mI),s=0;s<r.length;s++)t=fI(r[s],t);return t}function mI(n,e){return n.x-e.x}function fI(n,e){const t=gI(n,e);if(!t)return e;const i=ky(t,n);return Bs(i,i.next),Bs(t,t.next)}function gI(n,e){let t=e,i=-1/0,r;const s=n.x,a=n.y;do{if(a<=t.y&&a>=t.next.y&&t.next.y!==t.y){const d=t.x+(a-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=s&&d>i&&(i=d,r=t.x<t.next.x?t:t.next,d===s))return r}t=t.next}while(t!==e);if(!r)return null;const o=r,l=r.x,c=r.y;let u=1/0,h;t=r;do s>=t.x&&t.x>=l&&s!==t.x&&Za(a<c?s:i,a,l,c,a<c?i:s,a,t.x,t.y)&&(h=Math.abs(a-t.y)/(s-t.x),Tl(t,n)&&(h<u||h===u&&(t.x>r.x||t.x===r.x&&vI(r,t)))&&(r=t,u=h)),t=t.next;while(t!==o);return r}function vI(n,e){return Xt(n.prev,n,e.prev)<0&&Xt(e.next,n,n.next)<0}function yI(n,e,t,i){let r=n;do r.z===0&&(r.z=wm(r.x,r.y,e,t,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==n);r.prevZ.nextZ=null,r.prevZ=null,xI(r)}function xI(n){let e,t,i,r,s,a,o,l,c=1;do{for(t=n,n=null,s=null,a=0;t;){for(a++,i=t,o=0,e=0;e<c&&(o++,i=i.nextZ,!!i);e++);for(l=c;o>0||l>0&&i;)o!==0&&(l===0||!i||t.z<=i.z)?(r=t,t=t.nextZ,o--):(r=i,i=i.nextZ,l--),s?s.nextZ=r:n=r,r.prevZ=s,s=r;t=i}s.nextZ=null,c*=2}while(a>1);return n}function wm(n,e,t,i,r){return n=(n-t)*r|0,e=(e-i)*r|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function _I(n){let e=n,t=n;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==n);return t}function Za(n,e,t,i,r,s,a,o){return(r-a)*(e-o)>=(n-a)*(s-o)&&(n-a)*(i-o)>=(t-a)*(e-o)&&(t-a)*(s-o)>=(r-a)*(i-o)}function MI(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!bI(n,e)&&(Tl(n,e)&&Tl(e,n)&&TI(n,e)&&(Xt(n.prev,n,e.prev)||Xt(n,e.prev,e))||nh(n,e)&&Xt(n.prev,n,n.next)>0&&Xt(e.prev,e,e.next)>0)}function Xt(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function nh(n,e){return n.x===e.x&&n.y===e.y}function zy(n,e,t,i){const r=ah(Xt(n,e,t)),s=ah(Xt(n,e,i)),a=ah(Xt(t,i,n)),o=ah(Xt(t,i,e));return!!(r!==s&&a!==o||r===0&&sh(n,t,e)||s===0&&sh(n,i,e)||a===0&&sh(t,n,i)||o===0&&sh(t,e,i))}function sh(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function ah(n){return n>0?1:n<0?-1:0}function bI(n,e){let t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&zy(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function Tl(n,e){return Xt(n.prev,n,n.next)<0?Xt(n,e,n.next)>=0&&Xt(n,n.prev,e)>=0:Xt(n,e,n.prev)<0||Xt(n,n.next,e)<0}function TI(n,e){let t=n,i=!1;const r=(n.x+e.x)/2,s=(n.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==n);return i}function ky(n,e){const t=new Em(n.i,n.x,n.y),i=new Em(e.i,e.x,e.y),r=n.next,s=e.prev;return n.next=e,e.prev=n,t.next=r,r.prev=t,i.next=t,t.prev=i,s.next=i,i.prev=s,i}function Hy(n,e,t,i){const r=new Em(n,e,t);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function Sl(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function Em(n,e,t){this.i=n,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function SI(n,e,t,i){let r=0;for(let s=e,a=t-i;s<t;s+=i)r+=(n[a]-n[s])*(n[s+1]+n[a+1]),a=s;return r}class nn{static area(e){const t=e.length;let i=0;for(let r=t-1,s=0;s<t;r=s++)i+=e[r].x*e[s].y-e[s].x*e[r].y;return i*.5}static isClockWise(e){return nn.area(e)<0}static triangulateShape(e,t){const i=[],r=[],s=[];Gy(e),Wy(i,e);let a=e.length;t.forEach(Gy);for(let l=0;l<t.length;l++)r.push(a),a+=t[l].length,Wy(i,t[l]);const o=lI.triangulate(i,r);for(let l=0;l<o.length;l+=3)s.push(o.slice(l,l+3));return s}}function Gy(n){const e=n.length;e>2&&n[e-1].equals(n[0])&&n.pop()}function Wy(n,e){for(let t=0;t<e.length;t++)n.push(e[t].x),n.push(e[t].y)}class yc extends ct{constructor(e=new rs([new J(.5,.5),new J(-.5,.5),new J(-.5,-.5),new J(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const i=this,r=[],s=[];for(let o=0,l=e.length;o<l;o++){const c=e[o];a(c)}this.setAttribute("position",new De(r,3)),this.setAttribute("uv",new De(s,2)),this.computeVertexNormals();function a(o){const l=[],c=t.curveSegments!==void 0?t.curveSegments:12,u=t.steps!==void 0?t.steps:1,h=t.depth!==void 0?t.depth:1;let d=t.bevelEnabled!==void 0?t.bevelEnabled:!0,p=t.bevelThickness!==void 0?t.bevelThickness:.2,m=t.bevelSize!==void 0?t.bevelSize:p-.1,v=t.bevelOffset!==void 0?t.bevelOffset:0,f=t.bevelSegments!==void 0?t.bevelSegments:3;const g=t.extrudePath,x=t.UVGenerator!==void 0?t.UVGenerator:wI;let y,_=!1,I,b,w,C;g&&(y=g.getSpacedPoints(u),_=!0,d=!1,I=g.computeFrenetFrames(u,!1),b=new N,w=new N,C=new N),d||(f=0,p=0,m=0,v=0);const H=o.extractPoints(c);let M=H.shape;const T=H.holes;if(!nn.isClockWise(M)){M=M.reverse();for(let ce=0,ue=T.length;ce<ue;ce++){const L=T[ce];nn.isClockWise(L)&&(T[ce]=L.reverse())}}const k=nn.triangulateShape(M,T),j=M;for(let ce=0,ue=T.length;ce<ue;ce++){const L=T[ce];M=M.concat(L)}function Y(ce,ue,L){return ue||console.error("THREE.ExtrudeGeometry: vec does not exist"),ce.clone().addScaledVector(ue,L)}const re=M.length,$=k.length;function he(ce,ue,L){let He,pe,Ue;const we=ce.x-ue.x,$e=ce.y-ue.y,Be=L.x-ce.x,R=L.y-ce.y,S=we*we+$e*$e,W=we*R-$e*Be;if(Math.abs(W)>Number.EPSILON){const ne=Math.sqrt(S),de=Math.sqrt(Be*Be+R*R),se=ue.x-$e/ne,ke=ue.y+we/ne,Ee=L.x-R/de,Pe=L.y+Be/de,mt=((Ee-se)*R-(Pe-ke)*Be)/(we*R-$e*Be);He=se+we*mt-ce.x,pe=ke+$e*mt-ce.y;const ve=He*He+pe*pe;if(ve<=2)return new J(He,pe);Ue=Math.sqrt(ve/2)}else{let ne=!1;we>Number.EPSILON?Be>Number.EPSILON&&(ne=!0):we<-Number.EPSILON?Be<-Number.EPSILON&&(ne=!0):Math.sign($e)===Math.sign(R)&&(ne=!0),ne?(He=-$e,pe=we,Ue=Math.sqrt(S)):(He=we,pe=$e,Ue=Math.sqrt(S/2))}return new J(He/Ue,pe/Ue)}const Q=[];for(let ce=0,ue=j.length,L=ue-1,He=ce+1;ce<ue;ce++,L++,He++)L===ue&&(L=0),He===ue&&(He=0),Q[ce]=he(j[ce],j[L],j[He]);const ye=[];let be,Ve=Q.concat();for(let ce=0,ue=T.length;ce<ue;ce++){const L=T[ce];be=[];for(let He=0,pe=L.length,Ue=pe-1,we=He+1;He<pe;He++,Ue++,we++)Ue===pe&&(Ue=0),we===pe&&(we=0),be[He]=he(L[He],L[Ue],L[we]);ye.push(be),Ve=Ve.concat(be)}for(let ce=0;ce<f;ce++){const ue=ce/f,L=p*Math.cos(ue*Math.PI/2),He=m*Math.sin(ue*Math.PI/2)+v;for(let pe=0,Ue=j.length;pe<Ue;pe++){const we=Y(j[pe],Q[pe],He);Te(we.x,we.y,-L)}for(let pe=0,Ue=T.length;pe<Ue;pe++){const we=T[pe];be=ye[pe];for(let $e=0,Be=we.length;$e<Be;$e++){const R=Y(we[$e],be[$e],He);Te(R.x,R.y,-L)}}}const at=m+v;for(let ce=0;ce<re;ce++){const ue=d?Y(M[ce],Ve[ce],at):M[ce];_?(w.copy(I.normals[0]).multiplyScalar(ue.x),b.copy(I.binormals[0]).multiplyScalar(ue.y),C.copy(y[0]).add(w).add(b),Te(C.x,C.y,C.z)):Te(ue.x,ue.y,0)}for(let ce=1;ce<=u;ce++)for(let ue=0;ue<re;ue++){const L=d?Y(M[ue],Ve[ue],at):M[ue];_?(w.copy(I.normals[ce]).multiplyScalar(L.x),b.copy(I.binormals[ce]).multiplyScalar(L.y),C.copy(y[ce]).add(w).add(b),Te(C.x,C.y,C.z)):Te(L.x,L.y,h/u*ce)}for(let ce=f-1;ce>=0;ce--){const ue=ce/f,L=p*Math.cos(ue*Math.PI/2),He=m*Math.sin(ue*Math.PI/2)+v;for(let pe=0,Ue=j.length;pe<Ue;pe++){const we=Y(j[pe],Q[pe],He);Te(we.x,we.y,h+L)}for(let pe=0,Ue=T.length;pe<Ue;pe++){const we=T[pe];be=ye[pe];for(let $e=0,Be=we.length;$e<Be;$e++){const R=Y(we[$e],be[$e],He);_?Te(R.x,R.y+y[u-1].y,y[u-1].x+L):Te(R.x,R.y,h+L)}}}et(),ie();function et(){const ce=r.length/3;if(d){let ue=0,L=re*ue;for(let He=0;He<$;He++){const pe=k[He];Se(pe[2]+L,pe[1]+L,pe[0]+L)}ue=u+f*2,L=re*ue;for(let He=0;He<$;He++){const pe=k[He];Se(pe[0]+L,pe[1]+L,pe[2]+L)}}else{for(let ue=0;ue<$;ue++){const L=k[ue];Se(L[2],L[1],L[0])}for(let ue=0;ue<$;ue++){const L=k[ue];Se(L[0]+re*u,L[1]+re*u,L[2]+re*u)}}i.addGroup(ce,r.length/3-ce,0)}function ie(){const ce=r.length/3;let ue=0;le(j,ue),ue+=j.length;for(let L=0,He=T.length;L<He;L++){const pe=T[L];le(pe,ue),ue+=pe.length}i.addGroup(ce,r.length/3-ce,1)}function le(ce,ue){let L=ce.length;for(;--L>=0;){const He=L;let pe=L-1;pe<0&&(pe=ce.length-1);for(let Ue=0,we=u+f*2;Ue<we;Ue++){const $e=re*Ue,Be=re*(Ue+1),R=ue+He+$e,S=ue+pe+$e,W=ue+pe+Be,ne=ue+He+Be;Ye(R,S,W,ne)}}}function Te(ce,ue,L){l.push(ce),l.push(ue),l.push(L)}function Se(ce,ue,L){We(ce),We(ue),We(L);const He=r.length/3,pe=x.generateTopUV(i,r,He-3,He-2,He-1);ot(pe[0]),ot(pe[1]),ot(pe[2])}function Ye(ce,ue,L,He){We(ce),We(ue),We(He),We(ue),We(L),We(He);const pe=r.length/3,Ue=x.generateSideWallUV(i,r,pe-6,pe-3,pe-2,pe-1);ot(Ue[0]),ot(Ue[1]),ot(Ue[3]),ot(Ue[1]),ot(Ue[2]),ot(Ue[3])}function We(ce){r.push(l[ce*3+0]),r.push(l[ce*3+1]),r.push(l[ce*3+2])}function ot(ce){s.push(ce.x),s.push(ce.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes,i=this.parameters.options;return EI(t,i,e)}static fromJSON(e,t){const i=[];for(let s=0,a=e.shapes.length;s<a;s++){const o=t[e.shapes[s]];i.push(o)}const r=e.options.extrudePath;return r!==void 0&&(e.options.extrudePath=new eh[r.type]().fromJSON(r)),new yc(i,e.options)}}const wI={generateTopUV:function(n,e,t,i,r){const s=e[t*3],a=e[t*3+1],o=e[i*3],l=e[i*3+1],c=e[r*3],u=e[r*3+1];return[new J(s,a),new J(o,l),new J(c,u)]},generateSideWallUV:function(n,e,t,i,r,s){const a=e[t*3],o=e[t*3+1],l=e[t*3+2],c=e[i*3],u=e[i*3+1],h=e[i*3+2],d=e[r*3],p=e[r*3+1],m=e[r*3+2],v=e[s*3],f=e[s*3+1],g=e[s*3+2];return Math.abs(o-u)<Math.abs(a-c)?[new J(a,1-l),new J(c,1-h),new J(d,1-m),new J(v,1-g)]:[new J(o,1-l),new J(u,1-h),new J(p,1-m),new J(f,1-g)]}};function EI(n,e,t){if(t.shapes=[],Array.isArray(n))for(let i=0,r=n.length;i<r;i++){const s=n[i];t.shapes.push(s.uuid)}else t.shapes.push(n.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}class Pd extends fs{constructor(e=1,t=0){const i=(1+Math.sqrt(5))/2,r=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(r,s,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Pd(e.radius,e.detail)}}class wo extends fs{constructor(e=1,t=0){const i=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],r=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(i,r,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new wo(e.radius,e.detail)}}class xc extends ct{constructor(e=.5,t=1,i=32,r=1,s=0,a=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:i,phiSegments:r,thetaStart:s,thetaLength:a},i=Math.max(3,i),r=Math.max(1,r);const o=[],l=[],c=[],u=[];let h=e;const d=(t-e)/r,p=new N,m=new J;for(let v=0;v<=r;v++){for(let f=0;f<=i;f++){const g=s+f/i*a;p.x=h*Math.cos(g),p.y=h*Math.sin(g),l.push(p.x,p.y,p.z),c.push(0,0,1),m.x=(p.x/t+1)/2,m.y=(p.y/t+1)/2,u.push(m.x,m.y)}h+=d}for(let v=0;v<r;v++){const f=v*(i+1);for(let g=0;g<i;g++){const x=g+f,y=x,_=x+i+1,I=x+i+2,b=x+1;o.push(y,_,b),o.push(_,I,b)}}this.setIndex(o),this.setAttribute("position",new De(l,3)),this.setAttribute("normal",new De(c,3)),this.setAttribute("uv",new De(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new xc(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class Dd extends ct{constructor(e=new rs([new J(0,.5),new J(-.5,-.5),new J(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const i=[],r=[],s=[],a=[];let o=0,l=0;if(Array.isArray(e)===!1)c(e);else for(let u=0;u<e.length;u++)c(e[u]),this.addGroup(o,l,u),o+=l,l=0;this.setIndex(i),this.setAttribute("position",new De(r,3)),this.setAttribute("normal",new De(s,3)),this.setAttribute("uv",new De(a,2));function c(u){const h=r.length/3,d=u.extractPoints(t);let p=d.shape;const m=d.holes;nn.isClockWise(p)===!1&&(p=p.reverse());for(let f=0,g=m.length;f<g;f++){const x=m[f];nn.isClockWise(x)===!0&&(m[f]=x.reverse())}const v=nn.triangulateShape(p,m);for(let f=0,g=m.length;f<g;f++){const x=m[f];p=p.concat(x)}for(let f=0,g=p.length;f<g;f++){const x=p[f];r.push(x.x,x.y,0),s.push(0,0,1),a.push(x.x,x.y)}for(let f=0,g=v.length;f<g;f++){const x=v[f],y=x[0]+h,_=x[1]+h,I=x[2]+h;i.push(y,_,I),l+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes;return AI(t,e)}static fromJSON(e,t){const i=[];for(let r=0,s=e.shapes.length;r<s;r++){const a=t[e.shapes[r]];i.push(a)}return new Dd(i,e.curveSegments)}}function AI(n,e){if(e.shapes=[],Array.isArray(n))for(let t=0,i=n.length;t<i;t++){const r=n[t];e.shapes.push(r.uuid)}else e.shapes.push(n.uuid);return e}class Eo extends ct{constructor(e=1,t=32,i=16,r=0,s=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:s,thetaStart:a,thetaLength:o},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));const l=Math.min(a+o,Math.PI);let c=0;const u=[],h=new N,d=new N,p=[],m=[],v=[],f=[];for(let g=0;g<=i;g++){const x=[],y=g/i;let _=0;g===0&&a===0?_=.5/t:g===i&&l===Math.PI&&(_=-.5/t);for(let I=0;I<=t;I++){const b=I/t;h.x=-e*Math.cos(r+b*s)*Math.sin(a+y*o),h.y=e*Math.cos(a+y*o),h.z=e*Math.sin(r+b*s)*Math.sin(a+y*o),m.push(h.x,h.y,h.z),d.copy(h).normalize(),v.push(d.x,d.y,d.z),f.push(b+_,1-y),x.push(c++)}u.push(x)}for(let g=0;g<i;g++)for(let x=0;x<t;x++){const y=u[g][x+1],_=u[g][x],I=u[g+1][x],b=u[g+1][x+1];(g!==0||a>0)&&p.push(y,_,b),(g!==i-1||l<Math.PI)&&p.push(_,I,b)}this.setIndex(p),this.setAttribute("position",new De(m,3)),this.setAttribute("normal",new De(v,3)),this.setAttribute("uv",new De(f,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Eo(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class Ud extends fs{constructor(e=1,t=0){const i=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],r=[2,1,0,0,3,2,1,3,0,2,3,1];super(i,r,e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Ud(e.radius,e.detail)}}class _c extends ct{constructor(e=1,t=.4,i=12,r=48,s=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:r,arc:s},i=Math.floor(i),r=Math.floor(r);const a=[],o=[],l=[],c=[],u=new N,h=new N,d=new N;for(let p=0;p<=i;p++)for(let m=0;m<=r;m++){const v=m/r*s,f=p/i*Math.PI*2;h.x=(e+t*Math.cos(f))*Math.cos(v),h.y=(e+t*Math.cos(f))*Math.sin(v),h.z=t*Math.sin(f),o.push(h.x,h.y,h.z),u.x=e*Math.cos(v),u.y=e*Math.sin(v),d.subVectors(h,u).normalize(),l.push(d.x,d.y,d.z),c.push(m/r),c.push(p/i)}for(let p=1;p<=i;p++)for(let m=1;m<=r;m++){const v=(r+1)*p+m-1,f=(r+1)*(p-1)+m-1,g=(r+1)*(p-1)+m,x=(r+1)*p+m;a.push(v,f,x),a.push(f,g,x)}this.setIndex(a),this.setAttribute("position",new De(o,3)),this.setAttribute("normal",new De(l,3)),this.setAttribute("uv",new De(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new _c(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class Od extends ct{constructor(e=1,t=.4,i=64,r=8,s=2,a=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:r,p:s,q:a},i=Math.floor(i),r=Math.floor(r);const o=[],l=[],c=[],u=[],h=new N,d=new N,p=new N,m=new N,v=new N,f=new N,g=new N;for(let y=0;y<=i;++y){const _=y/i*s*Math.PI*2;x(_,s,a,e,p),x(_+.01,s,a,e,m),f.subVectors(m,p),g.addVectors(m,p),v.crossVectors(f,g),g.crossVectors(v,f),v.normalize(),g.normalize();for(let I=0;I<=r;++I){const b=I/r*Math.PI*2,w=-t*Math.cos(b),C=t*Math.sin(b);h.x=p.x+(w*g.x+C*v.x),h.y=p.y+(w*g.y+C*v.y),h.z=p.z+(w*g.z+C*v.z),l.push(h.x,h.y,h.z),d.subVectors(h,p).normalize(),c.push(d.x,d.y,d.z),u.push(y/i),u.push(I/r)}}for(let y=1;y<=i;y++)for(let _=1;_<=r;_++){const I=(r+1)*(y-1)+(_-1),b=(r+1)*y+(_-1),w=(r+1)*y+_,C=(r+1)*(y-1)+_;o.push(I,b,C),o.push(b,w,C)}this.setIndex(o),this.setAttribute("position",new De(l,3)),this.setAttribute("normal",new De(c,3)),this.setAttribute("uv",new De(u,2));function x(y,_,I,b,w){const C=Math.cos(y),H=Math.sin(y),M=I/_*y,T=Math.cos(M);w.x=b*(2+T)*.5*C,w.y=b*(2+T)*H*.5,w.z=b*Math.sin(M)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Od(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class Fd extends ct{constructor(e=new Mm(new N(-1,-1,0),new N(-1,1,0),new N(1,1,0)),t=64,i=1,r=8,s=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:i,radialSegments:r,closed:s};const a=e.computeFrenetFrames(t,s);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals;const o=new N,l=new N,c=new J;let u=new N;const h=[],d=[],p=[],m=[];v(),this.setIndex(m),this.setAttribute("position",new De(h,3)),this.setAttribute("normal",new De(d,3)),this.setAttribute("uv",new De(p,2));function v(){for(let y=0;y<t;y++)f(y);f(s===!1?t:0),x(),g()}function f(y){u=e.getPointAt(y/t,u);const _=a.normals[y],I=a.binormals[y];for(let b=0;b<=r;b++){const w=b/r*Math.PI*2,C=Math.sin(w),H=-Math.cos(w);l.x=H*_.x+C*I.x,l.y=H*_.y+C*I.y,l.z=H*_.z+C*I.z,l.normalize(),d.push(l.x,l.y,l.z),o.x=u.x+i*l.x,o.y=u.y+i*l.y,o.z=u.z+i*l.z,h.push(o.x,o.y,o.z)}}function g(){for(let y=1;y<=t;y++)for(let _=1;_<=r;_++){const I=(r+1)*(y-1)+(_-1),b=(r+1)*y+(_-1),w=(r+1)*y+_,C=(r+1)*(y-1)+_;m.push(I,b,C),m.push(b,w,C)}}function x(){for(let y=0;y<=t;y++)for(let _=0;_<=r;_++)c.x=y/t,c.y=_/r,p.push(c.x,c.y)}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new Fd(new eh[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class Am extends ct{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const t=[],i=new Set,r=new N,s=new N;if(e.index!==null){const a=e.attributes.position,o=e.index;let l=e.groups;l.length===0&&(l=[{start:0,count:o.count,materialIndex:0}]);for(let c=0,u=l.length;c<u;++c){const h=l[c],d=h.start,p=h.count;for(let m=d,v=d+p;m<v;m+=3)for(let f=0;f<3;f++){const g=o.getX(m+f),x=o.getX(m+(f+1)%3);r.fromBufferAttribute(a,g),s.fromBufferAttribute(a,x),jy(r,s,i)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}}else{const a=e.attributes.position;for(let o=0,l=a.count/3;o<l;o++)for(let c=0;c<3;c++){const u=3*o+c,h=3*o+(c+1)%3;r.fromBufferAttribute(a,u),s.fromBufferAttribute(a,h),jy(r,s,i)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}this.setAttribute("position",new De(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function jy(n,e,t){const i=`${n.x},${n.y},${n.z}-${e.x},${e.y},${e.z}`,r=`${e.x},${e.y},${e.z}-${n.x},${n.y},${n.z}`;return t.has(i)===!0||t.has(r)===!0?!1:(t.add(i),t.add(r),!0)}var Xy=Object.freeze({__proto__:null,BoxGeometry:yn,CapsuleGeometry:Cd,CircleGeometry:Rd,ConeGeometry:Id,CylinderGeometry:da,DodecahedronGeometry:Ld,EdgesGeometry:Sm,ExtrudeGeometry:yc,IcosahedronGeometry:Pd,LatheGeometry:vc,OctahedronGeometry:wo,PlaneGeometry:ha,PolyhedronGeometry:fs,RingGeometry:xc,ShapeGeometry:Dd,SphereGeometry:Eo,TetrahedronGeometry:Ud,TorusGeometry:_c,TorusKnotGeometry:Od,TubeGeometry:Fd,WireframeGeometry:Am});class oh extends hi{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new xe(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}}class Nm extends Pr{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class wl extends hi{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new xe(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 xe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new dr,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class lh extends wl{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new J(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Jt(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 xe(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 xe(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new xe(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class ch extends hi{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new xe(16777215),this.specular=new xe(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new xe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new dr,this.combine=ma,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Cm extends hi{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new xe(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new xe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class uh extends hi{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class hh extends hi{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new xe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new xe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new dr,this.combine=ma,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Rm extends hi{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new xe(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class dh extends Ni{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function zs(n,e,t){return!n||!t&&n.constructor===e?n:typeof e.BYTES_PER_ELEMENT=="number"?new e(n):Array.prototype.slice.call(n)}function qy(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function Yy(n){function e(r,s){return n[r]-n[s]}const t=n.length,i=new Array(t);for(let r=0;r!==t;++r)i[r]=r;return i.sort(e),i}function Im(n,e,t){const i=n.length,r=new n.constructor(i);for(let s=0,a=0;a!==i;++s){const o=t[s]*e;for(let l=0;l!==e;++l)r[a++]=n[o+l]}return r}function Lm(n,e,t,i){let r=1,s=n[0];for(;s!==void 0&&s[i]===void 0;)s=n[r++];if(s===void 0)return;let a=s[i];if(a!==void 0)if(Array.isArray(a))do a=s[i],a!==void 0&&(e.push(s.time),t.push.apply(t,a)),s=n[r++];while(s!==void 0);else if(a.toArray!==void 0)do a=s[i],a!==void 0&&(e.push(s.time),a.toArray(t,t.length)),s=n[r++];while(s!==void 0);else do a=s[i],a!==void 0&&(e.push(s.time),t.push(a)),s=n[r++];while(s!==void 0)}function NI(n,e,t,i,r=30){const s=n.clone();s.name=e;const a=[];for(let l=0;l<s.tracks.length;++l){const c=s.tracks[l],u=c.getValueSize(),h=[],d=[];for(let p=0;p<c.times.length;++p){const m=c.times[p]*r;if(!(m<t||m>=i)){h.push(c.times[p]);for(let v=0;v<u;++v)d.push(c.values[p*u+v])}}h.length!==0&&(c.times=zs(h,c.times.constructor),c.values=zs(d,c.values.constructor),a.push(c))}s.tracks=a;let o=1/0;for(let l=0;l<s.tracks.length;++l)o>s.tracks[l].times[0]&&(o=s.tracks[l].times[0]);for(let l=0;l<s.tracks.length;++l)s.tracks[l].shift(-1*o);return s.resetDuration(),s}function CI(n,e=0,t=n,i=30){i<=0&&(i=30);const r=t.tracks.length,s=e/i;for(let a=0;a<r;++a){const o=t.tracks[a],l=o.ValueTypeName;if(l==="bool"||l==="string")continue;const c=n.tracks.find(function(g){return g.name===o.name&&g.ValueTypeName===l});if(c===void 0)continue;let u=0;const h=o.getValueSize();o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(u=h/3);let d=0;const p=c.getValueSize();c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(d=p/3);const m=o.times.length-1;let v;if(s<=o.times[0]){const g=u,x=h-u;v=o.values.slice(g,x)}else if(s>=o.times[m]){const g=m*h+u,x=g+h-u;v=o.values.slice(g,x)}else{const g=o.createInterpolant(),x=u,y=h-u;g.evaluate(s),v=g.resultBuffer.slice(x,y)}l==="quaternion"&&new qi().fromArray(v).normalize().conjugate().toArray(v);const f=c.times.length;for(let g=0;g<f;++g){const x=g*p+d;if(l==="quaternion")qi.multiplyQuaternionsFlat(c.values,x,v,0,c.values,x);else{const y=p-d*2;for(let _=0;_<y;++_)c.values[x+_]-=v[_]}}}return n.blendMode=cp,n}const RI={convertArray:zs,isTypedArray:qy,getKeyframeOrder:Yy,sortedArray:Im,flattenJSON:Lm,subclip:NI,makeClipAdditive:CI};class Qa{constructor(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let i=this._cachedIndex,r=t[i],s=t[i-1];e:{t:{let a;i:{r:if(!(e<r)){for(let o=i+2;;){if(r===void 0){if(e<s)break r;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===o)break;if(s=r,r=t[++i],e<r)break t}a=t.length;break i}if(!(e>=s)){const o=t[1];e<o&&(i=2,s=o);for(let l=i-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===l)break;if(r=s,s=t[--i-1],e>=s)break t}a=i,i=0;break i}break e}for(;i<a;){const o=i+a>>>1;e<t[o]?a=o:i=o+1}if(r=t[i],s=t[i-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,s,r)}return this.interpolate_(i,s,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,s=e*r;for(let a=0;a!==r;++a)t[a]=i[s+a];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class $y extends Qa{constructor(e,t,i,r){super(e,t,i,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:_s,endingEnd:_s}}intervalChanged_(e,t,i){const r=this.parameterPositions;let s=e-2,a=e+1,o=r[s],l=r[a];if(o===void 0)switch(this.getSettings_().endingStart){case Ms:s=e,o=2*t-i;break;case qo:s=r.length-2,o=t+r[s]-r[s+1];break;default:s=e,o=i}if(l===void 0)switch(this.getSettings_().endingEnd){case Ms:a=e,l=2*i-t;break;case qo:a=1,l=i+r[1]-r[0];break;default:a=e-1,l=t}const c=(i-t)*.5,u=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(l-i),this._offsetPrev=s*u,this._offsetNext=a*u}interpolate_(e,t,i,r){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,u=this._offsetPrev,h=this._offsetNext,d=this._weightPrev,p=this._weightNext,m=(i-t)/(r-t),v=m*m,f=v*m,g=-d*f+2*d*v-d*m,x=(1+d)*f+(-1.5-2*d)*v+(-.5+d)*m+1,y=(-1-p)*f+(1.5+p)*v+.5*m,_=p*f-p*v;for(let I=0;I!==o;++I)s[I]=g*a[u+I]+x*a[c+I]+y*a[l+I]+_*a[h+I];return s}}class Pm extends Qa{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,u=(i-t)/(r-t),h=1-u;for(let d=0;d!==o;++d)s[d]=a[c+d]*h+a[l+d]*u;return s}}class Jy extends Qa{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}}class Jr{constructor(e,t,i,r){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=zs(t,this.TimeBufferType),this.values=zs(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:zs(e.times,Array),values:zs(e.values,Array)};const r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new Jy(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Pm(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new $y(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case ba:t=this.InterpolantFactoryMethodDiscrete;break;case Xo:t=this.InterpolantFactoryMethodLinear;break;case iu:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){const i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return console.warn("THREE.KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return ba;case this.InterpolantFactoryMethodLinear:return Xo;case this.InterpolantFactoryMethodSmooth:return iu}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]*=e}return this}trim(e,t){const i=this.times,r=i.length;let s=0,a=r-1;for(;s!==r&&i[s]<e;)++s;for(;a!==-1&&i[a]>t;)--a;if(++a,s!==0||a!==r){s>=a&&(a=Math.max(a,1),s=a-1);const o=this.getValueSize();this.times=i.slice(s,a),this.values=this.values.slice(s*o,a*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const i=this.times,r=this.values,s=i.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==s;o++){const l=i[o];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,l),e=!1;break}if(a!==null&&a>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,l,a),e=!1;break}a=l}if(r!==void 0&&qy(r))for(let o=0,l=r.length;o!==l;++o){const c=r[o];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),r=this.getInterpolation()===iu,s=e.length-1;let a=1;for(let o=1;o<s;++o){let l=!1;const c=e[o],u=e[o+1];if(c!==u&&(o!==1||c!==e[0]))if(r)l=!0;else{const h=o*i,d=h-i,p=h+i;for(let m=0;m!==i;++m){const v=t[h+m];if(v!==t[d+m]||v!==t[p+m]){l=!0;break}}}if(l){if(o!==a){e[a]=e[o];const h=o*i,d=a*i;for(let p=0;p!==i;++p)t[d+p]=t[h+p]}++a}}if(s>0){e[a]=e[s];for(let o=s*i,l=a*i,c=0;c!==i;++c)t[l+c]=t[o+c];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*i)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}}Jr.prototype.TimeBufferType=Float32Array,Jr.prototype.ValueBufferType=Float32Array,Jr.prototype.DefaultInterpolation=Xo;class ks extends Jr{constructor(e,t,i){super(e,t,i)}}ks.prototype.ValueTypeName="bool",ks.prototype.ValueBufferType=Array,ks.prototype.DefaultInterpolation=ba,ks.prototype.InterpolantFactoryMethodLinear=void 0,ks.prototype.InterpolantFactoryMethodSmooth=void 0;class ph extends Jr{}ph.prototype.ValueTypeName="color";class eo extends Jr{}eo.prototype.ValueTypeName="number";class Ky extends Qa{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=(i-t)/(r-t);let c=e*o;for(let u=c+o;c!==u;c+=4)qi.slerpFlat(s,0,a,c-o,a,c,l);return s}}class to extends Jr{InterpolantFactoryMethodLinear(e){return new Ky(this.times,this.values,this.getValueSize(),e)}}to.prototype.ValueTypeName="quaternion",to.prototype.InterpolantFactoryMethodSmooth=void 0;class Hs extends Jr{constructor(e,t,i){super(e,t,i)}}Hs.prototype.ValueTypeName="string",Hs.prototype.ValueBufferType=Array,Hs.prototype.DefaultInterpolation=ba,Hs.prototype.InterpolantFactoryMethodLinear=void 0,Hs.prototype.InterpolantFactoryMethodSmooth=void 0;class io extends Jr{}io.prototype.ValueTypeName="vector";class ro{constructor(e="",t=-1,i=[],r=ru){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=yr(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],i=e.tracks,r=1/(e.fps||1);for(let a=0,o=i.length;a!==o;++a)t.push(LI(i[a]).scale(r));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){const t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,a=i.length;s!==a;++s)t.push(Jr.toJSON(i[s]));return r}static CreateFromMorphTargetSequence(e,t,i,r){const s=t.length,a=[];for(let o=0;o<s;o++){let l=[],c=[];l.push((o+s-1)%s,o,(o+1)%s),c.push(0,1,0);const u=Yy(l);l=Im(l,1,u),c=Im(c,1,u),!r&&l[0]===0&&(l.push(s),c.push(c[0])),a.push(new eo(".morphTargetInfluences["+t[o].name+"]",l,c).scale(1/i))}return new this(e,-1,a)}static findByName(e,t){let i=e;if(!Array.isArray(e)){const r=e;i=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<i.length;r++)if(i[r].name===t)return i[r];return null}static CreateClipsFromMorphTargetSequences(e,t,i){const r={},s=/^([\w-]*?)([\d]+)$/;for(let o=0,l=e.length;o<l;o++){const c=e[o],u=c.name.match(s);if(u&&u.length>1){const h=u[1];let d=r[h];d||(r[h]=d=[]),d.push(c)}}const a=[];for(const o in r)a.push(this.CreateFromMorphTargetSequence(o,r[o],t,i));return a}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const i=function(u,h,d,p,m){if(d.length!==0){const v=[],f=[];Lm(d,v,f,p),v.length!==0&&m.push(new u(h,v,f))}},r=[],s=e.name||"default",a=e.fps||30,o=e.blendMode;let l=e.length||-1;const c=e.hierarchy||[];for(let u=0;u<c.length;u++){const h=c[u].keys;if(!(!h||h.length===0))if(h[0].morphTargets){const d={};let p;for(p=0;p<h.length;p++)if(h[p].morphTargets)for(let m=0;m<h[p].morphTargets.length;m++)d[h[p].morphTargets[m]]=-1;for(const m in d){const v=[],f=[];for(let g=0;g!==h[p].morphTargets.length;++g){const x=h[p];v.push(x.time),f.push(x.morphTarget===m?1:0)}r.push(new eo(".morphTargetInfluence["+m+"]",v,f))}l=d.length*a}else{const d=".bones["+t[u].name+"]";i(io,d+".position",h,"pos",r),i(to,d+".quaternion",h,"rot",r),i(io,d+".scale",h,"scl",r)}}return r.length===0?null:new this(s,l,r,o)}resetDuration(){const e=this.tracks;let t=0;for(let i=0,r=e.length;i!==r;++i){const s=this.tracks[i];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function II(n){switch(n.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return eo;case"vector":case"vector2":case"vector3":case"vector4":return io;case"color":return ph;case"quaternion":return to;case"bool":case"boolean":return ks;case"string":return Hs}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+n)}function LI(n){if(n.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=II(n.type);if(n.times===void 0){const t=[],i=[];Lm(n.keys,t,i,"value"),n.times=t,n.values=i}return e.parse!==void 0?e.parse(n):new e(n.name,n.times,n.values,n.interpolation)}const Rn={enabled:!1,files:{},add:function(n,e){this.enabled!==!1&&(this.files[n]=e)},get:function(n){if(this.enabled!==!1)return this.files[n]},remove:function(n){delete this.files[n]},clear:function(){this.files={}}};class mh{constructor(e,t,i){const r=this;let s=!1,a=0,o=0,l;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(u){o++,s===!1&&r.onStart!==void 0&&r.onStart(u,a,o),s=!0},this.itemEnd=function(u){a++,r.onProgress!==void 0&&r.onProgress(u,a,o),a===o&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(u){r.onError!==void 0&&r.onError(u)},this.resolveURL=function(u){return l?l(u):u},this.setURLModifier=function(u){return l=u,this},this.addHandler=function(u,h){return c.push(u,h),this},this.removeHandler=function(u){const h=c.indexOf(u);return h!==-1&&c.splice(h,2),this},this.getHandler=function(u){for(let h=0,d=c.length;h<d;h+=2){const p=c[h],m=c[h+1];if(p.global&&(p.lastIndex=0),p.test(u))return m}return null}}}const Dm=new mh;class Hi{constructor(e){this.manager=e!==void 0?e:Dm,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const i=this;return new Promise(function(r,s){i.load(e,r,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}Hi.DEFAULT_MATERIAL_NAME="__DEFAULT";const In={};class PI extends Error{constructor(e,t){super(e),this.response=t}}class Kr extends Hi{constructor(e){super(e)}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=Rn.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(In[e]!==void 0){In[e].push({onLoad:t,onProgress:i,onError:r});return}In[e]=[],In[e].push({onLoad:t,onProgress:i,onError:r});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),o=this.mimeType,l=this.responseType;fetch(a).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const u=In[e],h=c.body.getReader(),d=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),p=d?parseInt(d):0,m=p!==0;let v=0;const f=new ReadableStream({start(g){x();function x(){h.read().then(({done:y,value:_})=>{if(y)g.close();else{v+=_.byteLength;const I=new ProgressEvent("progress",{lengthComputable:m,loaded:v,total:p});for(let b=0,w=u.length;b<w;b++){const C=u[b];C.onProgress&&C.onProgress(I)}g.enqueue(_),x()}},y=>{g.error(y)})}}});return new Response(f)}else throw new PI(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(u=>new DOMParser().parseFromString(u,o));case"json":return c.json();default:if(o===void 0)return c.text();{const u=/charset="?([^;"\s]*)"?/i.exec(o),h=u&&u[1]?u[1].toLowerCase():void 0,d=new TextDecoder(h);return c.arrayBuffer().then(p=>d.decode(p))}}}).then(c=>{Rn.add(e,c);const u=In[e];delete In[e];for(let h=0,d=u.length;h<d;h++){const p=u[h];p.onLoad&&p.onLoad(c)}}).catch(c=>{const u=In[e];if(u===void 0)throw this.manager.itemError(e),c;delete In[e];for(let h=0,d=u.length;h<d;h++){const p=u[h];p.onError&&p.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class DI extends Hi{constructor(e){super(e)}load(e,t,i,r){const s=this,a=new Kr(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(o){try{t(s.parse(JSON.parse(o)))}catch(l){r?r(l):console.error(l),s.manager.itemError(e)}},i,r)}parse(e){const t=[];for(let i=0;i<e.length;i++){const r=ro.parse(e[i]);t.push(r)}return t}}class UI extends Hi{constructor(e){super(e)}load(e,t,i,r){const s=this,a=[],o=new yl,l=new Kr(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(s.withCredentials);let c=0;function u(h){l.load(e[h],function(d){const p=s.parse(d,!0);a[h]={width:p.width,height:p.height,format:p.format,mipmaps:p.mipmaps},c+=1,c===6&&(p.mipmapCount===1&&(o.minFilter=Lt),o.image=a,o.format=p.format,o.needsUpdate=!0,t&&t(o))},i,r)}if(Array.isArray(e))for(let h=0,d=e.length;h<d;++h)u(h);else l.load(e,function(h){const d=s.parse(h,!0);if(d.isCubemap){const p=d.mipmaps.length/d.mipmapCount;for(let m=0;m<p;m++){a[m]={mipmaps:[]};for(let v=0;v<d.mipmapCount;v++)a[m].mipmaps.push(d.mipmaps[m*d.mipmapCount+v]),a[m].format=d.format,a[m].width=d.width,a[m].height=d.height}o.image=a}else o.image.width=d.width,o.image.height=d.height,o.mipmaps=d.mipmaps;d.mipmapCount===1&&(o.minFilter=Lt),o.format=d.format,o.needsUpdate=!0,t&&t(o)},i,r);return o}}class El extends Hi{constructor(e){super(e)}load(e,t,i,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=Rn.get(e);if(a!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a;const o=Qo("img");function l(){u(),Rn.add(e,this),t&&t(this),s.manager.itemEnd(e)}function c(h){u(),r&&r(h),s.manager.itemError(e),s.manager.itemEnd(e)}function u(){o.removeEventListener("load",l,!1),o.removeEventListener("error",c,!1)}return o.addEventListener("load",l,!1),o.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),s.manager.itemStart(e),o.src=e,o}}class OI extends Hi{constructor(e){super(e)}load(e,t,i,r){const s=new Cs;s.colorSpace=Fi;const a=new El(this.manager);a.setCrossOrigin(this.crossOrigin),a.setPath(this.path);let o=0;function l(c){a.load(e[c],function(u){s.images[c]=u,o++,o===6&&(s.needsUpdate=!0,t&&t(s))},void 0,r)}for(let c=0;c<e.length;++c)l(c);return s}}class Zy extends Hi{constructor(e){super(e)}load(e,t,i,r){const s=this,a=new Ur,o=new Kr(this.manager);return o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setPath(this.path),o.setWithCredentials(s.withCredentials),o.load(e,function(l){let c;try{c=s.parse(l)}catch(u){if(r!==void 0)r(u);else{console.error(u);return}}c.image!==void 0?a.image=c.image:c.data!==void 0&&(a.image.width=c.width,a.image.height=c.height,a.image.data=c.data),a.wrapS=c.wrapS!==void 0?c.wrapS:gr,a.wrapT=c.wrapT!==void 0?c.wrapT:gr,a.magFilter=c.magFilter!==void 0?c.magFilter:Lt,a.minFilter=c.minFilter!==void 0?c.minFilter:Lt,a.anisotropy=c.anisotropy!==void 0?c.anisotropy:1,c.colorSpace!==void 0&&(a.colorSpace=c.colorSpace),c.flipY!==void 0&&(a.flipY=c.flipY),c.format!==void 0&&(a.format=c.format),c.type!==void 0&&(a.type=c.type),c.mipmaps!==void 0&&(a.mipmaps=c.mipmaps,a.minFilter=ji),c.mipmapCount===1&&(a.minFilter=Lt),c.generateMipmaps!==void 0&&(a.generateMipmaps=c.generateMipmaps),a.needsUpdate=!0,t&&t(a,c)},i,r),a}}class Qy extends Hi{constructor(e){super(e)}load(e,t,i,r){const s=new Wt,a=new El(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(o){s.image=o,s.needsUpdate=!0,t!==void 0&&t(s)},i,r),s}}class ns extends _t{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new xe(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(t.object.target=this.target.uuid),t}}class fh extends ns{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.groundColor=new xe(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const Um=new Re,ex=new N,tx=new N;class Om{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new J(512,512),this.map=null,this.mapPass=null,this.matrix=new Re,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new ka,this._frameExtents=new J(1,1),this._viewportCount=1,this._viewports=[new st(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,i=this.matrix;ex.setFromMatrixPosition(e.matrixWorld),t.position.copy(ex),tx.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(tx),t.updateMatrixWorld(),Um.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Um),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(Um)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class FI extends Om{constructor(){super(new di(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,i=wa*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(i!==t.fov||r!==t.aspect||s!==t.far)&&(t.fov=i,t.aspect=r,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class Al extends ns{constructor(e,t,i=0,r=Math.PI/3,s=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.target=new _t,this.distance=i,this.angle=r,this.penumbra=s,this.decay=a,this.map=null,this.shadow=new FI}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const ix=new Re,Nl=new N,Fm=new N;class VI extends Om{constructor(){super(new di(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new J(4,2),this._viewportCount=6,this._viewports=[new st(2,1,1,1),new st(0,1,1,1),new st(3,1,1,1),new st(1,1,1,1),new st(3,0,1,1),new st(1,0,1,1)],this._cubeDirections=[new N(1,0,0),new N(-1,0,0),new N(0,0,1),new N(0,0,-1),new N(0,1,0),new N(0,-1,0)],this._cubeUps=[new N(0,1,0),new N(0,1,0),new N(0,1,0),new N(0,1,0),new N(0,0,1),new N(0,0,-1)]}updateMatrices(e,t=0){const i=this.camera,r=this.matrix,s=e.distance||i.far;s!==i.far&&(i.far=s,i.updateProjectionMatrix()),Nl.setFromMatrixPosition(e.matrixWorld),i.position.copy(Nl),Fm.copy(i.position),Fm.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(Fm),i.updateMatrixWorld(),r.makeTranslation(-Nl.x,-Nl.y,-Nl.z),ix.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(ix)}}class gh extends ns{constructor(e,t,i=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=r,this.shadow=new VI}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class BI extends Om{constructor(){super(new Ls(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class vh extends ns{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.target=new _t,this.shadow=new BI}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class yh extends ns{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class Vm extends ns{constructor(e,t,i=10,r=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=i,this.height=r}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){const t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}}class rx{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new N)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){const i=e.x,r=e.y,s=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.282095),t.addScaledVector(a[1],.488603*r),t.addScaledVector(a[2],.488603*s),t.addScaledVector(a[3],.488603*i),t.addScaledVector(a[4],1.092548*(i*r)),t.addScaledVector(a[5],1.092548*(r*s)),t.addScaledVector(a[6],.315392*(3*s*s-1)),t.addScaledVector(a[7],1.092548*(i*s)),t.addScaledVector(a[8],.546274*(i*i-r*r)),t}getIrradianceAt(e,t){const i=e.x,r=e.y,s=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.886227),t.addScaledVector(a[1],2*.511664*r),t.addScaledVector(a[2],2*.511664*s),t.addScaledVector(a[3],2*.511664*i),t.addScaledVector(a[4],2*.429043*i*r),t.addScaledVector(a[5],2*.429043*r*s),t.addScaledVector(a[6],.743125*s*s-.247708),t.addScaledVector(a[7],2*.429043*i*s),t.addScaledVector(a[8],.429043*(i*i-r*r)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let i=0;i<9;i++)this.coefficients[i].addScaledVector(e.coefficients[i],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let i=0;i<9;i++)this.coefficients[i].lerp(e.coefficients[i],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(e,t=0){const i=this.coefficients;for(let r=0;r<9;r++)i[r].fromArray(e,t+r*3);return this}toArray(e=[],t=0){const i=this.coefficients;for(let r=0;r<9;r++)i[r].toArray(e,t+r*3);return e}static getBasisAt(e,t){const i=e.x,r=e.y,s=e.z;t[0]=.282095,t[1]=.488603*r,t[2]=.488603*s,t[3]=.488603*i,t[4]=1.092548*i*r,t[5]=1.092548*r*s,t[6]=.315392*(3*s*s-1),t[7]=1.092548*i*s,t[8]=.546274*(i*i-r*r)}}class Bm extends ns{constructor(e=new rx,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}class Mc extends Hi{constructor(e){super(e),this.textures={}}load(e,t,i,r){const s=this,a=new Kr(s.manager);a.setPath(s.path),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(o){try{t(s.parse(JSON.parse(o)))}catch(l){r?r(l):console.error(l),s.manager.itemError(e)}},i,r)}parse(e){const t=this.textures;function i(s){return t[s]===void 0&&console.warn("THREE.MaterialLoader: Undefined texture",s),t[s]}const r=this.createMaterialFromType(e.type);if(e.uuid!==void 0&&(r.uuid=e.uuid),e.name!==void 0&&(r.name=e.name),e.color!==void 0&&r.color!==void 0&&r.color.setHex(e.color),e.roughness!==void 0&&(r.roughness=e.roughness),e.metalness!==void 0&&(r.metalness=e.metalness),e.sheen!==void 0&&(r.sheen=e.sheen),e.sheenColor!==void 0&&(r.sheenColor=new xe().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(r.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&r.emissive!==void 0&&r.emissive.setHex(e.emissive),e.specular!==void 0&&r.specular!==void 0&&r.specular.setHex(e.specular),e.specularIntensity!==void 0&&(r.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&r.specularColor!==void 0&&r.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(r.shininess=e.shininess),e.clearcoat!==void 0&&(r.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(r.dispersion=e.dispersion),e.iridescence!==void 0&&(r.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(r.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(r.transmission=e.transmission),e.thickness!==void 0&&(r.thickness=e.thickness),e.attenuationDistance!==void 0&&(r.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&r.attenuationColor!==void 0&&r.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(r.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(r.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(r.fog=e.fog),e.flatShading!==void 0&&(r.flatShading=e.flatShading),e.blending!==void 0&&(r.blending=e.blending),e.combine!==void 0&&(r.combine=e.combine),e.side!==void 0&&(r.side=e.side),e.shadowSide!==void 0&&(r.shadowSide=e.shadowSide),e.opacity!==void 0&&(r.opacity=e.opacity),e.transparent!==void 0&&(r.transparent=e.transparent),e.alphaTest!==void 0&&(r.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(r.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(r.depthFunc=e.depthFunc),e.depthTest!==void 0&&(r.depthTest=e.depthTest),e.depthWrite!==void 0&&(r.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(r.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(r.blendSrc=e.blendSrc),e.blendDst!==void 0&&(r.blendDst=e.blendDst),e.blendEquation!==void 0&&(r.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(r.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(r.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(r.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&r.blendColor!==void 0&&r.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(r.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(r.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(r.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(r.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(r.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(r.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(r.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(r.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(r.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(r.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(r.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(r.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(r.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(r.rotation=e.rotation),e.linewidth!==void 0&&(r.linewidth=e.linewidth),e.dashSize!==void 0&&(r.dashSize=e.dashSize),e.gapSize!==void 0&&(r.gapSize=e.gapSize),e.scale!==void 0&&(r.scale=e.scale),e.polygonOffset!==void 0&&(r.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(r.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(r.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(r.dithering=e.dithering),e.alphaToCoverage!==void 0&&(r.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(r.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(r.forceSinglePass=e.forceSinglePass),e.visible!==void 0&&(r.visible=e.visible),e.toneMapped!==void 0&&(r.toneMapped=e.toneMapped),e.userData!==void 0&&(r.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?r.vertexColors=e.vertexColors>0:r.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const s in e.uniforms){const a=e.uniforms[s];switch(r.uniforms[s]={},a.type){case"t":r.uniforms[s].value=i(a.value);break;case"c":r.uniforms[s].value=new xe().setHex(a.value);break;case"v2":r.uniforms[s].value=new J().fromArray(a.value);break;case"v3":r.uniforms[s].value=new N().fromArray(a.value);break;case"v4":r.uniforms[s].value=new st().fromArray(a.value);break;case"m3":r.uniforms[s].value=new Ke().fromArray(a.value);break;case"m4":r.uniforms[s].value=new Re().fromArray(a.value);break;default:r.uniforms[s].value=a.value}}if(e.defines!==void 0&&(r.defines=e.defines),e.vertexShader!==void 0&&(r.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(r.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(r.glslVersion=e.glslVersion),e.extensions!==void 0)for(const s in e.extensions)r.extensions[s]=e.extensions[s];if(e.lights!==void 0&&(r.lights=e.lights),e.clipping!==void 0&&(r.clipping=e.clipping),e.size!==void 0&&(r.size=e.size),e.sizeAttenuation!==void 0&&(r.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(r.map=i(e.map)),e.matcap!==void 0&&(r.matcap=i(e.matcap)),e.alphaMap!==void 0&&(r.alphaMap=i(e.alphaMap)),e.bumpMap!==void 0&&(r.bumpMap=i(e.bumpMap)),e.bumpScale!==void 0&&(r.bumpScale=e.bumpScale),e.normalMap!==void 0&&(r.normalMap=i(e.normalMap)),e.normalMapType!==void 0&&(r.normalMapType=e.normalMapType),e.normalScale!==void 0){let s=e.normalScale;Array.isArray(s)===!1&&(s=[s,s]),r.normalScale=new J().fromArray(s)}return e.displacementMap!==void 0&&(r.displacementMap=i(e.displacementMap)),e.displacementScale!==void 0&&(r.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(r.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(r.roughnessMap=i(e.roughnessMap)),e.metalnessMap!==void 0&&(r.metalnessMap=i(e.metalnessMap)),e.emissiveMap!==void 0&&(r.emissiveMap=i(e.emissiveMap)),e.emissiveIntensity!==void 0&&(r.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(r.specularMap=i(e.specularMap)),e.specularIntensityMap!==void 0&&(r.specularIntensityMap=i(e.specularIntensityMap)),e.specularColorMap!==void 0&&(r.specularColorMap=i(e.specularColorMap)),e.envMap!==void 0&&(r.envMap=i(e.envMap)),e.envMapRotation!==void 0&&r.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(r.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(r.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(r.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(r.lightMap=i(e.lightMap)),e.lightMapIntensity!==void 0&&(r.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(r.aoMap=i(e.aoMap)),e.aoMapIntensity!==void 0&&(r.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(r.gradientMap=i(e.gradientMap)),e.clearcoatMap!==void 0&&(r.clearcoatMap=i(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(r.clearcoatRoughnessMap=i(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(r.clearcoatNormalMap=i(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(r.clearcoatNormalScale=new J().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(r.iridescenceMap=i(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(r.iridescenceThicknessMap=i(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(r.transmissionMap=i(e.transmissionMap)),e.thicknessMap!==void 0&&(r.thicknessMap=i(e.thicknessMap)),e.anisotropyMap!==void 0&&(r.anisotropyMap=i(e.anisotropyMap)),e.sheenColorMap!==void 0&&(r.sheenColorMap=i(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(r.sheenRoughnessMap=i(e.sheenRoughnessMap)),r}setTextures(e){return this.textures=e,this}createMaterialFromType(e){return Mc.createMaterialFromType(e)}static createMaterialFromType(e){const t={ShadowMaterial:oh,SpriteMaterial:ul,RawShaderMaterial:Nm,ShaderMaterial:Pr,PointsMaterial:Ka,MeshPhysicalMaterial:lh,MeshStandardMaterial:wl,MeshPhongMaterial:ch,MeshToonMaterial:Cm,MeshNormalMaterial:uh,MeshLambertMaterial:hh,MeshDepthMaterial:Uu,MeshDistanceMaterial:qp,MeshBasicMaterial:Yr,MeshMatcapMaterial:Rm,LineDashedMaterial:dh,LineBasicMaterial:Ni,Material:hi};return new t[e]}}class xh{static decodeText(e){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let i=0,r=e.length;i<r;i++)t+=String.fromCharCode(e[i]);try{return decodeURIComponent(escape(t))}catch{return t}}static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class zm extends ct{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){const e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}class nx extends Hi{constructor(e){super(e)}load(e,t,i,r){const s=this,a=new Kr(s.manager);a.setPath(s.path),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(o){try{t(s.parse(JSON.parse(o)))}catch(l){r?r(l):console.error(l),s.manager.itemError(e)}},i,r)}parse(e){const t={},i={};function r(d,p){if(t[p]!==void 0)return t[p];const m=d.interleavedBuffers[p],v=s(d,m.buffer),f=Ea(m.type,v),g=new ja(f,m.stride);return g.uuid=m.uuid,t[p]=g,g}function s(d,p){if(i[p]!==void 0)return i[p];const m=d.arrayBuffers[p],v=new Uint32Array(m).buffer;return i[p]=v,v}const a=e.isInstancedBufferGeometry?new zm:new ct,o=e.data.index;if(o!==void 0){const d=Ea(o.type,o.array);a.setIndex(new wt(d,1))}const l=e.data.attributes;for(const d in l){const p=l[d];let m;if(p.isInterleavedBufferAttribute){const v=r(e.data,p.data);m=new On(v,p.itemSize,p.offset,p.normalized)}else{const v=Ea(p.type,p.array),f=p.isInstancedBufferAttribute?Nn:wt;m=new f(v,p.itemSize,p.normalized)}p.name!==void 0&&(m.name=p.name),p.usage!==void 0&&m.setUsage(p.usage),a.setAttribute(d,m)}const c=e.data.morphAttributes;if(c)for(const d in c){const p=c[d],m=[];for(let v=0,f=p.length;v<f;v++){const g=p[v];let x;if(g.isInterleavedBufferAttribute){const y=r(e.data,g.data);x=new On(y,g.itemSize,g.offset,g.normalized)}else{const y=Ea(g.type,g.array);x=new wt(y,g.itemSize,g.normalized)}g.name!==void 0&&(x.name=g.name),m.push(x)}a.morphAttributes[d]=m}e.data.morphTargetsRelative&&(a.morphTargetsRelative=!0);const u=e.data.groups||e.data.drawcalls||e.data.offsets;if(u!==void 0)for(let d=0,p=u.length;d!==p;++d){const m=u[d];a.addGroup(m.start,m.count,m.materialIndex)}const h=e.data.boundingSphere;if(h!==void 0){const d=new N;h.center!==void 0&&d.fromArray(h.center),a.boundingSphere=new Ai(d,h.radius)}return e.name&&(a.name=e.name),e.userData&&(a.userData=e.userData),a}}class sx extends Hi{constructor(e){super(e)}load(e,t,i,r){const s=this,a=this.path===""?xh.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||a;const o=new Kr(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(l){let c=null;try{c=JSON.parse(l)}catch(h){r!==void 0&&r(h),console.error("THREE:ObjectLoader: Can't parse "+e+".",h.message);return}const u=c.metadata;if(u===void 0||u.type===void 0||u.type.toLowerCase()==="geometry"){r!==void 0&&r(new Error("THREE.ObjectLoader: Can't load "+e)),console.error("THREE.ObjectLoader: Can't load "+e);return}s.parse(c,t)},i,r)}async loadAsync(e,t){const i=this,r=this.path===""?xh.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||r;const s=new Kr(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials);const a=await s.loadAsync(e,t),o=JSON.parse(a),l=o.metadata;if(l===void 0||l.type===void 0||l.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+e);return await i.parseAsync(o)}parse(e,t){const i=this.parseAnimations(e.animations),r=this.parseShapes(e.shapes),s=this.parseGeometries(e.geometries,r),a=this.parseImages(e.images,function(){t!==void 0&&t(c)}),o=this.parseTextures(e.textures,a),l=this.parseMaterials(e.materials,o),c=this.parseObject(e.object,s,l,o,i),u=this.parseSkeletons(e.skeletons,c);if(this.bindSkeletons(c,u),this.bindLightTargets(c),t!==void 0){let h=!1;for(const d in a)if(a[d].data instanceof HTMLImageElement){h=!0;break}h===!1&&t(c)}return c}async parseAsync(e){const t=this.parseAnimations(e.animations),i=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,i),s=await this.parseImagesAsync(e.images),a=this.parseTextures(e.textures,s),o=this.parseMaterials(e.materials,a),l=this.parseObject(e.object,r,o,a,t),c=this.parseSkeletons(e.skeletons,l);return this.bindSkeletons(l,c),this.bindLightTargets(l),l}parseShapes(e){const t={};if(e!==void 0)for(let i=0,r=e.length;i<r;i++){const s=new rs().fromJSON(e[i]);t[s.uuid]=s}return t}parseSkeletons(e,t){const i={},r={};if(t.traverse(function(s){s.isBone&&(r[s.uuid]=s)}),e!==void 0)for(let s=0,a=e.length;s<a;s++){const o=new gc().fromJSON(e[s],r);i[o.uuid]=o}return i}parseGeometries(e,t){const i={};if(e!==void 0){const r=new nx;for(let s=0,a=e.length;s<a;s++){let o;const l=e[s];switch(l.type){case"BufferGeometry":case"InstancedBufferGeometry":o=r.parse(l);break;default:l.type in Xy?o=Xy[l.type].fromJSON(l,t):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${l.type}"`)}o.uuid=l.uuid,l.name!==void 0&&(o.name=l.name),l.userData!==void 0&&(o.userData=l.userData),i[l.uuid]=o}}return i}parseMaterials(e,t){const i={},r={};if(e!==void 0){const s=new Mc;s.setTextures(t);for(let a=0,o=e.length;a<o;a++){const l=e[a];i[l.uuid]===void 0&&(i[l.uuid]=s.parse(l)),r[l.uuid]=i[l.uuid]}}return r}parseAnimations(e){const t={};if(e!==void 0)for(let i=0;i<e.length;i++){const r=e[i],s=ro.parse(r);t[s.uuid]=s}return t}parseImages(e,t){const i=this,r={};let s;function a(l){return i.manager.itemStart(l),s.load(l,function(){i.manager.itemEnd(l)},void 0,function(){i.manager.itemError(l),i.manager.itemEnd(l)})}function o(l){if(typeof l=="string"){const c=l,u=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(c)?c:i.resourcePath+c;return a(u)}else return l.data?{data:Ea(l.type,l.data),width:l.width,height:l.height}:null}if(e!==void 0&&e.length>0){const l=new mh(t);s=new El(l),s.setCrossOrigin(this.crossOrigin);for(let c=0,u=e.length;c<u;c++){const h=e[c],d=h.url;if(Array.isArray(d)){const p=[];for(let m=0,v=d.length;m<v;m++){const f=d[m],g=o(f);g!==null&&(g instanceof HTMLImageElement?p.push(g):p.push(new Ur(g.data,g.width,g.height)))}r[h.uuid]=new $n(p)}else{const p=o(h.url);r[h.uuid]=new $n(p)}}}return r}async parseImagesAsync(e){const t=this,i={};let r;async function s(a){if(typeof a=="string"){const o=a,l=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(o)?o:t.resourcePath+o;return await r.loadAsync(l)}else return a.data?{data:Ea(a.type,a.data),width:a.width,height:a.height}:null}if(e!==void 0&&e.length>0){r=new El(this.manager),r.setCrossOrigin(this.crossOrigin);for(let a=0,o=e.length;a<o;a++){const l=e[a],c=l.url;if(Array.isArray(c)){const u=[];for(let h=0,d=c.length;h<d;h++){const p=c[h],m=await s(p);m!==null&&(m instanceof HTMLImageElement?u.push(m):u.push(new Ur(m.data,m.width,m.height)))}i[l.uuid]=new $n(u)}else{const u=await s(l.url);i[l.uuid]=new $n(u)}}}return i}parseTextures(e,t){function i(s,a){return typeof s=="number"?s:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",s),a[s])}const r={};if(e!==void 0)for(let s=0,a=e.length;s<a;s++){const o=e[s];o.image===void 0&&console.warn('THREE.ObjectLoader: No "image" specified for',o.uuid),t[o.image]===void 0&&console.warn("THREE.ObjectLoader: Undefined image",o.image);const l=t[o.image],c=l.data;let u;Array.isArray(c)?(u=new Cs,c.length===6&&(u.needsUpdate=!0)):(c&&c.data?u=new Ur:u=new Wt,c&&(u.needsUpdate=!0)),u.source=l,u.uuid=o.uuid,o.name!==void 0&&(u.name=o.name),o.mapping!==void 0&&(u.mapping=i(o.mapping,zI)),o.channel!==void 0&&(u.channel=o.channel),o.offset!==void 0&&u.offset.fromArray(o.offset),o.repeat!==void 0&&u.repeat.fromArray(o.repeat),o.center!==void 0&&u.center.fromArray(o.center),o.rotation!==void 0&&(u.rotation=o.rotation),o.wrap!==void 0&&(u.wrapS=i(o.wrap[0],ax),u.wrapT=i(o.wrap[1],ax)),o.format!==void 0&&(u.format=o.format),o.internalFormat!==void 0&&(u.internalFormat=o.internalFormat),o.type!==void 0&&(u.type=o.type),o.colorSpace!==void 0&&(u.colorSpace=o.colorSpace),o.minFilter!==void 0&&(u.minFilter=i(o.minFilter,ox)),o.magFilter!==void 0&&(u.magFilter=i(o.magFilter,ox)),o.anisotropy!==void 0&&(u.anisotropy=o.anisotropy),o.flipY!==void 0&&(u.flipY=o.flipY),o.generateMipmaps!==void 0&&(u.generateMipmaps=o.generateMipmaps),o.premultiplyAlpha!==void 0&&(u.premultiplyAlpha=o.premultiplyAlpha),o.unpackAlignment!==void 0&&(u.unpackAlignment=o.unpackAlignment),o.compareFunction!==void 0&&(u.compareFunction=o.compareFunction),o.userData!==void 0&&(u.userData=o.userData),r[o.uuid]=u}return r}parseObject(e,t,i,r,s){let a;function o(d){return t[d]===void 0&&console.warn("THREE.ObjectLoader: Undefined geometry",d),t[d]}function l(d){if(d!==void 0){if(Array.isArray(d)){const p=[];for(let m=0,v=d.length;m<v;m++){const f=d[m];i[f]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",f),p.push(i[f])}return p}return i[d]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",d),i[d]}}function c(d){return r[d]===void 0&&console.warn("THREE.ObjectLoader: Undefined texture",d),r[d]}let u,h;switch(e.type){case"Scene":a=new Ou,e.background!==void 0&&(Number.isInteger(e.background)?a.background=new xe(e.background):a.background=c(e.background)),e.environment!==void 0&&(a.environment=c(e.environment)),e.fog!==void 0&&(e.fog.type==="Fog"?a.fog=new Kp(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(a.fog=new Nd(e.fog.color,e.fog.density)),e.fog.name!==""&&(a.fog.name=e.fog.name)),e.backgroundBlurriness!==void 0&&(a.backgroundBlurriness=e.backgroundBlurriness),e.backgroundIntensity!==void 0&&(a.backgroundIntensity=e.backgroundIntensity),e.backgroundRotation!==void 0&&a.backgroundRotation.fromArray(e.backgroundRotation),e.environmentIntensity!==void 0&&(a.environmentIntensity=e.environmentIntensity),e.environmentRotation!==void 0&&a.environmentRotation.fromArray(e.environmentRotation);break;case"PerspectiveCamera":a=new di(e.fov,e.aspect,e.near,e.far),e.focus!==void 0&&(a.focus=e.focus),e.zoom!==void 0&&(a.zoom=e.zoom),e.filmGauge!==void 0&&(a.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(a.filmOffset=e.filmOffset),e.view!==void 0&&(a.view=Object.assign({},e.view));break;case"OrthographicCamera":a=new Ls(e.left,e.right,e.top,e.bottom,e.near,e.far),e.zoom!==void 0&&(a.zoom=e.zoom),e.view!==void 0&&(a.view=Object.assign({},e.view));break;case"AmbientLight":a=new yh(e.color,e.intensity);break;case"DirectionalLight":a=new vh(e.color,e.intensity),a.target=e.target||"";break;case"PointLight":a=new gh(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":a=new Vm(e.color,e.intensity,e.width,e.height);break;case"SpotLight":a=new Al(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay),a.target=e.target||"";break;case"HemisphereLight":a=new fh(e.color,e.groundColor,e.intensity);break;case"LightProbe":a=new Bm().fromJSON(e);break;case"SkinnedMesh":u=o(e.geometry),h=l(e.material),a=new rm(u,h),e.bindMode!==void 0&&(a.bindMode=e.bindMode),e.bindMatrix!==void 0&&a.bindMatrix.fromArray(e.bindMatrix),e.skeleton!==void 0&&(a.skeleton=e.skeleton);break;case"Mesh":u=o(e.geometry),h=l(e.material),a=new Ft(u,h);break;case"InstancedMesh":u=o(e.geometry),h=l(e.material);const d=e.count,p=e.instanceMatrix,m=e.instanceColor;a=new nm(u,h,d),a.instanceMatrix=new Nn(new Float32Array(p.array),16),m!==void 0&&(a.instanceColor=new Nn(new Float32Array(m.array),m.itemSize));break;case"BatchedMesh":u=o(e.geometry),h=l(e.material),a=new lm(e.maxInstanceCount,e.maxVertexCount,e.maxIndexCount,h),a.geometry=u,a.perObjectFrustumCulled=e.perObjectFrustumCulled,a.sortObjects=e.sortObjects,a._drawRanges=e.drawRanges,a._reservedRanges=e.reservedRanges,a._visibility=e.visibility,a._active=e.active,a._bounds=e.bounds.map(v=>{const f=new Bi;f.min.fromArray(v.boxMin),f.max.fromArray(v.boxMax);const g=new Ai;return g.radius=v.sphereRadius,g.center.fromArray(v.sphereCenter),{boxInitialized:v.boxInitialized,box:f,sphereInitialized:v.sphereInitialized,sphere:g}}),a._maxInstanceCount=e.maxInstanceCount,a._maxVertexCount=e.maxVertexCount,a._maxIndexCount=e.maxIndexCount,a._geometryInitialized=e.geometryInitialized,a._geometryCount=e.geometryCount,a._matricesTexture=c(e.matricesTexture.uuid),e.colorsTexture!==void 0&&(a._colorsTexture=c(e.colorsTexture.uuid));break;case"LOD":a=new em;break;case"Line":a=new Cn(o(e.geometry),l(e.material));break;case"LineLoop":a=new um(o(e.geometry),l(e.material));break;case"LineSegments":a=new $r(o(e.geometry),l(e.material));break;case"PointCloud":case"Points":a=new dm(o(e.geometry),l(e.material));break;case"Sprite":a=new Qp(l(e.material));break;case"Group":a=new Os;break;case"Bone":a=new Hu;break;default:a=new _t}if(a.uuid=e.uuid,e.name!==void 0&&(a.name=e.name),e.matrix!==void 0?(a.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(a.matrixAutoUpdate=e.matrixAutoUpdate),a.matrixAutoUpdate&&a.matrix.decompose(a.position,a.quaternion,a.scale)):(e.position!==void 0&&a.position.fromArray(e.position),e.rotation!==void 0&&a.rotation.fromArray(e.rotation),e.quaternion!==void 0&&a.quaternion.fromArray(e.quaternion),e.scale!==void 0&&a.scale.fromArray(e.scale)),e.up!==void 0&&a.up.fromArray(e.up),e.castShadow!==void 0&&(a.castShadow=e.castShadow),e.receiveShadow!==void 0&&(a.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.intensity!==void 0&&(a.shadow.intensity=e.shadow.intensity),e.shadow.bias!==void 0&&(a.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(a.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(a.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&a.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(a.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(a.visible=e.visible),e.frustumCulled!==void 0&&(a.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(a.renderOrder=e.renderOrder),e.userData!==void 0&&(a.userData=e.userData),e.layers!==void 0&&(a.layers.mask=e.layers),e.children!==void 0){const d=e.children;for(let p=0;p<d.length;p++)a.add(this.parseObject(d[p],t,i,r,s))}if(e.animations!==void 0){const d=e.animations;for(let p=0;p<d.length;p++){const m=d[p];a.animations.push(s[m])}}if(e.type==="LOD"){e.autoUpdate!==void 0&&(a.autoUpdate=e.autoUpdate);const d=e.levels;for(let p=0;p<d.length;p++){const m=d[p],v=a.getObjectByProperty("uuid",m.object);v!==void 0&&a.addLevel(v,m.distance,m.hysteresis)}}return a}bindSkeletons(e,t){Object.keys(t).length!==0&&e.traverse(function(i){if(i.isSkinnedMesh===!0&&i.skeleton!==void 0){const r=t[i.skeleton];r===void 0?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",i.skeleton):i.bind(r,i.bindMatrix)}})}bindLightTargets(e){e.traverse(function(t){if(t.isDirectionalLight||t.isSpotLight){const i=t.target,r=e.getObjectByProperty("uuid",i);r!==void 0?t.target=r:t.target=new _t}})}}const zI={UVMapping:Ic,CubeReflectionMapping:fr,CubeRefractionMapping:Ar,EquirectangularReflectionMapping:kn,EquirectangularRefractionMapping:Hn,CubeUVReflectionMapping:xs},ax={RepeatWrapping:Gn,ClampToEdgeWrapping:gr,MirroredRepeatWrapping:fa},ox={NearestFilter:$t,NearestMipmapNearestFilter:Lc,NearestMipmapLinearFilter:Mn,LinearFilter:Lt,LinearMipmapNearestFilter:Wn,LinearMipmapLinearFilter:ji};class lx extends Hi{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=Rn.get(e);if(a!==void 0){if(s.manager.itemStart(e),a.then){a.then(c=>{t&&t(c),s.manager.itemEnd(e)}).catch(c=>{r&&r(c)});return}return setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader;const l=fetch(e,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(c){return Rn.add(e,c),t&&t(c),s.manager.itemEnd(e),c}).catch(function(c){r&&r(c),Rn.remove(e),s.manager.itemError(e),s.manager.itemEnd(e)});Rn.add(e,l),s.manager.itemStart(e)}}let _h;class Mh{static getContext(){return _h===void 0&&(_h=new(window.AudioContext||window.webkitAudioContext)),_h}static setContext(e){_h=e}}class cx extends Hi{constructor(e){super(e)}load(e,t,i,r){const s=this,a=new Kr(this.manager);a.setResponseType("arraybuffer"),a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(l){try{const c=l.slice(0);Mh.getContext().decodeAudioData(c,function(u){t(u)}).catch(o)}catch(c){o(c)}},i,r);function o(l){r?r(l):console.error(l),s.manager.itemError(e)}}}const ux=new Re,hx=new Re,Gs=new Re;class km{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new di,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new di,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,Gs.copy(e.projectionMatrix);const i=t.eyeSep/2,r=i*t.near/t.focus,s=t.near*Math.tan(Ss*t.fov*.5)/t.zoom;let a,o;hx.elements[12]=-i,ux.elements[12]=i,a=-s*t.aspect+r,o=s*t.aspect+r,Gs.elements[0]=2*t.near/(o-a),Gs.elements[8]=(o+a)/(o-a),this.cameraL.projectionMatrix.copy(Gs),a=-s*t.aspect-r,o=s*t.aspect-r,Gs.elements[0]=2*t.near/(o-a),Gs.elements[8]=(o+a)/(o-a),this.cameraR.projectionMatrix.copy(Gs)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(hx),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(ux)}}class Hm{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=dx(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=dx();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function dx(){return performance.now()}const cn=new N,px=new qi,kI=new N,Ws=new N;let mx=class extends _t{constructor(){super(),this.type="AudioListener",this.context=Mh.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Hm}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(n){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=n,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(n){return this.gain.gain.setTargetAtTime(n,this.context.currentTime,.01),this}updateMatrixWorld(n){super.updateMatrixWorld(n);const e=this.context.listener,t=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(cn,px,kI),!(!Number.isFinite(cn.x)||!Number.isFinite(cn.y)||!Number.isFinite(cn.z)))if(Ws.set(0,0,-1).applyQuaternion(px),e.positionX){const i=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(cn.x,i),e.positionY.linearRampToValueAtTime(cn.y,i),e.positionZ.linearRampToValueAtTime(cn.z,i),e.forwardX.linearRampToValueAtTime(Ws.x,i),e.forwardY.linearRampToValueAtTime(Ws.y,i),e.forwardZ.linearRampToValueAtTime(Ws.z,i),e.upX.linearRampToValueAtTime(t.x,i),e.upY.linearRampToValueAtTime(t.y,i),e.upZ.linearRampToValueAtTime(t.z,i)}else e.setPosition(cn.x,cn.y,cn.z),e.setOrientation(Ws.x,Ws.y,Ws.z,t.x,t.y,t.z)}};class Gm extends _t{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||(this.buffer?this.buffer.duration:Number.MAX_VALUE))),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(e=0){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(this.context.currentTime+e),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this._connected!==!1){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}}getFilters(){return this.filters}setFilters(e){return e||(e=[]),this._connected===!0?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){return this.detune=e,this.isPlaying===!0&&this.source.detune!==void 0&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.playbackRate=e,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.loop=e,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}}const js=new N,fx=new qi,HI=new N,Xs=new N;class gx extends Gm{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){super.connect(),this.panner.connect(this.gain)}disconnect(){super.disconnect(),this.panner.disconnect(this.gain)}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(e){return this.panner.refDistance=e,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(e){return this.panner.rolloffFactor=e,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(e){return this.panner.distanceModel=e,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(e){return this.panner.maxDistance=e,this}setDirectionalCone(e,t,i){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=i,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(js,fx,HI),Xs.set(0,0,1).applyQuaternion(fx);const t=this.panner;if(t.positionX){const i=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(js.x,i),t.positionY.linearRampToValueAtTime(js.y,i),t.positionZ.linearRampToValueAtTime(js.z,i),t.orientationX.linearRampToValueAtTime(Xs.x,i),t.orientationY.linearRampToValueAtTime(Xs.y,i),t.orientationZ.linearRampToValueAtTime(Xs.z,i)}else t.setPosition(js.x,js.y,js.z),t.setOrientation(Xs.x,Xs.y,Xs.z)}}class GI{constructor(e,t=2048){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=t,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0;const t=this.getFrequencyData();for(let i=0;i<t.length;i++)e+=t[i];return e/t.length}}class vx{constructor(e,t,i){this.binding=e,this.valueSize=i;let r,s,a;switch(t){case"quaternion":r=this._slerp,s=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":r=this._select,s=this._select,a=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:r=this._lerp,s=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=s,this._setIdentity=a,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){const i=this.buffer,r=this.valueSize,s=e*r+r;let a=this.cumulativeWeight;if(a===0){for(let o=0;o!==r;++o)i[s+o]=i[o];a=t}else{a+=t;const o=t/a;this._mixBufferRegion(i,s,0,o,r)}this.cumulativeWeight=a}accumulateAdditive(e){const t=this.buffer,i=this.valueSize,r=i*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,i),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,i=this.buffer,r=e*t+t,s=this.cumulativeWeight,a=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){const l=t*this._origIndex;this._mixBufferRegion(i,r,l,1-s,t)}a>0&&this._mixBufferRegionAdditive(i,r,this._addIndex*t,1,t);for(let l=t,c=t+t;l!==c;++l)if(i[l]!==i[l+t]){o.setValue(i,r);break}}saveOriginalState(){const e=this.binding,t=this.buffer,i=this.valueSize,r=i*this._origIndex;e.getValue(t,r);for(let s=i,a=r;s!==a;++s)t[s]=t[r+s%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i<t;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[t+i]=this.buffer[e+i]}_select(e,t,i,r,s){if(r>=.5)for(let a=0;a!==s;++a)e[t+a]=e[i+a]}_slerp(e,t,i,r){qi.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,s){const a=this._workIndex*s;qi.multiplyQuaternionsFlat(e,a,e,t,e,i),qi.slerpFlat(e,t,e,t,e,a,r)}_lerp(e,t,i,r,s){const a=1-r;for(let o=0;o!==s;++o){const l=t+o;e[l]=e[l]*a+e[i+o]*r}}_lerpAdditive(e,t,i,r,s){for(let a=0;a!==s;++a){const o=t+a;e[o]=e[o]+e[i+a]*r}}}const Wm="\\[\\]\\.:\\/",WI=new RegExp("["+Wm+"]","g"),jm="[^"+Wm+"]",jI="[^"+Wm.replace("\\.","")+"]",XI=/((?:WC+[\/:])*)/.source.replace("WC",jm),qI=/(WCOD+)?/.source.replace("WCOD",jI),YI=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",jm),$I=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",jm),JI=new RegExp("^"+XI+qI+YI+$I+"$"),KI=["material","materials","bones","map"];class ZI{constructor(e,t,i){const r=i||Tt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();const i=this._targetGroup.nCachedObjects_,r=this._bindings[i];r!==void 0&&r.getValue(e,t)}setValue(e,t){const i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=i.length;r!==s;++r)i[r].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}}class Tt{constructor(e,t,i){this.path=t,this.parsedPath=i||Tt.parseTrackName(t),this.node=Tt.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new Tt.Composite(e,t,i):new Tt(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(WI,"")}static parseTrackName(e){const t=JI.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){const s=i.nodeName.substring(r+1);KI.indexOf(s)!==-1&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=s)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){const i=function(s,a){for(let o=0;o<s.length;o++){const l=s[o];if(!a&&(l.name===t||l.uuid===t)||a&&l.userData&&l.userData.name===t)return l;const c=i(l.children,a);if(c)return c}return null},r=i(e.children);if(r)return r;{const s=i(e.children,!0);if(s)return s}}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)e[t++]=i[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,i=t.objectName,r=t.propertyName;let s=t.propertyIndex;if(e||(e=Tt.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(i){let c=t.objectIndex;switch(i){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let u=0;u<e.length;u++)if(e[u].name===c){c=u;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[i]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(c!==void 0){if(e[c]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}const a=e[r];if(a===void 0){const c=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+r+" but it wasn't found.",e);return}let o=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?o=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=s}else a.fromArray!==void 0&&a.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(l=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=r;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}Tt.Composite=ZI,Tt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Tt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},Tt.prototype.GetterByBindingType=[Tt.prototype._getValue_direct,Tt.prototype._getValue_array,Tt.prototype._getValue_arrayElement,Tt.prototype._getValue_toArray],Tt.prototype.SetterByBindingTypeAndVersioning=[[Tt.prototype._setValue_direct,Tt.prototype._setValue_direct_setNeedsUpdate,Tt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Tt.prototype._setValue_array,Tt.prototype._setValue_array_setNeedsUpdate,Tt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Tt.prototype._setValue_arrayElement,Tt.prototype._setValue_arrayElement_setNeedsUpdate,Tt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Tt.prototype._setValue_fromArray,Tt.prototype._setValue_fromArray_setNeedsUpdate,Tt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class QI{constructor(){this.isAnimationObjectGroup=!0,this.uuid=yr(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const e={};this._indicesByUUID=e;for(let i=0,r=arguments.length;i!==r;++i)e[arguments[i].uuid]=i;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const t=this;this.stats={objects:{get total(){return t._objects.length},get inUse(){return this.total-t.nCachedObjects_}},get bindingsPerObject(){return t._bindings.length}}}add(){const e=this._objects,t=this._indicesByUUID,i=this._paths,r=this._parsedPaths,s=this._bindings,a=s.length;let o,l=e.length,c=this.nCachedObjects_;for(let u=0,h=arguments.length;u!==h;++u){const d=arguments[u],p=d.uuid;let m=t[p];if(m===void 0){m=l++,t[p]=m,e.push(d);for(let v=0,f=a;v!==f;++v)s[v].push(new Tt(d,i[v],r[v]))}else if(m<c){o=e[m];const v=--c,f=e[v];t[f.uuid]=m,e[m]=f,t[p]=v,e[v]=d;for(let g=0,x=a;g!==x;++g){const y=s[g],_=y[v];let I=y[m];y[m]=_,I===void 0&&(I=new Tt(d,i[g],r[g])),y[v]=I}}else e[m]!==o&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=c}remove(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,r=i.length;let s=this.nCachedObjects_;for(let a=0,o=arguments.length;a!==o;++a){const l=arguments[a],c=l.uuid,u=t[c];if(u!==void 0&&u>=s){const h=s++,d=e[h];t[d.uuid]=u,e[u]=d,t[c]=h,e[h]=l;for(let p=0,m=r;p!==m;++p){const v=i[p],f=v[h],g=v[u];v[u]=f,v[h]=g}}}this.nCachedObjects_=s}uncache(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,r=i.length;let s=this.nCachedObjects_,a=e.length;for(let o=0,l=arguments.length;o!==l;++o){const c=arguments[o],u=c.uuid,h=t[u];if(h!==void 0)if(delete t[u],h<s){const d=--s,p=e[d],m=--a,v=e[m];t[p.uuid]=h,e[h]=p,t[v.uuid]=d,e[d]=v,e.pop();for(let f=0,g=r;f!==g;++f){const x=i[f],y=x[d],_=x[m];x[h]=y,x[d]=_,x.pop()}}else{const d=--a,p=e[d];d>0&&(t[p.uuid]=h),e[h]=p,e.pop();for(let m=0,v=r;m!==v;++m){const f=i[m];f[h]=f[d],f.pop()}}}this.nCachedObjects_=s}subscribe_(e,t){const i=this._bindingsIndicesByPath;let r=i[e];const s=this._bindings;if(r!==void 0)return s[r];const a=this._paths,o=this._parsedPaths,l=this._objects,c=l.length,u=this.nCachedObjects_,h=new Array(c);r=s.length,i[e]=r,a.push(e),o.push(t),s.push(h);for(let d=u,p=l.length;d!==p;++d){const m=l[d];h[d]=new Tt(m,e,t)}return h}unsubscribe_(e){const t=this._bindingsIndicesByPath,i=t[e];if(i!==void 0){const r=this._paths,s=this._parsedPaths,a=this._bindings,o=a.length-1,l=a[o],c=e[o];t[c]=i,a[i]=l,a.pop(),s[i]=s[o],s.pop(),r[i]=r[o],r.pop()}}}class yx{constructor(e,t,i=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=r;const s=t.tracks,a=s.length,o=new Array(a),l={endingStart:_s,endingEnd:_s};for(let c=0;c!==a;++c){const u=s[c].createInterpolant(null);o[c]=u,u.settings=l}this._interpolantSettings=l,this._interpolants=o,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=lp,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i){if(e.fadeOut(t),this.fadeIn(t),i){const r=this._clip.duration,s=e._clip.duration,a=s/r,o=r/s;e.warp(1,a,t),this.warp(o,1,t)}return this}crossFadeTo(e,t,i){return e.crossFadeFrom(this,t,i)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){const r=this._mixer,s=r.time,a=this.timeScale;let o=this._timeScaleInterpolant;o===null&&(o=r._lendControlInterpolant(),this._timeScaleInterpolant=o);const l=o.parameterPositions,c=o.sampleValues;return l[0]=s,l[1]=s+i,c[0]=e/a,c[1]=t/a,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,r){if(!this.enabled){this._updateWeight(e);return}const s=this._startTime;if(s!==null){const l=(e-s)*i;l<0||i===0?t=0:(this._startTime=null,t=i*l)}t*=this._updateTimeScale(e);const a=this._updateTime(t),o=this._updateWeight(e);if(o>0){const l=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case cp:for(let u=0,h=l.length;u!==h;++u)l[u].evaluate(a),c[u].accumulateAdditive(o);break;case ru:default:for(let u=0,h=l.length;u!==h;++u)l[u].evaluate(a),c[u].accumulate(r,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const i=this._weightInterpolant;if(i!==null){const r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const i=this._timeScaleInterpolant;if(i!==null){const r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,i=this.loop;let r=this.time+e,s=this._loopCount;const a=i===V0;if(e===0)return s===-1?r:a&&(s&1)===1?t-r:r;if(i===op){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),r>=t||r<0){const o=Math.floor(r/t);r-=t*o,s+=Math.abs(o);const l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(l===1){const c=e<0;this._setEndings(c,!c,a)}else this._setEndings(!1,!1,a);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=r;if(a&&(s&1)===1)return t-r}return r}_setEndings(e,t,i){const r=this._interpolantSettings;i?(r.endingStart=Ms,r.endingEnd=Ms):(e?r.endingStart=this.zeroSlopeAtStart?Ms:_s:r.endingStart=qo,t?r.endingEnd=this.zeroSlopeAtEnd?Ms:_s:r.endingEnd=qo)}_scheduleFading(e,t,i){const r=this._mixer,s=r.time;let a=this._weightInterpolant;a===null&&(a=r._lendControlInterpolant(),this._weightInterpolant=a);const o=a.parameterPositions,l=a.sampleValues;return o[0]=s,l[0]=t,o[1]=s+e,l[1]=i,this}}const e2=new Float32Array(1);class xx extends vr{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const i=e._localRoot||this._root,r=e._clip.tracks,s=r.length,a=e._propertyBindings,o=e._interpolants,l=i.uuid,c=this._bindingsByRootAndName;let u=c[l];u===void 0&&(u={},c[l]=u);for(let h=0;h!==s;++h){const d=r[h],p=d.name;let m=u[p];if(m!==void 0)++m.referenceCount,a[h]=m;else{if(m=a[h],m!==void 0){m._cacheIndex===null&&(++m.referenceCount,this._addInactiveBinding(m,l,p));continue}const v=t&&t._propertyBindings[h].binding.parsedPath;m=new vx(Tt.create(i,p,v),d.ValueTypeName,d.getValueSize()),++m.referenceCount,this._addInactiveBinding(m,l,p),a[h]=m}o[h].resultBuffer=m.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const i=(e._localRoot||this._root).uuid,r=e._clip.uuid,s=this._actionsByClip[r];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,r,i)}const t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){const s=t[i];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){const s=t[i];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,i){const r=this._actions,s=this._actionsByClip;let a=s[t];if(a===void 0)a={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,s[t]=a;else{const o=a.knownActions;e._byClipCacheIndex=o.length,o.push(e)}e._cacheIndex=r.length,r.push(e),a.actionByRoot[i]=e}_removeInactiveAction(e){const t=this._actions,i=t[t.length-1],r=e._cacheIndex;i._cacheIndex=r,t[r]=i,t.pop(),e._cacheIndex=null;const s=e._clip.uuid,a=this._actionsByClip,o=a[s],l=o.knownActions,c=l[l.length-1],u=e._byClipCacheIndex;c._byClipCacheIndex=u,l[u]=c,l.pop(),e._byClipCacheIndex=null;const h=o.actionByRoot,d=(e._localRoot||this._root).uuid;delete h[d],l.length===0&&delete a[s],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){const s=t[i];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(e){const t=this._actions,i=e._cacheIndex,r=this._nActiveActions++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackAction(e){const t=this._actions,i=e._cacheIndex,r=--this._nActiveActions,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_addInactiveBinding(e,t,i){const r=this._bindingsByRootAndName,s=this._bindings;let a=r[t];a===void 0&&(a={},r[t]=a),a[i]=e,e._cacheIndex=s.length,s.push(e)}_removeInactiveBinding(e){const t=this._bindings,i=e.binding,r=i.rootNode.uuid,s=i.path,a=this._bindingsByRootAndName,o=a[r],l=t[t.length-1],c=e._cacheIndex;l._cacheIndex=c,t[c]=l,t.pop(),delete o[s],Object.keys(o).length===0&&delete a[r]}_lendBinding(e){const t=this._bindings,i=e._cacheIndex,r=this._nActiveBindings++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackBinding(e){const t=this._bindings,i=e._cacheIndex,r=--this._nActiveBindings,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let i=e[t];return i===void 0&&(i=new Pm(new Float32Array(2),new Float32Array(2),1,e2),i.__cacheIndex=t,e[t]=i),i}_takeBackControlInterpolant(e){const t=this._controlInterpolants,i=e.__cacheIndex,r=--this._nActiveControlInterpolants,s=t[r];e.__cacheIndex=r,t[r]=e,s.__cacheIndex=i,t[i]=s}clipAction(e,t,i){const r=t||this._root,s=r.uuid;let a=typeof e=="string"?ro.findByName(r,e):e;const o=a!==null?a.uuid:e,l=this._actionsByClip[o];let c=null;if(i===void 0&&(a!==null?i=a.blendMode:i=ru),l!==void 0){const h=l.actionByRoot[s];if(h!==void 0&&h.blendMode===i)return h;c=l.knownActions[0],a===null&&(a=c._clip)}if(a===null)return null;const u=new yx(this,a,t,i);return this._bindAction(u,c),this._addInactiveAction(u,o,s),u}existingAction(e,t){const i=t||this._root,r=i.uuid,s=typeof e=="string"?ro.findByName(i,e):e,a=s?s.uuid:e,o=this._actionsByClip[a];return o!==void 0&&o.actionByRoot[r]||null}stopAllAction(){const e=this._actions,t=this._nActiveActions;for(let i=t-1;i>=0;--i)e[i].stop();return this}update(e){e*=this.timeScale;const t=this._actions,i=this._nActiveActions,r=this.time+=e,s=Math.sign(e),a=this._accuIndex^=1;for(let c=0;c!==i;++c)t[c]._update(r,e,s,a);const o=this._bindings,l=this._nActiveBindings;for(let c=0;c!==l;++c)o[c].apply(a);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){const t=this._actions,i=e.uuid,r=this._actionsByClip,s=r[i];if(s!==void 0){const a=s.knownActions;for(let o=0,l=a.length;o!==l;++o){const c=a[o];this._deactivateAction(c);const u=c._cacheIndex,h=t[t.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,h._cacheIndex=u,t[u]=h,t.pop(),this._removeInactiveBindingsForAction(c)}delete r[i]}}uncacheRoot(e){const t=e.uuid,i=this._actionsByClip;for(const a in i){const o=i[a].actionByRoot,l=o[t];l!==void 0&&(this._deactivateAction(l),this._removeInactiveAction(l))}const r=this._bindingsByRootAndName,s=r[t];if(s!==void 0)for(const a in s){const o=s[a];o.restoreOriginalState(),this._removeInactiveBinding(o)}}uncacheAction(e,t){const i=this.existingAction(e,t);i!==null&&(this._deactivateAction(i),this._removeInactiveAction(i))}}let _x=class YS{constructor(e){this.value=e}clone(){return new YS(this.value.clone===void 0?this.value:this.value.clone())}},t2=0;class i2 extends vr{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:t2++}),this.name="",this.usage=Sa,this.uniforms=[]}add(e){return this.uniforms.push(e),this}remove(e){const t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}setName(e){return this.name=e,this}setUsage(e){return this.usage=e,this}dispose(){return this.dispatchEvent({type:"dispose"}),this}copy(e){this.name=e.name,this.usage=e.usage;const t=e.uniforms;this.uniforms.length=0;for(let i=0,r=t.length;i<r;i++){const s=Array.isArray(t[i])?t[i]:[t[i]];for(let a=0;a<s.length;a++)this.uniforms.push(s[a].clone())}return this}clone(){return new this.constructor().copy(this)}}class Xm extends ja{constructor(e,t,i=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){const t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}}class r2{constructor(e,t,i,r,s){this.isGLBufferAttribute=!0,this.name="",this.buffer=e,this.type=t,this.itemSize=i,this.elementSize=r,this.count=s,this.version=0}set needsUpdate(e){e===!0&&this.version++}setBuffer(e){return this.buffer=e,this}setType(e,t){return this.type=e,this.elementSize=t,this}setItemSize(e){return this.itemSize=e,this}setCount(e){return this.count=e,this}}const Mx=new Re;class bx{constructor(e,t,i=0,r=1/0){this.ray=new As(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new nl,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return Mx.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Mx),this}intersectObject(e,t=!0,i=[]){return qm(e,this,i,t),i.sort(Tx),i}intersectObjects(e,t=!0,i=[]){for(let r=0,s=e.length;r<s;r++)qm(e[r],this,i,t);return i.sort(Tx),i}}function Tx(n,e){return n.distance-e.distance}function qm(n,e,t,i){let r=!0;if(n.layers.test(e.layers)&&n.raycast(e,t)===!1&&(r=!1),r===!0&&i===!0){const s=n.children;for(let a=0,o=s.length;a<o;a++)qm(s[a],e,t,!0)}}class Sx{constructor(e=1,t=0,i=0){return this.radius=e,this.phi=t,this.theta=i,this}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(Jt(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class n2{constructor(e=1,t=0,i=0){return this.radius=e,this.theta=t,this.y=i,this}set(e,t,i){return this.radius=e,this.theta=t,this.y=i,this}copy(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+i*i),this.theta=Math.atan2(e,i),this.y=t,this}clone(){return new this.constructor().copy(this)}}class a0{constructor(e,t,i,r){a0.prototype.isMatrix2=!0,this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,i,r)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let i=0;i<4;i++)this.elements[i]=e[i+t];return this}set(e,t,i,r){const s=this.elements;return s[0]=e,s[2]=t,s[1]=i,s[3]=r,this}}const wx=new J;class s2{constructor(e=new J(1/0,1/0),t=new J(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const i=wx.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,wx).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const Ex=new N,bh=new N;class Ax{constructor(e=new N,t=new N){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){Ex.subVectors(e,this.start),bh.subVectors(this.end,this.start);const i=bh.dot(bh);let r=bh.dot(Ex)/i;return t&&(r=Jt(r,0,1)),r}closestPointToPoint(e,t,i){const r=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(r).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const Nx=new N;class a2 extends _t{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const i=new ct,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let a=0,o=1,l=32;a<l;a++,o++){const c=a/l*Math.PI*2,u=o/l*Math.PI*2;r.push(Math.cos(c),Math.sin(c),1,Math.cos(u),Math.sin(u),1)}i.setAttribute("position",new De(r,3));const s=new Ni({fog:!1,toneMapped:!1});this.cone=new $r(i,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),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 e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),Nx.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Nx),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const ss=new N,Th=new Re,Ym=new Re;class o2 extends $r{constructor(e){const t=Cx(e),i=new ct,r=[],s=[],a=new xe(0,0,1),o=new xe(0,1,0);for(let c=0;c<t.length;c++){const u=t[c];u.parent&&u.parent.isBone&&(r.push(0,0,0),r.push(0,0,0),s.push(a.r,a.g,a.b),s.push(o.r,o.g,o.b))}i.setAttribute("position",new De(r,3)),i.setAttribute("color",new De(s,3));const l=new Ni({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(i,l),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){const t=this.bones,i=this.geometry,r=i.getAttribute("position");Ym.copy(this.root.matrixWorld).invert();for(let s=0,a=0;s<t.length;s++){const o=t[s];o.parent&&o.parent.isBone&&(Th.multiplyMatrices(Ym,o.matrixWorld),ss.setFromMatrixPosition(Th),r.setXYZ(a,ss.x,ss.y,ss.z),Th.multiplyMatrices(Ym,o.parent.matrixWorld),ss.setFromMatrixPosition(Th),r.setXYZ(a+1,ss.x,ss.y,ss.z),a+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose()}}function Cx(n){const e=[];n.isBone===!0&&e.push(n);for(let t=0;t<n.children.length;t++)e.push.apply(e,Cx(n.children[t]));return e}class l2 extends Ft{constructor(e,t,i){const r=new Eo(t,4,2),s=new Yr({wireframe:!0,fog:!1,toneMapped:!1});super(r,s),this.light=e,this.color=i,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}}const c2=new N,Rx=new xe,Ix=new xe;class u2 extends _t{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="HemisphereLightHelper";const r=new wo(t);r.rotateY(Math.PI*.5),this.material=new Yr({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);const s=r.getAttribute("position"),a=new Float32Array(s.count*3);r.setAttribute("color",new wt(a,3)),this.add(new Ft(r,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const e=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{const t=e.geometry.getAttribute("color");Rx.copy(this.light.color),Ix.copy(this.light.groundColor);for(let i=0,r=t.count;i<r;i++){const s=i<r/2?Rx:Ix;t.setXYZ(i,s.r,s.g,s.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(c2.setFromMatrixPosition(this.light.matrixWorld).negate())}}let Lx=class extends $r{constructor(n=10,e=10,t=4473924,i=8947848){t=new xe(t),i=new xe(i);const r=e/2,s=n/e,a=n/2,o=[],l=[];for(let h=0,d=0,p=-a;h<=e;h++,p+=s){o.push(-a,0,p,a,0,p),o.push(p,0,-a,p,0,a);const m=h===r?t:i;m.toArray(l,d),d+=3,m.toArray(l,d),d+=3,m.toArray(l,d),d+=3,m.toArray(l,d),d+=3}const c=new ct;c.setAttribute("position",new De(o,3)),c.setAttribute("color",new De(l,3));const u=new Ni({vertexColors:!0,toneMapped:!1});super(c,u),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}};class h2 extends $r{constructor(e=10,t=16,i=8,r=64,s=4473924,a=8947848){s=new xe(s),a=new xe(a);const o=[],l=[];if(t>1)for(let h=0;h<t;h++){const d=h/t*(Math.PI*2),p=Math.sin(d)*e,m=Math.cos(d)*e;o.push(0,0,0),o.push(p,0,m);const v=h&1?s:a;l.push(v.r,v.g,v.b),l.push(v.r,v.g,v.b)}for(let h=0;h<i;h++){const d=h&1?s:a,p=e-e/i*h;for(let m=0;m<r;m++){let v=m/r*(Math.PI*2),f=Math.sin(v)*p,g=Math.cos(v)*p;o.push(f,0,g),l.push(d.r,d.g,d.b),v=(m+1)/r*(Math.PI*2),f=Math.sin(v)*p,g=Math.cos(v)*p,o.push(f,0,g),l.push(d.r,d.g,d.b)}}const c=new ct;c.setAttribute("position",new De(o,3)),c.setAttribute("color",new De(l,3));const u=new Ni({vertexColors:!0,toneMapped:!1});super(c,u),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const Px=new N,Sh=new N,Dx=new N;class Ux extends _t{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="DirectionalLightHelper",t===void 0&&(t=1);let r=new ct;r.setAttribute("position",new De([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));const s=new Ni({fog:!1,toneMapped:!1});this.lightPlane=new Cn(r,s),this.add(this.lightPlane),r=new ct,r.setAttribute("position",new De([0,0,0,0,0,1],3)),this.targetLine=new Cn(r,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),Px.setFromMatrixPosition(this.light.matrixWorld),Sh.setFromMatrixPosition(this.light.target.matrixWorld),Dx.subVectors(Sh,Px),this.lightPlane.lookAt(Sh),this.color!==void 0?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(Sh),this.targetLine.scale.z=Dx.length()}}const wh=new N,Kt=new ll;class Ox extends $r{constructor(e){const t=new ct,i=new Ni({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],a={};o("n1","n2"),o("n2","n4"),o("n4","n3"),o("n3","n1"),o("f1","f2"),o("f2","f4"),o("f4","f3"),o("f3","f1"),o("n1","f1"),o("n2","f2"),o("n3","f3"),o("n4","f4"),o("p","n1"),o("p","n2"),o("p","n3"),o("p","n4"),o("u1","u2"),o("u2","u3"),o("u3","u1"),o("c","t"),o("p","c"),o("cn1","cn2"),o("cn3","cn4"),o("cf1","cf2"),o("cf3","cf4");function o(m,v){l(m),l(v)}function l(m){r.push(0,0,0),s.push(0,0,0),a[m]===void 0&&(a[m]=[]),a[m].push(r.length/3-1)}t.setAttribute("position",new De(r,3)),t.setAttribute("color",new De(s,3)),super(t,i),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update();const c=new xe(16755200),u=new xe(16711680),h=new xe(43775),d=new xe(16777215),p=new xe(3355443);this.setColors(c,u,h,d,p)}setColors(e,t,i,r,s){const a=this.geometry.getAttribute("color");a.setXYZ(0,e.r,e.g,e.b),a.setXYZ(1,e.r,e.g,e.b),a.setXYZ(2,e.r,e.g,e.b),a.setXYZ(3,e.r,e.g,e.b),a.setXYZ(4,e.r,e.g,e.b),a.setXYZ(5,e.r,e.g,e.b),a.setXYZ(6,e.r,e.g,e.b),a.setXYZ(7,e.r,e.g,e.b),a.setXYZ(8,e.r,e.g,e.b),a.setXYZ(9,e.r,e.g,e.b),a.setXYZ(10,e.r,e.g,e.b),a.setXYZ(11,e.r,e.g,e.b),a.setXYZ(12,e.r,e.g,e.b),a.setXYZ(13,e.r,e.g,e.b),a.setXYZ(14,e.r,e.g,e.b),a.setXYZ(15,e.r,e.g,e.b),a.setXYZ(16,e.r,e.g,e.b),a.setXYZ(17,e.r,e.g,e.b),a.setXYZ(18,e.r,e.g,e.b),a.setXYZ(19,e.r,e.g,e.b),a.setXYZ(20,e.r,e.g,e.b),a.setXYZ(21,e.r,e.g,e.b),a.setXYZ(22,e.r,e.g,e.b),a.setXYZ(23,e.r,e.g,e.b),a.setXYZ(24,t.r,t.g,t.b),a.setXYZ(25,t.r,t.g,t.b),a.setXYZ(26,t.r,t.g,t.b),a.setXYZ(27,t.r,t.g,t.b),a.setXYZ(28,t.r,t.g,t.b),a.setXYZ(29,t.r,t.g,t.b),a.setXYZ(30,t.r,t.g,t.b),a.setXYZ(31,t.r,t.g,t.b),a.setXYZ(32,i.r,i.g,i.b),a.setXYZ(33,i.r,i.g,i.b),a.setXYZ(34,i.r,i.g,i.b),a.setXYZ(35,i.r,i.g,i.b),a.setXYZ(36,i.r,i.g,i.b),a.setXYZ(37,i.r,i.g,i.b),a.setXYZ(38,r.r,r.g,r.b),a.setXYZ(39,r.r,r.g,r.b),a.setXYZ(40,s.r,s.g,s.b),a.setXYZ(41,s.r,s.g,s.b),a.setXYZ(42,s.r,s.g,s.b),a.setXYZ(43,s.r,s.g,s.b),a.setXYZ(44,s.r,s.g,s.b),a.setXYZ(45,s.r,s.g,s.b),a.setXYZ(46,s.r,s.g,s.b),a.setXYZ(47,s.r,s.g,s.b),a.setXYZ(48,s.r,s.g,s.b),a.setXYZ(49,s.r,s.g,s.b),a.needsUpdate=!0}update(){const e=this.geometry,t=this.pointMap,i=1,r=1;Kt.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),ti("c",t,e,Kt,0,0,-1),ti("t",t,e,Kt,0,0,1),ti("n1",t,e,Kt,-1,-1,-1),ti("n2",t,e,Kt,i,-1,-1),ti("n3",t,e,Kt,-1,r,-1),ti("n4",t,e,Kt,i,r,-1),ti("f1",t,e,Kt,-1,-1,1),ti("f2",t,e,Kt,i,-1,1),ti("f3",t,e,Kt,-1,r,1),ti("f4",t,e,Kt,i,r,1),ti("u1",t,e,Kt,i*.7,r*1.1,-1),ti("u2",t,e,Kt,-1*.7,r*1.1,-1),ti("u3",t,e,Kt,0,r*2,-1),ti("cf1",t,e,Kt,-1,0,1),ti("cf2",t,e,Kt,i,0,1),ti("cf3",t,e,Kt,0,-1,1),ti("cf4",t,e,Kt,0,r,1),ti("cn1",t,e,Kt,-1,0,-1),ti("cn2",t,e,Kt,i,0,-1),ti("cn3",t,e,Kt,0,-1,-1),ti("cn4",t,e,Kt,0,r,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function ti(n,e,t,i,r,s,a){wh.set(r,s,a).unproject(i);const o=e[n];if(o!==void 0){const l=t.getAttribute("position");for(let c=0,u=o.length;c<u;c++)l.setXYZ(o[c],wh.x,wh.y,wh.z)}}const Eh=new Bi;class Fx extends $r{constructor(e,t=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=new Float32Array(8*3),s=new ct;s.setIndex(new wt(i,1)),s.setAttribute("position",new wt(r,3)),super(s,new Ni({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(e){if(e!==void 0&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),this.object!==void 0&&Eh.setFromObject(this.object),Eh.isEmpty())return;const t=Eh.min,i=Eh.max,r=this.geometry.attributes.position,s=r.array;s[0]=i.x,s[1]=i.y,s[2]=i.z,s[3]=t.x,s[4]=i.y,s[5]=i.z,s[6]=t.x,s[7]=t.y,s[8]=i.z,s[9]=i.x,s[10]=t.y,s[11]=i.z,s[12]=i.x,s[13]=i.y,s[14]=t.z,s[15]=t.x,s[16]=i.y,s[17]=t.z,s[18]=t.x,s[19]=t.y,s[20]=t.z,s[21]=i.x,s[22]=t.y,s[23]=t.z,r.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class Vx extends $r{constructor(e,t=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new ct;s.setIndex(new wt(i,1)),s.setAttribute("position",new De(r,3)),super(s,new Ni({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){const t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}}class d2 extends Cn{constructor(e,t=1,i=16776960){const r=i,s=[1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],a=new ct;a.setAttribute("position",new De(s,3)),a.computeBoundingSphere(),super(a,new Ni({color:r,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;const o=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],l=new ct;l.setAttribute("position",new De(o,3)),l.computeBoundingSphere(),this.add(new Ft(l,new Yr({color:r,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}const Bx=new N;let Ah,$m;class p2 extends _t{constructor(e=new N(0,0,1),t=new N(0,0,0),i=1,r=16776960,s=i*.2,a=s*.2){super(),this.type="ArrowHelper",Ah===void 0&&(Ah=new ct,Ah.setAttribute("position",new De([0,0,0,0,1,0],3)),$m=new da(0,.5,1,5,1),$m.translate(0,-.5,0)),this.position.copy(t),this.line=new Cn(Ah,new Ni({color:r,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Ft($m,new Yr({color:r,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(i,s,a)}setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{Bx.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(Bx,t)}}setLength(e,t=e*.2,i=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(i,t,i),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}let zx=class extends $r{constructor(n=1){const e=[0,0,0,n,0,0,0,0,0,0,n,0,0,0,0,0,0,n],t=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new ct;i.setAttribute("position",new De(e,3)),i.setAttribute("color",new De(t,3));const r=new Ni({vertexColors:!0,toneMapped:!1});super(i,r),this.type="AxesHelper"}setColors(n,e,t){const i=new xe,r=this.geometry.attributes.color.array;return i.set(n),i.toArray(r,0),i.toArray(r,3),i.set(e),i.toArray(r,6),i.toArray(r,9),i.set(t),i.toArray(r,12),i.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}};class kx{constructor(){this.type="ShapePath",this.color=new xe,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Ml,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,i,r){return this.currentPath.quadraticCurveTo(e,t,i,r),this}bezierCurveTo(e,t,i,r,s,a){return this.currentPath.bezierCurveTo(e,t,i,r,s,a),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(g){const x=[];for(let y=0,_=g.length;y<_;y++){const I=g[y],b=new rs;b.curves=I.curves,x.push(b)}return x}function i(g,x){const y=x.length;let _=!1;for(let I=y-1,b=0;b<y;I=b++){let w=x[I],C=x[b],H=C.x-w.x,M=C.y-w.y;if(Math.abs(M)>Number.EPSILON){if(M<0&&(w=x[b],H=-H,C=x[I],M=-M),g.y<w.y||g.y>C.y)continue;if(g.y===w.y){if(g.x===w.x)return!0}else{const T=M*(g.x-w.x)-H*(g.y-w.y);if(T===0)return!0;if(T<0)continue;_=!_}}else{if(g.y!==w.y)continue;if(C.x<=g.x&&g.x<=w.x||w.x<=g.x&&g.x<=C.x)return!0}}return _}const r=nn.isClockWise,s=this.subPaths;if(s.length===0)return[];let a,o,l;const c=[];if(s.length===1)return o=s[0],l=new rs,l.curves=o.curves,c.push(l),c;let u=!r(s[0].getPoints());u=e?!u:u;const h=[],d=[];let p=[],m=0,v;d[m]=void 0,p[m]=[];for(let g=0,x=s.length;g<x;g++)o=s[g],v=o.getPoints(),a=r(v),a=e?!a:a,a?(!u&&d[m]&&m++,d[m]={s:new rs,p:v},d[m].s.curves=o.curves,u&&m++,p[m]=[]):p[m].push({h:o,p:v[0]});if(!d[0])return t(s);if(d.length>1){let g=!1,x=0;for(let y=0,_=d.length;y<_;y++)h[y]=[];for(let y=0,_=d.length;y<_;y++){const I=p[y];for(let b=0;b<I.length;b++){const w=I[b];let C=!0;for(let H=0;H<d.length;H++)i(w.p,d[H].p)&&(y!==H&&x++,C?(C=!1,h[H].push(w)):g=!0);C&&h[y].push(w)}}x>0&&g===!1&&(p=h)}let f;for(let g=0,x=d.length;g<x;g++){l=d[g].s,c.push(l),f=p[g];for(let y=0,_=f.length;y<_;y++)l.holes.push(f[y].h)}return c}}class Hx extends vr{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(){}disconnect(){}dispose(){}update(){}}class m2 extends Ir{constructor(e=1,t=1,i=1,r={}){console.warn('THREE.WebGLMultipleRenderTargets has been deprecated and will be removed in r172. Use THREE.WebGLRenderTarget and set the "count" parameter to enable MRT.'),super(e,t,{...r,count:i}),this.isWebGLMultipleRenderTargets=!0}get texture(){return this.textures}}const f2=["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 Gx{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=e.object.isSkinnedMesh===!0,this.refreshUniforms=f2,this.renderId=0}firstInitialization(e){return this.renderObjects.has(e)===!1?(this.getRenderObjectData(e),!0):!1}getRenderObjectData(e){let t=this.renderObjects.get(e);return t===void 0&&(t={material:this.getMaterialData(e.material),worldMatrix:e.object.matrixWorld.clone()},e.object.center&&(t.center=e.object.center.clone()),e.object.morphTargetInfluences&&(t.morphTargetInfluences=e.object.morphTargetInfluences.slice()),e.bundle!==null&&(t.version=e.bundle.version),this.renderObjects.set(e,t)),t}containsNode(e){const t=e.material;for(const i in t)if(t[i]&&t[i].isNode)return!0;return e.renderer.nodes.modelViewMatrix!==null||e.renderer.nodes.modelNormalViewMatrix!==null}getMaterialData(e){const t={};for(const i of this.refreshUniforms){const r=e[i];r!=null&&(typeof r=="object"&&r.clone!==void 0?r.isTexture===!0?t[i]={id:r.id,version:r.version}:t[i]=r.clone():t[i]=r)}return t}equals(e){const{object:t,material:i}=e,r=this.getRenderObjectData(e);if(r.worldMatrix.equals(t.matrixWorld)!==!0)return r.worldMatrix.copy(t.matrixWorld),!1;const s=r.material;for(const a in s){const o=s[a],l=i[a];if(o.equals!==void 0){if(o.equals(l)===!1)return o.copy(l),!1}else if(l.isTexture===!0){if(o.id!==l.id||o.version!==l.version)return o.id=l.id,o.version=l.version,!1}else if(o!==l)return s[a]=l,!1}if(r.morphTargetInfluences){let a=!1;for(let o=0;o<r.morphTargetInfluences.length;o++)r.morphTargetInfluences[o]!==t.morphTargetInfluences[o]&&(a=!0);if(a)return!0}return r.center&&r.center.equals(t.center)===!1?(r.center.copy(t.center),!0):(e.bundle!==null&&(r.version=e.bundle.version),!0)}needsRefresh(e,t){if(this.hasNode||this.hasAnimation||this.firstInitialization(e))return!0;const{renderId:i}=t;if(this.renderId!==i)return this.renderId=i,!0;const r=e.object.static===!0,s=e.bundle!==null&&e.bundle.static===!0&&this.getRenderObjectData(e).version===e.bundle.version;return r||s?!1:this.equals(e)!==!0}}function Cl(n,e=0){let t=3735928559^e,i=1103547991^e;if(n instanceof Array)for(let r=0,s;r<n.length;r++)s=n[r],t=Math.imul(t^s,2654435761),i=Math.imul(i^s,1597334677);else for(let r=0,s;r<n.length;r++)s=n.charCodeAt(r),t=Math.imul(t^s,2654435761),i=Math.imul(i^s,1597334677);return t=Math.imul(t^t>>>16,2246822507),t^=Math.imul(i^i>>>13,3266489909),i=Math.imul(i^i>>>16,2246822507),i^=Math.imul(t^t>>>13,3266489909),4294967296*(2097151&i)+(t>>>0)}const Wx=n=>Cl(n),jx=n=>Cl(n),Jm=(...n)=>Cl(n);function Km(n,e=!1){const t=[];n.isNode===!0&&(t.push(n.id),n=n.getSelf());for(const{property:i,childNode:r}of Rl(n))t.push(t,Cl(i.slice(0,-4)),r.getCacheKey(e));return Cl(t)}function*Rl(n,e=!1){for(const t in n){if(t.startsWith("_")===!0)continue;const i=n[t];if(Array.isArray(i)===!0)for(let r=0;r<i.length;r++){const s=i[r];s&&(s.isNode===!0||e&&typeof s.toJSON=="function")&&(yield{property:t,index:r,childNode:s})}else if(i&&i.isNode===!0)yield{property:t,childNode:i};else if(typeof i=="object")for(const r in i){const s=i[r];s&&(s.isNode===!0||e&&typeof s.toJSON=="function")&&(yield{property:t,index:r,childNode:s})}}}function Ln(n){if(n==null)return null;const e=typeof n;return n.isNode===!0?"node":e==="number"?"float":e==="boolean"?"bool":e==="string"?"string":e==="function"?"shader":n.isVector2===!0?"vec2":n.isVector3===!0?"vec3":n.isVector4===!0?"vec4":n.isMatrix3===!0?"mat3":n.isMatrix4===!0?"mat4":n.isColor===!0?"color":n instanceof ArrayBuffer?"ArrayBuffer":null}function Zm(n,...e){const t=n?n.slice(-4):void 0;return e.length===1&&(t==="vec2"?e=[e[0],e[0]]:t==="vec3"?e=[e[0],e[0],e[0]]:t==="vec4"&&(e=[e[0],e[0],e[0],e[0]])),n==="color"?new xe(...e):t==="vec2"?new J(...e):t==="vec3"?new N(...e):t==="vec4"?new st(...e):t==="mat3"?new Ke(...e):t==="mat4"?new Re(...e):n==="bool"?e[0]||!1:n==="float"||n==="int"||n==="uint"?e[0]||0:n==="string"?e[0]||"":n==="ArrayBuffer"?ef(e[0]):null}function Qm(n){let e="";const t=new Uint8Array(n);for(let i=0;i<t.length;i++)e+=String.fromCharCode(t[i]);return btoa(e)}function ef(n){return Uint8Array.from(atob(n),e=>e.charCodeAt(0)).buffer}var g2=Object.freeze({__proto__:null,arrayBufferToBase64:Qm,base64ToArrayBuffer:ef,getCacheKey:Km,getNodeChildren:Rl,getValueFromType:Zm,getValueType:Ln,hash:Jm,hashArray:jx,hashString:Wx});const tf={VERTEX:"vertex",FRAGMENT:"fragment"},je={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},v2={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},rf=["fragment","vertex"],nf=["setup","analyze","generate"],sf=[...rf,"compute"],no=["x","y","z","w"];let y2=0;class qe extends vr{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=je.NONE,this.updateBeforeType=je.NONE,this.updateAfterType=je.NONE,this.uuid=au.generateUUID(),this.version=0,this._cacheKey=null,this._cacheKeyVersion=0,this.global=!1,this.isNode=!0,Object.defineProperty(this,"id",{value:y2++})}set needsUpdate(e){e===!0&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this.getSelf()),this}onFrameUpdate(e){return this.onUpdate(e,je.FRAME)}onRenderUpdate(e){return this.onUpdate(e,je.RENDER)}onObjectUpdate(e){return this.onUpdate(e,je.OBJECT)}onReference(e){return this.updateReference=e.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:e}of Rl(this))yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(const t of this.getChildren())t.traverse(e)}getCacheKey(e=!1){return e=e||this.version!==this._cacheKeyVersion,(e===!0||this._cacheKey===null)&&(this._cacheKey=Km(this,e),this._cacheKeyVersion=this.version),this._cacheKey}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){const t=this.getNodeType(e);return e.getElementType(t)}getNodeType(e){const t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){const t=this.getHash(e);return e.getNodeFromHash(t)||this}setup(e){const t=e.getNodeProperties(this);let i=0;for(const r of this.getChildren())t["node"+i++]=r;return null}analyze(e){if(e.increaseUsage(this)===1){const t=e.getNodeProperties(this);for(const i of Object.values(t))i&&i.isNode===!0&&i.build(e)}}generate(e,t){const{outputNode:i}=e.getNodeProperties(this);if(i&&i.isNode===!0)return i.build(e,t)}updateBefore(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(e,t=null){const i=this.getShared(e);if(this!==i)return i.build(e,t);e.addNode(this),e.addChain(this);let r=null;const s=e.getBuildStage();if(s==="setup"){this.updateReference(e);const a=e.getNodeProperties(this);if(a.initialized!==!0){const o=e.stack.nodes.length;a.initialized=!0,a.outputNode=this.setup(e),a.outputNode!==null&&e.stack.nodes.length;for(const l of Object.values(a))l&&l.isNode===!0&&l.build(e)}}else if(s==="analyze")this.analyze(e);else if(s==="generate")if(this.generate.length===1){const a=this.getNodeType(e),o=e.getDataFromNode(this);r=o.snippet,r===void 0?(r=this.generate(e)||"",o.snippet=r):o.flowCodes!==void 0&&e.context.nodeBlock!==void 0&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),r=e.format(r,a,t)}else r=this.generate(e,t)||"";return e.removeChain(this),r}getSerializeChildren(){return Rl(this)}serialize(e){const t=this.getSerializeChildren(),i={};for(const{property:r,index:s,childNode:a}of t)s!==void 0?(i[r]===void 0&&(i[r]=Number.isInteger(s)?[]:{}),i[r][s]=a.toJSON(e.meta).uuid):i[r]=a.toJSON(e.meta).uuid;Object.keys(i).length>0&&(e.inputNodes=i)}deserialize(e){if(e.inputNodes!==void 0){const t=e.meta.nodes;for(const i in e.inputNodes)if(Array.isArray(e.inputNodes[i])){const r=[];for(const s of e.inputNodes[i])r.push(t[s]);this[i]=r}else if(typeof e.inputNodes[i]=="object"){const r={};for(const s in e.inputNodes[i]){const a=e.inputNodes[i][s];r[s]=t[a]}this[i]=r}else{const r=e.inputNodes[i];this[i]=t[r]}}}toJSON(e){const{uuid:t,type:i}=this,r=e===void 0||typeof e=="string";r&&(e={textures:{},images:{},nodes:{}});let s=e.nodes[t];s===void 0&&(s={uuid:t,type:i,meta:e,metadata:{version:4.6,type:"Node",generator:"Node.toJSON"}},r!==!0&&(e.nodes[s.uuid]=s),this.serialize(s),delete s.meta);function a(o){const l=[];for(const c in o){const u=o[c];delete u.metadata,l.push(u)}return l}if(r){const o=a(e.textures),l=a(e.images),c=a(e.nodes);o.length>0&&(s.textures=o),l.length>0&&(s.images=l),c.length>0&&(s.nodes=c)}return s}}class as extends qe{static get type(){return"ArrayElementNode"}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}generate(e){const t=this.node.build(e),i=this.indexNode.build(e,"uint");return`${t}[ ${i} ]`}}class af extends qe{static get type(){return"ConvertNode"}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){const t=this.node.getNodeType(e);let i=null;for(const r of this.convertTo.split("|"))(i===null||e.getTypeLength(t)===e.getTypeLength(r))&&(i=r);return i}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){const i=this.node,r=this.getNodeType(e),s=i.build(e,r);return e.format(s,r,t)}}class pt extends qe{static get type(){return"TempNode"}constructor(e){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if(e.getBuildStage()==="generate"){const i=e.getVectorType(this.getNodeType(e,t)),r=e.getDataFromNode(this);if(r.propertyName!==void 0)return e.format(r.propertyName,i,t);if(i!=="void"&&t!=="void"&&this.hasDependencies(e)){const s=super.build(e,i),a=e.getVarFromNode(this,null,i),o=e.getPropertyName(a);return e.addLineFlowCode(`${o} = ${s}`,this),r.snippet=s,r.propertyName=o,e.format(r.propertyName,i,t)}}return super.build(e,t)}}class Xx extends pt{static get type(){return"JoinNode"}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return this.nodeType!==null?e.getVectorType(this.nodeType):e.getTypeFromLength(this.nodes.reduce((t,i)=>t+e.getTypeLength(i.getNodeType(e)),0))}generate(e,t){const i=this.getNodeType(e),r=this.nodes,s=e.getComponentType(i),a=[];for(const l of r){let c=l.build(e);const u=e.getComponentType(l.getNodeType(e));u!==s&&(c=e.format(c,u,s)),a.push(c)}const o=`${e.getType(i)}( ${a.join(", ")} )`;return e.format(o,i,t)}}const x2=no.join("");class Nh extends qe{static get type(){return"SplitNode"}constructor(e,t="x"){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(const t of this.components)e=Math.max(no.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}generate(e,t){const i=this.node,r=e.getTypeLength(i.getNodeType(e));let s=null;if(r>1){let a=null;this.getVectorLength()>=r&&(a=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));const o=i.build(e,a);this.components.length===r&&this.components===x2.slice(0,this.components.length)?s=e.format(o,a,t):s=e.format(`${o}.${this.components}`,this.getNodeType(e),t)}else s=i.build(e,t);return s}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}}class qx extends pt{static get type(){return"SetNode"}constructor(e,t,i){super(),this.sourceNode=e,this.components=t,this.targetNode=i}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{sourceNode:t,components:i,targetNode:r}=this,s=this.getNodeType(e),a=e.getTypeFromLength(i.length,r.getNodeType(e)),o=r.build(e,a),l=t.build(e,s),c=e.getTypeLength(s),u=[];for(let h=0;h<c;h++){const d=no[h];d===i[0]?(u.push(o),h+=i.length-1):u.push(l+"."+d)}return`${e.getType(s)}( ${u.join(", ")} )`}}class _2 extends pt{static get type(){return"FlipNode"}constructor(e,t){super(),this.sourceNode=e,this.components=t}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{components:t,sourceNode:i}=this,r=this.getNodeType(e),s=i.build(e),a=e.getVarFromNode(this),o=e.getPropertyName(a);e.addLineFlowCode(o+" = "+s,this);const l=e.getTypeLength(r),c=[];let u=0;for(let h=0;h<l;h++){const d=no[h];d===t[u]?(c.push("1.0 - "+(o+"."+d)),u++):c.push(o+"."+d)}return`${e.getType(r)}( ${c.join(", ")} )`}}class of extends qe{static get type(){return"InputNode"}constructor(e,t=null){super(t),this.isInputNode=!0,this.value=e,this.precision=null}getNodeType(){return this.nodeType===null?Ln(this.value):this.nodeType}getInputType(e){return this.getNodeType(e)}setPrecision(e){return this.precision=e,this}serialize(e){super.serialize(e),e.value=this.value,this.value&&this.value.toArray&&(e.value=this.value.toArray()),e.valueType=Ln(this.value),e.nodeType=this.nodeType,e.valueType==="ArrayBuffer"&&(e.value=Qm(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?Zm(e.valueType,...e.value):e.value,this.precision=e.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(e.value))}generate(){console.warn("Abstract function.")}}class Fr extends of{static get type(){return"ConstNode"}constructor(e,t=null){super(e,t),this.isConstNode=!0}generateConst(e){return e.generateConst(this.getNodeType(e),this.value)}generate(e,t){const i=this.getNodeType(e);return e.format(this.generateConst(e),i,t)}}let so=null;const ao=new Map;function te(n,e){if(ao.has(n)){console.warn(`Redefinition of method chaining ${n}`);return}if(typeof e!="function")throw new Error(`Node element ${n} is not a function`);ao.set(n,e)}const Yx=n=>n.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),$x=n=>Yx(n).split("").sort().join(""),Jx={setup(n,e){const t=e.shift();return n(Pl(t),...e)},get(n,e,t){if(typeof e=="string"&&n[e]===void 0){if(n.isStackNode!==!0&&e==="assign")return(...i)=>(so.assign(t,...i),t);if(ao.has(e)){const i=ao.get(e);return n.isStackNode?(...r)=>t.add(i(...r)):(...r)=>i(t,...r)}else{if(e==="self")return n;if(e.endsWith("Assign")&&ao.has(e.slice(0,e.length-6))){const i=ao.get(e.slice(0,e.length-6));return n.isStackNode?(...r)=>t.assign(r[0],i(...r)):(...r)=>t.assign(i(t,...r))}else{if(/^[xyzwrgbastpq]{1,4}$/.test(e)===!0)return e=Yx(e),G(new Nh(t,e));if(/^set[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=$x(e.slice(3).toLowerCase()),i=>G(new qx(n,e,i));if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=$x(e.slice(4).toLowerCase()),()=>G(new _2(G(n),e));if(e==="width"||e==="height"||e==="depth")return e==="width"?e="x":e==="height"?e="y":e==="depth"&&(e="z"),G(new Nh(n,e));if(/^\d+$/.test(e)===!0)return G(new as(t,new Fr(Number(e),"uint")))}}}return Reflect.get(n,e,t)},set(n,e,t,i){return typeof e=="string"&&n[e]===void 0&&(/^[xyzwrgbastpq]{1,4}$/.test(e)===!0||e==="width"||e==="height"||e==="depth"||/^\d+$/.test(e)===!0)?(i[e].assign(t),!0):Reflect.set(n,e,t,i)}},lf=new WeakMap,Kx=new WeakMap,M2=function(n,e=null){const t=Ln(n);if(t==="node"){let i=lf.get(n);return i===void 0&&(i=new Proxy(n,Jx),lf.set(n,i),lf.set(i,i)),i}else{if(e===null&&(t==="float"||t==="boolean")||t&&t!=="shader"&&t!=="string")return G(df(n,e));if(t==="shader")return U(n)}return n},b2=function(n,e=null){for(const t in n)n[t]=G(n[t],e);return n},T2=function(n,e=null){const t=n.length;for(let i=0;i<t;i++)n[i]=G(n[i],e);return n},S2=function(n,e=null,t=null,i=null){const r=s=>G(i!==null?Object.assign(s,i):s);return e===null?(...s)=>r(new n(...qs(s))):t!==null?(t=G(t),(...s)=>r(new n(e,...qs(s),t))):(...s)=>r(new n(e,...qs(s)))},w2=function(n,...e){return G(new n(...qs(e)))};class E2 extends qe{constructor(e,t){super(),this.shaderNode=e,this.inputNodes=t}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}call(e){const{shaderNode:t,inputNodes:i}=this,r=e.getNodeProperties(t);if(r.onceOutput)return r.onceOutput;let s=null;if(t.layout){let a=Kx.get(e.constructor);a===void 0&&(a=new WeakMap,Kx.set(e.constructor,a));let o=a.get(t);o===void 0&&(o=G(e.buildFunctionNode(t)),a.set(t,o)),e.currentFunctionNode!==null&&e.currentFunctionNode.includes.push(o),s=G(o.call(i))}else{const a=t.jsFunc,o=i!==null?a(i,e):a(e);s=G(o)}return t.once&&(r.onceOutput=s),s}getOutputNode(e){const t=e.getNodeProperties(this);return t.outputNode===null&&(t.outputNode=this.setupOutput(e)),t.outputNode}setup(e){return this.getOutputNode(e)}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}generate(e,t){return this.getOutputNode(e).build(e,t)}}class A2 extends qe{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1}setLayout(e){return this.layout=e,this}call(e=null){return Pl(e),G(new E2(this,e))}setup(){return this.call()}}const N2=[!1,!0],C2=[0,1,2,3],R2=[-1,-2],Zx=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],cf=new Map;for(const n of N2)cf.set(n,new Fr(n));const uf=new Map;for(const n of C2)uf.set(n,new Fr(n,"uint"));const hf=new Map([...uf].map(n=>new Fr(n.value,"int")));for(const n of R2)hf.set(n,new Fr(n,"int"));const Ch=new Map([...hf].map(n=>new Fr(n.value)));for(const n of Zx)Ch.set(n,new Fr(n));for(const n of Zx)Ch.set(-n,new Fr(-n));const Rh={bool:cf,uint:uf,ints:hf,float:Ch},Qx=new Map([...cf,...Ch]),df=(n,e)=>Qx.has(n)?Qx.get(n):n.isNode===!0?n:new Fr(n,e),I2=n=>{try{return n.getNodeType()}catch{return}},oi=function(n,e=null){return(...t)=>{if((t.length===0||!["bool","float","int","uint"].includes(n)&&t.every(r=>typeof r!="object"))&&(t=[Zm(n,...t)]),t.length===1&&e!==null&&e.has(t[0]))return G(e.get(t[0]));if(t.length===1){const r=df(t[0],n);return I2(r)===n?G(r):G(new af(r,n))}const i=t.map(r=>df(r));return G(new Xx(i,n))}},Il=n=>typeof n=="object"&&n!==null?n.value:n,e_=n=>n!=null?n.nodeType||n.convertTo||(typeof n=="string"?n:null):null;function Ll(n,e){return new Proxy(new A2(n,e),Jx)}const G=(n,e=null)=>M2(n,e),Pl=(n,e=null)=>new b2(n,e),qs=(n,e=null)=>new T2(n,e),K=(...n)=>new S2(...n),ge=(...n)=>new w2(...n),U=(n,e)=>{const t=new Ll(n,e),i=(...r)=>{let s;return Pl(r),r[0]&&r[0].isNode?s=[...r]:s=r[0],t.call(s)};return i.shaderNode=t,i.setLayout=r=>(t.setLayout(r),i),i.once=()=>(t.once=!0,i),i},L2=(...n)=>(console.warn("TSL.ShaderNode: tslFn() has been renamed to Fn()."),U(...n));te("toGlobal",n=>(n.global=!0,n));const Dl=n=>{so=n},pf=()=>so,Le=(...n)=>so.If(...n);function t_(n){return so&&so.add(n),n}te("append",t_);const i_=new oi("color"),E=new oi("float",Rh.float),P=new oi("int",Rh.ints),_e=new oi("uint",Rh.uint),os=new oi("bool",Rh.bool),z=new oi("vec2"),un=new oi("ivec2"),r_=new oi("uvec2"),n_=new oi("bvec2"),D=new oi("vec3"),s_=new oi("ivec3"),oo=new oi("uvec3"),mf=new oi("bvec3"),ae=new oi("vec4"),a_=new oi("ivec4"),o_=new oi("uvec4"),l_=new oi("bvec4"),Ul=new oi("mat2"),yi=new oi("mat3"),Ys=new oi("mat4"),P2=(n="")=>G(new Fr(n,"string")),D2=n=>G(new Fr(n,"ArrayBuffer"));te("toColor",i_),te("toFloat",E),te("toInt",P),te("toUint",_e),te("toBool",os),te("toVec2",z),te("toIVec2",un),te("toUVec2",r_),te("toBVec2",n_),te("toVec3",D),te("toIVec3",s_),te("toUVec3",oo),te("toBVec3",mf),te("toVec4",ae),te("toIVec4",a_),te("toUVec4",o_),te("toBVec4",l_),te("toMat2",Ul),te("toMat3",yi),te("toMat4",Ys);const c_=K(as),u_=(n,e)=>G(new af(G(n),e)),U2=(n,e)=>G(new Nh(G(n),e));te("element",c_),te("convert",u_);class ff extends qe{static get type(){return"UniformGroupNode"}constructor(e,t=!1,i=1){super("string"),this.name=e,this.version=0,this.shared=t,this.order=i,this.isUniformGroup=!0}set needsUpdate(e){e===!0&&this.version++}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}}const h_=n=>new ff(n),gf=(n,e=0)=>new ff(n,!0,e),O2=gf("frame"),xt=gf("render"),d_=h_("object");class $s extends of{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=d_}label(e){return this.name=e,this}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){const i=this.getSelf();return e=e.bind(i),super.onUpdate(r=>{const s=e(r,i);s!==void 0&&(this.value=s)},t)}generate(e,t){const i=this.getNodeType(e),r=this.getUniformHash(e);let s=e.getNodeFromHash(r);s===void 0&&(e.setHashNode(this,r),s=this);const a=s.getInputType(e),o=e.getUniformFromNode(s,a,e.shaderStage,this.name||e.context.label),l=e.getPropertyName(o);return e.context.label!==void 0&&delete e.context.label,e.format(l,i,t)}}const fe=(n,e)=>{const t=e_(e||n),i=n&&n.isNode===!0?n.node&&n.node.value||n.value:n;return G(new $s(i,t))};class Et extends qe{static get type(){return"PropertyNode"}constructor(e,t=null,i=!1){super(e),this.name=t,this.varying=i,this.isPropertyNode=!0}getHash(e){return this.name||super.getHash(e)}isGlobal(){return!0}generate(e){let t;return this.varying===!0?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}}const ar=(n,e)=>G(new Et(n,e)),Zr=(n,e)=>G(new Et(n,e,!0)),Nt=ge(Et,"vec4","DiffuseColor"),vf=ge(Et,"vec3","EmissiveColor"),hn=ge(Et,"float","Roughness"),Ol=ge(Et,"float","Metalness"),Ih=ge(Et,"float","Clearcoat"),Fl=ge(Et,"float","ClearcoatRoughness"),Js=ge(Et,"vec3","Sheen"),Lh=ge(Et,"float","SheenRoughness"),Ph=ge(Et,"float","Iridescence"),yf=ge(Et,"float","IridescenceIOR"),xf=ge(Et,"float","IridescenceThickness"),Dh=ge(Et,"float","AlphaT"),ls=ge(Et,"float","Anisotropy"),Vl=ge(Et,"vec3","AnisotropyT"),Ks=ge(Et,"vec3","AnisotropyB"),or=ge(Et,"color","SpecularColor"),Bl=ge(Et,"float","SpecularF90"),Uh=ge(Et,"float","Shininess"),_f=ge(Et,"vec4","Output"),Zs=ge(Et,"float","dashSize"),zl=ge(Et,"float","gapSize"),F2=ge(Et,"float","pointWidth"),kl=ge(Et,"float","IOR"),Oh=ge(Et,"float","Transmission"),Mf=ge(Et,"float","Thickness"),bf=ge(Et,"float","AttenuationDistance"),Tf=ge(Et,"color","AttenuationColor"),Sf=ge(Et,"float","Dispersion");class p_ extends pt{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t}hasDependencies(){return!1}getNodeType(e,t){return t!=="void"?this.targetNode.getNodeType(e):"void"}needsSplitAssign(e){const{targetNode:t}=this;if(e.isAvailable("swizzleAssign")===!1&&t.isSplitNode&&t.components.length>1){const i=e.getTypeLength(t.node.getNodeType(e));return no.join("").slice(0,i)!==t.components}return!1}generate(e,t){const{targetNode:i,sourceNode:r}=this,s=this.needsSplitAssign(e),a=i.getNodeType(e),o=i.context({assign:!0}).build(e),l=r.build(e,a),c=r.getNodeType(e),u=e.getDataFromNode(this);let h;if(u.initialized===!0)t!=="void"&&(h=o);else if(s){const d=e.getVarFromNode(this,null,a),p=e.getPropertyName(d);e.addLineFlowCode(`${p} = ${l}`,this);const m=i.node.context({assign:!0}).build(e);for(let v=0;v<i.components.length;v++){const f=i.components[v];e.addLineFlowCode(`${m}.${f} = ${p}[ ${v} ]`,this)}t!=="void"&&(h=o)}else h=`${o} = ${l}`,(t==="void"||c==="void")&&(e.addLineFlowCode(h,this),t!=="void"&&(h=o));return u.initialized=!0,e.format(h,a,t)}}const m_=K(p_);te("assign",m_);class f_ extends pt{static get type(){return"FunctionCallNode"}constructor(e=null,t={}){super(),this.functionNode=e,this.parameters=t}setParameters(e){return this.parameters=e,this}getParameters(){return this.parameters}getNodeType(e){return this.functionNode.getNodeType(e)}generate(e){const t=[],i=this.functionNode,r=i.getInputs(e),s=this.parameters;if(Array.isArray(s))for(let a=0;a<s.length;a++){const o=r[a],l=s[a];t.push(l.build(e,o.type))}else for(const a of r){const o=s[a.name];if(o!==void 0)t.push(o.build(e,a.type));else throw new Error(`FunctionCallNode: Input '${a.name}' not found in FunctionNode.`)}return`${i.build(e,"property")}( ${t.join(", ")} )`}}const g_=(n,...e)=>(e=e.length>1||e[0]&&e[0].isNode===!0?qs(e):Pl(e[0]),G(new f_(G(n),e)));te("call",g_);class Gt extends pt{static get type(){return"OperatorNode"}constructor(e,t,i,...r){if(super(),r.length>0){let s=new Gt(e,t,i);for(let a=0;a<r.length-1;a++)s=new Gt(e,s,r[a]);t=s,i=r[r.length-1]}this.op=e,this.aNode=t,this.bNode=i}getNodeType(e,t){const i=this.op,r=this.aNode,s=this.bNode,a=r.getNodeType(e),o=typeof s<"u"?s.getNodeType(e):null;if(a==="void"||o==="void")return"void";if(i==="%")return a;if(i==="~"||i==="&"||i==="|"||i==="^"||i===">>"||i==="<<")return e.getIntegerType(a);if(i==="!"||i==="=="||i==="&&"||i==="||"||i==="^^")return"bool";if(i==="<"||i===">"||i==="<="||i===">="){const l=t?e.getTypeLength(t):Math.max(e.getTypeLength(a),e.getTypeLength(o));return l>1?`bvec${l}`:"bool"}else return a==="float"&&e.isMatrix(o)?o:e.isMatrix(a)&&e.isVector(o)?e.getVectorFromMatrix(a):e.isVector(a)&&e.isMatrix(o)?e.getVectorFromMatrix(o):e.getTypeLength(o)>e.getTypeLength(a)?o:a}generate(e,t){const i=this.op,r=this.aNode,s=this.bNode,a=this.getNodeType(e,t);let o=null,l=null;a!=="void"?(o=r.getNodeType(e),l=typeof s<"u"?s.getNodeType(e):null,i==="<"||i===">"||i==="<="||i===">="||i==="=="?e.isVector(o)?l=o:o!==l&&(o=l="float"):i===">>"||i==="<<"?(o=a,l=e.changeComponentType(l,"uint")):e.isMatrix(o)&&e.isVector(l)?l=e.getVectorFromMatrix(o):e.isVector(o)&&e.isMatrix(l)?o=e.getVectorFromMatrix(l):o=l=a):o=l=a;const c=r.build(e,o),u=typeof s<"u"?s.build(e,l):null,h=e.getTypeLength(t),d=e.getFunctionOperator(i);if(t!=="void")return i==="<"&&h>1?e.useComparisonMethod?e.format(`${e.getMethod("lessThan",t)}( ${c}, ${u} )`,a,t):e.format(`( ${c} < ${u} )`,a,t):i==="<="&&h>1?e.useComparisonMethod?e.format(`${e.getMethod("lessThanEqual",t)}( ${c}, ${u} )`,a,t):e.format(`( ${c} <= ${u} )`,a,t):i===">"&&h>1?e.useComparisonMethod?e.format(`${e.getMethod("greaterThan",t)}( ${c}, ${u} )`,a,t):e.format(`( ${c} > ${u} )`,a,t):i===">="&&h>1?e.useComparisonMethod?e.format(`${e.getMethod("greaterThanEqual",t)}( ${c}, ${u} )`,a,t):e.format(`( ${c} >= ${u} )`,a,t):i==="!"||i==="~"?e.format(`(${i}${c})`,o,t):d?e.format(`${d}( ${c}, ${u} )`,a,t):e.format(`( ${c} ${i} ${u} )`,a,t);if(o!=="void")return d?e.format(`${d}( ${c}, ${u} )`,a,t):e.format(`${c} ${i} ${u}`,a,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}}const zt=K(Gt,"+"),Pt=K(Gt,"-"),lt=K(Gt,"*"),Qr=K(Gt,"/"),wf=K(Gt,"%"),v_=K(Gt,"=="),y_=K(Gt,"!="),x_=K(Gt,"<"),Ef=K(Gt,">"),__=K(Gt,"<="),M_=K(Gt,">="),b_=K(Gt,"&&"),T_=K(Gt,"||"),S_=K(Gt,"!"),w_=K(Gt,"^^"),E_=K(Gt,"&"),A_=K(Gt,"~"),N_=K(Gt,"|"),C_=K(Gt,"^"),R_=K(Gt,"<<"),I_=K(Gt,">>");te("add",zt),te("sub",Pt),te("mul",lt),te("div",Qr),te("modInt",wf),te("equal",v_),te("notEqual",y_),te("lessThan",x_),te("greaterThan",Ef),te("lessThanEqual",__),te("greaterThanEqual",M_),te("and",b_),te("or",T_),te("not",S_),te("xor",w_),te("bitAnd",E_),te("bitNot",A_),te("bitOr",N_),te("bitXor",C_),te("shiftLeft",R_),te("shiftRight",I_);const L_=(...n)=>(console.warn("TSL.OperatorNode: .remainder() has been renamed to .modInt()."),wf(...n));te("remainder",L_);class V extends pt{static get type(){return"MathNode"}constructor(e,t,i=null,r=null){super(),this.method=e,this.aNode=t,this.bNode=i,this.cNode=r}getInputType(e){const t=this.aNode.getNodeType(e),i=this.bNode?this.bNode.getNodeType(e):null,r=this.cNode?this.cNode.getNodeType(e):null,s=e.isMatrix(t)?0:e.getTypeLength(t),a=e.isMatrix(i)?0:e.getTypeLength(i),o=e.isMatrix(r)?0:e.getTypeLength(r);return s>a&&s>o?t:a>o?i:o>s?r:t}getNodeType(e){const t=this.method;return t===V.LENGTH||t===V.DISTANCE||t===V.DOT?"float":t===V.CROSS?"vec3":t===V.ALL?"bool":t===V.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):t===V.MOD?this.aNode.getNodeType(e):this.getInputType(e)}generate(e,t){const i=this.method,r=this.getNodeType(e),s=this.getInputType(e),a=this.aNode,o=this.bNode,l=this.cNode,c=e.renderer.isWebGLRenderer===!0;if(i===V.TRANSFORM_DIRECTION){let u=a,h=o;e.isMatrix(u.getNodeType(e))?h=ae(D(h),0):u=ae(D(u),0);const d=lt(u,h).xyz;return Mr(d).build(e,t)}else{if(i===V.NEGATE)return e.format("( - "+a.build(e,s)+" )",r,t);if(i===V.ONE_MINUS)return Pt(1,a).build(e,t);if(i===V.RECIPROCAL)return Qr(1,a).build(e,t);if(i===V.DIFFERENCE)return It(Pt(a,o)).build(e,t);{const u=[];return i===V.CROSS||i===V.MOD?u.push(a.build(e,r),o.build(e,r)):c&&i===V.STEP?u.push(a.build(e,e.getTypeLength(a.getNodeType(e))===1?"float":s),o.build(e,s)):c&&(i===V.MIN||i===V.MAX)||i===V.MOD?u.push(a.build(e,s),o.build(e,e.getTypeLength(o.getNodeType(e))===1?"float":s)):i===V.REFRACT?u.push(a.build(e,s),o.build(e,s),l.build(e,"float")):i===V.MIX?u.push(a.build(e,s),o.build(e,s),l.build(e,e.getTypeLength(l.getNodeType(e))===1?"float":s)):(u.push(a.build(e,s)),o!==null&&u.push(o.build(e,s)),l!==null&&u.push(l.build(e,s))),e.format(`${e.getMethod(i,r)}( ${u.join(", ")} )`,r,t)}}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}V.ALL="all",V.ANY="any",V.EQUALS="equals",V.RADIANS="radians",V.DEGREES="degrees",V.EXP="exp",V.EXP2="exp2",V.LOG="log",V.LOG2="log2",V.SQRT="sqrt",V.INVERSE_SQRT="inversesqrt",V.FLOOR="floor",V.CEIL="ceil",V.NORMALIZE="normalize",V.FRACT="fract",V.SIN="sin",V.COS="cos",V.TAN="tan",V.ASIN="asin",V.ACOS="acos",V.ATAN="atan",V.ABS="abs",V.SIGN="sign",V.LENGTH="length",V.NEGATE="negate",V.ONE_MINUS="oneMinus",V.DFDX="dFdx",V.DFDY="dFdy",V.ROUND="round",V.RECIPROCAL="reciprocal",V.TRUNC="trunc",V.FWIDTH="fwidth",V.BITCAST="bitcast",V.TRANSPOSE="transpose",V.ATAN2="atan2",V.MIN="min",V.MAX="max",V.MOD="mod",V.STEP="step",V.REFLECT="reflect",V.DISTANCE="distance",V.DIFFERENCE="difference",V.DOT="dot",V.CROSS="cross",V.POW="pow",V.TRANSFORM_DIRECTION="transformDirection",V.MIX="mix",V.CLAMP="clamp",V.REFRACT="refract",V.SMOOTHSTEP="smoothstep",V.FACEFORWARD="faceforward";const P_=E(1e-6),V2=E(1e6),Qs=E(Math.PI),B2=E(Math.PI*2),Af=K(V,V.ALL),D_=K(V,V.ANY),U_=K(V,V.EQUALS),O_=K(V,V.RADIANS),F_=K(V,V.DEGREES),Nf=K(V,V.EXP),Fh=K(V,V.EXP2),Cf=K(V,V.LOG),Hl=K(V,V.LOG2),en=K(V,V.SQRT),V_=K(V,V.INVERSE_SQRT),cs=K(V,V.FLOOR),Rf=K(V,V.CEIL),Mr=K(V,V.NORMALIZE),us=K(V,V.FRACT),Ci=K(V,V.SIN),br=K(V,V.COS),B_=K(V,V.TAN),z_=K(V,V.ASIN),Vh=K(V,V.ACOS),k_=K(V,V.ATAN),It=K(V,V.ABS),Gl=K(V,V.SIGN),ea=K(V,V.LENGTH),H_=K(V,V.NEGATE),G_=K(V,V.ONE_MINUS),W_=K(V,V.DFDX),j_=K(V,V.DFDY),X_=K(V,V.ROUND),q_=K(V,V.RECIPROCAL),If=K(V,V.TRUNC),Y_=K(V,V.FWIDTH),z2=K(V,V.BITCAST),$_=K(V,V.TRANSPOSE),J_=K(V,V.ATAN2),xi=K(V,V.MIN),ft=K(V,V.MAX),Bh=K(V,V.MOD),Wl=K(V,V.STEP),K_=K(V,V.REFLECT),Z_=K(V,V.DISTANCE),Q_=K(V,V.DIFFERENCE),qt=K(V,V.DOT),lo=K(V,V.CROSS),Ji=K(V,V.POW),Lf=K(V,V.POW,2),eM=K(V,V.POW,3),tM=K(V,V.POW,4),iM=K(V,V.TRANSFORM_DIRECTION),rM=n=>lt(Gl(n),Ji(It(n),1/3)),Pf=n=>qt(n,n),rt=K(V,V.MIX),li=(n,e=0,t=1)=>G(new V(V.CLAMP,G(n),G(e),G(t))),nM=n=>li(n),Df=K(V,V.REFRACT),Ki=K(V,V.SMOOTHSTEP),sM=K(V,V.FACEFORWARD),Uf=U(([n])=>{const e=43758.5453,t=qt(n.xy,z(12.9898,78.233)),i=Bh(t,Qs);return us(Ci(i).mul(e))}),aM=(n,e,t)=>rt(e,t,n),oM=(n,e,t)=>Ki(e,t,n);te("all",Af),te("any",D_),te("equals",U_),te("radians",O_),te("degrees",F_),te("exp",Nf),te("exp2",Fh),te("log",Cf),te("log2",Hl),te("sqrt",en),te("inverseSqrt",V_),te("floor",cs),te("ceil",Rf),te("normalize",Mr),te("fract",us),te("sin",Ci),te("cos",br),te("tan",B_),te("asin",z_),te("acos",Vh),te("atan",k_),te("abs",It),te("sign",Gl),te("length",ea),te("lengthSq",Pf),te("negate",H_),te("oneMinus",G_),te("dFdx",W_),te("dFdy",j_),te("round",X_),te("reciprocal",q_),te("trunc",If),te("fwidth",Y_),te("atan2",J_),te("min",xi),te("max",ft),te("mod",Bh),te("step",Wl),te("reflect",K_),te("distance",Z_),te("dot",qt),te("cross",lo),te("pow",Ji),te("pow2",Lf),te("pow3",eM),te("pow4",tM),te("transformDirection",iM),te("mix",aM),te("clamp",li),te("refract",Df),te("smoothstep",oM),te("faceForward",sM),te("difference",Q_),te("saturate",nM),te("cbrt",rM),te("transpose",$_),te("rand",Uf);class k2 extends qe{static get type(){return"ConditionalNode"}constructor(e,t,i=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=i}getNodeType(e){const t=this.ifNode.getNodeType(e);if(this.elseNode!==null){const i=this.elseNode.getNodeType(e);if(e.getTypeLength(i)>e.getTypeLength(t))return i}return t}setup(e){const t=this.condNode.cache(),i=this.ifNode.cache(),r=this.elseNode?this.elseNode.cache():null,s=e.context.nodeBlock;e.getDataFromNode(i).parentNodeBlock=s,r!==null&&(e.getDataFromNode(r).parentNodeBlock=s);const a=e.getNodeProperties(this);a.condNode=t,a.ifNode=i.context({nodeBlock:i}),a.elseNode=r?r.context({nodeBlock:r}):null}generate(e,t){const i=this.getNodeType(e),r=e.getDataFromNode(this);if(r.nodeProperty!==void 0)return r.nodeProperty;const{condNode:s,ifNode:a,elseNode:o}=e.getNodeProperties(this),l=t!=="void",c=l?ar(i).build(e):"";r.nodeProperty=c;const u=s.build(e,"bool");e.addFlowCode(`
|
|
3847
|
+
}`;class zR{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,i){if(this.texture===null){const r=new Wt,s=e.properties.get(r);s.__webglTexture=t.texture,(t.depthNear!=i.depthNear||t.depthFar!=i.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=r}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,i=new Pr({vertexShader:VR,fragmentShader:BR,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Ft(new ua(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class kR extends vr{constructor(e,t){super();const i=this;let r=null,s=1,a=null,o="local-floor",l=1,c=null,u=null,h=null,d=null,p=null,m=null;const v=new zR,f=t.getContextAttributes();let g=null,x=null;const y=[],_=[],I=new J;let b=null;const w=new di;w.layers.enable(1),w.viewport=new st;const C=new di;C.layers.enable(2),C.viewport=new st;const H=[w,C],M=new Yp;M.layers.enable(1),M.layers.enable(2);let T=null,k=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.controllerAutoUpdate=!0,this.getController=function(ie){let le=y[ie];return le===void 0&&(le=new $p,y[ie]=le),le.getTargetRaySpace()},this.getControllerGrip=function(ie){let le=y[ie];return le===void 0&&(le=new $p,y[ie]=le),le.getGripSpace()},this.getHand=function(ie){let le=y[ie];return le===void 0&&(le=new $p,y[ie]=le),le.getHandSpace()};function j(ie){const le=_.indexOf(ie.inputSource);if(le===-1)return;const Te=y[le];Te!==void 0&&(Te.update(ie.inputSource,ie.frame,c||a),Te.dispatchEvent({type:ie.type,data:ie.inputSource}))}function Y(){r.removeEventListener("select",j),r.removeEventListener("selectstart",j),r.removeEventListener("selectend",j),r.removeEventListener("squeeze",j),r.removeEventListener("squeezestart",j),r.removeEventListener("squeezeend",j),r.removeEventListener("end",Y),r.removeEventListener("inputsourceschange",re);for(let ie=0;ie<y.length;ie++){const le=_[ie];le!==null&&(_[ie]=null,y[ie]&&y[ie].disconnect(le))}T=null,k=null,v.reset(),e.setRenderTarget(g),p=null,d=null,h=null,r=null,x=null,et.stop(),i.isPresenting=!1,e.setPixelRatio(b),e.setSize(I.width,I.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(ie){s=ie,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(ie){o=ie,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(ie){c=ie},this.getBaseLayer=function(){return d!==null?d:p},this.getBinding=function(){return h},this.getFrame=function(){return m},this.getSession=function(){return r},this.setSession=async function(ie){if(r=ie,r!==null){if(g=e.getRenderTarget(),r.addEventListener("select",j),r.addEventListener("selectstart",j),r.addEventListener("selectend",j),r.addEventListener("squeeze",j),r.addEventListener("squeezestart",j),r.addEventListener("squeezeend",j),r.addEventListener("end",Y),r.addEventListener("inputsourceschange",re),f.xrCompatible!==!0&&await t.makeXRCompatible(),b=e.getPixelRatio(),e.getSize(I),typeof XRWebGLBinding<"u"&&"createProjectionLayer"in XRWebGLBinding.prototype){let le=null,Te=null,Se=null;f.depth&&(Se=f.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,le=f.stencil?Xn:jn,Te=f.stencil?Wn:Nr);const Ye={colorFormat:t.RGBA8,depthFormat:Se,scaleFactor:s};h=new XRWebGLBinding(r,t),d=h.createProjectionLayer(Ye),r.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),x=new Ir(d.textureWidth,d.textureHeight,{format:Ei,type:Wr,depthTexture:new Ds(d.textureWidth,d.textureHeight,Te,void 0,void 0,void 0,void 0,void 0,void 0,le),stencilBuffer:f.stencil,colorSpace:e.outputColorSpace,samples:f.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1})}else{const le={antialias:f.antialias,alpha:!0,depth:f.depth,stencil:f.stencil,framebufferScaleFactor:s};p=new XRWebGLLayer(r,t,le),r.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),x=new Ir(p.framebufferWidth,p.framebufferHeight,{format:Ei,type:Wr,colorSpace:e.outputColorSpace,stencilBuffer:f.stencil})}x.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await r.requestReferenceSpace(o),et.setContext(r),et.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return v.getDepthTexture()};function re(ie){for(let le=0;le<ie.removed.length;le++){const Te=ie.removed[le],Se=_.indexOf(Te);Se>=0&&(_[Se]=null,y[Se]&&y[Se].disconnect(Te))}for(let le=0;le<ie.added.length;le++){const Te=ie.added[le];let Se=_.indexOf(Te);if(Se===-1){for(let We=0;We<y.length;We++)if(We>=_.length){_.push(Te),Se=We;break}else if(_[We]===null){_[We]=Te,Se=We;break}if(Se===-1)break}const Ye=y[Se];Ye&&Ye.connect(Te)}}const $=new N,he=new N;function Q(ie,le,Te){$.setFromMatrixPosition(le.matrixWorld),he.setFromMatrixPosition(Te.matrixWorld);const Se=$.distanceTo(he),Ye=le.projectionMatrix.elements,We=Te.projectionMatrix.elements,ot=Ye[14]/(Ye[10]-1),ce=Ye[14]/(Ye[10]+1),ue=(Ye[9]+1)/Ye[5],L=(Ye[9]-1)/Ye[5],He=(Ye[8]-1)/Ye[0],pe=(We[8]+1)/We[0],Ue=ot*He,we=ot*pe,$e=Se/(-He+pe),Be=$e*-He;if(le.matrixWorld.decompose(ie.position,ie.quaternion,ie.scale),ie.translateX(Be),ie.translateZ($e),ie.matrixWorld.compose(ie.position,ie.quaternion,ie.scale),ie.matrixWorldInverse.copy(ie.matrixWorld).invert(),Ye[10]===-1)ie.projectionMatrix.copy(le.projectionMatrix),ie.projectionMatrixInverse.copy(le.projectionMatrixInverse);else{const R=ot+$e,S=ce+$e,W=Ue-Be,ne=we+(Se-Be),de=ue*ce/S*R,se=L*ce/S*R;ie.projectionMatrix.makePerspective(W,ne,de,se,R,S),ie.projectionMatrixInverse.copy(ie.projectionMatrix).invert()}}function ye(ie,le){le===null?ie.matrixWorld.copy(ie.matrix):ie.matrixWorld.multiplyMatrices(le.matrixWorld,ie.matrix),ie.matrixWorldInverse.copy(ie.matrixWorld).invert()}this.updateCamera=function(ie){if(r===null)return;let le=ie.near,Te=ie.far;v.texture!==null&&(v.depthNear>0&&(le=v.depthNear),v.depthFar>0&&(Te=v.depthFar)),M.near=C.near=w.near=le,M.far=C.far=w.far=Te,(T!==M.near||k!==M.far)&&(r.updateRenderState({depthNear:M.near,depthFar:M.far}),T=M.near,k=M.far);const Se=ie.parent,Ye=M.cameras;ye(M,Se);for(let We=0;We<Ye.length;We++)ye(Ye[We],Se);Ye.length===2?Q(M,w,C):M.projectionMatrix.copy(w.projectionMatrix),be(ie,M,Se)};function be(ie,le,Te){Te===null?ie.matrix.copy(le.matrixWorld):(ie.matrix.copy(Te.matrixWorld),ie.matrix.invert(),ie.matrix.multiply(le.matrixWorld)),ie.matrix.decompose(ie.position,ie.quaternion,ie.scale),ie.updateMatrixWorld(!0),ie.projectionMatrix.copy(le.projectionMatrix),ie.projectionMatrixInverse.copy(le.projectionMatrixInverse),ie.isPerspectiveCamera&&(ie.fov=Sa*2*Math.atan(1/ie.projectionMatrix.elements[5]),ie.zoom=1)}this.getCamera=function(){return M},this.getFoveation=function(){if(!(d===null&&p===null))return l},this.setFoveation=function(ie){l=ie,d!==null&&(d.fixedFoveation=ie),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=ie)},this.hasDepthSensing=function(){return v.texture!==null},this.getDepthSensingMesh=function(){return v.getMesh(M)};let Ve=null;function at(ie,le){if(u=le.getViewerPose(c||a),m=le,u!==null){const Te=u.views;p!==null&&(e.setRenderTargetFramebuffer(x,p.framebuffer),e.setRenderTarget(x));let Se=!1;Te.length!==M.cameras.length&&(M.cameras.length=0,Se=!0);for(let We=0;We<Te.length;We++){const ot=Te[We];let ce=null;if(p!==null)ce=p.getViewport(ot);else{const L=h.getViewSubImage(d,ot);ce=L.viewport,We===0&&(e.setRenderTargetTextures(x,L.colorTexture,d.ignoreDepthValues?void 0:L.depthStencilTexture),e.setRenderTarget(x))}let ue=H[We];ue===void 0&&(ue=new di,ue.layers.enable(We),ue.viewport=new st,H[We]=ue),ue.matrix.fromArray(ot.transform.matrix),ue.matrix.decompose(ue.position,ue.quaternion,ue.scale),ue.projectionMatrix.fromArray(ot.projectionMatrix),ue.projectionMatrixInverse.copy(ue.projectionMatrix).invert(),ue.viewport.set(ce.x,ce.y,ce.width,ce.height),We===0&&(M.matrix.copy(ue.matrix),M.matrix.decompose(M.position,M.quaternion,M.scale)),Se===!0&&M.cameras.push(ue)}const Ye=r.enabledFeatures;if(Ye&&Ye.includes("depth-sensing")){const We=h.getDepthInformation(Te[0]);We&&We.isValid&&We.texture&&v.init(e,We,r.renderState)}}if(i.controllerAutoUpdate)for(let Te=0;Te<y.length;Te++){const Se=_[Te],Ye=y[Te];Se!==null&&Ye!==void 0&&Ye.update(Se,le,c||a)}Ve&&Ve(ie,le),le.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:le}),m=null}const et=new Lv;et.setAnimationLoop(at),this.setAnimationLoop=function(ie){Ve=ie},this.dispose=function(){}}}const Os=new dr,HR=new Re;function GR(n,e){function t(f,g){f.matrixAutoUpdate===!0&&f.updateMatrix(),g.value.copy(f.matrix)}function i(f,g){g.color.getRGB(f.fogColor.value,Cv(n)),g.isFog?(f.fogNear.value=g.near,f.fogFar.value=g.far):g.isFogExp2&&(f.fogDensity.value=g.density)}function r(f,g,x,y,_){g.isMeshBasicMaterial||g.isMeshLambertMaterial?s(f,g):g.isMeshToonMaterial?(s(f,g),h(f,g)):g.isMeshPhongMaterial?(s(f,g),u(f,g)):g.isMeshStandardMaterial?(s(f,g),d(f,g),g.isMeshPhysicalMaterial&&p(f,g,_)):g.isMeshMatcapMaterial?(s(f,g),m(f,g)):g.isMeshDepthMaterial?s(f,g):g.isMeshDistanceMaterial?(s(f,g),v(f,g)):g.isMeshNormalMaterial?s(f,g):g.isLineBasicMaterial?(a(f,g),g.isLineDashedMaterial&&o(f,g)):g.isPointsMaterial?l(f,g,x,y):g.isSpriteMaterial?c(f,g):g.isShadowMaterial?(f.color.value.copy(g.color),f.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function s(f,g){f.opacity.value=g.opacity,g.color&&f.diffuse.value.copy(g.color),g.emissive&&f.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(f.map.value=g.map,t(g.map,f.mapTransform)),g.alphaMap&&(f.alphaMap.value=g.alphaMap,t(g.alphaMap,f.alphaMapTransform)),g.bumpMap&&(f.bumpMap.value=g.bumpMap,t(g.bumpMap,f.bumpMapTransform),f.bumpScale.value=g.bumpScale,g.side===si&&(f.bumpScale.value*=-1)),g.normalMap&&(f.normalMap.value=g.normalMap,t(g.normalMap,f.normalMapTransform),f.normalScale.value.copy(g.normalScale),g.side===si&&f.normalScale.value.negate()),g.displacementMap&&(f.displacementMap.value=g.displacementMap,t(g.displacementMap,f.displacementMapTransform),f.displacementScale.value=g.displacementScale,f.displacementBias.value=g.displacementBias),g.emissiveMap&&(f.emissiveMap.value=g.emissiveMap,t(g.emissiveMap,f.emissiveMapTransform)),g.specularMap&&(f.specularMap.value=g.specularMap,t(g.specularMap,f.specularMapTransform)),g.alphaTest>0&&(f.alphaTest.value=g.alphaTest);const x=e.get(g),y=x.envMap,_=x.envMapRotation;y&&(f.envMap.value=y,Os.copy(_),Os.x*=-1,Os.y*=-1,Os.z*=-1,y.isCubeTexture&&y.isRenderTargetTexture===!1&&(Os.y*=-1,Os.z*=-1),f.envMapRotation.value.setFromMatrix4(HR.makeRotationFromEuler(Os)),f.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,f.reflectivity.value=g.reflectivity,f.ior.value=g.ior,f.refractionRatio.value=g.refractionRatio),g.lightMap&&(f.lightMap.value=g.lightMap,f.lightMapIntensity.value=g.lightMapIntensity,t(g.lightMap,f.lightMapTransform)),g.aoMap&&(f.aoMap.value=g.aoMap,f.aoMapIntensity.value=g.aoMapIntensity,t(g.aoMap,f.aoMapTransform))}function a(f,g){f.diffuse.value.copy(g.color),f.opacity.value=g.opacity,g.map&&(f.map.value=g.map,t(g.map,f.mapTransform))}function o(f,g){f.dashSize.value=g.dashSize,f.totalSize.value=g.dashSize+g.gapSize,f.scale.value=g.scale}function l(f,g,x,y){f.diffuse.value.copy(g.color),f.opacity.value=g.opacity,f.size.value=g.size*x,f.scale.value=y*.5,g.map&&(f.map.value=g.map,t(g.map,f.uvTransform)),g.alphaMap&&(f.alphaMap.value=g.alphaMap,t(g.alphaMap,f.alphaMapTransform)),g.alphaTest>0&&(f.alphaTest.value=g.alphaTest)}function c(f,g){f.diffuse.value.copy(g.color),f.opacity.value=g.opacity,f.rotation.value=g.rotation,g.map&&(f.map.value=g.map,t(g.map,f.mapTransform)),g.alphaMap&&(f.alphaMap.value=g.alphaMap,t(g.alphaMap,f.alphaMapTransform)),g.alphaTest>0&&(f.alphaTest.value=g.alphaTest)}function u(f,g){f.specular.value.copy(g.specular),f.shininess.value=Math.max(g.shininess,1e-4)}function h(f,g){g.gradientMap&&(f.gradientMap.value=g.gradientMap)}function d(f,g){f.metalness.value=g.metalness,g.metalnessMap&&(f.metalnessMap.value=g.metalnessMap,t(g.metalnessMap,f.metalnessMapTransform)),f.roughness.value=g.roughness,g.roughnessMap&&(f.roughnessMap.value=g.roughnessMap,t(g.roughnessMap,f.roughnessMapTransform)),g.envMap&&(f.envMapIntensity.value=g.envMapIntensity)}function p(f,g,x){f.ior.value=g.ior,g.sheen>0&&(f.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),f.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(f.sheenColorMap.value=g.sheenColorMap,t(g.sheenColorMap,f.sheenColorMapTransform)),g.sheenRoughnessMap&&(f.sheenRoughnessMap.value=g.sheenRoughnessMap,t(g.sheenRoughnessMap,f.sheenRoughnessMapTransform))),g.clearcoat>0&&(f.clearcoat.value=g.clearcoat,f.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(f.clearcoatMap.value=g.clearcoatMap,t(g.clearcoatMap,f.clearcoatMapTransform)),g.clearcoatRoughnessMap&&(f.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,t(g.clearcoatRoughnessMap,f.clearcoatRoughnessMapTransform)),g.clearcoatNormalMap&&(f.clearcoatNormalMap.value=g.clearcoatNormalMap,t(g.clearcoatNormalMap,f.clearcoatNormalMapTransform),f.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===si&&f.clearcoatNormalScale.value.negate())),g.dispersion>0&&(f.dispersion.value=g.dispersion),g.iridescence>0&&(f.iridescence.value=g.iridescence,f.iridescenceIOR.value=g.iridescenceIOR,f.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],f.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(f.iridescenceMap.value=g.iridescenceMap,t(g.iridescenceMap,f.iridescenceMapTransform)),g.iridescenceThicknessMap&&(f.iridescenceThicknessMap.value=g.iridescenceThicknessMap,t(g.iridescenceThicknessMap,f.iridescenceThicknessMapTransform))),g.transmission>0&&(f.transmission.value=g.transmission,f.transmissionSamplerMap.value=x.texture,f.transmissionSamplerSize.value.set(x.width,x.height),g.transmissionMap&&(f.transmissionMap.value=g.transmissionMap,t(g.transmissionMap,f.transmissionMapTransform)),f.thickness.value=g.thickness,g.thicknessMap&&(f.thicknessMap.value=g.thicknessMap,t(g.thicknessMap,f.thicknessMapTransform)),f.attenuationDistance.value=g.attenuationDistance,f.attenuationColor.value.copy(g.attenuationColor)),g.anisotropy>0&&(f.anisotropyVector.value.set(g.anisotropy*Math.cos(g.anisotropyRotation),g.anisotropy*Math.sin(g.anisotropyRotation)),g.anisotropyMap&&(f.anisotropyMap.value=g.anisotropyMap,t(g.anisotropyMap,f.anisotropyMapTransform))),f.specularIntensity.value=g.specularIntensity,f.specularColor.value.copy(g.specularColor),g.specularColorMap&&(f.specularColorMap.value=g.specularColorMap,t(g.specularColorMap,f.specularColorMapTransform)),g.specularIntensityMap&&(f.specularIntensityMap.value=g.specularIntensityMap,t(g.specularIntensityMap,f.specularIntensityMapTransform))}function m(f,g){g.matcap&&(f.matcap.value=g.matcap)}function v(f,g){const x=e.get(g).light;f.referencePosition.value.setFromMatrixPosition(x.matrixWorld),f.nearDistance.value=x.shadow.camera.near,f.farDistance.value=x.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function WR(n,e,t,i){let r={},s={},a=[];const o=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function l(x,y){const _=y.program;i.uniformBlockBinding(x,_)}function c(x,y){let _=r[x.id];_===void 0&&(m(x),_=u(x),r[x.id]=_,x.addEventListener("dispose",f));const I=y.program;i.updateUBOMapping(x,I);const b=e.render.frame;s[x.id]!==b&&(d(x),s[x.id]=b)}function u(x){const y=h();x.__bindingPointIndex=y;const _=n.createBuffer(),I=x.__size,b=x.usage;return n.bindBuffer(n.UNIFORM_BUFFER,_),n.bufferData(n.UNIFORM_BUFFER,I,b),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,y,_),_}function h(){for(let x=0;x<o;x++)if(a.indexOf(x)===-1)return a.push(x),x;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(x){const y=r[x.id],_=x.uniforms,I=x.__cache;n.bindBuffer(n.UNIFORM_BUFFER,y);for(let b=0,w=_.length;b<w;b++){const C=Array.isArray(_[b])?_[b]:[_[b]];for(let H=0,M=C.length;H<M;H++){const T=C[H];if(p(T,b,H,I)===!0){const k=T.__offset,j=Array.isArray(T.value)?T.value:[T.value];let Y=0;for(let re=0;re<j.length;re++){const $=j[re],he=v($);typeof $=="number"||typeof $=="boolean"?(T.__data[0]=$,n.bufferSubData(n.UNIFORM_BUFFER,k+Y,T.__data)):$.isMatrix3?(T.__data[0]=$.elements[0],T.__data[1]=$.elements[1],T.__data[2]=$.elements[2],T.__data[3]=0,T.__data[4]=$.elements[3],T.__data[5]=$.elements[4],T.__data[6]=$.elements[5],T.__data[7]=0,T.__data[8]=$.elements[6],T.__data[9]=$.elements[7],T.__data[10]=$.elements[8],T.__data[11]=0):($.toArray(T.__data,Y),Y+=he.storage/Float32Array.BYTES_PER_ELEMENT)}n.bufferSubData(n.UNIFORM_BUFFER,k,T.__data)}}}n.bindBuffer(n.UNIFORM_BUFFER,null)}function p(x,y,_,I){const b=x.value,w=y+"_"+_;if(I[w]===void 0)return typeof b=="number"||typeof b=="boolean"?I[w]=b:I[w]=b.clone(),!0;{const C=I[w];if(typeof b=="number"||typeof b=="boolean"){if(C!==b)return I[w]=b,!0}else if(C.equals(b)===!1)return C.copy(b),!0}return!1}function m(x){const y=x.uniforms;let _=0;const I=16;for(let w=0,C=y.length;w<C;w++){const H=Array.isArray(y[w])?y[w]:[y[w]];for(let M=0,T=H.length;M<T;M++){const k=H[M],j=Array.isArray(k.value)?k.value:[k.value];for(let Y=0,re=j.length;Y<re;Y++){const $=j[Y],he=v($),Q=_%I,ye=Q%he.boundary,be=Q+ye;_+=ye,be!==0&&I-be<he.storage&&(_+=I-be),k.__data=new Float32Array(he.storage/Float32Array.BYTES_PER_ELEMENT),k.__offset=_,_+=he.storage}}}const b=_%I;return b>0&&(_+=I-b),x.__size=_,x.__cache={},this}function v(x){const y={boundary:0,storage:0};return typeof x=="number"||typeof x=="boolean"?(y.boundary=4,y.storage=4):x.isVector2?(y.boundary=8,y.storage=8):x.isVector3||x.isColor?(y.boundary=16,y.storage=12):x.isVector4?(y.boundary=16,y.storage=16):x.isMatrix3?(y.boundary=48,y.storage=48):x.isMatrix4?(y.boundary=64,y.storage=64):x.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",x),y}function f(x){const y=x.target;y.removeEventListener("dispose",f);const _=a.indexOf(y.__bindingPointIndex);a.splice(_,1),n.deleteBuffer(r[y.id]),delete r[y.id],delete s[y.id]}function g(){for(const x in r)n.deleteBuffer(r[x]);a=[],r={},s={}}return{bind:l,update:c,dispose:g}}class oy{constructor(e={}){const{canvas:t=cv(),context:i=null,depth:r=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:h=!1}=e;this.isWebGLRenderer=!0;let d;if(i!==null){if(typeof WebGLRenderingContext<"u"&&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 v=null,f=null;const g=[],x=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Fi,this.toneMapping=mr,this.toneMappingExposure=1;const y=this;let _=!1,I=0,b=0,w=null,C=-1,H=null;const M=new st,T=new st;let k=null;const j=new xe(0);let Y=0,re=t.width,$=t.height,he=1,Q=null,ye=null;const be=new st(0,0,re,$),Ve=new st(0,0,re,$);let at=!1;const et=new za;let ie=!1,le=!1;const Te=new Re,Se=new Re,Ye=new N,We=new st,ot={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ce=!1;function ue(){return w===null?he:1}let L=i;function He(A,B){return t.getContext(A,B)}try{const A={alpha:!0,depth:r,stencil:s,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine","three.js r169"),t.addEventListener("webglcontextlost",oe,!1),t.addEventListener("webglcontextrestored",Ne,!1),t.addEventListener("webglcontextcreationerror",Ae,!1),L===null){const B="webgl2";if(L=He(B,A),L===null)throw He(B)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(A){throw console.error("THREE.WebGLRenderer: "+A.message),A}let pe,Ue,we,$e,Be,R,S,W,ne,de,se,ke,Ee,Pe,mt,ve,ze,tt,it,Oe,Mt,ut,Dt,O;function Ce(){pe=new JN(L),pe.init(),ut=new ay(L,pe),Ue=new jN(L,pe,e,ut),we=new RR(L),Ue.reverseDepthBuffer&&we.buffers.depth.setReversed(!0),$e=new QN(L),Be=new vR,R=new OR(L,pe,we,Be,Ue,ut,$e),S=new qN(y),W=new $N(y),ne=new oE(L),Dt=new GN(L,ne),de=new KN(L,ne,$e,Dt),se=new tC(L,de,ne,$e),it=new eC(L,Ue,R),ve=new XN(Be),ke=new gR(y,S,W,pe,Ue,Dt,ve),Ee=new GR(y,Be),Pe=new xR,mt=new wR(pe),tt=new HN(y,S,W,we,se,d,l),ze=new NR(y,se,Ue),O=new WR(L,$e,Ue,we),Oe=new WN(L,pe,$e),Mt=new ZN(L,pe,$e),$e.programs=ke.programs,y.capabilities=Ue,y.extensions=pe,y.properties=Be,y.renderLists=Pe,y.shadowMap=ze,y.state=we,y.info=$e}Ce();const ee=new kR(y,L);this.xr=ee,this.getContext=function(){return L},this.getContextAttributes=function(){return L.getContextAttributes()},this.forceContextLoss=function(){const A=pe.get("WEBGL_lose_context");A&&A.loseContext()},this.forceContextRestore=function(){const A=pe.get("WEBGL_lose_context");A&&A.restoreContext()},this.getPixelRatio=function(){return he},this.setPixelRatio=function(A){A!==void 0&&(he=A,this.setSize(re,$,!1))},this.getSize=function(A){return A.set(re,$)},this.setSize=function(A,B,X=!0){if(ee.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}re=A,$=B,t.width=Math.floor(A*he),t.height=Math.floor(B*he),X===!0&&(t.style.width=A+"px",t.style.height=B+"px"),this.setViewport(0,0,A,B)},this.getDrawingBufferSize=function(A){return A.set(re*he,$*he).floor()},this.setDrawingBufferSize=function(A,B,X){re=A,$=B,he=X,t.width=Math.floor(A*X),t.height=Math.floor(B*X),this.setViewport(0,0,A,B)},this.getCurrentViewport=function(A){return A.copy(M)},this.getViewport=function(A){return A.copy(be)},this.setViewport=function(A,B,X,q){A.isVector4?be.set(A.x,A.y,A.z,A.w):be.set(A,B,X,q),we.viewport(M.copy(be).multiplyScalar(he).round())},this.getScissor=function(A){return A.copy(Ve)},this.setScissor=function(A,B,X,q){A.isVector4?Ve.set(A.x,A.y,A.z,A.w):Ve.set(A,B,X,q),we.scissor(T.copy(Ve).multiplyScalar(he).round())},this.getScissorTest=function(){return at},this.setScissorTest=function(A){we.setScissorTest(at=A)},this.setOpaqueSort=function(A){Q=A},this.setTransparentSort=function(A){ye=A},this.getClearColor=function(A){return A.copy(tt.getClearColor())},this.setClearColor=function(){tt.setClearColor.apply(tt,arguments)},this.getClearAlpha=function(){return tt.getClearAlpha()},this.setClearAlpha=function(){tt.setClearAlpha.apply(tt,arguments)},this.clear=function(A=!0,B=!0,X=!0){let q=0;if(A){let F=!1;if(w!==null){const me=w.texture.format;F=me===Uc||me===Dc||me===Uo}if(F){const me=w.texture.type,Ie=me===Wr||me===Nr||me===fa||me===Wn||me===Lc||me===Pc,Fe=tt.getClearColor(),Ge=tt.getClearAlpha(),Qe=Fe.r,Ze=Fe.g,Je=Fe.b;Ie?(p[0]=Qe,p[1]=Ze,p[2]=Je,p[3]=Ge,L.clearBufferuiv(L.COLOR,0,p)):(m[0]=Qe,m[1]=Ze,m[2]=Je,m[3]=Ge,L.clearBufferiv(L.COLOR,0,m))}else q|=L.COLOR_BUFFER_BIT}B&&(q|=L.DEPTH_BUFFER_BIT,L.clearDepth(this.capabilities.reverseDepthBuffer?0:1)),X&&(q|=L.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),L.clear(q)},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",oe,!1),t.removeEventListener("webglcontextrestored",Ne,!1),t.removeEventListener("webglcontextcreationerror",Ae,!1),Pe.dispose(),mt.dispose(),Be.dispose(),S.dispose(),W.dispose(),se.dispose(),Dt.dispose(),O.dispose(),ke.dispose(),ee.dispose(),ee.removeEventListener("sessionstart",a0),ee.removeEventListener("sessionend",o0),gs.stop()};function oe(A){A.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),_=!0}function Ne(){console.log("THREE.WebGLRenderer: Context Restored."),_=!1;const A=$e.autoReset,B=ze.enabled,X=ze.autoUpdate,q=ze.needsUpdate,F=ze.type;Ce(),$e.autoReset=A,ze.enabled=B,ze.autoUpdate=X,ze.needsUpdate=q,ze.type=F}function Ae(A){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",A.statusMessage)}function Ut(A){const B=A.target;B.removeEventListener("dispose",Ut),ni(B)}function ni(A){tr(A),Be.remove(A)}function tr(A){const B=Be.get(A).programs;B!==void 0&&(B.forEach(function(X){ke.releaseProgram(X)}),A.isShaderMaterial&&ke.releaseShaderCache(A))}this.renderBufferDirect=function(A,B,X,q,F,me){B===null&&(B=ot);const Ie=F.isMesh&&F.matrixWorld.determinant()<0,Fe=YS(A,B,X,q,F);we.setMaterial(q,Ie);let Ge=X.index,Qe=1;if(q.wireframe===!0){if(Ge=de.getWireframeAttribute(X),Ge===void 0)return;Qe=2}const Ze=X.drawRange,Je=X.attributes.position;let Rt=Ze.start*Qe,jt=(Ze.start+Ze.count)*Qe;me!==null&&(Rt=Math.max(Rt,me.start*Qe),jt=Math.min(jt,(me.start+me.count)*Qe)),Ge!==null?(Rt=Math.max(Rt,0),jt=Math.min(jt,Ge.count)):Je!=null&&(Rt=Math.max(Rt,0),jt=Math.min(jt,Je.count));const Qt=jt-Rt;if(Qt<0||Qt===1/0)return;Dt.setup(F,q,Fe,X,Ge);let ci,Ht=Oe;if(Ge!==null&&(ci=ne.get(Ge),Ht=Mt,Ht.setIndex(ci)),F.isMesh)q.wireframe===!0?(we.setLineWidth(q.wireframeLinewidth*ue()),Ht.setMode(L.LINES)):Ht.setMode(L.TRIANGLES);else if(F.isLine){let Xe=q.linewidth;Xe===void 0&&(Xe=1),we.setLineWidth(Xe*ue()),F.isLineSegments?Ht.setMode(L.LINES):F.isLineLoop?Ht.setMode(L.LINE_LOOP):Ht.setMode(L.LINE_STRIP)}else F.isPoints?Ht.setMode(L.POINTS):F.isSprite&&Ht.setMode(L.TRIANGLES);if(F.isBatchedMesh)if(F._multiDrawInstances!==null)Ht.renderMultiDrawInstances(F._multiDrawStarts,F._multiDrawCounts,F._multiDrawCount,F._multiDrawInstances);else if(pe.get("WEBGL_multi_draw"))Ht.renderMultiDraw(F._multiDrawStarts,F._multiDrawCounts,F._multiDrawCount);else{const Xe=F._multiDrawStarts,Wi=F._multiDrawCounts,vs=F._multiDrawCount,Hr=Ge?ne.get(Ge).bytesPerElement:1,da=Be.get(q).currentProgram.getUniforms();for(let pr=0;pr<vs;pr++)da.setValue(L,"_gl_DrawID",pr),Ht.render(Xe[pr]/Hr,Wi[pr])}else if(F.isInstancedMesh)Ht.renderInstances(Rt,Qt,F.count);else if(X.isInstancedBufferGeometry){const Xe=X._maxInstanceCount!==void 0?X._maxInstanceCount:1/0,Wi=Math.min(X.instanceCount,Xe);Ht.renderInstances(Rt,Qt,Wi)}else Ht.render(Rt,Qt)};function At(A,B,X){A.transparent===!0&&A.side===Gr&&A.forceSinglePass===!1?(A.side=si,A.needsUpdate=!0,bc(A,B,X),A.side=an,A.needsUpdate=!0,bc(A,B,X),A.side=Gr):bc(A,B,X)}this.compile=function(A,B,X=null){X===null&&(X=A),f=mt.get(X),f.init(B),x.push(f),X.traverseVisible(function(F){F.isLight&&F.layers.test(B.layers)&&(f.pushLight(F),F.castShadow&&f.pushShadow(F))}),A!==X&&A.traverseVisible(function(F){F.isLight&&F.layers.test(B.layers)&&(f.pushLight(F),F.castShadow&&f.pushShadow(F))}),f.setupLights();const q=new Set;return A.traverse(function(F){if(!(F.isMesh||F.isPoints||F.isLine||F.isSprite))return;const me=F.material;if(me)if(Array.isArray(me))for(let Ie=0;Ie<me.length;Ie++){const Fe=me[Ie];At(Fe,X,F),q.add(Fe)}else At(me,X,F),q.add(me)}),x.pop(),f=null,q},this.compileAsync=function(A,B,X=null){const q=this.compile(A,B,X);return new Promise(F=>{function me(){if(q.forEach(function(Ie){Be.get(Ie).currentProgram.isReady()&&q.delete(Ie)}),q.size===0){F(A);return}setTimeout(me,10)}pe.get("KHR_parallel_shader_compile")!==null?me():setTimeout(me,10)})};let ir=null;function xn(A){ir&&ir(A)}function a0(){gs.stop()}function o0(){gs.start()}const gs=new Lv;gs.setAnimationLoop(xn),typeof self<"u"&&gs.setContext(self),this.setAnimationLoop=function(A){ir=A,ee.setAnimationLoop(A),A===null?gs.stop():gs.start()},ee.addEventListener("sessionstart",a0),ee.addEventListener("sessionend",o0),this.render=function(A,B){if(B!==void 0&&B.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(_===!0)return;if(A.matrixWorldAutoUpdate===!0&&A.updateMatrixWorld(),B.parent===null&&B.matrixWorldAutoUpdate===!0&&B.updateMatrixWorld(),ee.enabled===!0&&ee.isPresenting===!0&&(ee.cameraAutoUpdate===!0&&ee.updateCamera(B),B=ee.getCamera()),A.isScene===!0&&A.onBeforeRender(y,A,B,w),f=mt.get(A,x.length),f.init(B),x.push(f),Se.multiplyMatrices(B.projectionMatrix,B.matrixWorldInverse),et.setFromProjectionMatrix(Se),le=this.localClippingEnabled,ie=ve.init(this.clippingPlanes,le),v=Pe.get(A,g.length),v.init(),g.push(v),ee.enabled===!0&&ee.isPresenting===!0){const me=y.xr.getDepthSensingMesh();me!==null&&Fd(me,B,-1/0,y.sortObjects)}Fd(A,B,0,y.sortObjects),v.finish(),y.sortObjects===!0&&v.sort(Q,ye),ce=ee.enabled===!1||ee.isPresenting===!1||ee.hasDepthSensing()===!1,ce&&tt.addToRenderList(v,A),this.info.render.frame++,ie===!0&&ve.beginShadows();const X=f.state.shadowsArray;ze.render(X,A,B),ie===!0&&ve.endShadows(),this.info.autoReset===!0&&this.info.reset();const q=v.opaque,F=v.transmissive;if(f.setupLights(),B.isArrayCamera){const me=B.cameras;if(F.length>0)for(let Ie=0,Fe=me.length;Ie<Fe;Ie++){const Ge=me[Ie];c0(q,F,A,Ge)}ce&&tt.render(A);for(let Ie=0,Fe=me.length;Ie<Fe;Ie++){const Ge=me[Ie];l0(v,A,Ge,Ge.viewport)}}else F.length>0&&c0(q,F,A,B),ce&&tt.render(A),l0(v,A,B);w!==null&&(R.updateMultisampleRenderTarget(w),R.updateRenderTargetMipmap(w)),A.isScene===!0&&A.onAfterRender(y,A,B),Dt.resetDefaultState(),C=-1,H=null,x.pop(),x.length>0?(f=x[x.length-1],ie===!0&&ve.setGlobalState(y.clippingPlanes,f.state.camera)):f=null,g.pop(),g.length>0?v=g[g.length-1]:v=null};function Fd(A,B,X,q){if(A.visible===!1)return;if(A.layers.test(B.layers)){if(A.isGroup)X=A.renderOrder;else if(A.isLOD)A.autoUpdate===!0&&A.update(B);else if(A.isLight)f.pushLight(A),A.castShadow&&f.pushShadow(A);else if(A.isSprite){if(!A.frustumCulled||et.intersectsSprite(A)){q&&We.setFromMatrixPosition(A.matrixWorld).applyMatrix4(Se);const me=se.update(A),Ie=A.material;Ie.visible&&v.push(A,me,Ie,X,We.z,null)}}else if((A.isMesh||A.isLine||A.isPoints)&&(!A.frustumCulled||et.intersectsObject(A))){const me=se.update(A),Ie=A.material;if(q&&(A.boundingSphere!==void 0?(A.boundingSphere===null&&A.computeBoundingSphere(),We.copy(A.boundingSphere.center)):(me.boundingSphere===null&&me.computeBoundingSphere(),We.copy(me.boundingSphere.center)),We.applyMatrix4(A.matrixWorld).applyMatrix4(Se)),Array.isArray(Ie)){const Fe=me.groups;for(let Ge=0,Qe=Fe.length;Ge<Qe;Ge++){const Ze=Fe[Ge],Je=Ie[Ze.materialIndex];Je&&Je.visible&&v.push(A,me,Je,X,We.z,Ze)}}else Ie.visible&&v.push(A,me,Ie,X,We.z,null)}}const F=A.children;for(let me=0,Ie=F.length;me<Ie;me++)Fd(F[me],B,X,q)}function l0(A,B,X,q){const F=A.opaque,me=A.transmissive,Ie=A.transparent;f.setupLightsView(X),ie===!0&&ve.setGlobalState(y.clippingPlanes,X),q&&we.viewport(M.copy(q)),F.length>0&&Mc(F,B,X),me.length>0&&Mc(me,B,X),Ie.length>0&&Mc(Ie,B,X),we.buffers.depth.setTest(!0),we.buffers.depth.setMask(!0),we.buffers.color.setMask(!0),we.setPolygonOffset(!1)}function c0(A,B,X,q){if((X.isScene===!0?X.overrideMaterial:null)!==null)return;f.state.transmissionRenderTarget[q.id]===void 0&&(f.state.transmissionRenderTarget[q.id]=new Ir(1,1,{generateMipmaps:!0,type:pe.has("EXT_color_buffer_half_float")||pe.has("EXT_color_buffer_float")?wi:Wr,minFilter:ji,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:vt.workingColorSpace}));const F=f.state.transmissionRenderTarget[q.id],me=q.viewport||M;F.setSize(me.z,me.w);const Ie=y.getRenderTarget();y.setRenderTarget(F),y.getClearColor(j),Y=y.getClearAlpha(),Y<1&&y.setClearColor(16777215,.5),y.clear(),ce&&tt.render(X);const Fe=y.toneMapping;y.toneMapping=mr;const Ge=q.viewport;if(q.viewport!==void 0&&(q.viewport=void 0),f.setupLightsView(q),ie===!0&&ve.setGlobalState(y.clippingPlanes,q),Mc(A,X,q),R.updateMultisampleRenderTarget(F),R.updateRenderTargetMipmap(F),pe.has("WEBGL_multisampled_render_to_texture")===!1){let Qe=!1;for(let Ze=0,Je=B.length;Ze<Je;Ze++){const Rt=B[Ze],jt=Rt.object,Qt=Rt.geometry,ci=Rt.material,Ht=Rt.group;if(ci.side===Gr&&jt.layers.test(q.layers)){const Xe=ci.side;ci.side=si,ci.needsUpdate=!0,u0(jt,X,q,Qt,ci,Ht),ci.side=Xe,ci.needsUpdate=!0,Qe=!0}}Qe===!0&&(R.updateMultisampleRenderTarget(F),R.updateRenderTargetMipmap(F))}y.setRenderTarget(Ie),y.setClearColor(j,Y),Ge!==void 0&&(q.viewport=Ge),y.toneMapping=Fe}function Mc(A,B,X){const q=B.isScene===!0?B.overrideMaterial:null;for(let F=0,me=A.length;F<me;F++){const Ie=A[F],Fe=Ie.object,Ge=Ie.geometry,Qe=q===null?Ie.material:q,Ze=Ie.group;Fe.layers.test(X.layers)&&u0(Fe,B,X,Ge,Qe,Ze)}}function u0(A,B,X,q,F,me){A.onBeforeRender(y,B,X,q,F,me),A.modelViewMatrix.multiplyMatrices(X.matrixWorldInverse,A.matrixWorld),A.normalMatrix.getNormalMatrix(A.modelViewMatrix),F.onBeforeRender(y,B,X,q,A,me),F.transparent===!0&&F.side===Gr&&F.forceSinglePass===!1?(F.side=si,F.needsUpdate=!0,y.renderBufferDirect(X,B,q,F,A,me),F.side=an,F.needsUpdate=!0,y.renderBufferDirect(X,B,q,F,A,me),F.side=Gr):y.renderBufferDirect(X,B,q,F,A,me),A.onAfterRender(y,B,X,q,F,me)}function bc(A,B,X){B.isScene!==!0&&(B=ot);const q=Be.get(A),F=f.state.lights,me=f.state.shadowsArray,Ie=F.state.version,Fe=ke.getParameters(A,F.state,me,B,X),Ge=ke.getProgramCacheKey(Fe);let Qe=q.programs;q.environment=A.isMeshStandardMaterial?B.environment:null,q.fog=B.fog,q.envMap=(A.isMeshStandardMaterial?W:S).get(A.envMap||q.environment),q.envMapRotation=q.environment!==null&&A.envMap===null?B.environmentRotation:A.envMapRotation,Qe===void 0&&(A.addEventListener("dispose",Ut),Qe=new Map,q.programs=Qe);let Ze=Qe.get(Ge);if(Ze!==void 0){if(q.currentProgram===Ze&&q.lightsStateVersion===Ie)return d0(A,Fe),Ze}else Fe.uniforms=ke.getUniforms(A),A.onBuild(X,Fe,y),A.onBeforeCompile(Fe,y),Ze=ke.acquireProgram(Fe,Ge),Qe.set(Ge,Ze),q.uniforms=Fe.uniforms;const Je=q.uniforms;return(!A.isShaderMaterial&&!A.isRawShaderMaterial||A.clipping===!0)&&(Je.clippingPlanes=ve.uniform),d0(A,Fe),q.needsLights=JS(A),q.lightsStateVersion=Ie,q.needsLights&&(Je.ambientLightColor.value=F.state.ambient,Je.lightProbe.value=F.state.probe,Je.directionalLights.value=F.state.directional,Je.directionalLightShadows.value=F.state.directionalShadow,Je.spotLights.value=F.state.spot,Je.spotLightShadows.value=F.state.spotShadow,Je.rectAreaLights.value=F.state.rectArea,Je.ltc_1.value=F.state.rectAreaLTC1,Je.ltc_2.value=F.state.rectAreaLTC2,Je.pointLights.value=F.state.point,Je.pointLightShadows.value=F.state.pointShadow,Je.hemisphereLights.value=F.state.hemi,Je.directionalShadowMap.value=F.state.directionalShadowMap,Je.directionalShadowMatrix.value=F.state.directionalShadowMatrix,Je.spotShadowMap.value=F.state.spotShadowMap,Je.spotLightMatrix.value=F.state.spotLightMatrix,Je.spotLightMap.value=F.state.spotLightMap,Je.pointShadowMap.value=F.state.pointShadowMap,Je.pointShadowMatrix.value=F.state.pointShadowMatrix),q.currentProgram=Ze,q.uniformsList=null,Ze}function h0(A){if(A.uniformsList===null){const B=A.currentProgram.getUniforms();A.uniformsList=Lu.seqWithValue(B.seq,A.uniforms)}return A.uniformsList}function d0(A,B){const X=Be.get(A);X.outputColorSpace=B.outputColorSpace,X.batching=B.batching,X.batchingColor=B.batchingColor,X.instancing=B.instancing,X.instancingColor=B.instancingColor,X.instancingMorph=B.instancingMorph,X.skinning=B.skinning,X.morphTargets=B.morphTargets,X.morphNormals=B.morphNormals,X.morphColors=B.morphColors,X.morphTargetsCount=B.morphTargetsCount,X.numClippingPlanes=B.numClippingPlanes,X.numIntersection=B.numClipIntersection,X.vertexAlphas=B.vertexAlphas,X.vertexTangents=B.vertexTangents,X.toneMapping=B.toneMapping}function YS(A,B,X,q,F){B.isScene!==!0&&(B=ot),R.resetTextureUnits();const me=B.fog,Ie=q.isMeshStandardMaterial?B.environment:null,Fe=w===null?y.outputColorSpace:w.isXRRenderTarget===!0?w.texture.colorSpace:nr,Ge=(q.isMeshStandardMaterial?W:S).get(q.envMap||Ie),Qe=q.vertexColors===!0&&!!X.attributes.color&&X.attributes.color.itemSize===4,Ze=!!X.attributes.tangent&&(!!q.normalMap||q.anisotropy>0),Je=!!X.morphAttributes.position,Rt=!!X.morphAttributes.normal,jt=!!X.morphAttributes.color;let Qt=mr;q.toneMapped&&(w===null||w.isXRRenderTarget===!0)&&(Qt=y.toneMapping);const ci=X.morphAttributes.position||X.morphAttributes.normal||X.morphAttributes.color,Ht=ci!==void 0?ci.length:0,Xe=Be.get(q),Wi=f.state.lights;if(ie===!0&&(le===!0||A!==H)){const wr=A===H&&q.id===C;ve.setState(q,A,wr)}let vs=!1;q.version===Xe.__version?(Xe.needsLights&&Xe.lightsStateVersion!==Wi.state.version||Xe.outputColorSpace!==Fe||F.isBatchedMesh&&Xe.batching===!1||!F.isBatchedMesh&&Xe.batching===!0||F.isBatchedMesh&&Xe.batchingColor===!0&&F.colorTexture===null||F.isBatchedMesh&&Xe.batchingColor===!1&&F.colorTexture!==null||F.isInstancedMesh&&Xe.instancing===!1||!F.isInstancedMesh&&Xe.instancing===!0||F.isSkinnedMesh&&Xe.skinning===!1||!F.isSkinnedMesh&&Xe.skinning===!0||F.isInstancedMesh&&Xe.instancingColor===!0&&F.instanceColor===null||F.isInstancedMesh&&Xe.instancingColor===!1&&F.instanceColor!==null||F.isInstancedMesh&&Xe.instancingMorph===!0&&F.morphTexture===null||F.isInstancedMesh&&Xe.instancingMorph===!1&&F.morphTexture!==null||Xe.envMap!==Ge||q.fog===!0&&Xe.fog!==me||Xe.numClippingPlanes!==void 0&&(Xe.numClippingPlanes!==ve.numPlanes||Xe.numIntersection!==ve.numIntersection)||Xe.vertexAlphas!==Qe||Xe.vertexTangents!==Ze||Xe.morphTargets!==Je||Xe.morphNormals!==Rt||Xe.morphColors!==jt||Xe.toneMapping!==Qt||Xe.morphTargetsCount!==Ht)&&(vs=!0):(vs=!0,Xe.__version=q.version);let Hr=Xe.currentProgram;vs===!0&&(Hr=bc(q,B,F));let da=!1,pr=!1,Vd=!1;const ei=Hr.getUniforms(),Fn=Xe.uniforms;if(we.useProgram(Hr.program)&&(da=!0,pr=!0,Vd=!0),q.id!==C&&(C=q.id,pr=!0),da||H!==A){Ue.reverseDepthBuffer?(Te.copy(A.projectionMatrix),Pw(Te),Dw(Te),ei.setValue(L,"projectionMatrix",Te)):ei.setValue(L,"projectionMatrix",A.projectionMatrix),ei.setValue(L,"viewMatrix",A.matrixWorldInverse);const wr=ei.map.cameraPosition;wr!==void 0&&wr.setValue(L,Ye.setFromMatrixPosition(A.matrixWorld)),Ue.logarithmicDepthBuffer&&ei.setValue(L,"logDepthBufFC",2/(Math.log(A.far+1)/Math.LN2)),(q.isMeshPhongMaterial||q.isMeshToonMaterial||q.isMeshLambertMaterial||q.isMeshBasicMaterial||q.isMeshStandardMaterial||q.isShaderMaterial)&&ei.setValue(L,"isOrthographic",A.isOrthographicCamera===!0),H!==A&&(H=A,pr=!0,Vd=!0)}if(F.isSkinnedMesh){ei.setOptional(L,F,"bindMatrix"),ei.setOptional(L,F,"bindMatrixInverse");const wr=F.skeleton;wr&&(wr.boneTexture===null&&wr.computeBoneTexture(),ei.setValue(L,"boneTexture",wr.boneTexture,R))}F.isBatchedMesh&&(ei.setOptional(L,F,"batchingTexture"),ei.setValue(L,"batchingTexture",F._matricesTexture,R),ei.setOptional(L,F,"batchingIdTexture"),ei.setValue(L,"batchingIdTexture",F._indirectTexture,R),ei.setOptional(L,F,"batchingColorTexture"),F._colorsTexture!==null&&ei.setValue(L,"batchingColorTexture",F._colorsTexture,R));const Bd=X.morphAttributes;if((Bd.position!==void 0||Bd.normal!==void 0||Bd.color!==void 0)&&it.update(F,X,Hr),(pr||Xe.receiveShadow!==F.receiveShadow)&&(Xe.receiveShadow=F.receiveShadow,ei.setValue(L,"receiveShadow",F.receiveShadow)),q.isMeshGouraudMaterial&&q.envMap!==null&&(Fn.envMap.value=Ge,Fn.flipEnvMap.value=Ge.isCubeTexture&&Ge.isRenderTargetTexture===!1?-1:1),q.isMeshStandardMaterial&&q.envMap===null&&B.environment!==null&&(Fn.envMapIntensity.value=B.environmentIntensity),pr&&(ei.setValue(L,"toneMappingExposure",y.toneMappingExposure),Xe.needsLights&&$S(Fn,Vd),me&&q.fog===!0&&Ee.refreshFogUniforms(Fn,me),Ee.refreshMaterialUniforms(Fn,q,he,$,f.state.transmissionRenderTarget[A.id]),Lu.upload(L,h0(Xe),Fn,R)),q.isShaderMaterial&&q.uniformsNeedUpdate===!0&&(Lu.upload(L,h0(Xe),Fn,R),q.uniformsNeedUpdate=!1),q.isSpriteMaterial&&ei.setValue(L,"center",F.center),ei.setValue(L,"modelViewMatrix",F.modelViewMatrix),ei.setValue(L,"normalMatrix",F.normalMatrix),ei.setValue(L,"modelMatrix",F.matrixWorld),q.isShaderMaterial||q.isRawShaderMaterial){const wr=q.uniformsGroups;for(let zd=0,KS=wr.length;zd<KS;zd++){const p0=wr[zd];O.update(p0,Hr),O.bind(p0,Hr)}}return Hr}function $S(A,B){A.ambientLightColor.needsUpdate=B,A.lightProbe.needsUpdate=B,A.directionalLights.needsUpdate=B,A.directionalLightShadows.needsUpdate=B,A.pointLights.needsUpdate=B,A.pointLightShadows.needsUpdate=B,A.spotLights.needsUpdate=B,A.spotLightShadows.needsUpdate=B,A.rectAreaLights.needsUpdate=B,A.hemisphereLights.needsUpdate=B}function JS(A){return A.isMeshLambertMaterial||A.isMeshToonMaterial||A.isMeshPhongMaterial||A.isMeshStandardMaterial||A.isShadowMaterial||A.isShaderMaterial&&A.lights===!0}this.getActiveCubeFace=function(){return I},this.getActiveMipmapLevel=function(){return b},this.getRenderTarget=function(){return w},this.setRenderTargetTextures=function(A,B,X){Be.get(A.texture).__webglTexture=B,Be.get(A.depthTexture).__webglTexture=X;const q=Be.get(A);q.__hasExternalTextures=!0,q.__autoAllocateDepthBuffer=X===void 0,q.__autoAllocateDepthBuffer||pe.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),q.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(A,B){const X=Be.get(A);X.__webglFramebuffer=B,X.__useDefaultFramebuffer=B===void 0},this.setRenderTarget=function(A,B=0,X=0){w=A,I=B,b=X;let q=!0,F=null,me=!1,Ie=!1;if(A){const Fe=Be.get(A);if(Fe.__useDefaultFramebuffer!==void 0)we.bindFramebuffer(L.FRAMEBUFFER,null),q=!1;else if(Fe.__webglFramebuffer===void 0)R.setupRenderTarget(A);else if(Fe.__hasExternalTextures)R.rebindTextures(A,Be.get(A.texture).__webglTexture,Be.get(A.depthTexture).__webglTexture);else if(A.depthBuffer){const Ze=A.depthTexture;if(Fe.__boundDepthTexture!==Ze){if(Ze!==null&&Be.has(Ze)&&(A.width!==Ze.image.width||A.height!==Ze.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");R.setupDepthRenderbuffer(A)}}const Ge=A.texture;(Ge.isData3DTexture||Ge.isDataArrayTexture||Ge.isCompressedArrayTexture)&&(Ie=!0);const Qe=Be.get(A).__webglFramebuffer;A.isWebGLCubeRenderTarget?(Array.isArray(Qe[B])?F=Qe[B][X]:F=Qe[B],me=!0):A.samples>0&&R.useMultisampledRTT(A)===!1?F=Be.get(A).__webglMultisampledFramebuffer:Array.isArray(Qe)?F=Qe[X]:F=Qe,M.copy(A.viewport),T.copy(A.scissor),k=A.scissorTest}else M.copy(be).multiplyScalar(he).floor(),T.copy(Ve).multiplyScalar(he).floor(),k=at;if(we.bindFramebuffer(L.FRAMEBUFFER,F)&&q&&we.drawBuffers(A,F),we.viewport(M),we.scissor(T),we.setScissorTest(k),me){const Fe=Be.get(A.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_CUBE_MAP_POSITIVE_X+B,Fe.__webglTexture,X)}else if(Ie){const Fe=Be.get(A.texture),Ge=B||0;L.framebufferTextureLayer(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,Fe.__webglTexture,X||0,Ge)}C=-1},this.readRenderTargetPixels=function(A,B,X,q,F,me,Ie){if(!(A&&A.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Fe=Be.get(A).__webglFramebuffer;if(A.isWebGLCubeRenderTarget&&Ie!==void 0&&(Fe=Fe[Ie]),Fe){we.bindFramebuffer(L.FRAMEBUFFER,Fe);try{const Ge=A.texture,Qe=Ge.format,Ze=Ge.type;if(!Ue.textureFormatReadable(Qe)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Ue.textureTypeReadable(Ze)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}B>=0&&B<=A.width-q&&X>=0&&X<=A.height-F&&L.readPixels(B,X,q,F,ut.convert(Qe),ut.convert(Ze),me)}finally{const Ge=w!==null?Be.get(w).__webglFramebuffer:null;we.bindFramebuffer(L.FRAMEBUFFER,Ge)}}},this.readRenderTargetPixelsAsync=async function(A,B,X,q,F,me,Ie){if(!(A&&A.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Fe=Be.get(A).__webglFramebuffer;if(A.isWebGLCubeRenderTarget&&Ie!==void 0&&(Fe=Fe[Ie]),Fe){const Ge=A.texture,Qe=Ge.format,Ze=Ge.type;if(!Ue.textureFormatReadable(Qe))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Ue.textureTypeReadable(Ze))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(B>=0&&B<=A.width-q&&X>=0&&X<=A.height-F){we.bindFramebuffer(L.FRAMEBUFFER,Fe);const Je=L.createBuffer();L.bindBuffer(L.PIXEL_PACK_BUFFER,Je),L.bufferData(L.PIXEL_PACK_BUFFER,me.byteLength,L.STREAM_READ),L.readPixels(B,X,q,F,ut.convert(Qe),ut.convert(Ze),0);const Rt=w!==null?Be.get(w).__webglFramebuffer:null;we.bindFramebuffer(L.FRAMEBUFFER,Rt);const jt=L.fenceSync(L.SYNC_GPU_COMMANDS_COMPLETE,0);return L.flush(),await Lw(L,jt,4),L.bindBuffer(L.PIXEL_PACK_BUFFER,Je),L.getBufferSubData(L.PIXEL_PACK_BUFFER,0,me),L.deleteBuffer(Je),L.deleteSync(jt),me}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(A,B=null,X=0){A.isTexture!==!0&&(au("WebGLRenderer: copyFramebufferToTexture function signature has changed."),B=arguments[0]||null,A=arguments[1]);const q=Math.pow(2,-X),F=Math.floor(A.image.width*q),me=Math.floor(A.image.height*q),Ie=B!==null?B.x:0,Fe=B!==null?B.y:0;R.setTexture2D(A,0),L.copyTexSubImage2D(L.TEXTURE_2D,X,0,0,Ie,Fe,F,me),we.unbindTexture()},this.copyTextureToTexture=function(A,B,X=null,q=null,F=0){A.isTexture!==!0&&(au("WebGLRenderer: copyTextureToTexture function signature has changed."),q=arguments[0]||null,A=arguments[1],B=arguments[2],F=arguments[3]||0,X=null);let me,Ie,Fe,Ge,Qe,Ze;X!==null?(me=X.max.x-X.min.x,Ie=X.max.y-X.min.y,Fe=X.min.x,Ge=X.min.y):(me=A.image.width,Ie=A.image.height,Fe=0,Ge=0),q!==null?(Qe=q.x,Ze=q.y):(Qe=0,Ze=0);const Je=ut.convert(B.format),Rt=ut.convert(B.type);R.setTexture2D(B,0),L.pixelStorei(L.UNPACK_FLIP_Y_WEBGL,B.flipY),L.pixelStorei(L.UNPACK_PREMULTIPLY_ALPHA_WEBGL,B.premultiplyAlpha),L.pixelStorei(L.UNPACK_ALIGNMENT,B.unpackAlignment);const jt=L.getParameter(L.UNPACK_ROW_LENGTH),Qt=L.getParameter(L.UNPACK_IMAGE_HEIGHT),ci=L.getParameter(L.UNPACK_SKIP_PIXELS),Ht=L.getParameter(L.UNPACK_SKIP_ROWS),Xe=L.getParameter(L.UNPACK_SKIP_IMAGES),Wi=A.isCompressedTexture?A.mipmaps[F]:A.image;L.pixelStorei(L.UNPACK_ROW_LENGTH,Wi.width),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,Wi.height),L.pixelStorei(L.UNPACK_SKIP_PIXELS,Fe),L.pixelStorei(L.UNPACK_SKIP_ROWS,Ge),A.isDataTexture?L.texSubImage2D(L.TEXTURE_2D,F,Qe,Ze,me,Ie,Je,Rt,Wi.data):A.isCompressedTexture?L.compressedTexSubImage2D(L.TEXTURE_2D,F,Qe,Ze,Wi.width,Wi.height,Je,Wi.data):L.texSubImage2D(L.TEXTURE_2D,F,Qe,Ze,me,Ie,Je,Rt,Wi),L.pixelStorei(L.UNPACK_ROW_LENGTH,jt),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,Qt),L.pixelStorei(L.UNPACK_SKIP_PIXELS,ci),L.pixelStorei(L.UNPACK_SKIP_ROWS,Ht),L.pixelStorei(L.UNPACK_SKIP_IMAGES,Xe),F===0&&B.generateMipmaps&&L.generateMipmap(L.TEXTURE_2D),we.unbindTexture()},this.copyTextureToTexture3D=function(A,B,X=null,q=null,F=0){A.isTexture!==!0&&(au("WebGLRenderer: copyTextureToTexture3D function signature has changed."),X=arguments[0]||null,q=arguments[1]||null,A=arguments[2],B=arguments[3],F=arguments[4]||0);let me,Ie,Fe,Ge,Qe,Ze,Je,Rt,jt;const Qt=A.isCompressedTexture?A.mipmaps[F]:A.image;X!==null?(me=X.max.x-X.min.x,Ie=X.max.y-X.min.y,Fe=X.max.z-X.min.z,Ge=X.min.x,Qe=X.min.y,Ze=X.min.z):(me=Qt.width,Ie=Qt.height,Fe=Qt.depth,Ge=0,Qe=0,Ze=0),q!==null?(Je=q.x,Rt=q.y,jt=q.z):(Je=0,Rt=0,jt=0);const ci=ut.convert(B.format),Ht=ut.convert(B.type);let Xe;if(B.isData3DTexture)R.setTexture3D(B,0),Xe=L.TEXTURE_3D;else if(B.isDataArrayTexture||B.isCompressedArrayTexture)R.setTexture2DArray(B,0),Xe=L.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}L.pixelStorei(L.UNPACK_FLIP_Y_WEBGL,B.flipY),L.pixelStorei(L.UNPACK_PREMULTIPLY_ALPHA_WEBGL,B.premultiplyAlpha),L.pixelStorei(L.UNPACK_ALIGNMENT,B.unpackAlignment);const Wi=L.getParameter(L.UNPACK_ROW_LENGTH),vs=L.getParameter(L.UNPACK_IMAGE_HEIGHT),Hr=L.getParameter(L.UNPACK_SKIP_PIXELS),da=L.getParameter(L.UNPACK_SKIP_ROWS),pr=L.getParameter(L.UNPACK_SKIP_IMAGES);L.pixelStorei(L.UNPACK_ROW_LENGTH,Qt.width),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,Qt.height),L.pixelStorei(L.UNPACK_SKIP_PIXELS,Ge),L.pixelStorei(L.UNPACK_SKIP_ROWS,Qe),L.pixelStorei(L.UNPACK_SKIP_IMAGES,Ze),A.isDataTexture||A.isData3DTexture?L.texSubImage3D(Xe,F,Je,Rt,jt,me,Ie,Fe,ci,Ht,Qt.data):B.isCompressedArrayTexture?L.compressedTexSubImage3D(Xe,F,Je,Rt,jt,me,Ie,Fe,ci,Qt.data):L.texSubImage3D(Xe,F,Je,Rt,jt,me,Ie,Fe,ci,Ht,Qt),L.pixelStorei(L.UNPACK_ROW_LENGTH,Wi),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,vs),L.pixelStorei(L.UNPACK_SKIP_PIXELS,Hr),L.pixelStorei(L.UNPACK_SKIP_ROWS,da),L.pixelStorei(L.UNPACK_SKIP_IMAGES,pr),F===0&&B.generateMipmaps&&L.generateMipmap(Xe),we.unbindTexture()},this.initRenderTarget=function(A){Be.get(A).__webglFramebuffer===void 0&&R.setupRenderTarget(A)},this.initTexture=function(A){A.isCubeTexture?R.setTextureCube(A,0):A.isData3DTexture?R.setTexture3D(A,0):A.isDataArrayTexture||A.isCompressedArrayTexture?R.setTexture2DArray(A,0):R.setTexture2D(A,0),we.unbindTexture()},this.resetState=function(){I=0,b=0,w=null,we.reset(),Dt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Rr}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=e===qo?"display-p3":"srgb",t.unpackColorSpace=vt.workingColorSpace===ba?"display-p3":"srgb"}}class Ad{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new xe(e),this.density=t}clone(){return new Ad(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}let Jp=class XS{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new xe(e),this.near=t,this.far=i}clone(){return new XS(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}};class Uu extends _t{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new dr,this.environmentIntensity=1,this.environmentRotation=new dr,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class Wa{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Ta,this.updateRanges=[],this.version=0,this.uuid=yr()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let r=0,s=this.stride;r<s;r++)this.array[e+r]=t.array[i+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=yr()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=yr()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const $i=new N;class On{constructor(e,t,i,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,i=this.data.count;t<i;t++)$i.fromBufferAttribute(this,t),$i.applyMatrix4(e),this.setXYZ(t,$i.x,$i.y,$i.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)$i.fromBufferAttribute(this,t),$i.applyNormalMatrix(e),this.setXYZ(t,$i.x,$i.y,$i.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)$i.fromBufferAttribute(this,t),$i.transformDirection(e),this.setXYZ(t,$i.x,$i.y,$i.z);return this}getComponent(e,t){let i=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(i=Xi(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=ht(i,this.array)),this.data.array[e*this.data.stride+this.offset+t]=i,this}setX(e,t){return this.normalized&&(t=ht(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=ht(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=ht(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=ht(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=Xi(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Xi(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Xi(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Xi(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=ht(t,this.array),i=ht(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=ht(t,this.array),i=ht(i,this.array),r=ht(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this}setXYZW(e,t,i,r,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=ht(t,this.array),i=ht(i,this.array),r=ht(r,this.array),s=ht(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return new wt(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new On(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class cl extends hi{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new xe(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let ja;const ul=new N,Xa=new N,qa=new N,Ya=new J,hl=new J,ly=new Re,Ou=new N,dl=new N,Fu=new N,cy=new J,Kp=new J,uy=new J;class Zp extends _t{constructor(e=new cl){if(super(),this.isSprite=!0,this.type="Sprite",ja===void 0){ja=new ct;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new Wa(t,5);ja.setIndex([0,1,2,0,2,3]),ja.setAttribute("position",new On(i,3,0,!1)),ja.setAttribute("uv",new On(i,2,3,!1))}this.geometry=ja,this.material=e,this.center=new J(.5,.5)}raycast(e,t){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Xa.setFromMatrixScale(this.matrixWorld),ly.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),qa.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Xa.multiplyScalar(-qa.z);const i=this.material.rotation;let r,s;i!==0&&(s=Math.cos(i),r=Math.sin(i));const a=this.center;Vu(Ou.set(-.5,-.5,0),qa,a,Xa,r,s),Vu(dl.set(.5,-.5,0),qa,a,Xa,r,s),Vu(Fu.set(.5,.5,0),qa,a,Xa,r,s),cy.set(0,0),Kp.set(1,0),uy.set(1,1);let o=e.ray.intersectTriangle(Ou,dl,Fu,!1,ul);if(o===null&&(Vu(dl.set(-.5,.5,0),qa,a,Xa,r,s),Kp.set(0,1),o=e.ray.intersectTriangle(Ou,Fu,dl,!1,ul),o===null))return;const l=e.ray.origin.distanceTo(ul);l<e.near||l>e.far||t.push({distance:l,point:ul.clone(),uv:er.getInterpolation(ul,Ou,dl,Fu,cy,Kp,uy,new J),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function Vu(n,e,t,i,r,s){Ya.subVectors(n,t).addScalar(.5).multiply(i),r!==void 0?(hl.x=s*Ya.x-r*Ya.y,hl.y=r*Ya.x+s*Ya.y):hl.copy(Ya),n.copy(e),n.x+=hl.x,n.y+=hl.y,n.applyMatrix4(ly)}const Bu=new N,hy=new N;class Qp extends _t{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let i=0,r=t.length;i<r;i++){const s=t[i];this.addLevel(s.object.clone(),s.distance,s.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,i=0){t=Math.abs(t);const r=this.levels;let s;for(s=0;s<r.length&&!(t<r[s].distance);s++);return r.splice(s,0,{distance:t,hysteresis:i,object:e}),this.add(e),this}removeLevel(e){const t=this.levels;for(let i=0;i<t.length;i++)if(t[i].distance===e){const r=t.splice(i,1);return this.remove(r[0].object),!0}return!1}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){const t=this.levels;if(t.length>0){let i,r;for(i=1,r=t.length;i<r;i++){let s=t[i].distance;if(t[i].object.visible&&(s-=s*t[i].hysteresis),e<s)break}return t[i-1].object}return null}raycast(e,t){if(this.levels.length>0){Bu.setFromMatrixPosition(this.matrixWorld);const i=e.ray.origin.distanceTo(Bu);this.getObjectForDistance(i).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){Bu.setFromMatrixPosition(e.matrixWorld),hy.setFromMatrixPosition(this.matrixWorld);const i=Bu.distanceTo(hy)/e.zoom;t[0].object.visible=!0;let r,s;for(r=1,s=t.length;r<s;r++){let a=t[r].distance;if(t[r].object.visible&&(a-=a*t[r].hysteresis),i>=a)t[r-1].object.visible=!1,t[r].object.visible=!0;else break}for(this._currentLevel=r-1;r<s;r++)t[r].object.visible=!1}}toJSON(e){const t=super.toJSON(e);this.autoUpdate===!1&&(t.object.autoUpdate=!1),t.object.levels=[];const i=this.levels;for(let r=0,s=i.length;r<s;r++){const a=i[r];t.object.levels.push({object:a.object.uuid,distance:a.distance,hysteresis:a.hysteresis})}return t}}const dy=new N,py=new st,my=new st,jR=new N,fy=new Re,zu=new N,em=new Ai,gy=new Re,tm=new Es;class im extends Ft{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=Kd,this.bindMatrix=new Re,this.bindMatrixInverse=new Re,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new Bi),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,zu),this.boundingBox.expandByPoint(zu)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Ai),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,zu),this.boundingSphere.expandByPoint(zu)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const i=this.material,r=this.matrixWorld;i!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),em.copy(this.boundingSphere),em.applyMatrix4(r),e.ray.intersectsSphere(em)!==!1&&(gy.copy(r).invert(),tm.copy(e.ray).applyMatrix4(gy),!(this.boundingBox!==null&&tm.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,tm)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new st,t=this.geometry.attributes.skinWeight;for(let i=0,r=t.count;i<r;i++){e.fromBufferAttribute(t,i);const s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(i,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===Kd?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===U0?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const i=this.skeleton,r=this.geometry;py.fromBufferAttribute(r.attributes.skinIndex,e),my.fromBufferAttribute(r.attributes.skinWeight,e),dy.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){const a=my.getComponent(s);if(a!==0){const o=py.getComponent(s);fy.multiplyMatrices(i.bones[o].matrixWorld,i.boneInverses[o]),t.addScaledVector(jR.copy(dy).applyMatrix4(fy),a)}}return t.applyMatrix4(this.bindMatrixInverse)}}class ku extends _t{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Ur extends Wt{constructor(e=null,t=1,i=1,r,s,a,o,l,c=$t,u=$t,h,d){super(null,a,o,l,c,u,r,s,h,d),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const vy=new Re,XR=new Re;class fc{constructor(e=[],t=[]){this.uuid=yr(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,r=this.bones.length;i<r;i++)this.boneInverses.push(new Re)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const i=new Re;this.bones[e]&&i.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const i=this.bones[e];i&&i.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const i=this.bones[e];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){const e=this.bones,t=this.boneInverses,i=this.boneMatrices,r=this.boneTexture;for(let s=0,a=e.length;s<a;s++){const o=e[s]?e[s].matrixWorld:XR;vy.multiplyMatrices(o,t[s]),vy.toArray(i,s*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new fc(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const i=new Ur(t,e,e,Ei,Oi);return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){const r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,r=e.bones.length;i<r;i++){const s=e.bones[i];let a=t[s];a===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),a=new ku),this.bones.push(a),this.boneInverses.push(new Re().fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){const e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,i=this.boneInverses;for(let r=0,s=t.length;r<s;r++){const a=t[r];e.bones.push(a.uuid);const o=i[r];e.boneInverses.push(o.toArray())}return e}}class Nn extends wt{constructor(e,t,i,r=1){super(e,t,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const $a=new Re,yy=new Re,Hu=[],xy=new Bi,qR=new Re,pl=new Ft,ml=new Ai;class rm extends Ft{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Nn(new Float32Array(i*16),16),this.instanceColor=null,this.morphTexture=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let r=0;r<i;r++)this.setMatrixAt(r,qR)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new Bi),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,$a),xy.copy(e.boundingBox).applyMatrix4($a),this.boundingBox.union(xy)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new Ai),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,$a),ml.copy(e.boundingSphere).applyMatrix4($a),this.boundingSphere.union(ml)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const i=t.morphTargetInfluences,r=this.morphTexture.source.data.data,s=i.length+1,a=e*s+1;for(let o=0;o<i.length;o++)i[o]=r[a+o]}raycast(e,t){const i=this.matrixWorld,r=this.count;if(pl.geometry=this.geometry,pl.material=this.material,pl.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),ml.copy(this.boundingSphere),ml.applyMatrix4(i),e.ray.intersectsSphere(ml)!==!1))for(let s=0;s<r;s++){this.getMatrixAt(s,$a),yy.multiplyMatrices(i,$a),pl.matrixWorld=yy,pl.raycast(e,Hu);for(let a=0,o=Hu.length;a<o;a++){const l=Hu[a];l.instanceId=s,l.object=this,t.push(l)}Hu.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Nn(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){const i=t.morphTargetInfluences,r=i.length+1;this.morphTexture===null&&(this.morphTexture=new Ur(new Float32Array(r*this.count),r,this.count,Do,Oi));const s=this.morphTexture.source.data.data;let a=0;for(let c=0;c<i.length;c++)a+=i[c];const o=this.geometry.morphTargetsRelative?1:1-a,l=r*e;s[l]=o,s.set(i,l+1)}updateMorphTargets(){}dispose(){return this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null),this}}function YR(n,e){return n.z-e.z}function $R(n,e){return e.z-n.z}class JR{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t,i){const r=this.pool,s=this.list;this.index>=r.length&&r.push({start:-1,count:-1,z:-1,index:-1});const a=r[this.index];s.push(a),this.index++,a.start=e.start,a.count=e.count,a.z=t,a.index=i}reset(){this.list.length=0,this.index=0}}const ts=new Re,nm=new Re,KR=new Re,ZR=new xe(1,1,1),_y=new Re,sm=new za,Gu=new Bi,Fs=new Ai,fl=new N,My=new N,QR=new N,am=new JR,ki=new Ft,Wu=[];function eI(n,e,t=0){const i=e.itemSize;if(n.isInterleavedBufferAttribute||n.array.constructor!==e.array.constructor){const r=n.count;for(let s=0;s<r;s++)for(let a=0;a<i;a++)e.setComponent(s+t,a,n.getComponent(s,a))}else e.array.set(n.array,t*i);e.needsUpdate=!0}class om extends Ft{get maxInstanceCount(){return this._maxInstanceCount}constructor(e,t,i=t*2,r){super(new ct,r),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._drawInfo=[],this._availableInstanceIds=[],this._drawRanges=[],this._reservedRanges=[],this._bounds=[],this._maxInstanceCount=e,this._maxVertexCount=t,this._maxIndexCount=i,this._geometryInitialized=!1,this._geometryCount=0,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),this._multiDrawCount=0,this._multiDrawInstances=null,this._visibilityChanged=!0,this._matricesTexture=null,this._indirectTexture=null,this._colorsTexture=null,this._initMatricesTexture(),this._initIndirectTexture()}_initMatricesTexture(){let e=Math.sqrt(this._maxInstanceCount*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4),i=new Ur(t,e,e,Ei,Oi);this._matricesTexture=i}_initIndirectTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Uint32Array(e*e),i=new Ur(t,e,e,Uo,Nr);this._indirectTexture=i}_initColorsTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Float32Array(e*e*4).fill(1),i=new Ur(t,e,e,Ei,Oi);i.colorSpace=vt.workingColorSpace,this._colorsTexture=i}_initializeGeometry(e){const t=this.geometry,i=this._maxVertexCount,r=this._maxIndexCount;if(this._geometryInitialized===!1){for(const s in e.attributes){const a=e.getAttribute(s),{array:o,itemSize:l,normalized:c}=a,u=new o.constructor(i*l),h=new wt(u,l,c);t.setAttribute(s,h)}if(e.getIndex()!==null){const s=i>65535?new Uint32Array(r):new Uint16Array(r);t.setIndex(new wt(s,1))}this._geometryInitialized=!0}}_validateGeometry(e){const t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('BatchedMesh: All geometries must consistently have "index".');for(const i in t.attributes){if(!e.hasAttribute(i))throw new Error(`BatchedMesh: Added geometry missing "${i}". All geometries must have consistent attributes.`);const r=e.getAttribute(i),s=t.getAttribute(i);if(r.itemSize!==s.itemSize||r.normalized!==s.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Bi);const e=this.boundingBox,t=this._drawInfo;e.makeEmpty();for(let i=0,r=t.length;i<r;i++){if(t[i].active===!1)continue;const s=t[i].geometryIndex;this.getMatrixAt(i,ts),this.getBoundingBoxAt(s,Gu).applyMatrix4(ts),e.union(Gu)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Ai);const e=this.boundingSphere,t=this._drawInfo;e.makeEmpty();for(let i=0,r=t.length;i<r;i++){if(t[i].active===!1)continue;const s=t[i].geometryIndex;this.getMatrixAt(i,ts),this.getBoundingSphereAt(s,Fs).applyMatrix4(ts),e.union(Fs)}}addInstance(e){if(this._drawInfo.length>=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("BatchedMesh: Maximum item count reached.");const t={visible:!0,active:!0,geometryIndex:e};let i=null;this._availableInstanceIds.length>0?(i=this._availableInstanceIds.pop(),this._drawInfo[i]=t):(i=this._drawInfo.length,this._drawInfo.push(t));const r=this._matricesTexture,s=r.image.data;KR.toArray(s,i*16),r.needsUpdate=!0;const a=this._colorsTexture;return a&&(ZR.toArray(a.image.data,i*4),a.needsUpdate=!0),i}addGeometry(e,t=-1,i=-1){if(this._initializeGeometry(e),this._validateGeometry(e),this._drawInfo.length>=this._maxInstanceCount)throw new Error("BatchedMesh: Maximum item count reached.");const r={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1};let s=null;const a=this._reservedRanges,o=this._drawRanges,l=this._bounds;this._geometryCount!==0&&(s=a[a.length-1]),t===-1?r.vertexCount=e.getAttribute("position").count:r.vertexCount=t,s===null?r.vertexStart=0:r.vertexStart=s.vertexStart+s.vertexCount;const c=e.getIndex(),u=c!==null;if(u&&(i===-1?r.indexCount=c.count:r.indexCount=i,s===null?r.indexStart=0:r.indexStart=s.indexStart+s.indexCount),r.indexStart!==-1&&r.indexStart+r.indexCount>this._maxIndexCount||r.vertexStart+r.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");const h=this._geometryCount;return this._geometryCount++,a.push(r),o.push({start:u?r.indexStart:r.vertexStart,count:-1}),l.push({boxInitialized:!1,box:new Bi,sphereInitialized:!1,sphere:new Ai}),this.setGeometryAt(h,e),h}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const i=this.geometry,r=i.getIndex()!==null,s=i.getIndex(),a=t.getIndex(),o=this._reservedRanges[e];if(r&&a.count>o.indexCount||t.attributes.position.count>o.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const l=o.vertexStart,c=o.vertexCount;for(const p in i.attributes){const m=t.getAttribute(p),v=i.getAttribute(p);eI(m,v,l);const f=m.itemSize;for(let g=m.count,x=c;g<x;g++){const y=l+g;for(let _=0;_<f;_++)v.setComponent(y,_,0)}v.needsUpdate=!0,v.addUpdateRange(l*f,c*f)}if(r){const p=o.indexStart;for(let m=0;m<a.count;m++)s.setX(p+m,l+a.getX(m));for(let m=a.count,v=o.indexCount;m<v;m++)s.setX(p+m,l);s.needsUpdate=!0,s.addUpdateRange(p,o.indexCount)}const u=this._bounds[e];t.boundingBox!==null?(u.box.copy(t.boundingBox),u.boxInitialized=!0):u.boxInitialized=!1,t.boundingSphere!==null?(u.sphere.copy(t.boundingSphere),u.sphereInitialized=!0):u.sphereInitialized=!1;const h=this._drawRanges[e],d=t.getAttribute("position");return h.count=r?a.count:d.count,this._visibilityChanged=!0,e}deleteInstance(e){const t=this._drawInfo;return e>=t.length||t[e].active===!1?this:(t[e].active=!1,this._availableInstanceIds.push(e),this._visibilityChanged=!0,this)}getBoundingBoxAt(e,t){if(e>=this._geometryCount)return null;const i=this._bounds[e],r=i.box,s=this.geometry;if(i.boxInitialized===!1){r.makeEmpty();const a=s.index,o=s.attributes.position,l=this._drawRanges[e];for(let c=l.start,u=l.start+l.count;c<u;c++){let h=c;a&&(h=a.getX(h)),r.expandByPoint(fl.fromBufferAttribute(o,h))}i.boxInitialized=!0}return t.copy(r),t}getBoundingSphereAt(e,t){if(e>=this._geometryCount)return null;const i=this._bounds[e],r=i.sphere,s=this.geometry;if(i.sphereInitialized===!1){r.makeEmpty(),this.getBoundingBoxAt(e,Gu),Gu.getCenter(r.center);const a=s.index,o=s.attributes.position,l=this._drawRanges[e];let c=0;for(let u=l.start,h=l.start+l.count;u<h;u++){let d=u;a&&(d=a.getX(d)),fl.fromBufferAttribute(o,d),c=Math.max(c,r.center.distanceToSquared(fl))}r.radius=Math.sqrt(c),i.sphereInitialized=!0}return t.copy(r),t}setMatrixAt(e,t){const i=this._drawInfo,r=this._matricesTexture,s=this._matricesTexture.image.data;return e>=i.length||i[e].active===!1?this:(t.toArray(s,e*16),r.needsUpdate=!0,this)}getMatrixAt(e,t){const i=this._drawInfo,r=this._matricesTexture.image.data;return e>=i.length||i[e].active===!1?null:t.fromArray(r,e*16)}setColorAt(e,t){this._colorsTexture===null&&this._initColorsTexture();const i=this._colorsTexture,r=this._colorsTexture.image.data,s=this._drawInfo;return e>=s.length||s[e].active===!1?this:(t.toArray(r,e*4),i.needsUpdate=!0,this)}getColorAt(e,t){const i=this._colorsTexture.image.data,r=this._drawInfo;return e>=r.length||r[e].active===!1?null:t.fromArray(i,e*4)}setVisibleAt(e,t){const i=this._drawInfo;return e>=i.length||i[e].active===!1||i[e].visible===t?this:(i[e].visible=t,this._visibilityChanged=!0,this)}getVisibleAt(e){const t=this._drawInfo;return e>=t.length||t[e].active===!1?!1:t[e].visible}setGeometryIdAt(e,t){const i=this._drawInfo;return e>=i.length||i[e].active===!1||t<0||t>=this._geometryCount?null:(i[e].geometryIndex=t,this)}getGeometryIdAt(e){const t=this._drawInfo;return e>=t.length||t[e].active===!1?-1:t[e].geometryIndex}getGeometryRangeAt(e,t={}){if(e<0||e>=this._geometryCount)return null;const i=this._drawRanges[e];return t.start=i.start,t.count=i.count,t}raycast(e,t){const i=this._drawInfo,r=this._drawRanges,s=this.matrixWorld,a=this.geometry;ki.material=this.material,ki.geometry.index=a.index,ki.geometry.attributes=a.attributes,ki.geometry.boundingBox===null&&(ki.geometry.boundingBox=new Bi),ki.geometry.boundingSphere===null&&(ki.geometry.boundingSphere=new Ai);for(let o=0,l=i.length;o<l;o++){if(!i[o].visible||!i[o].active)continue;const c=i[o].geometryIndex,u=r[c];ki.geometry.setDrawRange(u.start,u.count),this.getMatrixAt(o,ki.matrixWorld).premultiply(s),this.getBoundingBoxAt(c,ki.geometry.boundingBox),this.getBoundingSphereAt(c,ki.geometry.boundingSphere),ki.raycast(e,Wu);for(let h=0,d=Wu.length;h<d;h++){const p=Wu[h];p.object=this,p.batchId=o,t.push(p)}Wu.length=0}ki.material=null,ki.geometry.index=null,ki.geometry.attributes={},ki.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._drawRanges=e._drawRanges.map(t=>({...t})),this._reservedRanges=e._reservedRanges.map(t=>({...t})),this._drawInfo=e._drawInfo.map(t=>({...t})),this._bounds=e._bounds.map(t=>({boxInitialized:t.boxInitialized,box:t.box.clone(),sphereInitialized:t.sphereInitialized,sphere:t.sphere.clone()})),this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=e._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null),this}onBeforeRender(e,t,i,r,s){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const a=r.getIndex(),o=a===null?1:a.array.BYTES_PER_ELEMENT,l=this._drawInfo,c=this._multiDrawStarts,u=this._multiDrawCounts,h=this._drawRanges,d=this.perObjectFrustumCulled,p=this._indirectTexture,m=p.image.data;d&&(_y.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),sm.setFromProjectionMatrix(_y,e.coordinateSystem));let v=0;if(this.sortObjects){nm.copy(this.matrixWorld).invert(),fl.setFromMatrixPosition(i.matrixWorld).applyMatrix4(nm),My.set(0,0,-1).transformDirection(i.matrixWorld).transformDirection(nm);for(let x=0,y=l.length;x<y;x++)if(l[x].visible&&l[x].active){const _=l[x].geometryIndex;this.getMatrixAt(x,ts),this.getBoundingSphereAt(_,Fs).applyMatrix4(ts);let I=!1;if(d&&(I=!sm.intersectsSphere(Fs)),!I){const b=QR.subVectors(Fs.center,fl).dot(My);am.push(h[_],b,x)}}const f=am.list,g=this.customSort;g===null?f.sort(s.transparent?$R:YR):g.call(this,f,i);for(let x=0,y=f.length;x<y;x++){const _=f[x];c[v]=_.start*o,u[v]=_.count,m[v]=_.index,v++}am.reset()}else for(let f=0,g=l.length;f<g;f++)if(l[f].visible&&l[f].active){const x=l[f].geometryIndex;let y=!1;if(d&&(this.getMatrixAt(f,ts),this.getBoundingSphereAt(x,Fs).applyMatrix4(ts),y=!sm.intersectsSphere(Fs)),!y){const _=h[x];c[v]=_.start*o,u[v]=_.count,m[v]=f,v++}}p.needsUpdate=!0,this._multiDrawCount=v,this._visibilityChanged=!1}onBeforeShadow(e,t,i,r,s,a){this.onBeforeRender(e,null,r,s,a)}}class Ni extends hi{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new xe(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const ju=new N,Xu=new N,by=new Re,gl=new Es,qu=new Ai,lm=new N,Ty=new N;class Cn extends _t{constructor(e=new ct,t=new Ni){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[0];for(let r=1,s=t.count;r<s;r++)ju.fromBufferAttribute(t,r-1),Xu.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=ju.distanceTo(Xu);e.setAttribute("lineDistance",new De(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const i=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,a=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),qu.copy(i.boundingSphere),qu.applyMatrix4(r),qu.radius+=s,e.ray.intersectsSphere(qu)===!1)return;by.copy(r).invert(),gl.copy(e.ray).applyMatrix4(by);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=this.isLineSegments?2:1,u=i.index,h=i.attributes.position;if(u!==null){const d=Math.max(0,a.start),p=Math.min(u.count,a.start+a.count);for(let m=d,v=p-1;m<v;m+=c){const f=u.getX(m),g=u.getX(m+1),x=Yu(this,e,gl,l,f,g);x&&t.push(x)}if(this.isLineLoop){const m=u.getX(p-1),v=u.getX(d),f=Yu(this,e,gl,l,m,v);f&&t.push(f)}}else{const d=Math.max(0,a.start),p=Math.min(h.count,a.start+a.count);for(let m=d,v=p-1;m<v;m+=c){const f=Yu(this,e,gl,l,m,m+1);f&&t.push(f)}if(this.isLineLoop){const m=Yu(this,e,gl,l,p-1,d);m&&t.push(m)}}}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){const a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}}function Yu(n,e,t,i,r,s){const a=n.geometry.attributes.position;if(ju.fromBufferAttribute(a,r),Xu.fromBufferAttribute(a,s),t.distanceSqToSegment(ju,Xu,lm,Ty)>i)return;lm.applyMatrix4(n.matrixWorld);const o=e.ray.origin.distanceTo(lm);if(!(o<e.near||o>e.far))return{distance:o,point:Ty.clone().applyMatrix4(n.matrixWorld),index:r,face:null,faceIndex:null,barycoord:null,object:n}}const Sy=new N,wy=new N;class $r extends Cn{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[];for(let r=0,s=t.count;r<s;r+=2)Sy.fromBufferAttribute(t,r),wy.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+Sy.distanceTo(wy);e.setAttribute("lineDistance",new De(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class cm extends Cn{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class Ja extends hi{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new xe(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const Ey=new Re,um=new Es,$u=new Ai,Ju=new N;class hm extends _t{constructor(e=new ct,t=new Ja){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const i=this.geometry,r=this.matrixWorld,s=e.params.Points.threshold,a=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),$u.copy(i.boundingSphere),$u.applyMatrix4(r),$u.radius+=s,e.ray.intersectsSphere($u)===!1)return;Ey.copy(r).invert(),um.copy(e.ray).applyMatrix4(Ey);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=i.index,u=i.attributes.position;if(c!==null){const h=Math.max(0,a.start),d=Math.min(c.count,a.start+a.count);for(let p=h,m=d;p<m;p++){const v=c.getX(p);Ju.fromBufferAttribute(u,v),Ay(Ju,v,l,r,e,t,this)}}else{const h=Math.max(0,a.start),d=Math.min(u.count,a.start+a.count);for(let p=h,m=d;p<m;p++)Ju.fromBufferAttribute(u,p),Ay(Ju,p,l,r,e,t,this)}}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){const a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}}function Ay(n,e,t,i,r,s,a){const o=um.distanceSqToPoint(n);if(o<t){const l=new N;um.closestPointToPoint(n,l),l.applyMatrix4(i);const c=r.ray.origin.distanceTo(l);if(c<r.near||c>r.far)return;s.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class Ny extends Wt{constructor(e,t,i,r,s,a,o,l,c){super(e,t,i,r,s,a,o,l,c),this.isVideoTexture=!0,this.minFilter=a!==void 0?a:Lt,this.magFilter=s!==void 0?s:Lt,this.generateMipmaps=!1;const u=this;function h(){u.needsUpdate=!0,e.requestVideoFrameCallback(h)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(h)}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;!("requestVideoFrameCallback"in e)&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class dm extends Wt{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=$t,this.minFilter=$t,this.generateMipmaps=!1,this.needsUpdate=!0}}class vl extends Wt{constructor(e,t,i,r,s,a,o,l,c,u,h,d){super(null,a,o,l,c,u,r,s,h,d),this.isCompressedTexture=!0,this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class Cy extends vl{constructor(e,t,i,r,s,a){super(e,t,i,s,a),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=gr,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Ry extends vl{constructor(e,t,i){super(void 0,e[0].width,e[0].height,t,i,fr),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class Iy extends Wt{constructor(e,t,i,r,s,a,o,l,c){super(e,t,i,r,s,a,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Or{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let i,r=this.getPoint(0),s=0;t.push(0);for(let a=1;a<=e;a++)i=this.getPoint(a/e),s+=i.distanceTo(r),t.push(s),r=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const i=this.getLengths();let r=0;const s=i.length;let a;t?a=t:a=e*i[s-1];let o=0,l=s-1,c;for(;o<=l;)if(r=Math.floor(o+(l-o)/2),c=i[r]-a,c<0)o=r+1;else if(c>0)l=r-1;else{l=r;break}if(r=l,i[r]===a)return r/(s-1);const u=i[r],h=i[r+1]-u,d=(a-u)/h;return(r+d)/(s-1)}getTangent(e,t){let i=e-1e-4,r=e+1e-4;i<0&&(i=0),r>1&&(r=1);const s=this.getPoint(i),a=this.getPoint(r),o=t||(s.isVector2?new J:new N);return o.copy(a).sub(s).normalize(),o}getTangentAt(e,t){const i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){const i=new N,r=[],s=[],a=[],o=new N,l=new Re;for(let p=0;p<=e;p++){const m=p/e;r[p]=this.getTangentAt(m,new N)}s[0]=new N,a[0]=new N;let c=Number.MAX_VALUE;const u=Math.abs(r[0].x),h=Math.abs(r[0].y),d=Math.abs(r[0].z);u<=c&&(c=u,i.set(1,0,0)),h<=c&&(c=h,i.set(0,1,0)),d<=c&&i.set(0,0,1),o.crossVectors(r[0],i).normalize(),s[0].crossVectors(r[0],o),a[0].crossVectors(r[0],s[0]);for(let p=1;p<=e;p++){if(s[p]=s[p-1].clone(),a[p]=a[p-1].clone(),o.crossVectors(r[p-1],r[p]),o.length()>Number.EPSILON){o.normalize();const m=Math.acos(Jt(r[p-1].dot(r[p]),-1,1));s[p].applyMatrix4(l.makeRotationAxis(o,m))}a[p].crossVectors(r[p],s[p])}if(t===!0){let p=Math.acos(Jt(s[0].dot(s[e]),-1,1));p/=e,r[0].dot(o.crossVectors(s[0],s[e]))>0&&(p=-p);for(let m=1;m<=e;m++)s[m].applyMatrix4(l.makeRotationAxis(r[m],p*m)),a[m].crossVectors(r[m],s[m])}return{tangents:r,normals:s,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Ku extends Or{constructor(e=0,t=0,i=1,r=1,s=0,a=Math.PI*2,o=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=a,this.aClockwise=o,this.aRotation=l}getPoint(e,t=new J){const i=t,r=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const a=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(a?s=0:s=r),this.aClockwise===!0&&!a&&(s===r?s=-r:s=s-r);const o=this.aStartAngle+e*s;let l=this.aX+this.xRadius*Math.cos(o),c=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){const u=Math.cos(this.aRotation),h=Math.sin(this.aRotation),d=l-this.aX,p=c-this.aY;l=d*u-p*h+this.aX,c=d*h+p*u+this.aY}return i.set(l,c)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){const e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}}class Ly extends Ku{constructor(e,t,i,r,s,a){super(e,t,i,i,r,s,a),this.isArcCurve=!0,this.type="ArcCurve"}}function pm(){let n=0,e=0,t=0,i=0;function r(s,a,o,l){n=s,e=o,t=-3*s+3*a-2*o-l,i=2*s-2*a+o+l}return{initCatmullRom:function(s,a,o,l,c){r(a,o,c*(o-s),c*(l-a))},initNonuniformCatmullRom:function(s,a,o,l,c,u,h){let d=(a-s)/c-(o-s)/(c+u)+(o-a)/u,p=(o-a)/u-(l-a)/(u+h)+(l-o)/h;d*=u,p*=u,r(a,o,d,p)},calc:function(s){const a=s*s,o=a*s;return n+e*s+t*a+i*o}}}const Zu=new N,mm=new pm,fm=new pm,gm=new pm;class Py extends Or{constructor(e=[],t=!1,i="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=r}getPoint(e,t=new N){const i=t,r=this.points,s=r.length,a=(s-(this.closed?0:1))*e;let o=Math.floor(a),l=a-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/s)+1)*s:l===0&&o===s-1&&(o=s-2,l=1);let c,u;this.closed||o>0?c=r[(o-1)%s]:(Zu.subVectors(r[0],r[1]).add(r[0]),c=Zu);const h=r[o%s],d=r[(o+1)%s];if(this.closed||o+2<s?u=r[(o+2)%s]:(Zu.subVectors(r[s-1],r[s-2]).add(r[s-1]),u=Zu),this.curveType==="centripetal"||this.curveType==="chordal"){const p=this.curveType==="chordal"?.5:.25;let m=Math.pow(c.distanceToSquared(h),p),v=Math.pow(h.distanceToSquared(d),p),f=Math.pow(d.distanceToSquared(u),p);v<1e-4&&(v=1),m<1e-4&&(m=v),f<1e-4&&(f=v),mm.initNonuniformCatmullRom(c.x,h.x,d.x,u.x,m,v,f),fm.initNonuniformCatmullRom(c.y,h.y,d.y,u.y,m,v,f),gm.initNonuniformCatmullRom(c.z,h.z,d.z,u.z,m,v,f)}else this.curveType==="catmullrom"&&(mm.initCatmullRom(c.x,h.x,d.x,u.x,this.tension),fm.initCatmullRom(c.y,h.y,d.y,u.y,this.tension),gm.initCatmullRom(c.z,h.z,d.z,u.z,this.tension));return i.set(mm.calc(l),fm.calc(l),gm.calc(l)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(r.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){const r=this.points[t];e.points.push(r.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(new N().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function Dy(n,e,t,i,r){const s=(i-e)*.5,a=(r-t)*.5,o=n*n,l=n*o;return(2*t-2*i+s+a)*l+(-3*t+3*i-2*s-a)*o+s*n+t}function tI(n,e){const t=1-n;return t*t*e}function iI(n,e){return 2*(1-n)*n*e}function rI(n,e){return n*n*e}function yl(n,e,t,i){return tI(n,e)+iI(n,t)+rI(n,i)}function nI(n,e){const t=1-n;return t*t*t*e}function sI(n,e){const t=1-n;return 3*t*t*n*e}function aI(n,e){return 3*(1-n)*n*n*e}function oI(n,e){return n*n*n*e}function xl(n,e,t,i,r){return nI(n,e)+sI(n,t)+aI(n,i)+oI(n,r)}class vm extends Or{constructor(e=new J,t=new J,i=new J,r=new J){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new J){const i=t,r=this.v0,s=this.v1,a=this.v2,o=this.v3;return i.set(xl(e,r.x,s.x,a.x,o.x),xl(e,r.y,s.y,a.y,o.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class Uy extends Or{constructor(e=new N,t=new N,i=new N,r=new N){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new N){const i=t,r=this.v0,s=this.v1,a=this.v2,o=this.v3;return i.set(xl(e,r.x,s.x,a.x,o.x),xl(e,r.y,s.y,a.y,o.y),xl(e,r.z,s.z,a.z,o.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class ym extends Or{constructor(e=new J,t=new J){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new J){const i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new J){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Oy extends Or{constructor(e=new N,t=new N){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new N){const i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new N){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class xm extends Or{constructor(e=new J,t=new J,i=new J){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new J){const i=t,r=this.v0,s=this.v1,a=this.v2;return i.set(yl(e,r.x,s.x,a.x),yl(e,r.y,s.y,a.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class _m extends Or{constructor(e=new N,t=new N,i=new N){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new N){const i=t,r=this.v0,s=this.v1,a=this.v2;return i.set(yl(e,r.x,s.x,a.x),yl(e,r.y,s.y,a.y),yl(e,r.z,s.z,a.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Mm extends Or{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new J){const i=t,r=this.points,s=(r.length-1)*e,a=Math.floor(s),o=s-a,l=r[a===0?a:a-1],c=r[a],u=r[a>r.length-2?r.length-1:a+1],h=r[a>r.length-3?r.length-1:a+2];return i.set(Dy(o,l.x,c.x,u.x,h.x),Dy(o,l.y,c.y,u.y,h.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(r.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){const r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(new J().fromArray(r))}return this}}var Qu=Object.freeze({__proto__:null,ArcCurve:Ly,CatmullRomCurve3:Py,CubicBezierCurve:vm,CubicBezierCurve3:Uy,EllipseCurve:Ku,LineCurve:ym,LineCurve3:Oy,QuadraticBezierCurve:xm,QuadraticBezierCurve3:_m,SplineCurve:Mm});class Fy extends Or{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){const i=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new Qu[i](t,e))}return this}getPoint(e,t){const i=e*this.getLength(),r=this.getCurveLengths();let s=0;for(;s<r.length;){if(r[s]>=i){const a=r[s]-i,o=this.curves[s],l=o.getLength(),c=l===0?0:1-a/l;return o.getPointAt(c,t)}s++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let i=0,r=this.curves.length;i<r;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let i;for(let r=0,s=this.curves;r<s.length;r++){const a=s[r],o=a.isEllipseCurve?e*2:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?e*a.points.length:e,l=a.getPoints(o);for(let c=0;c<l.length;c++){const u=l[c];i&&i.equals(u)||(t.push(u),i=u)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){const r=e.curves[t];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){const r=this.curves[t];e.curves.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){const r=e.curves[t];this.curves.push(new Qu[r.type]().fromJSON(r))}return this}}class _l extends Fy{constructor(e){super(),this.type="Path",this.currentPoint=new J,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){const i=new ym(this.currentPoint.clone(),new J(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){const s=new xm(this.currentPoint.clone(),new J(e,t),new J(i,r));return this.curves.push(s),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,s,a){const o=new vm(this.currentPoint.clone(),new J(e,t),new J(i,r),new J(s,a));return this.curves.push(o),this.currentPoint.set(s,a),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),i=new Mm(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,r,s,a){const o=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(e+o,t+l,i,r,s,a),this}absarc(e,t,i,r,s,a){return this.absellipse(e,t,i,i,r,s,a),this}ellipse(e,t,i,r,s,a,o,l){const c=this.currentPoint.x,u=this.currentPoint.y;return this.absellipse(e+c,t+u,i,r,s,a,o,l),this}absellipse(e,t,i,r,s,a,o,l){const c=new Ku(e,t,i,r,s,a,o,l);if(this.curves.length>0){const h=c.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(c);const u=c.getPoint(1);return this.currentPoint.copy(u),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class gc extends ct{constructor(e=[new J(0,-.5),new J(.5,0),new J(0,.5)],t=12,i=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:r},t=Math.floor(t),r=Jt(r,0,Math.PI*2);const s=[],a=[],o=[],l=[],c=[],u=1/t,h=new N,d=new J,p=new N,m=new N,v=new N;let f=0,g=0;for(let x=0;x<=e.length-1;x++)switch(x){case 0:f=e[x+1].x-e[x].x,g=e[x+1].y-e[x].y,p.x=g*1,p.y=-f,p.z=g*0,v.copy(p),p.normalize(),l.push(p.x,p.y,p.z);break;case e.length-1:l.push(v.x,v.y,v.z);break;default:f=e[x+1].x-e[x].x,g=e[x+1].y-e[x].y,p.x=g*1,p.y=-f,p.z=g*0,m.copy(p),p.x+=v.x,p.y+=v.y,p.z+=v.z,p.normalize(),l.push(p.x,p.y,p.z),v.copy(m)}for(let x=0;x<=t;x++){const y=i+x*u*r,_=Math.sin(y),I=Math.cos(y);for(let b=0;b<=e.length-1;b++){h.x=e[b].x*_,h.y=e[b].y,h.z=e[b].x*I,a.push(h.x,h.y,h.z),d.x=x/t,d.y=b/(e.length-1),o.push(d.x,d.y);const w=l[3*b+0]*_,C=l[3*b+1],H=l[3*b+0]*I;c.push(w,C,H)}}for(let x=0;x<t;x++)for(let y=0;y<e.length-1;y++){const _=y+x*e.length,I=_,b=_+e.length,w=_+e.length+1,C=_+1;s.push(I,b,C),s.push(w,C,b)}this.setIndex(s),this.setAttribute("position",new De(a,3)),this.setAttribute("uv",new De(o,2)),this.setAttribute("normal",new De(c,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new gc(e.points,e.segments,e.phiStart,e.phiLength)}}class Nd extends gc{constructor(e=1,t=1,i=4,r=8){const s=new _l;s.absarc(0,-t/2,e,Math.PI*1.5,0),s.absarc(0,t/2,e,0,Math.PI*.5),super(s.getPoints(i),r),this.type="CapsuleGeometry",this.parameters={radius:e,length:t,capSegments:i,radialSegments:r}}static fromJSON(e){return new Nd(e.radius,e.length,e.capSegments,e.radialSegments)}}class Cd extends ct{constructor(e=1,t=32,i=0,r=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:r},t=Math.max(3,t);const s=[],a=[],o=[],l=[],c=new N,u=new J;a.push(0,0,0),o.push(0,0,1),l.push(.5,.5);for(let h=0,d=3;h<=t;h++,d+=3){const p=i+h/t*r;c.x=e*Math.cos(p),c.y=e*Math.sin(p),a.push(c.x,c.y,c.z),o.push(0,0,1),u.x=(a[d]/e+1)/2,u.y=(a[d+1]/e+1)/2,l.push(u.x,u.y)}for(let h=1;h<=t;h++)s.push(h,h+1,0);this.setIndex(s),this.setAttribute("position",new De(a,3)),this.setAttribute("normal",new De(o,3)),this.setAttribute("uv",new De(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Cd(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class ha extends ct{constructor(e=1,t=1,i=1,r=32,s=1,a=!1,o=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:s,openEnded:a,thetaStart:o,thetaLength:l};const c=this;r=Math.floor(r),s=Math.floor(s);const u=[],h=[],d=[],p=[];let m=0;const v=[],f=i/2;let g=0;x(),a===!1&&(e>0&&y(!0),t>0&&y(!1)),this.setIndex(u),this.setAttribute("position",new De(h,3)),this.setAttribute("normal",new De(d,3)),this.setAttribute("uv",new De(p,2));function x(){const _=new N,I=new N;let b=0;const w=(t-e)/i;for(let C=0;C<=s;C++){const H=[],M=C/s,T=M*(t-e)+e;for(let k=0;k<=r;k++){const j=k/r,Y=j*l+o,re=Math.sin(Y),$=Math.cos(Y);I.x=T*re,I.y=-M*i+f,I.z=T*$,h.push(I.x,I.y,I.z),_.set(re,w,$).normalize(),d.push(_.x,_.y,_.z),p.push(j,1-M),H.push(m++)}v.push(H)}for(let C=0;C<r;C++)for(let H=0;H<s;H++){const M=v[H][C],T=v[H+1][C],k=v[H+1][C+1],j=v[H][C+1];e>0&&(u.push(M,T,j),b+=3),t>0&&(u.push(T,k,j),b+=3)}c.addGroup(g,b,0),g+=b}function y(_){const I=m,b=new J,w=new N;let C=0;const H=_===!0?e:t,M=_===!0?1:-1;for(let k=1;k<=r;k++)h.push(0,f*M,0),d.push(0,M,0),p.push(.5,.5),m++;const T=m;for(let k=0;k<=r;k++){const j=k/r*l+o,Y=Math.cos(j),re=Math.sin(j);w.x=H*re,w.y=f*M,w.z=H*Y,h.push(w.x,w.y,w.z),d.push(0,M,0),b.x=Y*.5+.5,b.y=re*.5*M+.5,p.push(b.x,b.y),m++}for(let k=0;k<r;k++){const j=I+k,Y=T+k;_===!0?u.push(Y,Y+1,j):u.push(Y+1,Y,j),C+=3}c.addGroup(g,C,_===!0?1:2),g+=C}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ha(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Rd extends ha{constructor(e=1,t=1,i=32,r=1,s=!1,a=0,o=Math.PI*2){super(0,e,t,i,r,s,a,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:s,thetaStart:a,thetaLength:o}}static fromJSON(e){return new Rd(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class ms extends ct{constructor(e=[],t=[],i=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:r};const s=[],a=[];o(r),c(i),u(),this.setAttribute("position",new De(s,3)),this.setAttribute("normal",new De(s.slice(),3)),this.setAttribute("uv",new De(a,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function o(x){const y=new N,_=new N,I=new N;for(let b=0;b<t.length;b+=3)p(t[b+0],y),p(t[b+1],_),p(t[b+2],I),l(y,_,I,x)}function l(x,y,_,I){const b=I+1,w=[];for(let C=0;C<=b;C++){w[C]=[];const H=x.clone().lerp(_,C/b),M=y.clone().lerp(_,C/b),T=b-C;for(let k=0;k<=T;k++)k===0&&C===b?w[C][k]=H:w[C][k]=H.clone().lerp(M,k/T)}for(let C=0;C<b;C++)for(let H=0;H<2*(b-C)-1;H++){const M=Math.floor(H/2);H%2===0?(d(w[C][M+1]),d(w[C+1][M]),d(w[C][M])):(d(w[C][M+1]),d(w[C+1][M+1]),d(w[C+1][M]))}}function c(x){const y=new N;for(let _=0;_<s.length;_+=3)y.x=s[_+0],y.y=s[_+1],y.z=s[_+2],y.normalize().multiplyScalar(x),s[_+0]=y.x,s[_+1]=y.y,s[_+2]=y.z}function u(){const x=new N;for(let y=0;y<s.length;y+=3){x.x=s[y+0],x.y=s[y+1],x.z=s[y+2];const _=f(x)/2/Math.PI+.5,I=g(x)/Math.PI+.5;a.push(_,1-I)}m(),h()}function h(){for(let x=0;x<a.length;x+=6){const y=a[x+0],_=a[x+2],I=a[x+4],b=Math.max(y,_,I),w=Math.min(y,_,I);b>.9&&w<.1&&(y<.2&&(a[x+0]+=1),_<.2&&(a[x+2]+=1),I<.2&&(a[x+4]+=1))}}function d(x){s.push(x.x,x.y,x.z)}function p(x,y){const _=x*3;y.x=e[_+0],y.y=e[_+1],y.z=e[_+2]}function m(){const x=new N,y=new N,_=new N,I=new N,b=new J,w=new J,C=new J;for(let H=0,M=0;H<s.length;H+=9,M+=6){x.set(s[H+0],s[H+1],s[H+2]),y.set(s[H+3],s[H+4],s[H+5]),_.set(s[H+6],s[H+7],s[H+8]),b.set(a[M+0],a[M+1]),w.set(a[M+2],a[M+3]),C.set(a[M+4],a[M+5]),I.copy(x).add(y).add(_).divideScalar(3);const T=f(I);v(b,M+0,x,T),v(w,M+2,y,T),v(C,M+4,_,T)}}function v(x,y,_,I){I<0&&x.x===1&&(a[y]=x.x-1),_.x===0&&_.z===0&&(a[y]=I/2/Math.PI+.5)}function f(x){return Math.atan2(x.z,-x.x)}function g(x){return Math.atan2(-x.y,Math.sqrt(x.x*x.x+x.z*x.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ms(e.vertices,e.indices,e.radius,e.details)}}class Id extends ms{constructor(e=1,t=0){const i=(1+Math.sqrt(5))/2,r=1/i,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-i,0,-r,i,0,r,-i,0,r,i,-r,-i,0,-r,i,0,r,-i,0,r,i,0,-i,0,-r,i,0,-r,-i,0,r,i,0,r],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,a,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Id(e.radius,e.detail)}}const eh=new N,th=new N,bm=new N,ih=new er;class Tm extends ct{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){const i=Math.pow(10,4),r=Math.cos(Ts*t),s=e.getIndex(),a=e.getAttribute("position"),o=s?s.count:a.count,l=[0,0,0],c=["a","b","c"],u=new Array(3),h={},d=[];for(let p=0;p<o;p+=3){s?(l[0]=s.getX(p),l[1]=s.getX(p+1),l[2]=s.getX(p+2)):(l[0]=p,l[1]=p+1,l[2]=p+2);const{a:m,b:v,c:f}=ih;if(m.fromBufferAttribute(a,l[0]),v.fromBufferAttribute(a,l[1]),f.fromBufferAttribute(a,l[2]),ih.getNormal(bm),u[0]=`${Math.round(m.x*i)},${Math.round(m.y*i)},${Math.round(m.z*i)}`,u[1]=`${Math.round(v.x*i)},${Math.round(v.y*i)},${Math.round(v.z*i)}`,u[2]=`${Math.round(f.x*i)},${Math.round(f.y*i)},${Math.round(f.z*i)}`,!(u[0]===u[1]||u[1]===u[2]||u[2]===u[0]))for(let g=0;g<3;g++){const x=(g+1)%3,y=u[g],_=u[x],I=ih[c[g]],b=ih[c[x]],w=`${y}_${_}`,C=`${_}_${y}`;C in h&&h[C]?(bm.dot(h[C].normal)<=r&&(d.push(I.x,I.y,I.z),d.push(b.x,b.y,b.z)),h[C]=null):w in h||(h[w]={index0:l[g],index1:l[x],normal:bm.clone()})}}for(const p in h)if(h[p]){const{index0:m,index1:v}=h[p];eh.fromBufferAttribute(a,m),th.fromBufferAttribute(a,v),d.push(eh.x,eh.y,eh.z),d.push(th.x,th.y,th.z)}this.setAttribute("position",new De(d,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class is extends _l{constructor(e){super(e),this.uuid=yr(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let i=0,r=this.holes.length;i<r;i++)t[i]=this.holes[i].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){const r=e.holes[t];this.holes.push(r.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){const r=this.holes[t];e.holes.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){const r=e.holes[t];this.holes.push(new _l().fromJSON(r))}return this}}const lI={triangulate:function(n,e,t=2){const i=e&&e.length,r=i?e[0]*t:n.length;let s=Vy(n,0,r,t,!0);const a=[];if(!s||s.next===s.prev)return a;let o,l,c,u,h,d,p;if(i&&(s=pI(n,e,s,t)),n.length>80*t){o=c=n[0],l=u=n[1];for(let m=t;m<r;m+=t)h=n[m],d=n[m+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=p!==0?32767/p:0}return Ml(s,a,t,o,l,p,0),a}};function Vy(n,e,t,i,r){let s,a;if(r===SI(n,e,t,i)>0)for(s=e;s<t;s+=i)a=ky(s,n[s],n[s+1],a);else for(s=t-i;s>=e;s-=i)a=ky(s,n[s],n[s+1],a);return a&&rh(a,a.next)&&(Tl(a),a=a.next),a}function Vs(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&(rh(t,t.next)||Xt(t.prev,t,t.next)===0)){if(Tl(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function Ml(n,e,t,i,r,s,a){if(!n)return;!a&&s&&yI(n,i,r,s);let o=n,l,c;for(;n.prev!==n.next;){if(l=n.prev,c=n.next,s?uI(n,i,r,s):cI(n)){e.push(l.i/t|0),e.push(n.i/t|0),e.push(c.i/t|0),Tl(n),n=c.next,o=c.next;continue}if(n=c,n===o){a?a===1?(n=hI(Vs(n),e,t),Ml(n,e,t,i,r,s,2)):a===2&&dI(n,e,t,i,r,s):Ml(Vs(n),e,t,i,r,s,1);break}}}function cI(n){const e=n.prev,t=n,i=n.next;if(Xt(e,t,i)>=0)return!1;const r=e.x,s=t.x,a=i.x,o=e.y,l=t.y,c=i.y,u=r<s?r<a?r:a:s<a?s:a,h=o<l?o<c?o:c:l<c?l:c,d=r>s?r>a?r:a:s>a?s: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&&Ka(r,o,s,l,a,c,m.x,m.y)&&Xt(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function uI(n,e,t,i){const r=n.prev,s=n,a=n.next;if(Xt(r,s,a)>=0)return!1;const o=r.x,l=s.x,c=a.x,u=r.y,h=s.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,v=o>l?o>c?o:c:l>c?l:c,f=u>h?u>d?u:d:h>d?h:d,g=Sm(p,m,e,t,i),x=Sm(v,f,e,t,i);let y=n.prevZ,_=n.nextZ;for(;y&&y.z>=g&&_&&_.z<=x;){if(y.x>=p&&y.x<=v&&y.y>=m&&y.y<=f&&y!==r&&y!==a&&Ka(o,u,l,h,c,d,y.x,y.y)&&Xt(y.prev,y,y.next)>=0||(y=y.prevZ,_.x>=p&&_.x<=v&&_.y>=m&&_.y<=f&&_!==r&&_!==a&&Ka(o,u,l,h,c,d,_.x,_.y)&&Xt(_.prev,_,_.next)>=0))return!1;_=_.nextZ}for(;y&&y.z>=g;){if(y.x>=p&&y.x<=v&&y.y>=m&&y.y<=f&&y!==r&&y!==a&&Ka(o,u,l,h,c,d,y.x,y.y)&&Xt(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;_&&_.z<=x;){if(_.x>=p&&_.x<=v&&_.y>=m&&_.y<=f&&_!==r&&_!==a&&Ka(o,u,l,h,c,d,_.x,_.y)&&Xt(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function hI(n,e,t){let i=n;do{const r=i.prev,s=i.next.next;!rh(r,s)&&By(r,i,i.next,s)&&bl(r,s)&&bl(s,r)&&(e.push(r.i/t|0),e.push(i.i/t|0),e.push(s.i/t|0),Tl(i),Tl(i.next),i=n=s),i=i.next}while(i!==n);return Vs(i)}function dI(n,e,t,i,r,s){let a=n;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&MI(a,o)){let l=zy(a,o);a=Vs(a,a.next),l=Vs(l,l.next),Ml(a,e,t,i,r,s,0),Ml(l,e,t,i,r,s,0);return}o=o.next}a=a.next}while(a!==n)}function pI(n,e,t,i){const r=[];let s,a,o,l,c;for(s=0,a=e.length;s<a;s++)o=e[s]*i,l=s<a-1?e[s+1]*i:n.length,c=Vy(n,o,l,i,!1),c===c.next&&(c.steiner=!0),r.push(_I(c));for(r.sort(mI),s=0;s<r.length;s++)t=fI(r[s],t);return t}function mI(n,e){return n.x-e.x}function fI(n,e){const t=gI(n,e);if(!t)return e;const i=zy(t,n);return Vs(i,i.next),Vs(t,t.next)}function gI(n,e){let t=e,i=-1/0,r;const s=n.x,a=n.y;do{if(a<=t.y&&a>=t.next.y&&t.next.y!==t.y){const d=t.x+(a-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=s&&d>i&&(i=d,r=t.x<t.next.x?t:t.next,d===s))return r}t=t.next}while(t!==e);if(!r)return null;const o=r,l=r.x,c=r.y;let u=1/0,h;t=r;do s>=t.x&&t.x>=l&&s!==t.x&&Ka(a<c?s:i,a,l,c,a<c?i:s,a,t.x,t.y)&&(h=Math.abs(a-t.y)/(s-t.x),bl(t,n)&&(h<u||h===u&&(t.x>r.x||t.x===r.x&&vI(r,t)))&&(r=t,u=h)),t=t.next;while(t!==o);return r}function vI(n,e){return Xt(n.prev,n,e.prev)<0&&Xt(e.next,n,n.next)<0}function yI(n,e,t,i){let r=n;do r.z===0&&(r.z=Sm(r.x,r.y,e,t,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==n);r.prevZ.nextZ=null,r.prevZ=null,xI(r)}function xI(n){let e,t,i,r,s,a,o,l,c=1;do{for(t=n,n=null,s=null,a=0;t;){for(a++,i=t,o=0,e=0;e<c&&(o++,i=i.nextZ,!!i);e++);for(l=c;o>0||l>0&&i;)o!==0&&(l===0||!i||t.z<=i.z)?(r=t,t=t.nextZ,o--):(r=i,i=i.nextZ,l--),s?s.nextZ=r:n=r,r.prevZ=s,s=r;t=i}s.nextZ=null,c*=2}while(a>1);return n}function Sm(n,e,t,i,r){return n=(n-t)*r|0,e=(e-i)*r|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function _I(n){let e=n,t=n;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==n);return t}function Ka(n,e,t,i,r,s,a,o){return(r-a)*(e-o)>=(n-a)*(s-o)&&(n-a)*(i-o)>=(t-a)*(e-o)&&(t-a)*(s-o)>=(r-a)*(i-o)}function MI(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!bI(n,e)&&(bl(n,e)&&bl(e,n)&&TI(n,e)&&(Xt(n.prev,n,e.prev)||Xt(n,e.prev,e))||rh(n,e)&&Xt(n.prev,n,n.next)>0&&Xt(e.prev,e,e.next)>0)}function Xt(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function rh(n,e){return n.x===e.x&&n.y===e.y}function By(n,e,t,i){const r=sh(Xt(n,e,t)),s=sh(Xt(n,e,i)),a=sh(Xt(t,i,n)),o=sh(Xt(t,i,e));return!!(r!==s&&a!==o||r===0&&nh(n,t,e)||s===0&&nh(n,i,e)||a===0&&nh(t,n,i)||o===0&&nh(t,e,i))}function nh(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function sh(n){return n>0?1:n<0?-1:0}function bI(n,e){let t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&By(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function bl(n,e){return Xt(n.prev,n,n.next)<0?Xt(n,e,n.next)>=0&&Xt(n,n.prev,e)>=0:Xt(n,e,n.prev)<0||Xt(n,n.next,e)<0}function TI(n,e){let t=n,i=!1;const r=(n.x+e.x)/2,s=(n.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==n);return i}function zy(n,e){const t=new wm(n.i,n.x,n.y),i=new wm(e.i,e.x,e.y),r=n.next,s=e.prev;return n.next=e,e.prev=n,t.next=r,r.prev=t,i.next=t,t.prev=i,s.next=i,i.prev=s,i}function ky(n,e,t,i){const r=new wm(n,e,t);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function Tl(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function wm(n,e,t){this.i=n,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function SI(n,e,t,i){let r=0;for(let s=e,a=t-i;s<t;s+=i)r+=(n[a]-n[s])*(n[s+1]+n[a+1]),a=s;return r}class nn{static area(e){const t=e.length;let i=0;for(let r=t-1,s=0;s<t;r=s++)i+=e[r].x*e[s].y-e[s].x*e[r].y;return i*.5}static isClockWise(e){return nn.area(e)<0}static triangulateShape(e,t){const i=[],r=[],s=[];Hy(e),Gy(i,e);let a=e.length;t.forEach(Hy);for(let l=0;l<t.length;l++)r.push(a),a+=t[l].length,Gy(i,t[l]);const o=lI.triangulate(i,r);for(let l=0;l<o.length;l+=3)s.push(o.slice(l,l+3));return s}}function Hy(n){const e=n.length;e>2&&n[e-1].equals(n[0])&&n.pop()}function Gy(n,e){for(let t=0;t<e.length;t++)n.push(e[t].x),n.push(e[t].y)}class vc extends ct{constructor(e=new is([new J(.5,.5),new J(-.5,.5),new J(-.5,-.5),new J(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const i=this,r=[],s=[];for(let o=0,l=e.length;o<l;o++){const c=e[o];a(c)}this.setAttribute("position",new De(r,3)),this.setAttribute("uv",new De(s,2)),this.computeVertexNormals();function a(o){const l=[],c=t.curveSegments!==void 0?t.curveSegments:12,u=t.steps!==void 0?t.steps:1,h=t.depth!==void 0?t.depth:1;let d=t.bevelEnabled!==void 0?t.bevelEnabled:!0,p=t.bevelThickness!==void 0?t.bevelThickness:.2,m=t.bevelSize!==void 0?t.bevelSize:p-.1,v=t.bevelOffset!==void 0?t.bevelOffset:0,f=t.bevelSegments!==void 0?t.bevelSegments:3;const g=t.extrudePath,x=t.UVGenerator!==void 0?t.UVGenerator:wI;let y,_=!1,I,b,w,C;g&&(y=g.getSpacedPoints(u),_=!0,d=!1,I=g.computeFrenetFrames(u,!1),b=new N,w=new N,C=new N),d||(f=0,p=0,m=0,v=0);const H=o.extractPoints(c);let M=H.shape;const T=H.holes;if(!nn.isClockWise(M)){M=M.reverse();for(let ce=0,ue=T.length;ce<ue;ce++){const L=T[ce];nn.isClockWise(L)&&(T[ce]=L.reverse())}}const k=nn.triangulateShape(M,T),j=M;for(let ce=0,ue=T.length;ce<ue;ce++){const L=T[ce];M=M.concat(L)}function Y(ce,ue,L){return ue||console.error("THREE.ExtrudeGeometry: vec does not exist"),ce.clone().addScaledVector(ue,L)}const re=M.length,$=k.length;function he(ce,ue,L){let He,pe,Ue;const we=ce.x-ue.x,$e=ce.y-ue.y,Be=L.x-ce.x,R=L.y-ce.y,S=we*we+$e*$e,W=we*R-$e*Be;if(Math.abs(W)>Number.EPSILON){const ne=Math.sqrt(S),de=Math.sqrt(Be*Be+R*R),se=ue.x-$e/ne,ke=ue.y+we/ne,Ee=L.x-R/de,Pe=L.y+Be/de,mt=((Ee-se)*R-(Pe-ke)*Be)/(we*R-$e*Be);He=se+we*mt-ce.x,pe=ke+$e*mt-ce.y;const ve=He*He+pe*pe;if(ve<=2)return new J(He,pe);Ue=Math.sqrt(ve/2)}else{let ne=!1;we>Number.EPSILON?Be>Number.EPSILON&&(ne=!0):we<-Number.EPSILON?Be<-Number.EPSILON&&(ne=!0):Math.sign($e)===Math.sign(R)&&(ne=!0),ne?(He=-$e,pe=we,Ue=Math.sqrt(S)):(He=we,pe=$e,Ue=Math.sqrt(S/2))}return new J(He/Ue,pe/Ue)}const Q=[];for(let ce=0,ue=j.length,L=ue-1,He=ce+1;ce<ue;ce++,L++,He++)L===ue&&(L=0),He===ue&&(He=0),Q[ce]=he(j[ce],j[L],j[He]);const ye=[];let be,Ve=Q.concat();for(let ce=0,ue=T.length;ce<ue;ce++){const L=T[ce];be=[];for(let He=0,pe=L.length,Ue=pe-1,we=He+1;He<pe;He++,Ue++,we++)Ue===pe&&(Ue=0),we===pe&&(we=0),be[He]=he(L[He],L[Ue],L[we]);ye.push(be),Ve=Ve.concat(be)}for(let ce=0;ce<f;ce++){const ue=ce/f,L=p*Math.cos(ue*Math.PI/2),He=m*Math.sin(ue*Math.PI/2)+v;for(let pe=0,Ue=j.length;pe<Ue;pe++){const we=Y(j[pe],Q[pe],He);Te(we.x,we.y,-L)}for(let pe=0,Ue=T.length;pe<Ue;pe++){const we=T[pe];be=ye[pe];for(let $e=0,Be=we.length;$e<Be;$e++){const R=Y(we[$e],be[$e],He);Te(R.x,R.y,-L)}}}const at=m+v;for(let ce=0;ce<re;ce++){const ue=d?Y(M[ce],Ve[ce],at):M[ce];_?(w.copy(I.normals[0]).multiplyScalar(ue.x),b.copy(I.binormals[0]).multiplyScalar(ue.y),C.copy(y[0]).add(w).add(b),Te(C.x,C.y,C.z)):Te(ue.x,ue.y,0)}for(let ce=1;ce<=u;ce++)for(let ue=0;ue<re;ue++){const L=d?Y(M[ue],Ve[ue],at):M[ue];_?(w.copy(I.normals[ce]).multiplyScalar(L.x),b.copy(I.binormals[ce]).multiplyScalar(L.y),C.copy(y[ce]).add(w).add(b),Te(C.x,C.y,C.z)):Te(L.x,L.y,h/u*ce)}for(let ce=f-1;ce>=0;ce--){const ue=ce/f,L=p*Math.cos(ue*Math.PI/2),He=m*Math.sin(ue*Math.PI/2)+v;for(let pe=0,Ue=j.length;pe<Ue;pe++){const we=Y(j[pe],Q[pe],He);Te(we.x,we.y,h+L)}for(let pe=0,Ue=T.length;pe<Ue;pe++){const we=T[pe];be=ye[pe];for(let $e=0,Be=we.length;$e<Be;$e++){const R=Y(we[$e],be[$e],He);_?Te(R.x,R.y+y[u-1].y,y[u-1].x+L):Te(R.x,R.y,h+L)}}}et(),ie();function et(){const ce=r.length/3;if(d){let ue=0,L=re*ue;for(let He=0;He<$;He++){const pe=k[He];Se(pe[2]+L,pe[1]+L,pe[0]+L)}ue=u+f*2,L=re*ue;for(let He=0;He<$;He++){const pe=k[He];Se(pe[0]+L,pe[1]+L,pe[2]+L)}}else{for(let ue=0;ue<$;ue++){const L=k[ue];Se(L[2],L[1],L[0])}for(let ue=0;ue<$;ue++){const L=k[ue];Se(L[0]+re*u,L[1]+re*u,L[2]+re*u)}}i.addGroup(ce,r.length/3-ce,0)}function ie(){const ce=r.length/3;let ue=0;le(j,ue),ue+=j.length;for(let L=0,He=T.length;L<He;L++){const pe=T[L];le(pe,ue),ue+=pe.length}i.addGroup(ce,r.length/3-ce,1)}function le(ce,ue){let L=ce.length;for(;--L>=0;){const He=L;let pe=L-1;pe<0&&(pe=ce.length-1);for(let Ue=0,we=u+f*2;Ue<we;Ue++){const $e=re*Ue,Be=re*(Ue+1),R=ue+He+$e,S=ue+pe+$e,W=ue+pe+Be,ne=ue+He+Be;Ye(R,S,W,ne)}}}function Te(ce,ue,L){l.push(ce),l.push(ue),l.push(L)}function Se(ce,ue,L){We(ce),We(ue),We(L);const He=r.length/3,pe=x.generateTopUV(i,r,He-3,He-2,He-1);ot(pe[0]),ot(pe[1]),ot(pe[2])}function Ye(ce,ue,L,He){We(ce),We(ue),We(He),We(ue),We(L),We(He);const pe=r.length/3,Ue=x.generateSideWallUV(i,r,pe-6,pe-3,pe-2,pe-1);ot(Ue[0]),ot(Ue[1]),ot(Ue[3]),ot(Ue[1]),ot(Ue[2]),ot(Ue[3])}function We(ce){r.push(l[ce*3+0]),r.push(l[ce*3+1]),r.push(l[ce*3+2])}function ot(ce){s.push(ce.x),s.push(ce.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes,i=this.parameters.options;return EI(t,i,e)}static fromJSON(e,t){const i=[];for(let s=0,a=e.shapes.length;s<a;s++){const o=t[e.shapes[s]];i.push(o)}const r=e.options.extrudePath;return r!==void 0&&(e.options.extrudePath=new Qu[r.type]().fromJSON(r)),new vc(i,e.options)}}const wI={generateTopUV:function(n,e,t,i,r){const s=e[t*3],a=e[t*3+1],o=e[i*3],l=e[i*3+1],c=e[r*3],u=e[r*3+1];return[new J(s,a),new J(o,l),new J(c,u)]},generateSideWallUV:function(n,e,t,i,r,s){const a=e[t*3],o=e[t*3+1],l=e[t*3+2],c=e[i*3],u=e[i*3+1],h=e[i*3+2],d=e[r*3],p=e[r*3+1],m=e[r*3+2],v=e[s*3],f=e[s*3+1],g=e[s*3+2];return Math.abs(o-u)<Math.abs(a-c)?[new J(a,1-l),new J(c,1-h),new J(d,1-m),new J(v,1-g)]:[new J(o,1-l),new J(u,1-h),new J(p,1-m),new J(f,1-g)]}};function EI(n,e,t){if(t.shapes=[],Array.isArray(n))for(let i=0,r=n.length;i<r;i++){const s=n[i];t.shapes.push(s.uuid)}else t.shapes.push(n.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}class Ld extends ms{constructor(e=1,t=0){const i=(1+Math.sqrt(5))/2,r=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(r,s,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Ld(e.radius,e.detail)}}class So extends ms{constructor(e=1,t=0){const i=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],r=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(i,r,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new So(e.radius,e.detail)}}class yc extends ct{constructor(e=.5,t=1,i=32,r=1,s=0,a=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:i,phiSegments:r,thetaStart:s,thetaLength:a},i=Math.max(3,i),r=Math.max(1,r);const o=[],l=[],c=[],u=[];let h=e;const d=(t-e)/r,p=new N,m=new J;for(let v=0;v<=r;v++){for(let f=0;f<=i;f++){const g=s+f/i*a;p.x=h*Math.cos(g),p.y=h*Math.sin(g),l.push(p.x,p.y,p.z),c.push(0,0,1),m.x=(p.x/t+1)/2,m.y=(p.y/t+1)/2,u.push(m.x,m.y)}h+=d}for(let v=0;v<r;v++){const f=v*(i+1);for(let g=0;g<i;g++){const x=g+f,y=x,_=x+i+1,I=x+i+2,b=x+1;o.push(y,_,b),o.push(_,I,b)}}this.setIndex(o),this.setAttribute("position",new De(l,3)),this.setAttribute("normal",new De(c,3)),this.setAttribute("uv",new De(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new yc(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class Pd extends ct{constructor(e=new is([new J(0,.5),new J(-.5,-.5),new J(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const i=[],r=[],s=[],a=[];let o=0,l=0;if(Array.isArray(e)===!1)c(e);else for(let u=0;u<e.length;u++)c(e[u]),this.addGroup(o,l,u),o+=l,l=0;this.setIndex(i),this.setAttribute("position",new De(r,3)),this.setAttribute("normal",new De(s,3)),this.setAttribute("uv",new De(a,2));function c(u){const h=r.length/3,d=u.extractPoints(t);let p=d.shape;const m=d.holes;nn.isClockWise(p)===!1&&(p=p.reverse());for(let f=0,g=m.length;f<g;f++){const x=m[f];nn.isClockWise(x)===!0&&(m[f]=x.reverse())}const v=nn.triangulateShape(p,m);for(let f=0,g=m.length;f<g;f++){const x=m[f];p=p.concat(x)}for(let f=0,g=p.length;f<g;f++){const x=p[f];r.push(x.x,x.y,0),s.push(0,0,1),a.push(x.x,x.y)}for(let f=0,g=v.length;f<g;f++){const x=v[f],y=x[0]+h,_=x[1]+h,I=x[2]+h;i.push(y,_,I),l+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes;return AI(t,e)}static fromJSON(e,t){const i=[];for(let r=0,s=e.shapes.length;r<s;r++){const a=t[e.shapes[r]];i.push(a)}return new Pd(i,e.curveSegments)}}function AI(n,e){if(e.shapes=[],Array.isArray(n))for(let t=0,i=n.length;t<i;t++){const r=n[t];e.shapes.push(r.uuid)}else e.shapes.push(n.uuid);return e}class wo extends ct{constructor(e=1,t=32,i=16,r=0,s=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:s,thetaStart:a,thetaLength:o},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));const l=Math.min(a+o,Math.PI);let c=0;const u=[],h=new N,d=new N,p=[],m=[],v=[],f=[];for(let g=0;g<=i;g++){const x=[],y=g/i;let _=0;g===0&&a===0?_=.5/t:g===i&&l===Math.PI&&(_=-.5/t);for(let I=0;I<=t;I++){const b=I/t;h.x=-e*Math.cos(r+b*s)*Math.sin(a+y*o),h.y=e*Math.cos(a+y*o),h.z=e*Math.sin(r+b*s)*Math.sin(a+y*o),m.push(h.x,h.y,h.z),d.copy(h).normalize(),v.push(d.x,d.y,d.z),f.push(b+_,1-y),x.push(c++)}u.push(x)}for(let g=0;g<i;g++)for(let x=0;x<t;x++){const y=u[g][x+1],_=u[g][x],I=u[g+1][x],b=u[g+1][x+1];(g!==0||a>0)&&p.push(y,_,b),(g!==i-1||l<Math.PI)&&p.push(_,I,b)}this.setIndex(p),this.setAttribute("position",new De(m,3)),this.setAttribute("normal",new De(v,3)),this.setAttribute("uv",new De(f,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new wo(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class Dd extends ms{constructor(e=1,t=0){const i=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],r=[2,1,0,0,3,2,1,3,0,2,3,1];super(i,r,e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Dd(e.radius,e.detail)}}class xc extends ct{constructor(e=1,t=.4,i=12,r=48,s=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:r,arc:s},i=Math.floor(i),r=Math.floor(r);const a=[],o=[],l=[],c=[],u=new N,h=new N,d=new N;for(let p=0;p<=i;p++)for(let m=0;m<=r;m++){const v=m/r*s,f=p/i*Math.PI*2;h.x=(e+t*Math.cos(f))*Math.cos(v),h.y=(e+t*Math.cos(f))*Math.sin(v),h.z=t*Math.sin(f),o.push(h.x,h.y,h.z),u.x=e*Math.cos(v),u.y=e*Math.sin(v),d.subVectors(h,u).normalize(),l.push(d.x,d.y,d.z),c.push(m/r),c.push(p/i)}for(let p=1;p<=i;p++)for(let m=1;m<=r;m++){const v=(r+1)*p+m-1,f=(r+1)*(p-1)+m-1,g=(r+1)*(p-1)+m,x=(r+1)*p+m;a.push(v,f,x),a.push(f,g,x)}this.setIndex(a),this.setAttribute("position",new De(o,3)),this.setAttribute("normal",new De(l,3)),this.setAttribute("uv",new De(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new xc(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class Ud extends ct{constructor(e=1,t=.4,i=64,r=8,s=2,a=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:r,p:s,q:a},i=Math.floor(i),r=Math.floor(r);const o=[],l=[],c=[],u=[],h=new N,d=new N,p=new N,m=new N,v=new N,f=new N,g=new N;for(let y=0;y<=i;++y){const _=y/i*s*Math.PI*2;x(_,s,a,e,p),x(_+.01,s,a,e,m),f.subVectors(m,p),g.addVectors(m,p),v.crossVectors(f,g),g.crossVectors(v,f),v.normalize(),g.normalize();for(let I=0;I<=r;++I){const b=I/r*Math.PI*2,w=-t*Math.cos(b),C=t*Math.sin(b);h.x=p.x+(w*g.x+C*v.x),h.y=p.y+(w*g.y+C*v.y),h.z=p.z+(w*g.z+C*v.z),l.push(h.x,h.y,h.z),d.subVectors(h,p).normalize(),c.push(d.x,d.y,d.z),u.push(y/i),u.push(I/r)}}for(let y=1;y<=i;y++)for(let _=1;_<=r;_++){const I=(r+1)*(y-1)+(_-1),b=(r+1)*y+(_-1),w=(r+1)*y+_,C=(r+1)*(y-1)+_;o.push(I,b,C),o.push(b,w,C)}this.setIndex(o),this.setAttribute("position",new De(l,3)),this.setAttribute("normal",new De(c,3)),this.setAttribute("uv",new De(u,2));function x(y,_,I,b,w){const C=Math.cos(y),H=Math.sin(y),M=I/_*y,T=Math.cos(M);w.x=b*(2+T)*.5*C,w.y=b*(2+T)*H*.5,w.z=b*Math.sin(M)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ud(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class Od extends ct{constructor(e=new _m(new N(-1,-1,0),new N(-1,1,0),new N(1,1,0)),t=64,i=1,r=8,s=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:i,radialSegments:r,closed:s};const a=e.computeFrenetFrames(t,s);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals;const o=new N,l=new N,c=new J;let u=new N;const h=[],d=[],p=[],m=[];v(),this.setIndex(m),this.setAttribute("position",new De(h,3)),this.setAttribute("normal",new De(d,3)),this.setAttribute("uv",new De(p,2));function v(){for(let y=0;y<t;y++)f(y);f(s===!1?t:0),x(),g()}function f(y){u=e.getPointAt(y/t,u);const _=a.normals[y],I=a.binormals[y];for(let b=0;b<=r;b++){const w=b/r*Math.PI*2,C=Math.sin(w),H=-Math.cos(w);l.x=H*_.x+C*I.x,l.y=H*_.y+C*I.y,l.z=H*_.z+C*I.z,l.normalize(),d.push(l.x,l.y,l.z),o.x=u.x+i*l.x,o.y=u.y+i*l.y,o.z=u.z+i*l.z,h.push(o.x,o.y,o.z)}}function g(){for(let y=1;y<=t;y++)for(let _=1;_<=r;_++){const I=(r+1)*(y-1)+(_-1),b=(r+1)*y+(_-1),w=(r+1)*y+_,C=(r+1)*(y-1)+_;m.push(I,b,C),m.push(b,w,C)}}function x(){for(let y=0;y<=t;y++)for(let _=0;_<=r;_++)c.x=y/t,c.y=_/r,p.push(c.x,c.y)}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new Od(new Qu[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class Em extends ct{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const t=[],i=new Set,r=new N,s=new N;if(e.index!==null){const a=e.attributes.position,o=e.index;let l=e.groups;l.length===0&&(l=[{start:0,count:o.count,materialIndex:0}]);for(let c=0,u=l.length;c<u;++c){const h=l[c],d=h.start,p=h.count;for(let m=d,v=d+p;m<v;m+=3)for(let f=0;f<3;f++){const g=o.getX(m+f),x=o.getX(m+(f+1)%3);r.fromBufferAttribute(a,g),s.fromBufferAttribute(a,x),Wy(r,s,i)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}}else{const a=e.attributes.position;for(let o=0,l=a.count/3;o<l;o++)for(let c=0;c<3;c++){const u=3*o+c,h=3*o+(c+1)%3;r.fromBufferAttribute(a,u),s.fromBufferAttribute(a,h),Wy(r,s,i)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}this.setAttribute("position",new De(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function Wy(n,e,t){const i=`${n.x},${n.y},${n.z}-${e.x},${e.y},${e.z}`,r=`${e.x},${e.y},${e.z}-${n.x},${n.y},${n.z}`;return t.has(i)===!0||t.has(r)===!0?!1:(t.add(i),t.add(r),!0)}var jy=Object.freeze({__proto__:null,BoxGeometry:yn,CapsuleGeometry:Nd,CircleGeometry:Cd,ConeGeometry:Rd,CylinderGeometry:ha,DodecahedronGeometry:Id,EdgesGeometry:Tm,ExtrudeGeometry:vc,IcosahedronGeometry:Ld,LatheGeometry:gc,OctahedronGeometry:So,PlaneGeometry:ua,PolyhedronGeometry:ms,RingGeometry:yc,ShapeGeometry:Pd,SphereGeometry:wo,TetrahedronGeometry:Dd,TorusGeometry:xc,TorusKnotGeometry:Ud,TubeGeometry:Od,WireframeGeometry:Em});class ah extends hi{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new xe(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}}class Am extends Pr{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Sl extends hi{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new xe(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 xe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new dr,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class oh extends Sl{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new J(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Jt(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 xe(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 xe(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new xe(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class lh extends hi{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new xe(16777215),this.specular=new xe(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new xe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new dr,this.combine=pa,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Nm extends hi{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new xe(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new xe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class ch extends hi{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class uh extends hi{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new xe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new xe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new dr,this.combine=pa,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Cm extends hi{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new xe(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class hh extends Ni{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function Bs(n,e,t){return!n||!t&&n.constructor===e?n:typeof e.BYTES_PER_ELEMENT=="number"?new e(n):Array.prototype.slice.call(n)}function Xy(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function qy(n){function e(r,s){return n[r]-n[s]}const t=n.length,i=new Array(t);for(let r=0;r!==t;++r)i[r]=r;return i.sort(e),i}function Rm(n,e,t){const i=n.length,r=new n.constructor(i);for(let s=0,a=0;a!==i;++s){const o=t[s]*e;for(let l=0;l!==e;++l)r[a++]=n[o+l]}return r}function Im(n,e,t,i){let r=1,s=n[0];for(;s!==void 0&&s[i]===void 0;)s=n[r++];if(s===void 0)return;let a=s[i];if(a!==void 0)if(Array.isArray(a))do a=s[i],a!==void 0&&(e.push(s.time),t.push.apply(t,a)),s=n[r++];while(s!==void 0);else if(a.toArray!==void 0)do a=s[i],a!==void 0&&(e.push(s.time),a.toArray(t,t.length)),s=n[r++];while(s!==void 0);else do a=s[i],a!==void 0&&(e.push(s.time),t.push(a)),s=n[r++];while(s!==void 0)}function NI(n,e,t,i,r=30){const s=n.clone();s.name=e;const a=[];for(let l=0;l<s.tracks.length;++l){const c=s.tracks[l],u=c.getValueSize(),h=[],d=[];for(let p=0;p<c.times.length;++p){const m=c.times[p]*r;if(!(m<t||m>=i)){h.push(c.times[p]);for(let v=0;v<u;++v)d.push(c.values[p*u+v])}}h.length!==0&&(c.times=Bs(h,c.times.constructor),c.values=Bs(d,c.values.constructor),a.push(c))}s.tracks=a;let o=1/0;for(let l=0;l<s.tracks.length;++l)o>s.tracks[l].times[0]&&(o=s.tracks[l].times[0]);for(let l=0;l<s.tracks.length;++l)s.tracks[l].shift(-1*o);return s.resetDuration(),s}function CI(n,e=0,t=n,i=30){i<=0&&(i=30);const r=t.tracks.length,s=e/i;for(let a=0;a<r;++a){const o=t.tracks[a],l=o.ValueTypeName;if(l==="bool"||l==="string")continue;const c=n.tracks.find(function(g){return g.name===o.name&&g.ValueTypeName===l});if(c===void 0)continue;let u=0;const h=o.getValueSize();o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(u=h/3);let d=0;const p=c.getValueSize();c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(d=p/3);const m=o.times.length-1;let v;if(s<=o.times[0]){const g=u,x=h-u;v=o.values.slice(g,x)}else if(s>=o.times[m]){const g=m*h+u,x=g+h-u;v=o.values.slice(g,x)}else{const g=o.createInterpolant(),x=u,y=h-u;g.evaluate(s),v=g.resultBuffer.slice(x,y)}l==="quaternion"&&new qi().fromArray(v).normalize().conjugate().toArray(v);const f=c.times.length;for(let g=0;g<f;++g){const x=g*p+d;if(l==="quaternion")qi.multiplyQuaternionsFlat(c.values,x,v,0,c.values,x);else{const y=p-d*2;for(let _=0;_<y;++_)c.values[x+_]-=v[_]}}}return n.blendMode=lp,n}const RI={convertArray:Bs,isTypedArray:Xy,getKeyframeOrder:qy,sortedArray:Rm,flattenJSON:Im,subclip:NI,makeClipAdditive:CI};class Za{constructor(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let i=this._cachedIndex,r=t[i],s=t[i-1];e:{t:{let a;i:{r:if(!(e<r)){for(let o=i+2;;){if(r===void 0){if(e<s)break r;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===o)break;if(s=r,r=t[++i],e<r)break t}a=t.length;break i}if(!(e>=s)){const o=t[1];e<o&&(i=2,s=o);for(let l=i-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===l)break;if(r=s,s=t[--i-1],e>=s)break t}a=i,i=0;break i}break e}for(;i<a;){const o=i+a>>>1;e<t[o]?a=o:i=o+1}if(r=t[i],s=t[i-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,s,r)}return this.interpolate_(i,s,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,s=e*r;for(let a=0;a!==r;++a)t[a]=i[s+a];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class Yy extends Za{constructor(e,t,i,r){super(e,t,i,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:xs,endingEnd:xs}}intervalChanged_(e,t,i){const r=this.parameterPositions;let s=e-2,a=e+1,o=r[s],l=r[a];if(o===void 0)switch(this.getSettings_().endingStart){case _s:s=e,o=2*t-i;break;case Xo:s=r.length-2,o=t+r[s]-r[s+1];break;default:s=e,o=i}if(l===void 0)switch(this.getSettings_().endingEnd){case _s:a=e,l=2*i-t;break;case Xo:a=1,l=i+r[1]-r[0];break;default:a=e-1,l=t}const c=(i-t)*.5,u=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(l-i),this._offsetPrev=s*u,this._offsetNext=a*u}interpolate_(e,t,i,r){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,u=this._offsetPrev,h=this._offsetNext,d=this._weightPrev,p=this._weightNext,m=(i-t)/(r-t),v=m*m,f=v*m,g=-d*f+2*d*v-d*m,x=(1+d)*f+(-1.5-2*d)*v+(-.5+d)*m+1,y=(-1-p)*f+(1.5+p)*v+.5*m,_=p*f-p*v;for(let I=0;I!==o;++I)s[I]=g*a[u+I]+x*a[c+I]+y*a[l+I]+_*a[h+I];return s}}class Lm extends Za{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,u=(i-t)/(r-t),h=1-u;for(let d=0;d!==o;++d)s[d]=a[c+d]*h+a[l+d]*u;return s}}class $y extends Za{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}}class Jr{constructor(e,t,i,r){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Bs(t,this.TimeBufferType),this.values=Bs(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:Bs(e.times,Array),values:Bs(e.values,Array)};const r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new $y(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Lm(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Yy(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Ma:t=this.InterpolantFactoryMethodDiscrete;break;case jo:t=this.InterpolantFactoryMethodLinear;break;case tu:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){const i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return console.warn("THREE.KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Ma;case this.InterpolantFactoryMethodLinear:return jo;case this.InterpolantFactoryMethodSmooth:return tu}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]*=e}return this}trim(e,t){const i=this.times,r=i.length;let s=0,a=r-1;for(;s!==r&&i[s]<e;)++s;for(;a!==-1&&i[a]>t;)--a;if(++a,s!==0||a!==r){s>=a&&(a=Math.max(a,1),s=a-1);const o=this.getValueSize();this.times=i.slice(s,a),this.values=this.values.slice(s*o,a*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const i=this.times,r=this.values,s=i.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==s;o++){const l=i[o];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,l),e=!1;break}if(a!==null&&a>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,l,a),e=!1;break}a=l}if(r!==void 0&&Xy(r))for(let o=0,l=r.length;o!==l;++o){const c=r[o];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),r=this.getInterpolation()===tu,s=e.length-1;let a=1;for(let o=1;o<s;++o){let l=!1;const c=e[o],u=e[o+1];if(c!==u&&(o!==1||c!==e[0]))if(r)l=!0;else{const h=o*i,d=h-i,p=h+i;for(let m=0;m!==i;++m){const v=t[h+m];if(v!==t[d+m]||v!==t[p+m]){l=!0;break}}}if(l){if(o!==a){e[a]=e[o];const h=o*i,d=a*i;for(let p=0;p!==i;++p)t[d+p]=t[h+p]}++a}}if(s>0){e[a]=e[s];for(let o=s*i,l=a*i,c=0;c!==i;++c)t[l+c]=t[o+c];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*i)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}}Jr.prototype.TimeBufferType=Float32Array,Jr.prototype.ValueBufferType=Float32Array,Jr.prototype.DefaultInterpolation=jo;class zs extends Jr{constructor(e,t,i){super(e,t,i)}}zs.prototype.ValueTypeName="bool",zs.prototype.ValueBufferType=Array,zs.prototype.DefaultInterpolation=Ma,zs.prototype.InterpolantFactoryMethodLinear=void 0,zs.prototype.InterpolantFactoryMethodSmooth=void 0;class dh extends Jr{}dh.prototype.ValueTypeName="color";class Qa extends Jr{}Qa.prototype.ValueTypeName="number";class Jy extends Za{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=(i-t)/(r-t);let c=e*o;for(let u=c+o;c!==u;c+=4)qi.slerpFlat(s,0,a,c-o,a,c,l);return s}}class eo extends Jr{InterpolantFactoryMethodLinear(e){return new Jy(this.times,this.values,this.getValueSize(),e)}}eo.prototype.ValueTypeName="quaternion",eo.prototype.InterpolantFactoryMethodSmooth=void 0;class ks extends Jr{constructor(e,t,i){super(e,t,i)}}ks.prototype.ValueTypeName="string",ks.prototype.ValueBufferType=Array,ks.prototype.DefaultInterpolation=Ma,ks.prototype.InterpolantFactoryMethodLinear=void 0,ks.prototype.InterpolantFactoryMethodSmooth=void 0;class to extends Jr{}to.prototype.ValueTypeName="vector";class io{constructor(e="",t=-1,i=[],r=iu){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=yr(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],i=e.tracks,r=1/(e.fps||1);for(let a=0,o=i.length;a!==o;++a)t.push(LI(i[a]).scale(r));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){const t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,a=i.length;s!==a;++s)t.push(Jr.toJSON(i[s]));return r}static CreateFromMorphTargetSequence(e,t,i,r){const s=t.length,a=[];for(let o=0;o<s;o++){let l=[],c=[];l.push((o+s-1)%s,o,(o+1)%s),c.push(0,1,0);const u=qy(l);l=Rm(l,1,u),c=Rm(c,1,u),!r&&l[0]===0&&(l.push(s),c.push(c[0])),a.push(new Qa(".morphTargetInfluences["+t[o].name+"]",l,c).scale(1/i))}return new this(e,-1,a)}static findByName(e,t){let i=e;if(!Array.isArray(e)){const r=e;i=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<i.length;r++)if(i[r].name===t)return i[r];return null}static CreateClipsFromMorphTargetSequences(e,t,i){const r={},s=/^([\w-]*?)([\d]+)$/;for(let o=0,l=e.length;o<l;o++){const c=e[o],u=c.name.match(s);if(u&&u.length>1){const h=u[1];let d=r[h];d||(r[h]=d=[]),d.push(c)}}const a=[];for(const o in r)a.push(this.CreateFromMorphTargetSequence(o,r[o],t,i));return a}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const i=function(u,h,d,p,m){if(d.length!==0){const v=[],f=[];Im(d,v,f,p),v.length!==0&&m.push(new u(h,v,f))}},r=[],s=e.name||"default",a=e.fps||30,o=e.blendMode;let l=e.length||-1;const c=e.hierarchy||[];for(let u=0;u<c.length;u++){const h=c[u].keys;if(!(!h||h.length===0))if(h[0].morphTargets){const d={};let p;for(p=0;p<h.length;p++)if(h[p].morphTargets)for(let m=0;m<h[p].morphTargets.length;m++)d[h[p].morphTargets[m]]=-1;for(const m in d){const v=[],f=[];for(let g=0;g!==h[p].morphTargets.length;++g){const x=h[p];v.push(x.time),f.push(x.morphTarget===m?1:0)}r.push(new Qa(".morphTargetInfluence["+m+"]",v,f))}l=d.length*a}else{const d=".bones["+t[u].name+"]";i(to,d+".position",h,"pos",r),i(eo,d+".quaternion",h,"rot",r),i(to,d+".scale",h,"scl",r)}}return r.length===0?null:new this(s,l,r,o)}resetDuration(){const e=this.tracks;let t=0;for(let i=0,r=e.length;i!==r;++i){const s=this.tracks[i];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function II(n){switch(n.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Qa;case"vector":case"vector2":case"vector3":case"vector4":return to;case"color":return dh;case"quaternion":return eo;case"bool":case"boolean":return zs;case"string":return ks}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+n)}function LI(n){if(n.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=II(n.type);if(n.times===void 0){const t=[],i=[];Im(n.keys,t,i,"value"),n.times=t,n.values=i}return e.parse!==void 0?e.parse(n):new e(n.name,n.times,n.values,n.interpolation)}const Rn={enabled:!1,files:{},add:function(n,e){this.enabled!==!1&&(this.files[n]=e)},get:function(n){if(this.enabled!==!1)return this.files[n]},remove:function(n){delete this.files[n]},clear:function(){this.files={}}};class ph{constructor(e,t,i){const r=this;let s=!1,a=0,o=0,l;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(u){o++,s===!1&&r.onStart!==void 0&&r.onStart(u,a,o),s=!0},this.itemEnd=function(u){a++,r.onProgress!==void 0&&r.onProgress(u,a,o),a===o&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(u){r.onError!==void 0&&r.onError(u)},this.resolveURL=function(u){return l?l(u):u},this.setURLModifier=function(u){return l=u,this},this.addHandler=function(u,h){return c.push(u,h),this},this.removeHandler=function(u){const h=c.indexOf(u);return h!==-1&&c.splice(h,2),this},this.getHandler=function(u){for(let h=0,d=c.length;h<d;h+=2){const p=c[h],m=c[h+1];if(p.global&&(p.lastIndex=0),p.test(u))return m}return null}}}const Pm=new ph;class Hi{constructor(e){this.manager=e!==void 0?e:Pm,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const i=this;return new Promise(function(r,s){i.load(e,r,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}Hi.DEFAULT_MATERIAL_NAME="__DEFAULT";const In={};class PI extends Error{constructor(e,t){super(e),this.response=t}}class Kr extends Hi{constructor(e){super(e)}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=Rn.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(In[e]!==void 0){In[e].push({onLoad:t,onProgress:i,onError:r});return}In[e]=[],In[e].push({onLoad:t,onProgress:i,onError:r});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),o=this.mimeType,l=this.responseType;fetch(a).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const u=In[e],h=c.body.getReader(),d=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),p=d?parseInt(d):0,m=p!==0;let v=0;const f=new ReadableStream({start(g){x();function x(){h.read().then(({done:y,value:_})=>{if(y)g.close();else{v+=_.byteLength;const I=new ProgressEvent("progress",{lengthComputable:m,loaded:v,total:p});for(let b=0,w=u.length;b<w;b++){const C=u[b];C.onProgress&&C.onProgress(I)}g.enqueue(_),x()}},y=>{g.error(y)})}}});return new Response(f)}else throw new PI(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(u=>new DOMParser().parseFromString(u,o));case"json":return c.json();default:if(o===void 0)return c.text();{const u=/charset="?([^;"\s]*)"?/i.exec(o),h=u&&u[1]?u[1].toLowerCase():void 0,d=new TextDecoder(h);return c.arrayBuffer().then(p=>d.decode(p))}}}).then(c=>{Rn.add(e,c);const u=In[e];delete In[e];for(let h=0,d=u.length;h<d;h++){const p=u[h];p.onLoad&&p.onLoad(c)}}).catch(c=>{const u=In[e];if(u===void 0)throw this.manager.itemError(e),c;delete In[e];for(let h=0,d=u.length;h<d;h++){const p=u[h];p.onError&&p.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class DI extends Hi{constructor(e){super(e)}load(e,t,i,r){const s=this,a=new Kr(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(o){try{t(s.parse(JSON.parse(o)))}catch(l){r?r(l):console.error(l),s.manager.itemError(e)}},i,r)}parse(e){const t=[];for(let i=0;i<e.length;i++){const r=io.parse(e[i]);t.push(r)}return t}}class UI extends Hi{constructor(e){super(e)}load(e,t,i,r){const s=this,a=[],o=new vl,l=new Kr(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(s.withCredentials);let c=0;function u(h){l.load(e[h],function(d){const p=s.parse(d,!0);a[h]={width:p.width,height:p.height,format:p.format,mipmaps:p.mipmaps},c+=1,c===6&&(p.mipmapCount===1&&(o.minFilter=Lt),o.image=a,o.format=p.format,o.needsUpdate=!0,t&&t(o))},i,r)}if(Array.isArray(e))for(let h=0,d=e.length;h<d;++h)u(h);else l.load(e,function(h){const d=s.parse(h,!0);if(d.isCubemap){const p=d.mipmaps.length/d.mipmapCount;for(let m=0;m<p;m++){a[m]={mipmaps:[]};for(let v=0;v<d.mipmapCount;v++)a[m].mipmaps.push(d.mipmaps[m*d.mipmapCount+v]),a[m].format=d.format,a[m].width=d.width,a[m].height=d.height}o.image=a}else o.image.width=d.width,o.image.height=d.height,o.mipmaps=d.mipmaps;d.mipmapCount===1&&(o.minFilter=Lt),o.format=d.format,o.needsUpdate=!0,t&&t(o)},i,r);return o}}class wl extends Hi{constructor(e){super(e)}load(e,t,i,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=Rn.get(e);if(a!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a;const o=Zo("img");function l(){u(),Rn.add(e,this),t&&t(this),s.manager.itemEnd(e)}function c(h){u(),r&&r(h),s.manager.itemError(e),s.manager.itemEnd(e)}function u(){o.removeEventListener("load",l,!1),o.removeEventListener("error",c,!1)}return o.addEventListener("load",l,!1),o.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),s.manager.itemStart(e),o.src=e,o}}class OI extends Hi{constructor(e){super(e)}load(e,t,i,r){const s=new Ns;s.colorSpace=Fi;const a=new wl(this.manager);a.setCrossOrigin(this.crossOrigin),a.setPath(this.path);let o=0;function l(c){a.load(e[c],function(u){s.images[c]=u,o++,o===6&&(s.needsUpdate=!0,t&&t(s))},void 0,r)}for(let c=0;c<e.length;++c)l(c);return s}}class Ky extends Hi{constructor(e){super(e)}load(e,t,i,r){const s=this,a=new Ur,o=new Kr(this.manager);return o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setPath(this.path),o.setWithCredentials(s.withCredentials),o.load(e,function(l){let c;try{c=s.parse(l)}catch(u){if(r!==void 0)r(u);else{console.error(u);return}}c.image!==void 0?a.image=c.image:c.data!==void 0&&(a.image.width=c.width,a.image.height=c.height,a.image.data=c.data),a.wrapS=c.wrapS!==void 0?c.wrapS:gr,a.wrapT=c.wrapT!==void 0?c.wrapT:gr,a.magFilter=c.magFilter!==void 0?c.magFilter:Lt,a.minFilter=c.minFilter!==void 0?c.minFilter:Lt,a.anisotropy=c.anisotropy!==void 0?c.anisotropy:1,c.colorSpace!==void 0&&(a.colorSpace=c.colorSpace),c.flipY!==void 0&&(a.flipY=c.flipY),c.format!==void 0&&(a.format=c.format),c.type!==void 0&&(a.type=c.type),c.mipmaps!==void 0&&(a.mipmaps=c.mipmaps,a.minFilter=ji),c.mipmapCount===1&&(a.minFilter=Lt),c.generateMipmaps!==void 0&&(a.generateMipmaps=c.generateMipmaps),a.needsUpdate=!0,t&&t(a,c)},i,r),a}}class Zy extends Hi{constructor(e){super(e)}load(e,t,i,r){const s=new Wt,a=new wl(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(o){s.image=o,s.needsUpdate=!0,t!==void 0&&t(s)},i,r),s}}class rs extends _t{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new xe(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(t.object.target=this.target.uuid),t}}class mh extends rs{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.groundColor=new xe(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const Dm=new Re,Qy=new N,ex=new N;class Um{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new J(512,512),this.map=null,this.mapPass=null,this.matrix=new Re,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new za,this._frameExtents=new J(1,1),this._viewportCount=1,this._viewports=[new st(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,i=this.matrix;Qy.setFromMatrixPosition(e.matrixWorld),t.position.copy(Qy),ex.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(ex),t.updateMatrixWorld(),Dm.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Dm),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(Dm)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class FI extends Um{constructor(){super(new di(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,i=Sa*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(i!==t.fov||r!==t.aspect||s!==t.far)&&(t.fov=i,t.aspect=r,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class El extends rs{constructor(e,t,i=0,r=Math.PI/3,s=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.target=new _t,this.distance=i,this.angle=r,this.penumbra=s,this.decay=a,this.map=null,this.shadow=new FI}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const tx=new Re,Al=new N,Om=new N;class VI extends Um{constructor(){super(new di(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new J(4,2),this._viewportCount=6,this._viewports=[new st(2,1,1,1),new st(0,1,1,1),new st(3,1,1,1),new st(1,1,1,1),new st(3,0,1,1),new st(1,0,1,1)],this._cubeDirections=[new N(1,0,0),new N(-1,0,0),new N(0,0,1),new N(0,0,-1),new N(0,1,0),new N(0,-1,0)],this._cubeUps=[new N(0,1,0),new N(0,1,0),new N(0,1,0),new N(0,1,0),new N(0,0,1),new N(0,0,-1)]}updateMatrices(e,t=0){const i=this.camera,r=this.matrix,s=e.distance||i.far;s!==i.far&&(i.far=s,i.updateProjectionMatrix()),Al.setFromMatrixPosition(e.matrixWorld),i.position.copy(Al),Om.copy(i.position),Om.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(Om),i.updateMatrixWorld(),r.makeTranslation(-Al.x,-Al.y,-Al.z),tx.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(tx)}}class fh extends rs{constructor(e,t,i=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=r,this.shadow=new VI}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class BI extends Um{constructor(){super(new Is(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class gh extends rs{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.target=new _t,this.shadow=new BI}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class vh extends rs{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class Fm extends rs{constructor(e,t,i=10,r=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=i,this.height=r}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){const t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}}class ix{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new N)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){const i=e.x,r=e.y,s=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.282095),t.addScaledVector(a[1],.488603*r),t.addScaledVector(a[2],.488603*s),t.addScaledVector(a[3],.488603*i),t.addScaledVector(a[4],1.092548*(i*r)),t.addScaledVector(a[5],1.092548*(r*s)),t.addScaledVector(a[6],.315392*(3*s*s-1)),t.addScaledVector(a[7],1.092548*(i*s)),t.addScaledVector(a[8],.546274*(i*i-r*r)),t}getIrradianceAt(e,t){const i=e.x,r=e.y,s=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.886227),t.addScaledVector(a[1],2*.511664*r),t.addScaledVector(a[2],2*.511664*s),t.addScaledVector(a[3],2*.511664*i),t.addScaledVector(a[4],2*.429043*i*r),t.addScaledVector(a[5],2*.429043*r*s),t.addScaledVector(a[6],.743125*s*s-.247708),t.addScaledVector(a[7],2*.429043*i*s),t.addScaledVector(a[8],.429043*(i*i-r*r)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let i=0;i<9;i++)this.coefficients[i].addScaledVector(e.coefficients[i],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let i=0;i<9;i++)this.coefficients[i].lerp(e.coefficients[i],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(e,t=0){const i=this.coefficients;for(let r=0;r<9;r++)i[r].fromArray(e,t+r*3);return this}toArray(e=[],t=0){const i=this.coefficients;for(let r=0;r<9;r++)i[r].toArray(e,t+r*3);return e}static getBasisAt(e,t){const i=e.x,r=e.y,s=e.z;t[0]=.282095,t[1]=.488603*r,t[2]=.488603*s,t[3]=.488603*i,t[4]=1.092548*i*r,t[5]=1.092548*r*s,t[6]=.315392*(3*s*s-1),t[7]=1.092548*i*s,t[8]=.546274*(i*i-r*r)}}class Vm extends rs{constructor(e=new ix,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}class _c extends Hi{constructor(e){super(e),this.textures={}}load(e,t,i,r){const s=this,a=new Kr(s.manager);a.setPath(s.path),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(o){try{t(s.parse(JSON.parse(o)))}catch(l){r?r(l):console.error(l),s.manager.itemError(e)}},i,r)}parse(e){const t=this.textures;function i(s){return t[s]===void 0&&console.warn("THREE.MaterialLoader: Undefined texture",s),t[s]}const r=this.createMaterialFromType(e.type);if(e.uuid!==void 0&&(r.uuid=e.uuid),e.name!==void 0&&(r.name=e.name),e.color!==void 0&&r.color!==void 0&&r.color.setHex(e.color),e.roughness!==void 0&&(r.roughness=e.roughness),e.metalness!==void 0&&(r.metalness=e.metalness),e.sheen!==void 0&&(r.sheen=e.sheen),e.sheenColor!==void 0&&(r.sheenColor=new xe().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(r.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&r.emissive!==void 0&&r.emissive.setHex(e.emissive),e.specular!==void 0&&r.specular!==void 0&&r.specular.setHex(e.specular),e.specularIntensity!==void 0&&(r.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&r.specularColor!==void 0&&r.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(r.shininess=e.shininess),e.clearcoat!==void 0&&(r.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(r.dispersion=e.dispersion),e.iridescence!==void 0&&(r.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(r.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(r.transmission=e.transmission),e.thickness!==void 0&&(r.thickness=e.thickness),e.attenuationDistance!==void 0&&(r.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&r.attenuationColor!==void 0&&r.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(r.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(r.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(r.fog=e.fog),e.flatShading!==void 0&&(r.flatShading=e.flatShading),e.blending!==void 0&&(r.blending=e.blending),e.combine!==void 0&&(r.combine=e.combine),e.side!==void 0&&(r.side=e.side),e.shadowSide!==void 0&&(r.shadowSide=e.shadowSide),e.opacity!==void 0&&(r.opacity=e.opacity),e.transparent!==void 0&&(r.transparent=e.transparent),e.alphaTest!==void 0&&(r.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(r.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(r.depthFunc=e.depthFunc),e.depthTest!==void 0&&(r.depthTest=e.depthTest),e.depthWrite!==void 0&&(r.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(r.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(r.blendSrc=e.blendSrc),e.blendDst!==void 0&&(r.blendDst=e.blendDst),e.blendEquation!==void 0&&(r.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(r.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(r.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(r.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&r.blendColor!==void 0&&r.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(r.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(r.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(r.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(r.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(r.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(r.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(r.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(r.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(r.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(r.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(r.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(r.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(r.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(r.rotation=e.rotation),e.linewidth!==void 0&&(r.linewidth=e.linewidth),e.dashSize!==void 0&&(r.dashSize=e.dashSize),e.gapSize!==void 0&&(r.gapSize=e.gapSize),e.scale!==void 0&&(r.scale=e.scale),e.polygonOffset!==void 0&&(r.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(r.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(r.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(r.dithering=e.dithering),e.alphaToCoverage!==void 0&&(r.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(r.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(r.forceSinglePass=e.forceSinglePass),e.visible!==void 0&&(r.visible=e.visible),e.toneMapped!==void 0&&(r.toneMapped=e.toneMapped),e.userData!==void 0&&(r.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?r.vertexColors=e.vertexColors>0:r.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const s in e.uniforms){const a=e.uniforms[s];switch(r.uniforms[s]={},a.type){case"t":r.uniforms[s].value=i(a.value);break;case"c":r.uniforms[s].value=new xe().setHex(a.value);break;case"v2":r.uniforms[s].value=new J().fromArray(a.value);break;case"v3":r.uniforms[s].value=new N().fromArray(a.value);break;case"v4":r.uniforms[s].value=new st().fromArray(a.value);break;case"m3":r.uniforms[s].value=new Ke().fromArray(a.value);break;case"m4":r.uniforms[s].value=new Re().fromArray(a.value);break;default:r.uniforms[s].value=a.value}}if(e.defines!==void 0&&(r.defines=e.defines),e.vertexShader!==void 0&&(r.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(r.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(r.glslVersion=e.glslVersion),e.extensions!==void 0)for(const s in e.extensions)r.extensions[s]=e.extensions[s];if(e.lights!==void 0&&(r.lights=e.lights),e.clipping!==void 0&&(r.clipping=e.clipping),e.size!==void 0&&(r.size=e.size),e.sizeAttenuation!==void 0&&(r.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(r.map=i(e.map)),e.matcap!==void 0&&(r.matcap=i(e.matcap)),e.alphaMap!==void 0&&(r.alphaMap=i(e.alphaMap)),e.bumpMap!==void 0&&(r.bumpMap=i(e.bumpMap)),e.bumpScale!==void 0&&(r.bumpScale=e.bumpScale),e.normalMap!==void 0&&(r.normalMap=i(e.normalMap)),e.normalMapType!==void 0&&(r.normalMapType=e.normalMapType),e.normalScale!==void 0){let s=e.normalScale;Array.isArray(s)===!1&&(s=[s,s]),r.normalScale=new J().fromArray(s)}return e.displacementMap!==void 0&&(r.displacementMap=i(e.displacementMap)),e.displacementScale!==void 0&&(r.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(r.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(r.roughnessMap=i(e.roughnessMap)),e.metalnessMap!==void 0&&(r.metalnessMap=i(e.metalnessMap)),e.emissiveMap!==void 0&&(r.emissiveMap=i(e.emissiveMap)),e.emissiveIntensity!==void 0&&(r.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(r.specularMap=i(e.specularMap)),e.specularIntensityMap!==void 0&&(r.specularIntensityMap=i(e.specularIntensityMap)),e.specularColorMap!==void 0&&(r.specularColorMap=i(e.specularColorMap)),e.envMap!==void 0&&(r.envMap=i(e.envMap)),e.envMapRotation!==void 0&&r.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(r.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(r.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(r.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(r.lightMap=i(e.lightMap)),e.lightMapIntensity!==void 0&&(r.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(r.aoMap=i(e.aoMap)),e.aoMapIntensity!==void 0&&(r.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(r.gradientMap=i(e.gradientMap)),e.clearcoatMap!==void 0&&(r.clearcoatMap=i(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(r.clearcoatRoughnessMap=i(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(r.clearcoatNormalMap=i(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(r.clearcoatNormalScale=new J().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(r.iridescenceMap=i(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(r.iridescenceThicknessMap=i(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(r.transmissionMap=i(e.transmissionMap)),e.thicknessMap!==void 0&&(r.thicknessMap=i(e.thicknessMap)),e.anisotropyMap!==void 0&&(r.anisotropyMap=i(e.anisotropyMap)),e.sheenColorMap!==void 0&&(r.sheenColorMap=i(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(r.sheenRoughnessMap=i(e.sheenRoughnessMap)),r}setTextures(e){return this.textures=e,this}createMaterialFromType(e){return _c.createMaterialFromType(e)}static createMaterialFromType(e){const t={ShadowMaterial:ah,SpriteMaterial:cl,RawShaderMaterial:Am,ShaderMaterial:Pr,PointsMaterial:Ja,MeshPhysicalMaterial:oh,MeshStandardMaterial:Sl,MeshPhongMaterial:lh,MeshToonMaterial:Nm,MeshNormalMaterial:ch,MeshLambertMaterial:uh,MeshDepthMaterial:Du,MeshDistanceMaterial:Xp,MeshBasicMaterial:Yr,MeshMatcapMaterial:Cm,LineDashedMaterial:hh,LineBasicMaterial:Ni,Material:hi};return new t[e]}}class yh{static decodeText(e){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let i=0,r=e.length;i<r;i++)t+=String.fromCharCode(e[i]);try{return decodeURIComponent(escape(t))}catch{return t}}static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class Bm extends ct{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){const e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}class rx extends Hi{constructor(e){super(e)}load(e,t,i,r){const s=this,a=new Kr(s.manager);a.setPath(s.path),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(o){try{t(s.parse(JSON.parse(o)))}catch(l){r?r(l):console.error(l),s.manager.itemError(e)}},i,r)}parse(e){const t={},i={};function r(d,p){if(t[p]!==void 0)return t[p];const m=d.interleavedBuffers[p],v=s(d,m.buffer),f=wa(m.type,v),g=new Wa(f,m.stride);return g.uuid=m.uuid,t[p]=g,g}function s(d,p){if(i[p]!==void 0)return i[p];const m=d.arrayBuffers[p],v=new Uint32Array(m).buffer;return i[p]=v,v}const a=e.isInstancedBufferGeometry?new Bm:new ct,o=e.data.index;if(o!==void 0){const d=wa(o.type,o.array);a.setIndex(new wt(d,1))}const l=e.data.attributes;for(const d in l){const p=l[d];let m;if(p.isInterleavedBufferAttribute){const v=r(e.data,p.data);m=new On(v,p.itemSize,p.offset,p.normalized)}else{const v=wa(p.type,p.array),f=p.isInstancedBufferAttribute?Nn:wt;m=new f(v,p.itemSize,p.normalized)}p.name!==void 0&&(m.name=p.name),p.usage!==void 0&&m.setUsage(p.usage),a.setAttribute(d,m)}const c=e.data.morphAttributes;if(c)for(const d in c){const p=c[d],m=[];for(let v=0,f=p.length;v<f;v++){const g=p[v];let x;if(g.isInterleavedBufferAttribute){const y=r(e.data,g.data);x=new On(y,g.itemSize,g.offset,g.normalized)}else{const y=wa(g.type,g.array);x=new wt(y,g.itemSize,g.normalized)}g.name!==void 0&&(x.name=g.name),m.push(x)}a.morphAttributes[d]=m}e.data.morphTargetsRelative&&(a.morphTargetsRelative=!0);const u=e.data.groups||e.data.drawcalls||e.data.offsets;if(u!==void 0)for(let d=0,p=u.length;d!==p;++d){const m=u[d];a.addGroup(m.start,m.count,m.materialIndex)}const h=e.data.boundingSphere;if(h!==void 0){const d=new N;h.center!==void 0&&d.fromArray(h.center),a.boundingSphere=new Ai(d,h.radius)}return e.name&&(a.name=e.name),e.userData&&(a.userData=e.userData),a}}class nx extends Hi{constructor(e){super(e)}load(e,t,i,r){const s=this,a=this.path===""?yh.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||a;const o=new Kr(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(l){let c=null;try{c=JSON.parse(l)}catch(h){r!==void 0&&r(h),console.error("THREE:ObjectLoader: Can't parse "+e+".",h.message);return}const u=c.metadata;if(u===void 0||u.type===void 0||u.type.toLowerCase()==="geometry"){r!==void 0&&r(new Error("THREE.ObjectLoader: Can't load "+e)),console.error("THREE.ObjectLoader: Can't load "+e);return}s.parse(c,t)},i,r)}async loadAsync(e,t){const i=this,r=this.path===""?yh.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||r;const s=new Kr(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials);const a=await s.loadAsync(e,t),o=JSON.parse(a),l=o.metadata;if(l===void 0||l.type===void 0||l.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+e);return await i.parseAsync(o)}parse(e,t){const i=this.parseAnimations(e.animations),r=this.parseShapes(e.shapes),s=this.parseGeometries(e.geometries,r),a=this.parseImages(e.images,function(){t!==void 0&&t(c)}),o=this.parseTextures(e.textures,a),l=this.parseMaterials(e.materials,o),c=this.parseObject(e.object,s,l,o,i),u=this.parseSkeletons(e.skeletons,c);if(this.bindSkeletons(c,u),this.bindLightTargets(c),t!==void 0){let h=!1;for(const d in a)if(a[d].data instanceof HTMLImageElement){h=!0;break}h===!1&&t(c)}return c}async parseAsync(e){const t=this.parseAnimations(e.animations),i=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,i),s=await this.parseImagesAsync(e.images),a=this.parseTextures(e.textures,s),o=this.parseMaterials(e.materials,a),l=this.parseObject(e.object,r,o,a,t),c=this.parseSkeletons(e.skeletons,l);return this.bindSkeletons(l,c),this.bindLightTargets(l),l}parseShapes(e){const t={};if(e!==void 0)for(let i=0,r=e.length;i<r;i++){const s=new is().fromJSON(e[i]);t[s.uuid]=s}return t}parseSkeletons(e,t){const i={},r={};if(t.traverse(function(s){s.isBone&&(r[s.uuid]=s)}),e!==void 0)for(let s=0,a=e.length;s<a;s++){const o=new fc().fromJSON(e[s],r);i[o.uuid]=o}return i}parseGeometries(e,t){const i={};if(e!==void 0){const r=new rx;for(let s=0,a=e.length;s<a;s++){let o;const l=e[s];switch(l.type){case"BufferGeometry":case"InstancedBufferGeometry":o=r.parse(l);break;default:l.type in jy?o=jy[l.type].fromJSON(l,t):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${l.type}"`)}o.uuid=l.uuid,l.name!==void 0&&(o.name=l.name),l.userData!==void 0&&(o.userData=l.userData),i[l.uuid]=o}}return i}parseMaterials(e,t){const i={},r={};if(e!==void 0){const s=new _c;s.setTextures(t);for(let a=0,o=e.length;a<o;a++){const l=e[a];i[l.uuid]===void 0&&(i[l.uuid]=s.parse(l)),r[l.uuid]=i[l.uuid]}}return r}parseAnimations(e){const t={};if(e!==void 0)for(let i=0;i<e.length;i++){const r=e[i],s=io.parse(r);t[s.uuid]=s}return t}parseImages(e,t){const i=this,r={};let s;function a(l){return i.manager.itemStart(l),s.load(l,function(){i.manager.itemEnd(l)},void 0,function(){i.manager.itemError(l),i.manager.itemEnd(l)})}function o(l){if(typeof l=="string"){const c=l,u=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(c)?c:i.resourcePath+c;return a(u)}else return l.data?{data:wa(l.type,l.data),width:l.width,height:l.height}:null}if(e!==void 0&&e.length>0){const l=new ph(t);s=new wl(l),s.setCrossOrigin(this.crossOrigin);for(let c=0,u=e.length;c<u;c++){const h=e[c],d=h.url;if(Array.isArray(d)){const p=[];for(let m=0,v=d.length;m<v;m++){const f=d[m],g=o(f);g!==null&&(g instanceof HTMLImageElement?p.push(g):p.push(new Ur(g.data,g.width,g.height)))}r[h.uuid]=new Yn(p)}else{const p=o(h.url);r[h.uuid]=new Yn(p)}}}return r}async parseImagesAsync(e){const t=this,i={};let r;async function s(a){if(typeof a=="string"){const o=a,l=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(o)?o:t.resourcePath+o;return await r.loadAsync(l)}else return a.data?{data:wa(a.type,a.data),width:a.width,height:a.height}:null}if(e!==void 0&&e.length>0){r=new wl(this.manager),r.setCrossOrigin(this.crossOrigin);for(let a=0,o=e.length;a<o;a++){const l=e[a],c=l.url;if(Array.isArray(c)){const u=[];for(let h=0,d=c.length;h<d;h++){const p=c[h],m=await s(p);m!==null&&(m instanceof HTMLImageElement?u.push(m):u.push(new Ur(m.data,m.width,m.height)))}i[l.uuid]=new Yn(u)}else{const u=await s(l.url);i[l.uuid]=new Yn(u)}}}return i}parseTextures(e,t){function i(s,a){return typeof s=="number"?s:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",s),a[s])}const r={};if(e!==void 0)for(let s=0,a=e.length;s<a;s++){const o=e[s];o.image===void 0&&console.warn('THREE.ObjectLoader: No "image" specified for',o.uuid),t[o.image]===void 0&&console.warn("THREE.ObjectLoader: Undefined image",o.image);const l=t[o.image],c=l.data;let u;Array.isArray(c)?(u=new Ns,c.length===6&&(u.needsUpdate=!0)):(c&&c.data?u=new Ur:u=new Wt,c&&(u.needsUpdate=!0)),u.source=l,u.uuid=o.uuid,o.name!==void 0&&(u.name=o.name),o.mapping!==void 0&&(u.mapping=i(o.mapping,zI)),o.channel!==void 0&&(u.channel=o.channel),o.offset!==void 0&&u.offset.fromArray(o.offset),o.repeat!==void 0&&u.repeat.fromArray(o.repeat),o.center!==void 0&&u.center.fromArray(o.center),o.rotation!==void 0&&(u.rotation=o.rotation),o.wrap!==void 0&&(u.wrapS=i(o.wrap[0],sx),u.wrapT=i(o.wrap[1],sx)),o.format!==void 0&&(u.format=o.format),o.internalFormat!==void 0&&(u.internalFormat=o.internalFormat),o.type!==void 0&&(u.type=o.type),o.colorSpace!==void 0&&(u.colorSpace=o.colorSpace),o.minFilter!==void 0&&(u.minFilter=i(o.minFilter,ax)),o.magFilter!==void 0&&(u.magFilter=i(o.magFilter,ax)),o.anisotropy!==void 0&&(u.anisotropy=o.anisotropy),o.flipY!==void 0&&(u.flipY=o.flipY),o.generateMipmaps!==void 0&&(u.generateMipmaps=o.generateMipmaps),o.premultiplyAlpha!==void 0&&(u.premultiplyAlpha=o.premultiplyAlpha),o.unpackAlignment!==void 0&&(u.unpackAlignment=o.unpackAlignment),o.compareFunction!==void 0&&(u.compareFunction=o.compareFunction),o.userData!==void 0&&(u.userData=o.userData),r[o.uuid]=u}return r}parseObject(e,t,i,r,s){let a;function o(d){return t[d]===void 0&&console.warn("THREE.ObjectLoader: Undefined geometry",d),t[d]}function l(d){if(d!==void 0){if(Array.isArray(d)){const p=[];for(let m=0,v=d.length;m<v;m++){const f=d[m];i[f]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",f),p.push(i[f])}return p}return i[d]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",d),i[d]}}function c(d){return r[d]===void 0&&console.warn("THREE.ObjectLoader: Undefined texture",d),r[d]}let u,h;switch(e.type){case"Scene":a=new Uu,e.background!==void 0&&(Number.isInteger(e.background)?a.background=new xe(e.background):a.background=c(e.background)),e.environment!==void 0&&(a.environment=c(e.environment)),e.fog!==void 0&&(e.fog.type==="Fog"?a.fog=new Jp(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(a.fog=new Ad(e.fog.color,e.fog.density)),e.fog.name!==""&&(a.fog.name=e.fog.name)),e.backgroundBlurriness!==void 0&&(a.backgroundBlurriness=e.backgroundBlurriness),e.backgroundIntensity!==void 0&&(a.backgroundIntensity=e.backgroundIntensity),e.backgroundRotation!==void 0&&a.backgroundRotation.fromArray(e.backgroundRotation),e.environmentIntensity!==void 0&&(a.environmentIntensity=e.environmentIntensity),e.environmentRotation!==void 0&&a.environmentRotation.fromArray(e.environmentRotation);break;case"PerspectiveCamera":a=new di(e.fov,e.aspect,e.near,e.far),e.focus!==void 0&&(a.focus=e.focus),e.zoom!==void 0&&(a.zoom=e.zoom),e.filmGauge!==void 0&&(a.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(a.filmOffset=e.filmOffset),e.view!==void 0&&(a.view=Object.assign({},e.view));break;case"OrthographicCamera":a=new Is(e.left,e.right,e.top,e.bottom,e.near,e.far),e.zoom!==void 0&&(a.zoom=e.zoom),e.view!==void 0&&(a.view=Object.assign({},e.view));break;case"AmbientLight":a=new vh(e.color,e.intensity);break;case"DirectionalLight":a=new gh(e.color,e.intensity),a.target=e.target||"";break;case"PointLight":a=new fh(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":a=new Fm(e.color,e.intensity,e.width,e.height);break;case"SpotLight":a=new El(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay),a.target=e.target||"";break;case"HemisphereLight":a=new mh(e.color,e.groundColor,e.intensity);break;case"LightProbe":a=new Vm().fromJSON(e);break;case"SkinnedMesh":u=o(e.geometry),h=l(e.material),a=new im(u,h),e.bindMode!==void 0&&(a.bindMode=e.bindMode),e.bindMatrix!==void 0&&a.bindMatrix.fromArray(e.bindMatrix),e.skeleton!==void 0&&(a.skeleton=e.skeleton);break;case"Mesh":u=o(e.geometry),h=l(e.material),a=new Ft(u,h);break;case"InstancedMesh":u=o(e.geometry),h=l(e.material);const d=e.count,p=e.instanceMatrix,m=e.instanceColor;a=new rm(u,h,d),a.instanceMatrix=new Nn(new Float32Array(p.array),16),m!==void 0&&(a.instanceColor=new Nn(new Float32Array(m.array),m.itemSize));break;case"BatchedMesh":u=o(e.geometry),h=l(e.material),a=new om(e.maxInstanceCount,e.maxVertexCount,e.maxIndexCount,h),a.geometry=u,a.perObjectFrustumCulled=e.perObjectFrustumCulled,a.sortObjects=e.sortObjects,a._drawRanges=e.drawRanges,a._reservedRanges=e.reservedRanges,a._visibility=e.visibility,a._active=e.active,a._bounds=e.bounds.map(v=>{const f=new Bi;f.min.fromArray(v.boxMin),f.max.fromArray(v.boxMax);const g=new Ai;return g.radius=v.sphereRadius,g.center.fromArray(v.sphereCenter),{boxInitialized:v.boxInitialized,box:f,sphereInitialized:v.sphereInitialized,sphere:g}}),a._maxInstanceCount=e.maxInstanceCount,a._maxVertexCount=e.maxVertexCount,a._maxIndexCount=e.maxIndexCount,a._geometryInitialized=e.geometryInitialized,a._geometryCount=e.geometryCount,a._matricesTexture=c(e.matricesTexture.uuid),e.colorsTexture!==void 0&&(a._colorsTexture=c(e.colorsTexture.uuid));break;case"LOD":a=new Qp;break;case"Line":a=new Cn(o(e.geometry),l(e.material));break;case"LineLoop":a=new cm(o(e.geometry),l(e.material));break;case"LineSegments":a=new $r(o(e.geometry),l(e.material));break;case"PointCloud":case"Points":a=new hm(o(e.geometry),l(e.material));break;case"Sprite":a=new Zp(l(e.material));break;case"Group":a=new Us;break;case"Bone":a=new ku;break;default:a=new _t}if(a.uuid=e.uuid,e.name!==void 0&&(a.name=e.name),e.matrix!==void 0?(a.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(a.matrixAutoUpdate=e.matrixAutoUpdate),a.matrixAutoUpdate&&a.matrix.decompose(a.position,a.quaternion,a.scale)):(e.position!==void 0&&a.position.fromArray(e.position),e.rotation!==void 0&&a.rotation.fromArray(e.rotation),e.quaternion!==void 0&&a.quaternion.fromArray(e.quaternion),e.scale!==void 0&&a.scale.fromArray(e.scale)),e.up!==void 0&&a.up.fromArray(e.up),e.castShadow!==void 0&&(a.castShadow=e.castShadow),e.receiveShadow!==void 0&&(a.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.intensity!==void 0&&(a.shadow.intensity=e.shadow.intensity),e.shadow.bias!==void 0&&(a.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(a.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(a.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&a.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(a.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(a.visible=e.visible),e.frustumCulled!==void 0&&(a.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(a.renderOrder=e.renderOrder),e.userData!==void 0&&(a.userData=e.userData),e.layers!==void 0&&(a.layers.mask=e.layers),e.children!==void 0){const d=e.children;for(let p=0;p<d.length;p++)a.add(this.parseObject(d[p],t,i,r,s))}if(e.animations!==void 0){const d=e.animations;for(let p=0;p<d.length;p++){const m=d[p];a.animations.push(s[m])}}if(e.type==="LOD"){e.autoUpdate!==void 0&&(a.autoUpdate=e.autoUpdate);const d=e.levels;for(let p=0;p<d.length;p++){const m=d[p],v=a.getObjectByProperty("uuid",m.object);v!==void 0&&a.addLevel(v,m.distance,m.hysteresis)}}return a}bindSkeletons(e,t){Object.keys(t).length!==0&&e.traverse(function(i){if(i.isSkinnedMesh===!0&&i.skeleton!==void 0){const r=t[i.skeleton];r===void 0?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",i.skeleton):i.bind(r,i.bindMatrix)}})}bindLightTargets(e){e.traverse(function(t){if(t.isDirectionalLight||t.isSpotLight){const i=t.target,r=e.getObjectByProperty("uuid",i);r!==void 0?t.target=r:t.target=new _t}})}}const zI={UVMapping:Rc,CubeReflectionMapping:fr,CubeRefractionMapping:Ar,EquirectangularReflectionMapping:zn,EquirectangularRefractionMapping:kn,CubeUVReflectionMapping:ys},sx={RepeatWrapping:Hn,ClampToEdgeWrapping:gr,MirroredRepeatWrapping:ma},ax={NearestFilter:$t,NearestMipmapNearestFilter:Ic,NearestMipmapLinearFilter:Mn,LinearFilter:Lt,LinearMipmapNearestFilter:Gn,LinearMipmapLinearFilter:ji};class ox extends Hi{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=Rn.get(e);if(a!==void 0){if(s.manager.itemStart(e),a.then){a.then(c=>{t&&t(c),s.manager.itemEnd(e)}).catch(c=>{r&&r(c)});return}return setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader;const l=fetch(e,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(c){return Rn.add(e,c),t&&t(c),s.manager.itemEnd(e),c}).catch(function(c){r&&r(c),Rn.remove(e),s.manager.itemError(e),s.manager.itemEnd(e)});Rn.add(e,l),s.manager.itemStart(e)}}let xh;class _h{static getContext(){return xh===void 0&&(xh=new(window.AudioContext||window.webkitAudioContext)),xh}static setContext(e){xh=e}}class lx extends Hi{constructor(e){super(e)}load(e,t,i,r){const s=this,a=new Kr(this.manager);a.setResponseType("arraybuffer"),a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(l){try{const c=l.slice(0);_h.getContext().decodeAudioData(c,function(u){t(u)}).catch(o)}catch(c){o(c)}},i,r);function o(l){r?r(l):console.error(l),s.manager.itemError(e)}}}const cx=new Re,ux=new Re,Hs=new Re;class zm{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new di,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new di,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,Hs.copy(e.projectionMatrix);const i=t.eyeSep/2,r=i*t.near/t.focus,s=t.near*Math.tan(Ts*t.fov*.5)/t.zoom;let a,o;ux.elements[12]=-i,cx.elements[12]=i,a=-s*t.aspect+r,o=s*t.aspect+r,Hs.elements[0]=2*t.near/(o-a),Hs.elements[8]=(o+a)/(o-a),this.cameraL.projectionMatrix.copy(Hs),a=-s*t.aspect-r,o=s*t.aspect-r,Hs.elements[0]=2*t.near/(o-a),Hs.elements[8]=(o+a)/(o-a),this.cameraR.projectionMatrix.copy(Hs)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(ux),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(cx)}}class km{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=hx(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=hx();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function hx(){return performance.now()}const cn=new N,dx=new qi,kI=new N,Gs=new N;let px=class extends _t{constructor(){super(),this.type="AudioListener",this.context=_h.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new km}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(n){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=n,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(n){return this.gain.gain.setTargetAtTime(n,this.context.currentTime,.01),this}updateMatrixWorld(n){super.updateMatrixWorld(n);const e=this.context.listener,t=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(cn,dx,kI),!(!Number.isFinite(cn.x)||!Number.isFinite(cn.y)||!Number.isFinite(cn.z)))if(Gs.set(0,0,-1).applyQuaternion(dx),e.positionX){const i=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(cn.x,i),e.positionY.linearRampToValueAtTime(cn.y,i),e.positionZ.linearRampToValueAtTime(cn.z,i),e.forwardX.linearRampToValueAtTime(Gs.x,i),e.forwardY.linearRampToValueAtTime(Gs.y,i),e.forwardZ.linearRampToValueAtTime(Gs.z,i),e.upX.linearRampToValueAtTime(t.x,i),e.upY.linearRampToValueAtTime(t.y,i),e.upZ.linearRampToValueAtTime(t.z,i)}else e.setPosition(cn.x,cn.y,cn.z),e.setOrientation(Gs.x,Gs.y,Gs.z,t.x,t.y,t.z)}};class Hm extends _t{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||(this.buffer?this.buffer.duration:Number.MAX_VALUE))),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(e=0){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(this.context.currentTime+e),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this._connected!==!1){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}}getFilters(){return this.filters}setFilters(e){return e||(e=[]),this._connected===!0?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){return this.detune=e,this.isPlaying===!0&&this.source.detune!==void 0&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.playbackRate=e,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.loop=e,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}}const Ws=new N,mx=new qi,HI=new N,js=new N;class fx extends Hm{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){super.connect(),this.panner.connect(this.gain)}disconnect(){super.disconnect(),this.panner.disconnect(this.gain)}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(e){return this.panner.refDistance=e,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(e){return this.panner.rolloffFactor=e,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(e){return this.panner.distanceModel=e,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(e){return this.panner.maxDistance=e,this}setDirectionalCone(e,t,i){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=i,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(Ws,mx,HI),js.set(0,0,1).applyQuaternion(mx);const t=this.panner;if(t.positionX){const i=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(Ws.x,i),t.positionY.linearRampToValueAtTime(Ws.y,i),t.positionZ.linearRampToValueAtTime(Ws.z,i),t.orientationX.linearRampToValueAtTime(js.x,i),t.orientationY.linearRampToValueAtTime(js.y,i),t.orientationZ.linearRampToValueAtTime(js.z,i)}else t.setPosition(Ws.x,Ws.y,Ws.z),t.setOrientation(js.x,js.y,js.z)}}class GI{constructor(e,t=2048){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=t,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0;const t=this.getFrequencyData();for(let i=0;i<t.length;i++)e+=t[i];return e/t.length}}class gx{constructor(e,t,i){this.binding=e,this.valueSize=i;let r,s,a;switch(t){case"quaternion":r=this._slerp,s=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":r=this._select,s=this._select,a=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:r=this._lerp,s=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=s,this._setIdentity=a,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){const i=this.buffer,r=this.valueSize,s=e*r+r;let a=this.cumulativeWeight;if(a===0){for(let o=0;o!==r;++o)i[s+o]=i[o];a=t}else{a+=t;const o=t/a;this._mixBufferRegion(i,s,0,o,r)}this.cumulativeWeight=a}accumulateAdditive(e){const t=this.buffer,i=this.valueSize,r=i*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,i),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,i=this.buffer,r=e*t+t,s=this.cumulativeWeight,a=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){const l=t*this._origIndex;this._mixBufferRegion(i,r,l,1-s,t)}a>0&&this._mixBufferRegionAdditive(i,r,this._addIndex*t,1,t);for(let l=t,c=t+t;l!==c;++l)if(i[l]!==i[l+t]){o.setValue(i,r);break}}saveOriginalState(){const e=this.binding,t=this.buffer,i=this.valueSize,r=i*this._origIndex;e.getValue(t,r);for(let s=i,a=r;s!==a;++s)t[s]=t[r+s%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i<t;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[t+i]=this.buffer[e+i]}_select(e,t,i,r,s){if(r>=.5)for(let a=0;a!==s;++a)e[t+a]=e[i+a]}_slerp(e,t,i,r){qi.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,s){const a=this._workIndex*s;qi.multiplyQuaternionsFlat(e,a,e,t,e,i),qi.slerpFlat(e,t,e,t,e,a,r)}_lerp(e,t,i,r,s){const a=1-r;for(let o=0;o!==s;++o){const l=t+o;e[l]=e[l]*a+e[i+o]*r}}_lerpAdditive(e,t,i,r,s){for(let a=0;a!==s;++a){const o=t+a;e[o]=e[o]+e[i+a]*r}}}const Gm="\\[\\]\\.:\\/",WI=new RegExp("["+Gm+"]","g"),Wm="[^"+Gm+"]",jI="[^"+Gm.replace("\\.","")+"]",XI=/((?:WC+[\/:])*)/.source.replace("WC",Wm),qI=/(WCOD+)?/.source.replace("WCOD",jI),YI=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Wm),$I=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Wm),JI=new RegExp("^"+XI+qI+YI+$I+"$"),KI=["material","materials","bones","map"];class ZI{constructor(e,t,i){const r=i||Tt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();const i=this._targetGroup.nCachedObjects_,r=this._bindings[i];r!==void 0&&r.getValue(e,t)}setValue(e,t){const i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=i.length;r!==s;++r)i[r].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}}class Tt{constructor(e,t,i){this.path=t,this.parsedPath=i||Tt.parseTrackName(t),this.node=Tt.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new Tt.Composite(e,t,i):new Tt(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(WI,"")}static parseTrackName(e){const t=JI.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){const s=i.nodeName.substring(r+1);KI.indexOf(s)!==-1&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=s)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){const i=function(s,a){for(let o=0;o<s.length;o++){const l=s[o];if(!a&&(l.name===t||l.uuid===t)||a&&l.userData&&l.userData.name===t)return l;const c=i(l.children,a);if(c)return c}return null},r=i(e.children);if(r)return r;{const s=i(e.children,!0);if(s)return s}}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)e[t++]=i[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,i=t.objectName,r=t.propertyName;let s=t.propertyIndex;if(e||(e=Tt.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(i){let c=t.objectIndex;switch(i){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let u=0;u<e.length;u++)if(e[u].name===c){c=u;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[i]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(c!==void 0){if(e[c]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}const a=e[r];if(a===void 0){const c=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+r+" but it wasn't found.",e);return}let o=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?o=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=s}else a.fromArray!==void 0&&a.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(l=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=r;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}Tt.Composite=ZI,Tt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Tt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},Tt.prototype.GetterByBindingType=[Tt.prototype._getValue_direct,Tt.prototype._getValue_array,Tt.prototype._getValue_arrayElement,Tt.prototype._getValue_toArray],Tt.prototype.SetterByBindingTypeAndVersioning=[[Tt.prototype._setValue_direct,Tt.prototype._setValue_direct_setNeedsUpdate,Tt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Tt.prototype._setValue_array,Tt.prototype._setValue_array_setNeedsUpdate,Tt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Tt.prototype._setValue_arrayElement,Tt.prototype._setValue_arrayElement_setNeedsUpdate,Tt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Tt.prototype._setValue_fromArray,Tt.prototype._setValue_fromArray_setNeedsUpdate,Tt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class QI{constructor(){this.isAnimationObjectGroup=!0,this.uuid=yr(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const e={};this._indicesByUUID=e;for(let i=0,r=arguments.length;i!==r;++i)e[arguments[i].uuid]=i;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const t=this;this.stats={objects:{get total(){return t._objects.length},get inUse(){return this.total-t.nCachedObjects_}},get bindingsPerObject(){return t._bindings.length}}}add(){const e=this._objects,t=this._indicesByUUID,i=this._paths,r=this._parsedPaths,s=this._bindings,a=s.length;let o,l=e.length,c=this.nCachedObjects_;for(let u=0,h=arguments.length;u!==h;++u){const d=arguments[u],p=d.uuid;let m=t[p];if(m===void 0){m=l++,t[p]=m,e.push(d);for(let v=0,f=a;v!==f;++v)s[v].push(new Tt(d,i[v],r[v]))}else if(m<c){o=e[m];const v=--c,f=e[v];t[f.uuid]=m,e[m]=f,t[p]=v,e[v]=d;for(let g=0,x=a;g!==x;++g){const y=s[g],_=y[v];let I=y[m];y[m]=_,I===void 0&&(I=new Tt(d,i[g],r[g])),y[v]=I}}else e[m]!==o&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=c}remove(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,r=i.length;let s=this.nCachedObjects_;for(let a=0,o=arguments.length;a!==o;++a){const l=arguments[a],c=l.uuid,u=t[c];if(u!==void 0&&u>=s){const h=s++,d=e[h];t[d.uuid]=u,e[u]=d,t[c]=h,e[h]=l;for(let p=0,m=r;p!==m;++p){const v=i[p],f=v[h],g=v[u];v[u]=f,v[h]=g}}}this.nCachedObjects_=s}uncache(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,r=i.length;let s=this.nCachedObjects_,a=e.length;for(let o=0,l=arguments.length;o!==l;++o){const c=arguments[o],u=c.uuid,h=t[u];if(h!==void 0)if(delete t[u],h<s){const d=--s,p=e[d],m=--a,v=e[m];t[p.uuid]=h,e[h]=p,t[v.uuid]=d,e[d]=v,e.pop();for(let f=0,g=r;f!==g;++f){const x=i[f],y=x[d],_=x[m];x[h]=y,x[d]=_,x.pop()}}else{const d=--a,p=e[d];d>0&&(t[p.uuid]=h),e[h]=p,e.pop();for(let m=0,v=r;m!==v;++m){const f=i[m];f[h]=f[d],f.pop()}}}this.nCachedObjects_=s}subscribe_(e,t){const i=this._bindingsIndicesByPath;let r=i[e];const s=this._bindings;if(r!==void 0)return s[r];const a=this._paths,o=this._parsedPaths,l=this._objects,c=l.length,u=this.nCachedObjects_,h=new Array(c);r=s.length,i[e]=r,a.push(e),o.push(t),s.push(h);for(let d=u,p=l.length;d!==p;++d){const m=l[d];h[d]=new Tt(m,e,t)}return h}unsubscribe_(e){const t=this._bindingsIndicesByPath,i=t[e];if(i!==void 0){const r=this._paths,s=this._parsedPaths,a=this._bindings,o=a.length-1,l=a[o],c=e[o];t[c]=i,a[i]=l,a.pop(),s[i]=s[o],s.pop(),r[i]=r[o],r.pop()}}}class vx{constructor(e,t,i=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=r;const s=t.tracks,a=s.length,o=new Array(a),l={endingStart:xs,endingEnd:xs};for(let c=0;c!==a;++c){const u=s[c].createInterpolant(null);o[c]=u,u.settings=l}this._interpolantSettings=l,this._interpolants=o,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=op,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i){if(e.fadeOut(t),this.fadeIn(t),i){const r=this._clip.duration,s=e._clip.duration,a=s/r,o=r/s;e.warp(1,a,t),this.warp(o,1,t)}return this}crossFadeTo(e,t,i){return e.crossFadeFrom(this,t,i)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){const r=this._mixer,s=r.time,a=this.timeScale;let o=this._timeScaleInterpolant;o===null&&(o=r._lendControlInterpolant(),this._timeScaleInterpolant=o);const l=o.parameterPositions,c=o.sampleValues;return l[0]=s,l[1]=s+i,c[0]=e/a,c[1]=t/a,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,r){if(!this.enabled){this._updateWeight(e);return}const s=this._startTime;if(s!==null){const l=(e-s)*i;l<0||i===0?t=0:(this._startTime=null,t=i*l)}t*=this._updateTimeScale(e);const a=this._updateTime(t),o=this._updateWeight(e);if(o>0){const l=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case lp:for(let u=0,h=l.length;u!==h;++u)l[u].evaluate(a),c[u].accumulateAdditive(o);break;case iu:default:for(let u=0,h=l.length;u!==h;++u)l[u].evaluate(a),c[u].accumulate(r,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const i=this._weightInterpolant;if(i!==null){const r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const i=this._timeScaleInterpolant;if(i!==null){const r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,i=this.loop;let r=this.time+e,s=this._loopCount;const a=i===F0;if(e===0)return s===-1?r:a&&(s&1)===1?t-r:r;if(i===ap){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),r>=t||r<0){const o=Math.floor(r/t);r-=t*o,s+=Math.abs(o);const l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(l===1){const c=e<0;this._setEndings(c,!c,a)}else this._setEndings(!1,!1,a);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=r;if(a&&(s&1)===1)return t-r}return r}_setEndings(e,t,i){const r=this._interpolantSettings;i?(r.endingStart=_s,r.endingEnd=_s):(e?r.endingStart=this.zeroSlopeAtStart?_s:xs:r.endingStart=Xo,t?r.endingEnd=this.zeroSlopeAtEnd?_s:xs:r.endingEnd=Xo)}_scheduleFading(e,t,i){const r=this._mixer,s=r.time;let a=this._weightInterpolant;a===null&&(a=r._lendControlInterpolant(),this._weightInterpolant=a);const o=a.parameterPositions,l=a.sampleValues;return o[0]=s,l[0]=t,o[1]=s+e,l[1]=i,this}}const e2=new Float32Array(1);class yx extends vr{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const i=e._localRoot||this._root,r=e._clip.tracks,s=r.length,a=e._propertyBindings,o=e._interpolants,l=i.uuid,c=this._bindingsByRootAndName;let u=c[l];u===void 0&&(u={},c[l]=u);for(let h=0;h!==s;++h){const d=r[h],p=d.name;let m=u[p];if(m!==void 0)++m.referenceCount,a[h]=m;else{if(m=a[h],m!==void 0){m._cacheIndex===null&&(++m.referenceCount,this._addInactiveBinding(m,l,p));continue}const v=t&&t._propertyBindings[h].binding.parsedPath;m=new gx(Tt.create(i,p,v),d.ValueTypeName,d.getValueSize()),++m.referenceCount,this._addInactiveBinding(m,l,p),a[h]=m}o[h].resultBuffer=m.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const i=(e._localRoot||this._root).uuid,r=e._clip.uuid,s=this._actionsByClip[r];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,r,i)}const t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){const s=t[i];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){const s=t[i];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,i){const r=this._actions,s=this._actionsByClip;let a=s[t];if(a===void 0)a={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,s[t]=a;else{const o=a.knownActions;e._byClipCacheIndex=o.length,o.push(e)}e._cacheIndex=r.length,r.push(e),a.actionByRoot[i]=e}_removeInactiveAction(e){const t=this._actions,i=t[t.length-1],r=e._cacheIndex;i._cacheIndex=r,t[r]=i,t.pop(),e._cacheIndex=null;const s=e._clip.uuid,a=this._actionsByClip,o=a[s],l=o.knownActions,c=l[l.length-1],u=e._byClipCacheIndex;c._byClipCacheIndex=u,l[u]=c,l.pop(),e._byClipCacheIndex=null;const h=o.actionByRoot,d=(e._localRoot||this._root).uuid;delete h[d],l.length===0&&delete a[s],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){const s=t[i];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(e){const t=this._actions,i=e._cacheIndex,r=this._nActiveActions++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackAction(e){const t=this._actions,i=e._cacheIndex,r=--this._nActiveActions,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_addInactiveBinding(e,t,i){const r=this._bindingsByRootAndName,s=this._bindings;let a=r[t];a===void 0&&(a={},r[t]=a),a[i]=e,e._cacheIndex=s.length,s.push(e)}_removeInactiveBinding(e){const t=this._bindings,i=e.binding,r=i.rootNode.uuid,s=i.path,a=this._bindingsByRootAndName,o=a[r],l=t[t.length-1],c=e._cacheIndex;l._cacheIndex=c,t[c]=l,t.pop(),delete o[s],Object.keys(o).length===0&&delete a[r]}_lendBinding(e){const t=this._bindings,i=e._cacheIndex,r=this._nActiveBindings++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackBinding(e){const t=this._bindings,i=e._cacheIndex,r=--this._nActiveBindings,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let i=e[t];return i===void 0&&(i=new Lm(new Float32Array(2),new Float32Array(2),1,e2),i.__cacheIndex=t,e[t]=i),i}_takeBackControlInterpolant(e){const t=this._controlInterpolants,i=e.__cacheIndex,r=--this._nActiveControlInterpolants,s=t[r];e.__cacheIndex=r,t[r]=e,s.__cacheIndex=i,t[i]=s}clipAction(e,t,i){const r=t||this._root,s=r.uuid;let a=typeof e=="string"?io.findByName(r,e):e;const o=a!==null?a.uuid:e,l=this._actionsByClip[o];let c=null;if(i===void 0&&(a!==null?i=a.blendMode:i=iu),l!==void 0){const h=l.actionByRoot[s];if(h!==void 0&&h.blendMode===i)return h;c=l.knownActions[0],a===null&&(a=c._clip)}if(a===null)return null;const u=new vx(this,a,t,i);return this._bindAction(u,c),this._addInactiveAction(u,o,s),u}existingAction(e,t){const i=t||this._root,r=i.uuid,s=typeof e=="string"?io.findByName(i,e):e,a=s?s.uuid:e,o=this._actionsByClip[a];return o!==void 0&&o.actionByRoot[r]||null}stopAllAction(){const e=this._actions,t=this._nActiveActions;for(let i=t-1;i>=0;--i)e[i].stop();return this}update(e){e*=this.timeScale;const t=this._actions,i=this._nActiveActions,r=this.time+=e,s=Math.sign(e),a=this._accuIndex^=1;for(let c=0;c!==i;++c)t[c]._update(r,e,s,a);const o=this._bindings,l=this._nActiveBindings;for(let c=0;c!==l;++c)o[c].apply(a);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){const t=this._actions,i=e.uuid,r=this._actionsByClip,s=r[i];if(s!==void 0){const a=s.knownActions;for(let o=0,l=a.length;o!==l;++o){const c=a[o];this._deactivateAction(c);const u=c._cacheIndex,h=t[t.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,h._cacheIndex=u,t[u]=h,t.pop(),this._removeInactiveBindingsForAction(c)}delete r[i]}}uncacheRoot(e){const t=e.uuid,i=this._actionsByClip;for(const a in i){const o=i[a].actionByRoot,l=o[t];l!==void 0&&(this._deactivateAction(l),this._removeInactiveAction(l))}const r=this._bindingsByRootAndName,s=r[t];if(s!==void 0)for(const a in s){const o=s[a];o.restoreOriginalState(),this._removeInactiveBinding(o)}}uncacheAction(e,t){const i=this.existingAction(e,t);i!==null&&(this._deactivateAction(i),this._removeInactiveAction(i))}}let xx=class qS{constructor(e){this.value=e}clone(){return new qS(this.value.clone===void 0?this.value:this.value.clone())}},t2=0;class i2 extends vr{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:t2++}),this.name="",this.usage=Ta,this.uniforms=[]}add(e){return this.uniforms.push(e),this}remove(e){const t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}setName(e){return this.name=e,this}setUsage(e){return this.usage=e,this}dispose(){return this.dispatchEvent({type:"dispose"}),this}copy(e){this.name=e.name,this.usage=e.usage;const t=e.uniforms;this.uniforms.length=0;for(let i=0,r=t.length;i<r;i++){const s=Array.isArray(t[i])?t[i]:[t[i]];for(let a=0;a<s.length;a++)this.uniforms.push(s[a].clone())}return this}clone(){return new this.constructor().copy(this)}}class jm extends Wa{constructor(e,t,i=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){const t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}}class r2{constructor(e,t,i,r,s){this.isGLBufferAttribute=!0,this.name="",this.buffer=e,this.type=t,this.itemSize=i,this.elementSize=r,this.count=s,this.version=0}set needsUpdate(e){e===!0&&this.version++}setBuffer(e){return this.buffer=e,this}setType(e,t){return this.type=e,this.elementSize=t,this}setItemSize(e){return this.itemSize=e,this}setCount(e){return this.count=e,this}}const _x=new Re;class Mx{constructor(e,t,i=0,r=1/0){this.ray=new Es(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new rl,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return _x.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(_x),this}intersectObject(e,t=!0,i=[]){return Xm(e,this,i,t),i.sort(bx),i}intersectObjects(e,t=!0,i=[]){for(let r=0,s=e.length;r<s;r++)Xm(e[r],this,i,t);return i.sort(bx),i}}function bx(n,e){return n.distance-e.distance}function Xm(n,e,t,i){let r=!0;if(n.layers.test(e.layers)&&n.raycast(e,t)===!1&&(r=!1),r===!0&&i===!0){const s=n.children;for(let a=0,o=s.length;a<o;a++)Xm(s[a],e,t,!0)}}class Tx{constructor(e=1,t=0,i=0){return this.radius=e,this.phi=t,this.theta=i,this}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(Jt(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class n2{constructor(e=1,t=0,i=0){return this.radius=e,this.theta=t,this.y=i,this}set(e,t,i){return this.radius=e,this.theta=t,this.y=i,this}copy(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+i*i),this.theta=Math.atan2(e,i),this.y=t,this}clone(){return new this.constructor().copy(this)}}class s0{constructor(e,t,i,r){s0.prototype.isMatrix2=!0,this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,i,r)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let i=0;i<4;i++)this.elements[i]=e[i+t];return this}set(e,t,i,r){const s=this.elements;return s[0]=e,s[2]=t,s[1]=i,s[3]=r,this}}const Sx=new J;class s2{constructor(e=new J(1/0,1/0),t=new J(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const i=Sx.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Sx).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const wx=new N,Mh=new N;class Ex{constructor(e=new N,t=new N){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){wx.subVectors(e,this.start),Mh.subVectors(this.end,this.start);const i=Mh.dot(Mh);let r=Mh.dot(wx)/i;return t&&(r=Jt(r,0,1)),r}closestPointToPoint(e,t,i){const r=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(r).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const Ax=new N;class a2 extends _t{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const i=new ct,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let a=0,o=1,l=32;a<l;a++,o++){const c=a/l*Math.PI*2,u=o/l*Math.PI*2;r.push(Math.cos(c),Math.sin(c),1,Math.cos(u),Math.sin(u),1)}i.setAttribute("position",new De(r,3));const s=new Ni({fog:!1,toneMapped:!1});this.cone=new $r(i,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),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 e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),Ax.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Ax),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const ns=new N,bh=new Re,qm=new Re;class o2 extends $r{constructor(e){const t=Nx(e),i=new ct,r=[],s=[],a=new xe(0,0,1),o=new xe(0,1,0);for(let c=0;c<t.length;c++){const u=t[c];u.parent&&u.parent.isBone&&(r.push(0,0,0),r.push(0,0,0),s.push(a.r,a.g,a.b),s.push(o.r,o.g,o.b))}i.setAttribute("position",new De(r,3)),i.setAttribute("color",new De(s,3));const l=new Ni({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(i,l),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){const t=this.bones,i=this.geometry,r=i.getAttribute("position");qm.copy(this.root.matrixWorld).invert();for(let s=0,a=0;s<t.length;s++){const o=t[s];o.parent&&o.parent.isBone&&(bh.multiplyMatrices(qm,o.matrixWorld),ns.setFromMatrixPosition(bh),r.setXYZ(a,ns.x,ns.y,ns.z),bh.multiplyMatrices(qm,o.parent.matrixWorld),ns.setFromMatrixPosition(bh),r.setXYZ(a+1,ns.x,ns.y,ns.z),a+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose()}}function Nx(n){const e=[];n.isBone===!0&&e.push(n);for(let t=0;t<n.children.length;t++)e.push.apply(e,Nx(n.children[t]));return e}class l2 extends Ft{constructor(e,t,i){const r=new wo(t,4,2),s=new Yr({wireframe:!0,fog:!1,toneMapped:!1});super(r,s),this.light=e,this.color=i,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}}const c2=new N,Cx=new xe,Rx=new xe;class u2 extends _t{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="HemisphereLightHelper";const r=new So(t);r.rotateY(Math.PI*.5),this.material=new Yr({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);const s=r.getAttribute("position"),a=new Float32Array(s.count*3);r.setAttribute("color",new wt(a,3)),this.add(new Ft(r,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const e=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{const t=e.geometry.getAttribute("color");Cx.copy(this.light.color),Rx.copy(this.light.groundColor);for(let i=0,r=t.count;i<r;i++){const s=i<r/2?Cx:Rx;t.setXYZ(i,s.r,s.g,s.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(c2.setFromMatrixPosition(this.light.matrixWorld).negate())}}let Ix=class extends $r{constructor(n=10,e=10,t=4473924,i=8947848){t=new xe(t),i=new xe(i);const r=e/2,s=n/e,a=n/2,o=[],l=[];for(let h=0,d=0,p=-a;h<=e;h++,p+=s){o.push(-a,0,p,a,0,p),o.push(p,0,-a,p,0,a);const m=h===r?t:i;m.toArray(l,d),d+=3,m.toArray(l,d),d+=3,m.toArray(l,d),d+=3,m.toArray(l,d),d+=3}const c=new ct;c.setAttribute("position",new De(o,3)),c.setAttribute("color",new De(l,3));const u=new Ni({vertexColors:!0,toneMapped:!1});super(c,u),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}};class h2 extends $r{constructor(e=10,t=16,i=8,r=64,s=4473924,a=8947848){s=new xe(s),a=new xe(a);const o=[],l=[];if(t>1)for(let h=0;h<t;h++){const d=h/t*(Math.PI*2),p=Math.sin(d)*e,m=Math.cos(d)*e;o.push(0,0,0),o.push(p,0,m);const v=h&1?s:a;l.push(v.r,v.g,v.b),l.push(v.r,v.g,v.b)}for(let h=0;h<i;h++){const d=h&1?s:a,p=e-e/i*h;for(let m=0;m<r;m++){let v=m/r*(Math.PI*2),f=Math.sin(v)*p,g=Math.cos(v)*p;o.push(f,0,g),l.push(d.r,d.g,d.b),v=(m+1)/r*(Math.PI*2),f=Math.sin(v)*p,g=Math.cos(v)*p,o.push(f,0,g),l.push(d.r,d.g,d.b)}}const c=new ct;c.setAttribute("position",new De(o,3)),c.setAttribute("color",new De(l,3));const u=new Ni({vertexColors:!0,toneMapped:!1});super(c,u),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const Lx=new N,Th=new N,Px=new N;class Dx extends _t{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="DirectionalLightHelper",t===void 0&&(t=1);let r=new ct;r.setAttribute("position",new De([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));const s=new Ni({fog:!1,toneMapped:!1});this.lightPlane=new Cn(r,s),this.add(this.lightPlane),r=new ct,r.setAttribute("position",new De([0,0,0,0,0,1],3)),this.targetLine=new Cn(r,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),Lx.setFromMatrixPosition(this.light.matrixWorld),Th.setFromMatrixPosition(this.light.target.matrixWorld),Px.subVectors(Th,Lx),this.lightPlane.lookAt(Th),this.color!==void 0?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(Th),this.targetLine.scale.z=Px.length()}}const Sh=new N,Kt=new ol;class Ux extends $r{constructor(e){const t=new ct,i=new Ni({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],a={};o("n1","n2"),o("n2","n4"),o("n4","n3"),o("n3","n1"),o("f1","f2"),o("f2","f4"),o("f4","f3"),o("f3","f1"),o("n1","f1"),o("n2","f2"),o("n3","f3"),o("n4","f4"),o("p","n1"),o("p","n2"),o("p","n3"),o("p","n4"),o("u1","u2"),o("u2","u3"),o("u3","u1"),o("c","t"),o("p","c"),o("cn1","cn2"),o("cn3","cn4"),o("cf1","cf2"),o("cf3","cf4");function o(m,v){l(m),l(v)}function l(m){r.push(0,0,0),s.push(0,0,0),a[m]===void 0&&(a[m]=[]),a[m].push(r.length/3-1)}t.setAttribute("position",new De(r,3)),t.setAttribute("color",new De(s,3)),super(t,i),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update();const c=new xe(16755200),u=new xe(16711680),h=new xe(43775),d=new xe(16777215),p=new xe(3355443);this.setColors(c,u,h,d,p)}setColors(e,t,i,r,s){const a=this.geometry.getAttribute("color");a.setXYZ(0,e.r,e.g,e.b),a.setXYZ(1,e.r,e.g,e.b),a.setXYZ(2,e.r,e.g,e.b),a.setXYZ(3,e.r,e.g,e.b),a.setXYZ(4,e.r,e.g,e.b),a.setXYZ(5,e.r,e.g,e.b),a.setXYZ(6,e.r,e.g,e.b),a.setXYZ(7,e.r,e.g,e.b),a.setXYZ(8,e.r,e.g,e.b),a.setXYZ(9,e.r,e.g,e.b),a.setXYZ(10,e.r,e.g,e.b),a.setXYZ(11,e.r,e.g,e.b),a.setXYZ(12,e.r,e.g,e.b),a.setXYZ(13,e.r,e.g,e.b),a.setXYZ(14,e.r,e.g,e.b),a.setXYZ(15,e.r,e.g,e.b),a.setXYZ(16,e.r,e.g,e.b),a.setXYZ(17,e.r,e.g,e.b),a.setXYZ(18,e.r,e.g,e.b),a.setXYZ(19,e.r,e.g,e.b),a.setXYZ(20,e.r,e.g,e.b),a.setXYZ(21,e.r,e.g,e.b),a.setXYZ(22,e.r,e.g,e.b),a.setXYZ(23,e.r,e.g,e.b),a.setXYZ(24,t.r,t.g,t.b),a.setXYZ(25,t.r,t.g,t.b),a.setXYZ(26,t.r,t.g,t.b),a.setXYZ(27,t.r,t.g,t.b),a.setXYZ(28,t.r,t.g,t.b),a.setXYZ(29,t.r,t.g,t.b),a.setXYZ(30,t.r,t.g,t.b),a.setXYZ(31,t.r,t.g,t.b),a.setXYZ(32,i.r,i.g,i.b),a.setXYZ(33,i.r,i.g,i.b),a.setXYZ(34,i.r,i.g,i.b),a.setXYZ(35,i.r,i.g,i.b),a.setXYZ(36,i.r,i.g,i.b),a.setXYZ(37,i.r,i.g,i.b),a.setXYZ(38,r.r,r.g,r.b),a.setXYZ(39,r.r,r.g,r.b),a.setXYZ(40,s.r,s.g,s.b),a.setXYZ(41,s.r,s.g,s.b),a.setXYZ(42,s.r,s.g,s.b),a.setXYZ(43,s.r,s.g,s.b),a.setXYZ(44,s.r,s.g,s.b),a.setXYZ(45,s.r,s.g,s.b),a.setXYZ(46,s.r,s.g,s.b),a.setXYZ(47,s.r,s.g,s.b),a.setXYZ(48,s.r,s.g,s.b),a.setXYZ(49,s.r,s.g,s.b),a.needsUpdate=!0}update(){const e=this.geometry,t=this.pointMap,i=1,r=1;Kt.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),ti("c",t,e,Kt,0,0,-1),ti("t",t,e,Kt,0,0,1),ti("n1",t,e,Kt,-1,-1,-1),ti("n2",t,e,Kt,i,-1,-1),ti("n3",t,e,Kt,-1,r,-1),ti("n4",t,e,Kt,i,r,-1),ti("f1",t,e,Kt,-1,-1,1),ti("f2",t,e,Kt,i,-1,1),ti("f3",t,e,Kt,-1,r,1),ti("f4",t,e,Kt,i,r,1),ti("u1",t,e,Kt,i*.7,r*1.1,-1),ti("u2",t,e,Kt,-1*.7,r*1.1,-1),ti("u3",t,e,Kt,0,r*2,-1),ti("cf1",t,e,Kt,-1,0,1),ti("cf2",t,e,Kt,i,0,1),ti("cf3",t,e,Kt,0,-1,1),ti("cf4",t,e,Kt,0,r,1),ti("cn1",t,e,Kt,-1,0,-1),ti("cn2",t,e,Kt,i,0,-1),ti("cn3",t,e,Kt,0,-1,-1),ti("cn4",t,e,Kt,0,r,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function ti(n,e,t,i,r,s,a){Sh.set(r,s,a).unproject(i);const o=e[n];if(o!==void 0){const l=t.getAttribute("position");for(let c=0,u=o.length;c<u;c++)l.setXYZ(o[c],Sh.x,Sh.y,Sh.z)}}const wh=new Bi;class Ox extends $r{constructor(e,t=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=new Float32Array(24),s=new ct;s.setIndex(new wt(i,1)),s.setAttribute("position",new wt(r,3)),super(s,new Ni({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(e){if(e!==void 0&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),this.object!==void 0&&wh.setFromObject(this.object),wh.isEmpty())return;const t=wh.min,i=wh.max,r=this.geometry.attributes.position,s=r.array;s[0]=i.x,s[1]=i.y,s[2]=i.z,s[3]=t.x,s[4]=i.y,s[5]=i.z,s[6]=t.x,s[7]=t.y,s[8]=i.z,s[9]=i.x,s[10]=t.y,s[11]=i.z,s[12]=i.x,s[13]=i.y,s[14]=t.z,s[15]=t.x,s[16]=i.y,s[17]=t.z,s[18]=t.x,s[19]=t.y,s[20]=t.z,s[21]=i.x,s[22]=t.y,s[23]=t.z,r.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class Fx extends $r{constructor(e,t=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new ct;s.setIndex(new wt(i,1)),s.setAttribute("position",new De(r,3)),super(s,new Ni({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){const t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}}class d2 extends Cn{constructor(e,t=1,i=16776960){const r=i,s=[1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],a=new ct;a.setAttribute("position",new De(s,3)),a.computeBoundingSphere(),super(a,new Ni({color:r,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;const o=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],l=new ct;l.setAttribute("position",new De(o,3)),l.computeBoundingSphere(),this.add(new Ft(l,new Yr({color:r,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}const Vx=new N;let Eh,Ym;class p2 extends _t{constructor(e=new N(0,0,1),t=new N(0,0,0),i=1,r=16776960,s=i*.2,a=s*.2){super(),this.type="ArrowHelper",Eh===void 0&&(Eh=new ct,Eh.setAttribute("position",new De([0,0,0,0,1,0],3)),Ym=new ha(0,.5,1,5,1),Ym.translate(0,-.5,0)),this.position.copy(t),this.line=new Cn(Eh,new Ni({color:r,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Ft(Ym,new Yr({color:r,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(i,s,a)}setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{Vx.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(Vx,t)}}setLength(e,t=e*.2,i=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(i,t,i),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}let Bx=class extends $r{constructor(n=1){const e=[0,0,0,n,0,0,0,0,0,0,n,0,0,0,0,0,0,n],t=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new ct;i.setAttribute("position",new De(e,3)),i.setAttribute("color",new De(t,3));const r=new Ni({vertexColors:!0,toneMapped:!1});super(i,r),this.type="AxesHelper"}setColors(n,e,t){const i=new xe,r=this.geometry.attributes.color.array;return i.set(n),i.toArray(r,0),i.toArray(r,3),i.set(e),i.toArray(r,6),i.toArray(r,9),i.set(t),i.toArray(r,12),i.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}};class zx{constructor(){this.type="ShapePath",this.color=new xe,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new _l,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,i,r){return this.currentPath.quadraticCurveTo(e,t,i,r),this}bezierCurveTo(e,t,i,r,s,a){return this.currentPath.bezierCurveTo(e,t,i,r,s,a),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(g){const x=[];for(let y=0,_=g.length;y<_;y++){const I=g[y],b=new is;b.curves=I.curves,x.push(b)}return x}function i(g,x){const y=x.length;let _=!1;for(let I=y-1,b=0;b<y;I=b++){let w=x[I],C=x[b],H=C.x-w.x,M=C.y-w.y;if(Math.abs(M)>Number.EPSILON){if(M<0&&(w=x[b],H=-H,C=x[I],M=-M),g.y<w.y||g.y>C.y)continue;if(g.y===w.y){if(g.x===w.x)return!0}else{const T=M*(g.x-w.x)-H*(g.y-w.y);if(T===0)return!0;if(T<0)continue;_=!_}}else{if(g.y!==w.y)continue;if(C.x<=g.x&&g.x<=w.x||w.x<=g.x&&g.x<=C.x)return!0}}return _}const r=nn.isClockWise,s=this.subPaths;if(s.length===0)return[];let a,o,l;const c=[];if(s.length===1)return o=s[0],l=new is,l.curves=o.curves,c.push(l),c;let u=!r(s[0].getPoints());u=e?!u:u;const h=[],d=[];let p=[],m=0,v;d[m]=void 0,p[m]=[];for(let g=0,x=s.length;g<x;g++)o=s[g],v=o.getPoints(),a=r(v),a=e?!a:a,a?(!u&&d[m]&&m++,d[m]={s:new is,p:v},d[m].s.curves=o.curves,u&&m++,p[m]=[]):p[m].push({h:o,p:v[0]});if(!d[0])return t(s);if(d.length>1){let g=!1,x=0;for(let y=0,_=d.length;y<_;y++)h[y]=[];for(let y=0,_=d.length;y<_;y++){const I=p[y];for(let b=0;b<I.length;b++){const w=I[b];let C=!0;for(let H=0;H<d.length;H++)i(w.p,d[H].p)&&(y!==H&&x++,C?(C=!1,h[H].push(w)):g=!0);C&&h[y].push(w)}}x>0&&g===!1&&(p=h)}let f;for(let g=0,x=d.length;g<x;g++){l=d[g].s,c.push(l),f=p[g];for(let y=0,_=f.length;y<_;y++)l.holes.push(f[y].h)}return c}}class kx extends vr{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(){}disconnect(){}dispose(){}update(){}}class m2 extends Ir{constructor(e=1,t=1,i=1,r={}){console.warn('THREE.WebGLMultipleRenderTargets has been deprecated and will be removed in r172. Use THREE.WebGLRenderTarget and set the "count" parameter to enable MRT.'),super(e,t,{...r,count:i}),this.isWebGLMultipleRenderTargets=!0}get texture(){return this.textures}}const f2=["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 Hx{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=e.object.isSkinnedMesh===!0,this.refreshUniforms=f2,this.renderId=0}firstInitialization(e){return this.renderObjects.has(e)===!1?(this.getRenderObjectData(e),!0):!1}getRenderObjectData(e){let t=this.renderObjects.get(e);return t===void 0&&(t={material:this.getMaterialData(e.material),worldMatrix:e.object.matrixWorld.clone()},e.object.center&&(t.center=e.object.center.clone()),e.object.morphTargetInfluences&&(t.morphTargetInfluences=e.object.morphTargetInfluences.slice()),e.bundle!==null&&(t.version=e.bundle.version),this.renderObjects.set(e,t)),t}containsNode(e){const t=e.material;for(const i in t)if(t[i]&&t[i].isNode)return!0;return e.renderer.nodes.modelViewMatrix!==null||e.renderer.nodes.modelNormalViewMatrix!==null}getMaterialData(e){const t={};for(const i of this.refreshUniforms){const r=e[i];r!=null&&(typeof r=="object"&&r.clone!==void 0?r.isTexture===!0?t[i]={id:r.id,version:r.version}:t[i]=r.clone():t[i]=r)}return t}equals(e){const{object:t,material:i}=e,r=this.getRenderObjectData(e);if(r.worldMatrix.equals(t.matrixWorld)!==!0)return r.worldMatrix.copy(t.matrixWorld),!1;const s=r.material;for(const a in s){const o=s[a],l=i[a];if(o.equals!==void 0){if(o.equals(l)===!1)return o.copy(l),!1}else if(l.isTexture===!0){if(o.id!==l.id||o.version!==l.version)return o.id=l.id,o.version=l.version,!1}else if(o!==l)return s[a]=l,!1}if(r.morphTargetInfluences){let a=!1;for(let o=0;o<r.morphTargetInfluences.length;o++)r.morphTargetInfluences[o]!==t.morphTargetInfluences[o]&&(a=!0);if(a)return!0}return r.center&&r.center.equals(t.center)===!1?(r.center.copy(t.center),!0):(e.bundle!==null&&(r.version=e.bundle.version),!0)}needsRefresh(e,t){if(this.hasNode||this.hasAnimation||this.firstInitialization(e))return!0;const{renderId:i}=t;if(this.renderId!==i)return this.renderId=i,!0;const r=e.object.static===!0,s=e.bundle!==null&&e.bundle.static===!0&&this.getRenderObjectData(e).version===e.bundle.version;return r||s?!1:this.equals(e)!==!0}}function Nl(n,e=0){let t=3735928559^e,i=1103547991^e;if(n instanceof Array)for(let r=0,s;r<n.length;r++)s=n[r],t=Math.imul(t^s,2654435761),i=Math.imul(i^s,1597334677);else for(let r=0,s;r<n.length;r++)s=n.charCodeAt(r),t=Math.imul(t^s,2654435761),i=Math.imul(i^s,1597334677);return t=Math.imul(t^t>>>16,2246822507),t^=Math.imul(i^i>>>13,3266489909),i=Math.imul(i^i>>>16,2246822507),i^=Math.imul(t^t>>>13,3266489909),4294967296*(2097151&i)+(t>>>0)}const Gx=n=>Nl(n),Wx=n=>Nl(n),$m=(...n)=>Nl(n);function Jm(n,e=!1){const t=[];n.isNode===!0&&(t.push(n.id),n=n.getSelf());for(const{property:i,childNode:r}of Cl(n))t.push(t,Nl(i.slice(0,-4)),r.getCacheKey(e));return Nl(t)}function*Cl(n,e=!1){for(const t in n){if(t.startsWith("_")===!0)continue;const i=n[t];if(Array.isArray(i)===!0)for(let r=0;r<i.length;r++){const s=i[r];s&&(s.isNode===!0||e&&typeof s.toJSON=="function")&&(yield{property:t,index:r,childNode:s})}else if(i&&i.isNode===!0)yield{property:t,childNode:i};else if(typeof i=="object")for(const r in i){const s=i[r];s&&(s.isNode===!0||e&&typeof s.toJSON=="function")&&(yield{property:t,index:r,childNode:s})}}}function Ln(n){if(n==null)return null;const e=typeof n;return n.isNode===!0?"node":e==="number"?"float":e==="boolean"?"bool":e==="string"?"string":e==="function"?"shader":n.isVector2===!0?"vec2":n.isVector3===!0?"vec3":n.isVector4===!0?"vec4":n.isMatrix3===!0?"mat3":n.isMatrix4===!0?"mat4":n.isColor===!0?"color":n instanceof ArrayBuffer?"ArrayBuffer":null}function Km(n,...e){const t=n?n.slice(-4):void 0;return e.length===1&&(t==="vec2"?e=[e[0],e[0]]:t==="vec3"?e=[e[0],e[0],e[0]]:t==="vec4"&&(e=[e[0],e[0],e[0],e[0]])),n==="color"?new xe(...e):t==="vec2"?new J(...e):t==="vec3"?new N(...e):t==="vec4"?new st(...e):t==="mat3"?new Ke(...e):t==="mat4"?new Re(...e):n==="bool"?e[0]||!1:n==="float"||n==="int"||n==="uint"?e[0]||0:n==="string"?e[0]||"":n==="ArrayBuffer"?Qm(e[0]):null}function Zm(n){let e="";const t=new Uint8Array(n);for(let i=0;i<t.length;i++)e+=String.fromCharCode(t[i]);return btoa(e)}function Qm(n){return Uint8Array.from(atob(n),e=>e.charCodeAt(0)).buffer}var g2=Object.freeze({__proto__:null,arrayBufferToBase64:Zm,base64ToArrayBuffer:Qm,getCacheKey:Jm,getNodeChildren:Cl,getValueFromType:Km,getValueType:Ln,hash:$m,hashArray:Wx,hashString:Gx});const ef={VERTEX:"vertex",FRAGMENT:"fragment"},je={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},v2={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},tf=["fragment","vertex"],rf=["setup","analyze","generate"],nf=[...tf,"compute"],ro=["x","y","z","w"];let y2=0;class qe extends vr{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=je.NONE,this.updateBeforeType=je.NONE,this.updateAfterType=je.NONE,this.uuid=su.generateUUID(),this.version=0,this._cacheKey=null,this._cacheKeyVersion=0,this.global=!1,this.isNode=!0,Object.defineProperty(this,"id",{value:y2++})}set needsUpdate(e){e===!0&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this.getSelf()),this}onFrameUpdate(e){return this.onUpdate(e,je.FRAME)}onRenderUpdate(e){return this.onUpdate(e,je.RENDER)}onObjectUpdate(e){return this.onUpdate(e,je.OBJECT)}onReference(e){return this.updateReference=e.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:e}of Cl(this))yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(const t of this.getChildren())t.traverse(e)}getCacheKey(e=!1){return e=e||this.version!==this._cacheKeyVersion,(e===!0||this._cacheKey===null)&&(this._cacheKey=Jm(this,e),this._cacheKeyVersion=this.version),this._cacheKey}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){const t=this.getNodeType(e);return e.getElementType(t)}getNodeType(e){const t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){const t=this.getHash(e);return e.getNodeFromHash(t)||this}setup(e){const t=e.getNodeProperties(this);let i=0;for(const r of this.getChildren())t["node"+i++]=r;return null}analyze(e){if(e.increaseUsage(this)===1){const t=e.getNodeProperties(this);for(const i of Object.values(t))i&&i.isNode===!0&&i.build(e)}}generate(e,t){const{outputNode:i}=e.getNodeProperties(this);if(i&&i.isNode===!0)return i.build(e,t)}updateBefore(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(e,t=null){const i=this.getShared(e);if(this!==i)return i.build(e,t);e.addNode(this),e.addChain(this);let r=null;const s=e.getBuildStage();if(s==="setup"){this.updateReference(e);const a=e.getNodeProperties(this);if(a.initialized!==!0){const o=e.stack.nodes.length;a.initialized=!0,a.outputNode=this.setup(e),a.outputNode!==null&&e.stack.nodes.length;for(const l of Object.values(a))l&&l.isNode===!0&&l.build(e)}}else if(s==="analyze")this.analyze(e);else if(s==="generate")if(this.generate.length===1){const a=this.getNodeType(e),o=e.getDataFromNode(this);r=o.snippet,r===void 0?(r=this.generate(e)||"",o.snippet=r):o.flowCodes!==void 0&&e.context.nodeBlock!==void 0&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),r=e.format(r,a,t)}else r=this.generate(e,t)||"";return e.removeChain(this),r}getSerializeChildren(){return Cl(this)}serialize(e){const t=this.getSerializeChildren(),i={};for(const{property:r,index:s,childNode:a}of t)s!==void 0?(i[r]===void 0&&(i[r]=Number.isInteger(s)?[]:{}),i[r][s]=a.toJSON(e.meta).uuid):i[r]=a.toJSON(e.meta).uuid;Object.keys(i).length>0&&(e.inputNodes=i)}deserialize(e){if(e.inputNodes!==void 0){const t=e.meta.nodes;for(const i in e.inputNodes)if(Array.isArray(e.inputNodes[i])){const r=[];for(const s of e.inputNodes[i])r.push(t[s]);this[i]=r}else if(typeof e.inputNodes[i]=="object"){const r={};for(const s in e.inputNodes[i]){const a=e.inputNodes[i][s];r[s]=t[a]}this[i]=r}else{const r=e.inputNodes[i];this[i]=t[r]}}}toJSON(e){const{uuid:t,type:i}=this,r=e===void 0||typeof e=="string";r&&(e={textures:{},images:{},nodes:{}});let s=e.nodes[t];s===void 0&&(s={uuid:t,type:i,meta:e,metadata:{version:4.6,type:"Node",generator:"Node.toJSON"}},r!==!0&&(e.nodes[s.uuid]=s),this.serialize(s),delete s.meta);function a(o){const l=[];for(const c in o){const u=o[c];delete u.metadata,l.push(u)}return l}if(r){const o=a(e.textures),l=a(e.images),c=a(e.nodes);o.length>0&&(s.textures=o),l.length>0&&(s.images=l),c.length>0&&(s.nodes=c)}return s}}class ss extends qe{static get type(){return"ArrayElementNode"}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}generate(e){const t=this.node.build(e),i=this.indexNode.build(e,"uint");return`${t}[ ${i} ]`}}class sf extends qe{static get type(){return"ConvertNode"}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){const t=this.node.getNodeType(e);let i=null;for(const r of this.convertTo.split("|"))(i===null||e.getTypeLength(t)===e.getTypeLength(r))&&(i=r);return i}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){const i=this.node,r=this.getNodeType(e),s=i.build(e,r);return e.format(s,r,t)}}class pt extends qe{static get type(){return"TempNode"}constructor(e){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if(e.getBuildStage()==="generate"){const i=e.getVectorType(this.getNodeType(e,t)),r=e.getDataFromNode(this);if(r.propertyName!==void 0)return e.format(r.propertyName,i,t);if(i!=="void"&&t!=="void"&&this.hasDependencies(e)){const s=super.build(e,i),a=e.getVarFromNode(this,null,i),o=e.getPropertyName(a);return e.addLineFlowCode(`${o} = ${s}`,this),r.snippet=s,r.propertyName=o,e.format(r.propertyName,i,t)}}return super.build(e,t)}}class jx extends pt{static get type(){return"JoinNode"}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return this.nodeType!==null?e.getVectorType(this.nodeType):e.getTypeFromLength(this.nodes.reduce((t,i)=>t+e.getTypeLength(i.getNodeType(e)),0))}generate(e,t){const i=this.getNodeType(e),r=this.nodes,s=e.getComponentType(i),a=[];for(const l of r){let c=l.build(e);const u=e.getComponentType(l.getNodeType(e));u!==s&&(c=e.format(c,u,s)),a.push(c)}const o=`${e.getType(i)}( ${a.join(", ")} )`;return e.format(o,i,t)}}const x2=ro.join("");class Ah extends qe{static get type(){return"SplitNode"}constructor(e,t="x"){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(const t of this.components)e=Math.max(ro.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}generate(e,t){const i=this.node,r=e.getTypeLength(i.getNodeType(e));let s=null;if(r>1){let a=null;this.getVectorLength()>=r&&(a=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));const o=i.build(e,a);this.components.length===r&&this.components===x2.slice(0,this.components.length)?s=e.format(o,a,t):s=e.format(`${o}.${this.components}`,this.getNodeType(e),t)}else s=i.build(e,t);return s}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}}class Xx extends pt{static get type(){return"SetNode"}constructor(e,t,i){super(),this.sourceNode=e,this.components=t,this.targetNode=i}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{sourceNode:t,components:i,targetNode:r}=this,s=this.getNodeType(e),a=e.getTypeFromLength(i.length,r.getNodeType(e)),o=r.build(e,a),l=t.build(e,s),c=e.getTypeLength(s),u=[];for(let h=0;h<c;h++){const d=ro[h];d===i[0]?(u.push(o),h+=i.length-1):u.push(l+"."+d)}return`${e.getType(s)}( ${u.join(", ")} )`}}class _2 extends pt{static get type(){return"FlipNode"}constructor(e,t){super(),this.sourceNode=e,this.components=t}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{components:t,sourceNode:i}=this,r=this.getNodeType(e),s=i.build(e),a=e.getVarFromNode(this),o=e.getPropertyName(a);e.addLineFlowCode(o+" = "+s,this);const l=e.getTypeLength(r),c=[];let u=0;for(let h=0;h<l;h++){const d=ro[h];d===t[u]?(c.push("1.0 - "+(o+"."+d)),u++):c.push(o+"."+d)}return`${e.getType(r)}( ${c.join(", ")} )`}}class af extends qe{static get type(){return"InputNode"}constructor(e,t=null){super(t),this.isInputNode=!0,this.value=e,this.precision=null}getNodeType(){return this.nodeType===null?Ln(this.value):this.nodeType}getInputType(e){return this.getNodeType(e)}setPrecision(e){return this.precision=e,this}serialize(e){super.serialize(e),e.value=this.value,this.value&&this.value.toArray&&(e.value=this.value.toArray()),e.valueType=Ln(this.value),e.nodeType=this.nodeType,e.valueType==="ArrayBuffer"&&(e.value=Zm(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?Km(e.valueType,...e.value):e.value,this.precision=e.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(e.value))}generate(){console.warn("Abstract function.")}}class Fr extends af{static get type(){return"ConstNode"}constructor(e,t=null){super(e,t),this.isConstNode=!0}generateConst(e){return e.generateConst(this.getNodeType(e),this.value)}generate(e,t){const i=this.getNodeType(e);return e.format(this.generateConst(e),i,t)}}let no=null;const so=new Map;function te(n,e){if(so.has(n)){console.warn(`Redefinition of method chaining ${n}`);return}if(typeof e!="function")throw new Error(`Node element ${n} is not a function`);so.set(n,e)}const qx=n=>n.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),Yx=n=>qx(n).split("").sort().join(""),$x={setup(n,e){const t=e.shift();return n(Ll(t),...e)},get(n,e,t){if(typeof e=="string"&&n[e]===void 0){if(n.isStackNode!==!0&&e==="assign")return(...i)=>(no.assign(t,...i),t);if(so.has(e)){const i=so.get(e);return n.isStackNode?(...r)=>t.add(i(...r)):(...r)=>i(t,...r)}else{if(e==="self")return n;if(e.endsWith("Assign")&&so.has(e.slice(0,e.length-6))){const i=so.get(e.slice(0,e.length-6));return n.isStackNode?(...r)=>t.assign(r[0],i(...r)):(...r)=>t.assign(i(t,...r))}else{if(/^[xyzwrgbastpq]{1,4}$/.test(e)===!0)return e=qx(e),G(new Ah(t,e));if(/^set[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=Yx(e.slice(3).toLowerCase()),i=>G(new Xx(n,e,i));if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=Yx(e.slice(4).toLowerCase()),()=>G(new _2(G(n),e));if(e==="width"||e==="height"||e==="depth")return e==="width"?e="x":e==="height"?e="y":e==="depth"&&(e="z"),G(new Ah(n,e));if(/^\d+$/.test(e)===!0)return G(new ss(t,new Fr(Number(e),"uint")))}}}return Reflect.get(n,e,t)},set(n,e,t,i){return typeof e=="string"&&n[e]===void 0&&(/^[xyzwrgbastpq]{1,4}$/.test(e)===!0||e==="width"||e==="height"||e==="depth"||/^\d+$/.test(e)===!0)?(i[e].assign(t),!0):Reflect.set(n,e,t,i)}},of=new WeakMap,Jx=new WeakMap,M2=function(n,e=null){const t=Ln(n);if(t==="node"){let i=of.get(n);return i===void 0&&(i=new Proxy(n,$x),of.set(n,i),of.set(i,i)),i}else{if(e===null&&(t==="float"||t==="boolean")||t&&t!=="shader"&&t!=="string")return G(hf(n,e));if(t==="shader")return U(n)}return n},b2=function(n,e=null){for(const t in n)n[t]=G(n[t],e);return n},T2=function(n,e=null){const t=n.length;for(let i=0;i<t;i++)n[i]=G(n[i],e);return n},S2=function(n,e=null,t=null,i=null){const r=s=>G(i!==null?Object.assign(s,i):s);return e===null?(...s)=>r(new n(...Xs(s))):t!==null?(t=G(t),(...s)=>r(new n(e,...Xs(s),t))):(...s)=>r(new n(e,...Xs(s)))},w2=function(n,...e){return G(new n(...Xs(e)))};class E2 extends qe{constructor(e,t){super(),this.shaderNode=e,this.inputNodes=t}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}call(e){const{shaderNode:t,inputNodes:i}=this,r=e.getNodeProperties(t);if(r.onceOutput)return r.onceOutput;let s=null;if(t.layout){let a=Jx.get(e.constructor);a===void 0&&(a=new WeakMap,Jx.set(e.constructor,a));let o=a.get(t);o===void 0&&(o=G(e.buildFunctionNode(t)),a.set(t,o)),e.currentFunctionNode!==null&&e.currentFunctionNode.includes.push(o),s=G(o.call(i))}else{const a=t.jsFunc,o=i!==null?a(i,e):a(e);s=G(o)}return t.once&&(r.onceOutput=s),s}getOutputNode(e){const t=e.getNodeProperties(this);return t.outputNode===null&&(t.outputNode=this.setupOutput(e)),t.outputNode}setup(e){return this.getOutputNode(e)}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}generate(e,t){return this.getOutputNode(e).build(e,t)}}class A2 extends qe{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1}setLayout(e){return this.layout=e,this}call(e=null){return Ll(e),G(new E2(this,e))}setup(){return this.call()}}const N2=[!1,!0],C2=[0,1,2,3],R2=[-1,-2],Kx=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],lf=new Map;for(const n of N2)lf.set(n,new Fr(n));const cf=new Map;for(const n of C2)cf.set(n,new Fr(n,"uint"));const uf=new Map([...cf].map(n=>new Fr(n.value,"int")));for(const n of R2)uf.set(n,new Fr(n,"int"));const Nh=new Map([...uf].map(n=>new Fr(n.value)));for(const n of Kx)Nh.set(n,new Fr(n));for(const n of Kx)Nh.set(-n,new Fr(-n));const Ch={bool:lf,uint:cf,ints:uf,float:Nh},Zx=new Map([...lf,...Nh]),hf=(n,e)=>Zx.has(n)?Zx.get(n):n.isNode===!0?n:new Fr(n,e),I2=n=>{try{return n.getNodeType()}catch{return}},oi=function(n,e=null){return(...t)=>{if((t.length===0||!["bool","float","int","uint"].includes(n)&&t.every(r=>typeof r!="object"))&&(t=[Km(n,...t)]),t.length===1&&e!==null&&e.has(t[0]))return G(e.get(t[0]));if(t.length===1){const r=hf(t[0],n);return I2(r)===n?G(r):G(new sf(r,n))}const i=t.map(r=>hf(r));return G(new jx(i,n))}},Rl=n=>typeof n=="object"&&n!==null?n.value:n,Qx=n=>n!=null?n.nodeType||n.convertTo||(typeof n=="string"?n:null):null;function Il(n,e){return new Proxy(new A2(n,e),$x)}const G=(n,e=null)=>M2(n,e),Ll=(n,e=null)=>new b2(n,e),Xs=(n,e=null)=>new T2(n,e),K=(...n)=>new S2(...n),ge=(...n)=>new w2(...n),U=(n,e)=>{const t=new Il(n,e),i=(...r)=>{let s;return Ll(r),r[0]&&r[0].isNode?s=[...r]:s=r[0],t.call(s)};return i.shaderNode=t,i.setLayout=r=>(t.setLayout(r),i),i.once=()=>(t.once=!0,i),i},L2=(...n)=>(console.warn("TSL.ShaderNode: tslFn() has been renamed to Fn()."),U(...n));te("toGlobal",n=>(n.global=!0,n));const Pl=n=>{no=n},df=()=>no,Le=(...n)=>no.If(...n);function e_(n){return no&&no.add(n),n}te("append",e_);const t_=new oi("color"),E=new oi("float",Ch.float),P=new oi("int",Ch.ints),_e=new oi("uint",Ch.uint),as=new oi("bool",Ch.bool),z=new oi("vec2"),un=new oi("ivec2"),i_=new oi("uvec2"),r_=new oi("bvec2"),D=new oi("vec3"),n_=new oi("ivec3"),ao=new oi("uvec3"),pf=new oi("bvec3"),ae=new oi("vec4"),s_=new oi("ivec4"),a_=new oi("uvec4"),o_=new oi("bvec4"),Dl=new oi("mat2"),yi=new oi("mat3"),qs=new oi("mat4"),P2=(n="")=>G(new Fr(n,"string")),D2=n=>G(new Fr(n,"ArrayBuffer"));te("toColor",t_),te("toFloat",E),te("toInt",P),te("toUint",_e),te("toBool",as),te("toVec2",z),te("toIVec2",un),te("toUVec2",i_),te("toBVec2",r_),te("toVec3",D),te("toIVec3",n_),te("toUVec3",ao),te("toBVec3",pf),te("toVec4",ae),te("toIVec4",s_),te("toUVec4",a_),te("toBVec4",o_),te("toMat2",Dl),te("toMat3",yi),te("toMat4",qs);const l_=K(ss),c_=(n,e)=>G(new sf(G(n),e)),U2=(n,e)=>G(new Ah(G(n),e));te("element",l_),te("convert",c_);class mf extends qe{static get type(){return"UniformGroupNode"}constructor(e,t=!1,i=1){super("string"),this.name=e,this.version=0,this.shared=t,this.order=i,this.isUniformGroup=!0}set needsUpdate(e){e===!0&&this.version++}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}}const u_=n=>new mf(n),ff=(n,e=0)=>new mf(n,!0,e),O2=ff("frame"),xt=ff("render"),h_=u_("object");class Ys extends af{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=h_}label(e){return this.name=e,this}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){const i=this.getSelf();return e=e.bind(i),super.onUpdate(r=>{const s=e(r,i);s!==void 0&&(this.value=s)},t)}generate(e,t){const i=this.getNodeType(e),r=this.getUniformHash(e);let s=e.getNodeFromHash(r);s===void 0&&(e.setHashNode(this,r),s=this);const a=s.getInputType(e),o=e.getUniformFromNode(s,a,e.shaderStage,this.name||e.context.label),l=e.getPropertyName(o);return e.context.label!==void 0&&delete e.context.label,e.format(l,i,t)}}const fe=(n,e)=>{const t=Qx(e||n),i=n&&n.isNode===!0?n.node&&n.node.value||n.value:n;return G(new Ys(i,t))};class Et extends qe{static get type(){return"PropertyNode"}constructor(e,t=null,i=!1){super(e),this.name=t,this.varying=i,this.isPropertyNode=!0}getHash(e){return this.name||super.getHash(e)}isGlobal(){return!0}generate(e){let t;return this.varying===!0?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}}const ar=(n,e)=>G(new Et(n,e)),Zr=(n,e)=>G(new Et(n,e,!0)),Nt=ge(Et,"vec4","DiffuseColor"),gf=ge(Et,"vec3","EmissiveColor"),hn=ge(Et,"float","Roughness"),Ul=ge(Et,"float","Metalness"),Rh=ge(Et,"float","Clearcoat"),Ol=ge(Et,"float","ClearcoatRoughness"),$s=ge(Et,"vec3","Sheen"),Ih=ge(Et,"float","SheenRoughness"),Lh=ge(Et,"float","Iridescence"),vf=ge(Et,"float","IridescenceIOR"),yf=ge(Et,"float","IridescenceThickness"),Ph=ge(Et,"float","AlphaT"),os=ge(Et,"float","Anisotropy"),Fl=ge(Et,"vec3","AnisotropyT"),Js=ge(Et,"vec3","AnisotropyB"),or=ge(Et,"color","SpecularColor"),Vl=ge(Et,"float","SpecularF90"),Dh=ge(Et,"float","Shininess"),xf=ge(Et,"vec4","Output"),Ks=ge(Et,"float","dashSize"),Bl=ge(Et,"float","gapSize"),F2=ge(Et,"float","pointWidth"),zl=ge(Et,"float","IOR"),Uh=ge(Et,"float","Transmission"),_f=ge(Et,"float","Thickness"),Mf=ge(Et,"float","AttenuationDistance"),bf=ge(Et,"color","AttenuationColor"),Tf=ge(Et,"float","Dispersion");class d_ extends pt{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t}hasDependencies(){return!1}getNodeType(e,t){return t!=="void"?this.targetNode.getNodeType(e):"void"}needsSplitAssign(e){const{targetNode:t}=this;if(e.isAvailable("swizzleAssign")===!1&&t.isSplitNode&&t.components.length>1){const i=e.getTypeLength(t.node.getNodeType(e));return ro.join("").slice(0,i)!==t.components}return!1}generate(e,t){const{targetNode:i,sourceNode:r}=this,s=this.needsSplitAssign(e),a=i.getNodeType(e),o=i.context({assign:!0}).build(e),l=r.build(e,a),c=r.getNodeType(e),u=e.getDataFromNode(this);let h;if(u.initialized===!0)t!=="void"&&(h=o);else if(s){const d=e.getVarFromNode(this,null,a),p=e.getPropertyName(d);e.addLineFlowCode(`${p} = ${l}`,this);const m=i.node.context({assign:!0}).build(e);for(let v=0;v<i.components.length;v++){const f=i.components[v];e.addLineFlowCode(`${m}.${f} = ${p}[ ${v} ]`,this)}t!=="void"&&(h=o)}else h=`${o} = ${l}`,(t==="void"||c==="void")&&(e.addLineFlowCode(h,this),t!=="void"&&(h=o));return u.initialized=!0,e.format(h,a,t)}}const p_=K(d_);te("assign",p_);class m_ extends pt{static get type(){return"FunctionCallNode"}constructor(e=null,t={}){super(),this.functionNode=e,this.parameters=t}setParameters(e){return this.parameters=e,this}getParameters(){return this.parameters}getNodeType(e){return this.functionNode.getNodeType(e)}generate(e){const t=[],i=this.functionNode,r=i.getInputs(e),s=this.parameters;if(Array.isArray(s))for(let a=0;a<s.length;a++){const o=r[a],l=s[a];t.push(l.build(e,o.type))}else for(const a of r){const o=s[a.name];if(o!==void 0)t.push(o.build(e,a.type));else throw new Error(`FunctionCallNode: Input '${a.name}' not found in FunctionNode.`)}return`${i.build(e,"property")}( ${t.join(", ")} )`}}const f_=(n,...e)=>(e=e.length>1||e[0]&&e[0].isNode===!0?Xs(e):Ll(e[0]),G(new m_(G(n),e)));te("call",f_);class Gt extends pt{static get type(){return"OperatorNode"}constructor(e,t,i,...r){if(super(),r.length>0){let s=new Gt(e,t,i);for(let a=0;a<r.length-1;a++)s=new Gt(e,s,r[a]);t=s,i=r[r.length-1]}this.op=e,this.aNode=t,this.bNode=i}getNodeType(e,t){const i=this.op,r=this.aNode,s=this.bNode,a=r.getNodeType(e),o=typeof s<"u"?s.getNodeType(e):null;if(a==="void"||o==="void")return"void";if(i==="%")return a;if(i==="~"||i==="&"||i==="|"||i==="^"||i===">>"||i==="<<")return e.getIntegerType(a);if(i==="!"||i==="=="||i==="&&"||i==="||"||i==="^^")return"bool";if(i==="<"||i===">"||i==="<="||i===">="){const l=t?e.getTypeLength(t):Math.max(e.getTypeLength(a),e.getTypeLength(o));return l>1?`bvec${l}`:"bool"}else return a==="float"&&e.isMatrix(o)?o:e.isMatrix(a)&&e.isVector(o)?e.getVectorFromMatrix(a):e.isVector(a)&&e.isMatrix(o)?e.getVectorFromMatrix(o):e.getTypeLength(o)>e.getTypeLength(a)?o:a}generate(e,t){const i=this.op,r=this.aNode,s=this.bNode,a=this.getNodeType(e,t);let o=null,l=null;a!=="void"?(o=r.getNodeType(e),l=typeof s<"u"?s.getNodeType(e):null,i==="<"||i===">"||i==="<="||i===">="||i==="=="?e.isVector(o)?l=o:o!==l&&(o=l="float"):i===">>"||i==="<<"?(o=a,l=e.changeComponentType(l,"uint")):e.isMatrix(o)&&e.isVector(l)?l=e.getVectorFromMatrix(o):e.isVector(o)&&e.isMatrix(l)?o=e.getVectorFromMatrix(l):o=l=a):o=l=a;const c=r.build(e,o),u=typeof s<"u"?s.build(e,l):null,h=e.getTypeLength(t),d=e.getFunctionOperator(i);if(t!=="void")return i==="<"&&h>1?e.useComparisonMethod?e.format(`${e.getMethod("lessThan",t)}( ${c}, ${u} )`,a,t):e.format(`( ${c} < ${u} )`,a,t):i==="<="&&h>1?e.useComparisonMethod?e.format(`${e.getMethod("lessThanEqual",t)}( ${c}, ${u} )`,a,t):e.format(`( ${c} <= ${u} )`,a,t):i===">"&&h>1?e.useComparisonMethod?e.format(`${e.getMethod("greaterThan",t)}( ${c}, ${u} )`,a,t):e.format(`( ${c} > ${u} )`,a,t):i===">="&&h>1?e.useComparisonMethod?e.format(`${e.getMethod("greaterThanEqual",t)}( ${c}, ${u} )`,a,t):e.format(`( ${c} >= ${u} )`,a,t):i==="!"||i==="~"?e.format(`(${i}${c})`,o,t):d?e.format(`${d}( ${c}, ${u} )`,a,t):e.format(`( ${c} ${i} ${u} )`,a,t);if(o!=="void")return d?e.format(`${d}( ${c}, ${u} )`,a,t):e.format(`${c} ${i} ${u}`,a,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}}const zt=K(Gt,"+"),Pt=K(Gt,"-"),lt=K(Gt,"*"),Qr=K(Gt,"/"),Sf=K(Gt,"%"),g_=K(Gt,"=="),v_=K(Gt,"!="),y_=K(Gt,"<"),wf=K(Gt,">"),x_=K(Gt,"<="),__=K(Gt,">="),M_=K(Gt,"&&"),b_=K(Gt,"||"),T_=K(Gt,"!"),S_=K(Gt,"^^"),w_=K(Gt,"&"),E_=K(Gt,"~"),A_=K(Gt,"|"),N_=K(Gt,"^"),C_=K(Gt,"<<"),R_=K(Gt,">>");te("add",zt),te("sub",Pt),te("mul",lt),te("div",Qr),te("modInt",Sf),te("equal",g_),te("notEqual",v_),te("lessThan",y_),te("greaterThan",wf),te("lessThanEqual",x_),te("greaterThanEqual",__),te("and",M_),te("or",b_),te("not",T_),te("xor",S_),te("bitAnd",w_),te("bitNot",E_),te("bitOr",A_),te("bitXor",N_),te("shiftLeft",C_),te("shiftRight",R_);const I_=(...n)=>(console.warn("TSL.OperatorNode: .remainder() has been renamed to .modInt()."),Sf(...n));te("remainder",I_);class V extends pt{static get type(){return"MathNode"}constructor(e,t,i=null,r=null){super(),this.method=e,this.aNode=t,this.bNode=i,this.cNode=r}getInputType(e){const t=this.aNode.getNodeType(e),i=this.bNode?this.bNode.getNodeType(e):null,r=this.cNode?this.cNode.getNodeType(e):null,s=e.isMatrix(t)?0:e.getTypeLength(t),a=e.isMatrix(i)?0:e.getTypeLength(i),o=e.isMatrix(r)?0:e.getTypeLength(r);return s>a&&s>o?t:a>o?i:o>s?r:t}getNodeType(e){const t=this.method;return t===V.LENGTH||t===V.DISTANCE||t===V.DOT?"float":t===V.CROSS?"vec3":t===V.ALL?"bool":t===V.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):t===V.MOD?this.aNode.getNodeType(e):this.getInputType(e)}generate(e,t){const i=this.method,r=this.getNodeType(e),s=this.getInputType(e),a=this.aNode,o=this.bNode,l=this.cNode,c=e.renderer.isWebGLRenderer===!0;if(i===V.TRANSFORM_DIRECTION){let u=a,h=o;e.isMatrix(u.getNodeType(e))?h=ae(D(h),0):u=ae(D(u),0);const d=lt(u,h).xyz;return Mr(d).build(e,t)}else{if(i===V.NEGATE)return e.format("( - "+a.build(e,s)+" )",r,t);if(i===V.ONE_MINUS)return Pt(1,a).build(e,t);if(i===V.RECIPROCAL)return Qr(1,a).build(e,t);if(i===V.DIFFERENCE)return It(Pt(a,o)).build(e,t);{const u=[];return i===V.CROSS||i===V.MOD?u.push(a.build(e,r),o.build(e,r)):c&&i===V.STEP?u.push(a.build(e,e.getTypeLength(a.getNodeType(e))===1?"float":s),o.build(e,s)):c&&(i===V.MIN||i===V.MAX)||i===V.MOD?u.push(a.build(e,s),o.build(e,e.getTypeLength(o.getNodeType(e))===1?"float":s)):i===V.REFRACT?u.push(a.build(e,s),o.build(e,s),l.build(e,"float")):i===V.MIX?u.push(a.build(e,s),o.build(e,s),l.build(e,e.getTypeLength(l.getNodeType(e))===1?"float":s)):(u.push(a.build(e,s)),o!==null&&u.push(o.build(e,s)),l!==null&&u.push(l.build(e,s))),e.format(`${e.getMethod(i,r)}( ${u.join(", ")} )`,r,t)}}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}V.ALL="all",V.ANY="any",V.EQUALS="equals",V.RADIANS="radians",V.DEGREES="degrees",V.EXP="exp",V.EXP2="exp2",V.LOG="log",V.LOG2="log2",V.SQRT="sqrt",V.INVERSE_SQRT="inversesqrt",V.FLOOR="floor",V.CEIL="ceil",V.NORMALIZE="normalize",V.FRACT="fract",V.SIN="sin",V.COS="cos",V.TAN="tan",V.ASIN="asin",V.ACOS="acos",V.ATAN="atan",V.ABS="abs",V.SIGN="sign",V.LENGTH="length",V.NEGATE="negate",V.ONE_MINUS="oneMinus",V.DFDX="dFdx",V.DFDY="dFdy",V.ROUND="round",V.RECIPROCAL="reciprocal",V.TRUNC="trunc",V.FWIDTH="fwidth",V.BITCAST="bitcast",V.TRANSPOSE="transpose",V.ATAN2="atan2",V.MIN="min",V.MAX="max",V.MOD="mod",V.STEP="step",V.REFLECT="reflect",V.DISTANCE="distance",V.DIFFERENCE="difference",V.DOT="dot",V.CROSS="cross",V.POW="pow",V.TRANSFORM_DIRECTION="transformDirection",V.MIX="mix",V.CLAMP="clamp",V.REFRACT="refract",V.SMOOTHSTEP="smoothstep",V.FACEFORWARD="faceforward";const L_=E(1e-6),V2=E(1e6),Zs=E(Math.PI),B2=E(Math.PI*2),Ef=K(V,V.ALL),P_=K(V,V.ANY),D_=K(V,V.EQUALS),U_=K(V,V.RADIANS),O_=K(V,V.DEGREES),Af=K(V,V.EXP),Oh=K(V,V.EXP2),Nf=K(V,V.LOG),kl=K(V,V.LOG2),en=K(V,V.SQRT),F_=K(V,V.INVERSE_SQRT),ls=K(V,V.FLOOR),Cf=K(V,V.CEIL),Mr=K(V,V.NORMALIZE),cs=K(V,V.FRACT),Ci=K(V,V.SIN),br=K(V,V.COS),V_=K(V,V.TAN),B_=K(V,V.ASIN),Fh=K(V,V.ACOS),z_=K(V,V.ATAN),It=K(V,V.ABS),Hl=K(V,V.SIGN),Qs=K(V,V.LENGTH),k_=K(V,V.NEGATE),H_=K(V,V.ONE_MINUS),G_=K(V,V.DFDX),W_=K(V,V.DFDY),j_=K(V,V.ROUND),X_=K(V,V.RECIPROCAL),Rf=K(V,V.TRUNC),q_=K(V,V.FWIDTH),z2=K(V,V.BITCAST),Y_=K(V,V.TRANSPOSE),$_=K(V,V.ATAN2),xi=K(V,V.MIN),ft=K(V,V.MAX),Vh=K(V,V.MOD),Gl=K(V,V.STEP),J_=K(V,V.REFLECT),K_=K(V,V.DISTANCE),Z_=K(V,V.DIFFERENCE),qt=K(V,V.DOT),oo=K(V,V.CROSS),Ji=K(V,V.POW),If=K(V,V.POW,2),Q_=K(V,V.POW,3),eM=K(V,V.POW,4),tM=K(V,V.TRANSFORM_DIRECTION),iM=n=>lt(Hl(n),Ji(It(n),1/3)),Lf=n=>qt(n,n),rt=K(V,V.MIX),li=(n,e=0,t=1)=>G(new V(V.CLAMP,G(n),G(e),G(t))),rM=n=>li(n),Pf=K(V,V.REFRACT),Ki=K(V,V.SMOOTHSTEP),nM=K(V,V.FACEFORWARD),Df=U(([n])=>{const e=43758.5453,t=qt(n.xy,z(12.9898,78.233)),i=Vh(t,Zs);return cs(Ci(i).mul(e))}),sM=(n,e,t)=>rt(e,t,n),aM=(n,e,t)=>Ki(e,t,n);te("all",Ef),te("any",P_),te("equals",D_),te("radians",U_),te("degrees",O_),te("exp",Af),te("exp2",Oh),te("log",Nf),te("log2",kl),te("sqrt",en),te("inverseSqrt",F_),te("floor",ls),te("ceil",Cf),te("normalize",Mr),te("fract",cs),te("sin",Ci),te("cos",br),te("tan",V_),te("asin",B_),te("acos",Fh),te("atan",z_),te("abs",It),te("sign",Hl),te("length",Qs),te("lengthSq",Lf),te("negate",k_),te("oneMinus",H_),te("dFdx",G_),te("dFdy",W_),te("round",j_),te("reciprocal",X_),te("trunc",Rf),te("fwidth",q_),te("atan2",$_),te("min",xi),te("max",ft),te("mod",Vh),te("step",Gl),te("reflect",J_),te("distance",K_),te("dot",qt),te("cross",oo),te("pow",Ji),te("pow2",If),te("pow3",Q_),te("pow4",eM),te("transformDirection",tM),te("mix",sM),te("clamp",li),te("refract",Pf),te("smoothstep",aM),te("faceForward",nM),te("difference",Z_),te("saturate",rM),te("cbrt",iM),te("transpose",Y_),te("rand",Df);class k2 extends qe{static get type(){return"ConditionalNode"}constructor(e,t,i=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=i}getNodeType(e){const t=this.ifNode.getNodeType(e);if(this.elseNode!==null){const i=this.elseNode.getNodeType(e);if(e.getTypeLength(i)>e.getTypeLength(t))return i}return t}setup(e){const t=this.condNode.cache(),i=this.ifNode.cache(),r=this.elseNode?this.elseNode.cache():null,s=e.context.nodeBlock;e.getDataFromNode(i).parentNodeBlock=s,r!==null&&(e.getDataFromNode(r).parentNodeBlock=s);const a=e.getNodeProperties(this);a.condNode=t,a.ifNode=i.context({nodeBlock:i}),a.elseNode=r?r.context({nodeBlock:r}):null}generate(e,t){const i=this.getNodeType(e),r=e.getDataFromNode(this);if(r.nodeProperty!==void 0)return r.nodeProperty;const{condNode:s,ifNode:a,elseNode:o}=e.getNodeProperties(this),l=t!=="void",c=l?ar(i).build(e):"";r.nodeProperty=c;const u=s.build(e,"bool");e.addFlowCode(`
|
|
3848
3848
|
${e.tab}if ( ${u} ) {
|
|
3849
3849
|
|
|
3850
3850
|
`).addFlowTab();let h=a.build(e,i);if(h&&(l?h=c+" = "+h+";":h="return "+h+";"),e.removeFlowTab().addFlowCode(e.tab+" "+h+`
|
|
@@ -3857,18 +3857,18 @@ ${e.tab}if ( ${u} ) {
|
|
|
3857
3857
|
|
|
3858
3858
|
`)}else e.addFlowCode(`
|
|
3859
3859
|
|
|
3860
|
-
`);return e.format(c,i,t)}}const Ri=K(k2);te("select",Ri);const lM=(...n)=>(console.warn("TSL.ConditionalNode: cond() has been renamed to select()."),Ri(...n));te("cond",lM);class Of extends qe{static get type(){return"ContextNode"}constructor(e,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}analyze(e){this.node.build(e)}setup(e){const t=e.getContext();e.setContext({...e.context,...this.value});const i=this.node.build(e);return e.setContext(t),i}generate(e,t){const i=e.getContext();e.setContext({...e.context,...this.value});const r=this.node.build(e,t);return e.setContext(i),r}}const Ff=K(Of),cM=(n,e)=>Ff(n,{label:e});te("context",Ff),te("label",cM);class uM extends qe{static get type(){return"VarNode"}constructor(e,t=null){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}generate(e){const{node:t,name:i}=this,r=e.getVarFromNode(this,i,e.getVectorType(this.getNodeType(e))),s=e.getPropertyName(r),a=t.build(e,r.type);return e.addLineFlowCode(`${s} = ${a}`,this),s}}const Vf=K(uM);te("temp",Vf),te("toVar",(...n)=>Vf(...n).append());class hM extends qe{static get type(){return"VaryingNode"}constructor(e,t=null){super(),this.node=e,this.name=t,this.isVaryingNode=!0}isGlobal(){return!0}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}setupVarying(e){const t=e.getNodeProperties(this);let i=t.varying;if(i===void 0){const r=this.name,s=this.getNodeType(e);t.varying=i=e.getVaryingFromNode(this,r,s),t.node=this.node}return i.needsInterpolation||(i.needsInterpolation=e.shaderStage==="fragment"),i}setup(e){this.setupVarying(e)}analyze(e){return this.setupVarying(e),this.node.analyze(e)}generate(e){const t=e.getNodeProperties(this),i=this.setupVarying(e);if(t.propertyName===void 0){const r=this.getNodeType(e),s=e.getPropertyName(i,tf.VERTEX);e.flowNodeFromShaderStage(tf.VERTEX,this.node,r,s),t.propertyName=s}return e.getPropertyName(i)}}const Ii=K(hM);te("varying",Ii);const jl="WorkingColorSpace",Bf="OutputColorSpace";function dM(n){let e=null;return n===nr?e="Linear":n===Fi&&(e="sRGB"),e}function zh(n,e){return dM(n)+"To"+dM(e)}class Xl extends pt{static get type(){return"ColorSpaceNode"}constructor(e,t,i){super("vec4"),this.colorNode=e,this.source=t,this.target=i}getColorSpace(e,t){return t===jl?vt.workingColorSpace:t===Bf?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){const{renderer:t}=e,{colorNode:i}=this,r=this.getColorSpace(e,this.source),s=this.getColorSpace(e,this.target);if(r===s)return i;const a=zh(r,s);let o=null;const l=t.nodes.library.getColorSpaceFunction(a);return l!==null?o=ae(l(i.rgb),i.a):(console.error("ColorSpaceNode: Unsupported Color Space configuration.",a),o=i),o}}const pM=n=>G(new Xl(G(n),jl,Bf)),mM=n=>G(new Xl(G(n),Bf,jl)),fM=(n,e)=>G(new Xl(G(n),jl,e)),zf=(n,e)=>G(new Xl(G(n),e,jl));te("toOutputColorSpace",pM),te("toWorkingColorSpace",mM),te("workingToColorSpace",fM),te("colorSpaceToWorking",zf);let H2=class extends as{static get type(){return"ReferenceElementNode"}constructor(n,e){super(n,e),this.referenceNode=n,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(n){const e=super.generate(n),t=this.referenceNode.getNodeType(),i=this.getNodeType();return n.format(e,t,i)}};class gM extends qe{static get type(){return"ReferenceBaseNode"}constructor(e,t,i=null,r=null){super(),this.property=e,this.uniformType=t,this.object=i,this.count=r,this.properties=e.split("."),this.reference=i,this.node=null,this.group=null,this.updateType=je.OBJECT}setGroup(e){return this.group=e,this}element(e){return G(new H2(this,G(e)))}setNodeType(e){const t=fe(null,e).getSelf();this.group!==null&&t.setGroup(this.group),this.node=t}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let i=e[t[0]];for(let r=1;r<t.length;r++)i=i[t[r]];return i}updateReference(e){return this.reference=this.object!==null?this.object:e.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);const e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}}const G2=(n,e,t)=>G(new gM(n,e,t));class vM extends gM{static get type(){return"RendererReferenceNode"}constructor(e,t,i=null){super(e,t,i),this.renderer=i,this.setGroup(xt)}updateReference(e){return this.reference=this.renderer!==null?this.renderer:e.renderer,this.reference}}const yM=(n,e,t)=>G(new vM(n,e,t));class xM extends pt{static get type(){return"ToneMappingNode"}constructor(e,t=MM,i=null){super("vec3"),this.toneMapping=e,this.exposureNode=t,this.colorNode=i}getCacheKey(){return Jm(super.getCacheKey(),this.toneMapping)}setup(e){const t=this.colorNode||e.context.color,i=this.toneMapping;if(i===mr)return t;let r=null;const s=e.renderer.nodes.library.getToneMappingFunction(i);return s!==null?r=ae(s(t.rgb,this.exposureNode),t.a):(console.error("ToneMappingNode: Unsupported Tone Mapping configuration.",i),r=t),r}}const _M=(n,e,t)=>G(new xM(n,G(e),G(t))),MM=yM("toneMappingExposure","float");te("toneMapping",(n,e,t)=>_M(e,t,n));class bM extends of{static get type(){return"BufferAttributeNode"}constructor(e,t=null,i=0,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=i,this.bufferOffset=r,this.usage=Sa,this.instanced=!1,this.attribute=null,this.global=!0,e&&e.isBufferAttribute===!0&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){if(this.bufferStride===0&&this.bufferOffset===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getNodeType(e){return this.bufferType===null&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(this.attribute!==null)return;const t=this.getNodeType(e),i=this.value,r=e.getTypeLength(t),s=this.bufferStride||r,a=this.bufferOffset,o=i.isInterleavedBuffer===!0?i:new ja(i,s),l=new On(o,r,a);o.setUsage(this.usage),this.attribute=l,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){const t=this.getNodeType(e),i=e.getBufferAttributeFromNode(this,t),r=e.getPropertyName(i);let s=null;return e.shaderStage==="vertex"||e.shaderStage==="compute"?(this.name=r,s=r):s=Ii(this).build(e,t),s}getInputType(){return"bufferAttribute"}setUsage(e){return this.usage=e,this.attribute&&this.attribute.isBufferAttribute===!0&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}}const ql=(n,e,t,i)=>G(new bM(n,e,t,i)),TM=(n,e,t,i)=>ql(n,e,t,i).setUsage(bs),kh=(n,e,t,i)=>ql(n,e,t,i).setInstanced(!0),kf=(n,e,t,i)=>TM(n,e,t,i).setInstanced(!0);te("toAttribute",n=>ql(n.value));class SM extends qe{static get type(){return"ComputeNode"}constructor(e,t,i=[64]){super("void"),this.isComputeNode=!0,this.computeNode=e,this.count=t,this.workgroupSize=i,this.dispatchCount=0,this.version=1,this.updateBeforeType=je.OBJECT,this.updateDispatchCount()}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}updateDispatchCount(){const{count:e,workgroupSize:t}=this;let i=t[0];for(let r=1;r<t.length;r++)i*=t[r];this.dispatchCount=Math.ceil(e/i)}onInit(){}updateBefore({renderer:e}){e.compute(this)}generate(e){const{shaderStage:t}=e;if(t==="compute"){const i=this.computeNode.build(e,"void");i!==""&&e.addLineFlowCode(i,this)}}}const wM=(n,e,t)=>G(new SM(G(n),e,t));te("compute",wM);class EM extends qe{static get type(){return"CacheNode"}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isCacheNode=!0}getNodeType(e){return this.node.getNodeType(e)}build(e,...t){const i=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);const s=this.node.build(e,...t);return e.setCache(i),s}}const Yl=(n,...e)=>G(new EM(G(n),...e));te("cache",Yl);class AM extends qe{static get type(){return"BypassNode"}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}getNodeType(e){return this.outputNode.getNodeType(e)}generate(e){const t=this.callNode.build(e,"void");return t!==""&&e.addLineFlowCode(t,this),this.outputNode.build(e)}}const NM=K(AM);te("bypass",NM);class Hf extends qe{static get type(){return"RemapNode"}constructor(e,t,i,r=E(0),s=E(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=i,this.outLowNode=r,this.outHighNode=s,this.doClamp=!0}setup(){const{node:e,inLowNode:t,inHighNode:i,outLowNode:r,outHighNode:s,doClamp:a}=this;let o=e.sub(t).div(i.sub(t));return a===!0&&(o=o.clamp()),o.mul(s.sub(r)).add(r)}}const CM=K(Hf,null,null,{doClamp:!1}),RM=K(Hf);te("remap",CM),te("remapClamp",RM);class IM extends qe{static get type(){return"ExpressionNode"}constructor(e="",t="void"){super(t),this.snippet=e}generate(e,t){const i=this.getNodeType(e),r=this.snippet;if(i==="void")e.addLineFlowCode(r,this);else return e.format(`( ${r} )`,i,t)}}const hs=K(IM),LM=n=>(n?Ri(n,hs("discard")):hs("discard")).append(),W2=()=>hs("return").append();te("discard",LM);class PM extends pt{static get type(){return"RenderOutputNode"}constructor(e,t,i){super("vec4"),this.colorNode=e,this.toneMapping=t,this.outputColorSpace=i,this.isRenderOutput=!0}setup({context:e}){let t=this.colorNode||e.color;const i=(this.toneMapping!==null?this.toneMapping:e.toneMapping)||mr,r=(this.outputColorSpace!==null?this.outputColorSpace:e.outputColorSpace)||Cr;return i!==mr&&(t=t.toneMapping(i)),r!==Cr&&r!==vt.workingColorSpace&&(t=t.workingToColorSpace(r)),t}}const DM=(n,e=null,t=null)=>G(new PM(G(n),e,t));te("renderOutput",DM);function j2(n){console.warn("THREE.TSLBase: AddNodeElement has been removed in favor of tree-shaking. Trying add",n)}class Gf extends qe{static get type(){return"AttributeNode"}constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}getNodeType(e){let t=this.nodeType;if(t===null){const i=this.getAttributeName(e);if(e.hasGeometryAttribute(i)){const r=e.geometry.getAttribute(i);t=e.getTypeFromAttribute(r)}else t="float"}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){const t=this.getAttributeName(e),i=this.getNodeType(e);if(e.hasGeometryAttribute(t)===!0){const r=e.geometry.getAttribute(t),s=e.getTypeFromAttribute(r),a=e.getAttribute(t,s);return e.shaderStage==="vertex"?e.format(a.name,s,i):Ii(this).build(e,i)}else return console.warn(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(i)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}}const _i=(n,e)=>G(new Gf(n,e)),nt=n=>_i("uv"+(n>0?n:""),"vec2");class UM extends qe{static get type(){return"TextureSizeNode"}constructor(e,t=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){const i=this.textureNode.build(e,"property"),r=this.levelNode===null?"0":this.levelNode.build(e,"int");return e.format(`${e.getMethod("textureDimensions")}( ${i}, ${r} )`,this.getNodeType(e),t)}}const ds=K(UM);class OM extends $s{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=je.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){const e=this.texture,t=e.images,i=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(i&&i.width!==void 0){const{width:r,height:s}=i;this.value=Math.log2(Math.max(r,s))}}}const FM=K(OM);class dn extends $s{static get type(){return"TextureNode"}constructor(e,t=null,i=null,r=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=i,this.biasNode=r,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=je.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this.setUpdateMatrix(t===null)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}getNodeType(){return this.value.isDepthTexture===!0?"float":this.value.type===Nr?"uvec4":this.value.type===va?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return nt(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return this._matrixUniform===null&&(this._matrixUniform=fe(this.value.matrix)),this._matrixUniform.mul(D(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this.updateType=e?je.FRAME:je.NONE,this}setupUV(e,t){const i=this.value;return e.isFlipY()&&(i.isRenderTargetTexture===!0||i.isFramebufferTexture===!0||i.isDepthTexture===!0)&&(this.sampler?t=t.flipY():t=t.setY(P(ds(this,this.levelNode).y).sub(t.y).sub(1))),t}setup(e){const t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;let i=this.uvNode;(i===null||e.context.forceUVContext===!0)&&e.context.getUV&&(i=e.context.getUV(this)),i||(i=this.getDefaultUV()),this.updateMatrix===!0&&(i=this.getTransformedUV(i)),i=this.setupUV(e,i);let r=this.levelNode;r===null&&e.context.getTextureLevel&&(r=e.context.getTextureLevel(this)),t.uvNode=i,t.levelNode=r,t.biasNode=this.biasNode,t.compareNode=this.compareNode,t.gradNode=this.gradNode,t.depthNode=this.depthNode}generateUV(e,t){return t.build(e,this.sampler===!0?"vec2":"ivec2")}generateSnippet(e,t,i,r,s,a,o,l){const c=this.value;let u;return r?u=e.generateTextureLevel(c,t,i,r,a):s?u=e.generateTextureBias(c,t,i,s,a):l?u=e.generateTextureGrad(c,t,i,l,a):o?u=e.generateTextureCompare(c,t,i,o,a):this.sampler===!1?u=e.generateTextureLoad(c,t,i,a):u=e.generateTexture(c,t,i,a),u}generate(e,t){const i=e.getNodeProperties(this),r=this.value;if(!r||r.isTexture!==!0)throw new Error("TextureNode: Need a three.js texture.");const s=super.generate(e,"property");if(t==="sampler")return s+"_sampler";if(e.isReference(t))return s;{const a=e.getDataFromNode(this);let o=a.propertyName;if(o===void 0){const{uvNode:u,levelNode:h,biasNode:d,compareNode:p,depthNode:m,gradNode:v}=i,f=this.generateUV(e,u),g=h?h.build(e,"float"):null,x=d?d.build(e,"float"):null,y=m?m.build(e,"int"):null,_=p?p.build(e,"float"):null,I=v?[v[0].build(e,"vec2"),v[1].build(e,"vec2")]:null,b=e.getVarFromNode(this);o=e.getPropertyName(b);const w=this.generateSnippet(e,s,f,g,x,y,_,I);e.addLineFlowCode(`${o} = ${w}`,this),a.snippet=w,a.propertyName=o}let l=o;const c=this.getNodeType(e);return e.needsToWorkingColorSpace(r)&&(l=zf(hs(l,c),r.colorSpace).setup(e).build(e,c)),e.format(l,c,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}uv(e){const t=this.clone();return t.uvNode=G(e),t.referenceNode=this.getSelf(),G(t)}blur(e){const t=this.clone();return t.biasNode=G(e).mul(FM(t)),t.referenceNode=this.getSelf(),G(t)}level(e){const t=this.clone();return t.levelNode=G(e),t.referenceNode=this.getSelf(),G(t)}size(e){return ds(this,e)}bias(e){const t=this.clone();return t.biasNode=G(e),t.referenceNode=this.getSelf(),G(t)}compare(e){const t=this.clone();return t.compareNode=G(e),t.referenceNode=this.getSelf(),G(t)}grad(e,t){const i=this.clone();return i.gradNode=[G(e),G(t)],i.referenceNode=this.getSelf(),G(i)}depth(e){const t=this.clone();return t.depthNode=G(e),t.referenceNode=this.getSelf(),G(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){const e=this.value,t=this._matrixUniform;t!==null&&(t.value=e.matrix),e.matrixAutoUpdate===!0&&e.updateMatrix()}clone(){const e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e}}const yt=K(dn),Vr=(...n)=>yt(...n).setSampler(!1),X2=n=>(n.isNode===!0?n:yt(n)).convert("sampler"),co=fe("float").label("cameraNear").setGroup(xt).onRenderUpdate(({camera:n})=>n.near),uo=fe("float").label("cameraFar").setGroup(xt).onRenderUpdate(({camera:n})=>n.far),VM=fe("float").label("cameraLogDepth").setGroup(xt).onRenderUpdate(({camera:n})=>2/(Math.log(n.far+1)/Math.LN2)),lr=fe("mat4").label("cameraProjectionMatrix").setGroup(xt).onRenderUpdate(({camera:n})=>n.projectionMatrix),q2=fe("mat4").label("cameraProjectionMatrixInverse").setGroup(xt).onRenderUpdate(({camera:n})=>n.projectionMatrixInverse),cr=fe("mat4").label("cameraViewMatrix").setGroup(xt).onRenderUpdate(({camera:n})=>n.matrixWorldInverse),Y2=fe("mat4").label("cameraWorldMatrix").setGroup(xt).onRenderUpdate(({camera:n})=>n.matrixWorld),$2=fe("mat3").label("cameraNormalMatrix").setGroup(xt).onRenderUpdate(({camera:n})=>n.normalMatrix),Wf=fe(new N).label("cameraPosition").setGroup(xt).onRenderUpdate(({camera:n},e)=>e.value.setFromMatrixPosition(n.matrixWorld));class St extends qe{static get type(){return"Object3DNode"}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=je.OBJECT,this._uniformNode=new $s(null)}getNodeType(){const e=this.scope;if(e===St.WORLD_MATRIX)return"mat4";if(e===St.POSITION||e===St.VIEW_POSITION||e===St.DIRECTION||e===St.SCALE)return"vec3"}update(e){const t=this.object3d,i=this._uniformNode,r=this.scope;if(r===St.WORLD_MATRIX)i.value=t.matrixWorld;else if(r===St.POSITION)i.value=i.value||new N,i.value.setFromMatrixPosition(t.matrixWorld);else if(r===St.SCALE)i.value=i.value||new N,i.value.setFromMatrixScale(t.matrixWorld);else if(r===St.DIRECTION)i.value=i.value||new N,t.getWorldDirection(i.value);else if(r===St.VIEW_POSITION){const s=e.camera;i.value=i.value||new N,i.value.setFromMatrixPosition(t.matrixWorld),i.value.applyMatrix4(s.matrixWorldInverse)}}generate(e){const t=this.scope;return t===St.WORLD_MATRIX?this._uniformNode.nodeType="mat4":(t===St.POSITION||t===St.VIEW_POSITION||t===St.DIRECTION||t===St.SCALE)&&(this._uniformNode.nodeType="vec3"),this._uniformNode.build(e)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}}St.WORLD_MATRIX="worldMatrix",St.POSITION="position",St.SCALE="scale",St.VIEW_POSITION="viewPosition",St.DIRECTION="direction";const J2=K(St,St.DIRECTION),K2=K(St,St.WORLD_MATRIX),Z2=K(St,St.POSITION),Q2=K(St,St.SCALE),eL=K(St,St.VIEW_POSITION);class tn extends St{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}}const tL=ge(tn,tn.DIRECTION),Br=ge(tn,tn.WORLD_MATRIX),iL=ge(tn,tn.POSITION),rL=ge(tn,tn.SCALE),nL=ge(tn,tn.VIEW_POSITION),BM=fe(new Ke).onObjectUpdate(({object:n},e)=>e.value.getNormalMatrix(n.matrixWorld)),zM=fe(new Re).onObjectUpdate(({object:n},e)=>e.value.copy(n.matrixWorld).invert()),pn=cr.mul(Br).toVar("modelViewMatrix_2"),sL=U(n=>(n.context.isHighPrecisionModelViewMatrix=!0,fe("mat4").onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar("highPrecisionModelViewMatrix"),aL=U(n=>{const e=n.context.isHighPrecisionModelViewMatrix;return fe("mat3").onObjectUpdate(({object:t,camera:i})=>(e!==!0&&t.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix)))}).once()().toVar("highPrecisionModelNormalMatrix"),Li=_i("position","vec3"),Zt=Li.varying("positionLocal"),Hh=Li.varying("positionPrevious"),Gh=Br.mul(Zt).xyz.varying("v_positionWorld"),jf=Zt.transformDirection(Br).varying("v_positionWorldDirection").normalize().toVar("positionWorldDirection"),Pi=pn.mul(Zt).xyz.varying("v_positionView"),Vt=Pi.negate().varying("v_positionViewDirection").normalize().toVar("positionViewDirection");class kM extends qe{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){const{renderer:t,material:i}=e;return t.coordinateSystem===Rr&&i.side===si?"false":e.getFrontFacing()}}const HM=ge(kM),$l=E(HM).mul(2).sub(1),Wh=_i("normal","vec3"),ur=U(n=>n.geometry.hasAttribute("normal")===!1?(console.warn('TSL.NormalNode: Vertex attribute "normal" not found on geometry.'),D(0,1,0)):Wh,"vec3").once()().toVar("normalLocal"),GM=Pi.dFdx().cross(Pi.dFdy()).normalize().toVar("normalFlat"),hr=U(n=>{let e;return n.material.flatShading===!0?e=GM:e=Ii(qf(ur),"v_normalView").normalize(),e},"vec3").once()().toVar("normalView"),jh=Ii(hr.transformDirection(cr),"v_normalWorld").normalize().toVar("normalWorld"),Yt=U(n=>n.context.setupNormal(),"vec3").once()().mul($l).toVar("transformedNormalView"),Xf=Yt.transformDirection(cr).toVar("transformedNormalWorld"),ho=U(n=>n.context.setupClearcoatNormal(),"vec3").once()().mul($l).toVar("transformedClearcoatNormalView"),WM=U(([n,e=Br])=>{const t=yi(e),i=n.div(D(t[0].dot(t[0]),t[1].dot(t[1]),t[2].dot(t[2])));return t.mul(i).xyz}),qf=U(([n],e)=>{const t=e.renderer.nodes.modelNormalViewMatrix;if(t!==null)return t.transformDirection(n);const i=BM.mul(n);return cr.transformDirection(i)}),jM=fe(0).onReference(({material:n})=>n).onRenderUpdate(({material:n})=>n.refractionRatio),XM=Vt.negate().reflect(Yt),qM=Vt.negate().refract(Yt,jM),YM=XM.transformDirection(cr).toVar("reflectVector"),$M=qM.transformDirection(cr).toVar("reflectVector");class JM extends dn{static get type(){return"CubeTextureNode"}constructor(e,t=null,i=null,r=null){super(e,t,i,r),this.isCubeTextureNode=!0}getInputType(){return"cubeTexture"}getDefaultUV(){const e=this.value;return e.mapping===fr?YM:e.mapping===Ar?$M:(console.error('THREE.CubeTextureNode: Mapping "%s" not supported.',e.mapping),D(0,0,0))}setUpdateMatrix(){}setupUV(e,t){const i=this.value;return e.renderer.coordinateSystem===Ts||!i.isRenderTargetTexture?D(t.x.negate(),t.yz):t}generateUV(e,t){return t.build(e,"vec3")}}const Xh=K(JM);class qh extends $s{static get type(){return"BufferNode"}constructor(e,t,i=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=i}getElementType(e){return this.getNodeType(e)}getInputType(){return"buffer"}}const Jl=(n,e,t)=>G(new qh(n,e,t));class oL extends as{static get type(){return"UniformArrayElementNode"}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){const t=super.generate(e),i=this.getNodeType();return e.format(t,"vec4",i)}}class Yf extends qh{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null,"vec4"),this.array=e,this.elementType=t,this._elementType=null,this._elementLength=0,this.updateType=je.RENDER,this.isArrayBufferNode=!0}getElementType(){return this.elementType||this._elementType}getElementLength(){return this._elementLength}update(){const{array:e,value:t}=this,i=this.getElementLength(),r=this.getElementType();if(i===1)for(let s=0;s<e.length;s++){const a=s*4;t[a]=e[s]}else if(r==="color")for(let s=0;s<e.length;s++){const a=s*4,o=e[s];t[a]=o.r,t[a+1]=o.g,t[a+2]=o.b||0}else for(let s=0;s<e.length;s++){const a=s*4,o=e[s];t[a]=o.x,t[a+1]=o.y,t[a+2]=o.z||0,t[a+3]=o.w||0}}setup(e){const t=this.array.length;this._elementType=this.elementType===null?Ln(this.array[0]):this.elementType,this._elementLength=e.getTypeLength(this._elementType);let i=Float32Array;return this._elementType.charAt(0)==="i"?i=Int32Array:this._elementType.charAt(0)==="u"&&(i=Uint32Array),this.value=new i(t*4),this.bufferCount=t,this.bufferType=e.changeComponentType("vec4",e.getComponentType(this._elementType)),super.setup(e)}element(e){return G(new oL(this,G(e)))}}const mn=(n,e)=>G(new Yf(n,e)),lL=(n,e)=>(console.warn("TSL.UniformArrayNode: uniforms() has been renamed to uniformArray()."),G(new Yf(n,e)));class cL extends as{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),i=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,i,r)}}class Kl extends qe{static get type(){return"ReferenceNode"}constructor(e,t,i=null,r=null){super(),this.property=e,this.uniformType=t,this.object=i,this.count=r,this.properties=e.split("."),this.reference=i,this.node=null,this.group=null,this.name=null,this.updateType=je.OBJECT}element(e){return G(new cL(this,G(e)))}setGroup(e){return this.group=e,this}label(e){return this.name=e,this}setNodeType(e){let t=null;this.count!==null?t=Jl(null,e,this.count):Array.isArray(this.getValueFromReference())?t=mn(null,e):e==="texture"?t=yt(null):e==="cubeTexture"?t=Xh(null):t=fe(null,e),this.group!==null&&t.setGroup(this.group),this.name!==null&&t.label(this.name),this.node=t.getSelf()}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let i=e[t[0]];for(let r=1;r<t.length;r++)i=i[t[r]];return i}updateReference(e){return this.reference=this.object!==null?this.object:e.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);const e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}}const fi=(n,e,t)=>G(new Kl(n,e,t)),$f=(n,e,t,i)=>G(new Kl(n,e,i,t));class KM extends Kl{static get type(){return"MaterialReferenceNode"}constructor(e,t,i=null){super(e,t,i),this.material=i,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=this.material!==null?this.material:e.material,this.reference}}const rn=(n,e,t)=>G(new KM(n,e,t)),Yh=U(n=>(n.geometry.hasAttribute("tangent")===!1&&n.geometry.computeTangents(),_i("tangent","vec4")))(),Zl=Yh.xyz.toVar("tangentLocal"),Ql=pn.mul(ae(Zl,0)).xyz.varying("v_tangentView").normalize().toVar("tangentView"),ZM=Ql.transformDirection(cr).varying("v_tangentWorld").normalize().toVar("tangentWorld"),Jf=Ql.toVar("transformedTangentView"),uL=Jf.transformDirection(cr).normalize().toVar("transformedTangentWorld"),ec=n=>n.mul(Yh.w).xyz,hL=Ii(ec(Wh.cross(Yh)),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),dL=Ii(ec(ur.cross(Zl)),"v_bitangentLocal").normalize().toVar("bitangentLocal"),QM=Ii(ec(hr.cross(Ql)),"v_bitangentView").normalize().toVar("bitangentView"),pL=Ii(ec(jh.cross(ZM)),"v_bitangentWorld").normalize().toVar("bitangentWorld"),e1=ec(Yt.cross(Jf)).normalize().toVar("transformedBitangentView"),mL=e1.transformDirection(cr).normalize().toVar("transformedBitangentWorld"),ta=yi(Ql,QM,hr),t1=Vt.mul(ta),fL=(n,e)=>n.sub(t1.mul(e)),i1=(()=>{let n=Ks.cross(Vt);return n=n.cross(Ks).normalize(),n=rt(n,Yt,ls.mul(hn.oneMinus()).oneMinus().pow2().pow2()).normalize(),n})(),gL=U(n=>{const{eye_pos:e,surf_norm:t,mapN:i,uv:r}=n,s=e.dFdx(),a=e.dFdy(),o=r.dFdx(),l=r.dFdy(),c=t,u=a.cross(c),h=c.cross(s),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)),v=$l.mul(m.inverseSqrt());return zt(d.mul(i.x,v),p.mul(i.y,v),c.mul(i.z)).normalize()});class r1 extends pt{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=on}setup(e){const{normalMapType:t,scaleNode:i}=this;let r=this.node.mul(2).sub(1);i!==null&&(r=D(r.xy.mul(i),r.z));let s=null;return t===dp?s=qf(r):t===on&&(e.hasGeometryAttribute("tangent")===!0?s=ta.mul(r).normalize():s=gL({eye_pos:Pi,surf_norm:hr,mapN:r,uv:nt()})),s}}const Kf=K(r1),vL=U(({textureNode:n,bumpScale:e})=>{const t=r=>n.cache().context({getUV:s=>r(s.uvNode||nt()),forceUVContext:!0}),i=E(t(r=>r));return z(E(t(r=>r.add(r.dFdx()))).sub(i),E(t(r=>r.add(r.dFdy()))).sub(i)).mul(e)}),yL=U(n=>{const{surf_pos:e,surf_norm:t,dHdxy:i}=n,r=e.dFdx().normalize(),s=e.dFdy().normalize(),a=t,o=s.cross(a),l=a.cross(r),c=r.dot(o).mul($l),u=c.sign().mul(i.x.mul(o).add(i.y.mul(l)));return c.abs().mul(t).sub(u).normalize()});class n1 extends pt{static get type(){return"BumpMapNode"}constructor(e,t=null){super("vec3"),this.textureNode=e,this.scaleNode=t}setup(){const e=this.scaleNode!==null?this.scaleNode:1,t=vL({textureNode:this.textureNode,bumpScale:e});return yL({surf_pos:Pi,surf_norm:hr,dHdxy:t})}}const s1=K(n1),a1=new Map;class Z extends qe{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let i=a1.get(e);return i===void 0&&(i=rn(e,t),a1.set(e,i)),i}getFloat(e){return this.getCache(e,"float")}getColor(e){return this.getCache(e,"color")}getTexture(e){return this.getCache(e==="map"?"map":e+"Map","texture")}setup(e){const t=e.context.material,i=this.scope;let r=null;if(i===Z.COLOR){const s=t.color!==void 0?this.getColor(i):D();t.map&&t.map.isTexture===!0?r=s.mul(this.getTexture("map")):r=s}else if(i===Z.OPACITY){const s=this.getFloat(i);t.alphaMap&&t.alphaMap.isTexture===!0?r=s.mul(this.getTexture("alpha")):r=s}else if(i===Z.SPECULAR_STRENGTH)t.specularMap&&t.specularMap.isTexture===!0?r=this.getTexture("specular").r:r=E(1);else if(i===Z.SPECULAR_INTENSITY){const s=this.getFloat(i);t.specularMap?r=s.mul(this.getTexture(i).a):r=s}else if(i===Z.SPECULAR_COLOR){const s=this.getColor(i);t.specularColorMap&&t.specularColorMap.isTexture===!0?r=s.mul(this.getTexture(i).rgb):r=s}else if(i===Z.ROUGHNESS){const s=this.getFloat(i);t.roughnessMap&&t.roughnessMap.isTexture===!0?r=s.mul(this.getTexture(i).g):r=s}else if(i===Z.METALNESS){const s=this.getFloat(i);t.metalnessMap&&t.metalnessMap.isTexture===!0?r=s.mul(this.getTexture(i).b):r=s}else if(i===Z.EMISSIVE){const s=this.getFloat("emissiveIntensity"),a=this.getColor(i).mul(s);t.emissiveMap&&t.emissiveMap.isTexture===!0?r=a.mul(this.getTexture(i)):r=a}else if(i===Z.NORMAL)t.normalMap?(r=Kf(this.getTexture("normal"),this.getCache("normalScale","vec2")),r.normalMapType=t.normalMapType):t.bumpMap?r=s1(this.getTexture("bump").r,this.getFloat("bumpScale")):r=hr;else if(i===Z.CLEARCOAT){const s=this.getFloat(i);t.clearcoatMap&&t.clearcoatMap.isTexture===!0?r=s.mul(this.getTexture(i).r):r=s}else if(i===Z.CLEARCOAT_ROUGHNESS){const s=this.getFloat(i);t.clearcoatRoughnessMap&&t.clearcoatRoughnessMap.isTexture===!0?r=s.mul(this.getTexture(i).r):r=s}else if(i===Z.CLEARCOAT_NORMAL)t.clearcoatNormalMap?r=Kf(this.getTexture(i),this.getCache(i+"Scale","vec2")):r=hr;else if(i===Z.SHEEN){const s=this.getColor("sheenColor").mul(this.getFloat("sheen"));t.sheenColorMap&&t.sheenColorMap.isTexture===!0?r=s.mul(this.getTexture("sheenColor").rgb):r=s}else if(i===Z.SHEEN_ROUGHNESS){const s=this.getFloat(i);t.sheenRoughnessMap&&t.sheenRoughnessMap.isTexture===!0?r=s.mul(this.getTexture(i).a):r=s,r=r.clamp(.07,1)}else if(i===Z.ANISOTROPY)if(t.anisotropyMap&&t.anisotropyMap.isTexture===!0){const s=this.getTexture(i);r=Ul(mo.x,mo.y,mo.y.negate(),mo.x).mul(s.rg.mul(2).sub(z(1)).normalize().mul(s.b))}else r=mo;else if(i===Z.IRIDESCENCE_THICKNESS){const s=fi("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){const a=fi("0","float",t.iridescenceThicknessRange);r=s.sub(a).mul(this.getTexture(i).g).add(a)}else r=s}else if(i===Z.TRANSMISSION){const s=this.getFloat(i);t.transmissionMap?r=s.mul(this.getTexture(i).r):r=s}else if(i===Z.THICKNESS){const s=this.getFloat(i);t.thicknessMap?r=s.mul(this.getTexture(i).g):r=s}else if(i===Z.IOR)r=this.getFloat(i);else if(i===Z.LIGHT_MAP)r=this.getTexture(i).rgb.mul(this.getFloat("lightMapIntensity"));else if(i===Z.AO_MAP)r=this.getTexture(i).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else{const s=this.getNodeType(e);r=this.getCache(i,s)}return r}}Z.ALPHA_TEST="alphaTest",Z.COLOR="color",Z.OPACITY="opacity",Z.SHININESS="shininess",Z.SPECULAR="specular",Z.SPECULAR_STRENGTH="specularStrength",Z.SPECULAR_INTENSITY="specularIntensity",Z.SPECULAR_COLOR="specularColor",Z.REFLECTIVITY="reflectivity",Z.ROUGHNESS="roughness",Z.METALNESS="metalness",Z.NORMAL="normal",Z.CLEARCOAT="clearcoat",Z.CLEARCOAT_ROUGHNESS="clearcoatRoughness",Z.CLEARCOAT_NORMAL="clearcoatNormal",Z.EMISSIVE="emissive",Z.ROTATION="rotation",Z.SHEEN="sheen",Z.SHEEN_ROUGHNESS="sheenRoughness",Z.ANISOTROPY="anisotropy",Z.IRIDESCENCE="iridescence",Z.IRIDESCENCE_IOR="iridescenceIOR",Z.IRIDESCENCE_THICKNESS="iridescenceThickness",Z.IOR="ior",Z.TRANSMISSION="transmission",Z.THICKNESS="thickness",Z.ATTENUATION_DISTANCE="attenuationDistance",Z.ATTENUATION_COLOR="attenuationColor",Z.LINE_SCALE="scale",Z.LINE_DASH_SIZE="dashSize",Z.LINE_GAP_SIZE="gapSize",Z.LINE_WIDTH="linewidth",Z.LINE_DASH_OFFSET="dashOffset",Z.POINT_WIDTH="pointWidth",Z.DISPERSION="dispersion",Z.LIGHT_MAP="light",Z.AO_MAP="ao";const o1=ge(Z,Z.ALPHA_TEST),po=ge(Z,Z.COLOR),l1=ge(Z,Z.SHININESS),c1=ge(Z,Z.EMISSIVE),$h=ge(Z,Z.OPACITY),u1=ge(Z,Z.SPECULAR),Zf=ge(Z,Z.SPECULAR_INTENSITY),h1=ge(Z,Z.SPECULAR_COLOR),tc=ge(Z,Z.SPECULAR_STRENGTH),Jh=ge(Z,Z.REFLECTIVITY),d1=ge(Z,Z.ROUGHNESS),p1=ge(Z,Z.METALNESS),m1=ge(Z,Z.NORMAL).context({getUV:null}),f1=ge(Z,Z.CLEARCOAT),g1=ge(Z,Z.CLEARCOAT_ROUGHNESS),v1=ge(Z,Z.CLEARCOAT_NORMAL).context({getUV:null}),y1=ge(Z,Z.ROTATION),x1=ge(Z,Z.SHEEN),_1=ge(Z,Z.SHEEN_ROUGHNESS),M1=ge(Z,Z.ANISOTROPY),b1=ge(Z,Z.IRIDESCENCE),T1=ge(Z,Z.IRIDESCENCE_IOR),S1=ge(Z,Z.IRIDESCENCE_THICKNESS),w1=ge(Z,Z.TRANSMISSION),E1=ge(Z,Z.THICKNESS),A1=ge(Z,Z.IOR),N1=ge(Z,Z.ATTENUATION_DISTANCE),C1=ge(Z,Z.ATTENUATION_COLOR),Kh=ge(Z,Z.LINE_SCALE),Qf=ge(Z,Z.LINE_DASH_SIZE),eg=ge(Z,Z.LINE_GAP_SIZE),Zh=ge(Z,Z.LINE_WIDTH),tg=ge(Z,Z.LINE_DASH_OFFSET),R1=ge(Z,Z.POINT_WIDTH),I1=ge(Z,Z.DISPERSION),ig=ge(Z,Z.LIGHT_MAP),L1=ge(Z,Z.AO_MAP),mo=fe(new J).onReference(function(n){return n.material}).onRenderUpdate(function({material:n}){this.value.set(n.anisotropy*Math.cos(n.anisotropyRotation),n.anisotropy*Math.sin(n.anisotropyRotation))});class P1 extends pt{static get type(){return"ModelViewProjectionNode"}constructor(e=null){super("vec4"),this.positionNode=e}setup(e){if(e.shaderStage==="fragment")return Ii(e.context.mvp);const t=this.positionNode||Zt,i=e.renderer.nodes.modelViewMatrix||pn;return lr.mul(i).mul(t)}}const rg=K(P1);class Bt extends qe{static get type(){return"IndexNode"}constructor(e){super("uint"),this.scope=e,this.isInstanceIndexNode=!0}generate(e){const t=this.getNodeType(e),i=this.scope;let r;if(i===Bt.VERTEX)r=e.getVertexIndex();else if(i===Bt.INSTANCE)r=e.getInstanceIndex();else if(i===Bt.DRAW)r=e.getDrawIndex();else if(i===Bt.INVOCATION_LOCAL)r=e.getInvocationLocalIndex();else if(i===Bt.INVOCATION_SUBGROUP)r=e.getInvocationSubgroupIndex();else if(i===Bt.SUBGROUP)r=e.getSubgroupIndex();else throw new Error("THREE.IndexNode: Unknown scope: "+i);let s;return e.shaderStage==="vertex"||e.shaderStage==="compute"?s=r:s=Ii(this).build(e,t),s}}Bt.VERTEX="vertex",Bt.INSTANCE="instance",Bt.SUBGROUP="subgroup",Bt.INVOCATION_LOCAL="invocationLocal",Bt.INVOCATION_SUBGROUP="invocationSubgroup",Bt.DRAW="draw";const D1=ge(Bt,Bt.VERTEX),ic=ge(Bt,Bt.INSTANCE),xL=ge(Bt,Bt.SUBGROUP),_L=ge(Bt,Bt.INVOCATION_SUBGROUP),ML=ge(Bt,Bt.INVOCATION_LOCAL),U1=ge(Bt,Bt.DRAW);class O1 extends qe{static get type(){return"InstanceNode"}constructor(e){super("void"),this.instanceMesh=e,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=je.FRAME,this.buffer=null,this.bufferColor=null}setup(e){let t=this.instanceMatrixNode,i=this.instanceColorNode;const r=this.instanceMesh;if(t===null){const o=r.instanceMatrix;if(r.count<=1e3)t=Jl(o.array,"mat4",Math.max(r.count,1)).element(ic);else{const l=new Xm(o.array,16,1);this.buffer=l;const c=o.usage===bs?kf:kh,u=[c(l,"vec4",16,0),c(l,"vec4",16,4),c(l,"vec4",16,8),c(l,"vec4",16,12)];t=Ys(...u)}this.instanceMatrixNode=t}const s=r.instanceColor;if(s&&i===null){const o=new Nn(s.array,3),l=s.usage===bs?kf:kh;this.bufferColor=o,i=D(l(o,"vec3",3,0)),this.instanceColorNode=i}const a=t.mul(Zt).xyz;if(Zt.assign(a),e.hasGeometryAttribute("normal")){const o=WM(ur,t);ur.assign(o)}this.instanceColorNode!==null&&Zr("vec3","vInstanceColor").assign(this.instanceColorNode)}update(){this.instanceMesh.instanceMatrix.usage!==bs&&this.buffer!=null&&this.instanceMesh.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMesh.instanceMatrix.version),this.instanceMesh.instanceColor&&this.instanceMesh.instanceColor.usage!==bs&&this.bufferColor!=null&&this.instanceMesh.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceMesh.instanceColor.version)}}const F1=K(O1);class V1 extends qe{static get type(){return"BatchNode"}constructor(e){super("void"),this.batchMesh=e,this.batchingIdNode=null}setup(e){this.batchingIdNode===null&&(e.getDrawIndex()===null?this.batchingIdNode=ic:this.batchingIdNode=U1);const t=U(([p])=>{const m=ds(Vr(this.batchMesh._indirectTexture),0),v=P(p).modInt(P(m)),f=P(p).div(P(m));return Vr(this.batchMesh._indirectTexture,un(v,f)).x}).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]})(P(this.batchingIdNode)),i=this.batchMesh._matricesTexture,r=ds(Vr(i),0),s=E(t).mul(4).toInt().toVar(),a=s.modInt(r),o=s.div(P(r)),l=Ys(Vr(i,un(a,o)),Vr(i,un(a.add(1),o)),Vr(i,un(a.add(2),o)),Vr(i,un(a.add(3),o))),c=this.batchMesh._colorsTexture;if(c!==null){const p=U(([m])=>{const v=ds(Vr(c),0).x,f=m,g=f.modInt(v),x=f.div(v);return Vr(c,un(g,x)).rgb}).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]})(t);Zr("vec3","vBatchColor").assign(p)}const u=yi(l);Zt.assign(l.mul(Zt));const h=ur.div(D(u[0].dot(u[0]),u[1].dot(u[1]),u[2].dot(u[2]))),d=u.mul(h).xyz;ur.assign(d),e.hasGeometryAttribute("tangent")&&Zl.mulAssign(u)}}const B1=K(V1),z1=new WeakMap;class ng extends qe{static get type(){return"SkinningNode"}constructor(e,t=!1){super("void"),this.skinnedMesh=e,this.useReference=t,this.updateType=je.OBJECT,this.skinIndexNode=_i("skinIndex","uvec4"),this.skinWeightNode=_i("skinWeight","vec4");let i,r,s;t?(i=fi("bindMatrix","mat4"),r=fi("bindMatrixInverse","mat4"),s=$f("skeleton.boneMatrices","mat4",e.skeleton.bones.length)):(i=fe(e.bindMatrix,"mat4"),r=fe(e.bindMatrixInverse,"mat4"),s=Jl(e.skeleton.boneMatrices,"mat4",e.skeleton.bones.length)),this.bindMatrixNode=i,this.bindMatrixInverseNode=r,this.boneMatricesNode=s,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=Zt){const{skinIndexNode:i,skinWeightNode:r,bindMatrixNode:s,bindMatrixInverseNode:a}=this,o=e.element(i.x),l=e.element(i.y),c=e.element(i.z),u=e.element(i.w),h=s.mul(t),d=zt(o.mul(r.x).mul(h),l.mul(r.y).mul(h),c.mul(r.z).mul(h),u.mul(r.w).mul(h));return a.mul(d).xyz}getSkinnedNormal(e=this.boneMatricesNode,t=ur){const{skinIndexNode:i,skinWeightNode:r,bindMatrixNode:s,bindMatrixInverseNode:a}=this,o=e.element(i.x),l=e.element(i.y),c=e.element(i.z),u=e.element(i.w);let h=zt(r.x.mul(o),r.y.mul(l),r.z.mul(c),r.w.mul(u));return h=a.mul(h).mul(s),h.transformDirection(t).xyz}getPreviousSkinnedPosition(e){const t=e.object;return this.previousBoneMatricesNode===null&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=$f("skeleton.previousBoneMatrices","mat4",t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,Hh)}needsPreviousBoneMatrices(e){const t=e.renderer.getMRT();return t&&t.has("velocity")}setup(e){this.needsPreviousBoneMatrices(e)&&Hh.assign(this.getPreviousSkinnedPosition(e));const t=this.getSkinnedPosition();if(Zt.assign(t),e.hasGeometryAttribute("normal")){const i=this.getSkinnedNormal();ur.assign(i),e.hasGeometryAttribute("tangent")&&Zl.assign(i)}}generate(e,t){if(t!=="void")return Zt.build(e,t)}update(e){const t=(this.useReference?e.object:this.skinnedMesh).skeleton;z1.get(t)!==e.frameId&&(z1.set(t,e.frameId),this.previousBoneMatricesNode!==null&&t.previousBoneMatrices.set(t.boneMatrices),t.update())}}const bL=n=>G(new ng(n)),k1=n=>G(new ng(n,!0));class H1 extends qe{static get type(){return"LoopNode"}constructor(e=[]){super(),this.params=e}getVarName(e){return String.fromCharCode(105+e)}getProperties(e){const t=e.getNodeProperties(this);if(t.stackNode!==void 0)return t;const i={};for(let s=0,a=this.params.length-1;s<a;s++){const o=this.params[s],l=o.isNode!==!0&&o.name||this.getVarName(s),c=o.isNode!==!0&&o.type||"int";i[l]=hs(l,c)}const r=e.addStack();return t.returnsNode=this.params[this.params.length-1](i,r,e),t.stackNode=r,e.removeStack(),t}getNodeType(e){const{returnsNode:t}=this.getProperties(e);return t?t.getNodeType(e):"void"}setup(e){this.getProperties(e)}generate(e){const t=this.getProperties(e),i=this.params,r=t.stackNode;for(let o=0,l=i.length-1;o<l;o++){const c=i[o];let u=null,h=null,d=null,p=null,m=null,v=null;c.isNode?(p="int",d=this.getVarName(o),u="0",h=c.build(e,p),m="<"):(p=c.type||"int",d=c.name||this.getVarName(o),u=c.start,h=c.end,m=c.condition,v=c.update,typeof u=="number"?u=u.toString():u&&u.isNode&&(u=u.build(e,p)),typeof h=="number"?h=h.toString():h&&h.isNode&&(h=h.build(e,p)),u!==void 0&&h===void 0?(u=u+" - 1",h="0",m=">="):h!==void 0&&u===void 0&&(u="0",m="<"),m===void 0&&(Number(u)>Number(h)?m=">=":m="<"));const f={start:u,end:h},g=f.start,x=f.end;let y="",_="",I="";v||(p==="int"||p==="uint"?m.includes("<")?v="++":v="--":m.includes("<")?v="+= 1.":v="-= 1."),y+=e.getVar(p,d)+" = "+g,_+=d+" "+m+" "+x,I+=d+" "+v;const b=`for ( ${y}; ${_}; ${I} )`;e.addFlowCode((o===0?`
|
|
3860
|
+
`);return e.format(c,i,t)}}const Ri=K(k2);te("select",Ri);const oM=(...n)=>(console.warn("TSL.ConditionalNode: cond() has been renamed to select()."),Ri(...n));te("cond",oM);class Uf extends qe{static get type(){return"ContextNode"}constructor(e,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}analyze(e){this.node.build(e)}setup(e){const t=e.getContext();e.setContext({...e.context,...this.value});const i=this.node.build(e);return e.setContext(t),i}generate(e,t){const i=e.getContext();e.setContext({...e.context,...this.value});const r=this.node.build(e,t);return e.setContext(i),r}}const Of=K(Uf),lM=(n,e)=>Of(n,{label:e});te("context",Of),te("label",lM);class cM extends qe{static get type(){return"VarNode"}constructor(e,t=null){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}generate(e){const{node:t,name:i}=this,r=e.getVarFromNode(this,i,e.getVectorType(this.getNodeType(e))),s=e.getPropertyName(r),a=t.build(e,r.type);return e.addLineFlowCode(`${s} = ${a}`,this),s}}const Ff=K(cM);te("temp",Ff),te("toVar",(...n)=>Ff(...n).append());class uM extends qe{static get type(){return"VaryingNode"}constructor(e,t=null){super(),this.node=e,this.name=t,this.isVaryingNode=!0}isGlobal(){return!0}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}setupVarying(e){const t=e.getNodeProperties(this);let i=t.varying;if(i===void 0){const r=this.name,s=this.getNodeType(e);t.varying=i=e.getVaryingFromNode(this,r,s),t.node=this.node}return i.needsInterpolation||(i.needsInterpolation=e.shaderStage==="fragment"),i}setup(e){this.setupVarying(e)}analyze(e){return this.setupVarying(e),this.node.analyze(e)}generate(e){const t=e.getNodeProperties(this),i=this.setupVarying(e);if(t.propertyName===void 0){const r=this.getNodeType(e),s=e.getPropertyName(i,ef.VERTEX);e.flowNodeFromShaderStage(ef.VERTEX,this.node,r,s),t.propertyName=s}return e.getPropertyName(i)}}const Ii=K(uM);te("varying",Ii);const Wl="WorkingColorSpace",Vf="OutputColorSpace";function hM(n){let e=null;return n===nr?e="Linear":n===Fi&&(e="sRGB"),e}function Bh(n,e){return hM(n)+"To"+hM(e)}class jl extends pt{static get type(){return"ColorSpaceNode"}constructor(e,t,i){super("vec4"),this.colorNode=e,this.source=t,this.target=i}getColorSpace(e,t){return t===Wl?vt.workingColorSpace:t===Vf?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){const{renderer:t}=e,{colorNode:i}=this,r=this.getColorSpace(e,this.source),s=this.getColorSpace(e,this.target);if(r===s)return i;const a=Bh(r,s);let o=null;const l=t.nodes.library.getColorSpaceFunction(a);return l!==null?o=ae(l(i.rgb),i.a):(console.error("ColorSpaceNode: Unsupported Color Space configuration.",a),o=i),o}}const dM=n=>G(new jl(G(n),Wl,Vf)),pM=n=>G(new jl(G(n),Vf,Wl)),mM=(n,e)=>G(new jl(G(n),Wl,e)),Bf=(n,e)=>G(new jl(G(n),e,Wl));te("toOutputColorSpace",dM),te("toWorkingColorSpace",pM),te("workingToColorSpace",mM),te("colorSpaceToWorking",Bf);let H2=class extends ss{static get type(){return"ReferenceElementNode"}constructor(n,e){super(n,e),this.referenceNode=n,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(n){const e=super.generate(n),t=this.referenceNode.getNodeType(),i=this.getNodeType();return n.format(e,t,i)}};class fM extends qe{static get type(){return"ReferenceBaseNode"}constructor(e,t,i=null,r=null){super(),this.property=e,this.uniformType=t,this.object=i,this.count=r,this.properties=e.split("."),this.reference=i,this.node=null,this.group=null,this.updateType=je.OBJECT}setGroup(e){return this.group=e,this}element(e){return G(new H2(this,G(e)))}setNodeType(e){const t=fe(null,e).getSelf();this.group!==null&&t.setGroup(this.group),this.node=t}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let i=e[t[0]];for(let r=1;r<t.length;r++)i=i[t[r]];return i}updateReference(e){return this.reference=this.object!==null?this.object:e.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);const e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}}const G2=(n,e,t)=>G(new fM(n,e,t));class gM extends fM{static get type(){return"RendererReferenceNode"}constructor(e,t,i=null){super(e,t,i),this.renderer=i,this.setGroup(xt)}updateReference(e){return this.reference=this.renderer!==null?this.renderer:e.renderer,this.reference}}const vM=(n,e,t)=>G(new gM(n,e,t));class yM extends pt{static get type(){return"ToneMappingNode"}constructor(e,t=_M,i=null){super("vec3"),this.toneMapping=e,this.exposureNode=t,this.colorNode=i}getCacheKey(){return $m(super.getCacheKey(),this.toneMapping)}setup(e){const t=this.colorNode||e.context.color,i=this.toneMapping;if(i===mr)return t;let r=null;const s=e.renderer.nodes.library.getToneMappingFunction(i);return s!==null?r=ae(s(t.rgb,this.exposureNode),t.a):(console.error("ToneMappingNode: Unsupported Tone Mapping configuration.",i),r=t),r}}const xM=(n,e,t)=>G(new yM(n,G(e),G(t))),_M=vM("toneMappingExposure","float");te("toneMapping",(n,e,t)=>xM(e,t,n));class MM extends af{static get type(){return"BufferAttributeNode"}constructor(e,t=null,i=0,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=i,this.bufferOffset=r,this.usage=Ta,this.instanced=!1,this.attribute=null,this.global=!0,e&&e.isBufferAttribute===!0&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){if(this.bufferStride===0&&this.bufferOffset===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getNodeType(e){return this.bufferType===null&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(this.attribute!==null)return;const t=this.getNodeType(e),i=this.value,r=e.getTypeLength(t),s=this.bufferStride||r,a=this.bufferOffset,o=i.isInterleavedBuffer===!0?i:new Wa(i,s),l=new On(o,r,a);o.setUsage(this.usage),this.attribute=l,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){const t=this.getNodeType(e),i=e.getBufferAttributeFromNode(this,t),r=e.getPropertyName(i);let s=null;return e.shaderStage==="vertex"||e.shaderStage==="compute"?(this.name=r,s=r):s=Ii(this).build(e,t),s}getInputType(){return"bufferAttribute"}setUsage(e){return this.usage=e,this.attribute&&this.attribute.isBufferAttribute===!0&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}}const Xl=(n,e,t,i)=>G(new MM(n,e,t,i)),bM=(n,e,t,i)=>Xl(n,e,t,i).setUsage(Ms),zh=(n,e,t,i)=>Xl(n,e,t,i).setInstanced(!0),zf=(n,e,t,i)=>bM(n,e,t,i).setInstanced(!0);te("toAttribute",n=>Xl(n.value));class TM extends qe{static get type(){return"ComputeNode"}constructor(e,t,i=[64]){super("void"),this.isComputeNode=!0,this.computeNode=e,this.count=t,this.workgroupSize=i,this.dispatchCount=0,this.version=1,this.updateBeforeType=je.OBJECT,this.updateDispatchCount()}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}updateDispatchCount(){const{count:e,workgroupSize:t}=this;let i=t[0];for(let r=1;r<t.length;r++)i*=t[r];this.dispatchCount=Math.ceil(e/i)}onInit(){}updateBefore({renderer:e}){e.compute(this)}generate(e){const{shaderStage:t}=e;if(t==="compute"){const i=this.computeNode.build(e,"void");i!==""&&e.addLineFlowCode(i,this)}}}const SM=(n,e,t)=>G(new TM(G(n),e,t));te("compute",SM);class wM extends qe{static get type(){return"CacheNode"}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isCacheNode=!0}getNodeType(e){return this.node.getNodeType(e)}build(e,...t){const i=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);const s=this.node.build(e,...t);return e.setCache(i),s}}const ql=(n,...e)=>G(new wM(G(n),...e));te("cache",ql);class EM extends qe{static get type(){return"BypassNode"}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}getNodeType(e){return this.outputNode.getNodeType(e)}generate(e){const t=this.callNode.build(e,"void");return t!==""&&e.addLineFlowCode(t,this),this.outputNode.build(e)}}const AM=K(EM);te("bypass",AM);class kf extends qe{static get type(){return"RemapNode"}constructor(e,t,i,r=E(0),s=E(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=i,this.outLowNode=r,this.outHighNode=s,this.doClamp=!0}setup(){const{node:e,inLowNode:t,inHighNode:i,outLowNode:r,outHighNode:s,doClamp:a}=this;let o=e.sub(t).div(i.sub(t));return a===!0&&(o=o.clamp()),o.mul(s.sub(r)).add(r)}}const NM=K(kf,null,null,{doClamp:!1}),CM=K(kf);te("remap",NM),te("remapClamp",CM);class RM extends qe{static get type(){return"ExpressionNode"}constructor(e="",t="void"){super(t),this.snippet=e}generate(e,t){const i=this.getNodeType(e),r=this.snippet;if(i==="void")e.addLineFlowCode(r,this);else return e.format(`( ${r} )`,i,t)}}const us=K(RM),IM=n=>(n?Ri(n,us("discard")):us("discard")).append(),W2=()=>us("return").append();te("discard",IM);class LM extends pt{static get type(){return"RenderOutputNode"}constructor(e,t,i){super("vec4"),this.colorNode=e,this.toneMapping=t,this.outputColorSpace=i,this.isRenderOutput=!0}setup({context:e}){let t=this.colorNode||e.color;const i=(this.toneMapping!==null?this.toneMapping:e.toneMapping)||mr,r=(this.outputColorSpace!==null?this.outputColorSpace:e.outputColorSpace)||Cr;return i!==mr&&(t=t.toneMapping(i)),r!==Cr&&r!==vt.workingColorSpace&&(t=t.workingToColorSpace(r)),t}}const PM=(n,e=null,t=null)=>G(new LM(G(n),e,t));te("renderOutput",PM);function j2(n){console.warn("THREE.TSLBase: AddNodeElement has been removed in favor of tree-shaking. Trying add",n)}class Hf extends qe{static get type(){return"AttributeNode"}constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}getNodeType(e){let t=this.nodeType;if(t===null){const i=this.getAttributeName(e);if(e.hasGeometryAttribute(i)){const r=e.geometry.getAttribute(i);t=e.getTypeFromAttribute(r)}else t="float"}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){const t=this.getAttributeName(e),i=this.getNodeType(e);if(e.hasGeometryAttribute(t)===!0){const r=e.geometry.getAttribute(t),s=e.getTypeFromAttribute(r),a=e.getAttribute(t,s);return e.shaderStage==="vertex"?e.format(a.name,s,i):Ii(this).build(e,i)}else return console.warn(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(i)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}}const _i=(n,e)=>G(new Hf(n,e)),nt=n=>_i("uv"+(n>0?n:""),"vec2");class DM extends qe{static get type(){return"TextureSizeNode"}constructor(e,t=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){const i=this.textureNode.build(e,"property"),r=this.levelNode===null?"0":this.levelNode.build(e,"int");return e.format(`${e.getMethod("textureDimensions")}( ${i}, ${r} )`,this.getNodeType(e),t)}}const hs=K(DM);class UM extends Ys{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=je.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){const e=this.texture,t=e.images,i=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(i&&i.width!==void 0){const{width:r,height:s}=i;this.value=Math.log2(Math.max(r,s))}}}const OM=K(UM);class dn extends Ys{static get type(){return"TextureNode"}constructor(e,t=null,i=null,r=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=i,this.biasNode=r,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=je.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this.setUpdateMatrix(t===null)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}getNodeType(){return this.value.isDepthTexture===!0?"float":this.value.type===Nr?"uvec4":this.value.type===ga?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return nt(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return this._matrixUniform===null&&(this._matrixUniform=fe(this.value.matrix)),this._matrixUniform.mul(D(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this.updateType=e?je.FRAME:je.NONE,this}setupUV(e,t){const i=this.value;return e.isFlipY()&&(i.isRenderTargetTexture===!0||i.isFramebufferTexture===!0||i.isDepthTexture===!0)&&(this.sampler?t=t.flipY():t=t.setY(P(hs(this,this.levelNode).y).sub(t.y).sub(1))),t}setup(e){const t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;let i=this.uvNode;(i===null||e.context.forceUVContext===!0)&&e.context.getUV&&(i=e.context.getUV(this)),i||(i=this.getDefaultUV()),this.updateMatrix===!0&&(i=this.getTransformedUV(i)),i=this.setupUV(e,i);let r=this.levelNode;r===null&&e.context.getTextureLevel&&(r=e.context.getTextureLevel(this)),t.uvNode=i,t.levelNode=r,t.biasNode=this.biasNode,t.compareNode=this.compareNode,t.gradNode=this.gradNode,t.depthNode=this.depthNode}generateUV(e,t){return t.build(e,this.sampler===!0?"vec2":"ivec2")}generateSnippet(e,t,i,r,s,a,o,l){const c=this.value;let u;return r?u=e.generateTextureLevel(c,t,i,r,a):s?u=e.generateTextureBias(c,t,i,s,a):l?u=e.generateTextureGrad(c,t,i,l,a):o?u=e.generateTextureCompare(c,t,i,o,a):this.sampler===!1?u=e.generateTextureLoad(c,t,i,a):u=e.generateTexture(c,t,i,a),u}generate(e,t){const i=e.getNodeProperties(this),r=this.value;if(!r||r.isTexture!==!0)throw new Error("TextureNode: Need a three.js texture.");const s=super.generate(e,"property");if(t==="sampler")return s+"_sampler";if(e.isReference(t))return s;{const a=e.getDataFromNode(this);let o=a.propertyName;if(o===void 0){const{uvNode:u,levelNode:h,biasNode:d,compareNode:p,depthNode:m,gradNode:v}=i,f=this.generateUV(e,u),g=h?h.build(e,"float"):null,x=d?d.build(e,"float"):null,y=m?m.build(e,"int"):null,_=p?p.build(e,"float"):null,I=v?[v[0].build(e,"vec2"),v[1].build(e,"vec2")]:null,b=e.getVarFromNode(this);o=e.getPropertyName(b);const w=this.generateSnippet(e,s,f,g,x,y,_,I);e.addLineFlowCode(`${o} = ${w}`,this),a.snippet=w,a.propertyName=o}let l=o;const c=this.getNodeType(e);return e.needsToWorkingColorSpace(r)&&(l=Bf(us(l,c),r.colorSpace).setup(e).build(e,c)),e.format(l,c,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}uv(e){const t=this.clone();return t.uvNode=G(e),t.referenceNode=this.getSelf(),G(t)}blur(e){const t=this.clone();return t.biasNode=G(e).mul(OM(t)),t.referenceNode=this.getSelf(),G(t)}level(e){const t=this.clone();return t.levelNode=G(e),t.referenceNode=this.getSelf(),G(t)}size(e){return hs(this,e)}bias(e){const t=this.clone();return t.biasNode=G(e),t.referenceNode=this.getSelf(),G(t)}compare(e){const t=this.clone();return t.compareNode=G(e),t.referenceNode=this.getSelf(),G(t)}grad(e,t){const i=this.clone();return i.gradNode=[G(e),G(t)],i.referenceNode=this.getSelf(),G(i)}depth(e){const t=this.clone();return t.depthNode=G(e),t.referenceNode=this.getSelf(),G(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){const e=this.value,t=this._matrixUniform;t!==null&&(t.value=e.matrix),e.matrixAutoUpdate===!0&&e.updateMatrix()}clone(){const e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e}}const yt=K(dn),Vr=(...n)=>yt(...n).setSampler(!1),X2=n=>(n.isNode===!0?n:yt(n)).convert("sampler"),lo=fe("float").label("cameraNear").setGroup(xt).onRenderUpdate(({camera:n})=>n.near),co=fe("float").label("cameraFar").setGroup(xt).onRenderUpdate(({camera:n})=>n.far),FM=fe("float").label("cameraLogDepth").setGroup(xt).onRenderUpdate(({camera:n})=>2/(Math.log(n.far+1)/Math.LN2)),lr=fe("mat4").label("cameraProjectionMatrix").setGroup(xt).onRenderUpdate(({camera:n})=>n.projectionMatrix),q2=fe("mat4").label("cameraProjectionMatrixInverse").setGroup(xt).onRenderUpdate(({camera:n})=>n.projectionMatrixInverse),cr=fe("mat4").label("cameraViewMatrix").setGroup(xt).onRenderUpdate(({camera:n})=>n.matrixWorldInverse),Y2=fe("mat4").label("cameraWorldMatrix").setGroup(xt).onRenderUpdate(({camera:n})=>n.matrixWorld),$2=fe("mat3").label("cameraNormalMatrix").setGroup(xt).onRenderUpdate(({camera:n})=>n.normalMatrix),Gf=fe(new N).label("cameraPosition").setGroup(xt).onRenderUpdate(({camera:n},e)=>e.value.setFromMatrixPosition(n.matrixWorld));class St extends qe{static get type(){return"Object3DNode"}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=je.OBJECT,this._uniformNode=new Ys(null)}getNodeType(){const e=this.scope;if(e===St.WORLD_MATRIX)return"mat4";if(e===St.POSITION||e===St.VIEW_POSITION||e===St.DIRECTION||e===St.SCALE)return"vec3"}update(e){const t=this.object3d,i=this._uniformNode,r=this.scope;if(r===St.WORLD_MATRIX)i.value=t.matrixWorld;else if(r===St.POSITION)i.value=i.value||new N,i.value.setFromMatrixPosition(t.matrixWorld);else if(r===St.SCALE)i.value=i.value||new N,i.value.setFromMatrixScale(t.matrixWorld);else if(r===St.DIRECTION)i.value=i.value||new N,t.getWorldDirection(i.value);else if(r===St.VIEW_POSITION){const s=e.camera;i.value=i.value||new N,i.value.setFromMatrixPosition(t.matrixWorld),i.value.applyMatrix4(s.matrixWorldInverse)}}generate(e){const t=this.scope;return t===St.WORLD_MATRIX?this._uniformNode.nodeType="mat4":(t===St.POSITION||t===St.VIEW_POSITION||t===St.DIRECTION||t===St.SCALE)&&(this._uniformNode.nodeType="vec3"),this._uniformNode.build(e)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}}St.WORLD_MATRIX="worldMatrix",St.POSITION="position",St.SCALE="scale",St.VIEW_POSITION="viewPosition",St.DIRECTION="direction";const J2=K(St,St.DIRECTION),K2=K(St,St.WORLD_MATRIX),Z2=K(St,St.POSITION),Q2=K(St,St.SCALE),eL=K(St,St.VIEW_POSITION);class tn extends St{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}}const tL=ge(tn,tn.DIRECTION),Br=ge(tn,tn.WORLD_MATRIX),iL=ge(tn,tn.POSITION),rL=ge(tn,tn.SCALE),nL=ge(tn,tn.VIEW_POSITION),VM=fe(new Ke).onObjectUpdate(({object:n},e)=>e.value.getNormalMatrix(n.matrixWorld)),BM=fe(new Re).onObjectUpdate(({object:n},e)=>e.value.copy(n.matrixWorld).invert()),pn=cr.mul(Br).toVar("modelViewMatrix_2"),sL=U(n=>(n.context.isHighPrecisionModelViewMatrix=!0,fe("mat4").onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar("highPrecisionModelViewMatrix"),aL=U(n=>{const e=n.context.isHighPrecisionModelViewMatrix;return fe("mat3").onObjectUpdate(({object:t,camera:i})=>(e!==!0&&t.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix)))}).once()().toVar("highPrecisionModelNormalMatrix"),Li=_i("position","vec3"),Zt=Li.varying("positionLocal"),kh=Li.varying("positionPrevious"),Hh=Br.mul(Zt).xyz.varying("v_positionWorld"),Wf=Zt.transformDirection(Br).varying("v_positionWorldDirection").normalize().toVar("positionWorldDirection"),Pi=pn.mul(Zt).xyz.varying("v_positionView"),Vt=Pi.negate().varying("v_positionViewDirection").normalize().toVar("positionViewDirection");class zM extends qe{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){const{renderer:t,material:i}=e;return t.coordinateSystem===Rr&&i.side===si?"false":e.getFrontFacing()}}const kM=ge(zM),Yl=E(kM).mul(2).sub(1),Gh=_i("normal","vec3"),ur=U(n=>n.geometry.hasAttribute("normal")===!1?(console.warn('TSL.NormalNode: Vertex attribute "normal" not found on geometry.'),D(0,1,0)):Gh,"vec3").once()().toVar("normalLocal"),HM=Pi.dFdx().cross(Pi.dFdy()).normalize().toVar("normalFlat"),hr=U(n=>{let e;return n.material.flatShading===!0?e=HM:e=Ii(Xf(ur),"v_normalView").normalize(),e},"vec3").once()().toVar("normalView"),Wh=Ii(hr.transformDirection(cr),"v_normalWorld").normalize().toVar("normalWorld"),Yt=U(n=>n.context.setupNormal(),"vec3").once()().mul(Yl).toVar("transformedNormalView"),jf=Yt.transformDirection(cr).toVar("transformedNormalWorld"),uo=U(n=>n.context.setupClearcoatNormal(),"vec3").once()().mul(Yl).toVar("transformedClearcoatNormalView"),GM=U(([n,e=Br])=>{const t=yi(e),i=n.div(D(t[0].dot(t[0]),t[1].dot(t[1]),t[2].dot(t[2])));return t.mul(i).xyz}),Xf=U(([n],e)=>{const t=e.renderer.nodes.modelNormalViewMatrix;if(t!==null)return t.transformDirection(n);const i=VM.mul(n);return cr.transformDirection(i)}),WM=fe(0).onReference(({material:n})=>n).onRenderUpdate(({material:n})=>n.refractionRatio),jM=Vt.negate().reflect(Yt),XM=Vt.negate().refract(Yt,WM),qM=jM.transformDirection(cr).toVar("reflectVector"),YM=XM.transformDirection(cr).toVar("reflectVector");class $M extends dn{static get type(){return"CubeTextureNode"}constructor(e,t=null,i=null,r=null){super(e,t,i,r),this.isCubeTextureNode=!0}getInputType(){return"cubeTexture"}getDefaultUV(){const e=this.value;return e.mapping===fr?qM:e.mapping===Ar?YM:(console.error('THREE.CubeTextureNode: Mapping "%s" not supported.',e.mapping),D(0,0,0))}setUpdateMatrix(){}setupUV(e,t){const i=this.value;return e.renderer.coordinateSystem===bs||!i.isRenderTargetTexture?D(t.x.negate(),t.yz):t}generateUV(e,t){return t.build(e,"vec3")}}const jh=K($M);class Xh extends Ys{static get type(){return"BufferNode"}constructor(e,t,i=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=i}getElementType(e){return this.getNodeType(e)}getInputType(){return"buffer"}}const $l=(n,e,t)=>G(new Xh(n,e,t));class oL extends ss{static get type(){return"UniformArrayElementNode"}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){const t=super.generate(e),i=this.getNodeType();return e.format(t,"vec4",i)}}class qf extends Xh{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null,"vec4"),this.array=e,this.elementType=t,this._elementType=null,this._elementLength=0,this.updateType=je.RENDER,this.isArrayBufferNode=!0}getElementType(){return this.elementType||this._elementType}getElementLength(){return this._elementLength}update(){const{array:e,value:t}=this,i=this.getElementLength(),r=this.getElementType();if(i===1)for(let s=0;s<e.length;s++){const a=s*4;t[a]=e[s]}else if(r==="color")for(let s=0;s<e.length;s++){const a=s*4,o=e[s];t[a]=o.r,t[a+1]=o.g,t[a+2]=o.b||0}else for(let s=0;s<e.length;s++){const a=s*4,o=e[s];t[a]=o.x,t[a+1]=o.y,t[a+2]=o.z||0,t[a+3]=o.w||0}}setup(e){const t=this.array.length;this._elementType=this.elementType===null?Ln(this.array[0]):this.elementType,this._elementLength=e.getTypeLength(this._elementType);let i=Float32Array;return this._elementType.charAt(0)==="i"?i=Int32Array:this._elementType.charAt(0)==="u"&&(i=Uint32Array),this.value=new i(t*4),this.bufferCount=t,this.bufferType=e.changeComponentType("vec4",e.getComponentType(this._elementType)),super.setup(e)}element(e){return G(new oL(this,G(e)))}}const mn=(n,e)=>G(new qf(n,e)),lL=(n,e)=>(console.warn("TSL.UniformArrayNode: uniforms() has been renamed to uniformArray()."),G(new qf(n,e)));class cL extends ss{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),i=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,i,r)}}class Jl extends qe{static get type(){return"ReferenceNode"}constructor(e,t,i=null,r=null){super(),this.property=e,this.uniformType=t,this.object=i,this.count=r,this.properties=e.split("."),this.reference=i,this.node=null,this.group=null,this.name=null,this.updateType=je.OBJECT}element(e){return G(new cL(this,G(e)))}setGroup(e){return this.group=e,this}label(e){return this.name=e,this}setNodeType(e){let t=null;this.count!==null?t=$l(null,e,this.count):Array.isArray(this.getValueFromReference())?t=mn(null,e):e==="texture"?t=yt(null):e==="cubeTexture"?t=jh(null):t=fe(null,e),this.group!==null&&t.setGroup(this.group),this.name!==null&&t.label(this.name),this.node=t.getSelf()}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let i=e[t[0]];for(let r=1;r<t.length;r++)i=i[t[r]];return i}updateReference(e){return this.reference=this.object!==null?this.object:e.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);const e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}}const fi=(n,e,t)=>G(new Jl(n,e,t)),Yf=(n,e,t,i)=>G(new Jl(n,e,i,t));class JM extends Jl{static get type(){return"MaterialReferenceNode"}constructor(e,t,i=null){super(e,t,i),this.material=i,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=this.material!==null?this.material:e.material,this.reference}}const rn=(n,e,t)=>G(new JM(n,e,t)),qh=U(n=>(n.geometry.hasAttribute("tangent")===!1&&n.geometry.computeTangents(),_i("tangent","vec4")))(),Kl=qh.xyz.toVar("tangentLocal"),Zl=pn.mul(ae(Kl,0)).xyz.varying("v_tangentView").normalize().toVar("tangentView"),KM=Zl.transformDirection(cr).varying("v_tangentWorld").normalize().toVar("tangentWorld"),$f=Zl.toVar("transformedTangentView"),uL=$f.transformDirection(cr).normalize().toVar("transformedTangentWorld"),Ql=n=>n.mul(qh.w).xyz,hL=Ii(Ql(Gh.cross(qh)),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),dL=Ii(Ql(ur.cross(Kl)),"v_bitangentLocal").normalize().toVar("bitangentLocal"),ZM=Ii(Ql(hr.cross(Zl)),"v_bitangentView").normalize().toVar("bitangentView"),pL=Ii(Ql(Wh.cross(KM)),"v_bitangentWorld").normalize().toVar("bitangentWorld"),QM=Ql(Yt.cross($f)).normalize().toVar("transformedBitangentView"),mL=QM.transformDirection(cr).normalize().toVar("transformedBitangentWorld"),ea=yi(Zl,ZM,hr),e1=Vt.mul(ea),fL=(n,e)=>n.sub(e1.mul(e)),t1=(()=>{let n=Js.cross(Vt);return n=n.cross(Js).normalize(),n=rt(n,Yt,os.mul(hn.oneMinus()).oneMinus().pow2().pow2()).normalize(),n})(),gL=U(n=>{const{eye_pos:e,surf_norm:t,mapN:i,uv:r}=n,s=e.dFdx(),a=e.dFdy(),o=r.dFdx(),l=r.dFdy(),c=t,u=a.cross(c),h=c.cross(s),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)),v=Yl.mul(m.inverseSqrt());return zt(d.mul(i.x,v),p.mul(i.y,v),c.mul(i.z)).normalize()});class i1 extends pt{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=on}setup(e){const{normalMapType:t,scaleNode:i}=this;let r=this.node.mul(2).sub(1);i!==null&&(r=D(r.xy.mul(i),r.z));let s=null;return t===hp?s=Xf(r):t===on&&(e.hasGeometryAttribute("tangent")===!0?s=ea.mul(r).normalize():s=gL({eye_pos:Pi,surf_norm:hr,mapN:r,uv:nt()})),s}}const Jf=K(i1),vL=U(({textureNode:n,bumpScale:e})=>{const t=r=>n.cache().context({getUV:s=>r(s.uvNode||nt()),forceUVContext:!0}),i=E(t(r=>r));return z(E(t(r=>r.add(r.dFdx()))).sub(i),E(t(r=>r.add(r.dFdy()))).sub(i)).mul(e)}),yL=U(n=>{const{surf_pos:e,surf_norm:t,dHdxy:i}=n,r=e.dFdx().normalize(),s=e.dFdy().normalize(),a=t,o=s.cross(a),l=a.cross(r),c=r.dot(o).mul(Yl),u=c.sign().mul(i.x.mul(o).add(i.y.mul(l)));return c.abs().mul(t).sub(u).normalize()});class r1 extends pt{static get type(){return"BumpMapNode"}constructor(e,t=null){super("vec3"),this.textureNode=e,this.scaleNode=t}setup(){const e=this.scaleNode!==null?this.scaleNode:1,t=vL({textureNode:this.textureNode,bumpScale:e});return yL({surf_pos:Pi,surf_norm:hr,dHdxy:t})}}const n1=K(r1),s1=new Map;class Z extends qe{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let i=s1.get(e);return i===void 0&&(i=rn(e,t),s1.set(e,i)),i}getFloat(e){return this.getCache(e,"float")}getColor(e){return this.getCache(e,"color")}getTexture(e){return this.getCache(e==="map"?"map":e+"Map","texture")}setup(e){const t=e.context.material,i=this.scope;let r=null;if(i===Z.COLOR){const s=t.color!==void 0?this.getColor(i):D();t.map&&t.map.isTexture===!0?r=s.mul(this.getTexture("map")):r=s}else if(i===Z.OPACITY){const s=this.getFloat(i);t.alphaMap&&t.alphaMap.isTexture===!0?r=s.mul(this.getTexture("alpha")):r=s}else if(i===Z.SPECULAR_STRENGTH)t.specularMap&&t.specularMap.isTexture===!0?r=this.getTexture("specular").r:r=E(1);else if(i===Z.SPECULAR_INTENSITY){const s=this.getFloat(i);t.specularMap?r=s.mul(this.getTexture(i).a):r=s}else if(i===Z.SPECULAR_COLOR){const s=this.getColor(i);t.specularColorMap&&t.specularColorMap.isTexture===!0?r=s.mul(this.getTexture(i).rgb):r=s}else if(i===Z.ROUGHNESS){const s=this.getFloat(i);t.roughnessMap&&t.roughnessMap.isTexture===!0?r=s.mul(this.getTexture(i).g):r=s}else if(i===Z.METALNESS){const s=this.getFloat(i);t.metalnessMap&&t.metalnessMap.isTexture===!0?r=s.mul(this.getTexture(i).b):r=s}else if(i===Z.EMISSIVE){const s=this.getFloat("emissiveIntensity"),a=this.getColor(i).mul(s);t.emissiveMap&&t.emissiveMap.isTexture===!0?r=a.mul(this.getTexture(i)):r=a}else if(i===Z.NORMAL)t.normalMap?(r=Jf(this.getTexture("normal"),this.getCache("normalScale","vec2")),r.normalMapType=t.normalMapType):t.bumpMap?r=n1(this.getTexture("bump").r,this.getFloat("bumpScale")):r=hr;else if(i===Z.CLEARCOAT){const s=this.getFloat(i);t.clearcoatMap&&t.clearcoatMap.isTexture===!0?r=s.mul(this.getTexture(i).r):r=s}else if(i===Z.CLEARCOAT_ROUGHNESS){const s=this.getFloat(i);t.clearcoatRoughnessMap&&t.clearcoatRoughnessMap.isTexture===!0?r=s.mul(this.getTexture(i).r):r=s}else if(i===Z.CLEARCOAT_NORMAL)t.clearcoatNormalMap?r=Jf(this.getTexture(i),this.getCache(i+"Scale","vec2")):r=hr;else if(i===Z.SHEEN){const s=this.getColor("sheenColor").mul(this.getFloat("sheen"));t.sheenColorMap&&t.sheenColorMap.isTexture===!0?r=s.mul(this.getTexture("sheenColor").rgb):r=s}else if(i===Z.SHEEN_ROUGHNESS){const s=this.getFloat(i);t.sheenRoughnessMap&&t.sheenRoughnessMap.isTexture===!0?r=s.mul(this.getTexture(i).a):r=s,r=r.clamp(.07,1)}else if(i===Z.ANISOTROPY)if(t.anisotropyMap&&t.anisotropyMap.isTexture===!0){const s=this.getTexture(i);r=Dl(po.x,po.y,po.y.negate(),po.x).mul(s.rg.mul(2).sub(z(1)).normalize().mul(s.b))}else r=po;else if(i===Z.IRIDESCENCE_THICKNESS){const s=fi("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){const a=fi("0","float",t.iridescenceThicknessRange);r=s.sub(a).mul(this.getTexture(i).g).add(a)}else r=s}else if(i===Z.TRANSMISSION){const s=this.getFloat(i);t.transmissionMap?r=s.mul(this.getTexture(i).r):r=s}else if(i===Z.THICKNESS){const s=this.getFloat(i);t.thicknessMap?r=s.mul(this.getTexture(i).g):r=s}else if(i===Z.IOR)r=this.getFloat(i);else if(i===Z.LIGHT_MAP)r=this.getTexture(i).rgb.mul(this.getFloat("lightMapIntensity"));else if(i===Z.AO_MAP)r=this.getTexture(i).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else{const s=this.getNodeType(e);r=this.getCache(i,s)}return r}}Z.ALPHA_TEST="alphaTest",Z.COLOR="color",Z.OPACITY="opacity",Z.SHININESS="shininess",Z.SPECULAR="specular",Z.SPECULAR_STRENGTH="specularStrength",Z.SPECULAR_INTENSITY="specularIntensity",Z.SPECULAR_COLOR="specularColor",Z.REFLECTIVITY="reflectivity",Z.ROUGHNESS="roughness",Z.METALNESS="metalness",Z.NORMAL="normal",Z.CLEARCOAT="clearcoat",Z.CLEARCOAT_ROUGHNESS="clearcoatRoughness",Z.CLEARCOAT_NORMAL="clearcoatNormal",Z.EMISSIVE="emissive",Z.ROTATION="rotation",Z.SHEEN="sheen",Z.SHEEN_ROUGHNESS="sheenRoughness",Z.ANISOTROPY="anisotropy",Z.IRIDESCENCE="iridescence",Z.IRIDESCENCE_IOR="iridescenceIOR",Z.IRIDESCENCE_THICKNESS="iridescenceThickness",Z.IOR="ior",Z.TRANSMISSION="transmission",Z.THICKNESS="thickness",Z.ATTENUATION_DISTANCE="attenuationDistance",Z.ATTENUATION_COLOR="attenuationColor",Z.LINE_SCALE="scale",Z.LINE_DASH_SIZE="dashSize",Z.LINE_GAP_SIZE="gapSize",Z.LINE_WIDTH="linewidth",Z.LINE_DASH_OFFSET="dashOffset",Z.POINT_WIDTH="pointWidth",Z.DISPERSION="dispersion",Z.LIGHT_MAP="light",Z.AO_MAP="ao";const a1=ge(Z,Z.ALPHA_TEST),ho=ge(Z,Z.COLOR),o1=ge(Z,Z.SHININESS),l1=ge(Z,Z.EMISSIVE),Yh=ge(Z,Z.OPACITY),c1=ge(Z,Z.SPECULAR),Kf=ge(Z,Z.SPECULAR_INTENSITY),u1=ge(Z,Z.SPECULAR_COLOR),ec=ge(Z,Z.SPECULAR_STRENGTH),$h=ge(Z,Z.REFLECTIVITY),h1=ge(Z,Z.ROUGHNESS),d1=ge(Z,Z.METALNESS),p1=ge(Z,Z.NORMAL).context({getUV:null}),m1=ge(Z,Z.CLEARCOAT),f1=ge(Z,Z.CLEARCOAT_ROUGHNESS),g1=ge(Z,Z.CLEARCOAT_NORMAL).context({getUV:null}),v1=ge(Z,Z.ROTATION),y1=ge(Z,Z.SHEEN),x1=ge(Z,Z.SHEEN_ROUGHNESS),_1=ge(Z,Z.ANISOTROPY),M1=ge(Z,Z.IRIDESCENCE),b1=ge(Z,Z.IRIDESCENCE_IOR),T1=ge(Z,Z.IRIDESCENCE_THICKNESS),S1=ge(Z,Z.TRANSMISSION),w1=ge(Z,Z.THICKNESS),E1=ge(Z,Z.IOR),A1=ge(Z,Z.ATTENUATION_DISTANCE),N1=ge(Z,Z.ATTENUATION_COLOR),Jh=ge(Z,Z.LINE_SCALE),Zf=ge(Z,Z.LINE_DASH_SIZE),Qf=ge(Z,Z.LINE_GAP_SIZE),Kh=ge(Z,Z.LINE_WIDTH),eg=ge(Z,Z.LINE_DASH_OFFSET),C1=ge(Z,Z.POINT_WIDTH),R1=ge(Z,Z.DISPERSION),tg=ge(Z,Z.LIGHT_MAP),I1=ge(Z,Z.AO_MAP),po=fe(new J).onReference(function(n){return n.material}).onRenderUpdate(function({material:n}){this.value.set(n.anisotropy*Math.cos(n.anisotropyRotation),n.anisotropy*Math.sin(n.anisotropyRotation))});class L1 extends pt{static get type(){return"ModelViewProjectionNode"}constructor(e=null){super("vec4"),this.positionNode=e}setup(e){if(e.shaderStage==="fragment")return Ii(e.context.mvp);const t=this.positionNode||Zt,i=e.renderer.nodes.modelViewMatrix||pn;return lr.mul(i).mul(t)}}const ig=K(L1);class Bt extends qe{static get type(){return"IndexNode"}constructor(e){super("uint"),this.scope=e,this.isInstanceIndexNode=!0}generate(e){const t=this.getNodeType(e),i=this.scope;let r;if(i===Bt.VERTEX)r=e.getVertexIndex();else if(i===Bt.INSTANCE)r=e.getInstanceIndex();else if(i===Bt.DRAW)r=e.getDrawIndex();else if(i===Bt.INVOCATION_LOCAL)r=e.getInvocationLocalIndex();else if(i===Bt.INVOCATION_SUBGROUP)r=e.getInvocationSubgroupIndex();else if(i===Bt.SUBGROUP)r=e.getSubgroupIndex();else throw new Error("THREE.IndexNode: Unknown scope: "+i);let s;return e.shaderStage==="vertex"||e.shaderStage==="compute"?s=r:s=Ii(this).build(e,t),s}}Bt.VERTEX="vertex",Bt.INSTANCE="instance",Bt.SUBGROUP="subgroup",Bt.INVOCATION_LOCAL="invocationLocal",Bt.INVOCATION_SUBGROUP="invocationSubgroup",Bt.DRAW="draw";const P1=ge(Bt,Bt.VERTEX),tc=ge(Bt,Bt.INSTANCE),xL=ge(Bt,Bt.SUBGROUP),_L=ge(Bt,Bt.INVOCATION_SUBGROUP),ML=ge(Bt,Bt.INVOCATION_LOCAL),D1=ge(Bt,Bt.DRAW);class U1 extends qe{static get type(){return"InstanceNode"}constructor(e){super("void"),this.instanceMesh=e,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=je.FRAME,this.buffer=null,this.bufferColor=null}setup(e){let t=this.instanceMatrixNode,i=this.instanceColorNode;const r=this.instanceMesh;if(t===null){const o=r.instanceMatrix;if(r.count<=1e3)t=$l(o.array,"mat4",Math.max(r.count,1)).element(tc);else{const l=new jm(o.array,16,1);this.buffer=l;const c=o.usage===Ms?zf:zh,u=[c(l,"vec4",16,0),c(l,"vec4",16,4),c(l,"vec4",16,8),c(l,"vec4",16,12)];t=qs(...u)}this.instanceMatrixNode=t}const s=r.instanceColor;if(s&&i===null){const o=new Nn(s.array,3),l=s.usage===Ms?zf:zh;this.bufferColor=o,i=D(l(o,"vec3",3,0)),this.instanceColorNode=i}const a=t.mul(Zt).xyz;if(Zt.assign(a),e.hasGeometryAttribute("normal")){const o=GM(ur,t);ur.assign(o)}this.instanceColorNode!==null&&Zr("vec3","vInstanceColor").assign(this.instanceColorNode)}update(){this.instanceMesh.instanceMatrix.usage!==Ms&&this.buffer!=null&&this.instanceMesh.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMesh.instanceMatrix.version),this.instanceMesh.instanceColor&&this.instanceMesh.instanceColor.usage!==Ms&&this.bufferColor!=null&&this.instanceMesh.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceMesh.instanceColor.version)}}const O1=K(U1);class F1 extends qe{static get type(){return"BatchNode"}constructor(e){super("void"),this.batchMesh=e,this.batchingIdNode=null}setup(e){this.batchingIdNode===null&&(e.getDrawIndex()===null?this.batchingIdNode=tc:this.batchingIdNode=D1);const t=U(([p])=>{const m=hs(Vr(this.batchMesh._indirectTexture),0),v=P(p).modInt(P(m)),f=P(p).div(P(m));return Vr(this.batchMesh._indirectTexture,un(v,f)).x}).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]})(P(this.batchingIdNode)),i=this.batchMesh._matricesTexture,r=hs(Vr(i),0),s=E(t).mul(4).toInt().toVar(),a=s.modInt(r),o=s.div(P(r)),l=qs(Vr(i,un(a,o)),Vr(i,un(a.add(1),o)),Vr(i,un(a.add(2),o)),Vr(i,un(a.add(3),o))),c=this.batchMesh._colorsTexture;if(c!==null){const p=U(([m])=>{const v=hs(Vr(c),0).x,f=m,g=f.modInt(v),x=f.div(v);return Vr(c,un(g,x)).rgb}).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]})(t);Zr("vec3","vBatchColor").assign(p)}const u=yi(l);Zt.assign(l.mul(Zt));const h=ur.div(D(u[0].dot(u[0]),u[1].dot(u[1]),u[2].dot(u[2]))),d=u.mul(h).xyz;ur.assign(d),e.hasGeometryAttribute("tangent")&&Kl.mulAssign(u)}}const V1=K(F1),B1=new WeakMap;class rg extends qe{static get type(){return"SkinningNode"}constructor(e,t=!1){super("void"),this.skinnedMesh=e,this.useReference=t,this.updateType=je.OBJECT,this.skinIndexNode=_i("skinIndex","uvec4"),this.skinWeightNode=_i("skinWeight","vec4");let i,r,s;t?(i=fi("bindMatrix","mat4"),r=fi("bindMatrixInverse","mat4"),s=Yf("skeleton.boneMatrices","mat4",e.skeleton.bones.length)):(i=fe(e.bindMatrix,"mat4"),r=fe(e.bindMatrixInverse,"mat4"),s=$l(e.skeleton.boneMatrices,"mat4",e.skeleton.bones.length)),this.bindMatrixNode=i,this.bindMatrixInverseNode=r,this.boneMatricesNode=s,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=Zt){const{skinIndexNode:i,skinWeightNode:r,bindMatrixNode:s,bindMatrixInverseNode:a}=this,o=e.element(i.x),l=e.element(i.y),c=e.element(i.z),u=e.element(i.w),h=s.mul(t),d=zt(o.mul(r.x).mul(h),l.mul(r.y).mul(h),c.mul(r.z).mul(h),u.mul(r.w).mul(h));return a.mul(d).xyz}getSkinnedNormal(e=this.boneMatricesNode,t=ur){const{skinIndexNode:i,skinWeightNode:r,bindMatrixNode:s,bindMatrixInverseNode:a}=this,o=e.element(i.x),l=e.element(i.y),c=e.element(i.z),u=e.element(i.w);let h=zt(r.x.mul(o),r.y.mul(l),r.z.mul(c),r.w.mul(u));return h=a.mul(h).mul(s),h.transformDirection(t).xyz}getPreviousSkinnedPosition(e){const t=e.object;return this.previousBoneMatricesNode===null&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=Yf("skeleton.previousBoneMatrices","mat4",t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,kh)}needsPreviousBoneMatrices(e){const t=e.renderer.getMRT();return t&&t.has("velocity")}setup(e){this.needsPreviousBoneMatrices(e)&&kh.assign(this.getPreviousSkinnedPosition(e));const t=this.getSkinnedPosition();if(Zt.assign(t),e.hasGeometryAttribute("normal")){const i=this.getSkinnedNormal();ur.assign(i),e.hasGeometryAttribute("tangent")&&Kl.assign(i)}}generate(e,t){if(t!=="void")return Zt.build(e,t)}update(e){const t=(this.useReference?e.object:this.skinnedMesh).skeleton;B1.get(t)!==e.frameId&&(B1.set(t,e.frameId),this.previousBoneMatricesNode!==null&&t.previousBoneMatrices.set(t.boneMatrices),t.update())}}const bL=n=>G(new rg(n)),z1=n=>G(new rg(n,!0));class k1 extends qe{static get type(){return"LoopNode"}constructor(e=[]){super(),this.params=e}getVarName(e){return String.fromCharCode(105+e)}getProperties(e){const t=e.getNodeProperties(this);if(t.stackNode!==void 0)return t;const i={};for(let s=0,a=this.params.length-1;s<a;s++){const o=this.params[s],l=o.isNode!==!0&&o.name||this.getVarName(s),c=o.isNode!==!0&&o.type||"int";i[l]=us(l,c)}const r=e.addStack();return t.returnsNode=this.params[this.params.length-1](i,r,e),t.stackNode=r,e.removeStack(),t}getNodeType(e){const{returnsNode:t}=this.getProperties(e);return t?t.getNodeType(e):"void"}setup(e){this.getProperties(e)}generate(e){const t=this.getProperties(e),i=this.params,r=t.stackNode;for(let o=0,l=i.length-1;o<l;o++){const c=i[o];let u=null,h=null,d=null,p=null,m=null,v=null;c.isNode?(p="int",d=this.getVarName(o),u="0",h=c.build(e,p),m="<"):(p=c.type||"int",d=c.name||this.getVarName(o),u=c.start,h=c.end,m=c.condition,v=c.update,typeof u=="number"?u=u.toString():u&&u.isNode&&(u=u.build(e,p)),typeof h=="number"?h=h.toString():h&&h.isNode&&(h=h.build(e,p)),u!==void 0&&h===void 0?(u=u+" - 1",h="0",m=">="):h!==void 0&&u===void 0&&(u="0",m="<"),m===void 0&&(Number(u)>Number(h)?m=">=":m="<"));const f={start:u,end:h},g=f.start,x=f.end;let y="",_="",I="";v||(p==="int"||p==="uint"?m.includes("<")?v="++":v="--":m.includes("<")?v="+= 1.":v="-= 1."),y+=e.getVar(p,d)+" = "+g,_+=d+" "+m+" "+x,I+=d+" "+v;const b=`for ( ${y}; ${_}; ${I} )`;e.addFlowCode((o===0?`
|
|
3861
3861
|
`:"")+e.tab+b+` {
|
|
3862
3862
|
|
|
3863
3863
|
`).addFlowTab()}const s=r.build(e,"void"),a=t.returnsNode?t.returnsNode.build(e):"";e.removeFlowTab().addFlowCode(`
|
|
3864
3864
|
`+e.tab+s);for(let o=0,l=this.params.length-1;o<l;o++)e.addFlowCode((o===0?"":e.tab)+`}
|
|
3865
3865
|
|
|
3866
|
-
`).removeFlowTab();return e.addFlowTab(),a}}const gt=(...n)=>G(new H1(qs(n,"int"))).append(),TL=()=>hs("continue").append(),Qh=()=>hs("break").append(),SL=(...n)=>(console.warn("TSL.LoopNode: loop() has been renamed to Loop()."),gt(...n)),sg=new WeakMap,Tr=new st,G1=U(({bufferMap:n,influence:e,stride:t,width:i,depth:r,offset:s})=>{const a=P(D1).mul(t).add(s),o=a.div(i),l=a.sub(o.mul(i));return Vr(n,un(l,o)).depth(r).mul(e)});function wL(n){const e=n.morphAttributes.position!==void 0,t=n.morphAttributes.normal!==void 0,i=n.morphAttributes.color!==void 0,r=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,s=r!==void 0?r.length:0;let a=sg.get(n);if(a===void 0||a.count!==s){let o=function(){f.dispose(),sg.delete(n),n.removeEventListener("dispose",o)};a!==void 0&&a.texture.dispose();const l=n.morphAttributes.position||[],c=n.morphAttributes.normal||[],u=n.morphAttributes.color||[];let h=0;e===!0&&(h=1),t===!0&&(h=2),i===!0&&(h=3);let d=n.attributes.position.count*h,p=1;const m=4096;d>m&&(p=Math.ceil(d/m),d=m);const v=new Float32Array(d*p*4*s),f=new tl(v,d,p,s);f.type=Oi,f.needsUpdate=!0;const g=h*4;for(let x=0;x<s;x++){const y=l[x],_=c[x],I=u[x],b=d*p*4*x;for(let w=0;w<y.count;w++){const C=w*g;e===!0&&(Tr.fromBufferAttribute(y,w),v[b+C+0]=Tr.x,v[b+C+1]=Tr.y,v[b+C+2]=Tr.z,v[b+C+3]=0),t===!0&&(Tr.fromBufferAttribute(_,w),v[b+C+4]=Tr.x,v[b+C+5]=Tr.y,v[b+C+6]=Tr.z,v[b+C+7]=0),i===!0&&(Tr.fromBufferAttribute(I,w),v[b+C+8]=Tr.x,v[b+C+9]=Tr.y,v[b+C+10]=Tr.z,v[b+C+11]=I.itemSize===4?Tr.w:1)}}a={count:s,texture:f,stride:h,size:new J(d,p)},sg.set(n,a),n.addEventListener("dispose",o)}return a}class W1 extends qe{static get type(){return"MorphNode"}constructor(e){super("void"),this.mesh=e,this.morphBaseInfluence=fe(1),this.updateType=je.OBJECT}setup(e){const{geometry:t}=e,i=t.morphAttributes.position!==void 0,r=t.hasAttribute("normal")&&t.morphAttributes.normal!==void 0,s=t.morphAttributes.position||t.morphAttributes.normal||t.morphAttributes.color,a=s!==void 0?s.length:0,{texture:o,stride:l,size:c}=wL(t);i===!0&&Zt.mulAssign(this.morphBaseInfluence),r===!0&&ur.mulAssign(this.morphBaseInfluence);const u=P(c.width);gt(a,({i:h})=>{const d=E(0).toVar();this.mesh.count>1&&this.mesh.morphTexture!==null&&this.mesh.morphTexture!==void 0?d.assign(Vr(this.mesh.morphTexture,un(P(h).add(1),P(ic))).r):d.assign(fi("morphTargetInfluences","float").element(h).toVar()),i===!0&&Zt.addAssign(G1({bufferMap:o,influence:d,stride:l,width:u,depth:h,offset:P(0)})),r===!0&&ur.addAssign(G1({bufferMap:o,influence:d,stride:l,width:u,depth:h,offset:P(1)}))})}update(){const e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce((t,i)=>t+i,0)}}const j1=K(W1),EL=n=>n.sort((e,t)=>e.id-t.id),AL=(n,e)=>{for(const t of e)if(t.isAnalyticLightNode&&t.light.id===n)return t;return null},ag=new WeakMap;class X1 extends qe{static get type(){return"LightsNode"}constructor(e=[]){super("vec3"),this.totalDiffuseNode=D().toVar("totalDiffuse"),this.totalSpecularNode=D().toVar("totalSpecular"),this.outgoingLightNode=D().toVar("outgoingLight"),this._lights=e,this._lightNodes=null,this._lightNodesHash=null,this.global=!0}getHash(e){if(this._lightNodesHash===null){this._lightNodes===null&&this.setupLightsNode(e);const t=[];for(const i of this._lightNodes)t.push(i.getHash());this._lightNodesHash="lights-"+t.join(",")}return this._lightNodesHash}analyze(e){const t=e.getDataFromNode(this);for(const i of t.nodes)i.build(e)}setupLightsNode(e){const t=[],i=this._lightNodes,r=EL(this._lights),s=e.renderer.nodes.library;for(const a of r)if(a.isNode)t.push(G(a));else{let o=null;if(i!==null&&(o=AL(a.id,i)),o===null){const l=s.getLightNodeClass(a.constructor);if(l===null){console.warn(`LightsNode.setupNodeLights: Light node not found for ${a.constructor.name}`);continue}let c=null;ag.has(a)?c=ag.get(a):(c=new l(a),ag.set(a,c)),t.push(c)}}this._lightNodes=t}setup(e){this._lightNodes===null&&this.setupLightsNode(e);const t=e.context,i=t.lightingModel;let r=this.outgoingLightNode;if(i){const{_lightNodes:s,totalDiffuseNode:a,totalSpecularNode:o}=this;t.outgoingLight=r;const l=e.addStack(),c=e.getDataFromNode(this);c.nodes=l.nodes,i.start(t,l,e);for(const g of s)g.build(e);i.indirect(t,l,e);const{backdrop:u,backdropAlpha:h}=t,{directDiffuse:d,directSpecular:p,indirectDiffuse:m,indirectSpecular:v}=t.reflectedLight;let f=d.add(m);u!==null&&(h!==null?f=D(h.mix(f,u)):f=D(u),t.material.transparent=!0),a.assign(f),o.assign(p.add(v)),r.assign(a.add(o)),i.finish(t,l,e),r=r.bypass(e.removeStack())}return r}setLights(e){return this._lights=e,this._lightNodes=null,this._lightNodesHash=null,this}getLights(){return this._lights}}const q1=K(X1);class ia extends qe{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}generate(){console.warn("Abstract function.")}}class Y1 extends ia{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class $1 extends Of{static get type(){return"LightingContextNode"}constructor(e,t=null,i=null,r=null){super(e),this.lightingModel=t,this.backdropNode=i,this.backdropAlphaNode=r,this._value=null}getContext(){const{backdropNode:e,backdropAlphaNode:t}=this,i=D().toVar("directDiffuse"),r=D().toVar("directSpecular"),s=D().toVar("indirectDiffuse"),a=D().toVar("indirectSpecular"),o={directDiffuse:i,directSpecular:r,indirectDiffuse:s,indirectSpecular:a};return{radiance:D().toVar("radiance"),irradiance:D().toVar("irradiance"),iblIrradiance:D().toVar("iblIrradiance"),ambientOcclusion:E(1).toVar("ambientOcclusion"),reflectedLight:o,backdrop:e,backdropAlpha:t}}setup(e){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}const J1=K($1);class K1 extends ia{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}let rc,nc;class ri extends qe{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this.isViewportNode=!0}getNodeType(){return this.scope===ri.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=je.NONE;return(this.scope===ri.SIZE||this.scope===ri.VIEWPORT)&&(e=je.RENDER),this.updateType=e,e}update({renderer:e}){const t=e.getRenderTarget();this.scope===ri.VIEWPORT?t!==null?nc.copy(t.viewport):(e.getViewport(nc),nc.multiplyScalar(e.getPixelRatio())):t!==null?(rc.width=t.width,rc.height=t.height):e.getDrawingBufferSize(rc)}setup(){const e=this.scope;let t=null;return e===ri.SIZE?t=fe(rc||(rc=new J)):e===ri.VIEWPORT?t=fe(nc||(nc=new st)):t=z(go.div(fo)),t}generate(e){if(this.scope===ri.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){const i=e.getNodeProperties(fo).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${i}.y - ${t}.y )`}return t}return super.generate(e)}}ri.COORDINATE="coordinate",ri.VIEWPORT="viewport",ri.SIZE="size",ri.UV="uv";const ps=ge(ri,ri.UV),fo=ge(ri,ri.SIZE),go=ge(ri,ri.COORDINATE),Pn=ge(ri,ri.VIEWPORT),Z1=Pn.zw,Q1=go.sub(Pn.xy),NL=Q1.div(Z1),CL=U(()=>(console.warn('TSL.ViewportNode: "viewportResolution" is deprecated. Use "screenSize" instead.'),fo),"vec2").once()(),RL=U(()=>(console.warn('TSL.ViewportNode: "viewportTopLeft" is deprecated. Use "screenUV" instead.'),ps),"vec2").once()(),IL=U(()=>(console.warn('TSL.ViewportNode: "viewportBottomLeft" is deprecated. Use "screenUV.flipY()" instead.'),ps.flipY()),"vec2").once()(),sc=new J;class ac extends dn{static get type(){return"ViewportTextureNode"}constructor(e=ps,t=null,i=null){i===null&&(i=new pm,i.minFilter=ji),super(i,e,t),this.generateMipmaps=!1,this.isOutputTextureNode=!0,this.updateBeforeType=je.FRAME}updateBefore(e){const t=e.renderer;t.getDrawingBufferSize(sc);const i=this.value;(i.image.width!==sc.width||i.image.height!==sc.height)&&(i.image.width=sc.width,i.image.height=sc.height,i.needsUpdate=!0);const r=i.generateMipmaps;i.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(i),i.generateMipmaps=r}clone(){const e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}const LL=K(ac),eb=K(ac,null,null,{generateMipmaps:!0});let og=null;class tb extends ac{static get type(){return"ViewportDepthTextureNode"}constructor(e=ps,t=null){og===null&&(og=new Us),super(e,t,og)}}const lg=K(tb);class Qi extends qe{static get type(){return"ViewportDepthNode"}constructor(e,t=null){super("float"),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(e){const{scope:t}=this;return t===Qi.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){const{scope:t}=this,i=this.valueNode;let r=null;if(t===Qi.DEPTH_BASE)i!==null&&(r=rb().assign(i));else if(t===Qi.DEPTH)e.isPerspectiveCamera?r=ib(Pi.z,co,uo):r=oc(Pi.z,co,uo);else if(t===Qi.LINEAR_DEPTH)if(i!==null)if(e.isPerspectiveCamera){const s=cg(i,co,uo);r=oc(s,co,uo)}else r=i;else r=oc(Pi.z,co,uo);return r}}Qi.DEPTH_BASE="depthBase",Qi.DEPTH="depth",Qi.LINEAR_DEPTH="linearDepth";const oc=(n,e,t)=>n.add(e).div(e.sub(t)),PL=(n,e,t)=>e.sub(t).mul(n).sub(e),ib=(n,e,t)=>e.add(n).mul(t).div(t.sub(e).mul(n)),cg=(n,e,t)=>e.mul(t).div(t.sub(e).mul(n).sub(t)),rb=K(Qi,Qi.DEPTH_BASE),ug=ge(Qi,Qi.DEPTH),ed=K(Qi,Qi.LINEAR_DEPTH),DL=ed(lg());ug.assign=n=>rb(n);class gs extends qe{static get type(){return"ClippingNode"}constructor(e=gs.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);const t=e.clippingContext,{localClipIntersection:i,localClippingCount:r,globalClippingCount:s}=t,a=s+r,o=i?a-r:a;return this.scope===gs.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(t.planes,a,o):this.setupDefault(t.planes,a,o)}setupAlphaToCoverage(e,t,i){return U(()=>{const r=mn(e),s=ar("float","distanceToPlane"),a=ar("float","distanceToGradient"),o=ar("float","clipOpacity");o.assign(1);let l;if(gt(i,({i:c})=>{l=r.element(c),s.assign(Pi.dot(l.xyz).negate().add(l.w)),a.assign(s.fwidth().div(2)),o.mulAssign(Ki(a.negate(),a,s)),o.equal(0).discard()}),i<t){const c=ar("float","unionclipOpacity");c.assign(1),gt({start:i,end:t},({i:u})=>{l=r.element(u),s.assign(Pi.dot(l.xyz).negate().add(l.w)),a.assign(s.fwidth().div(2)),c.mulAssign(Ki(a.negate(),a,s).oneMinus())}),o.mulAssign(c.oneMinus())}Nt.a.mulAssign(o),Nt.a.equal(0).discard()})()}setupDefault(e,t,i){return U(()=>{const r=mn(e);let s;if(gt(i,({i:a})=>{s=r.element(a),Pi.dot(s.xyz).greaterThan(s.w).discard()}),i<t){const a=ar("bool","clipped");a.assign(!0),gt({start:i,end:t},({i:o})=>{s=r.element(o),a.assign(Pi.dot(s.xyz).greaterThan(s.w).and(a))}),a.discard()}})()}}gs.ALPHA_TO_COVERAGE="alphaToCoverage",gs.DEFAULT="default";const UL=()=>G(new gs),OL=()=>G(new gs(gs.ALPHA_TO_COVERAGE));class bt extends hi{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+Km(this)}build(e){this.setup(e)}setupObserver(e){return new Gx(e)}setup(e){e.context.setupNormal=()=>this.setupNormal(e),e.addStack(),e.stack.outputNode=this.vertexNode||this.setupPosition(e),e.addFlow("vertex",e.removeStack()),e.addStack();let t;const i=this.setupClipping(e);if(this.depthWrite===!0&&this.setupDepth(e),this.fragmentNode===null){this.setupDiffuseColor(e),this.setupVariants(e);const r=this.setupLighting(e);i!==null&&e.stack.add(i);const s=ae(r,Nt.a).max(0);if(t=this.setupOutput(e,s),_f.assign(t),this.outputNode!==null&&(t=this.outputNode),e.renderer.getRenderTarget()!==null){const a=e.renderer.getMRT(),o=this.mrtNode;a!==null?(t=a,o!==null&&(t=a.merge(o))):o!==null&&(t=o)}}else{let r=this.fragmentNode;r.isOutputStructNode!==!0&&(r=ae(r)),t=this.setupOutput(e,r)}e.stack.outputNode=t,e.addFlow("fragment",e.removeStack()),e.monitor=this.setupObserver(e)}setupClipping(e){if(e.clippingContext===null)return null;const{globalClippingCount:t,localClippingCount:i}=e.clippingContext;let r=null;if(t||i){const s=e.renderer.samples;this.alphaToCoverage&&s>1?r=OL():e.stack.add(UL())}return r}setupDepth(e){const{renderer:t}=e;let i=this.depthNode;if(i===null){const r="getMRT"in t&&t.getMRT();r&&r.has("depth")?i=r.get("depth"):t.logarithmicDepthBuffer===!0&&(i=rg().w.add(1).log2().mul(VM).mul(.5))}i!==null&&ug.assign(i).append()}setupPosition(e){const{object:t}=e,i=t.geometry;if(e.addStack(),(i.morphAttributes.position||i.morphAttributes.normal||i.morphAttributes.color)&&j1(t).append(),t.isSkinnedMesh===!0&&k1(t).append(),this.displacementMap){const s=rn("displacementMap","texture"),a=rn("displacementScale","float"),o=rn("displacementBias","float");Zt.addAssign(ur.normalize().mul(s.x.mul(a).add(o)))}t.isBatchedMesh&&B1(t).append(),t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&F1(t).append(),this.positionNode!==null&&Zt.assign(this.positionNode);const r=rg();return e.context.vertex=e.removeStack(),e.context.mvp=r,r}setupDiffuseColor({object:e,geometry:t}){let i=this.colorNode?ae(this.colorNode):po;this.vertexColors===!0&&t.hasAttribute("color")&&(i=ae(i.xyz.mul(_i("color","vec3")),i.a)),e.instanceColor&&(i=Zr("vec3","vInstanceColor").mul(i)),e.isBatchedMesh&&e._colorsTexture&&(i=Zr("vec3","vBatchColor").mul(i)),Nt.assign(i);const r=this.opacityNode?E(this.opacityNode):$h;if(Nt.a.assign(Nt.a.mul(r)),this.alphaTestNode!==null||this.alphaTest>0){const s=this.alphaTestNode!==null?E(this.alphaTestNode):o1;Nt.a.lessThanEqual(s).discard()}this.transparent===!1&&this.blending===_n&&this.alphaToCoverage===!1&&Nt.a.assign(1)}setupVariants(){}setupOutgoingLight(){return this.lights===!0?D(0):Nt.rgb}setupNormal(){return this.normalNode?D(this.normalNode):m1}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?rn("envMap","cubeTexture"):rn("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new K1(ig)),t}setupLights(e){const t=[],i=this.setupEnvironment(e);i&&i.isLightingNode&&t.push(i);const r=this.setupLightMap(e);if(r&&r.isLightingNode&&t.push(r),this.aoNode!==null||e.material.aoMap){const a=this.aoNode!==null?this.aoNode:L1;t.push(new Y1(a))}let s=this.lightsNode||e.lightsNode;return t.length>0&&(s=q1([...s.getLights(),...t])),s}setupLightingModel(){}setupLighting(e){const{material:t}=e,{backdropNode:i,backdropAlphaNode:r,emissiveNode:s}=this,a=this.lights===!0||this.lightsNode!==null?this.setupLights(e):null;let o=this.setupOutgoingLight(e);if(a&&a.getScope().getLights().length>0){const l=this.setupLightingModel(e);o=J1(a,l,i,r)}else i!==null&&(o=D(r!==null?rt(o,i,r):i));return(s&&s.isNode===!0||t.emissive&&t.emissive.isColor===!0)&&(vf.assign(D(s||c1)),o=o.add(vf)),o}setupOutput(e,t){if(this.fog===!0){const i=e.fogNode;i&&(t=ae(i.mix(t.rgb,i.colorNode),t.a))}return t}setDefaultValues(e){for(const i in e){const r=e[i];this[i]===void 0&&(this[i]=r,r&&r.clone&&(this[i]=r.clone()))}const t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(const i in t)Object.getOwnPropertyDescriptor(this.constructor.prototype,i)===void 0&&t[i].get!==void 0&&Object.defineProperty(this.constructor.prototype,i,t[i])}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{},nodes:{}});const i=hi.prototype.toJSON.call(this,e),r=Rl(this);i.inputNodes={};for(const{property:a,childNode:o}of r)i.inputNodes[a]=o.toJSON(e).uuid;function s(a){const o=[];for(const l in a){const c=a[l];delete c.metadata,o.push(c)}return o}if(t){const a=s(e.textures),o=s(e.images),l=s(e.nodes);a.length>0&&(i.textures=a),o.length>0&&(i.images=o),l.length>0&&(i.nodes=l)}return i}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,this.colorNode=e.colorNode,this.normalNode=e.normalNode,this.opacityNode=e.opacityNode,this.backdropNode=e.backdropNode,this.backdropAlphaNode=e.backdropAlphaNode,this.alphaTestNode=e.alphaTestNode,this.positionNode=e.positionNode,this.depthNode=e.depthNode,this.shadowNode=e.shadowNode,this.shadowPositionNode=e.shadowPositionNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,super.copy(e)}}const FL=new Ka;class VL extends bt{static get type(){return"InstancedPointsNodeMaterial"}constructor(e={}){super(),this.lights=!1,this.useAlphaToCoverage=!0,this.useColor=e.vertexColors,this.pointWidth=1,this.pointColorNode=null,this.pointWidthNode=null,this.setDefaultValues(FL),this.setValues(e)}setup(e){this.setupShaders(e),super.setup(e)}setupShaders({renderer:e}){const t=this.alphaToCoverage,i=this.useColor;this.vertexNode=U(()=>{const r=_i("instancePosition").xyz,s=ae(pn.mul(ae(r,1))),a=Pn.z.div(Pn.w),o=lr.mul(s),l=Li.xy.toVar();return l.mulAssign(this.pointWidthNode?this.pointWidthNode:R1),l.assign(l.div(Pn.z)),l.y.assign(l.y.mul(a)),l.assign(l.mul(o.w)),o.addAssign(ae(l,0,0)),o})(),this.fragmentNode=U(()=>{const r=E(1).toVar(),s=Pf(nt().mul(2).sub(1));if(t&&e.samples>1){const o=E(s.fwidth()).toVar();r.assign(Ki(o.oneMinus(),o.add(1),s).oneMinus())}else s.greaterThan(1).discard();let a;return this.pointColorNode?a=this.pointColorNode:i?a=_i("instanceColor").mul(po):a=po,r.mulAssign($h),ae(a,r)})()}get alphaToCoverage(){return this.useAlphaToCoverage}set alphaToCoverage(e){this.useAlphaToCoverage!==e&&(this.useAlphaToCoverage=e,this.needsUpdate=!0)}}const BL=new Ni;class zL extends bt{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.lights=!1,this.setDefaultValues(BL),this.setValues(e)}}const kL=new dh;class HL extends bt{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.lights=!1,this.setDefaultValues(kL),this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){const e=this.offsetNode,t=this.dashScaleNode?E(this.dashScaleNode):Kh,i=this.dashSizeNode?E(this.dashSizeNode):Qf,r=this.dashSizeNode?E(this.dashGapNode):eg;Zs.assign(i),zl.assign(r);const s=Ii(_i("lineDistance").mul(t));(e?s.add(e):s).mod(Zs.add(zl)).greaterThan(Zs).discard()}}const GL=new dh;class WL extends bt{static get type(){return"Line2NodeMaterial"}constructor(e={}){super(),this.lights=!1,this.setDefaultValues(GL),this.useAlphaToCoverage=!0,this.useColor=e.vertexColors,this.useDash=e.dashed,this.useWorldUnits=!1,this.dashOffset=0,this.lineWidth=1,this.lineColorNode=null,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setup(e){this.setupShaders(e),super.setup(e)}setupShaders({renderer:e}){const t=this.alphaToCoverage,i=this.useColor,r=this.dashed,s=this.worldUnits,a=U(({start:l,end:c})=>{const u=lr.element(2).element(2),h=lr.element(3).element(2).mul(-.5).div(u).sub(l.z).div(c.z.sub(l.z));return ae(rt(l.xyz,c.xyz,h),c.w)}).setLayout({name:"trimSegment",type:"vec4",inputs:[{name:"start",type:"vec4"},{name:"end",type:"vec4"}]});this.vertexNode=U(()=>{const l=_i("instanceStart"),c=_i("instanceEnd"),u=ae(pn.mul(ae(l,1))).toVar("start"),h=ae(pn.mul(ae(c,1))).toVar("end");s&&(Zr("vec3","worldStart").assign(u.xyz),Zr("vec3","worldEnd").assign(h.xyz));const d=Pn.z.div(Pn.w),p=lr.element(2).element(3).equal(-1);Le(p,()=>{Le(u.z.lessThan(0).and(h.z.greaterThan(0)),()=>{h.assign(a({start:u,end:h}))}).ElseIf(h.z.lessThan(0).and(u.z.greaterThanEqual(0)),()=>{u.assign(a({start:h,end:u}))})});const m=lr.mul(u),v=lr.mul(h),f=m.xyz.div(m.w),g=v.xyz.div(v.w),x=g.xy.sub(f.xy).toVar();x.x.assign(x.x.mul(d)),x.assign(x.normalize());const y=ae().toVar();if(s){const _=h.xyz.sub(u.xyz).normalize(),I=rt(u.xyz,h.xyz,.5).normalize(),b=_.cross(I).normalize(),w=_.cross(b),C=Zr("vec4","worldPos");C.assign(Li.y.lessThan(.5).select(u,h));const H=Zh.mul(.5);C.addAssign(ae(Li.x.lessThan(0).select(b.mul(H),b.mul(H).negate()),0)),r||(C.addAssign(ae(Li.y.lessThan(.5).select(_.mul(H).negate(),_.mul(H)),0)),C.addAssign(ae(w.mul(H),0)),Le(Li.y.greaterThan(1).or(Li.y.lessThan(0)),()=>{C.subAssign(ae(w.mul(2).mul(H),0))})),y.assign(lr.mul(C));const M=D().toVar();M.assign(Li.y.lessThan(.5).select(f,g)),y.z.assign(M.z.mul(y.w))}else{const _=z(x.y,x.x.negate()).toVar("offset");x.x.assign(x.x.div(d)),_.x.assign(_.x.div(d)),_.assign(Li.x.lessThan(0).select(_.negate(),_)),Le(Li.y.lessThan(0),()=>{_.assign(_.sub(x))}).ElseIf(Li.y.greaterThan(1),()=>{_.assign(_.add(x))}),_.assign(_.mul(Zh)),_.assign(_.div(Pn.w)),y.assign(Li.y.lessThan(.5).select(m,v)),_.assign(_.mul(y.w)),y.assign(y.add(ae(_,0,0)))}return y})();const o=U(({p1:l,p2:c,p3:u,p4:h})=>{const d=l.sub(u),p=h.sub(u),m=c.sub(l),v=d.dot(p),f=p.dot(m),g=d.dot(m),x=p.dot(p),y=m.dot(m).mul(x).sub(f.mul(f)),_=v.mul(f).sub(g.mul(x)).div(y).clamp(),I=v.add(f.mul(_)).div(x).clamp();return z(_,I)});this.fragmentNode=U(()=>{const l=nt();if(r){const h=this.offsetNode?E(this.offsetNodeNode):tg,d=this.dashScaleNode?E(this.dashScaleNode):Kh,p=this.dashSizeNode?E(this.dashSizeNode):Qf,m=this.dashSizeNode?E(this.dashGapNode):eg;Zs.assign(p),zl.assign(m);const v=_i("instanceDistanceStart"),f=_i("instanceDistanceEnd"),g=Li.y.lessThan(.5).select(d.mul(v),Kh.mul(f)),x=Ii(g.add(tg)),y=h?x.add(h):x;l.y.lessThan(-1).or(l.y.greaterThan(1)).discard(),y.mod(Zs.add(zl)).greaterThan(Zs).discard()}const c=E(1).toVar("alpha");if(s){const h=Zr("vec3","worldStart"),d=Zr("vec3","worldEnd"),p=Zr("vec4","worldPos").xyz.normalize().mul(1e5),m=d.sub(h),v=o({p1:h,p2:d,p3:D(0,0,0),p4:p}),f=h.add(m.mul(v.x)),g=p.mul(v.y),x=f.sub(g).length().div(Zh);if(!r)if(t&&e.samples>1){const y=x.fwidth();c.assign(Ki(y.negate().add(.5),y.add(.5),x).oneMinus())}else x.greaterThan(.5).discard()}else if(t&&e.samples>1){const h=l.x,d=l.y.greaterThan(0).select(l.y.sub(1),l.y.add(1)),p=h.mul(h).add(d.mul(d)),m=E(p.fwidth()).toVar("dlen");Le(l.y.abs().greaterThan(1),()=>{c.assign(Ki(m.oneMinus(),m.add(1),p).oneMinus())})}else Le(l.y.abs().greaterThan(1),()=>{const h=l.x,d=l.y.greaterThan(0).select(l.y.sub(1),l.y.add(1));h.mul(h).add(d.mul(d)).greaterThan(1).discard()});let u;if(this.lineColorNode)u=this.lineColorNode;else if(i){const h=_i("instanceColorStart"),d=_i("instanceColorEnd");u=Li.y.lessThan(.5).select(h,d).mul(po)}else u=po;return ae(u,c)})()}get worldUnits(){return this.useWorldUnits}set worldUnits(e){this.useWorldUnits!==e&&(this.useWorldUnits=e,this.needsUpdate=!0)}get dashed(){return this.useDash}set dashed(e){this.useDash!==e&&(this.useDash=e,this.needsUpdate=!0)}get alphaToCoverage(){return this.useAlphaToCoverage}set alphaToCoverage(e){this.useAlphaToCoverage!==e&&(this.useAlphaToCoverage=e,this.needsUpdate=!0)}}const nb=n=>G(n).mul(.5).add(.5),jL=n=>G(n).mul(2).sub(1),XL=new uh;class qL extends bt{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.lights=!1,this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(XL),this.setValues(e)}setupDiffuseColor(){const e=this.opacityNode?E(this.opacityNode):$h;Nt.assign(ae(nb(Yt),e))}}class sb extends pt{static get type(){return"EquirectUVNode"}constructor(e=jf){super("vec2"),this.dirNode=e}setup(){const e=this.dirNode,t=e.z.atan2(e.x).mul(1/(Math.PI*2)).add(.5),i=e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return z(t,i)}}const hg=K(sb);class ab extends Au{constructor(e=1,t={}){super(e,t),this.isCubeRenderTarget=!0}fromEquirectangularTexture(e,t){const i=t.minFilter,r=t.generateMipmaps;t.generateMipmaps=!0,this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const s=new yn(5,5,5),a=hg(jf),o=new bt;o.colorNode=yt(t,a,0),o.side=si,o.blending=Er;const l=new Ft(s,o),c=new Ou;c.add(l),t.minFilter===ji&&(t.minFilter=Lt);const u=new Eu(1,10,this),h=e.getMRT();return e.setMRT(null),u.update(e,c),e.setMRT(h),t.minFilter=i,t.currentGenerateMipmaps=r,l.geometry.dispose(),l.material.dispose(),this}}const lc=new WeakMap;class YL extends pt{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=Xh();const t=new Cs;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=je.RENDER}updateBefore(e){const{renderer:t,material:i}=e,r=this.envNode;if(r.isTextureNode||r.isMaterialReferenceNode){const s=r.isTextureNode?r.value:i[r.property];if(s&&s.isTexture){const a=s.mapping;if(a===kn||a===Hn){if(lc.has(s)){const o=lc.get(s);lb(o,s.mapping),this._cubeTexture=o}else{const o=s.image;if($L(o)){const l=new ab(o.height);l.fromEquirectangularTexture(t,s),lb(l.texture,s.mapping),this._cubeTexture=l.texture,lc.set(s,l.texture),s.addEventListener("dispose",ob)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}}function $L(n){return n==null?!1:n.height>0}function ob(n){const e=n.target;e.removeEventListener("dispose",ob);const t=lc.get(e);t!==void 0&&(lc.delete(e),t.dispose())}function lb(n,e){e===kn?n.mapping=fr:e===Hn&&(n.mapping=Ar)}const JL=K(YL);class td extends ia{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=JL(this.envNode)}}class KL extends ia{static get type(){return"BasicLightMapNode"}constructor(e=null){super(),this.lightMapNode=e}setup(e){const t=E(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}}class cc{start(){}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}class cb extends cc{constructor(){super()}indirect(e,t,i){const r=e.ambientOcclusion,s=e.reflectedLight,a=i.context.irradianceLightMap;s.indirectDiffuse.assign(ae(0)),a?s.indirectDiffuse.addAssign(a):s.indirectDiffuse.addAssign(ae(1,1,1,0)),s.indirectDiffuse.mulAssign(r),s.indirectDiffuse.mulAssign(Nt.rgb)}finish(e,t,i){const r=i.material,s=e.outgoingLight,a=i.context.environment;if(a)switch(r.combine){case ma:s.rgb.assign(rt(s.rgb,s.rgb.mul(a.rgb),tc.mul(Jh)));break;case $d:s.rgb.assign(rt(s.rgb,a.rgb,tc.mul(Jh)));break;case Jd:s.rgb.addAssign(a.rgb.mul(tc.mul(Jh)));break;default:console.warn("THREE.BasicLightingModel: Unsupported .combine value:",r.combine);break}}}const ZL=new Yr;class QL extends bt{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(ZL),this.setValues(e)}setupNormal(){return hr}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new td(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new KL(ig)),t}setupOutgoingLight(){return Nt.rgb}setupLightingModel(){return new cb}}const vo=U(({f0:n,f90:e,dotVH:t})=>{const i=t.mul(-5.55473).sub(6.98316).mul(t).exp2();return n.mul(i.oneMinus()).add(e.mul(i))}),ra=U(n=>n.diffuseColor.mul(1/Math.PI)),eP=()=>E(.25),tP=U(({dotNH:n})=>Uh.mul(E(.5)).add(1).mul(E(1/Math.PI)).mul(n.pow(Uh))),iP=U(({lightDirection:n})=>{const e=n.add(Vt).normalize(),t=Yt.dot(e).clamp(),i=Vt.dot(e).clamp(),r=vo({f0:or,f90:1,dotVH:i}),s=eP(),a=tP({dotNH:t});return r.mul(s).mul(a)});class dg extends cb{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:i}){const r=Yt.dot(e).clamp().mul(t);i.directDiffuse.addAssign(r.mul(ra({diffuseColor:Nt.rgb}))),this.specular===!0&&i.directSpecular.addAssign(r.mul(iP({lightDirection:e})).mul(tc))}indirect({ambientOcclusion:e,irradiance:t,reflectedLight:i}){i.indirectDiffuse.addAssign(t.mul(ra({diffuseColor:Nt}))),i.indirectDiffuse.mulAssign(e)}}const rP=new hh;class nP extends bt{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(rP),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new td(t):null}setupLightingModel(){return new dg(!1)}}const sP=new ch;class aP extends bt{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(sP),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new td(t):null}setupLightingModel(){return new dg}setupVariants(){const e=(this.shininessNode?E(this.shininessNode):l1).max(1e-4);Uh.assign(e);const t=this.specularNode||u1;or.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}}const ub=U(()=>{const n=hr.dFdx().abs().max(hr.dFdy().abs());return n.x.max(n.y).max(n.z)}),pg=U(n=>{const{roughness:e}=n,t=ub();let i=e.max(.0525);return i=i.add(t),i=i.min(1),i}),hb=U(({alpha:n,dotNL:e,dotNV:t})=>{const i=n.pow2(),r=e.mul(i.add(i.oneMinus().mul(t.pow2())).sqrt()),s=t.mul(i.add(i.oneMinus().mul(e.pow2())).sqrt());return Qr(.5,r.add(s).max(P_))}).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),oP=U(({alphaT:n,alphaB:e,dotTV:t,dotBV:i,dotTL:r,dotBL:s,dotNV:a,dotNL:o})=>{const l=o.mul(D(n.mul(t),e.mul(i),a).length()),c=a.mul(D(n.mul(r),e.mul(s),o).length());return Qr(.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"}]}),db=U(({alpha:n,dotNH:e})=>{const t=n.pow2(),i=e.pow2().mul(t.oneMinus()).oneMinus();return t.div(i.pow2()).mul(1/Math.PI)}).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),lP=E(1/Math.PI),cP=U(({alphaT:n,alphaB:e,dotNH:t,dotTH:i,dotBH:r})=>{const s=n.mul(e),a=D(e.mul(i),n.mul(r),s.mul(t)),o=a.dot(a),l=s.div(o);return lP.mul(s.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"}]}),mg=U(n=>{const{lightDirection:e,f0:t,f90:i,roughness:r,f:s,USE_IRIDESCENCE:a,USE_ANISOTROPY:o}=n,l=n.normalView||Yt,c=r.pow2(),u=e.add(Vt).normalize(),h=l.dot(e).clamp(),d=l.dot(Vt).clamp(),p=l.dot(u).clamp(),m=Vt.dot(u).clamp();let v=vo({f0:t,f90:i,dotVH:m}),f,g;if(Il(a)&&(v=Ph.mix(v,s)),Il(o)){const x=Vl.dot(e),y=Vl.dot(Vt),_=Vl.dot(u),I=Ks.dot(e),b=Ks.dot(Vt),w=Ks.dot(u);f=oP({alphaT:Dh,alphaB:c,dotTV:y,dotBV:b,dotTL:x,dotBL:I,dotNV:d,dotNL:h}),g=cP({alphaT:Dh,alphaB:c,dotNH:p,dotTH:_,dotBH:w})}else f=hb({alpha:c,dotNL:h,dotNV:d}),g=db({alpha:c,dotNH:p});return v.mul(f).mul(g)}),fg=U(({roughness:n,dotNV:e})=>{const t=ae(-1,-.0275,-.572,.022),i=ae(1,.0425,1.04,-.04),r=n.mul(t).add(i),s=r.x.mul(r.x).min(e.mul(-9.28).exp2()).mul(r.x).add(r.y);return z(-1.04,1.04).mul(s).add(r.zw)}).setLayout({name:"DFGApprox",type:"vec2",inputs:[{name:"roughness",type:"float"},{name:"dotNV",type:"vec3"}]}),pb=U(n=>{const{dotNV:e,specularColor:t,specularF90:i,roughness:r}=n,s=fg({dotNV:e,roughness:r});return t.mul(s.x).add(i.mul(s.y))}),mb=U(({f:n,f90:e,dotVH:t})=>{const i=t.oneMinus().saturate(),r=i.mul(i),s=i.mul(r,r).clamp(0,.9999);return n.sub(D(e).mul(s)).div(s.oneMinus())}).setLayout({name:"Schlick_to_F0",type:"vec3",inputs:[{name:"f",type:"vec3"},{name:"f90",type:"float"},{name:"dotVH",type:"float"}]}),uP=U(({roughness:n,dotNH:e})=>{const t=n.pow2(),i=E(1).div(t),r=e.pow2().oneMinus().max(.0078125);return E(2).add(i).mul(r.pow(i.mul(.5))).div(2*Math.PI)}).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),hP=U(({dotNV:n,dotNL:e})=>E(1).div(E(4).mul(e.add(n).sub(e.mul(n))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),dP=U(({lightDirection:n})=>{const e=n.add(Vt).normalize(),t=Yt.dot(n).clamp(),i=Yt.dot(Vt).clamp(),r=Yt.dot(e).clamp(),s=uP({roughness:Lh,dotNH:r}),a=hP({dotNV:i,dotNL:t});return Js.mul(s).mul(a)}),pP=U(({N:n,V:e,roughness:t})=>{const i=.0078125,r=n.dot(e).saturate(),s=z(t,r.oneMinus().sqrt());return s.assign(s.mul(.984375).add(i)),s}).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]}),mP=U(({f:n})=>{const e=n.length();return ft(e.mul(e).add(n.z).div(e.add(1)),0)}).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),id=U(({v1:n,v2:e})=>{const t=n.dot(e),i=t.abs().toVar(),r=i.mul(.0145206).add(.4965155).mul(i).add(.8543985).toVar(),s=i.add(4.1616724).mul(i).add(3.417594).toVar(),a=r.div(s),o=t.greaterThan(0).select(a,ft(t.mul(t).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(a));return n.cross(e).mul(o)}).setLayout({name:"LTC_EdgeVectorFormFactor",type:"vec3",inputs:[{name:"v1",type:"vec3"},{name:"v2",type:"vec3"}]}),fb=U(({N:n,V:e,P:t,mInv:i,p0:r,p1:s,p2:a,p3:o})=>{const l=s.sub(r).toVar(),c=o.sub(r).toVar(),u=l.cross(c),h=D().toVar();return Le(u.dot(t.sub(r)).greaterThanEqual(0),()=>{const d=e.sub(n.mul(e.dot(n))).normalize(),p=n.cross(d).negate(),m=i.mul(yi(d,p,n).transpose()).toVar(),v=m.mul(r.sub(t)).normalize().toVar(),f=m.mul(s.sub(t)).normalize().toVar(),g=m.mul(a.sub(t)).normalize().toVar(),x=m.mul(o.sub(t)).normalize().toVar(),y=D(0).toVar();y.addAssign(id({v1:v,v2:f})),y.addAssign(id({v1:f,v2:g})),y.addAssign(id({v1:g,v2:x})),y.addAssign(id({v1:x,v2:v})),h.assign(D(mP({f:y})))}),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"}]}),rd=1/6,gb=n=>lt(rd,lt(n,lt(n,n.negate().add(3)).sub(3)).add(1)),gg=n=>lt(rd,lt(n,lt(n,lt(3,n).sub(6))).add(4)),vb=n=>lt(rd,lt(n,lt(n,lt(-3,n).add(3)).add(3)).add(1)),vg=n=>lt(rd,Ji(n,3)),yb=n=>gb(n).add(gg(n)),xb=n=>vb(n).add(vg(n)),_b=n=>zt(-1,gg(n).div(gb(n).add(gg(n)))),Mb=n=>zt(1,vg(n).div(vb(n).add(vg(n)))),bb=(n,e,t)=>{const i=n.uvNode,r=lt(i,e.zw).add(.5),s=cs(r),a=us(r),o=yb(a.x),l=xb(a.x),c=_b(a.x),u=Mb(a.x),h=_b(a.y),d=Mb(a.y),p=z(s.x.add(c),s.y.add(h)).sub(.5).mul(e.xy),m=z(s.x.add(u),s.y.add(h)).sub(.5).mul(e.xy),v=z(s.x.add(c),s.y.add(d)).sub(.5).mul(e.xy),f=z(s.x.add(u),s.y.add(d)).sub(.5).mul(e.xy),g=yb(a.y).mul(zt(o.mul(n.uv(p).level(t)),l.mul(n.uv(m).level(t)))),x=xb(a.y).mul(zt(o.mul(n.uv(v).level(t)),l.mul(n.uv(f).level(t))));return g.add(x)},Tb=U(([n,e=E(3)])=>{const t=z(n.size(P(e))),i=z(n.size(P(e.add(1)))),r=Qr(1,t),s=Qr(1,i),a=bb(n,ae(r,t),cs(e)),o=bb(n,ae(s,i),Rf(e));return us(e).mix(a,o)}),Sb=U(([n,e,t,i,r])=>{const s=D(Df(e.negate(),Mr(n),Qr(1,i))),a=D(ea(r[0].xyz),ea(r[1].xyz),ea(r[2].xyz));return Mr(s).mul(t.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"}]}),fP=U(([n,e])=>n.mul(li(e.mul(2).sub(2),0,1))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),gP=eb(),wb=U(([n,e,t])=>{const i=gP.uv(n),r=Hl(E(fo.x)).mul(fP(e,t));return Tb(i,r)}),Eb=U(([n,e,t])=>(Le(t.notEqual(0),()=>{const i=Cf(e).negate().div(t);return Nf(i.negate().mul(n))}),D(1))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),vP=U(([n,e,t,i,r,s,a,o,l,c,u,h,d,p,m])=>{let v,f;if(m){v=ae().toVar(),f=D().toVar();const I=u.sub(1).mul(m.mul(.025)),b=D(u.sub(I),u,u.add(I));gt({start:0,end:3},({i:w})=>{const C=b.element(w),H=Sb(n,e,h,C,o),M=a.add(H),T=c.mul(l.mul(ae(M,1))),k=z(T.xy.div(T.w)).toVar();k.addAssign(1),k.divAssign(2),k.assign(z(k.x,k.y.oneMinus()));const j=wb(k,t,C);v.element(w).assign(j.element(w)),v.a.addAssign(j.a),f.element(w).assign(i.element(w).mul(Eb(ea(H),d,p).element(w)))}),v.a.divAssign(3)}else{const I=Sb(n,e,h,u,o),b=a.add(I),w=c.mul(l.mul(ae(b,1))),C=z(w.xy.div(w.w)).toVar();C.addAssign(1),C.divAssign(2),C.assign(z(C.x,C.y.oneMinus())),v=wb(C,t,u),f=i.mul(Eb(ea(I),d,p))}const g=f.rgb.mul(v.rgb),x=n.dot(e).clamp(),y=D(pb({dotNV:x,specularColor:r,specularF90:s,roughness:t})),_=f.r.add(f.g,f.b).div(3);return ae(y.oneMinus().mul(g),v.a.oneMinus().mul(_).oneMinus())}),yP=yi(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),xP=n=>{const e=n.sqrt();return D(1).add(e).div(D(1).sub(e))},Ab=(n,e)=>n.sub(e).div(n.add(e)).pow2(),_P=(n,e)=>{const t=n.mul(2*Math.PI*1e-9),i=D(54856e-17,44201e-17,52481e-17),r=D(1681e3,1795300,2208400),s=D(43278e5,93046e5,66121e5),a=E(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(t.mul(2239900).add(e.x).cos()).mul(t.pow2().mul(-45282e5).exp());let o=i.mul(s.mul(2*Math.PI).sqrt()).mul(r.mul(t).add(e).cos()).mul(t.pow2().negate().mul(s).exp());return o=D(o.x.add(a),o.y,o.z).div(10685e-11),yP.mul(o)},MP=U(({outsideIOR:n,eta2:e,cosTheta1:t,thinFilmThickness:i,baseF0:r})=>{const s=rt(n,e,Ki(0,.03,i)),a=n.div(s).pow2().mul(E(1).sub(t.pow2())),o=E(1).sub(a).sqrt(),l=Ab(s,n),c=vo({f0:l,f90:1,dotVH:t}),u=c.oneMinus(),h=s.lessThan(n).select(Math.PI,0),d=E(Math.PI).sub(h),p=xP(r.clamp(0,.9999)),m=Ab(p,s.toVec3()),v=vo({f0:m,f90:1,dotVH:o}),f=D(p.x.lessThan(s).select(Math.PI,0),p.y.lessThan(s).select(Math.PI,0),p.z.lessThan(s).select(Math.PI,0)),g=s.mul(i,o,2),x=D(d).add(f),y=c.mul(v).clamp(1e-5,.9999),_=y.sqrt(),I=u.pow2().mul(v).div(D(1).sub(y));let b=c.add(I),w=I.sub(u);for(let C=1;C<=2;++C){w=w.mul(_);const H=_P(E(C).mul(g),E(C).mul(x)).mul(2);b=b.add(w.mul(H))}return b.max(D(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"}]}),bP=U(({normal:n,viewDir:e,roughness:t})=>{const i=n.dot(e).saturate(),r=t.pow2(),s=Ri(t.lessThan(.25),E(-339.2).mul(r).add(E(161.4).mul(t)).sub(25.9),E(-8.48).mul(r).add(E(14.3).mul(t)).sub(9.95)),a=Ri(t.lessThan(.25),E(44).mul(r).sub(E(23.7).mul(t)).add(3.26),E(1.97).mul(r).sub(E(3.27).mul(t)).add(.72));return Ri(t.lessThan(.25),0,E(.1).mul(t).sub(.025)).add(s.mul(i).add(a).exp()).mul(1/Math.PI).saturate()}),yg=D(.04),xg=E(1);class nd extends cc{constructor(e=!1,t=!1,i=!1,r=!1,s=!1,a=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=i,this.anisotropy=r,this.transmission=s,this.dispersion=a,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0=null}start(e){if(this.clearcoat===!0&&(this.clearcoatRadiance=D().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=D().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=D().toVar("clearcoatSpecularIndirect")),this.sheen===!0&&(this.sheenSpecularDirect=D().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=D().toVar("sheenSpecularIndirect")),this.iridescence===!0){const t=Yt.dot(Vt).clamp();this.iridescenceFresnel=MP({outsideIOR:E(1),eta2:yf,cosTheta1:t,thinFilmThickness:xf,baseF0:or}),this.iridescenceF0=mb({f:this.iridescenceFresnel,f90:1,dotVH:t})}if(this.transmission===!0){const t=Gh,i=Wf.sub(Gh).normalize(),r=Xf;e.backdrop=vP(r,i,hn,Nt,or,Bl,t,Br,cr,lr,kl,Mf,Tf,bf,this.dispersion?Sf:null),e.backdropAlpha=Oh,Nt.a.mulAssign(rt(1,e.backdrop.a,Oh))}}computeMultiscattering(e,t,i){const r=Yt.dot(Vt).clamp(),s=fg({roughness:hn,dotNV:r}),a=(this.iridescenceF0?Ph.mix(or,this.iridescenceF0):or).mul(s.x).add(i.mul(s.y)),o=s.x.add(s.y).oneMinus(),l=or.add(or.oneMinus().mul(.047619)),c=a.mul(l).div(o.mul(l).oneMinus());e.addAssign(a),t.addAssign(c.mul(o))}direct({lightDirection:e,lightColor:t,reflectedLight:i}){const r=Yt.dot(e).clamp().mul(t);if(this.sheen===!0&&this.sheenSpecularDirect.addAssign(r.mul(dP({lightDirection:e}))),this.clearcoat===!0){const s=ho.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(s.mul(mg({lightDirection:e,f0:yg,f90:xg,roughness:Fl,normalView:ho})))}i.directDiffuse.addAssign(r.mul(ra({diffuseColor:Nt.rgb}))),i.directSpecular.addAssign(r.mul(mg({lightDirection:e,f0:or,f90:1,roughness:hn,iridescence:this.iridescence,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:i,halfHeight:r,reflectedLight:s,ltc_1:a,ltc_2:o}){const l=t.add(i).sub(r),c=t.sub(i).sub(r),u=t.sub(i).add(r),h=t.add(i).add(r),d=Yt,p=Vt,m=Pi.toVar(),v=pP({N:d,V:p,roughness:hn}),f=a.uv(v).toVar(),g=o.uv(v).toVar(),x=yi(D(f.x,0,f.y),D(0,1,0),D(f.z,0,f.w)).toVar(),y=or.mul(g.x).add(or.oneMinus().mul(g.y)).toVar();s.directSpecular.addAssign(e.mul(y).mul(fb({N:d,V:p,P:m,mInv:x,p0:l,p1:c,p2:u,p3:h}))),s.directDiffuse.addAssign(e.mul(Nt).mul(fb({N:d,V:p,P:m,mInv:yi(1,0,0,0,1,0,0,0,1),p0:l,p1:c,p2:u,p3:h})))}indirect(e,t,i){this.indirectDiffuse(e,t,i),this.indirectSpecular(e,t,i),this.ambientOcclusion(e,t,i)}indirectDiffuse({irradiance:e,reflectedLight:t}){t.indirectDiffuse.addAssign(e.mul(ra({diffuseColor:Nt})))}indirectSpecular({radiance:e,iblIrradiance:t,reflectedLight:i}){if(this.sheen===!0&&this.sheenSpecularIndirect.addAssign(t.mul(Js,bP({normal:Yt,viewDir:Vt,roughness:Lh}))),this.clearcoat===!0){const c=ho.dot(Vt).clamp(),u=pb({dotNV:c,specularColor:yg,specularF90:xg,roughness:Fl});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(u))}const r=D().toVar("singleScattering"),s=D().toVar("multiScattering"),a=t.mul(1/Math.PI);this.computeMultiscattering(r,s,Bl);const o=r.add(s),l=Nt.mul(o.r.max(o.g).max(o.b).oneMinus());i.indirectSpecular.addAssign(e.mul(r)),i.indirectSpecular.addAssign(s.mul(a)),i.indirectDiffuse.addAssign(l.mul(a))}ambientOcclusion({ambientOcclusion:e,reflectedLight:t}){const i=Yt.dot(Vt).clamp().add(e),r=hn.mul(-16).oneMinus().negate().exp2(),s=e.sub(i.pow(r).oneMinus()).clamp();this.clearcoat===!0&&this.clearcoatSpecularIndirect.mulAssign(e),this.sheen===!0&&this.sheenSpecularIndirect.mulAssign(e),t.indirectDiffuse.mulAssign(e),t.indirectSpecular.mulAssign(s)}finish(e){const{outgoingLight:t}=e;if(this.clearcoat===!0){const i=ho.dot(Vt).clamp(),r=vo({dotVH:i,f0:yg,f90:xg}),s=t.mul(Ih.mul(r).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(Ih));t.assign(s)}if(this.sheen===!0){const i=Js.r.max(Js.g).max(Js.b).mul(.157).oneMinus(),r=t.mul(i).add(this.sheenSpecularDirect,this.sheenSpecularIndirect);t.assign(r)}}}const Nb=E(1),_g=E(-2),sd=E(.8),Mg=E(-1),ad=E(.4),bg=E(2),od=E(.305),Tg=E(3),Cb=E(.21),TP=E(4),Rb=E(4),SP=E(16),wP=U(([n])=>{const e=D(It(n)).toVar(),t=E(-1).toVar();return Le(e.x.greaterThan(e.z),()=>{Le(e.x.greaterThan(e.y),()=>{t.assign(Ri(n.x.greaterThan(0),0,3))}).Else(()=>{t.assign(Ri(n.y.greaterThan(0),1,4))})}).Else(()=>{Le(e.z.greaterThan(e.y),()=>{t.assign(Ri(n.z.greaterThan(0),2,5))}).Else(()=>{t.assign(Ri(n.y.greaterThan(0),1,4))})}),t}).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),EP=U(([n,e])=>{const t=z().toVar();return Le(e.equal(0),()=>{t.assign(z(n.z,n.y).div(It(n.x)))}).ElseIf(e.equal(1),()=>{t.assign(z(n.x.negate(),n.z.negate()).div(It(n.y)))}).ElseIf(e.equal(2),()=>{t.assign(z(n.x.negate(),n.y).div(It(n.z)))}).ElseIf(e.equal(3),()=>{t.assign(z(n.z.negate(),n.y).div(It(n.x)))}).ElseIf(e.equal(4),()=>{t.assign(z(n.x.negate(),n.z).div(It(n.y)))}).Else(()=>{t.assign(z(n.x,n.y).div(It(n.z)))}),lt(.5,t.add(1))}).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),AP=U(([n])=>{const e=E(0).toVar();return Le(n.greaterThanEqual(sd),()=>{e.assign(Nb.sub(n).mul(Mg.sub(_g)).div(Nb.sub(sd)).add(_g))}).ElseIf(n.greaterThanEqual(ad),()=>{e.assign(sd.sub(n).mul(bg.sub(Mg)).div(sd.sub(ad)).add(Mg))}).ElseIf(n.greaterThanEqual(od),()=>{e.assign(ad.sub(n).mul(Tg.sub(bg)).div(ad.sub(od)).add(bg))}).ElseIf(n.greaterThanEqual(Cb),()=>{e.assign(od.sub(n).mul(TP.sub(Tg)).div(od.sub(Cb)).add(Tg))}).Else(()=>{e.assign(E(-2).mul(Hl(lt(1.16,n))))}),e}).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),Ib=U(([n,e])=>{const t=n.toVar();t.assign(lt(2,t).sub(1));const i=D(t,1).toVar();return Le(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"}]}),Lb=U(([n,e,t,i,r,s])=>{const a=E(t),o=D(e),l=li(AP(a),_g,s),c=us(l),u=cs(l),h=D(Sg(n,o,u,i,r,s)).toVar();return Le(c.notEqual(0),()=>{const d=D(Sg(n,o,u.add(1),i,r,s)).toVar();h.assign(rt(h,d,c))}),h}),Sg=U(([n,e,t,i,r,s])=>{const a=E(t).toVar(),o=D(e),l=E(wP(o)).toVar(),c=E(ft(Rb.sub(a),0)).toVar();a.assign(ft(a,Rb));const u=E(Fh(a)).toVar(),h=z(EP(o,l).mul(u.sub(2)).add(1)).toVar();return Le(l.greaterThan(2),()=>{h.y.addAssign(u),l.subAssign(3)}),h.x.addAssign(l.mul(u)),h.x.addAssign(c.mul(lt(3,SP))),h.y.addAssign(lt(4,Fh(s).sub(u))),h.x.mulAssign(i),h.y.mulAssign(r),n.uv(h).grad(z(),z())}),wg=U(({envMap:n,mipInt:e,outputDirection:t,theta:i,axis:r,CUBEUV_TEXEL_WIDTH:s,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:o})=>{const l=br(i),c=t.mul(l).add(r.cross(t).mul(Ci(i))).add(r.mul(r.dot(t).mul(l.oneMinus())));return Sg(n,c,e,s,a,o)}),Pb=U(({n,latitudinal:e,poleAxis:t,outputDirection:i,weights:r,samples:s,dTheta:a,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:c,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:h})=>{const d=D(Ri(e,t,lo(t,i))).toVar();Le(Af(d.equals(D(0))),()=>{d.assign(D(i.z,0,i.x.negate()))}),d.assign(Mr(d));const p=D().toVar();return p.addAssign(r.element(P(0)).mul(wg({theta:0,axis:d,outputDirection:i,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:c,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:h}))),gt({start:P(1),end:n},({i:m})=>{Le(m.greaterThanEqual(s),()=>{Qh()});const v=E(a.mul(E(m))).toVar();p.addAssign(r.element(m).mul(wg({theta:v.mul(-1),axis:d,outputDirection:i,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:c,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:h}))),p.addAssign(r.element(m).mul(wg({theta:v,axis:d,outputDirection:i,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:c,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:h})))}),ae(p,1)});let ld=null;const Db=new WeakMap;function NP(n){const e=Math.log2(n)-2,t=1/n;return{texelWidth:1/(3*Math.max(Math.pow(2,e),7*16)),texelHeight:t,maxMip:e}}function CP(n){let e=Db.get(n);if((e!==void 0?e.pmremVersion:-1)!==n.pmremVersion){const t=n.image;if(n.isCubeTexture)if(RP(t))e=ld.fromCubemap(n,e);else return null;else if(IP(t))e=ld.fromEquirectangular(n,e);else return null;e.pmremVersion=n.pmremVersion,Db.set(n,e)}return e.texture}class Ub extends pt{static get type(){return"PMREMNode"}constructor(e,t=null,i=null){super("vec3"),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=i,this._generator=null;const r=new Wt;r.isRenderTargetTexture=!0,this._texture=yt(r),this._width=fe(0),this._height=fe(0),this._maxMip=fe(0),this.updateBeforeType=je.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){const t=NP(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(){let e=this._pmrem;const t=e?e.pmremVersion:-1,i=this._value;t!==i.pmremVersion&&(i.isPMREMTexture===!0?e=i:e=CP(i),e!==null&&(this._pmrem=e,this.updateFromTexture(e)))}setup(e){ld===null&&(ld=e.createPMREMGenerator()),this.updateBefore(e);let t=this.uvNode;t===null&&e.context.getUV&&(t=e.context.getUV(this));const i=this.value;e.renderer.coordinateSystem===Rr&&i.isPMREMTexture!==!0&&i.isRenderTargetTexture===!0&&(t=D(t.x.negate(),t.yz));let r=this.levelNode;return r===null&&e.context.getTextureLevel&&(r=e.context.getTextureLevel(this)),Lb(this._texture,t,r,this._width,this._height,this._maxMip)}}function RP(n){if(n==null)return!1;let e=0;const t=6;for(let i=0;i<t;i++)n[i]!==void 0&&e++;return e===t}function IP(n){return n==null?!1:n.height>0}const Ob=K(Ub),Fb=new WeakMap;class Vb extends ia{static get type(){return"EnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){const{material:t}=e;let i=this.envNode;if(i.isTextureNode||i.isMaterialReferenceNode){const h=i.isTextureNode?i.value:t[i.property];let d=Fb.get(h);d===void 0&&(d=Ob(h),Fb.set(h,d)),i=d}const r=t.envMap?fi("envMapIntensity","float",e.material):fi("environmentIntensity","float",e.scene),s=t.useAnisotropy===!0||t.anisotropy>0?i1:Yt,a=i.context(Bb(hn,s)).mul(r),o=i.context(LP(Xf)).mul(Math.PI).mul(r),l=Yl(a),c=Yl(o);e.context.radiance.addAssign(l),e.context.iblIrradiance.addAssign(c);const u=e.context.lightingModel.clearcoatRadiance;if(u){const h=i.context(Bb(Fl,ho)).mul(r),d=Yl(h);u.addAssign(d)}}}const Bb=(n,e)=>{let t=null;return{getUV:()=>(t===null&&(t=Vt.negate().reflect(e),t=n.mul(n).mix(t,e).normalize(),t=t.transformDirection(cr)),t),getTextureLevel:()=>n}},LP=n=>({getUV:()=>n,getTextureLevel:()=>E(1)}),PP=new wl;class zb extends bt{static get type(){return"MeshStandardNodeMaterial"}constructor(e){super(),this.isMeshStandardNodeMaterial=!0,this.lights=!0,this.emissiveNode=null,this.metalnessNode=null,this.roughnessNode=null,this.setDefaultValues(PP),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t===null&&e.environmentNode&&(t=e.environmentNode),t?new Vb(t):null}setupLightingModel(){return new nd}setupSpecular(){const e=rt(D(.04),Nt.rgb,Ol);or.assign(e),Bl.assign(1)}setupVariants(){const e=this.metalnessNode?E(this.metalnessNode):p1;Ol.assign(e);let t=this.roughnessNode?E(this.roughnessNode):d1;t=pg({roughness:t}),hn.assign(t),this.setupSpecular(),Nt.assign(ae(Nt.rgb.mul(e.oneMinus()),Nt.a))}copy(e){return this.emissiveNode=e.emissiveNode,this.metalnessNode=e.metalnessNode,this.roughnessNode=e.roughnessNode,super.copy(e)}}const DP=new lh;class kb extends zb{static get type(){return"MeshPhysicalNodeMaterial"}constructor(e){super(),this.isMeshPhysicalNodeMaterial=!0,this.clearcoatNode=null,this.clearcoatRoughnessNode=null,this.clearcoatNormalNode=null,this.sheenNode=null,this.sheenRoughnessNode=null,this.iridescenceNode=null,this.iridescenceIORNode=null,this.iridescenceThicknessNode=null,this.specularIntensityNode=null,this.specularColorNode=null,this.iorNode=null,this.transmissionNode=null,this.thicknessNode=null,this.attenuationDistanceNode=null,this.attenuationColorNode=null,this.dispersionNode=null,this.anisotropyNode=null,this.setDefaultValues(DP),this.setValues(e)}get useClearcoat(){return this.clearcoat>0||this.clearcoatNode!==null}get useIridescence(){return this.iridescence>0||this.iridescenceNode!==null}get useSheen(){return this.sheen>0||this.sheenNode!==null}get useAnisotropy(){return this.anisotropy>0||this.anisotropyNode!==null}get useTransmission(){return this.transmission>0||this.transmissionNode!==null}get useDispersion(){return this.dispersion>0||this.dispersionNode!==null}setupSpecular(){const e=this.iorNode?E(this.iorNode):A1;kl.assign(e),or.assign(rt(xi(Lf(kl.sub(1).div(kl.add(1))).mul(h1),D(1)).mul(Zf),Nt.rgb,Ol)),Bl.assign(rt(Zf,1,Ol))}setupLightingModel(){return new nd(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){const t=this.clearcoatNode?E(this.clearcoatNode):f1,i=this.clearcoatRoughnessNode?E(this.clearcoatRoughnessNode):g1;Ih.assign(t),Fl.assign(pg({roughness:i}))}if(this.useSheen){const t=this.sheenNode?D(this.sheenNode):x1,i=this.sheenRoughnessNode?E(this.sheenRoughnessNode):_1;Js.assign(t),Lh.assign(i)}if(this.useIridescence){const t=this.iridescenceNode?E(this.iridescenceNode):b1,i=this.iridescenceIORNode?E(this.iridescenceIORNode):T1,r=this.iridescenceThicknessNode?E(this.iridescenceThicknessNode):S1;Ph.assign(t),yf.assign(i),xf.assign(r)}if(this.useAnisotropy){const t=(this.anisotropyNode?z(this.anisotropyNode):M1).toVar();ls.assign(t.length()),Le(ls.equal(0),()=>{t.assign(z(1,0))}).Else(()=>{t.divAssign(z(ls)),ls.assign(ls.saturate())}),Dh.assign(ls.pow2().mix(hn.pow2(),1)),Vl.assign(ta[0].mul(t.x).add(ta[1].mul(t.y))),Ks.assign(ta[1].mul(t.x).sub(ta[0].mul(t.y)))}if(this.useTransmission){const t=this.transmissionNode?E(this.transmissionNode):w1,i=this.thicknessNode?E(this.thicknessNode):E1,r=this.attenuationDistanceNode?E(this.attenuationDistanceNode):N1,s=this.attenuationColorNode?D(this.attenuationColorNode):C1;if(Oh.assign(t),Mf.assign(i),bf.assign(r),Tf.assign(s),this.useDispersion){const a=this.dispersionNode?E(this.dispersionNode):I1;Sf.assign(a)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?D(this.clearcoatNormalNode):v1}setup(e){e.context.setupClearcoatNormal=()=>this.setupClearcoatNormal(e),super.setup(e)}copy(e){return this.clearcoatNode=e.clearcoatNode,this.clearcoatRoughnessNode=e.clearcoatRoughnessNode,this.clearcoatNormalNode=e.clearcoatNormalNode,this.sheenNode=e.sheenNode,this.sheenRoughnessNode=e.sheenRoughnessNode,this.iridescenceNode=e.iridescenceNode,this.iridescenceIORNode=e.iridescenceIORNode,this.iridescenceThicknessNode=e.iridescenceThicknessNode,this.specularIntensityNode=e.specularIntensityNode,this.specularColorNode=e.specularColorNode,this.transmissionNode=e.transmissionNode,this.thicknessNode=e.thicknessNode,this.attenuationDistanceNode=e.attenuationDistanceNode,this.attenuationColorNode=e.attenuationColorNode,this.dispersionNode=e.dispersionNode,this.anisotropyNode=e.anisotropyNode,super.copy(e)}}class UP extends nd{constructor(e,t,i,r){super(e,t,i),this.useSSS=r}direct({lightDirection:e,lightColor:t,reflectedLight:i},r,s){if(this.useSSS===!0){const a=s.material,{thicknessColorNode:o,thicknessDistortionNode:l,thicknessAmbientNode:c,thicknessAttenuationNode:u,thicknessPowerNode:h,thicknessScaleNode:d}=a,p=e.add(Yt.mul(l)).normalize(),m=E(Vt.dot(p.negate()).saturate().pow(h).mul(d)),v=D(m.add(c).mul(o));i.directDiffuse.addAssign(v.mul(u.mul(t)))}super.direct({lightDirection:e,lightColor:t,reflectedLight:i},r,s)}}class OP extends kb{static get type(){return"MeshSSSNodeMaterial"}constructor(e){super(e),this.thicknessColorNode=null,this.thicknessDistortionNode=E(.1),this.thicknessAmbientNode=E(0),this.thicknessAttenuationNode=E(.1),this.thicknessPowerNode=E(2),this.thicknessScaleNode=E(10)}get useSSS(){return this.thicknessColorNode!==null}setupLightingModel(){return new UP(this.useClearcoat,this.useSheen,this.useIridescence,this.useSSS)}copy(e){return this.thicknessColorNode=e.thicknessColorNode,this.thicknessDistortionNode=e.thicknessDistortionNode,this.thicknessAmbientNode=e.thicknessAmbientNode,this.thicknessAttenuationNode=e.thicknessAttenuationNode,this.thicknessPowerNode=e.thicknessPowerNode,this.thicknessScaleNode=e.thicknessScaleNode,super.copy(e)}}const FP=U(({normal:n,lightDirection:e,builder:t})=>{const i=n.dot(e),r=z(i.mul(.5).add(.5),0);if(t.material.gradientMap){const s=rn("gradientMap","texture").context({getUV:()=>r});return D(s.r)}else{const s=r.fwidth().mul(.5);return rt(D(.7),D(1),Ki(E(.7).sub(s.x),E(.7).add(s.x),r.x))}});class VP extends cc{direct({lightDirection:e,lightColor:t,reflectedLight:i},r,s){const a=FP({normal:Wh,lightDirection:e,builder:s}).mul(t);i.directDiffuse.addAssign(a.mul(ra({diffuseColor:Nt.rgb})))}indirect({ambientOcclusion:e,irradiance:t,reflectedLight:i}){i.indirectDiffuse.addAssign(t.mul(ra({diffuseColor:Nt}))),i.indirectDiffuse.mulAssign(e)}}const BP=new Cm;class zP extends bt{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(BP),this.setValues(e)}setupLightingModel(){return new VP}}class Hb extends pt{static get type(){return"MatcapUVNode"}constructor(){super("vec2")}setup(){const e=D(Vt.z,0,Vt.x.negate()).normalize(),t=Vt.cross(e);return z(e.dot(Yt),t.dot(Yt)).mul(.495).add(.5)}}const Gb=ge(Hb),kP=new Rm;class HP extends bt{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.lights=!1,this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(kP),this.setValues(e)}setupVariants(e){const t=Gb;let i;e.material.matcap?i=rn("matcap","texture").context({getUV:()=>t}):i=D(rt(.2,.8,t.y)),Nt.rgb.mulAssign(i.rgb)}}const GP=new Ka;class WP extends bt{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.isPointsNodeMaterial=!0,this.lights=!1,this.transparent=!0,this.sizeNode=null,this.setDefaultValues(GP),this.setValues(e)}copy(e){return this.sizeNode=e.sizeNode,super.copy(e)}}class Wb extends pt{static get type(){return"RotateNode"}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}getNodeType(e){return this.positionNode.getNodeType(e)}setup(e){const{rotationNode:t,positionNode:i}=this;if(this.getNodeType(e)==="vec2"){const r=t.cos(),s=t.sin();return Ul(r,s,s.negate(),r).mul(i)}else{const r=t,s=Ys(ae(1,0,0,0),ae(0,br(r.x),Ci(r.x).negate(),0),ae(0,Ci(r.x),br(r.x),0),ae(0,0,0,1)),a=Ys(ae(br(r.y),0,Ci(r.y),0),ae(0,1,0,0),ae(Ci(r.y).negate(),0,br(r.y),0),ae(0,0,0,1)),o=Ys(ae(br(r.z),Ci(r.z).negate(),0,0),ae(Ci(r.z),br(r.z),0,0),ae(0,0,1,0),ae(0,0,0,1));return s.mul(a).mul(o).mul(ae(i,1)).xyz}}}const Eg=K(Wb),jP=new ul;class XP extends bt{static get type(){return"SpriteNodeMaterial"}constructor(e){super(),this.isSpriteNodeMaterial=!0,this.lights=!1,this._useSizeAttenuation=!0,this.positionNode=null,this.rotationNode=null,this.scaleNode=null,this.setDefaultValues(jP),this.setValues(e)}setupPosition({object:e,camera:t,context:i}){const r=this.sizeAttenuation,{positionNode:s,rotationNode:a,scaleNode:o}=this,l=Zt;let c=pn.mul(D(s||0)),u=z(Br[0].xyz.length(),Br[1].xyz.length());o!==null&&(u=u.mul(o)),!r&&t.isPerspectiveCamera&&(u=u.mul(c.z.negate()));let h=l.xy;if(e.center&&e.center.isVector2===!0){const v=G2("center","vec2");h=h.sub(v.sub(.5))}h=h.mul(u);const d=E(a||y1),p=Eg(h,d);c=ae(c.xy.add(p),c.zw);const m=lr.mul(c);return i.vertex=l,m}copy(e){return this.positionNode=e.positionNode,this.rotationNode=e.rotationNode,this.scaleNode=e.scaleNode,super.copy(e)}get sizeAttenuation(){return this._useSizeAttenuation}set sizeAttenuation(e){this._useSizeAttenuation!==e&&(this._useSizeAttenuation=e,this.needsUpdate=!0)}}class qP extends cc{constructor(){super(),this.shadowNode=E(1).toVar("shadowMask")}direct({shadowMask:e}){this.shadowNode.mulAssign(e)}finish(e){Nt.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(Nt.rgb)}}const YP=new oh;class $P extends bt{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.setDefaultValues(YP),this.setValues(e)}setupLightingModel(){return new qP}}const JP=U(({texture:n,uv:e})=>{const t=D().toVar();return Le(e.x.lessThan(1e-4),()=>{t.assign(D(1,0,0))}).ElseIf(e.y.lessThan(1e-4),()=>{t.assign(D(0,1,0))}).ElseIf(e.z.lessThan(1e-4),()=>{t.assign(D(0,0,1))}).ElseIf(e.x.greaterThan(1-1e-4),()=>{t.assign(D(-1,0,0))}).ElseIf(e.y.greaterThan(1-1e-4),()=>{t.assign(D(0,-1,0))}).ElseIf(e.z.greaterThan(1-1e-4),()=>{t.assign(D(0,0,-1))}).Else(()=>{const i=n.uv(e.add(D(-.01,0,0))).r.sub(n.uv(e.add(D(.01,0,0))).r),r=n.uv(e.add(D(0,-.01,0))).r.sub(n.uv(e.add(D(0,.01,0))).r),s=n.uv(e.add(D(0,0,-.01))).r.sub(n.uv(e.add(D(0,0,.01))).r);t.assign(D(i,r,s))}),t.normalize()});class jb extends dn{static get type(){return"Texture3DNode"}constructor(e,t=null,i=null){super(e,t,i),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return D(.5,.5,.5)}setUpdateMatrix(){}setupUV(e,t){return t}generateUV(e,t){return t.build(e,"vec3")}normal(e){return JP({texture:this,uv:e})}}const Xb=K(jb);class KP extends bt{static get type(){return"VolumeNodeMaterial"}constructor(e={}){super(),this.lights=!1,this.isVolumeNodeMaterial=!0,this.testNode=null,this.setValues(e)}setup(e){const t=Xb(this.map,null,0),i=U(({orig:r,dir:s})=>{const a=D(-.5),o=D(.5),l=s.reciprocal(),c=a.sub(r).mul(l),u=o.sub(r).mul(l),h=xi(c,u),d=ft(c,u),p=ft(h.x,ft(h.y,h.z)),m=xi(d.x,xi(d.y,d.z));return z(p,m)});this.fragmentNode=U(()=>{const r=Ii(D(zM.mul(ae(Wf,1)))),s=Ii(Li.sub(r)).normalize(),a=z(i({orig:r,dir:s})).toVar();a.x.greaterThan(a.y).discard(),a.assign(z(ft(a.x,0),a.y));const o=D(r.add(a.x.mul(s))).toVar(),l=D(s.abs().reciprocal()).toVar(),c=E(xi(l.x,xi(l.y,l.z))).toVar("delta");c.divAssign(rn("steps","float"));const u=ae(rn("base","color"),0).toVar();return gt({type:"float",start:a.x,end:a.y,update:"+= delta"},()=>{const h=ar("float","d").assign(t.uv(o.add(.5)).r);this.testNode!==null?this.testNode({map:t,mapValue:h,probe:o,finalColor:u}).append():(u.a.assign(1),Qh()),o.addAssign(s.mul(c))}),u.a.equal(0).discard(),ae(u)})(),super.setup(e)}}class qb extends Hi{constructor(e){super(e),this.textures={},this.nodes={}}load(e,t,i,r){const s=new Kr(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,a=>{try{t(this.parse(JSON.parse(a)))}catch(o){r?r(o):console.error(o),this.manager.itemError(e)}},i,r)}parseNodes(e){const t={};if(e!==void 0){for(const r of e){const{uuid:s,type:a}=r;t[s]=this.createNodeFromType(a),t[s].uuid=s}const i={nodes:t,textures:this.textures};for(const r of e)r.meta=i,t[r.uuid].deserialize(r),delete r.meta}return t}parse(e){const t=this.createNodeFromType(e.type);t.uuid=e.uuid;const i={nodes:this.parseNodes(e.nodes),textures:this.textures};return e.meta=i,t.deserialize(e),delete e.meta,t}setTextures(e){return this.textures=e,this}setNodes(e){return this.nodes=e,this}createNodeFromType(e){return this.nodes[e]===void 0?(console.error("THREE.NodeLoader: Node type not found:",e),E()):G(new this.nodes[e])}}class Yb extends Mc{constructor(e){super(e),this.nodes={},this.nodeMaterials={}}parse(e){const t=super.parse(e),i=this.nodes,r=e.inputNodes;for(const s in r){const a=r[s];t[s]=i[a]}return t}setNodes(e){return this.nodes=e,this}setNodeMaterials(e){return this.nodeMaterials=e,this}createMaterialFromType(e){const t=this.nodeMaterials[e];return t!==void 0?new t:super.createMaterialFromType(e)}}class ZP extends sx{constructor(e){super(e),this.nodes={},this.nodeMaterials={},this._nodesJSON=null}setNodes(e){return this.nodes=e,this}setNodeMaterials(e){return this.nodeMaterials=e,this}parse(e,t){this._nodesJSON=e.nodes;const i=super.parse(e,t);return this._nodesJSON=null,i}parseNodes(e,t){if(e!==void 0){const i=new qb;return i.setNodes(this.nodes),i.setTextures(t),i.parseNodes(e)}return{}}parseMaterials(e,t){const i={};if(e!==void 0){const r=this.parseNodes(this._nodesJSON,t),s=new Yb;s.setTextures(t),s.setNodes(r),s.setNodeMaterials(this.nodeMaterials);for(let a=0,o=e.length;a<o;a++){const l=e[a];i[l.uuid]=s.parse(l)}}return i}}class Ag{constructor(e,t,i=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=i}}class $b{constructor(e,t,i){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=i.getSelf()}get value(){return this.node.value}set value(e){this.node.value=e}get id(){return this.node.id}get groupNode(){return this.node.groupNode}}class Ng{constructor(e,t){this.isNodeVar=!0,this.name=e,this.type=t}}class Jb extends Ng{constructor(e,t){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0}}class Kb{constructor(e,t,i=""){this.name=e,this.type=t,this.code=i,Object.defineProperty(this,"isNodeCode",{value:!0})}}let QP=0;class cd{constructor(e=null){this.id=QP++,this.nodesData=new WeakMap,this.parent=e}getData(e){let t=this.nodesData.get(e);return t===void 0&&this.parent!==null&&(t=this.parent.getData(e)),t}setData(e,t){this.nodesData.set(e,t)}}class Cg extends Et{static get type(){return"ParameterNode"}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getHash(){return this.uuid}generate(){return this.name}}const e3=(n,e)=>G(new Cg(n,e));class Rg extends qe{static get type(){return"CodeNode"}constructor(e="",t=[],i=""){super("code"),this.isCodeNode=!0,this.code=e,this.language=i,this.includes=t}isGlobal(){return!0}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){const t=this.getIncludes(e);for(const r of t)r.build(e);const i=e.getCodeFromNode(this,this.getNodeType(e));return i.code=this.code,i.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}}const ud=K(Rg),t3=(n,e)=>ud(n,e,"js"),i3=(n,e)=>ud(n,e,"wgsl"),r3=(n,e)=>ud(n,e,"glsl");class Ig extends Rg{static get type(){return"FunctionNode"}constructor(e="",t=[],i=""){super(e,t,i)}getNodeType(e){return this.getNodeFunction(e).type}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){const t=e.getDataFromNode(this);let i=t.nodeFunction;return i===void 0&&(i=e.parser.parseFunction(this.code),t.nodeFunction=i),i}generate(e,t){super.generate(e);const i=this.getNodeFunction(e),r=i.name,s=i.type,a=e.getCodeFromNode(this,s);r!==""&&(a.name=r);const o=e.getPropertyName(a),l=this.getNodeFunction(e).getCode(o);return a.code=l+`
|
|
3867
|
-
`,t==="property"?o:e.format(`${o}()`,s,t)}}const Zb=(n,e=[],t="")=>{for(let s=0;s<e.length;s++){const a=e[s];typeof a=="function"&&(e[s]=a.functionNode)}const i=G(new Ig(n,e,t)),r=(...s)=>i.call(...s);return r.functionNode=i,r},n3=(n,e)=>Zb(n,e,"glsl"),s3=(n,e)=>Zb(n,e,"wgsl");class na{constructor(e,t){this.name=e,this.value=t,this.boundary=0,this.itemSize=0,this.offset=0}setValue(e){this.value=e}getValue(){return this.value}}class a3 extends na{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class o3 extends na{constructor(e,t=new J){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class l3 extends na{constructor(e,t=new N){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class c3 extends na{constructor(e,t=new st){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class u3 extends na{constructor(e,t=new xe){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class h3 extends na{constructor(e,t=new Ke){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class d3 extends na{constructor(e,t=new Re){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class p3 extends a3{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class m3 extends o3{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class f3 extends l3{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class g3 extends c3{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class v3 extends u3{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class y3 extends h3{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class x3 extends d3{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class Qb extends qe{static get type(){return"StackNode"}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this.isStackNode=!0}getNodeType(e){return this.outputNode?this.outputNode.getNodeType(e):"void"}add(e){return this.nodes.push(e),this}If(e,t){const i=new Ll(t);return this._currentCond=Ri(e,i),this.add(this._currentCond)}ElseIf(e,t){const i=new Ll(t),r=Ri(e,i);return this._currentCond.elseNode=r,this._currentCond=r,this}Else(e){return this._currentCond.elseNode=new Ll(e),this}build(e,...t){const i=pf();Dl(this);for(const r of this.nodes)r.build(e,"void");return Dl(i),this.outputNode?this.outputNode.build(e,...t):super.build(e,...t)}else(...e){return console.warn("TSL.StackNode: .else() has been renamed to .Else()."),this.Else(...e)}elseif(...e){return console.warn("TSL.StackNode: .elseif() has been renamed to .ElseIf()."),this.ElseIf(...e)}}const hd=K(Qb);class _3{constructor(){this.weakMap=new WeakMap}get(e){let t=this.weakMap;for(let i=0;i<e.length;i++)if(t=t.get(e[i]),t===void 0)return;return t.get(e[e.length-1])}set(e,t){let i=this.weakMap;for(let r=0;r<e.length;r++){const s=e[r];i.has(s)===!1&&i.set(s,new WeakMap),i=i.get(s)}return i.set(e[e.length-1],t)}delete(e){let t=this.weakMap;for(let i=0;i<e.length;i++)if(t=t.get(e[i]),t===void 0)return!1;return t.delete(e[e.length-1])}}const yo=4,eT=[.125,.215,.35,.446,.526,.582],sa=20,Lg=new Ls(-1,1,1,-1,0,1),M3=new di(90,1),tT=new xe;let Pg=null,Dg=0,Ug=0;const aa=(1+Math.sqrt(5))/2,xo=1/aa,iT=[new N(-aa,xo,0),new N(aa,xo,0),new N(-xo,0,aa),new N(xo,0,aa),new N(0,aa,-xo),new N(0,aa,xo),new N(-1,1,-1),new N(1,1,-1),new N(-1,1,1),new N(1,1,1)],b3=[3,1,5,0,4,2],Og=Ib(nt(),_i("faceIndex")).normalize(),Fg=D(Og.x,Og.y.negate(),Og.z);class T3{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}fromScene(e,t=0,i=.1,r=100){Pg=this._renderer.getRenderTarget(),Dg=this._renderer.getActiveCubeFace(),Ug=this._renderer.getActiveMipmapLevel(),this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,i,r,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}async compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=nT(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=sT(),await this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(Pg,Dg,Ug),e.scissorTest=!1,dd(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===fr||e.mapping===Ar?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Pg=this._renderer.getRenderTarget(),Dg=this._renderer.getActiveCubeFace(),Ug=this._renderer.getActiveMipmapLevel();const i=t||this._allocateTargets();return this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,i={magFilter:Lt,minFilter:Lt,generateMipmaps:!1,type:wi,format:Ei,colorSpace:nr},r=rT(e,t,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=rT(e,t,i);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas,lodMeshes:this._lodMeshes}=S3(s)),this._blurMaterial=w3(s,e,t)}return r}async _compileMaterial(e){const t=new Ft(this._lodPlanes[0],e);await this._renderer.compile(t,Lg)}_sceneToCubeUV(e,t,i,r){const s=M3;s.near=t,s.far=i;const a=[-1,1,-1,-1,-1,-1],o=[1,1,1,-1,-1,-1],l=this._renderer,c=l.autoClear;l.getClearColor(tT),l.autoClear=!1;let u=this._backgroundBox;if(u===null){const p=new Yr({name:"PMREM.Background",side:si,depthWrite:!1,depthTest:!1});u=new Ft(new yn,p)}let h=!1;const d=e.background;d?d.isColor&&(u.material.color.copy(d),e.background=null,h=!0):(u.material.color.copy(tT),h=!0),l.setRenderTarget(r),l.clear(),h&&l.render(u,s);for(let p=0;p<6;p++){const m=p%3;m===0?(s.up.set(0,a[p],0),s.lookAt(o[p],0,0)):m===1?(s.up.set(0,0,a[p]),s.lookAt(0,o[p],0)):(s.up.set(0,a[p],0),s.lookAt(0,0,o[p]));const v=this._cubeSize;dd(r,m*v,p>2?v:0,v,v),l.render(e,s)}l.autoClear=c,e.background=d}_textureToCubeUV(e,t){const i=this._renderer,r=e.mapping===fr||e.mapping===Ar;r?this._cubemapMaterial===null&&(this._cubemapMaterial=nT(e)):this._equirectMaterial===null&&(this._equirectMaterial=sT(e));const s=r?this._cubemapMaterial:this._equirectMaterial;s.fragmentNode.value=e;const a=this._lodMeshes[0];a.material=s;const o=this._cubeSize;dd(t,0,0,3*o,2*o),i.setRenderTarget(t),i.render(a,Lg)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;const r=this._lodPlanes.length;for(let s=1;s<r;s++){const a=Math.sqrt(this._sigmas[s]*this._sigmas[s]-this._sigmas[s-1]*this._sigmas[s-1]),o=iT[(r-s-1)%iT.length];this._blur(e,s-1,s,a,o)}t.autoClear=i}_blur(e,t,i,r,s){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,i,r,"latitudinal",s),this._halfBlur(a,e,i,i,r,"longitudinal",s)}_halfBlur(e,t,i,r,s,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const u=3,h=this._lodMeshes[r];h.material=c;const d=c.uniforms,p=this._sizeLods[i]-1,m=isFinite(s)?Math.PI/(2*p):2*Math.PI/(2*sa-1),v=s/m,f=isFinite(s)?1+Math.floor(u*v):sa;f>sa&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${f} samples when the maximum is set to ${sa}`);const g=[];let x=0;for(let w=0;w<sa;++w){const C=w/v,H=Math.exp(-C*C/2);g.push(H),w===0?x+=H:w<f&&(x+=2*H)}for(let w=0;w<g.length;w++)g[w]=g[w]/x;e.texture.frame=(e.texture.frame||0)+1,d.envMap.value=e.texture,d.samples.value=f,d.weights.array=g,d.latitudinal.value=a==="latitudinal"?1:0,o&&(d.poleAxis.value=o);const{_lodMax:y}=this;d.dTheta.value=m,d.mipInt.value=y-i;const _=this._sizeLods[r],I=3*_*(r>y-yo?r-y+yo:0),b=4*(this._cubeSize-_);dd(t,I,b,3*_,2*_),l.setRenderTarget(t),l.render(h,Lg)}}function S3(n){const e=[],t=[],i=[],r=[];let s=n;const a=n-yo+1+eT.length;for(let o=0;o<a;o++){const l=Math.pow(2,s);t.push(l);let c=1/l;o>n-yo?c=eT[o-n+yo-1]:o===0&&(c=0),i.push(c);const u=1/(l-2),h=-u,d=1+u,p=[h,h,d,h,d,d,h,h,d,d,h,d],m=6,v=6,f=3,g=2,x=1,y=new Float32Array(f*v*m),_=new Float32Array(g*v*m),I=new Float32Array(x*v*m);for(let w=0;w<m;w++){const C=w%3*2/3-1,H=w>2?0:-1,M=[C,H,0,C+2/3,H,0,C+2/3,H+1,0,C,H,0,C+2/3,H+1,0,C,H+1,0],T=b3[w];y.set(M,f*v*T),_.set(p,g*v*T);const k=[T,T,T,T,T,T];I.set(k,x*v*T)}const b=new ct;b.setAttribute("position",new wt(y,f)),b.setAttribute("uv",new wt(_,g)),b.setAttribute("faceIndex",new wt(I,x)),e.push(b),r.push(new Ft(b,null)),s>yo&&s--}return{lodPlanes:e,sizeLods:t,sigmas:i,lodMeshes:r}}function rT(n,e,t){const i=new ui(n,e,t);return i.texture.mapping=xs,i.texture.name="PMREM.cubeUv",i.texture.isPMREMTexture=!0,i.scissorTest=!0,i}function dd(n,e,t,i,r){n.viewport.set(e,t,i,r),n.scissor.set(e,t,i,r)}function Vg(n){const e=new bt;return e.depthTest=!1,e.depthWrite=!1,e.blending=Er,e.name=`PMREM_${n}`,e}function w3(n,e,t){const i=mn(new Array(sa).fill(0)),r=fe(new N(0,1,0)),s=fe(0),a=E(sa),o=fe(0),l=fe(1),c=yt(null),u=fe(0),h=E(1/e),d=E(1/t),p=E(n),m={n:a,latitudinal:o,weights:i,poleAxis:r,outputDirection:Fg,dTheta:s,samples:l,envMap:c,mipInt:u,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:p},v=Vg("blur");return v.uniforms=m,v.fragmentNode=Pb({...m,latitudinal:o.equal(1)}),v}function nT(n){const e=Vg("cubemap");return e.fragmentNode=Xh(n,Fg),e}function sT(n){const e=Vg("equirect");return e.fragmentNode=yt(n,hg(Fg),0),e}let E3=0;class aT{constructor(e="",t=[],i=0,r=[]){this.name=e,this.bindings=t,this.index=i,this.bindingsReference=r,this.id=E3++}}const oT=new WeakMap,A3=new Map([[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),N3=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),pd=n=>(n=Number(n),n+(n%1?"":".0"));class lT{constructor(e,t,i){this.object=e,this.material=e&&e.material||null,this.geometry=e&&e.geometry||null,this.renderer=t,this.parser=i,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=hd(),this.stacks=[],this.tab=" ",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new cd,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null,this.useComparisonMethod=!1}getBindGroupsCache(){let e=oT.get(this.renderer);return e===void 0&&(e=new _3,oT.set(this.renderer,e)),e}createRenderTarget(e,t,i){return new ui(e,t,i)}createCubeRenderTarget(e,t){return new ab(e,t)}createPMREMGenerator(){return new T3(this.renderer)}includes(e){return this.nodes.includes(e)}_getBindGroup(e,t){const i=this.getBindGroupsCache(),r=[];let s=!0;for(const o of t)r.push(o),s=s&&o.groupNode.shared!==!0;let a;return s?(a=i.get(r),a===void 0&&(a=new aT(e,r,this.bindingsIndexes[e].group,r),i.set(r,a))):a=new aT(e,r,this.bindingsIndexes[e].group,r),a}getBindGroupArray(e,t){const i=this.bindings[t];let r=i[e];return r===void 0&&(this.bindingsIndexes[e]===void 0&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),i[e]=r=[]),r}getBindings(){let e=this.bindGroups;if(e===null){const t={},i=this.bindings;for(const r of sf)for(const s in i[r]){const a=i[r][s];(t[s]||(t[s]=[])).push(...a)}e=[];for(const r in t){const s=t[r],a=this._getBindGroup(r,s);e.push(a)}this.bindGroups=e}return e}sortBindingGroups(){const e=this.getBindings();e.sort((t,i)=>t.bindings[0].groupNode.order-i.bindings[0].groupNode.order);for(let t=0;t<e.length;t++){const i=e[t];this.bindingsIndexes[i.name].group=t,i.index=t}}setHashNode(e,t){this.hashNodes[t]=e}addNode(e){this.nodes.includes(e)===!1&&(this.nodes.push(e),this.setHashNode(e,e.getHash(this)))}buildUpdateNodes(){for(const e of this.nodes){const t=e.getUpdateType(),i=e.getUpdateBeforeType(),r=e.getUpdateAfterType();t!==je.NONE&&this.updateNodes.push(e.getSelf()),i!==je.NONE&&this.updateBeforeNodes.push(e.getSelf()),r!==je.NONE&&this.updateAfterNodes.push(e.getSelf())}}get currentNode(){return this.chaining[this.chaining.length-1]}isFilteredTexture(e){return e.magFilter===Lt||e.magFilter===Wn||e.magFilter===Mn||e.magFilter===ji||e.minFilter===Lt||e.minFilter===Wn||e.minFilter===Mn||e.minFilter===ji}addChain(e){this.chaining.push(e)}removeChain(e){if(this.chaining.pop()!==e)throw new Error("NodeBuilder: Invalid node chaining!")}getMethod(e){return e}getNodeFromHash(e){return this.hashNodes[e]}addFlow(e,t){return this.flowNodes[e].push(t),t}setContext(e){this.context=e}getContext(){return this.context}getSharedContext(){return{...this.context},this.context}setCache(e){this.cache=e}getCache(){return this.cache}getCacheFromNode(e,t=!0){const i=this.getDataFromNode(e);return i.cache===void 0&&(i.cache=new cd(t?this.getCache():null)),i.cache}isAvailable(){return!1}getVertexIndex(){console.warn("Abstract function.")}getInstanceIndex(){console.warn("Abstract function.")}getDrawIndex(){console.warn("Abstract function.")}getFrontFacing(){console.warn("Abstract function.")}getFragCoord(){console.warn("Abstract function.")}isFlipY(){return!1}increaseUsage(e){const t=this.getDataFromNode(e);return t.usageCount=t.usageCount===void 0?1:t.usageCount+1,t.usageCount}generateTexture(){console.warn("Abstract function.")}generateTextureLod(){console.warn("Abstract function.")}generateConst(e,t=null){if(t===null&&(e==="float"||e==="int"||e==="uint"?t=0:e==="bool"?t=!1:e==="color"?t=new xe:e==="vec2"?t=new J:e==="vec3"?t=new N:e==="vec4"&&(t=new st)),e==="float")return pd(t);if(e==="int")return`${Math.round(t)}`;if(e==="uint")return t>=0?`${Math.round(t)}u`:"0u";if(e==="bool")return t?"true":"false";if(e==="color")return`${this.getType("vec3")}( ${pd(t.r)}, ${pd(t.g)}, ${pd(t.b)} )`;const i=this.getTypeLength(e),r=this.getComponentType(e),s=a=>this.generateConst(r,a);if(i===2)return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)} )`;if(i===3)return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)}, ${s(t.z)} )`;if(i===4)return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)}, ${s(t.z)}, ${s(t.w)} )`;if(i>4&&t&&(t.isMatrix3||t.isMatrix4))return`${this.getType(e)}( ${t.elements.map(s).join(", ")} )`;if(i>4)return`${this.getType(e)}()`;throw new Error(`NodeBuilder: Type '${e}' not found in generate constant attempt.`)}getType(e){return e==="color"?"vec3":e}hasGeometryAttribute(e){return this.geometry&&this.geometry.getAttribute(e)!==void 0}getAttribute(e,t){const i=this.attributes;for(const s of i)if(s.name===e)return s;const r=new Ag(e,t);return i.push(r),r}getPropertyName(e){return e.name}isVector(e){return/vec\d/.test(e)}isMatrix(e){return/mat\d/.test(e)}isReference(e){return e==="void"||e==="property"||e==="sampler"||e==="texture"||e==="cubeTexture"||e==="storageTexture"||e==="depthTexture"||e==="texture3D"}needsToWorkingColorSpace(){return!1}getComponentTypeFromTexture(e){const t=e.type;if(e.isDataTexture){if(t===va)return"int";if(t===Nr)return"uint"}return"float"}getElementType(e){return e==="mat2"?"vec2":e==="mat3"?"vec3":e==="mat4"?"vec4":this.getComponentType(e)}getComponentType(e){if(e=this.getVectorType(e),e==="float"||e==="bool"||e==="int"||e==="uint")return e;const t=/(b|i|u|)(vec|mat)([2-4])/.exec(e);return t===null?null:t[1]==="b"?"bool":t[1]==="i"?"int":t[1]==="u"?"uint":"float"}getVectorType(e){return e==="color"?"vec3":e==="texture"||e==="cubeTexture"||e==="storageTexture"||e==="texture3D"?"vec4":e}getTypeFromLength(e,t="float"){if(e===1)return t;const i=A3.get(e);return(t==="float"?"":t[0])+i}getTypeFromArray(e){return N3.get(e.constructor)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);const i=t.array,r=e.itemSize,s=e.normalized;let a;return!(e instanceof Ev)&&s!==!0&&(a=this.getTypeFromArray(i)),this.getTypeFromLength(r,a)}getTypeLength(e){const t=this.getVectorType(e),i=/vec([2-4])/.exec(t);return i!==null?Number(i[1]):t==="float"||t==="bool"||t==="int"||t==="uint"?1:/mat2/.test(e)===!0?4:/mat3/.test(e)===!0?9:/mat4/.test(e)===!0?16:0}getVectorFromMatrix(e){return e.replace("mat","vec")}changeComponentType(e,t){return this.getTypeFromLength(this.getTypeLength(e),t)}getIntegerType(e){const t=this.getComponentType(e);return t==="int"||t==="uint"?e:this.changeComponentType(e,"int")}addStack(){return this.stack=hd(this.stack),this.stacks.push(pf()||this.stack),Dl(this.stack),this.stack}removeStack(){const e=this.stack;return this.stack=e.parent,Dl(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,i=null){i=i===null?e.isGlobal(this)?this.globalCache:this.cache:i;let r=i.getData(e);return r===void 0&&(r={},i.setData(e,r)),r[t]===void 0&&(r[t]={}),r[t]}getNodeProperties(e,t="any"){const i=this.getDataFromNode(e,t);return i.properties||(i.properties={outputNode:null})}getBufferAttributeFromNode(e,t){const i=this.getDataFromNode(e);let r=i.bufferAttribute;if(r===void 0){const s=this.uniforms.index++;r=new Ag("nodeAttribute"+s,t,e),this.bufferAttributes.push(r),i.bufferAttribute=r}return r}getStructTypeFromNode(e,t=this.shaderStage){const i=this.getDataFromNode(e,t);if(i.structType===void 0){const r=this.structs.index++;e.name=`StructType${r}`,this.structs[t].push(e),i.structType=e}return e}getUniformFromNode(e,t,i=this.shaderStage,r=null){r==="in"&&(console.warn('NodeBuilder: "in" is a reserved word, using "inValue" instead.',e,r),e.name="inValue",r=e.name);const s=this.getDataFromNode(e,i,this.globalCache);let a=s.uniform;if(a===void 0){const o=this.uniforms.index++;a=new $b(r||"nodeUniform"+o,t,e),this.uniforms[i].push(a),s.uniform=a}return a}getVarFromNode(e,t=null,i=e.getNodeType(this),r=this.shaderStage){const s=this.getDataFromNode(e,r);let a=s.variable;if(a===void 0){const o=this.vars[r]||(this.vars[r]=[]);t===null&&(t="nodeVar"+o.length),a=new Ng(t,i),o.push(a),s.variable=a}return a}getVaryingFromNode(e,t=null,i=e.getNodeType(this)){const r=this.getDataFromNode(e,"any");let s=r.varying;if(s===void 0){const a=this.varyings,o=a.length;t===null&&(t="nodeVarying"+o),s=new Jb(t,i),a.push(s),r.varying=s}return s}getCodeFromNode(e,t,i=this.shaderStage){const r=this.getDataFromNode(e);let s=r.code;if(s===void 0){const a=this.codes[i]||(this.codes[i]=[]),o=a.length;s=new Kb("nodeCode"+o,t),a.push(s),r.code=s}return s}addFlowCodeHierarchy(e,t){const{flowCodes:i,flowCodeBlock:r}=this.getDataFromNode(e);let s=!0,a=t;for(;a;){if(r.get(a)===!0){s=!1;break}a=this.getDataFromNode(a).parentNodeBlock}if(s)for(const o of i)this.addLineFlowCode(o)}addLineFlowCodeBlock(e,t,i){const r=this.getDataFromNode(e),s=r.flowCodes||(r.flowCodes=[]),a=r.flowCodeBlock||(r.flowCodeBlock=new WeakMap);s.push(t),a.set(i,!0)}addLineFlowCode(e,t=null){return e===""?this:(t!==null&&this.context.nodeBlock&&this.addLineFlowCodeBlock(t,e,this.context.nodeBlock),e=this.tab+e,/;\s*$/.test(e)||(e=e+`;
|
|
3868
|
-
`),this.flow.code+=e,this)}addFlowCode(e){return this.flow.code+=e,this}addFlowTab(){return this.tab+=" ",this}removeFlowTab(){return this.tab=this.tab.slice(0,-1),this}getFlowData(e){return this.flowsData.get(e)}flowNode(e){const t=e.getNodeType(this),i=this.flowChildNode(e,t);return this.flowsData.set(e,i),i}buildFunctionNode(e){const t=new
|
|
3866
|
+
`).removeFlowTab();return e.addFlowTab(),a}}const gt=(...n)=>G(new k1(Xs(n,"int"))).append(),TL=()=>us("continue").append(),Zh=()=>us("break").append(),SL=(...n)=>(console.warn("TSL.LoopNode: loop() has been renamed to Loop()."),gt(...n)),ng=new WeakMap,Tr=new st,H1=U(({bufferMap:n,influence:e,stride:t,width:i,depth:r,offset:s})=>{const a=P(P1).mul(t).add(s),o=a.div(i),l=a.sub(o.mul(i));return Vr(n,un(l,o)).depth(r).mul(e)});function wL(n){const e=n.morphAttributes.position!==void 0,t=n.morphAttributes.normal!==void 0,i=n.morphAttributes.color!==void 0,r=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,s=r!==void 0?r.length:0;let a=ng.get(n);if(a===void 0||a.count!==s){let o=function(){f.dispose(),ng.delete(n),n.removeEventListener("dispose",o)};a!==void 0&&a.texture.dispose();const l=n.morphAttributes.position||[],c=n.morphAttributes.normal||[],u=n.morphAttributes.color||[];let h=0;e===!0&&(h=1),t===!0&&(h=2),i===!0&&(h=3);let d=n.attributes.position.count*h,p=1;const m=4096;d>m&&(p=Math.ceil(d/m),d=m);const v=new Float32Array(d*p*4*s),f=new el(v,d,p,s);f.type=Oi,f.needsUpdate=!0;const g=h*4;for(let x=0;x<s;x++){const y=l[x],_=c[x],I=u[x],b=d*p*4*x;for(let w=0;w<y.count;w++){const C=w*g;e===!0&&(Tr.fromBufferAttribute(y,w),v[b+C+0]=Tr.x,v[b+C+1]=Tr.y,v[b+C+2]=Tr.z,v[b+C+3]=0),t===!0&&(Tr.fromBufferAttribute(_,w),v[b+C+4]=Tr.x,v[b+C+5]=Tr.y,v[b+C+6]=Tr.z,v[b+C+7]=0),i===!0&&(Tr.fromBufferAttribute(I,w),v[b+C+8]=Tr.x,v[b+C+9]=Tr.y,v[b+C+10]=Tr.z,v[b+C+11]=I.itemSize===4?Tr.w:1)}}a={count:s,texture:f,stride:h,size:new J(d,p)},ng.set(n,a),n.addEventListener("dispose",o)}return a}class G1 extends qe{static get type(){return"MorphNode"}constructor(e){super("void"),this.mesh=e,this.morphBaseInfluence=fe(1),this.updateType=je.OBJECT}setup(e){const{geometry:t}=e,i=t.morphAttributes.position!==void 0,r=t.hasAttribute("normal")&&t.morphAttributes.normal!==void 0,s=t.morphAttributes.position||t.morphAttributes.normal||t.morphAttributes.color,a=s!==void 0?s.length:0,{texture:o,stride:l,size:c}=wL(t);i===!0&&Zt.mulAssign(this.morphBaseInfluence),r===!0&&ur.mulAssign(this.morphBaseInfluence);const u=P(c.width);gt(a,({i:h})=>{const d=E(0).toVar();this.mesh.count>1&&this.mesh.morphTexture!==null&&this.mesh.morphTexture!==void 0?d.assign(Vr(this.mesh.morphTexture,un(P(h).add(1),P(tc))).r):d.assign(fi("morphTargetInfluences","float").element(h).toVar()),i===!0&&Zt.addAssign(H1({bufferMap:o,influence:d,stride:l,width:u,depth:h,offset:P(0)})),r===!0&&ur.addAssign(H1({bufferMap:o,influence:d,stride:l,width:u,depth:h,offset:P(1)}))})}update(){const e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce((t,i)=>t+i,0)}}const W1=K(G1),EL=n=>n.sort((e,t)=>e.id-t.id),AL=(n,e)=>{for(const t of e)if(t.isAnalyticLightNode&&t.light.id===n)return t;return null},sg=new WeakMap;class j1 extends qe{static get type(){return"LightsNode"}constructor(e=[]){super("vec3"),this.totalDiffuseNode=D().toVar("totalDiffuse"),this.totalSpecularNode=D().toVar("totalSpecular"),this.outgoingLightNode=D().toVar("outgoingLight"),this._lights=e,this._lightNodes=null,this._lightNodesHash=null,this.global=!0}getHash(e){if(this._lightNodesHash===null){this._lightNodes===null&&this.setupLightsNode(e);const t=[];for(const i of this._lightNodes)t.push(i.getHash());this._lightNodesHash="lights-"+t.join(",")}return this._lightNodesHash}analyze(e){const t=e.getDataFromNode(this);for(const i of t.nodes)i.build(e)}setupLightsNode(e){const t=[],i=this._lightNodes,r=EL(this._lights),s=e.renderer.nodes.library;for(const a of r)if(a.isNode)t.push(G(a));else{let o=null;if(i!==null&&(o=AL(a.id,i)),o===null){const l=s.getLightNodeClass(a.constructor);if(l===null){console.warn(`LightsNode.setupNodeLights: Light node not found for ${a.constructor.name}`);continue}let c=null;sg.has(a)?c=sg.get(a):(c=new l(a),sg.set(a,c)),t.push(c)}}this._lightNodes=t}setup(e){this._lightNodes===null&&this.setupLightsNode(e);const t=e.context,i=t.lightingModel;let r=this.outgoingLightNode;if(i){const{_lightNodes:s,totalDiffuseNode:a,totalSpecularNode:o}=this;t.outgoingLight=r;const l=e.addStack(),c=e.getDataFromNode(this);c.nodes=l.nodes,i.start(t,l,e);for(const g of s)g.build(e);i.indirect(t,l,e);const{backdrop:u,backdropAlpha:h}=t,{directDiffuse:d,directSpecular:p,indirectDiffuse:m,indirectSpecular:v}=t.reflectedLight;let f=d.add(m);u!==null&&(h!==null?f=D(h.mix(f,u)):f=D(u),t.material.transparent=!0),a.assign(f),o.assign(p.add(v)),r.assign(a.add(o)),i.finish(t,l,e),r=r.bypass(e.removeStack())}return r}setLights(e){return this._lights=e,this._lightNodes=null,this._lightNodesHash=null,this}getLights(){return this._lights}}const X1=K(j1);class ta extends qe{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}generate(){console.warn("Abstract function.")}}class q1 extends ta{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class Y1 extends Uf{static get type(){return"LightingContextNode"}constructor(e,t=null,i=null,r=null){super(e),this.lightingModel=t,this.backdropNode=i,this.backdropAlphaNode=r,this._value=null}getContext(){const{backdropNode:e,backdropAlphaNode:t}=this,i=D().toVar("directDiffuse"),r=D().toVar("directSpecular"),s=D().toVar("indirectDiffuse"),a=D().toVar("indirectSpecular"),o={directDiffuse:i,directSpecular:r,indirectDiffuse:s,indirectSpecular:a};return{radiance:D().toVar("radiance"),irradiance:D().toVar("irradiance"),iblIrradiance:D().toVar("iblIrradiance"),ambientOcclusion:E(1).toVar("ambientOcclusion"),reflectedLight:o,backdrop:e,backdropAlpha:t}}setup(e){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}const $1=K(Y1);class J1 extends ta{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}let ic,rc;class ri extends qe{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this.isViewportNode=!0}getNodeType(){return this.scope===ri.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=je.NONE;return(this.scope===ri.SIZE||this.scope===ri.VIEWPORT)&&(e=je.RENDER),this.updateType=e,e}update({renderer:e}){const t=e.getRenderTarget();this.scope===ri.VIEWPORT?t!==null?rc.copy(t.viewport):(e.getViewport(rc),rc.multiplyScalar(e.getPixelRatio())):t!==null?(ic.width=t.width,ic.height=t.height):e.getDrawingBufferSize(ic)}setup(){const e=this.scope;let t=null;return e===ri.SIZE?t=fe(ic||(ic=new J)):e===ri.VIEWPORT?t=fe(rc||(rc=new st)):t=z(fo.div(mo)),t}generate(e){if(this.scope===ri.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){const i=e.getNodeProperties(mo).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${i}.y - ${t}.y )`}return t}return super.generate(e)}}ri.COORDINATE="coordinate",ri.VIEWPORT="viewport",ri.SIZE="size",ri.UV="uv";const ds=ge(ri,ri.UV),mo=ge(ri,ri.SIZE),fo=ge(ri,ri.COORDINATE),Pn=ge(ri,ri.VIEWPORT),K1=Pn.zw,Z1=fo.sub(Pn.xy),NL=Z1.div(K1),CL=U(()=>(console.warn('TSL.ViewportNode: "viewportResolution" is deprecated. Use "screenSize" instead.'),mo),"vec2").once()(),RL=U(()=>(console.warn('TSL.ViewportNode: "viewportTopLeft" is deprecated. Use "screenUV" instead.'),ds),"vec2").once()(),IL=U(()=>(console.warn('TSL.ViewportNode: "viewportBottomLeft" is deprecated. Use "screenUV.flipY()" instead.'),ds.flipY()),"vec2").once()(),nc=new J;class sc extends dn{static get type(){return"ViewportTextureNode"}constructor(e=ds,t=null,i=null){i===null&&(i=new dm,i.minFilter=ji),super(i,e,t),this.generateMipmaps=!1,this.isOutputTextureNode=!0,this.updateBeforeType=je.FRAME}updateBefore(e){const t=e.renderer;t.getDrawingBufferSize(nc);const i=this.value;(i.image.width!==nc.width||i.image.height!==nc.height)&&(i.image.width=nc.width,i.image.height=nc.height,i.needsUpdate=!0);const r=i.generateMipmaps;i.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(i),i.generateMipmaps=r}clone(){const e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}const LL=K(sc),Q1=K(sc,null,null,{generateMipmaps:!0});let ag=null;class eb extends sc{static get type(){return"ViewportDepthTextureNode"}constructor(e=ds,t=null){ag===null&&(ag=new Ds),super(e,t,ag)}}const og=K(eb);class Qi extends qe{static get type(){return"ViewportDepthNode"}constructor(e,t=null){super("float"),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(e){const{scope:t}=this;return t===Qi.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){const{scope:t}=this,i=this.valueNode;let r=null;if(t===Qi.DEPTH_BASE)i!==null&&(r=ib().assign(i));else if(t===Qi.DEPTH)e.isPerspectiveCamera?r=tb(Pi.z,lo,co):r=ac(Pi.z,lo,co);else if(t===Qi.LINEAR_DEPTH)if(i!==null)if(e.isPerspectiveCamera){const s=lg(i,lo,co);r=ac(s,lo,co)}else r=i;else r=ac(Pi.z,lo,co);return r}}Qi.DEPTH_BASE="depthBase",Qi.DEPTH="depth",Qi.LINEAR_DEPTH="linearDepth";const ac=(n,e,t)=>n.add(e).div(e.sub(t)),PL=(n,e,t)=>e.sub(t).mul(n).sub(e),tb=(n,e,t)=>e.add(n).mul(t).div(t.sub(e).mul(n)),lg=(n,e,t)=>e.mul(t).div(t.sub(e).mul(n).sub(t)),ib=K(Qi,Qi.DEPTH_BASE),cg=ge(Qi,Qi.DEPTH),Qh=K(Qi,Qi.LINEAR_DEPTH),DL=Qh(og());cg.assign=n=>ib(n);class fs extends qe{static get type(){return"ClippingNode"}constructor(e=fs.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);const t=e.clippingContext,{localClipIntersection:i,localClippingCount:r,globalClippingCount:s}=t,a=s+r,o=i?a-r:a;return this.scope===fs.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(t.planes,a,o):this.setupDefault(t.planes,a,o)}setupAlphaToCoverage(e,t,i){return U(()=>{const r=mn(e),s=ar("float","distanceToPlane"),a=ar("float","distanceToGradient"),o=ar("float","clipOpacity");o.assign(1);let l;if(gt(i,({i:c})=>{l=r.element(c),s.assign(Pi.dot(l.xyz).negate().add(l.w)),a.assign(s.fwidth().div(2)),o.mulAssign(Ki(a.negate(),a,s)),o.equal(0).discard()}),i<t){const c=ar("float","unionclipOpacity");c.assign(1),gt({start:i,end:t},({i:u})=>{l=r.element(u),s.assign(Pi.dot(l.xyz).negate().add(l.w)),a.assign(s.fwidth().div(2)),c.mulAssign(Ki(a.negate(),a,s).oneMinus())}),o.mulAssign(c.oneMinus())}Nt.a.mulAssign(o),Nt.a.equal(0).discard()})()}setupDefault(e,t,i){return U(()=>{const r=mn(e);let s;if(gt(i,({i:a})=>{s=r.element(a),Pi.dot(s.xyz).greaterThan(s.w).discard()}),i<t){const a=ar("bool","clipped");a.assign(!0),gt({start:i,end:t},({i:o})=>{s=r.element(o),a.assign(Pi.dot(s.xyz).greaterThan(s.w).and(a))}),a.discard()}})()}}fs.ALPHA_TO_COVERAGE="alphaToCoverage",fs.DEFAULT="default";const UL=()=>G(new fs),OL=()=>G(new fs(fs.ALPHA_TO_COVERAGE));class bt extends hi{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+Jm(this)}build(e){this.setup(e)}setupObserver(e){return new Hx(e)}setup(e){e.context.setupNormal=()=>this.setupNormal(e),e.addStack(),e.stack.outputNode=this.vertexNode||this.setupPosition(e),e.addFlow("vertex",e.removeStack()),e.addStack();let t;const i=this.setupClipping(e);if(this.depthWrite===!0&&this.setupDepth(e),this.fragmentNode===null){this.setupDiffuseColor(e),this.setupVariants(e);const r=this.setupLighting(e);i!==null&&e.stack.add(i);const s=ae(r,Nt.a).max(0);if(t=this.setupOutput(e,s),xf.assign(t),this.outputNode!==null&&(t=this.outputNode),e.renderer.getRenderTarget()!==null){const a=e.renderer.getMRT(),o=this.mrtNode;a!==null?(t=a,o!==null&&(t=a.merge(o))):o!==null&&(t=o)}}else{let r=this.fragmentNode;r.isOutputStructNode!==!0&&(r=ae(r)),t=this.setupOutput(e,r)}e.stack.outputNode=t,e.addFlow("fragment",e.removeStack()),e.monitor=this.setupObserver(e)}setupClipping(e){if(e.clippingContext===null)return null;const{globalClippingCount:t,localClippingCount:i}=e.clippingContext;let r=null;if(t||i){const s=e.renderer.samples;this.alphaToCoverage&&s>1?r=OL():e.stack.add(UL())}return r}setupDepth(e){const{renderer:t}=e;let i=this.depthNode;if(i===null){const r="getMRT"in t&&t.getMRT();r&&r.has("depth")?i=r.get("depth"):t.logarithmicDepthBuffer===!0&&(i=ig().w.add(1).log2().mul(FM).mul(.5))}i!==null&&cg.assign(i).append()}setupPosition(e){const{object:t}=e,i=t.geometry;if(e.addStack(),(i.morphAttributes.position||i.morphAttributes.normal||i.morphAttributes.color)&&W1(t).append(),t.isSkinnedMesh===!0&&z1(t).append(),this.displacementMap){const s=rn("displacementMap","texture"),a=rn("displacementScale","float"),o=rn("displacementBias","float");Zt.addAssign(ur.normalize().mul(s.x.mul(a).add(o)))}t.isBatchedMesh&&V1(t).append(),t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&O1(t).append(),this.positionNode!==null&&Zt.assign(this.positionNode);const r=ig();return e.context.vertex=e.removeStack(),e.context.mvp=r,r}setupDiffuseColor({object:e,geometry:t}){let i=this.colorNode?ae(this.colorNode):ho;this.vertexColors===!0&&t.hasAttribute("color")&&(i=ae(i.xyz.mul(_i("color","vec3")),i.a)),e.instanceColor&&(i=Zr("vec3","vInstanceColor").mul(i)),e.isBatchedMesh&&e._colorsTexture&&(i=Zr("vec3","vBatchColor").mul(i)),Nt.assign(i);const r=this.opacityNode?E(this.opacityNode):Yh;if(Nt.a.assign(Nt.a.mul(r)),this.alphaTestNode!==null||this.alphaTest>0){const s=this.alphaTestNode!==null?E(this.alphaTestNode):a1;Nt.a.lessThanEqual(s).discard()}this.transparent===!1&&this.blending===_n&&this.alphaToCoverage===!1&&Nt.a.assign(1)}setupVariants(){}setupOutgoingLight(){return this.lights===!0?D(0):Nt.rgb}setupNormal(){return this.normalNode?D(this.normalNode):p1}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?rn("envMap","cubeTexture"):rn("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new J1(tg)),t}setupLights(e){const t=[],i=this.setupEnvironment(e);i&&i.isLightingNode&&t.push(i);const r=this.setupLightMap(e);if(r&&r.isLightingNode&&t.push(r),this.aoNode!==null||e.material.aoMap){const a=this.aoNode!==null?this.aoNode:I1;t.push(new q1(a))}let s=this.lightsNode||e.lightsNode;return t.length>0&&(s=X1([...s.getLights(),...t])),s}setupLightingModel(){}setupLighting(e){const{material:t}=e,{backdropNode:i,backdropAlphaNode:r,emissiveNode:s}=this,a=this.lights===!0||this.lightsNode!==null?this.setupLights(e):null;let o=this.setupOutgoingLight(e);if(a&&a.getScope().getLights().length>0){const l=this.setupLightingModel(e);o=$1(a,l,i,r)}else i!==null&&(o=D(r!==null?rt(o,i,r):i));return(s&&s.isNode===!0||t.emissive&&t.emissive.isColor===!0)&&(gf.assign(D(s||l1)),o=o.add(gf)),o}setupOutput(e,t){if(this.fog===!0){const i=e.fogNode;i&&(t=ae(i.mix(t.rgb,i.colorNode),t.a))}return t}setDefaultValues(e){for(const i in e){const r=e[i];this[i]===void 0&&(this[i]=r,r&&r.clone&&(this[i]=r.clone()))}const t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(const i in t)Object.getOwnPropertyDescriptor(this.constructor.prototype,i)===void 0&&t[i].get!==void 0&&Object.defineProperty(this.constructor.prototype,i,t[i])}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{},nodes:{}});const i=hi.prototype.toJSON.call(this,e),r=Cl(this);i.inputNodes={};for(const{property:a,childNode:o}of r)i.inputNodes[a]=o.toJSON(e).uuid;function s(a){const o=[];for(const l in a){const c=a[l];delete c.metadata,o.push(c)}return o}if(t){const a=s(e.textures),o=s(e.images),l=s(e.nodes);a.length>0&&(i.textures=a),o.length>0&&(i.images=o),l.length>0&&(i.nodes=l)}return i}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,this.colorNode=e.colorNode,this.normalNode=e.normalNode,this.opacityNode=e.opacityNode,this.backdropNode=e.backdropNode,this.backdropAlphaNode=e.backdropAlphaNode,this.alphaTestNode=e.alphaTestNode,this.positionNode=e.positionNode,this.depthNode=e.depthNode,this.shadowNode=e.shadowNode,this.shadowPositionNode=e.shadowPositionNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,super.copy(e)}}const FL=new Ja;class VL extends bt{static get type(){return"InstancedPointsNodeMaterial"}constructor(e={}){super(),this.lights=!1,this.useAlphaToCoverage=!0,this.useColor=e.vertexColors,this.pointWidth=1,this.pointColorNode=null,this.pointWidthNode=null,this.setDefaultValues(FL),this.setValues(e)}setup(e){this.setupShaders(e),super.setup(e)}setupShaders({renderer:e}){const t=this.alphaToCoverage,i=this.useColor;this.vertexNode=U(()=>{const r=_i("instancePosition").xyz,s=ae(pn.mul(ae(r,1))),a=Pn.z.div(Pn.w),o=lr.mul(s),l=Li.xy.toVar();return l.mulAssign(this.pointWidthNode?this.pointWidthNode:C1),l.assign(l.div(Pn.z)),l.y.assign(l.y.mul(a)),l.assign(l.mul(o.w)),o.addAssign(ae(l,0,0)),o})(),this.fragmentNode=U(()=>{const r=E(1).toVar(),s=Lf(nt().mul(2).sub(1));if(t&&e.samples>1){const o=E(s.fwidth()).toVar();r.assign(Ki(o.oneMinus(),o.add(1),s).oneMinus())}else s.greaterThan(1).discard();let a;return this.pointColorNode?a=this.pointColorNode:i?a=_i("instanceColor").mul(ho):a=ho,r.mulAssign(Yh),ae(a,r)})()}get alphaToCoverage(){return this.useAlphaToCoverage}set alphaToCoverage(e){this.useAlphaToCoverage!==e&&(this.useAlphaToCoverage=e,this.needsUpdate=!0)}}const BL=new Ni;class zL extends bt{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.lights=!1,this.setDefaultValues(BL),this.setValues(e)}}const kL=new hh;class HL extends bt{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.lights=!1,this.setDefaultValues(kL),this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){const e=this.offsetNode,t=this.dashScaleNode?E(this.dashScaleNode):Jh,i=this.dashSizeNode?E(this.dashSizeNode):Zf,r=this.dashSizeNode?E(this.dashGapNode):Qf;Ks.assign(i),Bl.assign(r);const s=Ii(_i("lineDistance").mul(t));(e?s.add(e):s).mod(Ks.add(Bl)).greaterThan(Ks).discard()}}const GL=new hh;class WL extends bt{static get type(){return"Line2NodeMaterial"}constructor(e={}){super(),this.lights=!1,this.setDefaultValues(GL),this.useAlphaToCoverage=!0,this.useColor=e.vertexColors,this.useDash=e.dashed,this.useWorldUnits=!1,this.dashOffset=0,this.lineWidth=1,this.lineColorNode=null,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setup(e){this.setupShaders(e),super.setup(e)}setupShaders({renderer:e}){const t=this.alphaToCoverage,i=this.useColor,r=this.dashed,s=this.worldUnits,a=U(({start:l,end:c})=>{const u=lr.element(2).element(2),h=lr.element(3).element(2).mul(-.5).div(u).sub(l.z).div(c.z.sub(l.z));return ae(rt(l.xyz,c.xyz,h),c.w)}).setLayout({name:"trimSegment",type:"vec4",inputs:[{name:"start",type:"vec4"},{name:"end",type:"vec4"}]});this.vertexNode=U(()=>{const l=_i("instanceStart"),c=_i("instanceEnd"),u=ae(pn.mul(ae(l,1))).toVar("start"),h=ae(pn.mul(ae(c,1))).toVar("end");s&&(Zr("vec3","worldStart").assign(u.xyz),Zr("vec3","worldEnd").assign(h.xyz));const d=Pn.z.div(Pn.w),p=lr.element(2).element(3).equal(-1);Le(p,()=>{Le(u.z.lessThan(0).and(h.z.greaterThan(0)),()=>{h.assign(a({start:u,end:h}))}).ElseIf(h.z.lessThan(0).and(u.z.greaterThanEqual(0)),()=>{u.assign(a({start:h,end:u}))})});const m=lr.mul(u),v=lr.mul(h),f=m.xyz.div(m.w),g=v.xyz.div(v.w),x=g.xy.sub(f.xy).toVar();x.x.assign(x.x.mul(d)),x.assign(x.normalize());const y=ae().toVar();if(s){const _=h.xyz.sub(u.xyz).normalize(),I=rt(u.xyz,h.xyz,.5).normalize(),b=_.cross(I).normalize(),w=_.cross(b),C=Zr("vec4","worldPos");C.assign(Li.y.lessThan(.5).select(u,h));const H=Kh.mul(.5);C.addAssign(ae(Li.x.lessThan(0).select(b.mul(H),b.mul(H).negate()),0)),r||(C.addAssign(ae(Li.y.lessThan(.5).select(_.mul(H).negate(),_.mul(H)),0)),C.addAssign(ae(w.mul(H),0)),Le(Li.y.greaterThan(1).or(Li.y.lessThan(0)),()=>{C.subAssign(ae(w.mul(2).mul(H),0))})),y.assign(lr.mul(C));const M=D().toVar();M.assign(Li.y.lessThan(.5).select(f,g)),y.z.assign(M.z.mul(y.w))}else{const _=z(x.y,x.x.negate()).toVar("offset");x.x.assign(x.x.div(d)),_.x.assign(_.x.div(d)),_.assign(Li.x.lessThan(0).select(_.negate(),_)),Le(Li.y.lessThan(0),()=>{_.assign(_.sub(x))}).ElseIf(Li.y.greaterThan(1),()=>{_.assign(_.add(x))}),_.assign(_.mul(Kh)),_.assign(_.div(Pn.w)),y.assign(Li.y.lessThan(.5).select(m,v)),_.assign(_.mul(y.w)),y.assign(y.add(ae(_,0,0)))}return y})();const o=U(({p1:l,p2:c,p3:u,p4:h})=>{const d=l.sub(u),p=h.sub(u),m=c.sub(l),v=d.dot(p),f=p.dot(m),g=d.dot(m),x=p.dot(p),y=m.dot(m).mul(x).sub(f.mul(f)),_=v.mul(f).sub(g.mul(x)).div(y).clamp(),I=v.add(f.mul(_)).div(x).clamp();return z(_,I)});this.fragmentNode=U(()=>{const l=nt();if(r){const h=this.offsetNode?E(this.offsetNodeNode):eg,d=this.dashScaleNode?E(this.dashScaleNode):Jh,p=this.dashSizeNode?E(this.dashSizeNode):Zf,m=this.dashSizeNode?E(this.dashGapNode):Qf;Ks.assign(p),Bl.assign(m);const v=_i("instanceDistanceStart"),f=_i("instanceDistanceEnd"),g=Li.y.lessThan(.5).select(d.mul(v),Jh.mul(f)),x=Ii(g.add(eg)),y=h?x.add(h):x;l.y.lessThan(-1).or(l.y.greaterThan(1)).discard(),y.mod(Ks.add(Bl)).greaterThan(Ks).discard()}const c=E(1).toVar("alpha");if(s){const h=Zr("vec3","worldStart"),d=Zr("vec3","worldEnd"),p=Zr("vec4","worldPos").xyz.normalize().mul(1e5),m=d.sub(h),v=o({p1:h,p2:d,p3:D(0,0,0),p4:p}),f=h.add(m.mul(v.x)),g=p.mul(v.y),x=f.sub(g).length().div(Kh);if(!r)if(t&&e.samples>1){const y=x.fwidth();c.assign(Ki(y.negate().add(.5),y.add(.5),x).oneMinus())}else x.greaterThan(.5).discard()}else if(t&&e.samples>1){const h=l.x,d=l.y.greaterThan(0).select(l.y.sub(1),l.y.add(1)),p=h.mul(h).add(d.mul(d)),m=E(p.fwidth()).toVar("dlen");Le(l.y.abs().greaterThan(1),()=>{c.assign(Ki(m.oneMinus(),m.add(1),p).oneMinus())})}else Le(l.y.abs().greaterThan(1),()=>{const h=l.x,d=l.y.greaterThan(0).select(l.y.sub(1),l.y.add(1));h.mul(h).add(d.mul(d)).greaterThan(1).discard()});let u;if(this.lineColorNode)u=this.lineColorNode;else if(i){const h=_i("instanceColorStart"),d=_i("instanceColorEnd");u=Li.y.lessThan(.5).select(h,d).mul(ho)}else u=ho;return ae(u,c)})()}get worldUnits(){return this.useWorldUnits}set worldUnits(e){this.useWorldUnits!==e&&(this.useWorldUnits=e,this.needsUpdate=!0)}get dashed(){return this.useDash}set dashed(e){this.useDash!==e&&(this.useDash=e,this.needsUpdate=!0)}get alphaToCoverage(){return this.useAlphaToCoverage}set alphaToCoverage(e){this.useAlphaToCoverage!==e&&(this.useAlphaToCoverage=e,this.needsUpdate=!0)}}const rb=n=>G(n).mul(.5).add(.5),jL=n=>G(n).mul(2).sub(1),XL=new ch;class qL extends bt{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.lights=!1,this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(XL),this.setValues(e)}setupDiffuseColor(){const e=this.opacityNode?E(this.opacityNode):Yh;Nt.assign(ae(rb(Yt),e))}}class nb extends pt{static get type(){return"EquirectUVNode"}constructor(e=Wf){super("vec2"),this.dirNode=e}setup(){const e=this.dirNode,t=e.z.atan2(e.x).mul(1/(Math.PI*2)).add(.5),i=e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return z(t,i)}}const ug=K(nb);class sb extends Eu{constructor(e=1,t={}){super(e,t),this.isCubeRenderTarget=!0}fromEquirectangularTexture(e,t){const i=t.minFilter,r=t.generateMipmaps;t.generateMipmaps=!0,this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const s=new yn(5,5,5),a=ug(Wf),o=new bt;o.colorNode=yt(t,a,0),o.side=si,o.blending=Er;const l=new Ft(s,o),c=new Uu;c.add(l),t.minFilter===ji&&(t.minFilter=Lt);const u=new wu(1,10,this),h=e.getMRT();return e.setMRT(null),u.update(e,c),e.setMRT(h),t.minFilter=i,t.currentGenerateMipmaps=r,l.geometry.dispose(),l.material.dispose(),this}}const oc=new WeakMap;class YL extends pt{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=jh();const t=new Ns;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=je.RENDER}updateBefore(e){const{renderer:t,material:i}=e,r=this.envNode;if(r.isTextureNode||r.isMaterialReferenceNode){const s=r.isTextureNode?r.value:i[r.property];if(s&&s.isTexture){const a=s.mapping;if(a===zn||a===kn){if(oc.has(s)){const o=oc.get(s);ob(o,s.mapping),this._cubeTexture=o}else{const o=s.image;if($L(o)){const l=new sb(o.height);l.fromEquirectangularTexture(t,s),ob(l.texture,s.mapping),this._cubeTexture=l.texture,oc.set(s,l.texture),s.addEventListener("dispose",ab)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}}function $L(n){return n==null?!1:n.height>0}function ab(n){const e=n.target;e.removeEventListener("dispose",ab);const t=oc.get(e);t!==void 0&&(oc.delete(e),t.dispose())}function ob(n,e){e===zn?n.mapping=fr:e===kn&&(n.mapping=Ar)}const JL=K(YL);class ed extends ta{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=JL(this.envNode)}}class KL extends ta{static get type(){return"BasicLightMapNode"}constructor(e=null){super(),this.lightMapNode=e}setup(e){const t=E(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}}class lc{start(){}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}class lb extends lc{constructor(){super()}indirect(e,t,i){const r=e.ambientOcclusion,s=e.reflectedLight,a=i.context.irradianceLightMap;s.indirectDiffuse.assign(ae(0)),a?s.indirectDiffuse.addAssign(a):s.indirectDiffuse.addAssign(ae(1,1,1,0)),s.indirectDiffuse.mulAssign(r),s.indirectDiffuse.mulAssign(Nt.rgb)}finish(e,t,i){const r=i.material,s=e.outgoingLight,a=i.context.environment;if(a)switch(r.combine){case pa:s.rgb.assign(rt(s.rgb,s.rgb.mul(a.rgb),ec.mul($h)));break;case Yd:s.rgb.assign(rt(s.rgb,a.rgb,ec.mul($h)));break;case $d:s.rgb.addAssign(a.rgb.mul(ec.mul($h)));break;default:console.warn("THREE.BasicLightingModel: Unsupported .combine value:",r.combine);break}}}const ZL=new Yr;class QL extends bt{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(ZL),this.setValues(e)}setupNormal(){return hr}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new ed(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new KL(tg)),t}setupOutgoingLight(){return Nt.rgb}setupLightingModel(){return new lb}}const go=U(({f0:n,f90:e,dotVH:t})=>{const i=t.mul(-5.55473).sub(6.98316).mul(t).exp2();return n.mul(i.oneMinus()).add(e.mul(i))}),ia=U(n=>n.diffuseColor.mul(1/Math.PI)),eP=()=>E(.25),tP=U(({dotNH:n})=>Dh.mul(E(.5)).add(1).mul(E(1/Math.PI)).mul(n.pow(Dh))),iP=U(({lightDirection:n})=>{const e=n.add(Vt).normalize(),t=Yt.dot(e).clamp(),i=Vt.dot(e).clamp(),r=go({f0:or,f90:1,dotVH:i}),s=eP(),a=tP({dotNH:t});return r.mul(s).mul(a)});class hg extends lb{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:i}){const r=Yt.dot(e).clamp().mul(t);i.directDiffuse.addAssign(r.mul(ia({diffuseColor:Nt.rgb}))),this.specular===!0&&i.directSpecular.addAssign(r.mul(iP({lightDirection:e})).mul(ec))}indirect({ambientOcclusion:e,irradiance:t,reflectedLight:i}){i.indirectDiffuse.addAssign(t.mul(ia({diffuseColor:Nt}))),i.indirectDiffuse.mulAssign(e)}}const rP=new uh;class nP extends bt{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(rP),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new ed(t):null}setupLightingModel(){return new hg(!1)}}const sP=new lh;class aP extends bt{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(sP),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new ed(t):null}setupLightingModel(){return new hg}setupVariants(){const e=(this.shininessNode?E(this.shininessNode):o1).max(1e-4);Dh.assign(e);const t=this.specularNode||c1;or.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}}const cb=U(()=>{const n=hr.dFdx().abs().max(hr.dFdy().abs());return n.x.max(n.y).max(n.z)}),dg=U(n=>{const{roughness:e}=n,t=cb();let i=e.max(.0525);return i=i.add(t),i=i.min(1),i}),ub=U(({alpha:n,dotNL:e,dotNV:t})=>{const i=n.pow2(),r=e.mul(i.add(i.oneMinus().mul(t.pow2())).sqrt()),s=t.mul(i.add(i.oneMinus().mul(e.pow2())).sqrt());return Qr(.5,r.add(s).max(L_))}).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),oP=U(({alphaT:n,alphaB:e,dotTV:t,dotBV:i,dotTL:r,dotBL:s,dotNV:a,dotNL:o})=>{const l=o.mul(D(n.mul(t),e.mul(i),a).length()),c=a.mul(D(n.mul(r),e.mul(s),o).length());return Qr(.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"}]}),hb=U(({alpha:n,dotNH:e})=>{const t=n.pow2(),i=e.pow2().mul(t.oneMinus()).oneMinus();return t.div(i.pow2()).mul(1/Math.PI)}).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),lP=E(1/Math.PI),cP=U(({alphaT:n,alphaB:e,dotNH:t,dotTH:i,dotBH:r})=>{const s=n.mul(e),a=D(e.mul(i),n.mul(r),s.mul(t)),o=a.dot(a),l=s.div(o);return lP.mul(s.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"}]}),pg=U(n=>{const{lightDirection:e,f0:t,f90:i,roughness:r,f:s,USE_IRIDESCENCE:a,USE_ANISOTROPY:o}=n,l=n.normalView||Yt,c=r.pow2(),u=e.add(Vt).normalize(),h=l.dot(e).clamp(),d=l.dot(Vt).clamp(),p=l.dot(u).clamp(),m=Vt.dot(u).clamp();let v=go({f0:t,f90:i,dotVH:m}),f,g;if(Rl(a)&&(v=Lh.mix(v,s)),Rl(o)){const x=Fl.dot(e),y=Fl.dot(Vt),_=Fl.dot(u),I=Js.dot(e),b=Js.dot(Vt),w=Js.dot(u);f=oP({alphaT:Ph,alphaB:c,dotTV:y,dotBV:b,dotTL:x,dotBL:I,dotNV:d,dotNL:h}),g=cP({alphaT:Ph,alphaB:c,dotNH:p,dotTH:_,dotBH:w})}else f=ub({alpha:c,dotNL:h,dotNV:d}),g=hb({alpha:c,dotNH:p});return v.mul(f).mul(g)}),mg=U(({roughness:n,dotNV:e})=>{const t=ae(-1,-.0275,-.572,.022),i=ae(1,.0425,1.04,-.04),r=n.mul(t).add(i),s=r.x.mul(r.x).min(e.mul(-9.28).exp2()).mul(r.x).add(r.y);return z(-1.04,1.04).mul(s).add(r.zw)}).setLayout({name:"DFGApprox",type:"vec2",inputs:[{name:"roughness",type:"float"},{name:"dotNV",type:"vec3"}]}),db=U(n=>{const{dotNV:e,specularColor:t,specularF90:i,roughness:r}=n,s=mg({dotNV:e,roughness:r});return t.mul(s.x).add(i.mul(s.y))}),pb=U(({f:n,f90:e,dotVH:t})=>{const i=t.oneMinus().saturate(),r=i.mul(i),s=i.mul(r,r).clamp(0,.9999);return n.sub(D(e).mul(s)).div(s.oneMinus())}).setLayout({name:"Schlick_to_F0",type:"vec3",inputs:[{name:"f",type:"vec3"},{name:"f90",type:"float"},{name:"dotVH",type:"float"}]}),uP=U(({roughness:n,dotNH:e})=>{const t=n.pow2(),i=E(1).div(t),r=e.pow2().oneMinus().max(.0078125);return E(2).add(i).mul(r.pow(i.mul(.5))).div(2*Math.PI)}).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),hP=U(({dotNV:n,dotNL:e})=>E(1).div(E(4).mul(e.add(n).sub(e.mul(n))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),dP=U(({lightDirection:n})=>{const e=n.add(Vt).normalize(),t=Yt.dot(n).clamp(),i=Yt.dot(Vt).clamp(),r=Yt.dot(e).clamp(),s=uP({roughness:Ih,dotNH:r}),a=hP({dotNV:i,dotNL:t});return $s.mul(s).mul(a)}),pP=U(({N:n,V:e,roughness:t})=>{const i=.0078125,r=n.dot(e).saturate(),s=z(t,r.oneMinus().sqrt());return s.assign(s.mul(.984375).add(i)),s}).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]}),mP=U(({f:n})=>{const e=n.length();return ft(e.mul(e).add(n.z).div(e.add(1)),0)}).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),td=U(({v1:n,v2:e})=>{const t=n.dot(e),i=t.abs().toVar(),r=i.mul(.0145206).add(.4965155).mul(i).add(.8543985).toVar(),s=i.add(4.1616724).mul(i).add(3.417594).toVar(),a=r.div(s),o=t.greaterThan(0).select(a,ft(t.mul(t).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(a));return n.cross(e).mul(o)}).setLayout({name:"LTC_EdgeVectorFormFactor",type:"vec3",inputs:[{name:"v1",type:"vec3"},{name:"v2",type:"vec3"}]}),mb=U(({N:n,V:e,P:t,mInv:i,p0:r,p1:s,p2:a,p3:o})=>{const l=s.sub(r).toVar(),c=o.sub(r).toVar(),u=l.cross(c),h=D().toVar();return Le(u.dot(t.sub(r)).greaterThanEqual(0),()=>{const d=e.sub(n.mul(e.dot(n))).normalize(),p=n.cross(d).negate(),m=i.mul(yi(d,p,n).transpose()).toVar(),v=m.mul(r.sub(t)).normalize().toVar(),f=m.mul(s.sub(t)).normalize().toVar(),g=m.mul(a.sub(t)).normalize().toVar(),x=m.mul(o.sub(t)).normalize().toVar(),y=D(0).toVar();y.addAssign(td({v1:v,v2:f})),y.addAssign(td({v1:f,v2:g})),y.addAssign(td({v1:g,v2:x})),y.addAssign(td({v1:x,v2:v})),h.assign(D(mP({f:y})))}),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"}]}),id=1/6,fb=n=>lt(id,lt(n,lt(n,n.negate().add(3)).sub(3)).add(1)),fg=n=>lt(id,lt(n,lt(n,lt(3,n).sub(6))).add(4)),gb=n=>lt(id,lt(n,lt(n,lt(-3,n).add(3)).add(3)).add(1)),gg=n=>lt(id,Ji(n,3)),vb=n=>fb(n).add(fg(n)),yb=n=>gb(n).add(gg(n)),xb=n=>zt(-1,fg(n).div(fb(n).add(fg(n)))),_b=n=>zt(1,gg(n).div(gb(n).add(gg(n)))),Mb=(n,e,t)=>{const i=n.uvNode,r=lt(i,e.zw).add(.5),s=ls(r),a=cs(r),o=vb(a.x),l=yb(a.x),c=xb(a.x),u=_b(a.x),h=xb(a.y),d=_b(a.y),p=z(s.x.add(c),s.y.add(h)).sub(.5).mul(e.xy),m=z(s.x.add(u),s.y.add(h)).sub(.5).mul(e.xy),v=z(s.x.add(c),s.y.add(d)).sub(.5).mul(e.xy),f=z(s.x.add(u),s.y.add(d)).sub(.5).mul(e.xy),g=vb(a.y).mul(zt(o.mul(n.uv(p).level(t)),l.mul(n.uv(m).level(t)))),x=yb(a.y).mul(zt(o.mul(n.uv(v).level(t)),l.mul(n.uv(f).level(t))));return g.add(x)},bb=U(([n,e=E(3)])=>{const t=z(n.size(P(e))),i=z(n.size(P(e.add(1)))),r=Qr(1,t),s=Qr(1,i),a=Mb(n,ae(r,t),ls(e)),o=Mb(n,ae(s,i),Cf(e));return cs(e).mix(a,o)}),Tb=U(([n,e,t,i,r])=>{const s=D(Pf(e.negate(),Mr(n),Qr(1,i))),a=D(Qs(r[0].xyz),Qs(r[1].xyz),Qs(r[2].xyz));return Mr(s).mul(t.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"}]}),fP=U(([n,e])=>n.mul(li(e.mul(2).sub(2),0,1))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),gP=Q1(),Sb=U(([n,e,t])=>{const i=gP.uv(n),r=kl(E(mo.x)).mul(fP(e,t));return bb(i,r)}),wb=U(([n,e,t])=>(Le(t.notEqual(0),()=>{const i=Nf(e).negate().div(t);return Af(i.negate().mul(n))}),D(1))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),vP=U(([n,e,t,i,r,s,a,o,l,c,u,h,d,p,m])=>{let v,f;if(m){v=ae().toVar(),f=D().toVar();const I=u.sub(1).mul(m.mul(.025)),b=D(u.sub(I),u,u.add(I));gt({start:0,end:3},({i:w})=>{const C=b.element(w),H=Tb(n,e,h,C,o),M=a.add(H),T=c.mul(l.mul(ae(M,1))),k=z(T.xy.div(T.w)).toVar();k.addAssign(1),k.divAssign(2),k.assign(z(k.x,k.y.oneMinus()));const j=Sb(k,t,C);v.element(w).assign(j.element(w)),v.a.addAssign(j.a),f.element(w).assign(i.element(w).mul(wb(Qs(H),d,p).element(w)))}),v.a.divAssign(3)}else{const I=Tb(n,e,h,u,o),b=a.add(I),w=c.mul(l.mul(ae(b,1))),C=z(w.xy.div(w.w)).toVar();C.addAssign(1),C.divAssign(2),C.assign(z(C.x,C.y.oneMinus())),v=Sb(C,t,u),f=i.mul(wb(Qs(I),d,p))}const g=f.rgb.mul(v.rgb),x=n.dot(e).clamp(),y=D(db({dotNV:x,specularColor:r,specularF90:s,roughness:t})),_=f.r.add(f.g,f.b).div(3);return ae(y.oneMinus().mul(g),v.a.oneMinus().mul(_).oneMinus())}),yP=yi(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),xP=n=>{const e=n.sqrt();return D(1).add(e).div(D(1).sub(e))},Eb=(n,e)=>n.sub(e).div(n.add(e)).pow2(),_P=(n,e)=>{const t=n.mul(2*Math.PI*1e-9),i=D(54856e-17,44201e-17,52481e-17),r=D(1681e3,1795300,2208400),s=D(43278e5,93046e5,66121e5),a=E(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(t.mul(2239900).add(e.x).cos()).mul(t.pow2().mul(-45282e5).exp());let o=i.mul(s.mul(2*Math.PI).sqrt()).mul(r.mul(t).add(e).cos()).mul(t.pow2().negate().mul(s).exp());return o=D(o.x.add(a),o.y,o.z).div(10685e-11),yP.mul(o)},MP=U(({outsideIOR:n,eta2:e,cosTheta1:t,thinFilmThickness:i,baseF0:r})=>{const s=rt(n,e,Ki(0,.03,i)),a=n.div(s).pow2().mul(E(1).sub(t.pow2())),o=E(1).sub(a).sqrt(),l=Eb(s,n),c=go({f0:l,f90:1,dotVH:t}),u=c.oneMinus(),h=s.lessThan(n).select(Math.PI,0),d=E(Math.PI).sub(h),p=xP(r.clamp(0,.9999)),m=Eb(p,s.toVec3()),v=go({f0:m,f90:1,dotVH:o}),f=D(p.x.lessThan(s).select(Math.PI,0),p.y.lessThan(s).select(Math.PI,0),p.z.lessThan(s).select(Math.PI,0)),g=s.mul(i,o,2),x=D(d).add(f),y=c.mul(v).clamp(1e-5,.9999),_=y.sqrt(),I=u.pow2().mul(v).div(D(1).sub(y));let b=c.add(I),w=I.sub(u);for(let C=1;C<=2;++C){w=w.mul(_);const H=_P(E(C).mul(g),E(C).mul(x)).mul(2);b=b.add(w.mul(H))}return b.max(D(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"}]}),bP=U(({normal:n,viewDir:e,roughness:t})=>{const i=n.dot(e).saturate(),r=t.pow2(),s=Ri(t.lessThan(.25),E(-339.2).mul(r).add(E(161.4).mul(t)).sub(25.9),E(-8.48).mul(r).add(E(14.3).mul(t)).sub(9.95)),a=Ri(t.lessThan(.25),E(44).mul(r).sub(E(23.7).mul(t)).add(3.26),E(1.97).mul(r).sub(E(3.27).mul(t)).add(.72));return Ri(t.lessThan(.25),0,E(.1).mul(t).sub(.025)).add(s.mul(i).add(a).exp()).mul(1/Math.PI).saturate()}),vg=D(.04),yg=E(1);class rd extends lc{constructor(e=!1,t=!1,i=!1,r=!1,s=!1,a=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=i,this.anisotropy=r,this.transmission=s,this.dispersion=a,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0=null}start(e){if(this.clearcoat===!0&&(this.clearcoatRadiance=D().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=D().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=D().toVar("clearcoatSpecularIndirect")),this.sheen===!0&&(this.sheenSpecularDirect=D().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=D().toVar("sheenSpecularIndirect")),this.iridescence===!0){const t=Yt.dot(Vt).clamp();this.iridescenceFresnel=MP({outsideIOR:E(1),eta2:vf,cosTheta1:t,thinFilmThickness:yf,baseF0:or}),this.iridescenceF0=pb({f:this.iridescenceFresnel,f90:1,dotVH:t})}if(this.transmission===!0){const t=Hh,i=Gf.sub(Hh).normalize(),r=jf;e.backdrop=vP(r,i,hn,Nt,or,Vl,t,Br,cr,lr,zl,_f,bf,Mf,this.dispersion?Tf:null),e.backdropAlpha=Uh,Nt.a.mulAssign(rt(1,e.backdrop.a,Uh))}}computeMultiscattering(e,t,i){const r=Yt.dot(Vt).clamp(),s=mg({roughness:hn,dotNV:r}),a=(this.iridescenceF0?Lh.mix(or,this.iridescenceF0):or).mul(s.x).add(i.mul(s.y)),o=s.x.add(s.y).oneMinus(),l=or.add(or.oneMinus().mul(.047619)),c=a.mul(l).div(o.mul(l).oneMinus());e.addAssign(a),t.addAssign(c.mul(o))}direct({lightDirection:e,lightColor:t,reflectedLight:i}){const r=Yt.dot(e).clamp().mul(t);if(this.sheen===!0&&this.sheenSpecularDirect.addAssign(r.mul(dP({lightDirection:e}))),this.clearcoat===!0){const s=uo.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(s.mul(pg({lightDirection:e,f0:vg,f90:yg,roughness:Ol,normalView:uo})))}i.directDiffuse.addAssign(r.mul(ia({diffuseColor:Nt.rgb}))),i.directSpecular.addAssign(r.mul(pg({lightDirection:e,f0:or,f90:1,roughness:hn,iridescence:this.iridescence,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:i,halfHeight:r,reflectedLight:s,ltc_1:a,ltc_2:o}){const l=t.add(i).sub(r),c=t.sub(i).sub(r),u=t.sub(i).add(r),h=t.add(i).add(r),d=Yt,p=Vt,m=Pi.toVar(),v=pP({N:d,V:p,roughness:hn}),f=a.uv(v).toVar(),g=o.uv(v).toVar(),x=yi(D(f.x,0,f.y),D(0,1,0),D(f.z,0,f.w)).toVar(),y=or.mul(g.x).add(or.oneMinus().mul(g.y)).toVar();s.directSpecular.addAssign(e.mul(y).mul(mb({N:d,V:p,P:m,mInv:x,p0:l,p1:c,p2:u,p3:h}))),s.directDiffuse.addAssign(e.mul(Nt).mul(mb({N:d,V:p,P:m,mInv:yi(1,0,0,0,1,0,0,0,1),p0:l,p1:c,p2:u,p3:h})))}indirect(e,t,i){this.indirectDiffuse(e,t,i),this.indirectSpecular(e,t,i),this.ambientOcclusion(e,t,i)}indirectDiffuse({irradiance:e,reflectedLight:t}){t.indirectDiffuse.addAssign(e.mul(ia({diffuseColor:Nt})))}indirectSpecular({radiance:e,iblIrradiance:t,reflectedLight:i}){if(this.sheen===!0&&this.sheenSpecularIndirect.addAssign(t.mul($s,bP({normal:Yt,viewDir:Vt,roughness:Ih}))),this.clearcoat===!0){const c=uo.dot(Vt).clamp(),u=db({dotNV:c,specularColor:vg,specularF90:yg,roughness:Ol});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(u))}const r=D().toVar("singleScattering"),s=D().toVar("multiScattering"),a=t.mul(1/Math.PI);this.computeMultiscattering(r,s,Vl);const o=r.add(s),l=Nt.mul(o.r.max(o.g).max(o.b).oneMinus());i.indirectSpecular.addAssign(e.mul(r)),i.indirectSpecular.addAssign(s.mul(a)),i.indirectDiffuse.addAssign(l.mul(a))}ambientOcclusion({ambientOcclusion:e,reflectedLight:t}){const i=Yt.dot(Vt).clamp().add(e),r=hn.mul(-16).oneMinus().negate().exp2(),s=e.sub(i.pow(r).oneMinus()).clamp();this.clearcoat===!0&&this.clearcoatSpecularIndirect.mulAssign(e),this.sheen===!0&&this.sheenSpecularIndirect.mulAssign(e),t.indirectDiffuse.mulAssign(e),t.indirectSpecular.mulAssign(s)}finish(e){const{outgoingLight:t}=e;if(this.clearcoat===!0){const i=uo.dot(Vt).clamp(),r=go({dotVH:i,f0:vg,f90:yg}),s=t.mul(Rh.mul(r).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(Rh));t.assign(s)}if(this.sheen===!0){const i=$s.r.max($s.g).max($s.b).mul(.157).oneMinus(),r=t.mul(i).add(this.sheenSpecularDirect,this.sheenSpecularIndirect);t.assign(r)}}}const Ab=E(1),xg=E(-2),nd=E(.8),_g=E(-1),sd=E(.4),Mg=E(2),ad=E(.305),bg=E(3),Nb=E(.21),TP=E(4),Cb=E(4),SP=E(16),wP=U(([n])=>{const e=D(It(n)).toVar(),t=E(-1).toVar();return Le(e.x.greaterThan(e.z),()=>{Le(e.x.greaterThan(e.y),()=>{t.assign(Ri(n.x.greaterThan(0),0,3))}).Else(()=>{t.assign(Ri(n.y.greaterThan(0),1,4))})}).Else(()=>{Le(e.z.greaterThan(e.y),()=>{t.assign(Ri(n.z.greaterThan(0),2,5))}).Else(()=>{t.assign(Ri(n.y.greaterThan(0),1,4))})}),t}).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),EP=U(([n,e])=>{const t=z().toVar();return Le(e.equal(0),()=>{t.assign(z(n.z,n.y).div(It(n.x)))}).ElseIf(e.equal(1),()=>{t.assign(z(n.x.negate(),n.z.negate()).div(It(n.y)))}).ElseIf(e.equal(2),()=>{t.assign(z(n.x.negate(),n.y).div(It(n.z)))}).ElseIf(e.equal(3),()=>{t.assign(z(n.z.negate(),n.y).div(It(n.x)))}).ElseIf(e.equal(4),()=>{t.assign(z(n.x.negate(),n.z).div(It(n.y)))}).Else(()=>{t.assign(z(n.x,n.y).div(It(n.z)))}),lt(.5,t.add(1))}).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),AP=U(([n])=>{const e=E(0).toVar();return Le(n.greaterThanEqual(nd),()=>{e.assign(Ab.sub(n).mul(_g.sub(xg)).div(Ab.sub(nd)).add(xg))}).ElseIf(n.greaterThanEqual(sd),()=>{e.assign(nd.sub(n).mul(Mg.sub(_g)).div(nd.sub(sd)).add(_g))}).ElseIf(n.greaterThanEqual(ad),()=>{e.assign(sd.sub(n).mul(bg.sub(Mg)).div(sd.sub(ad)).add(Mg))}).ElseIf(n.greaterThanEqual(Nb),()=>{e.assign(ad.sub(n).mul(TP.sub(bg)).div(ad.sub(Nb)).add(bg))}).Else(()=>{e.assign(E(-2).mul(kl(lt(1.16,n))))}),e}).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),Rb=U(([n,e])=>{const t=n.toVar();t.assign(lt(2,t).sub(1));const i=D(t,1).toVar();return Le(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"}]}),Ib=U(([n,e,t,i,r,s])=>{const a=E(t),o=D(e),l=li(AP(a),xg,s),c=cs(l),u=ls(l),h=D(Tg(n,o,u,i,r,s)).toVar();return Le(c.notEqual(0),()=>{const d=D(Tg(n,o,u.add(1),i,r,s)).toVar();h.assign(rt(h,d,c))}),h}),Tg=U(([n,e,t,i,r,s])=>{const a=E(t).toVar(),o=D(e),l=E(wP(o)).toVar(),c=E(ft(Cb.sub(a),0)).toVar();a.assign(ft(a,Cb));const u=E(Oh(a)).toVar(),h=z(EP(o,l).mul(u.sub(2)).add(1)).toVar();return Le(l.greaterThan(2),()=>{h.y.addAssign(u),l.subAssign(3)}),h.x.addAssign(l.mul(u)),h.x.addAssign(c.mul(lt(3,SP))),h.y.addAssign(lt(4,Oh(s).sub(u))),h.x.mulAssign(i),h.y.mulAssign(r),n.uv(h).grad(z(),z())}),Sg=U(({envMap:n,mipInt:e,outputDirection:t,theta:i,axis:r,CUBEUV_TEXEL_WIDTH:s,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:o})=>{const l=br(i),c=t.mul(l).add(r.cross(t).mul(Ci(i))).add(r.mul(r.dot(t).mul(l.oneMinus())));return Tg(n,c,e,s,a,o)}),Lb=U(({n,latitudinal:e,poleAxis:t,outputDirection:i,weights:r,samples:s,dTheta:a,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:c,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:h})=>{const d=D(Ri(e,t,oo(t,i))).toVar();Le(Ef(d.equals(D(0))),()=>{d.assign(D(i.z,0,i.x.negate()))}),d.assign(Mr(d));const p=D().toVar();return p.addAssign(r.element(P(0)).mul(Sg({theta:0,axis:d,outputDirection:i,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:c,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:h}))),gt({start:P(1),end:n},({i:m})=>{Le(m.greaterThanEqual(s),()=>{Zh()});const v=E(a.mul(E(m))).toVar();p.addAssign(r.element(m).mul(Sg({theta:v.mul(-1),axis:d,outputDirection:i,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:c,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:h}))),p.addAssign(r.element(m).mul(Sg({theta:v,axis:d,outputDirection:i,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:c,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:h})))}),ae(p,1)});let od=null;const Pb=new WeakMap;function NP(n){const e=Math.log2(n)-2,t=1/n;return{texelWidth:1/(3*Math.max(Math.pow(2,e),112)),texelHeight:t,maxMip:e}}function CP(n){let e=Pb.get(n);if((e!==void 0?e.pmremVersion:-1)!==n.pmremVersion){const t=n.image;if(n.isCubeTexture)if(RP(t))e=od.fromCubemap(n,e);else return null;else if(IP(t))e=od.fromEquirectangular(n,e);else return null;e.pmremVersion=n.pmremVersion,Pb.set(n,e)}return e.texture}class Db extends pt{static get type(){return"PMREMNode"}constructor(e,t=null,i=null){super("vec3"),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=i,this._generator=null;const r=new Wt;r.isRenderTargetTexture=!0,this._texture=yt(r),this._width=fe(0),this._height=fe(0),this._maxMip=fe(0),this.updateBeforeType=je.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){const t=NP(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(){let e=this._pmrem;const t=e?e.pmremVersion:-1,i=this._value;t!==i.pmremVersion&&(i.isPMREMTexture===!0?e=i:e=CP(i),e!==null&&(this._pmrem=e,this.updateFromTexture(e)))}setup(e){od===null&&(od=e.createPMREMGenerator()),this.updateBefore(e);let t=this.uvNode;t===null&&e.context.getUV&&(t=e.context.getUV(this));const i=this.value;e.renderer.coordinateSystem===Rr&&i.isPMREMTexture!==!0&&i.isRenderTargetTexture===!0&&(t=D(t.x.negate(),t.yz));let r=this.levelNode;return r===null&&e.context.getTextureLevel&&(r=e.context.getTextureLevel(this)),Ib(this._texture,t,r,this._width,this._height,this._maxMip)}}function RP(n){if(n==null)return!1;let e=0;const t=6;for(let i=0;i<t;i++)n[i]!==void 0&&e++;return e===t}function IP(n){return n==null?!1:n.height>0}const Ub=K(Db),Ob=new WeakMap;class Fb extends ta{static get type(){return"EnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){const{material:t}=e;let i=this.envNode;if(i.isTextureNode||i.isMaterialReferenceNode){const h=i.isTextureNode?i.value:t[i.property];let d=Ob.get(h);d===void 0&&(d=Ub(h),Ob.set(h,d)),i=d}const r=t.envMap?fi("envMapIntensity","float",e.material):fi("environmentIntensity","float",e.scene),s=t.useAnisotropy===!0||t.anisotropy>0?t1:Yt,a=i.context(Vb(hn,s)).mul(r),o=i.context(LP(jf)).mul(Math.PI).mul(r),l=ql(a),c=ql(o);e.context.radiance.addAssign(l),e.context.iblIrradiance.addAssign(c);const u=e.context.lightingModel.clearcoatRadiance;if(u){const h=i.context(Vb(Ol,uo)).mul(r),d=ql(h);u.addAssign(d)}}}const Vb=(n,e)=>{let t=null;return{getUV:()=>(t===null&&(t=Vt.negate().reflect(e),t=n.mul(n).mix(t,e).normalize(),t=t.transformDirection(cr)),t),getTextureLevel:()=>n}},LP=n=>({getUV:()=>n,getTextureLevel:()=>E(1)}),PP=new Sl;class Bb extends bt{static get type(){return"MeshStandardNodeMaterial"}constructor(e){super(),this.isMeshStandardNodeMaterial=!0,this.lights=!0,this.emissiveNode=null,this.metalnessNode=null,this.roughnessNode=null,this.setDefaultValues(PP),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t===null&&e.environmentNode&&(t=e.environmentNode),t?new Fb(t):null}setupLightingModel(){return new rd}setupSpecular(){const e=rt(D(.04),Nt.rgb,Ul);or.assign(e),Vl.assign(1)}setupVariants(){const e=this.metalnessNode?E(this.metalnessNode):d1;Ul.assign(e);let t=this.roughnessNode?E(this.roughnessNode):h1;t=dg({roughness:t}),hn.assign(t),this.setupSpecular(),Nt.assign(ae(Nt.rgb.mul(e.oneMinus()),Nt.a))}copy(e){return this.emissiveNode=e.emissiveNode,this.metalnessNode=e.metalnessNode,this.roughnessNode=e.roughnessNode,super.copy(e)}}const DP=new oh;class zb extends Bb{static get type(){return"MeshPhysicalNodeMaterial"}constructor(e){super(),this.isMeshPhysicalNodeMaterial=!0,this.clearcoatNode=null,this.clearcoatRoughnessNode=null,this.clearcoatNormalNode=null,this.sheenNode=null,this.sheenRoughnessNode=null,this.iridescenceNode=null,this.iridescenceIORNode=null,this.iridescenceThicknessNode=null,this.specularIntensityNode=null,this.specularColorNode=null,this.iorNode=null,this.transmissionNode=null,this.thicknessNode=null,this.attenuationDistanceNode=null,this.attenuationColorNode=null,this.dispersionNode=null,this.anisotropyNode=null,this.setDefaultValues(DP),this.setValues(e)}get useClearcoat(){return this.clearcoat>0||this.clearcoatNode!==null}get useIridescence(){return this.iridescence>0||this.iridescenceNode!==null}get useSheen(){return this.sheen>0||this.sheenNode!==null}get useAnisotropy(){return this.anisotropy>0||this.anisotropyNode!==null}get useTransmission(){return this.transmission>0||this.transmissionNode!==null}get useDispersion(){return this.dispersion>0||this.dispersionNode!==null}setupSpecular(){const e=this.iorNode?E(this.iorNode):E1;zl.assign(e),or.assign(rt(xi(If(zl.sub(1).div(zl.add(1))).mul(u1),D(1)).mul(Kf),Nt.rgb,Ul)),Vl.assign(rt(Kf,1,Ul))}setupLightingModel(){return new rd(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){const t=this.clearcoatNode?E(this.clearcoatNode):m1,i=this.clearcoatRoughnessNode?E(this.clearcoatRoughnessNode):f1;Rh.assign(t),Ol.assign(dg({roughness:i}))}if(this.useSheen){const t=this.sheenNode?D(this.sheenNode):y1,i=this.sheenRoughnessNode?E(this.sheenRoughnessNode):x1;$s.assign(t),Ih.assign(i)}if(this.useIridescence){const t=this.iridescenceNode?E(this.iridescenceNode):M1,i=this.iridescenceIORNode?E(this.iridescenceIORNode):b1,r=this.iridescenceThicknessNode?E(this.iridescenceThicknessNode):T1;Lh.assign(t),vf.assign(i),yf.assign(r)}if(this.useAnisotropy){const t=(this.anisotropyNode?z(this.anisotropyNode):_1).toVar();os.assign(t.length()),Le(os.equal(0),()=>{t.assign(z(1,0))}).Else(()=>{t.divAssign(z(os)),os.assign(os.saturate())}),Ph.assign(os.pow2().mix(hn.pow2(),1)),Fl.assign(ea[0].mul(t.x).add(ea[1].mul(t.y))),Js.assign(ea[1].mul(t.x).sub(ea[0].mul(t.y)))}if(this.useTransmission){const t=this.transmissionNode?E(this.transmissionNode):S1,i=this.thicknessNode?E(this.thicknessNode):w1,r=this.attenuationDistanceNode?E(this.attenuationDistanceNode):A1,s=this.attenuationColorNode?D(this.attenuationColorNode):N1;if(Uh.assign(t),_f.assign(i),Mf.assign(r),bf.assign(s),this.useDispersion){const a=this.dispersionNode?E(this.dispersionNode):R1;Tf.assign(a)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?D(this.clearcoatNormalNode):g1}setup(e){e.context.setupClearcoatNormal=()=>this.setupClearcoatNormal(e),super.setup(e)}copy(e){return this.clearcoatNode=e.clearcoatNode,this.clearcoatRoughnessNode=e.clearcoatRoughnessNode,this.clearcoatNormalNode=e.clearcoatNormalNode,this.sheenNode=e.sheenNode,this.sheenRoughnessNode=e.sheenRoughnessNode,this.iridescenceNode=e.iridescenceNode,this.iridescenceIORNode=e.iridescenceIORNode,this.iridescenceThicknessNode=e.iridescenceThicknessNode,this.specularIntensityNode=e.specularIntensityNode,this.specularColorNode=e.specularColorNode,this.transmissionNode=e.transmissionNode,this.thicknessNode=e.thicknessNode,this.attenuationDistanceNode=e.attenuationDistanceNode,this.attenuationColorNode=e.attenuationColorNode,this.dispersionNode=e.dispersionNode,this.anisotropyNode=e.anisotropyNode,super.copy(e)}}class UP extends rd{constructor(e,t,i,r){super(e,t,i),this.useSSS=r}direct({lightDirection:e,lightColor:t,reflectedLight:i},r,s){if(this.useSSS===!0){const a=s.material,{thicknessColorNode:o,thicknessDistortionNode:l,thicknessAmbientNode:c,thicknessAttenuationNode:u,thicknessPowerNode:h,thicknessScaleNode:d}=a,p=e.add(Yt.mul(l)).normalize(),m=E(Vt.dot(p.negate()).saturate().pow(h).mul(d)),v=D(m.add(c).mul(o));i.directDiffuse.addAssign(v.mul(u.mul(t)))}super.direct({lightDirection:e,lightColor:t,reflectedLight:i},r,s)}}class OP extends zb{static get type(){return"MeshSSSNodeMaterial"}constructor(e){super(e),this.thicknessColorNode=null,this.thicknessDistortionNode=E(.1),this.thicknessAmbientNode=E(0),this.thicknessAttenuationNode=E(.1),this.thicknessPowerNode=E(2),this.thicknessScaleNode=E(10)}get useSSS(){return this.thicknessColorNode!==null}setupLightingModel(){return new UP(this.useClearcoat,this.useSheen,this.useIridescence,this.useSSS)}copy(e){return this.thicknessColorNode=e.thicknessColorNode,this.thicknessDistortionNode=e.thicknessDistortionNode,this.thicknessAmbientNode=e.thicknessAmbientNode,this.thicknessAttenuationNode=e.thicknessAttenuationNode,this.thicknessPowerNode=e.thicknessPowerNode,this.thicknessScaleNode=e.thicknessScaleNode,super.copy(e)}}const FP=U(({normal:n,lightDirection:e,builder:t})=>{const i=n.dot(e),r=z(i.mul(.5).add(.5),0);if(t.material.gradientMap){const s=rn("gradientMap","texture").context({getUV:()=>r});return D(s.r)}else{const s=r.fwidth().mul(.5);return rt(D(.7),D(1),Ki(E(.7).sub(s.x),E(.7).add(s.x),r.x))}});class VP extends lc{direct({lightDirection:e,lightColor:t,reflectedLight:i},r,s){const a=FP({normal:Gh,lightDirection:e,builder:s}).mul(t);i.directDiffuse.addAssign(a.mul(ia({diffuseColor:Nt.rgb})))}indirect({ambientOcclusion:e,irradiance:t,reflectedLight:i}){i.indirectDiffuse.addAssign(t.mul(ia({diffuseColor:Nt}))),i.indirectDiffuse.mulAssign(e)}}const BP=new Nm;class zP extends bt{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(BP),this.setValues(e)}setupLightingModel(){return new VP}}class kb extends pt{static get type(){return"MatcapUVNode"}constructor(){super("vec2")}setup(){const e=D(Vt.z,0,Vt.x.negate()).normalize(),t=Vt.cross(e);return z(e.dot(Yt),t.dot(Yt)).mul(.495).add(.5)}}const Hb=ge(kb),kP=new Cm;class HP extends bt{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.lights=!1,this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(kP),this.setValues(e)}setupVariants(e){const t=Hb;let i;e.material.matcap?i=rn("matcap","texture").context({getUV:()=>t}):i=D(rt(.2,.8,t.y)),Nt.rgb.mulAssign(i.rgb)}}const GP=new Ja;class WP extends bt{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.isPointsNodeMaterial=!0,this.lights=!1,this.transparent=!0,this.sizeNode=null,this.setDefaultValues(GP),this.setValues(e)}copy(e){return this.sizeNode=e.sizeNode,super.copy(e)}}class Gb extends pt{static get type(){return"RotateNode"}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}getNodeType(e){return this.positionNode.getNodeType(e)}setup(e){const{rotationNode:t,positionNode:i}=this;if(this.getNodeType(e)==="vec2"){const r=t.cos(),s=t.sin();return Dl(r,s,s.negate(),r).mul(i)}else{const r=t,s=qs(ae(1,0,0,0),ae(0,br(r.x),Ci(r.x).negate(),0),ae(0,Ci(r.x),br(r.x),0),ae(0,0,0,1)),a=qs(ae(br(r.y),0,Ci(r.y),0),ae(0,1,0,0),ae(Ci(r.y).negate(),0,br(r.y),0),ae(0,0,0,1)),o=qs(ae(br(r.z),Ci(r.z).negate(),0,0),ae(Ci(r.z),br(r.z),0,0),ae(0,0,1,0),ae(0,0,0,1));return s.mul(a).mul(o).mul(ae(i,1)).xyz}}}const wg=K(Gb),jP=new cl;class XP extends bt{static get type(){return"SpriteNodeMaterial"}constructor(e){super(),this.isSpriteNodeMaterial=!0,this.lights=!1,this._useSizeAttenuation=!0,this.positionNode=null,this.rotationNode=null,this.scaleNode=null,this.setDefaultValues(jP),this.setValues(e)}setupPosition({object:e,camera:t,context:i}){const r=this.sizeAttenuation,{positionNode:s,rotationNode:a,scaleNode:o}=this,l=Zt;let c=pn.mul(D(s||0)),u=z(Br[0].xyz.length(),Br[1].xyz.length());o!==null&&(u=u.mul(o)),!r&&t.isPerspectiveCamera&&(u=u.mul(c.z.negate()));let h=l.xy;if(e.center&&e.center.isVector2===!0){const v=G2("center","vec2");h=h.sub(v.sub(.5))}h=h.mul(u);const d=E(a||v1),p=wg(h,d);c=ae(c.xy.add(p),c.zw);const m=lr.mul(c);return i.vertex=l,m}copy(e){return this.positionNode=e.positionNode,this.rotationNode=e.rotationNode,this.scaleNode=e.scaleNode,super.copy(e)}get sizeAttenuation(){return this._useSizeAttenuation}set sizeAttenuation(e){this._useSizeAttenuation!==e&&(this._useSizeAttenuation=e,this.needsUpdate=!0)}}class qP extends lc{constructor(){super(),this.shadowNode=E(1).toVar("shadowMask")}direct({shadowMask:e}){this.shadowNode.mulAssign(e)}finish(e){Nt.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(Nt.rgb)}}const YP=new ah;class $P extends bt{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.setDefaultValues(YP),this.setValues(e)}setupLightingModel(){return new qP}}const JP=U(({texture:n,uv:e})=>{const t=D().toVar();return Le(e.x.lessThan(1e-4),()=>{t.assign(D(1,0,0))}).ElseIf(e.y.lessThan(1e-4),()=>{t.assign(D(0,1,0))}).ElseIf(e.z.lessThan(1e-4),()=>{t.assign(D(0,0,1))}).ElseIf(e.x.greaterThan(1-1e-4),()=>{t.assign(D(-1,0,0))}).ElseIf(e.y.greaterThan(1-1e-4),()=>{t.assign(D(0,-1,0))}).ElseIf(e.z.greaterThan(1-1e-4),()=>{t.assign(D(0,0,-1))}).Else(()=>{const i=n.uv(e.add(D(-.01,0,0))).r.sub(n.uv(e.add(D(.01,0,0))).r),r=n.uv(e.add(D(0,-.01,0))).r.sub(n.uv(e.add(D(0,.01,0))).r),s=n.uv(e.add(D(0,0,-.01))).r.sub(n.uv(e.add(D(0,0,.01))).r);t.assign(D(i,r,s))}),t.normalize()});class Wb extends dn{static get type(){return"Texture3DNode"}constructor(e,t=null,i=null){super(e,t,i),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return D(.5,.5,.5)}setUpdateMatrix(){}setupUV(e,t){return t}generateUV(e,t){return t.build(e,"vec3")}normal(e){return JP({texture:this,uv:e})}}const jb=K(Wb);class KP extends bt{static get type(){return"VolumeNodeMaterial"}constructor(e={}){super(),this.lights=!1,this.isVolumeNodeMaterial=!0,this.testNode=null,this.setValues(e)}setup(e){const t=jb(this.map,null,0),i=U(({orig:r,dir:s})=>{const a=D(-.5),o=D(.5),l=s.reciprocal(),c=a.sub(r).mul(l),u=o.sub(r).mul(l),h=xi(c,u),d=ft(c,u),p=ft(h.x,ft(h.y,h.z)),m=xi(d.x,xi(d.y,d.z));return z(p,m)});this.fragmentNode=U(()=>{const r=Ii(D(BM.mul(ae(Gf,1)))),s=Ii(Li.sub(r)).normalize(),a=z(i({orig:r,dir:s})).toVar();a.x.greaterThan(a.y).discard(),a.assign(z(ft(a.x,0),a.y));const o=D(r.add(a.x.mul(s))).toVar(),l=D(s.abs().reciprocal()).toVar(),c=E(xi(l.x,xi(l.y,l.z))).toVar("delta");c.divAssign(rn("steps","float"));const u=ae(rn("base","color"),0).toVar();return gt({type:"float",start:a.x,end:a.y,update:"+= delta"},()=>{const h=ar("float","d").assign(t.uv(o.add(.5)).r);this.testNode!==null?this.testNode({map:t,mapValue:h,probe:o,finalColor:u}).append():(u.a.assign(1),Zh()),o.addAssign(s.mul(c))}),u.a.equal(0).discard(),ae(u)})(),super.setup(e)}}class Xb extends Hi{constructor(e){super(e),this.textures={},this.nodes={}}load(e,t,i,r){const s=new Kr(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,a=>{try{t(this.parse(JSON.parse(a)))}catch(o){r?r(o):console.error(o),this.manager.itemError(e)}},i,r)}parseNodes(e){const t={};if(e!==void 0){for(const r of e){const{uuid:s,type:a}=r;t[s]=this.createNodeFromType(a),t[s].uuid=s}const i={nodes:t,textures:this.textures};for(const r of e)r.meta=i,t[r.uuid].deserialize(r),delete r.meta}return t}parse(e){const t=this.createNodeFromType(e.type);t.uuid=e.uuid;const i={nodes:this.parseNodes(e.nodes),textures:this.textures};return e.meta=i,t.deserialize(e),delete e.meta,t}setTextures(e){return this.textures=e,this}setNodes(e){return this.nodes=e,this}createNodeFromType(e){return this.nodes[e]===void 0?(console.error("THREE.NodeLoader: Node type not found:",e),E()):G(new this.nodes[e])}}class qb extends _c{constructor(e){super(e),this.nodes={},this.nodeMaterials={}}parse(e){const t=super.parse(e),i=this.nodes,r=e.inputNodes;for(const s in r){const a=r[s];t[s]=i[a]}return t}setNodes(e){return this.nodes=e,this}setNodeMaterials(e){return this.nodeMaterials=e,this}createMaterialFromType(e){const t=this.nodeMaterials[e];return t!==void 0?new t:super.createMaterialFromType(e)}}class ZP extends nx{constructor(e){super(e),this.nodes={},this.nodeMaterials={},this._nodesJSON=null}setNodes(e){return this.nodes=e,this}setNodeMaterials(e){return this.nodeMaterials=e,this}parse(e,t){this._nodesJSON=e.nodes;const i=super.parse(e,t);return this._nodesJSON=null,i}parseNodes(e,t){if(e!==void 0){const i=new Xb;return i.setNodes(this.nodes),i.setTextures(t),i.parseNodes(e)}return{}}parseMaterials(e,t){const i={};if(e!==void 0){const r=this.parseNodes(this._nodesJSON,t),s=new qb;s.setTextures(t),s.setNodes(r),s.setNodeMaterials(this.nodeMaterials);for(let a=0,o=e.length;a<o;a++){const l=e[a];i[l.uuid]=s.parse(l)}}return i}}class Eg{constructor(e,t,i=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=i}}class Yb{constructor(e,t,i){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=i.getSelf()}get value(){return this.node.value}set value(e){this.node.value=e}get id(){return this.node.id}get groupNode(){return this.node.groupNode}}class Ag{constructor(e,t){this.isNodeVar=!0,this.name=e,this.type=t}}class $b extends Ag{constructor(e,t){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0}}class Jb{constructor(e,t,i=""){this.name=e,this.type=t,this.code=i,Object.defineProperty(this,"isNodeCode",{value:!0})}}let QP=0;class ld{constructor(e=null){this.id=QP++,this.nodesData=new WeakMap,this.parent=e}getData(e){let t=this.nodesData.get(e);return t===void 0&&this.parent!==null&&(t=this.parent.getData(e)),t}setData(e,t){this.nodesData.set(e,t)}}class Ng extends Et{static get type(){return"ParameterNode"}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getHash(){return this.uuid}generate(){return this.name}}const e3=(n,e)=>G(new Ng(n,e));class Cg extends qe{static get type(){return"CodeNode"}constructor(e="",t=[],i=""){super("code"),this.isCodeNode=!0,this.code=e,this.language=i,this.includes=t}isGlobal(){return!0}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){const t=this.getIncludes(e);for(const r of t)r.build(e);const i=e.getCodeFromNode(this,this.getNodeType(e));return i.code=this.code,i.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}}const cd=K(Cg),t3=(n,e)=>cd(n,e,"js"),i3=(n,e)=>cd(n,e,"wgsl"),r3=(n,e)=>cd(n,e,"glsl");class Rg extends Cg{static get type(){return"FunctionNode"}constructor(e="",t=[],i=""){super(e,t,i)}getNodeType(e){return this.getNodeFunction(e).type}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){const t=e.getDataFromNode(this);let i=t.nodeFunction;return i===void 0&&(i=e.parser.parseFunction(this.code),t.nodeFunction=i),i}generate(e,t){super.generate(e);const i=this.getNodeFunction(e),r=i.name,s=i.type,a=e.getCodeFromNode(this,s);r!==""&&(a.name=r);const o=e.getPropertyName(a),l=this.getNodeFunction(e).getCode(o);return a.code=l+`
|
|
3867
|
+
`,t==="property"?o:e.format(`${o}()`,s,t)}}const Kb=(n,e=[],t="")=>{for(let s=0;s<e.length;s++){const a=e[s];typeof a=="function"&&(e[s]=a.functionNode)}const i=G(new Rg(n,e,t)),r=(...s)=>i.call(...s);return r.functionNode=i,r},n3=(n,e)=>Kb(n,e,"glsl"),s3=(n,e)=>Kb(n,e,"wgsl");class ra{constructor(e,t){this.name=e,this.value=t,this.boundary=0,this.itemSize=0,this.offset=0}setValue(e){this.value=e}getValue(){return this.value}}class a3 extends ra{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class o3 extends ra{constructor(e,t=new J){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class l3 extends ra{constructor(e,t=new N){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class c3 extends ra{constructor(e,t=new st){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class u3 extends ra{constructor(e,t=new xe){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class h3 extends ra{constructor(e,t=new Ke){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class d3 extends ra{constructor(e,t=new Re){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class p3 extends a3{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class m3 extends o3{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class f3 extends l3{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class g3 extends c3{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class v3 extends u3{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class y3 extends h3{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class x3 extends d3{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class Zb extends qe{static get type(){return"StackNode"}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this.isStackNode=!0}getNodeType(e){return this.outputNode?this.outputNode.getNodeType(e):"void"}add(e){return this.nodes.push(e),this}If(e,t){const i=new Il(t);return this._currentCond=Ri(e,i),this.add(this._currentCond)}ElseIf(e,t){const i=new Il(t),r=Ri(e,i);return this._currentCond.elseNode=r,this._currentCond=r,this}Else(e){return this._currentCond.elseNode=new Il(e),this}build(e,...t){const i=df();Pl(this);for(const r of this.nodes)r.build(e,"void");return Pl(i),this.outputNode?this.outputNode.build(e,...t):super.build(e,...t)}else(...e){return console.warn("TSL.StackNode: .else() has been renamed to .Else()."),this.Else(...e)}elseif(...e){return console.warn("TSL.StackNode: .elseif() has been renamed to .ElseIf()."),this.ElseIf(...e)}}const ud=K(Zb);class _3{constructor(){this.weakMap=new WeakMap}get(e){let t=this.weakMap;for(let i=0;i<e.length;i++)if(t=t.get(e[i]),t===void 0)return;return t.get(e[e.length-1])}set(e,t){let i=this.weakMap;for(let r=0;r<e.length;r++){const s=e[r];i.has(s)===!1&&i.set(s,new WeakMap),i=i.get(s)}return i.set(e[e.length-1],t)}delete(e){let t=this.weakMap;for(let i=0;i<e.length;i++)if(t=t.get(e[i]),t===void 0)return!1;return t.delete(e[e.length-1])}}const vo=4,Qb=[.125,.215,.35,.446,.526,.582],na=20,Ig=new Is(-1,1,1,-1,0,1),M3=new di(90,1),eT=new xe;let Lg=null,Pg=0,Dg=0;const sa=(1+Math.sqrt(5))/2,yo=1/sa,tT=[new N(-sa,yo,0),new N(sa,yo,0),new N(-yo,0,sa),new N(yo,0,sa),new N(0,sa,-yo),new N(0,sa,yo),new N(-1,1,-1),new N(1,1,-1),new N(-1,1,1),new N(1,1,1)],b3=[3,1,5,0,4,2],Ug=Rb(nt(),_i("faceIndex")).normalize(),Og=D(Ug.x,Ug.y.negate(),Ug.z);class T3{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}fromScene(e,t=0,i=.1,r=100){Lg=this._renderer.getRenderTarget(),Pg=this._renderer.getActiveCubeFace(),Dg=this._renderer.getActiveMipmapLevel(),this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,i,r,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}async compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=rT(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=nT(),await this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(Lg,Pg,Dg),e.scissorTest=!1,hd(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===fr||e.mapping===Ar?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Lg=this._renderer.getRenderTarget(),Pg=this._renderer.getActiveCubeFace(),Dg=this._renderer.getActiveMipmapLevel();const i=t||this._allocateTargets();return this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,i={magFilter:Lt,minFilter:Lt,generateMipmaps:!1,type:wi,format:Ei,colorSpace:nr},r=iT(e,t,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=iT(e,t,i);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas,lodMeshes:this._lodMeshes}=S3(s)),this._blurMaterial=w3(s,e,t)}return r}async _compileMaterial(e){const t=new Ft(this._lodPlanes[0],e);await this._renderer.compile(t,Ig)}_sceneToCubeUV(e,t,i,r){const s=M3;s.near=t,s.far=i;const a=[-1,1,-1,-1,-1,-1],o=[1,1,1,-1,-1,-1],l=this._renderer,c=l.autoClear;l.getClearColor(eT),l.autoClear=!1;let u=this._backgroundBox;if(u===null){const p=new Yr({name:"PMREM.Background",side:si,depthWrite:!1,depthTest:!1});u=new Ft(new yn,p)}let h=!1;const d=e.background;d?d.isColor&&(u.material.color.copy(d),e.background=null,h=!0):(u.material.color.copy(eT),h=!0),l.setRenderTarget(r),l.clear(),h&&l.render(u,s);for(let p=0;p<6;p++){const m=p%3;m===0?(s.up.set(0,a[p],0),s.lookAt(o[p],0,0)):m===1?(s.up.set(0,0,a[p]),s.lookAt(0,o[p],0)):(s.up.set(0,a[p],0),s.lookAt(0,0,o[p]));const v=this._cubeSize;hd(r,m*v,p>2?v:0,v,v),l.render(e,s)}l.autoClear=c,e.background=d}_textureToCubeUV(e,t){const i=this._renderer,r=e.mapping===fr||e.mapping===Ar;r?this._cubemapMaterial===null&&(this._cubemapMaterial=rT(e)):this._equirectMaterial===null&&(this._equirectMaterial=nT(e));const s=r?this._cubemapMaterial:this._equirectMaterial;s.fragmentNode.value=e;const a=this._lodMeshes[0];a.material=s;const o=this._cubeSize;hd(t,0,0,3*o,2*o),i.setRenderTarget(t),i.render(a,Ig)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;const r=this._lodPlanes.length;for(let s=1;s<r;s++){const a=Math.sqrt(this._sigmas[s]*this._sigmas[s]-this._sigmas[s-1]*this._sigmas[s-1]),o=tT[(r-s-1)%tT.length];this._blur(e,s-1,s,a,o)}t.autoClear=i}_blur(e,t,i,r,s){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,i,r,"latitudinal",s),this._halfBlur(a,e,i,i,r,"longitudinal",s)}_halfBlur(e,t,i,r,s,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const u=3,h=this._lodMeshes[r];h.material=c;const d=c.uniforms,p=this._sizeLods[i]-1,m=isFinite(s)?Math.PI/(2*p):2*Math.PI/(2*na-1),v=s/m,f=isFinite(s)?1+Math.floor(u*v):na;f>na&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${f} samples when the maximum is set to ${na}`);const g=[];let x=0;for(let w=0;w<na;++w){const C=w/v,H=Math.exp(-C*C/2);g.push(H),w===0?x+=H:w<f&&(x+=2*H)}for(let w=0;w<g.length;w++)g[w]=g[w]/x;e.texture.frame=(e.texture.frame||0)+1,d.envMap.value=e.texture,d.samples.value=f,d.weights.array=g,d.latitudinal.value=a==="latitudinal"?1:0,o&&(d.poleAxis.value=o);const{_lodMax:y}=this;d.dTheta.value=m,d.mipInt.value=y-i;const _=this._sizeLods[r],I=3*_*(r>y-vo?r-y+vo:0),b=4*(this._cubeSize-_);hd(t,I,b,3*_,2*_),l.setRenderTarget(t),l.render(h,Ig)}}function S3(n){const e=[],t=[],i=[],r=[];let s=n;const a=n-vo+1+Qb.length;for(let o=0;o<a;o++){const l=Math.pow(2,s);t.push(l);let c=1/l;o>n-vo?c=Qb[o-n+vo-1]:o===0&&(c=0),i.push(c);const u=1/(l-2),h=-u,d=1+u,p=[h,h,d,h,d,d,h,h,d,d,h,d],m=6,v=6,f=3,g=2,x=1,y=new Float32Array(f*v*m),_=new Float32Array(g*v*m),I=new Float32Array(x*v*m);for(let w=0;w<m;w++){const C=w%3*2/3-1,H=w>2?0:-1,M=[C,H,0,C+2/3,H,0,C+2/3,H+1,0,C,H,0,C+2/3,H+1,0,C,H+1,0],T=b3[w];y.set(M,f*v*T),_.set(p,g*v*T);const k=[T,T,T,T,T,T];I.set(k,x*v*T)}const b=new ct;b.setAttribute("position",new wt(y,f)),b.setAttribute("uv",new wt(_,g)),b.setAttribute("faceIndex",new wt(I,x)),e.push(b),r.push(new Ft(b,null)),s>vo&&s--}return{lodPlanes:e,sizeLods:t,sigmas:i,lodMeshes:r}}function iT(n,e,t){const i=new ui(n,e,t);return i.texture.mapping=ys,i.texture.name="PMREM.cubeUv",i.texture.isPMREMTexture=!0,i.scissorTest=!0,i}function hd(n,e,t,i,r){n.viewport.set(e,t,i,r),n.scissor.set(e,t,i,r)}function Fg(n){const e=new bt;return e.depthTest=!1,e.depthWrite=!1,e.blending=Er,e.name=`PMREM_${n}`,e}function w3(n,e,t){const i=mn(new Array(na).fill(0)),r=fe(new N(0,1,0)),s=fe(0),a=E(na),o=fe(0),l=fe(1),c=yt(null),u=fe(0),h=E(1/e),d=E(1/t),p=E(n),m={n:a,latitudinal:o,weights:i,poleAxis:r,outputDirection:Og,dTheta:s,samples:l,envMap:c,mipInt:u,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:p},v=Fg("blur");return v.uniforms=m,v.fragmentNode=Lb({...m,latitudinal:o.equal(1)}),v}function rT(n){const e=Fg("cubemap");return e.fragmentNode=jh(n,Og),e}function nT(n){const e=Fg("equirect");return e.fragmentNode=yt(n,ug(Og),0),e}let E3=0;class sT{constructor(e="",t=[],i=0,r=[]){this.name=e,this.bindings=t,this.index=i,this.bindingsReference=r,this.id=E3++}}const aT=new WeakMap,A3=new Map([[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),N3=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),dd=n=>(n=Number(n),n+(n%1?"":".0"));class oT{constructor(e,t,i){this.object=e,this.material=e&&e.material||null,this.geometry=e&&e.geometry||null,this.renderer=t,this.parser=i,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=ud(),this.stacks=[],this.tab=" ",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new ld,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null,this.useComparisonMethod=!1}getBindGroupsCache(){let e=aT.get(this.renderer);return e===void 0&&(e=new _3,aT.set(this.renderer,e)),e}createRenderTarget(e,t,i){return new ui(e,t,i)}createCubeRenderTarget(e,t){return new sb(e,t)}createPMREMGenerator(){return new T3(this.renderer)}includes(e){return this.nodes.includes(e)}_getBindGroup(e,t){const i=this.getBindGroupsCache(),r=[];let s=!0;for(const o of t)r.push(o),s=s&&o.groupNode.shared!==!0;let a;return s?(a=i.get(r),a===void 0&&(a=new sT(e,r,this.bindingsIndexes[e].group,r),i.set(r,a))):a=new sT(e,r,this.bindingsIndexes[e].group,r),a}getBindGroupArray(e,t){const i=this.bindings[t];let r=i[e];return r===void 0&&(this.bindingsIndexes[e]===void 0&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),i[e]=r=[]),r}getBindings(){let e=this.bindGroups;if(e===null){const t={},i=this.bindings;for(const r of nf)for(const s in i[r]){const a=i[r][s];(t[s]||(t[s]=[])).push(...a)}e=[];for(const r in t){const s=t[r],a=this._getBindGroup(r,s);e.push(a)}this.bindGroups=e}return e}sortBindingGroups(){const e=this.getBindings();e.sort((t,i)=>t.bindings[0].groupNode.order-i.bindings[0].groupNode.order);for(let t=0;t<e.length;t++){const i=e[t];this.bindingsIndexes[i.name].group=t,i.index=t}}setHashNode(e,t){this.hashNodes[t]=e}addNode(e){this.nodes.includes(e)===!1&&(this.nodes.push(e),this.setHashNode(e,e.getHash(this)))}buildUpdateNodes(){for(const e of this.nodes){const t=e.getUpdateType(),i=e.getUpdateBeforeType(),r=e.getUpdateAfterType();t!==je.NONE&&this.updateNodes.push(e.getSelf()),i!==je.NONE&&this.updateBeforeNodes.push(e.getSelf()),r!==je.NONE&&this.updateAfterNodes.push(e.getSelf())}}get currentNode(){return this.chaining[this.chaining.length-1]}isFilteredTexture(e){return e.magFilter===Lt||e.magFilter===Gn||e.magFilter===Mn||e.magFilter===ji||e.minFilter===Lt||e.minFilter===Gn||e.minFilter===Mn||e.minFilter===ji}addChain(e){this.chaining.push(e)}removeChain(e){if(this.chaining.pop()!==e)throw new Error("NodeBuilder: Invalid node chaining!")}getMethod(e){return e}getNodeFromHash(e){return this.hashNodes[e]}addFlow(e,t){return this.flowNodes[e].push(t),t}setContext(e){this.context=e}getContext(){return this.context}getSharedContext(){return{...this.context},this.context}setCache(e){this.cache=e}getCache(){return this.cache}getCacheFromNode(e,t=!0){const i=this.getDataFromNode(e);return i.cache===void 0&&(i.cache=new ld(t?this.getCache():null)),i.cache}isAvailable(){return!1}getVertexIndex(){console.warn("Abstract function.")}getInstanceIndex(){console.warn("Abstract function.")}getDrawIndex(){console.warn("Abstract function.")}getFrontFacing(){console.warn("Abstract function.")}getFragCoord(){console.warn("Abstract function.")}isFlipY(){return!1}increaseUsage(e){const t=this.getDataFromNode(e);return t.usageCount=t.usageCount===void 0?1:t.usageCount+1,t.usageCount}generateTexture(){console.warn("Abstract function.")}generateTextureLod(){console.warn("Abstract function.")}generateConst(e,t=null){if(t===null&&(e==="float"||e==="int"||e==="uint"?t=0:e==="bool"?t=!1:e==="color"?t=new xe:e==="vec2"?t=new J:e==="vec3"?t=new N:e==="vec4"&&(t=new st)),e==="float")return dd(t);if(e==="int")return`${Math.round(t)}`;if(e==="uint")return t>=0?`${Math.round(t)}u`:"0u";if(e==="bool")return t?"true":"false";if(e==="color")return`${this.getType("vec3")}( ${dd(t.r)}, ${dd(t.g)}, ${dd(t.b)} )`;const i=this.getTypeLength(e),r=this.getComponentType(e),s=a=>this.generateConst(r,a);if(i===2)return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)} )`;if(i===3)return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)}, ${s(t.z)} )`;if(i===4)return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)}, ${s(t.z)}, ${s(t.w)} )`;if(i>4&&t&&(t.isMatrix3||t.isMatrix4))return`${this.getType(e)}( ${t.elements.map(s).join(", ")} )`;if(i>4)return`${this.getType(e)}()`;throw new Error(`NodeBuilder: Type '${e}' not found in generate constant attempt.`)}getType(e){return e==="color"?"vec3":e}hasGeometryAttribute(e){return this.geometry&&this.geometry.getAttribute(e)!==void 0}getAttribute(e,t){const i=this.attributes;for(const s of i)if(s.name===e)return s;const r=new Eg(e,t);return i.push(r),r}getPropertyName(e){return e.name}isVector(e){return/vec\d/.test(e)}isMatrix(e){return/mat\d/.test(e)}isReference(e){return e==="void"||e==="property"||e==="sampler"||e==="texture"||e==="cubeTexture"||e==="storageTexture"||e==="depthTexture"||e==="texture3D"}needsToWorkingColorSpace(){return!1}getComponentTypeFromTexture(e){const t=e.type;if(e.isDataTexture){if(t===ga)return"int";if(t===Nr)return"uint"}return"float"}getElementType(e){return e==="mat2"?"vec2":e==="mat3"?"vec3":e==="mat4"?"vec4":this.getComponentType(e)}getComponentType(e){if(e=this.getVectorType(e),e==="float"||e==="bool"||e==="int"||e==="uint")return e;const t=/(b|i|u|)(vec|mat)([2-4])/.exec(e);return t===null?null:t[1]==="b"?"bool":t[1]==="i"?"int":t[1]==="u"?"uint":"float"}getVectorType(e){return e==="color"?"vec3":e==="texture"||e==="cubeTexture"||e==="storageTexture"||e==="texture3D"?"vec4":e}getTypeFromLength(e,t="float"){if(e===1)return t;const i=A3.get(e);return(t==="float"?"":t[0])+i}getTypeFromArray(e){return N3.get(e.constructor)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);const i=t.array,r=e.itemSize,s=e.normalized;let a;return!(e instanceof wv)&&s!==!0&&(a=this.getTypeFromArray(i)),this.getTypeFromLength(r,a)}getTypeLength(e){const t=this.getVectorType(e),i=/vec([2-4])/.exec(t);return i!==null?Number(i[1]):t==="float"||t==="bool"||t==="int"||t==="uint"?1:/mat2/.test(e)===!0?4:/mat3/.test(e)===!0?9:/mat4/.test(e)===!0?16:0}getVectorFromMatrix(e){return e.replace("mat","vec")}changeComponentType(e,t){return this.getTypeFromLength(this.getTypeLength(e),t)}getIntegerType(e){const t=this.getComponentType(e);return t==="int"||t==="uint"?e:this.changeComponentType(e,"int")}addStack(){return this.stack=ud(this.stack),this.stacks.push(df()||this.stack),Pl(this.stack),this.stack}removeStack(){const e=this.stack;return this.stack=e.parent,Pl(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,i=null){i=i===null?e.isGlobal(this)?this.globalCache:this.cache:i;let r=i.getData(e);return r===void 0&&(r={},i.setData(e,r)),r[t]===void 0&&(r[t]={}),r[t]}getNodeProperties(e,t="any"){const i=this.getDataFromNode(e,t);return i.properties||(i.properties={outputNode:null})}getBufferAttributeFromNode(e,t){const i=this.getDataFromNode(e);let r=i.bufferAttribute;if(r===void 0){const s=this.uniforms.index++;r=new Eg("nodeAttribute"+s,t,e),this.bufferAttributes.push(r),i.bufferAttribute=r}return r}getStructTypeFromNode(e,t=this.shaderStage){const i=this.getDataFromNode(e,t);if(i.structType===void 0){const r=this.structs.index++;e.name=`StructType${r}`,this.structs[t].push(e),i.structType=e}return e}getUniformFromNode(e,t,i=this.shaderStage,r=null){r==="in"&&(console.warn('NodeBuilder: "in" is a reserved word, using "inValue" instead.',e,r),e.name="inValue",r=e.name);const s=this.getDataFromNode(e,i,this.globalCache);let a=s.uniform;if(a===void 0){const o=this.uniforms.index++;a=new Yb(r||"nodeUniform"+o,t,e),this.uniforms[i].push(a),s.uniform=a}return a}getVarFromNode(e,t=null,i=e.getNodeType(this),r=this.shaderStage){const s=this.getDataFromNode(e,r);let a=s.variable;if(a===void 0){const o=this.vars[r]||(this.vars[r]=[]);t===null&&(t="nodeVar"+o.length),a=new Ag(t,i),o.push(a),s.variable=a}return a}getVaryingFromNode(e,t=null,i=e.getNodeType(this)){const r=this.getDataFromNode(e,"any");let s=r.varying;if(s===void 0){const a=this.varyings,o=a.length;t===null&&(t="nodeVarying"+o),s=new $b(t,i),a.push(s),r.varying=s}return s}getCodeFromNode(e,t,i=this.shaderStage){const r=this.getDataFromNode(e);let s=r.code;if(s===void 0){const a=this.codes[i]||(this.codes[i]=[]),o=a.length;s=new Jb("nodeCode"+o,t),a.push(s),r.code=s}return s}addFlowCodeHierarchy(e,t){const{flowCodes:i,flowCodeBlock:r}=this.getDataFromNode(e);let s=!0,a=t;for(;a;){if(r.get(a)===!0){s=!1;break}a=this.getDataFromNode(a).parentNodeBlock}if(s)for(const o of i)this.addLineFlowCode(o)}addLineFlowCodeBlock(e,t,i){const r=this.getDataFromNode(e),s=r.flowCodes||(r.flowCodes=[]),a=r.flowCodeBlock||(r.flowCodeBlock=new WeakMap);s.push(t),a.set(i,!0)}addLineFlowCode(e,t=null){return e===""?this:(t!==null&&this.context.nodeBlock&&this.addLineFlowCodeBlock(t,e,this.context.nodeBlock),e=this.tab+e,/;\s*$/.test(e)||(e=e+`;
|
|
3868
|
+
`),this.flow.code+=e,this)}addFlowCode(e){return this.flow.code+=e,this}addFlowTab(){return this.tab+=" ",this}removeFlowTab(){return this.tab=this.tab.slice(0,-1),this}getFlowData(e){return this.flowsData.get(e)}flowNode(e){const t=e.getNodeType(this),i=this.flowChildNode(e,t);return this.flowsData.set(e,i),i}buildFunctionNode(e){const t=new Rg,i=this.currentFunctionNode;return this.currentFunctionNode=t,t.code=this.buildFunctionCode(e),this.currentFunctionNode=i,t}flowShaderNode(e){const t=e.layout,i={[Symbol.iterator](){let a=0;const o=Object.values(this);return{next:()=>({value:o[a],done:a++>=o.length})}}};for(const a of t.inputs)i[a.name]=new Ng(a.type,a.name);e.layout=null;const r=e.call(i),s=this.flowStagesNode(r,t.type);return e.layout=t,s}flowStagesNode(e,t=null){const i=this.flow,r=this.vars,s=this.cache,a=this.buildStage,o=this.stack,l={code:""};this.flow=l,this.vars={},this.cache=new ld,this.stack=ud();for(const c of rf)this.setBuildStage(c),l.result=e.build(this,t);return l.vars=this.getVars(this.shaderStage),this.flow=i,this.vars=r,this.cache=s,this.stack=o,this.setBuildStage(a),l}getFunctionOperator(){return null}flowChildNode(e,t=null){const i=this.flow,r={code:""};return this.flow=r,r.result=e.build(this,t),this.flow=i,r}flowNodeFromShaderStage(e,t,i=null,r=null){const s=this.shaderStage;this.setShaderStage(e);const a=this.flowChildNode(t,i);return r!==null&&(a.code+=`${this.tab+r} = ${a.result};
|
|
3869
3869
|
`),this.flowCode[e]=this.flowCode[e]+a.code,this.setShaderStage(s),a}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){console.warn("Abstract function.")}getVaryings(){console.warn("Abstract function.")}getVar(e,t){return`${this.getType(e)} ${t}`}getVars(e){let t="";const i=this.vars[e];if(i!==void 0)for(const r of i)t+=`${this.getVar(r.type,r.name)}; `;return t}getUniforms(){console.warn("Abstract function.")}getCodes(e){const t=this.codes[e];let i="";if(t!==void 0)for(const r of t)i+=r.code+`
|
|
3870
|
-
`;return i}getHash(){return this.vertexShader+this.fragmentShader+this.computeShader}setShaderStage(e){this.shaderStage=e}getShaderStage(){return this.shaderStage}setBuildStage(e){this.buildStage=e}getBuildStage(){return this.buildStage}buildCode(){console.warn("Abstract function.")}build(){const{object:e,material:t,renderer:i}=this;if(t!==null){let r=i.nodes.library.fromMaterial(t);r===null&&(console.error(`NodeMaterial: Material "${t.type}" is not compatible.`),r=new bt),r.build(this)}else this.addFlow("compute",e);for(const r of
|
|
3871
|
-
`}}class cT{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.startTime=null,this.updateMap=new WeakMap,this.updateBeforeMap=new WeakMap,this.updateAfterMap=new WeakMap,this.renderer=null,this.material=null,this.camera=null,this.object=null,this.scene=null}_getMaps(e,t){let i=e.get(t);return i===void 0&&(i={renderMap:new WeakMap,frameMap:new WeakMap},e.set(t,i)),i}updateBeforeNode(e){const t=e.getUpdateBeforeType(),i=e.updateReference(this);if(t===je.FRAME){const{frameMap:r}=this._getMaps(this.updateBeforeMap,i);r.get(i)!==this.frameId&&e.updateBefore(this)!==!1&&r.set(i,this.frameId)}else if(t===je.RENDER){const{renderMap:r}=this._getMaps(this.updateBeforeMap,i);r.get(i)!==this.renderId&&e.updateBefore(this)!==!1&&r.set(i,this.renderId)}else t===je.OBJECT&&e.updateBefore(this)}updateAfterNode(e){const t=e.getUpdateAfterType(),i=e.updateReference(this);if(t===je.FRAME){const{frameMap:r}=this._getMaps(this.updateAfterMap,i);r.get(i)!==this.frameId&&e.updateAfter(this)!==!1&&r.set(i,this.frameId)}else if(t===je.RENDER){const{renderMap:r}=this._getMaps(this.updateAfterMap,i);r.get(i)!==this.renderId&&e.updateAfter(this)!==!1&&r.set(i,this.renderId)}else t===je.OBJECT&&e.updateAfter(this)}updateNode(e){const t=e.getUpdateType(),i=e.updateReference(this);if(t===je.FRAME){const{frameMap:r}=this._getMaps(this.updateMap,i);r.get(i)!==this.frameId&&e.update(this)!==!1&&r.set(i,this.frameId)}else if(t===je.RENDER){const{renderMap:r}=this._getMaps(this.updateMap,i);r.get(i)!==this.renderId&&e.update(this)!==!1&&r.set(i,this.renderId)}else t===je.OBJECT&&e.update(this)}update(){this.frameId++,this.lastTime===void 0&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}}class Bg{constructor(e,t,i=null,r="",s=!1){this.type=e,this.name=t,this.count=i,this.qualifier=r,this.isConst=s}}Bg.isNodeFunctionInput=!0;class C3 extends qe{static get type(){return"StructTypeNode"}constructor(e){super(),this.types=e,this.isStructTypeNode=!0}getMemberTypes(){return this.types}}class zg extends qe{static get type(){return"OutputStructNode"}constructor(...e){super(),this.members=e,this.isOutputStructNode=!0}setup(e){super.setup(e);const t=this.members,i=[];for(let r=0;r<t.length;r++)i.push(t[r].getNodeType(e));this.nodeType=e.getStructTypeFromNode(new C3(i)).name}generate(e,t){const i=e.getOutputStructName(),r=this.members,s=i!==""?i+".":"";for(let a=0;a<r.length;a++){const o=r[a].build(e,t);e.addLineFlowCode(`${s}m${a} = ${o}`,this)}return i}}const R3=K(zg);function kg(n,e){for(let t=0;t<n.length;t++)if(n[t].name===e)return t;return-1}class uT extends zg{static get type(){return"MRTNode"}constructor(e){super(),this.outputNodes=e,this.isMRTNode=!0}has(e){return this.outputNodes[e]!==void 0}get(e){return this.outputNodes[e]}merge(e){const t={...this.outputNodes,...e.outputNodes};return md(t)}setup(e){const t=this.outputNodes,i=e.renderer.getRenderTarget(),r=[],s=i.textures;for(const a in t){const o=kg(s,a);r[o]=ae(t[a])}return this.members=r,super.setup(e)}}const md=K(uT);class hT extends qe{static get type(){return"FunctionOverloadingNode"}constructor(e=[],...t){super(),this.functionNodes=e,this.parametersNodes=t,this._candidateFnCall=null,this.global=!0}getNodeType(){return this.functionNodes[0].shaderNode.layout.type}setup(e){const t=this.parametersNodes;let i=this._candidateFnCall;if(i===null){let r=null,s=-1;for(const a of this.functionNodes){const o=a.shaderNode.layout;if(o===null)throw new Error("FunctionOverloadingNode: FunctionNode must be a layout.");const l=o.inputs;if(t.length===l.length){let c=0;for(let u=0;u<t.length;u++){const h=t[u],d=l[u];h.getNodeType(e)===d.type?c++:c=0}c>s&&(r=a,s=c)}}this._candidateFnCall=i=r(...t)}return i}}const I3=K(hT),Di=n=>(...e)=>I3(n,...e);class Si extends $s{static get type(){return"TimerNode"}constructor(e=Si.LOCAL,t=1,i=0){super(i),this.scope=e,this.scale=t,this.updateType=je.FRAME}update(e){const t=this.scope,i=this.scale;t===Si.LOCAL?this.value+=e.deltaTime*i:t===Si.DELTA?this.value=e.deltaTime*i:t===Si.FRAME?this.value=e.frameId:this.value=e.time*i}serialize(e){super.serialize(e),e.scope=this.scope,e.scale=this.scale}deserialize(e){super.deserialize(e),this.scope=e.scope,this.scale=e.scale}}Si.LOCAL="local",Si.GLOBAL="global",Si.DELTA="delta",Si.FRAME="frame";const Hg=(n,e=0)=>G(new Si(Si.LOCAL,n,e)),L3=(n,e=0)=>G(new Si(Si.GLOBAL,n,e)),P3=(n,e=0)=>G(new Si(Si.DELTA,n,e)),D3=ge(Si,Si.FRAME).toUint();class gi extends qe{static get type(){return"OscNode"}constructor(e=gi.SINE,t=Hg()){super(),this.method=e,this.timeNode=t}getNodeType(e){return this.timeNode.getNodeType(e)}setup(){const e=this.method,t=G(this.timeNode);let i=null;return e===gi.SINE?i=t.add(.75).mul(Math.PI*2).sin().mul(.5).add(.5):e===gi.SQUARE?i=t.fract().round():e===gi.TRIANGLE?i=t.add(.5).fract().mul(2).sub(1).abs():e===gi.SAWTOOTH&&(i=t.fract()),i}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}gi.SINE="sine",gi.SQUARE="square",gi.TRIANGLE="triangle",gi.SAWTOOTH="sawtooth";const U3=K(gi,gi.SINE),O3=K(gi,gi.SQUARE),F3=K(gi,gi.TRIANGLE),V3=K(gi,gi.SAWTOOTH);class dT extends qe{static get type(){return"SpriteSheetUVNode"}constructor(e,t=nt(),i=E(0)){super("vec2"),this.countNode=e,this.uvNode=t,this.frameNode=i}setup(){const{frameNode:e,uvNode:t,countNode:i}=this,{width:r,height:s}=i,a=e.mod(r.mul(s)).floor(),o=a.mod(r),l=s.sub(a.add(1).div(r).ceil()),c=i.reciprocal(),u=z(o,l);return t.add(u).mul(c)}}const B3=K(dT);class pT extends as{static get type(){return"StorageArrayElementNode"}constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}setup(e){return e.isAvailable("storageBuffer")===!1&&this.node.bufferObject===!0&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let i;const r=e.context.assign;if(e.isAvailable("storageBuffer")===!1?this.node.bufferObject===!0&&r!==!0?i=e.generatePBO(this):i=this.node.build(e):i=super.generate(e),r!==!0){const s=this.getNodeType(e);i=e.format(i,s,t)}return i}}const z3=K(pT);class mT extends qe{static get type(){return"TriplanarTexturesNode"}constructor(e,t=null,i=null,r=E(1),s=Zt,a=ur){super("vec4"),this.textureXNode=e,this.textureYNode=t,this.textureZNode=i,this.scaleNode=r,this.positionNode=s,this.normalNode=a}setup(){const{textureXNode:e,textureYNode:t,textureZNode:i,scaleNode:r,positionNode:s,normalNode:a}=this;let o=a.abs().normalize();o=o.div(o.dot(D(1)));const l=s.yz.mul(r),c=s.zx.mul(r),u=s.xy.mul(r),h=e.value,d=t!==null?t.value:h,p=i!==null?i.value:h,m=yt(h,l).mul(o.x),v=yt(d,c).mul(o.y),f=yt(p,u).mul(o.z);return zt(m,v,f)}}const fT=K(mT),k3=(...n)=>fT(...n),_o=new ln,oa=new N,Mo=new N,Gg=new N,uc=new Re,fd=new N(0,0,-1),Dn=new st,hc=new N,gd=new N,dc=new st,vd=new J,gT=new ui,H3=ps.flipX();let Wg=!1;class vT extends dn{static get type(){return"ReflectorNode"}constructor(e={}){super(gT.texture,H3);const{target:t=new _t,resolution:i=1,generateMipmaps:r=!1,bounces:s=!0}=e;this.target=t,this.resolution=i,this.generateMipmaps=r,this.bounces=s,this.updateBeforeType=s?je.RENDER:je.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new WeakMap}_updateResolution(e,t){const i=this.resolution;t.getDrawingBufferSize(vd),e.setSize(Math.round(vd.width*i),Math.round(vd.height*i))}setup(e){return this._updateResolution(gT,e.renderer),super.setup(e)}getTextureNode(){return this.textureNode}getVirtualCamera(e){let t=this.virtualCameras.get(e);return t===void 0&&(t=e.clone(),this.virtualCameras.set(e,t)),t}getRenderTarget(e){let t=this.renderTargets.get(e);return t===void 0&&(t=new ui(0,0,{type:wi}),this.generateMipmaps===!0&&(t.texture.minFilter=F0,t.texture.generateMipmaps=!0),this.renderTargets.set(e,t)),t}updateBefore(e){if(this.bounces===!1&&Wg)return!1;Wg=!0;const{scene:t,camera:i,renderer:r,material:s}=e,{target:a}=this,o=this.getVirtualCamera(i),l=this.getRenderTarget(o);if(r.getDrawingBufferSize(vd),this._updateResolution(l,r),Mo.setFromMatrixPosition(a.matrixWorld),Gg.setFromMatrixPosition(i.matrixWorld),uc.extractRotation(a.matrixWorld),oa.set(0,0,1),oa.applyMatrix4(uc),hc.subVectors(Mo,Gg),hc.dot(oa)>0)return;hc.reflect(oa).negate(),hc.add(Mo),uc.extractRotation(i.matrixWorld),fd.set(0,0,-1),fd.applyMatrix4(uc),fd.add(Gg),gd.subVectors(Mo,fd),gd.reflect(oa).negate(),gd.add(Mo),o.coordinateSystem=i.coordinateSystem,o.position.copy(hc),o.up.set(0,1,0),o.up.applyMatrix4(uc),o.up.reflect(oa),o.lookAt(gd),o.near=i.near,o.far=i.far,o.updateMatrixWorld(),o.projectionMatrix.copy(i.projectionMatrix),_o.setFromNormalAndCoplanarPoint(oa,Mo),_o.applyMatrix4(o.matrixWorldInverse),Dn.set(_o.normal.x,_o.normal.y,_o.normal.z,_o.constant);const c=o.projectionMatrix;dc.x=(Math.sign(Dn.x)+c.elements[8])/c.elements[0],dc.y=(Math.sign(Dn.y)+c.elements[9])/c.elements[5],dc.z=-1,dc.w=(1+c.elements[10])/c.elements[14],Dn.multiplyScalar(1/Dn.dot(dc));const u=0;c.elements[2]=Dn.x,c.elements[6]=Dn.y,c.elements[10]=Dn.z-u,c.elements[14]=Dn.w,this.value=l.texture,s.visible=!1;const h=r.getRenderTarget(),d=r.getMRT();r.setMRT(null),r.setRenderTarget(l),r.render(t,o),r.setMRT(d),r.setRenderTarget(h),s.visible=!0,Wg=!1}}const G3=n=>G(new vT(n)),jg=new Ls(-1,1,1,-1,0,1);class W3 extends ct{constructor(e=!1){super();const t=e===!1?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new De([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new De(t,2))}}const j3=new W3;class fn extends Ft{constructor(e=null){super(j3,e),this.camera=jg,this.isQuadMesh=!0}renderAsync(e){return e.renderAsync(this,jg)}render(e){e.render(this,jg)}}const X3=new J;class yT extends dn{static get type(){return"RTTNode"}constructor(e,t=null,i=null,r={type:wi}){const s=new ui(t,i,r);super(s.texture,nt()),this.node=e,this.width=t,this.height=i,this.renderTarget=s,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this.updateMap=new WeakMap,this._rttNode=null,this._quadMesh=new fn(new bt),this.updateBeforeType=je.RENDER}get autoSize(){return this.width===null}setup(e){return this._rttNode=this.node.context(e.getSharedContext()),this._quadMesh.material.name="RTT",this._quadMesh.material.needsUpdate=!0,super.setup(e)}setSize(e,t){this.width=e,this.height=t;const i=e*this.pixelRatio,r=t*this.pixelRatio;this.renderTarget.setSize(i,r),this.textureNeedsUpdate=!0}setPixelRatio(e){this.pixelRatio=e,this.setSize(this.width,this.height)}updateBefore({renderer:e}){if(this.textureNeedsUpdate===!1&&this.autoUpdate===!1)return;if(this.textureNeedsUpdate=!1,this.autoSize===!0){this.pixelRatio=e.getPixelRatio();const i=e.getSize(X3);this.setSize(i.width,i.height)}this._quadMesh.material.fragmentNode=this._rttNode;const t=e.getRenderTarget();e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(t)}clone(){const e=new dn(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}}const xT=(n,...e)=>G(new yT(G(n),...e)),Zi=(n,...e)=>n.isTextureNode?n:xT(n,...e);class _T extends Gf{static get type(){return"VertexColorNode"}constructor(e=0){super(null,"vec4"),this.isVertexColorNode=!0,this.index=e}getAttributeName(){const e=this.index;return"color"+(e>0?e:"")}generate(e){const t=this.getAttributeName(e),i=e.hasGeometryAttribute(t);let r;return i===!0?r=super.generate(e):r=e.generateConst(this.nodeType,new st(1,1,1,1)),r}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}}const q3=(...n)=>G(new _T(...n));class MT extends qe{static get type(){return"PointUVNode"}constructor(){super("vec2"),this.isPointUVNode=!0}generate(){return"vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )"}}const Y3=ge(MT);class sn extends qe{static get type(){return"SceneNode"}constructor(e=sn.BACKGROUND_BLURRINESS,t=null){super(),this.scope=e,this.scene=t}setup(e){const t=this.scope,i=this.scene!==null?this.scene:e.scene;let r;return t===sn.BACKGROUND_BLURRINESS?r=fi("backgroundBlurriness","float",i):t===sn.BACKGROUND_INTENSITY?r=fi("backgroundIntensity","float",i):console.error("THREE.SceneNode: Unknown scope:",t),r}}sn.BACKGROUND_BLURRINESS="backgroundBlurriness",sn.BACKGROUND_INTENSITY="backgroundIntensity";const $3=ge(sn,sn.BACKGROUND_BLURRINESS),J3=ge(sn,sn.BACKGROUND_INTENSITY),bT={Storage:"storage",ReadOnlyStorage:"read-only-storage"},Xg={WriteOnly:"write-only",ReadOnly:"read-only"};class qg extends qh{static get type(){return"StorageBufferNode"}constructor(e,t,i=0){super(e,t,i),this.isStorageBufferNode=!0,this.access=bT.Storage,this.isAtomic=!1,this.bufferObject=!1,this.bufferCount=i,this._attribute=null,this._varying=null,this.global=!0,e.isStorageBufferAttribute!==!0&&e.isStorageInstancedBufferAttribute!==!0&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){if(this.bufferCount===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getInputType(){return"storageBuffer"}element(e){return z3(this,e)}setBufferObject(e){return this.bufferObject=e,this}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(bT.ReadOnlyStorage)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}generate(e){if(e.isAvailable("storageBuffer"))return super.generate(e);const t=this.getNodeType(e);this._attribute===null&&(this._attribute=ql(this.value),this._varying=Ii(this._attribute));const i=this._varying.build(e,t);return e.registerTransform(i,this._attribute),i}}const K3=(n,e,t)=>G(new qg(n,e,t)),Z3=(n,e,t)=>G(new qg(n,e,t).setBufferObject(!0));class TT extends dn{static get type(){return"StorageTextureNode"}constructor(e,t,i=null){super(e,t),this.storeNode=i,this.isStorageTextureNode=!0,this.access=Xg.WriteOnly}getInputType(){return"storageTexture"}setup(e){super.setup(e);const t=e.getNodeProperties(this);t.storeNode=this.storeNode}setAccess(e){return this.access=e,this}generate(e,t){let i;return this.storeNode!==null?i=this.generateStore(e):i=super.generate(e,t),i}toReadOnly(){return this.setAccess(Xg.ReadOnly)}toWriteOnly(){return this.setAccess(Xg.WriteOnly)}generateStore(e){const t=e.getNodeProperties(this),{uvNode:i,storeNode:r}=t,s=super.generate(e,"property"),a=i.build(e,"uvec2"),o=r.build(e,"vec4"),l=e.generateTextureStore(e,s,a,o);e.addLineFlowCode(l,this)}}const ST=K(TT),Q3=(n,e,t)=>{const i=ST(n,e,t);return t!==null&&i.append(),i};class wT extends Kl{static get type(){return"UserDataNode"}constructor(e,t,i=null){super(e,t,i),this.userData=i}updateReference(e){return this.reference=this.userData!==null?this.userData:e.object.userData,this.reference}}const eD=(n,e,t)=>G(new wT(n,e,t));class ET extends pt{static get type(){return"PosterizeNode"}constructor(e,t){super(),this.sourceNode=e,this.stepsNode=t}setup(){const{sourceNode:e,stepsNode:t}=this;return e.mul(t).floor().div(t)}}const tD=K(ET);let Yg=null;class AT extends ac{static get type(){return"ViewportSharedTextureNode"}constructor(e=ps,t=null){Yg===null&&(Yg=new pm),super(e,t,Yg)}updateReference(){return this}}const iD=K(AT),rD=new J;class NT extends dn{static get type(){return"PassTextureNode"}constructor(e,t){super(t),this.passNode=e,this.setUpdateMatrix(!1)}setup(e){return e.object.isQuadMesh&&this.passNode.build(e),super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}}class CT extends NT{static get type(){return"PassMultipleTextureNode"}constructor(e,t,i=!1){super(e,null),this.textureName=t,this.previousTexture=i}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){return new this.constructor(this.passNode,this.textureName,this.previousTexture)}}class Ti extends pt{static get type(){return"PassNode"}constructor(e,t,i,r={}){super("vec4"),this.scope=e,this.scene=t,this.camera=i,this.options=r,this._pixelRatio=1,this._width=1,this._height=1;const s=new Us;s.isRenderTargetTexture=!0,s.name="depth";const a=new ui(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:wi,...r});a.texture.name="output",a.depthTexture=s,this.renderTarget=a,this.updateBeforeType=je.FRAME,this._textures={output:a.texture,depth:s},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=fe(0),this._cameraFar=fe(0),this._mrt=null,this.isPassNode=!0}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}isGlobal(){return!0}getTexture(e){let t=this._textures[e];return t===void 0&&(t=this.renderTarget.texture.clone(),t.isRenderTargetTexture=!0,t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)),t}getPreviousTexture(e){let t=this._previousTextures[e];return t===void 0&&(t=this.getTexture(e).clone(),t.isRenderTargetTexture=!0,this._previousTextures[e]=t),t}toggleTexture(e){const t=this._previousTextures[e];if(t!==void 0){const i=this._textures[e],r=this.renderTarget.textures.indexOf(i);this.renderTarget.textures[r]=t,this._textures[e]=t,this._previousTextures[e]=i,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e="output"){let t=this._textureNodes[e];return t===void 0&&(this._textureNodes[e]=t=G(new CT(this,e)),this._textureNodes[e].updateTexture()),t}getPreviousTextureNode(e="output"){let t=this._previousTextureNodes[e];return t===void 0&&(this._textureNodes[e]===void 0&&this.getTextureNode(e),this._previousTextureNodes[e]=t=G(new CT(this,e,!0)),this._previousTextureNodes[e].updateTexture()),t}getViewZNode(e="depth"){let t=this._viewZNodes[e];if(t===void 0){const i=this._cameraNear,r=this._cameraFar;this._viewZNodes[e]=t=cg(this.getTextureNode(e),i,r)}return t}getLinearDepthNode(e="depth"){let t=this._linearDepthNodes[e];if(t===void 0){const i=this._cameraNear,r=this._cameraFar,s=this.getViewZNode(e);this._linearDepthNodes[e]=t=oc(s,i,r)}return t}setup({renderer:e}){return this.renderTarget.samples=this.options.samples===void 0?e.samples:this.options.samples,e.backend.isWebGLBackend===!0&&(this.renderTarget.samples=0),this.renderTarget.depthTexture.isMultisampleRenderTargetTexture=this.renderTarget.samples>1,this.scope===Ti.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){const{renderer:t}=e,{scene:i,camera:r}=this;this._pixelRatio=t.getPixelRatio();const s=t.getSize(rD);this.setSize(s.width,s.height);const a=t.getRenderTarget(),o=t.getMRT();this._cameraNear.value=r.near,this._cameraFar.value=r.far;for(const l in this._previousTextures)this.toggleTexture(l);t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.render(i,r),t.setRenderTarget(a),t.setMRT(o)}setSize(e,t){this._width=e,this._height=t;const i=this._width*this._pixelRatio,r=this._height*this._pixelRatio;this.renderTarget.setSize(i,r)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}}Ti.COLOR="color",Ti.DEPTH="depth";const nD=(n,e,t)=>G(new Ti(Ti.COLOR,n,e,t)),bo=(n,e)=>G(new NT(n,e)),sD=(n,e)=>G(new Ti(Ti.DEPTH,n,e)),RT=new fn,IT=new fn;class LT extends pt{static get type(){return"GaussianBlurNode"}constructor(e,t=null,i=2){super("vec4"),this.textureNode=e,this.directionNode=t,this.sigma=i,this._invSize=fe(new J),this._passDirection=fe(new J),this._horizontalRT=new ui,this._horizontalRT.texture.name="GaussianBlurNode.horizontal",this._verticalRT=new ui,this._verticalRT.texture.name="GaussianBlurNode.vertical",this._textureNode=bo(this,this._verticalRT.texture),this.updateBeforeType=je.RENDER,this.resolution=new J(1,1)}setSize(e,t){e=Math.max(Math.round(e*this.resolution.x),1),t=Math.max(Math.round(t*this.resolution.y),1),this._invSize.value.set(1/e,1/t),this._horizontalRT.setSize(e,t),this._verticalRT.setSize(e,t)}updateBefore(e){const{renderer:t}=e,i=this.textureNode,r=i.value,s=t.getRenderTarget(),a=t.getMRT(),o=i.value;RT.material=this._material,IT.material=this._material,this.setSize(r.image.width,r.image.height);const l=r.type;this._horizontalRT.texture.type=l,this._verticalRT.texture.type=l,t.setMRT(null),t.setRenderTarget(this._horizontalRT),this._passDirection.value.set(1,0),RT.render(t),i.value=this._horizontalRT.texture,t.setRenderTarget(this._verticalRT),this._passDirection.value.set(0,1),IT.render(t),t.setRenderTarget(s),t.setMRT(a),i.value=o}getTextureNode(){return this._textureNode}setup(e){const t=this.textureNode;if(t.isTextureNode!==!0)return console.error("GaussianBlurNode requires a TextureNode."),ae();const i=t.uvNode||nt(),r=z(this.directionNode||1),s=c=>t.uv(c),a=U(()=>{const c=3+2*this.sigma,u=this._getCoefficients(c),h=this._invSize,d=r.mul(this._passDirection),p=E(u[0]).toVar(),m=ae(s(i).mul(p)).toVar();for(let v=1;v<c;v++){const f=E(v),g=E(u[v]),x=z(d.mul(h.mul(f))).toVar(),y=ae(s(i.add(x))),_=ae(s(i.sub(x)));m.addAssign(y.add(_).mul(g)),p.addAssign(lt(2,g))}return m.div(p)}),o=this._material||(this._material=new bt);o.fragmentNode=a().context(e.getSharedContext()),o.name="Gaussian_blur",o.needsUpdate=!0;const l=e.getNodeProperties(this);return l.textureNode=t,this._textureNode}dispose(){this._horizontalRT.dispose(),this._verticalRT.dispose()}_getCoefficients(e){const t=[];for(let i=0;i<e;i++)t.push(.39894*Math.exp(-.5*i*i/(e*e))/e);return t}}const aD=(n,e,t)=>G(new LT(Zi(n),e,t)),$g=new J,PT=new fn;class DT extends pt{static get type(){return"AfterImageNode"}constructor(e,t=.96){super(e),this.textureNode=e,this.textureNodeOld=yt(),this.damp=fe(t),this._compRT=new ui,this._compRT.texture.name="AfterImageNode.comp",this._oldRT=new ui,this._oldRT.texture.name="AfterImageNode.old",this._textureNode=bo(this,this._compRT.texture),this.updateBeforeType=je.RENDER}getTextureNode(){return this._textureNode}setSize(e,t){this._compRT.setSize(e,t),this._oldRT.setSize(e,t)}updateBefore(e){const{renderer:t}=e,i=this.textureNode,r=i.value.type;this._compRT.texture.type=r,this._oldRT.texture.type=r,t.getDrawingBufferSize($g),this.setSize($g.x,$g.y);const s=t.getRenderTarget(),a=i.value;this.textureNodeOld.value=this._oldRT.texture,t.setRenderTarget(this._compRT),PT.render(t);const o=this._oldRT;this._oldRT=this._compRT,this._compRT=o,t.setRenderTarget(s),i.value=a}setup(e){const t=this.textureNode,i=this.textureNodeOld,r=t.uvNode||nt();i.uvNode=r;const s=u=>t.uv(u),a=U(([u,h])=>{const d=E(h).toVar(),p=ae(u).toVar();return ft(Gl(p.sub(d)),0)}),o=U(()=>{const u=ae(i),h=ae(s(r));return u.mulAssign(this.damp.mul(a(u,.1))),ft(h,u)}),l=this._materialComposed||(this._materialComposed=new bt);l.name="AfterImage",l.fragmentNode=o(),PT.material=l;const c=e.getNodeProperties(this);return c.textureNode=t,this._textureNode}dispose(){this._compRT.dispose(),this._oldRT.dispose()}}const oD=(n,e)=>G(new DT(Zi(n),e)),lD=U(([n])=>Ui(n.rgb)),cD=U(([n,e=E(1)])=>e.mix(Ui(n.rgb),n.rgb)),uD=U(([n,e=E(1)])=>{const t=zt(n.r,n.g,n.b).div(3),i=n.r.max(n.g.max(n.b)),r=i.sub(t).mul(e).mul(-3);return rt(n.rgb,i,r)}),hD=U(([n,e=E(1)])=>{const t=D(.57735,.57735,.57735),i=e.cos();return D(n.rgb.mul(i).add(t.cross(n.rgb).mul(e.sin()).add(t.mul(qt(t,n.rgb).mul(i.oneMinus())))))}),dD=new N,Ui=(n,e=D(...vt.getLuminanceCoefficients(dD)))=>qt(n,e),UT=(n,e)=>rt(D(0),n,Ui(n).sub(e).max(0)),OT=new fn;class FT extends pt{static get type(){return"AnamorphicNode"}constructor(e,t,i,r){super("vec4"),this.textureNode=e,this.tresholdNode=t,this.scaleNode=i,this.colorNode=D(.1,0,1),this.samples=r,this.resolution=new J(1,1),this._renderTarget=new ui,this._renderTarget.texture.name="anamorphic",this._invSize=fe(new J),this._textureNode=bo(this,this._renderTarget.texture),this.updateBeforeType=je.RENDER}getTextureNode(){return this._textureNode}setSize(e,t){this._invSize.value.set(1/e,1/t),e=Math.max(Math.round(e*this.resolution.x),1),t=Math.max(Math.round(t*this.resolution.y),1),this._renderTarget.setSize(e,t)}updateBefore(e){const{renderer:t}=e,i=this.textureNode,r=i.value;this._renderTarget.texture.type=r.type;const s=t.getRenderTarget(),a=i.value;OT.material=this._material,this.setSize(r.image.width,r.image.height),t.setRenderTarget(this._renderTarget),OT.render(t),t.setRenderTarget(s),i.value=a}setup(e){const t=this.textureNode,i=t.uvNode||nt(),r=l=>t.uv(l),s=U(()=>{const l=this.samples,c=Math.floor(l/2),u=D(0).toVar();return gt({start:-c,end:c},({i:h})=>{const d=E(h).abs().div(c).oneMinus(),p=z(i.x.add(this._invSize.x.mul(h).mul(this.scaleNode)),i.y),m=r(p),v=UT(m,this.tresholdNode).mul(d);u.addAssign(v)}),u.mul(this.colorNode)}),a=this._material||(this._material=new bt);a.name="Anamorphic",a.fragmentNode=s();const o=e.getNodeProperties(this);return o.textureNode=t,this._textureNode}dispose(){this._renderTarget.dispose()}}const pD=(n,e=.9,t=3,i=32)=>G(new FT(Zi(n),G(e),G(t),i));class VT extends pt{static get type(){return"SobelOperatorNode"}constructor(e){super(),this.textureNode=e,this.updateBeforeType=je.RENDER,this._invSize=fe(new J)}updateBefore(){const e=this.textureNode.value;this._invSize.value.set(1/e.image.width,1/e.image.height)}setup(){const{textureNode:e}=this,t=e.uvNode||nt(),i=r=>e.uv(r);return U(()=>{const r=this._invSize,s=yi(-1,-2,-1,0,0,0,1,2,1),a=yi(-1,0,1,-2,0,2,-1,0,1),o=Ui(i(t.add(r.mul(z(-1,-1)))).xyz),l=Ui(i(t.add(r.mul(z(-1,0)))).xyz),c=Ui(i(t.add(r.mul(z(-1,1)))).xyz),u=Ui(i(t.add(r.mul(z(0,-1)))).xyz),h=Ui(i(t.add(r.mul(z(0,0)))).xyz),d=Ui(i(t.add(r.mul(z(0,1)))).xyz),p=Ui(i(t.add(r.mul(z(1,-1)))).xyz),m=Ui(i(t.add(r.mul(z(1,0)))).xyz),v=Ui(i(t.add(r.mul(z(1,1)))).xyz),f=zt(s[0][0].mul(o),s[1][0].mul(u),s[2][0].mul(p),s[0][1].mul(l),s[1][1].mul(h),s[2][1].mul(m),s[0][2].mul(c),s[1][2].mul(d),s[2][2].mul(v)),g=zt(a[0][0].mul(o),a[1][0].mul(u),a[2][0].mul(p),a[0][1].mul(l),a[1][1].mul(h),a[2][1].mul(m),a[0][2].mul(c),a[1][2].mul(d),a[2][2].mul(v)),x=f.mul(f).add(g.mul(g)).sqrt();return ae(D(x),1)})()}}const mD=n=>G(new VT(Zi(n)));class BT extends pt{static get type(){return"DepthOfFieldNode"}constructor(e,t,i,r,s){super(),this.textureNode=e,this.viewZNode=t,this.focusNode=i,this.apertureNode=r,this.maxblurNode=s,this._aspect=fe(0),this.updateBeforeType=je.RENDER}updateBefore(){const e=this.textureNode.value;this._aspect.value=e.image.width/e.image.height}setup(){const e=this.textureNode,t=e.uvNode||nt(),i=r=>e.uv(r);return U(()=>{const r=z(1,this._aspect),s=this.focusNode.add(this.viewZNode),a=z(li(s.mul(this.apertureNode),this.maxblurNode.negate(),this.maxblurNode)),o=a.mul(.9),l=a.mul(.7),c=a.mul(.4);let u=ae(0);return u=u.add(i(t)),u=u.add(i(t.add(z(0,.4).mul(r).mul(a)))),u=u.add(i(t.add(z(.15,.37).mul(r).mul(a)))),u=u.add(i(t.add(z(.29,.29).mul(r).mul(a)))),u=u.add(i(t.add(z(-.37,.15).mul(r).mul(a)))),u=u.add(i(t.add(z(.4,0).mul(r).mul(a)))),u=u.add(i(t.add(z(.37,-.15).mul(r).mul(a)))),u=u.add(i(t.add(z(.29,-.29).mul(r).mul(a)))),u=u.add(i(t.add(z(-.15,-.37).mul(r).mul(a)))),u=u.add(i(t.add(z(0,-.4).mul(r).mul(a)))),u=u.add(i(t.add(z(-.15,.37).mul(r).mul(a)))),u=u.add(i(t.add(z(-.29,.29).mul(r).mul(a)))),u=u.add(i(t.add(z(.37,.15).mul(r).mul(a)))),u=u.add(i(t.add(z(-.4,0).mul(r).mul(a)))),u=u.add(i(t.add(z(-.37,-.15).mul(r).mul(a)))),u=u.add(i(t.add(z(-.29,-.29).mul(r).mul(a)))),u=u.add(i(t.add(z(.15,-.37).mul(r).mul(a)))),u=u.add(i(t.add(z(.15,.37).mul(r).mul(o)))),u=u.add(i(t.add(z(-.37,.15).mul(r).mul(o)))),u=u.add(i(t.add(z(.37,-.15).mul(r).mul(o)))),u=u.add(i(t.add(z(-.15,-.37).mul(r).mul(o)))),u=u.add(i(t.add(z(-.15,.37).mul(r).mul(o)))),u=u.add(i(t.add(z(.37,.15).mul(r).mul(o)))),u=u.add(i(t.add(z(-.37,-.15).mul(r).mul(o)))),u=u.add(i(t.add(z(.15,-.37).mul(r).mul(o)))),u=u.add(i(t.add(z(.29,.29).mul(r).mul(l)))),u=u.add(i(t.add(z(.4,0).mul(r).mul(l)))),u=u.add(i(t.add(z(.29,-.29).mul(r).mul(l)))),u=u.add(i(t.add(z(0,-.4).mul(r).mul(l)))),u=u.add(i(t.add(z(-.29,.29).mul(r).mul(l)))),u=u.add(i(t.add(z(-.4,0).mul(r).mul(l)))),u=u.add(i(t.add(z(-.29,-.29).mul(r).mul(l)))),u=u.add(i(t.add(z(0,.4).mul(r).mul(l)))),u=u.add(i(t.add(z(.29,.29).mul(r).mul(c)))),u=u.add(i(t.add(z(.4,0).mul(r).mul(c)))),u=u.add(i(t.add(z(.29,-.29).mul(r).mul(c)))),u=u.add(i(t.add(z(0,-.4).mul(r).mul(c)))),u=u.add(i(t.add(z(-.29,.29).mul(r).mul(c)))),u=u.add(i(t.add(z(-.4,0).mul(r).mul(c)))),u=u.add(i(t.add(z(-.29,-.29).mul(r).mul(c)))),u=u.add(i(t.add(z(0,.4).mul(r).mul(c)))),u=u.div(41),u.a=1,ae(u)})()}}const fD=(n,e,t=1,i=.025,r=1)=>G(new BT(Zi(n),G(e),G(t),G(i),G(r)));class zT extends pt{static get type(){return"DotScreenNode"}constructor(e,t=new J(.5,.5),i=1.57,r=1){super("vec4"),this.inputNode=e,this.center=fe(t),this.angle=fe(i),this.scale=fe(r)}setup(){const e=this.inputNode,t=U(()=>{const i=Ci(this.angle),r=br(this.angle),s=nt().mul(fo).sub(this.center),a=z(r.mul(s.x).sub(i.mul(s.y)),i.mul(s.x).add(r.mul(s.y))).mul(this.scale);return Ci(a.x).mul(Ci(a.y)).mul(4)});return U(()=>{const i=e,r=zt(i.r,i.g,i.b).div(3);return ae(D(r.mul(10).sub(5).add(t())),i.a)})()}}const gD=(n,e,t,i)=>G(new zT(G(n),e,t,i));class kT extends pt{static get type(){return"RGBShiftNode"}constructor(e,t=.005,i=0){super("vec4"),this.textureNode=e,this.amount=fe(t),this.angle=fe(i)}setup(){const{textureNode:e}=this,t=e.uvNode||nt(),i=r=>e.uv(r);return U(()=>{const r=z(br(this.angle),Ci(this.angle)).mul(this.amount),s=i(t.add(r)),a=i(t),o=i(t.sub(r));return ae(s.r,a.g,o.b,a.a)})()}}const vD=(n,e,t)=>G(new kT(Zi(n),e,t));class HT extends pt{static get type(){return"FilmNode"}constructor(e,t=null,i=null){super(),this.inputNode=e,this.intensityNode=t,this.uvNode=i}setup(){const e=this.uvNode||nt();return U(()=>{const t=this.inputNode.rgb,i=Uf(us(e.add(Hg())));let r=t.add(t.mul(li(i.add(.1),0,1)));return this.intensityNode!==null&&(r=rt(t,r,this.intensityNode)),ae(r,this.inputNode.a)})()}}const yD=K(HT);class GT extends pt{static get type(){return"Lut3DNode"}constructor(e,t,i,r){super(),this.inputNode=e,this.lutNode=t,this.size=fe(i),this.intensityNode=r}setup(){const{inputNode:e,lutNode:t}=this,i=r=>t.uv(r);return U(()=>{const r=e,s=E(1).div(this.size),a=E(.5).div(this.size),o=D(a).add(r.rgb.mul(E(1).sub(s))),l=ae(i(o).rgb,r.a);return ae(rt(r,l,this.intensityNode))})()}}const xD=(n,e,t,i)=>G(new GT(G(n),G(e),t,G(i))),WT=new fn,jT=new xe,_D=new J;class XT extends pt{static get type(){return"GTAONode"}constructor(e,t,i){super(),this.depthNode=e,this.normalNode=t,this.radius=fe(.25),this.resolution=fe(new J),this.thickness=fe(1),this.distanceExponent=fe(1),this.distanceFallOff=fe(1),this.scale=fe(1),this.noiseNode=yt(MD()),this.cameraProjectionMatrix=fe(i.projectionMatrix),this.cameraProjectionMatrixInverse=fe(i.projectionMatrixInverse),this.SAMPLES=fe(16),this._aoRenderTarget=new ui,this._aoRenderTarget.texture.name="GTAONode.AO",this._material=null,this._textureNode=bo(this,this._aoRenderTarget.texture),this.updateBeforeType=je.FRAME}getTextureNode(){return this._textureNode}setSize(e,t){this.resolution.value.set(e,t),this._aoRenderTarget.setSize(e,t)}updateBefore(e){const{renderer:t}=e,i=t.getDrawingBufferSize(_D),r=t.getRenderTarget(),s=t.getMRT();t.getClearColor(jT);const a=t.getClearAlpha();WT.material=this._material,this.setSize(i.width,i.height),t.setMRT(null),t.setClearColor(16777215,1),t.setRenderTarget(this._aoRenderTarget),WT.render(t),t.setRenderTarget(r),t.setMRT(s),t.setClearColor(jT,a)}setup(e){const t=nt(),i=c=>this.depthNode.uv(c).x,r=c=>this.noiseNode.uv(c),s=U(([c])=>{const u=this.cameraProjectionMatrix.mul(ae(c,1));let h=u.xy.div(u.w).mul(.5).add(.5).toVar();h=z(h.x,h.y.oneMinus());const d=i(h);return D(h,d)}),a=U(([c,u])=>{c=z(c.x,c.y.oneMinus()).mul(2).sub(1);const h=ae(D(c,u),1),d=ae(this.cameraProjectionMatrixInverse.mul(h));return d.xyz.div(d.w)}),o=U(()=>{const c=i(t);c.greaterThanEqual(1).discard();const u=a(t,c),h=this.normalNode.rgb.normalize(),d=this.radius,p=ds(this.noiseNode,0);let m=z(t.x,t.y.oneMinus());m=m.mul(this.resolution.div(p));const v=r(m),f=v.xyz.mul(2).sub(1),g=D(f.xy,0).normalize(),x=D(g.y.mul(-1),g.x,0),y=yi(g,x,D(0,0,1)),_=this.SAMPLES.lessThan(30).select(3,5),I=zt(this.SAMPLES,_.sub(1)).div(_),b=E(0).toVar();return gt({start:P(0),end:_,type:"int",condition:"<"},({i:w})=>{const C=E(w).div(E(_)).mul(Qs),H=ae(br(C),Ci(C),0,zt(.5,lt(.5,v.w)));H.xyz=Mr(y.mul(H.xyz));const M=Mr(u.xyz.negate()),T=Mr(lo(H.xyz,M)),k=lo(T,M),j=Mr(h.sub(T.mul(qt(h,T)))),Y=lo(j,T),re=z(qt(M,Y),qt(M,Y.negate())).toVar();gt({end:I,type:"int",name:"j",condition:"<"},({j:at})=>{const et=H.xyz.mul(d).mul(H.w).mul(Ji(Qr(E(at).add(1),E(I)),this.distanceExponent)),ie=s(u.add(et)),le=a(ie.xy,ie.z).sub(u);Le(It(le.z).lessThan(this.thickness),()=>{const Ye=qt(M,Mr(le));re.x.addAssign(ft(0,lt(Ye.sub(re.x),rt(1,E(2).div(E(at).add(2)),this.distanceFallOff))))});const Te=s(u.sub(et)),Se=a(Te.xy,Te.z).sub(u);Le(It(Se.z).lessThan(this.thickness),()=>{const Ye=qt(M,Mr(Se));re.y.addAssign(ft(0,lt(Ye.sub(re.y),rt(1,E(2).div(E(at).add(2)),this.distanceFallOff))))})});const $=en(Pt(1,re.mul(re))),he=qt(j,k),Q=qt(j,M),ye=lt(.5,Vh(re.y).sub(Vh(re.x)).add($.x.mul(re.x).sub($.y.mul(re.y)))),be=lt(.5,Pt(2,re.x.mul(re.x)).sub(re.y.mul(re.y))),Ve=he.mul(ye).add(Q.mul(be));b.addAssign(Ve)}),b.assign(li(b.div(_),0,1)),b.assign(Ji(b,this.scale)),ae(D(b),1)}),l=this._material||(this._material=new bt);return l.fragmentNode=o().context(e.getSharedContext()),l.name="GTAO",l.needsUpdate=!0,this._textureNode}dispose(){this._aoRenderTarget.dispose()}}function MD(n=5){const e=Math.floor(n)%2===0?Math.floor(n)+1:Math.floor(n),t=bD(e),i=t.length,r=new Uint8Array(i*4);for(let a=0;a<i;++a){const o=t[a],l=2*Math.PI*o/i,c=new N(Math.cos(l),Math.sin(l),0).normalize();r[a*4]=(c.x*.5+.5)*255,r[a*4+1]=(c.y*.5+.5)*255,r[a*4+2]=127,r[a*4+3]=255}const s=new Ur(r,e,e);return s.wrapS=Gn,s.wrapT=Gn,s.needsUpdate=!0,s}function bD(n){const e=Math.floor(n)%2===0?Math.floor(n)+1:Math.floor(n),t=e*e,i=Array(t).fill(0);let r=Math.floor(e/2),s=e-1;for(let a=1;a<=t;){if(r===-1&&s===e?(s=e-2,r=0):(s===e&&(s=0),r<0&&(r=e-1)),i[r*e+s]!==0){s-=2,r++;continue}else i[r*e+s]=a++;s++,r--}return i}const TD=(n,e,t)=>G(new XT(G(n),G(e),t));class qT extends pt{static get type(){return"DenoiseNode"}constructor(e,t,i,r,s){super(),this.textureNode=e,this.depthNode=t,this.normalNode=i,this.noiseNode=r,this.cameraProjectionMatrixInverse=fe(s.projectionMatrixInverse),this.lumaPhi=fe(5),this.depthPhi=fe(5),this.normalPhi=fe(5),this.radius=fe(5),this.index=fe(0),this._resolution=fe(new J),this._sampleVectors=mn(SD(16,2,1)),this.updateBeforeType=je.RENDER}updateBefore(){const e=this.textureNode.value;this._resolution.value.set(e.image.width,e.image.height)}setup(){const e=nt(),t=c=>this.textureNode.uv(c),i=c=>this.depthNode.uv(c).x,r=c=>this.normalNode.uv(c),s=c=>this.noiseNode.uv(c),a=U(([c,u])=>{c=z(c.x,c.y.oneMinus()).mul(2).sub(1);const h=ae(D(c,u),1),d=ae(this.cameraProjectionMatrixInverse.mul(h));return d.xyz.div(d.w)}),o=U(([c,u,h,d])=>{const p=t(d),m=i(d),v=r(d).rgb.normalize(),f=p.rgb,g=a(d,m),x=qt(u,v).toVar(),y=Ji(ft(x,0),this.normalPhi).toVar(),_=It(Ui(f).sub(Ui(c))).toVar(),I=ft(E(1).sub(_.div(this.lumaPhi)),0).toVar(),b=It(qt(h.sub(g),u)).toVar(),w=ft(E(1).sub(b.div(this.depthPhi)),0),C=I.mul(w).mul(y);return ae(f.mul(C),C)}),l=U(([c])=>{const u=i(c),h=r(c).rgb.normalize(),d=t(c);Le(u.greaterThanEqual(1).or(qt(h,h).equal(0)),()=>d);const p=D(d.rgb),m=a(c,u),v=ds(this.noiseNode,0);let f=z(c.x,c.y.oneMinus());f=f.mul(this._resolution.div(v));const g=s(f),x=Ci(g.element(this.index.mod(4).mul(2).mul(Qs))),y=br(g.element(this.index.mod(4).mul(2).mul(Qs))),_=z(x,y),I=Ul(_.x,_.y.negate(),_.x,_.y),b=E(1).toVar(),w=D(d.rgb).toVar();return gt({start:P(0),end:P(16),type:"int",condition:"<"},({i:C})=>{const H=this._sampleVectors.element(C).toVar(),M=I.mul(H.xy.mul(E(1).add(H.z.mul(this.radius.sub(1))))).div(this._resolution).toVar(),T=c.add(M).toVar(),k=o(p,h,m,T);w.addAssign(k.xyz),b.addAssign(k.w)}),Le(b.greaterThan(E(0)),()=>{w.divAssign(b)}),ae(w,d.a)}).setLayout({name:"denoise",type:"vec4",inputs:[{name:"uv",type:"vec2"}]});return U(()=>l(e))()}}function SD(n,e,t){const i=wD(n,e,t),r=[];for(let s=0;s<n;s++){const a=i[s];r.push(a)}return r}function wD(n,e,t){const i=[];for(let r=0;r<n;r++){const s=2*Math.PI*e*r/n,a=Math.pow(r/(n-1),t);i.push(new N(Math.cos(s),Math.sin(s),a))}return i}const ED=(n,e,t,i,r)=>G(new qT(Zi(n),G(e),G(t),G(i),r));class YT extends pt{static get type(){return"FXAANode"}constructor(e){super(),this.textureNode=e,this.updateBeforeType=je.RENDER,this._invSize=fe(new J)}updateBefore(){const e=this.textureNode.value;this._invSize.value.set(1/e.image.width,1/e.image.height)}setup(){const e=this.textureNode.bias(-100),t=e.uvNode||nt(),i=l=>e.uv(l),r=(l,c,u)=>e.uv(l.add(c.mul(u))),s=P(5),a=U(([l,c])=>{const u=ae(c).toVar(),h=ae(l).toVar(),d=ae(It(h.sub(u))).toVar();return ft(ft(ft(d.r,d.g),d.b),d.a)}),o=U(([l,c,u,h])=>{const d=i(l).toVar(),p=r(l,z(0,-1),c.xy).toVar(),m=r(l,z(1,0),c.xy).toVar(),v=r(l,z(0,1),c.xy).toVar(),f=r(l,z(-1,0),c.xy).toVar(),g=a(d,v).toVar(),x=a(d,p).toVar(),y=a(d,m).toVar(),_=a(d,f).toVar(),I=ft(g,ft(x,ft(y,_))).toVar();Le(I.lessThan(u),()=>d);const b=Pt(g.add(x),y.add(_)).toVar();b.mulAssign(h),Le(It(b).lessThan(.3),()=>{const Ve=y.greaterThan(_).select(1,-1).toVar(),at=x.greaterThan(g).select(1,-1).toVar(),et=z(Ve,at).toVar(),ie=r(l,z(et.x,et.y),c.xy),le=a(d,ie).toVar(),Te=r(l,z(et.x.negate(),et.y.negate()),c.xy),Se=a(d,Te).toVar();b.assign(Se.sub(le)),b.mulAssign(h),Le(It(b).lessThan(.3),()=>{const Ye=v.add(p).add(m).add(f);return rt(d,Ye.mul(.25),.4)})});const w=z().toVar();Le(b.lessThanEqual(0),()=>{v.assign(f),p.assign(m),w.x.assign(0),w.y.assign(c.y)}).Else(()=>{w.x.assign(c.x),w.y.assign(0)});const C=a(d,v).toVar(),H=a(d,p).toVar();Le(C.lessThanEqual(H),()=>{v.assign(p)});const M=P(0).toVar(),T=P(0).toVar(),k=E(0).toVar(),j=E(0).toVar(),Y=z(l).toVar(),re=z(l).toVar(),$=P(0).toVar(),he=P(0).toVar();gt(s,({i:Ve})=>{const at=Ve.add(1).toVar();Le(M.equal(0),()=>{k.addAssign(at),Y.assign(l.add(w.mul(k)));const et=i(Y.xy),ie=a(et,d).toVar(),le=a(et,v).toVar();Le(ie.greaterThan(le),()=>{M.assign(1)}),$.assign(Ve)}),Le(T.equal(0),()=>{j.addAssign(at),re.assign(l.sub(w.mul(j)));const et=i(re.xy),ie=a(et,d).toVar(),le=a(et,v).toVar();Le(ie.greaterThan(le),()=>{T.assign(1)}),he.assign(Ve)}),Le(M.equal(1).or(T.equal(1)),()=>{Qh()})}),Le(M.equal(0).and(T.equal(0)),()=>d);const Q=E(1).toVar(),ye=E(1).toVar();Le(M.equal(1),()=>{Q.assign(E($).div(E(s.sub(1))))}),Le(T.equal(1),()=>{ye.assign(E(he).div(E(s.sub(1))))});const be=xi(Q,ye);return be.assign(Ji(be,.5)),be.assign(E(1).sub(be)),rt(d,v,be.mul(.5))}).setLayout({name:"FxaaPixelShader",type:"vec4",inputs:[{name:"uv",type:"vec2"},{name:"fxaaQualityRcpFrame",type:"vec2"},{name:"fxaaQualityEdgeThreshold",type:"float"},{name:"fxaaQualityinvEdgeThreshold",type:"float"}]});return U(()=>{const l=E(.2),c=E(1).div(l);return o(t,this._invSize,l,c)})()}}const AD=n=>G(new YT(Zi(n))),la=new fn,ND=new xe(0,0,0),$T=new xe,CD=new J,RD=new J(1,0),ID=new J(0,1);class JT extends pt{static get type(){return"BloomNode"}constructor(e,t=1,i=0,r=0){super(),this.inputNode=e,this.strength=fe(t),this.radius=fe(i),this.threshold=fe(r),this.smoothWidth=fe(.01),this._renderTargetsHorizontal=[],this._renderTargetsVertical=[],this._nMips=5,this._renderTargetBright=new ui(1,1,{type:wi}),this._renderTargetBright.texture.name="UnrealBloomPass.bright",this._renderTargetBright.texture.generateMipmaps=!1;for(let s=0;s<this._nMips;s++){const a=new ui(1,1,{type:wi});a.texture.name="UnrealBloomPass.h"+s,a.texture.generateMipmaps=!1,this._renderTargetsHorizontal.push(a);const o=new ui(1,1,{type:wi});o.texture.name="UnrealBloomPass.v"+s,o.texture.generateMipmaps=!1,this._renderTargetsVertical.push(o)}this._compositeMaterial=null,this._highPassFilterMaterial=null,this._separableBlurMaterials=[],this._textureNodeBright=yt(this._renderTargetBright.texture),this._textureNodeBlur0=yt(this._renderTargetsVertical[0].texture),this._textureNodeBlur1=yt(this._renderTargetsVertical[1].texture),this._textureNodeBlur2=yt(this._renderTargetsVertical[2].texture),this._textureNodeBlur3=yt(this._renderTargetsVertical[3].texture),this._textureNodeBlur4=yt(this._renderTargetsVertical[4].texture),this._textureOutput=bo(this,this._renderTargetsHorizontal[0].texture),this.updateBeforeType=je.FRAME}getTextureNode(){return this._textureOutput}setSize(e,t){let i=Math.round(e/2),r=Math.round(t/2);this._renderTargetBright.setSize(i,r);for(let s=0;s<this._nMips;s++)this._renderTargetsHorizontal[s].setSize(i,r),this._renderTargetsVertical[s].setSize(i,r),this._separableBlurMaterials[s].invSize.value.set(1/i,1/r),i=Math.round(i/2),r=Math.round(r/2)}updateBefore(e){const{renderer:t}=e,i=t.getDrawingBufferSize(CD);this.setSize(i.width,i.height);const r=t.getRenderTarget(),s=t.getMRT();t.getClearColor($T);const a=t.getClearAlpha();this.setSize(i.width,i.height),t.setMRT(null),t.setClearColor(ND,0),t.setRenderTarget(this._renderTargetBright),la.material=this._highPassFilterMaterial,la.render(t);let o=this._renderTargetBright;for(let l=0;l<this._nMips;l++)la.material=this._separableBlurMaterials[l],this._separableBlurMaterials[l].colorTexture.value=o.texture,this._separableBlurMaterials[l].direction.value=RD,t.setRenderTarget(this._renderTargetsHorizontal[l]),t.clear(),la.render(t),this._separableBlurMaterials[l].colorTexture.value=this._renderTargetsHorizontal[l].texture,this._separableBlurMaterials[l].direction.value=ID,t.setRenderTarget(this._renderTargetsVertical[l]),t.clear(),la.render(t),o=this._renderTargetsVertical[l];t.setRenderTarget(this._renderTargetsHorizontal[0]),t.clear(),la.material=this._compositeMaterial,la.render(t),t.setRenderTarget(r),t.setMRT(s),t.setClearColor($T,a)}setup(e){const t=U(()=>{const l=this.inputNode,c=Ui(l.rgb),u=Ki(this.threshold,this.threshold.add(this.smoothWidth),c);return rt(ae(0),l,u)});this._highPassFilterMaterial=this._highPassFilterMaterial||new bt,this._highPassFilterMaterial.fragmentNode=t().context(e.getSharedContext()),this._highPassFilterMaterial.name="Bloom_highPass",this._highPassFilterMaterial.needsUpdate=!0;const i=[3,5,7,9,11];for(let l=0;l<this._nMips;l++)this._separableBlurMaterials.push(this._getSeperableBlurMaterial(e,i[l]));const r=mn([1,.8,.6,.4,.2]),s=mn([new N(1,1,1),new N(1,1,1),new N(1,1,1),new N(1,1,1),new N(1,1,1)]),a=U(([l,c])=>{const u=E(1.2).sub(l);return rt(l,u,c)}).setLayout({name:"lerpBloomFactor",type:"float",inputs:[{name:"factor",type:"float"},{name:"radius",type:"float"}]}),o=U(()=>{const l=a(r.element(0),this.radius).mul(ae(s.element(0),1)).mul(this._textureNodeBlur0),c=a(r.element(1),this.radius).mul(ae(s.element(1),1)).mul(this._textureNodeBlur1),u=a(r.element(2),this.radius).mul(ae(s.element(2),1)).mul(this._textureNodeBlur2),h=a(r.element(3),this.radius).mul(ae(s.element(3),1)).mul(this._textureNodeBlur3),d=a(r.element(4),this.radius).mul(ae(s.element(4),1)).mul(this._textureNodeBlur4);return l.add(c).add(u).add(h).add(d).mul(this.strength)});return this._compositeMaterial=this._compositeMaterial||new bt,this._compositeMaterial.fragmentNode=o().context(e.getSharedContext()),this._compositeMaterial.name="Bloom_comp",this._compositeMaterial.needsUpdate=!0,this._textureOutput}dispose(){for(let e=0;e<this._renderTargetsHorizontal.length;e++)this._renderTargetsHorizontal[e].dispose();for(let e=0;e<this._renderTargetsVertical.length;e++)this._renderTargetsVertical[e].dispose();this._renderTargetBright.dispose()}_getSeperableBlurMaterial(e,t){const i=[];for(let d=0;d<t;d++)i.push(.39894*Math.exp(-.5*d*d/(t*t))/t);const r=yt(),s=mn(i),a=fe(new J),o=fe(new J(.5,.5)),l=nt(),c=d=>r.uv(d),u=U(()=>{const d=s.element(0).toVar(),p=c(l).rgb.mul(d).toVar();return gt({start:P(1),end:P(t),type:"int",condition:"<"},({i:m})=>{const v=E(m),f=s.element(m),g=o.mul(a).mul(v),x=c(l.add(g)).rgb,y=c(l.sub(g)).rgb;p.addAssign(zt(x,y).mul(f)),d.addAssign(E(2).mul(f))}),ae(p.div(d),1)}),h=new bt;return h.fragmentNode=u().context(e.getSharedContext()),h.name="Bloom_seperable",h.needsUpdate=!0,h.colorTexture=r,h.direction=o,h.invSize=a,h}}const LD=(n,e,t,i)=>G(new JT(G(n),e,t,i));class KT extends pt{static get type(){return"TransitionNode"}constructor(e,t,i,r,s,a){super(),this.textureNodeA=e,this.textureNodeB=t,this.mixTextureNode=i,this.mixRatioNode=r,this.thresholdNode=s,this.useTextureNode=a}setup(){const{textureNodeA:e,textureNodeB:t,mixTextureNode:i,mixRatioNode:r,thresholdNode:s,useTextureNode:a}=this,o=l=>{const c=l.uvNode||nt();return l.uv(c)};return U(()=>{const l=o(e),c=o(t),u=ae().toVar();return Le(a.equal(P(1)),()=>{const h=o(i),d=r.mul(s.mul(2).add(1)).sub(s),p=li(Pt(h.r,d).mul(E(1).div(s)),0,1);u.assign(rt(l,c,p))}).Else(()=>{u.assign(rt(c,l,r))}),u})()}}const PD=(n,e,t,i=0,r=.1,s=0)=>G(new KT(Zi(n),Zi(e),Zi(t),G(i),G(r),G(s)));class DD extends pt{static get type(){return"PixelationNode"}constructor(e,t,i,r,s,a){super(),this.textureNode=e,this.depthNode=t,this.normalNode=i,this.pixelSize=r,this.normalEdgeStrength=s,this.depthEdgeStrength=a,this._resolution=fe(new st),this.updateBeforeType=je.RENDER}updateBefore(){const e=this.textureNode.value,t=e.image.width,i=e.image.height;this._resolution.value.set(t,i,1/t,1/i)}setup(){const{textureNode:e,depthNode:t,normalNode:i}=this,r=e.uvNode||nt(),s=t.uvNode||nt(),a=i.uvNode||nt(),o=()=>e.uv(r),l=(p,m)=>t.uv(s.add(z(p,m).mul(this._resolution.zw))).r,c=(p,m)=>i.uv(a.add(z(p,m).mul(this._resolution.zw))).rgb.normalize(),u=p=>{const m=ar("float","diff");return m.addAssign(li(l(1,0).sub(p))),m.addAssign(li(l(-1,0).sub(p))),m.addAssign(li(l(0,1).sub(p))),m.addAssign(li(l(0,-1).sub(p))),cs(Ki(.01,.02,m).mul(2)).div(2)},h=(p,m,v,f)=>{const g=l(p,m).sub(v),x=c(p,m),y=D(1,1,1),_=qt(f.sub(x),y),I=li(Ki(-.01,.01,_),0,1),b=li(Gl(g.mul(.25).add(.0025)),0,1);return E(1).sub(qt(f,x)).mul(b).mul(I)},d=(p,m)=>{const v=ar("float","indicator");return v.addAssign(h(0,-1,p,m)),v.addAssign(h(0,1,p,m)),v.addAssign(h(-1,0,p,m)),v.addAssign(h(1,0,p,m)),Wl(.1,v)};return U(()=>{const p=o(),m=ar("float","depth"),v=ar("vec3","normal");Le(this.depthEdgeStrength.greaterThan(0).or(this.normalEdgeStrength.greaterThan(0)),()=>{m.assign(l(0,0)),v.assign(c(0,0))});const f=ar("float","dei");Le(this.depthEdgeStrength.greaterThan(0),()=>{f.assign(u(m))});const g=ar("float","nei");Le(this.normalEdgeStrength.greaterThan(0),()=>{g.assign(d(m,v))});const x=f.greaterThan(0).select(E(1).sub(f.mul(this.depthEdgeStrength)),g.mul(this.normalEdgeStrength).add(1));return p.mul(x)})()}}const UD=(n,e,t,i=6,r=.3,s=.4)=>G(new DD(Zi(n),Zi(e),Zi(t),G(i),G(r),G(s)));class ZT extends Ti{static get type(){return"PixelationPassNode"}constructor(e,t,i=6,r=.3,s=.4){super("color",e,t,{minFilter:$t,magFilter:$t}),this.pixelSize=i,this.normalEdgeStrength=r,this.depthEdgeStrength=s,this.isPixelationPassNode=!0,this._mrt=md({output:_f,normal:hr})}setSize(e,t){const i=this.pixelSize.value?this.pixelSize.value:this.pixelSize,r=Math.floor(e/i),s=Math.floor(t/i);super.setSize(r,s)}setup(){const e=super.getTextureNode("output"),t=super.getTextureNode("depth"),i=super.getTextureNode("normal");return UD(e,t,i,this.pixelSize,this.normalEdgeStrength,this.depthEdgeStrength)}}const OD=(n,e,t,i,r)=>G(new ZT(n,e,t,i,r)),FD=new J;class QT extends Ti{static get type(){return"SSAAPassNode"}constructor(e,t){super(Ti.COLOR,e,t),this.isSSAAPassNode=!0,this.sampleLevel=4,this.unbiased=!0,this.clearColor=new xe(0),this.clearAlpha=0,this._currentClearColor=new xe,this.sampleWeight=fe(1),this.sampleRenderTarget=null,this._quadMesh=new fn}updateBefore(e){const{renderer:t}=e,{scene:i,camera:r}=this;this._pixelRatio=t.getPixelRatio();const s=t.getSize(FD);this.setSize(s.width,s.height),this.sampleRenderTarget.setSize(this.renderTarget.width,this.renderTarget.height),t.getClearColor(this._currentClearColor);const a=t.getClearAlpha(),o=t.getRenderTarget(),l=t.getMRT(),c=t.autoClear;this._cameraNear.value=r.near,this._cameraFar.value=r.far,t.setMRT(this.getMRT()),t.autoClear=!1;const u=VD[Math.max(0,Math.min(this.sampleLevel,5))],h=1/u.length,d=1/32,p={fullWidth:this.renderTarget.width,fullHeight:this.renderTarget.height,offsetX:0,offsetY:0,width:this.renderTarget.width,height:this.renderTarget.height},m=Object.assign({},r.view);m.enabled&&Object.assign(p,m);for(let v=0;v<u.length;v++){const f=u[v];if(r.setViewOffset&&r.setViewOffset(p.fullWidth,p.fullHeight,p.offsetX+f[0]*.0625,p.offsetY+f[1]*.0625,p.width,p.height),this.sampleWeight.value=h,this.unbiased){const g=-.5+(v+.5)/u.length;this.sampleWeight.value+=d*g}t.setClearColor(this.clearColor,this.clearAlpha),t.setRenderTarget(this.sampleRenderTarget),t.clear(),t.render(i,r),t.setRenderTarget(this.renderTarget),v===0&&(t.setClearColor(0,0),t.clear()),this._quadMesh.render(t)}t.copyTextureToTexture(this.sampleRenderTarget.depthTexture,this.renderTarget.depthTexture),r.setViewOffset&&m.enabled?r.setViewOffset(m.fullWidth,m.fullHeight,m.offsetX,m.offsetY,m.width,m.height):r.clearViewOffset&&r.clearViewOffset(),t.setRenderTarget(o),t.setMRT(l),t.autoClear=c,t.setClearColor(this._currentClearColor,a)}setup(e){this.sampleRenderTarget===null&&(this.sampleRenderTarget=this.renderTarget.clone());let t;const i=this.getMRT();if(i!==null){const r={};for(const s in i.outputNodes){const a=kg(this.sampleRenderTarget.textures,s);a>=0&&(r[s]=yt(this.sampleRenderTarget.textures[a]).mul(this.sampleWeight))}t=md(r)}else t=yt(this.sampleRenderTarget.texture).mul(this.sampleWeight);return this._quadMesh.material=new bt,this._quadMesh.material.fragmentNode=t,this._quadMesh.material.transparent=!0,this._quadMesh.material.depthTest=!1,this._quadMesh.material.depthWrite=!1,this._quadMesh.material.premultipliedAlpha=!0,this._quadMesh.material.blending=Ao,this._quadMesh.material.normals=!1,this._quadMesh.material.name="SSAA",super.setup(e)}dispose(){super.dispose(),this.sampleRenderTarget!==null&&this.sampleRenderTarget.dispose()}}const VD=[[[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]]],BD=(n,e)=>G(new QT(n,e)),zD=new J;class eS extends Ti{static get type(){return"StereoPassNode"}constructor(e,t){super(Ti.COLOR,e,t),this.isStereoPassNode=!0,this.stereo=new km,this.stereo.aspect=.5}updateBefore(e){const{renderer:t}=e,{scene:i,camera:r,stereo:s,renderTarget:a}=this;this._pixelRatio=t.getPixelRatio(),s.cameraL.coordinateSystem=t.coordinateSystem,s.cameraR.coordinateSystem=t.coordinateSystem,s.update(r);const o=t.getSize(zD);this.setSize(o.width,o.height);const l=t.autoClear;t.autoClear=!1;const c=t.getRenderTarget(),u=t.getMRT();this._cameraNear.value=r.near,this._cameraFar.value=r.far;for(const h in this._previousTextures)this.toggleTexture(h);t.setRenderTarget(a),t.setMRT(this._mrt),t.clear(),a.scissorTest=!0,a.scissor.set(0,0,a.width/2,a.height),a.viewport.set(0,0,a.width/2,a.height),t.render(i,s.cameraL),a.scissor.set(a.width/2,0,a.width/2,a.height),a.viewport.set(a.width/2,0,a.width/2,a.height),t.render(i,s.cameraR),a.scissorTest=!1,t.setRenderTarget(c),t.setMRT(u),t.autoClear=l}}const kD=(n,e)=>G(new eS(n,e)),HD=new J,tS=new fn;class iS extends Ti{static get type(){return"StereoCompositePassNode"}constructor(e,t){super(Ti.COLOR,e,t),this.isStereoCompositePassNode=!0,this.stereo=new km;const i={minFilter:Lt,magFilter:$t,type:wi};this._renderTargetL=new ui(1,1,i),this._renderTargetR=new ui(1,1,i),this._mapLeft=yt(this._renderTargetL.texture),this._mapRight=yt(this._renderTargetR.texture),this._material=null}updateStereoCamera(e){this.stereo.cameraL.coordinateSystem=e,this.stereo.cameraR.coordinateSystem=e,this.stereo.update(this.camera)}setSize(e,t){super.setSize(e,t),this._renderTargetL.setSize(this.renderTarget.width,this.renderTarget.height),this._renderTargetR.setSize(this.renderTarget.width,this.renderTarget.height)}updateBefore(e){const{renderer:t}=e,{scene:i,stereo:r,renderTarget:s}=this;this._pixelRatio=t.getPixelRatio(),this.updateStereoCamera(t.coordinateSystem);const a=t.getSize(HD);this.setSize(a.width,a.height);const o=t.getRenderTarget();t.setRenderTarget(this._renderTargetL),t.render(i,r.cameraL),t.setRenderTarget(this._renderTargetR),t.render(i,r.cameraR),t.setRenderTarget(s),tS.material=this._material,tS.render(t),t.setRenderTarget(o)}dispose(){super.dispose(),this._renderTargetL.dispose(),this._renderTargetR.dispose(),this._material!==null&&this._material.dispose()}}class rS extends iS{static get type(){return"AnaglyphPassNode"}constructor(e,t){super(e,t),this.isAnaglyphPassNode=!0,this._colorMatrixLeft=fe(new Ke().fromArray([.4561,-.0400822,-.0152161,.500484,-.0378246,-.0205971,.176381,-.0157589,-.00546856])),this._colorMatrixRight=fe(new Ke().fromArray([-.0434706,.378476,-.0721527,-.0879388,.73364,-.112961,-.00155529,-.0184503,1.2264]))}setup(e){const t=nt(),i=U(()=>{const s=this._mapLeft.uv(t),a=this._mapRight.uv(t),o=li(this._colorMatrixLeft.mul(s.rgb).add(this._colorMatrixRight.mul(a.rgb)));return ae(o.rgb,ft(s.a,a.a))}),r=this._material||(this._material=new bt);return r.fragmentNode=i().context(e.getSharedContext()),r.name="Anaglyph",r.needsUpdate=!0,super.setup(e)}}const GD=(n,e)=>G(new rS(n,e));class nS extends iS{static get type(){return"ParallaxBarrierPassNode"}constructor(e,t){super(e,t),this.isParallaxBarrierPassNode=!0}setup(e){const t=nt(),i=U(()=>{const s=ae().toVar();return Le(Bh(go.y,2).greaterThan(1),()=>{s.assign(this._mapLeft.uv(t))}).Else(()=>{s.assign(this._mapRight.uv(t))}),s}),r=this._material||(this._material=new bt);return r.fragmentNode=i().context(e.getSharedContext()),r.needsUpdate=!0,super.setup(e)}}const WD=(n,e)=>G(new nS(n,e));class sS extends Ti{static get type(){return"ToonOutlinePassNode"}constructor(e,t,i,r,s){super(Ti.COLOR,e,t),this.colorNode=i,this.thicknessNode=r,this.alphaNode=s,this._materialCache=new WeakMap}updateBefore(e){const{renderer:t}=e,i=t.getRenderObjectFunction();t.setRenderObjectFunction((r,s,a,o,l,c,u)=>{if((l.isMeshToonMaterial||l.isMeshToonNodeMaterial)&&l.wireframe===!1){const h=this._getOutlineMaterial(l);t.renderObject(r,s,a,o,h,c,u)}t.renderObject(r,s,a,o,l,c,u)}),super.updateBefore(e),t.setRenderObjectFunction(i)}_createMaterial(){const e=new bt;e.isMeshToonOutlineMaterial=!0,e.name="Toon_Outline",e.side=si;const t=ur.negate(),i=lr.mul(pn),r=E(1),s=i.mul(ae(Zt,1)),a=i.mul(ae(Zt.add(t),1)),o=Mr(s.sub(a));return e.vertexNode=s.add(o.mul(this.thicknessNode).mul(s.w).mul(r)),e.colorNode=ae(this.colorNode,this.alphaNode),e}_getOutlineMaterial(e){let t=this._materialCache.get(e);return t===void 0&&(t=this._createMaterial(),this._materialCache.set(e,t)),t}}const jD=(n,e,t=new xe(0,0,0),i=.003,r=1)=>G(new sS(n,e,G(t),G(i),G(r)));class aS extends qe{static get type(){return"ScriptableValueNode"}constructor(e=null){super(),this._value=e,this._cache=null,this.inputType=null,this.outpuType=null,this.events=new vr,this.isScriptableValueNode=!0}get isScriptableOutputNode(){return this.outputType!==null}set value(e){this._value!==e&&(this._cache&&this.inputType==="URL"&&this.value.value instanceof ArrayBuffer&&(URL.revokeObjectURL(this._cache),this._cache=null),this._value=e,this.events.dispatchEvent({type:"change"}),this.refresh())}get value(){return this._value}refresh(){this.events.dispatchEvent({type:"refresh"})}getValue(){const e=this.value;if(e&&this._cache===null&&this.inputType==="URL"&&e.value instanceof ArrayBuffer)this._cache=URL.createObjectURL(new Blob([e.value]));else if(e&&e.value!==null&&e.value!==void 0&&((this.inputType==="URL"||this.inputType==="String")&&typeof e.value=="string"||this.inputType==="Number"&&typeof e.value=="number"||this.inputType==="Vector2"&&e.value.isVector2||this.inputType==="Vector3"&&e.value.isVector3||this.inputType==="Vector4"&&e.value.isVector4||this.inputType==="Color"&&e.value.isColor||this.inputType==="Matrix3"&&e.value.isMatrix3||this.inputType==="Matrix4"&&e.value.isMatrix4))return e.value;return this._cache||e}getNodeType(e){return this.value&&this.value.isNode?this.value.getNodeType(e):"float"}setup(){return this.value&&this.value.isNode?this.value:E()}serialize(e){super.serialize(e),this.value!==null?this.inputType==="ArrayBuffer"?e.value=Qm(this.value):e.value=this.value?this.value.toJSON(e.meta).uuid:null:e.value=null,e.inputType=this.inputType,e.outputType=this.outputType}deserialize(e){super.deserialize(e);let t=null;e.value!==null&&(e.inputType==="ArrayBuffer"?t=ef(e.value):e.inputType==="Texture"?t=e.meta.textures[e.value]:t=e.meta.nodes[e.value]||null),this.value=t,this.inputType=e.inputType,this.outputType=e.outputType}}const yd=K(aS);class oS extends Map{get(e,t=null,...i){if(this.has(e))return super.get(e);if(t!==null){const r=t(...i);return this.set(e,r),r}}}class XD{constructor(e){this.scriptableNode=e}get parameters(){return this.scriptableNode.parameters}get layout(){return this.scriptableNode.getLayout()}getInputLayout(e){return this.scriptableNode.getInputLayout(e)}get(e){const t=this.parameters[e];return t?t.getValue():null}}const xd=new oS;class lS extends qe{static get type(){return"ScriptableNode"}constructor(e=null,t={}){super(),this.codeNode=e,this.parameters=t,this._local=new oS,this._output=yd(),this._outputs={},this._source=this.source,this._method=null,this._object=null,this._value=null,this._needsOutputUpdate=!0,this.onRefresh=this.onRefresh.bind(this),this.isScriptableNode=!0}get source(){return this.codeNode?this.codeNode.code:""}setLocal(e,t){return this._local.set(e,t)}getLocal(e){return this._local.get(e)}onRefresh(){this._refresh()}getInputLayout(e){for(const t of this.getLayout())if(t.inputType&&(t.id===e||t.name===e))return t}getOutputLayout(e){for(const t of this.getLayout())if(t.outputType&&(t.id===e||t.name===e))return t}setOutput(e,t){const i=this._outputs;return i[e]===void 0?i[e]=yd(t):i[e].value=t,this}getOutput(e){return this._outputs[e]}getParameter(e){return this.parameters[e]}setParameter(e,t){const i=this.parameters;return t&&t.isScriptableNode?(this.deleteParameter(e),i[e]=t,i[e].getDefaultOutput().events.addEventListener("refresh",this.onRefresh)):t&&t.isScriptableValueNode?(this.deleteParameter(e),i[e]=t,i[e].events.addEventListener("refresh",this.onRefresh)):i[e]===void 0?(i[e]=yd(t),i[e].events.addEventListener("refresh",this.onRefresh)):i[e].value=t,this}getValue(){return this.getDefaultOutput().getValue()}deleteParameter(e){let t=this.parameters[e];return t&&(t.isScriptableNode&&(t=t.getDefaultOutput()),t.events.removeEventListener("refresh",this.onRefresh)),this}clearParameters(){for(const e of Object.keys(this.parameters))this.deleteParameter(e);return this.needsUpdate=!0,this}call(e,...t){const i=this.getObject()[e];if(typeof i=="function")return i(...t)}async callAsync(e,...t){const i=this.getObject()[e];if(typeof i=="function")return i.constructor.name==="AsyncFunction"?await i(...t):i(...t)}getNodeType(e){return this.getDefaultOutputNode().getNodeType(e)}refresh(e=null){e!==null?this.getOutput(e).refresh():this._refresh()}getObject(){if(this.needsUpdate&&this.dispose(),this._object!==null)return this._object;const e=()=>this.refresh(),t=(c,u)=>this.setOutput(c,u),i=new XD(this),r=xd.get("THREE"),s=xd.get("TSL"),a=this.getMethod(this.codeNode),o=[i,this._local,xd,e,t,r,s];this._object=a(...o);const l=this._object.layout;if(l&&(l.cache===!1&&this._local.clear(),this._output.outputType=l.outputType||null,Array.isArray(l.elements)))for(const c of l.elements){const u=c.id||c.name;c.inputType&&(this.getParameter(u)===void 0&&this.setParameter(u,null),this.getParameter(u).inputType=c.inputType),c.outputType&&(this.getOutput(u)===void 0&&this.setOutput(u,null),this.getOutput(u).outputType=c.outputType)}return this._object}deserialize(e){super.deserialize(e);for(const t in this.parameters){let i=this.parameters[t];i.isScriptableNode&&(i=i.getDefaultOutput()),i.events.addEventListener("refresh",this.onRefresh)}}getLayout(){return this.getObject().layout}getDefaultOutputNode(){const e=this.getDefaultOutput().value;return e&&e.isNode?e:E()}getDefaultOutput(){return this._exec()._output}getMethod(){if(this.needsUpdate&&this.dispose(),this._method!==null)return this._method;const e=["parameters","local","global","refresh","setOutput","THREE","TSL"],t=["layout","init","main","dispose"].join(", "),i="var "+t+`; var output = {};
|
|
3870
|
+
`;return i}getHash(){return this.vertexShader+this.fragmentShader+this.computeShader}setShaderStage(e){this.shaderStage=e}getShaderStage(){return this.shaderStage}setBuildStage(e){this.buildStage=e}getBuildStage(){return this.buildStage}buildCode(){console.warn("Abstract function.")}build(){const{object:e,material:t,renderer:i}=this;if(t!==null){let r=i.nodes.library.fromMaterial(t);r===null&&(console.error(`NodeMaterial: Material "${t.type}" is not compatible.`),r=new bt),r.build(this)}else this.addFlow("compute",e);for(const r of rf){this.setBuildStage(r),this.context.vertex&&this.context.vertex.isNode&&this.flowNodeFromShaderStage("vertex",this.context.vertex);for(const s of nf){this.setShaderStage(s);const a=this.flowNodes[s];for(const o of a)r==="generate"?this.flowNode(o):o.build(this)}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}getNodeUniform(e,t){if(t==="float"||t==="int"||t==="uint")return new p3(e);if(t==="vec2"||t==="ivec2"||t==="uvec2")return new m3(e);if(t==="vec3"||t==="ivec3"||t==="uvec3")return new f3(e);if(t==="vec4"||t==="ivec4"||t==="uvec4")return new g3(e);if(t==="color")return new v3(e);if(t==="mat3")return new y3(e);if(t==="mat4")return new x3(e);throw new Error(`Uniform "${t}" not declared.`)}createNodeMaterial(e="NodeMaterial"){throw new Error(`THREE.NodeBuilder: createNodeMaterial() was deprecated. Use new ${e}() instead.`)}format(e,t,i){if(t=this.getVectorType(t),i=this.getVectorType(i),t===i||i===null||this.isReference(i))return e;const r=this.getTypeLength(t),s=this.getTypeLength(i);return r===16&&s===9?`${this.getType(i)}(${e}[0].xyz, ${e}[1].xyz, ${e}[2].xyz)`:r===9&&s===4?`${this.getType(i)}(${e}[0].xy, ${e}[1].xy)`:r>4||s>4||s===0?e:r===s?`${this.getType(i)}( ${e} )`:r>s?this.format(`${e}.${"xyz".slice(0,s)}`,this.getTypeFromLength(s,this.getComponentType(t)),i):s===4&&r>1?`${this.getType(i)}( ${this.format(e,t,"vec3")}, 1.0 )`:r===2?`${this.getType(i)}( ${this.format(e,t,"vec2")}, 0.0 )`:(r===1&&s>1&&t!==this.getComponentType(i)&&(e=`${this.getType(this.getComponentType(i))}( ${e} )`),`${this.getType(i)}( ${e} )`)}getSignature(){return`// Three.js r169 - Node System
|
|
3871
|
+
`}}class lT{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.startTime=null,this.updateMap=new WeakMap,this.updateBeforeMap=new WeakMap,this.updateAfterMap=new WeakMap,this.renderer=null,this.material=null,this.camera=null,this.object=null,this.scene=null}_getMaps(e,t){let i=e.get(t);return i===void 0&&(i={renderMap:new WeakMap,frameMap:new WeakMap},e.set(t,i)),i}updateBeforeNode(e){const t=e.getUpdateBeforeType(),i=e.updateReference(this);if(t===je.FRAME){const{frameMap:r}=this._getMaps(this.updateBeforeMap,i);r.get(i)!==this.frameId&&e.updateBefore(this)!==!1&&r.set(i,this.frameId)}else if(t===je.RENDER){const{renderMap:r}=this._getMaps(this.updateBeforeMap,i);r.get(i)!==this.renderId&&e.updateBefore(this)!==!1&&r.set(i,this.renderId)}else t===je.OBJECT&&e.updateBefore(this)}updateAfterNode(e){const t=e.getUpdateAfterType(),i=e.updateReference(this);if(t===je.FRAME){const{frameMap:r}=this._getMaps(this.updateAfterMap,i);r.get(i)!==this.frameId&&e.updateAfter(this)!==!1&&r.set(i,this.frameId)}else if(t===je.RENDER){const{renderMap:r}=this._getMaps(this.updateAfterMap,i);r.get(i)!==this.renderId&&e.updateAfter(this)!==!1&&r.set(i,this.renderId)}else t===je.OBJECT&&e.updateAfter(this)}updateNode(e){const t=e.getUpdateType(),i=e.updateReference(this);if(t===je.FRAME){const{frameMap:r}=this._getMaps(this.updateMap,i);r.get(i)!==this.frameId&&e.update(this)!==!1&&r.set(i,this.frameId)}else if(t===je.RENDER){const{renderMap:r}=this._getMaps(this.updateMap,i);r.get(i)!==this.renderId&&e.update(this)!==!1&&r.set(i,this.renderId)}else t===je.OBJECT&&e.update(this)}update(){this.frameId++,this.lastTime===void 0&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}}class Vg{constructor(e,t,i=null,r="",s=!1){this.type=e,this.name=t,this.count=i,this.qualifier=r,this.isConst=s}}Vg.isNodeFunctionInput=!0;class C3 extends qe{static get type(){return"StructTypeNode"}constructor(e){super(),this.types=e,this.isStructTypeNode=!0}getMemberTypes(){return this.types}}class Bg extends qe{static get type(){return"OutputStructNode"}constructor(...e){super(),this.members=e,this.isOutputStructNode=!0}setup(e){super.setup(e);const t=this.members,i=[];for(let r=0;r<t.length;r++)i.push(t[r].getNodeType(e));this.nodeType=e.getStructTypeFromNode(new C3(i)).name}generate(e,t){const i=e.getOutputStructName(),r=this.members,s=i!==""?i+".":"";for(let a=0;a<r.length;a++){const o=r[a].build(e,t);e.addLineFlowCode(`${s}m${a} = ${o}`,this)}return i}}const R3=K(Bg);function zg(n,e){for(let t=0;t<n.length;t++)if(n[t].name===e)return t;return-1}class cT extends Bg{static get type(){return"MRTNode"}constructor(e){super(),this.outputNodes=e,this.isMRTNode=!0}has(e){return this.outputNodes[e]!==void 0}get(e){return this.outputNodes[e]}merge(e){const t={...this.outputNodes,...e.outputNodes};return pd(t)}setup(e){const t=this.outputNodes,i=e.renderer.getRenderTarget(),r=[],s=i.textures;for(const a in t){const o=zg(s,a);r[o]=ae(t[a])}return this.members=r,super.setup(e)}}const pd=K(cT);class uT extends qe{static get type(){return"FunctionOverloadingNode"}constructor(e=[],...t){super(),this.functionNodes=e,this.parametersNodes=t,this._candidateFnCall=null,this.global=!0}getNodeType(){return this.functionNodes[0].shaderNode.layout.type}setup(e){const t=this.parametersNodes;let i=this._candidateFnCall;if(i===null){let r=null,s=-1;for(const a of this.functionNodes){const o=a.shaderNode.layout;if(o===null)throw new Error("FunctionOverloadingNode: FunctionNode must be a layout.");const l=o.inputs;if(t.length===l.length){let c=0;for(let u=0;u<t.length;u++){const h=t[u],d=l[u];h.getNodeType(e)===d.type?c++:c=0}c>s&&(r=a,s=c)}}this._candidateFnCall=i=r(...t)}return i}}const I3=K(uT),Di=n=>(...e)=>I3(n,...e);class Si extends Ys{static get type(){return"TimerNode"}constructor(e=Si.LOCAL,t=1,i=0){super(i),this.scope=e,this.scale=t,this.updateType=je.FRAME}update(e){const t=this.scope,i=this.scale;t===Si.LOCAL?this.value+=e.deltaTime*i:t===Si.DELTA?this.value=e.deltaTime*i:t===Si.FRAME?this.value=e.frameId:this.value=e.time*i}serialize(e){super.serialize(e),e.scope=this.scope,e.scale=this.scale}deserialize(e){super.deserialize(e),this.scope=e.scope,this.scale=e.scale}}Si.LOCAL="local",Si.GLOBAL="global",Si.DELTA="delta",Si.FRAME="frame";const kg=(n,e=0)=>G(new Si(Si.LOCAL,n,e)),L3=(n,e=0)=>G(new Si(Si.GLOBAL,n,e)),P3=(n,e=0)=>G(new Si(Si.DELTA,n,e)),D3=ge(Si,Si.FRAME).toUint();class gi extends qe{static get type(){return"OscNode"}constructor(e=gi.SINE,t=kg()){super(),this.method=e,this.timeNode=t}getNodeType(e){return this.timeNode.getNodeType(e)}setup(){const e=this.method,t=G(this.timeNode);let i=null;return e===gi.SINE?i=t.add(.75).mul(Math.PI*2).sin().mul(.5).add(.5):e===gi.SQUARE?i=t.fract().round():e===gi.TRIANGLE?i=t.add(.5).fract().mul(2).sub(1).abs():e===gi.SAWTOOTH&&(i=t.fract()),i}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}gi.SINE="sine",gi.SQUARE="square",gi.TRIANGLE="triangle",gi.SAWTOOTH="sawtooth";const U3=K(gi,gi.SINE),O3=K(gi,gi.SQUARE),F3=K(gi,gi.TRIANGLE),V3=K(gi,gi.SAWTOOTH);class hT extends qe{static get type(){return"SpriteSheetUVNode"}constructor(e,t=nt(),i=E(0)){super("vec2"),this.countNode=e,this.uvNode=t,this.frameNode=i}setup(){const{frameNode:e,uvNode:t,countNode:i}=this,{width:r,height:s}=i,a=e.mod(r.mul(s)).floor(),o=a.mod(r),l=s.sub(a.add(1).div(r).ceil()),c=i.reciprocal(),u=z(o,l);return t.add(u).mul(c)}}const B3=K(hT);class dT extends ss{static get type(){return"StorageArrayElementNode"}constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}setup(e){return e.isAvailable("storageBuffer")===!1&&this.node.bufferObject===!0&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let i;const r=e.context.assign;if(e.isAvailable("storageBuffer")===!1?this.node.bufferObject===!0&&r!==!0?i=e.generatePBO(this):i=this.node.build(e):i=super.generate(e),r!==!0){const s=this.getNodeType(e);i=e.format(i,s,t)}return i}}const z3=K(dT);class pT extends qe{static get type(){return"TriplanarTexturesNode"}constructor(e,t=null,i=null,r=E(1),s=Zt,a=ur){super("vec4"),this.textureXNode=e,this.textureYNode=t,this.textureZNode=i,this.scaleNode=r,this.positionNode=s,this.normalNode=a}setup(){const{textureXNode:e,textureYNode:t,textureZNode:i,scaleNode:r,positionNode:s,normalNode:a}=this;let o=a.abs().normalize();o=o.div(o.dot(D(1)));const l=s.yz.mul(r),c=s.zx.mul(r),u=s.xy.mul(r),h=e.value,d=t!==null?t.value:h,p=i!==null?i.value:h,m=yt(h,l).mul(o.x),v=yt(d,c).mul(o.y),f=yt(p,u).mul(o.z);return zt(m,v,f)}}const mT=K(pT),k3=(...n)=>mT(...n),xo=new ln,aa=new N,_o=new N,Hg=new N,cc=new Re,md=new N(0,0,-1),Dn=new st,uc=new N,fd=new N,hc=new st,gd=new J,fT=new ui,H3=ds.flipX();let Gg=!1;class gT extends dn{static get type(){return"ReflectorNode"}constructor(e={}){super(fT.texture,H3);const{target:t=new _t,resolution:i=1,generateMipmaps:r=!1,bounces:s=!0}=e;this.target=t,this.resolution=i,this.generateMipmaps=r,this.bounces=s,this.updateBeforeType=s?je.RENDER:je.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new WeakMap}_updateResolution(e,t){const i=this.resolution;t.getDrawingBufferSize(gd),e.setSize(Math.round(gd.width*i),Math.round(gd.height*i))}setup(e){return this._updateResolution(fT,e.renderer),super.setup(e)}getTextureNode(){return this.textureNode}getVirtualCamera(e){let t=this.virtualCameras.get(e);return t===void 0&&(t=e.clone(),this.virtualCameras.set(e,t)),t}getRenderTarget(e){let t=this.renderTargets.get(e);return t===void 0&&(t=new ui(0,0,{type:wi}),this.generateMipmaps===!0&&(t.texture.minFilter=O0,t.texture.generateMipmaps=!0),this.renderTargets.set(e,t)),t}updateBefore(e){if(this.bounces===!1&&Gg)return!1;Gg=!0;const{scene:t,camera:i,renderer:r,material:s}=e,{target:a}=this,o=this.getVirtualCamera(i),l=this.getRenderTarget(o);if(r.getDrawingBufferSize(gd),this._updateResolution(l,r),_o.setFromMatrixPosition(a.matrixWorld),Hg.setFromMatrixPosition(i.matrixWorld),cc.extractRotation(a.matrixWorld),aa.set(0,0,1),aa.applyMatrix4(cc),uc.subVectors(_o,Hg),uc.dot(aa)>0)return;uc.reflect(aa).negate(),uc.add(_o),cc.extractRotation(i.matrixWorld),md.set(0,0,-1),md.applyMatrix4(cc),md.add(Hg),fd.subVectors(_o,md),fd.reflect(aa).negate(),fd.add(_o),o.coordinateSystem=i.coordinateSystem,o.position.copy(uc),o.up.set(0,1,0),o.up.applyMatrix4(cc),o.up.reflect(aa),o.lookAt(fd),o.near=i.near,o.far=i.far,o.updateMatrixWorld(),o.projectionMatrix.copy(i.projectionMatrix),xo.setFromNormalAndCoplanarPoint(aa,_o),xo.applyMatrix4(o.matrixWorldInverse),Dn.set(xo.normal.x,xo.normal.y,xo.normal.z,xo.constant);const c=o.projectionMatrix;hc.x=(Math.sign(Dn.x)+c.elements[8])/c.elements[0],hc.y=(Math.sign(Dn.y)+c.elements[9])/c.elements[5],hc.z=-1,hc.w=(1+c.elements[10])/c.elements[14],Dn.multiplyScalar(1/Dn.dot(hc));const u=0;c.elements[2]=Dn.x,c.elements[6]=Dn.y,c.elements[10]=Dn.z-u,c.elements[14]=Dn.w,this.value=l.texture,s.visible=!1;const h=r.getRenderTarget(),d=r.getMRT();r.setMRT(null),r.setRenderTarget(l),r.render(t,o),r.setMRT(d),r.setRenderTarget(h),s.visible=!0,Gg=!1}}const G3=n=>G(new gT(n)),Wg=new Is(-1,1,1,-1,0,1);class W3 extends ct{constructor(e=!1){super();const t=e===!1?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new De([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new De(t,2))}}const j3=new W3;class fn extends Ft{constructor(e=null){super(j3,e),this.camera=Wg,this.isQuadMesh=!0}renderAsync(e){return e.renderAsync(this,Wg)}render(e){e.render(this,Wg)}}const X3=new J;class vT extends dn{static get type(){return"RTTNode"}constructor(e,t=null,i=null,r={type:wi}){const s=new ui(t,i,r);super(s.texture,nt()),this.node=e,this.width=t,this.height=i,this.renderTarget=s,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this.updateMap=new WeakMap,this._rttNode=null,this._quadMesh=new fn(new bt),this.updateBeforeType=je.RENDER}get autoSize(){return this.width===null}setup(e){return this._rttNode=this.node.context(e.getSharedContext()),this._quadMesh.material.name="RTT",this._quadMesh.material.needsUpdate=!0,super.setup(e)}setSize(e,t){this.width=e,this.height=t;const i=e*this.pixelRatio,r=t*this.pixelRatio;this.renderTarget.setSize(i,r),this.textureNeedsUpdate=!0}setPixelRatio(e){this.pixelRatio=e,this.setSize(this.width,this.height)}updateBefore({renderer:e}){if(this.textureNeedsUpdate===!1&&this.autoUpdate===!1)return;if(this.textureNeedsUpdate=!1,this.autoSize===!0){this.pixelRatio=e.getPixelRatio();const i=e.getSize(X3);this.setSize(i.width,i.height)}this._quadMesh.material.fragmentNode=this._rttNode;const t=e.getRenderTarget();e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(t)}clone(){const e=new dn(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}}const yT=(n,...e)=>G(new vT(G(n),...e)),Zi=(n,...e)=>n.isTextureNode?n:yT(n,...e);class xT extends Hf{static get type(){return"VertexColorNode"}constructor(e=0){super(null,"vec4"),this.isVertexColorNode=!0,this.index=e}getAttributeName(){const e=this.index;return"color"+(e>0?e:"")}generate(e){const t=this.getAttributeName(e),i=e.hasGeometryAttribute(t);let r;return i===!0?r=super.generate(e):r=e.generateConst(this.nodeType,new st(1,1,1,1)),r}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}}const q3=(...n)=>G(new xT(...n));class _T extends qe{static get type(){return"PointUVNode"}constructor(){super("vec2"),this.isPointUVNode=!0}generate(){return"vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )"}}const Y3=ge(_T);class sn extends qe{static get type(){return"SceneNode"}constructor(e=sn.BACKGROUND_BLURRINESS,t=null){super(),this.scope=e,this.scene=t}setup(e){const t=this.scope,i=this.scene!==null?this.scene:e.scene;let r;return t===sn.BACKGROUND_BLURRINESS?r=fi("backgroundBlurriness","float",i):t===sn.BACKGROUND_INTENSITY?r=fi("backgroundIntensity","float",i):console.error("THREE.SceneNode: Unknown scope:",t),r}}sn.BACKGROUND_BLURRINESS="backgroundBlurriness",sn.BACKGROUND_INTENSITY="backgroundIntensity";const $3=ge(sn,sn.BACKGROUND_BLURRINESS),J3=ge(sn,sn.BACKGROUND_INTENSITY),MT={Storage:"storage",ReadOnlyStorage:"read-only-storage"},jg={WriteOnly:"write-only",ReadOnly:"read-only"};class Xg extends Xh{static get type(){return"StorageBufferNode"}constructor(e,t,i=0){super(e,t,i),this.isStorageBufferNode=!0,this.access=MT.Storage,this.isAtomic=!1,this.bufferObject=!1,this.bufferCount=i,this._attribute=null,this._varying=null,this.global=!0,e.isStorageBufferAttribute!==!0&&e.isStorageInstancedBufferAttribute!==!0&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){if(this.bufferCount===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getInputType(){return"storageBuffer"}element(e){return z3(this,e)}setBufferObject(e){return this.bufferObject=e,this}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(MT.ReadOnlyStorage)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}generate(e){if(e.isAvailable("storageBuffer"))return super.generate(e);const t=this.getNodeType(e);this._attribute===null&&(this._attribute=Xl(this.value),this._varying=Ii(this._attribute));const i=this._varying.build(e,t);return e.registerTransform(i,this._attribute),i}}const K3=(n,e,t)=>G(new Xg(n,e,t)),Z3=(n,e,t)=>G(new Xg(n,e,t).setBufferObject(!0));class bT extends dn{static get type(){return"StorageTextureNode"}constructor(e,t,i=null){super(e,t),this.storeNode=i,this.isStorageTextureNode=!0,this.access=jg.WriteOnly}getInputType(){return"storageTexture"}setup(e){super.setup(e);const t=e.getNodeProperties(this);t.storeNode=this.storeNode}setAccess(e){return this.access=e,this}generate(e,t){let i;return this.storeNode!==null?i=this.generateStore(e):i=super.generate(e,t),i}toReadOnly(){return this.setAccess(jg.ReadOnly)}toWriteOnly(){return this.setAccess(jg.WriteOnly)}generateStore(e){const t=e.getNodeProperties(this),{uvNode:i,storeNode:r}=t,s=super.generate(e,"property"),a=i.build(e,"uvec2"),o=r.build(e,"vec4"),l=e.generateTextureStore(e,s,a,o);e.addLineFlowCode(l,this)}}const TT=K(bT),Q3=(n,e,t)=>{const i=TT(n,e,t);return t!==null&&i.append(),i};class ST extends Jl{static get type(){return"UserDataNode"}constructor(e,t,i=null){super(e,t,i),this.userData=i}updateReference(e){return this.reference=this.userData!==null?this.userData:e.object.userData,this.reference}}const eD=(n,e,t)=>G(new ST(n,e,t));class wT extends pt{static get type(){return"PosterizeNode"}constructor(e,t){super(),this.sourceNode=e,this.stepsNode=t}setup(){const{sourceNode:e,stepsNode:t}=this;return e.mul(t).floor().div(t)}}const tD=K(wT);let qg=null;class ET extends sc{static get type(){return"ViewportSharedTextureNode"}constructor(e=ds,t=null){qg===null&&(qg=new dm),super(e,t,qg)}updateReference(){return this}}const iD=K(ET),rD=new J;class AT extends dn{static get type(){return"PassTextureNode"}constructor(e,t){super(t),this.passNode=e,this.setUpdateMatrix(!1)}setup(e){return e.object.isQuadMesh&&this.passNode.build(e),super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}}class NT extends AT{static get type(){return"PassMultipleTextureNode"}constructor(e,t,i=!1){super(e,null),this.textureName=t,this.previousTexture=i}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){return new this.constructor(this.passNode,this.textureName,this.previousTexture)}}class Ti extends pt{static get type(){return"PassNode"}constructor(e,t,i,r={}){super("vec4"),this.scope=e,this.scene=t,this.camera=i,this.options=r,this._pixelRatio=1,this._width=1,this._height=1;const s=new Ds;s.isRenderTargetTexture=!0,s.name="depth";const a=new ui(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:wi,...r});a.texture.name="output",a.depthTexture=s,this.renderTarget=a,this.updateBeforeType=je.FRAME,this._textures={output:a.texture,depth:s},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=fe(0),this._cameraFar=fe(0),this._mrt=null,this.isPassNode=!0}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}isGlobal(){return!0}getTexture(e){let t=this._textures[e];return t===void 0&&(t=this.renderTarget.texture.clone(),t.isRenderTargetTexture=!0,t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)),t}getPreviousTexture(e){let t=this._previousTextures[e];return t===void 0&&(t=this.getTexture(e).clone(),t.isRenderTargetTexture=!0,this._previousTextures[e]=t),t}toggleTexture(e){const t=this._previousTextures[e];if(t!==void 0){const i=this._textures[e],r=this.renderTarget.textures.indexOf(i);this.renderTarget.textures[r]=t,this._textures[e]=t,this._previousTextures[e]=i,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e="output"){let t=this._textureNodes[e];return t===void 0&&(this._textureNodes[e]=t=G(new NT(this,e)),this._textureNodes[e].updateTexture()),t}getPreviousTextureNode(e="output"){let t=this._previousTextureNodes[e];return t===void 0&&(this._textureNodes[e]===void 0&&this.getTextureNode(e),this._previousTextureNodes[e]=t=G(new NT(this,e,!0)),this._previousTextureNodes[e].updateTexture()),t}getViewZNode(e="depth"){let t=this._viewZNodes[e];if(t===void 0){const i=this._cameraNear,r=this._cameraFar;this._viewZNodes[e]=t=lg(this.getTextureNode(e),i,r)}return t}getLinearDepthNode(e="depth"){let t=this._linearDepthNodes[e];if(t===void 0){const i=this._cameraNear,r=this._cameraFar,s=this.getViewZNode(e);this._linearDepthNodes[e]=t=ac(s,i,r)}return t}setup({renderer:e}){return this.renderTarget.samples=this.options.samples===void 0?e.samples:this.options.samples,e.backend.isWebGLBackend===!0&&(this.renderTarget.samples=0),this.renderTarget.depthTexture.isMultisampleRenderTargetTexture=this.renderTarget.samples>1,this.scope===Ti.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){const{renderer:t}=e,{scene:i,camera:r}=this;this._pixelRatio=t.getPixelRatio();const s=t.getSize(rD);this.setSize(s.width,s.height);const a=t.getRenderTarget(),o=t.getMRT();this._cameraNear.value=r.near,this._cameraFar.value=r.far;for(const l in this._previousTextures)this.toggleTexture(l);t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.render(i,r),t.setRenderTarget(a),t.setMRT(o)}setSize(e,t){this._width=e,this._height=t;const i=this._width*this._pixelRatio,r=this._height*this._pixelRatio;this.renderTarget.setSize(i,r)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}}Ti.COLOR="color",Ti.DEPTH="depth";const nD=(n,e,t)=>G(new Ti(Ti.COLOR,n,e,t)),Mo=(n,e)=>G(new AT(n,e)),sD=(n,e)=>G(new Ti(Ti.DEPTH,n,e)),CT=new fn,RT=new fn;class IT extends pt{static get type(){return"GaussianBlurNode"}constructor(e,t=null,i=2){super("vec4"),this.textureNode=e,this.directionNode=t,this.sigma=i,this._invSize=fe(new J),this._passDirection=fe(new J),this._horizontalRT=new ui,this._horizontalRT.texture.name="GaussianBlurNode.horizontal",this._verticalRT=new ui,this._verticalRT.texture.name="GaussianBlurNode.vertical",this._textureNode=Mo(this,this._verticalRT.texture),this.updateBeforeType=je.RENDER,this.resolution=new J(1,1)}setSize(e,t){e=Math.max(Math.round(e*this.resolution.x),1),t=Math.max(Math.round(t*this.resolution.y),1),this._invSize.value.set(1/e,1/t),this._horizontalRT.setSize(e,t),this._verticalRT.setSize(e,t)}updateBefore(e){const{renderer:t}=e,i=this.textureNode,r=i.value,s=t.getRenderTarget(),a=t.getMRT(),o=i.value;CT.material=this._material,RT.material=this._material,this.setSize(r.image.width,r.image.height);const l=r.type;this._horizontalRT.texture.type=l,this._verticalRT.texture.type=l,t.setMRT(null),t.setRenderTarget(this._horizontalRT),this._passDirection.value.set(1,0),CT.render(t),i.value=this._horizontalRT.texture,t.setRenderTarget(this._verticalRT),this._passDirection.value.set(0,1),RT.render(t),t.setRenderTarget(s),t.setMRT(a),i.value=o}getTextureNode(){return this._textureNode}setup(e){const t=this.textureNode;if(t.isTextureNode!==!0)return console.error("GaussianBlurNode requires a TextureNode."),ae();const i=t.uvNode||nt(),r=z(this.directionNode||1),s=c=>t.uv(c),a=U(()=>{const c=3+2*this.sigma,u=this._getCoefficients(c),h=this._invSize,d=r.mul(this._passDirection),p=E(u[0]).toVar(),m=ae(s(i).mul(p)).toVar();for(let v=1;v<c;v++){const f=E(v),g=E(u[v]),x=z(d.mul(h.mul(f))).toVar(),y=ae(s(i.add(x))),_=ae(s(i.sub(x)));m.addAssign(y.add(_).mul(g)),p.addAssign(lt(2,g))}return m.div(p)}),o=this._material||(this._material=new bt);o.fragmentNode=a().context(e.getSharedContext()),o.name="Gaussian_blur",o.needsUpdate=!0;const l=e.getNodeProperties(this);return l.textureNode=t,this._textureNode}dispose(){this._horizontalRT.dispose(),this._verticalRT.dispose()}_getCoefficients(e){const t=[];for(let i=0;i<e;i++)t.push(.39894*Math.exp(-.5*i*i/(e*e))/e);return t}}const aD=(n,e,t)=>G(new IT(Zi(n),e,t)),Yg=new J,LT=new fn;class PT extends pt{static get type(){return"AfterImageNode"}constructor(e,t=.96){super(e),this.textureNode=e,this.textureNodeOld=yt(),this.damp=fe(t),this._compRT=new ui,this._compRT.texture.name="AfterImageNode.comp",this._oldRT=new ui,this._oldRT.texture.name="AfterImageNode.old",this._textureNode=Mo(this,this._compRT.texture),this.updateBeforeType=je.RENDER}getTextureNode(){return this._textureNode}setSize(e,t){this._compRT.setSize(e,t),this._oldRT.setSize(e,t)}updateBefore(e){const{renderer:t}=e,i=this.textureNode,r=i.value.type;this._compRT.texture.type=r,this._oldRT.texture.type=r,t.getDrawingBufferSize(Yg),this.setSize(Yg.x,Yg.y);const s=t.getRenderTarget(),a=i.value;this.textureNodeOld.value=this._oldRT.texture,t.setRenderTarget(this._compRT),LT.render(t);const o=this._oldRT;this._oldRT=this._compRT,this._compRT=o,t.setRenderTarget(s),i.value=a}setup(e){const t=this.textureNode,i=this.textureNodeOld,r=t.uvNode||nt();i.uvNode=r;const s=u=>t.uv(u),a=U(([u,h])=>{const d=E(h).toVar(),p=ae(u).toVar();return ft(Hl(p.sub(d)),0)}),o=U(()=>{const u=ae(i),h=ae(s(r));return u.mulAssign(this.damp.mul(a(u,.1))),ft(h,u)}),l=this._materialComposed||(this._materialComposed=new bt);l.name="AfterImage",l.fragmentNode=o(),LT.material=l;const c=e.getNodeProperties(this);return c.textureNode=t,this._textureNode}dispose(){this._compRT.dispose(),this._oldRT.dispose()}}const oD=(n,e)=>G(new PT(Zi(n),e)),lD=U(([n])=>Ui(n.rgb)),cD=U(([n,e=E(1)])=>e.mix(Ui(n.rgb),n.rgb)),uD=U(([n,e=E(1)])=>{const t=zt(n.r,n.g,n.b).div(3),i=n.r.max(n.g.max(n.b)),r=i.sub(t).mul(e).mul(-3);return rt(n.rgb,i,r)}),hD=U(([n,e=E(1)])=>{const t=D(.57735,.57735,.57735),i=e.cos();return D(n.rgb.mul(i).add(t.cross(n.rgb).mul(e.sin()).add(t.mul(qt(t,n.rgb).mul(i.oneMinus())))))}),dD=new N,Ui=(n,e=D(...vt.getLuminanceCoefficients(dD)))=>qt(n,e),DT=(n,e)=>rt(D(0),n,Ui(n).sub(e).max(0)),UT=new fn;class OT extends pt{static get type(){return"AnamorphicNode"}constructor(e,t,i,r){super("vec4"),this.textureNode=e,this.tresholdNode=t,this.scaleNode=i,this.colorNode=D(.1,0,1),this.samples=r,this.resolution=new J(1,1),this._renderTarget=new ui,this._renderTarget.texture.name="anamorphic",this._invSize=fe(new J),this._textureNode=Mo(this,this._renderTarget.texture),this.updateBeforeType=je.RENDER}getTextureNode(){return this._textureNode}setSize(e,t){this._invSize.value.set(1/e,1/t),e=Math.max(Math.round(e*this.resolution.x),1),t=Math.max(Math.round(t*this.resolution.y),1),this._renderTarget.setSize(e,t)}updateBefore(e){const{renderer:t}=e,i=this.textureNode,r=i.value;this._renderTarget.texture.type=r.type;const s=t.getRenderTarget(),a=i.value;UT.material=this._material,this.setSize(r.image.width,r.image.height),t.setRenderTarget(this._renderTarget),UT.render(t),t.setRenderTarget(s),i.value=a}setup(e){const t=this.textureNode,i=t.uvNode||nt(),r=l=>t.uv(l),s=U(()=>{const l=this.samples,c=Math.floor(l/2),u=D(0).toVar();return gt({start:-c,end:c},({i:h})=>{const d=E(h).abs().div(c).oneMinus(),p=z(i.x.add(this._invSize.x.mul(h).mul(this.scaleNode)),i.y),m=r(p),v=DT(m,this.tresholdNode).mul(d);u.addAssign(v)}),u.mul(this.colorNode)}),a=this._material||(this._material=new bt);a.name="Anamorphic",a.fragmentNode=s();const o=e.getNodeProperties(this);return o.textureNode=t,this._textureNode}dispose(){this._renderTarget.dispose()}}const pD=(n,e=.9,t=3,i=32)=>G(new OT(Zi(n),G(e),G(t),i));class FT extends pt{static get type(){return"SobelOperatorNode"}constructor(e){super(),this.textureNode=e,this.updateBeforeType=je.RENDER,this._invSize=fe(new J)}updateBefore(){const e=this.textureNode.value;this._invSize.value.set(1/e.image.width,1/e.image.height)}setup(){const{textureNode:e}=this,t=e.uvNode||nt(),i=r=>e.uv(r);return U(()=>{const r=this._invSize,s=yi(-1,-2,-1,0,0,0,1,2,1),a=yi(-1,0,1,-2,0,2,-1,0,1),o=Ui(i(t.add(r.mul(z(-1,-1)))).xyz),l=Ui(i(t.add(r.mul(z(-1,0)))).xyz),c=Ui(i(t.add(r.mul(z(-1,1)))).xyz),u=Ui(i(t.add(r.mul(z(0,-1)))).xyz),h=Ui(i(t.add(r.mul(z(0,0)))).xyz),d=Ui(i(t.add(r.mul(z(0,1)))).xyz),p=Ui(i(t.add(r.mul(z(1,-1)))).xyz),m=Ui(i(t.add(r.mul(z(1,0)))).xyz),v=Ui(i(t.add(r.mul(z(1,1)))).xyz),f=zt(s[0][0].mul(o),s[1][0].mul(u),s[2][0].mul(p),s[0][1].mul(l),s[1][1].mul(h),s[2][1].mul(m),s[0][2].mul(c),s[1][2].mul(d),s[2][2].mul(v)),g=zt(a[0][0].mul(o),a[1][0].mul(u),a[2][0].mul(p),a[0][1].mul(l),a[1][1].mul(h),a[2][1].mul(m),a[0][2].mul(c),a[1][2].mul(d),a[2][2].mul(v)),x=f.mul(f).add(g.mul(g)).sqrt();return ae(D(x),1)})()}}const mD=n=>G(new FT(Zi(n)));class VT extends pt{static get type(){return"DepthOfFieldNode"}constructor(e,t,i,r,s){super(),this.textureNode=e,this.viewZNode=t,this.focusNode=i,this.apertureNode=r,this.maxblurNode=s,this._aspect=fe(0),this.updateBeforeType=je.RENDER}updateBefore(){const e=this.textureNode.value;this._aspect.value=e.image.width/e.image.height}setup(){const e=this.textureNode,t=e.uvNode||nt(),i=r=>e.uv(r);return U(()=>{const r=z(1,this._aspect),s=this.focusNode.add(this.viewZNode),a=z(li(s.mul(this.apertureNode),this.maxblurNode.negate(),this.maxblurNode)),o=a.mul(.9),l=a.mul(.7),c=a.mul(.4);let u=ae(0);return u=u.add(i(t)),u=u.add(i(t.add(z(0,.4).mul(r).mul(a)))),u=u.add(i(t.add(z(.15,.37).mul(r).mul(a)))),u=u.add(i(t.add(z(.29,.29).mul(r).mul(a)))),u=u.add(i(t.add(z(-.37,.15).mul(r).mul(a)))),u=u.add(i(t.add(z(.4,0).mul(r).mul(a)))),u=u.add(i(t.add(z(.37,-.15).mul(r).mul(a)))),u=u.add(i(t.add(z(.29,-.29).mul(r).mul(a)))),u=u.add(i(t.add(z(-.15,-.37).mul(r).mul(a)))),u=u.add(i(t.add(z(0,-.4).mul(r).mul(a)))),u=u.add(i(t.add(z(-.15,.37).mul(r).mul(a)))),u=u.add(i(t.add(z(-.29,.29).mul(r).mul(a)))),u=u.add(i(t.add(z(.37,.15).mul(r).mul(a)))),u=u.add(i(t.add(z(-.4,0).mul(r).mul(a)))),u=u.add(i(t.add(z(-.37,-.15).mul(r).mul(a)))),u=u.add(i(t.add(z(-.29,-.29).mul(r).mul(a)))),u=u.add(i(t.add(z(.15,-.37).mul(r).mul(a)))),u=u.add(i(t.add(z(.15,.37).mul(r).mul(o)))),u=u.add(i(t.add(z(-.37,.15).mul(r).mul(o)))),u=u.add(i(t.add(z(.37,-.15).mul(r).mul(o)))),u=u.add(i(t.add(z(-.15,-.37).mul(r).mul(o)))),u=u.add(i(t.add(z(-.15,.37).mul(r).mul(o)))),u=u.add(i(t.add(z(.37,.15).mul(r).mul(o)))),u=u.add(i(t.add(z(-.37,-.15).mul(r).mul(o)))),u=u.add(i(t.add(z(.15,-.37).mul(r).mul(o)))),u=u.add(i(t.add(z(.29,.29).mul(r).mul(l)))),u=u.add(i(t.add(z(.4,0).mul(r).mul(l)))),u=u.add(i(t.add(z(.29,-.29).mul(r).mul(l)))),u=u.add(i(t.add(z(0,-.4).mul(r).mul(l)))),u=u.add(i(t.add(z(-.29,.29).mul(r).mul(l)))),u=u.add(i(t.add(z(-.4,0).mul(r).mul(l)))),u=u.add(i(t.add(z(-.29,-.29).mul(r).mul(l)))),u=u.add(i(t.add(z(0,.4).mul(r).mul(l)))),u=u.add(i(t.add(z(.29,.29).mul(r).mul(c)))),u=u.add(i(t.add(z(.4,0).mul(r).mul(c)))),u=u.add(i(t.add(z(.29,-.29).mul(r).mul(c)))),u=u.add(i(t.add(z(0,-.4).mul(r).mul(c)))),u=u.add(i(t.add(z(-.29,.29).mul(r).mul(c)))),u=u.add(i(t.add(z(-.4,0).mul(r).mul(c)))),u=u.add(i(t.add(z(-.29,-.29).mul(r).mul(c)))),u=u.add(i(t.add(z(0,.4).mul(r).mul(c)))),u=u.div(41),u.a=1,ae(u)})()}}const fD=(n,e,t=1,i=.025,r=1)=>G(new VT(Zi(n),G(e),G(t),G(i),G(r)));class BT extends pt{static get type(){return"DotScreenNode"}constructor(e,t=new J(.5,.5),i=1.57,r=1){super("vec4"),this.inputNode=e,this.center=fe(t),this.angle=fe(i),this.scale=fe(r)}setup(){const e=this.inputNode,t=U(()=>{const i=Ci(this.angle),r=br(this.angle),s=nt().mul(mo).sub(this.center),a=z(r.mul(s.x).sub(i.mul(s.y)),i.mul(s.x).add(r.mul(s.y))).mul(this.scale);return Ci(a.x).mul(Ci(a.y)).mul(4)});return U(()=>{const i=e,r=zt(i.r,i.g,i.b).div(3);return ae(D(r.mul(10).sub(5).add(t())),i.a)})()}}const gD=(n,e,t,i)=>G(new BT(G(n),e,t,i));class zT extends pt{static get type(){return"RGBShiftNode"}constructor(e,t=.005,i=0){super("vec4"),this.textureNode=e,this.amount=fe(t),this.angle=fe(i)}setup(){const{textureNode:e}=this,t=e.uvNode||nt(),i=r=>e.uv(r);return U(()=>{const r=z(br(this.angle),Ci(this.angle)).mul(this.amount),s=i(t.add(r)),a=i(t),o=i(t.sub(r));return ae(s.r,a.g,o.b,a.a)})()}}const vD=(n,e,t)=>G(new zT(Zi(n),e,t));class kT extends pt{static get type(){return"FilmNode"}constructor(e,t=null,i=null){super(),this.inputNode=e,this.intensityNode=t,this.uvNode=i}setup(){const e=this.uvNode||nt();return U(()=>{const t=this.inputNode.rgb,i=Df(cs(e.add(kg())));let r=t.add(t.mul(li(i.add(.1),0,1)));return this.intensityNode!==null&&(r=rt(t,r,this.intensityNode)),ae(r,this.inputNode.a)})()}}const yD=K(kT);class HT extends pt{static get type(){return"Lut3DNode"}constructor(e,t,i,r){super(),this.inputNode=e,this.lutNode=t,this.size=fe(i),this.intensityNode=r}setup(){const{inputNode:e,lutNode:t}=this,i=r=>t.uv(r);return U(()=>{const r=e,s=E(1).div(this.size),a=E(.5).div(this.size),o=D(a).add(r.rgb.mul(E(1).sub(s))),l=ae(i(o).rgb,r.a);return ae(rt(r,l,this.intensityNode))})()}}const xD=(n,e,t,i)=>G(new HT(G(n),G(e),t,G(i))),GT=new fn,WT=new xe,_D=new J;class jT extends pt{static get type(){return"GTAONode"}constructor(e,t,i){super(),this.depthNode=e,this.normalNode=t,this.radius=fe(.25),this.resolution=fe(new J),this.thickness=fe(1),this.distanceExponent=fe(1),this.distanceFallOff=fe(1),this.scale=fe(1),this.noiseNode=yt(MD()),this.cameraProjectionMatrix=fe(i.projectionMatrix),this.cameraProjectionMatrixInverse=fe(i.projectionMatrixInverse),this.SAMPLES=fe(16),this._aoRenderTarget=new ui,this._aoRenderTarget.texture.name="GTAONode.AO",this._material=null,this._textureNode=Mo(this,this._aoRenderTarget.texture),this.updateBeforeType=je.FRAME}getTextureNode(){return this._textureNode}setSize(e,t){this.resolution.value.set(e,t),this._aoRenderTarget.setSize(e,t)}updateBefore(e){const{renderer:t}=e,i=t.getDrawingBufferSize(_D),r=t.getRenderTarget(),s=t.getMRT();t.getClearColor(WT);const a=t.getClearAlpha();GT.material=this._material,this.setSize(i.width,i.height),t.setMRT(null),t.setClearColor(16777215,1),t.setRenderTarget(this._aoRenderTarget),GT.render(t),t.setRenderTarget(r),t.setMRT(s),t.setClearColor(WT,a)}setup(e){const t=nt(),i=c=>this.depthNode.uv(c).x,r=c=>this.noiseNode.uv(c),s=U(([c])=>{const u=this.cameraProjectionMatrix.mul(ae(c,1));let h=u.xy.div(u.w).mul(.5).add(.5).toVar();h=z(h.x,h.y.oneMinus());const d=i(h);return D(h,d)}),a=U(([c,u])=>{c=z(c.x,c.y.oneMinus()).mul(2).sub(1);const h=ae(D(c,u),1),d=ae(this.cameraProjectionMatrixInverse.mul(h));return d.xyz.div(d.w)}),o=U(()=>{const c=i(t);c.greaterThanEqual(1).discard();const u=a(t,c),h=this.normalNode.rgb.normalize(),d=this.radius,p=hs(this.noiseNode,0);let m=z(t.x,t.y.oneMinus());m=m.mul(this.resolution.div(p));const v=r(m),f=v.xyz.mul(2).sub(1),g=D(f.xy,0).normalize(),x=D(g.y.mul(-1),g.x,0),y=yi(g,x,D(0,0,1)),_=this.SAMPLES.lessThan(30).select(3,5),I=zt(this.SAMPLES,_.sub(1)).div(_),b=E(0).toVar();return gt({start:P(0),end:_,type:"int",condition:"<"},({i:w})=>{const C=E(w).div(E(_)).mul(Zs),H=ae(br(C),Ci(C),0,zt(.5,lt(.5,v.w)));H.xyz=Mr(y.mul(H.xyz));const M=Mr(u.xyz.negate()),T=Mr(oo(H.xyz,M)),k=oo(T,M),j=Mr(h.sub(T.mul(qt(h,T)))),Y=oo(j,T),re=z(qt(M,Y),qt(M,Y.negate())).toVar();gt({end:I,type:"int",name:"j",condition:"<"},({j:at})=>{const et=H.xyz.mul(d).mul(H.w).mul(Ji(Qr(E(at).add(1),E(I)),this.distanceExponent)),ie=s(u.add(et)),le=a(ie.xy,ie.z).sub(u);Le(It(le.z).lessThan(this.thickness),()=>{const Ye=qt(M,Mr(le));re.x.addAssign(ft(0,lt(Ye.sub(re.x),rt(1,E(2).div(E(at).add(2)),this.distanceFallOff))))});const Te=s(u.sub(et)),Se=a(Te.xy,Te.z).sub(u);Le(It(Se.z).lessThan(this.thickness),()=>{const Ye=qt(M,Mr(Se));re.y.addAssign(ft(0,lt(Ye.sub(re.y),rt(1,E(2).div(E(at).add(2)),this.distanceFallOff))))})});const $=en(Pt(1,re.mul(re))),he=qt(j,k),Q=qt(j,M),ye=lt(.5,Fh(re.y).sub(Fh(re.x)).add($.x.mul(re.x).sub($.y.mul(re.y)))),be=lt(.5,Pt(2,re.x.mul(re.x)).sub(re.y.mul(re.y))),Ve=he.mul(ye).add(Q.mul(be));b.addAssign(Ve)}),b.assign(li(b.div(_),0,1)),b.assign(Ji(b,this.scale)),ae(D(b),1)}),l=this._material||(this._material=new bt);return l.fragmentNode=o().context(e.getSharedContext()),l.name="GTAO",l.needsUpdate=!0,this._textureNode}dispose(){this._aoRenderTarget.dispose()}}function MD(n=5){const e=Math.floor(n)%2===0?Math.floor(n)+1:Math.floor(n),t=bD(e),i=t.length,r=new Uint8Array(i*4);for(let a=0;a<i;++a){const o=t[a],l=2*Math.PI*o/i,c=new N(Math.cos(l),Math.sin(l),0).normalize();r[a*4]=(c.x*.5+.5)*255,r[a*4+1]=(c.y*.5+.5)*255,r[a*4+2]=127,r[a*4+3]=255}const s=new Ur(r,e,e);return s.wrapS=Hn,s.wrapT=Hn,s.needsUpdate=!0,s}function bD(n){const e=Math.floor(n)%2===0?Math.floor(n)+1:Math.floor(n),t=e*e,i=Array(t).fill(0);let r=Math.floor(e/2),s=e-1;for(let a=1;a<=t;){if(r===-1&&s===e?(s=e-2,r=0):(s===e&&(s=0),r<0&&(r=e-1)),i[r*e+s]!==0){s-=2,r++;continue}else i[r*e+s]=a++;s++,r--}return i}const TD=(n,e,t)=>G(new jT(G(n),G(e),t));class XT extends pt{static get type(){return"DenoiseNode"}constructor(e,t,i,r,s){super(),this.textureNode=e,this.depthNode=t,this.normalNode=i,this.noiseNode=r,this.cameraProjectionMatrixInverse=fe(s.projectionMatrixInverse),this.lumaPhi=fe(5),this.depthPhi=fe(5),this.normalPhi=fe(5),this.radius=fe(5),this.index=fe(0),this._resolution=fe(new J),this._sampleVectors=mn(SD(16,2,1)),this.updateBeforeType=je.RENDER}updateBefore(){const e=this.textureNode.value;this._resolution.value.set(e.image.width,e.image.height)}setup(){const e=nt(),t=c=>this.textureNode.uv(c),i=c=>this.depthNode.uv(c).x,r=c=>this.normalNode.uv(c),s=c=>this.noiseNode.uv(c),a=U(([c,u])=>{c=z(c.x,c.y.oneMinus()).mul(2).sub(1);const h=ae(D(c,u),1),d=ae(this.cameraProjectionMatrixInverse.mul(h));return d.xyz.div(d.w)}),o=U(([c,u,h,d])=>{const p=t(d),m=i(d),v=r(d).rgb.normalize(),f=p.rgb,g=a(d,m),x=qt(u,v).toVar(),y=Ji(ft(x,0),this.normalPhi).toVar(),_=It(Ui(f).sub(Ui(c))).toVar(),I=ft(E(1).sub(_.div(this.lumaPhi)),0).toVar(),b=It(qt(h.sub(g),u)).toVar(),w=ft(E(1).sub(b.div(this.depthPhi)),0),C=I.mul(w).mul(y);return ae(f.mul(C),C)}),l=U(([c])=>{const u=i(c),h=r(c).rgb.normalize(),d=t(c);Le(u.greaterThanEqual(1).or(qt(h,h).equal(0)),()=>d);const p=D(d.rgb),m=a(c,u),v=hs(this.noiseNode,0);let f=z(c.x,c.y.oneMinus());f=f.mul(this._resolution.div(v));const g=s(f),x=Ci(g.element(this.index.mod(4).mul(2).mul(Zs))),y=br(g.element(this.index.mod(4).mul(2).mul(Zs))),_=z(x,y),I=Dl(_.x,_.y.negate(),_.x,_.y),b=E(1).toVar(),w=D(d.rgb).toVar();return gt({start:P(0),end:P(16),type:"int",condition:"<"},({i:C})=>{const H=this._sampleVectors.element(C).toVar(),M=I.mul(H.xy.mul(E(1).add(H.z.mul(this.radius.sub(1))))).div(this._resolution).toVar(),T=c.add(M).toVar(),k=o(p,h,m,T);w.addAssign(k.xyz),b.addAssign(k.w)}),Le(b.greaterThan(E(0)),()=>{w.divAssign(b)}),ae(w,d.a)}).setLayout({name:"denoise",type:"vec4",inputs:[{name:"uv",type:"vec2"}]});return U(()=>l(e))()}}function SD(n,e,t){const i=wD(n,e,t),r=[];for(let s=0;s<n;s++){const a=i[s];r.push(a)}return r}function wD(n,e,t){const i=[];for(let r=0;r<n;r++){const s=2*Math.PI*e*r/n,a=Math.pow(r/(n-1),t);i.push(new N(Math.cos(s),Math.sin(s),a))}return i}const ED=(n,e,t,i,r)=>G(new XT(Zi(n),G(e),G(t),G(i),r));class qT extends pt{static get type(){return"FXAANode"}constructor(e){super(),this.textureNode=e,this.updateBeforeType=je.RENDER,this._invSize=fe(new J)}updateBefore(){const e=this.textureNode.value;this._invSize.value.set(1/e.image.width,1/e.image.height)}setup(){const e=this.textureNode.bias(-100),t=e.uvNode||nt(),i=l=>e.uv(l),r=(l,c,u)=>e.uv(l.add(c.mul(u))),s=P(5),a=U(([l,c])=>{const u=ae(c).toVar(),h=ae(l).toVar(),d=ae(It(h.sub(u))).toVar();return ft(ft(ft(d.r,d.g),d.b),d.a)}),o=U(([l,c,u,h])=>{const d=i(l).toVar(),p=r(l,z(0,-1),c.xy).toVar(),m=r(l,z(1,0),c.xy).toVar(),v=r(l,z(0,1),c.xy).toVar(),f=r(l,z(-1,0),c.xy).toVar(),g=a(d,v).toVar(),x=a(d,p).toVar(),y=a(d,m).toVar(),_=a(d,f).toVar(),I=ft(g,ft(x,ft(y,_))).toVar();Le(I.lessThan(u),()=>d);const b=Pt(g.add(x),y.add(_)).toVar();b.mulAssign(h),Le(It(b).lessThan(.3),()=>{const Ve=y.greaterThan(_).select(1,-1).toVar(),at=x.greaterThan(g).select(1,-1).toVar(),et=z(Ve,at).toVar(),ie=r(l,z(et.x,et.y),c.xy),le=a(d,ie).toVar(),Te=r(l,z(et.x.negate(),et.y.negate()),c.xy),Se=a(d,Te).toVar();b.assign(Se.sub(le)),b.mulAssign(h),Le(It(b).lessThan(.3),()=>{const Ye=v.add(p).add(m).add(f);return rt(d,Ye.mul(.25),.4)})});const w=z().toVar();Le(b.lessThanEqual(0),()=>{v.assign(f),p.assign(m),w.x.assign(0),w.y.assign(c.y)}).Else(()=>{w.x.assign(c.x),w.y.assign(0)});const C=a(d,v).toVar(),H=a(d,p).toVar();Le(C.lessThanEqual(H),()=>{v.assign(p)});const M=P(0).toVar(),T=P(0).toVar(),k=E(0).toVar(),j=E(0).toVar(),Y=z(l).toVar(),re=z(l).toVar(),$=P(0).toVar(),he=P(0).toVar();gt(s,({i:Ve})=>{const at=Ve.add(1).toVar();Le(M.equal(0),()=>{k.addAssign(at),Y.assign(l.add(w.mul(k)));const et=i(Y.xy),ie=a(et,d).toVar(),le=a(et,v).toVar();Le(ie.greaterThan(le),()=>{M.assign(1)}),$.assign(Ve)}),Le(T.equal(0),()=>{j.addAssign(at),re.assign(l.sub(w.mul(j)));const et=i(re.xy),ie=a(et,d).toVar(),le=a(et,v).toVar();Le(ie.greaterThan(le),()=>{T.assign(1)}),he.assign(Ve)}),Le(M.equal(1).or(T.equal(1)),()=>{Zh()})}),Le(M.equal(0).and(T.equal(0)),()=>d);const Q=E(1).toVar(),ye=E(1).toVar();Le(M.equal(1),()=>{Q.assign(E($).div(E(s.sub(1))))}),Le(T.equal(1),()=>{ye.assign(E(he).div(E(s.sub(1))))});const be=xi(Q,ye);return be.assign(Ji(be,.5)),be.assign(E(1).sub(be)),rt(d,v,be.mul(.5))}).setLayout({name:"FxaaPixelShader",type:"vec4",inputs:[{name:"uv",type:"vec2"},{name:"fxaaQualityRcpFrame",type:"vec2"},{name:"fxaaQualityEdgeThreshold",type:"float"},{name:"fxaaQualityinvEdgeThreshold",type:"float"}]});return U(()=>{const l=E(.2),c=E(1).div(l);return o(t,this._invSize,l,c)})()}}const AD=n=>G(new qT(Zi(n))),oa=new fn,ND=new xe(0,0,0),YT=new xe,CD=new J,RD=new J(1,0),ID=new J(0,1);class $T extends pt{static get type(){return"BloomNode"}constructor(e,t=1,i=0,r=0){super(),this.inputNode=e,this.strength=fe(t),this.radius=fe(i),this.threshold=fe(r),this.smoothWidth=fe(.01),this._renderTargetsHorizontal=[],this._renderTargetsVertical=[],this._nMips=5,this._renderTargetBright=new ui(1,1,{type:wi}),this._renderTargetBright.texture.name="UnrealBloomPass.bright",this._renderTargetBright.texture.generateMipmaps=!1;for(let s=0;s<this._nMips;s++){const a=new ui(1,1,{type:wi});a.texture.name="UnrealBloomPass.h"+s,a.texture.generateMipmaps=!1,this._renderTargetsHorizontal.push(a);const o=new ui(1,1,{type:wi});o.texture.name="UnrealBloomPass.v"+s,o.texture.generateMipmaps=!1,this._renderTargetsVertical.push(o)}this._compositeMaterial=null,this._highPassFilterMaterial=null,this._separableBlurMaterials=[],this._textureNodeBright=yt(this._renderTargetBright.texture),this._textureNodeBlur0=yt(this._renderTargetsVertical[0].texture),this._textureNodeBlur1=yt(this._renderTargetsVertical[1].texture),this._textureNodeBlur2=yt(this._renderTargetsVertical[2].texture),this._textureNodeBlur3=yt(this._renderTargetsVertical[3].texture),this._textureNodeBlur4=yt(this._renderTargetsVertical[4].texture),this._textureOutput=Mo(this,this._renderTargetsHorizontal[0].texture),this.updateBeforeType=je.FRAME}getTextureNode(){return this._textureOutput}setSize(e,t){let i=Math.round(e/2),r=Math.round(t/2);this._renderTargetBright.setSize(i,r);for(let s=0;s<this._nMips;s++)this._renderTargetsHorizontal[s].setSize(i,r),this._renderTargetsVertical[s].setSize(i,r),this._separableBlurMaterials[s].invSize.value.set(1/i,1/r),i=Math.round(i/2),r=Math.round(r/2)}updateBefore(e){const{renderer:t}=e,i=t.getDrawingBufferSize(CD);this.setSize(i.width,i.height);const r=t.getRenderTarget(),s=t.getMRT();t.getClearColor(YT);const a=t.getClearAlpha();this.setSize(i.width,i.height),t.setMRT(null),t.setClearColor(ND,0),t.setRenderTarget(this._renderTargetBright),oa.material=this._highPassFilterMaterial,oa.render(t);let o=this._renderTargetBright;for(let l=0;l<this._nMips;l++)oa.material=this._separableBlurMaterials[l],this._separableBlurMaterials[l].colorTexture.value=o.texture,this._separableBlurMaterials[l].direction.value=RD,t.setRenderTarget(this._renderTargetsHorizontal[l]),t.clear(),oa.render(t),this._separableBlurMaterials[l].colorTexture.value=this._renderTargetsHorizontal[l].texture,this._separableBlurMaterials[l].direction.value=ID,t.setRenderTarget(this._renderTargetsVertical[l]),t.clear(),oa.render(t),o=this._renderTargetsVertical[l];t.setRenderTarget(this._renderTargetsHorizontal[0]),t.clear(),oa.material=this._compositeMaterial,oa.render(t),t.setRenderTarget(r),t.setMRT(s),t.setClearColor(YT,a)}setup(e){const t=U(()=>{const l=this.inputNode,c=Ui(l.rgb),u=Ki(this.threshold,this.threshold.add(this.smoothWidth),c);return rt(ae(0),l,u)});this._highPassFilterMaterial=this._highPassFilterMaterial||new bt,this._highPassFilterMaterial.fragmentNode=t().context(e.getSharedContext()),this._highPassFilterMaterial.name="Bloom_highPass",this._highPassFilterMaterial.needsUpdate=!0;const i=[3,5,7,9,11];for(let l=0;l<this._nMips;l++)this._separableBlurMaterials.push(this._getSeperableBlurMaterial(e,i[l]));const r=mn([1,.8,.6,.4,.2]),s=mn([new N(1,1,1),new N(1,1,1),new N(1,1,1),new N(1,1,1),new N(1,1,1)]),a=U(([l,c])=>{const u=E(1.2).sub(l);return rt(l,u,c)}).setLayout({name:"lerpBloomFactor",type:"float",inputs:[{name:"factor",type:"float"},{name:"radius",type:"float"}]}),o=U(()=>{const l=a(r.element(0),this.radius).mul(ae(s.element(0),1)).mul(this._textureNodeBlur0),c=a(r.element(1),this.radius).mul(ae(s.element(1),1)).mul(this._textureNodeBlur1),u=a(r.element(2),this.radius).mul(ae(s.element(2),1)).mul(this._textureNodeBlur2),h=a(r.element(3),this.radius).mul(ae(s.element(3),1)).mul(this._textureNodeBlur3),d=a(r.element(4),this.radius).mul(ae(s.element(4),1)).mul(this._textureNodeBlur4);return l.add(c).add(u).add(h).add(d).mul(this.strength)});return this._compositeMaterial=this._compositeMaterial||new bt,this._compositeMaterial.fragmentNode=o().context(e.getSharedContext()),this._compositeMaterial.name="Bloom_comp",this._compositeMaterial.needsUpdate=!0,this._textureOutput}dispose(){for(let e=0;e<this._renderTargetsHorizontal.length;e++)this._renderTargetsHorizontal[e].dispose();for(let e=0;e<this._renderTargetsVertical.length;e++)this._renderTargetsVertical[e].dispose();this._renderTargetBright.dispose()}_getSeperableBlurMaterial(e,t){const i=[];for(let d=0;d<t;d++)i.push(.39894*Math.exp(-.5*d*d/(t*t))/t);const r=yt(),s=mn(i),a=fe(new J),o=fe(new J(.5,.5)),l=nt(),c=d=>r.uv(d),u=U(()=>{const d=s.element(0).toVar(),p=c(l).rgb.mul(d).toVar();return gt({start:P(1),end:P(t),type:"int",condition:"<"},({i:m})=>{const v=E(m),f=s.element(m),g=o.mul(a).mul(v),x=c(l.add(g)).rgb,y=c(l.sub(g)).rgb;p.addAssign(zt(x,y).mul(f)),d.addAssign(E(2).mul(f))}),ae(p.div(d),1)}),h=new bt;return h.fragmentNode=u().context(e.getSharedContext()),h.name="Bloom_seperable",h.needsUpdate=!0,h.colorTexture=r,h.direction=o,h.invSize=a,h}}const LD=(n,e,t,i)=>G(new $T(G(n),e,t,i));class JT extends pt{static get type(){return"TransitionNode"}constructor(e,t,i,r,s,a){super(),this.textureNodeA=e,this.textureNodeB=t,this.mixTextureNode=i,this.mixRatioNode=r,this.thresholdNode=s,this.useTextureNode=a}setup(){const{textureNodeA:e,textureNodeB:t,mixTextureNode:i,mixRatioNode:r,thresholdNode:s,useTextureNode:a}=this,o=l=>{const c=l.uvNode||nt();return l.uv(c)};return U(()=>{const l=o(e),c=o(t),u=ae().toVar();return Le(a.equal(P(1)),()=>{const h=o(i),d=r.mul(s.mul(2).add(1)).sub(s),p=li(Pt(h.r,d).mul(E(1).div(s)),0,1);u.assign(rt(l,c,p))}).Else(()=>{u.assign(rt(c,l,r))}),u})()}}const PD=(n,e,t,i=0,r=.1,s=0)=>G(new JT(Zi(n),Zi(e),Zi(t),G(i),G(r),G(s)));class DD extends pt{static get type(){return"PixelationNode"}constructor(e,t,i,r,s,a){super(),this.textureNode=e,this.depthNode=t,this.normalNode=i,this.pixelSize=r,this.normalEdgeStrength=s,this.depthEdgeStrength=a,this._resolution=fe(new st),this.updateBeforeType=je.RENDER}updateBefore(){const e=this.textureNode.value,t=e.image.width,i=e.image.height;this._resolution.value.set(t,i,1/t,1/i)}setup(){const{textureNode:e,depthNode:t,normalNode:i}=this,r=e.uvNode||nt(),s=t.uvNode||nt(),a=i.uvNode||nt(),o=()=>e.uv(r),l=(p,m)=>t.uv(s.add(z(p,m).mul(this._resolution.zw))).r,c=(p,m)=>i.uv(a.add(z(p,m).mul(this._resolution.zw))).rgb.normalize(),u=p=>{const m=ar("float","diff");return m.addAssign(li(l(1,0).sub(p))),m.addAssign(li(l(-1,0).sub(p))),m.addAssign(li(l(0,1).sub(p))),m.addAssign(li(l(0,-1).sub(p))),ls(Ki(.01,.02,m).mul(2)).div(2)},h=(p,m,v,f)=>{const g=l(p,m).sub(v),x=c(p,m),y=D(1,1,1),_=qt(f.sub(x),y),I=li(Ki(-.01,.01,_),0,1),b=li(Hl(g.mul(.25).add(.0025)),0,1);return E(1).sub(qt(f,x)).mul(b).mul(I)},d=(p,m)=>{const v=ar("float","indicator");return v.addAssign(h(0,-1,p,m)),v.addAssign(h(0,1,p,m)),v.addAssign(h(-1,0,p,m)),v.addAssign(h(1,0,p,m)),Gl(.1,v)};return U(()=>{const p=o(),m=ar("float","depth"),v=ar("vec3","normal");Le(this.depthEdgeStrength.greaterThan(0).or(this.normalEdgeStrength.greaterThan(0)),()=>{m.assign(l(0,0)),v.assign(c(0,0))});const f=ar("float","dei");Le(this.depthEdgeStrength.greaterThan(0),()=>{f.assign(u(m))});const g=ar("float","nei");Le(this.normalEdgeStrength.greaterThan(0),()=>{g.assign(d(m,v))});const x=f.greaterThan(0).select(E(1).sub(f.mul(this.depthEdgeStrength)),g.mul(this.normalEdgeStrength).add(1));return p.mul(x)})()}}const UD=(n,e,t,i=6,r=.3,s=.4)=>G(new DD(Zi(n),Zi(e),Zi(t),G(i),G(r),G(s)));class KT extends Ti{static get type(){return"PixelationPassNode"}constructor(e,t,i=6,r=.3,s=.4){super("color",e,t,{minFilter:$t,magFilter:$t}),this.pixelSize=i,this.normalEdgeStrength=r,this.depthEdgeStrength=s,this.isPixelationPassNode=!0,this._mrt=pd({output:xf,normal:hr})}setSize(e,t){const i=this.pixelSize.value?this.pixelSize.value:this.pixelSize,r=Math.floor(e/i),s=Math.floor(t/i);super.setSize(r,s)}setup(){const e=super.getTextureNode("output"),t=super.getTextureNode("depth"),i=super.getTextureNode("normal");return UD(e,t,i,this.pixelSize,this.normalEdgeStrength,this.depthEdgeStrength)}}const OD=(n,e,t,i,r)=>G(new KT(n,e,t,i,r)),FD=new J;class ZT extends Ti{static get type(){return"SSAAPassNode"}constructor(e,t){super(Ti.COLOR,e,t),this.isSSAAPassNode=!0,this.sampleLevel=4,this.unbiased=!0,this.clearColor=new xe(0),this.clearAlpha=0,this._currentClearColor=new xe,this.sampleWeight=fe(1),this.sampleRenderTarget=null,this._quadMesh=new fn}updateBefore(e){const{renderer:t}=e,{scene:i,camera:r}=this;this._pixelRatio=t.getPixelRatio();const s=t.getSize(FD);this.setSize(s.width,s.height),this.sampleRenderTarget.setSize(this.renderTarget.width,this.renderTarget.height),t.getClearColor(this._currentClearColor);const a=t.getClearAlpha(),o=t.getRenderTarget(),l=t.getMRT(),c=t.autoClear;this._cameraNear.value=r.near,this._cameraFar.value=r.far,t.setMRT(this.getMRT()),t.autoClear=!1;const u=VD[Math.max(0,Math.min(this.sampleLevel,5))],h=1/u.length,d=1/32,p={fullWidth:this.renderTarget.width,fullHeight:this.renderTarget.height,offsetX:0,offsetY:0,width:this.renderTarget.width,height:this.renderTarget.height},m=Object.assign({},r.view);m.enabled&&Object.assign(p,m);for(let v=0;v<u.length;v++){const f=u[v];if(r.setViewOffset&&r.setViewOffset(p.fullWidth,p.fullHeight,p.offsetX+f[0]*.0625,p.offsetY+f[1]*.0625,p.width,p.height),this.sampleWeight.value=h,this.unbiased){const g=-.5+(v+.5)/u.length;this.sampleWeight.value+=d*g}t.setClearColor(this.clearColor,this.clearAlpha),t.setRenderTarget(this.sampleRenderTarget),t.clear(),t.render(i,r),t.setRenderTarget(this.renderTarget),v===0&&(t.setClearColor(0,0),t.clear()),this._quadMesh.render(t)}t.copyTextureToTexture(this.sampleRenderTarget.depthTexture,this.renderTarget.depthTexture),r.setViewOffset&&m.enabled?r.setViewOffset(m.fullWidth,m.fullHeight,m.offsetX,m.offsetY,m.width,m.height):r.clearViewOffset&&r.clearViewOffset(),t.setRenderTarget(o),t.setMRT(l),t.autoClear=c,t.setClearColor(this._currentClearColor,a)}setup(e){this.sampleRenderTarget===null&&(this.sampleRenderTarget=this.renderTarget.clone());let t;const i=this.getMRT();if(i!==null){const r={};for(const s in i.outputNodes){const a=zg(this.sampleRenderTarget.textures,s);a>=0&&(r[s]=yt(this.sampleRenderTarget.textures[a]).mul(this.sampleWeight))}t=pd(r)}else t=yt(this.sampleRenderTarget.texture).mul(this.sampleWeight);return this._quadMesh.material=new bt,this._quadMesh.material.fragmentNode=t,this._quadMesh.material.transparent=!0,this._quadMesh.material.depthTest=!1,this._quadMesh.material.depthWrite=!1,this._quadMesh.material.premultipliedAlpha=!0,this._quadMesh.material.blending=Eo,this._quadMesh.material.normals=!1,this._quadMesh.material.name="SSAA",super.setup(e)}dispose(){super.dispose(),this.sampleRenderTarget!==null&&this.sampleRenderTarget.dispose()}}const VD=[[[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]]],BD=(n,e)=>G(new ZT(n,e)),zD=new J;class QT extends Ti{static get type(){return"StereoPassNode"}constructor(e,t){super(Ti.COLOR,e,t),this.isStereoPassNode=!0,this.stereo=new zm,this.stereo.aspect=.5}updateBefore(e){const{renderer:t}=e,{scene:i,camera:r,stereo:s,renderTarget:a}=this;this._pixelRatio=t.getPixelRatio(),s.cameraL.coordinateSystem=t.coordinateSystem,s.cameraR.coordinateSystem=t.coordinateSystem,s.update(r);const o=t.getSize(zD);this.setSize(o.width,o.height);const l=t.autoClear;t.autoClear=!1;const c=t.getRenderTarget(),u=t.getMRT();this._cameraNear.value=r.near,this._cameraFar.value=r.far;for(const h in this._previousTextures)this.toggleTexture(h);t.setRenderTarget(a),t.setMRT(this._mrt),t.clear(),a.scissorTest=!0,a.scissor.set(0,0,a.width/2,a.height),a.viewport.set(0,0,a.width/2,a.height),t.render(i,s.cameraL),a.scissor.set(a.width/2,0,a.width/2,a.height),a.viewport.set(a.width/2,0,a.width/2,a.height),t.render(i,s.cameraR),a.scissorTest=!1,t.setRenderTarget(c),t.setMRT(u),t.autoClear=l}}const kD=(n,e)=>G(new QT(n,e)),HD=new J,eS=new fn;class tS extends Ti{static get type(){return"StereoCompositePassNode"}constructor(e,t){super(Ti.COLOR,e,t),this.isStereoCompositePassNode=!0,this.stereo=new zm;const i={minFilter:Lt,magFilter:$t,type:wi};this._renderTargetL=new ui(1,1,i),this._renderTargetR=new ui(1,1,i),this._mapLeft=yt(this._renderTargetL.texture),this._mapRight=yt(this._renderTargetR.texture),this._material=null}updateStereoCamera(e){this.stereo.cameraL.coordinateSystem=e,this.stereo.cameraR.coordinateSystem=e,this.stereo.update(this.camera)}setSize(e,t){super.setSize(e,t),this._renderTargetL.setSize(this.renderTarget.width,this.renderTarget.height),this._renderTargetR.setSize(this.renderTarget.width,this.renderTarget.height)}updateBefore(e){const{renderer:t}=e,{scene:i,stereo:r,renderTarget:s}=this;this._pixelRatio=t.getPixelRatio(),this.updateStereoCamera(t.coordinateSystem);const a=t.getSize(HD);this.setSize(a.width,a.height);const o=t.getRenderTarget();t.setRenderTarget(this._renderTargetL),t.render(i,r.cameraL),t.setRenderTarget(this._renderTargetR),t.render(i,r.cameraR),t.setRenderTarget(s),eS.material=this._material,eS.render(t),t.setRenderTarget(o)}dispose(){super.dispose(),this._renderTargetL.dispose(),this._renderTargetR.dispose(),this._material!==null&&this._material.dispose()}}class iS extends tS{static get type(){return"AnaglyphPassNode"}constructor(e,t){super(e,t),this.isAnaglyphPassNode=!0,this._colorMatrixLeft=fe(new Ke().fromArray([.4561,-.0400822,-.0152161,.500484,-.0378246,-.0205971,.176381,-.0157589,-.00546856])),this._colorMatrixRight=fe(new Ke().fromArray([-.0434706,.378476,-.0721527,-.0879388,.73364,-.112961,-.00155529,-.0184503,1.2264]))}setup(e){const t=nt(),i=U(()=>{const s=this._mapLeft.uv(t),a=this._mapRight.uv(t),o=li(this._colorMatrixLeft.mul(s.rgb).add(this._colorMatrixRight.mul(a.rgb)));return ae(o.rgb,ft(s.a,a.a))}),r=this._material||(this._material=new bt);return r.fragmentNode=i().context(e.getSharedContext()),r.name="Anaglyph",r.needsUpdate=!0,super.setup(e)}}const GD=(n,e)=>G(new iS(n,e));class rS extends tS{static get type(){return"ParallaxBarrierPassNode"}constructor(e,t){super(e,t),this.isParallaxBarrierPassNode=!0}setup(e){const t=nt(),i=U(()=>{const s=ae().toVar();return Le(Vh(fo.y,2).greaterThan(1),()=>{s.assign(this._mapLeft.uv(t))}).Else(()=>{s.assign(this._mapRight.uv(t))}),s}),r=this._material||(this._material=new bt);return r.fragmentNode=i().context(e.getSharedContext()),r.needsUpdate=!0,super.setup(e)}}const WD=(n,e)=>G(new rS(n,e));class nS extends Ti{static get type(){return"ToonOutlinePassNode"}constructor(e,t,i,r,s){super(Ti.COLOR,e,t),this.colorNode=i,this.thicknessNode=r,this.alphaNode=s,this._materialCache=new WeakMap}updateBefore(e){const{renderer:t}=e,i=t.getRenderObjectFunction();t.setRenderObjectFunction((r,s,a,o,l,c,u)=>{if((l.isMeshToonMaterial||l.isMeshToonNodeMaterial)&&l.wireframe===!1){const h=this._getOutlineMaterial(l);t.renderObject(r,s,a,o,h,c,u)}t.renderObject(r,s,a,o,l,c,u)}),super.updateBefore(e),t.setRenderObjectFunction(i)}_createMaterial(){const e=new bt;e.isMeshToonOutlineMaterial=!0,e.name="Toon_Outline",e.side=si;const t=ur.negate(),i=lr.mul(pn),r=E(1),s=i.mul(ae(Zt,1)),a=i.mul(ae(Zt.add(t),1)),o=Mr(s.sub(a));return e.vertexNode=s.add(o.mul(this.thicknessNode).mul(s.w).mul(r)),e.colorNode=ae(this.colorNode,this.alphaNode),e}_getOutlineMaterial(e){let t=this._materialCache.get(e);return t===void 0&&(t=this._createMaterial(),this._materialCache.set(e,t)),t}}const jD=(n,e,t=new xe(0,0,0),i=.003,r=1)=>G(new nS(n,e,G(t),G(i),G(r)));class sS extends qe{static get type(){return"ScriptableValueNode"}constructor(e=null){super(),this._value=e,this._cache=null,this.inputType=null,this.outpuType=null,this.events=new vr,this.isScriptableValueNode=!0}get isScriptableOutputNode(){return this.outputType!==null}set value(e){this._value!==e&&(this._cache&&this.inputType==="URL"&&this.value.value instanceof ArrayBuffer&&(URL.revokeObjectURL(this._cache),this._cache=null),this._value=e,this.events.dispatchEvent({type:"change"}),this.refresh())}get value(){return this._value}refresh(){this.events.dispatchEvent({type:"refresh"})}getValue(){const e=this.value;if(e&&this._cache===null&&this.inputType==="URL"&&e.value instanceof ArrayBuffer)this._cache=URL.createObjectURL(new Blob([e.value]));else if(e&&e.value!==null&&e.value!==void 0&&((this.inputType==="URL"||this.inputType==="String")&&typeof e.value=="string"||this.inputType==="Number"&&typeof e.value=="number"||this.inputType==="Vector2"&&e.value.isVector2||this.inputType==="Vector3"&&e.value.isVector3||this.inputType==="Vector4"&&e.value.isVector4||this.inputType==="Color"&&e.value.isColor||this.inputType==="Matrix3"&&e.value.isMatrix3||this.inputType==="Matrix4"&&e.value.isMatrix4))return e.value;return this._cache||e}getNodeType(e){return this.value&&this.value.isNode?this.value.getNodeType(e):"float"}setup(){return this.value&&this.value.isNode?this.value:E()}serialize(e){super.serialize(e),this.value!==null?this.inputType==="ArrayBuffer"?e.value=Zm(this.value):e.value=this.value?this.value.toJSON(e.meta).uuid:null:e.value=null,e.inputType=this.inputType,e.outputType=this.outputType}deserialize(e){super.deserialize(e);let t=null;e.value!==null&&(e.inputType==="ArrayBuffer"?t=Qm(e.value):e.inputType==="Texture"?t=e.meta.textures[e.value]:t=e.meta.nodes[e.value]||null),this.value=t,this.inputType=e.inputType,this.outputType=e.outputType}}const vd=K(sS);class aS extends Map{get(e,t=null,...i){if(this.has(e))return super.get(e);if(t!==null){const r=t(...i);return this.set(e,r),r}}}class XD{constructor(e){this.scriptableNode=e}get parameters(){return this.scriptableNode.parameters}get layout(){return this.scriptableNode.getLayout()}getInputLayout(e){return this.scriptableNode.getInputLayout(e)}get(e){const t=this.parameters[e];return t?t.getValue():null}}const yd=new aS;class oS extends qe{static get type(){return"ScriptableNode"}constructor(e=null,t={}){super(),this.codeNode=e,this.parameters=t,this._local=new aS,this._output=vd(),this._outputs={},this._source=this.source,this._method=null,this._object=null,this._value=null,this._needsOutputUpdate=!0,this.onRefresh=this.onRefresh.bind(this),this.isScriptableNode=!0}get source(){return this.codeNode?this.codeNode.code:""}setLocal(e,t){return this._local.set(e,t)}getLocal(e){return this._local.get(e)}onRefresh(){this._refresh()}getInputLayout(e){for(const t of this.getLayout())if(t.inputType&&(t.id===e||t.name===e))return t}getOutputLayout(e){for(const t of this.getLayout())if(t.outputType&&(t.id===e||t.name===e))return t}setOutput(e,t){const i=this._outputs;return i[e]===void 0?i[e]=vd(t):i[e].value=t,this}getOutput(e){return this._outputs[e]}getParameter(e){return this.parameters[e]}setParameter(e,t){const i=this.parameters;return t&&t.isScriptableNode?(this.deleteParameter(e),i[e]=t,i[e].getDefaultOutput().events.addEventListener("refresh",this.onRefresh)):t&&t.isScriptableValueNode?(this.deleteParameter(e),i[e]=t,i[e].events.addEventListener("refresh",this.onRefresh)):i[e]===void 0?(i[e]=vd(t),i[e].events.addEventListener("refresh",this.onRefresh)):i[e].value=t,this}getValue(){return this.getDefaultOutput().getValue()}deleteParameter(e){let t=this.parameters[e];return t&&(t.isScriptableNode&&(t=t.getDefaultOutput()),t.events.removeEventListener("refresh",this.onRefresh)),this}clearParameters(){for(const e of Object.keys(this.parameters))this.deleteParameter(e);return this.needsUpdate=!0,this}call(e,...t){const i=this.getObject()[e];if(typeof i=="function")return i(...t)}async callAsync(e,...t){const i=this.getObject()[e];if(typeof i=="function")return i.constructor.name==="AsyncFunction"?await i(...t):i(...t)}getNodeType(e){return this.getDefaultOutputNode().getNodeType(e)}refresh(e=null){e!==null?this.getOutput(e).refresh():this._refresh()}getObject(){if(this.needsUpdate&&this.dispose(),this._object!==null)return this._object;const e=()=>this.refresh(),t=(c,u)=>this.setOutput(c,u),i=new XD(this),r=yd.get("THREE"),s=yd.get("TSL"),a=this.getMethod(this.codeNode),o=[i,this._local,yd,e,t,r,s];this._object=a(...o);const l=this._object.layout;if(l&&(l.cache===!1&&this._local.clear(),this._output.outputType=l.outputType||null,Array.isArray(l.elements)))for(const c of l.elements){const u=c.id||c.name;c.inputType&&(this.getParameter(u)===void 0&&this.setParameter(u,null),this.getParameter(u).inputType=c.inputType),c.outputType&&(this.getOutput(u)===void 0&&this.setOutput(u,null),this.getOutput(u).outputType=c.outputType)}return this._object}deserialize(e){super.deserialize(e);for(const t in this.parameters){let i=this.parameters[t];i.isScriptableNode&&(i=i.getDefaultOutput()),i.events.addEventListener("refresh",this.onRefresh)}}getLayout(){return this.getObject().layout}getDefaultOutputNode(){const e=this.getDefaultOutput().value;return e&&e.isNode?e:E()}getDefaultOutput(){return this._exec()._output}getMethod(){if(this.needsUpdate&&this.dispose(),this._method!==null)return this._method;const e=["parameters","local","global","refresh","setOutput","THREE","TSL"],t=["layout","init","main","dispose"].join(", "),i="var "+t+`; var output = {};
|
|
3872
3872
|
`,r=`
|
|
3873
|
-
return { ...output, `+t+" };",s=i+this.codeNode.code+r;return this._method=new Function(...e,s),this._method}dispose(){this._method!==null&&(this._object&&typeof this._object.dispose=="function"&&this._object.dispose(),this._method=null,this._object=null,this._source=null,this._value=null,this._needsOutputUpdate=!0,this._output.value=null,this._outputs={})}setup(){return this.getDefaultOutputNode()}getCacheKey(e){const t=[Wx(this.source),this.getDefaultOutputNode().getCacheKey(e)];for(const i in this.parameters)t.push(this.parameters[i].getCacheKey(e));return jx(t)}set needsUpdate(e){e===!0&&this.dispose()}get needsUpdate(){return this.source!==this._source}_exec(){return this.codeNode===null?this:(this._needsOutputUpdate===!0&&(this._value=this.call("main"),this._needsOutputUpdate=!1),this._output.value=this._value,this)}_refresh(){this.needsUpdate=!0,this._exec(),this._output.refresh()}}const qD=K(lS);class _d extends qe{static get type(){return"FogNode"}constructor(e,t){super("float"),this.isFogNode=!0,this.colorNode=e,this.factorNode=t}getViewZNode(e){let t;const i=e.context.getViewZ;return i!==void 0&&(t=i(this)),(t||Pi.z).negate()}setup(){return this.factorNode}}const YD=K(_d);class cS extends _d{static get type(){return"FogRangeNode"}constructor(e,t,i){super(e),this.isFogRangeNode=!0,this.nearNode=t,this.farNode=i}setup(e){const t=this.getViewZNode(e);return Ki(this.nearNode,this.farNode,t)}}const $D=K(cS);class uS extends _d{static get type(){return"FogExp2Node"}constructor(e,t){super(e),this.isFogExp2Node=!0,this.densityNode=t}setup(e){const t=this.getViewZNode(e),i=this.densityNode;return i.mul(i,t,t).negate().exp().oneMinus()}}const JD=K(uS);let ca=null,ua=null;class hS extends qe{static get type(){return"RangeNode"}constructor(e=E(),t=E()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){const t=e.getTypeLength(Ln(this.minNode.value)),i=e.getTypeLength(Ln(this.maxNode.value));return t>i?t:i}getNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):"float"}setup(e){const t=e.object;let i=null;if(t.count>1){const r=this.minNode.value,s=this.maxNode.value,a=e.getTypeLength(Ln(r)),o=e.getTypeLength(Ln(s));ca=ca||new st,ua=ua||new st,ca.setScalar(0),ua.setScalar(0),a===1?ca.setScalar(r):r.isColor?ca.set(r.r,r.g,r.b):ca.set(r.x,r.y,r.z||0,r.w||0),o===1?ua.setScalar(s):s.isColor?ua.set(s.r,s.g,s.b):ua.set(s.x,s.y,s.z||0,s.w||0);const l=4,c=l*t.count,u=new Float32Array(c);for(let d=0;d<c;d++){const p=d%l,m=ca.getComponent(p),v=ua.getComponent(p);u[d]=au.lerp(m,v,Math.random())}const h=this.getNodeType(e);if(t.count<=4096)i=Jl(u,"vec4",t.count).element(ic).convert(h);else{const d=new Nn(u,4);e.geometry.setAttribute("__range"+this.id,d),i=kh(d).convert(h)}}else i=E(0);return i}}const KD=K(hS),ZD=U(({depthTexture:n,shadowCoord:e})=>yt(n,e.xy).compare(e.z)),QD=U(({depthTexture:n,shadowCoord:e,shadow:t})=>{const i=(v,f)=>yt(n,v).compare(f),r=fi("mapSize","vec2",t).setGroup(xt),s=fi("radius","float",t).setGroup(xt),a=z(1).div(r),o=a.x.negate().mul(s),l=a.y.negate().mul(s),c=a.x.mul(s),u=a.y.mul(s),h=o.div(2),d=l.div(2),p=c.div(2),m=u.div(2);return zt(i(e.xy.add(z(o,l)),e.z),i(e.xy.add(z(0,l)),e.z),i(e.xy.add(z(c,l)),e.z),i(e.xy.add(z(h,d)),e.z),i(e.xy.add(z(0,d)),e.z),i(e.xy.add(z(p,d)),e.z),i(e.xy.add(z(o,0)),e.z),i(e.xy.add(z(h,0)),e.z),i(e.xy,e.z),i(e.xy.add(z(p,0)),e.z),i(e.xy.add(z(c,0)),e.z),i(e.xy.add(z(h,m)),e.z),i(e.xy.add(z(0,m)),e.z),i(e.xy.add(z(p,m)),e.z),i(e.xy.add(z(o,u)),e.z),i(e.xy.add(z(0,u)),e.z),i(e.xy.add(z(c,u)),e.z)).mul(1/17)}),eU=U(({depthTexture:n,shadowCoord:e,shadow:t})=>{const i=(u,h)=>yt(n,u).compare(h),r=fi("mapSize","vec2",t).setGroup(xt),s=z(1).div(r),a=s.x,o=s.y,l=e.xy,c=us(l.mul(r).add(.5));return l.subAssign(c.mul(s)),zt(i(l,e.z),i(l.add(z(a,0)),e.z),i(l.add(z(0,o)),e.z),i(l.add(s),e.z),rt(i(l.add(z(a.negate(),0)),e.z),i(l.add(z(a.mul(2),0)),e.z),c.x),rt(i(l.add(z(a.negate(),o)),e.z),i(l.add(z(a.mul(2),o)),e.z),c.x),rt(i(l.add(z(0,o.negate())),e.z),i(l.add(z(0,o.mul(2))),e.z),c.y),rt(i(l.add(z(a,o.negate())),e.z),i(l.add(z(a,o.mul(2))),e.z),c.y),rt(rt(i(l.add(z(a.negate(),o.negate())),e.z),i(l.add(z(a.mul(2),o.negate())),e.z),c.x),rt(i(l.add(z(a.negate(),o.mul(2))),e.z),i(l.add(z(a.mul(2),o.mul(2))),e.z),c.x),c.y)).mul(1/9)}),tU=U(({depthTexture:n,shadowCoord:e})=>{const t=E(1).toVar(),i=yt(n).uv(e.xy).rg,r=Wl(e.z,i.x);return Le(r.notEqual(E(1)),()=>{const s=e.z.sub(i.x),a=ft(0,i.y.mul(i.y));let o=a.div(a.add(s.mul(s)));o=li(Pt(o,.3).div(.95-.3)),t.assign(li(ft(r,o)))}),t}),iU=U(({samples:n,radius:e,size:t,shadowPass:i})=>{const r=E(0).toVar(),s=E(0).toVar(),a=n.lessThanEqual(E(1)).select(E(0),E(2).div(n.sub(1))),o=n.lessThanEqual(E(1)).select(E(0),E(-1));gt({start:P(0),end:P(n),type:"int",condition:"<"},({i:c})=>{const u=o.add(E(c).mul(a)),h=i.uv(zt(go.xy,z(0,u).mul(e)).div(t)).x;r.addAssign(h),s.addAssign(h.mul(h))}),r.divAssign(n),s.divAssign(n);const l=en(s.sub(r.mul(r)));return z(r,l)}),rU=U(({samples:n,radius:e,size:t,shadowPass:i})=>{const r=E(0).toVar(),s=E(0).toVar(),a=n.lessThanEqual(E(1)).select(E(0),E(2).div(n.sub(1))),o=n.lessThanEqual(E(1)).select(E(0),E(-1));gt({start:P(0),end:P(n),type:"int",condition:"<"},({i:c})=>{const u=o.add(E(c).mul(a)),h=i.uv(zt(go.xy,z(u,0).mul(e)).div(t));r.addAssign(h.x),s.addAssign(zt(h.y.mul(h.y),h.x.mul(h.x)))}),r.divAssign(n),s.divAssign(n);const l=en(s.sub(r.mul(r)));return z(r,l)}),nU=[ZD,QD,eU,tU];let To=null;const Md=new fn;class ms extends ia{static get type(){return"AnalyticLightNode"}constructor(e=null){super(),this.updateType=je.FRAME,this.light=e,this.color=new xe,this.colorNode=fe(this.color).setGroup(xt),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 Jm(super.getCacheKey(),this.light.id,this.light.castShadow?1:0)}getHash(){return this.light.uuid}setupShadow(e){const{object:t,renderer:i}=e;if(i.shadowMap.enabled===!1)return;let r=this.shadowColorNode;if(r===null){To===null&&(To=new bt,To.fragmentNode=ae(0,0,0,1),To.isShadowNodeMaterial=!0,To.name="ShadowMaterial");const s=i.shadowMap.type,a=this.light.shadow,o=new Us;o.compareFunction=pp;const l=e.createRenderTarget(a.mapSize.width,a.mapSize.height);if(l.depthTexture=o,a.camera.updateProjectionMatrix(),s===rr){o.compareFunction=null,this.vsmShadowMapVertical=e.createRenderTarget(a.mapSize.width,a.mapSize.height,{format:ya,type:wi}),this.vsmShadowMapHorizontal=e.createRenderTarget(a.mapSize.width,a.mapSize.height,{format:ya,type:wi});const y=yt(o),_=yt(this.vsmShadowMapVertical.texture),I=fi("blurSamples","float",a).setGroup(xt),b=fi("radius","float",a).setGroup(xt),w=fi("mapSize","vec2",a).setGroup(xt);let C=this.vsmMaterialVertical||(this.vsmMaterialVertical=new bt);C.fragmentNode=iU({samples:I,radius:b,size:w,shadowPass:y}).context(e.getSharedContext()),C.name="VSMVertical",C=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new bt),C.fragmentNode=rU({samples:I,radius:b,size:w,shadowPass:_}).context(e.getSharedContext()),C.name="VSMHorizontal"}const c=fi("intensity","float",a).setGroup(xt),u=fi("bias","float",a).setGroup(xt),h=fi("normalBias","float",a).setGroup(xt),d=t.material.shadowPositionNode||Gh;let p=fe(a.matrix).setGroup(xt).mul(d.add(jh.mul(h)));p=p.xyz.div(p.w);let m=p.z.add(u);i.coordinateSystem===Ts&&(m=m.mul(2).sub(1)),p=D(p.x,p.y.oneMinus(),m);const v=p.x.greaterThanEqual(0).and(p.x.lessThanEqual(1)).and(p.y.greaterThanEqual(0)).and(p.y.lessThanEqual(1)).and(p.z.lessThanEqual(1)),f=a.filterNode||nU[i.shadowMap.type]||null;if(f===null)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const g=yt(l.texture,p),x=v.select(f({depthTexture:s===rr?this.vsmShadowMapHorizontal.texture:o,shadowCoord:p,shadow:a}),E(1));this.shadowMap=l,this.light.shadow.map=l,this.shadowNode=x,this.shadowColorNode=r=this.colorNode.mul(rt(1,x.rgb.mix(g,1),c.mul(g.a))),this.baseColorNode=this.colorNode}this.colorNode=r,this.updateBeforeType=je.RENDER}setup(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):this.shadowNode!==null&&this.disposeShadow()}updateShadow(e){const{shadowMap:t,light:i}=this,{renderer:r,scene:s,camera:a}=e,o=r.shadowMap.type,l=t.depthTexture.version;this._depthVersionCached=l;const c=s.overrideMaterial;s.overrideMaterial=To,t.setSize(i.shadow.mapSize.width,i.shadow.mapSize.height),i.shadow.updateMatrices(i),i.shadow.camera.layers.mask=a.layers.mask;const u=r.getRenderTarget(),h=r.getRenderObjectFunction();r.setRenderObjectFunction((d,...p)=>{(d.castShadow===!0||d.receiveShadow&&o===rr)&&r.renderObject(d,...p)}),r.setRenderTarget(t),r.render(s,i.shadow.camera),r.setRenderObjectFunction(h),i.isPointLight!==!0&&o===rr&&this.vsmPass(e,i),r.setRenderTarget(u),s.overrideMaterial=c}vsmPass(e,t){const{renderer:i}=e;this.vsmShadowMapVertical.setSize(t.shadow.mapSize.width,t.shadow.mapSize.height),this.vsmShadowMapHorizontal.setSize(t.shadow.mapSize.width,t.shadow.mapSize.height),i.setRenderTarget(this.vsmShadowMapVertical),Md.material=this.vsmMaterialVertical,Md.render(i),i.setRenderTarget(this.vsmShadowMapHorizontal),Md.material=this.vsmMaterialHorizontal,Md.render(i)}disposeShadow(){this.shadowMap.dispose(),this.shadowMap=null,this.vsmShadowMapVertical!==null&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),this.vsmShadowMapHorizontal!==null&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null),this.shadowNode=null,this.shadowColorNode=null,this.baseColorNode=null,this.updateBeforeType=je.NONE}updateBefore(e){const t=this.light.shadow;(t.needsUpdate||t.autoUpdate)&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}update(){const{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}}const Jg=U(n=>{const{lightDistance:e,cutoffDistance:t,decayExponent:i}=n,r=e.pow(i).max(.01).reciprocal();return t.greaterThan(0).select(r.mul(e.div(t).pow4().oneMinus().clamp().pow2()),r)});let bd;function Kg(n){bd=bd||new WeakMap;let e=bd.get(n);return e===void 0&&bd.set(n,e={}),e}function Zg(n){const e=Kg(n);return e.position||(e.position=fe(new N).setGroup(xt).onRenderUpdate((t,i)=>i.value.setFromMatrixPosition(n.matrixWorld)))}function dS(n){const e=Kg(n);return e.targetPosition||(e.targetPosition=fe(new N).setGroup(xt).onRenderUpdate((t,i)=>i.value.setFromMatrixPosition(n.target.matrixWorld)))}function Td(n){const e=Kg(n);return e.viewPosition||(e.viewPosition=fe(new N).setGroup(xt).onRenderUpdate(({camera:t},i)=>{i.value=i.value||new N,i.value.setFromMatrixPosition(n.matrixWorld),i.value.applyMatrix4(t.matrixWorldInverse)}))}const Qg=n=>cr.transformDirection(Zg(n).sub(dS(n))),sU=U(([n])=>{const e=n.toUint().mul(747796405).add(2891336453),t=e.shiftRight(e.shiftRight(28).add(4)).bitXor(e).mul(277803737);return t.shiftRight(22).bitXor(t).toFloat().mul(1/2**32)}),e0=(n,e)=>Ji(lt(4,n.mul(Pt(1,n))),e),aU=(n,e)=>n.lessThan(.5)?e0(n.mul(2),e).div(2):Pt(1,e0(lt(Pt(1,n),2),e).div(2)),oU=(n,e,t)=>Ji(Qr(Ji(n,e),zt(Ji(n,e),Ji(Pt(1,n),t))),1/e),lU=(n,e)=>Ci(Qs.mul(e.mul(n).sub(1))).div(Qs.mul(e.mul(n).sub(1))),gn=U(([n])=>n.fract().sub(.5).abs()).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),pS=U(([n])=>D(gn(n.z.add(gn(n.y.mul(1)))),gn(n.z.add(gn(n.x.mul(1)))),gn(n.y.add(gn(n.x.mul(1)))))).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),cU=U(([n,e,t])=>{const i=D(n).toVar(),r=E(1.4).toVar(),s=E(0).toVar(),a=D(i).toVar();return gt({start:E(0),end:E(3),type:"float",condition:"<="},()=>{const o=D(pS(a.mul(2))).toVar();i.addAssign(o.add(t.mul(E(.1).mul(e)))),a.mulAssign(1.8),r.mulAssign(1.5),i.mulAssign(1.2);const l=E(gn(i.z.add(gn(i.x.add(gn(i.y)))))).toVar();s.addAssign(l.div(r)),a.addAssign(.14)}),s}).setLayout({name:"triNoise3D",type:"float",inputs:[{name:"p",type:"vec3"},{name:"spd",type:"float"},{name:"time",type:"float"}]}),uU=U(([n,e,t=z(.5)])=>Eg(n.sub(t),e).add(t)),hU=U(([n,e,t=z(.5)])=>{const i=n.sub(t),r=i.dot(i),s=r.mul(r).mul(e);return n.add(i.mul(s))}),dU=U(({position:n=null,horizontal:e=!0,vertical:t=!1})=>{let i;n!==null?(i=Br.toVar(),i[3][0]=n.x,i[3][1]=n.y,i[3][2]=n.z):i=Br;const r=cr.mul(i);return Il(e)&&(r[0][0]=Br[0].length(),r[0][1]=0,r[0][2]=0),Il(t)&&(r[1][0]=0,r[1][1]=Br[1].length(),r[1][2]=0),r[2][0]=0,r[2][1]=0,r[2][2]=1,lr.mul(r).mul(Zt)}),pU=U(([n=null])=>{const e=ed();return ed(lg(n)).sub(e).lessThan(0).select(ps,n)}),mS=new WeakMap;class mU extends pt{static get type(){return"VelocityNode"}constructor(){super("vec2"),this.updateType=je.OBJECT,this.updateAfterType=je.OBJECT,this.previousModelWorldMatrix=fe(new Re),this.previousProjectionMatrix=fe(new Re).setGroup(xt),this.previousCameraViewMatrix=fe(new Re)}update({frameId:e,camera:t,object:i}){const r=gS(i);this.previousModelWorldMatrix.value.copy(r);const s=fS(t);s.frameId!==e&&(s.frameId=e,s.previousProjectionMatrix===void 0?(s.previousProjectionMatrix=new Re,s.previousCameraViewMatrix=new Re,s.currentProjectionMatrix=new Re,s.currentCameraViewMatrix=new Re,s.previousProjectionMatrix.copy(t.projectionMatrix),s.previousCameraViewMatrix.copy(t.matrixWorldInverse)):(s.previousProjectionMatrix.copy(s.currentProjectionMatrix),s.previousCameraViewMatrix.copy(s.currentCameraViewMatrix)),s.currentProjectionMatrix.copy(t.projectionMatrix),s.currentCameraViewMatrix.copy(t.matrixWorldInverse),this.previousProjectionMatrix.value.copy(s.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(s.previousCameraViewMatrix))}updateAfter({object:e}){gS(e).copy(e.matrixWorld)}setup(){const e=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),t=lr.mul(pn).mul(Zt),i=this.previousProjectionMatrix.mul(e).mul(Hh),r=t.xy.div(t.w),s=i.xy.div(i.w);return Pt(r,s)}}function fS(n){let e=mS.get(n);return e===void 0&&(e={},mS.set(n,e)),e}function gS(n,e=0){const t=fS(n);let i=t[e];return i===void 0&&(t[e]=i=new Re),i}const fU=ge(mU),gU=U(([n,e])=>xi(1,n.oneMinus().div(e)).oneMinus()).setLayout({name:"burnBlend",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),vU=U(([n,e])=>xi(n.div(e.oneMinus()),1)).setLayout({name:"dodgeBlend",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),yU=U(([n,e])=>n.oneMinus().mul(e.oneMinus()).oneMinus()).setLayout({name:"screenBlend",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),xU=U(([n,e])=>rt(n.mul(2).mul(e),n.oneMinus().mul(2).mul(e.oneMinus()).oneMinus(),Wl(.5,n))).setLayout({name:"overlayBlend",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),_U=U(([n,e,t=P(16)])=>{const i=o=>n.uv(o),r=nt(),s=i(r).toVar(),a=E(t);return gt({start:P(1),end:t,type:"int",condition:"<="},({i:o})=>{const l=e.mul(E(o).div(a.sub(1)).sub(.5));s.addAssign(i(r.add(l)))}),s.divAssign(a),s}),MU=U(([n,e=1])=>{const t=n,i=Ui(t.rgb),r=D(i),s=xi(1,ft(0,E(10).mul(i.sub(.45)))),a=r.mul(t.rgb).mul(2),o=E(2).mul(r.oneMinus()).mul(t.rgb.oneMinus()).oneMinus(),l=rt(a,o,s),c=t.a.mul(e),u=c.mul(l.rgb);return u.addAssign(t.rgb.mul(c.oneMinus())),ae(u,t.a)}),bU=U(([n])=>{const e=D(n);return ae(qt(e,D(.393,.769,.189)),qt(e,D(.349,.686,.168)),qt(e,D(.272,.534,.131)),n.a)}),vS=U(([n])=>{const e=n.mul(.9478672986).add(.0521327014).pow(2.4),t=n.mul(.0773993808),i=n.lessThanEqual(.04045);return rt(e,t,i)}).setLayout({name:"sRGBToLinearSRGB",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),yS=U(([n])=>{const e=n.pow(.41666).mul(1.055).sub(.055),t=n.mul(12.92),i=n.lessThanEqual(.0031308);return rt(e,t,i)}).setLayout({name:"linearSRGBTosRGB",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),xS=U(([n,e])=>n.mul(e).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),_S=U(([n,e])=>(n=n.mul(e),n.div(n.add(1)).clamp())).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),MS=U(([n,e])=>{n=n.mul(e),n=n.sub(.004).max(0);const t=n.mul(n.mul(6.2).add(.5)),i=n.mul(n.mul(6.2).add(1.7)).add(.06);return t.div(i).pow(2.2)}).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),TU=U(([n])=>{const e=n.mul(n.add(.0245786)).sub(90537e-9),t=n.mul(n.add(.432951).mul(.983729)).add(.238081);return e.div(t)}),bS=U(([n,e])=>{const t=yi(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),i=yi(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return n=n.mul(e).div(.6),n=t.mul(n),n=TU(n),n=i.mul(n),n.clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),SU=yi(D(1.6605,-.1246,-.0182),D(-.5876,1.1329,-.1006),D(-.0728,-.0083,1.1187)),wU=yi(D(.6274,.0691,.0164),D(.3293,.9195,.088),D(.0433,.0113,.8956)),EU=U(([n])=>{const e=D(n).toVar(),t=D(e.mul(e)).toVar(),i=D(t.mul(t)).toVar();return E(15.5).mul(i.mul(t)).sub(lt(40.14,i.mul(e))).add(lt(31.96,i).sub(lt(6.868,t.mul(e))).add(lt(.4298,t).add(lt(.1191,e).sub(.00232))))}),TS=U(([n,e])=>{const t=D(n).toVar(),i=yi(D(.856627153315983,.137318972929847,.11189821299995),D(.0951212405381588,.761241990602591,.0767994186031903),D(.0482516061458583,.101439036467562,.811302368396859)),r=yi(D(1.1271005818144368,-.1413297634984383,-.14132976349843826),D(-.11060664309660323,1.157823702216272,-.11060664309660294),D(-.016493938717834573,-.016493938717834257,1.2519364065950405)),s=E(-12.47393),a=E(4.026069);return t.mulAssign(e),t.assign(wU.mul(t)),t.assign(i.mul(t)),t.assign(ft(t,1e-10)),t.assign(Hl(t)),t.assign(t.sub(s).div(a.sub(s))),t.assign(li(t,0,1)),t.assign(EU(t)),t.assign(r.mul(t)),t.assign(Ji(ft(D(0),t),D(2.2))),t.assign(SU.mul(t)),t.assign(li(t,0,1)),t}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),SS=U(([n,e])=>{const t=E(.76),i=E(.15);n=n.mul(e);const r=xi(n.r,xi(n.g,n.b)),s=Ri(r.lessThan(.08),r.sub(lt(6.25,r.mul(r))),.04);n.subAssign(s);const a=ft(n.r,ft(n.g,n.b));Le(a.lessThan(t),()=>n);const o=Pt(1,t),l=Pt(1,o.mul(o).div(a.add(o.sub(t))));n.mulAssign(l.div(a));const c=Pt(1,Qr(1,i.mul(a.sub(l)).add(1)));return rt(n,D(l),c)}).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class AU extends qe{static get type(){return"ComputeBuiltinNode"}constructor(e,t){super(t),this._builtinName=e}getHash(e){return this.getBuiltinName(e)}getNodeType(){return this.nodeType}setBuiltinName(e){return this._builtinName=e,this}getBuiltinName(){return this._builtinName}hasBuiltin(e){e.hasBuiltin(this._builtinName)}generate(e,t){const i=this.getBuiltinName(e),r=this.getNodeType(e);return e.shaderStage==="compute"?e.format(i,r,t):(console.warn(`ComputeBuiltinNode: Compute built-in value ${i} can not be accessed in the ${e.shaderStage} stage`),e.generateConst(r))}serialize(e){super.serialize(e),e.global=this.global,e._builtinName=this._builtinName}deserialize(e){super.deserialize(e),this.global=e.global,this._builtinName=e._builtinName}}const Sd=(n,e)=>G(new AU(n,e)),NU=Sd("numWorkgroups","uvec3"),CU=Sd("workgroupId","uvec3"),RU=Sd("localId","uvec3"),IU=Sd("subgroupSize","uint");class LU extends qe{constructor(e){super(),this.scope=e}generate(e){const{scope:t}=this,{renderer:i}=e;i.backend.isWebGLBackend===!0?e.addFlowCode(` // ${t}Barrier
|
|
3874
|
-
`):e.addLineFlowCode(`${t}Barrier()`,this)}}const t0=K(LU),PU=()=>t0("workgroup").append(),DU=()=>t0("storage").append(),UU=()=>t0("texture").append();class OU extends as{constructor(e,t){super(e,t),this.isWorkgroupInfoElementNode=!0}generate(e,t){let i;const r=e.context.assign;if(i=super.generate(e),r!==!0){const s=this.getNodeType(e);i=e.format(i,s,t)}return i}}class FU extends qe{constructor(e,t,i=0){super(t),this.bufferType=t,this.bufferCount=i,this.isWorkgroupInfoNode=!0,this.scope=e}label(e){return this.name=e,this}getHash(){return this.uuid}setScope(e){return this.scope=e,this}getInputType(){return`${this.scope}Array`}element(e){return G(new OU(this,e))}generate(e){return e.getScopedArray(this.name||`${this.scope}Array_${this.id}`,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}}const VU=(n,e)=>G(new FU("Workgroup",n,e));class Mi extends pt{static get type(){return"AtomicFunctionNode"}constructor(e,t,i,r=null){super("uint"),this.method=e,this.pointerNode=t,this.valueNode=i,this.storeNode=r}getInputType(e){return this.pointerNode.getNodeType(e)}getNodeType(e){return this.getInputType(e)}generate(e){const t=this.method,i=this.getNodeType(e),r=this.getInputType(e),s=this.pointerNode,a=this.valueNode,o=[];o.push(`&${s.build(e,r)}`),o.push(a.build(e,r));const l=`${e.getMethod(t,i)}( ${o.join(", ")} )`;if(this.storeNode!==null){const c=this.storeNode.build(e,r);e.addLineFlowCode(`${c} = ${l}`,this)}else e.addLineFlowCode(l,this)}}Mi.ATOMIC_LOAD="atomicLoad",Mi.ATOMIC_STORE="atomicStore",Mi.ATOMIC_ADD="atomicAdd",Mi.ATOMIC_SUB="atomicSub",Mi.ATOMIC_MAX="atomicMax",Mi.ATOMIC_MIN="atomicMin",Mi.ATOMIC_AND="atomicAnd",Mi.ATOMIC_OR="atomicOr",Mi.ATOMIC_XOR="atomicXor";const BU=K(Mi),Un=(n,e,t,i)=>{const r=BU(n,e,t,i);return r.append(),r},zU=(n,e,t=null)=>Un(Mi.ATOMIC_STORE,n,e,t),kU=(n,e,t=null)=>Un(Mi.ATOMIC_ADD,n,e,t),HU=(n,e,t=null)=>Un(Mi.ATOMIC_SUB,n,e,t),GU=(n,e,t=null)=>Un(Mi.ATOMIC_MAX,n,e,t),WU=(n,e,t=null)=>Un(Mi.ATOMIC_MIN,n,e,t),jU=(n,e,t=null)=>Un(Mi.ATOMIC_AND,n,e,t),XU=(n,e,t=null)=>Un(Mi.ATOMIC_OR,n,e,t),qU=(n,e,t=null)=>Un(Mi.ATOMIC_XOR,n,e,t),YU=U(([n=nt()])=>{const e=n.mul(2),t=e.x.floor(),i=e.y.floor();return t.add(i).mod(2).sign()}),pc=U(([n,e,t])=>{const i=E(t).toVar(),r=E(e).toVar(),s=os(n).toVar();return Ri(s,r,i)}).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),wd=U(([n,e])=>{const t=os(e).toVar(),i=E(n).toVar();return Ri(t,i.negate(),i)}).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),ii=U(([n])=>{const e=E(n).toVar();return P(cs(e))}).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),kt=U(([n,e])=>{const t=E(n).toVar();return e.assign(ii(t)),t.sub(E(e))}),$U=U(([n,e,t,i,r,s])=>{const a=E(s).toVar(),o=E(r).toVar(),l=E(i).toVar(),c=E(t).toVar(),u=E(e).toVar(),h=E(n).toVar(),d=E(Pt(1,o)).toVar();return Pt(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"}]}),JU=U(([n,e,t,i,r,s])=>{const a=E(s).toVar(),o=E(r).toVar(),l=D(i).toVar(),c=D(t).toVar(),u=D(e).toVar(),h=D(n).toVar(),d=E(Pt(1,o)).toVar();return Pt(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"}]}),wS=Di([$U,JU]),KU=U(([n,e,t,i,r,s,a,o,l,c,u])=>{const h=E(u).toVar(),d=E(c).toVar(),p=E(l).toVar(),m=E(o).toVar(),v=E(a).toVar(),f=E(s).toVar(),g=E(r).toVar(),x=E(i).toVar(),y=E(t).toVar(),_=E(e).toVar(),I=E(n).toVar(),b=E(Pt(1,p)).toVar(),w=E(Pt(1,d)).toVar();return E(Pt(1,h)).toVar().mul(w.mul(I.mul(b).add(_.mul(p))).add(d.mul(y.mul(b).add(x.mul(p))))).add(h.mul(w.mul(g.mul(b).add(f.mul(p))).add(d.mul(v.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"}]}),ZU=U(([n,e,t,i,r,s,a,o,l,c,u])=>{const h=E(u).toVar(),d=E(c).toVar(),p=E(l).toVar(),m=D(o).toVar(),v=D(a).toVar(),f=D(s).toVar(),g=D(r).toVar(),x=D(i).toVar(),y=D(t).toVar(),_=D(e).toVar(),I=D(n).toVar(),b=E(Pt(1,p)).toVar(),w=E(Pt(1,d)).toVar();return E(Pt(1,h)).toVar().mul(w.mul(I.mul(b).add(_.mul(p))).add(d.mul(y.mul(b).add(x.mul(p))))).add(h.mul(w.mul(g.mul(b).add(f.mul(p))).add(d.mul(v.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"}]}),ES=Di([KU,ZU]),QU=U(([n,e,t])=>{const i=E(t).toVar(),r=E(e).toVar(),s=_e(n).toVar(),a=_e(s.bitAnd(_e(7))).toVar(),o=E(pc(a.lessThan(_e(4)),r,i)).toVar(),l=E(lt(2,pc(a.lessThan(_e(4)),i,r))).toVar();return wd(o,os(a.bitAnd(_e(1)))).add(wd(l,os(a.bitAnd(_e(2)))))}).setLayout({name:"mx_gradient_float_0",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"}]}),eO=U(([n,e,t,i])=>{const r=E(i).toVar(),s=E(t).toVar(),a=E(e).toVar(),o=_e(n).toVar(),l=_e(o.bitAnd(_e(15))).toVar(),c=E(pc(l.lessThan(_e(8)),a,s)).toVar(),u=E(pc(l.lessThan(_e(4)),s,pc(l.equal(_e(12)).or(l.equal(_e(14))),a,r))).toVar();return wd(c,os(l.bitAnd(_e(1)))).add(wd(u,os(l.bitAnd(_e(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"}]}),bi=Di([QU,eO]),tO=U(([n,e,t])=>{const i=E(t).toVar(),r=E(e).toVar(),s=oo(n).toVar();return D(bi(s.x,r,i),bi(s.y,r,i),bi(s.z,r,i))}).setLayout({name:"mx_gradient_vec3_0",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"}]}),iO=U(([n,e,t,i])=>{const r=E(i).toVar(),s=E(t).toVar(),a=E(e).toVar(),o=oo(n).toVar();return D(bi(o.x,a,s,r),bi(o.y,a,s,r),bi(o.z,a,s,r))}).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"}]}),zr=Di([tO,iO]),rO=U(([n])=>{const e=E(n).toVar();return lt(.6616,e)}).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),nO=U(([n])=>{const e=E(n).toVar();return lt(.982,e)}).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),sO=U(([n])=>{const e=D(n).toVar();return lt(.6616,e)}).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),AS=Di([rO,sO]),aO=U(([n])=>{const e=D(n).toVar();return lt(.982,e)}).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),NS=Di([nO,aO]),Sr=U(([n,e])=>{const t=P(e).toVar(),i=_e(n).toVar();return i.shiftLeft(t).bitOr(i.shiftRight(P(32).sub(t)))}).setLayout({name:"mx_rotl32",type:"uint",inputs:[{name:"x",type:"uint"},{name:"k",type:"int"}]}),CS=U(([n,e,t])=>{n.subAssign(t),n.bitXorAssign(Sr(t,P(4))),t.addAssign(e),e.subAssign(n),e.bitXorAssign(Sr(n,P(6))),n.addAssign(t),t.subAssign(e),t.bitXorAssign(Sr(e,P(8))),e.addAssign(n),n.subAssign(t),n.bitXorAssign(Sr(t,P(16))),t.addAssign(e),e.subAssign(n),e.bitXorAssign(Sr(n,P(19))),n.addAssign(t),t.subAssign(e),t.bitXorAssign(Sr(e,P(4))),e.addAssign(n)}),mc=U(([n,e,t])=>{const i=_e(t).toVar(),r=_e(e).toVar(),s=_e(n).toVar();return i.bitXorAssign(r),i.subAssign(Sr(r,P(14))),s.bitXorAssign(i),s.subAssign(Sr(i,P(11))),r.bitXorAssign(s),r.subAssign(Sr(s,P(25))),i.bitXorAssign(r),i.subAssign(Sr(r,P(16))),s.bitXorAssign(i),s.subAssign(Sr(i,P(4))),r.bitXorAssign(s),r.subAssign(Sr(s,P(14))),i.bitXorAssign(r),i.subAssign(Sr(r,P(24))),i}).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),Gi=U(([n])=>{const e=_e(n).toVar();return E(e).div(E(_e(P(4294967295))))}).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),vn=U(([n])=>{const e=E(n).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"}]}),oO=U(([n])=>{const e=P(n).toVar(),t=_e(_e(1)).toVar(),i=_e(_e(P(3735928559)).add(t.shiftLeft(_e(2))).add(_e(13))).toVar();return mc(i.add(_e(e)),i,i)}).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),lO=U(([n,e])=>{const t=P(e).toVar(),i=P(n).toVar(),r=_e(_e(2)).toVar(),s=_e().toVar(),a=_e().toVar(),o=_e().toVar();return s.assign(a.assign(o.assign(_e(P(3735928559)).add(r.shiftLeft(_e(2))).add(_e(13))))),s.addAssign(_e(i)),a.addAssign(_e(t)),mc(s,a,o)}).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),cO=U(([n,e,t])=>{const i=P(t).toVar(),r=P(e).toVar(),s=P(n).toVar(),a=_e(_e(3)).toVar(),o=_e().toVar(),l=_e().toVar(),c=_e().toVar();return o.assign(l.assign(c.assign(_e(P(3735928559)).add(a.shiftLeft(_e(2))).add(_e(13))))),o.addAssign(_e(s)),l.addAssign(_e(r)),c.addAssign(_e(i)),mc(o,l,c)}).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),uO=U(([n,e,t,i])=>{const r=P(i).toVar(),s=P(t).toVar(),a=P(e).toVar(),o=P(n).toVar(),l=_e(_e(4)).toVar(),c=_e().toVar(),u=_e().toVar(),h=_e().toVar();return c.assign(u.assign(h.assign(_e(P(3735928559)).add(l.shiftLeft(_e(2))).add(_e(13))))),c.addAssign(_e(o)),u.addAssign(_e(a)),h.addAssign(_e(s)),CS(c,u,h),c.addAssign(_e(r)),mc(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"}]}),hO=U(([n,e,t,i,r])=>{const s=P(r).toVar(),a=P(i).toVar(),o=P(t).toVar(),l=P(e).toVar(),c=P(n).toVar(),u=_e(_e(5)).toVar(),h=_e().toVar(),d=_e().toVar(),p=_e().toVar();return h.assign(d.assign(p.assign(_e(P(3735928559)).add(u.shiftLeft(_e(2))).add(_e(13))))),h.addAssign(_e(c)),d.addAssign(_e(l)),p.addAssign(_e(o)),CS(h,d,p),h.addAssign(_e(a)),d.addAssign(_e(s)),mc(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"}]}),Ct=Di([oO,lO,cO,uO,hO]),dO=U(([n,e])=>{const t=P(e).toVar(),i=P(n).toVar(),r=_e(Ct(i,t)).toVar(),s=oo().toVar();return s.x.assign(r.bitAnd(P(255))),s.y.assign(r.shiftRight(P(8)).bitAnd(P(255))),s.z.assign(r.shiftRight(P(16)).bitAnd(P(255))),s}).setLayout({name:"mx_hash_vec3_0",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),pO=U(([n,e,t])=>{const i=P(t).toVar(),r=P(e).toVar(),s=P(n).toVar(),a=_e(Ct(s,r,i)).toVar(),o=oo().toVar();return o.x.assign(a.bitAnd(P(255))),o.y.assign(a.shiftRight(P(8)).bitAnd(P(255))),o.z.assign(a.shiftRight(P(16)).bitAnd(P(255))),o}).setLayout({name:"mx_hash_vec3_1",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),kr=Di([dO,pO]),mO=U(([n])=>{const e=z(n).toVar(),t=P().toVar(),i=P().toVar(),r=E(kt(e.x,t)).toVar(),s=E(kt(e.y,i)).toVar(),a=E(vn(r)).toVar(),o=E(vn(s)).toVar(),l=E(wS(bi(Ct(t,i),r,s),bi(Ct(t.add(P(1)),i),r.sub(1),s),bi(Ct(t,i.add(P(1))),r,s.sub(1)),bi(Ct(t.add(P(1)),i.add(P(1))),r.sub(1),s.sub(1)),a,o)).toVar();return AS(l)}).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),fO=U(([n])=>{const e=D(n).toVar(),t=P().toVar(),i=P().toVar(),r=P().toVar(),s=E(kt(e.x,t)).toVar(),a=E(kt(e.y,i)).toVar(),o=E(kt(e.z,r)).toVar(),l=E(vn(s)).toVar(),c=E(vn(a)).toVar(),u=E(vn(o)).toVar(),h=E(ES(bi(Ct(t,i,r),s,a,o),bi(Ct(t.add(P(1)),i,r),s.sub(1),a,o),bi(Ct(t,i.add(P(1)),r),s,a.sub(1),o),bi(Ct(t.add(P(1)),i.add(P(1)),r),s.sub(1),a.sub(1),o),bi(Ct(t,i,r.add(P(1))),s,a,o.sub(1)),bi(Ct(t.add(P(1)),i,r.add(P(1))),s.sub(1),a,o.sub(1)),bi(Ct(t,i.add(P(1)),r.add(P(1))),s,a.sub(1),o.sub(1)),bi(Ct(t.add(P(1)),i.add(P(1)),r.add(P(1))),s.sub(1),a.sub(1),o.sub(1)),l,c,u)).toVar();return NS(h)}).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]}),i0=Di([mO,fO]),gO=U(([n])=>{const e=z(n).toVar(),t=P().toVar(),i=P().toVar(),r=E(kt(e.x,t)).toVar(),s=E(kt(e.y,i)).toVar(),a=E(vn(r)).toVar(),o=E(vn(s)).toVar(),l=D(wS(zr(kr(t,i),r,s),zr(kr(t.add(P(1)),i),r.sub(1),s),zr(kr(t,i.add(P(1))),r,s.sub(1)),zr(kr(t.add(P(1)),i.add(P(1))),r.sub(1),s.sub(1)),a,o)).toVar();return AS(l)}).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),vO=U(([n])=>{const e=D(n).toVar(),t=P().toVar(),i=P().toVar(),r=P().toVar(),s=E(kt(e.x,t)).toVar(),a=E(kt(e.y,i)).toVar(),o=E(kt(e.z,r)).toVar(),l=E(vn(s)).toVar(),c=E(vn(a)).toVar(),u=E(vn(o)).toVar(),h=D(ES(zr(kr(t,i,r),s,a,o),zr(kr(t.add(P(1)),i,r),s.sub(1),a,o),zr(kr(t,i.add(P(1)),r),s,a.sub(1),o),zr(kr(t.add(P(1)),i.add(P(1)),r),s.sub(1),a.sub(1),o),zr(kr(t,i,r.add(P(1))),s,a,o.sub(1)),zr(kr(t.add(P(1)),i,r.add(P(1))),s.sub(1),a,o.sub(1)),zr(kr(t,i.add(P(1)),r.add(P(1))),s,a.sub(1),o.sub(1)),zr(kr(t.add(P(1)),i.add(P(1)),r.add(P(1))),s.sub(1),a.sub(1),o.sub(1)),l,c,u)).toVar();return NS(h)}).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),r0=Di([gO,vO]),yO=U(([n])=>{const e=E(n).toVar(),t=P(ii(e)).toVar();return Gi(Ct(t))}).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),xO=U(([n])=>{const e=z(n).toVar(),t=P(ii(e.x)).toVar(),i=P(ii(e.y)).toVar();return Gi(Ct(t,i))}).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),_O=U(([n])=>{const e=D(n).toVar(),t=P(ii(e.x)).toVar(),i=P(ii(e.y)).toVar(),r=P(ii(e.z)).toVar();return Gi(Ct(t,i,r))}).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),MO=U(([n])=>{const e=ae(n).toVar(),t=P(ii(e.x)).toVar(),i=P(ii(e.y)).toVar(),r=P(ii(e.z)).toVar(),s=P(ii(e.w)).toVar();return Gi(Ct(t,i,r,s))}).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]}),bO=Di([yO,xO,_O,MO]),TO=U(([n])=>{const e=E(n).toVar(),t=P(ii(e)).toVar();return D(Gi(Ct(t,P(0))),Gi(Ct(t,P(1))),Gi(Ct(t,P(2))))}).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),SO=U(([n])=>{const e=z(n).toVar(),t=P(ii(e.x)).toVar(),i=P(ii(e.y)).toVar();return D(Gi(Ct(t,i,P(0))),Gi(Ct(t,i,P(1))),Gi(Ct(t,i,P(2))))}).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),wO=U(([n])=>{const e=D(n).toVar(),t=P(ii(e.x)).toVar(),i=P(ii(e.y)).toVar(),r=P(ii(e.z)).toVar();return D(Gi(Ct(t,i,r,P(0))),Gi(Ct(t,i,r,P(1))),Gi(Ct(t,i,r,P(2))))}).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),EO=U(([n])=>{const e=ae(n).toVar(),t=P(ii(e.x)).toVar(),i=P(ii(e.y)).toVar(),r=P(ii(e.z)).toVar(),s=P(ii(e.w)).toVar();return D(Gi(Ct(t,i,r,s,P(0))),Gi(Ct(t,i,r,s,P(1))),Gi(Ct(t,i,r,s,P(2))))}).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]}),RS=Di([TO,SO,wO,EO]),Ed=U(([n,e,t,i])=>{const r=E(i).toVar(),s=E(t).toVar(),a=P(e).toVar(),o=D(n).toVar(),l=E(0).toVar(),c=E(1).toVar();return gt(a,()=>{l.addAssign(c.mul(i0(o))),c.mulAssign(r),o.mulAssign(s)}),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"}]}),IS=U(([n,e,t,i])=>{const r=E(i).toVar(),s=E(t).toVar(),a=P(e).toVar(),o=D(n).toVar(),l=D(0).toVar(),c=E(1).toVar();return gt(a,()=>{l.addAssign(c.mul(r0(o))),c.mulAssign(r),o.mulAssign(s)}),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"}]}),AO=U(([n,e,t,i])=>{const r=E(i).toVar(),s=E(t).toVar(),a=P(e).toVar(),o=D(n).toVar();return z(Ed(o,a,s,r),Ed(o.add(D(P(19),P(193),P(17))),a,s,r))}).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"}]}),NO=U(([n,e,t,i])=>{const r=E(i).toVar(),s=E(t).toVar(),a=P(e).toVar(),o=D(n).toVar(),l=D(IS(o,a,s,r)).toVar(),c=E(Ed(o.add(D(P(19),P(193),P(17))),a,s,r)).toVar();return ae(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"}]}),CO=U(([n,e,t,i,r,s,a])=>{const o=P(a).toVar(),l=E(s).toVar(),c=P(r).toVar(),u=P(i).toVar(),h=P(t).toVar(),d=P(e).toVar(),p=z(n).toVar(),m=D(RS(z(d.add(u),h.add(c)))).toVar(),v=z(m.x,m.y).toVar();v.subAssign(.5),v.mulAssign(l),v.addAssign(.5);const f=z(z(E(d),E(h)).add(v)).toVar(),g=z(f.sub(p)).toVar();return Le(o.equal(P(2)),()=>It(g.x).add(It(g.y))),Le(o.equal(P(3)),()=>ft(It(g.x),It(g.y))),qt(g,g)}).setLayout({name:"mx_worley_distance_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),RO=U(([n,e,t,i,r,s,a,o,l])=>{const c=P(l).toVar(),u=E(o).toVar(),h=P(a).toVar(),d=P(s).toVar(),p=P(r).toVar(),m=P(i).toVar(),v=P(t).toVar(),f=P(e).toVar(),g=D(n).toVar(),x=D(RS(D(f.add(p),v.add(d),m.add(h)))).toVar();x.subAssign(.5),x.mulAssign(u),x.addAssign(.5);const y=D(D(E(f),E(v),E(m)).add(x)).toVar(),_=D(y.sub(g)).toVar();return Le(c.equal(P(2)),()=>It(_.x).add(It(_.y)).add(It(_.z))),Le(c.equal(P(3)),()=>ft(ft(It(_.x),It(_.y)),It(_.z))),qt(_,_)}).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"}]}),So=Di([CO,RO]),IO=U(([n,e,t])=>{const i=P(t).toVar(),r=E(e).toVar(),s=z(n).toVar(),a=P().toVar(),o=P().toVar(),l=z(kt(s.x,a),kt(s.y,o)).toVar(),c=E(1e6).toVar();return gt({start:-1,end:P(1),name:"x",condition:"<="},({x:u})=>{gt({start:-1,end:P(1),name:"y",condition:"<="},({y:h})=>{const d=E(So(l,u,h,a,o,r,i)).toVar();c.assign(xi(c,d))})}),Le(i.equal(P(0)),()=>{c.assign(en(c))}),c}).setLayout({name:"mx_worley_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),LO=U(([n,e,t])=>{const i=P(t).toVar(),r=E(e).toVar(),s=z(n).toVar(),a=P().toVar(),o=P().toVar(),l=z(kt(s.x,a),kt(s.y,o)).toVar(),c=z(1e6,1e6).toVar();return gt({start:-1,end:P(1),name:"x",condition:"<="},({x:u})=>{gt({start:-1,end:P(1),name:"y",condition:"<="},({y:h})=>{const d=E(So(l,u,h,a,o,r,i)).toVar();Le(d.lessThan(c.x),()=>{c.y.assign(c.x),c.x.assign(d)}).ElseIf(d.lessThan(c.y),()=>{c.y.assign(d)})})}),Le(i.equal(P(0)),()=>{c.assign(en(c))}),c}).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),PO=U(([n,e,t])=>{const i=P(t).toVar(),r=E(e).toVar(),s=z(n).toVar(),a=P().toVar(),o=P().toVar(),l=z(kt(s.x,a),kt(s.y,o)).toVar(),c=D(1e6,1e6,1e6).toVar();return gt({start:-1,end:P(1),name:"x",condition:"<="},({x:u})=>{gt({start:-1,end:P(1),name:"y",condition:"<="},({y:h})=>{const d=E(So(l,u,h,a,o,r,i)).toVar();Le(d.lessThan(c.x),()=>{c.z.assign(c.y),c.y.assign(c.x),c.x.assign(d)}).ElseIf(d.lessThan(c.y),()=>{c.z.assign(c.y),c.y.assign(d)}).ElseIf(d.lessThan(c.z),()=>{c.z.assign(d)})})}),Le(i.equal(P(0)),()=>{c.assign(en(c))}),c}).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),DO=U(([n,e,t])=>{const i=P(t).toVar(),r=E(e).toVar(),s=D(n).toVar(),a=P().toVar(),o=P().toVar(),l=P().toVar(),c=D(kt(s.x,a),kt(s.y,o),kt(s.z,l)).toVar(),u=E(1e6).toVar();return gt({start:-1,end:P(1),name:"x",condition:"<="},({x:h})=>{gt({start:-1,end:P(1),name:"y",condition:"<="},({y:d})=>{gt({start:-1,end:P(1),name:"z",condition:"<="},({z:p})=>{const m=E(So(c,h,d,p,a,o,l,r,i)).toVar();u.assign(xi(u,m))})})}),Le(i.equal(P(0)),()=>{u.assign(en(u))}),u}).setLayout({name:"mx_worley_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),UO=Di([IO,DO]),OO=U(([n,e,t])=>{const i=P(t).toVar(),r=E(e).toVar(),s=D(n).toVar(),a=P().toVar(),o=P().toVar(),l=P().toVar(),c=D(kt(s.x,a),kt(s.y,o),kt(s.z,l)).toVar(),u=z(1e6,1e6).toVar();return gt({start:-1,end:P(1),name:"x",condition:"<="},({x:h})=>{gt({start:-1,end:P(1),name:"y",condition:"<="},({y:d})=>{gt({start:-1,end:P(1),name:"z",condition:"<="},({z:p})=>{const m=E(So(c,h,d,p,a,o,l,r,i)).toVar();Le(m.lessThan(u.x),()=>{u.y.assign(u.x),u.x.assign(m)}).ElseIf(m.lessThan(u.y),()=>{u.y.assign(m)})})})}),Le(i.equal(P(0)),()=>{u.assign(en(u))}),u}).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),FO=Di([LO,OO]),VO=U(([n,e,t])=>{const i=P(t).toVar(),r=E(e).toVar(),s=D(n).toVar(),a=P().toVar(),o=P().toVar(),l=P().toVar(),c=D(kt(s.x,a),kt(s.y,o),kt(s.z,l)).toVar(),u=D(1e6,1e6,1e6).toVar();return gt({start:-1,end:P(1),name:"x",condition:"<="},({x:h})=>{gt({start:-1,end:P(1),name:"y",condition:"<="},({y:d})=>{gt({start:-1,end:P(1),name:"z",condition:"<="},({z:p})=>{const m=E(So(c,h,d,p,a,o,l,r,i)).toVar();Le(m.lessThan(u.x),()=>{u.z.assign(u.y),u.y.assign(u.x),u.x.assign(m)}).ElseIf(m.lessThan(u.y),()=>{u.z.assign(u.y),u.y.assign(m)}).ElseIf(m.lessThan(u.z),()=>{u.z.assign(m)})})})}),Le(i.equal(P(0)),()=>{u.assign(en(u))}),u}).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),BO=Di([PO,VO]),zO=U(([n])=>{const e=n.y,t=n.z,i=D().toVar();return Le(e.lessThan(1e-4),()=>{i.assign(D(t,t,t))}).Else(()=>{let r=n.x;r=r.sub(cs(r)).mul(6).toVar();const s=P(If(r)),a=r.sub(E(s)),o=t.mul(e.oneMinus()),l=t.mul(e.mul(a).oneMinus()),c=t.mul(e.mul(a.oneMinus()).oneMinus());Le(s.equal(P(0)),()=>{i.assign(D(t,c,o))}).ElseIf(s.equal(P(1)),()=>{i.assign(D(l,t,o))}).ElseIf(s.equal(P(2)),()=>{i.assign(D(o,t,c))}).ElseIf(s.equal(P(3)),()=>{i.assign(D(o,l,t))}).ElseIf(s.equal(P(4)),()=>{i.assign(D(c,o,t))}).Else(()=>{i.assign(D(t,o,l))})}),i}).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),kO=U(([n])=>{const e=D(n).toVar(),t=E(e.x).toVar(),i=E(e.y).toVar(),r=E(e.z).toVar(),s=E(xi(t,xi(i,r))).toVar(),a=E(ft(t,ft(i,r))).toVar(),o=E(a.sub(s)).toVar(),l=E().toVar(),c=E().toVar(),u=E().toVar();return u.assign(a),Le(a.greaterThan(0),()=>{c.assign(o.div(a))}).Else(()=>{c.assign(0)}),Le(c.lessThanEqual(0),()=>{l.assign(0)}).Else(()=>{Le(t.greaterThanEqual(a),()=>{l.assign(i.sub(r).div(o))}).ElseIf(i.greaterThanEqual(a),()=>{l.assign(zt(2,r.sub(t).div(o)))}).Else(()=>{l.assign(zt(4,t.sub(i).div(o)))}),l.mulAssign(1/6),Le(l.lessThan(0),()=>{l.addAssign(1)})}),D(l,c,u)}).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),HO=U(([n])=>{const e=D(n).toVar(),t=mf(Ef(e,D(.04045))).toVar(),i=D(e.div(12.92)).toVar(),r=D(Ji(ft(e.add(D(.055)),D(0)).div(1.055),D(2.4))).toVar();return rt(i,r,t)}).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),LS=(n,e)=>{n=E(n),e=E(e);const t=z(e.dFdx(),e.dFdy()).length().mul(.7071067811865476);return Ki(n.sub(t),n.add(t),e)},PS=(n,e,t,i)=>rt(n,e,t[i].clamp()),GO=(n,e,t=nt())=>PS(n,e,t,"x"),WO=(n,e,t=nt())=>PS(n,e,t,"y"),DS=(n,e,t,i,r)=>rt(n,e,LS(t,i[r])),jO=(n,e,t,i=nt())=>DS(n,e,t,i,"x"),XO=(n,e,t,i=nt())=>DS(n,e,t,i,"y"),qO=(n=1,e=0,t=nt())=>t.mul(n).add(e),YO=(n,e=1)=>(n=E(n),n.abs().pow(e).mul(n.sign())),$O=(n,e=1,t=.5)=>E(n).sub(t).mul(e).add(t),JO=(n=nt(),e=1,t=0)=>i0(n.convert("vec2|vec3")).mul(e).add(t),KO=(n=nt(),e=1,t=0)=>r0(n.convert("vec2|vec3")).mul(e).add(t),ZO=(n=nt(),e=1,t=0)=>(n=n.convert("vec2|vec3"),ae(r0(n),i0(n.add(z(19,73)))).mul(e).add(t)),QO=(n=nt(),e=1)=>UO(n.convert("vec2|vec3"),e,P(1)),eF=(n=nt(),e=1)=>FO(n.convert("vec2|vec3"),e,P(1)),tF=(n=nt(),e=1)=>BO(n.convert("vec2|vec3"),e,P(1)),iF=(n=nt())=>bO(n.convert("vec2|vec3")),rF=(n=nt(),e=3,t=2,i=.5,r=1)=>Ed(n,P(e),t,i).mul(r),nF=(n=nt(),e=3,t=2,i=.5,r=1)=>AO(n,P(e),t,i).mul(r),sF=(n=nt(),e=3,t=2,i=.5,r=1)=>IS(n,P(e),t,i).mul(r),aF=(n=nt(),e=3,t=2,i=.5,r=1)=>NO(n,P(e),t,i).mul(r),US=U(([n,e])=>{const t=n.x,i=n.y,r=n.z;let s=e.element(0).mul(.886227);return s=s.add(e.element(1).mul(2*.511664).mul(i)),s=s.add(e.element(2).mul(2*.511664).mul(r)),s=s.add(e.element(3).mul(2*.511664).mul(t)),s=s.add(e.element(4).mul(2*.429043).mul(t).mul(i)),s=s.add(e.element(5).mul(2*.429043).mul(i).mul(r)),s=s.add(e.element(6).mul(r.mul(r).mul(.743125).sub(.247708))),s=s.add(e.element(7).mul(2*.429043).mul(t).mul(r)),s=s.add(e.element(8).mul(.429043).mul(lt(t,t).sub(lt(i,i)))),s});class OS extends ms{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=fe(0).setGroup(xt),this.decayExponentNode=fe(0).setGroup(xt)}update(e){const{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setup(e){const{colorNode:t,cutoffDistanceNode:i,decayExponentNode:r,light:s}=this,a=e.context.lightingModel,o=Td(s).sub(Pi),l=o.normalize(),c=o.length(),u=Jg({lightDistance:c,cutoffDistance:i,decayExponent:r}),h=t.mul(u),d=e.context.reflectedLight;a.direct({lightDirection:l,lightColor:h,reflectedLight:d},e.stack,e)}}class FS extends ms{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setup(e){super.setup(e);const t=e.context.lightingModel,i=this.colorNode,r=Qg(this.light),s=e.context.reflectedLight;t.direct({lightDirection:r,lightColor:i,reflectedLight:s},e.stack,e)}}const n0=new Re,Ad=new Re;let fc=null;class VS extends ms{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=fe(new N).setGroup(xt),this.halfWidth=fe(new N).setGroup(xt)}update(e){super.update(e);const{light:t}=this,i=e.camera.matrixWorldInverse;Ad.identity(),n0.copy(t.matrixWorld),n0.premultiply(i),Ad.extractRotation(n0),this.halfWidth.value.set(t.width*.5,0,0),this.halfHeight.value.set(0,t.height*.5,0),this.halfWidth.value.applyMatrix4(Ad),this.halfHeight.value.applyMatrix4(Ad)}setup(e){super.setup(e);let t,i;e.isAvailable("float32Filterable")?(t=yt(fc.LTC_FLOAT_1),i=yt(fc.LTC_FLOAT_2)):(t=yt(fc.LTC_HALF_1),i=yt(fc.LTC_HALF_2));const{colorNode:r,light:s}=this,a=e.context.lightingModel,o=Td(s),l=e.context.reflectedLight;a.directRectArea({lightColor:r,lightPosition:o,halfWidth:this.halfWidth,halfHeight:this.halfHeight,reflectedLight:l,ltc_1:t,ltc_2:i},e.stack,e)}static setLTC(e){fc=e}}class s0 extends ms{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=fe(0).setGroup(xt),this.penumbraCosNode=fe(0).setGroup(xt),this.cutoffDistanceNode=fe(0).setGroup(xt),this.decayExponentNode=fe(0).setGroup(xt)}update(e){super.update(e);const{light:t}=this;this.coneCosNode.value=Math.cos(t.angle),this.penumbraCosNode.value=Math.cos(t.angle*(1-t.penumbra)),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}getSpotAttenuation(e){const{coneCosNode:t,penumbraCosNode:i}=this;return Ki(t,i,e)}setup(e){super.setup(e);const t=e.context.lightingModel,{colorNode:i,cutoffDistanceNode:r,decayExponentNode:s,light:a}=this,o=Td(a).sub(Pi),l=o.normalize(),c=l.dot(Qg(a)),u=this.getSpotAttenuation(c),h=o.length(),d=Jg({lightDistance:h,cutoffDistance:r,decayExponent:s}),p=i.mul(u).mul(d),m=e.context.reflectedLight;t.direct({lightDirection:l,lightColor:p,reflectedLight:m},e.stack,e)}}class BS extends s0{static get type(){return"IESSpotLightNode"}getSpotAttenuation(e){const t=this.light.iesMap;let i=null;if(t&&t.isTexture===!0){const r=e.acos().mul(1/Math.PI);i=yt(t,z(r,0),0).r}else i=super.getSpotAttenuation(e);return i}}class zS extends ms{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}class kS extends ms{static get type(){return"HemisphereLightNode"}constructor(e=null){super(e),this.lightPositionNode=Zg(e),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=fe(new xe).setGroup(xt)}update(e){const{light:t}=this;super.update(e),this.lightPositionNode.object3d=t,this.groundColorNode.value.copy(t.groundColor).multiplyScalar(t.intensity)}setup(e){const{colorNode:t,groundColorNode:i,lightDirectionNode:r}=this,s=hr.dot(r).mul(.5).add(.5),a=rt(i,t,s);e.context.irradiance.addAssign(a)}}class HS extends ms{static get type(){return"LightProbeNode"}constructor(e=null){super(e);const t=[];for(let i=0;i<9;i++)t.push(new N);this.lightProbe=mn(t)}update(e){const{light:t}=this;super.update(e);for(let i=0;i<9;i++)this.lightProbe.array[i].copy(t.sh.coefficients[i]).multiplyScalar(t.intensity)}setup(e){const t=US(jh,this.lightProbe);e.context.irradiance.addAssign(t)}}class oF{parseFunction(){console.warn("Abstract function.")}}class GS{constructor(e,t,i="",r=""){this.type=e,this.inputs=t,this.name=i,this.precision=r}getCode(){console.warn("Abstract function.")}}GS.isNodeFunction=!0;const lF=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,cF=/[a-z_0-9]+/ig,WS="#pragma main",uF=n=>{n=n.trim();const e=n.indexOf(WS),t=e!==-1?n.slice(e+WS.length):n,i=t.match(lF);if(i!==null&&i.length===5){const r=i[4],s=[];let a=null;for(;(a=cF.exec(r))!==null;)s.push(a);const o=[];let l=0;for(;l<s.length;){const m=s[l][0]==="const";m===!0&&l++;let v=s[l][0];v==="in"||v==="out"||v==="inout"?l++:v="";const f=s[l++][0];let g=Number.parseInt(s[l][0]);Number.isNaN(g)===!1?l++:g=null;const x=s[l++][0];o.push(new Bg(f,x,g,v,m))}const c=t.substring(i[0].length),u=i[3]!==void 0?i[3]:"",h=i[2],d=i[1]!==void 0?i[1]:"",p=e!==-1?n.slice(0,e):"";return{type:h,inputs:o,name:u,precision:d,inputsCode:r,blockCode:c,headerCode:p}}else throw new Error("FunctionNode: Function is not a GLSL code.")};class hF extends GS{constructor(e){const{type:t,inputs:i,name:r,precision:s,inputsCode:a,blockCode:o,headerCode:l}=uF(e);super(t,i,r,s),this.inputsCode=a,this.blockCode=o,this.headerCode=l}getCode(e=this.name){let t;const i=this.blockCode;if(i!==""){const{type:r,inputsCode:s,headerCode:a,precision:o}=this;let l=`${r} ${e} ( ${s.trim()} )`;o!==""&&(l=`${o} ${l}`),t=a+l+i}else t="";return t}}class jS extends oF{parseFunction(e){return new hF(e)}}class dF{constructor(){this.lightNodes=new WeakMap,this.materialNodes=new Map,this.toneMappingNodes=new Map,this.colorSpaceNodes=new Map}fromMaterial(e){if(e.isNodeMaterial)return e;let t=null;const i=this.getMaterialNodeClass(e.type);if(i!==null){t=new i;for(const r in e)t[r]=e[r]}return t}addColorSpace(e,t){this.addType(e,t,this.colorSpaceNodes)}getColorSpaceFunction(e){return this.colorSpaceNodes.get(e)||null}addToneMapping(e,t){this.addType(e,t,this.toneMappingNodes)}getToneMappingFunction(e){return this.toneMappingNodes.get(e)||null}getMaterialNodeClass(e){return this.materialNodes.get(e)||null}addMaterial(e,t){this.addType(e,t.name,this.materialNodes)}getLightNodeClass(e){return this.lightNodes.get(e)||null}addLight(e,t){this.addClass(e,t,this.lightNodes)}addType(e,t,i){if(i.has(t)){console.warn(`Redefinition of node ${t}`);return}if(typeof e!="function")throw new Error(`Node class ${e.name} is not a class.`);if(typeof t=="function"||typeof t=="object")throw new Error(`Base class ${t} is not a class.`);i.set(t,e)}addClass(e,t,i){if(i.has(t)){console.warn(`Redefinition of node ${t.name}`);return}if(typeof e!="function")throw new Error(`Node class ${e.name} is not a class.`);if(typeof t!="function")throw new Error(`Base class ${t.name} is not a class.`);i.set(t,e)}}class pF extends Al{constructor(e,t,i,r,s,a){super(e,t,i,r,s,a),this.iesMap=null}copy(e,t){return super.copy(e,t),this.iesMap=e.iesMap,this}}class XS extends dF{constructor(){super(),this.addLight(OS,gh),this.addLight(FS,vh),this.addLight(VS,Vm),this.addLight(s0,Al),this.addLight(zS,yh),this.addLight(kS,fh),this.addLight(HS,Bm),this.addLight(BS,pF),this.addToneMapping(xS,Ec),this.addToneMapping(_S,Ac),this.addToneMapping(MS,Kd),this.addToneMapping(bS,Nc),this.addToneMapping(TS,Cc),this.addToneMapping(SS,Rc),this.addColorSpace(yS,zh(nr,Fi)),this.addColorSpace(vS,zh(Fi,nr))}}if(typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Vn}})),typeof window<"u"){try{import.meta&&(window.__THREE__IMPORTS__||(window.__THREE__IMPORTS__=[]),window.__THREE__IMPORTS__.push({url:import.meta.url,revision:Vn}))}catch{}window.__THREE__?(console.warn("WARNING: Multiple instances of Three.js being imported. Existing: "+window.__THREE__+", new: "+Vn),console.warn(window.__THREE__IMPORTS__)):window.__THREE__=Vn}const mF=Object.freeze(Object.defineProperty({__proto__:null,ACESFilmicToneMapping:Nc,AONode:Y1,AddEquation:Bn,AddOperation:Jd,AdditiveAnimationBlendMode:cp,AdditiveBlending:Ao,AfterImageNode:DT,AgXToneMapping:Cc,AlphaFormat:ip,AlwaysCompare:ov,AlwaysDepth:Co,AlwaysStencilFunc:nu,AmbientLight:yh,AmbientLightNode:zS,AnaglyphPassNode:rS,AnalyticLightNode:ms,AnamorphicNode:FT,AnimationAction:yx,AnimationClip:ro,AnimationLoader:DI,AnimationMixer:xx,AnimationObjectGroup:QI,AnimationUtils:RI,ArcCurve:Py,ArrayCamera:$p,ArrayElementNode:as,ArrowHelper:p2,AssignNode:p_,AttachedBindMode:Zd,AttributeNode:Gf,Audio:Gm,AudioAnalyser:GI,AudioContext:Mh,AudioListener:mx,AudioLoader:cx,AxesHelper:zx,BRDF_GGX:mg,BRDF_Lambert:ra,BackSide:si,BasicDepthPacking:up,BasicEnvironmentNode:td,BasicNodeLibrary:XS,BasicShadowMap:ew,BatchNode:V1,BatchedMesh:lm,BloomNode:JT,Bone:Hu,BooleanKeyframeTrack:ks,Box2:s2,Box3:Bi,Box3Helper:Vx,BoxGeometry:yn,BoxHelper:Fx,Break:Qh,BufferAttribute:wt,BufferAttributeNode:bM,BufferGeometry:ct,BufferGeometryLoader:nx,BufferNode:qh,BumpMapNode:n1,BypassNode:AM,ByteType:Qd,Cache:Rn,CacheNode:EM,Camera:ll,CameraHelper:Ox,CanvasTexture:Ly,CapsuleGeometry:Cd,CatmullRomCurve3:Dy,CineonToneMapping:Kd,CircleGeometry:Rd,ClampToEdgeWrapping:gr,Clock:Hm,CodeNode:Rg,Color:xe,ColorKeyframeTrack:ph,ColorManagement:vt,ColorSpaceNode:Xl,CompressedArrayTexture:Ry,CompressedCubeTexture:Iy,CompressedTexture:yl,CompressedTextureLoader:UI,ComputeNode:SM,ConeGeometry:Id,ConstNode:Fr,ConstantAlphaFactor:P0,ConstantColorFactor:I0,ContextNode:Of,Continue:TL,Controls:Hx,ConvertNode:af,CubeCamera:Eu,CubeReflectionMapping:fr,CubeRefractionMapping:Ar,CubeTexture:Cs,CubeTextureLoader:OI,CubeTextureNode:JM,CubeUVReflectionMapping:xs,CubicBezierCurve:ym,CubicBezierCurve3:Oy,CubicInterpolant:$y,CullFaceBack:Hd,CullFaceFront:y0,CullFaceFrontBack:QS,CullFaceNone:v0,Curve:Or,CurvePath:Vy,CustomBlending:qd,CustomToneMapping:U0,CylinderGeometry:da,Cylindrical:n2,DFGApprox:fg,D_GGX:db,Data3DTexture:lu,DataArrayTexture:tl,DataTexture:Ur,DataTextureLoader:Zy,DataUtils:wv,DecrementStencilOp:j0,DecrementWrapStencilOp:q0,DefaultLoadingManager:Dm,DenoiseNode:qT,DepthFormat:Xn,DepthOfFieldNode:BT,DepthStencilFormat:qn,DepthTexture:Us,DetachedBindMode:O0,DirectionalLight:vh,DirectionalLightHelper:Ux,DirectionalLightNode:FS,Discard:LM,DiscreteInterpolant:Jy,DisplayP3ColorSpace:Yo,DodecahedronGeometry:Ld,DotScreenNode:zT,DoubleSide:Gr,DstAlphaFactor:E0,DstColorFactor:N0,DynamicCopyUsage:dw,DynamicDrawUsage:bs,DynamicReadUsage:cw,EPSILON:P_,EdgesGeometry:Sm,EllipseCurve:Zu,EnvironmentNode:Vb,EqualCompare:rv,EqualDepth:Io,EqualStencilFunc:K0,EquirectUVNode:sb,EquirectangularReflectionMapping:kn,EquirectangularRefractionMapping:Hn,Euler:dr,EventDispatcher:vr,ExpressionNode:IM,ExtrudeGeometry:yc,FXAANode:YT,F_Schlick:vo,FileLoader:Kr,FilmNode:HT,Float16BufferAttribute:Ev,Float32BufferAttribute:De,FloatType:Oi,Fn:U,Fog:Kp,FogExp2:Nd,FogExp2Node:uS,FogNode:_d,FogRangeNode:cS,FramebufferTexture:pm,FrontFacingNode:kM,FrontSide:an,Frustum:ka,FunctionCallNode:f_,FunctionNode:Ig,FunctionOverloadingNode:hT,GLBufferAttribute:r2,GLSL1:mw,GLSL3:su,GLSLNodeParser:jS,GTAONode:XT,GaussianBlurNode:LT,GreaterCompare:nv,GreaterDepth:Po,GreaterEqualCompare:av,GreaterEqualDepth:Lo,GreaterEqualStencilFunc:tv,GreaterStencilFunc:Q0,GridHelper:Lx,Group:Os,HalfFloatType:wi,HemisphereLight:fh,HemisphereLightHelper:u2,HemisphereLightNode:kS,IESSpotLightNode:BS,INFINITY:V2,IcosahedronGeometry:Pd,If:Le,ImageBitmapLoader:lx,ImageLoader:El,ImageUtils:mv,IncrementStencilOp:W0,IncrementWrapStencilOp:X0,IndexNode:Bt,InstanceNode:O1,InstancedBufferAttribute:Nn,InstancedBufferGeometry:zm,InstancedInterleavedBuffer:Xm,InstancedMesh:nm,InstancedPointsNodeMaterial:VL,Int16BufferAttribute:Zw,Int32BufferAttribute:Qw,Int8BufferAttribute:$w,IntType:va,InterleavedBuffer:ja,InterleavedBufferAttribute:On,Interpolant:Qa,InterpolateDiscrete:ba,InterpolateLinear:Xo,InterpolateSmooth:iu,InvertStencilOp:Y0,IrradianceNode:K1,JoinNode:Xx,KeepStencilOp:Yn,KeyframeTrack:Jr,LOD:em,LatheGeometry:vc,Layers:nl,LessCompare:pp,LessDepth:Ro,LessEqualCompare:mp,LessEqualDepth:zn,LessEqualStencilFunc:Z0,LessStencilFunc:J0,Light:ns,LightProbe:Bm,LightProbeNode:HS,LightingContextNode:$1,LightingModel:cc,LightingNode:ia,LightsNode:X1,Line:Cn,Line2NodeMaterial:WL,Line3:Ax,LineBasicMaterial:Ni,LineBasicNodeMaterial:zL,LineCurve:xm,LineCurve3:Fy,LineDashedMaterial:dh,LineDashedNodeMaterial:HL,LineLoop:um,LineSegments:$r,LinearDisplayP3ColorSpace:Ta,LinearFilter:Lt,LinearInterpolant:Pm,LinearMipMapLinearFilter:F0,LinearMipMapNearestFilter:rw,LinearMipmapLinearFilter:ji,LinearMipmapNearestFilter:Wn,LinearSRGBColorSpace:nr,LinearToneMapping:Ec,LinearTransfer:$o,Loader:Hi,LoaderUtils:xh,LoadingManager:mh,Loop:gt,LoopNode:H1,LoopOnce:op,LoopPingPong:V0,LoopRepeat:lp,LuminanceAlphaFormat:sp,LuminanceFormat:np,Lut3DNode:GT,MOUSE:f0,MRTNode:uT,MatcapUVNode:Hb,Material:hi,MaterialLoader:Mc,MaterialNode:Z,MaterialReferenceNode:KM,MathUtils:au,Matrix2:a0,Matrix3:Ke,Matrix4:Re,MaxEquation:Yd,MaxMipLevelNode:OM,Mesh:Ft,MeshBasicMaterial:Yr,MeshBasicNodeMaterial:QL,MeshDepthMaterial:Uu,MeshDistanceMaterial:qp,MeshLambertMaterial:hh,MeshLambertNodeMaterial:nP,MeshMatcapMaterial:Rm,MeshMatcapNodeMaterial:HP,MeshNormalMaterial:uh,MeshNormalNodeMaterial:qL,MeshPhongMaterial:ch,MeshPhongNodeMaterial:aP,MeshPhysicalMaterial:lh,MeshPhysicalNodeMaterial:kb,MeshSSSNodeMaterial:OP,MeshStandardMaterial:wl,MeshStandardNodeMaterial:zb,MeshToonMaterial:Cm,MeshToonNodeMaterial:zP,MinEquation:M0,MirroredRepeatWrapping:fa,MixOperation:$d,ModelNode:tn,ModelViewProjectionNode:P1,MorphNode:W1,MultiplyBlending:Xd,MultiplyOperation:ma,NearestFilter:$t,NearestMipMapLinearFilter:iw,NearestMipMapNearestFilter:tw,NearestMipmapLinearFilter:Mn,NearestMipmapNearestFilter:Lc,NeutralToneMapping:Rc,NeverCompare:iv,NeverDepth:No,NeverStencilFunc:$0,NoBlending:Er,NoColorSpace:Cr,NoToneMapping:mr,Node:qe,NodeAttribute:Ag,NodeBuilder:lT,NodeCache:cd,NodeCode:Kb,NodeFrame:cT,NodeFunctionInput:Bg,NodeLoader:qb,NodeMaterial:bt,NodeMaterialLoader:Yb,NodeMaterialObserver:Gx,NodeObjectLoader:ZP,NodeShaderStage:tf,NodeType:v2,NodeUniform:$b,NodeUpdateType:je,NodeUtils:g2,NodeVar:Ng,NodeVarying:Jb,NormalAnimationBlendMode:ru,NormalBlending:_n,NormalMapNode:r1,NotEqualCompare:sv,NotEqualDepth:Do,NotEqualStencilFunc:ev,NumberKeyframeTrack:eo,Object3D:_t,Object3DNode:St,ObjectLoader:sx,ObjectSpaceNormalMap:dp,OctahedronGeometry:wo,OneFactor:T0,OneMinusConstantAlphaFactor:D0,OneMinusConstantColorFactor:L0,OneMinusDstAlphaFactor:A0,OneMinusDstColorFactor:C0,OneMinusSrcAlphaFactor:wc,OneMinusSrcColorFactor:w0,OrthographicCamera:Ls,OscNode:gi,OutputStructNode:zg,P3Primaries:Ko,PCFShadowMap:Gd,PCFSoftShadowMap:Wd,PI:Qs,PI2:B2,PMREMGenerator:Ru,PMREMNode:Ub,ParallaxBarrierPassNode:nS,ParameterNode:Cg,PassNode:Ti,Path:Ml,PerspectiveCamera:di,PhongLightingModel:dg,PhysicalLightingModel:nd,PixelationPassNode:ZT,Plane:ln,PlaneGeometry:ha,PlaneHelper:d2,PointLight:gh,PointLightHelper:l2,PointLightNode:OS,PointUVNode:MT,Points:dm,PointsMaterial:Ka,PointsNodeMaterial:WP,PolarGridHelper:h2,PolyhedronGeometry:fs,PositionalAudio:gx,PosterizeNode:ET,PropertyBinding:Tt,PropertyMixer:vx,PropertyNode:Et,QuadraticBezierCurve:_m,QuadraticBezierCurve3:Mm,Quaternion:qi,QuaternionKeyframeTrack:to,QuaternionLinearInterpolant:Ky,RED_GREEN_RGTC2_Format:eu,RED_RGTC1_Format:ap,REVISION:Vn,RGBADepthPacking:hp,RGBAFormat:Ei,RGBAIntegerFormat:Oc,RGBA_ASTC_10x10_Format:Yc,RGBA_ASTC_10x5_Format:jc,RGBA_ASTC_10x6_Format:Xc,RGBA_ASTC_10x8_Format:qc,RGBA_ASTC_12x10_Format:$c,RGBA_ASTC_12x12_Format:Jc,RGBA_ASTC_4x4_Format:Wo,RGBA_ASTC_5x4_Format:Bc,RGBA_ASTC_5x5_Format:zc,RGBA_ASTC_6x5_Format:kc,RGBA_ASTC_6x6_Format:jo,RGBA_ASTC_8x5_Format:Hc,RGBA_ASTC_8x6_Format:Gc,RGBA_ASTC_8x8_Format:Wc,RGBA_BPTC_Format:Ma,RGBA_ETC2_EAC_Format:Go,RGBA_PVRTC_2BPPV1_Format:Vc,RGBA_PVRTC_4BPPV1_Format:zo,RGBA_S3TC_DXT1_Format:xa,RGBA_S3TC_DXT3_Format:Vo,RGBA_S3TC_DXT5_Format:_a,RGBDepthPacking:sw,RGBFormat:rp,RGBIntegerFormat:nw,RGBShiftNode:kT,RGB_BPTC_SIGNED_Format:Kc,RGB_BPTC_UNSIGNED_Format:Zc,RGB_ETC1_Format:ko,RGB_ETC2_Format:Ho,RGB_PVRTC_2BPPV1_Format:Fc,RGB_PVRTC_4BPPV1_Format:Bo,RGB_S3TC_DXT1_Format:Fo,RGDepthPacking:aw,RGFormat:ya,RGIntegerFormat:Uc,RTTNode:yT,RangeNode:hS,RawShaderMaterial:Nm,Ray:As,Raycaster:bx,Rec709Primaries:Jo,RectAreaLight:Vm,RectAreaLightNode:VS,RedFormat:Uo,RedIntegerFormat:Oo,ReferenceNode:Kl,ReflectorNode:vT,ReinhardToneMapping:Ac,RemapNode:Hf,RenderOutputNode:PM,RenderTarget:ui,RendererReferenceNode:vM,RepeatWrapping:Gn,ReplaceStencilOp:G0,Return:W2,ReverseSubtractEquation:_0,RingGeometry:xc,RotateNode:Wb,SIGNED_RED_GREEN_RGTC2_Format:tu,SIGNED_RED_RGTC1_Format:Qc,SRGBColorSpace:Fi,SRGBTransfer:Ot,SSAAPassNode:QT,Scene:Ou,SceneNode:sn,Schlick_to_F0:mb,ScreenNode:ri,ScriptableNode:lS,ScriptableValueNode:aS,SetNode:qx,ShaderChunk:dt,ShaderLib:Dr,ShaderMaterial:Pr,ShaderNode:Ll,ShadowMaterial:oh,ShadowNodeMaterial:$P,Shape:rs,ShapeGeometry:Dd,ShapePath:kx,ShapeUtils:nn,ShortType:ep,Skeleton:gc,SkeletonHelper:o2,SkinnedMesh:rm,SkinningNode:ng,SobelOperatorNode:VT,Source:$n,Sphere:Ai,SphereGeometry:Eo,Spherical:Sx,SphericalHarmonics3:rx,SplineCurve:bm,SplitNode:Nh,SpotLight:Al,SpotLightHelper:a2,SpotLightNode:s0,Sprite:Qp,SpriteMaterial:ul,SpriteNodeMaterial:XP,SpriteSheetUVNode:dT,SrcAlphaFactor:Sc,SrcAlphaSaturateFactor:R0,SrcColorFactor:S0,StackNode:Qb,StaticCopyUsage:hw,StaticDrawUsage:Sa,StaticReadUsage:lw,StereoCamera:km,StereoPassNode:eS,StorageArrayElementNode:pT,StorageBufferNode:qg,StorageTextureNode:TT,StreamCopyUsage:pw,StreamDrawUsage:ow,StreamReadUsage:uw,StringKeyframeTrack:Hs,SubtractEquation:x0,SubtractiveBlending:jd,TBNViewMatrix:ta,TOUCH:g0,TangentSpaceNormalMap:on,TempNode:pt,TetrahedronGeometry:Ud,Texture:Wt,Texture3DNode:jb,TextureLoader:Qy,TextureNode:dn,TextureSizeNode:UM,TextureUtils:UR,TimerNode:Si,ToneMappingNode:xM,ToonOutlinePassNode:sS,TorusGeometry:_c,TorusKnotGeometry:Od,TransitionNode:KT,Triangle:er,TriangleFanDrawMode:k0,TriangleStripDrawMode:z0,TrianglesDrawMode:B0,TriplanarTexturesNode:mT,TubeGeometry:Fd,UVMapping:Ic,Uint16BufferAttribute:yu,Uint32BufferAttribute:Dp,Uint8BufferAttribute:Jw,Uint8ClampedBufferAttribute:Kw,Uniform:_x,UniformArrayNode:Yf,UniformGroupNode:ff,UniformNode:$s,UniformsGroup:i2,UniformsLib:Me,UniformsUtils:Fp,UnsignedByteType:Wr,UnsignedInt248Type:jn,UnsignedInt5999Type:tp,UnsignedIntType:Nr,UnsignedShort4444Type:Pc,UnsignedShort5551Type:Dc,UnsignedShortType:ga,UserDataNode:wT,VSMShadowMap:rr,V_GGX_SmithCorrelated:hb,VarNode:uM,VaryingNode:hM,Vector2:J,Vector3:N,Vector4:st,VectorKeyframeTrack:io,VertexColorNode:_T,VideoTexture:Cy,ViewportDepthNode:Qi,ViewportDepthTextureNode:tb,ViewportSharedTextureNode:AT,ViewportTextureNode:ac,VolumeNodeMaterial:KP,WebGL3DRenderTarget:Bw,WebGLArrayRenderTarget:Vw,WebGLCoordinateSystem:Rr,WebGLCubeRenderTarget:Au,WebGLMultipleRenderTargets:m2,WebGLRenderTarget:Ir,WebGLRenderer:ly,WebGLUtils:oy,WebGPUCoordinateSystem:Ts,WireframeGeometry:Am,WrapAroundEnding:qo,ZeroCurvatureEnding:_s,ZeroFactor:b0,ZeroSlopeEnding:Ms,ZeroStencilOp:H0,abs:It,acesFilmicToneMapping:bS,acos:Vh,add:zt,addMethodChaining:te,addNodeElement:j2,afterImage:oD,agxToneMapping:TS,all:Af,alphaT:Dh,anaglyphPass:GD,anamorphic:pD,and:b_,anisotropy:ls,anisotropyB:Ks,anisotropyT:Vl,any:D_,ao:TD,append:t_,arrayBuffer:D2,asin:z_,assign:m_,atan:k_,atan2:J_,atomicAdd:kU,atomicAnd:jU,atomicFunc:Un,atomicMax:GU,atomicMin:WU,atomicOr:XU,atomicStore:zU,atomicSub:HU,atomicXor:qU,attenuationColor:Tf,attenuationDistance:bf,attribute:_i,backgroundBlurriness:$3,backgroundIntensity:J3,batch:B1,billboarding:dU,bitAnd:E_,bitNot:A_,bitOr:N_,bitXor:C_,bitangentGeometry:hL,bitangentLocal:dL,bitangentView:QM,bitangentWorld:pL,bitcast:z2,bleach:MU,bloom:LD,blur:Pb,bool:os,buffer:Jl,bufferAttribute:ql,bumpMap:s1,burn:gU,bvec2:n_,bvec3:mf,bvec4:l_,bypass:NM,cache:Yl,call:g_,cameraFar:uo,cameraLogDepth:VM,cameraNear:co,cameraNormalMatrix:$2,cameraPosition:Wf,cameraProjectionMatrix:lr,cameraProjectionMatrixInverse:q2,cameraViewMatrix:cr,cameraWorldMatrix:Y2,cbrt:rM,ceil:Rf,checker:YU,cineonToneMapping:MS,clamp:li,clearcoat:Ih,clearcoatRoughness:Fl,code:ud,color:i_,colorSpaceToWorking:zf,colorToDirection:jL,compute:wM,cond:lM,context:Ff,convert:u_,convertToTexture:Zi,cos:br,createCanvasElement:uv,cross:lo,cubeTexture:Xh,dFdx:W_,dFdy:j_,dashSize:Zs,defaultBuildStages:nf,defaultShaderStages:rf,defined:Il,degrees:F_,denoise:ED,densityFog:JD,depth:ug,depthPass:sD,difference:Q_,diffuseColor:Nt,directionToColor:nb,dispersion:Sf,distance:Z_,div:Qr,dodge:vU,dof:fD,dot:qt,dotScreen:gD,drawIndex:U1,dynamicBufferAttribute:TM,element:c_,emissive:vf,equal:v_,equals:U_,equirectUV:hg,exp:Nf,exp2:Fh,expression:hs,faceDirection:$l,faceForward:sM,film:yD,float:E,floor:cs,fog:YD,fract:us,frameGroup:O2,frameId:D3,frontFacing:HM,fwidth:Y_,fxaa:AD,gain:aU,gapSize:zl,gaussianBlur:aD,getColorSpaceMethod:zh,getConstNodeType:e_,getCurrentStack:pf,getDirection:Ib,getDistanceAttenuation:Jg,getGeometryRoughness:ub,getRoughness:pg,getShIrradianceAt:US,getTextureIndex:kg,global:xd,glsl:r3,glslFn:n3,grayscale:lD,greaterThan:Ef,greaterThanEqual:M_,hash:sU,highPrecisionModelNormalViewMatrix:aL,highPrecisionModelViewMatrix:sL,hue:hD,instance:F1,instanceIndex:ic,instancedBufferAttribute:kh,instancedDynamicBufferAttribute:kf,int:P,inverseSqrt:V_,invocationLocalIndex:ML,invocationSubgroupIndex:_L,ior:kl,iridescence:Ph,iridescenceIOR:yf,iridescenceThickness:xf,ivec2:un,ivec3:s_,ivec4:a_,js:t3,label:cM,length:ea,lengthSq:Pf,lessThan:x_,lessThanEqual:__,lightPosition:Zg,lightTargetDirection:Qg,lightTargetPosition:dS,lightViewPosition:Td,lightingContext:J1,lights:q1,linearDepth:ed,linearSRGBTosRGB:yS,linearToneMapping:xS,localId:RU,log:Cf,log2:Hl,loop:SL,luminance:Ui,lut3D:xD,mat2:Ul,mat3:yi,mat4:Ys,matcapUV:Gb,materialAOMap:L1,materialAlphaTest:o1,materialAnisotropy:M1,materialAnisotropyVector:mo,materialAttenuationColor:C1,materialAttenuationDistance:N1,materialClearcoat:f1,materialClearcoatNormal:v1,materialClearcoatRoughness:g1,materialColor:po,materialDispersion:I1,materialEmissive:c1,materialIOR:A1,materialIridescence:b1,materialIridescenceIOR:T1,materialIridescenceThickness:S1,materialLightMap:ig,materialLineDashOffset:tg,materialLineDashSize:Qf,materialLineGapSize:eg,materialLineScale:Kh,materialLineWidth:Zh,materialMetalness:p1,materialNormal:m1,materialOpacity:$h,materialPointWidth:R1,materialReference:rn,materialReflectivity:Jh,materialRefractionRatio:jM,materialRotation:y1,materialRoughness:d1,materialSheen:x1,materialSheenRoughness:_1,materialShininess:l1,materialSpecular:u1,materialSpecularColor:h1,materialSpecularIntensity:Zf,materialSpecularStrength:tc,materialThickness:E1,materialTransmission:w1,max:ft,maxMipLevel:FM,metalness:Ol,min:xi,mix:rt,mixElement:aM,mod:Bh,modInt:wf,modelDirection:tL,modelNormalMatrix:BM,modelPosition:iL,modelScale:rL,modelViewMatrix:pn,modelViewPosition:nL,modelViewProjection:rg,modelWorldMatrix:Br,modelWorldMatrixInverse:zM,morphReference:j1,motionBlur:_U,mrt:md,mul:lt,mx_aastep:LS,mx_cell_noise_float:iF,mx_contrast:$O,mx_fractal_noise_float:rF,mx_fractal_noise_vec2:nF,mx_fractal_noise_vec3:sF,mx_fractal_noise_vec4:aF,mx_hsvtorgb:zO,mx_noise_float:JO,mx_noise_vec3:KO,mx_noise_vec4:ZO,mx_ramplr:GO,mx_ramptb:WO,mx_rgbtohsv:kO,mx_safepower:YO,mx_splitlr:jO,mx_splittb:XO,mx_srgb_texture_to_lin_rec709:HO,mx_transform_uv:qO,mx_worley_noise_float:QO,mx_worley_noise_vec2:eF,mx_worley_noise_vec3:tF,negate:H_,neutralToneMapping:SS,nodeArray:qs,nodeImmutable:ge,nodeObject:G,nodeObjects:Pl,nodeProxy:K,normalFlat:GM,normalGeometry:Wh,normalLocal:ur,normalMap:Kf,normalView:hr,normalWorld:jh,normalize:Mr,not:S_,notEqual:y_,numWorkgroups:NU,objectDirection:J2,objectGroup:d_,objectPosition:Z2,objectScale:Q2,objectViewPosition:eL,objectWorldMatrix:K2,oneMinus:G_,or:T_,orthographicDepthToViewZ:PL,oscSawtooth:V3,oscSine:U3,oscSquare:O3,oscTriangle:F3,output:_f,outputStruct:R3,overlay:xU,overloadingFn:Di,parabola:e0,parallaxBarrierPass:WD,parallaxDirection:t1,parallaxUV:fL,parameter:e3,pass:nD,passTexture:bo,pcurve:oU,perspectiveDepthToViewZ:cg,pixelationPass:OD,pmremTexture:Ob,pointUV:Y3,pointWidth:F2,positionGeometry:Li,positionLocal:Zt,positionPrevious:Hh,positionView:Pi,positionViewDirection:Vt,positionWorld:Gh,positionWorldDirection:jf,posterize:tD,pow:Ji,pow2:Lf,pow3:eM,pow4:tM,property:ar,radians:O_,rand:Uf,range:KD,rangeFog:$D,reciprocal:q_,reference:fi,referenceBuffer:$f,reflect:K_,reflectVector:YM,reflectView:XM,reflector:G3,refract:Df,refractVector:$M,refractView:qM,reinhardToneMapping:_S,remainder:L_,remap:CM,remapClamp:RM,renderGroup:xt,renderOutput:DM,rendererReference:yM,rgbShift:vD,rotate:Eg,rotateUV:uU,roughness:hn,round:X_,rtt:xT,sRGBToLinearSRGB:vS,sampler:X2,saturate:nM,saturation:cD,screen:yU,screenCoordinate:go,screenSize:fo,screenUV:ps,scriptable:qD,scriptableValue:yd,select:Ri,sepia:bU,setCurrentStack:Dl,shaderStages:sf,sharedUniformGroup:gf,sheen:Js,sheenRoughness:Lh,shiftLeft:R_,shiftRight:I_,shininess:Uh,sign:Gl,sin:Ci,sinc:lU,skinning:bL,skinningReference:k1,smoothstep:Ki,smoothstepElement:oM,sobel:mD,specularColor:or,specularF90:Bl,spherizeUV:hU,split:U2,spritesheetUV:B3,sqrt:en,ssaaPass:BD,stack:hd,step:Wl,stereoPass:kD,storage:K3,storageBarrier:DU,storageObject:Z3,storageTexture:ST,string:P2,sub:Pt,subgroupIndex:xL,subgroupSize:IU,tan:B_,tangentGeometry:Yh,tangentLocal:Zl,tangentView:Ql,tangentWorld:ZM,temp:Vf,texture:yt,texture3D:Xb,textureBarrier:UU,textureBicubic:Tb,textureCubeUV:Lb,textureLoad:Vr,textureSize:ds,textureStore:Q3,thickness:Mf,threshold:UT,timerDelta:P3,timerGlobal:L3,timerLocal:Hg,toOutputColorSpace:pM,toWorkingColorSpace:mM,toneMapping:_M,toneMappingExposure:MM,toonOutlinePass:jD,transformDirection:iM,transformNormal:WM,transformNormalToView:qf,transformedBentNormalView:i1,transformedBitangentView:e1,transformedBitangentWorld:mL,transformedClearcoatNormalView:ho,transformedNormalView:Yt,transformedNormalWorld:Xf,transformedTangentView:Jf,transformedTangentWorld:uL,transition:PD,transmission:Oh,transpose:$_,tri:gn,tri3:pS,triNoise3D:cU,triplanarTexture:k3,triplanarTextures:fT,trunc:If,tslFn:L2,uint:_e,uniform:fe,uniformArray:mn,uniformGroup:h_,uniforms:lL,userData:eD,uv:nt,uvec2:r_,uvec3:oo,uvec4:o_,varying:Ii,varyingProperty:Zr,vec2:z,vec3:D,vec4:ae,vectorComponents:no,velocity:fU,vertexColor:q3,vertexIndex:D1,vibrance:uD,viewZToOrthographicDepth:oc,viewZToPerspectiveDepth:ib,viewport:Pn,viewportBottomLeft:IL,viewportCoordinate:Q1,viewportDepthTexture:lg,viewportLinearDepth:DL,viewportMipTexture:eb,viewportResolution:CL,viewportSafeUV:pU,viewportSharedTexture:iD,viewportSize:Z1,viewportTexture:LL,viewportTopLeft:RL,viewportUV:NL,wgsl:i3,wgslFn:s3,workgroupArray:VU,workgroupBarrier:PU,workgroupId:CU,workingToColorSpace:fM,xor:w_},Symbol.toStringTag,{value:"Module"}));export{Nc as ACESFilmicToneMapping,Ao as AdditiveBlending,Cc as AgXToneMapping,Co as AlwaysDepth,nu as AlwaysStencilFunc,yh as AmbientLight,ro as AnimationClip,xx as AnimationMixer,$p as ArrayCamera,Gm as Audio,Mh as AudioContext,mx as AudioListener,cx as AudioLoader,zx as AxesHelper,si as BackSide,up as BasicDepthPacking,XS as BasicNodeLibrary,lm as BatchedMesh,Hu as Bone,Bi as Box3,Vx as Box3Helper,yn as BoxGeometry,Fx as BoxHelper,wt as BufferAttribute,ct as BufferGeometry,ll as Camera,Ox as CameraHelper,Ly as CanvasTexture,gr as ClampToEdgeWrapping,Hm as Clock,xe as Color,ph as ColorKeyframeTrack,vt as ColorManagement,Ry as CompressedArrayTexture,Iy as CompressedCubeTexture,yl as CompressedTexture,Hx as Controls,Eu as CubeCamera,Cs as CubeTexture,Or as Curve,qd as CustomBlending,da as CylinderGeometry,lu as Data3DTexture,Ur as DataTexture,Zy as DataTextureLoader,wv as DataUtils,j0 as DecrementStencilOp,q0 as DecrementWrapStencilOp,Dm as DefaultLoadingManager,Xn as DepthFormat,qn as DepthStencilFormat,Us as DepthTexture,vh as DirectionalLight,Ux as DirectionalLightHelper,Yo as DisplayP3ColorSpace,Gr as DoubleSide,bs as DynamicDrawUsage,Sm as EdgesGeometry,Io as EqualDepth,K0 as EqualStencilFunc,kn as EquirectangularReflectionMapping,Hn as EquirectangularRefractionMapping,dr as Euler,vr as EventDispatcher,yc as ExtrudeGeometry,Kr as FileLoader,De as Float32BufferAttribute,Oi as FloatType,Kp as Fog,an as FrontSide,ka as Frustum,su as GLSL3,jS as GLSLNodeParser,Po as GreaterDepth,Lo as GreaterEqualDepth,tv as GreaterEqualStencilFunc,Q0 as GreaterStencilFunc,Lx as GridHelper,Os as Group,wi as HalfFloatType,fh as HemisphereLight,lx as ImageBitmapLoader,W0 as IncrementStencilOp,X0 as IncrementWrapStencilOp,Nn as InstancedBufferAttribute,zm as InstancedBufferGeometry,Xm as InstancedInterleavedBuffer,nm as InstancedMesh,ja as InterleavedBuffer,On as InterleavedBufferAttribute,Qa as Interpolant,ba as InterpolateDiscrete,Xo as InterpolateLinear,Y0 as InvertStencilOp,Yn as KeepStencilOp,em as LOD,nl as Layers,Ro as LessDepth,zn as LessEqualDepth,Z0 as LessEqualStencilFunc,J0 as LessStencilFunc,Cn as Line,Ax as Line3,Ni as LineBasicMaterial,um as LineLoop,$r as LineSegments,Ta as LinearDisplayP3ColorSpace,Lt as LinearFilter,ji as LinearMipmapLinearFilter,Wn as LinearMipmapNearestFilter,nr as LinearSRGBColorSpace,Ec as LinearToneMapping,Hi as Loader,xh as LoaderUtils,mh as LoadingManager,op as LoopOnce,lp as LoopRepeat,f0 as MOUSE,hi as Material,au as MathUtils,Ke as Matrix3,Re as Matrix4,Yd as MaxEquation,Ft as Mesh,Yr as MeshBasicMaterial,Uu as MeshDepthMaterial,hh as MeshLambertMaterial,uh as MeshNormalMaterial,ch as MeshPhongMaterial,lh as MeshPhysicalMaterial,wl as MeshStandardMaterial,fa as MirroredRepeatWrapping,$t as NearestFilter,Mn as NearestMipmapLinearFilter,Lc as NearestMipmapNearestFilter,Rc as NeutralToneMapping,No as NeverDepth,$0 as NeverStencilFunc,Er as NoBlending,Cr as NoColorSpace,mr as NoToneMapping,qe as Node,lT as NodeBuilder,cT as NodeFrame,_n as NormalBlending,Do as NotEqualDepth,ev as NotEqualStencilFunc,eo as NumberKeyframeTrack,_t as Object3D,wo as OctahedronGeometry,Ls as OrthographicCamera,Wd as PCFSoftShadowMap$1,Ru as PMREMGenerator$1,di as PerspectiveCamera,ln as Plane,ha as PlaneGeometry,gh as PointLight,dm as Points,Ka as PointsMaterial,gx as PositionalAudio,Tt as PropertyBinding,qi as Quaternion,to as QuaternionKeyframeTrack,Vn as REVISION,hp as RGBADepthPacking,Ei as RGBAFormat,Wo as RGBA_ASTC_4x4_Format,jo as RGBA_ASTC_6x6_Format,Ma as RGBA_BPTC_Format,Go as RGBA_ETC2_EAC_Format,zo as RGBA_PVRTC_4BPPV1_Format,xa as RGBA_S3TC_DXT1_Format,_a as RGBA_S3TC_DXT5_Format,ko as RGB_ETC1_Format,Ho as RGB_ETC2_Format,Bo as RGB_PVRTC_4BPPV1_Format,ya as RGFormat,Nm as RawShaderMaterial,As as Ray,bx as Raycaster,Uo as RedFormat,Ac as ReinhardToneMapping,Gn as RepeatWrapping,G0 as ReplaceStencilOp,xc as RingGeometry,Fi as SRGBColorSpace,Ou as Scene,dt as ShaderChunk,Dr as ShaderLib,Pr as ShaderMaterial,oh as ShadowMaterial,rs as Shape,kx as ShapePath,nn as ShapeUtils,gc as Skeleton,rm as SkinnedMesh,$n as Source,Ai as Sphere,Eo as SphereGeometry,Sx as Spherical,Al as SpotLight,Qp as Sprite,ul as SpriteMaterial,mF as THREE,g0 as TOUCH,Wt as Texture,Qy as TextureLoader,_c as TorusGeometry,er as Triangle,k0 as TriangleFanDrawMode,z0 as TriangleStripDrawMode,B0 as TrianglesDrawMode,yu as Uint16BufferAttribute,_x as Uniform$1,Me as UniformsLib,Fp as UniformsUtils,Wr as UnsignedByteType,jn as UnsignedInt248Type,Nr as UnsignedIntType,J as Vector2,N as Vector3,st as Vector4,io as VectorKeyframeTrack,Cy as VideoTexture,Au as WebGLCubeRenderTarget,Ir as WebGLRenderTarget,ly as WebGLRenderer,Am as WireframeGeometry,H0 as ZeroStencilOp,rf as defaultShaderStages,hr as normalView};
|
|
3873
|
+
return { ...output, `+t+" };",s=i+this.codeNode.code+r;return this._method=new Function(...e,s),this._method}dispose(){this._method!==null&&(this._object&&typeof this._object.dispose=="function"&&this._object.dispose(),this._method=null,this._object=null,this._source=null,this._value=null,this._needsOutputUpdate=!0,this._output.value=null,this._outputs={})}setup(){return this.getDefaultOutputNode()}getCacheKey(e){const t=[Gx(this.source),this.getDefaultOutputNode().getCacheKey(e)];for(const i in this.parameters)t.push(this.parameters[i].getCacheKey(e));return Wx(t)}set needsUpdate(e){e===!0&&this.dispose()}get needsUpdate(){return this.source!==this._source}_exec(){return this.codeNode===null?this:(this._needsOutputUpdate===!0&&(this._value=this.call("main"),this._needsOutputUpdate=!1),this._output.value=this._value,this)}_refresh(){this.needsUpdate=!0,this._exec(),this._output.refresh()}}const qD=K(oS);class xd extends qe{static get type(){return"FogNode"}constructor(e,t){super("float"),this.isFogNode=!0,this.colorNode=e,this.factorNode=t}getViewZNode(e){let t;const i=e.context.getViewZ;return i!==void 0&&(t=i(this)),(t||Pi.z).negate()}setup(){return this.factorNode}}const YD=K(xd);class lS extends xd{static get type(){return"FogRangeNode"}constructor(e,t,i){super(e),this.isFogRangeNode=!0,this.nearNode=t,this.farNode=i}setup(e){const t=this.getViewZNode(e);return Ki(this.nearNode,this.farNode,t)}}const $D=K(lS);class cS extends xd{static get type(){return"FogExp2Node"}constructor(e,t){super(e),this.isFogExp2Node=!0,this.densityNode=t}setup(e){const t=this.getViewZNode(e),i=this.densityNode;return i.mul(i,t,t).negate().exp().oneMinus()}}const JD=K(cS);let la=null,ca=null;class uS extends qe{static get type(){return"RangeNode"}constructor(e=E(),t=E()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){const t=e.getTypeLength(Ln(this.minNode.value)),i=e.getTypeLength(Ln(this.maxNode.value));return t>i?t:i}getNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):"float"}setup(e){const t=e.object;let i=null;if(t.count>1){const r=this.minNode.value,s=this.maxNode.value,a=e.getTypeLength(Ln(r)),o=e.getTypeLength(Ln(s));la=la||new st,ca=ca||new st,la.setScalar(0),ca.setScalar(0),a===1?la.setScalar(r):r.isColor?la.set(r.r,r.g,r.b):la.set(r.x,r.y,r.z||0,r.w||0),o===1?ca.setScalar(s):s.isColor?ca.set(s.r,s.g,s.b):ca.set(s.x,s.y,s.z||0,s.w||0);const l=4,c=l*t.count,u=new Float32Array(c);for(let d=0;d<c;d++){const p=d%l,m=la.getComponent(p),v=ca.getComponent(p);u[d]=su.lerp(m,v,Math.random())}const h=this.getNodeType(e);if(t.count<=4096)i=$l(u,"vec4",t.count).element(tc).convert(h);else{const d=new Nn(u,4);e.geometry.setAttribute("__range"+this.id,d),i=zh(d).convert(h)}}else i=E(0);return i}}const KD=K(uS),ZD=U(({depthTexture:n,shadowCoord:e})=>yt(n,e.xy).compare(e.z)),QD=U(({depthTexture:n,shadowCoord:e,shadow:t})=>{const i=(v,f)=>yt(n,v).compare(f),r=fi("mapSize","vec2",t).setGroup(xt),s=fi("radius","float",t).setGroup(xt),a=z(1).div(r),o=a.x.negate().mul(s),l=a.y.negate().mul(s),c=a.x.mul(s),u=a.y.mul(s),h=o.div(2),d=l.div(2),p=c.div(2),m=u.div(2);return zt(i(e.xy.add(z(o,l)),e.z),i(e.xy.add(z(0,l)),e.z),i(e.xy.add(z(c,l)),e.z),i(e.xy.add(z(h,d)),e.z),i(e.xy.add(z(0,d)),e.z),i(e.xy.add(z(p,d)),e.z),i(e.xy.add(z(o,0)),e.z),i(e.xy.add(z(h,0)),e.z),i(e.xy,e.z),i(e.xy.add(z(p,0)),e.z),i(e.xy.add(z(c,0)),e.z),i(e.xy.add(z(h,m)),e.z),i(e.xy.add(z(0,m)),e.z),i(e.xy.add(z(p,m)),e.z),i(e.xy.add(z(o,u)),e.z),i(e.xy.add(z(0,u)),e.z),i(e.xy.add(z(c,u)),e.z)).mul(1/17)}),eU=U(({depthTexture:n,shadowCoord:e,shadow:t})=>{const i=(u,h)=>yt(n,u).compare(h),r=fi("mapSize","vec2",t).setGroup(xt),s=z(1).div(r),a=s.x,o=s.y,l=e.xy,c=cs(l.mul(r).add(.5));return l.subAssign(c.mul(s)),zt(i(l,e.z),i(l.add(z(a,0)),e.z),i(l.add(z(0,o)),e.z),i(l.add(s),e.z),rt(i(l.add(z(a.negate(),0)),e.z),i(l.add(z(a.mul(2),0)),e.z),c.x),rt(i(l.add(z(a.negate(),o)),e.z),i(l.add(z(a.mul(2),o)),e.z),c.x),rt(i(l.add(z(0,o.negate())),e.z),i(l.add(z(0,o.mul(2))),e.z),c.y),rt(i(l.add(z(a,o.negate())),e.z),i(l.add(z(a,o.mul(2))),e.z),c.y),rt(rt(i(l.add(z(a.negate(),o.negate())),e.z),i(l.add(z(a.mul(2),o.negate())),e.z),c.x),rt(i(l.add(z(a.negate(),o.mul(2))),e.z),i(l.add(z(a.mul(2),o.mul(2))),e.z),c.x),c.y)).mul(1/9)}),tU=U(({depthTexture:n,shadowCoord:e})=>{const t=E(1).toVar(),i=yt(n).uv(e.xy).rg,r=Gl(e.z,i.x);return Le(r.notEqual(E(1)),()=>{const s=e.z.sub(i.x),a=ft(0,i.y.mul(i.y));let o=a.div(a.add(s.mul(s)));o=li(Pt(o,.3).div(.95-.3)),t.assign(li(ft(r,o)))}),t}),iU=U(({samples:n,radius:e,size:t,shadowPass:i})=>{const r=E(0).toVar(),s=E(0).toVar(),a=n.lessThanEqual(E(1)).select(E(0),E(2).div(n.sub(1))),o=n.lessThanEqual(E(1)).select(E(0),E(-1));gt({start:P(0),end:P(n),type:"int",condition:"<"},({i:c})=>{const u=o.add(E(c).mul(a)),h=i.uv(zt(fo.xy,z(0,u).mul(e)).div(t)).x;r.addAssign(h),s.addAssign(h.mul(h))}),r.divAssign(n),s.divAssign(n);const l=en(s.sub(r.mul(r)));return z(r,l)}),rU=U(({samples:n,radius:e,size:t,shadowPass:i})=>{const r=E(0).toVar(),s=E(0).toVar(),a=n.lessThanEqual(E(1)).select(E(0),E(2).div(n.sub(1))),o=n.lessThanEqual(E(1)).select(E(0),E(-1));gt({start:P(0),end:P(n),type:"int",condition:"<"},({i:c})=>{const u=o.add(E(c).mul(a)),h=i.uv(zt(fo.xy,z(u,0).mul(e)).div(t));r.addAssign(h.x),s.addAssign(zt(h.y.mul(h.y),h.x.mul(h.x)))}),r.divAssign(n),s.divAssign(n);const l=en(s.sub(r.mul(r)));return z(r,l)}),nU=[ZD,QD,eU,tU];let bo=null;const _d=new fn;class ps extends ta{static get type(){return"AnalyticLightNode"}constructor(e=null){super(),this.updateType=je.FRAME,this.light=e,this.color=new xe,this.colorNode=fe(this.color).setGroup(xt),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 $m(super.getCacheKey(),this.light.id,this.light.castShadow?1:0)}getHash(){return this.light.uuid}setupShadow(e){const{object:t,renderer:i}=e;if(i.shadowMap.enabled===!1)return;let r=this.shadowColorNode;if(r===null){bo===null&&(bo=new bt,bo.fragmentNode=ae(0,0,0,1),bo.isShadowNodeMaterial=!0,bo.name="ShadowMaterial");const s=i.shadowMap.type,a=this.light.shadow,o=new Ds;o.compareFunction=dp;const l=e.createRenderTarget(a.mapSize.width,a.mapSize.height);if(l.depthTexture=o,a.camera.updateProjectionMatrix(),s===rr){o.compareFunction=null,this.vsmShadowMapVertical=e.createRenderTarget(a.mapSize.width,a.mapSize.height,{format:va,type:wi}),this.vsmShadowMapHorizontal=e.createRenderTarget(a.mapSize.width,a.mapSize.height,{format:va,type:wi});const y=yt(o),_=yt(this.vsmShadowMapVertical.texture),I=fi("blurSamples","float",a).setGroup(xt),b=fi("radius","float",a).setGroup(xt),w=fi("mapSize","vec2",a).setGroup(xt);let C=this.vsmMaterialVertical||(this.vsmMaterialVertical=new bt);C.fragmentNode=iU({samples:I,radius:b,size:w,shadowPass:y}).context(e.getSharedContext()),C.name="VSMVertical",C=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new bt),C.fragmentNode=rU({samples:I,radius:b,size:w,shadowPass:_}).context(e.getSharedContext()),C.name="VSMHorizontal"}const c=fi("intensity","float",a).setGroup(xt),u=fi("bias","float",a).setGroup(xt),h=fi("normalBias","float",a).setGroup(xt),d=t.material.shadowPositionNode||Hh;let p=fe(a.matrix).setGroup(xt).mul(d.add(Wh.mul(h)));p=p.xyz.div(p.w);let m=p.z.add(u);i.coordinateSystem===bs&&(m=m.mul(2).sub(1)),p=D(p.x,p.y.oneMinus(),m);const v=p.x.greaterThanEqual(0).and(p.x.lessThanEqual(1)).and(p.y.greaterThanEqual(0)).and(p.y.lessThanEqual(1)).and(p.z.lessThanEqual(1)),f=a.filterNode||nU[i.shadowMap.type]||null;if(f===null)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const g=yt(l.texture,p),x=v.select(f({depthTexture:s===rr?this.vsmShadowMapHorizontal.texture:o,shadowCoord:p,shadow:a}),E(1));this.shadowMap=l,this.light.shadow.map=l,this.shadowNode=x,this.shadowColorNode=r=this.colorNode.mul(rt(1,x.rgb.mix(g,1),c.mul(g.a))),this.baseColorNode=this.colorNode}this.colorNode=r,this.updateBeforeType=je.RENDER}setup(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):this.shadowNode!==null&&this.disposeShadow()}updateShadow(e){const{shadowMap:t,light:i}=this,{renderer:r,scene:s,camera:a}=e,o=r.shadowMap.type,l=t.depthTexture.version;this._depthVersionCached=l;const c=s.overrideMaterial;s.overrideMaterial=bo,t.setSize(i.shadow.mapSize.width,i.shadow.mapSize.height),i.shadow.updateMatrices(i),i.shadow.camera.layers.mask=a.layers.mask;const u=r.getRenderTarget(),h=r.getRenderObjectFunction();r.setRenderObjectFunction((d,...p)=>{(d.castShadow===!0||d.receiveShadow&&o===rr)&&r.renderObject(d,...p)}),r.setRenderTarget(t),r.render(s,i.shadow.camera),r.setRenderObjectFunction(h),i.isPointLight!==!0&&o===rr&&this.vsmPass(e,i),r.setRenderTarget(u),s.overrideMaterial=c}vsmPass(e,t){const{renderer:i}=e;this.vsmShadowMapVertical.setSize(t.shadow.mapSize.width,t.shadow.mapSize.height),this.vsmShadowMapHorizontal.setSize(t.shadow.mapSize.width,t.shadow.mapSize.height),i.setRenderTarget(this.vsmShadowMapVertical),_d.material=this.vsmMaterialVertical,_d.render(i),i.setRenderTarget(this.vsmShadowMapHorizontal),_d.material=this.vsmMaterialHorizontal,_d.render(i)}disposeShadow(){this.shadowMap.dispose(),this.shadowMap=null,this.vsmShadowMapVertical!==null&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),this.vsmShadowMapHorizontal!==null&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null),this.shadowNode=null,this.shadowColorNode=null,this.baseColorNode=null,this.updateBeforeType=je.NONE}updateBefore(e){const t=this.light.shadow;(t.needsUpdate||t.autoUpdate)&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}update(){const{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}}const $g=U(n=>{const{lightDistance:e,cutoffDistance:t,decayExponent:i}=n,r=e.pow(i).max(.01).reciprocal();return t.greaterThan(0).select(r.mul(e.div(t).pow4().oneMinus().clamp().pow2()),r)});let Md;function Jg(n){Md=Md||new WeakMap;let e=Md.get(n);return e===void 0&&Md.set(n,e={}),e}function Kg(n){const e=Jg(n);return e.position||(e.position=fe(new N).setGroup(xt).onRenderUpdate((t,i)=>i.value.setFromMatrixPosition(n.matrixWorld)))}function hS(n){const e=Jg(n);return e.targetPosition||(e.targetPosition=fe(new N).setGroup(xt).onRenderUpdate((t,i)=>i.value.setFromMatrixPosition(n.target.matrixWorld)))}function bd(n){const e=Jg(n);return e.viewPosition||(e.viewPosition=fe(new N).setGroup(xt).onRenderUpdate(({camera:t},i)=>{i.value=i.value||new N,i.value.setFromMatrixPosition(n.matrixWorld),i.value.applyMatrix4(t.matrixWorldInverse)}))}const Zg=n=>cr.transformDirection(Kg(n).sub(hS(n))),sU=U(([n])=>{const e=n.toUint().mul(747796405).add(2891336453),t=e.shiftRight(e.shiftRight(28).add(4)).bitXor(e).mul(277803737);return t.shiftRight(22).bitXor(t).toFloat().mul(1/2**32)}),Qg=(n,e)=>Ji(lt(4,n.mul(Pt(1,n))),e),aU=(n,e)=>n.lessThan(.5)?Qg(n.mul(2),e).div(2):Pt(1,Qg(lt(Pt(1,n),2),e).div(2)),oU=(n,e,t)=>Ji(Qr(Ji(n,e),zt(Ji(n,e),Ji(Pt(1,n),t))),1/e),lU=(n,e)=>Ci(Zs.mul(e.mul(n).sub(1))).div(Zs.mul(e.mul(n).sub(1))),gn=U(([n])=>n.fract().sub(.5).abs()).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),dS=U(([n])=>D(gn(n.z.add(gn(n.y.mul(1)))),gn(n.z.add(gn(n.x.mul(1)))),gn(n.y.add(gn(n.x.mul(1)))))).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),cU=U(([n,e,t])=>{const i=D(n).toVar(),r=E(1.4).toVar(),s=E(0).toVar(),a=D(i).toVar();return gt({start:E(0),end:E(3),type:"float",condition:"<="},()=>{const o=D(dS(a.mul(2))).toVar();i.addAssign(o.add(t.mul(E(.1).mul(e)))),a.mulAssign(1.8),r.mulAssign(1.5),i.mulAssign(1.2);const l=E(gn(i.z.add(gn(i.x.add(gn(i.y)))))).toVar();s.addAssign(l.div(r)),a.addAssign(.14)}),s}).setLayout({name:"triNoise3D",type:"float",inputs:[{name:"p",type:"vec3"},{name:"spd",type:"float"},{name:"time",type:"float"}]}),uU=U(([n,e,t=z(.5)])=>wg(n.sub(t),e).add(t)),hU=U(([n,e,t=z(.5)])=>{const i=n.sub(t),r=i.dot(i),s=r.mul(r).mul(e);return n.add(i.mul(s))}),dU=U(({position:n=null,horizontal:e=!0,vertical:t=!1})=>{let i;n!==null?(i=Br.toVar(),i[3][0]=n.x,i[3][1]=n.y,i[3][2]=n.z):i=Br;const r=cr.mul(i);return Rl(e)&&(r[0][0]=Br[0].length(),r[0][1]=0,r[0][2]=0),Rl(t)&&(r[1][0]=0,r[1][1]=Br[1].length(),r[1][2]=0),r[2][0]=0,r[2][1]=0,r[2][2]=1,lr.mul(r).mul(Zt)}),pU=U(([n=null])=>{const e=Qh();return Qh(og(n)).sub(e).lessThan(0).select(ds,n)}),pS=new WeakMap;class mU extends pt{static get type(){return"VelocityNode"}constructor(){super("vec2"),this.updateType=je.OBJECT,this.updateAfterType=je.OBJECT,this.previousModelWorldMatrix=fe(new Re),this.previousProjectionMatrix=fe(new Re).setGroup(xt),this.previousCameraViewMatrix=fe(new Re)}update({frameId:e,camera:t,object:i}){const r=fS(i);this.previousModelWorldMatrix.value.copy(r);const s=mS(t);s.frameId!==e&&(s.frameId=e,s.previousProjectionMatrix===void 0?(s.previousProjectionMatrix=new Re,s.previousCameraViewMatrix=new Re,s.currentProjectionMatrix=new Re,s.currentCameraViewMatrix=new Re,s.previousProjectionMatrix.copy(t.projectionMatrix),s.previousCameraViewMatrix.copy(t.matrixWorldInverse)):(s.previousProjectionMatrix.copy(s.currentProjectionMatrix),s.previousCameraViewMatrix.copy(s.currentCameraViewMatrix)),s.currentProjectionMatrix.copy(t.projectionMatrix),s.currentCameraViewMatrix.copy(t.matrixWorldInverse),this.previousProjectionMatrix.value.copy(s.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(s.previousCameraViewMatrix))}updateAfter({object:e}){fS(e).copy(e.matrixWorld)}setup(){const e=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),t=lr.mul(pn).mul(Zt),i=this.previousProjectionMatrix.mul(e).mul(kh),r=t.xy.div(t.w),s=i.xy.div(i.w);return Pt(r,s)}}function mS(n){let e=pS.get(n);return e===void 0&&(e={},pS.set(n,e)),e}function fS(n,e=0){const t=mS(n);let i=t[e];return i===void 0&&(t[e]=i=new Re),i}const fU=ge(mU),gU=U(([n,e])=>xi(1,n.oneMinus().div(e)).oneMinus()).setLayout({name:"burnBlend",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),vU=U(([n,e])=>xi(n.div(e.oneMinus()),1)).setLayout({name:"dodgeBlend",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),yU=U(([n,e])=>n.oneMinus().mul(e.oneMinus()).oneMinus()).setLayout({name:"screenBlend",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),xU=U(([n,e])=>rt(n.mul(2).mul(e),n.oneMinus().mul(2).mul(e.oneMinus()).oneMinus(),Gl(.5,n))).setLayout({name:"overlayBlend",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),_U=U(([n,e,t=P(16)])=>{const i=o=>n.uv(o),r=nt(),s=i(r).toVar(),a=E(t);return gt({start:P(1),end:t,type:"int",condition:"<="},({i:o})=>{const l=e.mul(E(o).div(a.sub(1)).sub(.5));s.addAssign(i(r.add(l)))}),s.divAssign(a),s}),MU=U(([n,e=1])=>{const t=n,i=Ui(t.rgb),r=D(i),s=xi(1,ft(0,E(10).mul(i.sub(.45)))),a=r.mul(t.rgb).mul(2),o=E(2).mul(r.oneMinus()).mul(t.rgb.oneMinus()).oneMinus(),l=rt(a,o,s),c=t.a.mul(e),u=c.mul(l.rgb);return u.addAssign(t.rgb.mul(c.oneMinus())),ae(u,t.a)}),bU=U(([n])=>{const e=D(n);return ae(qt(e,D(.393,.769,.189)),qt(e,D(.349,.686,.168)),qt(e,D(.272,.534,.131)),n.a)}),gS=U(([n])=>{const e=n.mul(.9478672986).add(.0521327014).pow(2.4),t=n.mul(.0773993808),i=n.lessThanEqual(.04045);return rt(e,t,i)}).setLayout({name:"sRGBToLinearSRGB",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),vS=U(([n])=>{const e=n.pow(.41666).mul(1.055).sub(.055),t=n.mul(12.92),i=n.lessThanEqual(.0031308);return rt(e,t,i)}).setLayout({name:"linearSRGBTosRGB",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),yS=U(([n,e])=>n.mul(e).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),xS=U(([n,e])=>(n=n.mul(e),n.div(n.add(1)).clamp())).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),_S=U(([n,e])=>{n=n.mul(e),n=n.sub(.004).max(0);const t=n.mul(n.mul(6.2).add(.5)),i=n.mul(n.mul(6.2).add(1.7)).add(.06);return t.div(i).pow(2.2)}).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),TU=U(([n])=>{const e=n.mul(n.add(.0245786)).sub(90537e-9),t=n.mul(n.add(.432951).mul(.983729)).add(.238081);return e.div(t)}),MS=U(([n,e])=>{const t=yi(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),i=yi(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return n=n.mul(e).div(.6),n=t.mul(n),n=TU(n),n=i.mul(n),n.clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),SU=yi(D(1.6605,-.1246,-.0182),D(-.5876,1.1329,-.1006),D(-.0728,-.0083,1.1187)),wU=yi(D(.6274,.0691,.0164),D(.3293,.9195,.088),D(.0433,.0113,.8956)),EU=U(([n])=>{const e=D(n).toVar(),t=D(e.mul(e)).toVar(),i=D(t.mul(t)).toVar();return E(15.5).mul(i.mul(t)).sub(lt(40.14,i.mul(e))).add(lt(31.96,i).sub(lt(6.868,t.mul(e))).add(lt(.4298,t).add(lt(.1191,e).sub(.00232))))}),bS=U(([n,e])=>{const t=D(n).toVar(),i=yi(D(.856627153315983,.137318972929847,.11189821299995),D(.0951212405381588,.761241990602591,.0767994186031903),D(.0482516061458583,.101439036467562,.811302368396859)),r=yi(D(1.1271005818144368,-.1413297634984383,-.14132976349843826),D(-.11060664309660323,1.157823702216272,-.11060664309660294),D(-.016493938717834573,-.016493938717834257,1.2519364065950405)),s=E(-12.47393),a=E(4.026069);return t.mulAssign(e),t.assign(wU.mul(t)),t.assign(i.mul(t)),t.assign(ft(t,1e-10)),t.assign(kl(t)),t.assign(t.sub(s).div(a.sub(s))),t.assign(li(t,0,1)),t.assign(EU(t)),t.assign(r.mul(t)),t.assign(Ji(ft(D(0),t),D(2.2))),t.assign(SU.mul(t)),t.assign(li(t,0,1)),t}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),TS=U(([n,e])=>{const t=E(.76),i=E(.15);n=n.mul(e);const r=xi(n.r,xi(n.g,n.b)),s=Ri(r.lessThan(.08),r.sub(lt(6.25,r.mul(r))),.04);n.subAssign(s);const a=ft(n.r,ft(n.g,n.b));Le(a.lessThan(t),()=>n);const o=Pt(1,t),l=Pt(1,o.mul(o).div(a.add(o.sub(t))));n.mulAssign(l.div(a));const c=Pt(1,Qr(1,i.mul(a.sub(l)).add(1)));return rt(n,D(l),c)}).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class AU extends qe{static get type(){return"ComputeBuiltinNode"}constructor(e,t){super(t),this._builtinName=e}getHash(e){return this.getBuiltinName(e)}getNodeType(){return this.nodeType}setBuiltinName(e){return this._builtinName=e,this}getBuiltinName(){return this._builtinName}hasBuiltin(e){e.hasBuiltin(this._builtinName)}generate(e,t){const i=this.getBuiltinName(e),r=this.getNodeType(e);return e.shaderStage==="compute"?e.format(i,r,t):(console.warn(`ComputeBuiltinNode: Compute built-in value ${i} can not be accessed in the ${e.shaderStage} stage`),e.generateConst(r))}serialize(e){super.serialize(e),e.global=this.global,e._builtinName=this._builtinName}deserialize(e){super.deserialize(e),this.global=e.global,this._builtinName=e._builtinName}}const Td=(n,e)=>G(new AU(n,e)),NU=Td("numWorkgroups","uvec3"),CU=Td("workgroupId","uvec3"),RU=Td("localId","uvec3"),IU=Td("subgroupSize","uint");class LU extends qe{constructor(e){super(),this.scope=e}generate(e){const{scope:t}=this,{renderer:i}=e;i.backend.isWebGLBackend===!0?e.addFlowCode(` // ${t}Barrier
|
|
3874
|
+
`):e.addLineFlowCode(`${t}Barrier()`,this)}}const e0=K(LU),PU=()=>e0("workgroup").append(),DU=()=>e0("storage").append(),UU=()=>e0("texture").append();class OU extends ss{constructor(e,t){super(e,t),this.isWorkgroupInfoElementNode=!0}generate(e,t){let i;const r=e.context.assign;if(i=super.generate(e),r!==!0){const s=this.getNodeType(e);i=e.format(i,s,t)}return i}}class FU extends qe{constructor(e,t,i=0){super(t),this.bufferType=t,this.bufferCount=i,this.isWorkgroupInfoNode=!0,this.scope=e}label(e){return this.name=e,this}getHash(){return this.uuid}setScope(e){return this.scope=e,this}getInputType(){return`${this.scope}Array`}element(e){return G(new OU(this,e))}generate(e){return e.getScopedArray(this.name||`${this.scope}Array_${this.id}`,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}}const VU=(n,e)=>G(new FU("Workgroup",n,e));class Mi extends pt{static get type(){return"AtomicFunctionNode"}constructor(e,t,i,r=null){super("uint"),this.method=e,this.pointerNode=t,this.valueNode=i,this.storeNode=r}getInputType(e){return this.pointerNode.getNodeType(e)}getNodeType(e){return this.getInputType(e)}generate(e){const t=this.method,i=this.getNodeType(e),r=this.getInputType(e),s=this.pointerNode,a=this.valueNode,o=[];o.push(`&${s.build(e,r)}`),o.push(a.build(e,r));const l=`${e.getMethod(t,i)}( ${o.join(", ")} )`;if(this.storeNode!==null){const c=this.storeNode.build(e,r);e.addLineFlowCode(`${c} = ${l}`,this)}else e.addLineFlowCode(l,this)}}Mi.ATOMIC_LOAD="atomicLoad",Mi.ATOMIC_STORE="atomicStore",Mi.ATOMIC_ADD="atomicAdd",Mi.ATOMIC_SUB="atomicSub",Mi.ATOMIC_MAX="atomicMax",Mi.ATOMIC_MIN="atomicMin",Mi.ATOMIC_AND="atomicAnd",Mi.ATOMIC_OR="atomicOr",Mi.ATOMIC_XOR="atomicXor";const BU=K(Mi),Un=(n,e,t,i)=>{const r=BU(n,e,t,i);return r.append(),r},zU=(n,e,t=null)=>Un(Mi.ATOMIC_STORE,n,e,t),kU=(n,e,t=null)=>Un(Mi.ATOMIC_ADD,n,e,t),HU=(n,e,t=null)=>Un(Mi.ATOMIC_SUB,n,e,t),GU=(n,e,t=null)=>Un(Mi.ATOMIC_MAX,n,e,t),WU=(n,e,t=null)=>Un(Mi.ATOMIC_MIN,n,e,t),jU=(n,e,t=null)=>Un(Mi.ATOMIC_AND,n,e,t),XU=(n,e,t=null)=>Un(Mi.ATOMIC_OR,n,e,t),qU=(n,e,t=null)=>Un(Mi.ATOMIC_XOR,n,e,t),YU=U(([n=nt()])=>{const e=n.mul(2),t=e.x.floor(),i=e.y.floor();return t.add(i).mod(2).sign()}),dc=U(([n,e,t])=>{const i=E(t).toVar(),r=E(e).toVar(),s=as(n).toVar();return Ri(s,r,i)}).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),Sd=U(([n,e])=>{const t=as(e).toVar(),i=E(n).toVar();return Ri(t,i.negate(),i)}).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),ii=U(([n])=>{const e=E(n).toVar();return P(ls(e))}).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),kt=U(([n,e])=>{const t=E(n).toVar();return e.assign(ii(t)),t.sub(E(e))}),$U=U(([n,e,t,i,r,s])=>{const a=E(s).toVar(),o=E(r).toVar(),l=E(i).toVar(),c=E(t).toVar(),u=E(e).toVar(),h=E(n).toVar(),d=E(Pt(1,o)).toVar();return Pt(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"}]}),JU=U(([n,e,t,i,r,s])=>{const a=E(s).toVar(),o=E(r).toVar(),l=D(i).toVar(),c=D(t).toVar(),u=D(e).toVar(),h=D(n).toVar(),d=E(Pt(1,o)).toVar();return Pt(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"}]}),SS=Di([$U,JU]),KU=U(([n,e,t,i,r,s,a,o,l,c,u])=>{const h=E(u).toVar(),d=E(c).toVar(),p=E(l).toVar(),m=E(o).toVar(),v=E(a).toVar(),f=E(s).toVar(),g=E(r).toVar(),x=E(i).toVar(),y=E(t).toVar(),_=E(e).toVar(),I=E(n).toVar(),b=E(Pt(1,p)).toVar(),w=E(Pt(1,d)).toVar();return E(Pt(1,h)).toVar().mul(w.mul(I.mul(b).add(_.mul(p))).add(d.mul(y.mul(b).add(x.mul(p))))).add(h.mul(w.mul(g.mul(b).add(f.mul(p))).add(d.mul(v.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"}]}),ZU=U(([n,e,t,i,r,s,a,o,l,c,u])=>{const h=E(u).toVar(),d=E(c).toVar(),p=E(l).toVar(),m=D(o).toVar(),v=D(a).toVar(),f=D(s).toVar(),g=D(r).toVar(),x=D(i).toVar(),y=D(t).toVar(),_=D(e).toVar(),I=D(n).toVar(),b=E(Pt(1,p)).toVar(),w=E(Pt(1,d)).toVar();return E(Pt(1,h)).toVar().mul(w.mul(I.mul(b).add(_.mul(p))).add(d.mul(y.mul(b).add(x.mul(p))))).add(h.mul(w.mul(g.mul(b).add(f.mul(p))).add(d.mul(v.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"}]}),wS=Di([KU,ZU]),QU=U(([n,e,t])=>{const i=E(t).toVar(),r=E(e).toVar(),s=_e(n).toVar(),a=_e(s.bitAnd(_e(7))).toVar(),o=E(dc(a.lessThan(_e(4)),r,i)).toVar(),l=E(lt(2,dc(a.lessThan(_e(4)),i,r))).toVar();return Sd(o,as(a.bitAnd(_e(1)))).add(Sd(l,as(a.bitAnd(_e(2)))))}).setLayout({name:"mx_gradient_float_0",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"}]}),eO=U(([n,e,t,i])=>{const r=E(i).toVar(),s=E(t).toVar(),a=E(e).toVar(),o=_e(n).toVar(),l=_e(o.bitAnd(_e(15))).toVar(),c=E(dc(l.lessThan(_e(8)),a,s)).toVar(),u=E(dc(l.lessThan(_e(4)),s,dc(l.equal(_e(12)).or(l.equal(_e(14))),a,r))).toVar();return Sd(c,as(l.bitAnd(_e(1)))).add(Sd(u,as(l.bitAnd(_e(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"}]}),bi=Di([QU,eO]),tO=U(([n,e,t])=>{const i=E(t).toVar(),r=E(e).toVar(),s=ao(n).toVar();return D(bi(s.x,r,i),bi(s.y,r,i),bi(s.z,r,i))}).setLayout({name:"mx_gradient_vec3_0",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"}]}),iO=U(([n,e,t,i])=>{const r=E(i).toVar(),s=E(t).toVar(),a=E(e).toVar(),o=ao(n).toVar();return D(bi(o.x,a,s,r),bi(o.y,a,s,r),bi(o.z,a,s,r))}).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"}]}),zr=Di([tO,iO]),rO=U(([n])=>{const e=E(n).toVar();return lt(.6616,e)}).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),nO=U(([n])=>{const e=E(n).toVar();return lt(.982,e)}).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),sO=U(([n])=>{const e=D(n).toVar();return lt(.6616,e)}).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),ES=Di([rO,sO]),aO=U(([n])=>{const e=D(n).toVar();return lt(.982,e)}).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),AS=Di([nO,aO]),Sr=U(([n,e])=>{const t=P(e).toVar(),i=_e(n).toVar();return i.shiftLeft(t).bitOr(i.shiftRight(P(32).sub(t)))}).setLayout({name:"mx_rotl32",type:"uint",inputs:[{name:"x",type:"uint"},{name:"k",type:"int"}]}),NS=U(([n,e,t])=>{n.subAssign(t),n.bitXorAssign(Sr(t,P(4))),t.addAssign(e),e.subAssign(n),e.bitXorAssign(Sr(n,P(6))),n.addAssign(t),t.subAssign(e),t.bitXorAssign(Sr(e,P(8))),e.addAssign(n),n.subAssign(t),n.bitXorAssign(Sr(t,P(16))),t.addAssign(e),e.subAssign(n),e.bitXorAssign(Sr(n,P(19))),n.addAssign(t),t.subAssign(e),t.bitXorAssign(Sr(e,P(4))),e.addAssign(n)}),pc=U(([n,e,t])=>{const i=_e(t).toVar(),r=_e(e).toVar(),s=_e(n).toVar();return i.bitXorAssign(r),i.subAssign(Sr(r,P(14))),s.bitXorAssign(i),s.subAssign(Sr(i,P(11))),r.bitXorAssign(s),r.subAssign(Sr(s,P(25))),i.bitXorAssign(r),i.subAssign(Sr(r,P(16))),s.bitXorAssign(i),s.subAssign(Sr(i,P(4))),r.bitXorAssign(s),r.subAssign(Sr(s,P(14))),i.bitXorAssign(r),i.subAssign(Sr(r,P(24))),i}).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),Gi=U(([n])=>{const e=_e(n).toVar();return E(e).div(E(_e(P(4294967295))))}).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),vn=U(([n])=>{const e=E(n).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"}]}),oO=U(([n])=>{const e=P(n).toVar(),t=_e(_e(1)).toVar(),i=_e(_e(P(3735928559)).add(t.shiftLeft(_e(2))).add(_e(13))).toVar();return pc(i.add(_e(e)),i,i)}).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),lO=U(([n,e])=>{const t=P(e).toVar(),i=P(n).toVar(),r=_e(_e(2)).toVar(),s=_e().toVar(),a=_e().toVar(),o=_e().toVar();return s.assign(a.assign(o.assign(_e(P(3735928559)).add(r.shiftLeft(_e(2))).add(_e(13))))),s.addAssign(_e(i)),a.addAssign(_e(t)),pc(s,a,o)}).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),cO=U(([n,e,t])=>{const i=P(t).toVar(),r=P(e).toVar(),s=P(n).toVar(),a=_e(_e(3)).toVar(),o=_e().toVar(),l=_e().toVar(),c=_e().toVar();return o.assign(l.assign(c.assign(_e(P(3735928559)).add(a.shiftLeft(_e(2))).add(_e(13))))),o.addAssign(_e(s)),l.addAssign(_e(r)),c.addAssign(_e(i)),pc(o,l,c)}).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),uO=U(([n,e,t,i])=>{const r=P(i).toVar(),s=P(t).toVar(),a=P(e).toVar(),o=P(n).toVar(),l=_e(_e(4)).toVar(),c=_e().toVar(),u=_e().toVar(),h=_e().toVar();return c.assign(u.assign(h.assign(_e(P(3735928559)).add(l.shiftLeft(_e(2))).add(_e(13))))),c.addAssign(_e(o)),u.addAssign(_e(a)),h.addAssign(_e(s)),NS(c,u,h),c.addAssign(_e(r)),pc(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"}]}),hO=U(([n,e,t,i,r])=>{const s=P(r).toVar(),a=P(i).toVar(),o=P(t).toVar(),l=P(e).toVar(),c=P(n).toVar(),u=_e(_e(5)).toVar(),h=_e().toVar(),d=_e().toVar(),p=_e().toVar();return h.assign(d.assign(p.assign(_e(P(3735928559)).add(u.shiftLeft(_e(2))).add(_e(13))))),h.addAssign(_e(c)),d.addAssign(_e(l)),p.addAssign(_e(o)),NS(h,d,p),h.addAssign(_e(a)),d.addAssign(_e(s)),pc(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"}]}),Ct=Di([oO,lO,cO,uO,hO]),dO=U(([n,e])=>{const t=P(e).toVar(),i=P(n).toVar(),r=_e(Ct(i,t)).toVar(),s=ao().toVar();return s.x.assign(r.bitAnd(P(255))),s.y.assign(r.shiftRight(P(8)).bitAnd(P(255))),s.z.assign(r.shiftRight(P(16)).bitAnd(P(255))),s}).setLayout({name:"mx_hash_vec3_0",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),pO=U(([n,e,t])=>{const i=P(t).toVar(),r=P(e).toVar(),s=P(n).toVar(),a=_e(Ct(s,r,i)).toVar(),o=ao().toVar();return o.x.assign(a.bitAnd(P(255))),o.y.assign(a.shiftRight(P(8)).bitAnd(P(255))),o.z.assign(a.shiftRight(P(16)).bitAnd(P(255))),o}).setLayout({name:"mx_hash_vec3_1",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),kr=Di([dO,pO]),mO=U(([n])=>{const e=z(n).toVar(),t=P().toVar(),i=P().toVar(),r=E(kt(e.x,t)).toVar(),s=E(kt(e.y,i)).toVar(),a=E(vn(r)).toVar(),o=E(vn(s)).toVar(),l=E(SS(bi(Ct(t,i),r,s),bi(Ct(t.add(P(1)),i),r.sub(1),s),bi(Ct(t,i.add(P(1))),r,s.sub(1)),bi(Ct(t.add(P(1)),i.add(P(1))),r.sub(1),s.sub(1)),a,o)).toVar();return ES(l)}).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),fO=U(([n])=>{const e=D(n).toVar(),t=P().toVar(),i=P().toVar(),r=P().toVar(),s=E(kt(e.x,t)).toVar(),a=E(kt(e.y,i)).toVar(),o=E(kt(e.z,r)).toVar(),l=E(vn(s)).toVar(),c=E(vn(a)).toVar(),u=E(vn(o)).toVar(),h=E(wS(bi(Ct(t,i,r),s,a,o),bi(Ct(t.add(P(1)),i,r),s.sub(1),a,o),bi(Ct(t,i.add(P(1)),r),s,a.sub(1),o),bi(Ct(t.add(P(1)),i.add(P(1)),r),s.sub(1),a.sub(1),o),bi(Ct(t,i,r.add(P(1))),s,a,o.sub(1)),bi(Ct(t.add(P(1)),i,r.add(P(1))),s.sub(1),a,o.sub(1)),bi(Ct(t,i.add(P(1)),r.add(P(1))),s,a.sub(1),o.sub(1)),bi(Ct(t.add(P(1)),i.add(P(1)),r.add(P(1))),s.sub(1),a.sub(1),o.sub(1)),l,c,u)).toVar();return AS(h)}).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]}),t0=Di([mO,fO]),gO=U(([n])=>{const e=z(n).toVar(),t=P().toVar(),i=P().toVar(),r=E(kt(e.x,t)).toVar(),s=E(kt(e.y,i)).toVar(),a=E(vn(r)).toVar(),o=E(vn(s)).toVar(),l=D(SS(zr(kr(t,i),r,s),zr(kr(t.add(P(1)),i),r.sub(1),s),zr(kr(t,i.add(P(1))),r,s.sub(1)),zr(kr(t.add(P(1)),i.add(P(1))),r.sub(1),s.sub(1)),a,o)).toVar();return ES(l)}).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),vO=U(([n])=>{const e=D(n).toVar(),t=P().toVar(),i=P().toVar(),r=P().toVar(),s=E(kt(e.x,t)).toVar(),a=E(kt(e.y,i)).toVar(),o=E(kt(e.z,r)).toVar(),l=E(vn(s)).toVar(),c=E(vn(a)).toVar(),u=E(vn(o)).toVar(),h=D(wS(zr(kr(t,i,r),s,a,o),zr(kr(t.add(P(1)),i,r),s.sub(1),a,o),zr(kr(t,i.add(P(1)),r),s,a.sub(1),o),zr(kr(t.add(P(1)),i.add(P(1)),r),s.sub(1),a.sub(1),o),zr(kr(t,i,r.add(P(1))),s,a,o.sub(1)),zr(kr(t.add(P(1)),i,r.add(P(1))),s.sub(1),a,o.sub(1)),zr(kr(t,i.add(P(1)),r.add(P(1))),s,a.sub(1),o.sub(1)),zr(kr(t.add(P(1)),i.add(P(1)),r.add(P(1))),s.sub(1),a.sub(1),o.sub(1)),l,c,u)).toVar();return AS(h)}).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),i0=Di([gO,vO]),yO=U(([n])=>{const e=E(n).toVar(),t=P(ii(e)).toVar();return Gi(Ct(t))}).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),xO=U(([n])=>{const e=z(n).toVar(),t=P(ii(e.x)).toVar(),i=P(ii(e.y)).toVar();return Gi(Ct(t,i))}).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),_O=U(([n])=>{const e=D(n).toVar(),t=P(ii(e.x)).toVar(),i=P(ii(e.y)).toVar(),r=P(ii(e.z)).toVar();return Gi(Ct(t,i,r))}).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),MO=U(([n])=>{const e=ae(n).toVar(),t=P(ii(e.x)).toVar(),i=P(ii(e.y)).toVar(),r=P(ii(e.z)).toVar(),s=P(ii(e.w)).toVar();return Gi(Ct(t,i,r,s))}).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]}),bO=Di([yO,xO,_O,MO]),TO=U(([n])=>{const e=E(n).toVar(),t=P(ii(e)).toVar();return D(Gi(Ct(t,P(0))),Gi(Ct(t,P(1))),Gi(Ct(t,P(2))))}).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),SO=U(([n])=>{const e=z(n).toVar(),t=P(ii(e.x)).toVar(),i=P(ii(e.y)).toVar();return D(Gi(Ct(t,i,P(0))),Gi(Ct(t,i,P(1))),Gi(Ct(t,i,P(2))))}).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),wO=U(([n])=>{const e=D(n).toVar(),t=P(ii(e.x)).toVar(),i=P(ii(e.y)).toVar(),r=P(ii(e.z)).toVar();return D(Gi(Ct(t,i,r,P(0))),Gi(Ct(t,i,r,P(1))),Gi(Ct(t,i,r,P(2))))}).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),EO=U(([n])=>{const e=ae(n).toVar(),t=P(ii(e.x)).toVar(),i=P(ii(e.y)).toVar(),r=P(ii(e.z)).toVar(),s=P(ii(e.w)).toVar();return D(Gi(Ct(t,i,r,s,P(0))),Gi(Ct(t,i,r,s,P(1))),Gi(Ct(t,i,r,s,P(2))))}).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]}),CS=Di([TO,SO,wO,EO]),wd=U(([n,e,t,i])=>{const r=E(i).toVar(),s=E(t).toVar(),a=P(e).toVar(),o=D(n).toVar(),l=E(0).toVar(),c=E(1).toVar();return gt(a,()=>{l.addAssign(c.mul(t0(o))),c.mulAssign(r),o.mulAssign(s)}),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"}]}),RS=U(([n,e,t,i])=>{const r=E(i).toVar(),s=E(t).toVar(),a=P(e).toVar(),o=D(n).toVar(),l=D(0).toVar(),c=E(1).toVar();return gt(a,()=>{l.addAssign(c.mul(i0(o))),c.mulAssign(r),o.mulAssign(s)}),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"}]}),AO=U(([n,e,t,i])=>{const r=E(i).toVar(),s=E(t).toVar(),a=P(e).toVar(),o=D(n).toVar();return z(wd(o,a,s,r),wd(o.add(D(P(19),P(193),P(17))),a,s,r))}).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"}]}),NO=U(([n,e,t,i])=>{const r=E(i).toVar(),s=E(t).toVar(),a=P(e).toVar(),o=D(n).toVar(),l=D(RS(o,a,s,r)).toVar(),c=E(wd(o.add(D(P(19),P(193),P(17))),a,s,r)).toVar();return ae(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"}]}),CO=U(([n,e,t,i,r,s,a])=>{const o=P(a).toVar(),l=E(s).toVar(),c=P(r).toVar(),u=P(i).toVar(),h=P(t).toVar(),d=P(e).toVar(),p=z(n).toVar(),m=D(CS(z(d.add(u),h.add(c)))).toVar(),v=z(m.x,m.y).toVar();v.subAssign(.5),v.mulAssign(l),v.addAssign(.5);const f=z(z(E(d),E(h)).add(v)).toVar(),g=z(f.sub(p)).toVar();return Le(o.equal(P(2)),()=>It(g.x).add(It(g.y))),Le(o.equal(P(3)),()=>ft(It(g.x),It(g.y))),qt(g,g)}).setLayout({name:"mx_worley_distance_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),RO=U(([n,e,t,i,r,s,a,o,l])=>{const c=P(l).toVar(),u=E(o).toVar(),h=P(a).toVar(),d=P(s).toVar(),p=P(r).toVar(),m=P(i).toVar(),v=P(t).toVar(),f=P(e).toVar(),g=D(n).toVar(),x=D(CS(D(f.add(p),v.add(d),m.add(h)))).toVar();x.subAssign(.5),x.mulAssign(u),x.addAssign(.5);const y=D(D(E(f),E(v),E(m)).add(x)).toVar(),_=D(y.sub(g)).toVar();return Le(c.equal(P(2)),()=>It(_.x).add(It(_.y)).add(It(_.z))),Le(c.equal(P(3)),()=>ft(ft(It(_.x),It(_.y)),It(_.z))),qt(_,_)}).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"}]}),To=Di([CO,RO]),IO=U(([n,e,t])=>{const i=P(t).toVar(),r=E(e).toVar(),s=z(n).toVar(),a=P().toVar(),o=P().toVar(),l=z(kt(s.x,a),kt(s.y,o)).toVar(),c=E(1e6).toVar();return gt({start:-1,end:P(1),name:"x",condition:"<="},({x:u})=>{gt({start:-1,end:P(1),name:"y",condition:"<="},({y:h})=>{const d=E(To(l,u,h,a,o,r,i)).toVar();c.assign(xi(c,d))})}),Le(i.equal(P(0)),()=>{c.assign(en(c))}),c}).setLayout({name:"mx_worley_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),LO=U(([n,e,t])=>{const i=P(t).toVar(),r=E(e).toVar(),s=z(n).toVar(),a=P().toVar(),o=P().toVar(),l=z(kt(s.x,a),kt(s.y,o)).toVar(),c=z(1e6,1e6).toVar();return gt({start:-1,end:P(1),name:"x",condition:"<="},({x:u})=>{gt({start:-1,end:P(1),name:"y",condition:"<="},({y:h})=>{const d=E(To(l,u,h,a,o,r,i)).toVar();Le(d.lessThan(c.x),()=>{c.y.assign(c.x),c.x.assign(d)}).ElseIf(d.lessThan(c.y),()=>{c.y.assign(d)})})}),Le(i.equal(P(0)),()=>{c.assign(en(c))}),c}).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),PO=U(([n,e,t])=>{const i=P(t).toVar(),r=E(e).toVar(),s=z(n).toVar(),a=P().toVar(),o=P().toVar(),l=z(kt(s.x,a),kt(s.y,o)).toVar(),c=D(1e6,1e6,1e6).toVar();return gt({start:-1,end:P(1),name:"x",condition:"<="},({x:u})=>{gt({start:-1,end:P(1),name:"y",condition:"<="},({y:h})=>{const d=E(To(l,u,h,a,o,r,i)).toVar();Le(d.lessThan(c.x),()=>{c.z.assign(c.y),c.y.assign(c.x),c.x.assign(d)}).ElseIf(d.lessThan(c.y),()=>{c.z.assign(c.y),c.y.assign(d)}).ElseIf(d.lessThan(c.z),()=>{c.z.assign(d)})})}),Le(i.equal(P(0)),()=>{c.assign(en(c))}),c}).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),DO=U(([n,e,t])=>{const i=P(t).toVar(),r=E(e).toVar(),s=D(n).toVar(),a=P().toVar(),o=P().toVar(),l=P().toVar(),c=D(kt(s.x,a),kt(s.y,o),kt(s.z,l)).toVar(),u=E(1e6).toVar();return gt({start:-1,end:P(1),name:"x",condition:"<="},({x:h})=>{gt({start:-1,end:P(1),name:"y",condition:"<="},({y:d})=>{gt({start:-1,end:P(1),name:"z",condition:"<="},({z:p})=>{const m=E(To(c,h,d,p,a,o,l,r,i)).toVar();u.assign(xi(u,m))})})}),Le(i.equal(P(0)),()=>{u.assign(en(u))}),u}).setLayout({name:"mx_worley_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),UO=Di([IO,DO]),OO=U(([n,e,t])=>{const i=P(t).toVar(),r=E(e).toVar(),s=D(n).toVar(),a=P().toVar(),o=P().toVar(),l=P().toVar(),c=D(kt(s.x,a),kt(s.y,o),kt(s.z,l)).toVar(),u=z(1e6,1e6).toVar();return gt({start:-1,end:P(1),name:"x",condition:"<="},({x:h})=>{gt({start:-1,end:P(1),name:"y",condition:"<="},({y:d})=>{gt({start:-1,end:P(1),name:"z",condition:"<="},({z:p})=>{const m=E(To(c,h,d,p,a,o,l,r,i)).toVar();Le(m.lessThan(u.x),()=>{u.y.assign(u.x),u.x.assign(m)}).ElseIf(m.lessThan(u.y),()=>{u.y.assign(m)})})})}),Le(i.equal(P(0)),()=>{u.assign(en(u))}),u}).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),FO=Di([LO,OO]),VO=U(([n,e,t])=>{const i=P(t).toVar(),r=E(e).toVar(),s=D(n).toVar(),a=P().toVar(),o=P().toVar(),l=P().toVar(),c=D(kt(s.x,a),kt(s.y,o),kt(s.z,l)).toVar(),u=D(1e6,1e6,1e6).toVar();return gt({start:-1,end:P(1),name:"x",condition:"<="},({x:h})=>{gt({start:-1,end:P(1),name:"y",condition:"<="},({y:d})=>{gt({start:-1,end:P(1),name:"z",condition:"<="},({z:p})=>{const m=E(To(c,h,d,p,a,o,l,r,i)).toVar();Le(m.lessThan(u.x),()=>{u.z.assign(u.y),u.y.assign(u.x),u.x.assign(m)}).ElseIf(m.lessThan(u.y),()=>{u.z.assign(u.y),u.y.assign(m)}).ElseIf(m.lessThan(u.z),()=>{u.z.assign(m)})})})}),Le(i.equal(P(0)),()=>{u.assign(en(u))}),u}).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),BO=Di([PO,VO]),zO=U(([n])=>{const e=n.y,t=n.z,i=D().toVar();return Le(e.lessThan(1e-4),()=>{i.assign(D(t,t,t))}).Else(()=>{let r=n.x;r=r.sub(ls(r)).mul(6).toVar();const s=P(Rf(r)),a=r.sub(E(s)),o=t.mul(e.oneMinus()),l=t.mul(e.mul(a).oneMinus()),c=t.mul(e.mul(a.oneMinus()).oneMinus());Le(s.equal(P(0)),()=>{i.assign(D(t,c,o))}).ElseIf(s.equal(P(1)),()=>{i.assign(D(l,t,o))}).ElseIf(s.equal(P(2)),()=>{i.assign(D(o,t,c))}).ElseIf(s.equal(P(3)),()=>{i.assign(D(o,l,t))}).ElseIf(s.equal(P(4)),()=>{i.assign(D(c,o,t))}).Else(()=>{i.assign(D(t,o,l))})}),i}).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),kO=U(([n])=>{const e=D(n).toVar(),t=E(e.x).toVar(),i=E(e.y).toVar(),r=E(e.z).toVar(),s=E(xi(t,xi(i,r))).toVar(),a=E(ft(t,ft(i,r))).toVar(),o=E(a.sub(s)).toVar(),l=E().toVar(),c=E().toVar(),u=E().toVar();return u.assign(a),Le(a.greaterThan(0),()=>{c.assign(o.div(a))}).Else(()=>{c.assign(0)}),Le(c.lessThanEqual(0),()=>{l.assign(0)}).Else(()=>{Le(t.greaterThanEqual(a),()=>{l.assign(i.sub(r).div(o))}).ElseIf(i.greaterThanEqual(a),()=>{l.assign(zt(2,r.sub(t).div(o)))}).Else(()=>{l.assign(zt(4,t.sub(i).div(o)))}),l.mulAssign(1/6),Le(l.lessThan(0),()=>{l.addAssign(1)})}),D(l,c,u)}).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),HO=U(([n])=>{const e=D(n).toVar(),t=pf(wf(e,D(.04045))).toVar(),i=D(e.div(12.92)).toVar(),r=D(Ji(ft(e.add(D(.055)),D(0)).div(1.055),D(2.4))).toVar();return rt(i,r,t)}).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),IS=(n,e)=>{n=E(n),e=E(e);const t=z(e.dFdx(),e.dFdy()).length().mul(.7071067811865476);return Ki(n.sub(t),n.add(t),e)},LS=(n,e,t,i)=>rt(n,e,t[i].clamp()),GO=(n,e,t=nt())=>LS(n,e,t,"x"),WO=(n,e,t=nt())=>LS(n,e,t,"y"),PS=(n,e,t,i,r)=>rt(n,e,IS(t,i[r])),jO=(n,e,t,i=nt())=>PS(n,e,t,i,"x"),XO=(n,e,t,i=nt())=>PS(n,e,t,i,"y"),qO=(n=1,e=0,t=nt())=>t.mul(n).add(e),YO=(n,e=1)=>(n=E(n),n.abs().pow(e).mul(n.sign())),$O=(n,e=1,t=.5)=>E(n).sub(t).mul(e).add(t),JO=(n=nt(),e=1,t=0)=>t0(n.convert("vec2|vec3")).mul(e).add(t),KO=(n=nt(),e=1,t=0)=>i0(n.convert("vec2|vec3")).mul(e).add(t),ZO=(n=nt(),e=1,t=0)=>(n=n.convert("vec2|vec3"),ae(i0(n),t0(n.add(z(19,73)))).mul(e).add(t)),QO=(n=nt(),e=1)=>UO(n.convert("vec2|vec3"),e,P(1)),eF=(n=nt(),e=1)=>FO(n.convert("vec2|vec3"),e,P(1)),tF=(n=nt(),e=1)=>BO(n.convert("vec2|vec3"),e,P(1)),iF=(n=nt())=>bO(n.convert("vec2|vec3")),rF=(n=nt(),e=3,t=2,i=.5,r=1)=>wd(n,P(e),t,i).mul(r),nF=(n=nt(),e=3,t=2,i=.5,r=1)=>AO(n,P(e),t,i).mul(r),sF=(n=nt(),e=3,t=2,i=.5,r=1)=>RS(n,P(e),t,i).mul(r),aF=(n=nt(),e=3,t=2,i=.5,r=1)=>NO(n,P(e),t,i).mul(r),DS=U(([n,e])=>{const t=n.x,i=n.y,r=n.z;let s=e.element(0).mul(.886227);return s=s.add(e.element(1).mul(2*.511664).mul(i)),s=s.add(e.element(2).mul(2*.511664).mul(r)),s=s.add(e.element(3).mul(2*.511664).mul(t)),s=s.add(e.element(4).mul(2*.429043).mul(t).mul(i)),s=s.add(e.element(5).mul(2*.429043).mul(i).mul(r)),s=s.add(e.element(6).mul(r.mul(r).mul(.743125).sub(.247708))),s=s.add(e.element(7).mul(2*.429043).mul(t).mul(r)),s=s.add(e.element(8).mul(.429043).mul(lt(t,t).sub(lt(i,i)))),s});class US extends ps{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=fe(0).setGroup(xt),this.decayExponentNode=fe(0).setGroup(xt)}update(e){const{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setup(e){const{colorNode:t,cutoffDistanceNode:i,decayExponentNode:r,light:s}=this,a=e.context.lightingModel,o=bd(s).sub(Pi),l=o.normalize(),c=o.length(),u=$g({lightDistance:c,cutoffDistance:i,decayExponent:r}),h=t.mul(u),d=e.context.reflectedLight;a.direct({lightDirection:l,lightColor:h,reflectedLight:d},e.stack,e)}}class OS extends ps{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setup(e){super.setup(e);const t=e.context.lightingModel,i=this.colorNode,r=Zg(this.light),s=e.context.reflectedLight;t.direct({lightDirection:r,lightColor:i,reflectedLight:s},e.stack,e)}}const r0=new Re,Ed=new Re;let mc=null;class FS extends ps{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=fe(new N).setGroup(xt),this.halfWidth=fe(new N).setGroup(xt)}update(e){super.update(e);const{light:t}=this,i=e.camera.matrixWorldInverse;Ed.identity(),r0.copy(t.matrixWorld),r0.premultiply(i),Ed.extractRotation(r0),this.halfWidth.value.set(t.width*.5,0,0),this.halfHeight.value.set(0,t.height*.5,0),this.halfWidth.value.applyMatrix4(Ed),this.halfHeight.value.applyMatrix4(Ed)}setup(e){super.setup(e);let t,i;e.isAvailable("float32Filterable")?(t=yt(mc.LTC_FLOAT_1),i=yt(mc.LTC_FLOAT_2)):(t=yt(mc.LTC_HALF_1),i=yt(mc.LTC_HALF_2));const{colorNode:r,light:s}=this,a=e.context.lightingModel,o=bd(s),l=e.context.reflectedLight;a.directRectArea({lightColor:r,lightPosition:o,halfWidth:this.halfWidth,halfHeight:this.halfHeight,reflectedLight:l,ltc_1:t,ltc_2:i},e.stack,e)}static setLTC(e){mc=e}}class n0 extends ps{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=fe(0).setGroup(xt),this.penumbraCosNode=fe(0).setGroup(xt),this.cutoffDistanceNode=fe(0).setGroup(xt),this.decayExponentNode=fe(0).setGroup(xt)}update(e){super.update(e);const{light:t}=this;this.coneCosNode.value=Math.cos(t.angle),this.penumbraCosNode.value=Math.cos(t.angle*(1-t.penumbra)),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}getSpotAttenuation(e){const{coneCosNode:t,penumbraCosNode:i}=this;return Ki(t,i,e)}setup(e){super.setup(e);const t=e.context.lightingModel,{colorNode:i,cutoffDistanceNode:r,decayExponentNode:s,light:a}=this,o=bd(a).sub(Pi),l=o.normalize(),c=l.dot(Zg(a)),u=this.getSpotAttenuation(c),h=o.length(),d=$g({lightDistance:h,cutoffDistance:r,decayExponent:s}),p=i.mul(u).mul(d),m=e.context.reflectedLight;t.direct({lightDirection:l,lightColor:p,reflectedLight:m},e.stack,e)}}class VS extends n0{static get type(){return"IESSpotLightNode"}getSpotAttenuation(e){const t=this.light.iesMap;let i=null;if(t&&t.isTexture===!0){const r=e.acos().mul(1/Math.PI);i=yt(t,z(r,0),0).r}else i=super.getSpotAttenuation(e);return i}}class BS extends ps{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}class zS extends ps{static get type(){return"HemisphereLightNode"}constructor(e=null){super(e),this.lightPositionNode=Kg(e),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=fe(new xe).setGroup(xt)}update(e){const{light:t}=this;super.update(e),this.lightPositionNode.object3d=t,this.groundColorNode.value.copy(t.groundColor).multiplyScalar(t.intensity)}setup(e){const{colorNode:t,groundColorNode:i,lightDirectionNode:r}=this,s=hr.dot(r).mul(.5).add(.5),a=rt(i,t,s);e.context.irradiance.addAssign(a)}}class kS extends ps{static get type(){return"LightProbeNode"}constructor(e=null){super(e);const t=[];for(let i=0;i<9;i++)t.push(new N);this.lightProbe=mn(t)}update(e){const{light:t}=this;super.update(e);for(let i=0;i<9;i++)this.lightProbe.array[i].copy(t.sh.coefficients[i]).multiplyScalar(t.intensity)}setup(e){const t=DS(Wh,this.lightProbe);e.context.irradiance.addAssign(t)}}class oF{parseFunction(){console.warn("Abstract function.")}}class HS{constructor(e,t,i="",r=""){this.type=e,this.inputs=t,this.name=i,this.precision=r}getCode(){console.warn("Abstract function.")}}HS.isNodeFunction=!0;const lF=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,cF=/[a-z_0-9]+/ig,GS="#pragma main",uF=n=>{n=n.trim();const e=n.indexOf(GS),t=e!==-1?n.slice(e+GS.length):n,i=t.match(lF);if(i!==null&&i.length===5){const r=i[4],s=[];let a=null;for(;(a=cF.exec(r))!==null;)s.push(a);const o=[];let l=0;for(;l<s.length;){const m=s[l][0]==="const";m===!0&&l++;let v=s[l][0];v==="in"||v==="out"||v==="inout"?l++:v="";const f=s[l++][0];let g=Number.parseInt(s[l][0]);Number.isNaN(g)===!1?l++:g=null;const x=s[l++][0];o.push(new Vg(f,x,g,v,m))}const c=t.substring(i[0].length),u=i[3]!==void 0?i[3]:"",h=i[2],d=i[1]!==void 0?i[1]:"",p=e!==-1?n.slice(0,e):"";return{type:h,inputs:o,name:u,precision:d,inputsCode:r,blockCode:c,headerCode:p}}else throw new Error("FunctionNode: Function is not a GLSL code.")};class hF extends HS{constructor(e){const{type:t,inputs:i,name:r,precision:s,inputsCode:a,blockCode:o,headerCode:l}=uF(e);super(t,i,r,s),this.inputsCode=a,this.blockCode=o,this.headerCode=l}getCode(e=this.name){let t;const i=this.blockCode;if(i!==""){const{type:r,inputsCode:s,headerCode:a,precision:o}=this;let l=`${r} ${e} ( ${s.trim()} )`;o!==""&&(l=`${o} ${l}`),t=a+l+i}else t="";return t}}class WS extends oF{parseFunction(e){return new hF(e)}}class dF{constructor(){this.lightNodes=new WeakMap,this.materialNodes=new Map,this.toneMappingNodes=new Map,this.colorSpaceNodes=new Map}fromMaterial(e){if(e.isNodeMaterial)return e;let t=null;const i=this.getMaterialNodeClass(e.type);if(i!==null){t=new i;for(const r in e)t[r]=e[r]}return t}addColorSpace(e,t){this.addType(e,t,this.colorSpaceNodes)}getColorSpaceFunction(e){return this.colorSpaceNodes.get(e)||null}addToneMapping(e,t){this.addType(e,t,this.toneMappingNodes)}getToneMappingFunction(e){return this.toneMappingNodes.get(e)||null}getMaterialNodeClass(e){return this.materialNodes.get(e)||null}addMaterial(e,t){this.addType(e,t.name,this.materialNodes)}getLightNodeClass(e){return this.lightNodes.get(e)||null}addLight(e,t){this.addClass(e,t,this.lightNodes)}addType(e,t,i){if(i.has(t)){console.warn(`Redefinition of node ${t}`);return}if(typeof e!="function")throw new Error(`Node class ${e.name} is not a class.`);if(typeof t=="function"||typeof t=="object")throw new Error(`Base class ${t} is not a class.`);i.set(t,e)}addClass(e,t,i){if(i.has(t)){console.warn(`Redefinition of node ${t.name}`);return}if(typeof e!="function")throw new Error(`Node class ${e.name} is not a class.`);if(typeof t!="function")throw new Error(`Base class ${t.name} is not a class.`);i.set(t,e)}}class pF extends El{constructor(e,t,i,r,s,a){super(e,t,i,r,s,a),this.iesMap=null}copy(e,t){return super.copy(e,t),this.iesMap=e.iesMap,this}}class jS extends dF{constructor(){super(),this.addLight(US,fh),this.addLight(OS,gh),this.addLight(FS,Fm),this.addLight(n0,El),this.addLight(BS,vh),this.addLight(zS,mh),this.addLight(kS,Vm),this.addLight(VS,pF),this.addToneMapping(yS,wc),this.addToneMapping(xS,Ec),this.addToneMapping(_S,Jd),this.addToneMapping(MS,Ac),this.addToneMapping(bS,Nc),this.addToneMapping(TS,Cc),this.addColorSpace(vS,Bh(nr,Fi)),this.addColorSpace(gS,Bh(Fi,nr))}}if(typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"169"}})),typeof window<"u"){try{import.meta&&(window.__THREE__IMPORTS__||(window.__THREE__IMPORTS__=[]),window.__THREE__IMPORTS__.push({url:import.meta.url,revision:"169"}))}catch{}window.__THREE__?(console.warn("WARNING: Multiple instances of Three.js being imported. Existing: "+window.__THREE__+", new: 169"),console.warn(window.__THREE__IMPORTS__)):window.__THREE__="169"}const mF=Object.freeze(Object.defineProperty({__proto__:null,ACESFilmicToneMapping:Ac,AONode:q1,AddEquation:Vn,AddOperation:$d,AdditiveAnimationBlendMode:lp,AdditiveBlending:Eo,AfterImageNode:PT,AgXToneMapping:Nc,AlphaFormat:tp,AlwaysCompare:av,AlwaysDepth:No,AlwaysStencilFunc:ru,AmbientLight:vh,AmbientLightNode:BS,AnaglyphPassNode:iS,AnalyticLightNode:ps,AnamorphicNode:OT,AnimationAction:vx,AnimationClip:io,AnimationLoader:DI,AnimationMixer:yx,AnimationObjectGroup:QI,AnimationUtils:RI,ArcCurve:Ly,ArrayCamera:Yp,ArrayElementNode:ss,ArrowHelper:p2,AssignNode:d_,AttachedBindMode:Kd,AttributeNode:Hf,Audio:Hm,AudioAnalyser:GI,AudioContext:_h,AudioListener:px,AudioLoader:lx,AxesHelper:Bx,BRDF_GGX:pg,BRDF_Lambert:ia,BackSide:si,BasicDepthPacking:cp,BasicEnvironmentNode:ed,BasicNodeLibrary:jS,BasicShadowMap:ew,BatchNode:F1,BatchedMesh:om,BloomNode:$T,Bone:ku,BooleanKeyframeTrack:zs,Box2:s2,Box3:Bi,Box3Helper:Fx,BoxGeometry:yn,BoxHelper:Ox,Break:Zh,BufferAttribute:wt,BufferAttributeNode:MM,BufferGeometry:ct,BufferGeometryLoader:rx,BufferNode:Xh,BumpMapNode:r1,BypassNode:EM,ByteType:Zd,Cache:Rn,CacheNode:wM,Camera:ol,CameraHelper:Ux,CanvasTexture:Iy,CapsuleGeometry:Nd,CatmullRomCurve3:Py,CineonToneMapping:Jd,CircleGeometry:Cd,ClampToEdgeWrapping:gr,Clock:km,CodeNode:Cg,Color:xe,ColorKeyframeTrack:dh,ColorManagement:vt,ColorSpaceNode:jl,CompressedArrayTexture:Cy,CompressedCubeTexture:Ry,CompressedTexture:vl,CompressedTextureLoader:UI,ComputeNode:TM,ConeGeometry:Rd,ConstNode:Fr,ConstantAlphaFactor:L0,ConstantColorFactor:R0,ContextNode:Uf,Continue:TL,Controls:kx,ConvertNode:sf,CubeCamera:wu,CubeReflectionMapping:fr,CubeRefractionMapping:Ar,CubeTexture:Ns,CubeTextureLoader:OI,CubeTextureNode:$M,CubeUVReflectionMapping:ys,CubicBezierCurve:vm,CubicBezierCurve3:Uy,CubicInterpolant:Yy,CullFaceBack:kd,CullFaceFront:v0,CullFaceFrontBack:QS,CullFaceNone:g0,Curve:Or,CurvePath:Fy,CustomBlending:Xd,CustomToneMapping:D0,CylinderGeometry:ha,Cylindrical:n2,DFGApprox:mg,D_GGX:hb,Data3DTexture:ou,DataArrayTexture:el,DataTexture:Ur,DataTextureLoader:Ky,DataUtils:Sv,DecrementStencilOp:W0,DecrementWrapStencilOp:X0,DefaultLoadingManager:Pm,DenoiseNode:XT,DepthFormat:jn,DepthOfFieldNode:VT,DepthStencilFormat:Xn,DepthTexture:Ds,DetachedBindMode:U0,DirectionalLight:gh,DirectionalLightHelper:Dx,DirectionalLightNode:OS,Discard:IM,DiscreteInterpolant:$y,DisplayP3ColorSpace:qo,DodecahedronGeometry:Id,DotScreenNode:BT,DoubleSide:Gr,DstAlphaFactor:w0,DstColorFactor:A0,DynamicCopyUsage:dw,DynamicDrawUsage:Ms,DynamicReadUsage:cw,EPSILON:L_,EdgesGeometry:Tm,EllipseCurve:Ku,EnvironmentNode:Fb,EqualCompare:iv,EqualDepth:Ro,EqualStencilFunc:J0,EquirectUVNode:nb,EquirectangularReflectionMapping:zn,EquirectangularRefractionMapping:kn,Euler:dr,EventDispatcher:vr,ExpressionNode:RM,ExtrudeGeometry:vc,FXAANode:qT,F_Schlick:go,FileLoader:Kr,FilmNode:kT,Float16BufferAttribute:wv,Float32BufferAttribute:De,FloatType:Oi,Fn:U,Fog:Jp,FogExp2:Ad,FogExp2Node:cS,FogNode:xd,FogRangeNode:lS,FramebufferTexture:dm,FrontFacingNode:zM,FrontSide:an,Frustum:za,FunctionCallNode:m_,FunctionNode:Rg,FunctionOverloadingNode:uT,GLBufferAttribute:r2,GLSL1:mw,GLSL3:nu,GLSLNodeParser:WS,GTAONode:jT,GaussianBlurNode:IT,GreaterCompare:rv,GreaterDepth:Lo,GreaterEqualCompare:sv,GreaterEqualDepth:Io,GreaterEqualStencilFunc:ev,GreaterStencilFunc:Z0,GridHelper:Ix,Group:Us,HalfFloatType:wi,HemisphereLight:mh,HemisphereLightHelper:u2,HemisphereLightNode:zS,IESSpotLightNode:VS,INFINITY:V2,IcosahedronGeometry:Ld,If:Le,ImageBitmapLoader:ox,ImageLoader:wl,ImageUtils:pv,IncrementStencilOp:G0,IncrementWrapStencilOp:j0,IndexNode:Bt,InstanceNode:U1,InstancedBufferAttribute:Nn,InstancedBufferGeometry:Bm,InstancedInterleavedBuffer:jm,InstancedMesh:rm,InstancedPointsNodeMaterial:VL,Int16BufferAttribute:Zw,Int32BufferAttribute:Qw,Int8BufferAttribute:$w,IntType:ga,InterleavedBuffer:Wa,InterleavedBufferAttribute:On,Interpolant:Za,InterpolateDiscrete:Ma,InterpolateLinear:jo,InterpolateSmooth:tu,InvertStencilOp:q0,IrradianceNode:J1,JoinNode:jx,KeepStencilOp:qn,KeyframeTrack:Jr,LOD:Qp,LatheGeometry:gc,Layers:rl,LessCompare:dp,LessDepth:Co,LessEqualCompare:pp,LessEqualDepth:Bn,LessEqualStencilFunc:K0,LessStencilFunc:$0,Light:rs,LightProbe:Vm,LightProbeNode:kS,LightingContextNode:Y1,LightingModel:lc,LightingNode:ta,LightsNode:j1,Line:Cn,Line2NodeMaterial:WL,Line3:Ex,LineBasicMaterial:Ni,LineBasicNodeMaterial:zL,LineCurve:ym,LineCurve3:Oy,LineDashedMaterial:hh,LineDashedNodeMaterial:HL,LineLoop:cm,LineSegments:$r,LinearDisplayP3ColorSpace:ba,LinearFilter:Lt,LinearInterpolant:Lm,LinearMipMapLinearFilter:O0,LinearMipMapNearestFilter:rw,LinearMipmapLinearFilter:ji,LinearMipmapNearestFilter:Gn,LinearSRGBColorSpace:nr,LinearToneMapping:wc,LinearTransfer:Yo,Loader:Hi,LoaderUtils:yh,LoadingManager:ph,Loop:gt,LoopNode:k1,LoopOnce:ap,LoopPingPong:F0,LoopRepeat:op,LuminanceAlphaFormat:np,LuminanceFormat:rp,Lut3DNode:HT,MOUSE:m0,MRTNode:cT,MatcapUVNode:kb,Material:hi,MaterialLoader:_c,MaterialNode:Z,MaterialReferenceNode:JM,MathUtils:su,Matrix2:s0,Matrix3:Ke,Matrix4:Re,MaxEquation:qd,MaxMipLevelNode:UM,Mesh:Ft,MeshBasicMaterial:Yr,MeshBasicNodeMaterial:QL,MeshDepthMaterial:Du,MeshDistanceMaterial:Xp,MeshLambertMaterial:uh,MeshLambertNodeMaterial:nP,MeshMatcapMaterial:Cm,MeshMatcapNodeMaterial:HP,MeshNormalMaterial:ch,MeshNormalNodeMaterial:qL,MeshPhongMaterial:lh,MeshPhongNodeMaterial:aP,MeshPhysicalMaterial:oh,MeshPhysicalNodeMaterial:zb,MeshSSSNodeMaterial:OP,MeshStandardMaterial:Sl,MeshStandardNodeMaterial:Bb,MeshToonMaterial:Nm,MeshToonNodeMaterial:zP,MinEquation:_0,MirroredRepeatWrapping:ma,MixOperation:Yd,ModelNode:tn,ModelViewProjectionNode:L1,MorphNode:G1,MultiplyBlending:jd,MultiplyOperation:pa,NearestFilter:$t,NearestMipMapLinearFilter:iw,NearestMipMapNearestFilter:tw,NearestMipmapLinearFilter:Mn,NearestMipmapNearestFilter:Ic,NeutralToneMapping:Cc,NeverCompare:tv,NeverDepth:Ao,NeverStencilFunc:Y0,NoBlending:Er,NoColorSpace:Cr,NoToneMapping:mr,Node:qe,NodeAttribute:Eg,NodeBuilder:oT,NodeCache:ld,NodeCode:Jb,NodeFrame:lT,NodeFunctionInput:Vg,NodeLoader:Xb,NodeMaterial:bt,NodeMaterialLoader:qb,NodeMaterialObserver:Hx,NodeObjectLoader:ZP,NodeShaderStage:ef,NodeType:v2,NodeUniform:Yb,NodeUpdateType:je,NodeUtils:g2,NodeVar:Ag,NodeVarying:$b,NormalAnimationBlendMode:iu,NormalBlending:_n,NormalMapNode:i1,NotEqualCompare:nv,NotEqualDepth:Po,NotEqualStencilFunc:Q0,NumberKeyframeTrack:Qa,Object3D:_t,Object3DNode:St,ObjectLoader:nx,ObjectSpaceNormalMap:hp,OctahedronGeometry:So,OneFactor:b0,OneMinusConstantAlphaFactor:P0,OneMinusConstantColorFactor:I0,OneMinusDstAlphaFactor:E0,OneMinusDstColorFactor:N0,OneMinusSrcAlphaFactor:Sc,OneMinusSrcColorFactor:S0,OrthographicCamera:Is,OscNode:gi,OutputStructNode:Bg,P3Primaries:Jo,PCFShadowMap:Hd,PCFSoftShadowMap:Gd,PI:Zs,PI2:B2,PMREMGenerator:Cu,PMREMNode:Db,ParallaxBarrierPassNode:rS,ParameterNode:Ng,PassNode:Ti,Path:_l,PerspectiveCamera:di,PhongLightingModel:hg,PhysicalLightingModel:rd,PixelationPassNode:KT,Plane:ln,PlaneGeometry:ua,PlaneHelper:d2,PointLight:fh,PointLightHelper:l2,PointLightNode:US,PointUVNode:_T,Points:hm,PointsMaterial:Ja,PointsNodeMaterial:WP,PolarGridHelper:h2,PolyhedronGeometry:ms,PositionalAudio:fx,PosterizeNode:wT,PropertyBinding:Tt,PropertyMixer:gx,PropertyNode:Et,QuadraticBezierCurve:xm,QuadraticBezierCurve3:_m,Quaternion:qi,QuaternionKeyframeTrack:eo,QuaternionLinearInterpolant:Jy,RED_GREEN_RGTC2_Format:Qc,RED_RGTC1_Format:sp,REVISION:"169",RGBADepthPacking:up,RGBAFormat:Ei,RGBAIntegerFormat:Uc,RGBA_ASTC_10x10_Format:qc,RGBA_ASTC_10x5_Format:Wc,RGBA_ASTC_10x6_Format:jc,RGBA_ASTC_10x8_Format:Xc,RGBA_ASTC_12x10_Format:Yc,RGBA_ASTC_12x12_Format:$c,RGBA_ASTC_4x4_Format:Go,RGBA_ASTC_5x4_Format:Vc,RGBA_ASTC_5x5_Format:Bc,RGBA_ASTC_6x5_Format:zc,RGBA_ASTC_6x6_Format:Wo,RGBA_ASTC_8x5_Format:kc,RGBA_ASTC_8x6_Format:Hc,RGBA_ASTC_8x8_Format:Gc,RGBA_BPTC_Format:_a,RGBA_ETC2_EAC_Format:Ho,RGBA_PVRTC_2BPPV1_Format:Fc,RGBA_PVRTC_4BPPV1_Format:Bo,RGBA_S3TC_DXT1_Format:ya,RGBA_S3TC_DXT3_Format:Fo,RGBA_S3TC_DXT5_Format:xa,RGBDepthPacking:sw,RGBFormat:ip,RGBIntegerFormat:nw,RGBShiftNode:zT,RGB_BPTC_SIGNED_Format:Jc,RGB_BPTC_UNSIGNED_Format:Kc,RGB_ETC1_Format:zo,RGB_ETC2_Format:ko,RGB_PVRTC_2BPPV1_Format:Oc,RGB_PVRTC_4BPPV1_Format:Vo,RGB_S3TC_DXT1_Format:Oo,RGDepthPacking:aw,RGFormat:va,RGIntegerFormat:Dc,RTTNode:vT,RangeNode:uS,RawShaderMaterial:Am,Ray:Es,Raycaster:Mx,Rec709Primaries:$o,RectAreaLight:Fm,RectAreaLightNode:FS,RedFormat:Do,RedIntegerFormat:Uo,ReferenceNode:Jl,ReflectorNode:gT,ReinhardToneMapping:Ec,RemapNode:kf,RenderOutputNode:LM,RenderTarget:ui,RendererReferenceNode:gM,RepeatWrapping:Hn,ReplaceStencilOp:H0,Return:W2,ReverseSubtractEquation:x0,RingGeometry:yc,RotateNode:Gb,SIGNED_RED_GREEN_RGTC2_Format:eu,SIGNED_RED_RGTC1_Format:Zc,SRGBColorSpace:Fi,SRGBTransfer:Ot,SSAAPassNode:ZT,Scene:Uu,SceneNode:sn,Schlick_to_F0:pb,ScreenNode:ri,ScriptableNode:oS,ScriptableValueNode:sS,SetNode:Xx,ShaderChunk:dt,ShaderLib:Dr,ShaderMaterial:Pr,ShaderNode:Il,ShadowMaterial:ah,ShadowNodeMaterial:$P,Shape:is,ShapeGeometry:Pd,ShapePath:zx,ShapeUtils:nn,ShortType:Qd,Skeleton:fc,SkeletonHelper:o2,SkinnedMesh:im,SkinningNode:rg,SobelOperatorNode:FT,Source:Yn,Sphere:Ai,SphereGeometry:wo,Spherical:Tx,SphericalHarmonics3:ix,SplineCurve:Mm,SplitNode:Ah,SpotLight:El,SpotLightHelper:a2,SpotLightNode:n0,Sprite:Zp,SpriteMaterial:cl,SpriteNodeMaterial:XP,SpriteSheetUVNode:hT,SrcAlphaFactor:Tc,SrcAlphaSaturateFactor:C0,SrcColorFactor:T0,StackNode:Zb,StaticCopyUsage:hw,StaticDrawUsage:Ta,StaticReadUsage:lw,StereoCamera:zm,StereoPassNode:QT,StorageArrayElementNode:dT,StorageBufferNode:Xg,StorageTextureNode:bT,StreamCopyUsage:pw,StreamDrawUsage:ow,StreamReadUsage:uw,StringKeyframeTrack:ks,SubtractEquation:y0,SubtractiveBlending:Wd,TBNViewMatrix:ea,TOUCH:f0,TangentSpaceNormalMap:on,TempNode:pt,TetrahedronGeometry:Dd,Texture:Wt,Texture3DNode:Wb,TextureLoader:Zy,TextureNode:dn,TextureSizeNode:DM,TextureUtils:UR,TimerNode:Si,ToneMappingNode:yM,ToonOutlinePassNode:nS,TorusGeometry:xc,TorusKnotGeometry:Ud,TransitionNode:JT,Triangle:er,TriangleFanDrawMode:z0,TriangleStripDrawMode:B0,TrianglesDrawMode:V0,TriplanarTexturesNode:pT,TubeGeometry:Od,UVMapping:Rc,Uint16BufferAttribute:vu,Uint32BufferAttribute:Pp,Uint8BufferAttribute:Jw,Uint8ClampedBufferAttribute:Kw,Uniform:xx,UniformArrayNode:qf,UniformGroupNode:mf,UniformNode:Ys,UniformsGroup:i2,UniformsLib:Me,UniformsUtils:Op,UnsignedByteType:Wr,UnsignedInt248Type:Wn,UnsignedInt5999Type:ep,UnsignedIntType:Nr,UnsignedShort4444Type:Lc,UnsignedShort5551Type:Pc,UnsignedShortType:fa,UserDataNode:ST,VSMShadowMap:rr,V_GGX_SmithCorrelated:ub,VarNode:cM,VaryingNode:uM,Vector2:J,Vector3:N,Vector4:st,VectorKeyframeTrack:to,VertexColorNode:xT,VideoTexture:Ny,ViewportDepthNode:Qi,ViewportDepthTextureNode:eb,ViewportSharedTextureNode:ET,ViewportTextureNode:sc,VolumeNodeMaterial:KP,WebGL3DRenderTarget:Bw,WebGLArrayRenderTarget:Vw,WebGLCoordinateSystem:Rr,WebGLCubeRenderTarget:Eu,WebGLMultipleRenderTargets:m2,WebGLRenderTarget:Ir,WebGLRenderer:oy,WebGLUtils:ay,WebGPUCoordinateSystem:bs,WireframeGeometry:Em,WrapAroundEnding:Xo,ZeroCurvatureEnding:xs,ZeroFactor:M0,ZeroSlopeEnding:_s,ZeroStencilOp:k0,abs:It,acesFilmicToneMapping:MS,acos:Fh,add:zt,addMethodChaining:te,addNodeElement:j2,afterImage:oD,agxToneMapping:bS,all:Ef,alphaT:Ph,anaglyphPass:GD,anamorphic:pD,and:M_,anisotropy:os,anisotropyB:Js,anisotropyT:Fl,any:P_,ao:TD,append:e_,arrayBuffer:D2,asin:B_,assign:p_,atan:z_,atan2:$_,atomicAdd:kU,atomicAnd:jU,atomicFunc:Un,atomicMax:GU,atomicMin:WU,atomicOr:XU,atomicStore:zU,atomicSub:HU,atomicXor:qU,attenuationColor:bf,attenuationDistance:Mf,attribute:_i,backgroundBlurriness:$3,backgroundIntensity:J3,batch:V1,billboarding:dU,bitAnd:w_,bitNot:E_,bitOr:A_,bitXor:N_,bitangentGeometry:hL,bitangentLocal:dL,bitangentView:ZM,bitangentWorld:pL,bitcast:z2,bleach:MU,bloom:LD,blur:Lb,bool:as,buffer:$l,bufferAttribute:Xl,bumpMap:n1,burn:gU,bvec2:r_,bvec3:pf,bvec4:o_,bypass:AM,cache:ql,call:f_,cameraFar:co,cameraLogDepth:FM,cameraNear:lo,cameraNormalMatrix:$2,cameraPosition:Gf,cameraProjectionMatrix:lr,cameraProjectionMatrixInverse:q2,cameraViewMatrix:cr,cameraWorldMatrix:Y2,cbrt:iM,ceil:Cf,checker:YU,cineonToneMapping:_S,clamp:li,clearcoat:Rh,clearcoatRoughness:Ol,code:cd,color:t_,colorSpaceToWorking:Bf,colorToDirection:jL,compute:SM,cond:oM,context:Of,convert:c_,convertToTexture:Zi,cos:br,createCanvasElement:cv,cross:oo,cubeTexture:jh,dFdx:G_,dFdy:W_,dashSize:Ks,defaultBuildStages:rf,defaultShaderStages:tf,defined:Rl,degrees:O_,denoise:ED,densityFog:JD,depth:cg,depthPass:sD,difference:Z_,diffuseColor:Nt,directionToColor:rb,dispersion:Tf,distance:K_,div:Qr,dodge:vU,dof:fD,dot:qt,dotScreen:gD,drawIndex:D1,dynamicBufferAttribute:bM,element:l_,emissive:gf,equal:g_,equals:D_,equirectUV:ug,exp:Af,exp2:Oh,expression:us,faceDirection:Yl,faceForward:nM,film:yD,float:E,floor:ls,fog:YD,fract:cs,frameGroup:O2,frameId:D3,frontFacing:kM,fwidth:q_,fxaa:AD,gain:aU,gapSize:Bl,gaussianBlur:aD,getColorSpaceMethod:Bh,getConstNodeType:Qx,getCurrentStack:df,getDirection:Rb,getDistanceAttenuation:$g,getGeometryRoughness:cb,getRoughness:dg,getShIrradianceAt:DS,getTextureIndex:zg,global:yd,glsl:r3,glslFn:n3,grayscale:lD,greaterThan:wf,greaterThanEqual:__,hash:sU,highPrecisionModelNormalViewMatrix:aL,highPrecisionModelViewMatrix:sL,hue:hD,instance:O1,instanceIndex:tc,instancedBufferAttribute:zh,instancedDynamicBufferAttribute:zf,int:P,inverseSqrt:F_,invocationLocalIndex:ML,invocationSubgroupIndex:_L,ior:zl,iridescence:Lh,iridescenceIOR:vf,iridescenceThickness:yf,ivec2:un,ivec3:n_,ivec4:s_,js:t3,label:lM,length:Qs,lengthSq:Lf,lessThan:y_,lessThanEqual:x_,lightPosition:Kg,lightTargetDirection:Zg,lightTargetPosition:hS,lightViewPosition:bd,lightingContext:$1,lights:X1,linearDepth:Qh,linearSRGBTosRGB:vS,linearToneMapping:yS,localId:RU,log:Nf,log2:kl,loop:SL,luminance:Ui,lut3D:xD,mat2:Dl,mat3:yi,mat4:qs,matcapUV:Hb,materialAOMap:I1,materialAlphaTest:a1,materialAnisotropy:_1,materialAnisotropyVector:po,materialAttenuationColor:N1,materialAttenuationDistance:A1,materialClearcoat:m1,materialClearcoatNormal:g1,materialClearcoatRoughness:f1,materialColor:ho,materialDispersion:R1,materialEmissive:l1,materialIOR:E1,materialIridescence:M1,materialIridescenceIOR:b1,materialIridescenceThickness:T1,materialLightMap:tg,materialLineDashOffset:eg,materialLineDashSize:Zf,materialLineGapSize:Qf,materialLineScale:Jh,materialLineWidth:Kh,materialMetalness:d1,materialNormal:p1,materialOpacity:Yh,materialPointWidth:C1,materialReference:rn,materialReflectivity:$h,materialRefractionRatio:WM,materialRotation:v1,materialRoughness:h1,materialSheen:y1,materialSheenRoughness:x1,materialShininess:o1,materialSpecular:c1,materialSpecularColor:u1,materialSpecularIntensity:Kf,materialSpecularStrength:ec,materialThickness:w1,materialTransmission:S1,max:ft,maxMipLevel:OM,metalness:Ul,min:xi,mix:rt,mixElement:sM,mod:Vh,modInt:Sf,modelDirection:tL,modelNormalMatrix:VM,modelPosition:iL,modelScale:rL,modelViewMatrix:pn,modelViewPosition:nL,modelViewProjection:ig,modelWorldMatrix:Br,modelWorldMatrixInverse:BM,morphReference:W1,motionBlur:_U,mrt:pd,mul:lt,mx_aastep:IS,mx_cell_noise_float:iF,mx_contrast:$O,mx_fractal_noise_float:rF,mx_fractal_noise_vec2:nF,mx_fractal_noise_vec3:sF,mx_fractal_noise_vec4:aF,mx_hsvtorgb:zO,mx_noise_float:JO,mx_noise_vec3:KO,mx_noise_vec4:ZO,mx_ramplr:GO,mx_ramptb:WO,mx_rgbtohsv:kO,mx_safepower:YO,mx_splitlr:jO,mx_splittb:XO,mx_srgb_texture_to_lin_rec709:HO,mx_transform_uv:qO,mx_worley_noise_float:QO,mx_worley_noise_vec2:eF,mx_worley_noise_vec3:tF,negate:k_,neutralToneMapping:TS,nodeArray:Xs,nodeImmutable:ge,nodeObject:G,nodeObjects:Ll,nodeProxy:K,normalFlat:HM,normalGeometry:Gh,normalLocal:ur,normalMap:Jf,normalView:hr,normalWorld:Wh,normalize:Mr,not:T_,notEqual:v_,numWorkgroups:NU,objectDirection:J2,objectGroup:h_,objectPosition:Z2,objectScale:Q2,objectViewPosition:eL,objectWorldMatrix:K2,oneMinus:H_,or:b_,orthographicDepthToViewZ:PL,oscSawtooth:V3,oscSine:U3,oscSquare:O3,oscTriangle:F3,output:xf,outputStruct:R3,overlay:xU,overloadingFn:Di,parabola:Qg,parallaxBarrierPass:WD,parallaxDirection:e1,parallaxUV:fL,parameter:e3,pass:nD,passTexture:Mo,pcurve:oU,perspectiveDepthToViewZ:lg,pixelationPass:OD,pmremTexture:Ub,pointUV:Y3,pointWidth:F2,positionGeometry:Li,positionLocal:Zt,positionPrevious:kh,positionView:Pi,positionViewDirection:Vt,positionWorld:Hh,positionWorldDirection:Wf,posterize:tD,pow:Ji,pow2:If,pow3:Q_,pow4:eM,property:ar,radians:U_,rand:Df,range:KD,rangeFog:$D,reciprocal:X_,reference:fi,referenceBuffer:Yf,reflect:J_,reflectVector:qM,reflectView:jM,reflector:G3,refract:Pf,refractVector:YM,refractView:XM,reinhardToneMapping:xS,remainder:I_,remap:NM,remapClamp:CM,renderGroup:xt,renderOutput:PM,rendererReference:vM,rgbShift:vD,rotate:wg,rotateUV:uU,roughness:hn,round:j_,rtt:yT,sRGBToLinearSRGB:gS,sampler:X2,saturate:rM,saturation:cD,screen:yU,screenCoordinate:fo,screenSize:mo,screenUV:ds,scriptable:qD,scriptableValue:vd,select:Ri,sepia:bU,setCurrentStack:Pl,shaderStages:nf,sharedUniformGroup:ff,sheen:$s,sheenRoughness:Ih,shiftLeft:C_,shiftRight:R_,shininess:Dh,sign:Hl,sin:Ci,sinc:lU,skinning:bL,skinningReference:z1,smoothstep:Ki,smoothstepElement:aM,sobel:mD,specularColor:or,specularF90:Vl,spherizeUV:hU,split:U2,spritesheetUV:B3,sqrt:en,ssaaPass:BD,stack:ud,step:Gl,stereoPass:kD,storage:K3,storageBarrier:DU,storageObject:Z3,storageTexture:TT,string:P2,sub:Pt,subgroupIndex:xL,subgroupSize:IU,tan:V_,tangentGeometry:qh,tangentLocal:Kl,tangentView:Zl,tangentWorld:KM,temp:Ff,texture:yt,texture3D:jb,textureBarrier:UU,textureBicubic:bb,textureCubeUV:Ib,textureLoad:Vr,textureSize:hs,textureStore:Q3,thickness:_f,threshold:DT,timerDelta:P3,timerGlobal:L3,timerLocal:kg,toOutputColorSpace:dM,toWorkingColorSpace:pM,toneMapping:xM,toneMappingExposure:_M,toonOutlinePass:jD,transformDirection:tM,transformNormal:GM,transformNormalToView:Xf,transformedBentNormalView:t1,transformedBitangentView:QM,transformedBitangentWorld:mL,transformedClearcoatNormalView:uo,transformedNormalView:Yt,transformedNormalWorld:jf,transformedTangentView:$f,transformedTangentWorld:uL,transition:PD,transmission:Uh,transpose:Y_,tri:gn,tri3:dS,triNoise3D:cU,triplanarTexture:k3,triplanarTextures:mT,trunc:Rf,tslFn:L2,uint:_e,uniform:fe,uniformArray:mn,uniformGroup:u_,uniforms:lL,userData:eD,uv:nt,uvec2:i_,uvec3:ao,uvec4:a_,varying:Ii,varyingProperty:Zr,vec2:z,vec3:D,vec4:ae,vectorComponents:ro,velocity:fU,vertexColor:q3,vertexIndex:P1,vibrance:uD,viewZToOrthographicDepth:ac,viewZToPerspectiveDepth:tb,viewport:Pn,viewportBottomLeft:IL,viewportCoordinate:Z1,viewportDepthTexture:og,viewportLinearDepth:DL,viewportMipTexture:Q1,viewportResolution:CL,viewportSafeUV:pU,viewportSharedTexture:iD,viewportSize:K1,viewportTexture:LL,viewportTopLeft:RL,viewportUV:NL,wgsl:i3,wgslFn:s3,workgroupArray:VU,workgroupBarrier:PU,workgroupId:CU,workingToColorSpace:mM,xor:S_},Symbol.toStringTag,{value:"Module"}));export{Ac as ACESFilmicToneMapping,Eo as AdditiveBlending,Nc as AgXToneMapping,No as AlwaysDepth,ru as AlwaysStencilFunc,vh as AmbientLight,io as AnimationClip,yx as AnimationMixer,Yp as ArrayCamera,Hm as Audio,_h as AudioContext,px as AudioListener,lx as AudioLoader,Bx as AxesHelper,si as BackSide,cp as BasicDepthPacking,jS as BasicNodeLibrary,om as BatchedMesh,ku as Bone,Bi as Box3,Fx as Box3Helper,yn as BoxGeometry,Ox as BoxHelper,wt as BufferAttribute,ct as BufferGeometry,ol as Camera,Ux as CameraHelper,Iy as CanvasTexture,gr as ClampToEdgeWrapping,km as Clock,xe as Color,dh as ColorKeyframeTrack,vt as ColorManagement,Cy as CompressedArrayTexture,Ry as CompressedCubeTexture,vl as CompressedTexture,kx as Controls,wu as CubeCamera,Ns as CubeTexture,Or as Curve,Xd as CustomBlending,ha as CylinderGeometry,ou as Data3DTexture,Ur as DataTexture,Ky as DataTextureLoader,Sv as DataUtils,W0 as DecrementStencilOp,X0 as DecrementWrapStencilOp,Pm as DefaultLoadingManager,jn as DepthFormat,Xn as DepthStencilFormat,Ds as DepthTexture,gh as DirectionalLight,Dx as DirectionalLightHelper,qo as DisplayP3ColorSpace,Gr as DoubleSide,Ms as DynamicDrawUsage,Tm as EdgesGeometry,Ro as EqualDepth,J0 as EqualStencilFunc,zn as EquirectangularReflectionMapping,kn as EquirectangularRefractionMapping,dr as Euler,vr as EventDispatcher,vc as ExtrudeGeometry,Kr as FileLoader,De as Float32BufferAttribute,Oi as FloatType,Jp as Fog,an as FrontSide,za as Frustum,nu as GLSL3,WS as GLSLNodeParser,Lo as GreaterDepth,Io as GreaterEqualDepth,ev as GreaterEqualStencilFunc,Z0 as GreaterStencilFunc,Ix as GridHelper,Us as Group,wi as HalfFloatType,mh as HemisphereLight,ox as ImageBitmapLoader,G0 as IncrementStencilOp,j0 as IncrementWrapStencilOp,Nn as InstancedBufferAttribute,Bm as InstancedBufferGeometry,jm as InstancedInterleavedBuffer,rm as InstancedMesh,Wa as InterleavedBuffer,On as InterleavedBufferAttribute,Za as Interpolant,Ma as InterpolateDiscrete,jo as InterpolateLinear,q0 as InvertStencilOp,qn as KeepStencilOp,Qp as LOD,rl as Layers,Co as LessDepth,Bn as LessEqualDepth,K0 as LessEqualStencilFunc,$0 as LessStencilFunc,Cn as Line,Ex as Line3,Ni as LineBasicMaterial,cm as LineLoop,$r as LineSegments,ba as LinearDisplayP3ColorSpace,Lt as LinearFilter,ji as LinearMipmapLinearFilter,Gn as LinearMipmapNearestFilter,nr as LinearSRGBColorSpace,wc as LinearToneMapping,Hi as Loader,yh as LoaderUtils,ph as LoadingManager,ap as LoopOnce,op as LoopRepeat,m0 as MOUSE,hi as Material,su as MathUtils,Ke as Matrix3,Re as Matrix4,qd as MaxEquation,Ft as Mesh,Yr as MeshBasicMaterial,Du as MeshDepthMaterial,uh as MeshLambertMaterial,ch as MeshNormalMaterial,lh as MeshPhongMaterial,oh as MeshPhysicalMaterial,Sl as MeshStandardMaterial,ma as MirroredRepeatWrapping,$t as NearestFilter,Mn as NearestMipmapLinearFilter,Ic as NearestMipmapNearestFilter,Cc as NeutralToneMapping,Ao as NeverDepth,Y0 as NeverStencilFunc,Er as NoBlending,Cr as NoColorSpace,mr as NoToneMapping,qe as Node,oT as NodeBuilder,lT as NodeFrame,_n as NormalBlending,Po as NotEqualDepth,Q0 as NotEqualStencilFunc,Qa as NumberKeyframeTrack,_t as Object3D,So as OctahedronGeometry,Is as OrthographicCamera,Gd as PCFSoftShadowMap$1,Cu as PMREMGenerator$1,di as PerspectiveCamera,ln as Plane,ua as PlaneGeometry,fh as PointLight,hm as Points,Ja as PointsMaterial,fx as PositionalAudio,Tt as PropertyBinding,qi as Quaternion,eo as QuaternionKeyframeTrack,ZS as REVISION,up as RGBADepthPacking,Ei as RGBAFormat,Go as RGBA_ASTC_4x4_Format,Wo as RGBA_ASTC_6x6_Format,_a as RGBA_BPTC_Format,Ho as RGBA_ETC2_EAC_Format,Bo as RGBA_PVRTC_4BPPV1_Format,ya as RGBA_S3TC_DXT1_Format,xa as RGBA_S3TC_DXT5_Format,zo as RGB_ETC1_Format,ko as RGB_ETC2_Format,Vo as RGB_PVRTC_4BPPV1_Format,va as RGFormat,Am as RawShaderMaterial,Es as Ray,Mx as Raycaster,Do as RedFormat,Ec as ReinhardToneMapping,Hn as RepeatWrapping,H0 as ReplaceStencilOp,yc as RingGeometry,Fi as SRGBColorSpace,Uu as Scene,dt as ShaderChunk,Dr as ShaderLib,Pr as ShaderMaterial,ah as ShadowMaterial,is as Shape,zx as ShapePath,nn as ShapeUtils,fc as Skeleton,im as SkinnedMesh,Yn as Source,Ai as Sphere,wo as SphereGeometry,Tx as Spherical,El as SpotLight,Zp as Sprite,cl as SpriteMaterial,mF as THREE,f0 as TOUCH,Wt as Texture,Zy as TextureLoader,xc as TorusGeometry,er as Triangle,z0 as TriangleFanDrawMode,B0 as TriangleStripDrawMode,V0 as TrianglesDrawMode,vu as Uint16BufferAttribute,xx as Uniform$1,Me as UniformsLib,Op as UniformsUtils,Wr as UnsignedByteType,Wn as UnsignedInt248Type,Nr as UnsignedIntType,J as Vector2,N as Vector3,st as Vector4,to as VectorKeyframeTrack,Ny as VideoTexture,Eu as WebGLCubeRenderTarget,Ir as WebGLRenderTarget,oy as WebGLRenderer,Em as WireframeGeometry,k0 as ZeroStencilOp,tf as defaultShaderStages,hr as normalView};
|