@needle-tools/engine 4.7.2-alpha → 4.7.2-next.6f2cd71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3782 -3782
- package/LICENSE.md +10 -10
- package/README.md +64 -64
- package/components.needle.json +1 -1
- package/dist/generateMeshBVH.worker-BaNp_Xtp.js +25 -0
- package/dist/{gltf-progressive-zdhlW609.umd.cjs → gltf-progressive-B9o1T8Vr.umd.cjs} +1 -1
- package/dist/{gltf-progressive-YjtQYFa9.js → gltf-progressive-DO0SisAM.js} +2 -2
- package/dist/{gltf-progressive-yOP1mp5W.min.js → gltf-progressive-DQF10PJE.min.js} +1 -1
- package/dist/{needle-engine.bundle-BhDF-YSv.min.js → needle-engine.bundle-B-NoV0t_.min.js} +64 -64
- package/dist/{needle-engine.bundle-D2myV4E4.umd.cjs → needle-engine.bundle-BMnlxDfi.umd.cjs} +59 -59
- package/dist/{needle-engine.bundle-gp00DTS4.js → needle-engine.bundle-CFi0ugBx.js} +638 -638
- package/dist/needle-engine.d.ts +130 -129
- package/dist/needle-engine.js +4 -4
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/dist/{postprocessing-8AQTeZsr.umd.cjs → postprocessing-CjW23fio.umd.cjs} +2 -2
- package/dist/{postprocessing-BkxN_08g.js → postprocessing-DYLNOL3W.js} +3 -3
- package/dist/{postprocessing-BDScN9yu.min.js → postprocessing-xYQWCHFu.min.js} +2 -2
- package/dist/{three-DMrv-4ar.umd.cjs → three-B_hneGZr.umd.cjs} +4 -4
- package/dist/{three-Bz6X1mrw.js → three-DrqIzZTH.js} +4198 -4198
- package/dist/{three-Boa-jOq-.min.js → three-DuDKwKB8.min.js} +33 -33
- package/dist/{three-examples-GggCDHv0.js → three-examples-B50TT3Iu.js} +5 -5
- package/dist/{three-examples-DuVhxqft.min.js → three-examples-DaDLBuy6.min.js} +14 -14
- package/dist/{three-examples-C7ryg8vN.umd.cjs → three-examples-X3OadjXB.umd.cjs} +3 -3
- package/dist/{three-mesh-ui-CY6Izc7C.min.js → three-mesh-ui-B3p3gyUz.min.js} +1 -1
- package/dist/{three-mesh-ui-CwlN0FUC.umd.cjs → three-mesh-ui-CQiIQIlA.umd.cjs} +1 -1
- package/dist/{three-mesh-ui-CLNOfsWn.js → three-mesh-ui-CxuWt7m-.js} +1 -1
- package/dist/{vendor-zxXa3Dmr.min.js → vendor-BlSxe9JJ.min.js} +3 -3
- package/dist/{vendor-BSD1RQIh.js → vendor-BmYIgaS1.js} +3 -3
- package/dist/{vendor-DHr4aqIZ.umd.cjs → vendor-Cavtu3CP.umd.cjs} +3 -3
- package/lib/asap/needle-asap.d.ts +1 -1
- package/lib/asap/needle-asap.js +95 -95
- package/lib/asap/sessiongranted.d.ts +3 -3
- package/lib/asap/sessiongranted.js +65 -65
- package/lib/asap/utils.d.ts +1 -1
- package/lib/asap/utils.js +3 -3
- package/lib/engine/analytics/index.d.ts +6 -6
- package/lib/engine/analytics/index.js +12 -12
- package/lib/engine/analytics/lcp.d.ts +3 -3
- package/lib/engine/analytics/lcp.js +34 -34
- package/lib/engine/api.d.ts +82 -82
- package/lib/engine/api.js +81 -81
- package/lib/engine/assets/index.d.ts +11 -11
- package/lib/engine/assets/index.js +47 -47
- package/lib/engine/assets/static.d.ts +1 -1
- package/lib/engine/assets/static.js +4 -4
- package/lib/engine/codegen/register_types.d.ts +1 -1
- package/lib/engine/codegen/register_types.js +300 -300
- package/lib/engine/debug/debug.d.ts +15 -15
- package/lib/engine/debug/debug.js +44 -44
- package/lib/engine/debug/debug_console.d.ts +2 -2
- package/lib/engine/debug/debug_console.js +307 -307
- package/lib/engine/debug/debug_overlay.d.ts +22 -22
- package/lib/engine/debug/debug_overlay.js +316 -316
- package/lib/engine/debug/debug_spatial_console.d.ts +2 -2
- package/lib/engine/debug/debug_spatial_console.js +390 -390
- package/lib/engine/debug/index.d.ts +2 -2
- package/lib/engine/debug/index.js +2 -2
- package/lib/engine/engine_addressables.d.ts +164 -164
- package/lib/engine/engine_addressables.js +601 -601
- package/lib/engine/engine_animation.d.ts +43 -43
- package/lib/engine/engine_animation.js +133 -133
- package/lib/engine/engine_application.d.ts +45 -45
- package/lib/engine/engine_application.js +104 -104
- package/lib/engine/engine_assetdatabase.d.ts +25 -25
- package/lib/engine/engine_assetdatabase.js +346 -346
- package/lib/engine/engine_audio.d.ts +4 -4
- package/lib/engine/engine_audio.js +23 -23
- package/lib/engine/engine_camera.d.ts +13 -13
- package/lib/engine/engine_camera.js +30 -30
- package/lib/engine/engine_components.d.ts +110 -110
- package/lib/engine/engine_components.js +374 -374
- package/lib/engine/engine_components_internal.d.ts +9 -9
- package/lib/engine/engine_components_internal.js +36 -36
- package/lib/engine/engine_constants.d.ts +10 -10
- package/lib/engine/engine_constants.js +41 -41
- package/lib/engine/engine_context.d.ts +475 -475
- package/lib/engine/engine_context.js +1673 -1673
- package/lib/engine/engine_context_registry.d.ts +71 -71
- package/lib/engine/engine_context_registry.js +117 -117
- package/lib/engine/engine_coroutine.d.ts +35 -35
- package/lib/engine/engine_coroutine.js +52 -52
- package/lib/engine/engine_create_objects.d.ts +119 -119
- package/lib/engine/engine_create_objects.js +320 -320
- package/lib/engine/engine_default_parameters.d.ts +2 -2
- package/lib/engine/engine_default_parameters.js +3 -3
- package/lib/engine/engine_editor-sync.d.ts +21 -21
- package/lib/engine/engine_editor-sync.js +4 -4
- package/lib/engine/engine_fileloader.d.ts +2 -2
- package/lib/engine/engine_fileloader.js +8 -8
- package/lib/engine/engine_gameobject.d.ts +68 -68
- package/lib/engine/engine_gameobject.js +619 -619
- package/lib/engine/engine_generic_utils.d.ts +1 -1
- package/lib/engine/engine_generic_utils.js +13 -13
- package/lib/engine/engine_gizmos.d.ts +149 -149
- package/lib/engine/engine_gizmos.js +530 -530
- package/lib/engine/engine_gltf.d.ts +12 -12
- package/lib/engine/engine_gltf.js +15 -15
- package/lib/engine/engine_gltf_builtin_components.d.ts +11 -11
- package/lib/engine/engine_gltf_builtin_components.js +341 -341
- package/lib/engine/engine_hot_reload.d.ts +8 -8
- package/lib/engine/engine_hot_reload.js +197 -197
- package/lib/engine/engine_input.d.ts +362 -362
- package/lib/engine/engine_input.js +1294 -1294
- package/lib/engine/engine_input_utils.d.ts +2 -2
- package/lib/engine/engine_input_utils.js +22 -22
- package/lib/engine/engine_instancing.d.ts +19 -19
- package/lib/engine/engine_instancing.js +39 -39
- package/lib/engine/engine_license.d.ts +11 -11
- package/lib/engine/engine_license.js +369 -369
- package/lib/engine/engine_lifecycle_api.d.ts +83 -83
- package/lib/engine/engine_lifecycle_api.js +106 -106
- package/lib/engine/engine_lifecycle_functions_internal.d.ts +32 -32
- package/lib/engine/engine_lifecycle_functions_internal.js +146 -146
- package/lib/engine/engine_lightdata.d.ts +23 -23
- package/lib/engine/engine_lightdata.js +101 -101
- package/lib/engine/engine_loaders.callbacks.d.ts +97 -97
- package/lib/engine/engine_loaders.callbacks.js +86 -86
- package/lib/engine/engine_loaders.d.ts +48 -48
- package/lib/engine/engine_loaders.gltf.d.ts +13 -13
- package/lib/engine/engine_loaders.gltf.js +62 -62
- package/lib/engine/engine_loaders.js +337 -337
- package/lib/engine/engine_lods.d.ts +35 -35
- package/lib/engine/engine_lods.js +160 -160
- package/lib/engine/engine_mainloop_utils.d.ts +32 -32
- package/lib/engine/engine_mainloop_utils.js +466 -466
- package/lib/engine/engine_math.d.ts +114 -114
- package/lib/engine/engine_math.js +247 -247
- package/lib/engine/engine_modules.d.ts +36 -36
- package/lib/engine/engine_modules.js +85 -85
- package/lib/engine/engine_networking.d.ts +260 -260
- package/lib/engine/engine_networking.js +764 -764
- package/lib/engine/engine_networking_auto.d.ts +24 -24
- package/lib/engine/engine_networking_auto.js +310 -310
- package/lib/engine/engine_networking_blob.d.ts +48 -48
- package/lib/engine/engine_networking_blob.js +228 -228
- package/lib/engine/engine_networking_files.d.ts +35 -35
- package/lib/engine/engine_networking_files.js +172 -172
- package/lib/engine/engine_networking_files_default_components.d.ts +6 -6
- package/lib/engine/engine_networking_files_default_components.js +42 -42
- package/lib/engine/engine_networking_instantiate.d.ts +100 -100
- package/lib/engine/engine_networking_instantiate.js +345 -345
- package/lib/engine/engine_networking_peer.d.ts +15 -15
- package/lib/engine/engine_networking_peer.js +132 -132
- package/lib/engine/engine_networking_streams.d.ts +123 -123
- package/lib/engine/engine_networking_streams.js +645 -645
- package/lib/engine/engine_networking_types.d.ts +22 -22
- package/lib/engine/engine_networking_types.js +7 -7
- package/lib/engine/engine_networking_utils.d.ts +2 -2
- package/lib/engine/engine_networking_utils.js +20 -20
- package/lib/engine/engine_networking_websocket.d.ts +1 -1
- package/lib/engine/engine_networking_websocket.js +2 -2
- package/lib/engine/engine_patcher.d.ts +10 -10
- package/lib/engine/engine_patcher.js +142 -142
- package/lib/engine/engine_physics.d.ts +152 -152
- package/lib/engine/engine_physics.js +645 -645
- package/lib/engine/engine_physics.types.d.ts +40 -40
- package/lib/engine/engine_physics.types.js +33 -33
- package/lib/engine/engine_physics_rapier.d.ts +147 -147
- package/lib/engine/engine_physics_rapier.js +1433 -1433
- package/lib/engine/engine_playerview.d.ts +26 -26
- package/lib/engine/engine_playerview.js +64 -64
- package/lib/engine/engine_scenelighting.d.ts +71 -71
- package/lib/engine/engine_scenelighting.js +226 -226
- package/lib/engine/engine_serialization.d.ts +3 -3
- package/lib/engine/engine_serialization.js +3 -3
- package/lib/engine/engine_serialization_builtin_serializer.d.ts +72 -72
- package/lib/engine/engine_serialization_builtin_serializer.js +403 -403
- package/lib/engine/engine_serialization_core.d.ts +94 -94
- package/lib/engine/engine_serialization_core.js +607 -607
- package/lib/engine/engine_serialization_decorator.d.ts +23 -23
- package/lib/engine/engine_serialization_decorator.js +66 -66
- package/lib/engine/engine_setup.d.ts +1 -1
- package/lib/engine/engine_setup.js +2 -2
- package/lib/engine/engine_shaders.d.ts +53 -53
- package/lib/engine/engine_shaders.js +252 -252
- package/lib/engine/engine_shims.d.ts +4 -4
- package/lib/engine/engine_shims.js +24 -24
- package/lib/engine/engine_test_utils.d.ts +39 -39
- package/lib/engine/engine_test_utils.js +83 -83
- package/lib/engine/engine_texture.d.ts +28 -28
- package/lib/engine/engine_texture.js +64 -64
- package/lib/engine/engine_three_utils.d.ts +204 -204
- package/lib/engine/engine_three_utils.js +788 -788
- package/lib/engine/engine_time.d.ts +51 -51
- package/lib/engine/engine_time.js +82 -82
- package/lib/engine/engine_time_utils.d.ts +88 -88
- package/lib/engine/engine_time_utils.js +215 -215
- package/lib/engine/engine_tonemapping.d.ts +6 -6
- package/lib/engine/engine_tonemapping.js +197 -197
- package/lib/engine/engine_types.d.ts +578 -578
- package/lib/engine/engine_types.js +95 -95
- package/lib/engine/engine_typestore.d.ts +28 -28
- package/lib/engine/engine_typestore.js +55 -55
- package/lib/engine/engine_util_decorator.d.ts +13 -13
- package/lib/engine/engine_util_decorator.js +116 -116
- package/lib/engine/engine_utils.d.ts +248 -248
- package/lib/engine/engine_utils.js +1012 -1012
- package/lib/engine/engine_utils_format.d.ts +24 -24
- package/lib/engine/engine_utils_format.js +239 -239
- package/lib/engine/engine_utils_screenshot.d.ts +159 -159
- package/lib/engine/engine_utils_screenshot.js +522 -522
- package/lib/engine/engine_utils_screenshot.xr.d.ts +5 -5
- package/lib/engine/engine_utils_screenshot.xr.js +90 -90
- package/lib/engine/engine_xr.d.ts +1 -1
- package/lib/engine/engine_xr.js +1 -1
- package/lib/engine/export/gltf/Writers.d.ts +19 -19
- package/lib/engine/export/gltf/Writers.js +24 -24
- package/lib/engine/export/gltf/index.d.ts +11 -11
- package/lib/engine/export/gltf/index.js +123 -123
- package/lib/engine/export/index.d.ts +2 -2
- package/lib/engine/export/index.js +2 -2
- package/lib/engine/export/state.d.ts +7 -7
- package/lib/engine/export/state.js +17 -17
- package/lib/engine/export/utils.d.ts +2 -2
- package/lib/engine/export/utils.js +7 -7
- package/lib/engine/extensions/EXT_texture_exr.d.ts +8 -8
- package/lib/engine/extensions/EXT_texture_exr.js +32 -32
- package/lib/engine/extensions/NEEDLE_animator_controller_model.d.ts +122 -122
- package/lib/engine/extensions/NEEDLE_animator_controller_model.js +95 -95
- package/lib/engine/extensions/NEEDLE_components.d.ts +35 -35
- package/lib/engine/extensions/NEEDLE_components.js +220 -220
- package/lib/engine/extensions/NEEDLE_gameobject_data.d.ts +10 -10
- package/lib/engine/extensions/NEEDLE_gameobject_data.js +57 -57
- package/lib/engine/extensions/NEEDLE_lighting_settings.d.ts +37 -37
- package/lib/engine/extensions/NEEDLE_lighting_settings.js +157 -157
- package/lib/engine/extensions/NEEDLE_lightmaps.d.ts +18 -18
- package/lib/engine/extensions/NEEDLE_lightmaps.js +99 -99
- package/lib/engine/extensions/NEEDLE_persistent_assets.d.ts +11 -11
- package/lib/engine/extensions/NEEDLE_persistent_assets.js +63 -63
- package/lib/engine/extensions/NEEDLE_progressive.d.ts +1 -1
- package/lib/engine/extensions/NEEDLE_progressive.js +1 -1
- package/lib/engine/extensions/NEEDLE_render_objects.d.ts +13 -13
- package/lib/engine/extensions/NEEDLE_render_objects.js +159 -159
- package/lib/engine/extensions/NEEDLE_techniques_webgl.d.ts +38 -38
- package/lib/engine/extensions/NEEDLE_techniques_webgl.js +564 -564
- package/lib/engine/extensions/extension_resolver.d.ts +4 -4
- package/lib/engine/extensions/extension_resolver.js +1 -1
- package/lib/engine/extensions/extension_utils.d.ts +12 -12
- package/lib/engine/extensions/extension_utils.js +152 -152
- package/lib/engine/extensions/extensions.d.ts +32 -32
- package/lib/engine/extensions/extensions.js +107 -107
- package/lib/engine/extensions/index.d.ts +6 -6
- package/lib/engine/extensions/index.js +6 -6
- package/lib/engine/extensions/usage_tracker.d.ts +13 -13
- package/lib/engine/extensions/usage_tracker.js +65 -65
- package/lib/engine/js-extensions/Camera.d.ts +1 -1
- package/lib/engine/js-extensions/Camera.js +39 -39
- package/lib/engine/js-extensions/ExtensionUtils.d.ts +9 -9
- package/lib/engine/js-extensions/ExtensionUtils.js +67 -67
- package/lib/engine/js-extensions/Layers.d.ts +6 -6
- package/lib/engine/js-extensions/Layers.js +22 -22
- package/lib/engine/js-extensions/Object3D.d.ts +120 -120
- package/lib/engine/js-extensions/Object3D.js +136 -136
- package/lib/engine/js-extensions/RGBAColor.d.ts +23 -23
- package/lib/engine/js-extensions/RGBAColor.js +111 -111
- package/lib/engine/js-extensions/Vector.d.ts +3 -3
- package/lib/engine/js-extensions/Vector.js +13 -13
- package/lib/engine/js-extensions/index.d.ts +5 -5
- package/lib/engine/js-extensions/index.js +5 -5
- package/lib/engine/physics/workers/mesh-bvh/GenerateMeshBVHWorker.d.ts +4 -4
- package/lib/engine/physics/workers/mesh-bvh/GenerateMeshBVHWorker.js +79 -79
- package/lib/engine/shaders/shaderData.d.ts +55 -55
- package/lib/engine/shaders/shaderData.js +58 -58
- package/lib/engine/tests/test_utils.d.ts +2 -2
- package/lib/engine/tests/test_utils.js +53 -53
- package/lib/engine/webcomponents/WebXRButtons.d.ts +56 -56
- package/lib/engine/webcomponents/WebXRButtons.js +230 -230
- package/lib/engine/webcomponents/api.d.ts +5 -5
- package/lib/engine/webcomponents/api.js +4 -4
- package/lib/engine/webcomponents/buttons.d.ts +51 -51
- package/lib/engine/webcomponents/buttons.js +264 -264
- package/lib/engine/webcomponents/fonts.d.ts +9 -9
- package/lib/engine/webcomponents/fonts.js +32 -32
- package/lib/engine/webcomponents/icons.d.ts +9 -9
- package/lib/engine/webcomponents/icons.js +52 -52
- package/lib/engine/webcomponents/index.d.ts +1 -1
- package/lib/engine/webcomponents/index.js +1 -1
- package/lib/engine/webcomponents/logo-element.d.ts +10 -10
- package/lib/engine/webcomponents/logo-element.js +67 -67
- package/lib/engine/webcomponents/needle menu/needle-menu-spatial.d.ts +37 -37
- package/lib/engine/webcomponents/needle menu/needle-menu-spatial.js +513 -513
- package/lib/engine/webcomponents/needle menu/needle-menu.d.ts +155 -155
- package/lib/engine/webcomponents/needle menu/needle-menu.js +1029 -1029
- package/lib/engine/webcomponents/needle-button.d.ts +34 -34
- package/lib/engine/webcomponents/needle-button.js +161 -161
- package/lib/engine/webcomponents/needle-engine.ar-overlay.d.ts +21 -21
- package/lib/engine/webcomponents/needle-engine.ar-overlay.js +166 -166
- package/lib/engine/webcomponents/needle-engine.attributes.d.ts +69 -69
- package/lib/engine/webcomponents/needle-engine.attributes.js +1 -1
- package/lib/engine/webcomponents/needle-engine.d.ts +116 -116
- package/lib/engine/webcomponents/needle-engine.extras.d.ts +6 -6
- package/lib/engine/webcomponents/needle-engine.extras.js +13 -13
- package/lib/engine/webcomponents/needle-engine.js +821 -821
- package/lib/engine/webcomponents/needle-engine.loading.d.ts +44 -44
- package/lib/engine/webcomponents/needle-engine.loading.js +341 -341
- package/lib/engine/xr/NeedleXRController.d.ts +313 -313
- package/lib/engine/xr/NeedleXRController.js +1007 -1007
- package/lib/engine/xr/NeedleXRSession.d.ts +340 -340
- package/lib/engine/xr/NeedleXRSession.js +1463 -1463
- package/lib/engine/xr/NeedleXRSync.d.ts +22 -22
- package/lib/engine/xr/NeedleXRSync.js +188 -188
- package/lib/engine/xr/SceneTransition.d.ts +18 -18
- package/lib/engine/xr/SceneTransition.js +69 -69
- package/lib/engine/xr/TempXRContext.d.ts +34 -34
- package/lib/engine/xr/TempXRContext.js +187 -187
- package/lib/engine/xr/XRRig.d.ts +7 -7
- package/lib/engine/xr/XRRig.js +1 -1
- package/lib/engine/xr/api.d.ts +6 -6
- package/lib/engine/xr/api.js +6 -6
- package/lib/engine/xr/events.d.ts +66 -66
- package/lib/engine/xr/events.js +93 -93
- package/lib/engine/xr/internal.d.ts +12 -12
- package/lib/engine/xr/internal.js +25 -25
- package/lib/engine/xr/usdz.d.ts +12 -12
- package/lib/engine/xr/usdz.js +29 -29
- package/lib/engine/xr/utils.d.ts +11 -11
- package/lib/engine/xr/utils.js +34 -34
- package/lib/engine-components/AlignmentConstraint.d.ts +10 -10
- package/lib/engine-components/AlignmentConstraint.js +39 -39
- package/lib/engine-components/Animation.d.ts +156 -156
- package/lib/engine-components/Animation.js +508 -508
- package/lib/engine-components/AnimationCurve.d.ts +40 -40
- package/lib/engine-components/AnimationCurve.js +159 -159
- package/lib/engine-components/AnimationUtils.d.ts +8 -8
- package/lib/engine-components/AnimationUtils.js +27 -27
- package/lib/engine-components/AnimationUtilsAutoplay.d.ts +1 -1
- package/lib/engine-components/AnimationUtilsAutoplay.js +39 -39
- package/lib/engine-components/Animator.d.ts +217 -217
- package/lib/engine-components/Animator.js +354 -354
- package/lib/engine-components/AnimatorController.d.ts +227 -227
- package/lib/engine-components/AnimatorController.js +1152 -1152
- package/lib/engine-components/AudioListener.d.ts +33 -33
- package/lib/engine-components/AudioListener.js +86 -86
- package/lib/engine-components/AudioSource.d.ts +217 -217
- package/lib/engine-components/AudioSource.js +635 -635
- package/lib/engine-components/AvatarLoader.d.ts +80 -80
- package/lib/engine-components/AvatarLoader.js +231 -231
- package/lib/engine-components/AxesHelper.d.ts +32 -32
- package/lib/engine-components/AxesHelper.js +67 -67
- package/lib/engine-components/BasicIKConstraint.d.ts +9 -9
- package/lib/engine-components/BasicIKConstraint.js +43 -43
- package/lib/engine-components/BoxCollider.d.ts +2 -2
- package/lib/engine-components/BoxCollider.js +2 -2
- package/lib/engine-components/BoxHelperComponent.d.ts +47 -47
- package/lib/engine-components/BoxHelperComponent.js +102 -102
- package/lib/engine-components/Camera.d.ts +231 -231
- package/lib/engine-components/Camera.js +700 -700
- package/lib/engine-components/CameraUtils.d.ts +1 -1
- package/lib/engine-components/CameraUtils.js +123 -123
- package/lib/engine-components/CharacterController.d.ts +55 -55
- package/lib/engine-components/CharacterController.js +236 -236
- package/lib/engine-components/Collider.d.ts +188 -188
- package/lib/engine-components/Collider.js +369 -369
- package/lib/engine-components/Component.d.ts +792 -792
- package/lib/engine-components/Component.js +920 -920
- package/lib/engine-components/ContactShadows.d.ts +94 -94
- package/lib/engine-components/ContactShadows.js +453 -453
- package/lib/engine-components/DeleteBox.d.ts +19 -19
- package/lib/engine-components/DeleteBox.js +58 -58
- package/lib/engine-components/DeviceFlag.d.ts +16 -16
- package/lib/engine-components/DeviceFlag.js +47 -47
- package/lib/engine-components/DragControls.d.ts +170 -170
- package/lib/engine-components/DragControls.js +1421 -1421
- package/lib/engine-components/DropListener.d.ts +215 -215
- package/lib/engine-components/DropListener.js +642 -642
- package/lib/engine-components/Duplicatable.d.ts +35 -35
- package/lib/engine-components/Duplicatable.js +202 -202
- package/lib/engine-components/EventList.d.ts +54 -54
- package/lib/engine-components/EventList.js +232 -232
- package/lib/engine-components/EventTrigger.d.ts +33 -33
- package/lib/engine-components/EventTrigger.js +75 -75
- package/lib/engine-components/EventType.d.ts +22 -22
- package/lib/engine-components/EventType.js +23 -23
- package/lib/engine-components/Fog.d.ts +22 -22
- package/lib/engine-components/Fog.js +61 -61
- package/lib/engine-components/Gizmos.d.ts +17 -17
- package/lib/engine-components/Gizmos.js +64 -64
- package/lib/engine-components/GridHelper.d.ts +20 -20
- package/lib/engine-components/GridHelper.js +54 -54
- package/lib/engine-components/GroundProjection.d.ts +67 -67
- package/lib/engine-components/GroundProjection.js +343 -343
- package/lib/engine-components/Interactable.d.ts +12 -12
- package/lib/engine-components/Interactable.js +12 -12
- package/lib/engine-components/Joints.d.ts +19 -19
- package/lib/engine-components/Joints.js +51 -51
- package/lib/engine-components/LODGroup.d.ts +35 -35
- package/lib/engine-components/LODGroup.js +152 -152
- package/lib/engine-components/Light.d.ts +180 -180
- package/lib/engine-components/Light.js +535 -535
- package/lib/engine-components/LookAtConstraint.d.ts +19 -19
- package/lib/engine-components/LookAtConstraint.js +35 -35
- package/lib/engine-components/NeedleMenu.d.ts +50 -50
- package/lib/engine-components/NeedleMenu.js +92 -92
- package/lib/engine-components/NestedGltf.d.ts +25 -25
- package/lib/engine-components/NestedGltf.js +88 -88
- package/lib/engine-components/Networking.d.ts +54 -54
- package/lib/engine-components/Networking.js +112 -112
- package/lib/engine-components/OffsetConstraint.d.ts +14 -14
- package/lib/engine-components/OffsetConstraint.js +65 -65
- package/lib/engine-components/OrbitControls.d.ts +268 -268
- package/lib/engine-components/OrbitControls.js +1015 -1015
- package/lib/engine-components/PlayerColor.d.ts +19 -19
- package/lib/engine-components/PlayerColor.js +94 -94
- package/lib/engine-components/ReflectionProbe.d.ts +28 -28
- package/lib/engine-components/ReflectionProbe.js +204 -204
- package/lib/engine-components/Renderer.d.ts +153 -153
- package/lib/engine-components/Renderer.js +834 -834
- package/lib/engine-components/RendererInstancing.d.ts +140 -140
- package/lib/engine-components/RendererInstancing.js +744 -744
- package/lib/engine-components/RendererLightmap.d.ts +24 -24
- package/lib/engine-components/RendererLightmap.js +182 -182
- package/lib/engine-components/RigidBody.d.ts +155 -155
- package/lib/engine-components/RigidBody.js +517 -517
- package/lib/engine-components/SceneSwitcher.d.ts +263 -263
- package/lib/engine-components/SceneSwitcher.js +971 -971
- package/lib/engine-components/ScreenCapture.d.ts +144 -144
- package/lib/engine-components/ScreenCapture.js +547 -547
- package/lib/engine-components/ShadowCatcher.d.ts +33 -33
- package/lib/engine-components/ShadowCatcher.js +166 -166
- package/lib/engine-components/Skybox.d.ts +88 -88
- package/lib/engine-components/Skybox.js +469 -469
- package/lib/engine-components/SmoothFollow.d.ts +34 -34
- package/lib/engine-components/SmoothFollow.js +82 -82
- package/lib/engine-components/SpatialTrigger.d.ts +102 -102
- package/lib/engine-components/SpatialTrigger.js +225 -225
- package/lib/engine-components/SpectatorCamera.d.ts +111 -111
- package/lib/engine-components/SpectatorCamera.js +715 -715
- package/lib/engine-components/SphereCollider.d.ts +2 -2
- package/lib/engine-components/SphereCollider.js +2 -2
- package/lib/engine-components/SpriteRenderer.d.ts +132 -132
- package/lib/engine-components/SpriteRenderer.js +472 -472
- package/lib/engine-components/SyncedCamera.d.ts +41 -41
- package/lib/engine-components/SyncedCamera.js +199 -199
- package/lib/engine-components/SyncedRoom.d.ts +106 -106
- package/lib/engine-components/SyncedRoom.js +371 -371
- package/lib/engine-components/SyncedTransform.d.ts +94 -94
- package/lib/engine-components/SyncedTransform.js +331 -331
- package/lib/engine-components/TestRunner.d.ts +16 -16
- package/lib/engine-components/TestRunner.js +102 -102
- package/lib/engine-components/TransformGizmo.d.ts +75 -75
- package/lib/engine-components/TransformGizmo.js +209 -209
- package/lib/engine-components/VideoPlayer.d.ts +184 -184
- package/lib/engine-components/VideoPlayer.js +978 -978
- package/lib/engine-components/Voip.d.ts +67 -67
- package/lib/engine-components/Voip.js +360 -360
- package/lib/engine-components/api.d.ts +51 -51
- package/lib/engine-components/api.js +50 -50
- package/lib/engine-components/avatar/AvatarBlink_Simple.d.ts +11 -11
- package/lib/engine-components/avatar/AvatarBlink_Simple.js +76 -76
- package/lib/engine-components/avatar/AvatarEyeLook_Rotation.d.ts +14 -14
- package/lib/engine-components/avatar/AvatarEyeLook_Rotation.js +68 -68
- package/lib/engine-components/avatar/Avatar_Brain_LookAt.d.ts +29 -29
- package/lib/engine-components/avatar/Avatar_Brain_LookAt.js +121 -121
- package/lib/engine-components/avatar/Avatar_MouthShapes.d.ts +15 -15
- package/lib/engine-components/avatar/Avatar_MouthShapes.js +79 -79
- package/lib/engine-components/avatar/Avatar_MustacheShake.d.ts +9 -9
- package/lib/engine-components/avatar/Avatar_MustacheShake.js +29 -29
- package/lib/engine-components/codegen/components.d.ts +216 -216
- package/lib/engine-components/codegen/components.js +218 -218
- package/lib/engine-components/debug/LogStats.d.ts +5 -5
- package/lib/engine-components/debug/LogStats.js +18 -18
- package/lib/engine-components/export/gltf/GltfExport.d.ts +30 -30
- package/lib/engine-components/export/gltf/GltfExport.js +246 -246
- package/lib/engine-components/export/gltf/index.d.ts +1 -1
- package/lib/engine-components/export/gltf/index.js +1 -1
- package/lib/engine-components/export/index.d.ts +1 -1
- package/lib/engine-components/export/index.js +1 -1
- package/lib/engine-components/export/usdz/Extension.d.ts +22 -22
- package/lib/engine-components/export/usdz/Extension.js +1 -1
- package/lib/engine-components/export/usdz/ThreeUSDZExporter.d.ts +162 -162
- package/lib/engine-components/export/usdz/ThreeUSDZExporter.js +1789 -1789
- package/lib/engine-components/export/usdz/USDZExporter.d.ts +130 -130
- package/lib/engine-components/export/usdz/USDZExporter.js +663 -663
- package/lib/engine-components/export/usdz/extensions/Animation.d.ts +106 -106
- package/lib/engine-components/export/usdz/extensions/Animation.js +1071 -1071
- package/lib/engine-components/export/usdz/extensions/DocumentExtension.d.ts +5 -5
- package/lib/engine-components/export/usdz/extensions/DocumentExtension.js +6 -6
- package/lib/engine-components/export/usdz/extensions/NodeMaterialConverter.d.ts +10 -10
- package/lib/engine-components/export/usdz/extensions/NodeMaterialConverter.js +451 -451
- package/lib/engine-components/export/usdz/extensions/USDZText.d.ts +54 -54
- package/lib/engine-components/export/usdz/extensions/USDZText.js +203 -203
- package/lib/engine-components/export/usdz/extensions/USDZUI.d.ts +8 -8
- package/lib/engine-components/export/usdz/extensions/USDZUI.js +158 -158
- package/lib/engine-components/export/usdz/extensions/behavior/Actions.d.ts +30 -30
- package/lib/engine-components/export/usdz/extensions/behavior/Actions.js +88 -88
- package/lib/engine-components/export/usdz/extensions/behavior/AudioExtension.d.ts +10 -10
- package/lib/engine-components/export/usdz/extensions/behavior/AudioExtension.js +86 -86
- package/lib/engine-components/export/usdz/extensions/behavior/Behaviour.d.ts +28 -28
- package/lib/engine-components/export/usdz/extensions/behavior/Behaviour.js +290 -290
- package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.d.ts +190 -190
- package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.js +1060 -1060
- package/lib/engine-components/export/usdz/extensions/behavior/BehavioursBuilder.d.ts +135 -135
- package/lib/engine-components/export/usdz/extensions/behavior/BehavioursBuilder.js +548 -548
- package/lib/engine-components/export/usdz/extensions/behavior/PhysicsExtension.d.ts +7 -7
- package/lib/engine-components/export/usdz/extensions/behavior/PhysicsExtension.js +115 -115
- package/lib/engine-components/export/usdz/index.d.ts +3 -3
- package/lib/engine-components/export/usdz/index.js +2 -2
- package/lib/engine-components/export/usdz/utils/animationutils.d.ts +7 -7
- package/lib/engine-components/export/usdz/utils/animationutils.js +163 -163
- package/lib/engine-components/export/usdz/utils/quicklook.d.ts +2 -2
- package/lib/engine-components/export/usdz/utils/quicklook.js +43 -43
- package/lib/engine-components/particlesystem/ParticleSystem.d.ts +177 -177
- package/lib/engine-components/particlesystem/ParticleSystem.js +1176 -1176
- package/lib/engine-components/particlesystem/ParticleSystemModules.d.ts +526 -526
- package/lib/engine-components/particlesystem/ParticleSystemModules.js +1930 -1930
- package/lib/engine-components/particlesystem/ParticleSystemSubEmitter.d.ts +25 -25
- package/lib/engine-components/particlesystem/ParticleSystemSubEmitter.js +87 -87
- package/lib/engine-components/particlesystem/api.d.ts +2 -2
- package/lib/engine-components/particlesystem/api.js +2 -2
- package/lib/engine-components/postprocessing/Effects/Antialiasing.d.ts +17 -17
- package/lib/engine-components/postprocessing/Effects/Antialiasing.js +59 -59
- package/lib/engine-components/postprocessing/Effects/BloomEffect.d.ts +46 -46
- package/lib/engine-components/postprocessing/Effects/BloomEffect.js +113 -113
- package/lib/engine-components/postprocessing/Effects/ChromaticAberration.d.ts +11 -11
- package/lib/engine-components/postprocessing/Effects/ChromaticAberration.js +39 -39
- package/lib/engine-components/postprocessing/Effects/ColorAdjustments.d.ts +23 -23
- package/lib/engine-components/postprocessing/Effects/ColorAdjustments.js +111 -111
- package/lib/engine-components/postprocessing/Effects/DepthOfField.d.ts +25 -25
- package/lib/engine-components/postprocessing/Effects/DepthOfField.js +104 -104
- package/lib/engine-components/postprocessing/Effects/EffectWrapper.d.ts +12 -12
- package/lib/engine-components/postprocessing/Effects/EffectWrapper.js +18 -18
- package/lib/engine-components/postprocessing/Effects/Pixelation.d.ts +11 -11
- package/lib/engine-components/postprocessing/Effects/Pixelation.js +32 -32
- package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusion.d.ts +18 -18
- package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusion.js +91 -91
- package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusionN8.d.ts +70 -70
- package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusionN8.js +176 -176
- package/lib/engine-components/postprocessing/Effects/Sharpening.d.ts +18 -18
- package/lib/engine-components/postprocessing/Effects/Sharpening.js +127 -127
- package/lib/engine-components/postprocessing/Effects/TiltShiftEffect.d.ts +17 -17
- package/lib/engine-components/postprocessing/Effects/TiltShiftEffect.js +70 -70
- package/lib/engine-components/postprocessing/Effects/Tonemapping.d.ts +19 -19
- package/lib/engine-components/postprocessing/Effects/Tonemapping.js +94 -94
- package/lib/engine-components/postprocessing/Effects/Tonemapping.utils.d.ts +13 -13
- package/lib/engine-components/postprocessing/Effects/Tonemapping.utils.js +51 -51
- package/lib/engine-components/postprocessing/Effects/Vignette.d.ts +15 -15
- package/lib/engine-components/postprocessing/Effects/Vignette.js +60 -60
- package/lib/engine-components/postprocessing/PostProcessingEffect.d.ts +90 -90
- package/lib/engine-components/postprocessing/PostProcessingEffect.js +168 -168
- package/lib/engine-components/postprocessing/PostProcessingHandler.d.ts +42 -42
- package/lib/engine-components/postprocessing/PostProcessingHandler.js +494 -494
- package/lib/engine-components/postprocessing/Volume.d.ts +90 -90
- package/lib/engine-components/postprocessing/Volume.js +385 -385
- package/lib/engine-components/postprocessing/VolumeParameter.d.ts +26 -26
- package/lib/engine-components/postprocessing/VolumeParameter.js +136 -136
- package/lib/engine-components/postprocessing/VolumeProfile.d.ts +15 -15
- package/lib/engine-components/postprocessing/VolumeProfile.js +60 -60
- package/lib/engine-components/postprocessing/index.d.ts +6 -6
- package/lib/engine-components/postprocessing/index.js +6 -6
- package/lib/engine-components/postprocessing/utils.d.ts +55 -55
- package/lib/engine-components/postprocessing/utils.js +119 -119
- package/lib/engine-components/timeline/PlayableDirector.d.ts +163 -163
- package/lib/engine-components/timeline/PlayableDirector.js +686 -686
- package/lib/engine-components/timeline/SignalAsset.d.ts +24 -24
- package/lib/engine-components/timeline/SignalAsset.js +130 -130
- package/lib/engine-components/timeline/TimelineModels.d.ts +89 -89
- package/lib/engine-components/timeline/TimelineModels.js +22 -22
- package/lib/engine-components/timeline/TimelineTracks.d.ts +110 -110
- package/lib/engine-components/timeline/TimelineTracks.js +879 -879
- package/lib/engine-components/timeline/index.d.ts +4 -4
- package/lib/engine-components/timeline/index.js +3 -3
- package/lib/engine-components/ui/BaseUIComponent.d.ts +48 -48
- package/lib/engine-components/ui/BaseUIComponent.js +170 -170
- package/lib/engine-components/ui/Button.d.ts +64 -64
- package/lib/engine-components/ui/Button.js +315 -315
- package/lib/engine-components/ui/Canvas.d.ts +74 -74
- package/lib/engine-components/ui/Canvas.js +407 -407
- package/lib/engine-components/ui/CanvasGroup.d.ts +19 -19
- package/lib/engine-components/ui/CanvasGroup.js +58 -58
- package/lib/engine-components/ui/EventSystem.d.ts +125 -125
- package/lib/engine-components/ui/EventSystem.js +765 -765
- package/lib/engine-components/ui/Graphic.d.ts +55 -55
- package/lib/engine-components/ui/Graphic.js +255 -255
- package/lib/engine-components/ui/Image.d.ts +35 -35
- package/lib/engine-components/ui/Image.js +116 -116
- package/lib/engine-components/ui/InputField.d.ts +42 -42
- package/lib/engine-components/ui/InputField.js +268 -268
- package/lib/engine-components/ui/Interfaces.d.ts +38 -38
- package/lib/engine-components/ui/Interfaces.js +12 -12
- package/lib/engine-components/ui/Layout.d.ts +84 -84
- package/lib/engine-components/ui/Layout.js +330 -330
- package/lib/engine-components/ui/Outline.d.ts +7 -7
- package/lib/engine-components/ui/Outline.js +20 -20
- package/lib/engine-components/ui/PointerEvents.d.ts +115 -115
- package/lib/engine-components/ui/PointerEvents.js +145 -145
- package/lib/engine-components/ui/RaycastUtils.d.ts +11 -11
- package/lib/engine-components/ui/RaycastUtils.js +67 -67
- package/lib/engine-components/ui/Raycaster.d.ts +30 -30
- package/lib/engine-components/ui/Raycaster.js +95 -95
- package/lib/engine-components/ui/RectTransform.d.ts +61 -61
- package/lib/engine-components/ui/RectTransform.js +356 -356
- package/lib/engine-components/ui/SpatialHtml.d.ts +8 -8
- package/lib/engine-components/ui/SpatialHtml.js +79 -79
- package/lib/engine-components/ui/Symbols.d.ts +1 -1
- package/lib/engine-components/ui/Symbols.js +1 -1
- package/lib/engine-components/ui/Text.d.ts +78 -78
- package/lib/engine-components/ui/Text.js +539 -539
- package/lib/engine-components/ui/Utils.d.ts +24 -24
- package/lib/engine-components/ui/Utils.js +90 -90
- package/lib/engine-components/ui/index.d.ts +1 -1
- package/lib/engine-components/ui/index.js +1 -1
- package/lib/engine-components/utils/EnvironmentScene.d.ts +5 -5
- package/lib/engine-components/utils/EnvironmentScene.js +205 -205
- package/lib/engine-components/utils/LookAt.d.ts +31 -31
- package/lib/engine-components/utils/LookAt.js +82 -82
- package/lib/engine-components/utils/OpenURL.d.ts +42 -42
- package/lib/engine-components/utils/OpenURL.js +119 -119
- package/lib/engine-components/webxr/Avatar.d.ts +25 -25
- package/lib/engine-components/webxr/Avatar.js +255 -255
- package/lib/engine-components/webxr/TeleportTarget.d.ts +7 -7
- package/lib/engine-components/webxr/TeleportTarget.js +7 -7
- package/lib/engine-components/webxr/WebARCameraBackground.d.ts +30 -30
- package/lib/engine-components/webxr/WebARCameraBackground.js +155 -155
- package/lib/engine-components/webxr/WebARSessionRoot.d.ts +98 -98
- package/lib/engine-components/webxr/WebARSessionRoot.js +770 -770
- package/lib/engine-components/webxr/WebXR.d.ts +232 -232
- package/lib/engine-components/webxr/WebXR.js +561 -561
- package/lib/engine-components/webxr/WebXRAvatar.d.ts +27 -27
- package/lib/engine-components/webxr/WebXRAvatar.js +44 -44
- package/lib/engine-components/webxr/WebXRImageTracking.d.ts +86 -86
- package/lib/engine-components/webxr/WebXRImageTracking.js +471 -471
- package/lib/engine-components/webxr/WebXRPlaneTracking.d.ts +92 -92
- package/lib/engine-components/webxr/WebXRPlaneTracking.js +500 -500
- package/lib/engine-components/webxr/WebXRRig.d.ts +32 -32
- package/lib/engine-components/webxr/WebXRRig.js +72 -72
- package/lib/engine-components/webxr/XRFlag.d.ts +38 -38
- package/lib/engine-components/webxr/XRFlag.js +139 -139
- package/lib/engine-components/webxr/controllers/XRControllerFollow.d.ts +47 -47
- package/lib/engine-components/webxr/controllers/XRControllerFollow.js +120 -120
- package/lib/engine-components/webxr/controllers/XRControllerModel.d.ts +43 -43
- package/lib/engine-components/webxr/controllers/XRControllerModel.js +352 -352
- package/lib/engine-components/webxr/controllers/XRControllerMovement.d.ts +78 -78
- package/lib/engine-components/webxr/controllers/XRControllerMovement.js +506 -506
- package/lib/engine-components/webxr/index.d.ts +3 -3
- package/lib/engine-components/webxr/index.js +3 -3
- package/lib/engine-components/webxr/types.d.ts +3 -3
- package/lib/engine-components/webxr/types.js +1 -1
- package/lib/engine-components-experimental/Presentation.d.ts +6 -6
- package/lib/engine-components-experimental/Presentation.js +9 -9
- package/lib/engine-components-experimental/api.d.ts +4 -4
- package/lib/engine-components-experimental/api.js +4 -4
- package/lib/engine-components-experimental/networking/PlayerSync.d.ts +156 -156
- package/lib/engine-components-experimental/networking/PlayerSync.js +377 -377
- package/lib/engine-schemes/api.d.ts +12 -12
- package/lib/engine-schemes/api.js +12 -12
- package/lib/engine-schemes/schemes.d.ts +7 -7
- package/lib/engine-schemes/schemes.js +19 -19
- package/lib/engine-schemes/synced-camera-model.d.ts +25 -25
- package/lib/engine-schemes/synced-camera-model.js +67 -67
- package/lib/engine-schemes/synced-transform-model.d.ts +31 -31
- package/lib/engine-schemes/synced-transform-model.js +66 -66
- package/lib/engine-schemes/transform.d.ts +12 -12
- package/lib/engine-schemes/transform.js +39 -39
- package/lib/engine-schemes/vec2.d.ts +10 -10
- package/lib/engine-schemes/vec2.js +25 -25
- package/lib/engine-schemes/vec3.d.ts +11 -11
- package/lib/engine-schemes/vec3.js +29 -29
- package/lib/engine-schemes/vec4.d.ts +12 -12
- package/lib/engine-schemes/vec4.js +33 -33
- package/lib/engine-schemes/vr-user-state-buffer.d.ts +37 -37
- package/lib/engine-schemes/vr-user-state-buffer.js +110 -110
- package/lib/include/three/EXT_mesh_gpu_instancing_exporter.d.ts +6 -6
- package/lib/include/three/EXT_mesh_gpu_instancing_exporter.js +45 -45
- package/lib/needle-engine.d.ts +7 -7
- package/lib/needle-engine.js +64 -64
- package/package.json +3 -3
- package/plugins/common/buildinfo.js +64 -64
- package/plugins/common/cloud.js +1 -1
- package/plugins/common/config.cjs +31 -31
- package/plugins/common/config.js +35 -35
- package/plugins/common/files.js +31 -31
- package/plugins/common/generator.js +10 -10
- package/plugins/common/license.js +452 -452
- package/plugins/common/logger.js +327 -327
- package/plugins/common/npm.js +15 -15
- package/plugins/common/timers.js +7 -7
- package/plugins/common/version.js +37 -37
- package/plugins/gltf-packer.mjs +1 -1
- package/plugins/next/alias.cjs +39 -39
- package/plugins/next/license.cjs +24 -24
- package/plugins/next/meshbvhworker.cjs +18 -18
- package/plugins/next/next.js +141 -141
- package/plugins/types/index.d.ts +2 -2
- package/plugins/types/license.d.ts +24 -24
- package/plugins/types/needleConfig.d.ts +27 -27
- package/plugins/types/next.d.ts +2 -2
- package/plugins/types/userconfig.d.ts +124 -124
- package/plugins/types/vite.d.ts +13 -13
- package/plugins/types/webmanifest.d.ts +32 -32
- package/plugins/vite/alias.js +189 -189
- package/plugins/vite/asap.js +251 -251
- package/plugins/vite/build-pipeline.js +371 -371
- package/plugins/vite/build.js +19 -19
- package/plugins/vite/buildinfo.js +41 -41
- package/plugins/vite/config.js +106 -106
- package/plugins/vite/copyfiles.js +138 -138
- package/plugins/vite/defines.js +70 -70
- package/plugins/vite/dependencies.js +232 -232
- package/plugins/vite/dependency-watcher.js +237 -237
- package/plugins/vite/drop-client.js +76 -76
- package/plugins/vite/drop.js +87 -87
- package/plugins/vite/editor-connection.js +124 -124
- package/plugins/vite/facebook-instant-games.js +102 -102
- package/plugins/vite/gzip.js +5 -5
- package/plugins/vite/imports-logger.js +143 -143
- package/plugins/vite/index.js +147 -147
- package/plugins/vite/license.js +56 -56
- package/plugins/vite/local-files.js +440 -440
- package/plugins/vite/logger.client.js +272 -272
- package/plugins/vite/logger.js +100 -100
- package/plugins/vite/materialx.js +31 -31
- package/plugins/vite/meta.js +163 -163
- package/plugins/vite/npm.js +7 -7
- package/plugins/vite/peer.js +29 -29
- package/plugins/vite/poster-client.js +73 -73
- package/plugins/vite/poster.js +79 -79
- package/plugins/vite/pwa.js +604 -604
- package/plugins/vite/reload-client.js +15 -15
- package/plugins/vite/reload.js +351 -351
- package/plugins/vite/server.js +66 -66
- package/plugins/vite/transform-codegen.js +55 -55
- package/plugins/vite/transform.js +32 -32
- package/plugins/vite/vite-4.4-hack.js +31 -31
- package/src/asap/needle-asap.ts +111 -111
- package/src/asap/sessiongranted.ts +75 -75
- package/src/asap/utils.ts +4 -4
- package/src/engine/analytics/index.ts +10 -10
- package/src/engine/analytics/lcp.ts +35 -35
- package/src/engine/api.ts +82 -82
- package/src/engine/assets/index.ts +59 -59
- package/src/engine/assets/static.js +5 -5
- package/src/engine/codegen/register_types.ts +300 -300
- package/src/engine/debug/debug.ts +51 -51
- package/src/engine/debug/debug_console.ts +333 -333
- package/src/engine/debug/debug_overlay.ts +332 -332
- package/src/engine/debug/debug_spatial_console.ts +429 -429
- package/src/engine/debug/index.ts +1 -1
- package/src/engine/engine_addressables.ts +671 -671
- package/src/engine/engine_animation.ts +145 -145
- package/src/engine/engine_application.ts +113 -113
- package/src/engine/engine_assetdatabase.ts +389 -389
- package/src/engine/engine_audio.ts +24 -24
- package/src/engine/engine_camera.ts +39 -39
- package/src/engine/engine_components.ts +366 -366
- package/src/engine/engine_components_internal.ts +40 -40
- package/src/engine/engine_constants.ts +52 -52
- package/src/engine/engine_context.ts +1824 -1824
- package/src/engine/engine_context_registry.ts +129 -129
- package/src/engine/engine_coroutine.ts +54 -54
- package/src/engine/engine_create_objects.ts +411 -411
- package/src/engine/engine_default_parameters.ts +3 -3
- package/src/engine/engine_editor-sync.ts +28 -28
- package/src/engine/engine_fileloader.js +9 -9
- package/src/engine/engine_gameobject.ts +712 -712
- package/src/engine/engine_generic_utils.js +13 -13
- package/src/engine/engine_gizmos.ts +577 -577
- package/src/engine/engine_gltf.ts +29 -29
- package/src/engine/engine_gltf_builtin_components.ts +403 -403
- package/src/engine/engine_hot_reload.ts +210 -210
- package/src/engine/engine_input.ts +1500 -1500
- package/src/engine/engine_input_utils.ts +23 -23
- package/src/engine/engine_instancing.ts +45 -45
- package/src/engine/engine_license.ts +386 -386
- package/src/engine/engine_lifecycle_api.ts +113 -113
- package/src/engine/engine_lifecycle_functions_internal.ts +193 -193
- package/src/engine/engine_lightdata.ts +125 -125
- package/src/engine/engine_loaders.callbacks.ts +136 -136
- package/src/engine/engine_loaders.gltf.ts +82 -82
- package/src/engine/engine_loaders.ts +378 -378
- package/src/engine/engine_lods.ts +186 -186
- package/src/engine/engine_mainloop_utils.ts +472 -472
- package/src/engine/engine_math.ts +282 -282
- package/src/engine/engine_modules.ts +83 -83
- package/src/engine/engine_networking.ts +862 -862
- package/src/engine/engine_networking_auto.ts +352 -352
- package/src/engine/engine_networking_blob.ts +275 -275
- package/src/engine/engine_networking_files.ts +217 -217
- package/src/engine/engine_networking_files_default_components.ts +58 -58
- package/src/engine/engine_networking_instantiate.ts +419 -419
- package/src/engine/engine_networking_peer.ts +159 -159
- package/src/engine/engine_networking_streams.ts +713 -713
- package/src/engine/engine_networking_types.ts +24 -24
- package/src/engine/engine_networking_utils.ts +23 -23
- package/src/engine/engine_networking_websocket.ts +2 -2
- package/src/engine/engine_patcher.ts +199 -199
- package/src/engine/engine_physics.ts +783 -783
- package/src/engine/engine_physics.types.ts +46 -46
- package/src/engine/engine_physics_rapier.ts +1577 -1577
- package/src/engine/engine_playerview.ts +80 -80
- package/src/engine/engine_scenelighting.ts +294 -294
- package/src/engine/engine_serialization.ts +2 -2
- package/src/engine/engine_serialization_builtin_serializer.ts +473 -473
- package/src/engine/engine_serialization_core.ts +720 -720
- package/src/engine/engine_serialization_decorator.ts +80 -80
- package/src/engine/engine_setup.ts +1 -1
- package/src/engine/engine_shaders.ts +267 -267
- package/src/engine/engine_shims.ts +32 -32
- package/src/engine/engine_test_utils.ts +109 -109
- package/src/engine/engine_texture.ts +82 -82
- package/src/engine/engine_three_utils.ts +928 -928
- package/src/engine/engine_time.ts +94 -94
- package/src/engine/engine_time_utils.ts +237 -237
- package/src/engine/engine_tonemapping.ts +208 -208
- package/src/engine/engine_types.ts +730 -730
- package/src/engine/engine_typestore.ts +63 -63
- package/src/engine/engine_util_decorator.ts +136 -136
- package/src/engine/engine_utils.ts +1115 -1115
- package/src/engine/engine_utils_format.ts +273 -273
- package/src/engine/engine_utils_screenshot.ts +708 -708
- package/src/engine/engine_utils_screenshot.xr.ts +103 -103
- package/src/engine/export/gltf/Writers.ts +34 -34
- package/src/engine/export/gltf/index.ts +158 -158
- package/src/engine/export/index.ts +2 -2
- package/src/engine/export/state.ts +19 -19
- package/src/engine/export/utils.ts +9 -9
- package/src/engine/extensions/EXT_texture_exr.ts +50 -50
- package/src/engine/extensions/NEEDLE_animator_controller_model.ts +195 -195
- package/src/engine/extensions/NEEDLE_components.ts +268 -268
- package/src/engine/extensions/NEEDLE_gameobject_data.ts +81 -81
- package/src/engine/extensions/NEEDLE_lighting_settings.ts +185 -185
- package/src/engine/extensions/NEEDLE_lightmaps.ts +119 -119
- package/src/engine/extensions/NEEDLE_persistent_assets.ts +76 -76
- package/src/engine/extensions/NEEDLE_render_objects.ts +209 -209
- package/src/engine/extensions/NEEDLE_techniques_webgl.ts +640 -640
- package/src/engine/extensions/extension_resolver.ts +4 -4
- package/src/engine/extensions/extension_utils.ts +166 -166
- package/src/engine/extensions/extensions.ts +140 -140
- package/src/engine/extensions/index.ts +5 -5
- package/src/engine/extensions/usage_tracker.ts +100 -100
- package/src/engine/js-extensions/Camera.ts +37 -37
- package/src/engine/js-extensions/ExtensionUtils.ts +85 -85
- package/src/engine/js-extensions/Layers.ts +23 -23
- package/src/engine/js-extensions/Object3D.ts +296 -296
- package/src/engine/js-extensions/RGBAColor.ts +126 -126
- package/src/engine/js-extensions/Vector.ts +18 -18
- package/src/engine/js-extensions/index.ts +4 -4
- package/src/engine/physics/workers/mesh-bvh/GenerateMeshBVHWorker.js +125 -125
- package/src/engine/shaders/shaderData.ts +67 -67
- package/src/engine/tests/test_utils.ts +63 -63
- package/src/engine/webcomponents/WebXRButtons.ts +260 -260
- package/src/engine/webcomponents/api.ts +6 -6
- package/src/engine/webcomponents/buttons.ts +292 -292
- package/src/engine/webcomponents/fonts.ts +41 -41
- package/src/engine/webcomponents/icons.ts +57 -57
- package/src/engine/webcomponents/index.ts +1 -1
- package/src/engine/webcomponents/logo-element.ts +78 -78
- package/src/engine/webcomponents/needle menu/needle-menu-spatial.ts +573 -573
- package/src/engine/webcomponents/needle menu/needle-menu.ts +1118 -1118
- package/src/engine/webcomponents/needle-button.ts +181 -181
- package/src/engine/webcomponents/needle-engine.ar-overlay.ts +186 -186
- package/src/engine/webcomponents/needle-engine.attributes.ts +82 -82
- package/src/engine/webcomponents/needle-engine.extras.ts +16 -16
- package/src/engine/webcomponents/needle-engine.loading.ts +373 -373
- package/src/engine/webcomponents/needle-engine.ts +860 -860
- package/src/engine/xr/NeedleXRController.ts +1125 -1125
- package/src/engine/xr/NeedleXRSession.ts +1624 -1624
- package/src/engine/xr/NeedleXRSync.ts +220 -220
- package/src/engine/xr/SceneTransition.ts +78 -78
- package/src/engine/xr/TempXRContext.ts +216 -216
- package/src/engine/xr/XRRig.ts +9 -9
- package/src/engine/xr/api.ts +5 -5
- package/src/engine/xr/events.ts +102 -102
- package/src/engine/xr/internal.ts +34 -34
- package/src/engine/xr/usdz.ts +30 -30
- package/src/engine/xr/utils.ts +39 -39
- package/src/engine-components/AlignmentConstraint.ts +36 -36
- package/src/engine-components/Animation.ts +557 -557
- package/src/engine-components/AnimationCurve.ts +150 -150
- package/src/engine-components/AnimationUtils.ts +28 -28
- package/src/engine-components/AnimationUtilsAutoplay.ts +43 -43
- package/src/engine-components/Animator.ts +397 -397
- package/src/engine-components/AnimatorController.ts +1293 -1293
- package/src/engine-components/AudioListener.ts +92 -92
- package/src/engine-components/AudioSource.ts +644 -644
- package/src/engine-components/AvatarLoader.ts +263 -263
- package/src/engine-components/AxesHelper.ts +59 -59
- package/src/engine-components/BasicIKConstraint.ts +54 -54
- package/src/engine-components/BoxCollider.ts +1 -1
- package/src/engine-components/BoxHelperComponent.ts +114 -114
- package/src/engine-components/Camera.ts +719 -719
- package/src/engine-components/CameraUtils.ts +138 -138
- package/src/engine-components/CharacterController.ts +253 -253
- package/src/engine-components/Collider.ts +374 -374
- package/src/engine-components/Component.ts +1297 -1297
- package/src/engine-components/ContactShadows.ts +506 -506
- package/src/engine-components/DeleteBox.ts +62 -62
- package/src/engine-components/DeviceFlag.ts +46 -46
- package/src/engine-components/DragControls.ts +1623 -1623
- package/src/engine-components/DropListener.ts +713 -713
- package/src/engine-components/Duplicatable.ts +198 -198
- package/src/engine-components/EventList.ts +266 -266
- package/src/engine-components/EventTrigger.ts +74 -74
- package/src/engine-components/EventType.ts +22 -22
- package/src/engine-components/Fog.ts +60 -60
- package/src/engine-components/Gizmos.ts +56 -56
- package/src/engine-components/GridHelper.ts +48 -48
- package/src/engine-components/GroundProjection.ts +356 -356
- package/src/engine-components/Interactable.ts +14 -14
- package/src/engine-components/Joints.ts +52 -52
- package/src/engine-components/LODGroup.ts +153 -153
- package/src/engine-components/Light.ts +558 -558
- package/src/engine-components/LookAtConstraint.ts +25 -25
- package/src/engine-components/NeedleMenu.ts +84 -84
- package/src/engine-components/NestedGltf.ts +86 -86
- package/src/engine-components/Networking.ts +114 -114
- package/src/engine-components/OffsetConstraint.ts +60 -60
- package/src/engine-components/OrbitControls.ts +1074 -1074
- package/src/engine-components/PlayerColor.ts +103 -103
- package/src/engine-components/ReflectionProbe.ts +220 -220
- package/src/engine-components/Renderer.ts +903 -903
- package/src/engine-components/RendererInstancing.ts +855 -855
- package/src/engine-components/RendererLightmap.ts +198 -198
- package/src/engine-components/RigidBody.ts +526 -526
- package/src/engine-components/SceneSwitcher.ts +1030 -1030
- package/src/engine-components/ScreenCapture.ts +592 -592
- package/src/engine-components/ShadowCatcher.ts +172 -172
- package/src/engine-components/Skybox.ts +475 -475
- package/src/engine-components/SmoothFollow.ts +76 -76
- package/src/engine-components/SpatialTrigger.ts +229 -229
- package/src/engine-components/SpectatorCamera.ts +787 -787
- package/src/engine-components/SphereCollider.ts +1 -1
- package/src/engine-components/SpriteRenderer.ts +468 -468
- package/src/engine-components/SyncedCamera.ts +220 -220
- package/src/engine-components/SyncedRoom.ts +380 -380
- package/src/engine-components/SyncedTransform.ts +383 -383
- package/src/engine-components/TestRunner.ts +118 -118
- package/src/engine-components/TransformGizmo.ts +219 -219
- package/src/engine-components/VideoPlayer.ts +1025 -1025
- package/src/engine-components/Voip.ts +363 -363
- package/src/engine-components/api.ts +60 -60
- package/src/engine-components/avatar/AvatarBlink_Simple.ts +69 -69
- package/src/engine-components/avatar/AvatarEyeLook_Rotation.ts +63 -63
- package/src/engine-components/avatar/Avatar_Brain_LookAt.ts +139 -139
- package/src/engine-components/avatar/Avatar_MouthShapes.ts +83 -83
- package/src/engine-components/avatar/Avatar_MustacheShake.ts +31 -31
- package/src/engine-components/codegen/components.ts +217 -217
- package/src/engine-components/debug/LogStats.ts +21 -21
- package/src/engine-components/export/gltf/GltfExport.ts +265 -265
- package/src/engine-components/export/usdz/Extension.ts +24 -24
- package/src/engine-components/export/usdz/ThreeUSDZExporter.ts +2426 -2426
- package/src/engine-components/export/usdz/USDZExporter.ts +705 -705
- package/src/engine-components/export/usdz/extensions/Animation.ts +1204 -1204
- package/src/engine-components/export/usdz/extensions/DocumentExtension.ts +9 -9
- package/src/engine-components/export/usdz/extensions/NodeMaterialConverter.ts +532 -532
- package/src/engine-components/export/usdz/extensions/USDZText.ts +240 -240
- package/src/engine-components/export/usdz/extensions/USDZUI.ts +189 -189
- package/src/engine-components/export/usdz/extensions/behavior/Actions.ts +99 -99
- package/src/engine-components/export/usdz/extensions/behavior/AudioExtension.ts +102 -102
- package/src/engine-components/export/usdz/extensions/behavior/Behaviour.ts +320 -320
- package/src/engine-components/export/usdz/extensions/behavior/BehaviourComponents.ts +1225 -1225
- package/src/engine-components/export/usdz/extensions/behavior/BehavioursBuilder.ts +646 -646
- package/src/engine-components/export/usdz/extensions/behavior/PhysicsExtension.ts +132 -132
- package/src/engine-components/export/usdz/index.ts +2 -2
- package/src/engine-components/export/usdz/utils/animationutils.ts +191 -191
- package/src/engine-components/export/usdz/utils/quicklook.ts +50 -50
- package/src/engine-components/particlesystem/ParticleSystem.ts +1287 -1287
- package/src/engine-components/particlesystem/ParticleSystemModules.ts +1765 -1765
- package/src/engine-components/particlesystem/ParticleSystemSubEmitter.ts +111 -111
- package/src/engine-components/particlesystem/api.ts +1 -1
- package/src/engine-components/postprocessing/Effects/Antialiasing.ts +64 -64
- package/src/engine-components/postprocessing/Effects/BloomEffect.ts +116 -116
- package/src/engine-components/postprocessing/Effects/ChromaticAberration.ts +37 -37
- package/src/engine-components/postprocessing/Effects/ColorAdjustments.ts +106 -106
- package/src/engine-components/postprocessing/Effects/DepthOfField.ts +103 -103
- package/src/engine-components/postprocessing/Effects/EffectWrapper.ts +25 -25
- package/src/engine-components/postprocessing/Effects/Pixelation.ts +32 -32
- package/src/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusion.ts +90 -90
- package/src/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusionN8.ts +192 -192
- package/src/engine-components/postprocessing/Effects/Sharpening.ts +143 -143
- package/src/engine-components/postprocessing/Effects/TiltShiftEffect.ts +61 -61
- package/src/engine-components/postprocessing/Effects/Tonemapping.ts +103 -103
- package/src/engine-components/postprocessing/Effects/Tonemapping.utils.ts +60 -60
- package/src/engine-components/postprocessing/Effects/Vignette.ts +59 -59
- package/src/engine-components/postprocessing/PostProcessingEffect.ts +192 -192
- package/src/engine-components/postprocessing/PostProcessingHandler.ts +572 -572
- package/src/engine-components/postprocessing/Volume.ts +426 -426
- package/src/engine-components/postprocessing/VolumeParameter.ts +158 -158
- package/src/engine-components/postprocessing/VolumeProfile.ts +61 -61
- package/src/engine-components/postprocessing/index.ts +5 -5
- package/src/engine-components/postprocessing/utils.ts +154 -154
- package/src/engine-components/timeline/PlayableDirector.ts +722 -722
- package/src/engine-components/timeline/SignalAsset.ts +144 -144
- package/src/engine-components/timeline/TimelineModels.ts +92 -92
- package/src/engine-components/timeline/TimelineTracks.ts +967 -967
- package/src/engine-components/timeline/index.ts +3 -3
- package/src/engine-components/ui/BaseUIComponent.ts +203 -203
- package/src/engine-components/ui/Button.ts +307 -307
- package/src/engine-components/ui/Canvas.ts +419 -419
- package/src/engine-components/ui/CanvasGroup.ts +54 -54
- package/src/engine-components/ui/EventSystem.ts +854 -854
- package/src/engine-components/ui/Graphic.ts +275 -275
- package/src/engine-components/ui/Image.ts +112 -112
- package/src/engine-components/ui/InputField.ts +321 -321
- package/src/engine-components/ui/Interfaces.ts +57 -57
- package/src/engine-components/ui/Layout.ts +334 -334
- package/src/engine-components/ui/Outline.ts +13 -13
- package/src/engine-components/ui/PointerEvents.ts +206 -206
- package/src/engine-components/ui/RaycastUtils.ts +69 -69
- package/src/engine-components/ui/Raycaster.ts +102 -102
- package/src/engine-components/ui/RectTransform.ts +375 -375
- package/src/engine-components/ui/SpatialHtml.ts +79 -79
- package/src/engine-components/ui/Symbols.ts +1 -1
- package/src/engine-components/ui/Text.ts +578 -578
- package/src/engine-components/ui/Utils.ts +113 -113
- package/src/engine-components/utils/EnvironmentScene.ts +245 -245
- package/src/engine-components/utils/LookAt.ts +88 -88
- package/src/engine-components/utils/OpenURL.ts +114 -114
- package/src/engine-components/webxr/Avatar.ts +265 -265
- package/src/engine-components/webxr/TeleportTarget.ts +9 -9
- package/src/engine-components/webxr/WebARCameraBackground.ts +175 -175
- package/src/engine-components/webxr/WebARSessionRoot.ts +880 -880
- package/src/engine-components/webxr/WebXR.ts +585 -585
- package/src/engine-components/webxr/WebXRAvatar.ts +66 -66
- package/src/engine-components/webxr/WebXRImageTracking.ts +519 -519
- package/src/engine-components/webxr/WebXRPlaneTracking.ts +570 -570
- package/src/engine-components/webxr/WebXRRig.ts +77 -77
- package/src/engine-components/webxr/XRFlag.ts +147 -147
- package/src/engine-components/webxr/controllers/XRControllerFollow.ts +118 -118
- package/src/engine-components/webxr/controllers/XRControllerModel.ts +373 -373
- package/src/engine-components/webxr/controllers/XRControllerMovement.ts +550 -550
- package/src/engine-components/webxr/index.ts +2 -2
- package/src/engine-components/webxr/types.ts +3 -3
- package/src/engine-components-experimental/Presentation.ts +12 -12
- package/src/engine-components-experimental/api.ts +4 -4
- package/src/engine-components-experimental/networking/PlayerSync.ts +401 -401
- package/src/engine-schemes/COMPILE_SCHEMES.bat +3 -3
- package/src/engine-schemes/COMPILE_TS.bat +11 -11
- package/src/engine-schemes/README.md +1 -1
- package/src/engine-schemes/api.ts +12 -12
- package/src/engine-schemes/schemes.ts +28 -28
- package/src/engine-schemes/synced-camera-model.ts +92 -92
- package/src/engine-schemes/synced-transform-model.ts +90 -90
- package/src/engine-schemes/syncedCamera.fbs +10 -10
- package/src/engine-schemes/transform.ts +50 -50
- package/src/engine-schemes/transforms.fbs +25 -25
- package/src/engine-schemes/vec.fbs +19 -19
- package/src/engine-schemes/vec2.ts +33 -33
- package/src/engine-schemes/vec3.ts +38 -38
- package/src/engine-schemes/vec4.ts +43 -43
- package/src/engine-schemes/vr-user-state-buffer.ts +145 -145
- package/src/engine-schemes/vrUserStateBuffer.fbs +17 -17
- package/src/include/draco/draco_decoder.js +34 -34
- package/src/include/ktx2/basis_transcoder.js +21 -21
- package/src/include/needle/arial-msdf.json +1471 -1471
- package/src/include/three/DragControls.js +231 -231
- package/src/include/three/EXT_mesh_gpu_instancing_exporter.js +66 -66
- package/src/needle-engine.ts +70 -70
- package/dist/generateMeshBVH.worker-Cdfpaq5W.js +0 -25
- package/src/engine-schemes/dist/api.js +0 -17
- package/src/engine-schemes/dist/api.js.meta +0 -7
- package/src/engine-schemes/dist/schemes.js +0 -25
- package/src/engine-schemes/dist/schemes.js.meta +0 -7
- package/src/engine-schemes/dist/synced-camera-model.js +0 -74
- package/src/engine-schemes/dist/synced-camera-model.js.meta +0 -7
- package/src/engine-schemes/dist/synced-transform-model.js +0 -73
- package/src/engine-schemes/dist/synced-transform-model.js.meta +0 -7
- package/src/engine-schemes/dist/transform.js +0 -46
- package/src/engine-schemes/dist/transform.js.meta +0 -7
- package/src/engine-schemes/dist/vec2.js +0 -32
- package/src/engine-schemes/dist/vec2.js.meta +0 -7
- package/src/engine-schemes/dist/vec3.js +0 -36
- package/src/engine-schemes/dist/vec3.js.meta +0 -7
- package/src/engine-schemes/dist/vec4.js +0 -40
- package/src/engine-schemes/dist/vec4.js.meta +0 -7
- package/src/engine-schemes/dist/vr-user-state-buffer.js +0 -110
- package/src/engine-schemes/dist/vr-user-state-buffer.js.meta +0 -7
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const M=require("./three-DMrv-4ar.umd.cjs"),st={ComponentState:Object.freeze({DEFAULT:"default",TOUCHED:"touched",PRESSED:"pressed"}),ComponentProperty:Object.freeze({BUTTON:"button",X_AXIS:"xAxis",Y_AXIS:"yAxis",STATE:"state"}),ButtonTouchThreshold:.05,AxisTouchThreshold:.1,VisualResponseProperty:Object.freeze({TRANSFORM:"transform",VISIBILITY:"visibility"})};async function uo(n){const t=await fetch(n);if(t.ok)return t.json();throw new Error(t.statusText)}async function ga(n){return await uo(`${n}/profilesList.json`)}async function va(n,t,e=null,i=!0){if(!n)throw new Error("No xrInputSource supplied");const r=await ga(t);let s;if(n.profiles.some(c=>{const l=r[c];return l&&(s={profileId:c,profilePath:`${t}/${l.path}`,deprecated:!!l.deprecated}),!!s}),!s){if(!e)throw new Error("No matching profile name found");const c=r[e];if(!c)throw new Error(`No matching profile name found and default profile "${e}" missing.`);s={profileId:e,profilePath:`${t}/${c.path}`,deprecated:!!c.deprecated}}const a=await uo(s.profilePath);let o;if(i){let c;if(n.handedness==="any"?c=a.layouts[Object.keys(a.layouts)[0]]:c=a.layouts[n.handedness],!c)throw new Error(`No matching handedness, ${n.handedness}, in profile ${s.profileId}`);c.assetPath&&(o=s.profilePath.replace("profile.json",c.assetPath))}return{profile:a,assetPath:o}}const _a={xAxis:0,yAxis:0,button:0,state:st.ComponentState.DEFAULT};function xa(n=0,t=0){let e=n,i=t;if(Math.sqrt(n*n+t*t)>1){const a=Math.atan2(t,n);e=Math.cos(a),i=Math.sin(a)}return{normalizedXAxis:e*.5+.5,normalizedYAxis:i*.5+.5}}class Sa{constructor(t){this.componentProperty=t.componentProperty,this.states=t.states,this.valueNodeName=t.valueNodeName,this.valueNodeProperty=t.valueNodeProperty,this.valueNodeProperty===st.VisualResponseProperty.TRANSFORM&&(this.minNodeName=t.minNodeName,this.maxNodeName=t.maxNodeName),this.value=0,this.updateFromComponent(_a)}updateFromComponent({xAxis:t,yAxis:e,button:i,state:r}){const{normalizedXAxis:s,normalizedYAxis:a}=xa(t,e);switch(this.componentProperty){case st.ComponentProperty.X_AXIS:this.value=this.states.includes(r)?s:.5;break;case st.ComponentProperty.Y_AXIS:this.value=this.states.includes(r)?a:.5;break;case st.ComponentProperty.BUTTON:this.value=this.states.includes(r)?i:0;break;case st.ComponentProperty.STATE:this.valueNodeProperty===st.VisualResponseProperty.VISIBILITY?this.value=this.states.includes(r):this.value=this.states.includes(r)?1:0;break;default:throw new Error(`Unexpected visualResponse componentProperty ${this.componentProperty}`)}}}class ba{constructor(t,e){if(!t||!e||!e.visualResponses||!e.gamepadIndices||Object.keys(e.gamepadIndices).length===0)throw new Error("Invalid arguments supplied");this.id=t,this.type=e.type,this.rootNodeName=e.rootNodeName,this.touchPointNodeName=e.touchPointNodeName,this.visualResponses={},Object.keys(e.visualResponses).forEach(i=>{const r=new Sa(e.visualResponses[i]);this.visualResponses[i]=r}),this.gamepadIndices=Object.assign({},e.gamepadIndices),this.values={state:st.ComponentState.DEFAULT,button:this.gamepadIndices.button!==void 0?0:void 0,xAxis:this.gamepadIndices.xAxis!==void 0?0:void 0,yAxis:this.gamepadIndices.yAxis!==void 0?0:void 0}}get data(){return{id:this.id,...this.values}}updateFromGamepad(t){if(this.values.state=st.ComponentState.DEFAULT,this.gamepadIndices.button!==void 0&&t.buttons.length>this.gamepadIndices.button){const e=t.buttons[this.gamepadIndices.button];this.values.button=e.value,this.values.button=this.values.button<0?0:this.values.button,this.values.button=this.values.button>1?1:this.values.button,e.pressed||this.values.button===1?this.values.state=st.ComponentState.PRESSED:(e.touched||this.values.button>st.ButtonTouchThreshold)&&(this.values.state=st.ComponentState.TOUCHED)}this.gamepadIndices.xAxis!==void 0&&t.axes.length>this.gamepadIndices.xAxis&&(this.values.xAxis=t.axes[this.gamepadIndices.xAxis],this.values.xAxis=this.values.xAxis<-1?-1:this.values.xAxis,this.values.xAxis=this.values.xAxis>1?1:this.values.xAxis,this.values.state===st.ComponentState.DEFAULT&&Math.abs(this.values.xAxis)>st.AxisTouchThreshold&&(this.values.state=st.ComponentState.TOUCHED)),this.gamepadIndices.yAxis!==void 0&&t.axes.length>this.gamepadIndices.yAxis&&(this.values.yAxis=t.axes[this.gamepadIndices.yAxis],this.values.yAxis=this.values.yAxis<-1?-1:this.values.yAxis,this.values.yAxis=this.values.yAxis>1?1:this.values.yAxis,this.values.state===st.ComponentState.DEFAULT&&Math.abs(this.values.yAxis)>st.AxisTouchThreshold&&(this.values.state=st.ComponentState.TOUCHED)),Object.values(this.visualResponses).forEach(e=>{e.updateFromComponent(this.values)})}}class Ta{constructor(t,e,i){if(!t)throw new Error("No xrInputSource supplied");if(!e)throw new Error("No profile supplied");this.xrInputSource=t,this.assetUrl=i,this.id=e.profileId,this.layoutDescription=e.layouts[t.handedness],this.components={},Object.keys(this.layoutDescription.components).forEach(r=>{const s=this.layoutDescription.components[r];this.components[r]=new ba(r,s)}),this.updateFromGamepad()}get gripSpace(){return this.xrInputSource.gripSpace}get targetRaySpace(){return this.xrInputSource.targetRaySpace}get data(){const t=[];return Object.values(this.components).forEach(e=>{t.push(e.data)}),t}updateFromGamepad(){Object.values(this.components).forEach(t=>{t.updateFromGamepad(this.xrInputSource.gamepad)})}}const Xr=2,qt=4,oe=4,ho=4,de=new Int32Array(2),os=new Float32Array(de.buffer),as=new Float64Array(de.buffer),tr=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;class ce{constructor(t,e){this.low=t|0,this.high=e|0}static create(t,e){return t==0&&e==0?ce.ZERO:new ce(t,e)}toFloat64(){return(this.low>>>0)+this.high*4294967296}equals(t){return this.low==t.low&&this.high==t.high}}ce.ZERO=new ce(0,0);var Pn;(function(n){n[n.UTF8_BYTES=1]="UTF8_BYTES",n[n.UTF16_STRING=2]="UTF16_STRING"})(Pn||(Pn={}));class gi{constructor(t){this.bytes_=t,this.position_=0}static allocate(t){return new gi(new Uint8Array(t))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(t){this.position_=t}capacity(){return this.bytes_.length}readInt8(t){return this.readUint8(t)<<24>>24}readUint8(t){return this.bytes_[t]}readInt16(t){return this.readUint16(t)<<16>>16}readUint16(t){return this.bytes_[t]|this.bytes_[t+1]<<8}readInt32(t){return this.bytes_[t]|this.bytes_[t+1]<<8|this.bytes_[t+2]<<16|this.bytes_[t+3]<<24}readUint32(t){return this.readInt32(t)>>>0}readInt64(t){return new ce(this.readInt32(t),this.readInt32(t+4))}readUint64(t){return new ce(this.readUint32(t),this.readUint32(t+4))}readFloat32(t){return de[0]=this.readInt32(t),os[0]}readFloat64(t){return de[tr?0:1]=this.readInt32(t),de[tr?1:0]=this.readInt32(t+4),as[0]}writeInt8(t,e){this.bytes_[t]=e}writeUint8(t,e){this.bytes_[t]=e}writeInt16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeUint16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeInt32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeUint32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeInt64(t,e){this.writeInt32(t,e.low),this.writeInt32(t+4,e.high)}writeUint64(t,e){this.writeUint32(t,e.low),this.writeUint32(t+4,e.high)}writeFloat32(t,e){os[0]=e,this.writeInt32(t,de[0])}writeFloat64(t,e){as[0]=e,this.writeInt32(t,de[tr?0:1]),this.writeInt32(t+4,de[tr?1:0])}getBufferIdentifier(){if(this.bytes_.length<this.position_+qt+oe)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");let t="";for(let e=0;e<oe;e++)t+=String.fromCharCode(this.readInt8(this.position_+qt+e));return t}__offset(t,e){const i=t-this.readInt32(t);return e<this.readInt16(i)?this.readInt16(i+e):0}__union(t,e){return t.bb_pos=e+this.readInt32(e),t.bb=this,t}__string(t,e){t+=this.readInt32(t);const i=this.readInt32(t);let r="",s=0;if(t+=qt,e===Pn.UTF8_BYTES)return this.bytes_.subarray(t,t+i);for(;s<i;){let a;const o=this.readUint8(t+s++);if(o<192)a=o;else{const c=this.readUint8(t+s++);if(o<224)a=(o&31)<<6|c&63;else{const l=this.readUint8(t+s++);if(o<240)a=(o&15)<<12|(c&63)<<6|l&63;else{const u=this.readUint8(t+s++);a=(o&7)<<18|(c&63)<<12|(l&63)<<6|u&63}}}a<65536?r+=String.fromCharCode(a):(a-=65536,r+=String.fromCharCode((a>>10)+55296,(a&1023)+56320))}return r}__union_with_string(t,e){return typeof t=="string"?this.__string(e):this.__union(t,e)}__indirect(t){return t+this.readInt32(t)}__vector(t){return t+this.readInt32(t)+qt}__vector_len(t){return this.readInt32(t+this.readInt32(t))}__has_identifier(t){if(t.length!=oe)throw new Error("FlatBuffers: file identifier must be length "+oe);for(let e=0;e<oe;e++)if(t.charCodeAt(e)!=this.readInt8(this.position()+qt+e))return!1;return!0}createLong(t,e){return ce.create(t,e)}createScalarList(t,e){const i=[];for(let r=0;r<e;++r)t(r)!==null&&i.push(t(r));return i}createObjList(t,e){const i=[];for(let r=0;r<e;++r){const s=t(r);s!==null&&i.push(s.unpack())}return i}}class Wn{constructor(t){this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null;let e;t?e=t:e=1024,this.bb=gi.allocate(e),this.space=e}clear(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null}forceDefaults(t){this.force_defaults=t}dataBuffer(){return this.bb}asUint8Array(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())}prep(t,e){t>this.minalign&&(this.minalign=t);const i=~(this.bb.capacity()-this.space+e)+1&t-1;for(;this.space<i+t+e;){const r=this.bb.capacity();this.bb=Wn.growByteBuffer(this.bb),this.space+=this.bb.capacity()-r}this.pad(i)}pad(t){for(let e=0;e<t;e++)this.bb.writeInt8(--this.space,0)}writeInt8(t){this.bb.writeInt8(this.space-=1,t)}writeInt16(t){this.bb.writeInt16(this.space-=2,t)}writeInt32(t){this.bb.writeInt32(this.space-=4,t)}writeInt64(t){this.bb.writeInt64(this.space-=8,t)}writeFloat32(t){this.bb.writeFloat32(this.space-=4,t)}writeFloat64(t){this.bb.writeFloat64(this.space-=8,t)}addInt8(t){this.prep(1,0),this.writeInt8(t)}addInt16(t){this.prep(2,0),this.writeInt16(t)}addInt32(t){this.prep(4,0),this.writeInt32(t)}addInt64(t){this.prep(8,0),this.writeInt64(t)}addFloat32(t){this.prep(4,0),this.writeFloat32(t)}addFloat64(t){this.prep(8,0),this.writeFloat64(t)}addFieldInt8(t,e,i){(this.force_defaults||e!=i)&&(this.addInt8(e),this.slot(t))}addFieldInt16(t,e,i){(this.force_defaults||e!=i)&&(this.addInt16(e),this.slot(t))}addFieldInt32(t,e,i){(this.force_defaults||e!=i)&&(this.addInt32(e),this.slot(t))}addFieldInt64(t,e,i){(this.force_defaults||!e.equals(i))&&(this.addInt64(e),this.slot(t))}addFieldFloat32(t,e,i){(this.force_defaults||e!=i)&&(this.addFloat32(e),this.slot(t))}addFieldFloat64(t,e,i){(this.force_defaults||e!=i)&&(this.addFloat64(e),this.slot(t))}addFieldOffset(t,e,i){(this.force_defaults||e!=i)&&(this.addOffset(e),this.slot(t))}addFieldStruct(t,e,i){e!=i&&(this.nested(e),this.slot(t))}nested(t){if(t!=this.offset())throw new Error("FlatBuffers: struct must be serialized inline.")}notNested(){if(this.isNested)throw new Error("FlatBuffers: object serialization must not be nested.")}slot(t){this.vtable!==null&&(this.vtable[t]=this.offset())}offset(){return this.bb.capacity()-this.space}static growByteBuffer(t){const e=t.capacity();if(e&3221225472)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");const i=e<<1,r=gi.allocate(i);return r.setPosition(i-e),r.bytes().set(t.bytes(),i-e),r}addOffset(t){this.prep(qt,0),this.writeInt32(this.offset()-t+qt)}startObject(t){this.notNested(),this.vtable==null&&(this.vtable=[]),this.vtable_in_use=t;for(let e=0;e<t;e++)this.vtable[e]=0;this.isNested=!0,this.object_start=this.offset()}endObject(){if(this.vtable==null||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);const t=this.offset();let e=this.vtable_in_use-1;for(;e>=0&&this.vtable[e]==0;e--);const i=e+1;for(;e>=0;e--)this.addInt16(this.vtable[e]!=0?t-this.vtable[e]:0);const r=2;this.addInt16(t-this.object_start);const s=(i+r)*Xr;this.addInt16(s);let a=0;const o=this.space;t:for(e=0;e<this.vtables.length;e++){const c=this.bb.capacity()-this.vtables[e];if(s==this.bb.readInt16(c)){for(let l=Xr;l<s;l+=Xr)if(this.bb.readInt16(o+l)!=this.bb.readInt16(c+l))continue t;a=this.vtables[e];break}}return a?(this.space=this.bb.capacity()-t,this.bb.writeInt32(this.space,a-t)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-t,this.offset()-t)),this.isNested=!1,t}finish(t,e,i){const r=i?ho:0;if(e){const s=e;if(this.prep(this.minalign,qt+oe+r),s.length!=oe)throw new Error("FlatBuffers: file identifier must be length "+oe);for(let a=oe-1;a>=0;a--)this.writeInt8(s.charCodeAt(a))}this.prep(this.minalign,qt+r),this.addOffset(t),r&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(t,e){this.finish(t,e,!0)}requiredField(t,e){const i=this.bb.capacity()-t,r=i-this.bb.readInt32(i);if(!(this.bb.readInt16(r+e)!=0))throw new Error("FlatBuffers: field "+e+" must be set")}startVector(t,e,i){this.notNested(),this.vector_num_elems=e,this.prep(qt,t*e),this.prep(i,t*e)}endVector(){return this.writeInt32(this.vector_num_elems),this.offset()}createSharedString(t){if(!t)return 0;if(this.string_maps||(this.string_maps=new Map),this.string_maps.has(t))return this.string_maps.get(t);const e=this.createString(t);return this.string_maps.set(t,e),e}createString(t){if(!t)return 0;let e;if(t instanceof Uint8Array)e=t;else{e=[];let i=0;for(;i<t.length;){let r;const s=t.charCodeAt(i++);if(s<55296||s>=56320)r=s;else{const a=t.charCodeAt(i++);r=(s<<10)+a+-56613888}r<128?e.push(r):(r<2048?e.push(r>>6&31|192):(r<65536?e.push(r>>12&15|224):e.push(r>>18&7|240,r>>12&63|128),e.push(r>>6&63|128)),e.push(r&63|128))}}this.addInt8(0),this.startVector(1,e.length,1),this.bb.setPosition(this.space-=e.length);for(let i=0,r=this.space,s=this.bb.bytes();i<e.length;i++)s[r++]=e[i];return this.endVector()}createLong(t,e){return ce.create(t,e)}createObjectOffset(t){return t===null?0:typeof t=="string"?this.createString(t):t.pack(this)}createObjectOffsetList(t){const e=[];for(let i=0;i<t.length;++i){const r=t[i];if(r!==null)e.push(this.createObjectOffset(r));else throw new Error("FlatBuffers: Argument for createObjectOffsetList cannot contain null.")}return e}createStructOffsetList(t,e){return e(this,t.length),this.createObjectOffsetList(t),this.endVector()}}function Vr(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Wr={exports:{}},cs;function ls(){return cs||(cs=1,function(n){var t={};t.useBlobBuilder=function(){try{return new Blob([]),!1}catch{return!0}}(),t.useArrayBufferView=!t.useBlobBuilder&&function(){try{return new Blob([new Uint8Array([])]).size===0}catch{return!0}}(),n.exports.binaryFeatures=t;var e=n.exports.BlobBuilder;typeof window<"u"&&(e=n.exports.BlobBuilder=window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder||window.BlobBuilder);function i(){this._pieces=[],this._parts=[]}i.prototype.append=function(r){typeof r=="number"?this._pieces.push(r):(this.flush(),this._parts.push(r))},i.prototype.flush=function(){if(this._pieces.length>0){var r=new Uint8Array(this._pieces);t.useArrayBufferView||(r=r.buffer),this._parts.push(r),this._pieces=[]}},i.prototype.getBuffer=function(){if(this.flush(),t.useBlobBuilder){for(var r=new e,s=0,a=this._parts.length;s<a;s++)r.append(this._parts[s]);return r.getBlob()}else return new Blob(this._parts)},n.exports.BufferBuilder=i}(Wr)),Wr.exports}var Hr,us;function Ma(){if(us)return Hr;us=1;var n=ls().BufferBuilder,t=ls().binaryFeatures,e={unpack:function(o){var c=new i(o);return c.unpack()},pack:function(o){var c=new r;c.pack(o);var l=c.getBuffer();return l}};Hr=e;function i(o){this.index=0,this.dataBuffer=o,this.dataView=new Uint8Array(this.dataBuffer),this.length=this.dataBuffer.byteLength}i.prototype.unpack=function(){var o=this.unpack_uint8();if(o<128)return o;if((o^224)<32)return(o^224)-32;var c;if((c=o^160)<=15)return this.unpack_raw(c);if((c=o^176)<=15)return this.unpack_string(c);if((c=o^144)<=15)return this.unpack_array(c);if((c=o^128)<=15)return this.unpack_map(c);switch(o){case 192:return null;case 193:return;case 194:return!1;case 195:return!0;case 202:return this.unpack_float();case 203:return this.unpack_double();case 204:return this.unpack_uint8();case 205:return this.unpack_uint16();case 206:return this.unpack_uint32();case 207:return this.unpack_uint64();case 208:return this.unpack_int8();case 209:return this.unpack_int16();case 210:return this.unpack_int32();case 211:return this.unpack_int64();case 212:return;case 213:return;case 214:return;case 215:return;case 216:return c=this.unpack_uint16(),this.unpack_string(c);case 217:return c=this.unpack_uint32(),this.unpack_string(c);case 218:return c=this.unpack_uint16(),this.unpack_raw(c);case 219:return c=this.unpack_uint32(),this.unpack_raw(c);case 220:return c=this.unpack_uint16(),this.unpack_array(c);case 221:return c=this.unpack_uint32(),this.unpack_array(c);case 222:return c=this.unpack_uint16(),this.unpack_map(c);case 223:return c=this.unpack_uint32(),this.unpack_map(c)}},i.prototype.unpack_uint8=function(){var o=this.dataView[this.index]&255;return this.index++,o},i.prototype.unpack_uint16=function(){var o=this.read(2),c=(o[0]&255)*256+(o[1]&255);return this.index+=2,c},i.prototype.unpack_uint32=function(){var o=this.read(4),c=((o[0]*256+o[1])*256+o[2])*256+o[3];return this.index+=4,c},i.prototype.unpack_uint64=function(){var o=this.read(8),c=((((((o[0]*256+o[1])*256+o[2])*256+o[3])*256+o[4])*256+o[5])*256+o[6])*256+o[7];return this.index+=8,c},i.prototype.unpack_int8=function(){var o=this.unpack_uint8();return o<128?o:o-256},i.prototype.unpack_int16=function(){var o=this.unpack_uint16();return o<32768?o:o-65536},i.prototype.unpack_int32=function(){var o=this.unpack_uint32();return o<Math.pow(2,31)?o:o-Math.pow(2,32)},i.prototype.unpack_int64=function(){var o=this.unpack_uint64();return o<Math.pow(2,63)?o:o-Math.pow(2,64)},i.prototype.unpack_raw=function(o){if(this.length<this.index+o)throw new Error("BinaryPackFailure: index is out of range "+this.index+" "+o+" "+this.length);var c=this.dataBuffer.slice(this.index,this.index+o);return this.index+=o,c},i.prototype.unpack_string=function(o){for(var c=this.read(o),l=0,u="",h,f;l<o;)h=c[l],h<128?(u+=String.fromCharCode(h),l++):(h^192)<32?(f=(h^192)<<6|c[l+1]&63,u+=String.fromCharCode(f),l+=2):(f=(h&15)<<12|(c[l+1]&63)<<6|c[l+2]&63,u+=String.fromCharCode(f),l+=3);return this.index+=o,u},i.prototype.unpack_array=function(o){for(var c=new Array(o),l=0;l<o;l++)c[l]=this.unpack();return c},i.prototype.unpack_map=function(o){for(var c={},l=0;l<o;l++){var u=this.unpack(),h=this.unpack();c[u]=h}return c},i.prototype.unpack_float=function(){var o=this.unpack_uint32(),c=o>>31,l=(o>>23&255)-127,u=o&8388607|8388608;return(c===0?1:-1)*u*Math.pow(2,l-23)},i.prototype.unpack_double=function(){var o=this.unpack_uint32(),c=this.unpack_uint32(),l=o>>31,u=(o>>20&2047)-1023,h=o&1048575|1048576,f=h*Math.pow(2,u-20)+c*Math.pow(2,u-52);return(l===0?1:-1)*f},i.prototype.read=function(o){var c=this.index;if(c+o<=this.length)return this.dataView.subarray(c,c+o);throw new Error("BinaryPackFailure: read index out of range")};function r(){this.bufferBuilder=new n}r.prototype.getBuffer=function(){return this.bufferBuilder.getBuffer()},r.prototype.pack=function(o){var c=typeof o;if(c==="string")this.pack_string(o);else if(c==="number")Math.floor(o)===o?this.pack_integer(o):this.pack_double(o);else if(c==="boolean")o===!0?this.bufferBuilder.append(195):o===!1&&this.bufferBuilder.append(194);else if(c==="undefined")this.bufferBuilder.append(192);else if(c==="object")if(o===null)this.bufferBuilder.append(192);else{var l=o.constructor;if(l==Array)this.pack_array(o);else if(l==Blob||l==File||o instanceof Blob||o instanceof File)this.pack_bin(o);else if(l==ArrayBuffer)t.useArrayBufferView?this.pack_bin(new Uint8Array(o)):this.pack_bin(o);else if("BYTES_PER_ELEMENT"in o)t.useArrayBufferView?this.pack_bin(new Uint8Array(o.buffer)):this.pack_bin(o.buffer);else if(l==Object||l.toString().startsWith("class"))this.pack_object(o);else if(l==Date)this.pack_string(o.toString());else if(typeof o.toBinaryPack=="function")this.bufferBuilder.append(o.toBinaryPack());else throw new Error('Type "'+l.toString()+'" not yet supported')}else throw new Error('Type "'+c+'" not yet supported');this.bufferBuilder.flush()},r.prototype.pack_bin=function(o){var c=o.length||o.byteLength||o.size;if(c<=15)this.pack_uint8(160+c);else if(c<=65535)this.bufferBuilder.append(218),this.pack_uint16(c);else if(c<=4294967295)this.bufferBuilder.append(219),this.pack_uint32(c);else throw new Error("Invalid length");this.bufferBuilder.append(o)},r.prototype.pack_string=function(o){var c=a(o);if(c<=15)this.pack_uint8(176+c);else if(c<=65535)this.bufferBuilder.append(216),this.pack_uint16(c);else if(c<=4294967295)this.bufferBuilder.append(217),this.pack_uint32(c);else throw new Error("Invalid length");this.bufferBuilder.append(o)},r.prototype.pack_array=function(o){var c=o.length;if(c<=15)this.pack_uint8(144+c);else if(c<=65535)this.bufferBuilder.append(220),this.pack_uint16(c);else if(c<=4294967295)this.bufferBuilder.append(221),this.pack_uint32(c);else throw new Error("Invalid length");for(var l=0;l<c;l++)this.pack(o[l])},r.prototype.pack_integer=function(o){if(o>=-32&&o<=127)this.bufferBuilder.append(o&255);else if(o>=0&&o<=255)this.bufferBuilder.append(204),this.pack_uint8(o);else if(o>=-128&&o<=127)this.bufferBuilder.append(208),this.pack_int8(o);else if(o>=0&&o<=65535)this.bufferBuilder.append(205),this.pack_uint16(o);else if(o>=-32768&&o<=32767)this.bufferBuilder.append(209),this.pack_int16(o);else if(o>=0&&o<=4294967295)this.bufferBuilder.append(206),this.pack_uint32(o);else if(o>=-2147483648&&o<=2147483647)this.bufferBuilder.append(210),this.pack_int32(o);else if(o>=-9223372036854776e3&&o<=9223372036854776e3)this.bufferBuilder.append(211),this.pack_int64(o);else if(o>=0&&o<=18446744073709552e3)this.bufferBuilder.append(207),this.pack_uint64(o);else throw new Error("Invalid integer")},r.prototype.pack_double=function(o){var c=0;o<0&&(c=1,o=-o);var l=Math.floor(Math.log(o)/Math.LN2),u=o/Math.pow(2,l)-1,h=Math.floor(u*Math.pow(2,52)),f=Math.pow(2,32),d=c<<31|l+1023<<20|h/f&1048575,y=h%f;this.bufferBuilder.append(203),this.pack_int32(d),this.pack_int32(y)},r.prototype.pack_object=function(o){var c=Object.keys(o),l=c.length;if(l<=15)this.pack_uint8(128+l);else if(l<=65535)this.bufferBuilder.append(222),this.pack_uint16(l);else if(l<=4294967295)this.bufferBuilder.append(223),this.pack_uint32(l);else throw new Error("Invalid length");for(var u in o)o.hasOwnProperty(u)&&(this.pack(u),this.pack(o[u]))},r.prototype.pack_uint8=function(o){this.bufferBuilder.append(o)},r.prototype.pack_uint16=function(o){this.bufferBuilder.append(o>>8),this.bufferBuilder.append(o&255)},r.prototype.pack_uint32=function(o){var c=o&4294967295;this.bufferBuilder.append((c&4278190080)>>>24),this.bufferBuilder.append((c&16711680)>>>16),this.bufferBuilder.append((c&65280)>>>8),this.bufferBuilder.append(c&255)},r.prototype.pack_uint64=function(o){var c=o/Math.pow(2,32),l=o%Math.pow(2,32);this.bufferBuilder.append((c&4278190080)>>>24),this.bufferBuilder.append((c&16711680)>>>16),this.bufferBuilder.append((c&65280)>>>8),this.bufferBuilder.append(c&255),this.bufferBuilder.append((l&4278190080)>>>24),this.bufferBuilder.append((l&16711680)>>>16),this.bufferBuilder.append((l&65280)>>>8),this.bufferBuilder.append(l&255)},r.prototype.pack_int8=function(o){this.bufferBuilder.append(o&255)},r.prototype.pack_int16=function(o){this.bufferBuilder.append((o&65280)>>8),this.bufferBuilder.append(o&255)},r.prototype.pack_int32=function(o){this.bufferBuilder.append(o>>>24&255),this.bufferBuilder.append((o&16711680)>>>16),this.bufferBuilder.append((o&65280)>>>8),this.bufferBuilder.append(o&255)},r.prototype.pack_int64=function(o){var c=Math.floor(o/Math.pow(2,32)),l=o%Math.pow(2,32);this.bufferBuilder.append((c&4278190080)>>>24),this.bufferBuilder.append((c&16711680)>>>16),this.bufferBuilder.append((c&65280)>>>8),this.bufferBuilder.append(c&255),this.bufferBuilder.append((l&4278190080)>>>24),this.bufferBuilder.append((l&16711680)>>>16),this.bufferBuilder.append((l&65280)>>>8),this.bufferBuilder.append(l&255)};function s(o){var c=o.charCodeAt(0);return c<=2047?"00":c<=65535?"000":c<=2097151?"0000":c<=67108863?"00000":"000000"}function a(o){return o.length>600?new Blob([o]).size:o.replace(/[^\u0000-\u007F]/g,s).length}return Hr}var Ca=Ma();const hs=Vr(Ca);let fo=!0,po=!0;function li(n,t,e){const i=n.match(t);return i&&i.length>=e&&parseInt(i[e],10)}function $e(n,t,e){if(!n.RTCPeerConnection)return;const i=n.RTCPeerConnection.prototype,r=i.addEventListener;i.addEventListener=function(a,o){if(a!==t)return r.apply(this,arguments);const c=l=>{const u=e(l);u&&(o.handleEvent?o.handleEvent(u):o(u))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new Map),this._eventMap[t].set(o,c),r.apply(this,[a,c])};const s=i.removeEventListener;i.removeEventListener=function(a,o){if(a!==t||!this._eventMap||!this._eventMap[t])return s.apply(this,arguments);if(!this._eventMap[t].has(o))return s.apply(this,arguments);const c=this._eventMap[t].get(o);return this._eventMap[t].delete(o),this._eventMap[t].size===0&&delete this._eventMap[t],Object.keys(this._eventMap).length===0&&delete this._eventMap,s.apply(this,[a,c])},Object.defineProperty(i,"on"+t,{get(){return this["_on"+t]},set(a){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),a&&this.addEventListener(t,this["_on"+t]=a)},enumerable:!0,configurable:!0})}function Pa(n){return typeof n!="boolean"?new Error("Argument type: "+typeof n+". Please use a boolean."):(fo=n,n?"adapter.js logging disabled":"adapter.js logging enabled")}function wa(n){return typeof n!="boolean"?new Error("Argument type: "+typeof n+". Please use a boolean."):(po=!n,"adapter.js deprecation warnings "+(n?"disabled":"enabled"))}function Hn(){if(typeof window=="object"){if(fo)return;typeof console<"u"&&typeof console.log=="function"&&console.log.apply(console,arguments)}}function Jr(n,t){po&&console.warn(n+" is deprecated, please use "+t+" instead.")}function Ea(n){const t={browser:null,version:null};if(typeof n>"u"||!n.navigator)return t.browser="Not a browser.",t;const{navigator:e}=n;if(e.mozGetUserMedia)t.browser="firefox",t.version=li(e.userAgent,/Firefox\/(\d+)\./,1);else if(e.webkitGetUserMedia||n.isSecureContext===!1&&n.webkitRTCPeerConnection&&!n.RTCIceGatherer)t.browser="chrome",t.version=li(e.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(e.mediaDevices&&e.userAgent.match(/Edge\/(\d+).(\d+)$/))t.browser="edge",t.version=li(e.userAgent,/Edge\/(\d+).(\d+)$/,2);else if(n.RTCPeerConnection&&e.userAgent.match(/AppleWebKit\/(\d+)\./))t.browser="safari",t.version=li(e.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=n.RTCRtpTransceiver&&"currentDirection"in n.RTCRtpTransceiver.prototype;else return t.browser="Not a supported browser.",t;return t}function fs(n){return Object.prototype.toString.call(n)==="[object Object]"}function mo(n){return fs(n)?Object.keys(n).reduce(function(t,e){const i=fs(n[e]),r=i?mo(n[e]):n[e],s=i&&!Object.keys(r).length;return r===void 0||s?t:Object.assign(t,{[e]:r})},{}):n}function wn(n,t,e){!t||e.has(t.id)||(e.set(t.id,t),Object.keys(t).forEach(i=>{i.endsWith("Id")?wn(n,n.get(t[i]),e):i.endsWith("Ids")&&t[i].forEach(r=>{wn(n,n.get(r),e)})}))}function ds(n,t,e){const i=e?"outbound-rtp":"inbound-rtp",r=new Map;if(t===null)return r;const s=[];return n.forEach(a=>{a.type==="track"&&a.trackIdentifier===t.id&&s.push(a)}),s.forEach(a=>{n.forEach(o=>{o.type===i&&o.trackId===a.id&&wn(n,o,r)})}),r}const ps=Hn;function yo(n,t){const e=n&&n.navigator;if(!e.mediaDevices)return;const i=function(o){if(typeof o!="object"||o.mandatory||o.optional)return o;const c={};return Object.keys(o).forEach(l=>{if(l==="require"||l==="advanced"||l==="mediaSource")return;const u=typeof o[l]=="object"?o[l]:{ideal:o[l]};u.exact!==void 0&&typeof u.exact=="number"&&(u.min=u.max=u.exact);const h=function(f,d){return f?f+d.charAt(0).toUpperCase()+d.slice(1):d==="deviceId"?"sourceId":d};if(u.ideal!==void 0){c.optional=c.optional||[];let f={};typeof u.ideal=="number"?(f[h("min",l)]=u.ideal,c.optional.push(f),f={},f[h("max",l)]=u.ideal,c.optional.push(f)):(f[h("",l)]=u.ideal,c.optional.push(f))}u.exact!==void 0&&typeof u.exact!="number"?(c.mandatory=c.mandatory||{},c.mandatory[h("",l)]=u.exact):["min","max"].forEach(f=>{u[f]!==void 0&&(c.mandatory=c.mandatory||{},c.mandatory[h(f,l)]=u[f])})}),o.advanced&&(c.optional=(c.optional||[]).concat(o.advanced)),c},r=function(o,c){if(t.version>=61)return c(o);if(o=JSON.parse(JSON.stringify(o)),o&&typeof o.audio=="object"){const l=function(u,h,f){h in u&&!(f in u)&&(u[f]=u[h],delete u[h])};o=JSON.parse(JSON.stringify(o)),l(o.audio,"autoGainControl","googAutoGainControl"),l(o.audio,"noiseSuppression","googNoiseSuppression"),o.audio=i(o.audio)}if(o&&typeof o.video=="object"){let l=o.video.facingMode;l=l&&(typeof l=="object"?l:{ideal:l});const u=t.version<66;if(l&&(l.exact==="user"||l.exact==="environment"||l.ideal==="user"||l.ideal==="environment")&&!(e.mediaDevices.getSupportedConstraints&&e.mediaDevices.getSupportedConstraints().facingMode&&!u)){delete o.video.facingMode;let h;if(l.exact==="environment"||l.ideal==="environment"?h=["back","rear"]:(l.exact==="user"||l.ideal==="user")&&(h=["front"]),h)return e.mediaDevices.enumerateDevices().then(f=>{f=f.filter(y=>y.kind==="videoinput");let d=f.find(y=>h.some(_=>y.label.toLowerCase().includes(_)));return!d&&f.length&&h.includes("back")&&(d=f[f.length-1]),d&&(o.video.deviceId=l.exact?{exact:d.deviceId}:{ideal:d.deviceId}),o.video=i(o.video),ps("chrome: "+JSON.stringify(o)),c(o)})}o.video=i(o.video)}return ps("chrome: "+JSON.stringify(o)),c(o)},s=function(o){return t.version>=64?o:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[o.name]||o.name,message:o.message,constraint:o.constraint||o.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}},a=function(o,c,l){r(o,u=>{e.webkitGetUserMedia(u,c,h=>{l&&l(s(h))})})};if(e.getUserMedia=a.bind(e),e.mediaDevices.getUserMedia){const o=e.mediaDevices.getUserMedia.bind(e.mediaDevices);e.mediaDevices.getUserMedia=function(c){return r(c,l=>o(l).then(u=>{if(l.audio&&!u.getAudioTracks().length||l.video&&!u.getVideoTracks().length)throw u.getTracks().forEach(h=>{h.stop()}),new DOMException("","NotFoundError");return u},u=>Promise.reject(s(u))))}}}function Ra(n,t){if(!(n.navigator.mediaDevices&&"getDisplayMedia"in n.navigator.mediaDevices)&&n.navigator.mediaDevices){if(typeof t!="function"){console.error("shimGetDisplayMedia: getSourceId argument is not a function");return}n.navigator.mediaDevices.getDisplayMedia=function(i){return t(i).then(r=>{const s=i.video&&i.video.width,a=i.video&&i.video.height,o=i.video&&i.video.frameRate;return i.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:r,maxFrameRate:o||3}},s&&(i.video.mandatory.maxWidth=s),a&&(i.video.mandatory.maxHeight=a),n.navigator.mediaDevices.getUserMedia(i)})}}}function go(n){n.MediaStream=n.MediaStream||n.webkitMediaStream}function vo(n){if(typeof n=="object"&&n.RTCPeerConnection&&!("ontrack"in n.RTCPeerConnection.prototype)){Object.defineProperty(n.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});const t=n.RTCPeerConnection.prototype.setRemoteDescription;n.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=i=>{i.stream.addEventListener("addtrack",r=>{let s;n.RTCPeerConnection.prototype.getReceivers?s=this.getReceivers().find(o=>o.track&&o.track.id===r.track.id):s={track:r.track};const a=new Event("track");a.track=r.track,a.receiver=s,a.transceiver={receiver:s},a.streams=[i.stream],this.dispatchEvent(a)}),i.stream.getTracks().forEach(r=>{let s;n.RTCPeerConnection.prototype.getReceivers?s=this.getReceivers().find(o=>o.track&&o.track.id===r.id):s={track:r};const a=new Event("track");a.track=r,a.receiver=s,a.transceiver={receiver:s},a.streams=[i.stream],this.dispatchEvent(a)})},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else $e(n,"track",t=>(t.transceiver||Object.defineProperty(t,"transceiver",{value:{receiver:t.receiver}}),t))}function _o(n){if(typeof n=="object"&&n.RTCPeerConnection&&!("getSenders"in n.RTCPeerConnection.prototype)&&"createDTMFSender"in n.RTCPeerConnection.prototype){const t=function(r,s){return{track:s,get dtmf(){return this._dtmf===void 0&&(s.kind==="audio"?this._dtmf=r.createDTMFSender(s):this._dtmf=null),this._dtmf},_pc:r}};if(!n.RTCPeerConnection.prototype.getSenders){n.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const r=n.RTCPeerConnection.prototype.addTrack;n.RTCPeerConnection.prototype.addTrack=function(o,c){let l=r.apply(this,arguments);return l||(l=t(this,o),this._senders.push(l)),l};const s=n.RTCPeerConnection.prototype.removeTrack;n.RTCPeerConnection.prototype.removeTrack=function(o){s.apply(this,arguments);const c=this._senders.indexOf(o);c!==-1&&this._senders.splice(c,1)}}const e=n.RTCPeerConnection.prototype.addStream;n.RTCPeerConnection.prototype.addStream=function(s){this._senders=this._senders||[],e.apply(this,[s]),s.getTracks().forEach(a=>{this._senders.push(t(this,a))})};const i=n.RTCPeerConnection.prototype.removeStream;n.RTCPeerConnection.prototype.removeStream=function(s){this._senders=this._senders||[],i.apply(this,[s]),s.getTracks().forEach(a=>{const o=this._senders.find(c=>c.track===a);o&&this._senders.splice(this._senders.indexOf(o),1)})}}else if(typeof n=="object"&&n.RTCPeerConnection&&"getSenders"in n.RTCPeerConnection.prototype&&"createDTMFSender"in n.RTCPeerConnection.prototype&&n.RTCRtpSender&&!("dtmf"in n.RTCRtpSender.prototype)){const t=n.RTCPeerConnection.prototype.getSenders;n.RTCPeerConnection.prototype.getSenders=function(){const i=t.apply(this,[]);return i.forEach(r=>r._pc=this),i},Object.defineProperty(n.RTCRtpSender.prototype,"dtmf",{get(){return this._dtmf===void 0&&(this.track.kind==="audio"?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function xo(n){if(!n.RTCPeerConnection)return;const t=n.RTCPeerConnection.prototype.getStats;n.RTCPeerConnection.prototype.getStats=function(){const[i,r,s]=arguments;if(arguments.length>0&&typeof i=="function")return t.apply(this,arguments);if(t.length===0&&(arguments.length===0||typeof i!="function"))return t.apply(this,[]);const a=function(c){const l={};return c.result().forEach(h=>{const f={id:h.id,timestamp:h.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[h.type]||h.type};h.names().forEach(d=>{f[d]=h.stat(d)}),l[f.id]=f}),l},o=function(c){return new Map(Object.keys(c).map(l=>[l,c[l]]))};if(arguments.length>=2){const c=function(l){r(o(a(l)))};return t.apply(this,[c,i])}return new Promise((c,l)=>{t.apply(this,[function(u){c(o(a(u)))},l])}).then(r,s)}}function So(n){if(!(typeof n=="object"&&n.RTCPeerConnection&&n.RTCRtpSender&&n.RTCRtpReceiver))return;if(!("getStats"in n.RTCRtpSender.prototype)){const e=n.RTCPeerConnection.prototype.getSenders;e&&(n.RTCPeerConnection.prototype.getSenders=function(){const s=e.apply(this,[]);return s.forEach(a=>a._pc=this),s});const i=n.RTCPeerConnection.prototype.addTrack;i&&(n.RTCPeerConnection.prototype.addTrack=function(){const s=i.apply(this,arguments);return s._pc=this,s}),n.RTCRtpSender.prototype.getStats=function(){const s=this;return this._pc.getStats().then(a=>ds(a,s.track,!0))}}if(!("getStats"in n.RTCRtpReceiver.prototype)){const e=n.RTCPeerConnection.prototype.getReceivers;e&&(n.RTCPeerConnection.prototype.getReceivers=function(){const r=e.apply(this,[]);return r.forEach(s=>s._pc=this),r}),$e(n,"track",i=>(i.receiver._pc=i.srcElement,i)),n.RTCRtpReceiver.prototype.getStats=function(){const r=this;return this._pc.getStats().then(s=>ds(s,r.track,!1))}}if(!("getStats"in n.RTCRtpSender.prototype&&"getStats"in n.RTCRtpReceiver.prototype))return;const t=n.RTCPeerConnection.prototype.getStats;n.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof n.MediaStreamTrack){const i=arguments[0];let r,s,a;return this.getSenders().forEach(o=>{o.track===i&&(r?a=!0:r=o)}),this.getReceivers().forEach(o=>(o.track===i&&(s?a=!0:s=o),o.track===i)),a||r&&s?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):r?r.getStats():s?s.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return t.apply(this,arguments)}}function bo(n){n.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(a=>this._shimmedLocalStreams[a][0])};const t=n.RTCPeerConnection.prototype.addTrack;n.RTCPeerConnection.prototype.addTrack=function(a,o){if(!o)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const c=t.apply(this,arguments);return this._shimmedLocalStreams[o.id]?this._shimmedLocalStreams[o.id].indexOf(c)===-1&&this._shimmedLocalStreams[o.id].push(c):this._shimmedLocalStreams[o.id]=[o,c],c};const e=n.RTCPeerConnection.prototype.addStream;n.RTCPeerConnection.prototype.addStream=function(a){this._shimmedLocalStreams=this._shimmedLocalStreams||{},a.getTracks().forEach(l=>{if(this.getSenders().find(h=>h.track===l))throw new DOMException("Track already exists.","InvalidAccessError")});const o=this.getSenders();e.apply(this,arguments);const c=this.getSenders().filter(l=>o.indexOf(l)===-1);this._shimmedLocalStreams[a.id]=[a].concat(c)};const i=n.RTCPeerConnection.prototype.removeStream;n.RTCPeerConnection.prototype.removeStream=function(a){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[a.id],i.apply(this,arguments)};const r=n.RTCPeerConnection.prototype.removeTrack;n.RTCPeerConnection.prototype.removeTrack=function(a){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},a&&Object.keys(this._shimmedLocalStreams).forEach(o=>{const c=this._shimmedLocalStreams[o].indexOf(a);c!==-1&&this._shimmedLocalStreams[o].splice(c,1),this._shimmedLocalStreams[o].length===1&&delete this._shimmedLocalStreams[o]}),r.apply(this,arguments)}}function To(n,t){if(!n.RTCPeerConnection)return;if(n.RTCPeerConnection.prototype.addTrack&&t.version>=65)return bo(n);const e=n.RTCPeerConnection.prototype.getLocalStreams;n.RTCPeerConnection.prototype.getLocalStreams=function(){const u=e.apply(this);return this._reverseStreams=this._reverseStreams||{},u.map(h=>this._reverseStreams[h.id])};const i=n.RTCPeerConnection.prototype.addStream;n.RTCPeerConnection.prototype.addStream=function(u){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},u.getTracks().forEach(h=>{if(this.getSenders().find(d=>d.track===h))throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[u.id]){const h=new n.MediaStream(u.getTracks());this._streams[u.id]=h,this._reverseStreams[h.id]=u,u=h}i.apply(this,[u])};const r=n.RTCPeerConnection.prototype.removeStream;n.RTCPeerConnection.prototype.removeStream=function(u){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},r.apply(this,[this._streams[u.id]||u]),delete this._reverseStreams[this._streams[u.id]?this._streams[u.id].id:u.id],delete this._streams[u.id]},n.RTCPeerConnection.prototype.addTrack=function(u,h){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const f=[].slice.call(arguments,1);if(f.length!==1||!f[0].getTracks().find(_=>_===u))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");if(this.getSenders().find(_=>_.track===u))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const y=this._streams[h.id];if(y)y.addTrack(u),Promise.resolve().then(()=>{this.dispatchEvent(new Event("negotiationneeded"))});else{const _=new n.MediaStream([u]);this._streams[h.id]=_,this._reverseStreams[_.id]=h,this.addStream(_)}return this.getSenders().find(_=>_.track===u)};function s(l,u){let h=u.sdp;return Object.keys(l._reverseStreams||[]).forEach(f=>{const d=l._reverseStreams[f],y=l._streams[d.id];h=h.replace(new RegExp(y.id,"g"),d.id)}),new RTCSessionDescription({type:u.type,sdp:h})}function a(l,u){let h=u.sdp;return Object.keys(l._reverseStreams||[]).forEach(f=>{const d=l._reverseStreams[f],y=l._streams[d.id];h=h.replace(new RegExp(d.id,"g"),y.id)}),new RTCSessionDescription({type:u.type,sdp:h})}["createOffer","createAnswer"].forEach(function(l){const u=n.RTCPeerConnection.prototype[l],h={[l](){const f=arguments;return arguments.length&&typeof arguments[0]=="function"?u.apply(this,[y=>{const _=s(this,y);f[0].apply(null,[_])},y=>{f[1]&&f[1].apply(null,y)},arguments[2]]):u.apply(this,arguments).then(y=>s(this,y))}};n.RTCPeerConnection.prototype[l]=h[l]});const o=n.RTCPeerConnection.prototype.setLocalDescription;n.RTCPeerConnection.prototype.setLocalDescription=function(){return!arguments.length||!arguments[0].type?o.apply(this,arguments):(arguments[0]=a(this,arguments[0]),o.apply(this,arguments))};const c=Object.getOwnPropertyDescriptor(n.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(n.RTCPeerConnection.prototype,"localDescription",{get(){const l=c.get.apply(this);return l.type===""?l:s(this,l)}}),n.RTCPeerConnection.prototype.removeTrack=function(u){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!u._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(!(u._pc===this))throw new DOMException("Sender was not created by this connection.","InvalidAccessError");this._streams=this._streams||{};let f;Object.keys(this._streams).forEach(d=>{this._streams[d].getTracks().find(_=>u.track===_)&&(f=this._streams[d])}),f&&(f.getTracks().length===1?this.removeStream(this._reverseStreams[f.id]):f.removeTrack(u.track),this.dispatchEvent(new Event("negotiationneeded")))}}function En(n,t){!n.RTCPeerConnection&&n.webkitRTCPeerConnection&&(n.RTCPeerConnection=n.webkitRTCPeerConnection),n.RTCPeerConnection&&t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(e){const i=n.RTCPeerConnection.prototype[e],r={[e](){return arguments[0]=new(e==="addIceCandidate"?n.RTCIceCandidate:n.RTCSessionDescription)(arguments[0]),i.apply(this,arguments)}};n.RTCPeerConnection.prototype[e]=r[e]})}function Mo(n,t){$e(n,"negotiationneeded",e=>{const i=e.target;if(!((t.version<72||i.getConfiguration&&i.getConfiguration().sdpSemantics==="plan-b")&&i.signalingState!=="stable"))return e})}const ms=Object.freeze(Object.defineProperty({__proto__:null,fixNegotiationNeeded:Mo,shimAddTrackRemoveTrack:To,shimAddTrackRemoveTrackWithNative:bo,shimGetDisplayMedia:Ra,shimGetSendersWithDtmf:_o,shimGetStats:xo,shimGetUserMedia:yo,shimMediaStream:go,shimOnTrack:vo,shimPeerConnection:En,shimSenderReceiverGetStats:So},Symbol.toStringTag,{value:"Module"}));function Aa(n,t){let e=!1;return n=JSON.parse(JSON.stringify(n)),n.filter(i=>{if(i&&(i.urls||i.url)){let r=i.urls||i.url;i.url&&!i.urls&&Jr("RTCIceServer.url","RTCIceServer.urls");const s=typeof r=="string";return s&&(r=[r]),r=r.filter(a=>{if(a.indexOf("stun:")===0)return!1;const o=a.startsWith("turn")&&!a.startsWith("turn:[")&&a.includes("transport=udp");return o&&!e?(e=!0,!0):o&&!e}),delete i.url,i.urls=s?r[0]:r,!!r.length}})}var Yr={exports:{}},ys;function Co(){return ys||(ys=1,function(n){var t={};t.generateIdentifier=function(){return Math.random().toString(36).substr(2,10)},t.localCName=t.generateIdentifier(),t.splitLines=function(e){return e.trim().split(`
|
|
1
|
+
"use strict";const M=require("./three-B_hneGZr.umd.cjs"),st={ComponentState:Object.freeze({DEFAULT:"default",TOUCHED:"touched",PRESSED:"pressed"}),ComponentProperty:Object.freeze({BUTTON:"button",X_AXIS:"xAxis",Y_AXIS:"yAxis",STATE:"state"}),ButtonTouchThreshold:.05,AxisTouchThreshold:.1,VisualResponseProperty:Object.freeze({TRANSFORM:"transform",VISIBILITY:"visibility"})};async function uo(n){const t=await fetch(n);if(t.ok)return t.json();throw new Error(t.statusText)}async function ga(n){return await uo(`${n}/profilesList.json`)}async function va(n,t,e=null,i=!0){if(!n)throw new Error("No xrInputSource supplied");const r=await ga(t);let s;if(n.profiles.some(c=>{const l=r[c];return l&&(s={profileId:c,profilePath:`${t}/${l.path}`,deprecated:!!l.deprecated}),!!s}),!s){if(!e)throw new Error("No matching profile name found");const c=r[e];if(!c)throw new Error(`No matching profile name found and default profile "${e}" missing.`);s={profileId:e,profilePath:`${t}/${c.path}`,deprecated:!!c.deprecated}}const a=await uo(s.profilePath);let o;if(i){let c;if(n.handedness==="any"?c=a.layouts[Object.keys(a.layouts)[0]]:c=a.layouts[n.handedness],!c)throw new Error(`No matching handedness, ${n.handedness}, in profile ${s.profileId}`);c.assetPath&&(o=s.profilePath.replace("profile.json",c.assetPath))}return{profile:a,assetPath:o}}const _a={xAxis:0,yAxis:0,button:0,state:st.ComponentState.DEFAULT};function xa(n=0,t=0){let e=n,i=t;if(Math.sqrt(n*n+t*t)>1){const a=Math.atan2(t,n);e=Math.cos(a),i=Math.sin(a)}return{normalizedXAxis:e*.5+.5,normalizedYAxis:i*.5+.5}}class Sa{constructor(t){this.componentProperty=t.componentProperty,this.states=t.states,this.valueNodeName=t.valueNodeName,this.valueNodeProperty=t.valueNodeProperty,this.valueNodeProperty===st.VisualResponseProperty.TRANSFORM&&(this.minNodeName=t.minNodeName,this.maxNodeName=t.maxNodeName),this.value=0,this.updateFromComponent(_a)}updateFromComponent({xAxis:t,yAxis:e,button:i,state:r}){const{normalizedXAxis:s,normalizedYAxis:a}=xa(t,e);switch(this.componentProperty){case st.ComponentProperty.X_AXIS:this.value=this.states.includes(r)?s:.5;break;case st.ComponentProperty.Y_AXIS:this.value=this.states.includes(r)?a:.5;break;case st.ComponentProperty.BUTTON:this.value=this.states.includes(r)?i:0;break;case st.ComponentProperty.STATE:this.valueNodeProperty===st.VisualResponseProperty.VISIBILITY?this.value=this.states.includes(r):this.value=this.states.includes(r)?1:0;break;default:throw new Error(`Unexpected visualResponse componentProperty ${this.componentProperty}`)}}}class ba{constructor(t,e){if(!t||!e||!e.visualResponses||!e.gamepadIndices||Object.keys(e.gamepadIndices).length===0)throw new Error("Invalid arguments supplied");this.id=t,this.type=e.type,this.rootNodeName=e.rootNodeName,this.touchPointNodeName=e.touchPointNodeName,this.visualResponses={},Object.keys(e.visualResponses).forEach(i=>{const r=new Sa(e.visualResponses[i]);this.visualResponses[i]=r}),this.gamepadIndices=Object.assign({},e.gamepadIndices),this.values={state:st.ComponentState.DEFAULT,button:this.gamepadIndices.button!==void 0?0:void 0,xAxis:this.gamepadIndices.xAxis!==void 0?0:void 0,yAxis:this.gamepadIndices.yAxis!==void 0?0:void 0}}get data(){return{id:this.id,...this.values}}updateFromGamepad(t){if(this.values.state=st.ComponentState.DEFAULT,this.gamepadIndices.button!==void 0&&t.buttons.length>this.gamepadIndices.button){const e=t.buttons[this.gamepadIndices.button];this.values.button=e.value,this.values.button=this.values.button<0?0:this.values.button,this.values.button=this.values.button>1?1:this.values.button,e.pressed||this.values.button===1?this.values.state=st.ComponentState.PRESSED:(e.touched||this.values.button>st.ButtonTouchThreshold)&&(this.values.state=st.ComponentState.TOUCHED)}this.gamepadIndices.xAxis!==void 0&&t.axes.length>this.gamepadIndices.xAxis&&(this.values.xAxis=t.axes[this.gamepadIndices.xAxis],this.values.xAxis=this.values.xAxis<-1?-1:this.values.xAxis,this.values.xAxis=this.values.xAxis>1?1:this.values.xAxis,this.values.state===st.ComponentState.DEFAULT&&Math.abs(this.values.xAxis)>st.AxisTouchThreshold&&(this.values.state=st.ComponentState.TOUCHED)),this.gamepadIndices.yAxis!==void 0&&t.axes.length>this.gamepadIndices.yAxis&&(this.values.yAxis=t.axes[this.gamepadIndices.yAxis],this.values.yAxis=this.values.yAxis<-1?-1:this.values.yAxis,this.values.yAxis=this.values.yAxis>1?1:this.values.yAxis,this.values.state===st.ComponentState.DEFAULT&&Math.abs(this.values.yAxis)>st.AxisTouchThreshold&&(this.values.state=st.ComponentState.TOUCHED)),Object.values(this.visualResponses).forEach(e=>{e.updateFromComponent(this.values)})}}class Ta{constructor(t,e,i){if(!t)throw new Error("No xrInputSource supplied");if(!e)throw new Error("No profile supplied");this.xrInputSource=t,this.assetUrl=i,this.id=e.profileId,this.layoutDescription=e.layouts[t.handedness],this.components={},Object.keys(this.layoutDescription.components).forEach(r=>{const s=this.layoutDescription.components[r];this.components[r]=new ba(r,s)}),this.updateFromGamepad()}get gripSpace(){return this.xrInputSource.gripSpace}get targetRaySpace(){return this.xrInputSource.targetRaySpace}get data(){const t=[];return Object.values(this.components).forEach(e=>{t.push(e.data)}),t}updateFromGamepad(){Object.values(this.components).forEach(t=>{t.updateFromGamepad(this.xrInputSource.gamepad)})}}const Xr=2,qt=4,oe=4,ho=4,de=new Int32Array(2),os=new Float32Array(de.buffer),as=new Float64Array(de.buffer),tr=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;class ce{constructor(t,e){this.low=t|0,this.high=e|0}static create(t,e){return t==0&&e==0?ce.ZERO:new ce(t,e)}toFloat64(){return(this.low>>>0)+this.high*4294967296}equals(t){return this.low==t.low&&this.high==t.high}}ce.ZERO=new ce(0,0);var Pn;(function(n){n[n.UTF8_BYTES=1]="UTF8_BYTES",n[n.UTF16_STRING=2]="UTF16_STRING"})(Pn||(Pn={}));class gi{constructor(t){this.bytes_=t,this.position_=0}static allocate(t){return new gi(new Uint8Array(t))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(t){this.position_=t}capacity(){return this.bytes_.length}readInt8(t){return this.readUint8(t)<<24>>24}readUint8(t){return this.bytes_[t]}readInt16(t){return this.readUint16(t)<<16>>16}readUint16(t){return this.bytes_[t]|this.bytes_[t+1]<<8}readInt32(t){return this.bytes_[t]|this.bytes_[t+1]<<8|this.bytes_[t+2]<<16|this.bytes_[t+3]<<24}readUint32(t){return this.readInt32(t)>>>0}readInt64(t){return new ce(this.readInt32(t),this.readInt32(t+4))}readUint64(t){return new ce(this.readUint32(t),this.readUint32(t+4))}readFloat32(t){return de[0]=this.readInt32(t),os[0]}readFloat64(t){return de[tr?0:1]=this.readInt32(t),de[tr?1:0]=this.readInt32(t+4),as[0]}writeInt8(t,e){this.bytes_[t]=e}writeUint8(t,e){this.bytes_[t]=e}writeInt16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeUint16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeInt32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeUint32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeInt64(t,e){this.writeInt32(t,e.low),this.writeInt32(t+4,e.high)}writeUint64(t,e){this.writeUint32(t,e.low),this.writeUint32(t+4,e.high)}writeFloat32(t,e){os[0]=e,this.writeInt32(t,de[0])}writeFloat64(t,e){as[0]=e,this.writeInt32(t,de[tr?0:1]),this.writeInt32(t+4,de[tr?1:0])}getBufferIdentifier(){if(this.bytes_.length<this.position_+qt+oe)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");let t="";for(let e=0;e<oe;e++)t+=String.fromCharCode(this.readInt8(this.position_+qt+e));return t}__offset(t,e){const i=t-this.readInt32(t);return e<this.readInt16(i)?this.readInt16(i+e):0}__union(t,e){return t.bb_pos=e+this.readInt32(e),t.bb=this,t}__string(t,e){t+=this.readInt32(t);const i=this.readInt32(t);let r="",s=0;if(t+=qt,e===Pn.UTF8_BYTES)return this.bytes_.subarray(t,t+i);for(;s<i;){let a;const o=this.readUint8(t+s++);if(o<192)a=o;else{const c=this.readUint8(t+s++);if(o<224)a=(o&31)<<6|c&63;else{const l=this.readUint8(t+s++);if(o<240)a=(o&15)<<12|(c&63)<<6|l&63;else{const u=this.readUint8(t+s++);a=(o&7)<<18|(c&63)<<12|(l&63)<<6|u&63}}}a<65536?r+=String.fromCharCode(a):(a-=65536,r+=String.fromCharCode((a>>10)+55296,(a&1023)+56320))}return r}__union_with_string(t,e){return typeof t=="string"?this.__string(e):this.__union(t,e)}__indirect(t){return t+this.readInt32(t)}__vector(t){return t+this.readInt32(t)+qt}__vector_len(t){return this.readInt32(t+this.readInt32(t))}__has_identifier(t){if(t.length!=oe)throw new Error("FlatBuffers: file identifier must be length "+oe);for(let e=0;e<oe;e++)if(t.charCodeAt(e)!=this.readInt8(this.position()+qt+e))return!1;return!0}createLong(t,e){return ce.create(t,e)}createScalarList(t,e){const i=[];for(let r=0;r<e;++r)t(r)!==null&&i.push(t(r));return i}createObjList(t,e){const i=[];for(let r=0;r<e;++r){const s=t(r);s!==null&&i.push(s.unpack())}return i}}class Wn{constructor(t){this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null;let e;t?e=t:e=1024,this.bb=gi.allocate(e),this.space=e}clear(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null}forceDefaults(t){this.force_defaults=t}dataBuffer(){return this.bb}asUint8Array(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())}prep(t,e){t>this.minalign&&(this.minalign=t);const i=~(this.bb.capacity()-this.space+e)+1&t-1;for(;this.space<i+t+e;){const r=this.bb.capacity();this.bb=Wn.growByteBuffer(this.bb),this.space+=this.bb.capacity()-r}this.pad(i)}pad(t){for(let e=0;e<t;e++)this.bb.writeInt8(--this.space,0)}writeInt8(t){this.bb.writeInt8(this.space-=1,t)}writeInt16(t){this.bb.writeInt16(this.space-=2,t)}writeInt32(t){this.bb.writeInt32(this.space-=4,t)}writeInt64(t){this.bb.writeInt64(this.space-=8,t)}writeFloat32(t){this.bb.writeFloat32(this.space-=4,t)}writeFloat64(t){this.bb.writeFloat64(this.space-=8,t)}addInt8(t){this.prep(1,0),this.writeInt8(t)}addInt16(t){this.prep(2,0),this.writeInt16(t)}addInt32(t){this.prep(4,0),this.writeInt32(t)}addInt64(t){this.prep(8,0),this.writeInt64(t)}addFloat32(t){this.prep(4,0),this.writeFloat32(t)}addFloat64(t){this.prep(8,0),this.writeFloat64(t)}addFieldInt8(t,e,i){(this.force_defaults||e!=i)&&(this.addInt8(e),this.slot(t))}addFieldInt16(t,e,i){(this.force_defaults||e!=i)&&(this.addInt16(e),this.slot(t))}addFieldInt32(t,e,i){(this.force_defaults||e!=i)&&(this.addInt32(e),this.slot(t))}addFieldInt64(t,e,i){(this.force_defaults||!e.equals(i))&&(this.addInt64(e),this.slot(t))}addFieldFloat32(t,e,i){(this.force_defaults||e!=i)&&(this.addFloat32(e),this.slot(t))}addFieldFloat64(t,e,i){(this.force_defaults||e!=i)&&(this.addFloat64(e),this.slot(t))}addFieldOffset(t,e,i){(this.force_defaults||e!=i)&&(this.addOffset(e),this.slot(t))}addFieldStruct(t,e,i){e!=i&&(this.nested(e),this.slot(t))}nested(t){if(t!=this.offset())throw new Error("FlatBuffers: struct must be serialized inline.")}notNested(){if(this.isNested)throw new Error("FlatBuffers: object serialization must not be nested.")}slot(t){this.vtable!==null&&(this.vtable[t]=this.offset())}offset(){return this.bb.capacity()-this.space}static growByteBuffer(t){const e=t.capacity();if(e&3221225472)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");const i=e<<1,r=gi.allocate(i);return r.setPosition(i-e),r.bytes().set(t.bytes(),i-e),r}addOffset(t){this.prep(qt,0),this.writeInt32(this.offset()-t+qt)}startObject(t){this.notNested(),this.vtable==null&&(this.vtable=[]),this.vtable_in_use=t;for(let e=0;e<t;e++)this.vtable[e]=0;this.isNested=!0,this.object_start=this.offset()}endObject(){if(this.vtable==null||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);const t=this.offset();let e=this.vtable_in_use-1;for(;e>=0&&this.vtable[e]==0;e--);const i=e+1;for(;e>=0;e--)this.addInt16(this.vtable[e]!=0?t-this.vtable[e]:0);const r=2;this.addInt16(t-this.object_start);const s=(i+r)*Xr;this.addInt16(s);let a=0;const o=this.space;t:for(e=0;e<this.vtables.length;e++){const c=this.bb.capacity()-this.vtables[e];if(s==this.bb.readInt16(c)){for(let l=Xr;l<s;l+=Xr)if(this.bb.readInt16(o+l)!=this.bb.readInt16(c+l))continue t;a=this.vtables[e];break}}return a?(this.space=this.bb.capacity()-t,this.bb.writeInt32(this.space,a-t)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-t,this.offset()-t)),this.isNested=!1,t}finish(t,e,i){const r=i?ho:0;if(e){const s=e;if(this.prep(this.minalign,qt+oe+r),s.length!=oe)throw new Error("FlatBuffers: file identifier must be length "+oe);for(let a=oe-1;a>=0;a--)this.writeInt8(s.charCodeAt(a))}this.prep(this.minalign,qt+r),this.addOffset(t),r&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(t,e){this.finish(t,e,!0)}requiredField(t,e){const i=this.bb.capacity()-t,r=i-this.bb.readInt32(i);if(!(this.bb.readInt16(r+e)!=0))throw new Error("FlatBuffers: field "+e+" must be set")}startVector(t,e,i){this.notNested(),this.vector_num_elems=e,this.prep(qt,t*e),this.prep(i,t*e)}endVector(){return this.writeInt32(this.vector_num_elems),this.offset()}createSharedString(t){if(!t)return 0;if(this.string_maps||(this.string_maps=new Map),this.string_maps.has(t))return this.string_maps.get(t);const e=this.createString(t);return this.string_maps.set(t,e),e}createString(t){if(!t)return 0;let e;if(t instanceof Uint8Array)e=t;else{e=[];let i=0;for(;i<t.length;){let r;const s=t.charCodeAt(i++);if(s<55296||s>=56320)r=s;else{const a=t.charCodeAt(i++);r=(s<<10)+a+-56613888}r<128?e.push(r):(r<2048?e.push(r>>6&31|192):(r<65536?e.push(r>>12&15|224):e.push(r>>18&7|240,r>>12&63|128),e.push(r>>6&63|128)),e.push(r&63|128))}}this.addInt8(0),this.startVector(1,e.length,1),this.bb.setPosition(this.space-=e.length);for(let i=0,r=this.space,s=this.bb.bytes();i<e.length;i++)s[r++]=e[i];return this.endVector()}createLong(t,e){return ce.create(t,e)}createObjectOffset(t){return t===null?0:typeof t=="string"?this.createString(t):t.pack(this)}createObjectOffsetList(t){const e=[];for(let i=0;i<t.length;++i){const r=t[i];if(r!==null)e.push(this.createObjectOffset(r));else throw new Error("FlatBuffers: Argument for createObjectOffsetList cannot contain null.")}return e}createStructOffsetList(t,e){return e(this,t.length),this.createObjectOffsetList(t),this.endVector()}}function Vr(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Wr={exports:{}},cs;function ls(){return cs||(cs=1,function(n){var t={};t.useBlobBuilder=function(){try{return new Blob([]),!1}catch{return!0}}(),t.useArrayBufferView=!t.useBlobBuilder&&function(){try{return new Blob([new Uint8Array([])]).size===0}catch{return!0}}(),n.exports.binaryFeatures=t;var e=n.exports.BlobBuilder;typeof window<"u"&&(e=n.exports.BlobBuilder=window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder||window.BlobBuilder);function i(){this._pieces=[],this._parts=[]}i.prototype.append=function(r){typeof r=="number"?this._pieces.push(r):(this.flush(),this._parts.push(r))},i.prototype.flush=function(){if(this._pieces.length>0){var r=new Uint8Array(this._pieces);t.useArrayBufferView||(r=r.buffer),this._parts.push(r),this._pieces=[]}},i.prototype.getBuffer=function(){if(this.flush(),t.useBlobBuilder){for(var r=new e,s=0,a=this._parts.length;s<a;s++)r.append(this._parts[s]);return r.getBlob()}else return new Blob(this._parts)},n.exports.BufferBuilder=i}(Wr)),Wr.exports}var Hr,us;function Ma(){if(us)return Hr;us=1;var n=ls().BufferBuilder,t=ls().binaryFeatures,e={unpack:function(o){var c=new i(o);return c.unpack()},pack:function(o){var c=new r;c.pack(o);var l=c.getBuffer();return l}};Hr=e;function i(o){this.index=0,this.dataBuffer=o,this.dataView=new Uint8Array(this.dataBuffer),this.length=this.dataBuffer.byteLength}i.prototype.unpack=function(){var o=this.unpack_uint8();if(o<128)return o;if((o^224)<32)return(o^224)-32;var c;if((c=o^160)<=15)return this.unpack_raw(c);if((c=o^176)<=15)return this.unpack_string(c);if((c=o^144)<=15)return this.unpack_array(c);if((c=o^128)<=15)return this.unpack_map(c);switch(o){case 192:return null;case 193:return;case 194:return!1;case 195:return!0;case 202:return this.unpack_float();case 203:return this.unpack_double();case 204:return this.unpack_uint8();case 205:return this.unpack_uint16();case 206:return this.unpack_uint32();case 207:return this.unpack_uint64();case 208:return this.unpack_int8();case 209:return this.unpack_int16();case 210:return this.unpack_int32();case 211:return this.unpack_int64();case 212:return;case 213:return;case 214:return;case 215:return;case 216:return c=this.unpack_uint16(),this.unpack_string(c);case 217:return c=this.unpack_uint32(),this.unpack_string(c);case 218:return c=this.unpack_uint16(),this.unpack_raw(c);case 219:return c=this.unpack_uint32(),this.unpack_raw(c);case 220:return c=this.unpack_uint16(),this.unpack_array(c);case 221:return c=this.unpack_uint32(),this.unpack_array(c);case 222:return c=this.unpack_uint16(),this.unpack_map(c);case 223:return c=this.unpack_uint32(),this.unpack_map(c)}},i.prototype.unpack_uint8=function(){var o=this.dataView[this.index]&255;return this.index++,o},i.prototype.unpack_uint16=function(){var o=this.read(2),c=(o[0]&255)*256+(o[1]&255);return this.index+=2,c},i.prototype.unpack_uint32=function(){var o=this.read(4),c=((o[0]*256+o[1])*256+o[2])*256+o[3];return this.index+=4,c},i.prototype.unpack_uint64=function(){var o=this.read(8),c=((((((o[0]*256+o[1])*256+o[2])*256+o[3])*256+o[4])*256+o[5])*256+o[6])*256+o[7];return this.index+=8,c},i.prototype.unpack_int8=function(){var o=this.unpack_uint8();return o<128?o:o-256},i.prototype.unpack_int16=function(){var o=this.unpack_uint16();return o<32768?o:o-65536},i.prototype.unpack_int32=function(){var o=this.unpack_uint32();return o<Math.pow(2,31)?o:o-Math.pow(2,32)},i.prototype.unpack_int64=function(){var o=this.unpack_uint64();return o<Math.pow(2,63)?o:o-Math.pow(2,64)},i.prototype.unpack_raw=function(o){if(this.length<this.index+o)throw new Error("BinaryPackFailure: index is out of range "+this.index+" "+o+" "+this.length);var c=this.dataBuffer.slice(this.index,this.index+o);return this.index+=o,c},i.prototype.unpack_string=function(o){for(var c=this.read(o),l=0,u="",h,f;l<o;)h=c[l],h<128?(u+=String.fromCharCode(h),l++):(h^192)<32?(f=(h^192)<<6|c[l+1]&63,u+=String.fromCharCode(f),l+=2):(f=(h&15)<<12|(c[l+1]&63)<<6|c[l+2]&63,u+=String.fromCharCode(f),l+=3);return this.index+=o,u},i.prototype.unpack_array=function(o){for(var c=new Array(o),l=0;l<o;l++)c[l]=this.unpack();return c},i.prototype.unpack_map=function(o){for(var c={},l=0;l<o;l++){var u=this.unpack(),h=this.unpack();c[u]=h}return c},i.prototype.unpack_float=function(){var o=this.unpack_uint32(),c=o>>31,l=(o>>23&255)-127,u=o&8388607|8388608;return(c===0?1:-1)*u*Math.pow(2,l-23)},i.prototype.unpack_double=function(){var o=this.unpack_uint32(),c=this.unpack_uint32(),l=o>>31,u=(o>>20&2047)-1023,h=o&1048575|1048576,f=h*Math.pow(2,u-20)+c*Math.pow(2,u-52);return(l===0?1:-1)*f},i.prototype.read=function(o){var c=this.index;if(c+o<=this.length)return this.dataView.subarray(c,c+o);throw new Error("BinaryPackFailure: read index out of range")};function r(){this.bufferBuilder=new n}r.prototype.getBuffer=function(){return this.bufferBuilder.getBuffer()},r.prototype.pack=function(o){var c=typeof o;if(c==="string")this.pack_string(o);else if(c==="number")Math.floor(o)===o?this.pack_integer(o):this.pack_double(o);else if(c==="boolean")o===!0?this.bufferBuilder.append(195):o===!1&&this.bufferBuilder.append(194);else if(c==="undefined")this.bufferBuilder.append(192);else if(c==="object")if(o===null)this.bufferBuilder.append(192);else{var l=o.constructor;if(l==Array)this.pack_array(o);else if(l==Blob||l==File||o instanceof Blob||o instanceof File)this.pack_bin(o);else if(l==ArrayBuffer)t.useArrayBufferView?this.pack_bin(new Uint8Array(o)):this.pack_bin(o);else if("BYTES_PER_ELEMENT"in o)t.useArrayBufferView?this.pack_bin(new Uint8Array(o.buffer)):this.pack_bin(o.buffer);else if(l==Object||l.toString().startsWith("class"))this.pack_object(o);else if(l==Date)this.pack_string(o.toString());else if(typeof o.toBinaryPack=="function")this.bufferBuilder.append(o.toBinaryPack());else throw new Error('Type "'+l.toString()+'" not yet supported')}else throw new Error('Type "'+c+'" not yet supported');this.bufferBuilder.flush()},r.prototype.pack_bin=function(o){var c=o.length||o.byteLength||o.size;if(c<=15)this.pack_uint8(160+c);else if(c<=65535)this.bufferBuilder.append(218),this.pack_uint16(c);else if(c<=4294967295)this.bufferBuilder.append(219),this.pack_uint32(c);else throw new Error("Invalid length");this.bufferBuilder.append(o)},r.prototype.pack_string=function(o){var c=a(o);if(c<=15)this.pack_uint8(176+c);else if(c<=65535)this.bufferBuilder.append(216),this.pack_uint16(c);else if(c<=4294967295)this.bufferBuilder.append(217),this.pack_uint32(c);else throw new Error("Invalid length");this.bufferBuilder.append(o)},r.prototype.pack_array=function(o){var c=o.length;if(c<=15)this.pack_uint8(144+c);else if(c<=65535)this.bufferBuilder.append(220),this.pack_uint16(c);else if(c<=4294967295)this.bufferBuilder.append(221),this.pack_uint32(c);else throw new Error("Invalid length");for(var l=0;l<c;l++)this.pack(o[l])},r.prototype.pack_integer=function(o){if(o>=-32&&o<=127)this.bufferBuilder.append(o&255);else if(o>=0&&o<=255)this.bufferBuilder.append(204),this.pack_uint8(o);else if(o>=-128&&o<=127)this.bufferBuilder.append(208),this.pack_int8(o);else if(o>=0&&o<=65535)this.bufferBuilder.append(205),this.pack_uint16(o);else if(o>=-32768&&o<=32767)this.bufferBuilder.append(209),this.pack_int16(o);else if(o>=0&&o<=4294967295)this.bufferBuilder.append(206),this.pack_uint32(o);else if(o>=-2147483648&&o<=2147483647)this.bufferBuilder.append(210),this.pack_int32(o);else if(o>=-9223372036854776e3&&o<=9223372036854776e3)this.bufferBuilder.append(211),this.pack_int64(o);else if(o>=0&&o<=18446744073709552e3)this.bufferBuilder.append(207),this.pack_uint64(o);else throw new Error("Invalid integer")},r.prototype.pack_double=function(o){var c=0;o<0&&(c=1,o=-o);var l=Math.floor(Math.log(o)/Math.LN2),u=o/Math.pow(2,l)-1,h=Math.floor(u*Math.pow(2,52)),f=Math.pow(2,32),d=c<<31|l+1023<<20|h/f&1048575,y=h%f;this.bufferBuilder.append(203),this.pack_int32(d),this.pack_int32(y)},r.prototype.pack_object=function(o){var c=Object.keys(o),l=c.length;if(l<=15)this.pack_uint8(128+l);else if(l<=65535)this.bufferBuilder.append(222),this.pack_uint16(l);else if(l<=4294967295)this.bufferBuilder.append(223),this.pack_uint32(l);else throw new Error("Invalid length");for(var u in o)o.hasOwnProperty(u)&&(this.pack(u),this.pack(o[u]))},r.prototype.pack_uint8=function(o){this.bufferBuilder.append(o)},r.prototype.pack_uint16=function(o){this.bufferBuilder.append(o>>8),this.bufferBuilder.append(o&255)},r.prototype.pack_uint32=function(o){var c=o&4294967295;this.bufferBuilder.append((c&4278190080)>>>24),this.bufferBuilder.append((c&16711680)>>>16),this.bufferBuilder.append((c&65280)>>>8),this.bufferBuilder.append(c&255)},r.prototype.pack_uint64=function(o){var c=o/Math.pow(2,32),l=o%Math.pow(2,32);this.bufferBuilder.append((c&4278190080)>>>24),this.bufferBuilder.append((c&16711680)>>>16),this.bufferBuilder.append((c&65280)>>>8),this.bufferBuilder.append(c&255),this.bufferBuilder.append((l&4278190080)>>>24),this.bufferBuilder.append((l&16711680)>>>16),this.bufferBuilder.append((l&65280)>>>8),this.bufferBuilder.append(l&255)},r.prototype.pack_int8=function(o){this.bufferBuilder.append(o&255)},r.prototype.pack_int16=function(o){this.bufferBuilder.append((o&65280)>>8),this.bufferBuilder.append(o&255)},r.prototype.pack_int32=function(o){this.bufferBuilder.append(o>>>24&255),this.bufferBuilder.append((o&16711680)>>>16),this.bufferBuilder.append((o&65280)>>>8),this.bufferBuilder.append(o&255)},r.prototype.pack_int64=function(o){var c=Math.floor(o/Math.pow(2,32)),l=o%Math.pow(2,32);this.bufferBuilder.append((c&4278190080)>>>24),this.bufferBuilder.append((c&16711680)>>>16),this.bufferBuilder.append((c&65280)>>>8),this.bufferBuilder.append(c&255),this.bufferBuilder.append((l&4278190080)>>>24),this.bufferBuilder.append((l&16711680)>>>16),this.bufferBuilder.append((l&65280)>>>8),this.bufferBuilder.append(l&255)};function s(o){var c=o.charCodeAt(0);return c<=2047?"00":c<=65535?"000":c<=2097151?"0000":c<=67108863?"00000":"000000"}function a(o){return o.length>600?new Blob([o]).size:o.replace(/[^\u0000-\u007F]/g,s).length}return Hr}var Ca=Ma();const hs=Vr(Ca);let fo=!0,po=!0;function li(n,t,e){const i=n.match(t);return i&&i.length>=e&&parseInt(i[e],10)}function $e(n,t,e){if(!n.RTCPeerConnection)return;const i=n.RTCPeerConnection.prototype,r=i.addEventListener;i.addEventListener=function(a,o){if(a!==t)return r.apply(this,arguments);const c=l=>{const u=e(l);u&&(o.handleEvent?o.handleEvent(u):o(u))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new Map),this._eventMap[t].set(o,c),r.apply(this,[a,c])};const s=i.removeEventListener;i.removeEventListener=function(a,o){if(a!==t||!this._eventMap||!this._eventMap[t])return s.apply(this,arguments);if(!this._eventMap[t].has(o))return s.apply(this,arguments);const c=this._eventMap[t].get(o);return this._eventMap[t].delete(o),this._eventMap[t].size===0&&delete this._eventMap[t],Object.keys(this._eventMap).length===0&&delete this._eventMap,s.apply(this,[a,c])},Object.defineProperty(i,"on"+t,{get(){return this["_on"+t]},set(a){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),a&&this.addEventListener(t,this["_on"+t]=a)},enumerable:!0,configurable:!0})}function Pa(n){return typeof n!="boolean"?new Error("Argument type: "+typeof n+". Please use a boolean."):(fo=n,n?"adapter.js logging disabled":"adapter.js logging enabled")}function wa(n){return typeof n!="boolean"?new Error("Argument type: "+typeof n+". Please use a boolean."):(po=!n,"adapter.js deprecation warnings "+(n?"disabled":"enabled"))}function Hn(){if(typeof window=="object"){if(fo)return;typeof console<"u"&&typeof console.log=="function"&&console.log.apply(console,arguments)}}function Jr(n,t){po&&console.warn(n+" is deprecated, please use "+t+" instead.")}function Ea(n){const t={browser:null,version:null};if(typeof n>"u"||!n.navigator)return t.browser="Not a browser.",t;const{navigator:e}=n;if(e.mozGetUserMedia)t.browser="firefox",t.version=li(e.userAgent,/Firefox\/(\d+)\./,1);else if(e.webkitGetUserMedia||n.isSecureContext===!1&&n.webkitRTCPeerConnection&&!n.RTCIceGatherer)t.browser="chrome",t.version=li(e.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(e.mediaDevices&&e.userAgent.match(/Edge\/(\d+).(\d+)$/))t.browser="edge",t.version=li(e.userAgent,/Edge\/(\d+).(\d+)$/,2);else if(n.RTCPeerConnection&&e.userAgent.match(/AppleWebKit\/(\d+)\./))t.browser="safari",t.version=li(e.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=n.RTCRtpTransceiver&&"currentDirection"in n.RTCRtpTransceiver.prototype;else return t.browser="Not a supported browser.",t;return t}function fs(n){return Object.prototype.toString.call(n)==="[object Object]"}function mo(n){return fs(n)?Object.keys(n).reduce(function(t,e){const i=fs(n[e]),r=i?mo(n[e]):n[e],s=i&&!Object.keys(r).length;return r===void 0||s?t:Object.assign(t,{[e]:r})},{}):n}function wn(n,t,e){!t||e.has(t.id)||(e.set(t.id,t),Object.keys(t).forEach(i=>{i.endsWith("Id")?wn(n,n.get(t[i]),e):i.endsWith("Ids")&&t[i].forEach(r=>{wn(n,n.get(r),e)})}))}function ds(n,t,e){const i=e?"outbound-rtp":"inbound-rtp",r=new Map;if(t===null)return r;const s=[];return n.forEach(a=>{a.type==="track"&&a.trackIdentifier===t.id&&s.push(a)}),s.forEach(a=>{n.forEach(o=>{o.type===i&&o.trackId===a.id&&wn(n,o,r)})}),r}const ps=Hn;function yo(n,t){const e=n&&n.navigator;if(!e.mediaDevices)return;const i=function(o){if(typeof o!="object"||o.mandatory||o.optional)return o;const c={};return Object.keys(o).forEach(l=>{if(l==="require"||l==="advanced"||l==="mediaSource")return;const u=typeof o[l]=="object"?o[l]:{ideal:o[l]};u.exact!==void 0&&typeof u.exact=="number"&&(u.min=u.max=u.exact);const h=function(f,d){return f?f+d.charAt(0).toUpperCase()+d.slice(1):d==="deviceId"?"sourceId":d};if(u.ideal!==void 0){c.optional=c.optional||[];let f={};typeof u.ideal=="number"?(f[h("min",l)]=u.ideal,c.optional.push(f),f={},f[h("max",l)]=u.ideal,c.optional.push(f)):(f[h("",l)]=u.ideal,c.optional.push(f))}u.exact!==void 0&&typeof u.exact!="number"?(c.mandatory=c.mandatory||{},c.mandatory[h("",l)]=u.exact):["min","max"].forEach(f=>{u[f]!==void 0&&(c.mandatory=c.mandatory||{},c.mandatory[h(f,l)]=u[f])})}),o.advanced&&(c.optional=(c.optional||[]).concat(o.advanced)),c},r=function(o,c){if(t.version>=61)return c(o);if(o=JSON.parse(JSON.stringify(o)),o&&typeof o.audio=="object"){const l=function(u,h,f){h in u&&!(f in u)&&(u[f]=u[h],delete u[h])};o=JSON.parse(JSON.stringify(o)),l(o.audio,"autoGainControl","googAutoGainControl"),l(o.audio,"noiseSuppression","googNoiseSuppression"),o.audio=i(o.audio)}if(o&&typeof o.video=="object"){let l=o.video.facingMode;l=l&&(typeof l=="object"?l:{ideal:l});const u=t.version<66;if(l&&(l.exact==="user"||l.exact==="environment"||l.ideal==="user"||l.ideal==="environment")&&!(e.mediaDevices.getSupportedConstraints&&e.mediaDevices.getSupportedConstraints().facingMode&&!u)){delete o.video.facingMode;let h;if(l.exact==="environment"||l.ideal==="environment"?h=["back","rear"]:(l.exact==="user"||l.ideal==="user")&&(h=["front"]),h)return e.mediaDevices.enumerateDevices().then(f=>{f=f.filter(y=>y.kind==="videoinput");let d=f.find(y=>h.some(_=>y.label.toLowerCase().includes(_)));return!d&&f.length&&h.includes("back")&&(d=f[f.length-1]),d&&(o.video.deviceId=l.exact?{exact:d.deviceId}:{ideal:d.deviceId}),o.video=i(o.video),ps("chrome: "+JSON.stringify(o)),c(o)})}o.video=i(o.video)}return ps("chrome: "+JSON.stringify(o)),c(o)},s=function(o){return t.version>=64?o:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[o.name]||o.name,message:o.message,constraint:o.constraint||o.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}},a=function(o,c,l){r(o,u=>{e.webkitGetUserMedia(u,c,h=>{l&&l(s(h))})})};if(e.getUserMedia=a.bind(e),e.mediaDevices.getUserMedia){const o=e.mediaDevices.getUserMedia.bind(e.mediaDevices);e.mediaDevices.getUserMedia=function(c){return r(c,l=>o(l).then(u=>{if(l.audio&&!u.getAudioTracks().length||l.video&&!u.getVideoTracks().length)throw u.getTracks().forEach(h=>{h.stop()}),new DOMException("","NotFoundError");return u},u=>Promise.reject(s(u))))}}}function Ra(n,t){if(!(n.navigator.mediaDevices&&"getDisplayMedia"in n.navigator.mediaDevices)&&n.navigator.mediaDevices){if(typeof t!="function"){console.error("shimGetDisplayMedia: getSourceId argument is not a function");return}n.navigator.mediaDevices.getDisplayMedia=function(i){return t(i).then(r=>{const s=i.video&&i.video.width,a=i.video&&i.video.height,o=i.video&&i.video.frameRate;return i.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:r,maxFrameRate:o||3}},s&&(i.video.mandatory.maxWidth=s),a&&(i.video.mandatory.maxHeight=a),n.navigator.mediaDevices.getUserMedia(i)})}}}function go(n){n.MediaStream=n.MediaStream||n.webkitMediaStream}function vo(n){if(typeof n=="object"&&n.RTCPeerConnection&&!("ontrack"in n.RTCPeerConnection.prototype)){Object.defineProperty(n.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});const t=n.RTCPeerConnection.prototype.setRemoteDescription;n.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=i=>{i.stream.addEventListener("addtrack",r=>{let s;n.RTCPeerConnection.prototype.getReceivers?s=this.getReceivers().find(o=>o.track&&o.track.id===r.track.id):s={track:r.track};const a=new Event("track");a.track=r.track,a.receiver=s,a.transceiver={receiver:s},a.streams=[i.stream],this.dispatchEvent(a)}),i.stream.getTracks().forEach(r=>{let s;n.RTCPeerConnection.prototype.getReceivers?s=this.getReceivers().find(o=>o.track&&o.track.id===r.id):s={track:r};const a=new Event("track");a.track=r,a.receiver=s,a.transceiver={receiver:s},a.streams=[i.stream],this.dispatchEvent(a)})},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else $e(n,"track",t=>(t.transceiver||Object.defineProperty(t,"transceiver",{value:{receiver:t.receiver}}),t))}function _o(n){if(typeof n=="object"&&n.RTCPeerConnection&&!("getSenders"in n.RTCPeerConnection.prototype)&&"createDTMFSender"in n.RTCPeerConnection.prototype){const t=function(r,s){return{track:s,get dtmf(){return this._dtmf===void 0&&(s.kind==="audio"?this._dtmf=r.createDTMFSender(s):this._dtmf=null),this._dtmf},_pc:r}};if(!n.RTCPeerConnection.prototype.getSenders){n.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const r=n.RTCPeerConnection.prototype.addTrack;n.RTCPeerConnection.prototype.addTrack=function(o,c){let l=r.apply(this,arguments);return l||(l=t(this,o),this._senders.push(l)),l};const s=n.RTCPeerConnection.prototype.removeTrack;n.RTCPeerConnection.prototype.removeTrack=function(o){s.apply(this,arguments);const c=this._senders.indexOf(o);c!==-1&&this._senders.splice(c,1)}}const e=n.RTCPeerConnection.prototype.addStream;n.RTCPeerConnection.prototype.addStream=function(s){this._senders=this._senders||[],e.apply(this,[s]),s.getTracks().forEach(a=>{this._senders.push(t(this,a))})};const i=n.RTCPeerConnection.prototype.removeStream;n.RTCPeerConnection.prototype.removeStream=function(s){this._senders=this._senders||[],i.apply(this,[s]),s.getTracks().forEach(a=>{const o=this._senders.find(c=>c.track===a);o&&this._senders.splice(this._senders.indexOf(o),1)})}}else if(typeof n=="object"&&n.RTCPeerConnection&&"getSenders"in n.RTCPeerConnection.prototype&&"createDTMFSender"in n.RTCPeerConnection.prototype&&n.RTCRtpSender&&!("dtmf"in n.RTCRtpSender.prototype)){const t=n.RTCPeerConnection.prototype.getSenders;n.RTCPeerConnection.prototype.getSenders=function(){const i=t.apply(this,[]);return i.forEach(r=>r._pc=this),i},Object.defineProperty(n.RTCRtpSender.prototype,"dtmf",{get(){return this._dtmf===void 0&&(this.track.kind==="audio"?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function xo(n){if(!n.RTCPeerConnection)return;const t=n.RTCPeerConnection.prototype.getStats;n.RTCPeerConnection.prototype.getStats=function(){const[i,r,s]=arguments;if(arguments.length>0&&typeof i=="function")return t.apply(this,arguments);if(t.length===0&&(arguments.length===0||typeof i!="function"))return t.apply(this,[]);const a=function(c){const l={};return c.result().forEach(h=>{const f={id:h.id,timestamp:h.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[h.type]||h.type};h.names().forEach(d=>{f[d]=h.stat(d)}),l[f.id]=f}),l},o=function(c){return new Map(Object.keys(c).map(l=>[l,c[l]]))};if(arguments.length>=2){const c=function(l){r(o(a(l)))};return t.apply(this,[c,i])}return new Promise((c,l)=>{t.apply(this,[function(u){c(o(a(u)))},l])}).then(r,s)}}function So(n){if(!(typeof n=="object"&&n.RTCPeerConnection&&n.RTCRtpSender&&n.RTCRtpReceiver))return;if(!("getStats"in n.RTCRtpSender.prototype)){const e=n.RTCPeerConnection.prototype.getSenders;e&&(n.RTCPeerConnection.prototype.getSenders=function(){const s=e.apply(this,[]);return s.forEach(a=>a._pc=this),s});const i=n.RTCPeerConnection.prototype.addTrack;i&&(n.RTCPeerConnection.prototype.addTrack=function(){const s=i.apply(this,arguments);return s._pc=this,s}),n.RTCRtpSender.prototype.getStats=function(){const s=this;return this._pc.getStats().then(a=>ds(a,s.track,!0))}}if(!("getStats"in n.RTCRtpReceiver.prototype)){const e=n.RTCPeerConnection.prototype.getReceivers;e&&(n.RTCPeerConnection.prototype.getReceivers=function(){const r=e.apply(this,[]);return r.forEach(s=>s._pc=this),r}),$e(n,"track",i=>(i.receiver._pc=i.srcElement,i)),n.RTCRtpReceiver.prototype.getStats=function(){const r=this;return this._pc.getStats().then(s=>ds(s,r.track,!1))}}if(!("getStats"in n.RTCRtpSender.prototype&&"getStats"in n.RTCRtpReceiver.prototype))return;const t=n.RTCPeerConnection.prototype.getStats;n.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof n.MediaStreamTrack){const i=arguments[0];let r,s,a;return this.getSenders().forEach(o=>{o.track===i&&(r?a=!0:r=o)}),this.getReceivers().forEach(o=>(o.track===i&&(s?a=!0:s=o),o.track===i)),a||r&&s?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):r?r.getStats():s?s.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return t.apply(this,arguments)}}function bo(n){n.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(a=>this._shimmedLocalStreams[a][0])};const t=n.RTCPeerConnection.prototype.addTrack;n.RTCPeerConnection.prototype.addTrack=function(a,o){if(!o)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const c=t.apply(this,arguments);return this._shimmedLocalStreams[o.id]?this._shimmedLocalStreams[o.id].indexOf(c)===-1&&this._shimmedLocalStreams[o.id].push(c):this._shimmedLocalStreams[o.id]=[o,c],c};const e=n.RTCPeerConnection.prototype.addStream;n.RTCPeerConnection.prototype.addStream=function(a){this._shimmedLocalStreams=this._shimmedLocalStreams||{},a.getTracks().forEach(l=>{if(this.getSenders().find(h=>h.track===l))throw new DOMException("Track already exists.","InvalidAccessError")});const o=this.getSenders();e.apply(this,arguments);const c=this.getSenders().filter(l=>o.indexOf(l)===-1);this._shimmedLocalStreams[a.id]=[a].concat(c)};const i=n.RTCPeerConnection.prototype.removeStream;n.RTCPeerConnection.prototype.removeStream=function(a){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[a.id],i.apply(this,arguments)};const r=n.RTCPeerConnection.prototype.removeTrack;n.RTCPeerConnection.prototype.removeTrack=function(a){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},a&&Object.keys(this._shimmedLocalStreams).forEach(o=>{const c=this._shimmedLocalStreams[o].indexOf(a);c!==-1&&this._shimmedLocalStreams[o].splice(c,1),this._shimmedLocalStreams[o].length===1&&delete this._shimmedLocalStreams[o]}),r.apply(this,arguments)}}function To(n,t){if(!n.RTCPeerConnection)return;if(n.RTCPeerConnection.prototype.addTrack&&t.version>=65)return bo(n);const e=n.RTCPeerConnection.prototype.getLocalStreams;n.RTCPeerConnection.prototype.getLocalStreams=function(){const u=e.apply(this);return this._reverseStreams=this._reverseStreams||{},u.map(h=>this._reverseStreams[h.id])};const i=n.RTCPeerConnection.prototype.addStream;n.RTCPeerConnection.prototype.addStream=function(u){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},u.getTracks().forEach(h=>{if(this.getSenders().find(d=>d.track===h))throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[u.id]){const h=new n.MediaStream(u.getTracks());this._streams[u.id]=h,this._reverseStreams[h.id]=u,u=h}i.apply(this,[u])};const r=n.RTCPeerConnection.prototype.removeStream;n.RTCPeerConnection.prototype.removeStream=function(u){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},r.apply(this,[this._streams[u.id]||u]),delete this._reverseStreams[this._streams[u.id]?this._streams[u.id].id:u.id],delete this._streams[u.id]},n.RTCPeerConnection.prototype.addTrack=function(u,h){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const f=[].slice.call(arguments,1);if(f.length!==1||!f[0].getTracks().find(_=>_===u))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");if(this.getSenders().find(_=>_.track===u))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const y=this._streams[h.id];if(y)y.addTrack(u),Promise.resolve().then(()=>{this.dispatchEvent(new Event("negotiationneeded"))});else{const _=new n.MediaStream([u]);this._streams[h.id]=_,this._reverseStreams[_.id]=h,this.addStream(_)}return this.getSenders().find(_=>_.track===u)};function s(l,u){let h=u.sdp;return Object.keys(l._reverseStreams||[]).forEach(f=>{const d=l._reverseStreams[f],y=l._streams[d.id];h=h.replace(new RegExp(y.id,"g"),d.id)}),new RTCSessionDescription({type:u.type,sdp:h})}function a(l,u){let h=u.sdp;return Object.keys(l._reverseStreams||[]).forEach(f=>{const d=l._reverseStreams[f],y=l._streams[d.id];h=h.replace(new RegExp(d.id,"g"),y.id)}),new RTCSessionDescription({type:u.type,sdp:h})}["createOffer","createAnswer"].forEach(function(l){const u=n.RTCPeerConnection.prototype[l],h={[l](){const f=arguments;return arguments.length&&typeof arguments[0]=="function"?u.apply(this,[y=>{const _=s(this,y);f[0].apply(null,[_])},y=>{f[1]&&f[1].apply(null,y)},arguments[2]]):u.apply(this,arguments).then(y=>s(this,y))}};n.RTCPeerConnection.prototype[l]=h[l]});const o=n.RTCPeerConnection.prototype.setLocalDescription;n.RTCPeerConnection.prototype.setLocalDescription=function(){return!arguments.length||!arguments[0].type?o.apply(this,arguments):(arguments[0]=a(this,arguments[0]),o.apply(this,arguments))};const c=Object.getOwnPropertyDescriptor(n.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(n.RTCPeerConnection.prototype,"localDescription",{get(){const l=c.get.apply(this);return l.type===""?l:s(this,l)}}),n.RTCPeerConnection.prototype.removeTrack=function(u){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!u._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(!(u._pc===this))throw new DOMException("Sender was not created by this connection.","InvalidAccessError");this._streams=this._streams||{};let f;Object.keys(this._streams).forEach(d=>{this._streams[d].getTracks().find(_=>u.track===_)&&(f=this._streams[d])}),f&&(f.getTracks().length===1?this.removeStream(this._reverseStreams[f.id]):f.removeTrack(u.track),this.dispatchEvent(new Event("negotiationneeded")))}}function En(n,t){!n.RTCPeerConnection&&n.webkitRTCPeerConnection&&(n.RTCPeerConnection=n.webkitRTCPeerConnection),n.RTCPeerConnection&&t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(e){const i=n.RTCPeerConnection.prototype[e],r={[e](){return arguments[0]=new(e==="addIceCandidate"?n.RTCIceCandidate:n.RTCSessionDescription)(arguments[0]),i.apply(this,arguments)}};n.RTCPeerConnection.prototype[e]=r[e]})}function Mo(n,t){$e(n,"negotiationneeded",e=>{const i=e.target;if(!((t.version<72||i.getConfiguration&&i.getConfiguration().sdpSemantics==="plan-b")&&i.signalingState!=="stable"))return e})}const ms=Object.freeze(Object.defineProperty({__proto__:null,fixNegotiationNeeded:Mo,shimAddTrackRemoveTrack:To,shimAddTrackRemoveTrackWithNative:bo,shimGetDisplayMedia:Ra,shimGetSendersWithDtmf:_o,shimGetStats:xo,shimGetUserMedia:yo,shimMediaStream:go,shimOnTrack:vo,shimPeerConnection:En,shimSenderReceiverGetStats:So},Symbol.toStringTag,{value:"Module"}));function Aa(n,t){let e=!1;return n=JSON.parse(JSON.stringify(n)),n.filter(i=>{if(i&&(i.urls||i.url)){let r=i.urls||i.url;i.url&&!i.urls&&Jr("RTCIceServer.url","RTCIceServer.urls");const s=typeof r=="string";return s&&(r=[r]),r=r.filter(a=>{if(a.indexOf("stun:")===0)return!1;const o=a.startsWith("turn")&&!a.startsWith("turn:[")&&a.includes("transport=udp");return o&&!e?(e=!0,!0):o&&!e}),delete i.url,i.urls=s?r[0]:r,!!r.length}})}var Yr={exports:{}},ys;function Co(){return ys||(ys=1,function(n){var t={};t.generateIdentifier=function(){return Math.random().toString(36).substr(2,10)},t.localCName=t.generateIdentifier(),t.splitLines=function(e){return e.trim().split(`
|
|
2
2
|
`).map(function(i){return i.trim()})},t.splitSections=function(e){var i=e.split(`
|
|
3
3
|
m=`);return i.map(function(r,s){return(s>0?"m="+r:r).trim()+`\r
|
|
4
4
|
`})},t.getDescription=function(e){var i=t.splitSections(e);return i&&i[0]},t.getMediaSections=function(e){var i=t.splitSections(e);return i.shift(),i},t.matchPrefix=function(e,i){return t.splitLines(e).filter(function(r){return r.indexOf(i)===0})},t.parseCandidate=function(e){var i;e.indexOf("a=candidate:")===0?i=e.substring(12).split(" "):i=e.substring(10).split(" ");for(var r={foundation:i[0],component:parseInt(i[1],10),protocol:i[2].toLowerCase(),priority:parseInt(i[3],10),ip:i[4],address:i[4],port:parseInt(i[5],10),type:i[7]},s=8;s<i.length;s+=2)switch(i[s]){case"raddr":r.relatedAddress=i[s+1];break;case"rport":r.relatedPort=parseInt(i[s+1],10);break;case"tcptype":r.tcpType=i[s+1];break;case"ufrag":r.ufrag=i[s+1],r.usernameFragment=i[s+1];break;default:r[i[s]]=i[s+1];break}return r},t.writeCandidate=function(e){var i=[];i.push(e.foundation),i.push(e.component),i.push(e.protocol.toUpperCase()),i.push(e.priority),i.push(e.address||e.ip),i.push(e.port);var r=e.type;return i.push("typ"),i.push(r),r!=="host"&&e.relatedAddress&&e.relatedPort&&(i.push("raddr"),i.push(e.relatedAddress),i.push("rport"),i.push(e.relatedPort)),e.tcpType&&e.protocol.toLowerCase()==="tcp"&&(i.push("tcptype"),i.push(e.tcpType)),(e.usernameFragment||e.ufrag)&&(i.push("ufrag"),i.push(e.usernameFragment||e.ufrag)),"candidate:"+i.join(" ")},t.parseIceOptions=function(e){return e.substr(14).split(" ")},t.parseRtpMap=function(e){var i=e.substr(9).split(" "),r={payloadType:parseInt(i.shift(),10)};return i=i[0].split("/"),r.name=i[0],r.clockRate=parseInt(i[1],10),r.channels=i.length===3?parseInt(i[2],10):1,r.numChannels=r.channels,r},t.writeRtpMap=function(e){var i=e.payloadType;e.preferredPayloadType!==void 0&&(i=e.preferredPayloadType);var r=e.channels||e.numChannels||1;return"a=rtpmap:"+i+" "+e.name+"/"+e.clockRate+(r!==1?"/"+r:"")+`\r
|
|
@@ -15,7 +15,7 @@ a=ice-pwd:`+e.password+`\r
|
|
|
15
15
|
`,r+=`a=rtcp:9 IN IP4 0.0.0.0\r
|
|
16
16
|
`,i.codecs.forEach(function(a){r+=t.writeRtpMap(a),r+=t.writeFmtp(a),r+=t.writeRtcpFb(a)});var s=0;return i.codecs.forEach(function(a){a.maxptime>s&&(s=a.maxptime)}),s>0&&(r+="a=maxptime:"+s+`\r
|
|
17
17
|
`),r+=`a=rtcp-mux\r
|
|
18
|
-
`,i.headerExtensions&&i.headerExtensions.forEach(function(a){r+=t.writeExtmap(a)}),r},t.parseRtpEncodingParameters=function(e){var i=[],r=t.parseRtpParameters(e),s=r.fecMechanisms.indexOf("RED")!==-1,a=r.fecMechanisms.indexOf("ULPFEC")!==-1,o=t.matchPrefix(e,"a=ssrc:").map(function(f){return t.parseSsrcMedia(f)}).filter(function(f){return f.attribute==="cname"}),c=o.length>0&&o[0].ssrc,l,u=t.matchPrefix(e,"a=ssrc-group:FID").map(function(f){var d=f.substr(17).split(" ");return d.map(function(y){return parseInt(y,10)})});u.length>0&&u[0].length>1&&u[0][0]===c&&(l=u[0][1]),r.codecs.forEach(function(f){if(f.name.toUpperCase()==="RTX"&&f.parameters.apt){var d={ssrc:c,codecPayloadType:parseInt(f.parameters.apt,10)};c&&l&&(d.rtx={ssrc:l}),i.push(d),s&&(d=JSON.parse(JSON.stringify(d)),d.fec={ssrc:c,mechanism:a?"red+ulpfec":"red"},i.push(d))}}),i.length===0&&c&&i.push({ssrc:c});var h=t.matchPrefix(e,"b=");return h.length&&(h[0].indexOf("b=TIAS:")===0?h=parseInt(h[0].substr(7),10):h[0].indexOf("b=AS:")===0?h=parseInt(h[0].substr(5),10)*1e3*.95-
|
|
18
|
+
`,i.headerExtensions&&i.headerExtensions.forEach(function(a){r+=t.writeExtmap(a)}),r},t.parseRtpEncodingParameters=function(e){var i=[],r=t.parseRtpParameters(e),s=r.fecMechanisms.indexOf("RED")!==-1,a=r.fecMechanisms.indexOf("ULPFEC")!==-1,o=t.matchPrefix(e,"a=ssrc:").map(function(f){return t.parseSsrcMedia(f)}).filter(function(f){return f.attribute==="cname"}),c=o.length>0&&o[0].ssrc,l,u=t.matchPrefix(e,"a=ssrc-group:FID").map(function(f){var d=f.substr(17).split(" ");return d.map(function(y){return parseInt(y,10)})});u.length>0&&u[0].length>1&&u[0][0]===c&&(l=u[0][1]),r.codecs.forEach(function(f){if(f.name.toUpperCase()==="RTX"&&f.parameters.apt){var d={ssrc:c,codecPayloadType:parseInt(f.parameters.apt,10)};c&&l&&(d.rtx={ssrc:l}),i.push(d),s&&(d=JSON.parse(JSON.stringify(d)),d.fec={ssrc:c,mechanism:a?"red+ulpfec":"red"},i.push(d))}}),i.length===0&&c&&i.push({ssrc:c});var h=t.matchPrefix(e,"b=");return h.length&&(h[0].indexOf("b=TIAS:")===0?h=parseInt(h[0].substr(7),10):h[0].indexOf("b=AS:")===0?h=parseInt(h[0].substr(5),10)*1e3*.95-2e3*8:h=void 0,i.forEach(function(f){f.maxBitrate=h})),i},t.parseRtcpParameters=function(e){var i={},r=t.matchPrefix(e,"a=ssrc:").map(function(o){return t.parseSsrcMedia(o)}).filter(function(o){return o.attribute==="cname"})[0];r&&(i.cname=r.value,i.ssrc=r.ssrc);var s=t.matchPrefix(e,"a=rtcp-rsize");i.reducedSize=s.length>0,i.compound=s.length===0;var a=t.matchPrefix(e,"a=rtcp-mux");return i.mux=a.length>0,i},t.parseMsid=function(e){var i,r=t.matchPrefix(e,"a=msid:");if(r.length===1)return i=r[0].substr(7).split(" "),{stream:i[0],track:i[1]};var s=t.matchPrefix(e,"a=ssrc:").map(function(a){return t.parseSsrcMedia(a)}).filter(function(a){return a.attribute==="msid"});if(s.length>0)return i=s[0].value.split(" "),{stream:i[0],track:i[1]}},t.parseSctpDescription=function(e){var i=t.parseMLine(e),r=t.matchPrefix(e,"a=max-message-size:"),s;r.length>0&&(s=parseInt(r[0].substr(19),10)),isNaN(s)&&(s=65536);var a=t.matchPrefix(e,"a=sctp-port:");if(a.length>0)return{port:parseInt(a[0].substr(12),10),protocol:i.fmt,maxMessageSize:s};var o=t.matchPrefix(e,"a=sctpmap:");if(o.length>0){var c=t.matchPrefix(e,"a=sctpmap:")[0].substr(10).split(" ");return{port:parseInt(c[0],10),protocol:c[1],maxMessageSize:s}}},t.writeSctpDescription=function(e,i){var r=[];return e.protocol!=="DTLS/SCTP"?r=["m="+e.kind+" 9 "+e.protocol+" "+i.protocol+`\r
|
|
19
19
|
`,`c=IN IP4 0.0.0.0\r
|
|
20
20
|
`,"a=sctp-port:"+i.port+`\r
|
|
21
21
|
`]:r=["m="+e.kind+" 9 "+e.protocol+" "+i.port+`\r
|
|
@@ -1118,4 +1118,4 @@ void main() {
|
|
|
1118
1118
|
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
|
|
1119
1119
|
|
|
1120
1120
|
#include <fog_vertex>
|
|
1121
|
-
}`;class Cl extends oa{constructor(t){super(t),this.vector_=new O,this.vector2_=new O,this.vector3_=new O,this.quaternion_=new J,this.maxParticles=1e4,this.setupBuffers(),this.rebuildMaterial()}setupBuffers(){this.geometry&&this.geometry.dispose(),this.geometry=new M.BufferGeometry,this.indexBuffer=new M.BufferAttribute(new Uint32Array(this.maxParticles*6),1),this.indexBuffer.setUsage(M.DynamicDrawUsage),this.geometry.setIndex(this.indexBuffer),this.positionBuffer=new M.BufferAttribute(new Float32Array(this.maxParticles*6),3),this.positionBuffer.setUsage(M.DynamicDrawUsage),this.geometry.setAttribute("position",this.positionBuffer),this.previousBuffer=new M.BufferAttribute(new Float32Array(this.maxParticles*6),3),this.previousBuffer.setUsage(M.DynamicDrawUsage),this.geometry.setAttribute("previous",this.previousBuffer),this.nextBuffer=new M.BufferAttribute(new Float32Array(this.maxParticles*6),3),this.nextBuffer.setUsage(M.DynamicDrawUsage),this.geometry.setAttribute("next",this.nextBuffer),this.widthBuffer=new M.BufferAttribute(new Float32Array(this.maxParticles*2),1),this.widthBuffer.setUsage(M.DynamicDrawUsage),this.geometry.setAttribute("width",this.widthBuffer),this.sideBuffer=new M.BufferAttribute(new Float32Array(this.maxParticles*2),1),this.sideBuffer.setUsage(M.DynamicDrawUsage),this.geometry.setAttribute("side",this.sideBuffer),this.uvBuffer=new M.BufferAttribute(new Float32Array(this.maxParticles*4),2),this.uvBuffer.setUsage(M.DynamicDrawUsage),this.geometry.setAttribute("uv",this.uvBuffer),this.colorBuffer=new M.BufferAttribute(new Float32Array(this.maxParticles*8),4),this.colorBuffer.setUsage(M.DynamicDrawUsage),this.geometry.setAttribute("color",this.colorBuffer)}expandBuffers(t){for(;t>=this.maxParticles;)this.maxParticles*=2;this.setupBuffers()}rebuildMaterial(){this.layers.mask=this.settings.layers.mask;const t={lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},resolution:{value:new Je(1,1)},sizeAttenuation:{value:1},visibility:{value:1},alphaTest:{value:0}},e={};if(e.USE_UV="",e.USE_COLOR_ALPHA="",this.settings.material.map&&(e.USE_MAP="",e.MAP_UV=Nn(this.settings.material.map.channel),t.map=new M.Uniform$1(this.settings.material.map),t.mapTransform=new M.Uniform$1(new Xt().copy(this.settings.material.map.matrix))),this.settings.material.defines&&this.settings.material.defines.USE_COLOR_AS_ALPHA!==void 0&&(e.USE_COLOR_AS_ALPHA=""),this.settings.renderMode===exports.RenderMode.Trail)this.material=new M.ShaderMaterial({uniforms:t,defines:e,vertexShader:Ml,fragmentShader:Tl,transparent:this.settings.material.transparent,depthWrite:!this.settings.material.transparent,side:this.settings.material.side,blending:this.settings.material.blending||M.AdditiveBlending,blendDst:this.settings.material.blendDst,blendSrc:this.settings.material.blendSrc,blendEquation:this.settings.material.blendEquation,premultipliedAlpha:this.settings.material.premultipliedAlpha});else throw new Error("render mode unavailable")}update(){let t=0,e=0,i=0;this.systems.forEach(r=>{for(let s=0;s<r.particleNum;s++)i+=r.particles[s].previous.length*2}),i>this.maxParticles&&this.expandBuffers(i),this.systems.forEach(r=>{r.emitter.updateMatrixWorld&&(r.emitter.updateWorldMatrix(!0,!1),r.emitter.updateMatrixWorld(!0));const s=this.quaternion_,a=this.vector2_,o=this.vector3_;r.emitter.matrixWorld.decompose(a,s,o);const c=r.particles,l=r.particleNum,u=this.settings.uTileCount,h=this.settings.vTileCount,f=1/u,d=1/h;for(let y=0;y<l;y++){const _=c[y],p=_.uvTile%h,m=Math.floor(_.uvTile/h+.001),g=_.previous.values();let v=g.next(),S=v.value,x=S;v.done||(v=g.next());let b;v.value!==void 0?b=v.value:b=x;for(let T=0;T<_.previous.length;T++,t+=2){if(this.positionBuffer.setXYZ(t,x.position.x,x.position.y,x.position.z),this.positionBuffer.setXYZ(t+1,x.position.x,x.position.y,x.position.z),r.worldSpace?(this.positionBuffer.setXYZ(t,x.position.x,x.position.y,x.position.z),this.positionBuffer.setXYZ(t+1,x.position.x,x.position.y,x.position.z)):(_.parentMatrix?this.vector_.copy(x.position).applyMatrix4(_.parentMatrix):this.vector_.copy(x.position).applyMatrix4(r.emitter.matrixWorld),this.positionBuffer.setXYZ(t,this.vector_.x,this.vector_.y,this.vector_.z),this.positionBuffer.setXYZ(t+1,this.vector_.x,this.vector_.y,this.vector_.z)),r.worldSpace?(this.previousBuffer.setXYZ(t,S.position.x,S.position.y,S.position.z),this.previousBuffer.setXYZ(t+1,S.position.x,S.position.y,S.position.z)):(_.parentMatrix?this.vector_.copy(S.position).applyMatrix4(_.parentMatrix):this.vector_.copy(S.position).applyMatrix4(r.emitter.matrixWorld),this.previousBuffer.setXYZ(t,this.vector_.x,this.vector_.y,this.vector_.z),this.previousBuffer.setXYZ(t+1,this.vector_.x,this.vector_.y,this.vector_.z)),r.worldSpace?(this.nextBuffer.setXYZ(t,b.position.x,b.position.y,b.position.z),this.nextBuffer.setXYZ(t+1,b.position.x,b.position.y,b.position.z)):(_.parentMatrix?this.vector_.copy(b.position).applyMatrix4(_.parentMatrix):this.vector_.copy(b.position).applyMatrix4(r.emitter.matrixWorld),this.nextBuffer.setXYZ(t,this.vector_.x,this.vector_.y,this.vector_.z),this.nextBuffer.setXYZ(t+1,this.vector_.x,this.vector_.y,this.vector_.z)),this.sideBuffer.setX(t,-1),this.sideBuffer.setX(t+1,1),r.worldSpace)this.widthBuffer.setX(t,x.size),this.widthBuffer.setX(t+1,x.size);else if(_.parentMatrix)this.widthBuffer.setX(t,x.size),this.widthBuffer.setX(t+1,x.size);else{const w=(Math.abs(o.x)+Math.abs(o.y)+Math.abs(o.z))/3;this.widthBuffer.setX(t,x.size*w),this.widthBuffer.setX(t+1,x.size*w)}this.uvBuffer.setXY(t,(T/_.previous.length+p)*f,(h-m-1)*d),this.uvBuffer.setXY(t+1,(T/_.previous.length+p)*f,(h-m)*d),this.colorBuffer.setXYZW(t,x.color.x,x.color.y,x.color.z,x.color.w),this.colorBuffer.setXYZW(t+1,x.color.x,x.color.y,x.color.z,x.color.w),T+1<_.previous.length&&(this.indexBuffer.setX(e*3,t),this.indexBuffer.setX(e*3+1,t+1),this.indexBuffer.setX(e*3+2,t+2),e++,this.indexBuffer.setX(e*3,t+2),this.indexBuffer.setX(e*3+1,t+1),this.indexBuffer.setX(e*3+2,t+3),e++),S=x,x=b,v.done||(v=g.next(),v.value!==void 0&&(b=v.value))}}}),this.positionBuffer.clearUpdateRanges(),this.positionBuffer.addUpdateRange(0,t*3),this.positionBuffer.needsUpdate=!0,this.previousBuffer.clearUpdateRanges(),this.previousBuffer.addUpdateRange(0,t*3),this.previousBuffer.needsUpdate=!0,this.nextBuffer.clearUpdateRanges(),this.nextBuffer.addUpdateRange(0,t*3),this.nextBuffer.needsUpdate=!0,this.sideBuffer.clearUpdateRanges(),this.sideBuffer.addUpdateRange(0,t),this.sideBuffer.needsUpdate=!0,this.widthBuffer.clearUpdateRanges(),this.widthBuffer.addUpdateRange(0,t),this.widthBuffer.needsUpdate=!0,this.uvBuffer.clearUpdateRanges(),this.uvBuffer.addUpdateRange(0,t*2),this.uvBuffer.needsUpdate=!0,this.colorBuffer.clearUpdateRanges(),this.colorBuffer.addUpdateRange(0,t*4),this.colorBuffer.needsUpdate=!0,this.indexBuffer.clearUpdateRanges(),this.indexBuffer.addUpdateRange(0,e*3),this.indexBuffer.needsUpdate=!0,this.geometry.setDrawRange(0,e*3)}dispose(){this.geometry.dispose()}}class Yi{get geometry(){return this._geometry}set geometry(t){if(this._geometry=t,t===void 0||typeof t=="string")return;const e=new M.Triangle;this._triangleIndexToArea.length=0;let i=0;if(!t.getIndex())return;const r=t.getIndex().array,s=r.length/3;this._triangleIndexToArea.push(0);for(let a=0;a<s;a++)e.setFromAttributeAndIndices(t.getAttribute("position"),r[a*3],r[a*3+1],r[a*3+2]),i+=e.getArea(),this._triangleIndexToArea.push(i);t.userData.triangleIndexToArea=this._triangleIndexToArea}constructor(t){this.type="mesh_surface",this._triangleIndexToArea=[],this._tempA=new M.Vector3,this._tempB=new M.Vector3,this._tempC=new M.Vector3,t&&(this.geometry=t)}initialize(t){const e=this._geometry;if(!e||e.getIndex()===null){t.position.set(0,0,0),t.velocity.set(0,0,1).multiplyScalar(t.startSpeed);return}const i=this._triangleIndexToArea.length-1;let r=0,s=i;const a=Math.random()*this._triangleIndexToArea[i];for(;r+1<s;){const d=Math.floor((r+s)/2);a<this._triangleIndexToArea[d]?s=d:r=d}let o=Math.random(),c=Math.random();o+c>1&&(o=1-o,c=1-c);const l=e.getIndex().array[r*3],u=e.getIndex().array[r*3+1],h=e.getIndex().array[r*3+2],f=e.getAttribute("position");this._tempA.fromBufferAttribute(f,l),this._tempB.fromBufferAttribute(f,u),this._tempC.fromBufferAttribute(f,h),this._tempB.sub(this._tempA),this._tempC.sub(this._tempA),this._tempA.addScaledVector(this._tempB,o).addScaledVector(this._tempC,c),t.position.copy(this._tempA),this._tempA.copy(this._tempB).cross(this._tempC).normalize(),t.velocity.copy(this._tempA).normalize().multiplyScalar(t.startSpeed)}toJSON(){return{type:"mesh_surface",mesh:this._geometry?this._geometry.uuid:""}}static fromJSON(t,e){return new Yi(e.geometries[t.geometry])}clone(){return new Yi(this._geometry)}update(t,e){}}il({id:"three.quarks",emitterShapes:[{type:"mesh_surface",params:[["geometry",["geometry"]]],constructor:Yi,loadJSON:Yi.fromJSON}],behaviors:[]});class is extends M.Object3D{constructor(){super(),this.batches=[],this.systemToBatchIndex=new Map,this.type="BatchedRenderer",this.depthTexture=null}static equals(t,e){return t.material.side===e.material.side&&t.material.blending===e.material.blending&&t.material.blendSrc===e.material.blendSrc&&t.material.blendDst===e.material.blendDst&&t.material.blendEquation===e.material.blendEquation&&t.material.premultipliedAlpha===e.material.premultipliedAlpha&&t.material.transparent===e.material.transparent&&t.material.depthTest===e.material.depthTest&&t.material.type===e.material.type&&t.material.alphaTest===e.material.alphaTest&&t.material.map===e.material.map&&t.renderMode===e.renderMode&&t.blendTiles===e.blendTiles&&t.softParticles===e.softParticles&&t.softFarFade===e.softFarFade&&t.softNearFade===e.softNearFade&&t.uTileCount===e.uTileCount&&t.vTileCount===e.vTileCount&&t.instancingGeometry===e.instancingGeometry&&t.renderOrder===e.renderOrder&&t.layers.mask===e.layers.mask}addSystem(t){t._renderer=this;const e=t.getRendererSettings();for(let r=0;r<this.batches.length;r++)if(is.equals(this.batches[r].settings,e)){this.batches[r].addSystem(t),this.systemToBatchIndex.set(t,r);return}let i;switch(e.renderMode){case exports.RenderMode.Trail:i=new Cl(e);break;case exports.RenderMode.Mesh:case exports.RenderMode.BillBoard:case exports.RenderMode.VerticalBillBoard:case exports.RenderMode.HorizontalBillBoard:case exports.RenderMode.StretchedBillBoard:i=new bl(e);break}this.depthTexture&&i.applyDepthTexture(this.depthTexture),i.addSystem(t),this.batches.push(i),this.systemToBatchIndex.set(t,this.batches.length-1),this.add(i)}deleteSystem(t){const e=this.systemToBatchIndex.get(t);e!=null&&(this.batches[e].removeSystem(t),this.systemToBatchIndex.delete(t))}setDepthTexture(t){this.depthTexture=t;for(const e of this.batches)e.applyDepthTexture(t)}updateSystem(t){this.deleteSystem(t),this.addSystem(t)}update(t){this.systemToBatchIndex.forEach((e,i)=>{i.update(t)});for(let e=0;e<this.batches.length;e++)this.batches[e].update()}}const Pl=is;hl();console.log("%c Particle system powered by three.quarks. https://quarks.art/","font-size: 14px; font-weight: bold;");const aa=Math.sqrt(5),wl=(aa-1)/4,at=(5-aa)/20,ar=n=>Math.floor(n)|0,cr=new Float64Array([0,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,1,0,1,1,1,0,1,-1,1,0,-1,1,1,0,-1,-1,-1,0,1,1,-1,0,1,-1,-1,0,-1,1,-1,0,-1,-1,1,1,0,1,1,1,0,-1,1,-1,0,1,1,-1,0,-1,-1,1,0,1,-1,1,0,-1,-1,-1,0,1,-1,-1,0,-1,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,0]);function El(n=Math.random){const t=Rl(n),e=new Float64Array(t).map(a=>cr[a%32*4]),i=new Float64Array(t).map(a=>cr[a%32*4+1]),r=new Float64Array(t).map(a=>cr[a%32*4+2]),s=new Float64Array(t).map(a=>cr[a%32*4+3]);return function(o,c,l,u){let h,f,d,y,_;const p=(o+c+l+u)*wl,m=ar(o+p),g=ar(c+p),v=ar(l+p),S=ar(u+p),x=(m+g+v+S)*at,b=m-x,T=g-x,w=v-x,C=S-x,P=o-b,R=c-T,E=l-w,A=u-C;let k=0,z=0,U=0,L=0;P>R?k++:z++,P>E?k++:U++,P>A?k++:L++,R>E?z++:U++,R>A?z++:L++,E>A?U++:L++;const I=k>=3?1:0,X=z>=3?1:0,Z=U>=3?1:0,it=L>=3?1:0,K=k>=2?1:0,pt=z>=2?1:0,mt=U>=2?1:0,rt=L>=2?1:0,W=k>=1?1:0,j=z>=1?1:0,Ht=U>=1?1:0,Dt=L>=1?1:0,Lt=P-I+at,Vt=R-X+at,vt=E-Z+at,At=A-it+at,_t=P-K+2*at,Yt=R-pt+2*at,Zt=E-mt+2*at,H=A-rt+2*at,Jt=P-W+3*at,Qt=R-j+3*at,ve=E-Ht+3*at,Kt=A-Dt+3*at,te=P-1+4*at,ee=R-1+4*at,ie=E-1+4*at,re=A-1+4*at,kt=m&255,zt=g&255,Bt=v&255,Ot=S&255;let V=.6-P*P-R*R-E*E-A*A;if(V<0)h=0;else{const q=kt+t[zt+t[Bt+t[Ot]]];V*=V,h=V*V*(e[q]*P+i[q]*R+r[q]*E+s[q]*A)}let We=.6-Lt*Lt-Vt*Vt-vt*vt-At*At;if(We<0)f=0;else{const q=kt+I+t[zt+X+t[Bt+Z+t[Ot+it]]];We*=We,f=We*We*(e[q]*Lt+i[q]*Vt+r[q]*vt+s[q]*At)}let He=.6-_t*_t-Yt*Yt-Zt*Zt-H*H;if(He<0)d=0;else{const q=kt+K+t[zt+pt+t[Bt+mt+t[Ot+rt]]];He*=He,d=He*He*(e[q]*_t+i[q]*Yt+r[q]*Zt+s[q]*H)}let Ye=.6-Jt*Jt-Qt*Qt-ve*ve-Kt*Kt;if(Ye<0)y=0;else{const q=kt+W+t[zt+j+t[Bt+Ht+t[Ot+Dt]]];Ye*=Ye,y=Ye*Ye*(e[q]*Jt+i[q]*Qt+r[q]*ve+s[q]*Kt)}let Ze=.6-te*te-ee*ee-ie*ie-re*re;if(Ze<0)_=0;else{const q=kt+1+t[zt+1+t[Bt+1+t[Ot+1]]];Ze*=Ze,_=Ze*Ze*(e[q]*te+i[q]*ee+r[q]*ie+s[q]*re)}return 27*(h+f+d+y+_)}}function Rl(n){const e=new Uint8Array(512);for(let i=0;i<512/2;i++)e[i]=i;for(let i=0;i<512/2-1;i++){const r=i+~~(n()*(256-i)),s=e[i];e[i]=e[r],e[r]=s}for(let i=256;i<512;i++)e[i]=e[i-256];return e}class Al{constructor(t,e){if(this._retries=0,!Number.isInteger(t)||t<0)throw new Error("Base must be a positive integer or zero");if(e!==void 0&&(!Number.isInteger(e)||e<0))throw new Error("ExpMax must be a undefined, a positive integer or zero");this.base=t,this.expMax=e,this.i=0}get retries(){return this._retries}get current(){return this.base*Math.pow(2,this.i)}next(){return this._retries++,this.i=this.expMax===void 0?this.i+1:Math.min(this.i+1,this.expMax),this.current}reset(){this._retries=0,this.i=0}}var G;(function(n){n.open="open",n.close="close",n.error="error",n.message="message",n.retry="retry",n.reconnect="reconnect"})(G||(G={}));class ca{constructor(t,e,i){var r,s,a,o,c,l,u,h,f,d,y,_,p,m,g;this._closedByUser=!1,this.handleOpenEvent=v=>this.handleEvent(G.open,v),this.handleErrorEvent=v=>this.handleEvent(G.error,v),this.handleCloseEvent=v=>this.handleEvent(G.close,v),this.handleMessageEvent=v=>this.handleEvent(G.message,v),this._url=t,this._protocols=e,this._options={buffer:i==null?void 0:i.buffer,retry:{maxRetries:(r=i==null?void 0:i.retry)===null||r===void 0?void 0:r.maxRetries,instantReconnect:(s=i==null?void 0:i.retry)===null||s===void 0?void 0:s.instantReconnect,backoff:(a=i==null?void 0:i.retry)===null||a===void 0?void 0:a.backoff},listeners:{open:[...(c=(o=i==null?void 0:i.listeners)===null||o===void 0?void 0:o.open)!==null&&c!==void 0?c:[]],close:[...(u=(l=i==null?void 0:i.listeners)===null||l===void 0?void 0:l.close)!==null&&u!==void 0?u:[]],error:[...(f=(h=i==null?void 0:i.listeners)===null||h===void 0?void 0:h.error)!==null&&f!==void 0?f:[]],message:[...(y=(d=i==null?void 0:i.listeners)===null||d===void 0?void 0:d.message)!==null&&y!==void 0?y:[]],retry:[...(p=(_=i==null?void 0:i.listeners)===null||_===void 0?void 0:_.retry)!==null&&p!==void 0?p:[]],reconnect:[...(g=(m=i==null?void 0:i.listeners)===null||m===void 0?void 0:m.reconnect)!==null&&g!==void 0?g:[]]}},this._underlyingWebsocket=this.tryConnect()}get url(){return this._url}get protocols(){return this._protocols}get buffer(){return this._options.buffer}get maxRetries(){return this._options.retry.maxRetries}get instantReconnect(){return this._options.retry.instantReconnect}get backoff(){return this._options.retry.backoff}get closedByUser(){return this._closedByUser}get lastConnection(){return this._lastConnection}get underlyingWebsocket(){return this._underlyingWebsocket}get readyState(){return this._underlyingWebsocket.readyState}get bufferedAmount(){return this._underlyingWebsocket.bufferedAmount}get extensions(){return this._underlyingWebsocket.extensions}get binaryType(){return this._underlyingWebsocket.binaryType}set binaryType(t){this._underlyingWebsocket.binaryType=t}send(t){this.closedByUser||(this._underlyingWebsocket.readyState===this._underlyingWebsocket.OPEN?this._underlyingWebsocket.send(t):this.buffer!==void 0&&this.buffer.add(t))}close(t,e){this.cancelScheduledConnectionRetry(),this._closedByUser=!0,this._underlyingWebsocket.close(t,e)}addEventListener(t,e,i){this._options.listeners[t].push({listener:e,options:i})}removeEventListener(t,e,i){const r=s=>s.listener!==e||s.options!==i;this._options.listeners[t]=this._options.listeners[t].filter(r)}tryConnect(){return this._underlyingWebsocket=new WebSocket(this.url,this.protocols),this._underlyingWebsocket.addEventListener(G.open,this.handleOpenEvent),this._underlyingWebsocket.addEventListener(G.close,this.handleCloseEvent),this._underlyingWebsocket.addEventListener(G.error,this.handleErrorEvent),this._underlyingWebsocket.addEventListener(G.message,this.handleMessageEvent),this._underlyingWebsocket}clearWebsocket(){this._underlyingWebsocket.removeEventListener(G.open,this.handleOpenEvent),this._underlyingWebsocket.removeEventListener(G.close,this.handleCloseEvent),this._underlyingWebsocket.removeEventListener(G.error,this.handleErrorEvent),this._underlyingWebsocket.removeEventListener(G.message,this.handleMessageEvent),this._underlyingWebsocket.close()}dispatchEvent(t,e){const i=this._options.listeners[t],r=[];i.forEach(({listener:s,options:a})=>{s(this,e),(a===void 0||a.once===void 0||!a.once)&&r.push({listener:s,options:a})}),this._options.listeners[t]=r}handleEvent(t,e){switch(t){case G.close:this.dispatchEvent(t,e),this.scheduleConnectionRetryIfNeeded();break;case G.open:if(this.backoff!==void 0&&this._lastConnection!==void 0){const i={retries:this.backoff.retries,lastConnection:new Date(this._lastConnection)},r=new CustomEvent(G.reconnect,{detail:i});this.dispatchEvent(G.reconnect,r),this.backoff.reset()}this._lastConnection=new Date,this.dispatchEvent(t,e),this.sendBufferedData();break;case G.retry:this.dispatchEvent(t,e),this.clearWebsocket(),this.tryConnect();break;default:this.dispatchEvent(t,e);break}}sendBufferedData(){if(this.buffer!==void 0)for(let t=this.buffer.read();t!==void 0;t=this.buffer.read())this.send(t)}scheduleConnectionRetryIfNeeded(){if(this.closedByUser||this.backoff===void 0)return;const t=i=>{const r=new CustomEvent(G.retry,{detail:i});this.handleEvent(G.retry,r)},e={backoff:this._options.retry.instantReconnect===!0?0:this.backoff.next(),retries:this._options.retry.instantReconnect===!0?0:this.backoff.retries,lastConnection:this._lastConnection};(this._options.retry.maxRetries===void 0||e.retries<=this._options.retry.maxRetries)&&(this.retryTimeout=globalThis.setTimeout(()=>t(e),e.backoff))}cancelScheduledConnectionRetry(){globalThis.clearTimeout(this.retryTimeout)}}class kl{constructor(t){this._url=t}get url(){return this._url}withProtocols(t){return this._protocols=t,this}get protocols(){return this._protocols}withMaxRetries(t){var e;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(e=this._options)===null||e===void 0?void 0:e.retry),{maxRetries:t})}),this}get maxRetries(){var t,e;return(e=(t=this._options)===null||t===void 0?void 0:t.retry)===null||e===void 0?void 0:e.maxRetries}withInstantReconnect(t){var e;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(e=this._options)===null||e===void 0?void 0:e.retry),{instantReconnect:t})}),this}get instantReconnect(){var t,e;return(e=(t=this._options)===null||t===void 0?void 0:t.retry)===null||e===void 0?void 0:e.instantReconnect}withBackoff(t){var e;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(e=this._options)===null||e===void 0?void 0:e.retry),{backoff:t})}),this}get backoff(){var t,e;return(e=(t=this._options)===null||t===void 0?void 0:t.retry)===null||e===void 0?void 0:e.backoff}withBuffer(t){return this._options=Object.assign(Object.assign({},this._options),{buffer:t}),this}get buffer(){var t;return(t=this._options)===null||t===void 0?void 0:t.buffer}onOpen(t,e){return this.addListener(G.open,t,e),this}onClose(t,e){return this.addListener(G.close,t,e),this}onError(t,e){return this.addListener(G.error,t,e),this}onMessage(t,e){return this.addListener(G.message,t,e),this}onRetry(t,e){return this.addListener(G.retry,t,e),this}onReconnect(t,e){return this.addListener(G.reconnect,t,e),this}build(){return new ca(this._url,this._protocols,this._options)}addListener(t,e,i){var r,s,a,o,c,l,u,h,f,d,y,_,p,m,g,v,S,x,b,T,w;return this._options=Object.assign(Object.assign({},this._options),{listeners:{open:(a=(s=(r=this._options)===null||r===void 0?void 0:r.listeners)===null||s===void 0?void 0:s.open)!==null&&a!==void 0?a:[],close:(l=(c=(o=this._options)===null||o===void 0?void 0:o.listeners)===null||c===void 0?void 0:c.close)!==null&&l!==void 0?l:[],error:(f=(h=(u=this._options)===null||u===void 0?void 0:u.listeners)===null||h===void 0?void 0:h.error)!==null&&f!==void 0?f:[],message:(_=(y=(d=this._options)===null||d===void 0?void 0:d.listeners)===null||y===void 0?void 0:y.message)!==null&&_!==void 0?_:[],retry:(g=(m=(p=this._options)===null||p===void 0?void 0:p.listeners)===null||m===void 0?void 0:m.retry)!==null&&g!==void 0?g:[],reconnect:(x=(S=(v=this._options)===null||v===void 0?void 0:v.listeners)===null||S===void 0?void 0:S.reconnect)!==null&&x!==void 0?x:[],[t]:[...(w=(T=(b=this._options)===null||b===void 0?void 0:b.listeners)===null||T===void 0?void 0:T[t])!==null&&w!==void 0?w:[],{listener:e,options:i}]}}),this}}const zl=Object.freeze(Object.defineProperty({__proto__:null,ExponentialBackoff:Al,Websocket:ca,WebsocketBuilder:kl,get WebsocketEvent(){return G}},Symbol.toStringTag,{value:"Module"})),rs=0,la=1,ua=2,Fn=2,dn=1.25,$s=1,mi=6*4+4+4,$r=65535,Bl=Math.pow(2,-24),pn=Symbol("SKIP_GENERATION");function Ol(n){return n.index?n.index.count:n.attributes.position.count}function Xe(n){return Ol(n)/3}function Il(n,t=ArrayBuffer){return n>65535?new Uint32Array(new t(4*n)):new Uint16Array(new t(2*n))}function Ul(n,t){if(!n.index){const e=n.attributes.position.count,i=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,r=Il(e,i);n.setIndex(new M.BufferAttribute(r,1));for(let s=0;s<e;s++)r[s]=s}}function ha(n,t){const e=Xe(n),i=t||n.drawRange,r=i.start/3,s=(i.start+i.count)/3,a=Math.max(0,r),o=Math.min(e,s)-a;return[{offset:Math.floor(a),count:Math.floor(o)}]}function fa(n,t){if(!n.groups||!n.groups.length)return ha(n,t);const e=[],i=new Set,r=t||n.drawRange,s=r.start/3,a=(r.start+r.count)/3;for(const c of n.groups){const l=c.start/3,u=(c.start+c.count)/3;i.add(Math.max(s,l)),i.add(Math.min(a,u))}const o=Array.from(i.values()).sort((c,l)=>c-l);for(let c=0;c<o.length-1;c++){const l=o[c],u=o[c+1];e.push({offset:Math.floor(l),count:Math.floor(u-l)})}return e}function Nl(n,t){const e=Xe(n),i=fa(n,t).sort((a,o)=>a.offset-o.offset),r=i[i.length-1];r.count=Math.min(e-r.offset,r.count);let s=0;return i.forEach(({count:a})=>s+=a),e!==s}function mn(n,t,e,i,r){let s=1/0,a=1/0,o=1/0,c=-1/0,l=-1/0,u=-1/0,h=1/0,f=1/0,d=1/0,y=-1/0,_=-1/0,p=-1/0;for(let m=t*6,g=(t+e)*6;m<g;m+=6){const v=n[m+0],S=n[m+1],x=v-S,b=v+S;x<s&&(s=x),b>c&&(c=b),v<h&&(h=v),v>y&&(y=v);const T=n[m+2],w=n[m+3],C=T-w,P=T+w;C<a&&(a=C),P>l&&(l=P),T<f&&(f=T),T>_&&(_=T);const R=n[m+4],E=n[m+5],A=R-E,k=R+E;A<o&&(o=A),k>u&&(u=k),R<d&&(d=R),R>p&&(p=R)}i[0]=s,i[1]=a,i[2]=o,i[3]=c,i[4]=l,i[5]=u,r[0]=h,r[1]=f,r[2]=d,r[3]=y,r[4]=_,r[5]=p}function Fl(n,t=null,e=null,i=null){const r=n.attributes.position,s=n.index?n.index.array:null,a=Xe(n),o=r.normalized;let c;t===null?(c=new Float32Array(a*6),e=0,i=a):(c=t,e=e||0,i=i||a);const l=r.array,u=r.offset||0;let h=3;r.isInterleavedBufferAttribute&&(h=r.data.stride);const f=["getX","getY","getZ"];for(let d=e;d<e+i;d++){const y=d*3,_=d*6;let p=y+0,m=y+1,g=y+2;s&&(p=s[p],m=s[m],g=s[g]),o||(p=p*h+u,m=m*h+u,g=g*h+u);for(let v=0;v<3;v++){let S,x,b;o?(S=r[f[v]](p),x=r[f[v]](m),b=r[f[v]](g)):(S=l[p+v],x=l[m+v],b=l[g+v]);let T=S;x<T&&(T=x),b<T&&(T=b);let w=S;x>w&&(w=x),b>w&&(w=b);const C=(w-T)/2,P=v*2;c[_+P+0]=T+C,c[_+P+1]=C+(Math.abs(T)+C)*Bl}}return c}function Y(n,t,e){return e.min.x=t[n],e.min.y=t[n+1],e.min.z=t[n+2],e.max.x=t[n+3],e.max.y=t[n+4],e.max.z=t[n+5],e}function qs(n){let t=-1,e=-1/0;for(let i=0;i<3;i++){const r=n[i+3]-n[i];r>e&&(e=r,t=i)}return t}function Xs(n,t){t.set(n)}function Ws(n,t,e){let i,r;for(let s=0;s<3;s++){const a=s+3;i=n[s],r=t[s],e[s]=i<r?i:r,i=n[a],r=t[a],e[a]=i>r?i:r}}function lr(n,t,e){for(let i=0;i<3;i++){const r=t[n+2*i],s=t[n+2*i+1],a=r-s,o=r+s;a<e[i]&&(e[i]=a),o>e[i+3]&&(e[i+3]=o)}}function ei(n){const t=n[3]-n[0],e=n[4]-n[1],i=n[5]-n[2];return 2*(t*e+e*i+i*t)}const ne=32,Dl=(n,t)=>n.candidate-t.candidate,fe=new Array(ne).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),ur=new Float32Array(6);function Ll(n,t,e,i,r,s){let a=-1,o=0;if(s===rs)a=qs(t),a!==-1&&(o=(t[a]+t[a+3])/2);else if(s===la)a=qs(n),a!==-1&&(o=Vl(e,i,r,a));else if(s===ua){const c=ei(n);let l=dn*r;const u=i*6,h=(i+r)*6;for(let f=0;f<3;f++){const d=t[f],p=(t[f+3]-d)/ne;if(r<ne/4){const m=[...fe];m.length=r;let g=0;for(let S=u;S<h;S+=6,g++){const x=m[g];x.candidate=e[S+2*f],x.count=0;const{bounds:b,leftCacheBounds:T,rightCacheBounds:w}=x;for(let C=0;C<3;C++)w[C]=1/0,w[C+3]=-1/0,T[C]=1/0,T[C+3]=-1/0,b[C]=1/0,b[C+3]=-1/0;lr(S,e,b)}m.sort(Dl);let v=r;for(let S=0;S<v;S++){const x=m[S];for(;S+1<v&&m[S+1].candidate===x.candidate;)m.splice(S+1,1),v--}for(let S=u;S<h;S+=6){const x=e[S+2*f];for(let b=0;b<v;b++){const T=m[b];x>=T.candidate?lr(S,e,T.rightCacheBounds):(lr(S,e,T.leftCacheBounds),T.count++)}}for(let S=0;S<v;S++){const x=m[S],b=x.count,T=r-x.count,w=x.leftCacheBounds,C=x.rightCacheBounds;let P=0;b!==0&&(P=ei(w)/c);let R=0;T!==0&&(R=ei(C)/c);const E=$s+dn*(P*b+R*T);E<l&&(a=f,l=E,o=x.candidate)}}else{for(let v=0;v<ne;v++){const S=fe[v];S.count=0,S.candidate=d+p+v*p;const x=S.bounds;for(let b=0;b<3;b++)x[b]=1/0,x[b+3]=-1/0}for(let v=u;v<h;v+=6){let b=~~((e[v+2*f]-d)/p);b>=ne&&(b=ne-1);const T=fe[b];T.count++,lr(v,e,T.bounds)}const m=fe[ne-1];Xs(m.bounds,m.rightCacheBounds);for(let v=ne-2;v>=0;v--){const S=fe[v],x=fe[v+1];Ws(S.bounds,x.rightCacheBounds,S.rightCacheBounds)}let g=0;for(let v=0;v<ne-1;v++){const S=fe[v],x=S.count,b=S.bounds,w=fe[v+1].rightCacheBounds;x!==0&&(g===0?Xs(b,ur):Ws(b,ur,ur)),g+=x;let C=0,P=0;g!==0&&(C=ei(ur)/c);const R=r-g;R!==0&&(P=ei(w)/c);const E=$s+dn*(C*g+P*R);E<l&&(a=f,l=E,o=S.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:a,pos:o}}function Vl(n,t,e,i){let r=0;for(let s=t,a=t+e;s<a;s++)r+=n[s*6+i*2];return r/e}class yn{constructor(){this.boundingData=new Float32Array(6)}}function Jl(n,t,e,i,r,s){let a=i,o=i+r-1;const c=s.pos,l=s.axis*2;for(;;){for(;a<=o&&e[a*6+l]<c;)a++;for(;a<=o&&e[o*6+l]>=c;)o--;if(a<o){for(let u=0;u<3;u++){let h=t[a*3+u];t[a*3+u]=t[o*3+u],t[o*3+u]=h}for(let u=0;u<6;u++){let h=e[a*6+u];e[a*6+u]=e[o*6+u],e[o*6+u]=h}a++,o--}else return a}}function Gl(n,t,e,i,r,s){let a=i,o=i+r-1;const c=s.pos,l=s.axis*2;for(;;){for(;a<=o&&e[a*6+l]<c;)a++;for(;a<=o&&e[o*6+l]>=c;)o--;if(a<o){let u=n[a];n[a]=n[o],n[o]=u;for(let h=0;h<6;h++){let f=e[a*6+h];e[a*6+h]=e[o*6+h],e[o*6+h]=f}a++,o--}else return a}}function St(n,t){return t[n+15]===65535}function Mt(n,t){return t[n+6]}function Ct(n,t){return t[n+14]}function Pt(n){return n+8}function wt(n,t){return t[n+6]}function da(n,t){return t[n+7]}let pa,fi,Ar,ma;const jl=Math.pow(2,32);function Dn(n){return"count"in n?1:1+Dn(n.left)+Dn(n.right)}function $l(n,t,e){return pa=new Float32Array(e),fi=new Uint32Array(e),Ar=new Uint16Array(e),ma=new Uint8Array(e),Ln(n,t)}function Ln(n,t){const e=n/4,i=n/2,r="count"in t,s=t.boundingData;for(let a=0;a<6;a++)pa[e+a]=s[a];if(r)if(t.buffer){const a=t.buffer;ma.set(new Uint8Array(a),n);for(let o=n,c=n+a.byteLength;o<c;o+=mi){const l=o/2;St(l,Ar)||(fi[o/4+6]+=e)}return n+a.byteLength}else{const a=t.offset,o=t.count;return fi[e+6]=a,Ar[i+14]=o,Ar[i+15]=$r,n+mi}else{const a=t.left,o=t.right,c=t.splitAxis;let l;if(l=Ln(n+mi,a),l/4>jl)throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return fi[e+6]=l/4,l=Ln(l,o),fi[e+7]=c,l}}function ql(n,t){const e=(n.index?n.index.count:n.attributes.position.count)/3,i=e>2**16,r=i?4:2,s=t?new SharedArrayBuffer(e*r):new ArrayBuffer(e*r),a=i?new Uint32Array(s):new Uint16Array(s);for(let o=0,c=a.length;o<c;o++)a[o]=o;return a}function Xl(n,t,e,i,r){const{maxDepth:s,verbose:a,maxLeafTris:o,strategy:c,onProgress:l,indirect:u}=r,h=n._indirectBuffer,f=n.geometry,d=f.index?f.index.array:null,y=u?Gl:Jl,_=Xe(f),p=new Float32Array(6);let m=!1;const g=new yn;return mn(t,e,i,g.boundingData,p),S(g,e,i,p),g;function v(x){l&&l(x/_)}function S(x,b,T,w=null,C=0){if(!m&&C>=s&&(m=!0,a&&(console.warn(`MeshBVH: Max depth of ${s} reached when generating BVH. Consider increasing maxDepth.`),console.warn(f))),T<=o||C>=s)return v(b+T),x.offset=b,x.count=T,x;const P=Ll(x.boundingData,w,t,b,T,c);if(P.axis===-1)return v(b+T),x.offset=b,x.count=T,x;const R=y(h,d,t,b,T,P);if(R===b||R===b+T)v(b+T),x.offset=b,x.count=T;else{x.splitAxis=P.axis;const E=new yn,A=b,k=R-b;x.left=E,mn(t,A,k,E.boundingData,p),S(E,A,k,p,C+1);const z=new yn,U=R,L=T-k;x.right=z,mn(t,U,L,z.boundingData,p),S(z,U,L,p,C+1)}return x}}function Wl(n,t){const e=n.geometry;t.indirect&&(n._indirectBuffer=ql(e,t.useSharedArrayBuffer),Nl(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.')),n._indirectBuffer||Ul(e,t);const i=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,r=Fl(e),s=t.indirect?ha(e,t.range):fa(e,t.range);n._roots=s.map(a=>{const o=Xl(n,r,a.offset,a.count,t),c=Dn(o),l=new i(mi*c);return $l(0,o,l),l})}class le{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(t,e){let i=1/0,r=-1/0;for(let s=0,a=t.length;s<a;s++){const c=t[s][e];i=c<i?c:i,r=c>r?c:r}this.min=i,this.max=r}setFromPoints(t,e){let i=1/0,r=-1/0;for(let s=0,a=e.length;s<a;s++){const o=e[s],c=t.dot(o);i=c<i?c:i,r=c>r?c:r}this.min=i,this.max=r}isSeparated(t){return this.min>t.max||t.min>this.max}}le.prototype.setFromBox=function(){const n=new M.Vector3;return function(e,i){const r=i.min,s=i.max;let a=1/0,o=-1/0;for(let c=0;c<=1;c++)for(let l=0;l<=1;l++)for(let u=0;u<=1;u++){n.x=r.x*c+s.x*(1-c),n.y=r.y*l+s.y*(1-l),n.z=r.z*u+s.z*(1-u);const h=e.dot(n);a=Math.min(h,a),o=Math.max(h,o)}this.min=a,this.max=o}}();const Hl=function(){const n=new M.Vector3,t=new M.Vector3,e=new M.Vector3;return function(r,s,a){const o=r.start,c=n,l=s.start,u=t;e.subVectors(o,l),n.subVectors(r.end,r.start),t.subVectors(s.end,s.start);const h=e.dot(u),f=u.dot(c),d=u.dot(u),y=e.dot(c),p=c.dot(c)*d-f*f;let m,g;p!==0?m=(h*f-y*d)/p:m=0,g=(h+m*f)/d,a.x=m,a.y=g}}(),ns=function(){const n=new M.Vector2,t=new M.Vector3,e=new M.Vector3;return function(r,s,a,o){Hl(r,s,n);let c=n.x,l=n.y;if(c>=0&&c<=1&&l>=0&&l<=1){r.at(c,a),s.at(l,o);return}else if(c>=0&&c<=1){l<0?s.at(0,o):s.at(1,o),r.closestPointToPoint(o,!0,a);return}else if(l>=0&&l<=1){c<0?r.at(0,a):r.at(1,a),s.closestPointToPoint(a,!0,o);return}else{let u;c<0?u=r.start:u=r.end;let h;l<0?h=s.start:h=s.end;const f=t,d=e;if(r.closestPointToPoint(h,!0,t),s.closestPointToPoint(u,!0,e),f.distanceToSquared(h)<=d.distanceToSquared(u)){a.copy(f),o.copy(h);return}else{a.copy(u),o.copy(d);return}}}}(),Yl=function(){const n=new M.Vector3,t=new M.Vector3,e=new M.Plane,i=new M.Line3;return function(s,a){const{radius:o,center:c}=s,{a:l,b:u,c:h}=a;if(i.start=l,i.end=u,i.closestPointToPoint(c,!0,n).distanceTo(c)<=o||(i.start=l,i.end=h,i.closestPointToPoint(c,!0,n).distanceTo(c)<=o)||(i.start=u,i.end=h,i.closestPointToPoint(c,!0,n).distanceTo(c)<=o))return!0;const _=a.getPlane(e);if(Math.abs(_.distanceToPoint(c))<=o){const m=_.projectPoint(c,t);if(a.containsPoint(m))return!0}return!1}}(),Zl=1e-15;function gn(n){return Math.abs(n)<Zl}class Rt extends M.Triangle{constructor(...t){super(...t),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new M.Vector3),this.satBounds=new Array(4).fill().map(()=>new le),this.points=[this.a,this.b,this.c],this.sphere=new M.Sphere,this.plane=new M.Plane,this.needsUpdate=!0}intersectsSphere(t){return Yl(t,this)}update(){const t=this.a,e=this.b,i=this.c,r=this.points,s=this.satAxes,a=this.satBounds,o=s[0],c=a[0];this.getNormal(o),c.setFromPoints(o,r);const l=s[1],u=a[1];l.subVectors(t,e),u.setFromPoints(l,r);const h=s[2],f=a[2];h.subVectors(e,i),f.setFromPoints(h,r);const d=s[3],y=a[3];d.subVectors(i,t),y.setFromPoints(d,r),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(o,t),this.needsUpdate=!1}}Rt.prototype.closestPointToSegment=function(){const n=new M.Vector3,t=new M.Vector3,e=new M.Line3;return function(r,s=null,a=null){const{start:o,end:c}=r,l=this.points;let u,h=1/0;for(let f=0;f<3;f++){const d=(f+1)%3;e.start.copy(l[f]),e.end.copy(l[d]),ns(e,r,n,t),u=n.distanceToSquared(t),u<h&&(h=u,s&&s.copy(n),a&&a.copy(t))}return this.closestPointToPoint(o,n),u=o.distanceToSquared(n),u<h&&(h=u,s&&s.copy(n),a&&a.copy(o)),this.closestPointToPoint(c,n),u=c.distanceToSquared(n),u<h&&(h=u,s&&s.copy(n),a&&a.copy(c)),Math.sqrt(h)}}();Rt.prototype.intersectsTriangle=function(){const n=new Rt,t=new Array(3),e=new Array(3),i=new le,r=new le,s=new M.Vector3,a=new M.Vector3,o=new M.Vector3,c=new M.Vector3,l=new M.Vector3,u=new M.Line3,h=new M.Line3,f=new M.Line3,d=new M.Vector3;function y(_,p,m){const g=_.points;let v=0,S=-1;for(let x=0;x<3;x++){const{start:b,end:T}=u;b.copy(g[x]),T.copy(g[(x+1)%3]),u.delta(a);const w=gn(p.distanceToPoint(b));if(gn(p.normal.dot(a))&&w){m.copy(u),v=2;break}const C=p.intersectLine(u,d);if(!C&&w&&d.copy(b),(C||w)&&!gn(d.distanceTo(T))){if(v<=1)(v===1?m.start:m.end).copy(d),w&&(S=v);else if(v>=2){(S===1?m.start:m.end).copy(d),v=2;break}if(v++,v===2&&S===-1)break}}return v}return function(p,m=null,g=!1){this.needsUpdate&&this.update(),p.isExtendedTriangle?p.needsUpdate&&p.update():(n.copy(p),n.update(),p=n);const v=this.plane,S=p.plane;if(Math.abs(v.normal.dot(S.normal))>1-1e-10){const x=this.satBounds,b=this.satAxes;e[0]=p.a,e[1]=p.b,e[2]=p.c;for(let C=0;C<4;C++){const P=x[C],R=b[C];if(i.setFromPoints(R,e),P.isSeparated(i))return!1}const T=p.satBounds,w=p.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let C=0;C<4;C++){const P=T[C],R=w[C];if(i.setFromPoints(R,t),P.isSeparated(i))return!1}for(let C=0;C<4;C++){const P=b[C];for(let R=0;R<4;R++){const E=w[R];if(s.crossVectors(P,E),i.setFromPoints(s,t),r.setFromPoints(s,e),i.isSeparated(r))return!1}}return m&&(g||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),m.start.set(0,0,0),m.end.set(0,0,0)),!0}else{const x=y(this,S,h);if(x===1&&p.containsPoint(h.end))return m&&(m.start.copy(h.end),m.end.copy(h.end)),!0;if(x!==2)return!1;const b=y(p,v,f);if(b===1&&this.containsPoint(f.end))return m&&(m.start.copy(f.end),m.end.copy(f.end)),!0;if(b!==2)return!1;if(h.delta(o),f.delta(c),o.dot(c)<0){let A=f.start;f.start=f.end,f.end=A}const T=h.start.dot(o),w=h.end.dot(o),C=f.start.dot(o),P=f.end.dot(o),R=w<C,E=T<P;return T!==P&&C!==w&&R===E?!1:(m&&(l.subVectors(h.start,f.start),l.dot(o)>0?m.start.copy(h.start):m.start.copy(f.start),l.subVectors(h.end,f.end),l.dot(o)<0?m.end.copy(h.end):m.end.copy(f.end)),!0)}}}();Rt.prototype.distanceToPoint=function(){const n=new M.Vector3;return function(e){return this.closestPointToPoint(e,n),e.distanceTo(n)}}();Rt.prototype.distanceToTriangle=function(){const n=new M.Vector3,t=new M.Vector3,e=["a","b","c"],i=new M.Line3,r=new M.Line3;return function(a,o=null,c=null){const l=o||c?i:null;if(this.intersectsTriangle(a,l))return(o||c)&&(o&&l.getCenter(o),c&&l.getCenter(c)),0;let u=1/0;for(let h=0;h<3;h++){let f;const d=e[h],y=a[d];this.closestPointToPoint(y,n),f=y.distanceToSquared(n),f<u&&(u=f,o&&o.copy(n),c&&c.copy(y));const _=this[d];a.closestPointToPoint(_,n),f=_.distanceToSquared(n),f<u&&(u=f,o&&o.copy(_),c&&c.copy(n))}for(let h=0;h<3;h++){const f=e[h],d=e[(h+1)%3];i.set(this[f],this[d]);for(let y=0;y<3;y++){const _=e[y],p=e[(y+1)%3];r.set(a[_],a[p]),ns(i,r,n,t);const m=n.distanceToSquared(t);m<u&&(u=m,o&&o.copy(n),c&&c.copy(t))}}return Math.sqrt(u)}}();class dt{constructor(t,e,i){this.isOrientedBox=!0,this.min=new M.Vector3,this.max=new M.Vector3,this.matrix=new M.Matrix4,this.invMatrix=new M.Matrix4,this.points=new Array(8).fill().map(()=>new M.Vector3),this.satAxes=new Array(3).fill().map(()=>new M.Vector3),this.satBounds=new Array(3).fill().map(()=>new le),this.alignedSatBounds=new Array(3).fill().map(()=>new le),this.needsUpdate=!1,t&&this.min.copy(t),e&&this.max.copy(e),i&&this.matrix.copy(i)}set(t,e,i){this.min.copy(t),this.max.copy(e),this.matrix.copy(i),this.needsUpdate=!0}copy(t){this.min.copy(t.min),this.max.copy(t.max),this.matrix.copy(t.matrix),this.needsUpdate=!0}}dt.prototype.update=function(){return function(){const t=this.matrix,e=this.min,i=this.max,r=this.points;for(let l=0;l<=1;l++)for(let u=0;u<=1;u++)for(let h=0;h<=1;h++){const f=1*l|2*u|4*h,d=r[f];d.x=l?i.x:e.x,d.y=u?i.y:e.y,d.z=h?i.z:e.z,d.applyMatrix4(t)}const s=this.satBounds,a=this.satAxes,o=r[0];for(let l=0;l<3;l++){const u=a[l],h=s[l],f=1<<l,d=r[f];u.subVectors(o,d),h.setFromPoints(u,r)}const c=this.alignedSatBounds;c[0].setFromPointsField(r,"x"),c[1].setFromPointsField(r,"y"),c[2].setFromPointsField(r,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();dt.prototype.intersectsBox=function(){const n=new le;return function(e){this.needsUpdate&&this.update();const i=e.min,r=e.max,s=this.satBounds,a=this.satAxes,o=this.alignedSatBounds;if(n.min=i.x,n.max=r.x,o[0].isSeparated(n)||(n.min=i.y,n.max=r.y,o[1].isSeparated(n))||(n.min=i.z,n.max=r.z,o[2].isSeparated(n)))return!1;for(let c=0;c<3;c++){const l=a[c],u=s[c];if(n.setFromBox(l,e),u.isSeparated(n))return!1}return!0}}();dt.prototype.intersectsTriangle=function(){const n=new Rt,t=new Array(3),e=new le,i=new le,r=new M.Vector3;return function(a){this.needsUpdate&&this.update(),a.isExtendedTriangle?a.needsUpdate&&a.update():(n.copy(a),n.update(),a=n);const o=this.satBounds,c=this.satAxes;t[0]=a.a,t[1]=a.b,t[2]=a.c;for(let f=0;f<3;f++){const d=o[f],y=c[f];if(e.setFromPoints(y,t),d.isSeparated(e))return!1}const l=a.satBounds,u=a.satAxes,h=this.points;for(let f=0;f<3;f++){const d=l[f],y=u[f];if(e.setFromPoints(y,h),d.isSeparated(e))return!1}for(let f=0;f<3;f++){const d=c[f];for(let y=0;y<4;y++){const _=u[y];if(r.crossVectors(d,_),e.setFromPoints(r,t),i.setFromPoints(r,h),e.isSeparated(i))return!1}}return!0}}();dt.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}}();dt.prototype.distanceToPoint=function(){const n=new M.Vector3;return function(e){return this.closestPointToPoint(e,n),e.distanceTo(n)}}();dt.prototype.distanceToBox=function(){const n=["x","y","z"],t=new Array(12).fill().map(()=>new M.Line3),e=new Array(12).fill().map(()=>new M.Line3),i=new M.Vector3,r=new M.Vector3;return function(a,o=0,c=null,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(a))return(c||l)&&(a.getCenter(r),this.closestPointToPoint(r,i),a.closestPointToPoint(i,r),c&&c.copy(i),l&&l.copy(r)),0;const u=o*o,h=a.min,f=a.max,d=this.points;let y=1/0;for(let p=0;p<8;p++){const m=d[p];r.copy(m).clamp(h,f);const g=m.distanceToSquared(r);if(g<y&&(y=g,c&&c.copy(m),l&&l.copy(r),g<u))return Math.sqrt(g)}let _=0;for(let p=0;p<3;p++)for(let m=0;m<=1;m++)for(let g=0;g<=1;g++){const v=(p+1)%3,S=(p+2)%3,x=m<<v|g<<S,b=1<<p|m<<v|g<<S,T=d[x],w=d[b];t[_].set(T,w);const P=n[p],R=n[v],E=n[S],A=e[_],k=A.start,z=A.end;k[P]=h[P],k[R]=m?h[R]:f[R],k[E]=g?h[E]:f[R],z[P]=f[P],z[R]=m?h[R]:f[R],z[E]=g?h[E]:f[R],_++}for(let p=0;p<=1;p++)for(let m=0;m<=1;m++)for(let g=0;g<=1;g++){r.x=p?f.x:h.x,r.y=m?f.y:h.y,r.z=g?f.z:h.z,this.closestPointToPoint(r,i);const v=r.distanceToSquared(i);if(v<y&&(y=v,c&&c.copy(i),l&&l.copy(r),v<u))return Math.sqrt(v)}for(let p=0;p<12;p++){const m=t[p];for(let g=0;g<12;g++){const v=e[g];ns(m,v,i,r);const S=i.distanceToSquared(r);if(S<y&&(y=S,c&&c.copy(i),l&&l.copy(r),S<u))return Math.sqrt(S)}}return Math.sqrt(y)}}();class ss{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 Ql extends ss{constructor(){super(()=>new Rt)}}const Et=new Ql;class Kl{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const t=[];let e=null;this.setBuffer=i=>{e&&t.push(e),e=i,this.float32Array=new Float32Array(i),this.uint16Array=new Uint16Array(i),this.uint32Array=new Uint32Array(i)},this.clearBuffer=()=>{e=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,t.length!==0&&this.setBuffer(t.pop())}}}const $=new Kl;let ye,Ve;const Be=[],hr=new ss(()=>new M.Box3);function tu(n,t,e,i,r,s){ye=hr.getPrimitive(),Ve=hr.getPrimitive(),Be.push(ye,Ve),$.setBuffer(n._roots[t]);const a=Vn(0,n.geometry,e,i,r,s);$.clearBuffer(),hr.releasePrimitive(ye),hr.releasePrimitive(Ve),Be.pop(),Be.pop();const o=Be.length;return o>0&&(Ve=Be[o-1],ye=Be[o-2]),a}function Vn(n,t,e,i,r=null,s=0,a=0){const{float32Array:o,uint16Array:c,uint32Array:l}=$;let u=n*2;if(St(u,c)){const f=Mt(n,l),d=Ct(u,c);return Y(n,o,ye),i(f,d,!1,a,s+n,ye)}else{let P=function(E){const{uint16Array:A,uint32Array:k}=$;let z=E*2;for(;!St(z,A);)E=Pt(E),z=E*2;return Mt(E,k)},R=function(E){const{uint16Array:A,uint32Array:k}=$;let z=E*2;for(;!St(z,A);)E=wt(E,k),z=E*2;return Mt(E,k)+Ct(z,A)};const f=Pt(n),d=wt(n,l);let y=f,_=d,p,m,g,v;if(r&&(g=ye,v=Ve,Y(y,o,g),Y(_,o,v),p=r(g),m=r(v),m<p)){y=d,_=f;const E=p;p=m,m=E,g=v}g||(g=ye,Y(y,o,g));const S=St(y*2,c),x=e(g,S,p,a+1,s+y);let b;if(x===Fn){const E=P(y),k=R(y)-E;b=i(E,k,!0,a+1,s+y,g)}else b=x&&Vn(y,t,e,i,r,s,a+1);if(b)return!0;v=Ve,Y(_,o,v);const T=St(_*2,c),w=e(v,T,m,a+1,s+_);let C;if(w===Fn){const E=P(_),k=R(_)-E;C=i(E,k,!0,a+1,s+_,v)}else C=w&&Vn(_,t,e,i,r,s,a+1);return!!C}}const ii=new M.Vector3,vn=new M.Vector3;function eu(n,t,e={},i=0,r=1/0){const s=i*i,a=r*r;let o=1/0,c=null;if(n.shapecast({boundsTraverseOrder:u=>(ii.copy(t).clamp(u.min,u.max),ii.distanceToSquared(t)),intersectsBounds:(u,h,f)=>f<o&&f<a,intersectsTriangle:(u,h)=>{u.closestPointToPoint(t,ii);const f=t.distanceToSquared(ii);return f<o&&(vn.copy(ii),o=f,c=h),f<s}}),o===1/0)return null;const l=Math.sqrt(o);return e.point?e.point.copy(vn):e.point=vn.clone(),e.distance=l,e.faceIndex=c,e}const iu=parseInt(M.REVISION)>=169,Se=new M.Vector3,be=new M.Vector3,Te=new M.Vector3,fr=new M.Vector2,dr=new M.Vector2,pr=new M.Vector2,Hs=new M.Vector3,Ys=new M.Vector3,Zs=new M.Vector3,ri=new M.Vector3;function ru(n,t,e,i,r,s,a,o){let c;if(s===M.BackSide?c=n.intersectTriangle(i,e,t,!0,r):c=n.intersectTriangle(t,e,i,s!==M.DoubleSide,r),c===null)return null;const l=n.origin.distanceTo(r);return l<a||l>o?null:{distance:l,point:r.clone()}}function nu(n,t,e,i,r,s,a,o,c,l,u){Se.fromBufferAttribute(t,s),be.fromBufferAttribute(t,a),Te.fromBufferAttribute(t,o);const h=ru(n,Se,be,Te,ri,c,l,u);if(h){const f=new M.Vector3;M.Triangle.getBarycoord(ri,Se,be,Te,f),i&&(fr.fromBufferAttribute(i,s),dr.fromBufferAttribute(i,a),pr.fromBufferAttribute(i,o),h.uv=M.Triangle.getInterpolation(ri,Se,be,Te,fr,dr,pr,new M.Vector2)),r&&(fr.fromBufferAttribute(r,s),dr.fromBufferAttribute(r,a),pr.fromBufferAttribute(r,o),h.uv1=M.Triangle.getInterpolation(ri,Se,be,Te,fr,dr,pr,new M.Vector2)),e&&(Hs.fromBufferAttribute(e,s),Ys.fromBufferAttribute(e,a),Zs.fromBufferAttribute(e,o),h.normal=M.Triangle.getInterpolation(ri,Se,be,Te,Hs,Ys,Zs,new M.Vector3),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const d={a:s,b:a,c:o,normal:new M.Vector3,materialIndex:0};M.Triangle.getNormal(Se,be,Te,d.normal),h.face=d,h.faceIndex=s,iu&&(h.barycoord=f)}return h}function qr(n,t,e,i,r,s,a){const o=i*3;let c=o+0,l=o+1,u=o+2;const h=n.index;n.index&&(c=h.getX(c),l=h.getX(l),u=h.getX(u));const{position:f,normal:d,uv:y,uv1:_}=n.attributes,p=nu(e,f,d,y,_,c,l,u,t,s,a);return p?(p.faceIndex=i,r&&r.push(p),p):null}function et(n,t,e,i){const r=n.a,s=n.b,a=n.c;let o=t,c=t+1,l=t+2;e&&(o=e.getX(o),c=e.getX(c),l=e.getX(l)),r.x=i.getX(o),r.y=i.getY(o),r.z=i.getZ(o),s.x=i.getX(c),s.y=i.getY(c),s.z=i.getZ(c),a.x=i.getX(l),a.y=i.getY(l),a.z=i.getZ(l)}function su(n,t,e,i,r,s,a,o){const{geometry:c,_indirectBuffer:l}=n;for(let u=i,h=i+r;u<h;u++)qr(c,t,e,u,s,a,o)}function ou(n,t,e,i,r,s,a){const{geometry:o,_indirectBuffer:c}=n;let l=1/0,u=null;for(let h=i,f=i+r;h<f;h++){let d;d=qr(o,t,e,h,null,s,a),d&&d.distance<l&&(u=d,l=d.distance)}return u}function au(n,t,e,i,r,s,a){const{geometry:o}=e,{index:c}=o,l=o.attributes.position;for(let u=n,h=t+n;u<h;u++){let f;if(f=u,et(a,f*3,c,l),a.needsUpdate=!0,i(a,f,r,s))return!0}return!1}function cu(n,t=null){t&&Array.isArray(t)&&(t=new Set(t));const e=n.geometry,i=e.index?e.index.array:null,r=e.attributes.position;let s,a,o,c,l=0;const u=n._roots;for(let f=0,d=u.length;f<d;f++)s=u[f],a=new Uint32Array(s),o=new Uint16Array(s),c=new Float32Array(s),h(0,l),l+=s.byteLength;function h(f,d,y=!1){const _=f*2;if(o[_+15]===$r){const m=a[f+6],g=o[_+14];let v=1/0,S=1/0,x=1/0,b=-1/0,T=-1/0,w=-1/0;for(let C=3*m,P=3*(m+g);C<P;C++){let R=i[C];const E=r.getX(R),A=r.getY(R),k=r.getZ(R);E<v&&(v=E),E>b&&(b=E),A<S&&(S=A),A>T&&(T=A),k<x&&(x=k),k>w&&(w=k)}return c[f+0]!==v||c[f+1]!==S||c[f+2]!==x||c[f+3]!==b||c[f+4]!==T||c[f+5]!==w?(c[f+0]=v,c[f+1]=S,c[f+2]=x,c[f+3]=b,c[f+4]=T,c[f+5]=w,!0):!1}else{const m=f+8,g=a[f+6],v=m+d,S=g+d;let x=y,b=!1,T=!1;t?x||(b=t.has(v),T=t.has(S),x=!b&&!T):(b=!0,T=!0);const w=x||b,C=x||T;let P=!1;w&&(P=h(m,d,x));let R=!1;C&&(R=h(g,d,x));const E=P||R;if(E)for(let A=0;A<3;A++){const k=m+A,z=g+A,U=c[k],L=c[k+3],I=c[z],X=c[z+3];c[f+A]=U<I?U:I,c[f+A+3]=L>X?L:X}return E}}}function ge(n,t,e,i,r){let s,a,o,c,l,u;const h=1/e.direction.x,f=1/e.direction.y,d=1/e.direction.z,y=e.origin.x,_=e.origin.y,p=e.origin.z;let m=t[n],g=t[n+3],v=t[n+1],S=t[n+3+1],x=t[n+2],b=t[n+3+2];return h>=0?(s=(m-y)*h,a=(g-y)*h):(s=(g-y)*h,a=(m-y)*h),f>=0?(o=(v-_)*f,c=(S-_)*f):(o=(S-_)*f,c=(v-_)*f),s>c||o>a||((o>s||isNaN(s))&&(s=o),(c<a||isNaN(a))&&(a=c),d>=0?(l=(x-p)*d,u=(b-p)*d):(l=(b-p)*d,u=(x-p)*d),s>u||l>a)?!1:((l>s||s!==s)&&(s=l),(u<a||a!==a)&&(a=u),s<=r&&a>=i)}function lu(n,t,e,i,r,s,a,o){const{geometry:c,_indirectBuffer:l}=n;for(let u=i,h=i+r;u<h;u++){let f=l?l[u]:u;qr(c,t,e,f,s,a,o)}}function uu(n,t,e,i,r,s,a){const{geometry:o,_indirectBuffer:c}=n;let l=1/0,u=null;for(let h=i,f=i+r;h<f;h++){let d;d=qr(o,t,e,c?c[h]:h,null,s,a),d&&d.distance<l&&(u=d,l=d.distance)}return u}function hu(n,t,e,i,r,s,a){const{geometry:o}=e,{index:c}=o,l=o.attributes.position;for(let u=n,h=t+n;u<h;u++){let f;if(f=e.resolveTriangleIndex(u),et(a,f*3,c,l),a.needsUpdate=!0,i(a,f,r,s))return!0}return!1}function fu(n,t,e,i,r,s,a){$.setBuffer(n._roots[t]),Jn(0,n,e,i,r,s,a),$.clearBuffer()}function Jn(n,t,e,i,r,s,a){const{float32Array:o,uint16Array:c,uint32Array:l}=$,u=n*2;if(St(u,c)){const f=Mt(n,l),d=Ct(u,c);su(t,e,i,f,d,r,s,a)}else{const f=Pt(n);ge(f,o,i,s,a)&&Jn(f,t,e,i,r,s,a);const d=wt(n,l);ge(d,o,i,s,a)&&Jn(d,t,e,i,r,s,a)}}const du=["x","y","z"];function pu(n,t,e,i,r,s){$.setBuffer(n._roots[t]);const a=Gn(0,n,e,i,r,s);return $.clearBuffer(),a}function Gn(n,t,e,i,r,s){const{float32Array:a,uint16Array:o,uint32Array:c}=$;let l=n*2;if(St(l,o)){const h=Mt(n,c),f=Ct(l,o);return ou(t,e,i,h,f,r,s)}else{const h=da(n,c),f=du[h],y=i.direction[f]>=0;let _,p;y?(_=Pt(n),p=wt(n,c)):(_=wt(n,c),p=Pt(n));const g=ge(_,a,i,r,s)?Gn(_,t,e,i,r,s):null;if(g){const x=g.point[f];if(y?x<=a[p+h]:x>=a[p+h+3])return g}const S=ge(p,a,i,r,s)?Gn(p,t,e,i,r,s):null;return g&&S?g.distance<=S.distance?g:S:g||S||null}}const mr=new M.Box3,Oe=new Rt,Ie=new Rt,ni=new M.Matrix4,Qs=new dt,yr=new dt;function mu(n,t,e,i){$.setBuffer(n._roots[t]);const r=jn(0,n,e,i);return $.clearBuffer(),r}function jn(n,t,e,i,r=null){const{float32Array:s,uint16Array:a,uint32Array:o}=$;let c=n*2;if(r===null&&(e.boundingBox||e.computeBoundingBox(),Qs.set(e.boundingBox.min,e.boundingBox.max,i),r=Qs),St(c,a)){const u=t.geometry,h=u.index,f=u.attributes.position,d=e.index,y=e.attributes.position,_=Mt(n,o),p=Ct(c,a);if(ni.copy(i).invert(),e.boundsTree)return Y(n,s,yr),yr.matrix.copy(ni),yr.needsUpdate=!0,e.boundsTree.shapecast({intersectsBounds:g=>yr.intersectsBox(g),intersectsTriangle:g=>{g.a.applyMatrix4(i),g.b.applyMatrix4(i),g.c.applyMatrix4(i),g.needsUpdate=!0;for(let v=_*3,S=(p+_)*3;v<S;v+=3)if(et(Ie,v,h,f),Ie.needsUpdate=!0,g.intersectsTriangle(Ie))return!0;return!1}});for(let m=_*3,g=(p+_)*3;m<g;m+=3){et(Oe,m,h,f),Oe.a.applyMatrix4(ni),Oe.b.applyMatrix4(ni),Oe.c.applyMatrix4(ni),Oe.needsUpdate=!0;for(let v=0,S=d.count;v<S;v+=3)if(et(Ie,v,d,y),Ie.needsUpdate=!0,Oe.intersectsTriangle(Ie))return!0}}else{const u=n+8,h=o[n+6];return Y(u,s,mr),!!(r.intersectsBox(mr)&&jn(u,t,e,i,r)||(Y(h,s,mr),r.intersectsBox(mr)&&jn(h,t,e,i,r)))}}const gr=new M.Matrix4,_n=new dt,si=new dt,yu=new M.Vector3,gu=new M.Vector3,vu=new M.Vector3,_u=new M.Vector3;function xu(n,t,e,i={},r={},s=0,a=1/0){t.boundingBox||t.computeBoundingBox(),_n.set(t.boundingBox.min,t.boundingBox.max,e),_n.needsUpdate=!0;const o=n.geometry,c=o.attributes.position,l=o.index,u=t.attributes.position,h=t.index,f=Et.getPrimitive(),d=Et.getPrimitive();let y=yu,_=gu,p=null,m=null;r&&(p=vu,m=_u);let g=1/0,v=null,S=null;return gr.copy(e).invert(),si.matrix.copy(gr),n.shapecast({boundsTraverseOrder:x=>_n.distanceToBox(x),intersectsBounds:(x,b,T)=>T<g&&T<a?(b&&(si.min.copy(x.min),si.max.copy(x.max),si.needsUpdate=!0),!0):!1,intersectsRange:(x,b)=>{if(t.boundsTree)return t.boundsTree.shapecast({boundsTraverseOrder:w=>si.distanceToBox(w),intersectsBounds:(w,C,P)=>P<g&&P<a,intersectsRange:(w,C)=>{for(let P=w,R=w+C;P<R;P++){et(d,3*P,h,u),d.a.applyMatrix4(e),d.b.applyMatrix4(e),d.c.applyMatrix4(e),d.needsUpdate=!0;for(let E=x,A=x+b;E<A;E++){et(f,3*E,l,c),f.needsUpdate=!0;const k=f.distanceToTriangle(d,y,p);if(k<g&&(_.copy(y),m&&m.copy(p),g=k,v=E,S=P),k<s)return!0}}}});{const T=Xe(t);for(let w=0,C=T;w<C;w++){et(d,3*w,h,u),d.a.applyMatrix4(e),d.b.applyMatrix4(e),d.c.applyMatrix4(e),d.needsUpdate=!0;for(let P=x,R=x+b;P<R;P++){et(f,3*P,l,c),f.needsUpdate=!0;const E=f.distanceToTriangle(d,y,p);if(E<g&&(_.copy(y),m&&m.copy(p),g=E,v=P,S=w),E<s)return!0}}}}}),Et.releasePrimitive(f),Et.releasePrimitive(d),g===1/0?null:(i.point?i.point.copy(_):i.point=_.clone(),i.distance=g,i.faceIndex=v,r&&(r.point?r.point.copy(m):r.point=m.clone(),r.point.applyMatrix4(gr),_.applyMatrix4(gr),r.distance=_.sub(r.point).length(),r.faceIndex=S),i)}function Su(n,t=null){t&&Array.isArray(t)&&(t=new Set(t));const e=n.geometry,i=e.index?e.index.array:null,r=e.attributes.position;let s,a,o,c,l=0;const u=n._roots;for(let f=0,d=u.length;f<d;f++)s=u[f],a=new Uint32Array(s),o=new Uint16Array(s),c=new Float32Array(s),h(0,l),l+=s.byteLength;function h(f,d,y=!1){const _=f*2;if(o[_+15]===$r){const m=a[f+6],g=o[_+14];let v=1/0,S=1/0,x=1/0,b=-1/0,T=-1/0,w=-1/0;for(let C=m,P=m+g;C<P;C++){const R=3*n.resolveTriangleIndex(C);for(let E=0;E<3;E++){let A=R+E;A=i?i[A]:A;const k=r.getX(A),z=r.getY(A),U=r.getZ(A);k<v&&(v=k),k>b&&(b=k),z<S&&(S=z),z>T&&(T=z),U<x&&(x=U),U>w&&(w=U)}}return c[f+0]!==v||c[f+1]!==S||c[f+2]!==x||c[f+3]!==b||c[f+4]!==T||c[f+5]!==w?(c[f+0]=v,c[f+1]=S,c[f+2]=x,c[f+3]=b,c[f+4]=T,c[f+5]=w,!0):!1}else{const m=f+8,g=a[f+6],v=m+d,S=g+d;let x=y,b=!1,T=!1;t?x||(b=t.has(v),T=t.has(S),x=!b&&!T):(b=!0,T=!0);const w=x||b,C=x||T;let P=!1;w&&(P=h(m,d,x));let R=!1;C&&(R=h(g,d,x));const E=P||R;if(E)for(let A=0;A<3;A++){const k=m+A,z=g+A,U=c[k],L=c[k+3],I=c[z],X=c[z+3];c[f+A]=U<I?U:I,c[f+A+3]=L>X?L:X}return E}}}function bu(n,t,e,i,r,s,a){$.setBuffer(n._roots[t]),$n(0,n,e,i,r,s,a),$.clearBuffer()}function $n(n,t,e,i,r,s,a){const{float32Array:o,uint16Array:c,uint32Array:l}=$,u=n*2;if(St(u,c)){const f=Mt(n,l),d=Ct(u,c);lu(t,e,i,f,d,r,s,a)}else{const f=Pt(n);ge(f,o,i,s,a)&&$n(f,t,e,i,r,s,a);const d=wt(n,l);ge(d,o,i,s,a)&&$n(d,t,e,i,r,s,a)}}const Tu=["x","y","z"];function Mu(n,t,e,i,r,s){$.setBuffer(n._roots[t]);const a=qn(0,n,e,i,r,s);return $.clearBuffer(),a}function qn(n,t,e,i,r,s){const{float32Array:a,uint16Array:o,uint32Array:c}=$;let l=n*2;if(St(l,o)){const h=Mt(n,c),f=Ct(l,o);return uu(t,e,i,h,f,r,s)}else{const h=da(n,c),f=Tu[h],y=i.direction[f]>=0;let _,p;y?(_=Pt(n),p=wt(n,c)):(_=wt(n,c),p=Pt(n));const g=ge(_,a,i,r,s)?qn(_,t,e,i,r,s):null;if(g){const x=g.point[f];if(y?x<=a[p+h]:x>=a[p+h+3])return g}const S=ge(p,a,i,r,s)?qn(p,t,e,i,r,s):null;return g&&S?g.distance<=S.distance?g:S:g||S||null}}const vr=new M.Box3,Ue=new Rt,Ne=new Rt,oi=new M.Matrix4,Ks=new dt,_r=new dt;function Cu(n,t,e,i){$.setBuffer(n._roots[t]);const r=Xn(0,n,e,i);return $.clearBuffer(),r}function Xn(n,t,e,i,r=null){const{float32Array:s,uint16Array:a,uint32Array:o}=$;let c=n*2;if(r===null&&(e.boundingBox||e.computeBoundingBox(),Ks.set(e.boundingBox.min,e.boundingBox.max,i),r=Ks),St(c,a)){const u=t.geometry,h=u.index,f=u.attributes.position,d=e.index,y=e.attributes.position,_=Mt(n,o),p=Ct(c,a);if(oi.copy(i).invert(),e.boundsTree)return Y(n,s,_r),_r.matrix.copy(oi),_r.needsUpdate=!0,e.boundsTree.shapecast({intersectsBounds:g=>_r.intersectsBox(g),intersectsTriangle:g=>{g.a.applyMatrix4(i),g.b.applyMatrix4(i),g.c.applyMatrix4(i),g.needsUpdate=!0;for(let v=_,S=p+_;v<S;v++)if(et(Ne,3*t.resolveTriangleIndex(v),h,f),Ne.needsUpdate=!0,g.intersectsTriangle(Ne))return!0;return!1}});for(let m=_,g=p+_;m<g;m++){const v=t.resolveTriangleIndex(m);et(Ue,3*v,h,f),Ue.a.applyMatrix4(oi),Ue.b.applyMatrix4(oi),Ue.c.applyMatrix4(oi),Ue.needsUpdate=!0;for(let S=0,x=d.count;S<x;S+=3)if(et(Ne,S,d,y),Ne.needsUpdate=!0,Ue.intersectsTriangle(Ne))return!0}}else{const u=n+8,h=o[n+6];return Y(u,s,vr),!!(r.intersectsBox(vr)&&Xn(u,t,e,i,r)||(Y(h,s,vr),r.intersectsBox(vr)&&Xn(h,t,e,i,r)))}}const xr=new M.Matrix4,xn=new dt,ai=new dt,Pu=new M.Vector3,wu=new M.Vector3,Eu=new M.Vector3,Ru=new M.Vector3;function Au(n,t,e,i={},r={},s=0,a=1/0){t.boundingBox||t.computeBoundingBox(),xn.set(t.boundingBox.min,t.boundingBox.max,e),xn.needsUpdate=!0;const o=n.geometry,c=o.attributes.position,l=o.index,u=t.attributes.position,h=t.index,f=Et.getPrimitive(),d=Et.getPrimitive();let y=Pu,_=wu,p=null,m=null;r&&(p=Eu,m=Ru);let g=1/0,v=null,S=null;return xr.copy(e).invert(),ai.matrix.copy(xr),n.shapecast({boundsTraverseOrder:x=>xn.distanceToBox(x),intersectsBounds:(x,b,T)=>T<g&&T<a?(b&&(ai.min.copy(x.min),ai.max.copy(x.max),ai.needsUpdate=!0),!0):!1,intersectsRange:(x,b)=>{if(t.boundsTree){const T=t.boundsTree;return T.shapecast({boundsTraverseOrder:w=>ai.distanceToBox(w),intersectsBounds:(w,C,P)=>P<g&&P<a,intersectsRange:(w,C)=>{for(let P=w,R=w+C;P<R;P++){const E=T.resolveTriangleIndex(P);et(d,3*E,h,u),d.a.applyMatrix4(e),d.b.applyMatrix4(e),d.c.applyMatrix4(e),d.needsUpdate=!0;for(let A=x,k=x+b;A<k;A++){const z=n.resolveTriangleIndex(A);et(f,3*z,l,c),f.needsUpdate=!0;const U=f.distanceToTriangle(d,y,p);if(U<g&&(_.copy(y),m&&m.copy(p),g=U,v=A,S=P),U<s)return!0}}}})}else{const T=Xe(t);for(let w=0,C=T;w<C;w++){et(d,3*w,h,u),d.a.applyMatrix4(e),d.b.applyMatrix4(e),d.c.applyMatrix4(e),d.needsUpdate=!0;for(let P=x,R=x+b;P<R;P++){const E=n.resolveTriangleIndex(P);et(f,3*E,l,c),f.needsUpdate=!0;const A=f.distanceToTriangle(d,y,p);if(A<g&&(_.copy(y),m&&m.copy(p),g=A,v=P,S=w),A<s)return!0}}}}}),Et.releasePrimitive(f),Et.releasePrimitive(d),g===1/0?null:(i.point?i.point.copy(_):i.point=_.clone(),i.distance=g,i.faceIndex=v,r&&(r.point?r.point.copy(m):r.point=m.clone(),r.point.applyMatrix4(xr),_.applyMatrix4(xr),r.distance=_.sub(r.point).length(),r.faceIndex=S),i)}function ku(){return typeof SharedArrayBuffer<"u"}const yi=new $.constructor,Lr=new $.constructor,pe=new ss(()=>new M.Box3),Fe=new M.Box3,De=new M.Box3,Sn=new M.Box3,bn=new M.Box3;let Tn=!1;function zu(n,t,e,i){if(Tn)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");Tn=!0;const r=n._roots,s=t._roots;let a,o=0,c=0;const l=new M.Matrix4().copy(e).invert();for(let u=0,h=r.length;u<h;u++){yi.setBuffer(r[u]),c=0;const f=pe.getPrimitive();Y(0,yi.float32Array,f),f.applyMatrix4(l);for(let d=0,y=s.length;d<y&&(Lr.setBuffer(s[d]),a=Ut(0,0,e,l,i,o,c,0,0,f),Lr.clearBuffer(),c+=s[d].length,!a);d++);if(pe.releasePrimitive(f),yi.clearBuffer(),o+=r[u].length,a)break}return Tn=!1,a}function Ut(n,t,e,i,r,s=0,a=0,o=0,c=0,l=null,u=!1){let h,f;u?(h=Lr,f=yi):(h=yi,f=Lr);const d=h.float32Array,y=h.uint32Array,_=h.uint16Array,p=f.float32Array,m=f.uint32Array,g=f.uint16Array,v=n*2,S=t*2,x=St(v,_),b=St(S,g);let T=!1;if(b&&x)u?T=r(Mt(t,m),Ct(t*2,g),Mt(n,y),Ct(n*2,_),c,a+t,o,s+n):T=r(Mt(n,y),Ct(n*2,_),Mt(t,m),Ct(t*2,g),o,s+n,c,a+t);else if(b){const w=pe.getPrimitive();Y(t,p,w),w.applyMatrix4(e);const C=Pt(n),P=wt(n,y);Y(C,d,Fe),Y(P,d,De);const R=w.intersectsBox(Fe),E=w.intersectsBox(De);T=R&&Ut(t,C,i,e,r,a,s,c,o+1,w,!u)||E&&Ut(t,P,i,e,r,a,s,c,o+1,w,!u),pe.releasePrimitive(w)}else{const w=Pt(t),C=wt(t,m);Y(w,p,Sn),Y(C,p,bn);const P=l.intersectsBox(Sn),R=l.intersectsBox(bn);if(P&&R)T=Ut(n,w,e,i,r,s,a,o,c+1,l,u)||Ut(n,C,e,i,r,s,a,o,c+1,l,u);else if(P)if(x)T=Ut(n,w,e,i,r,s,a,o,c+1,l,u);else{const E=pe.getPrimitive();E.copy(Sn).applyMatrix4(e);const A=Pt(n),k=wt(n,y);Y(A,d,Fe),Y(k,d,De);const z=E.intersectsBox(Fe),U=E.intersectsBox(De);T=z&&Ut(w,A,i,e,r,a,s,c,o+1,E,!u)||U&&Ut(w,k,i,e,r,a,s,c,o+1,E,!u),pe.releasePrimitive(E)}else if(R)if(x)T=Ut(n,C,e,i,r,s,a,o,c+1,l,u);else{const E=pe.getPrimitive();E.copy(bn).applyMatrix4(e);const A=Pt(n),k=wt(n,y);Y(A,d,Fe),Y(k,d,De);const z=E.intersectsBox(Fe),U=E.intersectsBox(De);T=z&&Ut(C,A,i,e,r,a,s,c,o+1,E,!u)||U&&Ut(C,k,i,e,r,a,s,c,o+1,E,!u),pe.releasePrimitive(E)}}return T}const Sr=new dt,to=new M.Box3,Bu={strategy:rs,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null};class Ki{static serialize(t,e={}){e={cloneBuffers:!0,...e};const i=t.geometry,r=t._roots,s=t._indirectBuffer,a=i.getIndex();let o;return e.cloneBuffers?o={roots:r.map(c=>c.slice()),index:a?a.array.slice():null,indirectBuffer:s?s.slice():null}:o={roots:r,index:a?a.array:null,indirectBuffer:s},o}static deserialize(t,e,i={}){i={setIndex:!0,indirect:!!t.indirectBuffer,...i};const{index:r,roots:s,indirectBuffer:a}=t,o=new Ki(e,{...i,[pn]:!0});if(o._roots=s,o._indirectBuffer=a||null,i.setIndex){const c=e.getIndex();if(c===null){const l=new M.BufferAttribute(t.index,1,!1);e.setIndex(l)}else c.array!==r&&(c.array.set(r),c.needsUpdate=!0)}return o}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({...Bu,[pn]:!1},e),e.useSharedArrayBuffer&&!ku())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=t,this._roots=null,this._indirectBuffer=null,e[pn]||(Wl(this,e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new M.Box3))),this.resolveTriangleIndex=e.indirect?i=>this._indirectBuffer[i]:i=>i}refit(t=null){return(this.indirect?Su:cu)(this,t)}traverse(t,e=0){const i=this._roots[e],r=new Uint32Array(i),s=new Uint16Array(i);a(0);function a(o,c=0){const l=o*2,u=s[l+15]===$r;if(u){const h=r[o+6],f=s[l+14];t(c,u,new Float32Array(i,o*4,6),h,f)}else{const h=o+mi/4,f=r[o+6],d=r[o+7];t(c,u,new Float32Array(i,o*4,6),d)||(a(h,c+1),a(f,c+1))}}}raycast(t,e=M.FrontSide,i=0,r=1/0){const s=this._roots,a=this.geometry,o=[],c=e.isMaterial,l=Array.isArray(e),u=a.groups,h=c?e.side:e,f=this.indirect?bu:fu;for(let d=0,y=s.length;d<y;d++){const _=l?e[u[d].materialIndex].side:h,p=o.length;if(f(this,d,_,t,o,i,r),l){const m=u[d].materialIndex;for(let g=p,v=o.length;g<v;g++)o[g].face.materialIndex=m}}return o}raycastFirst(t,e=M.FrontSide,i=0,r=1/0){const s=this._roots,a=this.geometry,o=e.isMaterial,c=Array.isArray(e);let l=null;const u=a.groups,h=o?e.side:e,f=this.indirect?Mu:pu;for(let d=0,y=s.length;d<y;d++){const _=c?e[u[d].materialIndex].side:h,p=f(this,d,_,t,i,r);p!=null&&(l==null||p.distance<l.distance)&&(l=p,c&&(p.face.materialIndex=u[d].materialIndex))}return l}intersectsGeometry(t,e){let i=!1;const r=this._roots,s=this.indirect?Cu:mu;for(let a=0,o=r.length;a<o&&(i=s(this,a,t,e),!i);a++);return i}shapecast(t){const e=Et.getPrimitive(),i=this.indirect?hu:au;let{boundsTraverseOrder:r,intersectsBounds:s,intersectsRange:a,intersectsTriangle:o}=t;if(a&&o){const h=a;a=(f,d,y,_,p)=>h(f,d,y,_,p)?!0:i(f,d,this,o,y,_,e)}else a||(o?a=(h,f,d,y)=>i(h,f,this,o,d,y,e):a=(h,f,d)=>d);let c=!1,l=0;const u=this._roots;for(let h=0,f=u.length;h<f;h++){const d=u[h];if(c=tu(this,h,s,a,r,l),c)break;l+=d.byteLength}return Et.releasePrimitive(e),c}bvhcast(t,e,i){let{intersectsRanges:r,intersectsTriangles:s}=i;const a=Et.getPrimitive(),o=this.geometry.index,c=this.geometry.attributes.position,l=this.indirect?y=>{const _=this.resolveTriangleIndex(y);et(a,_*3,o,c)}:y=>{et(a,y*3,o,c)},u=Et.getPrimitive(),h=t.geometry.index,f=t.geometry.attributes.position,d=t.indirect?y=>{const _=t.resolveTriangleIndex(y);et(u,_*3,h,f)}:y=>{et(u,y*3,h,f)};if(s){const y=(_,p,m,g,v,S,x,b)=>{for(let T=m,w=m+g;T<w;T++){d(T),u.a.applyMatrix4(e),u.b.applyMatrix4(e),u.c.applyMatrix4(e),u.needsUpdate=!0;for(let C=_,P=_+p;C<P;C++)if(l(C),a.needsUpdate=!0,s(a,u,C,T,v,S,x,b))return!0}return!1};if(r){const _=r;r=function(p,m,g,v,S,x,b,T){return _(p,m,g,v,S,x,b,T)?!0:y(p,m,g,v,S,x,b,T)}}else r=y}return zu(this,t,e,r)}intersectsBox(t,e){return Sr.set(t.min,t.max,e),Sr.needsUpdate=!0,this.shapecast({intersectsBounds:i=>Sr.intersectsBox(i),intersectsTriangle:i=>Sr.intersectsTriangle(i)})}intersectsSphere(t){return this.shapecast({intersectsBounds:e=>t.intersectsBox(e),intersectsTriangle:e=>e.intersectsSphere(t)})}closestPointToGeometry(t,e,i={},r={},s=0,a=1/0){return(this.indirect?Au:xu)(this,t,e,i,r,s,a)}closestPointToPoint(t,e={},i=0,r=1/0){return eu(this,t,e,i,r)}getBoundingBox(t){return t.makeEmpty(),this._roots.forEach(i=>{Y(0,new Float32Array(i),to),t.union(to)}),t}}function eo(n,t,e){return n===null?null:(n.point.applyMatrix4(t.matrixWorld),n.distance=n.point.distanceTo(e.ray.origin),n.object=t,n)}const br=new M.Ray,io=new M.Vector3,ro=new M.Matrix4,Ou=M.Mesh.prototype.raycast,Iu=M.BatchedMesh.prototype.raycast,no=new M.Vector3,ct=new M.Mesh,Tr=[];function Uu(n,t){this.isBatchedMesh?Nu.call(this,n,t):Fu.call(this,n,t)}function Nu(n,t){if(this.boundsTrees){const e=this.boundsTrees,i=this._drawInfo||this._instanceInfo,r=this._drawRanges||this._geometryInfo,s=this.matrixWorld;ct.material=this.material,ct.geometry=this.geometry;const a=ct.geometry.boundsTree,o=ct.geometry.drawRange;ct.geometry.boundingSphere===null&&(ct.geometry.boundingSphere=new M.Sphere);for(let c=0,l=i.length;c<l;c++){if(!this.getVisibleAt(c))continue;const u=i[c].geometryIndex;if(ct.geometry.boundsTree=e[u],this.getMatrixAt(c,ct.matrixWorld).premultiply(s),!ct.geometry.boundsTree){this.getBoundingBoxAt(u,ct.geometry.boundingBox),this.getBoundingSphereAt(u,ct.geometry.boundingSphere);const h=r[u];ct.geometry.setDrawRange(h.start,h.count)}ct.raycast(n,Tr);for(let h=0,f=Tr.length;h<f;h++){const d=Tr[h];d.object=this,d.batchId=c,t.push(d)}Tr.length=0}ct.geometry.boundsTree=a,ct.geometry.drawRange=o,ct.material=null,ct.geometry=null}else Iu.call(this,n,t)}function Fu(n,t){if(this.geometry.boundsTree){if(this.material===void 0)return;ro.copy(this.matrixWorld).invert(),br.copy(n.ray).applyMatrix4(ro),no.setFromMatrixScale(this.matrixWorld),io.copy(br.direction).multiply(no);const e=io.length(),i=n.near/e,r=n.far/e,s=this.geometry.boundsTree;if(n.firstHitOnly===!0){const a=eo(s.raycastFirst(br,this.material,i,r),this,n);a&&t.push(a)}else{const a=s.raycast(br,this.material,i,r);for(let o=0,c=a.length;o<c;o++){const l=eo(a[o],this,n);l&&t.push(l)}}}else Ou.call(this,n,t)}function Du(n={}){return this.boundsTree=new Ki(this,n),this.boundsTree}const Me=new M.Vector3,Ce=new M.Vector3,Pe=new M.Vector3,so=new M.Vector4,Mr=new M.Vector3,Mn=new M.Vector3,oo=new M.Vector4,ao=new M.Vector4,Cr=new M.Matrix4,co=new M.Matrix4;function ci(n,t){if(!n&&!t)return;const e=n.count===t.count,i=n.normalized===t.normalized,r=n.array.constructor===t.array.constructor,s=n.itemSize===t.itemSize;if(!e||!i||!r||!s)throw new Error}function di(n,t=null){const e=n.array.constructor,i=n.normalized,r=n.itemSize,s=t===null?n.count:t;return new M.BufferAttribute(new e(r*s),r,i)}function ya(n,t,e=0){if(n.isInterleavedBufferAttribute){const i=n.itemSize;for(let r=0,s=n.count;r<s;r++){const a=r+e;t.setX(a,n.getX(r)),i>=2&&t.setY(a,n.getY(r)),i>=3&&t.setZ(a,n.getZ(r)),i>=4&&t.setW(a,n.getW(r))}}else{const i=t.array,r=i.constructor,s=i.BYTES_PER_ELEMENT*n.itemSize*e;new r(i.buffer,s,n.array.length).set(n.array)}}function Lu(n,t,e){const i=n.elements,r=t.elements;for(let s=0,a=r.length;s<a;s++)i[s]+=r[s]*e}function lo(n,t,e){const i=n.skeleton,r=n.geometry,s=i.bones,a=i.boneInverses;oo.fromBufferAttribute(r.attributes.skinIndex,t),ao.fromBufferAttribute(r.attributes.skinWeight,t),Cr.elements.fill(0);for(let o=0;o<4;o++){const c=ao.getComponent(o);if(c!==0){const l=oo.getComponent(o);co.multiplyMatrices(s[l].matrixWorld,a[l]),Lu(Cr,co,c)}}return Cr.multiply(n.bindMatrix).premultiply(n.bindMatrixInverse),e.transformDirection(Cr),e}function Cn(n,t,e,i,r){Mr.set(0,0,0);for(let s=0,a=n.length;s<a;s++){const o=t[s],c=n[s];o!==0&&(Mn.fromBufferAttribute(c,i),e?Mr.addScaledVector(Mn,o):Mr.addScaledVector(Mn.sub(r),o))}r.add(Mr)}function Vu(n,t={useGroups:!1,updateIndex:!1,skipAttributes:[]},e=new M.BufferGeometry){const i=n[0].index!==null,{useGroups:r=!1,updateIndex:s=!1,skipAttributes:a=[]}=t,o=new Set(Object.keys(n[0].attributes)),c={};let l=0;e.clearGroups();for(let u=0;u<n.length;++u){const h=n[u];let f=0;if(i!==(h.index!==null))throw new Error("StaticGeometryGenerator: All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.");for(const d in h.attributes){if(!o.has(d))throw new Error('StaticGeometryGenerator: All geometries must have compatible attributes; make sure "'+d+'" attribute exists among all geometries, or in none of them.');c[d]===void 0&&(c[d]=[]),c[d].push(h.attributes[d]),f++}if(f!==o.size)throw new Error("StaticGeometryGenerator: Make sure all geometries have the same number of attributes.");if(r){let d;if(i)d=h.index.count;else if(h.attributes.position!==void 0)d=h.attributes.position.count;else throw new Error("StaticGeometryGenerator: The geometry must have either an index or a position attribute");e.addGroup(l,d,u),l+=d}}if(i){let u=!1;if(!e.index){let h=0;for(let f=0;f<n.length;++f)h+=n[f].index.count;e.setIndex(new M.BufferAttribute(new Uint32Array(h),1,!1)),u=!0}if(s||u){const h=e.index;let f=0,d=0;for(let y=0;y<n.length;++y){const _=n[y],p=_.index;if(a[y]!==!0)for(let m=0;m<p.count;++m)h.setX(f,p.getX(m)+d),f++;d+=_.attributes.position.count}}}for(const u in c){const h=c[u];if(!(u in e.attributes)){let y=0;for(const _ in h)y+=h[_].count;e.setAttribute(u,di(c[u][0],y))}const f=e.attributes[u];let d=0;for(let y=0,_=h.length;y<_;y++){const p=h[y];a[y]!==!0&&ya(p,f,d),d+=p.count}}return e}function Ju(n,t){if(n===null||t===null)return n===t;if(n.length!==t.length)return!1;for(let e=0,i=n.length;e<i;e++)if(n[e]!==t[e])return!1;return!0}function Gu(n){const{index:t,attributes:e}=n;if(t)for(let i=0,r=t.count;i<r;i+=3){const s=t.getX(i),a=t.getX(i+2);t.setX(i,a),t.setX(i+2,s)}else for(const i in e){const r=e[i],s=r.itemSize;for(let a=0,o=r.count;a<o;a+=3)for(let c=0;c<s;c++){const l=r.getComponent(a,c),u=r.getComponent(a+2,c);r.setComponent(a,c,u),r.setComponent(a+2,c,l)}}return n}class ju{constructor(t){this.matrixWorld=new M.Matrix4,this.geometryHash=null,this.boneMatrices=null,this.primitiveCount=-1,this.mesh=t,this.update()}update(){const t=this.mesh,e=t.geometry,i=t.skeleton,r=(e.index?e.index.count:e.attributes.position.count)/3;if(this.matrixWorld.copy(t.matrixWorld),this.geometryHash=e.attributes.position.version,this.primitiveCount=r,i){i.boneTexture||i.computeBoneTexture(),i.update();const s=i.boneMatrices;!this.boneMatrices||this.boneMatrices.length!==s.length?this.boneMatrices=s.slice():this.boneMatrices.set(s)}else this.boneMatrices=null}didChange(){const t=this.mesh,e=t.geometry,i=(e.index?e.index.count:e.attributes.position.count)/3;return!(this.matrixWorld.equals(t.matrixWorld)&&this.geometryHash===e.attributes.position.version&&Ju(t.skeleton&&t.skeleton.boneMatrices||null,this.boneMatrices)&&this.primitiveCount===i)}}class $u{constructor(t){Array.isArray(t)||(t=[t]);const e=[];t.forEach(i=>{i.traverseVisible(r=>{r.isMesh&&e.push(r)})}),this.meshes=e,this.useGroups=!0,this.applyWorldTransforms=!0,this.attributes=["position","normal","color","tangent","uv","uv2"],this._intermediateGeometry=new Array(e.length).fill().map(()=>new M.BufferGeometry),this._diffMap=new WeakMap}getMaterials(){const t=[];return this.meshes.forEach(e=>{Array.isArray(e.material)?t.push(...e.material):t.push(e.material)}),t}generate(t=new M.BufferGeometry){let e=[];const{meshes:i,useGroups:r,_intermediateGeometry:s,_diffMap:a}=this;for(let o=0,c=i.length;o<c;o++){const l=i[o],u=s[o],h=a.get(l);!h||h.didChange(l)?(this._convertToStaticGeometry(l,u),e.push(!1),h?h.update():a.set(l,new ju(l))):e.push(!0)}if(s.length===0){t.setIndex(null);const o=t.attributes;for(const c in o)t.deleteAttribute(c);for(const c in this.attributes)t.setAttribute(this.attributes[c],new M.BufferAttribute(new Float32Array(0),4,!1))}else Vu(s,{useGroups:r,skipAttributes:e},t);for(const o in t.attributes)t.attributes[o].needsUpdate=!0;return t}_convertToStaticGeometry(t,e=new M.BufferGeometry){const i=t.geometry,r=this.applyWorldTransforms,s=this.attributes.includes("normal"),a=this.attributes.includes("tangent"),o=i.attributes,c=e.attributes;!e.index&&i.index&&(e.index=i.index.clone()),c.position||e.setAttribute("position",di(o.position)),s&&!c.normal&&o.normal&&e.setAttribute("normal",di(o.normal)),a&&!c.tangent&&o.tangent&&e.setAttribute("tangent",di(o.tangent)),ci(i.index,e.index),ci(o.position,c.position),s&&ci(o.normal,c.normal),a&&ci(o.tangent,c.tangent);const l=o.position,u=s?o.normal:null,h=a?o.tangent:null,f=i.morphAttributes.position,d=i.morphAttributes.normal,y=i.morphAttributes.tangent,_=i.morphTargetsRelative,p=t.morphTargetInfluences,m=new M.Matrix3;m.getNormalMatrix(t.matrixWorld),i.index&&e.index.array.set(i.index.array);for(let g=0,v=o.position.count;g<v;g++)Me.fromBufferAttribute(l,g),u&&Ce.fromBufferAttribute(u,g),h&&(so.fromBufferAttribute(h,g),Pe.fromBufferAttribute(h,g)),p&&(f&&Cn(f,p,_,g,Me),d&&Cn(d,p,_,g,Ce),y&&Cn(y,p,_,g,Pe)),t.isSkinnedMesh&&(t.applyBoneTransform(g,Me),u&&lo(t,g,Ce),h&&lo(t,g,Pe)),r&&Me.applyMatrix4(t.matrixWorld),c.position.setXYZ(g,Me.x,Me.y,Me.z),u&&(r&&Ce.applyNormalMatrix(m),c.normal.setXYZ(g,Ce.x,Ce.y,Ce.z)),h&&(r&&Pe.transformDirection(t.matrixWorld),c.tangent.setXYZW(g,Pe.x,Pe.y,Pe.z,so.w));for(const g in this.attributes){const v=this.attributes[g];v==="position"||v==="tangent"||v==="normal"||!(v in o)||(c[v]||e.setAttribute(v,di(o[v])),ci(o[v],c[v]),ya(o[v],c[v]))}return t.matrixWorld.determinant()<0&&Gu(e),e}}const qu=Object.freeze(Object.defineProperty({__proto__:null,AVERAGE:la,CENTER:rs,CONTAINED:Fn,ExtendedTriangle:Rt,MeshBVH:Ki,OrientedBox:dt,SAH:ua,StaticGeometryGenerator:$u,acceleratedRaycast:Uu,computeBoundsTree:Du},Symbol.toStringTag,{value:"Module"}));class Xu{constructor(t){this.name="WorkerBase",this.running=!1,this.worker=t,this.worker.onerror=e=>{throw e.message?new Error(`${this.name}: Could not create Web Worker with error "${e.message}"`):new Error(`${this.name}: Could not create Web Worker.`)}}runTask(){}generate(...t){if(this.running)throw new Error("GenerateMeshBVHWorker: Already running job.");if(this.worker===null)throw new Error("GenerateMeshBVHWorker: Worker has been disposed.");this.running=!0;const e=this.runTask(this.worker,...t);return e.finally(()=>{this.running=!1}),e}dispose(){this.worker.terminate(),this.worker=null}}exports.$70d766613f57b014$export$2e2bcd8739ae039=Ko;exports.BatchedParticleRenderer=Pl;exports.Builder=Wn;exports.ByteBuffer=gi;exports.ConstantColor=Re;exports.ConstantValue=F;exports.Matrix4=Ft;exports.MeshBVH=Ki;exports.MotionController=Ta;exports.ParticleSystem=Dr;exports.SIZE_PREFIX_LENGTH=ho;exports.TrailParticle=Nr;exports.Vector4=bt;exports.WorkerBase=Xu;exports.bundler=ec;exports.createNoise4D=El;exports.fetchProfile=va;exports.index=zl;exports.index$1=qu;exports.md5=gc;exports.v5=fc;
|
|
1121
|
+
}`;class Cl extends oa{constructor(t){super(t),this.vector_=new O,this.vector2_=new O,this.vector3_=new O,this.quaternion_=new J,this.maxParticles=1e4,this.setupBuffers(),this.rebuildMaterial()}setupBuffers(){this.geometry&&this.geometry.dispose(),this.geometry=new M.BufferGeometry,this.indexBuffer=new M.BufferAttribute(new Uint32Array(this.maxParticles*6),1),this.indexBuffer.setUsage(M.DynamicDrawUsage),this.geometry.setIndex(this.indexBuffer),this.positionBuffer=new M.BufferAttribute(new Float32Array(this.maxParticles*6),3),this.positionBuffer.setUsage(M.DynamicDrawUsage),this.geometry.setAttribute("position",this.positionBuffer),this.previousBuffer=new M.BufferAttribute(new Float32Array(this.maxParticles*6),3),this.previousBuffer.setUsage(M.DynamicDrawUsage),this.geometry.setAttribute("previous",this.previousBuffer),this.nextBuffer=new M.BufferAttribute(new Float32Array(this.maxParticles*6),3),this.nextBuffer.setUsage(M.DynamicDrawUsage),this.geometry.setAttribute("next",this.nextBuffer),this.widthBuffer=new M.BufferAttribute(new Float32Array(this.maxParticles*2),1),this.widthBuffer.setUsage(M.DynamicDrawUsage),this.geometry.setAttribute("width",this.widthBuffer),this.sideBuffer=new M.BufferAttribute(new Float32Array(this.maxParticles*2),1),this.sideBuffer.setUsage(M.DynamicDrawUsage),this.geometry.setAttribute("side",this.sideBuffer),this.uvBuffer=new M.BufferAttribute(new Float32Array(this.maxParticles*4),2),this.uvBuffer.setUsage(M.DynamicDrawUsage),this.geometry.setAttribute("uv",this.uvBuffer),this.colorBuffer=new M.BufferAttribute(new Float32Array(this.maxParticles*8),4),this.colorBuffer.setUsage(M.DynamicDrawUsage),this.geometry.setAttribute("color",this.colorBuffer)}expandBuffers(t){for(;t>=this.maxParticles;)this.maxParticles*=2;this.setupBuffers()}rebuildMaterial(){this.layers.mask=this.settings.layers.mask;const t={lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},resolution:{value:new Je(1,1)},sizeAttenuation:{value:1},visibility:{value:1},alphaTest:{value:0}},e={};if(e.USE_UV="",e.USE_COLOR_ALPHA="",this.settings.material.map&&(e.USE_MAP="",e.MAP_UV=Nn(this.settings.material.map.channel),t.map=new M.Uniform$1(this.settings.material.map),t.mapTransform=new M.Uniform$1(new Xt().copy(this.settings.material.map.matrix))),this.settings.material.defines&&this.settings.material.defines.USE_COLOR_AS_ALPHA!==void 0&&(e.USE_COLOR_AS_ALPHA=""),this.settings.renderMode===exports.RenderMode.Trail)this.material=new M.ShaderMaterial({uniforms:t,defines:e,vertexShader:Ml,fragmentShader:Tl,transparent:this.settings.material.transparent,depthWrite:!this.settings.material.transparent,side:this.settings.material.side,blending:this.settings.material.blending||M.AdditiveBlending,blendDst:this.settings.material.blendDst,blendSrc:this.settings.material.blendSrc,blendEquation:this.settings.material.blendEquation,premultipliedAlpha:this.settings.material.premultipliedAlpha});else throw new Error("render mode unavailable")}update(){let t=0,e=0,i=0;this.systems.forEach(r=>{for(let s=0;s<r.particleNum;s++)i+=r.particles[s].previous.length*2}),i>this.maxParticles&&this.expandBuffers(i),this.systems.forEach(r=>{r.emitter.updateMatrixWorld&&(r.emitter.updateWorldMatrix(!0,!1),r.emitter.updateMatrixWorld(!0));const s=this.quaternion_,a=this.vector2_,o=this.vector3_;r.emitter.matrixWorld.decompose(a,s,o);const c=r.particles,l=r.particleNum,u=this.settings.uTileCount,h=this.settings.vTileCount,f=1/u,d=1/h;for(let y=0;y<l;y++){const _=c[y],p=_.uvTile%h,m=Math.floor(_.uvTile/h+.001),g=_.previous.values();let v=g.next(),S=v.value,x=S;v.done||(v=g.next());let b;v.value!==void 0?b=v.value:b=x;for(let T=0;T<_.previous.length;T++,t+=2){if(this.positionBuffer.setXYZ(t,x.position.x,x.position.y,x.position.z),this.positionBuffer.setXYZ(t+1,x.position.x,x.position.y,x.position.z),r.worldSpace?(this.positionBuffer.setXYZ(t,x.position.x,x.position.y,x.position.z),this.positionBuffer.setXYZ(t+1,x.position.x,x.position.y,x.position.z)):(_.parentMatrix?this.vector_.copy(x.position).applyMatrix4(_.parentMatrix):this.vector_.copy(x.position).applyMatrix4(r.emitter.matrixWorld),this.positionBuffer.setXYZ(t,this.vector_.x,this.vector_.y,this.vector_.z),this.positionBuffer.setXYZ(t+1,this.vector_.x,this.vector_.y,this.vector_.z)),r.worldSpace?(this.previousBuffer.setXYZ(t,S.position.x,S.position.y,S.position.z),this.previousBuffer.setXYZ(t+1,S.position.x,S.position.y,S.position.z)):(_.parentMatrix?this.vector_.copy(S.position).applyMatrix4(_.parentMatrix):this.vector_.copy(S.position).applyMatrix4(r.emitter.matrixWorld),this.previousBuffer.setXYZ(t,this.vector_.x,this.vector_.y,this.vector_.z),this.previousBuffer.setXYZ(t+1,this.vector_.x,this.vector_.y,this.vector_.z)),r.worldSpace?(this.nextBuffer.setXYZ(t,b.position.x,b.position.y,b.position.z),this.nextBuffer.setXYZ(t+1,b.position.x,b.position.y,b.position.z)):(_.parentMatrix?this.vector_.copy(b.position).applyMatrix4(_.parentMatrix):this.vector_.copy(b.position).applyMatrix4(r.emitter.matrixWorld),this.nextBuffer.setXYZ(t,this.vector_.x,this.vector_.y,this.vector_.z),this.nextBuffer.setXYZ(t+1,this.vector_.x,this.vector_.y,this.vector_.z)),this.sideBuffer.setX(t,-1),this.sideBuffer.setX(t+1,1),r.worldSpace)this.widthBuffer.setX(t,x.size),this.widthBuffer.setX(t+1,x.size);else if(_.parentMatrix)this.widthBuffer.setX(t,x.size),this.widthBuffer.setX(t+1,x.size);else{const w=(Math.abs(o.x)+Math.abs(o.y)+Math.abs(o.z))/3;this.widthBuffer.setX(t,x.size*w),this.widthBuffer.setX(t+1,x.size*w)}this.uvBuffer.setXY(t,(T/_.previous.length+p)*f,(h-m-1)*d),this.uvBuffer.setXY(t+1,(T/_.previous.length+p)*f,(h-m)*d),this.colorBuffer.setXYZW(t,x.color.x,x.color.y,x.color.z,x.color.w),this.colorBuffer.setXYZW(t+1,x.color.x,x.color.y,x.color.z,x.color.w),T+1<_.previous.length&&(this.indexBuffer.setX(e*3,t),this.indexBuffer.setX(e*3+1,t+1),this.indexBuffer.setX(e*3+2,t+2),e++,this.indexBuffer.setX(e*3,t+2),this.indexBuffer.setX(e*3+1,t+1),this.indexBuffer.setX(e*3+2,t+3),e++),S=x,x=b,v.done||(v=g.next(),v.value!==void 0&&(b=v.value))}}}),this.positionBuffer.clearUpdateRanges(),this.positionBuffer.addUpdateRange(0,t*3),this.positionBuffer.needsUpdate=!0,this.previousBuffer.clearUpdateRanges(),this.previousBuffer.addUpdateRange(0,t*3),this.previousBuffer.needsUpdate=!0,this.nextBuffer.clearUpdateRanges(),this.nextBuffer.addUpdateRange(0,t*3),this.nextBuffer.needsUpdate=!0,this.sideBuffer.clearUpdateRanges(),this.sideBuffer.addUpdateRange(0,t),this.sideBuffer.needsUpdate=!0,this.widthBuffer.clearUpdateRanges(),this.widthBuffer.addUpdateRange(0,t),this.widthBuffer.needsUpdate=!0,this.uvBuffer.clearUpdateRanges(),this.uvBuffer.addUpdateRange(0,t*2),this.uvBuffer.needsUpdate=!0,this.colorBuffer.clearUpdateRanges(),this.colorBuffer.addUpdateRange(0,t*4),this.colorBuffer.needsUpdate=!0,this.indexBuffer.clearUpdateRanges(),this.indexBuffer.addUpdateRange(0,e*3),this.indexBuffer.needsUpdate=!0,this.geometry.setDrawRange(0,e*3)}dispose(){this.geometry.dispose()}}class Yi{get geometry(){return this._geometry}set geometry(t){if(this._geometry=t,t===void 0||typeof t=="string")return;const e=new M.Triangle;this._triangleIndexToArea.length=0;let i=0;if(!t.getIndex())return;const r=t.getIndex().array,s=r.length/3;this._triangleIndexToArea.push(0);for(let a=0;a<s;a++)e.setFromAttributeAndIndices(t.getAttribute("position"),r[a*3],r[a*3+1],r[a*3+2]),i+=e.getArea(),this._triangleIndexToArea.push(i);t.userData.triangleIndexToArea=this._triangleIndexToArea}constructor(t){this.type="mesh_surface",this._triangleIndexToArea=[],this._tempA=new M.Vector3,this._tempB=new M.Vector3,this._tempC=new M.Vector3,t&&(this.geometry=t)}initialize(t){const e=this._geometry;if(!e||e.getIndex()===null){t.position.set(0,0,0),t.velocity.set(0,0,1).multiplyScalar(t.startSpeed);return}const i=this._triangleIndexToArea.length-1;let r=0,s=i;const a=Math.random()*this._triangleIndexToArea[i];for(;r+1<s;){const d=Math.floor((r+s)/2);a<this._triangleIndexToArea[d]?s=d:r=d}let o=Math.random(),c=Math.random();o+c>1&&(o=1-o,c=1-c);const l=e.getIndex().array[r*3],u=e.getIndex().array[r*3+1],h=e.getIndex().array[r*3+2],f=e.getAttribute("position");this._tempA.fromBufferAttribute(f,l),this._tempB.fromBufferAttribute(f,u),this._tempC.fromBufferAttribute(f,h),this._tempB.sub(this._tempA),this._tempC.sub(this._tempA),this._tempA.addScaledVector(this._tempB,o).addScaledVector(this._tempC,c),t.position.copy(this._tempA),this._tempA.copy(this._tempB).cross(this._tempC).normalize(),t.velocity.copy(this._tempA).normalize().multiplyScalar(t.startSpeed)}toJSON(){return{type:"mesh_surface",mesh:this._geometry?this._geometry.uuid:""}}static fromJSON(t,e){return new Yi(e.geometries[t.geometry])}clone(){return new Yi(this._geometry)}update(t,e){}}il({id:"three.quarks",emitterShapes:[{type:"mesh_surface",params:[["geometry",["geometry"]]],constructor:Yi,loadJSON:Yi.fromJSON}],behaviors:[]});class is extends M.Object3D{constructor(){super(),this.batches=[],this.systemToBatchIndex=new Map,this.type="BatchedRenderer",this.depthTexture=null}static equals(t,e){return t.material.side===e.material.side&&t.material.blending===e.material.blending&&t.material.blendSrc===e.material.blendSrc&&t.material.blendDst===e.material.blendDst&&t.material.blendEquation===e.material.blendEquation&&t.material.premultipliedAlpha===e.material.premultipliedAlpha&&t.material.transparent===e.material.transparent&&t.material.depthTest===e.material.depthTest&&t.material.type===e.material.type&&t.material.alphaTest===e.material.alphaTest&&t.material.map===e.material.map&&t.renderMode===e.renderMode&&t.blendTiles===e.blendTiles&&t.softParticles===e.softParticles&&t.softFarFade===e.softFarFade&&t.softNearFade===e.softNearFade&&t.uTileCount===e.uTileCount&&t.vTileCount===e.vTileCount&&t.instancingGeometry===e.instancingGeometry&&t.renderOrder===e.renderOrder&&t.layers.mask===e.layers.mask}addSystem(t){t._renderer=this;const e=t.getRendererSettings();for(let r=0;r<this.batches.length;r++)if(is.equals(this.batches[r].settings,e)){this.batches[r].addSystem(t),this.systemToBatchIndex.set(t,r);return}let i;switch(e.renderMode){case exports.RenderMode.Trail:i=new Cl(e);break;case exports.RenderMode.Mesh:case exports.RenderMode.BillBoard:case exports.RenderMode.VerticalBillBoard:case exports.RenderMode.HorizontalBillBoard:case exports.RenderMode.StretchedBillBoard:i=new bl(e);break}this.depthTexture&&i.applyDepthTexture(this.depthTexture),i.addSystem(t),this.batches.push(i),this.systemToBatchIndex.set(t,this.batches.length-1),this.add(i)}deleteSystem(t){const e=this.systemToBatchIndex.get(t);e!=null&&(this.batches[e].removeSystem(t),this.systemToBatchIndex.delete(t))}setDepthTexture(t){this.depthTexture=t;for(const e of this.batches)e.applyDepthTexture(t)}updateSystem(t){this.deleteSystem(t),this.addSystem(t)}update(t){this.systemToBatchIndex.forEach((e,i)=>{i.update(t)});for(let e=0;e<this.batches.length;e++)this.batches[e].update()}}const Pl=is;hl();console.log("%c Particle system powered by three.quarks. https://quarks.art/","font-size: 14px; font-weight: bold;");const aa=Math.sqrt(5),wl=(aa-1)/4,at=(5-aa)/20,ar=n=>Math.floor(n)|0,cr=new Float64Array([0,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,1,0,1,1,1,0,1,-1,1,0,-1,1,1,0,-1,-1,-1,0,1,1,-1,0,1,-1,-1,0,-1,1,-1,0,-1,-1,1,1,0,1,1,1,0,-1,1,-1,0,1,1,-1,0,-1,-1,1,0,1,-1,1,0,-1,-1,-1,0,1,-1,-1,0,-1,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,0]);function El(n=Math.random){const t=Rl(n),e=new Float64Array(t).map(a=>cr[a%32*4]),i=new Float64Array(t).map(a=>cr[a%32*4+1]),r=new Float64Array(t).map(a=>cr[a%32*4+2]),s=new Float64Array(t).map(a=>cr[a%32*4+3]);return function(o,c,l,u){let h,f,d,y,_;const p=(o+c+l+u)*wl,m=ar(o+p),g=ar(c+p),v=ar(l+p),S=ar(u+p),x=(m+g+v+S)*at,b=m-x,T=g-x,w=v-x,C=S-x,P=o-b,R=c-T,E=l-w,A=u-C;let k=0,z=0,U=0,L=0;P>R?k++:z++,P>E?k++:U++,P>A?k++:L++,R>E?z++:U++,R>A?z++:L++,E>A?U++:L++;const I=k>=3?1:0,X=z>=3?1:0,Z=U>=3?1:0,it=L>=3?1:0,K=k>=2?1:0,pt=z>=2?1:0,mt=U>=2?1:0,rt=L>=2?1:0,W=k>=1?1:0,j=z>=1?1:0,Ht=U>=1?1:0,Dt=L>=1?1:0,Lt=P-I+at,Vt=R-X+at,vt=E-Z+at,At=A-it+at,_t=P-K+2*at,Yt=R-pt+2*at,Zt=E-mt+2*at,H=A-rt+2*at,Jt=P-W+3*at,Qt=R-j+3*at,ve=E-Ht+3*at,Kt=A-Dt+3*at,te=P-1+4*at,ee=R-1+4*at,ie=E-1+4*at,re=A-1+4*at,kt=m&255,zt=g&255,Bt=v&255,Ot=S&255;let V=.6-P*P-R*R-E*E-A*A;if(V<0)h=0;else{const q=kt+t[zt+t[Bt+t[Ot]]];V*=V,h=V*V*(e[q]*P+i[q]*R+r[q]*E+s[q]*A)}let We=.6-Lt*Lt-Vt*Vt-vt*vt-At*At;if(We<0)f=0;else{const q=kt+I+t[zt+X+t[Bt+Z+t[Ot+it]]];We*=We,f=We*We*(e[q]*Lt+i[q]*Vt+r[q]*vt+s[q]*At)}let He=.6-_t*_t-Yt*Yt-Zt*Zt-H*H;if(He<0)d=0;else{const q=kt+K+t[zt+pt+t[Bt+mt+t[Ot+rt]]];He*=He,d=He*He*(e[q]*_t+i[q]*Yt+r[q]*Zt+s[q]*H)}let Ye=.6-Jt*Jt-Qt*Qt-ve*ve-Kt*Kt;if(Ye<0)y=0;else{const q=kt+W+t[zt+j+t[Bt+Ht+t[Ot+Dt]]];Ye*=Ye,y=Ye*Ye*(e[q]*Jt+i[q]*Qt+r[q]*ve+s[q]*Kt)}let Ze=.6-te*te-ee*ee-ie*ie-re*re;if(Ze<0)_=0;else{const q=kt+1+t[zt+1+t[Bt+1+t[Ot+1]]];Ze*=Ze,_=Ze*Ze*(e[q]*te+i[q]*ee+r[q]*ie+s[q]*re)}return 27*(h+f+d+y+_)}}function Rl(n){const e=new Uint8Array(512);for(let i=0;i<512/2;i++)e[i]=i;for(let i=0;i<512/2-1;i++){const r=i+~~(n()*(256-i)),s=e[i];e[i]=e[r],e[r]=s}for(let i=256;i<512;i++)e[i]=e[i-256];return e}class Al{constructor(t,e){if(this._retries=0,!Number.isInteger(t)||t<0)throw new Error("Base must be a positive integer or zero");if(e!==void 0&&(!Number.isInteger(e)||e<0))throw new Error("ExpMax must be a undefined, a positive integer or zero");this.base=t,this.expMax=e,this.i=0}get retries(){return this._retries}get current(){return this.base*Math.pow(2,this.i)}next(){return this._retries++,this.i=this.expMax===void 0?this.i+1:Math.min(this.i+1,this.expMax),this.current}reset(){this._retries=0,this.i=0}}var G;(function(n){n.open="open",n.close="close",n.error="error",n.message="message",n.retry="retry",n.reconnect="reconnect"})(G||(G={}));class ca{constructor(t,e,i){var r,s,a,o,c,l,u,h,f,d,y,_,p,m,g;this._closedByUser=!1,this.handleOpenEvent=v=>this.handleEvent(G.open,v),this.handleErrorEvent=v=>this.handleEvent(G.error,v),this.handleCloseEvent=v=>this.handleEvent(G.close,v),this.handleMessageEvent=v=>this.handleEvent(G.message,v),this._url=t,this._protocols=e,this._options={buffer:i==null?void 0:i.buffer,retry:{maxRetries:(r=i==null?void 0:i.retry)===null||r===void 0?void 0:r.maxRetries,instantReconnect:(s=i==null?void 0:i.retry)===null||s===void 0?void 0:s.instantReconnect,backoff:(a=i==null?void 0:i.retry)===null||a===void 0?void 0:a.backoff},listeners:{open:[...(c=(o=i==null?void 0:i.listeners)===null||o===void 0?void 0:o.open)!==null&&c!==void 0?c:[]],close:[...(u=(l=i==null?void 0:i.listeners)===null||l===void 0?void 0:l.close)!==null&&u!==void 0?u:[]],error:[...(f=(h=i==null?void 0:i.listeners)===null||h===void 0?void 0:h.error)!==null&&f!==void 0?f:[]],message:[...(y=(d=i==null?void 0:i.listeners)===null||d===void 0?void 0:d.message)!==null&&y!==void 0?y:[]],retry:[...(p=(_=i==null?void 0:i.listeners)===null||_===void 0?void 0:_.retry)!==null&&p!==void 0?p:[]],reconnect:[...(g=(m=i==null?void 0:i.listeners)===null||m===void 0?void 0:m.reconnect)!==null&&g!==void 0?g:[]]}},this._underlyingWebsocket=this.tryConnect()}get url(){return this._url}get protocols(){return this._protocols}get buffer(){return this._options.buffer}get maxRetries(){return this._options.retry.maxRetries}get instantReconnect(){return this._options.retry.instantReconnect}get backoff(){return this._options.retry.backoff}get closedByUser(){return this._closedByUser}get lastConnection(){return this._lastConnection}get underlyingWebsocket(){return this._underlyingWebsocket}get readyState(){return this._underlyingWebsocket.readyState}get bufferedAmount(){return this._underlyingWebsocket.bufferedAmount}get extensions(){return this._underlyingWebsocket.extensions}get binaryType(){return this._underlyingWebsocket.binaryType}set binaryType(t){this._underlyingWebsocket.binaryType=t}send(t){this.closedByUser||(this._underlyingWebsocket.readyState===this._underlyingWebsocket.OPEN?this._underlyingWebsocket.send(t):this.buffer!==void 0&&this.buffer.add(t))}close(t,e){this.cancelScheduledConnectionRetry(),this._closedByUser=!0,this._underlyingWebsocket.close(t,e)}addEventListener(t,e,i){this._options.listeners[t].push({listener:e,options:i})}removeEventListener(t,e,i){const r=s=>s.listener!==e||s.options!==i;this._options.listeners[t]=this._options.listeners[t].filter(r)}tryConnect(){return this._underlyingWebsocket=new WebSocket(this.url,this.protocols),this._underlyingWebsocket.addEventListener(G.open,this.handleOpenEvent),this._underlyingWebsocket.addEventListener(G.close,this.handleCloseEvent),this._underlyingWebsocket.addEventListener(G.error,this.handleErrorEvent),this._underlyingWebsocket.addEventListener(G.message,this.handleMessageEvent),this._underlyingWebsocket}clearWebsocket(){this._underlyingWebsocket.removeEventListener(G.open,this.handleOpenEvent),this._underlyingWebsocket.removeEventListener(G.close,this.handleCloseEvent),this._underlyingWebsocket.removeEventListener(G.error,this.handleErrorEvent),this._underlyingWebsocket.removeEventListener(G.message,this.handleMessageEvent),this._underlyingWebsocket.close()}dispatchEvent(t,e){const i=this._options.listeners[t],r=[];i.forEach(({listener:s,options:a})=>{s(this,e),(a===void 0||a.once===void 0||!a.once)&&r.push({listener:s,options:a})}),this._options.listeners[t]=r}handleEvent(t,e){switch(t){case G.close:this.dispatchEvent(t,e),this.scheduleConnectionRetryIfNeeded();break;case G.open:if(this.backoff!==void 0&&this._lastConnection!==void 0){const i={retries:this.backoff.retries,lastConnection:new Date(this._lastConnection)},r=new CustomEvent(G.reconnect,{detail:i});this.dispatchEvent(G.reconnect,r),this.backoff.reset()}this._lastConnection=new Date,this.dispatchEvent(t,e),this.sendBufferedData();break;case G.retry:this.dispatchEvent(t,e),this.clearWebsocket(),this.tryConnect();break;default:this.dispatchEvent(t,e);break}}sendBufferedData(){if(this.buffer!==void 0)for(let t=this.buffer.read();t!==void 0;t=this.buffer.read())this.send(t)}scheduleConnectionRetryIfNeeded(){if(this.closedByUser||this.backoff===void 0)return;const t=i=>{const r=new CustomEvent(G.retry,{detail:i});this.handleEvent(G.retry,r)},e={backoff:this._options.retry.instantReconnect===!0?0:this.backoff.next(),retries:this._options.retry.instantReconnect===!0?0:this.backoff.retries,lastConnection:this._lastConnection};(this._options.retry.maxRetries===void 0||e.retries<=this._options.retry.maxRetries)&&(this.retryTimeout=globalThis.setTimeout(()=>t(e),e.backoff))}cancelScheduledConnectionRetry(){globalThis.clearTimeout(this.retryTimeout)}}class kl{constructor(t){this._url=t}get url(){return this._url}withProtocols(t){return this._protocols=t,this}get protocols(){return this._protocols}withMaxRetries(t){var e;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(e=this._options)===null||e===void 0?void 0:e.retry),{maxRetries:t})}),this}get maxRetries(){var t,e;return(e=(t=this._options)===null||t===void 0?void 0:t.retry)===null||e===void 0?void 0:e.maxRetries}withInstantReconnect(t){var e;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(e=this._options)===null||e===void 0?void 0:e.retry),{instantReconnect:t})}),this}get instantReconnect(){var t,e;return(e=(t=this._options)===null||t===void 0?void 0:t.retry)===null||e===void 0?void 0:e.instantReconnect}withBackoff(t){var e;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(e=this._options)===null||e===void 0?void 0:e.retry),{backoff:t})}),this}get backoff(){var t,e;return(e=(t=this._options)===null||t===void 0?void 0:t.retry)===null||e===void 0?void 0:e.backoff}withBuffer(t){return this._options=Object.assign(Object.assign({},this._options),{buffer:t}),this}get buffer(){var t;return(t=this._options)===null||t===void 0?void 0:t.buffer}onOpen(t,e){return this.addListener(G.open,t,e),this}onClose(t,e){return this.addListener(G.close,t,e),this}onError(t,e){return this.addListener(G.error,t,e),this}onMessage(t,e){return this.addListener(G.message,t,e),this}onRetry(t,e){return this.addListener(G.retry,t,e),this}onReconnect(t,e){return this.addListener(G.reconnect,t,e),this}build(){return new ca(this._url,this._protocols,this._options)}addListener(t,e,i){var r,s,a,o,c,l,u,h,f,d,y,_,p,m,g,v,S,x,b,T,w;return this._options=Object.assign(Object.assign({},this._options),{listeners:{open:(a=(s=(r=this._options)===null||r===void 0?void 0:r.listeners)===null||s===void 0?void 0:s.open)!==null&&a!==void 0?a:[],close:(l=(c=(o=this._options)===null||o===void 0?void 0:o.listeners)===null||c===void 0?void 0:c.close)!==null&&l!==void 0?l:[],error:(f=(h=(u=this._options)===null||u===void 0?void 0:u.listeners)===null||h===void 0?void 0:h.error)!==null&&f!==void 0?f:[],message:(_=(y=(d=this._options)===null||d===void 0?void 0:d.listeners)===null||y===void 0?void 0:y.message)!==null&&_!==void 0?_:[],retry:(g=(m=(p=this._options)===null||p===void 0?void 0:p.listeners)===null||m===void 0?void 0:m.retry)!==null&&g!==void 0?g:[],reconnect:(x=(S=(v=this._options)===null||v===void 0?void 0:v.listeners)===null||S===void 0?void 0:S.reconnect)!==null&&x!==void 0?x:[],[t]:[...(w=(T=(b=this._options)===null||b===void 0?void 0:b.listeners)===null||T===void 0?void 0:T[t])!==null&&w!==void 0?w:[],{listener:e,options:i}]}}),this}}const zl=Object.freeze(Object.defineProperty({__proto__:null,ExponentialBackoff:Al,Websocket:ca,WebsocketBuilder:kl,get WebsocketEvent(){return G}},Symbol.toStringTag,{value:"Module"})),rs=0,la=1,ua=2,Fn=2,dn=1.25,$s=1,mi=32,$r=65535,Bl=Math.pow(2,-24),pn=Symbol("SKIP_GENERATION");function Ol(n){return n.index?n.index.count:n.attributes.position.count}function Xe(n){return Ol(n)/3}function Il(n,t=ArrayBuffer){return n>65535?new Uint32Array(new t(4*n)):new Uint16Array(new t(2*n))}function Ul(n,t){if(!n.index){const e=n.attributes.position.count,i=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,r=Il(e,i);n.setIndex(new M.BufferAttribute(r,1));for(let s=0;s<e;s++)r[s]=s}}function ha(n,t){const e=Xe(n),i=t||n.drawRange,r=i.start/3,s=(i.start+i.count)/3,a=Math.max(0,r),o=Math.min(e,s)-a;return[{offset:Math.floor(a),count:Math.floor(o)}]}function fa(n,t){if(!n.groups||!n.groups.length)return ha(n,t);const e=[],i=new Set,r=t||n.drawRange,s=r.start/3,a=(r.start+r.count)/3;for(const c of n.groups){const l=c.start/3,u=(c.start+c.count)/3;i.add(Math.max(s,l)),i.add(Math.min(a,u))}const o=Array.from(i.values()).sort((c,l)=>c-l);for(let c=0;c<o.length-1;c++){const l=o[c],u=o[c+1];e.push({offset:Math.floor(l),count:Math.floor(u-l)})}return e}function Nl(n,t){const e=Xe(n),i=fa(n,t).sort((a,o)=>a.offset-o.offset),r=i[i.length-1];r.count=Math.min(e-r.offset,r.count);let s=0;return i.forEach(({count:a})=>s+=a),e!==s}function mn(n,t,e,i,r){let s=1/0,a=1/0,o=1/0,c=-1/0,l=-1/0,u=-1/0,h=1/0,f=1/0,d=1/0,y=-1/0,_=-1/0,p=-1/0;for(let m=t*6,g=(t+e)*6;m<g;m+=6){const v=n[m+0],S=n[m+1],x=v-S,b=v+S;x<s&&(s=x),b>c&&(c=b),v<h&&(h=v),v>y&&(y=v);const T=n[m+2],w=n[m+3],C=T-w,P=T+w;C<a&&(a=C),P>l&&(l=P),T<f&&(f=T),T>_&&(_=T);const R=n[m+4],E=n[m+5],A=R-E,k=R+E;A<o&&(o=A),k>u&&(u=k),R<d&&(d=R),R>p&&(p=R)}i[0]=s,i[1]=a,i[2]=o,i[3]=c,i[4]=l,i[5]=u,r[0]=h,r[1]=f,r[2]=d,r[3]=y,r[4]=_,r[5]=p}function Fl(n,t=null,e=null,i=null){const r=n.attributes.position,s=n.index?n.index.array:null,a=Xe(n),o=r.normalized;let c;t===null?(c=new Float32Array(a*6),e=0,i=a):(c=t,e=e||0,i=i||a);const l=r.array,u=r.offset||0;let h=3;r.isInterleavedBufferAttribute&&(h=r.data.stride);const f=["getX","getY","getZ"];for(let d=e;d<e+i;d++){const y=d*3,_=d*6;let p=y+0,m=y+1,g=y+2;s&&(p=s[p],m=s[m],g=s[g]),o||(p=p*h+u,m=m*h+u,g=g*h+u);for(let v=0;v<3;v++){let S,x,b;o?(S=r[f[v]](p),x=r[f[v]](m),b=r[f[v]](g)):(S=l[p+v],x=l[m+v],b=l[g+v]);let T=S;x<T&&(T=x),b<T&&(T=b);let w=S;x>w&&(w=x),b>w&&(w=b);const C=(w-T)/2,P=v*2;c[_+P+0]=T+C,c[_+P+1]=C+(Math.abs(T)+C)*Bl}}return c}function Y(n,t,e){return e.min.x=t[n],e.min.y=t[n+1],e.min.z=t[n+2],e.max.x=t[n+3],e.max.y=t[n+4],e.max.z=t[n+5],e}function qs(n){let t=-1,e=-1/0;for(let i=0;i<3;i++){const r=n[i+3]-n[i];r>e&&(e=r,t=i)}return t}function Xs(n,t){t.set(n)}function Ws(n,t,e){let i,r;for(let s=0;s<3;s++){const a=s+3;i=n[s],r=t[s],e[s]=i<r?i:r,i=n[a],r=t[a],e[a]=i>r?i:r}}function lr(n,t,e){for(let i=0;i<3;i++){const r=t[n+2*i],s=t[n+2*i+1],a=r-s,o=r+s;a<e[i]&&(e[i]=a),o>e[i+3]&&(e[i+3]=o)}}function ei(n){const t=n[3]-n[0],e=n[4]-n[1],i=n[5]-n[2];return 2*(t*e+e*i+i*t)}const ne=32,Dl=(n,t)=>n.candidate-t.candidate,fe=new Array(ne).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),ur=new Float32Array(6);function Ll(n,t,e,i,r,s){let a=-1,o=0;if(s===rs)a=qs(t),a!==-1&&(o=(t[a]+t[a+3])/2);else if(s===la)a=qs(n),a!==-1&&(o=Vl(e,i,r,a));else if(s===ua){const c=ei(n);let l=dn*r;const u=i*6,h=(i+r)*6;for(let f=0;f<3;f++){const d=t[f],p=(t[f+3]-d)/ne;if(r<ne/4){const m=[...fe];m.length=r;let g=0;for(let S=u;S<h;S+=6,g++){const x=m[g];x.candidate=e[S+2*f],x.count=0;const{bounds:b,leftCacheBounds:T,rightCacheBounds:w}=x;for(let C=0;C<3;C++)w[C]=1/0,w[C+3]=-1/0,T[C]=1/0,T[C+3]=-1/0,b[C]=1/0,b[C+3]=-1/0;lr(S,e,b)}m.sort(Dl);let v=r;for(let S=0;S<v;S++){const x=m[S];for(;S+1<v&&m[S+1].candidate===x.candidate;)m.splice(S+1,1),v--}for(let S=u;S<h;S+=6){const x=e[S+2*f];for(let b=0;b<v;b++){const T=m[b];x>=T.candidate?lr(S,e,T.rightCacheBounds):(lr(S,e,T.leftCacheBounds),T.count++)}}for(let S=0;S<v;S++){const x=m[S],b=x.count,T=r-x.count,w=x.leftCacheBounds,C=x.rightCacheBounds;let P=0;b!==0&&(P=ei(w)/c);let R=0;T!==0&&(R=ei(C)/c);const E=$s+dn*(P*b+R*T);E<l&&(a=f,l=E,o=x.candidate)}}else{for(let v=0;v<ne;v++){const S=fe[v];S.count=0,S.candidate=d+p+v*p;const x=S.bounds;for(let b=0;b<3;b++)x[b]=1/0,x[b+3]=-1/0}for(let v=u;v<h;v+=6){let b=~~((e[v+2*f]-d)/p);b>=ne&&(b=ne-1);const T=fe[b];T.count++,lr(v,e,T.bounds)}const m=fe[ne-1];Xs(m.bounds,m.rightCacheBounds);for(let v=ne-2;v>=0;v--){const S=fe[v],x=fe[v+1];Ws(S.bounds,x.rightCacheBounds,S.rightCacheBounds)}let g=0;for(let v=0;v<ne-1;v++){const S=fe[v],x=S.count,b=S.bounds,w=fe[v+1].rightCacheBounds;x!==0&&(g===0?Xs(b,ur):Ws(b,ur,ur)),g+=x;let C=0,P=0;g!==0&&(C=ei(ur)/c);const R=r-g;R!==0&&(P=ei(w)/c);const E=$s+dn*(C*g+P*R);E<l&&(a=f,l=E,o=S.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:a,pos:o}}function Vl(n,t,e,i){let r=0;for(let s=t,a=t+e;s<a;s++)r+=n[s*6+i*2];return r/e}class yn{constructor(){this.boundingData=new Float32Array(6)}}function Jl(n,t,e,i,r,s){let a=i,o=i+r-1;const c=s.pos,l=s.axis*2;for(;;){for(;a<=o&&e[a*6+l]<c;)a++;for(;a<=o&&e[o*6+l]>=c;)o--;if(a<o){for(let u=0;u<3;u++){let h=t[a*3+u];t[a*3+u]=t[o*3+u],t[o*3+u]=h}for(let u=0;u<6;u++){let h=e[a*6+u];e[a*6+u]=e[o*6+u],e[o*6+u]=h}a++,o--}else return a}}function Gl(n,t,e,i,r,s){let a=i,o=i+r-1;const c=s.pos,l=s.axis*2;for(;;){for(;a<=o&&e[a*6+l]<c;)a++;for(;a<=o&&e[o*6+l]>=c;)o--;if(a<o){let u=n[a];n[a]=n[o],n[o]=u;for(let h=0;h<6;h++){let f=e[a*6+h];e[a*6+h]=e[o*6+h],e[o*6+h]=f}a++,o--}else return a}}function St(n,t){return t[n+15]===65535}function Mt(n,t){return t[n+6]}function Ct(n,t){return t[n+14]}function Pt(n){return n+8}function wt(n,t){return t[n+6]}function da(n,t){return t[n+7]}let pa,fi,Ar,ma;const jl=Math.pow(2,32);function Dn(n){return"count"in n?1:1+Dn(n.left)+Dn(n.right)}function $l(n,t,e){return pa=new Float32Array(e),fi=new Uint32Array(e),Ar=new Uint16Array(e),ma=new Uint8Array(e),Ln(n,t)}function Ln(n,t){const e=n/4,i=n/2,r="count"in t,s=t.boundingData;for(let a=0;a<6;a++)pa[e+a]=s[a];if(r)if(t.buffer){const a=t.buffer;ma.set(new Uint8Array(a),n);for(let o=n,c=n+a.byteLength;o<c;o+=mi){const l=o/2;St(l,Ar)||(fi[o/4+6]+=e)}return n+a.byteLength}else{const a=t.offset,o=t.count;return fi[e+6]=a,Ar[i+14]=o,Ar[i+15]=$r,n+mi}else{const a=t.left,o=t.right,c=t.splitAxis;let l;if(l=Ln(n+mi,a),l/4>jl)throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return fi[e+6]=l/4,l=Ln(l,o),fi[e+7]=c,l}}function ql(n,t){const e=(n.index?n.index.count:n.attributes.position.count)/3,i=e>2**16,r=i?4:2,s=t?new SharedArrayBuffer(e*r):new ArrayBuffer(e*r),a=i?new Uint32Array(s):new Uint16Array(s);for(let o=0,c=a.length;o<c;o++)a[o]=o;return a}function Xl(n,t,e,i,r){const{maxDepth:s,verbose:a,maxLeafTris:o,strategy:c,onProgress:l,indirect:u}=r,h=n._indirectBuffer,f=n.geometry,d=f.index?f.index.array:null,y=u?Gl:Jl,_=Xe(f),p=new Float32Array(6);let m=!1;const g=new yn;return mn(t,e,i,g.boundingData,p),S(g,e,i,p),g;function v(x){l&&l(x/_)}function S(x,b,T,w=null,C=0){if(!m&&C>=s&&(m=!0,a&&(console.warn(`MeshBVH: Max depth of ${s} reached when generating BVH. Consider increasing maxDepth.`),console.warn(f))),T<=o||C>=s)return v(b+T),x.offset=b,x.count=T,x;const P=Ll(x.boundingData,w,t,b,T,c);if(P.axis===-1)return v(b+T),x.offset=b,x.count=T,x;const R=y(h,d,t,b,T,P);if(R===b||R===b+T)v(b+T),x.offset=b,x.count=T;else{x.splitAxis=P.axis;const E=new yn,A=b,k=R-b;x.left=E,mn(t,A,k,E.boundingData,p),S(E,A,k,p,C+1);const z=new yn,U=R,L=T-k;x.right=z,mn(t,U,L,z.boundingData,p),S(z,U,L,p,C+1)}return x}}function Wl(n,t){const e=n.geometry;t.indirect&&(n._indirectBuffer=ql(e,t.useSharedArrayBuffer),Nl(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.')),n._indirectBuffer||Ul(e,t);const i=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,r=Fl(e),s=t.indirect?ha(e,t.range):fa(e,t.range);n._roots=s.map(a=>{const o=Xl(n,r,a.offset,a.count,t),c=Dn(o),l=new i(mi*c);return $l(0,o,l),l})}class le{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(t,e){let i=1/0,r=-1/0;for(let s=0,a=t.length;s<a;s++){const c=t[s][e];i=c<i?c:i,r=c>r?c:r}this.min=i,this.max=r}setFromPoints(t,e){let i=1/0,r=-1/0;for(let s=0,a=e.length;s<a;s++){const o=e[s],c=t.dot(o);i=c<i?c:i,r=c>r?c:r}this.min=i,this.max=r}isSeparated(t){return this.min>t.max||t.min>this.max}}le.prototype.setFromBox=function(){const n=new M.Vector3;return function(e,i){const r=i.min,s=i.max;let a=1/0,o=-1/0;for(let c=0;c<=1;c++)for(let l=0;l<=1;l++)for(let u=0;u<=1;u++){n.x=r.x*c+s.x*(1-c),n.y=r.y*l+s.y*(1-l),n.z=r.z*u+s.z*(1-u);const h=e.dot(n);a=Math.min(h,a),o=Math.max(h,o)}this.min=a,this.max=o}}();const Hl=function(){const n=new M.Vector3,t=new M.Vector3,e=new M.Vector3;return function(r,s,a){const o=r.start,c=n,l=s.start,u=t;e.subVectors(o,l),n.subVectors(r.end,r.start),t.subVectors(s.end,s.start);const h=e.dot(u),f=u.dot(c),d=u.dot(u),y=e.dot(c),p=c.dot(c)*d-f*f;let m,g;p!==0?m=(h*f-y*d)/p:m=0,g=(h+m*f)/d,a.x=m,a.y=g}}(),ns=function(){const n=new M.Vector2,t=new M.Vector3,e=new M.Vector3;return function(r,s,a,o){Hl(r,s,n);let c=n.x,l=n.y;if(c>=0&&c<=1&&l>=0&&l<=1){r.at(c,a),s.at(l,o);return}else if(c>=0&&c<=1){l<0?s.at(0,o):s.at(1,o),r.closestPointToPoint(o,!0,a);return}else if(l>=0&&l<=1){c<0?r.at(0,a):r.at(1,a),s.closestPointToPoint(a,!0,o);return}else{let u;c<0?u=r.start:u=r.end;let h;l<0?h=s.start:h=s.end;const f=t,d=e;if(r.closestPointToPoint(h,!0,t),s.closestPointToPoint(u,!0,e),f.distanceToSquared(h)<=d.distanceToSquared(u)){a.copy(f),o.copy(h);return}else{a.copy(u),o.copy(d);return}}}}(),Yl=function(){const n=new M.Vector3,t=new M.Vector3,e=new M.Plane,i=new M.Line3;return function(s,a){const{radius:o,center:c}=s,{a:l,b:u,c:h}=a;if(i.start=l,i.end=u,i.closestPointToPoint(c,!0,n).distanceTo(c)<=o||(i.start=l,i.end=h,i.closestPointToPoint(c,!0,n).distanceTo(c)<=o)||(i.start=u,i.end=h,i.closestPointToPoint(c,!0,n).distanceTo(c)<=o))return!0;const _=a.getPlane(e);if(Math.abs(_.distanceToPoint(c))<=o){const m=_.projectPoint(c,t);if(a.containsPoint(m))return!0}return!1}}(),Zl=1e-15;function gn(n){return Math.abs(n)<Zl}class Rt extends M.Triangle{constructor(...t){super(...t),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new M.Vector3),this.satBounds=new Array(4).fill().map(()=>new le),this.points=[this.a,this.b,this.c],this.sphere=new M.Sphere,this.plane=new M.Plane,this.needsUpdate=!0}intersectsSphere(t){return Yl(t,this)}update(){const t=this.a,e=this.b,i=this.c,r=this.points,s=this.satAxes,a=this.satBounds,o=s[0],c=a[0];this.getNormal(o),c.setFromPoints(o,r);const l=s[1],u=a[1];l.subVectors(t,e),u.setFromPoints(l,r);const h=s[2],f=a[2];h.subVectors(e,i),f.setFromPoints(h,r);const d=s[3],y=a[3];d.subVectors(i,t),y.setFromPoints(d,r),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(o,t),this.needsUpdate=!1}}Rt.prototype.closestPointToSegment=function(){const n=new M.Vector3,t=new M.Vector3,e=new M.Line3;return function(r,s=null,a=null){const{start:o,end:c}=r,l=this.points;let u,h=1/0;for(let f=0;f<3;f++){const d=(f+1)%3;e.start.copy(l[f]),e.end.copy(l[d]),ns(e,r,n,t),u=n.distanceToSquared(t),u<h&&(h=u,s&&s.copy(n),a&&a.copy(t))}return this.closestPointToPoint(o,n),u=o.distanceToSquared(n),u<h&&(h=u,s&&s.copy(n),a&&a.copy(o)),this.closestPointToPoint(c,n),u=c.distanceToSquared(n),u<h&&(h=u,s&&s.copy(n),a&&a.copy(c)),Math.sqrt(h)}}();Rt.prototype.intersectsTriangle=function(){const n=new Rt,t=new Array(3),e=new Array(3),i=new le,r=new le,s=new M.Vector3,a=new M.Vector3,o=new M.Vector3,c=new M.Vector3,l=new M.Vector3,u=new M.Line3,h=new M.Line3,f=new M.Line3,d=new M.Vector3;function y(_,p,m){const g=_.points;let v=0,S=-1;for(let x=0;x<3;x++){const{start:b,end:T}=u;b.copy(g[x]),T.copy(g[(x+1)%3]),u.delta(a);const w=gn(p.distanceToPoint(b));if(gn(p.normal.dot(a))&&w){m.copy(u),v=2;break}const C=p.intersectLine(u,d);if(!C&&w&&d.copy(b),(C||w)&&!gn(d.distanceTo(T))){if(v<=1)(v===1?m.start:m.end).copy(d),w&&(S=v);else if(v>=2){(S===1?m.start:m.end).copy(d),v=2;break}if(v++,v===2&&S===-1)break}}return v}return function(p,m=null,g=!1){this.needsUpdate&&this.update(),p.isExtendedTriangle?p.needsUpdate&&p.update():(n.copy(p),n.update(),p=n);const v=this.plane,S=p.plane;if(Math.abs(v.normal.dot(S.normal))>1-1e-10){const x=this.satBounds,b=this.satAxes;e[0]=p.a,e[1]=p.b,e[2]=p.c;for(let C=0;C<4;C++){const P=x[C],R=b[C];if(i.setFromPoints(R,e),P.isSeparated(i))return!1}const T=p.satBounds,w=p.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let C=0;C<4;C++){const P=T[C],R=w[C];if(i.setFromPoints(R,t),P.isSeparated(i))return!1}for(let C=0;C<4;C++){const P=b[C];for(let R=0;R<4;R++){const E=w[R];if(s.crossVectors(P,E),i.setFromPoints(s,t),r.setFromPoints(s,e),i.isSeparated(r))return!1}}return m&&(g||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),m.start.set(0,0,0),m.end.set(0,0,0)),!0}else{const x=y(this,S,h);if(x===1&&p.containsPoint(h.end))return m&&(m.start.copy(h.end),m.end.copy(h.end)),!0;if(x!==2)return!1;const b=y(p,v,f);if(b===1&&this.containsPoint(f.end))return m&&(m.start.copy(f.end),m.end.copy(f.end)),!0;if(b!==2)return!1;if(h.delta(o),f.delta(c),o.dot(c)<0){let A=f.start;f.start=f.end,f.end=A}const T=h.start.dot(o),w=h.end.dot(o),C=f.start.dot(o),P=f.end.dot(o),R=w<C,E=T<P;return T!==P&&C!==w&&R===E?!1:(m&&(l.subVectors(h.start,f.start),l.dot(o)>0?m.start.copy(h.start):m.start.copy(f.start),l.subVectors(h.end,f.end),l.dot(o)<0?m.end.copy(h.end):m.end.copy(f.end)),!0)}}}();Rt.prototype.distanceToPoint=function(){const n=new M.Vector3;return function(e){return this.closestPointToPoint(e,n),e.distanceTo(n)}}();Rt.prototype.distanceToTriangle=function(){const n=new M.Vector3,t=new M.Vector3,e=["a","b","c"],i=new M.Line3,r=new M.Line3;return function(a,o=null,c=null){const l=o||c?i:null;if(this.intersectsTriangle(a,l))return(o||c)&&(o&&l.getCenter(o),c&&l.getCenter(c)),0;let u=1/0;for(let h=0;h<3;h++){let f;const d=e[h],y=a[d];this.closestPointToPoint(y,n),f=y.distanceToSquared(n),f<u&&(u=f,o&&o.copy(n),c&&c.copy(y));const _=this[d];a.closestPointToPoint(_,n),f=_.distanceToSquared(n),f<u&&(u=f,o&&o.copy(_),c&&c.copy(n))}for(let h=0;h<3;h++){const f=e[h],d=e[(h+1)%3];i.set(this[f],this[d]);for(let y=0;y<3;y++){const _=e[y],p=e[(y+1)%3];r.set(a[_],a[p]),ns(i,r,n,t);const m=n.distanceToSquared(t);m<u&&(u=m,o&&o.copy(n),c&&c.copy(t))}}return Math.sqrt(u)}}();class dt{constructor(t,e,i){this.isOrientedBox=!0,this.min=new M.Vector3,this.max=new M.Vector3,this.matrix=new M.Matrix4,this.invMatrix=new M.Matrix4,this.points=new Array(8).fill().map(()=>new M.Vector3),this.satAxes=new Array(3).fill().map(()=>new M.Vector3),this.satBounds=new Array(3).fill().map(()=>new le),this.alignedSatBounds=new Array(3).fill().map(()=>new le),this.needsUpdate=!1,t&&this.min.copy(t),e&&this.max.copy(e),i&&this.matrix.copy(i)}set(t,e,i){this.min.copy(t),this.max.copy(e),this.matrix.copy(i),this.needsUpdate=!0}copy(t){this.min.copy(t.min),this.max.copy(t.max),this.matrix.copy(t.matrix),this.needsUpdate=!0}}dt.prototype.update=function(){return function(){const t=this.matrix,e=this.min,i=this.max,r=this.points;for(let l=0;l<=1;l++)for(let u=0;u<=1;u++)for(let h=0;h<=1;h++){const f=1*l|2*u|4*h,d=r[f];d.x=l?i.x:e.x,d.y=u?i.y:e.y,d.z=h?i.z:e.z,d.applyMatrix4(t)}const s=this.satBounds,a=this.satAxes,o=r[0];for(let l=0;l<3;l++){const u=a[l],h=s[l],f=1<<l,d=r[f];u.subVectors(o,d),h.setFromPoints(u,r)}const c=this.alignedSatBounds;c[0].setFromPointsField(r,"x"),c[1].setFromPointsField(r,"y"),c[2].setFromPointsField(r,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();dt.prototype.intersectsBox=function(){const n=new le;return function(e){this.needsUpdate&&this.update();const i=e.min,r=e.max,s=this.satBounds,a=this.satAxes,o=this.alignedSatBounds;if(n.min=i.x,n.max=r.x,o[0].isSeparated(n)||(n.min=i.y,n.max=r.y,o[1].isSeparated(n))||(n.min=i.z,n.max=r.z,o[2].isSeparated(n)))return!1;for(let c=0;c<3;c++){const l=a[c],u=s[c];if(n.setFromBox(l,e),u.isSeparated(n))return!1}return!0}}();dt.prototype.intersectsTriangle=function(){const n=new Rt,t=new Array(3),e=new le,i=new le,r=new M.Vector3;return function(a){this.needsUpdate&&this.update(),a.isExtendedTriangle?a.needsUpdate&&a.update():(n.copy(a),n.update(),a=n);const o=this.satBounds,c=this.satAxes;t[0]=a.a,t[1]=a.b,t[2]=a.c;for(let f=0;f<3;f++){const d=o[f],y=c[f];if(e.setFromPoints(y,t),d.isSeparated(e))return!1}const l=a.satBounds,u=a.satAxes,h=this.points;for(let f=0;f<3;f++){const d=l[f],y=u[f];if(e.setFromPoints(y,h),d.isSeparated(e))return!1}for(let f=0;f<3;f++){const d=c[f];for(let y=0;y<4;y++){const _=u[y];if(r.crossVectors(d,_),e.setFromPoints(r,t),i.setFromPoints(r,h),e.isSeparated(i))return!1}}return!0}}();dt.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}}();dt.prototype.distanceToPoint=function(){const n=new M.Vector3;return function(e){return this.closestPointToPoint(e,n),e.distanceTo(n)}}();dt.prototype.distanceToBox=function(){const n=["x","y","z"],t=new Array(12).fill().map(()=>new M.Line3),e=new Array(12).fill().map(()=>new M.Line3),i=new M.Vector3,r=new M.Vector3;return function(a,o=0,c=null,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(a))return(c||l)&&(a.getCenter(r),this.closestPointToPoint(r,i),a.closestPointToPoint(i,r),c&&c.copy(i),l&&l.copy(r)),0;const u=o*o,h=a.min,f=a.max,d=this.points;let y=1/0;for(let p=0;p<8;p++){const m=d[p];r.copy(m).clamp(h,f);const g=m.distanceToSquared(r);if(g<y&&(y=g,c&&c.copy(m),l&&l.copy(r),g<u))return Math.sqrt(g)}let _=0;for(let p=0;p<3;p++)for(let m=0;m<=1;m++)for(let g=0;g<=1;g++){const v=(p+1)%3,S=(p+2)%3,x=m<<v|g<<S,b=1<<p|m<<v|g<<S,T=d[x],w=d[b];t[_].set(T,w);const P=n[p],R=n[v],E=n[S],A=e[_],k=A.start,z=A.end;k[P]=h[P],k[R]=m?h[R]:f[R],k[E]=g?h[E]:f[R],z[P]=f[P],z[R]=m?h[R]:f[R],z[E]=g?h[E]:f[R],_++}for(let p=0;p<=1;p++)for(let m=0;m<=1;m++)for(let g=0;g<=1;g++){r.x=p?f.x:h.x,r.y=m?f.y:h.y,r.z=g?f.z:h.z,this.closestPointToPoint(r,i);const v=r.distanceToSquared(i);if(v<y&&(y=v,c&&c.copy(i),l&&l.copy(r),v<u))return Math.sqrt(v)}for(let p=0;p<12;p++){const m=t[p];for(let g=0;g<12;g++){const v=e[g];ns(m,v,i,r);const S=i.distanceToSquared(r);if(S<y&&(y=S,c&&c.copy(i),l&&l.copy(r),S<u))return Math.sqrt(S)}}return Math.sqrt(y)}}();class ss{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 Ql extends ss{constructor(){super(()=>new Rt)}}const Et=new Ql;class Kl{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const t=[];let e=null;this.setBuffer=i=>{e&&t.push(e),e=i,this.float32Array=new Float32Array(i),this.uint16Array=new Uint16Array(i),this.uint32Array=new Uint32Array(i)},this.clearBuffer=()=>{e=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,t.length!==0&&this.setBuffer(t.pop())}}}const $=new Kl;let ye,Ve;const Be=[],hr=new ss(()=>new M.Box3);function tu(n,t,e,i,r,s){ye=hr.getPrimitive(),Ve=hr.getPrimitive(),Be.push(ye,Ve),$.setBuffer(n._roots[t]);const a=Vn(0,n.geometry,e,i,r,s);$.clearBuffer(),hr.releasePrimitive(ye),hr.releasePrimitive(Ve),Be.pop(),Be.pop();const o=Be.length;return o>0&&(Ve=Be[o-1],ye=Be[o-2]),a}function Vn(n,t,e,i,r=null,s=0,a=0){const{float32Array:o,uint16Array:c,uint32Array:l}=$;let u=n*2;if(St(u,c)){const f=Mt(n,l),d=Ct(u,c);return Y(n,o,ye),i(f,d,!1,a,s+n,ye)}else{let P=function(E){const{uint16Array:A,uint32Array:k}=$;let z=E*2;for(;!St(z,A);)E=Pt(E),z=E*2;return Mt(E,k)},R=function(E){const{uint16Array:A,uint32Array:k}=$;let z=E*2;for(;!St(z,A);)E=wt(E,k),z=E*2;return Mt(E,k)+Ct(z,A)};const f=Pt(n),d=wt(n,l);let y=f,_=d,p,m,g,v;if(r&&(g=ye,v=Ve,Y(y,o,g),Y(_,o,v),p=r(g),m=r(v),m<p)){y=d,_=f;const E=p;p=m,m=E,g=v}g||(g=ye,Y(y,o,g));const S=St(y*2,c),x=e(g,S,p,a+1,s+y);let b;if(x===Fn){const E=P(y),k=R(y)-E;b=i(E,k,!0,a+1,s+y,g)}else b=x&&Vn(y,t,e,i,r,s,a+1);if(b)return!0;v=Ve,Y(_,o,v);const T=St(_*2,c),w=e(v,T,m,a+1,s+_);let C;if(w===Fn){const E=P(_),k=R(_)-E;C=i(E,k,!0,a+1,s+_,v)}else C=w&&Vn(_,t,e,i,r,s,a+1);return!!C}}const ii=new M.Vector3,vn=new M.Vector3;function eu(n,t,e={},i=0,r=1/0){const s=i*i,a=r*r;let o=1/0,c=null;if(n.shapecast({boundsTraverseOrder:u=>(ii.copy(t).clamp(u.min,u.max),ii.distanceToSquared(t)),intersectsBounds:(u,h,f)=>f<o&&f<a,intersectsTriangle:(u,h)=>{u.closestPointToPoint(t,ii);const f=t.distanceToSquared(ii);return f<o&&(vn.copy(ii),o=f,c=h),f<s}}),o===1/0)return null;const l=Math.sqrt(o);return e.point?e.point.copy(vn):e.point=vn.clone(),e.distance=l,e.faceIndex=c,e}const iu=parseInt(M.REVISION)>=169,Se=new M.Vector3,be=new M.Vector3,Te=new M.Vector3,fr=new M.Vector2,dr=new M.Vector2,pr=new M.Vector2,Hs=new M.Vector3,Ys=new M.Vector3,Zs=new M.Vector3,ri=new M.Vector3;function ru(n,t,e,i,r,s,a,o){let c;if(s===M.BackSide?c=n.intersectTriangle(i,e,t,!0,r):c=n.intersectTriangle(t,e,i,s!==M.DoubleSide,r),c===null)return null;const l=n.origin.distanceTo(r);return l<a||l>o?null:{distance:l,point:r.clone()}}function nu(n,t,e,i,r,s,a,o,c,l,u){Se.fromBufferAttribute(t,s),be.fromBufferAttribute(t,a),Te.fromBufferAttribute(t,o);const h=ru(n,Se,be,Te,ri,c,l,u);if(h){const f=new M.Vector3;M.Triangle.getBarycoord(ri,Se,be,Te,f),i&&(fr.fromBufferAttribute(i,s),dr.fromBufferAttribute(i,a),pr.fromBufferAttribute(i,o),h.uv=M.Triangle.getInterpolation(ri,Se,be,Te,fr,dr,pr,new M.Vector2)),r&&(fr.fromBufferAttribute(r,s),dr.fromBufferAttribute(r,a),pr.fromBufferAttribute(r,o),h.uv1=M.Triangle.getInterpolation(ri,Se,be,Te,fr,dr,pr,new M.Vector2)),e&&(Hs.fromBufferAttribute(e,s),Ys.fromBufferAttribute(e,a),Zs.fromBufferAttribute(e,o),h.normal=M.Triangle.getInterpolation(ri,Se,be,Te,Hs,Ys,Zs,new M.Vector3),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const d={a:s,b:a,c:o,normal:new M.Vector3,materialIndex:0};M.Triangle.getNormal(Se,be,Te,d.normal),h.face=d,h.faceIndex=s,iu&&(h.barycoord=f)}return h}function qr(n,t,e,i,r,s,a){const o=i*3;let c=o+0,l=o+1,u=o+2;const h=n.index;n.index&&(c=h.getX(c),l=h.getX(l),u=h.getX(u));const{position:f,normal:d,uv:y,uv1:_}=n.attributes,p=nu(e,f,d,y,_,c,l,u,t,s,a);return p?(p.faceIndex=i,r&&r.push(p),p):null}function et(n,t,e,i){const r=n.a,s=n.b,a=n.c;let o=t,c=t+1,l=t+2;e&&(o=e.getX(o),c=e.getX(c),l=e.getX(l)),r.x=i.getX(o),r.y=i.getY(o),r.z=i.getZ(o),s.x=i.getX(c),s.y=i.getY(c),s.z=i.getZ(c),a.x=i.getX(l),a.y=i.getY(l),a.z=i.getZ(l)}function su(n,t,e,i,r,s,a,o){const{geometry:c,_indirectBuffer:l}=n;for(let u=i,h=i+r;u<h;u++)qr(c,t,e,u,s,a,o)}function ou(n,t,e,i,r,s,a){const{geometry:o,_indirectBuffer:c}=n;let l=1/0,u=null;for(let h=i,f=i+r;h<f;h++){let d;d=qr(o,t,e,h,null,s,a),d&&d.distance<l&&(u=d,l=d.distance)}return u}function au(n,t,e,i,r,s,a){const{geometry:o}=e,{index:c}=o,l=o.attributes.position;for(let u=n,h=t+n;u<h;u++){let f;if(f=u,et(a,f*3,c,l),a.needsUpdate=!0,i(a,f,r,s))return!0}return!1}function cu(n,t=null){t&&Array.isArray(t)&&(t=new Set(t));const e=n.geometry,i=e.index?e.index.array:null,r=e.attributes.position;let s,a,o,c,l=0;const u=n._roots;for(let f=0,d=u.length;f<d;f++)s=u[f],a=new Uint32Array(s),o=new Uint16Array(s),c=new Float32Array(s),h(0,l),l+=s.byteLength;function h(f,d,y=!1){const _=f*2;if(o[_+15]===$r){const m=a[f+6],g=o[_+14];let v=1/0,S=1/0,x=1/0,b=-1/0,T=-1/0,w=-1/0;for(let C=3*m,P=3*(m+g);C<P;C++){let R=i[C];const E=r.getX(R),A=r.getY(R),k=r.getZ(R);E<v&&(v=E),E>b&&(b=E),A<S&&(S=A),A>T&&(T=A),k<x&&(x=k),k>w&&(w=k)}return c[f+0]!==v||c[f+1]!==S||c[f+2]!==x||c[f+3]!==b||c[f+4]!==T||c[f+5]!==w?(c[f+0]=v,c[f+1]=S,c[f+2]=x,c[f+3]=b,c[f+4]=T,c[f+5]=w,!0):!1}else{const m=f+8,g=a[f+6],v=m+d,S=g+d;let x=y,b=!1,T=!1;t?x||(b=t.has(v),T=t.has(S),x=!b&&!T):(b=!0,T=!0);const w=x||b,C=x||T;let P=!1;w&&(P=h(m,d,x));let R=!1;C&&(R=h(g,d,x));const E=P||R;if(E)for(let A=0;A<3;A++){const k=m+A,z=g+A,U=c[k],L=c[k+3],I=c[z],X=c[z+3];c[f+A]=U<I?U:I,c[f+A+3]=L>X?L:X}return E}}}function ge(n,t,e,i,r){let s,a,o,c,l,u;const h=1/e.direction.x,f=1/e.direction.y,d=1/e.direction.z,y=e.origin.x,_=e.origin.y,p=e.origin.z;let m=t[n],g=t[n+3],v=t[n+1],S=t[n+3+1],x=t[n+2],b=t[n+3+2];return h>=0?(s=(m-y)*h,a=(g-y)*h):(s=(g-y)*h,a=(m-y)*h),f>=0?(o=(v-_)*f,c=(S-_)*f):(o=(S-_)*f,c=(v-_)*f),s>c||o>a||((o>s||isNaN(s))&&(s=o),(c<a||isNaN(a))&&(a=c),d>=0?(l=(x-p)*d,u=(b-p)*d):(l=(b-p)*d,u=(x-p)*d),s>u||l>a)?!1:((l>s||s!==s)&&(s=l),(u<a||a!==a)&&(a=u),s<=r&&a>=i)}function lu(n,t,e,i,r,s,a,o){const{geometry:c,_indirectBuffer:l}=n;for(let u=i,h=i+r;u<h;u++){let f=l?l[u]:u;qr(c,t,e,f,s,a,o)}}function uu(n,t,e,i,r,s,a){const{geometry:o,_indirectBuffer:c}=n;let l=1/0,u=null;for(let h=i,f=i+r;h<f;h++){let d;d=qr(o,t,e,c?c[h]:h,null,s,a),d&&d.distance<l&&(u=d,l=d.distance)}return u}function hu(n,t,e,i,r,s,a){const{geometry:o}=e,{index:c}=o,l=o.attributes.position;for(let u=n,h=t+n;u<h;u++){let f;if(f=e.resolveTriangleIndex(u),et(a,f*3,c,l),a.needsUpdate=!0,i(a,f,r,s))return!0}return!1}function fu(n,t,e,i,r,s,a){$.setBuffer(n._roots[t]),Jn(0,n,e,i,r,s,a),$.clearBuffer()}function Jn(n,t,e,i,r,s,a){const{float32Array:o,uint16Array:c,uint32Array:l}=$,u=n*2;if(St(u,c)){const f=Mt(n,l),d=Ct(u,c);su(t,e,i,f,d,r,s,a)}else{const f=Pt(n);ge(f,o,i,s,a)&&Jn(f,t,e,i,r,s,a);const d=wt(n,l);ge(d,o,i,s,a)&&Jn(d,t,e,i,r,s,a)}}const du=["x","y","z"];function pu(n,t,e,i,r,s){$.setBuffer(n._roots[t]);const a=Gn(0,n,e,i,r,s);return $.clearBuffer(),a}function Gn(n,t,e,i,r,s){const{float32Array:a,uint16Array:o,uint32Array:c}=$;let l=n*2;if(St(l,o)){const h=Mt(n,c),f=Ct(l,o);return ou(t,e,i,h,f,r,s)}else{const h=da(n,c),f=du[h],y=i.direction[f]>=0;let _,p;y?(_=Pt(n),p=wt(n,c)):(_=wt(n,c),p=Pt(n));const g=ge(_,a,i,r,s)?Gn(_,t,e,i,r,s):null;if(g){const x=g.point[f];if(y?x<=a[p+h]:x>=a[p+h+3])return g}const S=ge(p,a,i,r,s)?Gn(p,t,e,i,r,s):null;return g&&S?g.distance<=S.distance?g:S:g||S||null}}const mr=new M.Box3,Oe=new Rt,Ie=new Rt,ni=new M.Matrix4,Qs=new dt,yr=new dt;function mu(n,t,e,i){$.setBuffer(n._roots[t]);const r=jn(0,n,e,i);return $.clearBuffer(),r}function jn(n,t,e,i,r=null){const{float32Array:s,uint16Array:a,uint32Array:o}=$;let c=n*2;if(r===null&&(e.boundingBox||e.computeBoundingBox(),Qs.set(e.boundingBox.min,e.boundingBox.max,i),r=Qs),St(c,a)){const u=t.geometry,h=u.index,f=u.attributes.position,d=e.index,y=e.attributes.position,_=Mt(n,o),p=Ct(c,a);if(ni.copy(i).invert(),e.boundsTree)return Y(n,s,yr),yr.matrix.copy(ni),yr.needsUpdate=!0,e.boundsTree.shapecast({intersectsBounds:g=>yr.intersectsBox(g),intersectsTriangle:g=>{g.a.applyMatrix4(i),g.b.applyMatrix4(i),g.c.applyMatrix4(i),g.needsUpdate=!0;for(let v=_*3,S=(p+_)*3;v<S;v+=3)if(et(Ie,v,h,f),Ie.needsUpdate=!0,g.intersectsTriangle(Ie))return!0;return!1}});for(let m=_*3,g=(p+_)*3;m<g;m+=3){et(Oe,m,h,f),Oe.a.applyMatrix4(ni),Oe.b.applyMatrix4(ni),Oe.c.applyMatrix4(ni),Oe.needsUpdate=!0;for(let v=0,S=d.count;v<S;v+=3)if(et(Ie,v,d,y),Ie.needsUpdate=!0,Oe.intersectsTriangle(Ie))return!0}}else{const u=n+8,h=o[n+6];return Y(u,s,mr),!!(r.intersectsBox(mr)&&jn(u,t,e,i,r)||(Y(h,s,mr),r.intersectsBox(mr)&&jn(h,t,e,i,r)))}}const gr=new M.Matrix4,_n=new dt,si=new dt,yu=new M.Vector3,gu=new M.Vector3,vu=new M.Vector3,_u=new M.Vector3;function xu(n,t,e,i={},r={},s=0,a=1/0){t.boundingBox||t.computeBoundingBox(),_n.set(t.boundingBox.min,t.boundingBox.max,e),_n.needsUpdate=!0;const o=n.geometry,c=o.attributes.position,l=o.index,u=t.attributes.position,h=t.index,f=Et.getPrimitive(),d=Et.getPrimitive();let y=yu,_=gu,p=null,m=null;r&&(p=vu,m=_u);let g=1/0,v=null,S=null;return gr.copy(e).invert(),si.matrix.copy(gr),n.shapecast({boundsTraverseOrder:x=>_n.distanceToBox(x),intersectsBounds:(x,b,T)=>T<g&&T<a?(b&&(si.min.copy(x.min),si.max.copy(x.max),si.needsUpdate=!0),!0):!1,intersectsRange:(x,b)=>{if(t.boundsTree)return t.boundsTree.shapecast({boundsTraverseOrder:w=>si.distanceToBox(w),intersectsBounds:(w,C,P)=>P<g&&P<a,intersectsRange:(w,C)=>{for(let P=w,R=w+C;P<R;P++){et(d,3*P,h,u),d.a.applyMatrix4(e),d.b.applyMatrix4(e),d.c.applyMatrix4(e),d.needsUpdate=!0;for(let E=x,A=x+b;E<A;E++){et(f,3*E,l,c),f.needsUpdate=!0;const k=f.distanceToTriangle(d,y,p);if(k<g&&(_.copy(y),m&&m.copy(p),g=k,v=E,S=P),k<s)return!0}}}});{const T=Xe(t);for(let w=0,C=T;w<C;w++){et(d,3*w,h,u),d.a.applyMatrix4(e),d.b.applyMatrix4(e),d.c.applyMatrix4(e),d.needsUpdate=!0;for(let P=x,R=x+b;P<R;P++){et(f,3*P,l,c),f.needsUpdate=!0;const E=f.distanceToTriangle(d,y,p);if(E<g&&(_.copy(y),m&&m.copy(p),g=E,v=P,S=w),E<s)return!0}}}}}),Et.releasePrimitive(f),Et.releasePrimitive(d),g===1/0?null:(i.point?i.point.copy(_):i.point=_.clone(),i.distance=g,i.faceIndex=v,r&&(r.point?r.point.copy(m):r.point=m.clone(),r.point.applyMatrix4(gr),_.applyMatrix4(gr),r.distance=_.sub(r.point).length(),r.faceIndex=S),i)}function Su(n,t=null){t&&Array.isArray(t)&&(t=new Set(t));const e=n.geometry,i=e.index?e.index.array:null,r=e.attributes.position;let s,a,o,c,l=0;const u=n._roots;for(let f=0,d=u.length;f<d;f++)s=u[f],a=new Uint32Array(s),o=new Uint16Array(s),c=new Float32Array(s),h(0,l),l+=s.byteLength;function h(f,d,y=!1){const _=f*2;if(o[_+15]===$r){const m=a[f+6],g=o[_+14];let v=1/0,S=1/0,x=1/0,b=-1/0,T=-1/0,w=-1/0;for(let C=m,P=m+g;C<P;C++){const R=3*n.resolveTriangleIndex(C);for(let E=0;E<3;E++){let A=R+E;A=i?i[A]:A;const k=r.getX(A),z=r.getY(A),U=r.getZ(A);k<v&&(v=k),k>b&&(b=k),z<S&&(S=z),z>T&&(T=z),U<x&&(x=U),U>w&&(w=U)}}return c[f+0]!==v||c[f+1]!==S||c[f+2]!==x||c[f+3]!==b||c[f+4]!==T||c[f+5]!==w?(c[f+0]=v,c[f+1]=S,c[f+2]=x,c[f+3]=b,c[f+4]=T,c[f+5]=w,!0):!1}else{const m=f+8,g=a[f+6],v=m+d,S=g+d;let x=y,b=!1,T=!1;t?x||(b=t.has(v),T=t.has(S),x=!b&&!T):(b=!0,T=!0);const w=x||b,C=x||T;let P=!1;w&&(P=h(m,d,x));let R=!1;C&&(R=h(g,d,x));const E=P||R;if(E)for(let A=0;A<3;A++){const k=m+A,z=g+A,U=c[k],L=c[k+3],I=c[z],X=c[z+3];c[f+A]=U<I?U:I,c[f+A+3]=L>X?L:X}return E}}}function bu(n,t,e,i,r,s,a){$.setBuffer(n._roots[t]),$n(0,n,e,i,r,s,a),$.clearBuffer()}function $n(n,t,e,i,r,s,a){const{float32Array:o,uint16Array:c,uint32Array:l}=$,u=n*2;if(St(u,c)){const f=Mt(n,l),d=Ct(u,c);lu(t,e,i,f,d,r,s,a)}else{const f=Pt(n);ge(f,o,i,s,a)&&$n(f,t,e,i,r,s,a);const d=wt(n,l);ge(d,o,i,s,a)&&$n(d,t,e,i,r,s,a)}}const Tu=["x","y","z"];function Mu(n,t,e,i,r,s){$.setBuffer(n._roots[t]);const a=qn(0,n,e,i,r,s);return $.clearBuffer(),a}function qn(n,t,e,i,r,s){const{float32Array:a,uint16Array:o,uint32Array:c}=$;let l=n*2;if(St(l,o)){const h=Mt(n,c),f=Ct(l,o);return uu(t,e,i,h,f,r,s)}else{const h=da(n,c),f=Tu[h],y=i.direction[f]>=0;let _,p;y?(_=Pt(n),p=wt(n,c)):(_=wt(n,c),p=Pt(n));const g=ge(_,a,i,r,s)?qn(_,t,e,i,r,s):null;if(g){const x=g.point[f];if(y?x<=a[p+h]:x>=a[p+h+3])return g}const S=ge(p,a,i,r,s)?qn(p,t,e,i,r,s):null;return g&&S?g.distance<=S.distance?g:S:g||S||null}}const vr=new M.Box3,Ue=new Rt,Ne=new Rt,oi=new M.Matrix4,Ks=new dt,_r=new dt;function Cu(n,t,e,i){$.setBuffer(n._roots[t]);const r=Xn(0,n,e,i);return $.clearBuffer(),r}function Xn(n,t,e,i,r=null){const{float32Array:s,uint16Array:a,uint32Array:o}=$;let c=n*2;if(r===null&&(e.boundingBox||e.computeBoundingBox(),Ks.set(e.boundingBox.min,e.boundingBox.max,i),r=Ks),St(c,a)){const u=t.geometry,h=u.index,f=u.attributes.position,d=e.index,y=e.attributes.position,_=Mt(n,o),p=Ct(c,a);if(oi.copy(i).invert(),e.boundsTree)return Y(n,s,_r),_r.matrix.copy(oi),_r.needsUpdate=!0,e.boundsTree.shapecast({intersectsBounds:g=>_r.intersectsBox(g),intersectsTriangle:g=>{g.a.applyMatrix4(i),g.b.applyMatrix4(i),g.c.applyMatrix4(i),g.needsUpdate=!0;for(let v=_,S=p+_;v<S;v++)if(et(Ne,3*t.resolveTriangleIndex(v),h,f),Ne.needsUpdate=!0,g.intersectsTriangle(Ne))return!0;return!1}});for(let m=_,g=p+_;m<g;m++){const v=t.resolveTriangleIndex(m);et(Ue,3*v,h,f),Ue.a.applyMatrix4(oi),Ue.b.applyMatrix4(oi),Ue.c.applyMatrix4(oi),Ue.needsUpdate=!0;for(let S=0,x=d.count;S<x;S+=3)if(et(Ne,S,d,y),Ne.needsUpdate=!0,Ue.intersectsTriangle(Ne))return!0}}else{const u=n+8,h=o[n+6];return Y(u,s,vr),!!(r.intersectsBox(vr)&&Xn(u,t,e,i,r)||(Y(h,s,vr),r.intersectsBox(vr)&&Xn(h,t,e,i,r)))}}const xr=new M.Matrix4,xn=new dt,ai=new dt,Pu=new M.Vector3,wu=new M.Vector3,Eu=new M.Vector3,Ru=new M.Vector3;function Au(n,t,e,i={},r={},s=0,a=1/0){t.boundingBox||t.computeBoundingBox(),xn.set(t.boundingBox.min,t.boundingBox.max,e),xn.needsUpdate=!0;const o=n.geometry,c=o.attributes.position,l=o.index,u=t.attributes.position,h=t.index,f=Et.getPrimitive(),d=Et.getPrimitive();let y=Pu,_=wu,p=null,m=null;r&&(p=Eu,m=Ru);let g=1/0,v=null,S=null;return xr.copy(e).invert(),ai.matrix.copy(xr),n.shapecast({boundsTraverseOrder:x=>xn.distanceToBox(x),intersectsBounds:(x,b,T)=>T<g&&T<a?(b&&(ai.min.copy(x.min),ai.max.copy(x.max),ai.needsUpdate=!0),!0):!1,intersectsRange:(x,b)=>{if(t.boundsTree){const T=t.boundsTree;return T.shapecast({boundsTraverseOrder:w=>ai.distanceToBox(w),intersectsBounds:(w,C,P)=>P<g&&P<a,intersectsRange:(w,C)=>{for(let P=w,R=w+C;P<R;P++){const E=T.resolveTriangleIndex(P);et(d,3*E,h,u),d.a.applyMatrix4(e),d.b.applyMatrix4(e),d.c.applyMatrix4(e),d.needsUpdate=!0;for(let A=x,k=x+b;A<k;A++){const z=n.resolveTriangleIndex(A);et(f,3*z,l,c),f.needsUpdate=!0;const U=f.distanceToTriangle(d,y,p);if(U<g&&(_.copy(y),m&&m.copy(p),g=U,v=A,S=P),U<s)return!0}}}})}else{const T=Xe(t);for(let w=0,C=T;w<C;w++){et(d,3*w,h,u),d.a.applyMatrix4(e),d.b.applyMatrix4(e),d.c.applyMatrix4(e),d.needsUpdate=!0;for(let P=x,R=x+b;P<R;P++){const E=n.resolveTriangleIndex(P);et(f,3*E,l,c),f.needsUpdate=!0;const A=f.distanceToTriangle(d,y,p);if(A<g&&(_.copy(y),m&&m.copy(p),g=A,v=P,S=w),A<s)return!0}}}}}),Et.releasePrimitive(f),Et.releasePrimitive(d),g===1/0?null:(i.point?i.point.copy(_):i.point=_.clone(),i.distance=g,i.faceIndex=v,r&&(r.point?r.point.copy(m):r.point=m.clone(),r.point.applyMatrix4(xr),_.applyMatrix4(xr),r.distance=_.sub(r.point).length(),r.faceIndex=S),i)}function ku(){return typeof SharedArrayBuffer<"u"}const yi=new $.constructor,Lr=new $.constructor,pe=new ss(()=>new M.Box3),Fe=new M.Box3,De=new M.Box3,Sn=new M.Box3,bn=new M.Box3;let Tn=!1;function zu(n,t,e,i){if(Tn)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");Tn=!0;const r=n._roots,s=t._roots;let a,o=0,c=0;const l=new M.Matrix4().copy(e).invert();for(let u=0,h=r.length;u<h;u++){yi.setBuffer(r[u]),c=0;const f=pe.getPrimitive();Y(0,yi.float32Array,f),f.applyMatrix4(l);for(let d=0,y=s.length;d<y&&(Lr.setBuffer(s[d]),a=Ut(0,0,e,l,i,o,c,0,0,f),Lr.clearBuffer(),c+=s[d].length,!a);d++);if(pe.releasePrimitive(f),yi.clearBuffer(),o+=r[u].length,a)break}return Tn=!1,a}function Ut(n,t,e,i,r,s=0,a=0,o=0,c=0,l=null,u=!1){let h,f;u?(h=Lr,f=yi):(h=yi,f=Lr);const d=h.float32Array,y=h.uint32Array,_=h.uint16Array,p=f.float32Array,m=f.uint32Array,g=f.uint16Array,v=n*2,S=t*2,x=St(v,_),b=St(S,g);let T=!1;if(b&&x)u?T=r(Mt(t,m),Ct(t*2,g),Mt(n,y),Ct(n*2,_),c,a+t,o,s+n):T=r(Mt(n,y),Ct(n*2,_),Mt(t,m),Ct(t*2,g),o,s+n,c,a+t);else if(b){const w=pe.getPrimitive();Y(t,p,w),w.applyMatrix4(e);const C=Pt(n),P=wt(n,y);Y(C,d,Fe),Y(P,d,De);const R=w.intersectsBox(Fe),E=w.intersectsBox(De);T=R&&Ut(t,C,i,e,r,a,s,c,o+1,w,!u)||E&&Ut(t,P,i,e,r,a,s,c,o+1,w,!u),pe.releasePrimitive(w)}else{const w=Pt(t),C=wt(t,m);Y(w,p,Sn),Y(C,p,bn);const P=l.intersectsBox(Sn),R=l.intersectsBox(bn);if(P&&R)T=Ut(n,w,e,i,r,s,a,o,c+1,l,u)||Ut(n,C,e,i,r,s,a,o,c+1,l,u);else if(P)if(x)T=Ut(n,w,e,i,r,s,a,o,c+1,l,u);else{const E=pe.getPrimitive();E.copy(Sn).applyMatrix4(e);const A=Pt(n),k=wt(n,y);Y(A,d,Fe),Y(k,d,De);const z=E.intersectsBox(Fe),U=E.intersectsBox(De);T=z&&Ut(w,A,i,e,r,a,s,c,o+1,E,!u)||U&&Ut(w,k,i,e,r,a,s,c,o+1,E,!u),pe.releasePrimitive(E)}else if(R)if(x)T=Ut(n,C,e,i,r,s,a,o,c+1,l,u);else{const E=pe.getPrimitive();E.copy(bn).applyMatrix4(e);const A=Pt(n),k=wt(n,y);Y(A,d,Fe),Y(k,d,De);const z=E.intersectsBox(Fe),U=E.intersectsBox(De);T=z&&Ut(C,A,i,e,r,a,s,c,o+1,E,!u)||U&&Ut(C,k,i,e,r,a,s,c,o+1,E,!u),pe.releasePrimitive(E)}}return T}const Sr=new dt,to=new M.Box3,Bu={strategy:rs,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null};class Ki{static serialize(t,e={}){e={cloneBuffers:!0,...e};const i=t.geometry,r=t._roots,s=t._indirectBuffer,a=i.getIndex();let o;return e.cloneBuffers?o={roots:r.map(c=>c.slice()),index:a?a.array.slice():null,indirectBuffer:s?s.slice():null}:o={roots:r,index:a?a.array:null,indirectBuffer:s},o}static deserialize(t,e,i={}){i={setIndex:!0,indirect:!!t.indirectBuffer,...i};const{index:r,roots:s,indirectBuffer:a}=t,o=new Ki(e,{...i,[pn]:!0});if(o._roots=s,o._indirectBuffer=a||null,i.setIndex){const c=e.getIndex();if(c===null){const l=new M.BufferAttribute(t.index,1,!1);e.setIndex(l)}else c.array!==r&&(c.array.set(r),c.needsUpdate=!0)}return o}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({...Bu,[pn]:!1},e),e.useSharedArrayBuffer&&!ku())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=t,this._roots=null,this._indirectBuffer=null,e[pn]||(Wl(this,e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new M.Box3))),this.resolveTriangleIndex=e.indirect?i=>this._indirectBuffer[i]:i=>i}refit(t=null){return(this.indirect?Su:cu)(this,t)}traverse(t,e=0){const i=this._roots[e],r=new Uint32Array(i),s=new Uint16Array(i);a(0);function a(o,c=0){const l=o*2,u=s[l+15]===$r;if(u){const h=r[o+6],f=s[l+14];t(c,u,new Float32Array(i,o*4,6),h,f)}else{const h=o+mi/4,f=r[o+6],d=r[o+7];t(c,u,new Float32Array(i,o*4,6),d)||(a(h,c+1),a(f,c+1))}}}raycast(t,e=M.FrontSide,i=0,r=1/0){const s=this._roots,a=this.geometry,o=[],c=e.isMaterial,l=Array.isArray(e),u=a.groups,h=c?e.side:e,f=this.indirect?bu:fu;for(let d=0,y=s.length;d<y;d++){const _=l?e[u[d].materialIndex].side:h,p=o.length;if(f(this,d,_,t,o,i,r),l){const m=u[d].materialIndex;for(let g=p,v=o.length;g<v;g++)o[g].face.materialIndex=m}}return o}raycastFirst(t,e=M.FrontSide,i=0,r=1/0){const s=this._roots,a=this.geometry,o=e.isMaterial,c=Array.isArray(e);let l=null;const u=a.groups,h=o?e.side:e,f=this.indirect?Mu:pu;for(let d=0,y=s.length;d<y;d++){const _=c?e[u[d].materialIndex].side:h,p=f(this,d,_,t,i,r);p!=null&&(l==null||p.distance<l.distance)&&(l=p,c&&(p.face.materialIndex=u[d].materialIndex))}return l}intersectsGeometry(t,e){let i=!1;const r=this._roots,s=this.indirect?Cu:mu;for(let a=0,o=r.length;a<o&&(i=s(this,a,t,e),!i);a++);return i}shapecast(t){const e=Et.getPrimitive(),i=this.indirect?hu:au;let{boundsTraverseOrder:r,intersectsBounds:s,intersectsRange:a,intersectsTriangle:o}=t;if(a&&o){const h=a;a=(f,d,y,_,p)=>h(f,d,y,_,p)?!0:i(f,d,this,o,y,_,e)}else a||(o?a=(h,f,d,y)=>i(h,f,this,o,d,y,e):a=(h,f,d)=>d);let c=!1,l=0;const u=this._roots;for(let h=0,f=u.length;h<f;h++){const d=u[h];if(c=tu(this,h,s,a,r,l),c)break;l+=d.byteLength}return Et.releasePrimitive(e),c}bvhcast(t,e,i){let{intersectsRanges:r,intersectsTriangles:s}=i;const a=Et.getPrimitive(),o=this.geometry.index,c=this.geometry.attributes.position,l=this.indirect?y=>{const _=this.resolveTriangleIndex(y);et(a,_*3,o,c)}:y=>{et(a,y*3,o,c)},u=Et.getPrimitive(),h=t.geometry.index,f=t.geometry.attributes.position,d=t.indirect?y=>{const _=t.resolveTriangleIndex(y);et(u,_*3,h,f)}:y=>{et(u,y*3,h,f)};if(s){const y=(_,p,m,g,v,S,x,b)=>{for(let T=m,w=m+g;T<w;T++){d(T),u.a.applyMatrix4(e),u.b.applyMatrix4(e),u.c.applyMatrix4(e),u.needsUpdate=!0;for(let C=_,P=_+p;C<P;C++)if(l(C),a.needsUpdate=!0,s(a,u,C,T,v,S,x,b))return!0}return!1};if(r){const _=r;r=function(p,m,g,v,S,x,b,T){return _(p,m,g,v,S,x,b,T)?!0:y(p,m,g,v,S,x,b,T)}}else r=y}return zu(this,t,e,r)}intersectsBox(t,e){return Sr.set(t.min,t.max,e),Sr.needsUpdate=!0,this.shapecast({intersectsBounds:i=>Sr.intersectsBox(i),intersectsTriangle:i=>Sr.intersectsTriangle(i)})}intersectsSphere(t){return this.shapecast({intersectsBounds:e=>t.intersectsBox(e),intersectsTriangle:e=>e.intersectsSphere(t)})}closestPointToGeometry(t,e,i={},r={},s=0,a=1/0){return(this.indirect?Au:xu)(this,t,e,i,r,s,a)}closestPointToPoint(t,e={},i=0,r=1/0){return eu(this,t,e,i,r)}getBoundingBox(t){return t.makeEmpty(),this._roots.forEach(i=>{Y(0,new Float32Array(i),to),t.union(to)}),t}}function eo(n,t,e){return n===null?null:(n.point.applyMatrix4(t.matrixWorld),n.distance=n.point.distanceTo(e.ray.origin),n.object=t,n)}const br=new M.Ray,io=new M.Vector3,ro=new M.Matrix4,Ou=M.Mesh.prototype.raycast,Iu=M.BatchedMesh.prototype.raycast,no=new M.Vector3,ct=new M.Mesh,Tr=[];function Uu(n,t){this.isBatchedMesh?Nu.call(this,n,t):Fu.call(this,n,t)}function Nu(n,t){if(this.boundsTrees){const e=this.boundsTrees,i=this._drawInfo||this._instanceInfo,r=this._drawRanges||this._geometryInfo,s=this.matrixWorld;ct.material=this.material,ct.geometry=this.geometry;const a=ct.geometry.boundsTree,o=ct.geometry.drawRange;ct.geometry.boundingSphere===null&&(ct.geometry.boundingSphere=new M.Sphere);for(let c=0,l=i.length;c<l;c++){if(!this.getVisibleAt(c))continue;const u=i[c].geometryIndex;if(ct.geometry.boundsTree=e[u],this.getMatrixAt(c,ct.matrixWorld).premultiply(s),!ct.geometry.boundsTree){this.getBoundingBoxAt(u,ct.geometry.boundingBox),this.getBoundingSphereAt(u,ct.geometry.boundingSphere);const h=r[u];ct.geometry.setDrawRange(h.start,h.count)}ct.raycast(n,Tr);for(let h=0,f=Tr.length;h<f;h++){const d=Tr[h];d.object=this,d.batchId=c,t.push(d)}Tr.length=0}ct.geometry.boundsTree=a,ct.geometry.drawRange=o,ct.material=null,ct.geometry=null}else Iu.call(this,n,t)}function Fu(n,t){if(this.geometry.boundsTree){if(this.material===void 0)return;ro.copy(this.matrixWorld).invert(),br.copy(n.ray).applyMatrix4(ro),no.setFromMatrixScale(this.matrixWorld),io.copy(br.direction).multiply(no);const e=io.length(),i=n.near/e,r=n.far/e,s=this.geometry.boundsTree;if(n.firstHitOnly===!0){const a=eo(s.raycastFirst(br,this.material,i,r),this,n);a&&t.push(a)}else{const a=s.raycast(br,this.material,i,r);for(let o=0,c=a.length;o<c;o++){const l=eo(a[o],this,n);l&&t.push(l)}}}else Ou.call(this,n,t)}function Du(n={}){return this.boundsTree=new Ki(this,n),this.boundsTree}const Me=new M.Vector3,Ce=new M.Vector3,Pe=new M.Vector3,so=new M.Vector4,Mr=new M.Vector3,Mn=new M.Vector3,oo=new M.Vector4,ao=new M.Vector4,Cr=new M.Matrix4,co=new M.Matrix4;function ci(n,t){if(!n&&!t)return;const e=n.count===t.count,i=n.normalized===t.normalized,r=n.array.constructor===t.array.constructor,s=n.itemSize===t.itemSize;if(!e||!i||!r||!s)throw new Error}function di(n,t=null){const e=n.array.constructor,i=n.normalized,r=n.itemSize,s=t===null?n.count:t;return new M.BufferAttribute(new e(r*s),r,i)}function ya(n,t,e=0){if(n.isInterleavedBufferAttribute){const i=n.itemSize;for(let r=0,s=n.count;r<s;r++){const a=r+e;t.setX(a,n.getX(r)),i>=2&&t.setY(a,n.getY(r)),i>=3&&t.setZ(a,n.getZ(r)),i>=4&&t.setW(a,n.getW(r))}}else{const i=t.array,r=i.constructor,s=i.BYTES_PER_ELEMENT*n.itemSize*e;new r(i.buffer,s,n.array.length).set(n.array)}}function Lu(n,t,e){const i=n.elements,r=t.elements;for(let s=0,a=r.length;s<a;s++)i[s]+=r[s]*e}function lo(n,t,e){const i=n.skeleton,r=n.geometry,s=i.bones,a=i.boneInverses;oo.fromBufferAttribute(r.attributes.skinIndex,t),ao.fromBufferAttribute(r.attributes.skinWeight,t),Cr.elements.fill(0);for(let o=0;o<4;o++){const c=ao.getComponent(o);if(c!==0){const l=oo.getComponent(o);co.multiplyMatrices(s[l].matrixWorld,a[l]),Lu(Cr,co,c)}}return Cr.multiply(n.bindMatrix).premultiply(n.bindMatrixInverse),e.transformDirection(Cr),e}function Cn(n,t,e,i,r){Mr.set(0,0,0);for(let s=0,a=n.length;s<a;s++){const o=t[s],c=n[s];o!==0&&(Mn.fromBufferAttribute(c,i),e?Mr.addScaledVector(Mn,o):Mr.addScaledVector(Mn.sub(r),o))}r.add(Mr)}function Vu(n,t={useGroups:!1,updateIndex:!1,skipAttributes:[]},e=new M.BufferGeometry){const i=n[0].index!==null,{useGroups:r=!1,updateIndex:s=!1,skipAttributes:a=[]}=t,o=new Set(Object.keys(n[0].attributes)),c={};let l=0;e.clearGroups();for(let u=0;u<n.length;++u){const h=n[u];let f=0;if(i!==(h.index!==null))throw new Error("StaticGeometryGenerator: All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.");for(const d in h.attributes){if(!o.has(d))throw new Error('StaticGeometryGenerator: All geometries must have compatible attributes; make sure "'+d+'" attribute exists among all geometries, or in none of them.');c[d]===void 0&&(c[d]=[]),c[d].push(h.attributes[d]),f++}if(f!==o.size)throw new Error("StaticGeometryGenerator: Make sure all geometries have the same number of attributes.");if(r){let d;if(i)d=h.index.count;else if(h.attributes.position!==void 0)d=h.attributes.position.count;else throw new Error("StaticGeometryGenerator: The geometry must have either an index or a position attribute");e.addGroup(l,d,u),l+=d}}if(i){let u=!1;if(!e.index){let h=0;for(let f=0;f<n.length;++f)h+=n[f].index.count;e.setIndex(new M.BufferAttribute(new Uint32Array(h),1,!1)),u=!0}if(s||u){const h=e.index;let f=0,d=0;for(let y=0;y<n.length;++y){const _=n[y],p=_.index;if(a[y]!==!0)for(let m=0;m<p.count;++m)h.setX(f,p.getX(m)+d),f++;d+=_.attributes.position.count}}}for(const u in c){const h=c[u];if(!(u in e.attributes)){let y=0;for(const _ in h)y+=h[_].count;e.setAttribute(u,di(c[u][0],y))}const f=e.attributes[u];let d=0;for(let y=0,_=h.length;y<_;y++){const p=h[y];a[y]!==!0&&ya(p,f,d),d+=p.count}}return e}function Ju(n,t){if(n===null||t===null)return n===t;if(n.length!==t.length)return!1;for(let e=0,i=n.length;e<i;e++)if(n[e]!==t[e])return!1;return!0}function Gu(n){const{index:t,attributes:e}=n;if(t)for(let i=0,r=t.count;i<r;i+=3){const s=t.getX(i),a=t.getX(i+2);t.setX(i,a),t.setX(i+2,s)}else for(const i in e){const r=e[i],s=r.itemSize;for(let a=0,o=r.count;a<o;a+=3)for(let c=0;c<s;c++){const l=r.getComponent(a,c),u=r.getComponent(a+2,c);r.setComponent(a,c,u),r.setComponent(a+2,c,l)}}return n}class ju{constructor(t){this.matrixWorld=new M.Matrix4,this.geometryHash=null,this.boneMatrices=null,this.primitiveCount=-1,this.mesh=t,this.update()}update(){const t=this.mesh,e=t.geometry,i=t.skeleton,r=(e.index?e.index.count:e.attributes.position.count)/3;if(this.matrixWorld.copy(t.matrixWorld),this.geometryHash=e.attributes.position.version,this.primitiveCount=r,i){i.boneTexture||i.computeBoneTexture(),i.update();const s=i.boneMatrices;!this.boneMatrices||this.boneMatrices.length!==s.length?this.boneMatrices=s.slice():this.boneMatrices.set(s)}else this.boneMatrices=null}didChange(){const t=this.mesh,e=t.geometry,i=(e.index?e.index.count:e.attributes.position.count)/3;return!(this.matrixWorld.equals(t.matrixWorld)&&this.geometryHash===e.attributes.position.version&&Ju(t.skeleton&&t.skeleton.boneMatrices||null,this.boneMatrices)&&this.primitiveCount===i)}}class $u{constructor(t){Array.isArray(t)||(t=[t]);const e=[];t.forEach(i=>{i.traverseVisible(r=>{r.isMesh&&e.push(r)})}),this.meshes=e,this.useGroups=!0,this.applyWorldTransforms=!0,this.attributes=["position","normal","color","tangent","uv","uv2"],this._intermediateGeometry=new Array(e.length).fill().map(()=>new M.BufferGeometry),this._diffMap=new WeakMap}getMaterials(){const t=[];return this.meshes.forEach(e=>{Array.isArray(e.material)?t.push(...e.material):t.push(e.material)}),t}generate(t=new M.BufferGeometry){let e=[];const{meshes:i,useGroups:r,_intermediateGeometry:s,_diffMap:a}=this;for(let o=0,c=i.length;o<c;o++){const l=i[o],u=s[o],h=a.get(l);!h||h.didChange(l)?(this._convertToStaticGeometry(l,u),e.push(!1),h?h.update():a.set(l,new ju(l))):e.push(!0)}if(s.length===0){t.setIndex(null);const o=t.attributes;for(const c in o)t.deleteAttribute(c);for(const c in this.attributes)t.setAttribute(this.attributes[c],new M.BufferAttribute(new Float32Array(0),4,!1))}else Vu(s,{useGroups:r,skipAttributes:e},t);for(const o in t.attributes)t.attributes[o].needsUpdate=!0;return t}_convertToStaticGeometry(t,e=new M.BufferGeometry){const i=t.geometry,r=this.applyWorldTransforms,s=this.attributes.includes("normal"),a=this.attributes.includes("tangent"),o=i.attributes,c=e.attributes;!e.index&&i.index&&(e.index=i.index.clone()),c.position||e.setAttribute("position",di(o.position)),s&&!c.normal&&o.normal&&e.setAttribute("normal",di(o.normal)),a&&!c.tangent&&o.tangent&&e.setAttribute("tangent",di(o.tangent)),ci(i.index,e.index),ci(o.position,c.position),s&&ci(o.normal,c.normal),a&&ci(o.tangent,c.tangent);const l=o.position,u=s?o.normal:null,h=a?o.tangent:null,f=i.morphAttributes.position,d=i.morphAttributes.normal,y=i.morphAttributes.tangent,_=i.morphTargetsRelative,p=t.morphTargetInfluences,m=new M.Matrix3;m.getNormalMatrix(t.matrixWorld),i.index&&e.index.array.set(i.index.array);for(let g=0,v=o.position.count;g<v;g++)Me.fromBufferAttribute(l,g),u&&Ce.fromBufferAttribute(u,g),h&&(so.fromBufferAttribute(h,g),Pe.fromBufferAttribute(h,g)),p&&(f&&Cn(f,p,_,g,Me),d&&Cn(d,p,_,g,Ce),y&&Cn(y,p,_,g,Pe)),t.isSkinnedMesh&&(t.applyBoneTransform(g,Me),u&&lo(t,g,Ce),h&&lo(t,g,Pe)),r&&Me.applyMatrix4(t.matrixWorld),c.position.setXYZ(g,Me.x,Me.y,Me.z),u&&(r&&Ce.applyNormalMatrix(m),c.normal.setXYZ(g,Ce.x,Ce.y,Ce.z)),h&&(r&&Pe.transformDirection(t.matrixWorld),c.tangent.setXYZW(g,Pe.x,Pe.y,Pe.z,so.w));for(const g in this.attributes){const v=this.attributes[g];v==="position"||v==="tangent"||v==="normal"||!(v in o)||(c[v]||e.setAttribute(v,di(o[v])),ci(o[v],c[v]),ya(o[v],c[v]))}return t.matrixWorld.determinant()<0&&Gu(e),e}}const qu=Object.freeze(Object.defineProperty({__proto__:null,AVERAGE:la,CENTER:rs,CONTAINED:Fn,ExtendedTriangle:Rt,MeshBVH:Ki,OrientedBox:dt,SAH:ua,StaticGeometryGenerator:$u,acceleratedRaycast:Uu,computeBoundsTree:Du},Symbol.toStringTag,{value:"Module"}));class Xu{constructor(t){this.name="WorkerBase",this.running=!1,this.worker=t,this.worker.onerror=e=>{throw e.message?new Error(`${this.name}: Could not create Web Worker with error "${e.message}"`):new Error(`${this.name}: Could not create Web Worker.`)}}runTask(){}generate(...t){if(this.running)throw new Error("GenerateMeshBVHWorker: Already running job.");if(this.worker===null)throw new Error("GenerateMeshBVHWorker: Worker has been disposed.");this.running=!0;const e=this.runTask(this.worker,...t);return e.finally(()=>{this.running=!1}),e}dispose(){this.worker.terminate(),this.worker=null}}exports.$70d766613f57b014$export$2e2bcd8739ae039=Ko;exports.BatchedParticleRenderer=Pl;exports.Builder=Wn;exports.ByteBuffer=gi;exports.ConstantColor=Re;exports.ConstantValue=F;exports.Matrix4=Ft;exports.MeshBVH=Ki;exports.MotionController=Ta;exports.ParticleSystem=Dr;exports.SIZE_PREFIX_LENGTH=ho;exports.TrailParticle=Nr;exports.Vector4=bt;exports.WorkerBase=Xu;exports.bundler=ec;exports.createNoise4D=El;exports.fetchProfile=va;exports.index=zl;exports.index$1=qu;exports.md5=gc;exports.v5=fc;
|