@needle-tools/engine 2.24.0-pre
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 +568 -0
- package/LICENSE.md +10 -0
- package/README.md +11 -0
- package/dist/needle-engine.d.ts +5011 -0
- package/dist/needle-engine.js +6605 -0
- package/dist/needle-engine.js.map +7 -0
- package/dist/needle-engine.min.js +167 -0
- package/dist/needle-engine.min.js.map +7 -0
- package/lib/engine/debug/error_overlay.d.ts +1 -0
- package/lib/engine/debug/error_overlay.js +110 -0
- package/lib/engine/debug/error_overlay.js.map +1 -0
- package/lib/engine/engine.d.ts +27 -0
- package/lib/engine/engine.js +13 -0
- package/lib/engine/engine.js.map +1 -0
- package/lib/engine/engine_addressables.d.ts +46 -0
- package/lib/engine/engine_addressables.js +264 -0
- package/lib/engine/engine_addressables.js.map +1 -0
- package/lib/engine/engine_application.d.ts +13 -0
- package/lib/engine/engine_application.js +35 -0
- package/lib/engine/engine_application.js.map +1 -0
- package/lib/engine/engine_assetdatabase.d.ts +54 -0
- package/lib/engine/engine_assetdatabase.js +150 -0
- package/lib/engine/engine_assetdatabase.js.map +1 -0
- package/lib/engine/engine_caching.d.ts +0 -0
- package/lib/engine/engine_caching.js +2 -0
- package/lib/engine/engine_caching.js.map +1 -0
- package/lib/engine/engine_constants.d.ts +2 -0
- package/lib/engine/engine_constants.js +3 -0
- package/lib/engine/engine_constants.js.map +1 -0
- package/lib/engine/engine_coroutine.d.ts +3 -0
- package/lib/engine/engine_coroutine.js +14 -0
- package/lib/engine/engine_coroutine.js.map +1 -0
- package/lib/engine/engine_default_parameters.d.ts +2 -0
- package/lib/engine/engine_default_parameters.js +4 -0
- package/lib/engine/engine_default_parameters.js.map +1 -0
- package/lib/engine/engine_element.d.ts +32 -0
- package/lib/engine/engine_element.js +340 -0
- package/lib/engine/engine_element.js.map +1 -0
- package/lib/engine/engine_element_loading.d.ts +31 -0
- package/lib/engine/engine_element_loading.js +154 -0
- package/lib/engine/engine_element_loading.js.map +1 -0
- package/lib/engine/engine_element_overlay.d.ts +17 -0
- package/lib/engine/engine_element_overlay.js +95 -0
- package/lib/engine/engine_element_overlay.js.map +1 -0
- package/lib/engine/engine_gizmos.d.ts +2 -0
- package/lib/engine/engine_gizmos.js +14 -0
- package/lib/engine/engine_gizmos.js.map +1 -0
- package/lib/engine/engine_gltf.d.ts +2 -0
- package/lib/engine/engine_gltf.js +2 -0
- package/lib/engine/engine_gltf.js.map +1 -0
- package/lib/engine/engine_gltf_builtin_components.d.ts +8 -0
- package/lib/engine/engine_gltf_builtin_components.js +251 -0
- package/lib/engine/engine_gltf_builtin_components.js.map +1 -0
- package/lib/engine/engine_input.d.ts +193 -0
- package/lib/engine/engine_input.js +566 -0
- package/lib/engine/engine_input.js.map +1 -0
- package/lib/engine/engine_input_utils.d.ts +2 -0
- package/lib/engine/engine_input_utils.js +23 -0
- package/lib/engine/engine_input_utils.js.map +1 -0
- package/lib/engine/engine_lightdata.d.ts +21 -0
- package/lib/engine/engine_lightdata.js +85 -0
- package/lib/engine/engine_lightdata.js.map +1 -0
- package/lib/engine/engine_loaders.d.ts +3 -0
- package/lib/engine/engine_loaders.js +20 -0
- package/lib/engine/engine_loaders.js.map +1 -0
- package/lib/engine/engine_mainloop_utils.d.ts +9 -0
- package/lib/engine/engine_mainloop_utils.js +288 -0
- package/lib/engine/engine_mainloop_utils.js.map +1 -0
- package/lib/engine/engine_math.d.ts +11 -0
- package/lib/engine/engine_math.js +40 -0
- package/lib/engine/engine_math.js.map +1 -0
- package/lib/engine/engine_networking.d.ts +133 -0
- package/lib/engine/engine_networking.js +541 -0
- package/lib/engine/engine_networking.js.map +1 -0
- package/lib/engine/engine_networking_auto.d.ts +18 -0
- package/lib/engine/engine_networking_auto.js +252 -0
- package/lib/engine/engine_networking_auto.js.map +1 -0
- package/lib/engine/engine_networking_files.d.ts +23 -0
- package/lib/engine/engine_networking_files.js +173 -0
- package/lib/engine/engine_networking_files.js.map +1 -0
- package/lib/engine/engine_networking_files_default_components.d.ts +3 -0
- package/lib/engine/engine_networking_files_default_components.js +45 -0
- package/lib/engine/engine_networking_files_default_components.js.map +1 -0
- package/lib/engine/engine_networking_instantiate.d.ts +34 -0
- package/lib/engine/engine_networking_instantiate.js +274 -0
- package/lib/engine/engine_networking_instantiate.js.map +1 -0
- package/lib/engine/engine_networking_peer.d.ts +10 -0
- package/lib/engine/engine_networking_peer.js +106 -0
- package/lib/engine/engine_networking_peer.js.map +1 -0
- package/lib/engine/engine_networking_utils.d.ts +1 -0
- package/lib/engine/engine_networking_utils.js +11 -0
- package/lib/engine/engine_networking_utils.js.map +1 -0
- package/lib/engine/engine_networking_websocket.d.ts +0 -0
- package/lib/engine/engine_networking_websocket.js +3 -0
- package/lib/engine/engine_networking_websocket.js.map +1 -0
- package/lib/engine/engine_physics.d.ts +88 -0
- package/lib/engine/engine_physics.js +563 -0
- package/lib/engine/engine_physics.js.map +1 -0
- package/lib/engine/engine_rendererdata.d.ts +48 -0
- package/lib/engine/engine_rendererdata.js +182 -0
- package/lib/engine/engine_rendererdata.js.map +1 -0
- package/lib/engine/engine_scenetools.d.ts +25 -0
- package/lib/engine/engine_scenetools.js +211 -0
- package/lib/engine/engine_scenetools.js.map +1 -0
- package/lib/engine/engine_serialization.d.ts +3 -0
- package/lib/engine/engine_serialization.js +5 -0
- package/lib/engine/engine_serialization.js.map +1 -0
- package/lib/engine/engine_serialization_builtin_serializer.d.ts +49 -0
- package/lib/engine/engine_serialization_builtin_serializer.js +238 -0
- package/lib/engine/engine_serialization_builtin_serializer.js.map +1 -0
- package/lib/engine/engine_serialization_core.d.ts +70 -0
- package/lib/engine/engine_serialization_core.js +417 -0
- package/lib/engine/engine_serialization_core.js.map +1 -0
- package/lib/engine/engine_serialization_decorator.d.ts +9 -0
- package/lib/engine/engine_serialization_decorator.js +44 -0
- package/lib/engine/engine_serialization_decorator.js.map +1 -0
- package/lib/engine/engine_setup.d.ts +129 -0
- package/lib/engine/engine_setup.js +609 -0
- package/lib/engine/engine_setup.js.map +1 -0
- package/lib/engine/engine_shaders.d.ts +31 -0
- package/lib/engine/engine_shaders.js +230 -0
- package/lib/engine/engine_shaders.js.map +1 -0
- package/lib/engine/engine_three_utils.d.ts +20 -0
- package/lib/engine/engine_three_utils.js +247 -0
- package/lib/engine/engine_three_utils.js.map +1 -0
- package/lib/engine/engine_time.d.ts +13 -0
- package/lib/engine/engine_time.js +31 -0
- package/lib/engine/engine_time.js.map +1 -0
- package/lib/engine/engine_typestore.d.ts +7 -0
- package/lib/engine/engine_typestore.js +17 -0
- package/lib/engine/engine_typestore.js.map +1 -0
- package/lib/engine/engine_utils.d.ts +34 -0
- package/lib/engine/engine_utils.js +239 -0
- package/lib/engine/engine_utils.js.map +1 -0
- package/lib/engine/engine_web_api.d.ts +12 -0
- package/lib/engine/engine_web_api.js +114 -0
- package/lib/engine/engine_web_api.js.map +1 -0
- package/lib/engine/extensions/KHR_animation_pointer.d.ts +0 -0
- package/lib/engine/extensions/KHR_animation_pointer.js +385 -0
- package/lib/engine/extensions/KHR_animation_pointer.js.map +1 -0
- package/lib/engine/extensions/NEEDLE_animator_controller.d.ts +0 -0
- package/lib/engine/extensions/NEEDLE_animator_controller.js +59 -0
- package/lib/engine/extensions/NEEDLE_animator_controller.js.map +1 -0
- package/lib/engine/extensions/NEEDLE_animator_controller_model.d.ts +108 -0
- package/lib/engine/extensions/NEEDLE_animator_controller_model.js +92 -0
- package/lib/engine/extensions/NEEDLE_animator_controller_model.js.map +1 -0
- package/lib/engine/extensions/NEEDLE_components.d.ts +32 -0
- package/lib/engine/extensions/NEEDLE_components.js +193 -0
- package/lib/engine/extensions/NEEDLE_components.js.map +1 -0
- package/lib/engine/extensions/NEEDLE_deferred_texture.d.ts +18 -0
- package/lib/engine/extensions/NEEDLE_deferred_texture.js +149 -0
- package/lib/engine/extensions/NEEDLE_deferred_texture.js.map +1 -0
- package/lib/engine/extensions/NEEDLE_gameobject_data.d.ts +10 -0
- package/lib/engine/extensions/NEEDLE_gameobject_data.js +54 -0
- package/lib/engine/extensions/NEEDLE_gameobject_data.js.map +1 -0
- package/lib/engine/extensions/NEEDLE_lighting_settings.d.ts +35 -0
- package/lib/engine/extensions/NEEDLE_lighting_settings.js +136 -0
- package/lib/engine/extensions/NEEDLE_lighting_settings.js.map +1 -0
- package/lib/engine/extensions/NEEDLE_lightmaps.d.ts +17 -0
- package/lib/engine/extensions/NEEDLE_lightmaps.js +69 -0
- package/lib/engine/extensions/NEEDLE_lightmaps.js.map +1 -0
- package/lib/engine/extensions/NEEDLE_persistent_assets.d.ts +11 -0
- package/lib/engine/extensions/NEEDLE_persistent_assets.js +64 -0
- package/lib/engine/extensions/NEEDLE_persistent_assets.js.map +1 -0
- package/lib/engine/extensions/NEEDLE_render_objects.d.ts +12 -0
- package/lib/engine/extensions/NEEDLE_render_objects.js +144 -0
- package/lib/engine/extensions/NEEDLE_render_objects.js.map +1 -0
- package/lib/engine/extensions/NEEDLE_techniques_webgl.d.ts +39 -0
- package/lib/engine/extensions/NEEDLE_techniques_webgl.js +419 -0
- package/lib/engine/extensions/NEEDLE_techniques_webgl.js.map +1 -0
- package/lib/engine/extensions/NEEDLE_timeline.d.ts +0 -0
- package/lib/engine/extensions/NEEDLE_timeline.js +57 -0
- package/lib/engine/extensions/NEEDLE_timeline.js.map +1 -0
- package/lib/engine/extensions/extension_resolver.d.ts +4 -0
- package/lib/engine/extensions/extension_resolver.js +2 -0
- package/lib/engine/extensions/extension_resolver.js.map +1 -0
- package/lib/engine/extensions/extension_utils.d.ts +2 -0
- package/lib/engine/extensions/extension_utils.js +130 -0
- package/lib/engine/extensions/extension_utils.js.map +1 -0
- package/lib/engine/extensions/extensions.d.ts +6 -0
- package/lib/engine/extensions/extensions.js +41 -0
- package/lib/engine/extensions/extensions.js.map +1 -0
- package/lib/engine/shaders/shaderData.d.ts +55 -0
- package/lib/engine/shaders/shaderData.js +59 -0
- package/lib/engine/shaders/shaderData.js.map +1 -0
- package/lib/engine/tests/simulate_avatars.d.ts +0 -0
- package/lib/engine/tests/simulate_avatars.js +3 -0
- package/lib/engine/tests/simulate_avatars.js.map +1 -0
- package/lib/engine/tests/test_utils.d.ts +2 -0
- package/lib/engine/tests/test_utils.js +54 -0
- package/lib/engine/tests/test_utils.js.map +1 -0
- package/lib/engine-components/AlignmentConstraint.d.ts +10 -0
- package/lib/engine-components/AlignmentConstraint.js +27 -0
- package/lib/engine-components/AlignmentConstraint.js.map +1 -0
- package/lib/engine-components/Animation.d.ts +44 -0
- package/lib/engine-components/Animation.js +257 -0
- package/lib/engine-components/Animation.js.map +1 -0
- package/lib/engine-components/AnimationCurve.d.ts +15 -0
- package/lib/engine-components/AnimationCurve.js +62 -0
- package/lib/engine-components/AnimationCurve.js.map +1 -0
- package/lib/engine-components/Animator.d.ts +48 -0
- package/lib/engine-components/Animator.js +126 -0
- package/lib/engine-components/Animator.js.map +1 -0
- package/lib/engine-components/AnimatorController.d.ts +39 -0
- package/lib/engine-components/AnimatorController.js +687 -0
- package/lib/engine-components/AnimatorController.js.map +1 -0
- package/lib/engine-components/AudioListener.d.ts +7 -0
- package/lib/engine-components/AudioListener.js +29 -0
- package/lib/engine-components/AudioListener.js.map +1 -0
- package/lib/engine-components/AudioSource.d.ts +61 -0
- package/lib/engine-components/AudioSource.js +377 -0
- package/lib/engine-components/AudioSource.js.map +1 -0
- package/lib/engine-components/AvatarLoader.d.ts +22 -0
- package/lib/engine-components/AvatarLoader.js +203 -0
- package/lib/engine-components/AvatarLoader.js.map +1 -0
- package/lib/engine-components/AxesHelper.d.ts +9 -0
- package/lib/engine-components/AxesHelper.js +43 -0
- package/lib/engine-components/AxesHelper.js.map +1 -0
- package/lib/engine-components/BasicIKConstraint.d.ts +9 -0
- package/lib/engine-components/BasicIKConstraint.js +44 -0
- package/lib/engine-components/BasicIKConstraint.js.map +1 -0
- package/lib/engine-components/BoxCollider.d.ts +2 -0
- package/lib/engine-components/BoxCollider.js +3 -0
- package/lib/engine-components/BoxCollider.js.map +1 -0
- package/lib/engine-components/BoxHelperComponent.d.ts +16 -0
- package/lib/engine-components/BoxHelperComponent.js +72 -0
- package/lib/engine-components/BoxHelperComponent.js.map +1 -0
- package/lib/engine-components/Camera.d.ts +38 -0
- package/lib/engine-components/Camera.js +258 -0
- package/lib/engine-components/Camera.js.map +1 -0
- package/lib/engine-components/Collider.d.ts +21 -0
- package/lib/engine-components/Collider.js +65 -0
- package/lib/engine-components/Collider.js.map +1 -0
- package/lib/engine-components/Component.d.ts +165 -0
- package/lib/engine-components/Component.js +895 -0
- package/lib/engine-components/Component.js.map +1 -0
- package/lib/engine-components/ComponentExtensions.d.ts +2 -0
- package/lib/engine-components/ComponentExtensions.js +3 -0
- package/lib/engine-components/ComponentExtensions.js.map +1 -0
- package/lib/engine-components/DeleteBox.d.ts +9 -0
- package/lib/engine-components/DeleteBox.js +27 -0
- package/lib/engine-components/DeleteBox.js.map +1 -0
- package/lib/engine-components/DeviceFlag.d.ts +12 -0
- package/lib/engine-components/DeviceFlag.js +50 -0
- package/lib/engine-components/DeviceFlag.js.map +1 -0
- package/lib/engine-components/DragControls.d.ts +44 -0
- package/lib/engine-components/DragControls.js +465 -0
- package/lib/engine-components/DragControls.js.map +1 -0
- package/lib/engine-components/DropListener.d.ts +15 -0
- package/lib/engine-components/DropListener.js +102 -0
- package/lib/engine-components/DropListener.js.map +1 -0
- package/lib/engine-components/Duplicatable.d.ts +16 -0
- package/lib/engine-components/Duplicatable.js +150 -0
- package/lib/engine-components/Duplicatable.js.map +1 -0
- package/lib/engine-components/EventList.d.ts +22 -0
- package/lib/engine-components/EventList.js +97 -0
- package/lib/engine-components/EventList.js.map +1 -0
- package/lib/engine-components/EventTrigger.d.ts +3 -0
- package/lib/engine-components/EventTrigger.js +4 -0
- package/lib/engine-components/EventTrigger.js.map +1 -0
- package/lib/engine-components/EventType.d.ts +19 -0
- package/lib/engine-components/EventType.js +72 -0
- package/lib/engine-components/EventType.js.map +1 -0
- package/lib/engine-components/FlyControls.d.ts +7 -0
- package/lib/engine-components/FlyControls.js +22 -0
- package/lib/engine-components/FlyControls.js.map +1 -0
- package/lib/engine-components/Gizmos.d.ts +12 -0
- package/lib/engine-components/Gizmos.js +61 -0
- package/lib/engine-components/Gizmos.js.map +1 -0
- package/lib/engine-components/GltfExport.d.ts +28 -0
- package/lib/engine-components/GltfExport.js +201 -0
- package/lib/engine-components/GltfExport.js.map +1 -0
- package/lib/engine-components/GridHelper.d.ts +11 -0
- package/lib/engine-components/GridHelper.js +41 -0
- package/lib/engine-components/GridHelper.js.map +1 -0
- package/lib/engine-components/GroundProjection.d.ts +18 -0
- package/lib/engine-components/GroundProjection.js +77 -0
- package/lib/engine-components/GroundProjection.js.map +1 -0
- package/lib/engine-components/Interactable.d.ts +10 -0
- package/lib/engine-components/Interactable.js +13 -0
- package/lib/engine-components/Interactable.js.map +1 -0
- package/lib/engine-components/LODGroup.d.ts +29 -0
- package/lib/engine-components/LODGroup.js +176 -0
- package/lib/engine-components/LODGroup.js.map +1 -0
- package/lib/engine-components/Light.d.ts +69 -0
- package/lib/engine-components/Light.js +407 -0
- package/lib/engine-components/Light.js.map +1 -0
- package/lib/engine-components/LookAtConstraint.d.ts +7 -0
- package/lib/engine-components/LookAtConstraint.js +18 -0
- package/lib/engine-components/LookAtConstraint.js.map +1 -0
- package/lib/engine-components/MeshCollider.d.ts +4 -0
- package/lib/engine-components/MeshCollider.js +8 -0
- package/lib/engine-components/MeshCollider.js.map +1 -0
- package/lib/engine-components/NavMesh.d.ts +5 -0
- package/lib/engine-components/NavMesh.js +11 -0
- package/lib/engine-components/NavMesh.js.map +1 -0
- package/lib/engine-components/NestedGltf.d.ts +10 -0
- package/lib/engine-components/NestedGltf.js +61 -0
- package/lib/engine-components/NestedGltf.js.map +1 -0
- package/lib/engine-components/Networking.d.ts +9 -0
- package/lib/engine-components/Networking.js +47 -0
- package/lib/engine-components/Networking.js.map +1 -0
- package/lib/engine-components/OffsetConstraint.d.ts +11 -0
- package/lib/engine-components/OffsetConstraint.js +31 -0
- package/lib/engine-components/OffsetConstraint.js.map +1 -0
- package/lib/engine-components/OrbitControls.d.ts +45 -0
- package/lib/engine-components/OrbitControls.js +247 -0
- package/lib/engine-components/OrbitControls.js.map +1 -0
- package/lib/engine-components/ParticleSystem.d.ts +34 -0
- package/lib/engine-components/ParticleSystem.js +216 -0
- package/lib/engine-components/ParticleSystem.js.map +1 -0
- package/lib/engine-components/ParticleSystemModules.d.ts +93 -0
- package/lib/engine-components/ParticleSystemModules.js +167 -0
- package/lib/engine-components/ParticleSystemModules.js.map +1 -0
- package/lib/engine-components/PlayerColor.d.ts +13 -0
- package/lib/engine-components/PlayerColor.js +85 -0
- package/lib/engine-components/PlayerColor.js.map +1 -0
- package/lib/engine-components/Renderer.d.ts +72 -0
- package/lib/engine-components/Renderer.js +678 -0
- package/lib/engine-components/Renderer.js.map +1 -0
- package/lib/engine-components/RendererLightmap.d.ts +23 -0
- package/lib/engine-components/RendererLightmap.js +128 -0
- package/lib/engine-components/RendererLightmap.js.map +1 -0
- package/lib/engine-components/Rigidbody.d.ts +42 -0
- package/lib/engine-components/Rigidbody.js +170 -0
- package/lib/engine-components/Rigidbody.js.map +1 -0
- package/lib/engine-components/ScreenCapture.d.ts +9 -0
- package/lib/engine-components/ScreenCapture.js +44 -0
- package/lib/engine-components/ScreenCapture.js.map +1 -0
- package/lib/engine-components/ShadowCatcher.d.ts +15 -0
- package/lib/engine-components/ShadowCatcher.js +94 -0
- package/lib/engine-components/ShadowCatcher.js.map +1 -0
- package/lib/engine-components/Skybox.d.ts +16 -0
- package/lib/engine-components/Skybox.js +121 -0
- package/lib/engine-components/Skybox.js.map +1 -0
- package/lib/engine-components/SmoothFollow.d.ts +13 -0
- package/lib/engine-components/SmoothFollow.js +57 -0
- package/lib/engine-components/SmoothFollow.js.map +1 -0
- package/lib/engine-components/SpatialTrigger.d.ts +27 -0
- package/lib/engine-components/SpatialTrigger.js +145 -0
- package/lib/engine-components/SpatialTrigger.js.map +1 -0
- package/lib/engine-components/SpectatorCamera.d.ts +36 -0
- package/lib/engine-components/SpectatorCamera.js +311 -0
- package/lib/engine-components/SpectatorCamera.js.map +1 -0
- package/lib/engine-components/SphereCollider.d.ts +2 -0
- package/lib/engine-components/SphereCollider.js +3 -0
- package/lib/engine-components/SphereCollider.js.map +1 -0
- package/lib/engine-components/SpringJoint.d.ts +13 -0
- package/lib/engine-components/SpringJoint.js +42 -0
- package/lib/engine-components/SpringJoint.js.map +1 -0
- package/lib/engine-components/SpriteRenderer.d.ts +33 -0
- package/lib/engine-components/SpriteRenderer.js +141 -0
- package/lib/engine-components/SpriteRenderer.js.map +1 -0
- package/lib/engine-components/SyncedCamera.d.ts +23 -0
- package/lib/engine-components/SyncedCamera.js +188 -0
- package/lib/engine-components/SyncedCamera.js.map +1 -0
- package/lib/engine-components/SyncedRoom.d.ts +20 -0
- package/lib/engine-components/SyncedRoom.js +151 -0
- package/lib/engine-components/SyncedRoom.js.map +1 -0
- package/lib/engine-components/SyncedTransform.d.ts +35 -0
- package/lib/engine-components/SyncedTransform.js +268 -0
- package/lib/engine-components/SyncedTransform.js.map +1 -0
- package/lib/engine-components/TestRunner.d.ts +13 -0
- package/lib/engine-components/TestRunner.js +100 -0
- package/lib/engine-components/TestRunner.js.map +1 -0
- package/lib/engine-components/TransformGizmo.d.ts +15 -0
- package/lib/engine-components/TransformGizmo.js +166 -0
- package/lib/engine-components/TransformGizmo.js.map +1 -0
- package/lib/engine-components/VideoPlayer.d.ts +55 -0
- package/lib/engine-components/VideoPlayer.js +307 -0
- package/lib/engine-components/VideoPlayer.js.map +1 -0
- package/lib/engine-components/Voip.d.ts +22 -0
- package/lib/engine-components/Voip.js +400 -0
- package/lib/engine-components/Voip.js.map +1 -0
- package/lib/engine-components/Volume.d.ts +30 -0
- package/lib/engine-components/Volume.js +86 -0
- package/lib/engine-components/Volume.js.map +1 -0
- package/lib/engine-components/WebARSessionRoot.d.ts +21 -0
- package/lib/engine-components/WebARSessionRoot.js +105 -0
- package/lib/engine-components/WebARSessionRoot.js.map +1 -0
- package/lib/engine-components/WebXR.d.ts +90 -0
- package/lib/engine-components/WebXR.js +498 -0
- package/lib/engine-components/WebXR.js.map +1 -0
- package/lib/engine-components/WebXRAvatar.d.ts +59 -0
- package/lib/engine-components/WebXRAvatar.js +263 -0
- package/lib/engine-components/WebXRAvatar.js.map +1 -0
- package/lib/engine-components/WebXRController.d.ts +145 -0
- package/lib/engine-components/WebXRController.js +924 -0
- package/lib/engine-components/WebXRController.js.map +1 -0
- package/lib/engine-components/WebXRGrabRendering.d.ts +42 -0
- package/lib/engine-components/WebXRGrabRendering.js +138 -0
- package/lib/engine-components/WebXRGrabRendering.js.map +1 -0
- package/lib/engine-components/WebXRRig.d.ts +4 -0
- package/lib/engine-components/WebXRRig.js +8 -0
- package/lib/engine-components/WebXRRig.js.map +1 -0
- package/lib/engine-components/WebXRSync.d.ts +54 -0
- package/lib/engine-components/WebXRSync.js +405 -0
- package/lib/engine-components/WebXRSync.js.map +1 -0
- package/lib/engine-components/XRFlag.d.ts +32 -0
- package/lib/engine-components/XRFlag.js +115 -0
- package/lib/engine-components/XRFlag.js.map +1 -0
- package/lib/engine-components/avatar/AvatarBlink_Simple.d.ts +10 -0
- package/lib/engine-components/avatar/AvatarBlink_Simple.js +76 -0
- package/lib/engine-components/avatar/AvatarBlink_Simple.js.map +1 -0
- package/lib/engine-components/avatar/AvatarEyeLook_Rotation.d.ts +13 -0
- package/lib/engine-components/avatar/AvatarEyeLook_Rotation.js +75 -0
- package/lib/engine-components/avatar/AvatarEyeLook_Rotation.js.map +1 -0
- package/lib/engine-components/avatar/Avatar_Brain_LookAt.d.ts +27 -0
- package/lib/engine-components/avatar/Avatar_Brain_LookAt.js +120 -0
- package/lib/engine-components/avatar/Avatar_Brain_LookAt.js.map +1 -0
- package/lib/engine-components/avatar/Avatar_MouthShapes.d.ts +13 -0
- package/lib/engine-components/avatar/Avatar_MouthShapes.js +77 -0
- package/lib/engine-components/avatar/Avatar_MouthShapes.js.map +1 -0
- package/lib/engine-components/avatar/Avatar_MustacheShake.d.ts +8 -0
- package/lib/engine-components/avatar/Avatar_MustacheShake.js +29 -0
- package/lib/engine-components/avatar/Avatar_MustacheShake.js.map +1 -0
- package/lib/engine-components/codegen/exports.d.ts +140 -0
- package/lib/engine-components/codegen/exports.js +142 -0
- package/lib/engine-components/codegen/exports.js.map +1 -0
- package/lib/engine-components/debug/LogStats.d.ts +5 -0
- package/lib/engine-components/debug/LogStats.js +19 -0
- package/lib/engine-components/debug/LogStats.js.map +1 -0
- package/lib/engine-components/js-extensions/RGBAColor.d.ts +9 -0
- package/lib/engine-components/js-extensions/RGBAColor.js +35 -0
- package/lib/engine-components/js-extensions/RGBAColor.js.map +1 -0
- package/lib/engine-components/timeline/PlayableDirector.d.ts +66 -0
- package/lib/engine-components/timeline/PlayableDirector.js +460 -0
- package/lib/engine-components/timeline/PlayableDirector.js.map +1 -0
- package/lib/engine-components/timeline/SignalAsset.d.ts +19 -0
- package/lib/engine-components/timeline/SignalAsset.js +87 -0
- package/lib/engine-components/timeline/SignalAsset.js.map +1 -0
- package/lib/engine-components/timeline/TimelineModels.d.ts +86 -0
- package/lib/engine-components/timeline/TimelineModels.js +23 -0
- package/lib/engine-components/timeline/TimelineModels.js.map +1 -0
- package/lib/engine-components/timeline/TimelineTracks.d.ts +73 -0
- package/lib/engine-components/timeline/TimelineTracks.js +573 -0
- package/lib/engine-components/timeline/TimelineTracks.js.map +1 -0
- package/lib/engine-components/ui/BaseUIComponent.d.ts +24 -0
- package/lib/engine-components/ui/BaseUIComponent.js +129 -0
- package/lib/engine-components/ui/BaseUIComponent.js.map +1 -0
- package/lib/engine-components/ui/Button.d.ts +55 -0
- package/lib/engine-components/ui/Button.js +217 -0
- package/lib/engine-components/ui/Button.js.map +1 -0
- package/lib/engine-components/ui/Canvas.d.ts +39 -0
- package/lib/engine-components/ui/Canvas.js +169 -0
- package/lib/engine-components/ui/Canvas.js.map +1 -0
- package/lib/engine-components/ui/CanvasGroup.d.ts +14 -0
- package/lib/engine-components/ui/CanvasGroup.js +53 -0
- package/lib/engine-components/ui/CanvasGroup.js.map +1 -0
- package/lib/engine-components/ui/EventSystem.d.ts +44 -0
- package/lib/engine-components/ui/EventSystem.js +480 -0
- package/lib/engine-components/ui/EventSystem.js.map +1 -0
- package/lib/engine-components/ui/Graphic.d.ts +33 -0
- package/lib/engine-components/ui/Graphic.js +145 -0
- package/lib/engine-components/ui/Graphic.js.map +1 -0
- package/lib/engine-components/ui/Image.d.ts +20 -0
- package/lib/engine-components/ui/Image.js +61 -0
- package/lib/engine-components/ui/Image.js.map +1 -0
- package/lib/engine-components/ui/InputField.d.ts +25 -0
- package/lib/engine-components/ui/InputField.js +179 -0
- package/lib/engine-components/ui/InputField.js.map +1 -0
- package/lib/engine-components/ui/Interfaces.d.ts +7 -0
- package/lib/engine-components/ui/Interfaces.js +2 -0
- package/lib/engine-components/ui/Interfaces.js.map +1 -0
- package/lib/engine-components/ui/Keyboard.d.ts +31 -0
- package/lib/engine-components/ui/Keyboard.js +177 -0
- package/lib/engine-components/ui/Keyboard.js.map +1 -0
- package/lib/engine-components/ui/Layout.d.ts +10 -0
- package/lib/engine-components/ui/Layout.js +11 -0
- package/lib/engine-components/ui/Layout.js.map +1 -0
- package/lib/engine-components/ui/PointerEvents.d.ts +35 -0
- package/lib/engine-components/ui/PointerEvents.js +20 -0
- package/lib/engine-components/ui/PointerEvents.js.map +1 -0
- package/lib/engine-components/ui/Raycaster.d.ts +20 -0
- package/lib/engine-components/ui/Raycaster.js +40 -0
- package/lib/engine-components/ui/Raycaster.js.map +1 -0
- package/lib/engine-components/ui/RectTransform.d.ts +39 -0
- package/lib/engine-components/ui/RectTransform.js +173 -0
- package/lib/engine-components/ui/RectTransform.js.map +1 -0
- package/lib/engine-components/ui/SpatialHtml.d.ts +6 -0
- package/lib/engine-components/ui/SpatialHtml.js +58 -0
- package/lib/engine-components/ui/SpatialHtml.js.map +1 -0
- package/lib/engine-components/ui/Text.d.ts +68 -0
- package/lib/engine-components/ui/Text.js +631 -0
- package/lib/engine-components/ui/Text.js.map +1 -0
- package/lib/engine-components/ui/Utils.d.ts +19 -0
- package/lib/engine-components/ui/Utils.js +85 -0
- package/lib/engine-components/ui/Utils.js.map +1 -0
- package/lib/engine-schemes/schemes.d.ts +4 -0
- package/lib/engine-schemes/schemes.js +20 -0
- package/lib/engine-schemes/schemes.js.map +1 -0
- package/lib/engine-schemes/synced-camera-model.d.ts +25 -0
- package/lib/engine-schemes/synced-camera-model.js +68 -0
- package/lib/engine-schemes/synced-camera-model.js.map +1 -0
- package/lib/engine-schemes/synced-transform-model.d.ts +31 -0
- package/lib/engine-schemes/synced-transform-model.js +67 -0
- package/lib/engine-schemes/synced-transform-model.js.map +1 -0
- package/lib/engine-schemes/transform.d.ts +12 -0
- package/lib/engine-schemes/transform.js +40 -0
- package/lib/engine-schemes/transform.js.map +1 -0
- package/lib/engine-schemes/vec3.d.ts +11 -0
- package/lib/engine-schemes/vec3.js +30 -0
- package/lib/engine-schemes/vec3.js.map +1 -0
- package/lib/engine-schemes/vec4.d.ts +12 -0
- package/lib/engine-schemes/vec4.js +34 -0
- package/lib/engine-schemes/vec4.js.map +1 -0
- package/lib/engine-schemes/vr-user-state-buffer.d.ts +36 -0
- package/lib/engine-schemes/vr-user-state-buffer.js +104 -0
- package/lib/engine-schemes/vr-user-state-buffer.js.map +1 -0
- package/lib/needle-engine.d.ts +5 -0
- package/lib/needle-engine.js +34 -0
- package/lib/needle-engine.js.map +1 -0
- package/package.json +63 -0
- package/src/engine/codegen/register_types.js +297 -0
- package/src/engine/debug/error_overlay.ts +122 -0
- package/src/engine/engine.ts +15 -0
- package/src/engine/engine_addressables.ts +297 -0
- package/src/engine/engine_application.ts +42 -0
- package/src/engine/engine_assetdatabase.ts +215 -0
- package/src/engine/engine_caching.ts +0 -0
- package/src/engine/engine_components.js +202 -0
- package/src/engine/engine_constants.ts +3 -0
- package/src/engine/engine_coroutine.ts +16 -0
- package/src/engine/engine_default_parameters.ts +4 -0
- package/src/engine/engine_element.ts +380 -0
- package/src/engine/engine_element_loading.ts +178 -0
- package/src/engine/engine_element_overlay.ts +108 -0
- package/src/engine/engine_fileloader.js +9 -0
- package/src/engine/engine_generic_utils.js +14 -0
- package/src/engine/engine_gizmos.ts +15 -0
- package/src/engine/engine_gltf.ts +4 -0
- package/src/engine/engine_gltf_builtin_components.ts +298 -0
- package/src/engine/engine_input.ts +581 -0
- package/src/engine/engine_input_utils.ts +24 -0
- package/src/engine/engine_lightdata.ts +111 -0
- package/src/engine/engine_loaders.ts +26 -0
- package/src/engine/engine_mainloop_utils.ts +292 -0
- package/src/engine/engine_math.ts +43 -0
- package/src/engine/engine_networking.ts +664 -0
- package/src/engine/engine_networking_auto.ts +300 -0
- package/src/engine/engine_networking_files.ts +198 -0
- package/src/engine/engine_networking_files_default_components.ts +54 -0
- package/src/engine/engine_networking_instantiate.ts +321 -0
- package/src/engine/engine_networking_peer.ts +128 -0
- package/src/engine/engine_networking_utils.ts +12 -0
- package/src/engine/engine_networking_websocket.ts +1 -0
- package/src/engine/engine_physics.ts +652 -0
- package/src/engine/engine_rendererdata.ts +214 -0
- package/src/engine/engine_scenetools.ts +231 -0
- package/src/engine/engine_serialization.ts +4 -0
- package/src/engine/engine_serialization_builtin_serializer.ts +266 -0
- package/src/engine/engine_serialization_core.ts +513 -0
- package/src/engine/engine_serialization_decorator.ts +55 -0
- package/src/engine/engine_setup.ts +705 -0
- package/src/engine/engine_shaders.ts +243 -0
- package/src/engine/engine_three_utils.ts +290 -0
- package/src/engine/engine_time.ts +38 -0
- package/src/engine/engine_typestore.ts +21 -0
- package/src/engine/engine_utils.ts +268 -0
- package/src/engine/engine_web_api.ts +122 -0
- package/src/engine/extensions/EXT_texture_exr.js +42 -0
- package/src/engine/extensions/KHR_animation_pointer.ts +484 -0
- package/src/engine/extensions/NEEDLE_animator_controller.ts +68 -0
- package/src/engine/extensions/NEEDLE_animator_controller_model.ts +185 -0
- package/src/engine/extensions/NEEDLE_components.ts +234 -0
- package/src/engine/extensions/NEEDLE_deferred_texture.ts +175 -0
- package/src/engine/extensions/NEEDLE_gameobject_data.ts +76 -0
- package/src/engine/extensions/NEEDLE_lighting_settings.ts +161 -0
- package/src/engine/extensions/NEEDLE_lightmaps.ts +93 -0
- package/src/engine/extensions/NEEDLE_persistent_assets.ts +76 -0
- package/src/engine/extensions/NEEDLE_render_objects.ts +197 -0
- package/src/engine/extensions/NEEDLE_techniques_webgl.ts +482 -0
- package/src/engine/extensions/NEEDLE_timeline.ts +68 -0
- package/src/engine/extensions/extension_resolver.ts +5 -0
- package/src/engine/extensions/extension_utils.ts +138 -0
- package/src/engine/extensions/extensions.ts +49 -0
- package/src/engine/shaders/shaderData.ts +68 -0
- package/src/engine/tests/simulate_avatars.ts +2 -0
- package/src/engine/tests/test_utils.ts +63 -0
- package/src/engine-components/AlignmentConstraint.ts +33 -0
- package/src/engine-components/Animation.ts +282 -0
- package/src/engine-components/AnimationCurve.ts +42 -0
- package/src/engine-components/Animator.ts +148 -0
- package/src/engine-components/AnimatorController.ts +799 -0
- package/src/engine-components/AudioListener.ts +32 -0
- package/src/engine-components/AudioSource.ts +383 -0
- package/src/engine-components/AvatarLoader.ts +240 -0
- package/src/engine-components/AxesHelper.ts +32 -0
- package/src/engine-components/BasicIKConstraint.ts +54 -0
- package/src/engine-components/BoxCollider.ts +2 -0
- package/src/engine-components/BoxHelperComponent.ts +83 -0
- package/src/engine-components/Camera.ts +261 -0
- package/src/engine-components/Collider.ts +72 -0
- package/src/engine-components/Component.ts +1042 -0
- package/src/engine-components/ComponentExtensions.ts +7 -0
- package/src/engine-components/DeleteBox.ts +34 -0
- package/src/engine-components/DeviceFlag.ts +46 -0
- package/src/engine-components/DragControls.ts +534 -0
- package/src/engine-components/DropListener.ts +101 -0
- package/src/engine-components/Duplicatable.ts +146 -0
- package/src/engine-components/EventList.ts +116 -0
- package/src/engine-components/EventTrigger.ts +28 -0
- package/src/engine-components/EventType.ts +88 -0
- package/src/engine-components/FlyControls.ts +27 -0
- package/src/engine-components/Gizmos.ts +53 -0
- package/src/engine-components/GltfExport.ts +232 -0
- package/src/engine-components/GridHelper.ts +32 -0
- package/src/engine-components/GroundProjection.ts +75 -0
- package/src/engine-components/Interactable.ts +28 -0
- package/src/engine-components/LODGroup.ts +173 -0
- package/src/engine-components/Light.ts +418 -0
- package/src/engine-components/LookAtConstraint.ts +12 -0
- package/src/engine-components/MeshCollider.ts +12 -0
- package/src/engine-components/NavMesh.ts +118 -0
- package/src/engine-components/NestedGltf.ts +56 -0
- package/src/engine-components/Networking.ts +58 -0
- package/src/engine-components/OffsetConstraint.ts +32 -0
- package/src/engine-components/OrbitControls.ts +270 -0
- package/src/engine-components/ParticleSystem.ts +249 -0
- package/src/engine-components/ParticleSystemModules.ts +173 -0
- package/src/engine-components/PlayerColor.ts +93 -0
- package/src/engine-components/Renderer.ts +732 -0
- package/src/engine-components/RendererLightmap.ts +152 -0
- package/src/engine-components/RigidBody.ts +177 -0
- package/src/engine-components/ScreenCapture.ts +47 -0
- package/src/engine-components/ShadowCatcher.ts +93 -0
- package/src/engine-components/Skybox.ts +116 -0
- package/src/engine-components/SmoothFollow.ts +55 -0
- package/src/engine-components/SpatialTrigger.ts +142 -0
- package/src/engine-components/SpectatorCamera.ts +350 -0
- package/src/engine-components/SphereCollider.ts +2 -0
- package/src/engine-components/SpringJoint.ts +45 -0
- package/src/engine-components/SpriteRenderer.ts +143 -0
- package/src/engine-components/SyncedCamera.ts +206 -0
- package/src/engine-components/SyncedRoom.ts +157 -0
- package/src/engine-components/SyncedTransform.ts +339 -0
- package/src/engine-components/TestRunner.ts +116 -0
- package/src/engine-components/TransformGizmo.ts +185 -0
- package/src/engine-components/VideoPlayer.ts +308 -0
- package/src/engine-components/Voip.ts +455 -0
- package/src/engine-components/Volume.ts +86 -0
- package/src/engine-components/WebARSessionRoot.ts +109 -0
- package/src/engine-components/WebXR.ts +586 -0
- package/src/engine-components/WebXRAvatar.ts +326 -0
- package/src/engine-components/WebXRController.ts +1049 -0
- package/src/engine-components/WebXRGrabRendering.ts +151 -0
- package/src/engine-components/WebXRRig.ts +9 -0
- package/src/engine-components/WebXRSync.ts +458 -0
- package/src/engine-components/XRFlag.ts +134 -0
- package/src/engine-components/avatar/AvatarBlink_Simple.ts +68 -0
- package/src/engine-components/avatar/AvatarEyeLook_Rotation.ts +69 -0
- package/src/engine-components/avatar/Avatar_Brain_LookAt.ts +137 -0
- package/src/engine-components/avatar/Avatar_MouthShapes.ts +81 -0
- package/src/engine-components/avatar/Avatar_MustacheShake.ts +29 -0
- package/src/engine-components/codegen/exports.ts +141 -0
- package/src/engine-components/debug/LogStats.ts +22 -0
- package/src/engine-components/js-extensions/RGBAColor.ts +36 -0
- package/src/engine-components/timeline/PlayableDirector.ts +485 -0
- package/src/engine-components/timeline/SignalAsset.ts +108 -0
- package/src/engine-components/timeline/TimelineModels.ts +91 -0
- package/src/engine-components/timeline/TimelineTracks.ts +627 -0
- package/src/engine-components/ui/BaseUIComponent.ts +153 -0
- package/src/engine-components/ui/Button.ts +251 -0
- package/src/engine-components/ui/Canvas.ts +166 -0
- package/src/engine-components/ui/CanvasGroup.ts +47 -0
- package/src/engine-components/ui/EventSystem.ts +523 -0
- package/src/engine-components/ui/Graphic.ts +157 -0
- package/src/engine-components/ui/Image.ts +57 -0
- package/src/engine-components/ui/InputField.ts +235 -0
- package/src/engine-components/ui/Interfaces.ts +8 -0
- package/src/engine-components/ui/Keyboard.ts +203 -0
- package/src/engine-components/ui/Layout.ts +17 -0
- package/src/engine-components/ui/PointerEvents.ts +54 -0
- package/src/engine-components/ui/Raycaster.ts +47 -0
- package/src/engine-components/ui/RectTransform.ts +180 -0
- package/src/engine-components/ui/SpatialHtml.ts +63 -0
- package/src/engine-components/ui/Text.ts +634 -0
- package/src/engine-components/ui/Utils.ts +105 -0
- package/src/engine-components-experimental/Presentation.ts +13 -0
- package/src/engine-components-experimental/annotation/LineDrawer.ts +191 -0
- package/src/engine-components-experimental/annotation/LinesManager.ts +218 -0
- package/src/engine-components-experimental/networking/PlayerSync.ts +131 -0
- package/src/engine-schemes/COMPILE_SCHEMES.bat +4 -0
- package/src/engine-schemes/COMPILE_TS.bat +12 -0
- package/src/engine-schemes/schemes.ts +29 -0
- package/src/engine-schemes/synced-camera-model.ts +92 -0
- package/src/engine-schemes/synced-transform-model.ts +90 -0
- package/src/engine-schemes/syncedCamera.fbs +11 -0
- package/src/engine-schemes/transform.ts +50 -0
- package/src/engine-schemes/transforms.fbs +26 -0
- package/src/engine-schemes/vec.fbs +19 -0
- package/src/engine-schemes/vec2.ts +33 -0
- package/src/engine-schemes/vec3.ts +38 -0
- package/src/engine-schemes/vec4.ts +43 -0
- package/src/engine-schemes/vr-user-state-buffer.ts +138 -0
- package/src/engine-schemes/vrUserStateBuffer.fbs +17 -0
- package/src/needle-engine.ts +39 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Behaviour, GameObject } from "./Component";
|
|
2
|
+
import * as THREE from "three";
|
|
3
|
+
import { AudioSource } from "./AudioSource";
|
|
4
|
+
import { Camera } from "./Camera";
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export class AudioListener extends Behaviour {
|
|
8
|
+
|
|
9
|
+
get listener(): THREE.AudioListener {
|
|
10
|
+
if (this._listener == null)
|
|
11
|
+
this._listener = new THREE.AudioListener();
|
|
12
|
+
return this._listener;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
private _listener: THREE.AudioListener | null = null;
|
|
16
|
+
|
|
17
|
+
awake() {
|
|
18
|
+
AudioSource.registerWaitForAllowAudio(() => {
|
|
19
|
+
const listener = this.listener;
|
|
20
|
+
if (listener == null) return;
|
|
21
|
+
// if the listener is already parented to some object d0nt change it
|
|
22
|
+
if (listener.parent) return;
|
|
23
|
+
|
|
24
|
+
const cam = GameObject.getComponentInParent(this.gameObject, Camera);
|
|
25
|
+
if (cam) {
|
|
26
|
+
cam.cam.add(listener);
|
|
27
|
+
}
|
|
28
|
+
else
|
|
29
|
+
this.gameObject.add(listener);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
import { Behaviour, GameObject } from "./Component";
|
|
2
|
+
import * as THREE from "three";
|
|
3
|
+
import { PositionalAudioHelper } from 'three/examples/jsm/helpers/PositionalAudioHelper.js';
|
|
4
|
+
import { AudioListener } from "./AudioListener";
|
|
5
|
+
import * as utils from "../engine/engine_utils";
|
|
6
|
+
import { serializeable } from "../engine/engine_serialization_decorator";
|
|
7
|
+
import { Application, ApplicationEvents } from "../engine/engine_application";
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
const debug = utils.getParam("debugaudio");
|
|
11
|
+
|
|
12
|
+
export enum AudioRolloffMode {
|
|
13
|
+
/// <summary>
|
|
14
|
+
/// <para>Use this mode when you want a real-world rolloff.</para>
|
|
15
|
+
/// </summary>
|
|
16
|
+
Logarithmic = 0,
|
|
17
|
+
/// <summary>
|
|
18
|
+
/// <para>Use this mode when you want to lower the volume of your sound over the distance.</para>
|
|
19
|
+
/// </summary>
|
|
20
|
+
Linear = 1,
|
|
21
|
+
/// <summary>
|
|
22
|
+
/// <para>Use this when you want to use a custom rolloff.</para>
|
|
23
|
+
/// </summary>
|
|
24
|
+
Custom = 2,
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
export class AudioSource extends Behaviour {
|
|
29
|
+
|
|
30
|
+
private static _didCallBeginWaitForUserInteraction: boolean = false;
|
|
31
|
+
public static get userInteractionRegistered(): boolean {
|
|
32
|
+
|
|
33
|
+
if (!AudioSource._didCallBeginWaitForUserInteraction) {
|
|
34
|
+
AudioSource._didCallBeginWaitForUserInteraction = true;
|
|
35
|
+
AudioSource._beginWaitForUserInteraction();
|
|
36
|
+
}
|
|
37
|
+
return AudioSource._userInteractionRegistered;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
private static callbacks: Function[] = [];
|
|
41
|
+
public static registerWaitForAllowAudio(cb: Function) {
|
|
42
|
+
if (cb !== null) {
|
|
43
|
+
if (this._userInteractionRegistered) {
|
|
44
|
+
cb();
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (this.callbacks.indexOf(cb) === -1)
|
|
48
|
+
this.callbacks.push(cb);
|
|
49
|
+
if (!AudioSource._didCallBeginWaitForUserInteraction) {
|
|
50
|
+
AudioSource._didCallBeginWaitForUserInteraction = true;
|
|
51
|
+
AudioSource._beginWaitForUserInteraction();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
private static _userInteractionRegistered: boolean = false;
|
|
57
|
+
private static _beginWaitForUserInteraction(cb: Function | null = null) {
|
|
58
|
+
if (this._userInteractionRegistered) {
|
|
59
|
+
if (cb) cb();
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (cb !== null)
|
|
63
|
+
this.registerWaitForAllowAudio(cb);
|
|
64
|
+
const callback = () => {
|
|
65
|
+
if (fn == undefined) return;
|
|
66
|
+
if (AudioSource._userInteractionRegistered) return;
|
|
67
|
+
AudioSource._userInteractionRegistered = true;
|
|
68
|
+
console.log("registered interaction, can play audio now");
|
|
69
|
+
document.removeEventListener('pointerdown', fn);
|
|
70
|
+
document.removeEventListener('click', fn);
|
|
71
|
+
document.removeEventListener('dragstart', fn);
|
|
72
|
+
document.removeEventListener('touchstart', fn);
|
|
73
|
+
for (const cb of this.callbacks) {
|
|
74
|
+
cb();
|
|
75
|
+
}
|
|
76
|
+
this.callbacks.length = 0;
|
|
77
|
+
};
|
|
78
|
+
let fn = callback.bind(this);
|
|
79
|
+
document.addEventListener('pointerdown', fn);
|
|
80
|
+
document.addEventListener('click', fn);
|
|
81
|
+
document.addEventListener('dragstart', fn);
|
|
82
|
+
document.addEventListener('touchstart', fn);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
@serializeable()
|
|
86
|
+
private clip: string = "";
|
|
87
|
+
|
|
88
|
+
@serializeable()
|
|
89
|
+
playOnAwake: boolean = false;
|
|
90
|
+
|
|
91
|
+
@serializeable()
|
|
92
|
+
get loop(): boolean {
|
|
93
|
+
if (this.sound) this._loop = this.sound.getLoop();
|
|
94
|
+
return this._loop;
|
|
95
|
+
}
|
|
96
|
+
set loop(val: boolean) {
|
|
97
|
+
this._loop = val;
|
|
98
|
+
if (this.sound) this.sound.setLoop(val);
|
|
99
|
+
}
|
|
100
|
+
@serializeable()
|
|
101
|
+
get spatialBlend(): number {
|
|
102
|
+
return this._spatialBlend;
|
|
103
|
+
}
|
|
104
|
+
set spatialBlend(val: number) {
|
|
105
|
+
if (val === this._spatialBlend) return;
|
|
106
|
+
this._spatialBlend = val;
|
|
107
|
+
this._needUpdateSpatialDistanceSettings = true;
|
|
108
|
+
}
|
|
109
|
+
@serializeable()
|
|
110
|
+
get minDistance(): number {
|
|
111
|
+
return this._minDistance;
|
|
112
|
+
}
|
|
113
|
+
set minDistance(val: number) {
|
|
114
|
+
if (this._minDistance === val) return;
|
|
115
|
+
this._minDistance = val;
|
|
116
|
+
this._needUpdateSpatialDistanceSettings = true;
|
|
117
|
+
}
|
|
118
|
+
@serializeable()
|
|
119
|
+
get maxDistance(): number {
|
|
120
|
+
return this._maxDistance;
|
|
121
|
+
}
|
|
122
|
+
set maxDistance(val: number) {
|
|
123
|
+
if (this._maxDistance === val) return;
|
|
124
|
+
this._maxDistance = val;
|
|
125
|
+
this._needUpdateSpatialDistanceSettings = true;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
private _spatialBlend: number = 0;
|
|
129
|
+
private _minDistance: number = 1;
|
|
130
|
+
private _maxDistance: number = 100;
|
|
131
|
+
|
|
132
|
+
@serializeable()
|
|
133
|
+
get volume(): number { return this._volume; }
|
|
134
|
+
set volume(val: number) {
|
|
135
|
+
this._volume = val;
|
|
136
|
+
if (this.sound) {
|
|
137
|
+
if (debug) console.log(this.name, "audio set volume", val);
|
|
138
|
+
this.sound.setVolume(val);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
private _volume: number = 1;
|
|
142
|
+
|
|
143
|
+
@serializeable()
|
|
144
|
+
rollOffMode: AudioRolloffMode = 0;
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
private _loop: boolean = false;
|
|
148
|
+
private sound: THREE.PositionalAudio | null = null;
|
|
149
|
+
private helper: PositionalAudioHelper | null = null;
|
|
150
|
+
private wasPlaying = false;
|
|
151
|
+
private audioLoader: THREE.AudioLoader | null = null;
|
|
152
|
+
private shouldPlay: boolean = false;
|
|
153
|
+
// set this from audio context time, used to set clip offset when setting "time" property
|
|
154
|
+
// there is maybe a better way to set a audio clip current time?!
|
|
155
|
+
private _lastClipStartedLoading: string | null = null;
|
|
156
|
+
|
|
157
|
+
public get Sound(): THREE.PositionalAudio | null {
|
|
158
|
+
if (!this.sound && AudioSource._userInteractionRegistered) {
|
|
159
|
+
const listener = GameObject.getComponent(this.context.mainCamera, AudioListener) ?? GameObject.findObjectOfType(AudioListener, this.context);
|
|
160
|
+
if (listener?.listener) {
|
|
161
|
+
this.sound = new THREE.PositionalAudio(listener.listener);
|
|
162
|
+
this.gameObject.add(this.sound);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return this.sound;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
public get ShouldPlay(): boolean { return this.shouldPlay; }
|
|
169
|
+
|
|
170
|
+
private _focusCallback?: any;
|
|
171
|
+
|
|
172
|
+
awake() {
|
|
173
|
+
this.audioLoader = new THREE.AudioLoader();
|
|
174
|
+
if (this.playOnAwake) this.shouldPlay = true;
|
|
175
|
+
|
|
176
|
+
window.addEventListener('visibilitychange', _evt => {
|
|
177
|
+
switch (document.visibilityState) {
|
|
178
|
+
case "hidden":
|
|
179
|
+
this.wasPlaying = this.isPlaying;
|
|
180
|
+
this.pause();
|
|
181
|
+
break;
|
|
182
|
+
case "visible":
|
|
183
|
+
if (this.wasPlaying) this.play();
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
this._focusCallback = () => {
|
|
189
|
+
if (this.enabled && this.playOnAwake && !this.isPlaying && AudioSource._userInteractionRegistered) {
|
|
190
|
+
this.play();
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
this.context.application.addEventListener(ApplicationEvents.Visible, this._focusCallback);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
onDestroy() {
|
|
198
|
+
this.context.application.removeEventListener(ApplicationEvents.Visible, this._focusCallback);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
onEnable(): void {
|
|
203
|
+
if (!AudioSource._userInteractionRegistered) {
|
|
204
|
+
AudioSource._beginWaitForUserInteraction(() => {
|
|
205
|
+
if (this.enabled && !this.destroyed && this.shouldPlay)
|
|
206
|
+
this.loadAndPlay(this.clip);
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
else if (this.playOnAwake && this.context.application.isVisible) {
|
|
210
|
+
this.play();
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
onDisable() {
|
|
215
|
+
this.stop();
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
private lerp = (x, y, a) => x * (1 - a) + y * a;
|
|
219
|
+
|
|
220
|
+
private onLoaded(buffer) {
|
|
221
|
+
if (debug) console.log("audio buffer loaded");
|
|
222
|
+
AudioSource.registerWaitForAllowAudio(() => {
|
|
223
|
+
if (debug)
|
|
224
|
+
console.log("finished loading", buffer);
|
|
225
|
+
|
|
226
|
+
const sound = this.Sound;
|
|
227
|
+
if (!sound) {
|
|
228
|
+
console.warn("Failed getting sound", this.name);
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
if (sound.isPlaying)
|
|
232
|
+
sound.stop();
|
|
233
|
+
|
|
234
|
+
sound.setBuffer(buffer);
|
|
235
|
+
sound.loop = this.loop;
|
|
236
|
+
sound.setVolume(this.volume);
|
|
237
|
+
sound.autoplay = this.shouldPlay;
|
|
238
|
+
// sound.setDistanceModel('linear');
|
|
239
|
+
// sound.setRolloffFactor(1);
|
|
240
|
+
this.applySpatialDistanceSettings();
|
|
241
|
+
// sound.setDirectionalCone(180, 360, 0.1);
|
|
242
|
+
if (sound.isPlaying)
|
|
243
|
+
sound.stop();
|
|
244
|
+
|
|
245
|
+
if (debug) console.log(this.name, this.shouldPlay, AudioSource.userInteractionRegistered, this);
|
|
246
|
+
|
|
247
|
+
if (this.shouldPlay && AudioSource._userInteractionRegistered)
|
|
248
|
+
this.play();
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
private applySpatialDistanceSettings() {
|
|
253
|
+
const sound = this.sound;
|
|
254
|
+
if (!sound) return;
|
|
255
|
+
this._needUpdateSpatialDistanceSettings = false;
|
|
256
|
+
const dist = this.lerp(10 * this._maxDistance / Math.max(0.0001, this.spatialBlend), this._minDistance, this.spatialBlend);
|
|
257
|
+
if (debug) console.log(this.name, this._minDistance, this._maxDistance, this.spatialBlend, "Ref distance=" + dist);
|
|
258
|
+
sound.setRefDistance(dist);
|
|
259
|
+
sound.setMaxDistance(Math.max(0.01, this._maxDistance));
|
|
260
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/distanceModel
|
|
261
|
+
switch (this.rollOffMode) {
|
|
262
|
+
case AudioRolloffMode.Logarithmic:
|
|
263
|
+
sound.setDistanceModel('exponential');
|
|
264
|
+
break;
|
|
265
|
+
case AudioRolloffMode.Linear:
|
|
266
|
+
sound.setDistanceModel('linear');
|
|
267
|
+
break;
|
|
268
|
+
case AudioRolloffMode.Custom:
|
|
269
|
+
break;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
if (this.spatialBlend > 0) {
|
|
273
|
+
if (debug && !this.helper) {
|
|
274
|
+
this.helper = new PositionalAudioHelper(sound, sound.getRefDistance());
|
|
275
|
+
sound.add(this.helper);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
else if (this.helper && this.helper.parent) {
|
|
279
|
+
this.helper.removeFromParent();
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
private loadAndPlay(clip?: string) {
|
|
284
|
+
if (clip)
|
|
285
|
+
this.clip = clip;
|
|
286
|
+
if (this.clip) {
|
|
287
|
+
if (debug)
|
|
288
|
+
console.log(this.clip);
|
|
289
|
+
if (this.clip.endsWith(".mp3") || this.clip.endsWith(".wav")) {
|
|
290
|
+
if (!this.audioLoader)
|
|
291
|
+
this.audioLoader = new THREE.AudioLoader();
|
|
292
|
+
this.shouldPlay = true;
|
|
293
|
+
if (this._lastClipStartedLoading === this.clip) {
|
|
294
|
+
if (debug) console.log("Is currently loading:", this._lastClipStartedLoading, this)
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
this._lastClipStartedLoading = this.clip;
|
|
298
|
+
if (debug)
|
|
299
|
+
console.log("load audio", this.clip);
|
|
300
|
+
this.audioLoader.load(this.clip, this.onLoaded.bind(this), () => { }, console.error);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
play(clip: string | undefined = undefined) {
|
|
306
|
+
if (!this.audioLoader || !this.sound || (clip && clip !== this.clip)) {
|
|
307
|
+
this.loadAndPlay(clip);
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
this.shouldPlay = true;
|
|
312
|
+
this._hasEnded = false;
|
|
313
|
+
if (debug)
|
|
314
|
+
console.log("play", this.sound?.getVolume(), this.sound);
|
|
315
|
+
if (this.sound && !this.sound.isPlaying) {
|
|
316
|
+
this.sound.play();
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
pause() {
|
|
321
|
+
if (debug) console.log("Pause", this);
|
|
322
|
+
this._hasEnded = true;
|
|
323
|
+
this.shouldPlay = false;
|
|
324
|
+
if (this.sound && this.sound.isPlaying) {
|
|
325
|
+
this._lastContextTime = this.sound?.context.currentTime;
|
|
326
|
+
this.sound.pause();
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
stop() {
|
|
331
|
+
if (debug) console.log("Pause", this);
|
|
332
|
+
this._hasEnded = true;
|
|
333
|
+
this.shouldPlay = false;
|
|
334
|
+
if (this.sound) {
|
|
335
|
+
this._lastContextTime = this.sound?.context.currentTime;
|
|
336
|
+
if (debug)
|
|
337
|
+
console.log(this._lastContextTime)
|
|
338
|
+
this.sound.stop();
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
private _lastContextTime: number = 0;
|
|
343
|
+
|
|
344
|
+
get isPlaying(): boolean { return this.sound?.isPlaying ?? false; }
|
|
345
|
+
set isPlaying(_: boolean) { }
|
|
346
|
+
|
|
347
|
+
get time(): number { return this.sound?.source ? (this.sound.source?.context.currentTime - this._lastContextTime + this.sound.offset) : 0; }
|
|
348
|
+
set time(val: number) {
|
|
349
|
+
if (this.sound) {
|
|
350
|
+
if (val === this.sound.offset) return;
|
|
351
|
+
const wasPlaying = this.isPlaying;
|
|
352
|
+
this.stop();
|
|
353
|
+
this.sound.offset = val;
|
|
354
|
+
if (wasPlaying)
|
|
355
|
+
this.play();
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
private _hasEnded: boolean = true;
|
|
360
|
+
private _needUpdateSpatialDistanceSettings: boolean = false;
|
|
361
|
+
|
|
362
|
+
update() {
|
|
363
|
+
if (this.helper) {
|
|
364
|
+
if (this.isPlaying)
|
|
365
|
+
this.helper.update();
|
|
366
|
+
this.helper.visible = this.isPlaying;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
if (this._needUpdateSpatialDistanceSettings) {
|
|
370
|
+
this.applySpatialDistanceSettings();
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
if (this.sound && !this.sound.isPlaying && this.shouldPlay && !this._hasEnded) {
|
|
374
|
+
this._hasEnded = true;
|
|
375
|
+
if (debug)
|
|
376
|
+
console.log("Audio clip ended", this.clip);
|
|
377
|
+
this.sound.dispatchEvent({ type: 'ended', target: this });
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
// this.gameObject.position.x = Math.sin(time.time) * 2;
|
|
381
|
+
// this.gameObject.position.z = Math.cos(time.time * .5) * 2;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { GLTF, GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader";
|
|
2
|
+
import * as THREE from "three";
|
|
3
|
+
import * as utils from "../engine/engine_utils"
|
|
4
|
+
import * as object from "../engine/engine_gltf_builtin_components";
|
|
5
|
+
import * as loaders from "../engine/engine_loaders"
|
|
6
|
+
import { Context } from "../engine/engine_setup";
|
|
7
|
+
import { GameObject, InstantiateOptions } from "./Component";
|
|
8
|
+
import { download_file } from "../engine/engine_web_api";
|
|
9
|
+
import { parseSync } from "../engine/engine_scenetools";
|
|
10
|
+
|
|
11
|
+
const debug = utils.getParam("debugavatar");
|
|
12
|
+
|
|
13
|
+
export class AvatarModel {
|
|
14
|
+
root: THREE.Object3D;
|
|
15
|
+
head: THREE.Object3D;
|
|
16
|
+
leftHand: THREE.Object3D | null;
|
|
17
|
+
rigthHand: THREE.Object3D | null;
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
get isValid(): boolean {
|
|
21
|
+
return this.head !== null && this.head !== undefined;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
constructor(root: THREE.Object3D, head: THREE.Object3D, leftHand: THREE.Object3D | null, rigthHand: THREE.Object3D | null) {
|
|
25
|
+
this.root = root;
|
|
26
|
+
this.head = head;
|
|
27
|
+
this.leftHand = leftHand;
|
|
28
|
+
this.rigthHand = rigthHand;
|
|
29
|
+
this.root?.traverse(h => h.layers.set(2));
|
|
30
|
+
// this.head?.traverse(h => h.layers.set(2));
|
|
31
|
+
// this.leftHand?.traverse(h => h.layers.set(2));
|
|
32
|
+
// this.rigthHand?.traverse(h => h.layers.set(2));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// createNewInstance(): AvatarModel {
|
|
36
|
+
// const head = GameObject.instantiate(this.head);
|
|
37
|
+
// const lh = GameObject.instantiate(this.leftHand);
|
|
38
|
+
// const rh = GameObject.instantiate(this.rigthHand);
|
|
39
|
+
// const model = new AvatarModel(this.root, head, lh, rh);
|
|
40
|
+
// this.assignRandomColors();
|
|
41
|
+
// return model;
|
|
42
|
+
// }
|
|
43
|
+
|
|
44
|
+
assignRandomColors() {
|
|
45
|
+
AvatarLoader.assignRandomPlayerColors(this);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export class AvatarLoader {
|
|
50
|
+
|
|
51
|
+
private readonly avatarRegistryUrl: string | null = null;// = "https://needle-storage-castle-demo.glitch.me";//"https://smol-worlds.glitch.me/files/";
|
|
52
|
+
// private loader: GLTFLoader | null;
|
|
53
|
+
private avatarModelCache: Map<string, AvatarModel | null> = new Map<string, AvatarModel | null>();
|
|
54
|
+
|
|
55
|
+
public async getOrCreateNewAvatarInstance(context: Context, avatarId: string | THREE.Object3D): Promise<AvatarModel | null> {
|
|
56
|
+
|
|
57
|
+
if (!avatarId) {
|
|
58
|
+
console.error("Can not create avatar: failed to provide id or root object");
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
let root: THREE.Object3D | null = null;
|
|
63
|
+
if (typeof avatarId === "string") {
|
|
64
|
+
root = await this.loadAvatar(context, avatarId);
|
|
65
|
+
if (!root) {
|
|
66
|
+
const opts = new InstantiateOptions();
|
|
67
|
+
// opts.parent = context.scene.uuid;
|
|
68
|
+
root = GameObject.instantiate(utils.tryFindObject(avatarId, context.scene), opts);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
else root = avatarId;
|
|
72
|
+
|
|
73
|
+
if (!root) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
const model = this.findAvatar(root);
|
|
77
|
+
// console.log(model);
|
|
78
|
+
model.assignRandomColors();
|
|
79
|
+
// this.cacheModel(avatarId, model);
|
|
80
|
+
|
|
81
|
+
if (model.isValid) {
|
|
82
|
+
if (debug)
|
|
83
|
+
console.log("[Custom Avatar] valid config", avatarId, debug ? model : "");
|
|
84
|
+
return model;
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
console.warn("[Custom Avatar] config isn't valid", avatarId, debug ? model : "");
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
private async loadAvatar(context: Context, avatarId: string): Promise<THREE.Object3D | null> {
|
|
94
|
+
|
|
95
|
+
console.assert(avatarId !== undefined && avatarId !== null && typeof avatarId === "string", "Avatar id must not be null");
|
|
96
|
+
if (avatarId.length <= 0) return null;
|
|
97
|
+
if (!avatarId) return null;
|
|
98
|
+
|
|
99
|
+
if (debug)
|
|
100
|
+
console.log("[Custom Avatar] " + avatarId + ", loading...");
|
|
101
|
+
// should probably be done by the server?!
|
|
102
|
+
if (!avatarId.endsWith(".glb"))
|
|
103
|
+
avatarId += ".glb";
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
// for the demo we use the storage backend we uploaded the avatar to (by file drop)
|
|
107
|
+
if (this.avatarRegistryUrl === null) {
|
|
108
|
+
// try loading avatar from local file
|
|
109
|
+
const download_res = await fetch("./" + avatarId);
|
|
110
|
+
let bin: ArrayBuffer | null = null;
|
|
111
|
+
if (download_res.ok) {
|
|
112
|
+
const blob = await download_res.blob();
|
|
113
|
+
if (blob) bin = await blob.arrayBuffer();
|
|
114
|
+
}
|
|
115
|
+
if (!bin) {
|
|
116
|
+
bin = await download_file(avatarId, avatarId, 0, "no url here go away", true);
|
|
117
|
+
if (!bin) return null;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const gltf = await parseSync(context, bin, null!, 0);
|
|
121
|
+
return gltf?.scene ?? null;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
// if (this.avatarModelCache.has(avatarId)) {
|
|
126
|
+
// console.log("[Custom Avatar] " + avatarId + ", found in cache");
|
|
127
|
+
// return new Promise((res, _) => {
|
|
128
|
+
// var model = this.avatarModelCache.get(avatarId)?.createNewInstance();
|
|
129
|
+
// res(model);
|
|
130
|
+
// });
|
|
131
|
+
// }
|
|
132
|
+
// return null;
|
|
133
|
+
|
|
134
|
+
const loader = new GLTFLoader();
|
|
135
|
+
loaders.addDracoAndKTX2Loaders(loader, context);
|
|
136
|
+
|
|
137
|
+
// TODO: cache binary (fetch finary from model gallery and use binary method)
|
|
138
|
+
return new Promise((resolve, _reject) => {
|
|
139
|
+
const url = this.avatarRegistryUrl + "/" + avatarId;
|
|
140
|
+
loader.load(url,
|
|
141
|
+
async gltf => {
|
|
142
|
+
await object.createBuiltinComponents(context, url, gltf);
|
|
143
|
+
resolve(gltf.scene);
|
|
144
|
+
},
|
|
145
|
+
progress => {
|
|
146
|
+
if (debug)
|
|
147
|
+
console.log("[Custom Avatar] " + (progress.loaded / progress.total * 100) + '% loaded of ' + (progress.total / 1024) + "kB");
|
|
148
|
+
},
|
|
149
|
+
error => {
|
|
150
|
+
console.error("[Custom Avatar] " + "Error when loading: " + error);
|
|
151
|
+
resolve(null);
|
|
152
|
+
}
|
|
153
|
+
);
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
private cacheModel(_id: string, _model: AvatarModel) {
|
|
158
|
+
// this.avatarModelCache.set(id, model);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// TODO this should be burned to the ground once 🤞 we have proper extras that define object relations.
|
|
162
|
+
private findAvatar(obj: THREE.Object3D): AvatarModel {
|
|
163
|
+
|
|
164
|
+
const root: THREE.Object3D = obj;
|
|
165
|
+
let searchIn = root;
|
|
166
|
+
// some GLTFs have a "scene" root it seems, others don't, we skip the root here if there's only one child
|
|
167
|
+
if (searchIn.children.length == 1)
|
|
168
|
+
searchIn = obj.children[0];
|
|
169
|
+
let head = this.findAvatarPart(searchIn, "head");
|
|
170
|
+
|
|
171
|
+
const leftHand = this.findAvatarPart(searchIn, "left");
|
|
172
|
+
const rightHand = this.findAvatarPart(searchIn, "right");
|
|
173
|
+
|
|
174
|
+
if (!head) {
|
|
175
|
+
// very last fallback, entire root is used as head
|
|
176
|
+
head = root;
|
|
177
|
+
|
|
178
|
+
// normalize size, if the object isn't properly setup the scale might be totally off
|
|
179
|
+
let boundsSize = new THREE.Vector3();
|
|
180
|
+
new THREE.Box3().setFromObject(head).getSize(boundsSize);
|
|
181
|
+
let maxAxis = Math.max(boundsSize.x, boundsSize.y, boundsSize.z);
|
|
182
|
+
console.warn("[Custom Avatar] " + "Normalizing head scale, it's too big: " + maxAxis + " meters! Should be < 0.3m");
|
|
183
|
+
if (maxAxis > 0.3) {
|
|
184
|
+
head.scale.multiplyScalar(1.0 / maxAxis * 0.3);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const model = new AvatarModel(root, head, leftHand, rightHand);
|
|
189
|
+
return model;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
private findAvatarPart(obj: THREE.Object3D, searchString: string): THREE.Object3D | null {
|
|
194
|
+
for (let child of obj.children) {
|
|
195
|
+
if (child.name.toLowerCase().indexOf(searchString) > -1)
|
|
196
|
+
return child;
|
|
197
|
+
}
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
private handleCustomAvatarErrors(response) {
|
|
202
|
+
if (!response.ok) {
|
|
203
|
+
throw Error(response.statusText);
|
|
204
|
+
}
|
|
205
|
+
return response;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
public static assignRandomPlayerColors(model: AvatarModel) {
|
|
209
|
+
|
|
210
|
+
const foundMaterials: Map<string, THREE.Material> = new Map<string, THREE.Material>();
|
|
211
|
+
|
|
212
|
+
function findPlayerColorMeshesAndAssignColors(o) {
|
|
213
|
+
// console.log(o);
|
|
214
|
+
if (o.type === "Mesh") {
|
|
215
|
+
const mesh = o as THREE.Mesh;
|
|
216
|
+
const mat: THREE.Material = mesh.material as THREE.Material;
|
|
217
|
+
if (mat && mat.name) {
|
|
218
|
+
if (foundMaterials.has(mat.uuid)) {
|
|
219
|
+
const found = foundMaterials.get(mat.uuid);
|
|
220
|
+
if (found)
|
|
221
|
+
mesh.material = found;
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
if (mat.name.endsWith("_playercolor") || mat.name.endsWith("_player_color2")) {
|
|
225
|
+
const uuid = mat.uuid;
|
|
226
|
+
mesh.material = mat.clone();
|
|
227
|
+
mesh.material["color"] = new THREE.Color(Math.random(), Math.random(), Math.random());
|
|
228
|
+
foundMaterials.set(uuid, mesh.material);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
if (model.head)
|
|
234
|
+
model.head.traverse(findPlayerColorMeshesAndAssignColors);
|
|
235
|
+
if (model.leftHand)
|
|
236
|
+
model.leftHand.traverse(findPlayerColorMeshesAndAssignColors);
|
|
237
|
+
if (model.rigthHand)
|
|
238
|
+
model.rigthHand.traverse(findPlayerColorMeshesAndAssignColors);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Behaviour } from "./Component";
|
|
2
|
+
import * as params from "../engine/engine_default_parameters";
|
|
3
|
+
import { serializeable } from "../engine/engine_serialization_decorator";
|
|
4
|
+
import { AxesHelper as _AxesHelper } from "three";
|
|
5
|
+
|
|
6
|
+
export class AxesHelper extends Behaviour {
|
|
7
|
+
@serializeable()
|
|
8
|
+
public length: number = 1;
|
|
9
|
+
@serializeable()
|
|
10
|
+
public depthTest: boolean = true;
|
|
11
|
+
@serializeable()
|
|
12
|
+
public isGizmo:boolean = true;
|
|
13
|
+
|
|
14
|
+
private _axes: THREE.AxesHelper | null = null;
|
|
15
|
+
|
|
16
|
+
onEnable(): void {
|
|
17
|
+
if (this.isGizmo && !params.showGizmos) return;
|
|
18
|
+
if (!this._axes)
|
|
19
|
+
this._axes = new _AxesHelper(this.length);
|
|
20
|
+
this.gameObject.add(this._axes);
|
|
21
|
+
const mat: any = this._axes.material;
|
|
22
|
+
if (mat) {
|
|
23
|
+
if (mat.depthTest !== undefined)
|
|
24
|
+
mat.depthTest = this.depthTest;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
onDisable(): void {
|
|
29
|
+
if (!this._axes) return;
|
|
30
|
+
this.gameObject.remove(this._axes);
|
|
31
|
+
}
|
|
32
|
+
}
|