@needle-tools/engine 4.7.0 → 4.7.2-alpha
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 -3778
- package/LICENSE.md +10 -10
- package/README.md +64 -64
- package/components.needle.json +1 -1
- package/dist/generateMeshBVH.worker-Cdfpaq5W.js +25 -0
- package/dist/gltf-progressive-YjtQYFa9.js +1052 -0
- package/dist/gltf-progressive-yOP1mp5W.min.js +8 -0
- package/dist/gltf-progressive-zdhlW609.umd.cjs +8 -0
- package/dist/{needle-engine.bundle-BFsiOavn.min.js → needle-engine.bundle-BhDF-YSv.min.js} +107 -107
- package/dist/{needle-engine.bundle-BxOXkBoQ.umd.cjs → needle-engine.bundle-D2myV4E4.umd.cjs} +114 -114
- package/dist/{needle-engine.bundle-BodidWhS.js → needle-engine.bundle-gp00DTS4.js} +2932 -2920
- package/dist/needle-engine.d.ts +129 -130
- 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-CjW23fio.umd.cjs → postprocessing-8AQTeZsr.umd.cjs} +2 -2
- package/dist/{postprocessing-xYQWCHFu.min.js → postprocessing-BDScN9yu.min.js} +2 -2
- package/dist/{postprocessing-DYLNOL3W.js → postprocessing-BkxN_08g.js} +3 -3
- package/dist/{three-DuDKwKB8.min.js → three-Boa-jOq-.min.js} +33 -33
- package/dist/{three-DrqIzZTH.js → three-Bz6X1mrw.js} +4198 -4198
- package/dist/{three-B_hneGZr.umd.cjs → three-DMrv-4ar.umd.cjs} +4 -4
- package/dist/{three-examples-X3OadjXB.umd.cjs → three-examples-C7ryg8vN.umd.cjs} +3 -3
- package/dist/{three-examples-DaDLBuy6.min.js → three-examples-DuVhxqft.min.js} +14 -14
- package/dist/{three-examples-B50TT3Iu.js → three-examples-GggCDHv0.js} +5 -5
- package/dist/{three-mesh-ui-CxuWt7m-.js → three-mesh-ui-CLNOfsWn.js} +1 -1
- package/dist/{three-mesh-ui-B3p3gyUz.min.js → three-mesh-ui-CY6Izc7C.min.js} +1 -1
- package/dist/{three-mesh-ui-CQiIQIlA.umd.cjs → three-mesh-ui-CwlN0FUC.umd.cjs} +1 -1
- package/dist/{vendor-BmYIgaS1.js → vendor-BSD1RQIh.js} +3 -3
- package/dist/{vendor-Cavtu3CP.umd.cjs → vendor-DHr4aqIZ.umd.cjs} +3 -3
- package/dist/{vendor-BlSxe9JJ.min.js → vendor-zxXa3Dmr.min.js} +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 -166
- package/lib/engine/engine_addressables.js +601 -608
- package/lib/engine/engine_addressables.js.map +1 -1
- 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 -91
- package/lib/engine/engine_lightdata.js.map +1 -1
- 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 -31
- package/lib/engine/engine_lods.js +160 -146
- package/lib/engine/engine_lods.js.map +1 -1
- 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/RendererInstancing.js.map +1 -1
- 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 +2 -2
- 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 -320
- 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 -262
- 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 -680
- 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 -117
- 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 -168
- 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/dist/api.js +17 -0
- package/src/engine-schemes/dist/api.js.meta +7 -0
- package/src/engine-schemes/dist/schemes.js +25 -0
- package/src/engine-schemes/dist/schemes.js.meta +7 -0
- package/src/engine-schemes/dist/synced-camera-model.js +74 -0
- package/src/engine-schemes/dist/synced-camera-model.js.meta +7 -0
- package/src/engine-schemes/dist/synced-transform-model.js +73 -0
- package/src/engine-schemes/dist/synced-transform-model.js.meta +7 -0
- package/src/engine-schemes/dist/transform.js +46 -0
- package/src/engine-schemes/dist/transform.js.meta +7 -0
- package/src/engine-schemes/dist/vec2.js +32 -0
- package/src/engine-schemes/dist/vec2.js.meta +7 -0
- package/src/engine-schemes/dist/vec3.js +36 -0
- package/src/engine-schemes/dist/vec3.js.meta +7 -0
- package/src/engine-schemes/dist/vec4.js +40 -0
- package/src/engine-schemes/dist/vec4.js.meta +7 -0
- package/src/engine-schemes/dist/vr-user-state-buffer.js +110 -0
- package/src/engine-schemes/dist/vr-user-state-buffer.js.meta +7 -0
- 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-BaNp_Xtp.js +0 -25
- package/dist/gltf-progressive-Bl4okF1b.min.js +0 -8
- package/dist/gltf-progressive-DSpdn0QT.js +0 -1054
- package/dist/gltf-progressive-P8b8a0qY.umd.cjs +0 -8
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
(function(){"use strict";/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2010-2024 Three.js Authors
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*/const Xe="169",Ss="",$t="srgb",_s="srgb-linear",ho="display-p3",Rn="display-p3-linear",gi="linear",Bn="srgb",In="rec709",vn="p3";class Ye{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const s=this._listeners;s[t]===void 0&&(s[t]=[]),s[t].indexOf(e)===-1&&s[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;const s=this._listeners;return s[t]!==void 0&&s[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;const i=this._listeners[t];if(i!==void 0){const n=i.indexOf(e);n!==-1&&i.splice(n,1)}}dispatchEvent(t){if(this._listeners===void 0)return;const s=this._listeners[t.type];if(s!==void 0){t.target=this;const i=s.slice(0);for(let n=0,o=i.length;n<o;n++)i[n].call(this,t);t.target=null}}}const ot=["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 Pn=1234567;const Ln=Math.PI/180,On=180/Math.PI;function Kt(){const r=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,s=Math.random()*4294967295|0;return(ot[r&255]+ot[r>>8&255]+ot[r>>16&255]+ot[r>>24&255]+"-"+ot[t&255]+ot[t>>8&255]+"-"+ot[t>>16&15|64]+ot[t>>24&255]+"-"+ot[e&63|128]+ot[e>>8&255]+"-"+ot[e>>16&255]+ot[e>>24&255]+ot[s&255]+ot[s>>8&255]+ot[s>>16&255]+ot[s>>24&255]).toLowerCase()}function at(r,t,e){return Math.max(t,Math.min(e,r))}function xi(r,t){return(r%t+t)%t}function uo(r,t,e,s,i){return s+(r-t)*(i-s)/(e-t)}function lo(r,t,e){return r!==t?(e-r)/(t-r):0}function Ze(r,t,e){return(1-e)*r+e*t}function po(r,t,e,s){return Ze(r,t,1-Math.exp(-e*s))}function fo(r,t=1){return t-Math.abs(xi(r,t*2)-t)}function mo(r,t,e){return r<=t?0:r>=e?1:(r=(r-t)/(e-t),r*r*(3-2*r))}function yo(r,t,e){return r<=t?0:r>=e?1:(r=(r-t)/(e-t),r*r*r*(r*(r*6-15)+10))}function go(r,t){return r+Math.floor(Math.random()*(t-r+1))}function xo(r,t){return r+Math.random()*(t-r)}function To(r){return r*(.5-Math.random())}function No(r){r!==void 0&&(Pn=r);let t=Pn+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function wo(r){return r*Ln}function Ao(r){return r*On}function Mo(r){return(r&r-1)===0&&r!==0}function So(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function _o(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function zo(r,t,e,s,i){const n=Math.cos,o=Math.sin,a=n(e/2),c=o(e/2),u=n((t+s)/2),h=o((t+s)/2),l=n((t-s)/2),d=o((t-s)/2),p=n((s-t)/2),f=o((s-t)/2);switch(i){case"XYX":r.set(a*h,c*l,c*d,a*u);break;case"YZY":r.set(c*d,a*h,c*l,a*u);break;case"ZXZ":r.set(c*l,c*d,a*h,a*u);break;case"XZX":r.set(a*h,c*f,c*p,a*u);break;case"YXY":r.set(c*p,a*h,c*f,a*u);break;case"ZYZ":r.set(c*f,c*p,a*h,a*u);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Et(r,t){switch(t.constructor){case Float32Array:return r;case Uint32Array:return r/4294967295;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int32Array:return Math.max(r/2147483647,-1);case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw new Error("Invalid component type.")}}function $(r,t){switch(t.constructor){case Float32Array:return r;case Uint32Array:return Math.round(r*4294967295);case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int32Array:return Math.round(r*2147483647);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw new Error("Invalid component type.")}}const bo={DEG2RAD:Ln,RAD2DEG:On,generateUUID:Kt,clamp:at,euclideanModulo:xi,mapLinear:uo,inverseLerp:lo,lerp:Ze,damp:po,pingpong:fo,smoothstep:mo,smootherstep:yo,randInt:go,randFloat:xo,randFloatSpread:To,seededRandom:No,degToRad:wo,radToDeg:Ao,isPowerOfTwo:Mo,ceilPowerOfTwo:So,floorPowerOfTwo:_o,setQuaternionFromProperEuler:zo,normalize:$,denormalize:Et};class J{constructor(t=0,e=0){J.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,s=this.y,i=t.elements;return this.x=i[0]*e+i[3]*s+i[6],this.y=i[1]*e+i[4]*s+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Math.max(t,Math.min(e,s)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const s=this.dot(t)/e;return Math.acos(at(s,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,s=this.y-t.y;return e*e+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const s=Math.cos(e),i=Math.sin(e),n=this.x-t.x,o=this.y-t.y;return this.x=n*s-o*i+t.x,this.y=n*i+o*s+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Ct{constructor(t,e,s,i,n,o,a,c,u){Ct.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,s,i,n,o,a,c,u)}set(t,e,s,i,n,o,a,c,u){const h=this.elements;return h[0]=t,h[1]=i,h[2]=a,h[3]=e,h[4]=n,h[5]=c,h[6]=s,h[7]=o,h[8]=u,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],this}extractBasis(t,e,s){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),s.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const s=t.elements,i=e.elements,n=this.elements,o=s[0],a=s[3],c=s[6],u=s[1],h=s[4],l=s[7],d=s[2],p=s[5],f=s[8],m=i[0],g=i[3],y=i[6],T=i[1],w=i[4],M=i[7],N=i[2],_=i[5],S=i[8];return n[0]=o*m+a*T+c*N,n[3]=o*g+a*w+c*_,n[6]=o*y+a*M+c*S,n[1]=u*m+h*T+l*N,n[4]=u*g+h*w+l*_,n[7]=u*y+h*M+l*S,n[2]=d*m+p*T+f*N,n[5]=d*g+p*w+f*_,n[8]=d*y+p*M+f*S,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],s=t[1],i=t[2],n=t[3],o=t[4],a=t[5],c=t[6],u=t[7],h=t[8];return e*o*h-e*a*u-s*n*h+s*a*c+i*n*u-i*o*c}invert(){const t=this.elements,e=t[0],s=t[1],i=t[2],n=t[3],o=t[4],a=t[5],c=t[6],u=t[7],h=t[8],l=h*o-a*u,d=a*c-h*n,p=u*n-o*c,f=e*l+s*d+i*p;if(f===0)return this.set(0,0,0,0,0,0,0,0,0);const m=1/f;return t[0]=l*m,t[1]=(i*u-h*s)*m,t[2]=(a*s-i*o)*m,t[3]=d*m,t[4]=(h*e-i*c)*m,t[5]=(i*n-a*e)*m,t[6]=p*m,t[7]=(s*c-u*e)*m,t[8]=(o*e-s*n)*m,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,s,i,n,o,a){const c=Math.cos(n),u=Math.sin(n);return this.set(s*c,s*u,-s*(c*o+u*a)+o+t,-i*u,i*c,-i*(-u*o+c*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(Ti.makeScale(t,e)),this}rotate(t){return this.premultiply(Ti.makeRotation(-t)),this}translate(t,e){return this.premultiply(Ti.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,s,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,s=t.elements;for(let i=0;i<9;i++)if(e[i]!==s[i])return!1;return!0}fromArray(t,e=0){for(let s=0;s<9;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){const s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t}clone(){return new this.constructor().fromArray(this.elements)}}const Ti=new Ct;function Eo(r){for(let t=r.length-1;t>=0;--t)if(r[t]>=65535)return!0;return!1}function Dn(r){return document.createElementNS("http://www.w3.org/1999/xhtml",r)}const Un=new Ct().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),Vn=new Ct().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),Je={[_s]:{transfer:gi,primaries:In,luminanceCoefficients:[.2126,.7152,.0722],toReference:r=>r,fromReference:r=>r},[$t]:{transfer:Bn,primaries:In,luminanceCoefficients:[.2126,.7152,.0722],toReference:r=>r.convertSRGBToLinear(),fromReference:r=>r.convertLinearToSRGB()},[Rn]:{transfer:gi,primaries:vn,luminanceCoefficients:[.2289,.6917,.0793],toReference:r=>r.applyMatrix3(Vn),fromReference:r=>r.applyMatrix3(Un)},[ho]:{transfer:Bn,primaries:vn,luminanceCoefficients:[.2289,.6917,.0793],toReference:r=>r.convertSRGBToLinear().applyMatrix3(Vn),fromReference:r=>r.applyMatrix3(Un).convertLinearToSRGB()}},Co=new Set([_s,Rn]),mt={enabled:!0,_workingColorSpace:_s,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(r){if(!Co.has(r))throw new Error(`Unsupported working color space, "${r}".`);this._workingColorSpace=r},convert:function(r,t,e){if(this.enabled===!1||t===e||!t||!e)return r;const s=Je[t].toReference,i=Je[e].fromReference;return i(s(r))},fromWorkingColorSpace:function(r,t){return this.convert(r,this._workingColorSpace,t)},toWorkingColorSpace:function(r,t){return this.convert(r,t,this._workingColorSpace)},getPrimaries:function(r){return Je[r].primaries},getTransfer:function(r){return r===Ss?gi:Je[r].transfer},getLuminanceCoefficients:function(r,t=this._workingColorSpace){return r.fromArray(Je[t].luminanceCoefficients)}};function xe(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function Ni(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}let Te;class Fo{static getDataURL(t){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{Te===void 0&&(Te=Dn("canvas")),Te.width=t.width,Te.height=t.height;const s=Te.getContext("2d");t instanceof ImageData?s.putImageData(t,0,0):s.drawImage(t,0,0,t.width,t.height),e=Te}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const e=Dn("canvas");e.width=t.width,e.height=t.height;const s=e.getContext("2d");s.drawImage(t,0,0,t.width,t.height);const i=s.getImageData(0,0,t.width,t.height),n=i.data;for(let o=0;o<n.length;o++)n[o]=xe(n[o]/255)*255;return s.putImageData(i,0,0),e}else if(t.data){const e=t.data.slice(0);for(let s=0;s<e.length;s++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[s]=Math.floor(xe(e[s]/255)*255):e[s]=xe(e[s]);return{data:e,width:t.width,height:t.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let Ro=0;class kn{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Ro++}),this.uuid=Kt(),this.data=t,this.dataReady=!0,this.version=0}set needsUpdate(t){t===!0&&this.version++}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];const s={uuid:this.uuid,url:""},i=this.data;if(i!==null){let n;if(Array.isArray(i)){n=[];for(let o=0,a=i.length;o<a;o++)i[o].isDataTexture?n.push(wi(i[o].image)):n.push(wi(i[o]))}else n=wi(i);s.url=n}return e||(t.images[this.uuid]=s),s}}function wi(r){return typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&r instanceof ImageBitmap?Fo.getDataURL(r):r.data?{data:Array.from(r.data),width:r.width,height:r.height,type:r.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let Bo=0;class Dt extends Ye{constructor(t=Dt.DEFAULT_IMAGE,e=Dt.DEFAULT_MAPPING,s=1001,i=1001,n=1006,o=1008,a=1023,c=1009,u=Dt.DEFAULT_ANISOTROPY,h=Ss){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Bo++}),this.uuid=Kt(),this.name="",this.source=new kn(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=s,this.wrapT=i,this.magFilter=n,this.minFilter=o,this.anisotropy=u,this.format=a,this.internalFormat=null,this.type=c,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 Ct,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}get image(){return this.source.data}set image(t=null){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];const s={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(s.userData=this.userData),e||(t.textures[this.uuid]=s),s}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==300)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case 1e3:t.x=t.x-Math.floor(t.x);break;case 1001:t.x=t.x<0?0:1;break;case 1002:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case 1e3:t.y=t.y-Math.floor(t.y);break;case 1001:t.y=t.y<0?0:1;break;case 1002:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}}Dt.DEFAULT_IMAGE=null,Dt.DEFAULT_MAPPING=300,Dt.DEFAULT_ANISOTROPY=4;class Ft{constructor(t=0,e=0,s=0,i=1){Ft.prototype.isVector4=!0,this.x=t,this.y=e,this.z=s,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,s,i){return this.x=t,this.y=e,this.z=s,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,s=this.y,i=this.z,n=this.w,o=t.elements;return this.x=o[0]*e+o[4]*s+o[8]*i+o[12]*n,this.y=o[1]*e+o[5]*s+o[9]*i+o[13]*n,this.z=o[2]*e+o[6]*s+o[10]*i+o[14]*n,this.w=o[3]*e+o[7]*s+o[11]*i+o[15]*n,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,s,i,n;const c=t.elements,u=c[0],h=c[4],l=c[8],d=c[1],p=c[5],f=c[9],m=c[2],g=c[6],y=c[10];if(Math.abs(h-d)<.01&&Math.abs(l-m)<.01&&Math.abs(f-g)<.01){if(Math.abs(h+d)<.1&&Math.abs(l+m)<.1&&Math.abs(f+g)<.1&&Math.abs(u+p+y-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const w=(u+1)/2,M=(p+1)/2,N=(y+1)/2,_=(h+d)/4,S=(l+m)/4,E=(f+g)/4;return w>M&&w>N?w<.01?(s=0,i=.707106781,n=.707106781):(s=Math.sqrt(w),i=_/s,n=S/s):M>N?M<.01?(s=.707106781,i=0,n=.707106781):(i=Math.sqrt(M),s=_/i,n=E/i):N<.01?(s=.707106781,i=.707106781,n=0):(n=Math.sqrt(N),s=S/n,i=E/n),this.set(s,i,n,e),this}let T=Math.sqrt((g-f)*(g-f)+(l-m)*(l-m)+(d-h)*(d-h));return Math.abs(T)<.001&&(T=1),this.x=(g-f)/T,this.y=(l-m)/T,this.z=(d-h)/T,this.w=Math.acos((u+p+y-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this}clampLength(t,e){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Math.max(t,Math.min(e,s)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this.z=t.z+(e.z-t.z)*s,this.w=t.w+(e.w-t.w)*s,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class Hn extends Ye{constructor(t=1,e=1,s={}){super(),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=1,this.scissor=new Ft(0,0,t,e),this.scissorTest=!1,this.viewport=new Ft(0,0,t,e);const i={width:t,height:e,depth:1};s=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:1006,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},s);const n=new Dt(i,s.mapping,s.wrapS,s.wrapT,s.magFilter,s.minFilter,s.format,s.type,s.anisotropy,s.colorSpace);n.flipY=!1,n.generateMipmaps=s.generateMipmaps,n.internalFormat=s.internalFormat,this.textures=[];const o=s.count;for(let a=0;a<o;a++)this.textures[a]=n.clone(),this.textures[a].isRenderTargetTexture=!0;this.depthBuffer=s.depthBuffer,this.stencilBuffer=s.stencilBuffer,this.resolveDepthBuffer=s.resolveDepthBuffer,this.resolveStencilBuffer=s.resolveStencilBuffer,this.depthTexture=s.depthTexture,this.samples=s.samples}get texture(){return this.textures[0]}set texture(t){this.textures[0]=t}setSize(t,e,s=1){if(this.width!==t||this.height!==e||this.depth!==s){this.width=t,this.height=e,this.depth=s;for(let i=0,n=this.textures.length;i<n;i++)this.textures[i].image.width=t,this.textures[i].image.height=e,this.textures[i].image.depth=s;this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let s=0,i=t.textures.length;s<i;s++)this.textures[s]=t.textures[s].clone(),this.textures[s].isRenderTargetTexture=!0;const e=Object.assign({},t.texture.image);return this.texture.source=new kn(e),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,t.depthTexture!==null&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class je{constructor(t=0,e=0,s=0,i=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=s,this._w=i}static slerpFlat(t,e,s,i,n,o,a){let c=s[i+0],u=s[i+1],h=s[i+2],l=s[i+3];const d=n[o+0],p=n[o+1],f=n[o+2],m=n[o+3];if(a===0){t[e+0]=c,t[e+1]=u,t[e+2]=h,t[e+3]=l;return}if(a===1){t[e+0]=d,t[e+1]=p,t[e+2]=f,t[e+3]=m;return}if(l!==m||c!==d||u!==p||h!==f){let g=1-a;const y=c*d+u*p+h*f+l*m,T=y>=0?1:-1,w=1-y*y;if(w>Number.EPSILON){const N=Math.sqrt(w),_=Math.atan2(N,y*T);g=Math.sin(g*_)/N,a=Math.sin(a*_)/N}const M=a*T;if(c=c*g+d*M,u=u*g+p*M,h=h*g+f*M,l=l*g+m*M,g===1-a){const N=1/Math.sqrt(c*c+u*u+h*h+l*l);c*=N,u*=N,h*=N,l*=N}}t[e]=c,t[e+1]=u,t[e+2]=h,t[e+3]=l}static multiplyQuaternionsFlat(t,e,s,i,n,o){const a=s[i],c=s[i+1],u=s[i+2],h=s[i+3],l=n[o],d=n[o+1],p=n[o+2],f=n[o+3];return t[e]=a*f+h*l+c*p-u*d,t[e+1]=c*f+h*d+u*l-a*p,t[e+2]=u*f+h*p+a*d-c*l,t[e+3]=h*f-a*l-c*d-u*p,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,s,i){return this._x=t,this._y=e,this._z=s,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const s=t._x,i=t._y,n=t._z,o=t._order,a=Math.cos,c=Math.sin,u=a(s/2),h=a(i/2),l=a(n/2),d=c(s/2),p=c(i/2),f=c(n/2);switch(o){case"XYZ":this._x=d*h*l+u*p*f,this._y=u*p*l-d*h*f,this._z=u*h*f+d*p*l,this._w=u*h*l-d*p*f;break;case"YXZ":this._x=d*h*l+u*p*f,this._y=u*p*l-d*h*f,this._z=u*h*f-d*p*l,this._w=u*h*l+d*p*f;break;case"ZXY":this._x=d*h*l-u*p*f,this._y=u*p*l+d*h*f,this._z=u*h*f+d*p*l,this._w=u*h*l-d*p*f;break;case"ZYX":this._x=d*h*l-u*p*f,this._y=u*p*l+d*h*f,this._z=u*h*f-d*p*l,this._w=u*h*l+d*p*f;break;case"YZX":this._x=d*h*l+u*p*f,this._y=u*p*l+d*h*f,this._z=u*h*f-d*p*l,this._w=u*h*l-d*p*f;break;case"XZY":this._x=d*h*l-u*p*f,this._y=u*p*l-d*h*f,this._z=u*h*f+d*p*l,this._w=u*h*l+d*p*f;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const s=e/2,i=Math.sin(s);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(s),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,s=e[0],i=e[4],n=e[8],o=e[1],a=e[5],c=e[9],u=e[2],h=e[6],l=e[10],d=s+a+l;if(d>0){const p=.5/Math.sqrt(d+1);this._w=.25/p,this._x=(h-c)*p,this._y=(n-u)*p,this._z=(o-i)*p}else if(s>a&&s>l){const p=2*Math.sqrt(1+s-a-l);this._w=(h-c)/p,this._x=.25*p,this._y=(i+o)/p,this._z=(n+u)/p}else if(a>l){const p=2*Math.sqrt(1+a-s-l);this._w=(n-u)/p,this._x=(i+o)/p,this._y=.25*p,this._z=(c+h)/p}else{const p=2*Math.sqrt(1+l-s-a);this._w=(o-i)/p,this._x=(n+u)/p,this._y=(c+h)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let s=t.dot(e)+1;return s<Number.EPSILON?(s=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=s):(this._x=0,this._y=-t.z,this._z=t.y,this._w=s)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=s),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(at(this.dot(t),-1,1)))}rotateTowards(t,e){const s=this.angleTo(t);if(s===0)return this;const i=Math.min(1,e/s);return this.slerp(t,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const s=t._x,i=t._y,n=t._z,o=t._w,a=e._x,c=e._y,u=e._z,h=e._w;return this._x=s*h+o*a+i*u-n*c,this._y=i*h+o*c+n*a-s*u,this._z=n*h+o*u+s*c-i*a,this._w=o*h-s*a-i*c-n*u,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const s=this._x,i=this._y,n=this._z,o=this._w;let a=o*t._w+s*t._x+i*t._y+n*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=o,this._x=s,this._y=i,this._z=n,this;const c=1-a*a;if(c<=Number.EPSILON){const p=1-e;return this._w=p*o+e*this._w,this._x=p*s+e*this._x,this._y=p*i+e*this._y,this._z=p*n+e*this._z,this.normalize(),this}const u=Math.sqrt(c),h=Math.atan2(u,a),l=Math.sin((1-e)*h)/u,d=Math.sin(e*h)/u;return this._w=o*l+this._w*d,this._x=s*l+this._x*d,this._y=i*l+this._y*d,this._z=n*l+this._z*d,this._onChangeCallback(),this}slerpQuaternions(t,e,s){return this.copy(t).slerp(e,s)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),s=Math.random(),i=Math.sqrt(1-s),n=Math.sqrt(s);return this.set(i*Math.sin(t),i*Math.cos(t),n*Math.sin(e),n*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class A{constructor(t=0,e=0,s=0){A.prototype.isVector3=!0,this.x=t,this.y=e,this.z=s}set(t,e,s){return s===void 0&&(s=this.z),this.x=t,this.y=e,this.z=s,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(qn.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(qn.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,s=this.y,i=this.z,n=t.elements;return this.x=n[0]*e+n[3]*s+n[6]*i,this.y=n[1]*e+n[4]*s+n[7]*i,this.z=n[2]*e+n[5]*s+n[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,s=this.y,i=this.z,n=t.elements,o=1/(n[3]*e+n[7]*s+n[11]*i+n[15]);return this.x=(n[0]*e+n[4]*s+n[8]*i+n[12])*o,this.y=(n[1]*e+n[5]*s+n[9]*i+n[13])*o,this.z=(n[2]*e+n[6]*s+n[10]*i+n[14])*o,this}applyQuaternion(t){const e=this.x,s=this.y,i=this.z,n=t.x,o=t.y,a=t.z,c=t.w,u=2*(o*i-a*s),h=2*(a*e-n*i),l=2*(n*s-o*e);return this.x=e+c*u+o*l-a*h,this.y=s+c*h+a*u-n*l,this.z=i+c*l+n*h-o*u,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,s=this.y,i=this.z,n=t.elements;return this.x=n[0]*e+n[4]*s+n[8]*i,this.y=n[1]*e+n[5]*s+n[9]*i,this.z=n[2]*e+n[6]*s+n[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Math.max(t,Math.min(e,s)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this.z=t.z+(e.z-t.z)*s,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const s=t.x,i=t.y,n=t.z,o=e.x,a=e.y,c=e.z;return this.x=i*c-n*a,this.y=n*o-s*c,this.z=s*a-i*o,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const s=t.dot(this)/e;return this.copy(t).multiplyScalar(s)}projectOnPlane(t){return Ai.copy(this).projectOnVector(t),this.sub(Ai)}reflect(t){return this.sub(Ai.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const s=this.dot(t)/e;return Math.acos(at(s,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,s=this.y-t.y,i=this.z-t.z;return e*e+s*s+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,s){const i=Math.sin(e)*t;return this.x=i*Math.sin(s),this.y=Math.cos(e)*t,this.z=i*Math.cos(s),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,s){return this.x=t*Math.sin(e),this.y=s,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),s=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=s,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,s=Math.sqrt(1-e*e);return this.x=s*Math.cos(t),this.y=e,this.z=s*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Ai=new A,qn=new je;class ht{constructor(t=new A(1/0,1/0,1/0),e=new A(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,s=t.length;e<s;e+=3)this.expandByPoint(Rt.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,s=t.count;e<s;e++)this.expandByPoint(Rt.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,s=t.length;e<s;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const s=Rt.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(s),this.max.copy(t).add(s),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const s=t.geometry;if(s!==void 0){const n=s.getAttribute("position");if(e===!0&&n!==void 0&&t.isInstancedMesh!==!0)for(let o=0,a=n.count;o<a;o++)t.isMesh===!0?t.getVertexPosition(o,Rt):Rt.fromBufferAttribute(n,o),Rt.applyMatrix4(t.matrixWorld),this.expandByPoint(Rt);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),zs.copy(t.boundingBox)):(s.boundingBox===null&&s.computeBoundingBox(),zs.copy(s.boundingBox)),zs.applyMatrix4(t.matrixWorld),this.union(zs)}const i=t.children;for(let n=0,o=i.length;n<o;n++)this.expandByObject(i[n],e);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,Rt),Rt.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,s;return t.normal.x>0?(e=t.normal.x*this.min.x,s=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,s=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,s+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,s+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,s+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,s+=t.normal.z*this.min.z),e<=-t.constant&&s>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Qe),bs.subVectors(this.max,Qe),Ne.subVectors(t.a,Qe),we.subVectors(t.b,Qe),Ae.subVectors(t.c,Qe),te.subVectors(we,Ne),ee.subVectors(Ae,we),ue.subVectors(Ne,Ae);let e=[0,-te.z,te.y,0,-ee.z,ee.y,0,-ue.z,ue.y,te.z,0,-te.x,ee.z,0,-ee.x,ue.z,0,-ue.x,-te.y,te.x,0,-ee.y,ee.x,0,-ue.y,ue.x,0];return!Mi(e,Ne,we,Ae,bs)||(e=[1,0,0,0,1,0,0,0,1],!Mi(e,Ne,we,Ae,bs))?!1:(Es.crossVectors(te,ee),e=[Es.x,Es.y,Es.z],Mi(e,Ne,we,Ae,bs))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Rt).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(Rt).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(Wt[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Wt[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Wt[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Wt[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Wt[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Wt[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Wt[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Wt[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Wt),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const Wt=[new A,new A,new A,new A,new A,new A,new A,new A],Rt=new A,zs=new ht,Ne=new A,we=new A,Ae=new A,te=new A,ee=new A,ue=new A,Qe=new A,bs=new A,Es=new A,le=new A;function Mi(r,t,e,s,i){for(let n=0,o=r.length-3;n<=o;n+=3){le.fromArray(r,n);const a=i.x*Math.abs(le.x)+i.y*Math.abs(le.y)+i.z*Math.abs(le.z),c=t.dot(le),u=e.dot(le),h=s.dot(le);if(Math.max(-Math.max(c,u,h),Math.min(c,u,h))>a)return!1}return!0}const Io=new ht,Ke=new A,Si=new A;class $n{constructor(t=new A,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const s=this.center;e!==void 0?s.copy(e):Io.setFromPoints(t).getCenter(s);let i=0;for(let n=0,o=t.length;n<o;n++)i=Math.max(i,s.distanceToSquared(t[n]));return this.radius=Math.sqrt(i),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const s=this.center.distanceToSquared(t);return e.copy(t),s>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;Ke.subVectors(t,this.center);const e=Ke.lengthSq();if(e>this.radius*this.radius){const s=Math.sqrt(e),i=(s-this.radius)*.5;this.center.addScaledVector(Ke,i/s),this.radius+=i}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(Si.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Ke.copy(t.center).add(Si)),this.expandByPoint(Ke.copy(t.center).sub(Si))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}}class it{constructor(t,e,s,i,n,o,a,c,u,h,l,d,p,f,m,g){it.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,s,i,n,o,a,c,u,h,l,d,p,f,m,g)}set(t,e,s,i,n,o,a,c,u,h,l,d,p,f,m,g){const y=this.elements;return y[0]=t,y[4]=e,y[8]=s,y[12]=i,y[1]=n,y[5]=o,y[9]=a,y[13]=c,y[2]=u,y[6]=h,y[10]=l,y[14]=d,y[3]=p,y[7]=f,y[11]=m,y[15]=g,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 it().fromArray(this.elements)}copy(t){const e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],e[9]=s[9],e[10]=s[10],e[11]=s[11],e[12]=s[12],e[13]=s[13],e[14]=s[14],e[15]=s[15],this}copyPosition(t){const e=this.elements,s=t.elements;return e[12]=s[12],e[13]=s[13],e[14]=s[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,s){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),s.setFromMatrixColumn(this,2),this}makeBasis(t,e,s){return this.set(t.x,e.x,s.x,0,t.y,e.y,s.y,0,t.z,e.z,s.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,s=t.elements,i=1/Me.setFromMatrixColumn(t,0).length(),n=1/Me.setFromMatrixColumn(t,1).length(),o=1/Me.setFromMatrixColumn(t,2).length();return e[0]=s[0]*i,e[1]=s[1]*i,e[2]=s[2]*i,e[3]=0,e[4]=s[4]*n,e[5]=s[5]*n,e[6]=s[6]*n,e[7]=0,e[8]=s[8]*o,e[9]=s[9]*o,e[10]=s[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,s=t.x,i=t.y,n=t.z,o=Math.cos(s),a=Math.sin(s),c=Math.cos(i),u=Math.sin(i),h=Math.cos(n),l=Math.sin(n);if(t.order==="XYZ"){const d=o*h,p=o*l,f=a*h,m=a*l;e[0]=c*h,e[4]=-c*l,e[8]=u,e[1]=p+f*u,e[5]=d-m*u,e[9]=-a*c,e[2]=m-d*u,e[6]=f+p*u,e[10]=o*c}else if(t.order==="YXZ"){const d=c*h,p=c*l,f=u*h,m=u*l;e[0]=d+m*a,e[4]=f*a-p,e[8]=o*u,e[1]=o*l,e[5]=o*h,e[9]=-a,e[2]=p*a-f,e[6]=m+d*a,e[10]=o*c}else if(t.order==="ZXY"){const d=c*h,p=c*l,f=u*h,m=u*l;e[0]=d-m*a,e[4]=-o*l,e[8]=f+p*a,e[1]=p+f*a,e[5]=o*h,e[9]=m-d*a,e[2]=-o*u,e[6]=a,e[10]=o*c}else if(t.order==="ZYX"){const d=o*h,p=o*l,f=a*h,m=a*l;e[0]=c*h,e[4]=f*u-p,e[8]=d*u+m,e[1]=c*l,e[5]=m*u+d,e[9]=p*u-f,e[2]=-u,e[6]=a*c,e[10]=o*c}else if(t.order==="YZX"){const d=o*c,p=o*u,f=a*c,m=a*u;e[0]=c*h,e[4]=m-d*l,e[8]=f*l+p,e[1]=l,e[5]=o*h,e[9]=-a*h,e[2]=-u*h,e[6]=p*l+f,e[10]=d-m*l}else if(t.order==="XZY"){const d=o*c,p=o*u,f=a*c,m=a*u;e[0]=c*h,e[4]=-l,e[8]=u*h,e[1]=d*l+m,e[5]=o*h,e[9]=p*l-f,e[2]=f*l-p,e[6]=a*h,e[10]=m*l+d}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(vo,t,Po)}lookAt(t,e,s){const i=this.elements;return yt.subVectors(t,e),yt.lengthSq()===0&&(yt.z=1),yt.normalize(),se.crossVectors(s,yt),se.lengthSq()===0&&(Math.abs(s.z)===1?yt.x+=1e-4:yt.z+=1e-4,yt.normalize(),se.crossVectors(s,yt)),se.normalize(),Cs.crossVectors(yt,se),i[0]=se.x,i[4]=Cs.x,i[8]=yt.x,i[1]=se.y,i[5]=Cs.y,i[9]=yt.y,i[2]=se.z,i[6]=Cs.z,i[10]=yt.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const s=t.elements,i=e.elements,n=this.elements,o=s[0],a=s[4],c=s[8],u=s[12],h=s[1],l=s[5],d=s[9],p=s[13],f=s[2],m=s[6],g=s[10],y=s[14],T=s[3],w=s[7],M=s[11],N=s[15],_=i[0],S=i[4],E=i[8],F=i[12],R=i[1],I=i[5],B=i[9],P=i[13],L=i[2],U=i[6],W=i[10],Nt=i[14],Ht=i[3],qt=i[7],mi=i[11],yi=i[15];return n[0]=o*_+a*R+c*L+u*Ht,n[4]=o*S+a*I+c*U+u*qt,n[8]=o*E+a*B+c*W+u*mi,n[12]=o*F+a*P+c*Nt+u*yi,n[1]=h*_+l*R+d*L+p*Ht,n[5]=h*S+l*I+d*U+p*qt,n[9]=h*E+l*B+d*W+p*mi,n[13]=h*F+l*P+d*Nt+p*yi,n[2]=f*_+m*R+g*L+y*Ht,n[6]=f*S+m*I+g*U+y*qt,n[10]=f*E+m*B+g*W+y*mi,n[14]=f*F+m*P+g*Nt+y*yi,n[3]=T*_+w*R+M*L+N*Ht,n[7]=T*S+w*I+M*U+N*qt,n[11]=T*E+w*B+M*W+N*mi,n[15]=T*F+w*P+M*Nt+N*yi,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],s=t[4],i=t[8],n=t[12],o=t[1],a=t[5],c=t[9],u=t[13],h=t[2],l=t[6],d=t[10],p=t[14],f=t[3],m=t[7],g=t[11],y=t[15];return f*(+n*c*l-i*u*l-n*a*d+s*u*d+i*a*p-s*c*p)+m*(+e*c*p-e*u*d+n*o*d-i*o*p+i*u*h-n*c*h)+g*(+e*u*l-e*a*p-n*o*l+s*o*p+n*a*h-s*u*h)+y*(-i*a*h-e*c*l+e*a*d+i*o*l-s*o*d+s*c*h)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,s){const i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=s),this}invert(){const t=this.elements,e=t[0],s=t[1],i=t[2],n=t[3],o=t[4],a=t[5],c=t[6],u=t[7],h=t[8],l=t[9],d=t[10],p=t[11],f=t[12],m=t[13],g=t[14],y=t[15],T=l*g*u-m*d*u+m*c*p-a*g*p-l*c*y+a*d*y,w=f*d*u-h*g*u-f*c*p+o*g*p+h*c*y-o*d*y,M=h*m*u-f*l*u+f*a*p-o*m*p-h*a*y+o*l*y,N=f*l*c-h*m*c-f*a*d+o*m*d+h*a*g-o*l*g,_=e*T+s*w+i*M+n*N;if(_===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const S=1/_;return t[0]=T*S,t[1]=(m*d*n-l*g*n-m*i*p+s*g*p+l*i*y-s*d*y)*S,t[2]=(a*g*n-m*c*n+m*i*u-s*g*u-a*i*y+s*c*y)*S,t[3]=(l*c*n-a*d*n-l*i*u+s*d*u+a*i*p-s*c*p)*S,t[4]=w*S,t[5]=(h*g*n-f*d*n+f*i*p-e*g*p-h*i*y+e*d*y)*S,t[6]=(f*c*n-o*g*n-f*i*u+e*g*u+o*i*y-e*c*y)*S,t[7]=(o*d*n-h*c*n+h*i*u-e*d*u-o*i*p+e*c*p)*S,t[8]=M*S,t[9]=(f*l*n-h*m*n-f*s*p+e*m*p+h*s*y-e*l*y)*S,t[10]=(o*m*n-f*a*n+f*s*u-e*m*u-o*s*y+e*a*y)*S,t[11]=(h*a*n-o*l*n-h*s*u+e*l*u+o*s*p-e*a*p)*S,t[12]=N*S,t[13]=(h*m*i-f*l*i+f*s*d-e*m*d-h*s*g+e*l*g)*S,t[14]=(f*a*i-o*m*i-f*s*c+e*m*c+o*s*g-e*a*g)*S,t[15]=(o*l*i-h*a*i+h*s*c-e*l*c-o*s*d+e*a*d)*S,this}scale(t){const e=this.elements,s=t.x,i=t.y,n=t.z;return e[0]*=s,e[4]*=i,e[8]*=n,e[1]*=s,e[5]*=i,e[9]*=n,e[2]*=s,e[6]*=i,e[10]*=n,e[3]*=s,e[7]*=i,e[11]*=n,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],s=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,s,i))}makeTranslation(t,e,s){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,s,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),s=Math.sin(t);return this.set(1,0,0,0,0,e,-s,0,0,s,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,0,s,0,0,1,0,0,-s,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,0,s,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const s=Math.cos(e),i=Math.sin(e),n=1-s,o=t.x,a=t.y,c=t.z,u=n*o,h=n*a;return this.set(u*o+s,u*a-i*c,u*c+i*a,0,u*a+i*c,h*a+s,h*c-i*o,0,u*c-i*a,h*c+i*o,n*c*c+s,0,0,0,0,1),this}makeScale(t,e,s){return this.set(t,0,0,0,0,e,0,0,0,0,s,0,0,0,0,1),this}makeShear(t,e,s,i,n,o){return this.set(1,s,n,0,t,1,o,0,e,i,1,0,0,0,0,1),this}compose(t,e,s){const i=this.elements,n=e._x,o=e._y,a=e._z,c=e._w,u=n+n,h=o+o,l=a+a,d=n*u,p=n*h,f=n*l,m=o*h,g=o*l,y=a*l,T=c*u,w=c*h,M=c*l,N=s.x,_=s.y,S=s.z;return i[0]=(1-(m+y))*N,i[1]=(p+M)*N,i[2]=(f-w)*N,i[3]=0,i[4]=(p-M)*_,i[5]=(1-(d+y))*_,i[6]=(g+T)*_,i[7]=0,i[8]=(f+w)*S,i[9]=(g-T)*S,i[10]=(1-(d+m))*S,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,s){const i=this.elements;let n=Me.set(i[0],i[1],i[2]).length();const o=Me.set(i[4],i[5],i[6]).length(),a=Me.set(i[8],i[9],i[10]).length();this.determinant()<0&&(n=-n),t.x=i[12],t.y=i[13],t.z=i[14],Bt.copy(this);const u=1/n,h=1/o,l=1/a;return Bt.elements[0]*=u,Bt.elements[1]*=u,Bt.elements[2]*=u,Bt.elements[4]*=h,Bt.elements[5]*=h,Bt.elements[6]*=h,Bt.elements[8]*=l,Bt.elements[9]*=l,Bt.elements[10]*=l,e.setFromRotationMatrix(Bt),s.x=n,s.y=o,s.z=a,this}makePerspective(t,e,s,i,n,o,a=2e3){const c=this.elements,u=2*n/(e-t),h=2*n/(s-i),l=(e+t)/(e-t),d=(s+i)/(s-i);let p,f;if(a===2e3)p=-(o+n)/(o-n),f=-2*o*n/(o-n);else if(a===2001)p=-o/(o-n),f=-o*n/(o-n);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return c[0]=u,c[4]=0,c[8]=l,c[12]=0,c[1]=0,c[5]=h,c[9]=d,c[13]=0,c[2]=0,c[6]=0,c[10]=p,c[14]=f,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(t,e,s,i,n,o,a=2e3){const c=this.elements,u=1/(e-t),h=1/(s-i),l=1/(o-n),d=(e+t)*u,p=(s+i)*h;let f,m;if(a===2e3)f=(o+n)*l,m=-2*l;else if(a===2001)f=n*l,m=-1*l;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return c[0]=2*u,c[4]=0,c[8]=0,c[12]=-d,c[1]=0,c[5]=2*h,c[9]=0,c[13]=-p,c[2]=0,c[6]=0,c[10]=m,c[14]=-f,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(t){const e=this.elements,s=t.elements;for(let i=0;i<16;i++)if(e[i]!==s[i])return!1;return!0}fromArray(t,e=0){for(let s=0;s<16;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){const s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t[e+9]=s[9],t[e+10]=s[10],t[e+11]=s[11],t[e+12]=s[12],t[e+13]=s[13],t[e+14]=s[14],t[e+15]=s[15],t}}const Me=new A,Bt=new it,vo=new A(0,0,0),Po=new A(1,1,1),se=new A,Cs=new A,yt=new A,Wn=new it,Gn=new je;class Fs{constructor(t=0,e=0,s=0,i=Fs.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=s,this._order=i}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,s,i=this._order){return this._x=t,this._y=e,this._z=s,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,s=!0){const i=t.elements,n=i[0],o=i[4],a=i[8],c=i[1],u=i[5],h=i[9],l=i[2],d=i[6],p=i[10];switch(e){case"XYZ":this._y=Math.asin(at(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,p),this._z=Math.atan2(-o,n)):(this._x=Math.atan2(d,u),this._z=0);break;case"YXZ":this._x=Math.asin(-at(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(a,p),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-l,n),this._z=0);break;case"ZXY":this._x=Math.asin(at(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-l,p),this._z=Math.atan2(-o,u)):(this._y=0,this._z=Math.atan2(c,n));break;case"ZYX":this._y=Math.asin(-at(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(d,p),this._z=Math.atan2(c,n)):(this._x=0,this._z=Math.atan2(-o,u));break;case"YZX":this._z=Math.asin(at(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-h,u),this._y=Math.atan2(-l,n)):(this._x=0,this._y=Math.atan2(a,p));break;case"XZY":this._z=Math.asin(-at(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,u),this._y=Math.atan2(a,n)):(this._x=Math.atan2(-h,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,s===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,s){return Wn.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Wn,e,s)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Gn.setFromEuler(this),this.setFromQuaternion(Gn,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Fs.DEFAULT_ORDER="XYZ";class Lo{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}}let Oo=0;const Xn=new A,Se=new je,Gt=new it,Rs=new A,ts=new A,Do=new A,Uo=new je,Yn=new A(1,0,0),Zn=new A(0,1,0),Jn=new A(0,0,1),jn={type:"added"},Vo={type:"removed"},_e={type:"childadded",child:null},_i={type:"childremoved",child:null};class ie extends Ye{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Oo++}),this.uuid=Kt(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=ie.DEFAULT_UP.clone();const t=new A,e=new Fs,s=new je,i=new A(1,1,1);function n(){s.setFromEuler(e,!1)}function o(){e.setFromQuaternion(s,void 0,!1)}e._onChange(n),s._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:s},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new it},normalMatrix:{value:new Ct}}),this.matrix=new it,this.matrixWorld=new it,this.matrixAutoUpdate=ie.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=ie.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Lo,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return Se.setFromAxisAngle(t,e),this.quaternion.multiply(Se),this}rotateOnWorldAxis(t,e){return Se.setFromAxisAngle(t,e),this.quaternion.premultiply(Se),this}rotateX(t){return this.rotateOnAxis(Yn,t)}rotateY(t){return this.rotateOnAxis(Zn,t)}rotateZ(t){return this.rotateOnAxis(Jn,t)}translateOnAxis(t,e){return Xn.copy(t).applyQuaternion(this.quaternion),this.position.add(Xn.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(Yn,t)}translateY(t){return this.translateOnAxis(Zn,t)}translateZ(t){return this.translateOnAxis(Jn,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(Gt.copy(this.matrixWorld).invert())}lookAt(t,e,s){t.isVector3?Rs.copy(t):Rs.set(t,e,s);const i=this.parent;this.updateWorldMatrix(!0,!1),ts.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Gt.lookAt(ts,Rs,this.up):Gt.lookAt(Rs,ts,this.up),this.quaternion.setFromRotationMatrix(Gt),i&&(Gt.extractRotation(i.matrixWorld),Se.setFromRotationMatrix(Gt),this.quaternion.premultiply(Se.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(jn),_e.child=t,this.dispatchEvent(_e),_e.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let s=0;s<arguments.length;s++)this.remove(arguments[s]);return this}const e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(Vo),_i.child=t,this.dispatchEvent(_i),_i.child=null),this}removeFromParent(){const t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),Gt.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),Gt.multiply(t.parent.matrixWorld)),t.applyMatrix4(Gt),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(jn),_e.child=t,this.dispatchEvent(_e),_e.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let s=0,i=this.children.length;s<i;s++){const o=this.children[s].getObjectByProperty(t,e);if(o!==void 0)return o}}getObjectsByProperty(t,e,s=[]){this[t]===e&&s.push(this);const i=this.children;for(let n=0,o=i.length;n<o;n++)i[n].getObjectsByProperty(t,e,s);return s}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ts,t,Do),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ts,Uo,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let s=0,i=e.length;s<i;s++)e[s].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);const e=this.children;for(let s=0,i=e.length;s<i;s++)e[s].traverseVisible(t)}traverseAncestors(t){const e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let s=0,i=e.length;s<i;s++)e[s].updateMatrixWorld(t)}updateWorldMatrix(t,e){const s=this.parent;if(t===!0&&s!==null&&s.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)),e===!0){const i=this.children;for(let n=0,o=i.length;n<o;n++)i[n].updateWorldMatrix(!1,!0)}}toJSON(t){const e=t===void 0||typeof t=="string",s={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},s.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map(a=>({boxInitialized:a.boxInitialized,boxMin:a.box.min.toArray(),boxMax:a.box.max.toArray(),sphereInitialized:a.sphereInitialized,sphereRadius:a.sphere.radius,sphereCenter:a.sphere.center.toArray()})),i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(t),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),this.boundingBox!==null&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()}));function n(a,c){return a[c.uuid]===void 0&&(a[c.uuid]=c.toJSON(t)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=n(t.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const c=a.shapes;if(Array.isArray(c))for(let u=0,h=c.length;u<h;u++){const l=c[u];n(t.shapes,l)}else n(t.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(n(t.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const a=[];for(let c=0,u=this.material.length;c<u;c++)a.push(n(t.materials,this.material[c]));i.material=a}else i.material=n(t.materials,this.material);if(this.children.length>0){i.children=[];for(let a=0;a<this.children.length;a++)i.children.push(this.children[a].toJSON(t).object)}if(this.animations.length>0){i.animations=[];for(let a=0;a<this.animations.length;a++){const c=this.animations[a];i.animations.push(n(t.animations,c))}}if(e){const a=o(t.geometries),c=o(t.materials),u=o(t.textures),h=o(t.images),l=o(t.shapes),d=o(t.skeletons),p=o(t.animations),f=o(t.nodes);a.length>0&&(s.geometries=a),c.length>0&&(s.materials=c),u.length>0&&(s.textures=u),h.length>0&&(s.images=h),l.length>0&&(s.shapes=l),d.length>0&&(s.skeletons=d),p.length>0&&(s.animations=p),f.length>0&&(s.nodes=f)}return s.object=i,s;function o(a){const c=[];for(const u in a){const h=a[u];delete h.metadata,c.push(h)}return c}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let s=0;s<t.children.length;s++){const i=t.children[s];this.add(i.clone())}return this}}ie.DEFAULT_UP=new A(0,1,0),ie.DEFAULT_MATRIX_AUTO_UPDATE=!0,ie.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const It=new A,Xt=new A,zi=new A,Yt=new A,ze=new A,be=new A,Qn=new A,bi=new A,Ei=new A,Ci=new A,Fi=new Ft,Ri=new Ft,Bi=new Ft;class wt{constructor(t=new A,e=new A,s=new A){this.a=t,this.b=e,this.c=s}static getNormal(t,e,s,i){i.subVectors(s,e),It.subVectors(t,e),i.cross(It);const n=i.lengthSq();return n>0?i.multiplyScalar(1/Math.sqrt(n)):i.set(0,0,0)}static getBarycoord(t,e,s,i,n){It.subVectors(i,e),Xt.subVectors(s,e),zi.subVectors(t,e);const o=It.dot(It),a=It.dot(Xt),c=It.dot(zi),u=Xt.dot(Xt),h=Xt.dot(zi),l=o*u-a*a;if(l===0)return n.set(0,0,0),null;const d=1/l,p=(u*c-a*h)*d,f=(o*h-a*c)*d;return n.set(1-p-f,f,p)}static containsPoint(t,e,s,i){return this.getBarycoord(t,e,s,i,Yt)===null?!1:Yt.x>=0&&Yt.y>=0&&Yt.x+Yt.y<=1}static getInterpolation(t,e,s,i,n,o,a,c){return this.getBarycoord(t,e,s,i,Yt)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(n,Yt.x),c.addScaledVector(o,Yt.y),c.addScaledVector(a,Yt.z),c)}static getInterpolatedAttribute(t,e,s,i,n,o){return Fi.setScalar(0),Ri.setScalar(0),Bi.setScalar(0),Fi.fromBufferAttribute(t,e),Ri.fromBufferAttribute(t,s),Bi.fromBufferAttribute(t,i),o.setScalar(0),o.addScaledVector(Fi,n.x),o.addScaledVector(Ri,n.y),o.addScaledVector(Bi,n.z),o}static isFrontFacing(t,e,s,i){return It.subVectors(s,e),Xt.subVectors(t,e),It.cross(Xt).dot(i)<0}set(t,e,s){return this.a.copy(t),this.b.copy(e),this.c.copy(s),this}setFromPointsAndIndices(t,e,s,i){return this.a.copy(t[e]),this.b.copy(t[s]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,e,s,i){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,s),this.c.fromBufferAttribute(t,i),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return It.subVectors(this.c,this.b),Xt.subVectors(this.a,this.b),It.cross(Xt).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return wt.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return wt.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,s,i,n){return wt.getInterpolation(t,this.a,this.b,this.c,e,s,i,n)}containsPoint(t){return wt.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return wt.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const s=this.a,i=this.b,n=this.c;let o,a;ze.subVectors(i,s),be.subVectors(n,s),bi.subVectors(t,s);const c=ze.dot(bi),u=be.dot(bi);if(c<=0&&u<=0)return e.copy(s);Ei.subVectors(t,i);const h=ze.dot(Ei),l=be.dot(Ei);if(h>=0&&l<=h)return e.copy(i);const d=c*l-h*u;if(d<=0&&c>=0&&h<=0)return o=c/(c-h),e.copy(s).addScaledVector(ze,o);Ci.subVectors(t,n);const p=ze.dot(Ci),f=be.dot(Ci);if(f>=0&&p<=f)return e.copy(n);const m=p*u-c*f;if(m<=0&&u>=0&&f<=0)return a=u/(u-f),e.copy(s).addScaledVector(be,a);const g=h*f-p*l;if(g<=0&&l-h>=0&&p-f>=0)return Qn.subVectors(n,i),a=(l-h)/(l-h+(p-f)),e.copy(i).addScaledVector(Qn,a);const y=1/(g+m+d);return o=m*y,a=d*y,e.copy(s).addScaledVector(ze,o).addScaledVector(be,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const Kn={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},ne={h:0,s:0,l:0},Bs={h:0,s:0,l:0};function Ii(r,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?r+(t-r)*6*e:e<1/2?t:e<2/3?r+(t-r)*6*(2/3-e):r}class vi{constructor(t,e,s){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,s)}set(t,e,s){if(e===void 0&&s===void 0){const i=t;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(t,e,s);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=$t){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,mt.toWorkingColorSpace(this,e),this}setRGB(t,e,s,i=mt.workingColorSpace){return this.r=t,this.g=e,this.b=s,mt.toWorkingColorSpace(this,i),this}setHSL(t,e,s,i=mt.workingColorSpace){if(t=xi(t,1),e=at(e,0,1),s=at(s,0,1),e===0)this.r=this.g=this.b=s;else{const n=s<=.5?s*(1+e):s+e-s*e,o=2*s-n;this.r=Ii(o,n,t+1/3),this.g=Ii(o,n,t),this.b=Ii(o,n,t-1/3)}return mt.toWorkingColorSpace(this,i),this}setStyle(t,e=$t){function s(n){n!==void 0&&parseFloat(n)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(t)){let n;const o=i[1],a=i[2];switch(o){case"rgb":case"rgba":if(n=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return s(n[4]),this.setRGB(Math.min(255,parseInt(n[1],10))/255,Math.min(255,parseInt(n[2],10))/255,Math.min(255,parseInt(n[3],10))/255,e);if(n=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return s(n[4]),this.setRGB(Math.min(100,parseInt(n[1],10))/100,Math.min(100,parseInt(n[2],10))/100,Math.min(100,parseInt(n[3],10))/100,e);break;case"hsl":case"hsla":if(n=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return s(n[4]),this.setHSL(parseFloat(n[1])/360,parseFloat(n[2])/100,parseFloat(n[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){const n=i[1],o=n.length;if(o===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,e);if(o===6)return this.setHex(parseInt(n,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=$t){const s=Kn[t.toLowerCase()];return s!==void 0?this.setHex(s,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=xe(t.r),this.g=xe(t.g),this.b=xe(t.b),this}copyLinearToSRGB(t){return this.r=Ni(t.r),this.g=Ni(t.g),this.b=Ni(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=$t){return mt.fromWorkingColorSpace(ct.copy(this),t),Math.round(at(ct.r*255,0,255))*65536+Math.round(at(ct.g*255,0,255))*256+Math.round(at(ct.b*255,0,255))}getHexString(t=$t){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=mt.workingColorSpace){mt.fromWorkingColorSpace(ct.copy(this),e);const s=ct.r,i=ct.g,n=ct.b,o=Math.max(s,i,n),a=Math.min(s,i,n);let c,u;const h=(a+o)/2;if(a===o)c=0,u=0;else{const l=o-a;switch(u=h<=.5?l/(o+a):l/(2-o-a),o){case s:c=(i-n)/l+(i<n?6:0);break;case i:c=(n-s)/l+2;break;case n:c=(s-i)/l+4;break}c/=6}return t.h=c,t.s=u,t.l=h,t}getRGB(t,e=mt.workingColorSpace){return mt.fromWorkingColorSpace(ct.copy(this),e),t.r=ct.r,t.g=ct.g,t.b=ct.b,t}getStyle(t=$t){mt.fromWorkingColorSpace(ct.copy(this),t);const e=ct.r,s=ct.g,i=ct.b;return t!==$t?`color(${t} ${e.toFixed(3)} ${s.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(s*255)},${Math.round(i*255)})`}offsetHSL(t,e,s){return this.getHSL(ne),this.setHSL(ne.h+t,ne.s+e,ne.l+s)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,s){return this.r=t.r+(e.r-t.r)*s,this.g=t.g+(e.g-t.g)*s,this.b=t.b+(e.b-t.b)*s,this}lerpHSL(t,e){this.getHSL(ne),t.getHSL(Bs);const s=Ze(ne.h,Bs.h,e),i=Ze(ne.s,Bs.s,e),n=Ze(ne.l,Bs.l,e);return this.setHSL(s,i,n),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,s=this.g,i=this.b,n=t.elements;return this.r=n[0]*e+n[3]*s+n[6]*i,this.g=n[1]*e+n[4]*s+n[7]*i,this.b=n[2]*e+n[5]*s+n[8]*i,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const ct=new vi;vi.NAMES=Kn;const j=new A,Is=new J;class vt{constructor(t,e,s=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=s,this.usage=35044,this.updateRanges=[],this.gpuType=1015,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,s){t*=this.itemSize,s*=e.itemSize;for(let i=0,n=this.itemSize;i<n;i++)this.array[t+i]=e.array[s+i];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,s=this.count;e<s;e++)Is.fromBufferAttribute(this,e),Is.applyMatrix3(t),this.setXY(e,Is.x,Is.y);else if(this.itemSize===3)for(let e=0,s=this.count;e<s;e++)j.fromBufferAttribute(this,e),j.applyMatrix3(t),this.setXYZ(e,j.x,j.y,j.z);return this}applyMatrix4(t){for(let e=0,s=this.count;e<s;e++)j.fromBufferAttribute(this,e),j.applyMatrix4(t),this.setXYZ(e,j.x,j.y,j.z);return this}applyNormalMatrix(t){for(let e=0,s=this.count;e<s;e++)j.fromBufferAttribute(this,e),j.applyNormalMatrix(t),this.setXYZ(e,j.x,j.y,j.z);return this}transformDirection(t){for(let e=0,s=this.count;e<s;e++)j.fromBufferAttribute(this,e),j.transformDirection(t),this.setXYZ(e,j.x,j.y,j.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let s=this.array[t*this.itemSize+e];return this.normalized&&(s=Et(s,this.array)),s}setComponent(t,e,s){return this.normalized&&(s=$(s,this.array)),this.array[t*this.itemSize+e]=s,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=Et(e,this.array)),e}setX(t,e){return this.normalized&&(e=$(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=Et(e,this.array)),e}setY(t,e){return this.normalized&&(e=$(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=Et(e,this.array)),e}setZ(t,e){return this.normalized&&(e=$(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=Et(e,this.array)),e}setW(t,e){return this.normalized&&(e=$(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,s){return t*=this.itemSize,this.normalized&&(e=$(e,this.array),s=$(s,this.array)),this.array[t+0]=e,this.array[t+1]=s,this}setXYZ(t,e,s,i){return t*=this.itemSize,this.normalized&&(e=$(e,this.array),s=$(s,this.array),i=$(i,this.array)),this.array[t+0]=e,this.array[t+1]=s,this.array[t+2]=i,this}setXYZW(t,e,s,i,n){return t*=this.itemSize,this.normalized&&(e=$(e,this.array),s=$(s,this.array),i=$(i,this.array),n=$(n,this.array)),this.array[t+0]=e,this.array[t+1]=s,this.array[t+2]=i,this.array[t+3]=n,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==35044&&(t.usage=this.usage),t}}class ko extends vt{constructor(t,e,s){super(new Uint16Array(t),e,s)}}class Ho extends vt{constructor(t,e,s){super(new Uint32Array(t),e,s)}}class qo extends vt{constructor(t,e,s){super(new Float32Array(t),e,s)}}let $o=0;const At=new it,Pi=new ie,Ee=new A,gt=new ht,es=new ht,nt=new A;class Li extends Ye{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:$o++}),this.uuid=Kt(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(Eo(t)?Ho:ko)(t,1):this.index=t,this}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,s=0){this.groups.push({start:t,count:e,materialIndex:s})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);const s=this.attributes.normal;if(s!==void 0){const n=new Ct().getNormalMatrix(t);s.applyNormalMatrix(n),s.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(t),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return At.makeRotationFromQuaternion(t),this.applyMatrix4(At),this}rotateX(t){return At.makeRotationX(t),this.applyMatrix4(At),this}rotateY(t){return At.makeRotationY(t),this.applyMatrix4(At),this}rotateZ(t){return At.makeRotationZ(t),this.applyMatrix4(At),this}translate(t,e,s){return At.makeTranslation(t,e,s),this.applyMatrix4(At),this}scale(t,e,s){return At.makeScale(t,e,s),this.applyMatrix4(At),this}lookAt(t){return Pi.lookAt(t),Pi.updateMatrix(),this.applyMatrix4(Pi.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Ee).negate(),this.translate(Ee.x,Ee.y,Ee.z),this}setFromPoints(t){const e=[];for(let s=0,i=t.length;s<i;s++){const n=t[s];e.push(n.x,n.y,n.z||0)}return this.setAttribute("position",new qo(e,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ht);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new A(-1/0,-1/0,-1/0),new A(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let s=0,i=e.length;s<i;s++){const n=e[s];gt.setFromBufferAttribute(n),this.morphTargetsRelative?(nt.addVectors(this.boundingBox.min,gt.min),this.boundingBox.expandByPoint(nt),nt.addVectors(this.boundingBox.max,gt.max),this.boundingBox.expandByPoint(nt)):(this.boundingBox.expandByPoint(gt.min),this.boundingBox.expandByPoint(gt.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 $n);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new A,1/0);return}if(t){const s=this.boundingSphere.center;if(gt.setFromBufferAttribute(t),e)for(let n=0,o=e.length;n<o;n++){const a=e[n];es.setFromBufferAttribute(a),this.morphTargetsRelative?(nt.addVectors(gt.min,es.min),gt.expandByPoint(nt),nt.addVectors(gt.max,es.max),gt.expandByPoint(nt)):(gt.expandByPoint(es.min),gt.expandByPoint(es.max))}gt.getCenter(s);let i=0;for(let n=0,o=t.count;n<o;n++)nt.fromBufferAttribute(t,n),i=Math.max(i,s.distanceToSquared(nt));if(e)for(let n=0,o=e.length;n<o;n++){const a=e[n],c=this.morphTargetsRelative;for(let u=0,h=a.count;u<h;u++)nt.fromBufferAttribute(a,u),c&&(Ee.fromBufferAttribute(t,u),nt.add(Ee)),i=Math.max(i,s.distanceToSquared(nt))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const s=e.position,i=e.normal,n=e.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new vt(new Float32Array(4*s.count),4));const o=this.getAttribute("tangent"),a=[],c=[];for(let E=0;E<s.count;E++)a[E]=new A,c[E]=new A;const u=new A,h=new A,l=new A,d=new J,p=new J,f=new J,m=new A,g=new A;function y(E,F,R){u.fromBufferAttribute(s,E),h.fromBufferAttribute(s,F),l.fromBufferAttribute(s,R),d.fromBufferAttribute(n,E),p.fromBufferAttribute(n,F),f.fromBufferAttribute(n,R),h.sub(u),l.sub(u),p.sub(d),f.sub(d);const I=1/(p.x*f.y-f.x*p.y);isFinite(I)&&(m.copy(h).multiplyScalar(f.y).addScaledVector(l,-p.y).multiplyScalar(I),g.copy(l).multiplyScalar(p.x).addScaledVector(h,-f.x).multiplyScalar(I),a[E].add(m),a[F].add(m),a[R].add(m),c[E].add(g),c[F].add(g),c[R].add(g))}let T=this.groups;T.length===0&&(T=[{start:0,count:t.count}]);for(let E=0,F=T.length;E<F;++E){const R=T[E],I=R.start,B=R.count;for(let P=I,L=I+B;P<L;P+=3)y(t.getX(P+0),t.getX(P+1),t.getX(P+2))}const w=new A,M=new A,N=new A,_=new A;function S(E){N.fromBufferAttribute(i,E),_.copy(N);const F=a[E];w.copy(F),w.sub(N.multiplyScalar(N.dot(F))).normalize(),M.crossVectors(_,F);const I=M.dot(c[E])<0?-1:1;o.setXYZW(E,w.x,w.y,w.z,I)}for(let E=0,F=T.length;E<F;++E){const R=T[E],I=R.start,B=R.count;for(let P=I,L=I+B;P<L;P+=3)S(t.getX(P+0)),S(t.getX(P+1)),S(t.getX(P+2))}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(e!==void 0){let s=this.getAttribute("normal");if(s===void 0)s=new vt(new Float32Array(e.count*3),3),this.setAttribute("normal",s);else for(let d=0,p=s.count;d<p;d++)s.setXYZ(d,0,0,0);const i=new A,n=new A,o=new A,a=new A,c=new A,u=new A,h=new A,l=new A;if(t)for(let d=0,p=t.count;d<p;d+=3){const f=t.getX(d+0),m=t.getX(d+1),g=t.getX(d+2);i.fromBufferAttribute(e,f),n.fromBufferAttribute(e,m),o.fromBufferAttribute(e,g),h.subVectors(o,n),l.subVectors(i,n),h.cross(l),a.fromBufferAttribute(s,f),c.fromBufferAttribute(s,m),u.fromBufferAttribute(s,g),a.add(h),c.add(h),u.add(h),s.setXYZ(f,a.x,a.y,a.z),s.setXYZ(m,c.x,c.y,c.z),s.setXYZ(g,u.x,u.y,u.z)}else for(let d=0,p=e.count;d<p;d+=3)i.fromBufferAttribute(e,d+0),n.fromBufferAttribute(e,d+1),o.fromBufferAttribute(e,d+2),h.subVectors(o,n),l.subVectors(i,n),h.cross(l),s.setXYZ(d+0,h.x,h.y,h.z),s.setXYZ(d+1,h.x,h.y,h.z),s.setXYZ(d+2,h.x,h.y,h.z);this.normalizeNormals(),s.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,s=t.count;e<s;e++)nt.fromBufferAttribute(t,e),nt.normalize(),t.setXYZ(e,nt.x,nt.y,nt.z)}toNonIndexed(){function t(a,c){const u=a.array,h=a.itemSize,l=a.normalized,d=new u.constructor(c.length*h);let p=0,f=0;for(let m=0,g=c.length;m<g;m++){a.isInterleavedBufferAttribute?p=c[m]*a.data.stride+a.offset:p=c[m]*h;for(let y=0;y<h;y++)d[f++]=u[p++]}return new vt(d,h,l)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new Li,s=this.index.array,i=this.attributes;for(const a in i){const c=i[a],u=t(c,s);e.setAttribute(a,u)}const n=this.morphAttributes;for(const a in n){const c=[],u=n[a];for(let h=0,l=u.length;h<l;h++){const d=u[h],p=t(d,s);c.push(p)}e.morphAttributes[a]=c}e.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let a=0,c=o.length;a<c;a++){const u=o[a];e.addGroup(u.start,u.count,u.materialIndex)}return e}toJSON(){const t={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const u in c)c[u]!==void 0&&(t[u]=c[u]);return t}t.data={attributes:{}};const e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const s=this.attributes;for(const c in s){const u=s[c];t.data.attributes[c]=u.toJSON(t.data)}const i={};let n=!1;for(const c in this.morphAttributes){const u=this.morphAttributes[c],h=[];for(let l=0,d=u.length;l<d;l++){const p=u[l];h.push(p.toJSON(t.data))}h.length>0&&(i[c]=h,n=!0)}n&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(t.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return a!==null&&(t.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const s=t.index;s!==null&&this.setIndex(s.clone(e));const i=t.attributes;for(const u in i){const h=i[u];this.setAttribute(u,h.clone(e))}const n=t.morphAttributes;for(const u in n){const h=[],l=n[u];for(let d=0,p=l.length;d<p;d++)h.push(l[d].clone(e));this.morphAttributes[u]=h}this.morphTargetsRelative=t.morphTargetsRelative;const o=t.groups;for(let u=0,h=o.length;u<h;u++){const l=o[u];this.addGroup(l.start,l.count,l.materialIndex)}const a=t.boundingBox;a!==null&&(this.boundingBox=a.clone());const c=t.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const Oi=new A,Wo=new A,Go=new Ct;class Di{constructor(t=new A(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,s,i){return this.normal.set(t,e,s),this.constant=i,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,s){const i=Oi.subVectors(s,e).cross(Wo.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(i,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e){const s=t.delta(Oi),i=this.normal.dot(s);if(i===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;const n=-(t.start.dot(this.normal)+this.constant)/i;return n<0||n>1?null:e.copy(t.start).addScaledVector(s,n)}intersectsLine(t){const e=this.distanceToPoint(t.start),s=this.distanceToPoint(t.end);return e<0&&s>0||s<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const s=e||Go.getNormalMatrix(t),i=this.coplanarPoint(Oi).applyMatrix4(t),n=this.normal.applyMatrix3(s).normalize();return this.constant=-i.dot(n),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}}class tr extends Dt{constructor(t,e,s,i,n,o,a,c,u,h=1026){if(h!==1026&&h!==1027)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");s===void 0&&h===1026&&(s=1014),s===void 0&&h===1027&&(s=1020),super(null,i,n,o,a,c,h,s,u),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=a!==void 0?a:1003,this.minFilter=c!==void 0?c:1003,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return this.compareFunction!==null&&(e.compareFunction=this.compareFunction),e}}class Xo{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=35044,this.updateRanges=[],this.version=0,this.uuid=Kt()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,s){t*=this.stride,s*=e.stride;for(let i=0,n=this.stride;i<n;i++)this.array[t+i]=e.array[s+i];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Kt()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),s=new this.constructor(e,this.stride);return s.setUsage(this.usage),s}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Kt()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const ut=new A;class Ui{constructor(t,e,s,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=s,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,s=this.data.count;e<s;e++)ut.fromBufferAttribute(this,e),ut.applyMatrix4(t),this.setXYZ(e,ut.x,ut.y,ut.z);return this}applyNormalMatrix(t){for(let e=0,s=this.count;e<s;e++)ut.fromBufferAttribute(this,e),ut.applyNormalMatrix(t),this.setXYZ(e,ut.x,ut.y,ut.z);return this}transformDirection(t){for(let e=0,s=this.count;e<s;e++)ut.fromBufferAttribute(this,e),ut.transformDirection(t),this.setXYZ(e,ut.x,ut.y,ut.z);return this}getComponent(t,e){let s=this.array[t*this.data.stride+this.offset+e];return this.normalized&&(s=Et(s,this.array)),s}setComponent(t,e,s){return this.normalized&&(s=$(s,this.array)),this.data.array[t*this.data.stride+this.offset+e]=s,this}setX(t,e){return this.normalized&&(e=$(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=$(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=$(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=$(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=Et(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=Et(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=Et(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=Et(e,this.array)),e}setXY(t,e,s){return t=t*this.data.stride+this.offset,this.normalized&&(e=$(e,this.array),s=$(s,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=s,this}setXYZ(t,e,s,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=$(e,this.array),s=$(s,this.array),i=$(i,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=s,this.data.array[t+2]=i,this}setXYZW(t,e,s,i,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=$(e,this.array),s=$(s,this.array),i=$(i,this.array),n=$(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=s,this.data.array[t+2]=i,this.data.array[t+3]=n,this}clone(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let s=0;s<this.count;s++){const i=s*this.data.stride+this.offset;for(let n=0;n<this.itemSize;n++)e.push(this.data.array[i+n])}return new vt(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new Ui(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let s=0;s<this.count;s++){const i=s*this.data.stride+this.offset;for(let n=0;n<this.itemSize;n++)e.push(this.data.array[i+n])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class Yo extends Dt{constructor(t,e){super({width:t,height:e}),this.isFramebufferTexture=!0,this.magFilter=1003,this.minFilter=1003,this.generateMipmaps=!1,this.needsUpdate=!0}}const er=new A,vs=new A;class Zt{constructor(t=new A,e=new A){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){er.subVectors(t,this.start),vs.subVectors(this.end,this.start);const s=vs.dot(vs);let n=vs.dot(er)/s;return e&&(n=at(n,0,1)),n}closestPointToPoint(t,e,s){const i=this.closestPointToPointParameter(t,e);return this.delta(s).multiplyScalar(i).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}function Vi(r,t=0){let e=3735928559^t,s=1103547991^t;if(r instanceof Array)for(let i=0,n;i<r.length;i++)n=r[i],e=Math.imul(e^n,2654435761),s=Math.imul(s^n,1597334677);else for(let i=0,n;i<r.length;i++)n=r.charCodeAt(i),e=Math.imul(e^n,2654435761),s=Math.imul(s^n,1597334677);return e=Math.imul(e^e>>>16,2246822507),e^=Math.imul(s^s>>>13,3266489909),s=Math.imul(s^s>>>16,2246822507),s^=Math.imul(e^e>>>13,3266489909),4294967296*(2097151&s)+(e>>>0)}const Zo=(...r)=>Vi(r);function Jo(r,t=!1){const e=[];r.isNode===!0&&(e.push(r.id),r=r.getSelf());for(const{property:s,childNode:i}of ki(r))e.push(e,Vi(s.slice(0,-4)),i.getCacheKey(t));return Vi(e)}function*ki(r,t=!1){for(const e in r){if(e.startsWith("_")===!0)continue;const s=r[e];if(Array.isArray(s)===!0)for(let i=0;i<s.length;i++){const n=s[i];n&&(n.isNode===!0||t&&typeof n.toJSON=="function")&&(yield{property:e,index:i,childNode:n})}else if(s&&s.isNode===!0)yield{property:e,childNode:s};else if(typeof s=="object")for(const i in s){const n=s[i];n&&(n.isNode===!0||t&&typeof n.toJSON=="function")&&(yield{property:e,index:i,childNode:n})}}}function Ps(r){if(r==null)return null;const t=typeof r;return r.isNode===!0?"node":t==="number"?"float":t==="boolean"?"bool":t==="string"?"string":t==="function"?"shader":r.isVector2===!0?"vec2":r.isVector3===!0?"vec3":r.isVector4===!0?"vec4":r.isMatrix3===!0?"mat3":r.isMatrix4===!0?"mat4":r.isColor===!0?"color":r instanceof ArrayBuffer?"ArrayBuffer":null}function sr(r,...t){const e=r?r.slice(-4):void 0;return t.length===1&&(e==="vec2"?t=[t[0],t[0]]:e==="vec3"?t=[t[0],t[0],t[0]]:e==="vec4"&&(t=[t[0],t[0],t[0],t[0]])),r==="color"?new vi(...t):e==="vec2"?new J(...t):e==="vec3"?new A(...t):e==="vec4"?new Ft(...t):e==="mat3"?new Ct(...t):e==="mat4"?new it(...t):r==="bool"?t[0]||!1:r==="float"||r==="int"||r==="uint"?t[0]||0:r==="string"?t[0]||"":r==="ArrayBuffer"?Qo(t[0]):null}function jo(r){let t="";const e=new Uint8Array(r);for(let s=0;s<e.length;s++)t+=String.fromCharCode(e[s]);return btoa(t)}function Qo(r){return Uint8Array.from(atob(r),t=>t.charCodeAt(0)).buffer}const ir={VERTEX:"vertex"},Q={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},ss=["x","y","z","w"];let Ko=0;class V extends Ye{static get type(){return"Node"}constructor(t=null){super(),this.nodeType=t,this.updateType=Q.NONE,this.updateBeforeType=Q.NONE,this.updateAfterType=Q.NONE,this.uuid=bo.generateUUID(),this.version=0,this._cacheKey=null,this._cacheKeyVersion=0,this.global=!1,this.isNode=!0,Object.defineProperty(this,"id",{value:Ko++})}set needsUpdate(t){t===!0&&this.version++}get type(){return this.constructor.type}onUpdate(t,e){return this.updateType=e,this.update=t.bind(this.getSelf()),this}onFrameUpdate(t){return this.onUpdate(t,Q.FRAME)}onRenderUpdate(t){return this.onUpdate(t,Q.RENDER)}onObjectUpdate(t){return this.onUpdate(t,Q.OBJECT)}onReference(t){return this.updateReference=t.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:t}of ki(this))yield t}dispose(){this.dispatchEvent({type:"dispose"})}traverse(t){t(this);for(const e of this.getChildren())e.traverse(t)}getCacheKey(t=!1){return t=t||this.version!==this._cacheKeyVersion,(t===!0||this._cacheKey===null)&&(this._cacheKey=Jo(this,t),this._cacheKeyVersion=this.version),this._cacheKey}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(t){const e=this.getNodeType(t);return t.getElementType(e)}getNodeType(t){const e=t.getNodeProperties(this);return e.outputNode?e.outputNode.getNodeType(t):this.nodeType}getShared(t){const e=this.getHash(t);return t.getNodeFromHash(e)||this}setup(t){const e=t.getNodeProperties(this);let s=0;for(const i of this.getChildren())e["node"+s++]=i;return null}analyze(t){if(t.increaseUsage(this)===1){const s=t.getNodeProperties(this);for(const i of Object.values(s))i&&i.isNode===!0&&i.build(t)}}generate(t,e){const{outputNode:s}=t.getNodeProperties(this);if(s&&s.isNode===!0)return s.build(t,e)}updateBefore(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(t,e=null){const s=this.getShared(t);if(this!==s)return s.build(t,e);t.addNode(this),t.addChain(this);let i=null;const n=t.getBuildStage();if(n==="setup"){this.updateReference(t);const o=t.getNodeProperties(this);if(o.initialized!==!0){const a=t.stack.nodes.length;o.initialized=!0,o.outputNode=this.setup(t),o.outputNode!==null&&t.stack.nodes.length;for(const c of Object.values(o))c&&c.isNode===!0&&c.build(t)}}else if(n==="analyze")this.analyze(t);else if(n==="generate")if(this.generate.length===1){const a=this.getNodeType(t),c=t.getDataFromNode(this);i=c.snippet,i===void 0?(i=this.generate(t)||"",c.snippet=i):c.flowCodes!==void 0&&t.context.nodeBlock!==void 0&&t.addFlowCodeHierarchy(this,t.context.nodeBlock),i=t.format(i,a,e)}else i=this.generate(t,e)||"";return t.removeChain(this),i}getSerializeChildren(){return ki(this)}serialize(t){const e=this.getSerializeChildren(),s={};for(const{property:i,index:n,childNode:o}of e)n!==void 0?(s[i]===void 0&&(s[i]=Number.isInteger(n)?[]:{}),s[i][n]=o.toJSON(t.meta).uuid):s[i]=o.toJSON(t.meta).uuid;Object.keys(s).length>0&&(t.inputNodes=s)}deserialize(t){if(t.inputNodes!==void 0){const e=t.meta.nodes;for(const s in t.inputNodes)if(Array.isArray(t.inputNodes[s])){const i=[];for(const n of t.inputNodes[s])i.push(e[n]);this[s]=i}else if(typeof t.inputNodes[s]=="object"){const i={};for(const n in t.inputNodes[s]){const o=t.inputNodes[s][n];i[n]=e[o]}this[s]=i}else{const i=t.inputNodes[s];this[s]=e[i]}}}toJSON(t){const{uuid:e,type:s}=this,i=t===void 0||typeof t=="string";i&&(t={textures:{},images:{},nodes:{}});let n=t.nodes[e];n===void 0&&(n={uuid:e,type:s,meta:t,metadata:{version:4.6,type:"Node",generator:"Node.toJSON"}},i!==!0&&(t.nodes[n.uuid]=n),this.serialize(n),delete n.meta);function o(a){const c=[];for(const u in a){const h=a[u];delete h.metadata,c.push(h)}return c}if(i){const a=o(t.textures),c=o(t.images),u=o(t.nodes);a.length>0&&(n.textures=a),c.length>0&&(n.images=c),u.length>0&&(n.nodes=u)}return n}}class is extends V{static get type(){return"ArrayElementNode"}constructor(t,e){super(),this.node=t,this.indexNode=e,this.isArrayElementNode=!0}getNodeType(t){return this.node.getElementType(t)}generate(t){const e=this.node.build(t),s=this.indexNode.build(t,"uint");return`${e}[ ${s} ]`}}class nr extends V{static get type(){return"ConvertNode"}constructor(t,e){super(),this.node=t,this.convertTo=e}getNodeType(t){const e=this.node.getNodeType(t);let s=null;for(const i of this.convertTo.split("|"))(s===null||t.getTypeLength(e)===t.getTypeLength(i))&&(s=i);return s}serialize(t){super.serialize(t),t.convertTo=this.convertTo}deserialize(t){super.deserialize(t),this.convertTo=t.convertTo}generate(t,e){const s=this.node,i=this.getNodeType(t),n=s.build(t,i);return t.format(n,i,e)}}class dt extends V{static get type(){return"TempNode"}constructor(t){super(t),this.isTempNode=!0}hasDependencies(t){return t.getDataFromNode(this).usageCount>1}build(t,e){if(t.getBuildStage()==="generate"){const i=t.getVectorType(this.getNodeType(t,e)),n=t.getDataFromNode(this);if(n.propertyName!==void 0)return t.format(n.propertyName,i,e);if(i!=="void"&&e!=="void"&&this.hasDependencies(t)){const o=super.build(t,i),a=t.getVarFromNode(this,null,i),c=t.getPropertyName(a);return t.addLineFlowCode(`${c} = ${o}`,this),n.snippet=o,n.propertyName=c,t.format(n.propertyName,i,e)}}return super.build(t,e)}}class ta extends dt{static get type(){return"JoinNode"}constructor(t=[],e=null){super(e),this.nodes=t}getNodeType(t){return this.nodeType!==null?t.getVectorType(this.nodeType):t.getTypeFromLength(this.nodes.reduce((e,s)=>e+t.getTypeLength(s.getNodeType(t)),0))}generate(t,e){const s=this.getNodeType(t),i=this.nodes,n=t.getComponentType(s),o=[];for(const c of i){let u=c.build(t);const h=t.getComponentType(c.getNodeType(t));h!==n&&(u=t.format(u,h,n)),o.push(u)}const a=`${t.getType(s)}( ${o.join(", ")} )`;return t.format(a,s,e)}}const ea=ss.join("");class rr extends V{static get type(){return"SplitNode"}constructor(t,e="x"){super(),this.node=t,this.components=e,this.isSplitNode=!0}getVectorLength(){let t=this.components.length;for(const e of this.components)t=Math.max(ss.indexOf(e)+1,t);return t}getComponentType(t){return t.getComponentType(this.node.getNodeType(t))}getNodeType(t){return t.getTypeFromLength(this.components.length,this.getComponentType(t))}generate(t,e){const s=this.node,i=t.getTypeLength(s.getNodeType(t));let n=null;if(i>1){let o=null;this.getVectorLength()>=i&&(o=t.getTypeFromLength(this.getVectorLength(),this.getComponentType(t)));const c=s.build(t,o);this.components.length===i&&this.components===ea.slice(0,this.components.length)?n=t.format(c,o,e):n=t.format(`${c}.${this.components}`,this.getNodeType(t),e)}else n=s.build(t,e);return n}serialize(t){super.serialize(t),t.components=this.components}deserialize(t){super.deserialize(t),this.components=t.components}}class sa extends dt{static get type(){return"SetNode"}constructor(t,e,s){super(),this.sourceNode=t,this.components=e,this.targetNode=s}getNodeType(t){return this.sourceNode.getNodeType(t)}generate(t){const{sourceNode:e,components:s,targetNode:i}=this,n=this.getNodeType(t),o=t.getTypeFromLength(s.length,i.getNodeType(t)),a=i.build(t,o),c=e.build(t,n),u=t.getTypeLength(n),h=[];for(let l=0;l<u;l++){const d=ss[l];d===s[0]?(h.push(a),l+=s.length-1):h.push(c+"."+d)}return`${t.getType(n)}( ${h.join(", ")} )`}}class ia extends dt{static get type(){return"FlipNode"}constructor(t,e){super(),this.sourceNode=t,this.components=e}getNodeType(t){return this.sourceNode.getNodeType(t)}generate(t){const{components:e,sourceNode:s}=this,i=this.getNodeType(t),n=s.build(t),o=t.getVarFromNode(this),a=t.getPropertyName(o);t.addLineFlowCode(a+" = "+n,this);const c=t.getTypeLength(i),u=[];let h=0;for(let l=0;l<c;l++){const d=ss[l];d===e[h]?(u.push("1.0 - "+(a+"."+d)),h++):u.push(a+"."+d)}return`${t.getType(i)}( ${u.join(", ")} )`}}class Hi extends V{static get type(){return"InputNode"}constructor(t,e=null){super(e),this.isInputNode=!0,this.value=t,this.precision=null}getNodeType(){return this.nodeType===null?Ps(this.value):this.nodeType}getInputType(t){return this.getNodeType(t)}setPrecision(t){return this.precision=t,this}serialize(t){super.serialize(t),t.value=this.value,this.value&&this.value.toArray&&(t.value=this.value.toArray()),t.valueType=Ps(this.value),t.nodeType=this.nodeType,t.valueType==="ArrayBuffer"&&(t.value=jo(t.value)),t.precision=this.precision}deserialize(t){super.deserialize(t),this.nodeType=t.nodeType,this.value=Array.isArray(t.value)?sr(t.valueType,...t.value):t.value,this.precision=t.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(t.value))}generate(){console.warn("Abstract function.")}}class Jt extends Hi{static get type(){return"ConstNode"}constructor(t,e=null){super(t,e),this.isConstNode=!0}generateConst(t){return t.generateConst(this.getNodeType(t),this.value)}generate(t,e){const s=this.getNodeType(t);return t.format(this.generateConst(t),s,e)}}let or=null;const Ce=new Map;function b(r,t){if(Ce.has(r)){console.warn(`Redefinition of method chaining ${r}`);return}if(typeof t!="function")throw new Error(`Node element ${r} is not a function`);Ce.set(r,t)}const ar=r=>r.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),cr=r=>ar(r).split("").sort().join(""),hr={setup(r,t){const e=t.shift();return r(Ds(e),...t)},get(r,t,e){if(typeof t=="string"&&r[t]===void 0){if(r.isStackNode!==!0&&t==="assign")return(...s)=>(or.assign(e,...s),e);if(Ce.has(t)){const s=Ce.get(t);return r.isStackNode?(...i)=>e.add(s(...i)):(...i)=>s(e,...i)}else{if(t==="self")return r;if(t.endsWith("Assign")&&Ce.has(t.slice(0,t.length-6))){const s=Ce.get(t.slice(0,t.length-6));return r.isStackNode?(...i)=>e.assign(i[0],s(...i)):(...i)=>e.assign(s(e,...i))}else{if(/^[xyzwrgbastpq]{1,4}$/.test(t)===!0)return t=ar(t),v(new rr(e,t));if(/^set[XYZWRGBASTPQ]{1,4}$/.test(t)===!0)return t=cr(t.slice(3).toLowerCase()),s=>v(new sa(r,t,s));if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(t)===!0)return t=cr(t.slice(4).toLowerCase()),()=>v(new ia(v(r),t));if(t==="width"||t==="height"||t==="depth")return t==="width"?t="x":t==="height"?t="y":t==="depth"&&(t="z"),v(new rr(r,t));if(/^\d+$/.test(t)===!0)return v(new is(e,new Jt(Number(t),"uint")))}}}return Reflect.get(r,t,e)},set(r,t,e,s){return typeof t=="string"&&r[t]===void 0&&(/^[xyzwrgbastpq]{1,4}$/.test(t)===!0||t==="width"||t==="height"||t==="depth"||/^\d+$/.test(t)===!0)?(s[t].assign(e),!0):Reflect.set(r,t,e,s)}},qi=new WeakMap,ur=new WeakMap,na=function(r,t=null){const e=Ps(r);if(e==="node"){let s=qi.get(r);return s===void 0&&(s=new Proxy(r,hr),qi.set(r,s),qi.set(s,s)),s}else{if(t===null&&(e==="float"||e==="boolean")||e&&e!=="shader"&&e!=="string")return v(Xi(r,t));if(e==="shader")return tt(r)}return r},ra=function(r,t=null){for(const e in r)r[e]=v(r[e],t);return r},oa=function(r,t=null){const e=r.length;for(let s=0;s<e;s++)r[s]=v(r[s],t);return r},aa=function(r,t=null,e=null,s=null){const i=n=>v(s!==null?Object.assign(n,s):n);return t===null?(...n)=>i(new r(...Fe(n))):e!==null?(e=v(e),(...n)=>i(new r(t,...Fe(n),e))):(...n)=>i(new r(t,...Fe(n)))},ca=function(r,...t){return v(new r(...Fe(t)))};class ha extends V{constructor(t,e){super(),this.shaderNode=t,this.inputNodes=e}getNodeType(t){return this.shaderNode.nodeType||this.getOutputNode(t).getNodeType(t)}call(t){const{shaderNode:e,inputNodes:s}=this,i=t.getNodeProperties(e);if(i.onceOutput)return i.onceOutput;let n=null;if(e.layout){let o=ur.get(t.constructor);o===void 0&&(o=new WeakMap,ur.set(t.constructor,o));let a=o.get(e);a===void 0&&(a=v(t.buildFunctionNode(e)),o.set(e,a)),t.currentFunctionNode!==null&&t.currentFunctionNode.includes.push(a),n=v(a.call(s))}else{const o=e.jsFunc,a=s!==null?o(s,t):o(t);n=v(a)}return e.once&&(i.onceOutput=n),n}getOutputNode(t){const e=t.getNodeProperties(this);return e.outputNode===null&&(e.outputNode=this.setupOutput(t)),e.outputNode}setup(t){return this.getOutputNode(t)}setupOutput(t){return t.addStack(),t.stack.outputNode=this.call(t),t.removeStack()}generate(t,e){return this.getOutputNode(t).build(t,e)}}class ua extends V{constructor(t,e){super(e),this.jsFunc=t,this.layout=null,this.global=!0,this.once=!1}setLayout(t){return this.layout=t,this}call(t=null){return Ds(t),v(new ha(this,t))}setup(){return this.call()}}const la=[!1,!0],da=[0,1,2,3],pa=[-1,-2],lr=[.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],$i=new Map;for(const r of la)$i.set(r,new Jt(r));const Wi=new Map;for(const r of da)Wi.set(r,new Jt(r,"uint"));const Gi=new Map([...Wi].map(r=>new Jt(r.value,"int")));for(const r of pa)Gi.set(r,new Jt(r,"int"));const Ls=new Map([...Gi].map(r=>new Jt(r.value)));for(const r of lr)Ls.set(r,new Jt(r));for(const r of lr)Ls.set(-r,new Jt(-r));const Os={bool:$i,uint:Wi,ints:Gi,float:Ls},dr=new Map([...$i,...Ls]),Xi=(r,t)=>dr.has(r)?dr.get(r):r.isNode===!0?r:new Jt(r,t),fa=r=>{try{return r.getNodeType()}catch{return}},K=function(r,t=null){return(...e)=>{if((e.length===0||!["bool","float","int","uint"].includes(r)&&e.every(i=>typeof i!="object"))&&(e=[sr(r,...e)]),e.length===1&&t!==null&&t.has(e[0]))return v(t.get(e[0]));if(e.length===1){const i=Xi(e[0],r);return fa(i)===r?v(i):v(new nr(i,r))}const s=e.map(i=>Xi(i));return v(new ta(s,r))}},ma=r=>r!=null?r.nodeType||r.convertTo||(typeof r=="string"?r:null):null;function ya(r,t){return new Proxy(new ua(r,t),hr)}const v=(r,t=null)=>na(r,t),Ds=(r,t=null)=>new ra(r,t),Fe=(r,t=null)=>new oa(r,t),C=(...r)=>new aa(...r),O=(...r)=>new ca(...r),tt=(r,t)=>{const e=new ya(r,t),s=(...i)=>{let n;return Ds(i),i[0]&&i[0].isNode?n=[...i]:n=i[0],e.call(n)};return s.shaderNode=e,s.setLayout=i=>(e.setLayout(i),s),s.once=()=>(e.once=!0,s),s};b("toGlobal",r=>(r.global=!0,r));const Yi=(...r)=>or.If(...r);function ga(r){return r}b("append",ga);const xa=new K("color"),q=new K("float",Os.float),Re=new K("int",Os.ints),Ta=new K("uint",Os.uint),Na=new K("bool",Os.bool),D=new K("vec2"),wa=new K("ivec2"),Aa=new K("uvec2"),Ma=new K("bvec2"),k=new K("vec3"),Sa=new K("ivec3"),_a=new K("uvec3"),za=new K("bvec3"),Be=new K("vec4"),ba=new K("ivec4"),Ea=new K("uvec4"),Ca=new K("bvec4"),pr=new K("mat2"),Us=new K("mat3"),Fa=new K("mat4");b("toColor",xa),b("toFloat",q),b("toInt",Re),b("toUint",Ta),b("toBool",Na),b("toVec2",D),b("toIVec2",wa),b("toUVec2",Aa),b("toBVec2",Ma),b("toVec3",k),b("toIVec3",Sa),b("toUVec3",_a),b("toBVec3",za),b("toVec4",Be),b("toIVec4",ba),b("toUVec4",Ea),b("toBVec4",Ca),b("toMat2",pr),b("toMat3",Us),b("toMat4",Fa);const Ra=C(is),Ba=(r,t)=>v(new nr(v(r),t));b("element",Ra),b("convert",Ba);class fr extends V{static get type(){return"UniformGroupNode"}constructor(t,e=!1,s=1){super("string"),this.name=t,this.version=0,this.shared=e,this.order=s,this.isUniformGroup=!0}set needsUpdate(t){t===!0&&this.version++}serialize(t){super.serialize(t),t.name=this.name,t.version=this.version,t.shared=this.shared}deserialize(t){super.deserialize(t),this.name=t.name,this.version=t.version,this.shared=t.shared}}const Ia=r=>new fr(r),de=((r,t=0)=>new fr(r,!0,t))("render"),va=Ia("object");class Ie extends Hi{static get type(){return"UniformNode"}constructor(t,e=null){super(t,e),this.isUniformNode=!0,this.name="",this.groupNode=va}label(t){return this.name=t,this}setGroup(t){return this.groupNode=t,this}getGroup(){return this.groupNode}getUniformHash(t){return this.getHash(t)}onUpdate(t,e){const s=this.getSelf();return t=t.bind(s),super.onUpdate(i=>{const n=t(i,s);n!==void 0&&(this.value=n)},e)}generate(t,e){const s=this.getNodeType(t),i=this.getUniformHash(t);let n=t.getNodeFromHash(i);n===void 0&&(t.setHashNode(this,i),n=this);const o=n.getInputType(t),a=t.getUniformFromNode(n,o,t.shaderStage,this.name||t.context.label),c=t.getPropertyName(a);return t.context.label!==void 0&&delete t.context.label,t.format(c,s,e)}}const xt=(r,t)=>{const e=ma(t||r),s=r&&r.isNode===!0?r.node&&r.node.value||r.value:r;return v(new Ie(s,e))};class mr extends V{static get type(){return"PropertyNode"}constructor(t,e=null,s=!1){super(t),this.name=e,this.varying=s,this.isPropertyNode=!0}getHash(t){return this.name||super.getHash(t)}isGlobal(){return!0}generate(t){let e;return this.varying===!0?(e=t.getVaryingFromNode(this,this.name),e.needsInterpolation=!0):e=t.getVarFromNode(this,this.name),t.getPropertyName(e)}}const ve=(r,t)=>v(new mr(r,t)),yr=O(mr,"vec4","DiffuseColor");class Pa extends dt{static get type(){return"AssignNode"}constructor(t,e){super(),this.targetNode=t,this.sourceNode=e}hasDependencies(){return!1}getNodeType(t,e){return e!=="void"?this.targetNode.getNodeType(t):"void"}needsSplitAssign(t){const{targetNode:e}=this;if(t.isAvailable("swizzleAssign")===!1&&e.isSplitNode&&e.components.length>1){const s=t.getTypeLength(e.node.getNodeType(t));return ss.join("").slice(0,s)!==e.components}return!1}generate(t,e){const{targetNode:s,sourceNode:i}=this,n=this.needsSplitAssign(t),o=s.getNodeType(t),a=s.context({assign:!0}).build(t),c=i.build(t,o),u=i.getNodeType(t),h=t.getDataFromNode(this);let l;if(h.initialized===!0)e!=="void"&&(l=a);else if(n){const d=t.getVarFromNode(this,null,o),p=t.getPropertyName(d);t.addLineFlowCode(`${p} = ${c}`,this);const f=s.node.context({assign:!0}).build(t);for(let m=0;m<s.components.length;m++){const g=s.components[m];t.addLineFlowCode(`${f}.${g} = ${p}[ ${m} ]`,this)}e!=="void"&&(l=a)}else l=`${a} = ${c}`,(e==="void"||u==="void")&&(t.addLineFlowCode(l,this),e!=="void"&&(l=a));return h.initialized=!0,t.format(l,o,e)}}b("assign",C(Pa));class La extends dt{static get type(){return"FunctionCallNode"}constructor(t=null,e={}){super(),this.functionNode=t,this.parameters=e}setParameters(t){return this.parameters=t,this}getParameters(){return this.parameters}getNodeType(t){return this.functionNode.getNodeType(t)}generate(t){const e=[],s=this.functionNode,i=s.getInputs(t),n=this.parameters;if(Array.isArray(n))for(let a=0;a<n.length;a++){const c=i[a],u=n[a];e.push(u.build(t,c.type))}else for(const a of i){const c=n[a.name];if(c!==void 0)e.push(c.build(t,a.type));else throw new Error(`FunctionCallNode: Input '${a.name}' not found in FunctionNode.`)}return`${s.build(t,"property")}( ${e.join(", ")} )`}}b("call",(r,...t)=>(t=t.length>1||t[0]&&t[0].isNode===!0?Fe(t):Ds(t[0]),v(new La(v(r),t))));class Y extends dt{static get type(){return"OperatorNode"}constructor(t,e,s,...i){if(super(),i.length>0){let n=new Y(t,e,s);for(let o=0;o<i.length-1;o++)n=new Y(t,n,i[o]);e=n,s=i[i.length-1]}this.op=t,this.aNode=e,this.bNode=s}getNodeType(t,e){const s=this.op,i=this.aNode,n=this.bNode,o=i.getNodeType(t),a=typeof n<"u"?n.getNodeType(t):null;if(o==="void"||a==="void")return"void";if(s==="%")return o;if(s==="~"||s==="&"||s==="|"||s==="^"||s===">>"||s==="<<")return t.getIntegerType(o);if(s==="!"||s==="=="||s==="&&"||s==="||"||s==="^^")return"bool";if(s==="<"||s===">"||s==="<="||s===">="){const c=e?t.getTypeLength(e):Math.max(t.getTypeLength(o),t.getTypeLength(a));return c>1?`bvec${c}`:"bool"}else return o==="float"&&t.isMatrix(a)?a:t.isMatrix(o)&&t.isVector(a)?t.getVectorFromMatrix(o):t.isVector(o)&&t.isMatrix(a)?t.getVectorFromMatrix(a):t.getTypeLength(a)>t.getTypeLength(o)?a:o}generate(t,e){const s=this.op,i=this.aNode,n=this.bNode,o=this.getNodeType(t,e);let a=null,c=null;o!=="void"?(a=i.getNodeType(t),c=typeof n<"u"?n.getNodeType(t):null,s==="<"||s===">"||s==="<="||s===">="||s==="=="?t.isVector(a)?c=a:a!==c&&(a=c="float"):s===">>"||s==="<<"?(a=o,c=t.changeComponentType(c,"uint")):t.isMatrix(a)&&t.isVector(c)?c=t.getVectorFromMatrix(a):t.isVector(a)&&t.isMatrix(c)?a=t.getVectorFromMatrix(c):a=c=o):a=c=o;const u=i.build(t,a),h=typeof n<"u"?n.build(t,c):null,l=t.getTypeLength(e),d=t.getFunctionOperator(s);if(e!=="void")return s==="<"&&l>1?t.useComparisonMethod?t.format(`${t.getMethod("lessThan",e)}( ${u}, ${h} )`,o,e):t.format(`( ${u} < ${h} )`,o,e):s==="<="&&l>1?t.useComparisonMethod?t.format(`${t.getMethod("lessThanEqual",e)}( ${u}, ${h} )`,o,e):t.format(`( ${u} <= ${h} )`,o,e):s===">"&&l>1?t.useComparisonMethod?t.format(`${t.getMethod("greaterThan",e)}( ${u}, ${h} )`,o,e):t.format(`( ${u} > ${h} )`,o,e):s===">="&&l>1?t.useComparisonMethod?t.format(`${t.getMethod("greaterThanEqual",e)}( ${u}, ${h} )`,o,e):t.format(`( ${u} >= ${h} )`,o,e):s==="!"||s==="~"?t.format(`(${s}${u})`,a,e):d?t.format(`${d}( ${u}, ${h} )`,o,e):t.format(`( ${u} ${s} ${h} )`,o,e);if(a!=="void")return d?t.format(`${d}( ${u}, ${h} )`,o,e):t.format(`${u} ${s} ${h}`,o,e)}serialize(t){super.serialize(t),t.op=this.op}deserialize(t){super.deserialize(t),this.op=t.op}}const pe=C(Y,"+"),Vs=C(Y,"-"),ks=C(Y,"*"),gr=C(Y,"/"),xr=C(Y,"%"),Oa=C(Y,"=="),Da=C(Y,"!="),Ua=C(Y,"<"),Va=C(Y,">"),ka=C(Y,"<="),Ha=C(Y,">="),qa=C(Y,"&&"),$a=C(Y,"||"),Wa=C(Y,"!"),Ga=C(Y,"^^"),Xa=C(Y,"&"),Ya=C(Y,"~"),Za=C(Y,"|"),Ja=C(Y,"^"),ja=C(Y,"<<"),Qa=C(Y,">>");b("add",pe),b("sub",Vs),b("mul",ks),b("div",gr),b("modInt",xr),b("equal",Oa),b("notEqual",Da),b("lessThan",Ua),b("greaterThan",Va),b("lessThanEqual",ka),b("greaterThanEqual",Ha),b("and",qa),b("or",$a),b("not",Wa),b("xor",Ga),b("bitAnd",Xa),b("bitNot",Ya),b("bitOr",Za),b("bitXor",Ja),b("shiftLeft",ja),b("shiftRight",Qa),b("remainder",(...r)=>(console.warn("TSL.OperatorNode: .remainder() has been renamed to .modInt()."),xr(...r)));class x extends dt{static get type(){return"MathNode"}constructor(t,e,s=null,i=null){super(),this.method=t,this.aNode=e,this.bNode=s,this.cNode=i}getInputType(t){const e=this.aNode.getNodeType(t),s=this.bNode?this.bNode.getNodeType(t):null,i=this.cNode?this.cNode.getNodeType(t):null,n=t.isMatrix(e)?0:t.getTypeLength(e),o=t.isMatrix(s)?0:t.getTypeLength(s),a=t.isMatrix(i)?0:t.getTypeLength(i);return n>o&&n>a?e:o>a?s:a>n?i:e}getNodeType(t){const e=this.method;return e===x.LENGTH||e===x.DISTANCE||e===x.DOT?"float":e===x.CROSS?"vec3":e===x.ALL?"bool":e===x.EQUALS?t.changeComponentType(this.aNode.getNodeType(t),"bool"):e===x.MOD?this.aNode.getNodeType(t):this.getInputType(t)}generate(t,e){const s=this.method,i=this.getNodeType(t),n=this.getInputType(t),o=this.aNode,a=this.bNode,c=this.cNode,u=t.renderer.isWebGLRenderer===!0;if(s===x.TRANSFORM_DIRECTION){let h=o,l=a;t.isMatrix(h.getNodeType(t))?l=Be(k(l),0):h=Be(k(h),0);const d=ks(h,l).xyz;return Tr(d).build(t,e)}else{if(s===x.NEGATE)return t.format("( - "+o.build(t,n)+" )",i,e);if(s===x.ONE_MINUS)return Vs(1,o).build(t,e);if(s===x.RECIPROCAL)return gr(1,o).build(t,e);if(s===x.DIFFERENCE)return ji(Vs(o,a)).build(t,e);{const h=[];return s===x.CROSS||s===x.MOD?h.push(o.build(t,i),a.build(t,i)):u&&s===x.STEP?h.push(o.build(t,t.getTypeLength(o.getNodeType(t))===1?"float":n),a.build(t,n)):u&&(s===x.MIN||s===x.MAX)||s===x.MOD?h.push(o.build(t,n),a.build(t,t.getTypeLength(a.getNodeType(t))===1?"float":n)):s===x.REFRACT?h.push(o.build(t,n),a.build(t,n),c.build(t,"float")):s===x.MIX?h.push(o.build(t,n),a.build(t,n),c.build(t,t.getTypeLength(c.getNodeType(t))===1?"float":n)):(h.push(o.build(t,n)),a!==null&&h.push(a.build(t,n)),c!==null&&h.push(c.build(t,n))),t.format(`${t.getMethod(s,i)}( ${h.join(", ")} )`,i,e)}}}serialize(t){super.serialize(t),t.method=this.method}deserialize(t){super.deserialize(t),this.method=t.method}}x.ALL="all",x.ANY="any",x.EQUALS="equals",x.RADIANS="radians",x.DEGREES="degrees",x.EXP="exp",x.EXP2="exp2",x.LOG="log",x.LOG2="log2",x.SQRT="sqrt",x.INVERSE_SQRT="inversesqrt",x.FLOOR="floor",x.CEIL="ceil",x.NORMALIZE="normalize",x.FRACT="fract",x.SIN="sin",x.COS="cos",x.TAN="tan",x.ASIN="asin",x.ACOS="acos",x.ATAN="atan",x.ABS="abs",x.SIGN="sign",x.LENGTH="length",x.NEGATE="negate",x.ONE_MINUS="oneMinus",x.DFDX="dFdx",x.DFDY="dFdy",x.ROUND="round",x.RECIPROCAL="reciprocal",x.TRUNC="trunc",x.FWIDTH="fwidth",x.BITCAST="bitcast",x.TRANSPOSE="transpose",x.ATAN2="atan2",x.MIN="min",x.MAX="max",x.MOD="mod",x.STEP="step",x.REFLECT="reflect",x.DISTANCE="distance",x.DIFFERENCE="difference",x.DOT="dot",x.CROSS="cross",x.POW="pow",x.TRANSFORM_DIRECTION="transformDirection",x.MIX="mix",x.CLAMP="clamp",x.REFRACT="refract",x.SMOOTHSTEP="smoothstep",x.FACEFORWARD="faceforward";const Ka=q(Math.PI),tc=C(x,x.ALL),ec=C(x,x.ANY),sc=C(x,x.EQUALS),ic=C(x,x.RADIANS),nc=C(x,x.DEGREES),rc=C(x,x.EXP),oc=C(x,x.EXP2),ac=C(x,x.LOG),cc=C(x,x.LOG2),Zi=C(x,x.SQRT),hc=C(x,x.INVERSE_SQRT),uc=C(x,x.FLOOR),lc=C(x,x.CEIL),Tr=C(x,x.NORMALIZE),Ji=C(x,x.FRACT),Nr=C(x,x.SIN),dc=C(x,x.COS),pc=C(x,x.TAN),fc=C(x,x.ASIN),mc=C(x,x.ACOS),yc=C(x,x.ATAN),ji=C(x,x.ABS),wr=C(x,x.SIGN),gc=C(x,x.LENGTH),xc=C(x,x.NEGATE),Tc=C(x,x.ONE_MINUS),Nc=C(x,x.DFDX),wc=C(x,x.DFDY),Ac=C(x,x.ROUND),Mc=C(x,x.RECIPROCAL),Sc=C(x,x.TRUNC),_c=C(x,x.FWIDTH);x.BITCAST;const zc=C(x,x.TRANSPOSE),bc=C(x,x.ATAN2),Ec=C(x,x.MIN),Qi=C(x,x.MAX),Ar=C(x,x.MOD),Mr=C(x,x.STEP),Cc=C(x,x.REFLECT),Fc=C(x,x.DISTANCE),Rc=C(x,x.DIFFERENCE),Ki=C(x,x.DOT),Bc=C(x,x.CROSS),Sr=C(x,x.POW),Ic=C(x,x.POW,2),vc=C(x,x.POW,3),Pc=C(x,x.POW,4),Lc=C(x,x.TRANSFORM_DIRECTION),Oc=r=>ks(wr(r),Sr(ji(r),1/3)),Dc=r=>Ki(r,r),re=C(x,x.MIX),Hs=(r,t=0,e=1)=>v(new x(x.CLAMP,v(r),v(t),v(e))),Uc=r=>Hs(r),Vc=C(x,x.REFRACT),tn=C(x,x.SMOOTHSTEP),kc=C(x,x.FACEFORWARD),Hc=tt(([r])=>{const s=43758.5453,i=Ki(r.xy,D(12.9898,78.233)),n=Ar(i,Ka);return Ji(Nr(n).mul(s))}),qc=(r,t,e)=>re(t,e,r),$c=(r,t,e)=>tn(t,e,r);b("all",tc),b("any",ec),b("equals",sc),b("radians",ic),b("degrees",nc),b("exp",rc),b("exp2",oc),b("log",ac),b("log2",cc),b("sqrt",Zi),b("inverseSqrt",hc),b("floor",uc),b("ceil",lc),b("normalize",Tr),b("fract",Ji),b("sin",Nr),b("cos",dc),b("tan",pc),b("asin",fc),b("acos",mc),b("atan",yc),b("abs",ji),b("sign",wr),b("length",gc),b("lengthSq",Dc),b("negate",xc),b("oneMinus",Tc),b("dFdx",Nc),b("dFdy",wc),b("round",Ac),b("reciprocal",Mc),b("trunc",Sc),b("fwidth",_c),b("atan2",bc),b("min",Ec),b("max",Qi),b("mod",Ar),b("step",Mr),b("reflect",Cc),b("distance",Fc),b("dot",Ki),b("cross",Bc),b("pow",Sr),b("pow2",Ic),b("pow3",vc),b("pow4",Pc),b("transformDirection",Lc),b("mix",qc),b("clamp",Hs),b("refract",Vc),b("smoothstep",$c),b("faceForward",kc),b("difference",Rc),b("saturate",Uc),b("cbrt",Oc),b("transpose",zc),b("rand",Hc);class Wc extends V{static get type(){return"ConditionalNode"}constructor(t,e,s=null){super(),this.condNode=t,this.ifNode=e,this.elseNode=s}getNodeType(t){const e=this.ifNode.getNodeType(t);if(this.elseNode!==null){const s=this.elseNode.getNodeType(t);if(t.getTypeLength(s)>t.getTypeLength(e))return s}return e}setup(t){const e=this.condNode.cache(),s=this.ifNode.cache(),i=this.elseNode?this.elseNode.cache():null,n=t.context.nodeBlock;t.getDataFromNode(s).parentNodeBlock=n,i!==null&&(t.getDataFromNode(i).parentNodeBlock=n);const o=t.getNodeProperties(this);o.condNode=e,o.ifNode=s.context({nodeBlock:s}),o.elseNode=i?i.context({nodeBlock:i}):null}generate(t,e){const s=this.getNodeType(t),i=t.getDataFromNode(this);if(i.nodeProperty!==void 0)return i.nodeProperty;const{condNode:n,ifNode:o,elseNode:a}=t.getNodeProperties(this),c=e!=="void",u=c?ve(s).build(t):"";i.nodeProperty=u;const h=n.build(t,"bool");t.addFlowCode(`
|
|
6
|
+
${t.tab}if ( ${h} ) {
|
|
7
|
+
|
|
8
|
+
`).addFlowTab();let l=o.build(t,s);if(l&&(c?l=u+" = "+l+";":l="return "+l+";"),t.removeFlowTab().addFlowCode(t.tab+" "+l+`
|
|
9
|
+
|
|
10
|
+
`+t.tab+"}"),a!==null){t.addFlowCode(` else {
|
|
11
|
+
|
|
12
|
+
`).addFlowTab();let d=a.build(t,s);d&&(c?d=u+" = "+d+";":d="return "+d+";"),t.removeFlowTab().addFlowCode(t.tab+" "+d+`
|
|
13
|
+
|
|
14
|
+
`+t.tab+`}
|
|
15
|
+
|
|
16
|
+
`)}else t.addFlowCode(`
|
|
17
|
+
|
|
18
|
+
`);return t.format(u,s,e)}}const en=C(Wc);b("select",en),b("cond",(...r)=>(console.warn("TSL.ConditionalNode: cond() has been renamed to select()."),en(...r)));class Gc extends V{static get type(){return"ContextNode"}constructor(t,e={}){super(),this.isContextNode=!0,this.node=t,this.value=e}getScope(){return this.node.getScope()}getNodeType(t){return this.node.getNodeType(t)}analyze(t){this.node.build(t)}setup(t){const e=t.getContext();t.setContext({...t.context,...this.value});const s=this.node.build(t);return t.setContext(e),s}generate(t,e){const s=t.getContext();t.setContext({...t.context,...this.value});const i=this.node.build(t,e);return t.setContext(s),i}}const _r=C(Gc),Xc=(r,t)=>_r(r,{label:t});b("context",_r),b("label",Xc);class Yc extends V{static get type(){return"VarNode"}constructor(t,e=null){super(),this.node=t,this.name=e,this.global=!0,this.isVarNode=!0}getHash(t){return this.name||super.getHash(t)}getNodeType(t){return this.node.getNodeType(t)}generate(t){const{node:e,name:s}=this,i=t.getVarFromNode(this,s,t.getVectorType(this.getNodeType(t))),n=t.getPropertyName(i),o=e.build(t,i.type);return t.addLineFlowCode(`${n} = ${o}`,this),n}}const zr=C(Yc);b("temp",zr),b("toVar",(...r)=>zr(...r).append());class Zc extends V{static get type(){return"VaryingNode"}constructor(t,e=null){super(),this.node=t,this.name=e,this.isVaryingNode=!0}isGlobal(){return!0}getHash(t){return this.name||super.getHash(t)}getNodeType(t){return this.node.getNodeType(t)}setupVarying(t){const e=t.getNodeProperties(this);let s=e.varying;if(s===void 0){const i=this.name,n=this.getNodeType(t);e.varying=s=t.getVaryingFromNode(this,i,n),e.node=this.node}return s.needsInterpolation||(s.needsInterpolation=t.shaderStage==="fragment"),s}setup(t){this.setupVarying(t)}analyze(t){return this.setupVarying(t),this.node.analyze(t)}generate(t){const e=t.getNodeProperties(this),s=this.setupVarying(t);if(e.propertyName===void 0){const i=this.getNodeType(t),n=t.getPropertyName(s,ir.VERTEX);t.flowNodeFromShaderStage(ir.VERTEX,this.node,i,n),e.propertyName=n}return t.getPropertyName(s)}}const Pe=C(Zc);b("varying",Pe);const ns="WorkingColorSpace",sn="OutputColorSpace";function br(r){let t=null;return r===_s?t="Linear":r===$t&&(t="sRGB"),t}function Jc(r,t){return br(r)+"To"+br(t)}class qs extends dt{static get type(){return"ColorSpaceNode"}constructor(t,e,s){super("vec4"),this.colorNode=t,this.source=e,this.target=s}getColorSpace(t,e){return e===ns?mt.workingColorSpace:e===sn?t.context.outputColorSpace||t.renderer.outputColorSpace:e}setup(t){const{renderer:e}=t,{colorNode:s}=this,i=this.getColorSpace(t,this.source),n=this.getColorSpace(t,this.target);if(i===n)return s;const o=Jc(i,n);let a=null;const c=e.nodes.library.getColorSpaceFunction(o);return c!==null?a=Be(c(s.rgb),s.a):(console.error("ColorSpaceNode: Unsupported Color Space configuration.",o),a=s),a}}const jc=r=>v(new qs(v(r),ns,sn)),Qc=r=>v(new qs(v(r),sn,ns)),Kc=(r,t)=>v(new qs(v(r),ns,t)),Er=(r,t)=>v(new qs(v(r),t,ns));b("toOutputColorSpace",jc),b("toWorkingColorSpace",Qc),b("workingToColorSpace",Kc),b("colorSpaceToWorking",Er);let th=class extends is{static get type(){return"ReferenceElementNode"}constructor(t,e){super(t,e),this.referenceNode=t,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(t){const e=super.generate(t),s=this.referenceNode.getNodeType(),i=this.getNodeType();return t.format(e,s,i)}};class eh extends V{static get type(){return"ReferenceBaseNode"}constructor(t,e,s=null,i=null){super(),this.property=t,this.uniformType=e,this.object=s,this.count=i,this.properties=t.split("."),this.reference=s,this.node=null,this.group=null,this.updateType=Q.OBJECT}setGroup(t){return this.group=t,this}element(t){return v(new th(this,v(t)))}setNodeType(t){const e=xt(null,t).getSelf();this.group!==null&&e.setGroup(this.group),this.node=e}getNodeType(t){return this.node===null&&(this.updateReference(t),this.updateValue()),this.node.getNodeType(t)}getValueFromReference(t=this.reference){const{properties:e}=this;let s=t[e[0]];for(let i=1;i<e.length;i++)s=s[e[i]];return s}updateReference(t){return this.reference=this.object!==null?this.object:t.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);const t=this.getValueFromReference();Array.isArray(t)?this.node.array=t:this.node.value=t}}class sh extends eh{static get type(){return"RendererReferenceNode"}constructor(t,e,s=null){super(t,e,s),this.renderer=s,this.setGroup(de)}updateReference(t){return this.reference=this.renderer!==null?this.renderer:t.renderer,this.reference}}const ih=(r,t,e)=>v(new sh(r,t,e));class nh extends dt{static get type(){return"ToneMappingNode"}constructor(t,e=oh,s=null){super("vec3"),this.toneMapping=t,this.exposureNode=e,this.colorNode=s}getCacheKey(){return Zo(super.getCacheKey(),this.toneMapping)}setup(t){const e=this.colorNode||t.context.color,s=this.toneMapping;if(s===0)return e;let i=null;const n=t.renderer.nodes.library.getToneMappingFunction(s);return n!==null?i=Be(n(e.rgb,this.exposureNode),e.a):(console.error("ToneMappingNode: Unsupported Tone Mapping configuration.",s),i=e),i}}const rh=(r,t,e)=>v(new nh(r,v(t),v(e))),oh=ih("toneMappingExposure","float");b("toneMapping",(r,t,e)=>rh(t,e,r));class ah extends Hi{static get type(){return"BufferAttributeNode"}constructor(t,e=null,s=0,i=0){super(t,e),this.isBufferNode=!0,this.bufferType=e,this.bufferStride=s,this.bufferOffset=i,this.usage=35044,this.instanced=!1,this.attribute=null,this.global=!0,t&&t.isBufferAttribute===!0&&(this.attribute=t,this.usage=t.usage,this.instanced=t.isInstancedBufferAttribute)}getHash(t){if(this.bufferStride===0&&this.bufferOffset===0){let e=t.globalCache.getData(this.value);return e===void 0&&(e={node:this},t.globalCache.setData(this.value,e)),e.node.uuid}return this.uuid}getNodeType(t){return this.bufferType===null&&(this.bufferType=t.getTypeFromAttribute(this.attribute)),this.bufferType}setup(t){if(this.attribute!==null)return;const e=this.getNodeType(t),s=this.value,i=t.getTypeLength(e),n=this.bufferStride||i,o=this.bufferOffset,a=s.isInterleavedBuffer===!0?s:new Xo(s,n),c=new Ui(a,i,o);a.setUsage(this.usage),this.attribute=c,this.attribute.isInstancedBufferAttribute=this.instanced}generate(t){const e=this.getNodeType(t),s=t.getBufferAttributeFromNode(this,e),i=t.getPropertyName(s);let n=null;return t.shaderStage==="vertex"||t.shaderStage==="compute"?(this.name=i,n=i):n=Pe(this).build(t,e),n}getInputType(){return"bufferAttribute"}setUsage(t){return this.usage=t,this.attribute&&this.attribute.isBufferAttribute===!0&&(this.attribute.usage=t),this}setInstanced(t){return this.instanced=t,this}}const ch=(r,t,e,s)=>v(new ah(r,t,e,s));b("toAttribute",r=>ch(r.value));class hh extends V{static get type(){return"ComputeNode"}constructor(t,e,s=[64]){super("void"),this.isComputeNode=!0,this.computeNode=t,this.count=e,this.workgroupSize=s,this.dispatchCount=0,this.version=1,this.updateBeforeType=Q.OBJECT,this.updateDispatchCount()}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}updateDispatchCount(){const{count:t,workgroupSize:e}=this;let s=e[0];for(let i=1;i<e.length;i++)s*=e[i];this.dispatchCount=Math.ceil(t/s)}onInit(){}updateBefore({renderer:t}){t.compute(this)}generate(t){const{shaderStage:e}=t;if(e==="compute"){const s=this.computeNode.build(t,"void");s!==""&&t.addLineFlowCode(s,this)}}}b("compute",(r,t,e)=>v(new hh(v(r),t,e)));class uh extends V{static get type(){return"CacheNode"}constructor(t,e=!0){super(),this.node=t,this.parent=e,this.isCacheNode=!0}getNodeType(t){return this.node.getNodeType(t)}build(t,...e){const s=t.getCache(),i=t.getCacheFromNode(this,this.parent);t.setCache(i);const n=this.node.build(t,...e);return t.setCache(s),n}}b("cache",(r,...t)=>v(new uh(v(r),...t)));class lh extends V{static get type(){return"BypassNode"}constructor(t,e){super(),this.isBypassNode=!0,this.outputNode=t,this.callNode=e}getNodeType(t){return this.outputNode.getNodeType(t)}generate(t){const e=this.callNode.build(t,"void");return e!==""&&t.addLineFlowCode(e,this),this.outputNode.build(t)}}b("bypass",C(lh));class Cr extends V{static get type(){return"RemapNode"}constructor(t,e,s,i=q(0),n=q(1)){super(),this.node=t,this.inLowNode=e,this.inHighNode=s,this.outLowNode=i,this.outHighNode=n,this.doClamp=!0}setup(){const{node:t,inLowNode:e,inHighNode:s,outLowNode:i,outHighNode:n,doClamp:o}=this;let a=t.sub(e).div(s.sub(e));return o===!0&&(a=a.clamp()),a.mul(n.sub(i)).add(i)}}const dh=C(Cr,null,null,{doClamp:!1}),ph=C(Cr);b("remap",dh),b("remapClamp",ph);class fh extends V{static get type(){return"ExpressionNode"}constructor(t="",e="void"){super(e),this.snippet=t}generate(t,e){const s=this.getNodeType(t),i=this.snippet;if(s==="void")t.addLineFlowCode(i,this);else return t.format(`( ${i} )`,s,e)}}const $s=C(fh);b("discard",r=>(r?en(r,$s("discard")):$s("discard")).append());class mh extends dt{static get type(){return"RenderOutputNode"}constructor(t,e,s){super("vec4"),this.colorNode=t,this.toneMapping=e,this.outputColorSpace=s,this.isRenderOutput=!0}setup({context:t}){let e=this.colorNode||t.color;const s=(this.toneMapping!==null?this.toneMapping:t.toneMapping)||0,i=(this.outputColorSpace!==null?this.outputColorSpace:t.outputColorSpace)||Ss;return s!==0&&(e=e.toneMapping(s)),i!==Ss&&i!==mt.workingColorSpace&&(e=e.workingToColorSpace(i)),e}}b("renderOutput",(r,t=null,e=null)=>v(new mh(v(r),t,e)));class yh extends V{static get type(){return"AttributeNode"}constructor(t,e=null){super(e),this.global=!0,this._attributeName=t}getHash(t){return this.getAttributeName(t)}getNodeType(t){let e=this.nodeType;if(e===null){const s=this.getAttributeName(t);if(t.hasGeometryAttribute(s)){const i=t.geometry.getAttribute(s);e=t.getTypeFromAttribute(i)}else e="float"}return e}setAttributeName(t){return this._attributeName=t,this}getAttributeName(){return this._attributeName}generate(t){const e=this.getAttributeName(t),s=this.getNodeType(t);if(t.hasGeometryAttribute(e)===!0){const n=t.geometry.getAttribute(e),o=t.getTypeFromAttribute(n),a=t.getAttribute(e,o);return t.shaderStage==="vertex"?t.format(a.name,o,s):Pe(this).build(t,s)}else return console.warn(`AttributeNode: Vertex attribute "${e}" not found on geometry.`),t.generateConst(s)}serialize(t){super.serialize(t),t.global=this.global,t._attributeName=this._attributeName}deserialize(t){super.deserialize(t),this.global=t.global,this._attributeName=t._attributeName}}const rs=(r,t)=>v(new yh(r,t)),Ws=r=>rs("uv"+(r>0?r:""),"vec2");class gh extends V{static get type(){return"TextureSizeNode"}constructor(t,e=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=t,this.levelNode=e}generate(t,e){const s=this.textureNode.build(t,"property"),i=this.levelNode===null?"0":this.levelNode.build(t,"int");return t.format(`${t.getMethod("textureDimensions")}( ${s}, ${i} )`,this.getNodeType(t),e)}}const Fr=C(gh);class xh extends Ie{static get type(){return"MaxMipLevelNode"}constructor(t){super(0),this._textureNode=t,this.updateType=Q.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){const t=this.texture,e=t.images,s=e&&e.length>0?e[0]&&e[0].image||e[0]:t.image;if(s&&s.width!==void 0){const{width:i,height:n}=s;this.value=Math.log2(Math.max(i,n))}}}const Th=C(xh);class Gs extends Ie{static get type(){return"TextureNode"}constructor(t,e=null,s=null,i=null){super(t),this.isTextureNode=!0,this.uvNode=e,this.levelNode=s,this.biasNode=i,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=Q.NONE,this.referenceNode=null,this._value=t,this._matrixUniform=null,this.setUpdateMatrix(e===null)}set value(t){this.referenceNode?this.referenceNode.value=t:this._value=t}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}getNodeType(){return this.value.isDepthTexture===!0?"float":this.value.type===1014?"uvec4":this.value.type===1013?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return Ws(this.value.channel)}updateReference(){return this.value}getTransformedUV(t){return this._matrixUniform===null&&(this._matrixUniform=xt(this.value.matrix)),this._matrixUniform.mul(k(t,1)).xy}setUpdateMatrix(t){return this.updateMatrix=t,this.updateType=t?Q.FRAME:Q.NONE,this}setupUV(t,e){const s=this.value;return t.isFlipY()&&(s.isRenderTargetTexture===!0||s.isFramebufferTexture===!0||s.isDepthTexture===!0)&&(this.sampler?e=e.flipY():e=e.setY(Re(Fr(this,this.levelNode).y).sub(e.y).sub(1))),e}setup(t){const e=t.getNodeProperties(this);e.referenceNode=this.referenceNode;let s=this.uvNode;(s===null||t.context.forceUVContext===!0)&&t.context.getUV&&(s=t.context.getUV(this)),s||(s=this.getDefaultUV()),this.updateMatrix===!0&&(s=this.getTransformedUV(s)),s=this.setupUV(t,s);let i=this.levelNode;i===null&&t.context.getTextureLevel&&(i=t.context.getTextureLevel(this)),e.uvNode=s,e.levelNode=i,e.biasNode=this.biasNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.depthNode=this.depthNode}generateUV(t,e){return e.build(t,this.sampler===!0?"vec2":"ivec2")}generateSnippet(t,e,s,i,n,o,a,c){const u=this.value;let h;return i?h=t.generateTextureLevel(u,e,s,i,o):n?h=t.generateTextureBias(u,e,s,n,o):c?h=t.generateTextureGrad(u,e,s,c,o):a?h=t.generateTextureCompare(u,e,s,a,o):this.sampler===!1?h=t.generateTextureLoad(u,e,s,o):h=t.generateTexture(u,e,s,o),h}generate(t,e){const s=t.getNodeProperties(this),i=this.value;if(!i||i.isTexture!==!0)throw new Error("TextureNode: Need a three.js texture.");const n=super.generate(t,"property");if(e==="sampler")return n+"_sampler";if(t.isReference(e))return n;{const o=t.getDataFromNode(this);let a=o.propertyName;if(a===void 0){const{uvNode:h,levelNode:l,biasNode:d,compareNode:p,depthNode:f,gradNode:m}=s,g=this.generateUV(t,h),y=l?l.build(t,"float"):null,T=d?d.build(t,"float"):null,w=f?f.build(t,"int"):null,M=p?p.build(t,"float"):null,N=m?[m[0].build(t,"vec2"),m[1].build(t,"vec2")]:null,_=t.getVarFromNode(this);a=t.getPropertyName(_);const S=this.generateSnippet(t,n,g,y,T,w,M,N);t.addLineFlowCode(`${a} = ${S}`,this),o.snippet=S,o.propertyName=a}let c=a;const u=this.getNodeType(t);return t.needsToWorkingColorSpace(i)&&(c=Er($s(c,u),i.colorSpace).setup(t).build(t,u)),t.format(c,u,e)}}setSampler(t){return this.sampler=t,this}getSampler(){return this.sampler}uv(t){const e=this.clone();return e.uvNode=v(t),e.referenceNode=this.getSelf(),v(e)}blur(t){const e=this.clone();return e.biasNode=v(t).mul(Th(e)),e.referenceNode=this.getSelf(),v(e)}level(t){const e=this.clone();return e.levelNode=v(t),e.referenceNode=this.getSelf(),v(e)}size(t){return Fr(this,t)}bias(t){const e=this.clone();return e.biasNode=v(t),e.referenceNode=this.getSelf(),v(e)}compare(t){const e=this.clone();return e.compareNode=v(t),e.referenceNode=this.getSelf(),v(e)}grad(t,e){const s=this.clone();return s.gradNode=[v(t),v(e)],s.referenceNode=this.getSelf(),v(s)}depth(t){const e=this.clone();return e.depthNode=v(t),e.referenceNode=this.getSelf(),v(e)}serialize(t){super.serialize(t),t.value=this.value.toJSON(t.meta).uuid,t.sampler=this.sampler,t.updateMatrix=this.updateMatrix,t.updateType=this.updateType}deserialize(t){super.deserialize(t),this.value=t.meta.textures[t.value],this.sampler=t.sampler,this.updateMatrix=t.updateMatrix,this.updateType=t.updateType}update(){const t=this.value,e=this._matrixUniform;e!==null&&(e.value=t.matrix),t.matrixAutoUpdate===!0&&t.updateMatrix()}clone(){const t=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return t.sampler=this.sampler,t}}const os=C(Gs),as=xt("float").label("cameraNear").setGroup(de).onRenderUpdate(({camera:r})=>r.near),cs=xt("float").label("cameraFar").setGroup(de).onRenderUpdate(({camera:r})=>r.far),Xs=xt("mat4").label("cameraViewMatrix").setGroup(de).onRenderUpdate(({camera:r})=>r.matrixWorldInverse);class H extends V{static get type(){return"Object3DNode"}constructor(t,e=null){super(),this.scope=t,this.object3d=e,this.updateType=Q.OBJECT,this._uniformNode=new Ie(null)}getNodeType(){const t=this.scope;if(t===H.WORLD_MATRIX)return"mat4";if(t===H.POSITION||t===H.VIEW_POSITION||t===H.DIRECTION||t===H.SCALE)return"vec3"}update(t){const e=this.object3d,s=this._uniformNode,i=this.scope;if(i===H.WORLD_MATRIX)s.value=e.matrixWorld;else if(i===H.POSITION)s.value=s.value||new A,s.value.setFromMatrixPosition(e.matrixWorld);else if(i===H.SCALE)s.value=s.value||new A,s.value.setFromMatrixScale(e.matrixWorld);else if(i===H.DIRECTION)s.value=s.value||new A,e.getWorldDirection(s.value);else if(i===H.VIEW_POSITION){const n=t.camera;s.value=s.value||new A,s.value.setFromMatrixPosition(e.matrixWorld),s.value.applyMatrix4(n.matrixWorldInverse)}}generate(t){const e=this.scope;return e===H.WORLD_MATRIX?this._uniformNode.nodeType="mat4":(e===H.POSITION||e===H.VIEW_POSITION||e===H.DIRECTION||e===H.SCALE)&&(this._uniformNode.nodeType="vec3"),this._uniformNode.build(t)}serialize(t){super.serialize(t),t.scope=this.scope}deserialize(t){super.deserialize(t),this.scope=t.scope}}H.WORLD_MATRIX="worldMatrix",H.POSITION="position",H.SCALE="scale",H.VIEW_POSITION="viewPosition",H.DIRECTION="direction",H.DIRECTION,H.WORLD_MATRIX,H.POSITION,H.SCALE,H.VIEW_POSITION;class Ut extends H{static get type(){return"ModelNode"}constructor(t){super(t)}update(t){this.object3d=t.object,super.update(t)}}Ut.DIRECTION;const Nh=O(Ut,Ut.WORLD_MATRIX);Ut.POSITION,Ut.SCALE,Ut.VIEW_POSITION;const wh=xt(new Ct).onObjectUpdate(({object:r},t)=>t.value.getNormalMatrix(r.matrixWorld)),Rr=Xs.mul(Nh).toVar("modelViewMatrix_2"),Ah=rs("position","vec3").varying("positionLocal"),Mt=Rr.mul(Ah).xyz.varying("v_positionView"),Br=Mt.negate().varying("v_positionViewDirection").normalize().toVar("positionViewDirection");class Mh extends V{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(t){const{renderer:e,material:s}=t;return e.coordinateSystem===2e3&&s.side===1?"false":t.getFrontFacing()}}const nn=q(O(Mh)).mul(2).sub(1),Sh=rs("normal","vec3"),_h=tt(r=>r.geometry.hasAttribute("normal")===!1?(console.warn('TSL.NormalNode: Vertex attribute "normal" not found on geometry.'),k(0,1,0)):Sh,"vec3").once()().toVar("normalLocal"),zh=Mt.dFdx().cross(Mt.dFdy()).normalize().toVar("normalFlat"),Le=tt(r=>{let t;return r.material.flatShading===!0?t=zh:t=Pe(vr(_h),"v_normalView").normalize(),t},"vec3").once()().toVar("normalView"),Ir=tt(r=>r.context.setupNormal(),"vec3").once()().mul(nn).toVar("transformedNormalView"),vr=tt(([r],t)=>{const e=t.renderer.nodes.modelNormalViewMatrix;if(e!==null)return e.transformDirection(r);const s=wh.mul(r);return Xs.transformDirection(s)}),bh=xt(0).onReference(({material:r})=>r).onRenderUpdate(({material:r})=>r.refractionRatio),Eh=Br.negate().reflect(Ir),Ch=Br.negate().refract(Ir,bh),Fh=Eh.transformDirection(Xs).toVar("reflectVector"),Rh=Ch.transformDirection(Xs).toVar("reflectVector");class Bh extends Gs{static get type(){return"CubeTextureNode"}constructor(t,e=null,s=null,i=null){super(t,e,s,i),this.isCubeTextureNode=!0}getInputType(){return"cubeTexture"}getDefaultUV(){const t=this.value;return t.mapping===301?Fh:t.mapping===302?Rh:(console.error('THREE.CubeTextureNode: Mapping "%s" not supported.',t.mapping),k(0,0,0))}setUpdateMatrix(){}setupUV(t,e){const s=this.value;return t.renderer.coordinateSystem===2001||!s.isRenderTargetTexture?k(e.x.negate(),e.yz):e}generateUV(t,e){return e.build(t,"vec3")}}const Ih=C(Bh);class Pr extends Ie{static get type(){return"BufferNode"}constructor(t,e,s=0){super(t,e),this.isBufferNode=!0,this.bufferType=e,this.bufferCount=s}getElementType(t){return this.getNodeType(t)}getInputType(){return"buffer"}}const vh=(r,t,e)=>v(new Pr(r,t,e));class Ph extends is{static get type(){return"UniformArrayElementNode"}constructor(t,e){super(t,e),this.isArrayBufferElementNode=!0}generate(t){const e=super.generate(t),s=this.getNodeType();return t.format(e,"vec4",s)}}class Lh extends Pr{static get type(){return"UniformArrayNode"}constructor(t,e=null){super(null,"vec4"),this.array=t,this.elementType=e,this._elementType=null,this._elementLength=0,this.updateType=Q.RENDER,this.isArrayBufferNode=!0}getElementType(){return this.elementType||this._elementType}getElementLength(){return this._elementLength}update(){const{array:t,value:e}=this,s=this.getElementLength(),i=this.getElementType();if(s===1)for(let n=0;n<t.length;n++){const o=n*4;e[o]=t[n]}else if(i==="color")for(let n=0;n<t.length;n++){const o=n*4,a=t[n];e[o]=a.r,e[o+1]=a.g,e[o+2]=a.b||0}else for(let n=0;n<t.length;n++){const o=n*4,a=t[n];e[o]=a.x,e[o+1]=a.y,e[o+2]=a.z||0,e[o+3]=a.w||0}}setup(t){const e=this.array.length;this._elementType=this.elementType===null?Ps(this.array[0]):this.elementType,this._elementLength=t.getTypeLength(this._elementType);let s=Float32Array;return this._elementType.charAt(0)==="i"?s=Int32Array:this._elementType.charAt(0)==="u"&&(s=Uint32Array),this.value=new s(e*4),this.bufferCount=e,this.bufferType=t.changeComponentType("vec4",t.getComponentType(this._elementType)),super.setup(t)}element(t){return v(new Ph(this,v(t)))}}const rn=(r,t)=>v(new Lh(r,t));class Oh extends is{static get type(){return"ReferenceElementNode"}constructor(t,e){super(t,e),this.referenceNode=t,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(t){const e=super.generate(t),s=this.referenceNode.getNodeType(),i=this.getNodeType();return t.format(e,s,i)}}class Lr extends V{static get type(){return"ReferenceNode"}constructor(t,e,s=null,i=null){super(),this.property=t,this.uniformType=e,this.object=s,this.count=i,this.properties=t.split("."),this.reference=s,this.node=null,this.group=null,this.name=null,this.updateType=Q.OBJECT}element(t){return v(new Oh(this,v(t)))}setGroup(t){return this.group=t,this}label(t){return this.name=t,this}setNodeType(t){let e=null;this.count!==null?e=vh(null,t,this.count):Array.isArray(this.getValueFromReference())?e=rn(null,t):t==="texture"?e=os(null):t==="cubeTexture"?e=Ih(null):e=xt(null,t),this.group!==null&&e.setGroup(this.group),this.name!==null&&e.label(this.name),this.node=e.getSelf()}getNodeType(t){return this.node===null&&(this.updateReference(t),this.updateValue()),this.node.getNodeType(t)}getValueFromReference(t=this.reference){const{properties:e}=this;let s=t[e[0]];for(let i=1;i<e.length;i++)s=s[e[i]];return s}updateReference(t){return this.reference=this.object!==null?this.object:t.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);const t=this.getValueFromReference();Array.isArray(t)?this.node.array=t:this.node.value=t}}const fe=(r,t,e)=>v(new Lr(r,t,e));class Dh extends Lr{static get type(){return"MaterialReferenceNode"}constructor(t,e,s=null){super(t,e,s),this.material=s,this.isMaterialReferenceNode=!0}updateReference(t){return this.reference=this.material!==null?this.material:t.material,this.reference}}const Uh=(r,t,e)=>v(new Dh(r,t,e)),Or=tt(r=>(r.geometry.hasAttribute("tangent")===!1&&r.geometry.computeTangents(),rs("tangent","vec4")))(),Vh=Or.xyz.toVar("tangentLocal"),Dr=Rr.mul(Be(Vh,0)).xyz.varying("v_tangentView").normalize().toVar("tangentView"),kh=Us(Dr,Pe((r=>r.mul(Or.w).xyz)(Le.cross(Dr)),"v_bitangentView").normalize().toVar("bitangentView"),Le),Hh=tt(r=>{const{eye_pos:t,surf_norm:e,mapN:s,uv:i}=r,n=t.dFdx(),o=t.dFdy(),a=i.dFdx(),c=i.dFdy(),u=e,h=o.cross(u),l=u.cross(n),d=h.mul(a.x).add(l.mul(c.x)),p=h.mul(a.y).add(l.mul(c.y)),f=d.dot(d).max(p.dot(p)),m=nn.mul(f.inverseSqrt());return pe(d.mul(s.x,m),p.mul(s.y,m),u.mul(s.z)).normalize()});class qh extends dt{static get type(){return"NormalMapNode"}constructor(t,e=null){super("vec3"),this.node=t,this.scaleNode=e,this.normalMapType=0}setup(t){const{normalMapType:e,scaleNode:s}=this;let i=this.node.mul(2).sub(1);s!==null&&(i=k(i.xy.mul(s),i.z));let n=null;return e===1?n=vr(i):e===0&&(t.hasGeometryAttribute("tangent")===!0?n=kh.mul(i).normalize():n=Hh({eye_pos:Mt,surf_norm:Le,mapN:i,uv:Ws()})),n}}const Ur=C(qh),$h=tt(({textureNode:r,bumpScale:t})=>{const e=i=>r.cache().context({getUV:n=>i(n.uvNode||Ws()),forceUVContext:!0}),s=q(e(i=>i));return D(q(e(i=>i.add(i.dFdx()))).sub(s),q(e(i=>i.add(i.dFdy()))).sub(s)).mul(t)}),Wh=tt(r=>{const{surf_pos:t,surf_norm:e,dHdxy:s}=r,i=t.dFdx().normalize(),n=t.dFdy().normalize(),o=e,a=n.cross(o),c=o.cross(i),u=i.dot(a).mul(nn),h=u.sign().mul(s.x.mul(a).add(s.y.mul(c)));return u.abs().mul(e).sub(h).normalize()});class Gh extends dt{static get type(){return"BumpMapNode"}constructor(t,e=null){super("vec3"),this.textureNode=t,this.scaleNode=e}setup(){const t=this.scaleNode!==null?this.scaleNode:1,e=$h({textureNode:this.textureNode,bumpScale:t});return Wh({surf_pos:Mt,surf_norm:Le,dHdxy:e})}}const Xh=C(Gh),Vr=new Map;class z extends V{static get type(){return"MaterialNode"}constructor(t){super(),this.scope=t}getCache(t,e){let s=Vr.get(t);return s===void 0&&(s=Uh(t,e),Vr.set(t,s)),s}getFloat(t){return this.getCache(t,"float")}getColor(t){return this.getCache(t,"color")}getTexture(t){return this.getCache(t==="map"?"map":t+"Map","texture")}setup(t){const e=t.context.material,s=this.scope;let i=null;if(s===z.COLOR){const n=e.color!==void 0?this.getColor(s):k();e.map&&e.map.isTexture===!0?i=n.mul(this.getTexture("map")):i=n}else if(s===z.OPACITY){const n=this.getFloat(s);e.alphaMap&&e.alphaMap.isTexture===!0?i=n.mul(this.getTexture("alpha")):i=n}else if(s===z.SPECULAR_STRENGTH)e.specularMap&&e.specularMap.isTexture===!0?i=this.getTexture("specular").r:i=q(1);else if(s===z.SPECULAR_INTENSITY){const n=this.getFloat(s);e.specularMap?i=n.mul(this.getTexture(s).a):i=n}else if(s===z.SPECULAR_COLOR){const n=this.getColor(s);e.specularColorMap&&e.specularColorMap.isTexture===!0?i=n.mul(this.getTexture(s).rgb):i=n}else if(s===z.ROUGHNESS){const n=this.getFloat(s);e.roughnessMap&&e.roughnessMap.isTexture===!0?i=n.mul(this.getTexture(s).g):i=n}else if(s===z.METALNESS){const n=this.getFloat(s);e.metalnessMap&&e.metalnessMap.isTexture===!0?i=n.mul(this.getTexture(s).b):i=n}else if(s===z.EMISSIVE){const n=this.getFloat("emissiveIntensity"),o=this.getColor(s).mul(n);e.emissiveMap&&e.emissiveMap.isTexture===!0?i=o.mul(this.getTexture(s)):i=o}else if(s===z.NORMAL)e.normalMap?(i=Ur(this.getTexture("normal"),this.getCache("normalScale","vec2")),i.normalMapType=e.normalMapType):e.bumpMap?i=Xh(this.getTexture("bump").r,this.getFloat("bumpScale")):i=Le;else if(s===z.CLEARCOAT){const n=this.getFloat(s);e.clearcoatMap&&e.clearcoatMap.isTexture===!0?i=n.mul(this.getTexture(s).r):i=n}else if(s===z.CLEARCOAT_ROUGHNESS){const n=this.getFloat(s);e.clearcoatRoughnessMap&&e.clearcoatRoughnessMap.isTexture===!0?i=n.mul(this.getTexture(s).r):i=n}else if(s===z.CLEARCOAT_NORMAL)e.clearcoatNormalMap?i=Ur(this.getTexture(s),this.getCache(s+"Scale","vec2")):i=Le;else if(s===z.SHEEN){const n=this.getColor("sheenColor").mul(this.getFloat("sheen"));e.sheenColorMap&&e.sheenColorMap.isTexture===!0?i=n.mul(this.getTexture("sheenColor").rgb):i=n}else if(s===z.SHEEN_ROUGHNESS){const n=this.getFloat(s);e.sheenRoughnessMap&&e.sheenRoughnessMap.isTexture===!0?i=n.mul(this.getTexture(s).a):i=n,i=i.clamp(.07,1)}else if(s===z.ANISOTROPY)if(e.anisotropyMap&&e.anisotropyMap.isTexture===!0){const n=this.getTexture(s);i=pr(hs.x,hs.y,hs.y.negate(),hs.x).mul(n.rg.mul(2).sub(D(1)).normalize().mul(n.b))}else i=hs;else if(s===z.IRIDESCENCE_THICKNESS){const n=fe("1","float",e.iridescenceThicknessRange);if(e.iridescenceThicknessMap){const o=fe("0","float",e.iridescenceThicknessRange);i=n.sub(o).mul(this.getTexture(s).g).add(o)}else i=n}else if(s===z.TRANSMISSION){const n=this.getFloat(s);e.transmissionMap?i=n.mul(this.getTexture(s).r):i=n}else if(s===z.THICKNESS){const n=this.getFloat(s);e.thicknessMap?i=n.mul(this.getTexture(s).g):i=n}else if(s===z.IOR)i=this.getFloat(s);else if(s===z.LIGHT_MAP)i=this.getTexture(s).rgb.mul(this.getFloat("lightMapIntensity"));else if(s===z.AO_MAP)i=this.getTexture(s).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else{const n=this.getNodeType(t);i=this.getCache(s,n)}return i}}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",z.ALPHA_TEST,z.COLOR,z.SHININESS,z.EMISSIVE,z.OPACITY,z.SPECULAR,z.SPECULAR_INTENSITY,z.SPECULAR_COLOR,z.SPECULAR_STRENGTH,z.REFLECTIVITY,z.ROUGHNESS,z.METALNESS,z.CLEARCOAT,z.CLEARCOAT_ROUGHNESS,z.ROTATION,z.SHEEN,z.SHEEN_ROUGHNESS,z.ANISOTROPY,z.IRIDESCENCE,z.IRIDESCENCE_IOR,z.IRIDESCENCE_THICKNESS,z.TRANSMISSION,z.THICKNESS,z.IOR,z.ATTENUATION_DISTANCE,z.ATTENUATION_COLOR,z.LINE_SCALE,z.LINE_DASH_SIZE,z.LINE_GAP_SIZE,z.LINE_WIDTH,z.LINE_DASH_OFFSET,z.POINT_WIDTH,z.DISPERSION,z.LIGHT_MAP,z.AO_MAP;const hs=xt(new J).onReference(function(r){return r.material}).onRenderUpdate(function({material:r}){this.value.set(r.anisotropy*Math.cos(r.anisotropyRotation),r.anisotropy*Math.sin(r.anisotropyRotation))});class G extends V{static get type(){return"IndexNode"}constructor(t){super("uint"),this.scope=t,this.isInstanceIndexNode=!0}generate(t){const e=this.getNodeType(t),s=this.scope;let i;if(s===G.VERTEX)i=t.getVertexIndex();else if(s===G.INSTANCE)i=t.getInstanceIndex();else if(s===G.DRAW)i=t.getDrawIndex();else if(s===G.INVOCATION_LOCAL)i=t.getInvocationLocalIndex();else if(s===G.INVOCATION_SUBGROUP)i=t.getInvocationSubgroupIndex();else if(s===G.SUBGROUP)i=t.getSubgroupIndex();else throw new Error("THREE.IndexNode: Unknown scope: "+s);let n;return t.shaderStage==="vertex"||t.shaderStage==="compute"?n=i:n=Pe(this).build(t,e),n}}G.VERTEX="vertex",G.INSTANCE="instance",G.SUBGROUP="subgroup",G.INVOCATION_LOCAL="invocationLocal",G.INVOCATION_SUBGROUP="invocationSubgroup",G.DRAW="draw",G.VERTEX,G.INSTANCE,G.SUBGROUP,G.INVOCATION_SUBGROUP,G.INVOCATION_LOCAL,G.DRAW;class Yh extends V{static get type(){return"LoopNode"}constructor(t=[]){super(),this.params=t}getVarName(t){return String.fromCharCode(105+t)}getProperties(t){const e=t.getNodeProperties(this);if(e.stackNode!==void 0)return e;const s={};for(let n=0,o=this.params.length-1;n<o;n++){const a=this.params[n],c=a.isNode!==!0&&a.name||this.getVarName(n),u=a.isNode!==!0&&a.type||"int";s[c]=$s(c,u)}const i=t.addStack();return e.returnsNode=this.params[this.params.length-1](s,i,t),e.stackNode=i,t.removeStack(),e}getNodeType(t){const{returnsNode:e}=this.getProperties(t);return e?e.getNodeType(t):"void"}setup(t){this.getProperties(t)}generate(t){const e=this.getProperties(t),s=this.params,i=e.stackNode;for(let a=0,c=s.length-1;a<c;a++){const u=s[a];let h=null,l=null,d=null,p=null,f=null,m=null;u.isNode?(p="int",d=this.getVarName(a),h="0",l=u.build(t,p),f="<"):(p=u.type||"int",d=u.name||this.getVarName(a),h=u.start,l=u.end,f=u.condition,m=u.update,typeof h=="number"?h=h.toString():h&&h.isNode&&(h=h.build(t,p)),typeof l=="number"?l=l.toString():l&&l.isNode&&(l=l.build(t,p)),h!==void 0&&l===void 0?(h=h+" - 1",l="0",f=">="):l!==void 0&&h===void 0&&(h="0",f="<"),f===void 0&&(Number(h)>Number(l)?f=">=":f="<"));const g={start:h,end:l},y=g.start,T=g.end;let w="",M="",N="";m||(p==="int"||p==="uint"?f.includes("<")?m="++":m="--":f.includes("<")?m="+= 1.":m="-= 1."),w+=t.getVar(p,d)+" = "+y,M+=d+" "+f+" "+T,N+=d+" "+m;const _=`for ( ${w}; ${M}; ${N} )`;t.addFlowCode((a===0?`
|
|
19
|
+
`:"")+t.tab+_+` {
|
|
20
|
+
|
|
21
|
+
`).addFlowTab()}const n=i.build(t,"void"),o=e.returnsNode?e.returnsNode.build(t):"";t.removeFlowTab().addFlowCode(`
|
|
22
|
+
`+t.tab+n);for(let a=0,c=this.params.length-1;a<c;a++)t.addFlowCode((a===0?"":t.tab)+`}
|
|
23
|
+
|
|
24
|
+
`).removeFlowTab();return t.addFlowTab(),o}}const Oe=(...r)=>v(new Yh(Fe(r,"int"))).append();let us,ls;class et extends V{static get type(){return"ScreenNode"}constructor(t){super(),this.scope=t,this.isViewportNode=!0}getNodeType(){return this.scope===et.VIEWPORT?"vec4":"vec2"}getUpdateType(){let t=Q.NONE;return(this.scope===et.SIZE||this.scope===et.VIEWPORT)&&(t=Q.RENDER),this.updateType=t,t}update({renderer:t}){const e=t.getRenderTarget();this.scope===et.VIEWPORT?e!==null?ls.copy(e.viewport):(t.getViewport(ls),ls.multiplyScalar(t.getPixelRatio())):e!==null?(us.width=e.width,us.height=e.height):t.getDrawingBufferSize(us)}setup(){const t=this.scope;let e=null;return t===et.SIZE?e=xt(us||(us=new J)):t===et.VIEWPORT?e=xt(ls||(ls=new Ft)):e=D(Ys.div(kr)),e}generate(t){if(this.scope===et.COORDINATE){let e=t.getFragCoord();if(t.isFlipY()){const s=t.getNodeProperties(kr).outputNode.build(t);e=`${t.getType("vec2")}( ${e}.x, ${s}.y - ${e}.y )`}return e}return super.generate(t)}}et.COORDINATE="coordinate",et.VIEWPORT="viewport",et.SIZE="size",et.UV="uv";const on=O(et,et.UV),kr=O(et,et.SIZE),Ys=O(et,et.COORDINATE),Hr=O(et,et.VIEWPORT);Hr.zw,Hr.xy;const ds=new J;class Zh extends Gs{static get type(){return"ViewportTextureNode"}constructor(t=on,e=null,s=null){s===null&&(s=new Yo,s.minFilter=1008),super(s,t,e),this.generateMipmaps=!1,this.isOutputTextureNode=!0,this.updateBeforeType=Q.FRAME}updateBefore(t){const e=t.renderer;e.getDrawingBufferSize(ds);const s=this.value;(s.image.width!==ds.width||s.image.height!==ds.height)&&(s.image.width=ds.width,s.image.height=ds.height,s.needsUpdate=!0);const i=s.generateMipmaps;s.generateMipmaps=this.generateMipmaps,e.copyFramebufferToTexture(s),s.generateMipmaps=i}clone(){const t=new this.constructor(this.uvNode,this.levelNode,this.value);return t.generateMipmaps=this.generateMipmaps,t}}let an=null;class Jh extends Zh{static get type(){return"ViewportDepthTextureNode"}constructor(t=on,e=null){an===null&&(an=new tr),super(t,e,an)}}const jh=C(Jh);class pt extends V{static get type(){return"ViewportDepthNode"}constructor(t,e=null){super("float"),this.scope=t,this.valueNode=e,this.isViewportDepthNode=!0}generate(t){const{scope:e}=this;return e===pt.DEPTH_BASE?t.getFragDepth():super.generate(t)}setup({camera:t}){const{scope:e}=this,s=this.valueNode;let i=null;if(e===pt.DEPTH_BASE)s!==null&&(i=$r().assign(s));else if(e===pt.DEPTH)t.isPerspectiveCamera?i=Qh(Mt.z,as,cs):i=Zs(Mt.z,as,cs);else if(e===pt.LINEAR_DEPTH)if(s!==null)if(t.isPerspectiveCamera){const n=qr(s,as,cs);i=Zs(n,as,cs)}else i=s;else i=Zs(Mt.z,as,cs);return i}}pt.DEPTH_BASE="depthBase",pt.DEPTH="depth",pt.LINEAR_DEPTH="linearDepth";const Zs=(r,t,e)=>r.add(t).div(t.sub(e)),Qh=(r,t,e)=>t.add(r).mul(e).div(e.sub(t).mul(r)),qr=(r,t,e)=>t.mul(e).div(e.sub(t).mul(r).sub(e)),$r=C(pt,pt.DEPTH_BASE),Kh=O(pt,pt.DEPTH),tu=C(pt,pt.LINEAR_DEPTH);jh(),Kh.assign=r=>$r(r);class ps extends V{static get type(){return"ClippingNode"}constructor(t=ps.DEFAULT){super(),this.scope=t}setup(t){super.setup(t);const e=t.clippingContext,{localClipIntersection:s,localClippingCount:i,globalClippingCount:n}=e,o=n+i,a=s?o-i:o;return this.scope===ps.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(e.planes,o,a):this.setupDefault(e.planes,o,a)}setupAlphaToCoverage(t,e,s){return tt(()=>{const i=rn(t),n=ve("float","distanceToPlane"),o=ve("float","distanceToGradient"),a=ve("float","clipOpacity");a.assign(1);let c;if(Oe(s,({i:u})=>{c=i.element(u),n.assign(Mt.dot(c.xyz).negate().add(c.w)),o.assign(n.fwidth().div(2)),a.mulAssign(tn(o.negate(),o,n)),a.equal(0).discard()}),s<e){const u=ve("float","unionclipOpacity");u.assign(1),Oe({start:s,end:e},({i:h})=>{c=i.element(h),n.assign(Mt.dot(c.xyz).negate().add(c.w)),o.assign(n.fwidth().div(2)),u.mulAssign(tn(o.negate(),o,n).oneMinus())}),a.mulAssign(u.oneMinus())}yr.a.mulAssign(a),yr.a.equal(0).discard()})()}setupDefault(t,e,s){return tt(()=>{const i=rn(t);let n;if(Oe(s,({i:o})=>{n=i.element(o),Mt.dot(n.xyz).greaterThan(n.w).discard()}),s<e){const o=ve("bool","clipped");o.assign(!0),Oe({start:s,end:e},({i:a})=>{n=i.element(a),o.assign(Mt.dot(n.xyz).greaterThan(n.w).and(o))}),o.discard()}})()}}ps.ALPHA_TO_COVERAGE="alphaToCoverage",ps.DEFAULT="default",k(.04),q(1);const eu=tt(([r,t])=>{const e=r.toVar();e.assign(ks(2,e).sub(1));const s=k(e,1).toVar();return Yi(t.equal(0),()=>{s.assign(s.zyx)}).ElseIf(t.equal(1),()=>{s.assign(s.xzy),s.xz.mulAssign(-1)}).ElseIf(t.equal(2),()=>{s.x.mulAssign(-1)}).ElseIf(t.equal(3),()=>{s.assign(s.zyx),s.xz.mulAssign(-1)}).ElseIf(t.equal(4),()=>{s.assign(s.xzy),s.xy.mulAssign(-1)}).ElseIf(t.equal(5),()=>{s.z.mulAssign(-1)}),s}).setLayout({name:"getDirection",type:"vec3",inputs:[{name:"uv",type:"vec2"},{name:"face",type:"float"}]});tt(({texture:r,uv:t})=>{const s=k().toVar();return Yi(t.x.lessThan(1e-4),()=>{s.assign(k(1,0,0))}).ElseIf(t.y.lessThan(1e-4),()=>{s.assign(k(0,1,0))}).ElseIf(t.z.lessThan(1e-4),()=>{s.assign(k(0,0,1))}).ElseIf(t.x.greaterThan(1-1e-4),()=>{s.assign(k(-1,0,0))}).ElseIf(t.y.greaterThan(1-1e-4),()=>{s.assign(k(0,-1,0))}).ElseIf(t.z.greaterThan(1-1e-4),()=>{s.assign(k(0,0,-1))}).Else(()=>{const n=r.uv(t.add(k(-.01,0,0))).r.sub(r.uv(t.add(k(.01,0,0))).r),o=r.uv(t.add(k(0,-.01,0))).r.sub(r.uv(t.add(k(0,.01,0))).r),a=r.uv(t.add(k(0,0,-.01))).r.sub(r.uv(t.add(k(0,0,.01))).r);s.assign(k(n,o,a))}),s.normalize()});const cn=eu(Ws(),rs("faceIndex")).normalize();k(cn.x,cn.y.negate(),cn.z);class Pt extends Ie{static get type(){return"TimerNode"}constructor(t=Pt.LOCAL,e=1,s=0){super(s),this.scope=t,this.scale=e,this.updateType=Q.FRAME}update(t){const e=this.scope,s=this.scale;e===Pt.LOCAL?this.value+=t.deltaTime*s:e===Pt.DELTA?this.value=t.deltaTime*s:e===Pt.FRAME?this.value=t.frameId:this.value=t.time*s}serialize(t){super.serialize(t),t.scope=this.scope,t.scale=this.scale}deserialize(t){super.deserialize(t),this.scope=t.scope,this.scale=t.scale}}Pt.LOCAL="local",Pt.GLOBAL="global",Pt.DELTA="delta",Pt.FRAME="frame";const su=(r,t=0)=>v(new Pt(Pt.LOCAL,r,t));class rt extends V{static get type(){return"OscNode"}constructor(t=rt.SINE,e=su()){super(),this.method=t,this.timeNode=e}getNodeType(t){return this.timeNode.getNodeType(t)}setup(){const t=this.method,e=v(this.timeNode);let s=null;return t===rt.SINE?s=e.add(.75).mul(Math.PI*2).sin().mul(.5).add(.5):t===rt.SQUARE?s=e.fract().round():t===rt.TRIANGLE?s=e.add(.5).fract().mul(2).sub(1).abs():t===rt.SAWTOOTH&&(s=e.fract()),s}serialize(t){super.serialize(t),t.method=this.method}deserialize(t){super.deserialize(t),this.method=t.method}}rt.SINE="sine",rt.SQUARE="square",rt.TRIANGLE="triangle",rt.SAWTOOTH="sawtooth",rt.SINE,rt.SQUARE,rt.TRIANGLE,rt.SAWTOOTH,new Di,new A,new A,new A,new it,new A(0,0,-1),new Ft,new A,new A,new Ft,new J,new Hn,on.flipX();class Vt extends V{static get type(){return"SceneNode"}constructor(t=Vt.BACKGROUND_BLURRINESS,e=null){super(),this.scope=t,this.scene=e}setup(t){const e=this.scope,s=this.scene!==null?this.scene:t.scene;let i;return e===Vt.BACKGROUND_BLURRINESS?i=fe("backgroundBlurriness","float",s):e===Vt.BACKGROUND_INTENSITY?i=fe("backgroundIntensity","float",s):console.error("THREE.SceneNode: Unknown scope:",e),i}}Vt.BACKGROUND_BLURRINESS="backgroundBlurriness",Vt.BACKGROUND_INTENSITY="backgroundIntensity",Vt.BACKGROUND_BLURRINESS,Vt.BACKGROUND_INTENSITY;const iu=new J;class nu extends Gs{static get type(){return"PassTextureNode"}constructor(t,e){super(e),this.passNode=t,this.setUpdateMatrix(!1)}setup(t){return t.object.isQuadMesh&&this.passNode.build(t),super.setup(t)}clone(){return new this.constructor(this.passNode,this.value)}}class Wr extends nu{static get type(){return"PassMultipleTextureNode"}constructor(t,e,s=!1){super(t,null),this.textureName=e,this.previousTexture=s}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(t){return this.updateTexture(),super.setup(t)}clone(){return new this.constructor(this.passNode,this.textureName,this.previousTexture)}}class Js extends dt{static get type(){return"PassNode"}constructor(t,e,s,i={}){super("vec4"),this.scope=t,this.scene=e,this.camera=s,this.options=i,this._pixelRatio=1,this._width=1,this._height=1;const n=new tr;n.isRenderTargetTexture=!0,n.name="depth";const o=new Hn(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:1016,...i});o.texture.name="output",o.depthTexture=n,this.renderTarget=o,this.updateBeforeType=Q.FRAME,this._textures={output:o.texture,depth:n},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=xt(0),this._cameraFar=xt(0),this._mrt=null,this.isPassNode=!0}setMRT(t){return this._mrt=t,this}getMRT(){return this._mrt}isGlobal(){return!0}getTexture(t){let e=this._textures[t];return e===void 0&&(e=this.renderTarget.texture.clone(),e.isRenderTargetTexture=!0,e.name=t,this._textures[t]=e,this.renderTarget.textures.push(e)),e}getPreviousTexture(t){let e=this._previousTextures[t];return e===void 0&&(e=this.getTexture(t).clone(),e.isRenderTargetTexture=!0,this._previousTextures[t]=e),e}toggleTexture(t){const e=this._previousTextures[t];if(e!==void 0){const s=this._textures[t],i=this.renderTarget.textures.indexOf(s);this.renderTarget.textures[i]=e,this._textures[t]=e,this._previousTextures[t]=s,this._textureNodes[t].updateTexture(),this._previousTextureNodes[t].updateTexture()}}getTextureNode(t="output"){let e=this._textureNodes[t];return e===void 0&&(this._textureNodes[t]=e=v(new Wr(this,t)),this._textureNodes[t].updateTexture()),e}getPreviousTextureNode(t="output"){let e=this._previousTextureNodes[t];return e===void 0&&(this._textureNodes[t]===void 0&&this.getTextureNode(t),this._previousTextureNodes[t]=e=v(new Wr(this,t,!0)),this._previousTextureNodes[t].updateTexture()),e}getViewZNode(t="depth"){let e=this._viewZNodes[t];if(e===void 0){const s=this._cameraNear,i=this._cameraFar;this._viewZNodes[t]=e=qr(this.getTextureNode(t),s,i)}return e}getLinearDepthNode(t="depth"){let e=this._linearDepthNodes[t];if(e===void 0){const s=this._cameraNear,i=this._cameraFar,n=this.getViewZNode(t);this._linearDepthNodes[t]=e=Zs(n,s,i)}return e}setup({renderer:t}){return this.renderTarget.samples=this.options.samples===void 0?t.samples:this.options.samples,t.backend.isWebGLBackend===!0&&(this.renderTarget.samples=0),this.renderTarget.depthTexture.isMultisampleRenderTargetTexture=this.renderTarget.samples>1,this.scope===Js.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(t){const{renderer:e}=t,{scene:s,camera:i}=this;this._pixelRatio=e.getPixelRatio();const n=e.getSize(iu);this.setSize(n.width,n.height);const o=e.getRenderTarget(),a=e.getMRT();this._cameraNear.value=i.near,this._cameraFar.value=i.far;for(const c in this._previousTextures)this.toggleTexture(c);e.setRenderTarget(this.renderTarget),e.setMRT(this._mrt),e.render(s,i),e.setRenderTarget(o),e.setMRT(a)}setSize(t,e){this._width=t,this._height=e;const s=this._width*this._pixelRatio,i=this._height*this._pixelRatio;this.renderTarget.setSize(s,i)}setPixelRatio(t){this._pixelRatio=t,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}}Js.COLOR="color",Js.DEPTH="depth",tt(({depthTexture:r,shadowCoord:t})=>os(r,t.xy).compare(t.z)),tt(({depthTexture:r,shadowCoord:t,shadow:e})=>{const s=(m,g)=>os(r,m).compare(g),i=fe("mapSize","vec2",e).setGroup(de),n=fe("radius","float",e).setGroup(de),o=D(1).div(i),a=o.x.negate().mul(n),c=o.y.negate().mul(n),u=o.x.mul(n),h=o.y.mul(n),l=a.div(2),d=c.div(2),p=u.div(2),f=h.div(2);return pe(s(t.xy.add(D(a,c)),t.z),s(t.xy.add(D(0,c)),t.z),s(t.xy.add(D(u,c)),t.z),s(t.xy.add(D(l,d)),t.z),s(t.xy.add(D(0,d)),t.z),s(t.xy.add(D(p,d)),t.z),s(t.xy.add(D(a,0)),t.z),s(t.xy.add(D(l,0)),t.z),s(t.xy,t.z),s(t.xy.add(D(p,0)),t.z),s(t.xy.add(D(u,0)),t.z),s(t.xy.add(D(l,f)),t.z),s(t.xy.add(D(0,f)),t.z),s(t.xy.add(D(p,f)),t.z),s(t.xy.add(D(a,h)),t.z),s(t.xy.add(D(0,h)),t.z),s(t.xy.add(D(u,h)),t.z)).mul(1/17)}),tt(({depthTexture:r,shadowCoord:t,shadow:e})=>{const s=(h,l)=>os(r,h).compare(l),i=fe("mapSize","vec2",e).setGroup(de),n=D(1).div(i),o=n.x,a=n.y,c=t.xy,u=Ji(c.mul(i).add(.5));return c.subAssign(u.mul(n)),pe(s(c,t.z),s(c.add(D(o,0)),t.z),s(c.add(D(0,a)),t.z),s(c.add(n),t.z),re(s(c.add(D(o.negate(),0)),t.z),s(c.add(D(o.mul(2),0)),t.z),u.x),re(s(c.add(D(o.negate(),a)),t.z),s(c.add(D(o.mul(2),a)),t.z),u.x),re(s(c.add(D(0,a.negate())),t.z),s(c.add(D(0,a.mul(2))),t.z),u.y),re(s(c.add(D(o,a.negate())),t.z),s(c.add(D(o,a.mul(2))),t.z),u.y),re(re(s(c.add(D(o.negate(),a.negate())),t.z),s(c.add(D(o.mul(2),a.negate())),t.z),u.x),re(s(c.add(D(o.negate(),a.mul(2))),t.z),s(c.add(D(o.mul(2),a.mul(2))),t.z),u.x),u.y)).mul(1/9)}),tt(({depthTexture:r,shadowCoord:t})=>{const e=q(1).toVar(),s=os(r).uv(t.xy).rg,i=Mr(t.z,s.x);return Yi(i.notEqual(q(1)),()=>{const n=t.z.sub(s.x),o=Qi(0,s.y.mul(s.y));let a=o.div(o.add(n.mul(n)));a=Hs(Vs(a,.3).div(.95-.3)),e.assign(Hs(Qi(i,a)))}),e}),tt(({samples:r,radius:t,size:e,shadowPass:s})=>{const i=q(0).toVar(),n=q(0).toVar(),o=r.lessThanEqual(q(1)).select(q(0),q(2).div(r.sub(1))),a=r.lessThanEqual(q(1)).select(q(0),q(-1));Oe({start:Re(0),end:Re(r),type:"int",condition:"<"},({i:u})=>{const h=a.add(q(u).mul(o)),l=s.uv(pe(Ys.xy,D(0,h).mul(t)).div(e)).x;i.addAssign(l),n.addAssign(l.mul(l))}),i.divAssign(r),n.divAssign(r);const c=Zi(n.sub(i.mul(i)));return D(i,c)}),tt(({samples:r,radius:t,size:e,shadowPass:s})=>{const i=q(0).toVar(),n=q(0).toVar(),o=r.lessThanEqual(q(1)).select(q(0),q(2).div(r.sub(1))),a=r.lessThanEqual(q(1)).select(q(0),q(-1));Oe({start:Re(0),end:Re(r),type:"int",condition:"<"},({i:u})=>{const h=a.add(q(u).mul(o)),l=s.uv(pe(Ys.xy,D(h,0).mul(t)).div(e));i.addAssign(l.x),n.addAssign(pe(l.y.mul(l.y),l.x.mul(l.x)))}),i.divAssign(r),n.divAssign(r);const c=Zi(n.sub(i.mul(i)));return D(i,c)}),k(1.6605,-.1246,-.0182),k(-.5876,1.1329,-.1006),k(-.0728,-.0083,1.1187),k(.6274,.0691,.0164),k(.3293,.9195,.088),k(.0433,.0113,.8956);class ru extends V{constructor(t){super(),this.scope=t}generate(t){const{scope:e}=this,{renderer:s}=t;s.backend.isWebGLBackend===!0?t.addFlowCode(` // ${e}Barrier
|
|
25
|
+
`):t.addLineFlowCode(`${e}Barrier()`,this)}}C(ru);class kt extends dt{static get type(){return"AtomicFunctionNode"}constructor(t,e,s,i=null){super("uint"),this.method=t,this.pointerNode=e,this.valueNode=s,this.storeNode=i}getInputType(t){return this.pointerNode.getNodeType(t)}getNodeType(t){return this.getInputType(t)}generate(t){const e=this.method,s=this.getNodeType(t),i=this.getInputType(t),n=this.pointerNode,o=this.valueNode,a=[];a.push(`&${n.build(t,i)}`),a.push(o.build(t,i));const c=`${t.getMethod(e,s)}( ${a.join(", ")} )`;if(this.storeNode!==null){const u=this.storeNode.build(t,i);t.addLineFlowCode(`${u} = ${c}`,this)}else t.addLineFlowCode(c,this)}}if(kt.ATOMIC_LOAD="atomicLoad",kt.ATOMIC_STORE="atomicStore",kt.ATOMIC_ADD="atomicAdd",kt.ATOMIC_SUB="atomicSub",kt.ATOMIC_MAX="atomicMax",kt.ATOMIC_MIN="atomicMin",kt.ATOMIC_AND="atomicAnd",kt.ATOMIC_OR="atomicOr",kt.ATOMIC_XOR="atomicXor",C(kt),typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Xe}})),typeof window<"u"){try{self.location.href,window.__THREE__IMPORTS__||(window.__THREE__IMPORTS__=[]),window.__THREE__IMPORTS__.push({url:self.location.href,revision:Xe})}catch{}window.__THREE__?(console.warn("WARNING: Multiple instances of Three.js being imported. Existing: "+window.__THREE__+", new: "+Xe),console.warn(window.__THREE__IMPORTS__)):window.__THREE__=Xe}const Gr=0,ou=1,au=2,Xr=2,hn=1.25,Yr=1,fs=6*4+4+4,js=65535,cu=Math.pow(2,-24),un=Symbol("SKIP_GENERATION");function hu(r){return r.index?r.index.count:r.attributes.position.count}function De(r){return hu(r)/3}function uu(r,t=ArrayBuffer){return r>65535?new Uint32Array(new t(4*r)):new Uint16Array(new t(2*r))}function lu(r,t){if(!r.index){const e=r.attributes.position.count,s=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=uu(e,s);r.setIndex(new vt(i,1));for(let n=0;n<e;n++)i[n]=n}}function Zr(r,t){const e=De(r),s=t||r.drawRange,i=s.start/3,n=(s.start+s.count)/3,o=Math.max(0,i),a=Math.min(e,n)-o;return[{offset:Math.floor(o),count:Math.floor(a)}]}function Jr(r,t){if(!r.groups||!r.groups.length)return Zr(r,t);const e=[],s=new Set,i=t||r.drawRange,n=i.start/3,o=(i.start+i.count)/3;for(const c of r.groups){const u=c.start/3,h=(c.start+c.count)/3;s.add(Math.max(n,u)),s.add(Math.min(o,h))}const a=Array.from(s.values()).sort((c,u)=>c-u);for(let c=0;c<a.length-1;c++){const u=a[c],h=a[c+1];e.push({offset:Math.floor(u),count:Math.floor(h-u)})}return e}function du(r,t){const e=De(r),s=Jr(r,t).sort((o,a)=>o.offset-a.offset),i=s[s.length-1];i.count=Math.min(e-i.offset,i.count);let n=0;return s.forEach(({count:o})=>n+=o),e!==n}function ln(r,t,e,s,i){let n=1/0,o=1/0,a=1/0,c=-1/0,u=-1/0,h=-1/0,l=1/0,d=1/0,p=1/0,f=-1/0,m=-1/0,g=-1/0;for(let y=t*6,T=(t+e)*6;y<T;y+=6){const w=r[y+0],M=r[y+1],N=w-M,_=w+M;N<n&&(n=N),_>c&&(c=_),w<l&&(l=w),w>f&&(f=w);const S=r[y+2],E=r[y+3],F=S-E,R=S+E;F<o&&(o=F),R>u&&(u=R),S<d&&(d=S),S>m&&(m=S);const I=r[y+4],B=r[y+5],P=I-B,L=I+B;P<a&&(a=P),L>h&&(h=L),I<p&&(p=I),I>g&&(g=I)}s[0]=n,s[1]=o,s[2]=a,s[3]=c,s[4]=u,s[5]=h,i[0]=l,i[1]=d,i[2]=p,i[3]=f,i[4]=m,i[5]=g}function pu(r,t=null,e=null,s=null){const i=r.attributes.position,n=r.index?r.index.array:null,o=De(r),a=i.normalized;let c;t===null?(c=new Float32Array(o*6),e=0,s=o):(c=t,e=e||0,s=s||o);const u=i.array,h=i.offset||0;let l=3;i.isInterleavedBufferAttribute&&(l=i.data.stride);const d=["getX","getY","getZ"];for(let p=e;p<e+s;p++){const f=p*3,m=p*6;let g=f+0,y=f+1,T=f+2;n&&(g=n[g],y=n[y],T=n[T]),a||(g=g*l+h,y=y*l+h,T=T*l+h);for(let w=0;w<3;w++){let M,N,_;a?(M=i[d[w]](g),N=i[d[w]](y),_=i[d[w]](T)):(M=u[g+w],N=u[y+w],_=u[T+w]);let S=M;N<S&&(S=N),_<S&&(S=_);let E=M;N>E&&(E=N),_>E&&(E=_);const F=(E-S)/2,R=w*2;c[m+R+0]=S+F,c[m+R+1]=F+(Math.abs(S)+F)*cu}}return c}function Z(r,t,e){return e.min.x=t[r],e.min.y=t[r+1],e.min.z=t[r+2],e.max.x=t[r+3],e.max.y=t[r+4],e.max.z=t[r+5],e}function jr(r){let t=-1,e=-1/0;for(let s=0;s<3;s++){const i=r[s+3]-r[s];i>e&&(e=i,t=s)}return t}function Qr(r,t){t.set(r)}function Kr(r,t,e){let s,i;for(let n=0;n<3;n++){const o=n+3;s=r[n],i=t[n],e[n]=s<i?s:i,s=r[o],i=t[o],e[o]=s>i?s:i}}function Qs(r,t,e){for(let s=0;s<3;s++){const i=t[r+2*s],n=t[r+2*s+1],o=i-n,a=i+n;o<e[s]&&(e[s]=o),a>e[s+3]&&(e[s+3]=a)}}function ms(r){const t=r[3]-r[0],e=r[4]-r[1],s=r[5]-r[2];return 2*(t*e+e*s+s*t)}const jt=32,fu=(r,t)=>r.candidate-t.candidate,oe=new Array(jt).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Ks=new Float32Array(6);function mu(r,t,e,s,i,n){let o=-1,a=0;if(n===Gr)o=jr(t),o!==-1&&(a=(t[o]+t[o+3])/2);else if(n===ou)o=jr(r),o!==-1&&(a=yu(e,s,i,o));else if(n===au){const c=ms(r);let u=hn*i;const h=s*6,l=(s+i)*6;for(let d=0;d<3;d++){const p=t[d],g=(t[d+3]-p)/jt;if(i<jt/4){const y=[...oe];y.length=i;let T=0;for(let M=h;M<l;M+=6,T++){const N=y[T];N.candidate=e[M+2*d],N.count=0;const{bounds:_,leftCacheBounds:S,rightCacheBounds:E}=N;for(let F=0;F<3;F++)E[F]=1/0,E[F+3]=-1/0,S[F]=1/0,S[F+3]=-1/0,_[F]=1/0,_[F+3]=-1/0;Qs(M,e,_)}y.sort(fu);let w=i;for(let M=0;M<w;M++){const N=y[M];for(;M+1<w&&y[M+1].candidate===N.candidate;)y.splice(M+1,1),w--}for(let M=h;M<l;M+=6){const N=e[M+2*d];for(let _=0;_<w;_++){const S=y[_];N>=S.candidate?Qs(M,e,S.rightCacheBounds):(Qs(M,e,S.leftCacheBounds),S.count++)}}for(let M=0;M<w;M++){const N=y[M],_=N.count,S=i-N.count,E=N.leftCacheBounds,F=N.rightCacheBounds;let R=0;_!==0&&(R=ms(E)/c);let I=0;S!==0&&(I=ms(F)/c);const B=Yr+hn*(R*_+I*S);B<u&&(o=d,u=B,a=N.candidate)}}else{for(let w=0;w<jt;w++){const M=oe[w];M.count=0,M.candidate=p+g+w*g;const N=M.bounds;for(let _=0;_<3;_++)N[_]=1/0,N[_+3]=-1/0}for(let w=h;w<l;w+=6){let _=~~((e[w+2*d]-p)/g);_>=jt&&(_=jt-1);const S=oe[_];S.count++,Qs(w,e,S.bounds)}const y=oe[jt-1];Qr(y.bounds,y.rightCacheBounds);for(let w=jt-2;w>=0;w--){const M=oe[w],N=oe[w+1];Kr(M.bounds,N.rightCacheBounds,M.rightCacheBounds)}let T=0;for(let w=0;w<jt-1;w++){const M=oe[w],N=M.count,_=M.bounds,E=oe[w+1].rightCacheBounds;N!==0&&(T===0?Qr(_,Ks):Kr(_,Ks,Ks)),T+=N;let F=0,R=0;T!==0&&(F=ms(Ks)/c);const I=i-T;I!==0&&(R=ms(E)/c);const B=Yr+hn*(F*T+R*I);B<u&&(o=d,u=B,a=M.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${n} used.`);return{axis:o,pos:a}}function yu(r,t,e,s){let i=0;for(let n=t,o=t+e;n<o;n++)i+=r[n*6+s*2];return i/e}class dn{constructor(){this.boundingData=new Float32Array(6)}}function gu(r,t,e,s,i,n){let o=s,a=s+i-1;const c=n.pos,u=n.axis*2;for(;;){for(;o<=a&&e[o*6+u]<c;)o++;for(;o<=a&&e[a*6+u]>=c;)a--;if(o<a){for(let h=0;h<3;h++){let l=t[o*3+h];t[o*3+h]=t[a*3+h],t[a*3+h]=l}for(let h=0;h<6;h++){let l=e[o*6+h];e[o*6+h]=e[a*6+h],e[a*6+h]=l}o++,a--}else return o}}function xu(r,t,e,s,i,n){let o=s,a=s+i-1;const c=n.pos,u=n.axis*2;for(;;){for(;o<=a&&e[o*6+u]<c;)o++;for(;o<=a&&e[a*6+u]>=c;)a--;if(o<a){let h=r[o];r[o]=r[a],r[a]=h;for(let l=0;l<6;l++){let d=e[o*6+l];e[o*6+l]=e[a*6+l],e[a*6+l]=d}o++,a--}else return o}}function ft(r,t){return t[r+15]===65535}function Tt(r,t){return t[r+6]}function St(r,t){return t[r+14]}function _t(r){return r+8}function zt(r,t){return t[r+6]}function to(r,t){return t[r+7]}function Jl(r){return r}let eo,ys,ti,so;const Tu=Math.pow(2,32);function pn(r){return"count"in r?1:1+pn(r.left)+pn(r.right)}function Nu(r,t,e){return eo=new Float32Array(e),ys=new Uint32Array(e),ti=new Uint16Array(e),so=new Uint8Array(e),fn(r,t)}function fn(r,t){const e=r/4,s=r/2,i="count"in t,n=t.boundingData;for(let o=0;o<6;o++)eo[e+o]=n[o];if(i)if(t.buffer){const o=t.buffer;so.set(new Uint8Array(o),r);for(let a=r,c=r+o.byteLength;a<c;a+=fs){const u=a/2;ft(u,ti)||(ys[a/4+6]+=e)}return r+o.byteLength}else{const o=t.offset,a=t.count;return ys[e+6]=o,ti[s+14]=a,ti[s+15]=js,r+fs}else{const o=t.left,a=t.right,c=t.splitAxis;let u;if(u=fn(r+fs,o),u/4>Tu)throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return ys[e+6]=u/4,u=fn(u,a),ys[e+7]=c,u}}function wu(r,t){const e=(r.index?r.index.count:r.attributes.position.count)/3,s=e>2**16,i=s?4:2,n=t?new SharedArrayBuffer(e*i):new ArrayBuffer(e*i),o=s?new Uint32Array(n):new Uint16Array(n);for(let a=0,c=o.length;a<c;a++)o[a]=a;return o}function Au(r,t,e,s,i){const{maxDepth:n,verbose:o,maxLeafTris:a,strategy:c,onProgress:u,indirect:h}=i,l=r._indirectBuffer,d=r.geometry,p=d.index?d.index.array:null,f=h?xu:gu,m=De(d),g=new Float32Array(6);let y=!1;const T=new dn;return ln(t,e,s,T.boundingData,g),M(T,e,s,g),T;function w(N){u&&u(N/m)}function M(N,_,S,E=null,F=0){if(!y&&F>=n&&(y=!0,o&&(console.warn(`MeshBVH: Max depth of ${n} reached when generating BVH. Consider increasing maxDepth.`),console.warn(d))),S<=a||F>=n)return w(_+S),N.offset=_,N.count=S,N;const R=mu(N.boundingData,E,t,_,S,c);if(R.axis===-1)return w(_+S),N.offset=_,N.count=S,N;const I=f(l,p,t,_,S,R);if(I===_||I===_+S)w(_+S),N.offset=_,N.count=S;else{N.splitAxis=R.axis;const B=new dn,P=_,L=I-_;N.left=B,ln(t,P,L,B.boundingData,g),M(B,P,L,g,F+1);const U=new dn,W=I,Nt=S-L;N.right=U,ln(t,W,Nt,U.boundingData,g),M(U,W,Nt,g,F+1)}return N}}function Mu(r,t){const e=r.geometry;t.indirect&&(r._indirectBuffer=wu(e,t.useSharedArrayBuffer),du(e,t.range)&&!t.verbose&&console.warn('MeshBVH: Provided geometry contains groups or a range that do not fully span the vertex contents while using the "indirect" option. BVH may incorrectly report intersections on unrendered portions of the geometry.')),r._indirectBuffer||lu(e,t);const s=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=pu(e),n=t.indirect?Zr(e,t.range):Jr(e,t.range);r._roots=n.map(o=>{const a=Au(r,i,o.offset,o.count,t),c=pn(a),u=new s(fs*c);return Nu(0,a,u),u})}class Qt{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(t,e){let s=1/0,i=-1/0;for(let n=0,o=t.length;n<o;n++){const c=t[n][e];s=c<s?c:s,i=c>i?c:i}this.min=s,this.max=i}setFromPoints(t,e){let s=1/0,i=-1/0;for(let n=0,o=e.length;n<o;n++){const a=e[n],c=t.dot(a);s=c<s?c:s,i=c>i?c:i}this.min=s,this.max=i}isSeparated(t){return this.min>t.max||t.min>this.max}}Qt.prototype.setFromBox=function(){const r=new A;return function(e,s){const i=s.min,n=s.max;let o=1/0,a=-1/0;for(let c=0;c<=1;c++)for(let u=0;u<=1;u++)for(let h=0;h<=1;h++){r.x=i.x*c+n.x*(1-c),r.y=i.y*u+n.y*(1-u),r.z=i.z*h+n.z*(1-h);const l=e.dot(r);o=Math.min(l,o),a=Math.max(l,a)}this.min=o,this.max=a}}();const Su=function(){const r=new A,t=new A,e=new A;return function(i,n,o){const a=i.start,c=r,u=n.start,h=t;e.subVectors(a,u),r.subVectors(i.end,i.start),t.subVectors(n.end,n.start);const l=e.dot(h),d=h.dot(c),p=h.dot(h),f=e.dot(c),g=c.dot(c)*p-d*d;let y,T;g!==0?y=(l*d-f*p)/g:y=0,T=(l+y*d)/p,o.x=y,o.y=T}}(),mn=function(){const r=new J,t=new A,e=new A;return function(i,n,o,a){Su(i,n,r);let c=r.x,u=r.y;if(c>=0&&c<=1&&u>=0&&u<=1){i.at(c,o),n.at(u,a);return}else if(c>=0&&c<=1){u<0?n.at(0,a):n.at(1,a),i.closestPointToPoint(a,!0,o);return}else if(u>=0&&u<=1){c<0?i.at(0,o):i.at(1,o),n.closestPointToPoint(o,!0,a);return}else{let h;c<0?h=i.start:h=i.end;let l;u<0?l=n.start:l=n.end;const d=t,p=e;if(i.closestPointToPoint(l,!0,t),n.closestPointToPoint(h,!0,e),d.distanceToSquared(l)<=p.distanceToSquared(h)){o.copy(d),a.copy(l);return}else{o.copy(h),a.copy(p);return}}}}(),_u=function(){const r=new A,t=new A,e=new Di,s=new Zt;return function(n,o){const{radius:a,center:c}=n,{a:u,b:h,c:l}=o;if(s.start=u,s.end=h,s.closestPointToPoint(c,!0,r).distanceTo(c)<=a||(s.start=u,s.end=l,s.closestPointToPoint(c,!0,r).distanceTo(c)<=a)||(s.start=h,s.end=l,s.closestPointToPoint(c,!0,r).distanceTo(c)<=a))return!0;const m=o.getPlane(e);if(Math.abs(m.distanceToPoint(c))<=a){const y=m.projectPoint(c,t);if(o.containsPoint(y))return!0}return!1}}(),zu=1e-15;function yn(r){return Math.abs(r)<zu}class Lt extends wt{constructor(...t){super(...t),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new A),this.satBounds=new Array(4).fill().map(()=>new Qt),this.points=[this.a,this.b,this.c],this.sphere=new $n,this.plane=new Di,this.needsUpdate=!0}intersectsSphere(t){return _u(t,this)}update(){const t=this.a,e=this.b,s=this.c,i=this.points,n=this.satAxes,o=this.satBounds,a=n[0],c=o[0];this.getNormal(a),c.setFromPoints(a,i);const u=n[1],h=o[1];u.subVectors(t,e),h.setFromPoints(u,i);const l=n[2],d=o[2];l.subVectors(e,s),d.setFromPoints(l,i);const p=n[3],f=o[3];p.subVectors(s,t),f.setFromPoints(p,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,t),this.needsUpdate=!1}}Lt.prototype.closestPointToSegment=function(){const r=new A,t=new A,e=new Zt;return function(i,n=null,o=null){const{start:a,end:c}=i,u=this.points;let h,l=1/0;for(let d=0;d<3;d++){const p=(d+1)%3;e.start.copy(u[d]),e.end.copy(u[p]),mn(e,i,r,t),h=r.distanceToSquared(t),h<l&&(l=h,n&&n.copy(r),o&&o.copy(t))}return this.closestPointToPoint(a,r),h=a.distanceToSquared(r),h<l&&(l=h,n&&n.copy(r),o&&o.copy(a)),this.closestPointToPoint(c,r),h=c.distanceToSquared(r),h<l&&(l=h,n&&n.copy(r),o&&o.copy(c)),Math.sqrt(l)}}(),Lt.prototype.intersectsTriangle=function(){const r=new Lt,t=new Array(3),e=new Array(3),s=new Qt,i=new Qt,n=new A,o=new A,a=new A,c=new A,u=new A,h=new Zt,l=new Zt,d=new Zt,p=new A;function f(m,g,y){const T=m.points;let w=0,M=-1;for(let N=0;N<3;N++){const{start:_,end:S}=h;_.copy(T[N]),S.copy(T[(N+1)%3]),h.delta(o);const E=yn(g.distanceToPoint(_));if(yn(g.normal.dot(o))&&E){y.copy(h),w=2;break}const F=g.intersectLine(h,p);if(!F&&E&&p.copy(_),(F||E)&&!yn(p.distanceTo(S))){if(w<=1)(w===1?y.start:y.end).copy(p),E&&(M=w);else if(w>=2){(M===1?y.start:y.end).copy(p),w=2;break}if(w++,w===2&&M===-1)break}}return w}return function(g,y=null,T=!1){this.needsUpdate&&this.update(),g.isExtendedTriangle?g.needsUpdate&&g.update():(r.copy(g),r.update(),g=r);const w=this.plane,M=g.plane;if(Math.abs(w.normal.dot(M.normal))>1-1e-10){const N=this.satBounds,_=this.satAxes;e[0]=g.a,e[1]=g.b,e[2]=g.c;for(let F=0;F<4;F++){const R=N[F],I=_[F];if(s.setFromPoints(I,e),R.isSeparated(s))return!1}const S=g.satBounds,E=g.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let F=0;F<4;F++){const R=S[F],I=E[F];if(s.setFromPoints(I,t),R.isSeparated(s))return!1}for(let F=0;F<4;F++){const R=_[F];for(let I=0;I<4;I++){const B=E[I];if(n.crossVectors(R,B),s.setFromPoints(n,t),i.setFromPoints(n,e),s.isSeparated(i))return!1}}return y&&(T||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),y.start.set(0,0,0),y.end.set(0,0,0)),!0}else{const N=f(this,M,l);if(N===1&&g.containsPoint(l.end))return y&&(y.start.copy(l.end),y.end.copy(l.end)),!0;if(N!==2)return!1;const _=f(g,w,d);if(_===1&&this.containsPoint(d.end))return y&&(y.start.copy(d.end),y.end.copy(d.end)),!0;if(_!==2)return!1;if(l.delta(a),d.delta(c),a.dot(c)<0){let P=d.start;d.start=d.end,d.end=P}const S=l.start.dot(a),E=l.end.dot(a),F=d.start.dot(a),R=d.end.dot(a),I=E<F,B=S<R;return S!==R&&F!==E&&I===B?!1:(y&&(u.subVectors(l.start,d.start),u.dot(a)>0?y.start.copy(l.start):y.start.copy(d.start),u.subVectors(l.end,d.end),u.dot(a)<0?y.end.copy(l.end):y.end.copy(d.end)),!0)}}}(),Lt.prototype.distanceToPoint=function(){const r=new A;return function(e){return this.closestPointToPoint(e,r),e.distanceTo(r)}}(),Lt.prototype.distanceToTriangle=function(){const r=new A,t=new A,e=["a","b","c"],s=new Zt,i=new Zt;return function(o,a=null,c=null){const u=a||c?s:null;if(this.intersectsTriangle(o,u))return(a||c)&&(a&&u.getCenter(a),c&&u.getCenter(c)),0;let h=1/0;for(let l=0;l<3;l++){let d;const p=e[l],f=o[p];this.closestPointToPoint(f,r),d=f.distanceToSquared(r),d<h&&(h=d,a&&a.copy(r),c&&c.copy(f));const m=this[p];o.closestPointToPoint(m,r),d=m.distanceToSquared(r),d<h&&(h=d,a&&a.copy(m),c&&c.copy(r))}for(let l=0;l<3;l++){const d=e[l],p=e[(l+1)%3];s.set(this[d],this[p]);for(let f=0;f<3;f++){const m=e[f],g=e[(f+1)%3];i.set(o[m],o[g]),mn(s,i,r,t);const y=r.distanceToSquared(t);y<h&&(h=y,a&&a.copy(r),c&&c.copy(t))}}return Math.sqrt(h)}}();class lt{constructor(t,e,s){this.isOrientedBox=!0,this.min=new A,this.max=new A,this.matrix=new it,this.invMatrix=new it,this.points=new Array(8).fill().map(()=>new A),this.satAxes=new Array(3).fill().map(()=>new A),this.satBounds=new Array(3).fill().map(()=>new Qt),this.alignedSatBounds=new Array(3).fill().map(()=>new Qt),this.needsUpdate=!1,t&&this.min.copy(t),e&&this.max.copy(e),s&&this.matrix.copy(s)}set(t,e,s){this.min.copy(t),this.max.copy(e),this.matrix.copy(s),this.needsUpdate=!0}copy(t){this.min.copy(t.min),this.max.copy(t.max),this.matrix.copy(t.matrix),this.needsUpdate=!0}}lt.prototype.update=function(){return function(){const t=this.matrix,e=this.min,s=this.max,i=this.points;for(let u=0;u<=1;u++)for(let h=0;h<=1;h++)for(let l=0;l<=1;l++){const d=1*u|2*h|4*l,p=i[d];p.x=u?s.x:e.x,p.y=h?s.y:e.y,p.z=l?s.z:e.z,p.applyMatrix4(t)}const n=this.satBounds,o=this.satAxes,a=i[0];for(let u=0;u<3;u++){const h=o[u],l=n[u],d=1<<u,p=i[d];h.subVectors(a,p),l.setFromPoints(h,i)}const c=this.alignedSatBounds;c[0].setFromPointsField(i,"x"),c[1].setFromPointsField(i,"y"),c[2].setFromPointsField(i,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}(),lt.prototype.intersectsBox=function(){const r=new Qt;return function(e){this.needsUpdate&&this.update();const s=e.min,i=e.max,n=this.satBounds,o=this.satAxes,a=this.alignedSatBounds;if(r.min=s.x,r.max=i.x,a[0].isSeparated(r)||(r.min=s.y,r.max=i.y,a[1].isSeparated(r))||(r.min=s.z,r.max=i.z,a[2].isSeparated(r)))return!1;for(let c=0;c<3;c++){const u=o[c],h=n[c];if(r.setFromBox(u,e),h.isSeparated(r))return!1}return!0}}(),lt.prototype.intersectsTriangle=function(){const r=new Lt,t=new Array(3),e=new Qt,s=new Qt,i=new A;return function(o){this.needsUpdate&&this.update(),o.isExtendedTriangle?o.needsUpdate&&o.update():(r.copy(o),r.update(),o=r);const a=this.satBounds,c=this.satAxes;t[0]=o.a,t[1]=o.b,t[2]=o.c;for(let d=0;d<3;d++){const p=a[d],f=c[d];if(e.setFromPoints(f,t),p.isSeparated(e))return!1}const u=o.satBounds,h=o.satAxes,l=this.points;for(let d=0;d<3;d++){const p=u[d],f=h[d];if(e.setFromPoints(f,l),p.isSeparated(e))return!1}for(let d=0;d<3;d++){const p=c[d];for(let f=0;f<4;f++){const m=h[f];if(i.crossVectors(p,m),e.setFromPoints(i,t),s.setFromPoints(i,l),e.isSeparated(s))return!1}}return!0}}(),lt.prototype.closestPointToPoint=function(){return function(t,e){return this.needsUpdate&&this.update(),e.copy(t).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),e}}(),lt.prototype.distanceToPoint=function(){const r=new A;return function(e){return this.closestPointToPoint(e,r),e.distanceTo(r)}}(),lt.prototype.distanceToBox=function(){const r=["x","y","z"],t=new Array(12).fill().map(()=>new Zt),e=new Array(12).fill().map(()=>new Zt),s=new A,i=new A;return function(o,a=0,c=null,u=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(c||u)&&(o.getCenter(i),this.closestPointToPoint(i,s),o.closestPointToPoint(s,i),c&&c.copy(s),u&&u.copy(i)),0;const h=a*a,l=o.min,d=o.max,p=this.points;let f=1/0;for(let g=0;g<8;g++){const y=p[g];i.copy(y).clamp(l,d);const T=y.distanceToSquared(i);if(T<f&&(f=T,c&&c.copy(y),u&&u.copy(i),T<h))return Math.sqrt(T)}let m=0;for(let g=0;g<3;g++)for(let y=0;y<=1;y++)for(let T=0;T<=1;T++){const w=(g+1)%3,M=(g+2)%3,N=y<<w|T<<M,_=1<<g|y<<w|T<<M,S=p[N],E=p[_];t[m].set(S,E);const R=r[g],I=r[w],B=r[M],P=e[m],L=P.start,U=P.end;L[R]=l[R],L[I]=y?l[I]:d[I],L[B]=T?l[B]:d[I],U[R]=d[R],U[I]=y?l[I]:d[I],U[B]=T?l[B]:d[I],m++}for(let g=0;g<=1;g++)for(let y=0;y<=1;y++)for(let T=0;T<=1;T++){i.x=g?d.x:l.x,i.y=y?d.y:l.y,i.z=T?d.z:l.z,this.closestPointToPoint(i,s);const w=i.distanceToSquared(s);if(w<f&&(f=w,c&&c.copy(s),u&&u.copy(i),w<h))return Math.sqrt(w)}for(let g=0;g<12;g++){const y=t[g];for(let T=0;T<12;T++){const w=e[T];mn(y,w,s,i);const M=s.distanceToSquared(i);if(M<f&&(f=M,c&&c.copy(s),u&&u.copy(i),M<h))return Math.sqrt(M)}}return Math.sqrt(f)}}();class gn{constructor(t){this._getNewPrimitive=t,this._primitives=[]}getPrimitive(){const t=this._primitives;return t.length===0?this._getNewPrimitive():t.pop()}releasePrimitive(t){this._primitives.push(t)}}class bu extends gn{constructor(){super(()=>new Lt)}}const bt=new bu;class Eu{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const t=[];let e=null;this.setBuffer=s=>{e&&t.push(e),e=s,this.float32Array=new Float32Array(s),this.uint16Array=new Uint16Array(s),this.uint32Array=new Uint32Array(s)},this.clearBuffer=()=>{e=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,t.length!==0&&this.setBuffer(t.pop())}}}const X=new Eu;let ae,Ue;const Ve=[],ei=new gn(()=>new ht);function Cu(r,t,e,s,i,n){ae=ei.getPrimitive(),Ue=ei.getPrimitive(),Ve.push(ae,Ue),X.setBuffer(r._roots[t]);const o=xn(0,r.geometry,e,s,i,n);X.clearBuffer(),ei.releasePrimitive(ae),ei.releasePrimitive(Ue),Ve.pop(),Ve.pop();const a=Ve.length;return a>0&&(Ue=Ve[a-1],ae=Ve[a-2]),o}function xn(r,t,e,s,i=null,n=0,o=0){const{float32Array:a,uint16Array:c,uint32Array:u}=X;let h=r*2;if(ft(h,c)){const d=Tt(r,u),p=St(h,c);return Z(r,a,ae),s(d,p,!1,o,n+r,ae)}else{let R=function(B){const{uint16Array:P,uint32Array:L}=X;let U=B*2;for(;!ft(U,P);)B=_t(B),U=B*2;return Tt(B,L)},I=function(B){const{uint16Array:P,uint32Array:L}=X;let U=B*2;for(;!ft(U,P);)B=zt(B,L),U=B*2;return Tt(B,L)+St(U,P)};const d=_t(r),p=zt(r,u);let f=d,m=p,g,y,T,w;if(i&&(T=ae,w=Ue,Z(f,a,T),Z(m,a,w),g=i(T),y=i(w),y<g)){f=p,m=d;const B=g;g=y,y=B,T=w}T||(T=ae,Z(f,a,T));const M=ft(f*2,c),N=e(T,M,g,o+1,n+f);let _;if(N===Xr){const B=R(f),L=I(f)-B;_=s(B,L,!0,o+1,n+f,T)}else _=N&&xn(f,t,e,s,i,n,o+1);if(_)return!0;w=Ue,Z(m,a,w);const S=ft(m*2,c),E=e(w,S,y,o+1,n+m);let F;if(E===Xr){const B=R(m),L=I(m)-B;F=s(B,L,!0,o+1,n+m,w)}else F=E&&xn(m,t,e,s,i,n,o+1);return!!F}}const gs=new A,Tn=new A;function Fu(r,t,e={},s=0,i=1/0){const n=s*s,o=i*i;let a=1/0,c=null;if(r.shapecast({boundsTraverseOrder:h=>(gs.copy(t).clamp(h.min,h.max),gs.distanceToSquared(t)),intersectsBounds:(h,l,d)=>d<a&&d<o,intersectsTriangle:(h,l)=>{h.closestPointToPoint(t,gs);const d=t.distanceToSquared(gs);return d<a&&(Tn.copy(gs),a=d,c=l),d<n}}),a===1/0)return null;const u=Math.sqrt(a);return e.point?e.point.copy(Tn):e.point=Tn.clone(),e.distance=u,e.faceIndex=c,e}const Ru=parseInt(Xe)>=169,me=new A,ye=new A,ge=new A,si=new J,ii=new J,ni=new J,io=new A,no=new A,ro=new A,xs=new A;function Bu(r,t,e,s,i,n,o,a){let c;if(n===1?c=r.intersectTriangle(s,e,t,!0,i):c=r.intersectTriangle(t,e,s,n!==2,i),c===null)return null;const u=r.origin.distanceTo(i);return u<o||u>a?null:{distance:u,point:i.clone()}}function Iu(r,t,e,s,i,n,o,a,c,u,h){me.fromBufferAttribute(t,n),ye.fromBufferAttribute(t,o),ge.fromBufferAttribute(t,a);const l=Bu(r,me,ye,ge,xs,c,u,h);if(l){const d=new A;wt.getBarycoord(xs,me,ye,ge,d),s&&(si.fromBufferAttribute(s,n),ii.fromBufferAttribute(s,o),ni.fromBufferAttribute(s,a),l.uv=wt.getInterpolation(xs,me,ye,ge,si,ii,ni,new J)),i&&(si.fromBufferAttribute(i,n),ii.fromBufferAttribute(i,o),ni.fromBufferAttribute(i,a),l.uv1=wt.getInterpolation(xs,me,ye,ge,si,ii,ni,new J)),e&&(io.fromBufferAttribute(e,n),no.fromBufferAttribute(e,o),ro.fromBufferAttribute(e,a),l.normal=wt.getInterpolation(xs,me,ye,ge,io,no,ro,new A),l.normal.dot(r.direction)>0&&l.normal.multiplyScalar(-1));const p={a:n,b:o,c:a,normal:new A,materialIndex:0};wt.getNormal(me,ye,ge,p.normal),l.face=p,l.faceIndex=n,Ru&&(l.barycoord=d)}return l}function ri(r,t,e,s,i,n,o){const a=s*3;let c=a+0,u=a+1,h=a+2;const l=r.index;r.index&&(c=l.getX(c),u=l.getX(u),h=l.getX(h));const{position:d,normal:p,uv:f,uv1:m}=r.attributes,g=Iu(e,d,p,f,m,c,u,h,t,n,o);return g?(g.faceIndex=s,i&&i.push(g),g):null}function st(r,t,e,s){const i=r.a,n=r.b,o=r.c;let a=t,c=t+1,u=t+2;e&&(a=e.getX(a),c=e.getX(c),u=e.getX(u)),i.x=s.getX(a),i.y=s.getY(a),i.z=s.getZ(a),n.x=s.getX(c),n.y=s.getY(c),n.z=s.getZ(c),o.x=s.getX(u),o.y=s.getY(u),o.z=s.getZ(u)}function vu(r,t,e,s,i,n,o,a){const{geometry:c,_indirectBuffer:u}=r;for(let h=s,l=s+i;h<l;h++)ri(c,t,e,h,n,o,a)}function Pu(r,t,e,s,i,n,o){const{geometry:a,_indirectBuffer:c}=r;let u=1/0,h=null;for(let l=s,d=s+i;l<d;l++){let p;p=ri(a,t,e,l,null,n,o),p&&p.distance<u&&(h=p,u=p.distance)}return h}function Lu(r,t,e,s,i,n,o){const{geometry:a}=e,{index:c}=a,u=a.attributes.position;for(let h=r,l=t+r;h<l;h++){let d;if(d=h,st(o,d*3,c,u),o.needsUpdate=!0,s(o,d,i,n))return!0}return!1}function Ou(r,t=null){t&&Array.isArray(t)&&(t=new Set(t));const e=r.geometry,s=e.index?e.index.array:null,i=e.attributes.position;let n,o,a,c,u=0;const h=r._roots;for(let d=0,p=h.length;d<p;d++)n=h[d],o=new Uint32Array(n),a=new Uint16Array(n),c=new Float32Array(n),l(0,u),u+=n.byteLength;function l(d,p,f=!1){const m=d*2;if(a[m+15]===js){const y=o[d+6],T=a[m+14];let w=1/0,M=1/0,N=1/0,_=-1/0,S=-1/0,E=-1/0;for(let F=3*y,R=3*(y+T);F<R;F++){let I=s[F];const B=i.getX(I),P=i.getY(I),L=i.getZ(I);B<w&&(w=B),B>_&&(_=B),P<M&&(M=P),P>S&&(S=P),L<N&&(N=L),L>E&&(E=L)}return c[d+0]!==w||c[d+1]!==M||c[d+2]!==N||c[d+3]!==_||c[d+4]!==S||c[d+5]!==E?(c[d+0]=w,c[d+1]=M,c[d+2]=N,c[d+3]=_,c[d+4]=S,c[d+5]=E,!0):!1}else{const y=d+8,T=o[d+6],w=y+p,M=T+p;let N=f,_=!1,S=!1;t?N||(_=t.has(w),S=t.has(M),N=!_&&!S):(_=!0,S=!0);const E=N||_,F=N||S;let R=!1;E&&(R=l(y,p,N));let I=!1;F&&(I=l(T,p,N));const B=R||I;if(B)for(let P=0;P<3;P++){const L=y+P,U=T+P,W=c[L],Nt=c[L+3],Ht=c[U],qt=c[U+3];c[d+P]=W<Ht?W:Ht,c[d+P+3]=Nt>qt?Nt:qt}return B}}}function ce(r,t,e,s,i){let n,o,a,c,u,h;const l=1/e.direction.x,d=1/e.direction.y,p=1/e.direction.z,f=e.origin.x,m=e.origin.y,g=e.origin.z;let y=t[r],T=t[r+3],w=t[r+1],M=t[r+3+1],N=t[r+2],_=t[r+3+2];return l>=0?(n=(y-f)*l,o=(T-f)*l):(n=(T-f)*l,o=(y-f)*l),d>=0?(a=(w-m)*d,c=(M-m)*d):(a=(M-m)*d,c=(w-m)*d),n>c||a>o||((a>n||isNaN(n))&&(n=a),(c<o||isNaN(o))&&(o=c),p>=0?(u=(N-g)*p,h=(_-g)*p):(u=(_-g)*p,h=(N-g)*p),n>h||u>o)?!1:((u>n||n!==n)&&(n=u),(h<o||o!==o)&&(o=h),n<=i&&o>=s)}function Du(r,t,e,s,i,n,o,a){const{geometry:c,_indirectBuffer:u}=r;for(let h=s,l=s+i;h<l;h++){let d=u?u[h]:h;ri(c,t,e,d,n,o,a)}}function Uu(r,t,e,s,i,n,o){const{geometry:a,_indirectBuffer:c}=r;let u=1/0,h=null;for(let l=s,d=s+i;l<d;l++){let p;p=ri(a,t,e,c?c[l]:l,null,n,o),p&&p.distance<u&&(h=p,u=p.distance)}return h}function Vu(r,t,e,s,i,n,o){const{geometry:a}=e,{index:c}=a,u=a.attributes.position;for(let h=r,l=t+r;h<l;h++){let d;if(d=e.resolveTriangleIndex(h),st(o,d*3,c,u),o.needsUpdate=!0,s(o,d,i,n))return!0}return!1}function ku(r,t,e,s,i,n,o){X.setBuffer(r._roots[t]),Nn(0,r,e,s,i,n,o),X.clearBuffer()}function Nn(r,t,e,s,i,n,o){const{float32Array:a,uint16Array:c,uint32Array:u}=X,h=r*2;if(ft(h,c)){const d=Tt(r,u),p=St(h,c);vu(t,e,s,d,p,i,n,o)}else{const d=_t(r);ce(d,a,s,n,o)&&Nn(d,t,e,s,i,n,o);const p=zt(r,u);ce(p,a,s,n,o)&&Nn(p,t,e,s,i,n,o)}}const Hu=["x","y","z"];function qu(r,t,e,s,i,n){X.setBuffer(r._roots[t]);const o=wn(0,r,e,s,i,n);return X.clearBuffer(),o}function wn(r,t,e,s,i,n){const{float32Array:o,uint16Array:a,uint32Array:c}=X;let u=r*2;if(ft(u,a)){const l=Tt(r,c),d=St(u,a);return Pu(t,e,s,l,d,i,n)}else{const l=to(r,c),d=Hu[l],f=s.direction[d]>=0;let m,g;f?(m=_t(r),g=zt(r,c)):(m=zt(r,c),g=_t(r));const T=ce(m,o,s,i,n)?wn(m,t,e,s,i,n):null;if(T){const N=T.point[d];if(f?N<=o[g+l]:N>=o[g+l+3])return T}const M=ce(g,o,s,i,n)?wn(g,t,e,s,i,n):null;return T&&M?T.distance<=M.distance?T:M:T||M||null}}const oi=new ht,ke=new Lt,He=new Lt,Ts=new it,oo=new lt,ai=new lt;function $u(r,t,e,s){X.setBuffer(r._roots[t]);const i=An(0,r,e,s);return X.clearBuffer(),i}function An(r,t,e,s,i=null){const{float32Array:n,uint16Array:o,uint32Array:a}=X;let c=r*2;if(i===null&&(e.boundingBox||e.computeBoundingBox(),oo.set(e.boundingBox.min,e.boundingBox.max,s),i=oo),ft(c,o)){const h=t.geometry,l=h.index,d=h.attributes.position,p=e.index,f=e.attributes.position,m=Tt(r,a),g=St(c,o);if(Ts.copy(s).invert(),e.boundsTree)return Z(r,n,ai),ai.matrix.copy(Ts),ai.needsUpdate=!0,e.boundsTree.shapecast({intersectsBounds:T=>ai.intersectsBox(T),intersectsTriangle:T=>{T.a.applyMatrix4(s),T.b.applyMatrix4(s),T.c.applyMatrix4(s),T.needsUpdate=!0;for(let w=m*3,M=(g+m)*3;w<M;w+=3)if(st(He,w,l,d),He.needsUpdate=!0,T.intersectsTriangle(He))return!0;return!1}});for(let y=m*3,T=(g+m)*3;y<T;y+=3){st(ke,y,l,d),ke.a.applyMatrix4(Ts),ke.b.applyMatrix4(Ts),ke.c.applyMatrix4(Ts),ke.needsUpdate=!0;for(let w=0,M=p.count;w<M;w+=3)if(st(He,w,p,f),He.needsUpdate=!0,ke.intersectsTriangle(He))return!0}}else{const h=r+8,l=a[r+6];return Z(h,n,oi),!!(i.intersectsBox(oi)&&An(h,t,e,s,i)||(Z(l,n,oi),i.intersectsBox(oi)&&An(l,t,e,s,i)))}}const ci=new it,Mn=new lt,Ns=new lt,Wu=new A,Gu=new A,Xu=new A,Yu=new A;function Zu(r,t,e,s={},i={},n=0,o=1/0){t.boundingBox||t.computeBoundingBox(),Mn.set(t.boundingBox.min,t.boundingBox.max,e),Mn.needsUpdate=!0;const a=r.geometry,c=a.attributes.position,u=a.index,h=t.attributes.position,l=t.index,d=bt.getPrimitive(),p=bt.getPrimitive();let f=Wu,m=Gu,g=null,y=null;i&&(g=Xu,y=Yu);let T=1/0,w=null,M=null;return ci.copy(e).invert(),Ns.matrix.copy(ci),r.shapecast({boundsTraverseOrder:N=>Mn.distanceToBox(N),intersectsBounds:(N,_,S)=>S<T&&S<o?(_&&(Ns.min.copy(N.min),Ns.max.copy(N.max),Ns.needsUpdate=!0),!0):!1,intersectsRange:(N,_)=>{if(t.boundsTree)return t.boundsTree.shapecast({boundsTraverseOrder:E=>Ns.distanceToBox(E),intersectsBounds:(E,F,R)=>R<T&&R<o,intersectsRange:(E,F)=>{for(let R=E,I=E+F;R<I;R++){st(p,3*R,l,h),p.a.applyMatrix4(e),p.b.applyMatrix4(e),p.c.applyMatrix4(e),p.needsUpdate=!0;for(let B=N,P=N+_;B<P;B++){st(d,3*B,u,c),d.needsUpdate=!0;const L=d.distanceToTriangle(p,f,g);if(L<T&&(m.copy(f),y&&y.copy(g),T=L,w=B,M=R),L<n)return!0}}}});{const S=De(t);for(let E=0,F=S;E<F;E++){st(p,3*E,l,h),p.a.applyMatrix4(e),p.b.applyMatrix4(e),p.c.applyMatrix4(e),p.needsUpdate=!0;for(let R=N,I=N+_;R<I;R++){st(d,3*R,u,c),d.needsUpdate=!0;const B=d.distanceToTriangle(p,f,g);if(B<T&&(m.copy(f),y&&y.copy(g),T=B,w=R,M=E),B<n)return!0}}}}}),bt.releasePrimitive(d),bt.releasePrimitive(p),T===1/0?null:(s.point?s.point.copy(m):s.point=m.clone(),s.distance=T,s.faceIndex=w,i&&(i.point?i.point.copy(y):i.point=y.clone(),i.point.applyMatrix4(ci),m.applyMatrix4(ci),i.distance=m.sub(i.point).length(),i.faceIndex=M),s)}function Ju(r,t=null){t&&Array.isArray(t)&&(t=new Set(t));const e=r.geometry,s=e.index?e.index.array:null,i=e.attributes.position;let n,o,a,c,u=0;const h=r._roots;for(let d=0,p=h.length;d<p;d++)n=h[d],o=new Uint32Array(n),a=new Uint16Array(n),c=new Float32Array(n),l(0,u),u+=n.byteLength;function l(d,p,f=!1){const m=d*2;if(a[m+15]===js){const y=o[d+6],T=a[m+14];let w=1/0,M=1/0,N=1/0,_=-1/0,S=-1/0,E=-1/0;for(let F=y,R=y+T;F<R;F++){const I=3*r.resolveTriangleIndex(F);for(let B=0;B<3;B++){let P=I+B;P=s?s[P]:P;const L=i.getX(P),U=i.getY(P),W=i.getZ(P);L<w&&(w=L),L>_&&(_=L),U<M&&(M=U),U>S&&(S=U),W<N&&(N=W),W>E&&(E=W)}}return c[d+0]!==w||c[d+1]!==M||c[d+2]!==N||c[d+3]!==_||c[d+4]!==S||c[d+5]!==E?(c[d+0]=w,c[d+1]=M,c[d+2]=N,c[d+3]=_,c[d+4]=S,c[d+5]=E,!0):!1}else{const y=d+8,T=o[d+6],w=y+p,M=T+p;let N=f,_=!1,S=!1;t?N||(_=t.has(w),S=t.has(M),N=!_&&!S):(_=!0,S=!0);const E=N||_,F=N||S;let R=!1;E&&(R=l(y,p,N));let I=!1;F&&(I=l(T,p,N));const B=R||I;if(B)for(let P=0;P<3;P++){const L=y+P,U=T+P,W=c[L],Nt=c[L+3],Ht=c[U],qt=c[U+3];c[d+P]=W<Ht?W:Ht,c[d+P+3]=Nt>qt?Nt:qt}return B}}}function ju(r,t,e,s,i,n,o){X.setBuffer(r._roots[t]),Sn(0,r,e,s,i,n,o),X.clearBuffer()}function Sn(r,t,e,s,i,n,o){const{float32Array:a,uint16Array:c,uint32Array:u}=X,h=r*2;if(ft(h,c)){const d=Tt(r,u),p=St(h,c);Du(t,e,s,d,p,i,n,o)}else{const d=_t(r);ce(d,a,s,n,o)&&Sn(d,t,e,s,i,n,o);const p=zt(r,u);ce(p,a,s,n,o)&&Sn(p,t,e,s,i,n,o)}}const Qu=["x","y","z"];function Ku(r,t,e,s,i,n){X.setBuffer(r._roots[t]);const o=_n(0,r,e,s,i,n);return X.clearBuffer(),o}function _n(r,t,e,s,i,n){const{float32Array:o,uint16Array:a,uint32Array:c}=X;let u=r*2;if(ft(u,a)){const l=Tt(r,c),d=St(u,a);return Uu(t,e,s,l,d,i,n)}else{const l=to(r,c),d=Qu[l],f=s.direction[d]>=0;let m,g;f?(m=_t(r),g=zt(r,c)):(m=zt(r,c),g=_t(r));const T=ce(m,o,s,i,n)?_n(m,t,e,s,i,n):null;if(T){const N=T.point[d];if(f?N<=o[g+l]:N>=o[g+l+3])return T}const M=ce(g,o,s,i,n)?_n(g,t,e,s,i,n):null;return T&&M?T.distance<=M.distance?T:M:T||M||null}}const hi=new ht,qe=new Lt,$e=new Lt,ws=new it,ao=new lt,ui=new lt;function tl(r,t,e,s){X.setBuffer(r._roots[t]);const i=zn(0,r,e,s);return X.clearBuffer(),i}function zn(r,t,e,s,i=null){const{float32Array:n,uint16Array:o,uint32Array:a}=X;let c=r*2;if(i===null&&(e.boundingBox||e.computeBoundingBox(),ao.set(e.boundingBox.min,e.boundingBox.max,s),i=ao),ft(c,o)){const h=t.geometry,l=h.index,d=h.attributes.position,p=e.index,f=e.attributes.position,m=Tt(r,a),g=St(c,o);if(ws.copy(s).invert(),e.boundsTree)return Z(r,n,ui),ui.matrix.copy(ws),ui.needsUpdate=!0,e.boundsTree.shapecast({intersectsBounds:T=>ui.intersectsBox(T),intersectsTriangle:T=>{T.a.applyMatrix4(s),T.b.applyMatrix4(s),T.c.applyMatrix4(s),T.needsUpdate=!0;for(let w=m,M=g+m;w<M;w++)if(st($e,3*t.resolveTriangleIndex(w),l,d),$e.needsUpdate=!0,T.intersectsTriangle($e))return!0;return!1}});for(let y=m,T=g+m;y<T;y++){const w=t.resolveTriangleIndex(y);st(qe,3*w,l,d),qe.a.applyMatrix4(ws),qe.b.applyMatrix4(ws),qe.c.applyMatrix4(ws),qe.needsUpdate=!0;for(let M=0,N=p.count;M<N;M+=3)if(st($e,M,p,f),$e.needsUpdate=!0,qe.intersectsTriangle($e))return!0}}else{const h=r+8,l=a[r+6];return Z(h,n,hi),!!(i.intersectsBox(hi)&&zn(h,t,e,s,i)||(Z(l,n,hi),i.intersectsBox(hi)&&zn(l,t,e,s,i)))}}const li=new it,bn=new lt,As=new lt,el=new A,sl=new A,il=new A,nl=new A;function rl(r,t,e,s={},i={},n=0,o=1/0){t.boundingBox||t.computeBoundingBox(),bn.set(t.boundingBox.min,t.boundingBox.max,e),bn.needsUpdate=!0;const a=r.geometry,c=a.attributes.position,u=a.index,h=t.attributes.position,l=t.index,d=bt.getPrimitive(),p=bt.getPrimitive();let f=el,m=sl,g=null,y=null;i&&(g=il,y=nl);let T=1/0,w=null,M=null;return li.copy(e).invert(),As.matrix.copy(li),r.shapecast({boundsTraverseOrder:N=>bn.distanceToBox(N),intersectsBounds:(N,_,S)=>S<T&&S<o?(_&&(As.min.copy(N.min),As.max.copy(N.max),As.needsUpdate=!0),!0):!1,intersectsRange:(N,_)=>{if(t.boundsTree){const S=t.boundsTree;return S.shapecast({boundsTraverseOrder:E=>As.distanceToBox(E),intersectsBounds:(E,F,R)=>R<T&&R<o,intersectsRange:(E,F)=>{for(let R=E,I=E+F;R<I;R++){const B=S.resolveTriangleIndex(R);st(p,3*B,l,h),p.a.applyMatrix4(e),p.b.applyMatrix4(e),p.c.applyMatrix4(e),p.needsUpdate=!0;for(let P=N,L=N+_;P<L;P++){const U=r.resolveTriangleIndex(P);st(d,3*U,u,c),d.needsUpdate=!0;const W=d.distanceToTriangle(p,f,g);if(W<T&&(m.copy(f),y&&y.copy(g),T=W,w=P,M=R),W<n)return!0}}}})}else{const S=De(t);for(let E=0,F=S;E<F;E++){st(p,3*E,l,h),p.a.applyMatrix4(e),p.b.applyMatrix4(e),p.c.applyMatrix4(e),p.needsUpdate=!0;for(let R=N,I=N+_;R<I;R++){const B=r.resolveTriangleIndex(R);st(d,3*B,u,c),d.needsUpdate=!0;const P=d.distanceToTriangle(p,f,g);if(P<T&&(m.copy(f),y&&y.copy(g),T=P,w=R,M=E),P<n)return!0}}}}}),bt.releasePrimitive(d),bt.releasePrimitive(p),T===1/0?null:(s.point?s.point.copy(m):s.point=m.clone(),s.distance=T,s.faceIndex=w,i&&(i.point?i.point.copy(y):i.point=y.clone(),i.point.applyMatrix4(li),m.applyMatrix4(li),i.distance=m.sub(i.point).length(),i.faceIndex=M),s)}function ol(){return typeof SharedArrayBuffer<"u"}const Ms=new X.constructor,di=new X.constructor,he=new gn(()=>new ht),We=new ht,Ge=new ht,En=new ht,Cn=new ht;let Fn=!1;function al(r,t,e,s){if(Fn)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");Fn=!0;const i=r._roots,n=t._roots;let o,a=0,c=0;const u=new it().copy(e).invert();for(let h=0,l=i.length;h<l;h++){Ms.setBuffer(i[h]),c=0;const d=he.getPrimitive();Z(0,Ms.float32Array,d),d.applyMatrix4(u);for(let p=0,f=n.length;p<f&&(di.setBuffer(n[p]),o=Ot(0,0,e,u,s,a,c,0,0,d),di.clearBuffer(),c+=n[p].length,!o);p++);if(he.releasePrimitive(d),Ms.clearBuffer(),a+=i[h].length,o)break}return Fn=!1,o}function Ot(r,t,e,s,i,n=0,o=0,a=0,c=0,u=null,h=!1){let l,d;h?(l=di,d=Ms):(l=Ms,d=di);const p=l.float32Array,f=l.uint32Array,m=l.uint16Array,g=d.float32Array,y=d.uint32Array,T=d.uint16Array,w=r*2,M=t*2,N=ft(w,m),_=ft(M,T);let S=!1;if(_&&N)h?S=i(Tt(t,y),St(t*2,T),Tt(r,f),St(r*2,m),c,o+t,a,n+r):S=i(Tt(r,f),St(r*2,m),Tt(t,y),St(t*2,T),a,n+r,c,o+t);else if(_){const E=he.getPrimitive();Z(t,g,E),E.applyMatrix4(e);const F=_t(r),R=zt(r,f);Z(F,p,We),Z(R,p,Ge);const I=E.intersectsBox(We),B=E.intersectsBox(Ge);S=I&&Ot(t,F,s,e,i,o,n,c,a+1,E,!h)||B&&Ot(t,R,s,e,i,o,n,c,a+1,E,!h),he.releasePrimitive(E)}else{const E=_t(t),F=zt(t,y);Z(E,g,En),Z(F,g,Cn);const R=u.intersectsBox(En),I=u.intersectsBox(Cn);if(R&&I)S=Ot(r,E,e,s,i,n,o,a,c+1,u,h)||Ot(r,F,e,s,i,n,o,a,c+1,u,h);else if(R)if(N)S=Ot(r,E,e,s,i,n,o,a,c+1,u,h);else{const B=he.getPrimitive();B.copy(En).applyMatrix4(e);const P=_t(r),L=zt(r,f);Z(P,p,We),Z(L,p,Ge);const U=B.intersectsBox(We),W=B.intersectsBox(Ge);S=U&&Ot(E,P,s,e,i,o,n,c,a+1,B,!h)||W&&Ot(E,L,s,e,i,o,n,c,a+1,B,!h),he.releasePrimitive(B)}else if(I)if(N)S=Ot(r,F,e,s,i,n,o,a,c+1,u,h);else{const B=he.getPrimitive();B.copy(Cn).applyMatrix4(e);const P=_t(r),L=zt(r,f);Z(P,p,We),Z(L,p,Ge);const U=B.intersectsBox(We),W=B.intersectsBox(Ge);S=U&&Ot(F,P,s,e,i,o,n,c,a+1,B,!h)||W&&Ot(F,L,s,e,i,o,n,c,a+1,B,!h),he.releasePrimitive(B)}}return S}const pi=new lt,co=new ht,cl={strategy:Gr,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null};class fi{static serialize(t,e={}){e={cloneBuffers:!0,...e};const s=t.geometry,i=t._roots,n=t._indirectBuffer,o=s.getIndex();let a;return e.cloneBuffers?a={roots:i.map(c=>c.slice()),index:o?o.array.slice():null,indirectBuffer:n?n.slice():null}:a={roots:i,index:o?o.array:null,indirectBuffer:n},a}static deserialize(t,e,s={}){s={setIndex:!0,indirect:!!t.indirectBuffer,...s};const{index:i,roots:n,indirectBuffer:o}=t,a=new fi(e,{...s,[un]:!0});if(a._roots=n,a._indirectBuffer=o||null,s.setIndex){const c=e.getIndex();if(c===null){const u=new vt(t.index,1,!1);e.setIndex(u)}else c.array!==i&&(c.array.set(i),c.needsUpdate=!0)}return a}get indirect(){return!!this._indirectBuffer}constructor(t,e={}){if(t.isBufferGeometry){if(t.index&&t.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(e=Object.assign({...cl,[un]:!1},e),e.useSharedArrayBuffer&&!ol())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=t,this._roots=null,this._indirectBuffer=null,e[un]||(Mu(this,e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new ht))),this.resolveTriangleIndex=e.indirect?s=>this._indirectBuffer[s]:s=>s}refit(t=null){return(this.indirect?Ju:Ou)(this,t)}traverse(t,e=0){const s=this._roots[e],i=new Uint32Array(s),n=new Uint16Array(s);o(0);function o(a,c=0){const u=a*2,h=n[u+15]===js;if(h){const l=i[a+6],d=n[u+14];t(c,h,new Float32Array(s,a*4,6),l,d)}else{const l=a+fs/4,d=i[a+6],p=i[a+7];t(c,h,new Float32Array(s,a*4,6),p)||(o(l,c+1),o(d,c+1))}}}raycast(t,e=0,s=0,i=1/0){const n=this._roots,o=this.geometry,a=[],c=e.isMaterial,u=Array.isArray(e),h=o.groups,l=c?e.side:e,d=this.indirect?ju:ku;for(let p=0,f=n.length;p<f;p++){const m=u?e[h[p].materialIndex].side:l,g=a.length;if(d(this,p,m,t,a,s,i),u){const y=h[p].materialIndex;for(let T=g,w=a.length;T<w;T++)a[T].face.materialIndex=y}}return a}raycastFirst(t,e=0,s=0,i=1/0){const n=this._roots,o=this.geometry,a=e.isMaterial,c=Array.isArray(e);let u=null;const h=o.groups,l=a?e.side:e,d=this.indirect?Ku:qu;for(let p=0,f=n.length;p<f;p++){const m=c?e[h[p].materialIndex].side:l,g=d(this,p,m,t,s,i);g!=null&&(u==null||g.distance<u.distance)&&(u=g,c&&(g.face.materialIndex=h[p].materialIndex))}return u}intersectsGeometry(t,e){let s=!1;const i=this._roots,n=this.indirect?tl:$u;for(let o=0,a=i.length;o<a&&(s=n(this,o,t,e),!s);o++);return s}shapecast(t){const e=bt.getPrimitive(),s=this.indirect?Vu:Lu;let{boundsTraverseOrder:i,intersectsBounds:n,intersectsRange:o,intersectsTriangle:a}=t;if(o&&a){const l=o;o=(d,p,f,m,g)=>l(d,p,f,m,g)?!0:s(d,p,this,a,f,m,e)}else o||(a?o=(l,d,p,f)=>s(l,d,this,a,p,f,e):o=(l,d,p)=>p);let c=!1,u=0;const h=this._roots;for(let l=0,d=h.length;l<d;l++){const p=h[l];if(c=Cu(this,l,n,o,i,u),c)break;u+=p.byteLength}return bt.releasePrimitive(e),c}bvhcast(t,e,s){let{intersectsRanges:i,intersectsTriangles:n}=s;const o=bt.getPrimitive(),a=this.geometry.index,c=this.geometry.attributes.position,u=this.indirect?f=>{const m=this.resolveTriangleIndex(f);st(o,m*3,a,c)}:f=>{st(o,f*3,a,c)},h=bt.getPrimitive(),l=t.geometry.index,d=t.geometry.attributes.position,p=t.indirect?f=>{const m=t.resolveTriangleIndex(f);st(h,m*3,l,d)}:f=>{st(h,f*3,l,d)};if(n){const f=(m,g,y,T,w,M,N,_)=>{for(let S=y,E=y+T;S<E;S++){p(S),h.a.applyMatrix4(e),h.b.applyMatrix4(e),h.c.applyMatrix4(e),h.needsUpdate=!0;for(let F=m,R=m+g;F<R;F++)if(u(F),o.needsUpdate=!0,n(o,h,F,S,w,M,N,_))return!0}return!1};if(i){const m=i;i=function(g,y,T,w,M,N,_,S){return m(g,y,T,w,M,N,_,S)?!0:f(g,y,T,w,M,N,_,S)}}else i=f}return al(this,t,e,i)}intersectsBox(t,e){return pi.set(t.min,t.max,e),pi.needsUpdate=!0,this.shapecast({intersectsBounds:s=>pi.intersectsBox(s),intersectsTriangle:s=>pi.intersectsTriangle(s)})}intersectsSphere(t){return this.shapecast({intersectsBounds:e=>t.intersectsBox(e),intersectsTriangle:e=>e.intersectsSphere(t)})}closestPointToGeometry(t,e,s={},i={},n=0,o=1/0){return(this.indirect?rl:Zu)(this,t,e,s,i,n,o)}closestPointToPoint(t,e={},s=0,i=1/0){return Fu(this,t,e,s,i)}getBoundingBox(t){return t.makeEmpty(),this._roots.forEach(s=>{Z(0,new Float32Array(s),co),t.union(co)}),t}}onmessage=({data:r})=>{let t=performance.now();function e(o){o=Math.min(o,1);const a=performance.now();a-t>=10&&o!==1&&(postMessage({error:null,serialized:null,position:null,progress:o}),t=a)}const{index:s,position:i,options:n}=r;try{const o=new Li;if(o.setAttribute("position",new vt(i,3,!1)),s&&o.setIndex(new vt(s,1,!1)),n.includedProgressCallback&&(n.onProgress=e),n.groups){const h=n.groups;for(const l in h){const d=h[l];o.addGroup(d.start,d.count,d.materialIndex)}}const a=new fi(o,n),c=fi.serialize(a,{copyIndexBuffer:!1});let u=[i.buffer,...c.roots];c.index&&u.push(c.index.buffer),u=u.filter(h=>typeof SharedArrayBuffer>"u"||!(h instanceof SharedArrayBuffer)),a._indirectBuffer&&u.push(c.indirectBuffer.buffer),postMessage({error:null,serialized:c,position:i,progress:1},u)}catch(o){postMessage({error:o,serialized:null,position:null,progress:1})}}})();
|