@needle-tools/engine 5.1.0-canary.db0c38f → 5.1.0-canary.e6680fa
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/.needle/generated/needle-bindings.gen.d.ts +5 -0
- package/CHANGELOG.md +133 -1
- package/SKILL.md +4 -1
- package/components.needle.json +1 -1
- package/dist/needle-engine.bundle-Bl_hyH5G.umd.cjs +1734 -0
- package/dist/needle-engine.bundle-Cduc1gj6.min.js +1734 -0
- package/dist/{needle-engine.bundle-B29kieh0.js → needle-engine.bundle-DNcqT8nJ.js} +13770 -12741
- package/dist/needle-engine.d.ts +1628 -402
- package/dist/needle-engine.js +591 -586
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/dist/three.js +1 -0
- package/dist/three.min.js +21 -21
- package/dist/three.umd.cjs +16 -16
- package/lib/engine/api.d.ts +9 -2
- package/lib/engine/api.js +7 -1
- package/lib/engine/api.js.map +1 -1
- package/lib/engine/codegen/register_types.js +10 -18
- package/lib/engine/codegen/register_types.js.map +1 -1
- package/lib/engine/debug/debug_spatial_console.d.ts +2 -0
- package/lib/engine/debug/debug_spatial_console.js +10 -7
- package/lib/engine/debug/debug_spatial_console.js.map +1 -1
- package/lib/engine/engine_addressables.d.ts +2 -0
- package/lib/engine/engine_addressables.js +6 -3
- package/lib/engine/engine_addressables.js.map +1 -1
- package/lib/engine/engine_audio.d.ts +68 -0
- package/lib/engine/engine_audio.js +172 -0
- package/lib/engine/engine_audio.js.map +1 -1
- package/lib/engine/engine_camera.fit.js +16 -4
- package/lib/engine/engine_camera.fit.js.map +1 -1
- package/lib/engine/engine_components.js +1 -1
- package/lib/engine/engine_components.js.map +1 -1
- package/lib/engine/engine_context.d.ts +41 -27
- package/lib/engine/engine_context.js +71 -30
- package/lib/engine/engine_context.js.map +1 -1
- package/lib/engine/engine_context_eventbus.d.ts +47 -0
- package/lib/engine/engine_context_eventbus.js +47 -0
- package/lib/engine/engine_context_eventbus.js.map +1 -0
- package/lib/engine/engine_disposable.d.ts +172 -0
- package/lib/engine/engine_disposable.js +136 -0
- package/lib/engine/engine_disposable.js.map +1 -0
- package/lib/engine/engine_gameobject.d.ts +1 -10
- package/lib/engine/engine_gameobject.js +22 -120
- package/lib/engine/engine_gameobject.js.map +1 -1
- package/lib/engine/engine_gltf_builtin_components.js +7 -69
- package/lib/engine/engine_gltf_builtin_components.js.map +1 -1
- package/lib/engine/engine_init.js +16 -1
- package/lib/engine/engine_init.js.map +1 -1
- package/lib/engine/engine_input.d.ts +24 -5
- package/lib/engine/engine_input.js +3 -2
- package/lib/engine/engine_input.js.map +1 -1
- package/lib/engine/engine_instantiate_resolve.d.ts +42 -0
- package/lib/engine/engine_instantiate_resolve.js +372 -0
- package/lib/engine/engine_instantiate_resolve.js.map +1 -0
- package/lib/engine/engine_license.d.ts +8 -6
- package/lib/engine/engine_license.js +195 -59
- package/lib/engine/engine_license.js.map +1 -1
- package/lib/engine/engine_lifecycle_functions_internal.js +5 -0
- package/lib/engine/engine_lifecycle_functions_internal.js.map +1 -1
- package/lib/engine/engine_mainloop_utils.js +7 -4
- package/lib/engine/engine_mainloop_utils.js.map +1 -1
- package/lib/engine/engine_networking.d.ts +51 -37
- package/lib/engine/engine_networking.js +132 -82
- package/lib/engine/engine_networking.js.map +1 -1
- package/lib/engine/engine_networking.transport.websocket.d.ts +15 -0
- package/lib/engine/engine_networking.transport.websocket.js +38 -0
- package/lib/engine/engine_networking.transport.websocket.js.map +1 -0
- package/lib/engine/engine_networking_blob.js +4 -4
- package/lib/engine/engine_networking_blob.js.map +1 -1
- package/lib/engine/engine_networking_instantiate.js +2 -2
- package/lib/engine/engine_networking_instantiate.js.map +1 -1
- package/lib/engine/engine_networking_types.d.ts +39 -1
- package/lib/engine/engine_networking_types.js +7 -0
- package/lib/engine/engine_networking_types.js.map +1 -1
- package/lib/engine/engine_physics_rapier.d.ts +21 -3
- package/lib/engine/engine_physics_rapier.js +94 -25
- package/lib/engine/engine_physics_rapier.js.map +1 -1
- package/lib/engine/engine_pmrem.js +53 -5
- package/lib/engine/engine_pmrem.js.map +1 -1
- package/lib/engine/engine_scenedata.d.ts +13 -17
- package/lib/engine/engine_scenedata.js +58 -31
- package/lib/engine/engine_scenedata.js.map +1 -1
- package/lib/engine/engine_serialization_builtin_serializer.d.ts +10 -16
- package/lib/engine/engine_serialization_builtin_serializer.js +56 -46
- package/lib/engine/engine_serialization_builtin_serializer.js.map +1 -1
- package/lib/engine/engine_serialization_core.d.ts +1 -0
- package/lib/engine/engine_serialization_core.js +7 -0
- package/lib/engine/engine_serialization_core.js.map +1 -1
- package/lib/engine/engine_ssr.d.ts +2 -0
- package/lib/engine/engine_ssr.js +20 -0
- package/lib/engine/engine_ssr.js.map +1 -1
- package/lib/engine/engine_types.d.ts +31 -11
- package/lib/engine/engine_types.js +1 -1
- package/lib/engine/engine_types.js.map +1 -1
- package/lib/engine/engine_util_decorator.js +7 -2
- package/lib/engine/engine_util_decorator.js.map +1 -1
- package/lib/engine/engine_utils.d.ts +1 -1
- package/lib/engine/engine_utils.js +19 -5
- package/lib/engine/engine_utils.js.map +1 -1
- package/lib/engine/engine_utils_format.js +20 -14
- package/lib/engine/engine_utils_format.js.map +1 -1
- package/lib/engine/engine_utils_qrcode.js +2 -2
- package/lib/engine/engine_utils_qrcode.js.map +1 -1
- package/lib/engine/physics/workers/mesh-bvh/GenerateMeshBVHWorker.js +1 -1
- package/lib/engine/physics/workers/mesh-bvh/GenerateMeshBVHWorker.js.map +1 -1
- package/lib/engine/webcomponents/jsx.d.ts +51 -0
- package/lib/engine/webcomponents/logo-element.js.map +1 -1
- package/lib/engine/webcomponents/needle menu/needle-menu-spatial.js +2 -2
- package/lib/engine/webcomponents/needle menu/needle-menu-spatial.js.map +1 -1
- package/lib/engine/webcomponents/needle menu/needle-menu.d.ts +3 -4
- package/lib/engine/webcomponents/needle menu/needle-menu.js +6 -6
- package/lib/engine/webcomponents/needle menu/needle-menu.js.map +1 -1
- package/lib/engine/webcomponents/needle-button.js.map +1 -1
- package/lib/engine/webcomponents/needle-engine.d.ts +10 -4
- package/lib/engine/webcomponents/needle-engine.js +3 -3
- package/lib/engine/webcomponents/needle-engine.js.map +1 -1
- package/lib/engine/webcomponents/needle-engine.loading.js +2 -2
- package/lib/engine/webcomponents/needle-engine.loading.js.map +1 -1
- package/lib/engine/xr/NeedleXRSession.d.ts +3 -2
- package/lib/engine/xr/NeedleXRSession.js +50 -14
- package/lib/engine/xr/NeedleXRSession.js.map +1 -1
- package/lib/engine/xr/TempXRContext.js +2 -2
- package/lib/engine/xr/TempXRContext.js.map +1 -1
- package/lib/engine/xr/events.d.ts +1 -1
- package/lib/engine/xr/events.js.map +1 -1
- package/lib/engine-components/Animation.js +17 -16
- package/lib/engine-components/Animation.js.map +1 -1
- package/lib/engine-components/AnimationBuilder.d.ts +158 -0
- package/lib/engine-components/AnimationBuilder.js +305 -0
- package/lib/engine-components/AnimationBuilder.js.map +1 -0
- package/lib/engine-components/Animator.d.ts +6 -0
- package/lib/engine-components/Animator.js +23 -13
- package/lib/engine-components/Animator.js.map +1 -1
- package/lib/engine-components/AnimatorController.builder.d.ts +191 -0
- package/lib/engine-components/AnimatorController.builder.js +263 -0
- package/lib/engine-components/AnimatorController.builder.js.map +1 -0
- package/lib/engine-components/AnimatorController.d.ts +4 -119
- package/lib/engine-components/AnimatorController.js +37 -233
- package/lib/engine-components/AnimatorController.js.map +1 -1
- package/lib/engine-components/AudioSource.d.ts +19 -3
- package/lib/engine-components/AudioSource.js +121 -68
- package/lib/engine-components/AudioSource.js.map +1 -1
- package/lib/engine-components/Camera.d.ts +6 -1
- package/lib/engine-components/Camera.js +16 -3
- package/lib/engine-components/Camera.js.map +1 -1
- package/lib/engine-components/CameraUtils.js +14 -6
- package/lib/engine-components/CameraUtils.js.map +1 -1
- package/lib/engine-components/Collider.d.ts +18 -9
- package/lib/engine-components/Collider.js +61 -14
- package/lib/engine-components/Collider.js.map +1 -1
- package/lib/engine-components/Component.d.ts +72 -9
- package/lib/engine-components/Component.js +114 -10
- package/lib/engine-components/Component.js.map +1 -1
- package/lib/engine-components/ContactShadows.d.ts +1 -0
- package/lib/engine-components/ContactShadows.js +14 -1
- package/lib/engine-components/ContactShadows.js.map +1 -1
- package/lib/engine-components/DragControls.d.ts +7 -0
- package/lib/engine-components/DragControls.js +19 -7
- package/lib/engine-components/DragControls.js.map +1 -1
- package/lib/engine-components/DropListener.js +4 -0
- package/lib/engine-components/DropListener.js.map +1 -1
- package/lib/engine-components/EventList.d.ts +31 -9
- package/lib/engine-components/EventList.js +37 -76
- package/lib/engine-components/EventList.js.map +1 -1
- package/lib/engine-components/Joints.d.ts +4 -2
- package/lib/engine-components/Joints.js +19 -3
- package/lib/engine-components/Joints.js.map +1 -1
- package/lib/engine-components/Light.d.ts +6 -8
- package/lib/engine-components/Light.js +48 -27
- package/lib/engine-components/Light.js.map +1 -1
- package/lib/engine-components/Networking.d.ts +1 -1
- package/lib/engine-components/Networking.js +1 -1
- package/lib/engine-components/OrbitControls.d.ts +1 -2
- package/lib/engine-components/OrbitControls.js +37 -14
- package/lib/engine-components/OrbitControls.js.map +1 -1
- package/lib/engine-components/ReflectionProbe.js +2 -0
- package/lib/engine-components/ReflectionProbe.js.map +1 -1
- package/lib/engine-components/RigidBody.d.ts +12 -4
- package/lib/engine-components/RigidBody.js +18 -4
- package/lib/engine-components/RigidBody.js.map +1 -1
- package/lib/engine-components/SceneSwitcher.js +3 -0
- package/lib/engine-components/SceneSwitcher.js.map +1 -1
- package/lib/engine-components/SeeThrough.js +2 -2
- package/lib/engine-components/SeeThrough.js.map +1 -1
- package/lib/engine-components/VideoPlayer.d.ts +8 -2
- package/lib/engine-components/VideoPlayer.js +42 -19
- package/lib/engine-components/VideoPlayer.js.map +1 -1
- package/lib/engine-components/Voip.d.ts +16 -7
- package/lib/engine-components/Voip.js +90 -53
- package/lib/engine-components/Voip.js.map +1 -1
- package/lib/engine-components/api.d.ts +3 -1
- package/lib/engine-components/api.js +3 -1
- package/lib/engine-components/api.js.map +1 -1
- package/lib/engine-components/codegen/components.d.ts +7 -13
- package/lib/engine-components/codegen/components.js +7 -13
- package/lib/engine-components/codegen/components.js.map +1 -1
- package/lib/engine-components/export/usdz/USDZExporter.js +4 -4
- package/lib/engine-components/export/usdz/USDZExporter.js.map +1 -1
- package/lib/engine-components/postprocessing/Effects/Tonemapping.utils.d.ts +1 -1
- package/lib/engine-components/postprocessing/VolumeParameter.d.ts +2 -0
- package/lib/engine-components/postprocessing/VolumeParameter.js +4 -1
- package/lib/engine-components/postprocessing/VolumeParameter.js.map +1 -1
- package/lib/engine-components/timeline/PlayableDirector.d.ts +21 -11
- package/lib/engine-components/timeline/PlayableDirector.js +75 -67
- package/lib/engine-components/timeline/PlayableDirector.js.map +1 -1
- package/lib/engine-components/timeline/SignalAsset.d.ts +3 -1
- package/lib/engine-components/timeline/SignalAsset.js +1 -0
- package/lib/engine-components/timeline/SignalAsset.js.map +1 -1
- package/lib/engine-components/timeline/TimelineBuilder.d.ts +413 -0
- package/lib/engine-components/timeline/TimelineBuilder.js +506 -0
- package/lib/engine-components/timeline/TimelineBuilder.js.map +1 -0
- package/lib/engine-components/timeline/TimelineModels.d.ts +2 -1
- package/lib/engine-components/timeline/TimelineModels.js +3 -0
- package/lib/engine-components/timeline/TimelineModels.js.map +1 -1
- package/lib/engine-components/timeline/TimelineTracks.d.ts +37 -6
- package/lib/engine-components/timeline/TimelineTracks.js +92 -26
- package/lib/engine-components/timeline/TimelineTracks.js.map +1 -1
- package/lib/engine-components/timeline/index.d.ts +2 -1
- package/lib/engine-components/timeline/index.js +2 -0
- package/lib/engine-components/timeline/index.js.map +1 -1
- package/lib/engine-components/ui/Canvas.d.ts +1 -1
- package/lib/engine-components/ui/Canvas.js +2 -8
- package/lib/engine-components/ui/Canvas.js.map +1 -1
- package/lib/engine-components/ui/Text.d.ts +1 -0
- package/lib/engine-components/ui/Text.js +10 -7
- package/lib/engine-components/ui/Text.js.map +1 -1
- package/lib/engine-components/web/CursorFollow.d.ts +0 -1
- package/lib/engine-components/web/CursorFollow.js +21 -13
- package/lib/engine-components/web/CursorFollow.js.map +1 -1
- package/lib/engine-components/webxr/WebXRImageTracking.d.ts +62 -1
- package/lib/engine-components/webxr/WebXRImageTracking.js +59 -2
- package/lib/engine-components/webxr/WebXRImageTracking.js.map +1 -1
- package/lib/needle-engine.d.ts +2 -0
- package/lib/needle-engine.js +2 -0
- package/lib/needle-engine.js.map +1 -1
- package/package.json +4 -84
- package/plugins/common/cloud.js +6 -1
- package/plugins/common/license.js +55 -12
- package/plugins/common/worker.js +9 -4
- package/plugins/dts-generator/dts.codegen.js +255 -50
- package/plugins/dts-generator/dts.scan.js +37 -9
- package/plugins/dts-generator/dts.writer.js +1 -1
- package/plugins/dts-generator/glb.discovery.js +140 -23
- package/plugins/dts-generator/glb.extractor.js +48 -8
- package/plugins/dts-generator/glb.reader.js +80 -27
- package/plugins/dts-generator/index.js +1 -1
- package/plugins/types/needle-bindings.d.ts +25 -14
- package/plugins/types/userconfig.d.ts +16 -1
- package/plugins/vite/asap.js +18 -9
- package/plugins/vite/build-pipeline.js +57 -20
- package/plugins/vite/dependencies.js +29 -10
- package/plugins/vite/dependency-watcher.d.ts +2 -2
- package/plugins/vite/dependency-watcher.js +5 -6
- package/plugins/vite/drop.d.ts +2 -2
- package/plugins/vite/drop.js +3 -4
- package/plugins/vite/dts-generator.d.ts +2 -2
- package/plugins/vite/dts-generator.js +43 -9
- package/plugins/vite/editor-connection.js +3 -3
- package/plugins/vite/index.d.ts +9 -3
- package/plugins/vite/index.js +23 -10
- package/plugins/vite/license.js +42 -7
- package/plugins/vite/local-files-core.js +3 -3
- package/plugins/vite/local-files-utils.d.ts +3 -1
- package/plugins/vite/local-files-utils.js +29 -5
- package/plugins/vite/meta.js +4 -2
- package/plugins/vite/poster.d.ts +2 -2
- package/plugins/vite/poster.js +3 -5
- package/plugins/vite/reload.d.ts +2 -2
- package/plugins/vite/reload.js +23 -23
- package/plugins/vite/server.js +2 -1
- package/src/engine/api.ts +12 -2
- package/src/engine/codegen/register_types.ts +10 -18
- package/src/engine/debug/debug_spatial_console.ts +10 -7
- package/src/engine/engine_addressables.ts +6 -3
- package/src/engine/engine_audio.ts +184 -0
- package/src/engine/engine_camera.fit.ts +15 -4
- package/src/engine/engine_components.ts +1 -1
- package/src/engine/engine_context.ts +85 -38
- package/src/engine/engine_context_eventbus.ts +73 -0
- package/src/engine/engine_disposable.ts +214 -0
- package/src/engine/engine_gameobject.ts +54 -159
- package/src/engine/engine_gltf_builtin_components.ts +7 -76
- package/src/engine/engine_init.ts +15 -1
- package/src/engine/engine_input.ts +28 -7
- package/src/engine/engine_instantiate_resolve.ts +407 -0
- package/src/engine/engine_license.ts +209 -61
- package/src/engine/engine_lifecycle_functions_internal.ts +7 -0
- package/src/engine/engine_mainloop_utils.ts +7 -4
- package/src/engine/engine_networking.transport.websocket.ts +45 -0
- package/src/engine/engine_networking.ts +161 -137
- package/src/engine/engine_networking_blob.ts +4 -4
- package/src/engine/engine_networking_instantiate.ts +2 -2
- package/src/engine/engine_networking_types.ts +41 -1
- package/src/engine/engine_physics_rapier.ts +102 -33
- package/src/engine/engine_pmrem.ts +56 -6
- package/src/engine/engine_scenedata.ts +56 -30
- package/src/engine/engine_serialization_builtin_serializer.ts +64 -52
- package/src/engine/engine_serialization_core.ts +9 -0
- package/src/engine/engine_ssr.ts +29 -3
- package/src/engine/engine_types.ts +48 -27
- package/src/engine/engine_util_decorator.ts +7 -2
- package/src/engine/engine_utils.ts +16 -5
- package/src/engine/engine_utils_format.ts +20 -14
- package/src/engine/engine_utils_qrcode.ts +2 -2
- package/src/engine/physics/workers/mesh-bvh/GenerateMeshBVHWorker.js +1 -1
- package/src/engine/webcomponents/jsx.d.ts +51 -0
- package/src/engine/webcomponents/logo-element.ts +1 -0
- package/src/engine/webcomponents/needle menu/needle-menu-spatial.ts +2 -2
- package/src/engine/webcomponents/needle menu/needle-menu.ts +8 -7
- package/src/engine/webcomponents/needle-button.ts +1 -0
- package/src/engine/webcomponents/needle-engine.loading.ts +6 -6
- package/src/engine/webcomponents/needle-engine.ts +13 -6
- package/src/engine/xr/NeedleXRSession.ts +48 -13
- package/src/engine/xr/TempXRContext.ts +2 -2
- package/src/engine/xr/events.ts +1 -1
- package/src/engine-components/Animation.ts +19 -16
- package/src/engine-components/AnimationBuilder.ts +472 -0
- package/src/engine-components/Animator.ts +24 -12
- package/src/engine-components/AnimatorController.builder.ts +387 -0
- package/src/engine-components/AnimatorController.ts +24 -292
- package/src/engine-components/AudioSource.ts +130 -79
- package/src/engine-components/Camera.ts +16 -3
- package/src/engine-components/CameraUtils.ts +12 -5
- package/src/engine-components/Collider.ts +66 -18
- package/src/engine-components/Component.ts +118 -20
- package/src/engine-components/ContactShadows.ts +15 -1
- package/src/engine-components/DragControls.ts +18 -11
- package/src/engine-components/DropListener.ts +4 -0
- package/src/engine-components/EventList.ts +45 -83
- package/src/engine-components/Joints.ts +20 -4
- package/src/engine-components/Light.ts +49 -27
- package/src/engine-components/Networking.ts +1 -1
- package/src/engine-components/OrbitControls.ts +42 -16
- package/src/engine-components/ReflectionProbe.ts +2 -0
- package/src/engine-components/RigidBody.ts +18 -4
- package/src/engine-components/SceneSwitcher.ts +3 -0
- package/src/engine-components/SeeThrough.ts +2 -2
- package/src/engine-components/VideoPlayer.ts +40 -17
- package/src/engine-components/Voip.ts +88 -53
- package/src/engine-components/api.ts +3 -1
- package/src/engine-components/codegen/components.ts +7 -13
- package/src/engine-components/export/usdz/USDZExporter.ts +4 -4
- package/src/engine-components/postprocessing/VolumeParameter.ts +4 -1
- package/src/engine-components/timeline/PlayableDirector.ts +83 -81
- package/src/engine-components/timeline/SignalAsset.ts +4 -1
- package/src/engine-components/timeline/TimelineBuilder.ts +824 -0
- package/src/engine-components/timeline/TimelineModels.ts +5 -1
- package/src/engine-components/timeline/TimelineTracks.ts +96 -27
- package/src/engine-components/timeline/index.ts +2 -1
- package/src/engine-components/ui/Canvas.ts +2 -8
- package/src/engine-components/ui/Text.ts +12 -8
- package/src/engine-components/web/CursorFollow.ts +21 -14
- package/src/engine-components/webxr/WebXRImageTracking.ts +79 -7
- package/src/needle-engine.ts +3 -0
- package/dist/needle-engine.bundle-Dq0Ly8fW.umd.cjs +0 -1732
- package/dist/needle-engine.bundle-YnpzzOPL.min.js +0 -1732
- package/lib/engine-components/AvatarLoader.d.ts +0 -80
- package/lib/engine-components/AvatarLoader.js +0 -232
- package/lib/engine-components/AvatarLoader.js.map +0 -1
- package/lib/engine-components/avatar/AvatarBlink_Simple.d.ts +0 -11
- package/lib/engine-components/avatar/AvatarBlink_Simple.js +0 -77
- package/lib/engine-components/avatar/AvatarBlink_Simple.js.map +0 -1
- package/lib/engine-components/avatar/AvatarEyeLook_Rotation.d.ts +0 -14
- package/lib/engine-components/avatar/AvatarEyeLook_Rotation.js +0 -69
- package/lib/engine-components/avatar/AvatarEyeLook_Rotation.js.map +0 -1
- package/lib/engine-components/avatar/Avatar_Brain_LookAt.d.ts +0 -29
- package/lib/engine-components/avatar/Avatar_Brain_LookAt.js +0 -122
- package/lib/engine-components/avatar/Avatar_Brain_LookAt.js.map +0 -1
- package/lib/engine-components/avatar/Avatar_MouthShapes.d.ts +0 -15
- package/lib/engine-components/avatar/Avatar_MouthShapes.js +0 -80
- package/lib/engine-components/avatar/Avatar_MouthShapes.js.map +0 -1
- package/lib/engine-components/avatar/Avatar_MustacheShake.d.ts +0 -9
- package/lib/engine-components/avatar/Avatar_MustacheShake.js +0 -30
- package/lib/engine-components/avatar/Avatar_MustacheShake.js.map +0 -1
- package/src/engine-components/AvatarLoader.ts +0 -264
- package/src/engine-components/avatar/AvatarBlink_Simple.ts +0 -70
- package/src/engine-components/avatar/AvatarEyeLook_Rotation.ts +0 -64
- package/src/engine-components/avatar/Avatar_Brain_LookAt.ts +0 -140
- package/src/engine-components/avatar/Avatar_MouthShapes.ts +0 -84
- package/src/engine-components/avatar/Avatar_MustacheShake.ts +0 -32
- package/src/vite-env.d.ts +0 -16
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { CameraHelper, Color, DirectionalLight, DirectionalLightHelper, Light as ThreeLight, OrthographicCamera, PointLight, SpotLight, Vector3 } from "three";
|
|
2
2
|
|
|
3
3
|
import { serializable } from "../engine/engine_serialization_decorator.js";
|
|
4
|
-
import { FrameEvent } from "../engine/engine_setup.js";
|
|
5
4
|
import { setWorldPositionXYZ } from "../engine/engine_three_utils.js";
|
|
6
5
|
import type { ILight } from "../engine/engine_types.js";
|
|
7
6
|
import { getParam } from "../engine/engine_utils.js";
|
|
8
7
|
import type { NeedleXREventArgs } from "../engine/xr/api.js";
|
|
9
8
|
import { Behaviour, GameObject } from "./Component.js";
|
|
9
|
+
import { isDevEnvironment } from "../engine/debug/index.js";
|
|
10
10
|
|
|
11
11
|
// https://threejs.org/examples/webgl_shadowmap_csm.html
|
|
12
12
|
|
|
@@ -106,11 +106,43 @@ enum LightShadows {
|
|
|
106
106
|
export class Light extends Behaviour implements ILight {
|
|
107
107
|
|
|
108
108
|
/**
|
|
109
|
-
* The type of light
|
|
110
|
-
* Can not be changed at runtime.
|
|
109
|
+
* The type of light as a lowercase string: `"directional"`, `"point"`, `"spot"`.
|
|
110
|
+
* Implements {@link ILight.type}. Can not be changed at runtime.
|
|
111
111
|
*/
|
|
112
|
+
get type(): ILight["type"] {
|
|
113
|
+
return this._type;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** Numeric LightType serialized from Unity/Blender — converts to string on write */
|
|
112
117
|
@serializable()
|
|
113
|
-
|
|
118
|
+
set type(value: LightType | ILight["type"]) {
|
|
119
|
+
if (this.light && this.__didAwake) {
|
|
120
|
+
throw new Error("Changing the light type at runtime is not supported");
|
|
121
|
+
}
|
|
122
|
+
switch (value) {
|
|
123
|
+
case LightType.Directional:
|
|
124
|
+
this._type = "directional";
|
|
125
|
+
break;
|
|
126
|
+
case LightType.Point:
|
|
127
|
+
this._type = "point";
|
|
128
|
+
break;
|
|
129
|
+
case LightType.Spot:
|
|
130
|
+
this._type = "spot";
|
|
131
|
+
break;
|
|
132
|
+
case "directional":
|
|
133
|
+
case "point":
|
|
134
|
+
case "spot":
|
|
135
|
+
this._type = value;
|
|
136
|
+
break;
|
|
137
|
+
default:
|
|
138
|
+
if (debug || isDevEnvironment())
|
|
139
|
+
console.warn(`[Light] Unsupported light type: ${LightType[value]} (${value}) on '${this.name}'`);
|
|
140
|
+
this._type = "unsupported" as any;
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
private _type: ILight["type"] = "point";
|
|
145
|
+
|
|
114
146
|
|
|
115
147
|
/**
|
|
116
148
|
* The maximum distance the light affects.
|
|
@@ -345,7 +377,7 @@ export class Light extends Behaviour implements ILight {
|
|
|
345
377
|
*/
|
|
346
378
|
public getWorldPosition(vec: Vector3): Vector3 {
|
|
347
379
|
if (this.light) {
|
|
348
|
-
if (this.type ===
|
|
380
|
+
if (this.type === "directional") {
|
|
349
381
|
return this.light.getWorldPosition(vec).multiplyScalar(1);
|
|
350
382
|
}
|
|
351
383
|
return this.light.getWorldPosition(vec);
|
|
@@ -372,12 +404,13 @@ export class Light extends Behaviour implements ILight {
|
|
|
372
404
|
else if (this.light.parent !== this.gameObject)
|
|
373
405
|
this.gameObject.add(this.light);
|
|
374
406
|
}
|
|
375
|
-
|
|
376
|
-
this.startCoroutine(this.updateMainLightRoutine(), FrameEvent.LateUpdate);
|
|
407
|
+
this.context.lights.push(this);
|
|
377
408
|
}
|
|
378
409
|
|
|
379
410
|
onDisable() {
|
|
380
411
|
if (debug) console.log("DISABLE LIGHT", this.name);
|
|
412
|
+
const index = this.context.lights.indexOf(this);
|
|
413
|
+
if (index !== -1) this.context.lights.splice(index, 1);
|
|
381
414
|
if (this.light) {
|
|
382
415
|
if (this.selfIsLight)
|
|
383
416
|
this.light.intensity = 0;
|
|
@@ -399,14 +432,14 @@ export class Light extends Behaviour implements ILight {
|
|
|
399
432
|
this._intensity = this.light.intensity;
|
|
400
433
|
|
|
401
434
|
switch (this.type) {
|
|
402
|
-
case
|
|
435
|
+
case "directional":
|
|
403
436
|
this.setDirectionalLight(this.light as DirectionalLight);
|
|
404
437
|
break;
|
|
405
438
|
}
|
|
406
439
|
}
|
|
407
440
|
else if (!this.light) {
|
|
408
441
|
switch (this.type) {
|
|
409
|
-
case
|
|
442
|
+
case "directional":
|
|
410
443
|
// console.log(this);
|
|
411
444
|
const dirLight = new DirectionalLight(this.color, this.intensity * Math.PI);
|
|
412
445
|
// directional light target is at 0 0 0 by default
|
|
@@ -425,7 +458,7 @@ export class Light extends Behaviour implements ILight {
|
|
|
425
458
|
}
|
|
426
459
|
break;
|
|
427
460
|
|
|
428
|
-
case
|
|
461
|
+
case "spot":
|
|
429
462
|
const spotLight = new SpotLight(this.color, this.intensity * Math.PI, this.range, toRadians(this.spotAngle / 2), 1 - toRadians(this.innerSpotAngle / 2) / toRadians(this.spotAngle / 2), 2);
|
|
430
463
|
spotLight.position.set(0, 0, 0);
|
|
431
464
|
spotLight.rotation.set(0, 0, 0);
|
|
@@ -437,13 +470,18 @@ export class Light extends Behaviour implements ILight {
|
|
|
437
470
|
spotLightTarget.rotation.set(0, 0, 0);
|
|
438
471
|
break;
|
|
439
472
|
|
|
440
|
-
case
|
|
473
|
+
case "point":
|
|
441
474
|
const pointLight = new PointLight(this.color, this.intensity * Math.PI, this.range);
|
|
442
475
|
this.light = pointLight;
|
|
443
476
|
|
|
444
477
|
// const pointHelper = new PointLightHelper(pointLight, this.range, this.color);
|
|
445
478
|
// scene.add(pointHelper);
|
|
446
479
|
break;
|
|
480
|
+
|
|
481
|
+
default:
|
|
482
|
+
if (debug) console.warn(`[Light] Unsupported light type: ${LightType[this.type as any]} (${this.type}) on '${this.name}'`);
|
|
483
|
+
break;
|
|
484
|
+
|
|
447
485
|
}
|
|
448
486
|
}
|
|
449
487
|
|
|
@@ -526,22 +564,6 @@ export class Light extends Behaviour implements ILight {
|
|
|
526
564
|
|
|
527
565
|
}
|
|
528
566
|
|
|
529
|
-
/**
|
|
530
|
-
* Coroutine that updates the main light reference in the context
|
|
531
|
-
* if this directional light should be the main light
|
|
532
|
-
*/
|
|
533
|
-
*updateMainLightRoutine() {
|
|
534
|
-
while (true) {
|
|
535
|
-
if (this.type === LightType.Directional) {
|
|
536
|
-
if (!this.context.mainLight || this.intensity > this.context.mainLight.intensity) {
|
|
537
|
-
this.context.mainLight = this;
|
|
538
|
-
}
|
|
539
|
-
yield;
|
|
540
|
-
}
|
|
541
|
-
break;
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
|
|
545
567
|
/**
|
|
546
568
|
* Controls whether the renderer's shadow map type can be changed when soft shadows are used
|
|
547
569
|
*/
|
|
@@ -37,7 +37,7 @@ const debug = getParam("debugnet");
|
|
|
37
37
|
* @see {@link RoomEvents} for room lifecycle events
|
|
38
38
|
* @see {@link isLocalNetwork} for local network detection
|
|
39
39
|
* @link https://engine.needle.tools/docs/how-to-guides/networking/
|
|
40
|
-
* @summary
|
|
40
|
+
* @summary Configures the websocket server URL for multiplayer networking
|
|
41
41
|
* @category Networking
|
|
42
42
|
* @group Components
|
|
43
43
|
*/
|
|
@@ -582,7 +582,7 @@ export class OrbitControls extends Behaviour implements ICameraController {
|
|
|
582
582
|
};
|
|
583
583
|
|
|
584
584
|
private _onPointerUpLate = (evt: NEPointerEvent) => {
|
|
585
|
-
if (this.doubleClickToFocus && evt.isDoubleClick && !evt.used) {
|
|
585
|
+
if (this.doubleClickToFocus && evt.isDoubleClick && !evt.used && this.canFocusAtPointer()) {
|
|
586
586
|
this.setTargetFromRaycast();
|
|
587
587
|
}
|
|
588
588
|
// Automatically update the camera focus
|
|
@@ -663,7 +663,15 @@ export class OrbitControls extends Behaviour implements ICameraController {
|
|
|
663
663
|
}
|
|
664
664
|
this._controls.enabled = true;
|
|
665
665
|
|
|
666
|
-
|
|
666
|
+
// Interrupt programmatic transitions on meaningful new user interaction:
|
|
667
|
+
// - Middle/right button down (always intentional camera control)
|
|
668
|
+
// - Mouse wheel (zoom intent)
|
|
669
|
+
// - Left button drag start: getPointerDown(0) with a position delta — a bare click
|
|
670
|
+
// without movement shouldn't cancel an animation, but starting to drag should.
|
|
671
|
+
// Using getPointerDown (not getPointerPressed) ensures we only interrupt once at
|
|
672
|
+
// drag onset, not continuously every frame during a drag.
|
|
673
|
+
const leftDragStart = this.context.input.getPointerDown(0) && (this.context.input.getPointerPositionDelta(0)?.length() || 0) > .1;
|
|
674
|
+
if (this.context.input.getPointerDown(1) || this.context.input.getPointerDown(2) || this.context.input.mouseWheelChanged || leftDragStart) {
|
|
667
675
|
this._inputs += 1;
|
|
668
676
|
}
|
|
669
677
|
if (this._inputs > 0 && this.allowInterrupt) {
|
|
@@ -708,7 +716,7 @@ export class OrbitControls extends Behaviour implements ICameraController {
|
|
|
708
716
|
}
|
|
709
717
|
}
|
|
710
718
|
|
|
711
|
-
const focusAtPointer = (this.middleClickToFocus && this.context.input.getPointerClicked(1));
|
|
719
|
+
const focusAtPointer = (this.middleClickToFocus && this.context.input.getPointerClicked(1) && this.canFocusAtPointer());
|
|
712
720
|
if (focusAtPointer) {
|
|
713
721
|
this.setTargetFromRaycast();
|
|
714
722
|
}
|
|
@@ -758,19 +766,26 @@ export class OrbitControls extends Behaviour implements ICameraController {
|
|
|
758
766
|
|
|
759
767
|
if (this.targetBounds) {
|
|
760
768
|
// #region target bounds
|
|
761
|
-
const targetVector = this._controls.target;
|
|
762
769
|
const boundsCenter = this.targetBounds.worldPosition;
|
|
763
770
|
const boundsHalfSize = getTempVector(this.targetBounds.worldScale).multiplyScalar(0.5);
|
|
764
771
|
const min = getTempVector(boundsCenter).sub(boundsHalfSize);
|
|
765
772
|
const max = getTempVector(boundsCenter).add(boundsHalfSize);
|
|
766
|
-
|
|
767
|
-
const duration = .1;
|
|
768
|
-
if (duration <= 0) targetVector.copy(newTarget);
|
|
769
|
-
else targetVector.lerp(newTarget, this.context.time.deltaTime / duration);
|
|
773
|
+
|
|
770
774
|
if (this._lookTargetLerpActive) {
|
|
771
|
-
|
|
772
|
-
|
|
775
|
+
// During a programmatic transition (fitCamera / setLookTargetPosition with immediate: false),
|
|
776
|
+
// only clamp the destination. The look-target lerp (above) handles moving _controls.target
|
|
777
|
+
// towards the endpoint — we must not fight it by also lerping _controls.target here.
|
|
778
|
+
this._lookTargetEndPosition.clamp(min, max);
|
|
779
|
+
}
|
|
780
|
+
else {
|
|
781
|
+
// Interactive use (pan/orbit): smoothly push the target back into bounds
|
|
782
|
+
const targetVector = this._controls.target;
|
|
783
|
+
const newTarget = getTempVector(targetVector).clamp(min, max);
|
|
784
|
+
const duration = .1;
|
|
785
|
+
if (duration <= 0) targetVector.copy(newTarget);
|
|
786
|
+
else targetVector.lerp(newTarget, Math.min(1, this.context.time.deltaTime / duration));
|
|
773
787
|
}
|
|
788
|
+
|
|
774
789
|
if (debug) {
|
|
775
790
|
Gizmos.DrawWireBox(boundsCenter, boundsHalfSize.multiplyScalar(2), 0xffaa00);
|
|
776
791
|
}
|
|
@@ -847,7 +862,8 @@ export class OrbitControls extends Behaviour implements ICameraController {
|
|
|
847
862
|
this._controls.update(this.context.time.deltaTime);
|
|
848
863
|
|
|
849
864
|
if (debug) {
|
|
850
|
-
|
|
865
|
+
const distance = this._controls.getDistance();
|
|
866
|
+
Gizmos.DrawWireSphere(this._controls.target, 0.01 * distance, 0x00ff00);
|
|
851
867
|
}
|
|
852
868
|
}
|
|
853
869
|
}
|
|
@@ -1022,7 +1038,8 @@ export class OrbitControls extends Behaviour implements ICameraController {
|
|
|
1022
1038
|
|
|
1023
1039
|
if (debug) {
|
|
1024
1040
|
console.warn("OrbitControls: setLookTargetPosition", position, immediateOrDuration);
|
|
1025
|
-
|
|
1041
|
+
const distance = this._controls.getDistance();
|
|
1042
|
+
Gizmos.DrawWireSphere(this._lookTargetEndPosition, 0.01 * distance, 0xff5500, 2);
|
|
1026
1043
|
}
|
|
1027
1044
|
|
|
1028
1045
|
if (immediateOrDuration === true) {
|
|
@@ -1063,6 +1080,12 @@ export class OrbitControls extends Behaviour implements ICameraController {
|
|
|
1063
1080
|
if (this.lookAtTarget && this.lockLookAtTarget) this.lookAtTarget.worldPosition = this._controls.target;
|
|
1064
1081
|
}
|
|
1065
1082
|
|
|
1083
|
+
private canFocusAtPointer(): boolean {
|
|
1084
|
+
// A locked lookAtTarget is the authoritative orbit center. Pointer focus would
|
|
1085
|
+
// otherwise move the assigned scene object via lerpLookTarget's back-sync.
|
|
1086
|
+
return !(this.lookAtTarget && this.lockLookAtTarget);
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1066
1089
|
private setTargetFromRaycast(ray?: Ray, immediateOrDuration: number | boolean = false): boolean {
|
|
1067
1090
|
if (!this.controls) return false;
|
|
1068
1091
|
const rc = ray ? this.context.physics.raycastFromRay(ray) : this.context.physics.raycast();
|
|
@@ -1086,13 +1109,16 @@ export class OrbitControls extends Behaviour implements ICameraController {
|
|
|
1086
1109
|
// Adapted from https://discourse.threejs.org/t/camera-zoom-to-fit-object/936/24
|
|
1087
1110
|
// Slower but better implementation that takes bones and exact vertex positions into account: https://github.com/google/model-viewer/blob/04e900c5027de8c5306fe1fe9627707f42811b05/packages/model-viewer/src/three-components/ModelScene.ts#L321
|
|
1088
1111
|
|
|
1089
|
-
/**
|
|
1090
|
-
* Fits the camera to show the objects provided (defaults to the scene if no objects are passed in)
|
|
1112
|
+
/**
|
|
1113
|
+
* Fits the camera to show the objects provided (defaults to the scene if no objects are passed in)
|
|
1091
1114
|
* @param options The options for fitting the camera. Use to provide objects to fit to, fit direction and size and other settings.
|
|
1092
1115
|
*/
|
|
1093
1116
|
fitCamera(options?: OrbitFitCameraOptions);
|
|
1094
|
-
|
|
1095
|
-
|
|
1117
|
+
// Deprecated overload commented out: it accepted Object3D as first arg, which caused
|
|
1118
|
+
// TypeScript autocomplete to show Object3D properties (position, worldPosition, etc.)
|
|
1119
|
+
// instead of OrbitFitCameraOptions. The implementation still handles Object3D at runtime
|
|
1120
|
+
// for backwards-compat — use fitCamera({ objects: [...] }) instead.
|
|
1121
|
+
// fitCamera(objects?: Object3D | Array<Object3D>, options?: Omit<OrbitFitCameraOptions, "objects">);
|
|
1096
1122
|
fitCamera(objectsOrOptions?: Object3D | Array<Object3D> | OrbitFitCameraOptions, options?: OrbitFitCameraOptions): void {
|
|
1097
1123
|
|
|
1098
1124
|
|
|
@@ -290,6 +290,8 @@ export class ReflectionProbe extends Behaviour {
|
|
|
290
290
|
const current = block.getOverride("envMap")?.value;
|
|
291
291
|
if (current === this.texture) {
|
|
292
292
|
block.removeOveride("envMap");
|
|
293
|
+
block.removeOveride("envMapRotation");
|
|
294
|
+
block.removeOveride("envMapIntensity");
|
|
293
295
|
}
|
|
294
296
|
}
|
|
295
297
|
}
|
|
@@ -204,12 +204,19 @@ export class Rigidbody extends Behaviour implements IRigidbody {
|
|
|
204
204
|
|
|
205
205
|
get isRigidbody() { return true; }
|
|
206
206
|
|
|
207
|
-
/** When true the mass
|
|
207
|
+
/** When true the mass is automatically computed from the attached colliders using `mass = density × volume`.
|
|
208
|
+
* Each collider's {@link Collider.density} determines how heavy it contributes to the total mass.
|
|
209
|
+
* Disable to set mass explicitly via the `mass` property.
|
|
210
|
+
*/
|
|
208
211
|
@validate()
|
|
209
212
|
autoMass: boolean = true;
|
|
210
213
|
|
|
211
|
-
/**
|
|
212
|
-
*
|
|
214
|
+
/** The mass of the rigidbody in kg (when `autoMass` is disabled).
|
|
215
|
+
* When `autoMass` is enabled, reading this returns the computed mass from `density × volume` of all attached colliders.
|
|
216
|
+
* Setting this property automatically disables `autoMass`.
|
|
217
|
+
*
|
|
218
|
+
* **Prefer using {@link Collider.density}** with `autoMass` enabled instead — density scales
|
|
219
|
+
* naturally with collider size, while explicit mass stays fixed regardless of shape changes.
|
|
213
220
|
*/
|
|
214
221
|
@serializable()
|
|
215
222
|
set mass(value: number) {
|
|
@@ -403,9 +410,16 @@ export class Rigidbody extends Behaviour implements IRigidbody {
|
|
|
403
410
|
this.context.physics.engine?.removeBody(this);
|
|
404
411
|
}
|
|
405
412
|
|
|
406
|
-
onValidate() {
|
|
413
|
+
onValidate(property?: string) {
|
|
407
414
|
this._propertiesChanged = true;
|
|
415
|
+
if (property === "autoMass" && !this.autoMass) {
|
|
416
|
+
if (isDevEnvironment() && !Rigidbody._didWarnAutoMass) {
|
|
417
|
+
Rigidbody._didWarnAutoMass = true;
|
|
418
|
+
console.warn("[Rigidbody] autoMass disabled — consider using Collider.density instead of setting mass explicitly. Density scales naturally with collider size.");
|
|
419
|
+
}
|
|
420
|
+
}
|
|
408
421
|
}
|
|
422
|
+
private static _didWarnAutoMass = false;
|
|
409
423
|
|
|
410
424
|
// need to do this right before updating physics to prevent rendered object glitching through physical bodies
|
|
411
425
|
* beforePhysics() {
|
|
@@ -747,6 +747,9 @@ export class SceneSwitcher extends Behaviour {
|
|
|
747
747
|
const openedEvt = new CustomEvent<LoadSceneEvent>("scene-opened", { detail: { scene: scene, switcher: this, index: index } });
|
|
748
748
|
this.dispatchEvent(openedEvt);
|
|
749
749
|
this.sceneLoaded?.invoke(this);
|
|
750
|
+
if (this._currentSceneAsset) {
|
|
751
|
+
this.context.events.emit("scene-content-changed", { source: this, object: this._currentSceneAsset });
|
|
752
|
+
}
|
|
750
753
|
return true;
|
|
751
754
|
}
|
|
752
755
|
}
|
|
@@ -249,10 +249,10 @@ export class SeeThrough extends Behaviour {
|
|
|
249
249
|
}
|
|
250
250
|
|
|
251
251
|
const materials = renderer.sharedMaterials;// : this.rendererMaterials.get(renderer);
|
|
252
|
-
if (!materials) return;
|
|
252
|
+
if (!materials?.length) return;
|
|
253
253
|
|
|
254
254
|
const block = MaterialPropertyBlock.get(renderer.gameObject);
|
|
255
|
-
const currentOpacity = (block.getOverride("opacity")?.value ?? materials[0]
|
|
255
|
+
const currentOpacity = (block.getOverride("opacity")?.value ?? materials[0]?.opacity ?? 1);
|
|
256
256
|
|
|
257
257
|
let newAlpha = Mathf.lerp(currentOpacity, targetAlpha, duration <= 0 ? 1 : this.context.time.deltaTime / duration);;
|
|
258
258
|
if (newAlpha >= 0.99) newAlpha = 1;
|
|
@@ -207,16 +207,13 @@ export class VideoPlayer extends Behaviour {
|
|
|
207
207
|
*/
|
|
208
208
|
get isPlaying(): boolean {
|
|
209
209
|
const video = this._videoElement;
|
|
210
|
-
if (video)
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
const stream = video.srcObject as MediaStream;
|
|
216
|
-
if (stream.active) return true;
|
|
217
|
-
}
|
|
210
|
+
if (!video) return false;
|
|
211
|
+
if (video.paused || video.ended) return false;
|
|
212
|
+
if (video.srcObject) {
|
|
213
|
+
const stream = video.srcObject as MediaStream;
|
|
214
|
+
return stream.active;
|
|
218
215
|
}
|
|
219
|
-
return
|
|
216
|
+
return video.currentTime > 0 && video.readyState > video.HAVE_CURRENT_DATA;
|
|
220
217
|
}
|
|
221
218
|
|
|
222
219
|
get crossOrigin(): string | null {
|
|
@@ -430,26 +427,52 @@ export class VideoPlayer extends Behaviour {
|
|
|
430
427
|
|
|
431
428
|
private _playErrors: number = 0;
|
|
432
429
|
|
|
433
|
-
/**
|
|
434
|
-
|
|
430
|
+
/**
|
|
431
|
+
* Plays the assigned video clip, URL, or MediaStream.
|
|
432
|
+
* If a `clip` argument is passed, it is used as the new video source (mirroring {@link AudioSource.play}).
|
|
433
|
+
*
|
|
434
|
+
* @param clip - Optional video URL string or {@link MediaStream} to play. If omitted, plays the currently assigned source.
|
|
435
|
+
* @returns A promise that resolves to `true` when playback was successfully started, or `false` on error.
|
|
436
|
+
*/
|
|
437
|
+
async play(clip?: string | MediaStream): Promise<boolean> {
|
|
438
|
+
// Defensive: if called from an event handler with a non-string/non-MediaStream argument
|
|
439
|
+
// (e.g. SpatialTrigger.onEnter passes a receiver object), ignore the arg and fall back to the assigned source.
|
|
440
|
+
// Same pattern as AudioSource.play.
|
|
441
|
+
if (clip !== undefined && typeof clip !== "string" && !(clip instanceof MediaStream)) {
|
|
442
|
+
if (isDevEnvironment()) console.warn("[VideoPlayer] Called play with unknown argument type. Using assigned source instead.", clip);
|
|
443
|
+
clip = undefined;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
if (typeof clip === "string") {
|
|
447
|
+
this.setClipURL(clip);
|
|
448
|
+
}
|
|
449
|
+
else if (clip instanceof MediaStream) {
|
|
450
|
+
this.setVideo(clip);
|
|
451
|
+
}
|
|
452
|
+
|
|
435
453
|
if (!this._videoElement) this.create(false);
|
|
436
454
|
if (!this._videoElement) {
|
|
437
455
|
if (debug) console.warn("Can not play: no video element found", this);
|
|
438
|
-
return
|
|
456
|
+
return false;
|
|
439
457
|
}
|
|
440
|
-
if (this._isPlaying && !this._videoElement?.ended && !this._videoElement?.paused) return;
|
|
458
|
+
if (this._isPlaying && !this._videoElement?.ended && !this._videoElement?.paused) return true;
|
|
441
459
|
this._isPlaying = true;
|
|
442
460
|
if (!this._receivedInput) this._videoElement.muted = true;
|
|
443
461
|
this.handleBeginPlaying(false);
|
|
444
462
|
|
|
445
463
|
if (this.shouldUseM3U) {
|
|
446
464
|
this.ensureM3UCanBePlayed();
|
|
447
|
-
return;
|
|
465
|
+
return true;
|
|
448
466
|
}
|
|
449
467
|
|
|
450
468
|
if (debug) console.log("Video Play()", this.clip, this._videoElement, this.time);
|
|
451
469
|
this._videoElement.currentTime = this.time;
|
|
452
|
-
|
|
470
|
+
try {
|
|
471
|
+
await this._videoElement.play();
|
|
472
|
+
if (debug) console.log("play", this._videoElement, this.time);
|
|
473
|
+
return true;
|
|
474
|
+
}
|
|
475
|
+
catch (err: any) {
|
|
453
476
|
if (this._playErrors++ < 10) console.error(err);
|
|
454
477
|
else if (this._playErrors === 10) console.error("Multiple errors playing video, further errors will be suppressed. Use 'debugvideo' param to see all errors.");
|
|
455
478
|
// https://developer.chrome.com/blog/play-request-was-interrupted/
|
|
@@ -459,8 +482,8 @@ export class VideoPlayer extends Behaviour {
|
|
|
459
482
|
if (this._isPlaying && !this.destroyed && this.activeAndEnabled)
|
|
460
483
|
this.play();
|
|
461
484
|
}, 1000);
|
|
462
|
-
|
|
463
|
-
|
|
485
|
+
return false;
|
|
486
|
+
}
|
|
464
487
|
}
|
|
465
488
|
|
|
466
489
|
/**
|