@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,799 @@
|
|
|
1
|
+
import { Animator } from "./Animator";
|
|
2
|
+
import { AnimatorConditionMode, AnimatorControllerModel, AnimatorControllerParameterType, AnimatorStateInfo, Condition, createMotion, State, StateMachineBehaviour } from "../engine/extensions/NEEDLE_animator_controller_model";
|
|
3
|
+
import { AnimationAction, AnimationClip, AnimationMixer, AxesHelper, Euler, KeyframeTrack, LoopOnce, LoopRepeat, Matrix4, Object3D, Quaternion, Vector3 } from "three";
|
|
4
|
+
import { deepClone, getParam } from "../engine/engine_utils";
|
|
5
|
+
import { Context } from "../engine/engine_setup";
|
|
6
|
+
import * as THREE from "three";
|
|
7
|
+
import { TypeStore } from "../engine/engine_typestore";
|
|
8
|
+
import { assign } from "../engine/engine_serialization_core";
|
|
9
|
+
import { Mathf } from "../engine/engine_math";
|
|
10
|
+
|
|
11
|
+
const debug = getParam("debuganimatorcontroller");
|
|
12
|
+
const debugRootMotion = getParam("debugrootmotion");
|
|
13
|
+
|
|
14
|
+
export class AnimatorController {
|
|
15
|
+
|
|
16
|
+
Play(name: string | number, layerIndex: number = -1, normalizedTime: number = Number.NEGATIVE_INFINITY, durationInSec: number = 0) {
|
|
17
|
+
if (layerIndex < 0) layerIndex = 0;
|
|
18
|
+
else if (layerIndex >= this.model.layers.length) {
|
|
19
|
+
console.warn("invalid layer");
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const layer = this.model.layers[layerIndex];
|
|
23
|
+
const sm = layer.stateMachine;
|
|
24
|
+
for (const state of sm.states) {
|
|
25
|
+
if (state.name === name || state.hash === name) {
|
|
26
|
+
if (debug)
|
|
27
|
+
console.log("transition to ", state);
|
|
28
|
+
this.transitionTo(state, durationInSec, normalizedTime);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
console.warn("Could not find " + name + " to play");
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
Reset() {
|
|
36
|
+
this.setStartTransition();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
SetBool(name: string | number, value: boolean) {
|
|
40
|
+
const key = typeof name === "string" ? "name" : "hash";
|
|
41
|
+
return this.model?.parameters.filter(p => p[key] === name).forEach(p => p.value = value);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
GetBool(name: string | number): boolean {
|
|
45
|
+
const key = typeof name === "string" ? "name" : "hash";
|
|
46
|
+
return this.model?.parameters.find(p => p[key] === name)?.value as boolean ?? false;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
SetFloat(name: string | number, val: number) {
|
|
50
|
+
const key = typeof name === "string" ? "name" : "hash";
|
|
51
|
+
return this.model?.parameters.filter(p => p[key] === name).forEach(p => p.value = val);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
GetFloat(name: string | number): number {
|
|
55
|
+
const key = typeof name === "string" ? "name" : "hash";
|
|
56
|
+
return this.model?.parameters.find(p => p[key] === name)?.value as number ?? 0;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
SetInteger(name: string | number, val: number) {
|
|
60
|
+
const key = typeof name === "string" ? "name" : "hash";
|
|
61
|
+
return this.model?.parameters.filter(p => p[key] === name).forEach(p => p.value = val);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
GetInteger(name: string | number): number {
|
|
65
|
+
const key = typeof name === "string" ? "name" : "hash";
|
|
66
|
+
return this.model?.parameters.find(p => p[key] === name)?.value as number ?? 0;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
SetTrigger(name: string | number) {
|
|
70
|
+
if (debug)
|
|
71
|
+
console.log("SET TRIGGER", name);
|
|
72
|
+
const key = typeof name === "string" ? "name" : "hash";
|
|
73
|
+
return this.model?.parameters.filter(p => p[key] === name).forEach(p => p.value = true);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
ResetTrigger(name: string | number) {
|
|
77
|
+
const key = typeof name === "string" ? "name" : "hash";
|
|
78
|
+
return this.model?.parameters.filter(p => p[key] === name).forEach(p => p.value = false);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
IsInTransition(): boolean {
|
|
82
|
+
return this._activeStates.length > 1;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
SetSpeed(speed: number) {
|
|
86
|
+
this._speed = speed;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
FindState(name: string | undefined | null): State | null {
|
|
90
|
+
if (!name) return null;
|
|
91
|
+
for (const layer of this.model.layers) {
|
|
92
|
+
for (const state of layer.stateMachine.states) {
|
|
93
|
+
if (state.name === name) return state;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
normalizedStartOffset: number = 0;
|
|
100
|
+
|
|
101
|
+
private _speed: number = 1;
|
|
102
|
+
|
|
103
|
+
animator?: Animator;
|
|
104
|
+
model: AnimatorControllerModel;
|
|
105
|
+
get context(): Context | undefined | null { return this.animator?.context; }
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
// applyRootMotion(obj: THREE.Object3D) {
|
|
109
|
+
// // this.internalApplyRootMotion(obj);
|
|
110
|
+
// }
|
|
111
|
+
|
|
112
|
+
bind(animator: Animator) {
|
|
113
|
+
this.animator = animator;
|
|
114
|
+
this._mixer = new AnimationMixer(this.animator.gameObject);
|
|
115
|
+
this.createActions(this.animator);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
clone() {
|
|
119
|
+
// clone runtime controller but dont clone clip or action
|
|
120
|
+
const clonedModel = deepClone(this.model, (_owner, _key, _value) => {
|
|
121
|
+
if (_value === null || _value === undefined) return true;
|
|
122
|
+
// dont clone three Objects
|
|
123
|
+
if (_value.type === "Object3D" || _value.isObject3D === true) return false;
|
|
124
|
+
// dont clone AnimationAction
|
|
125
|
+
if (_value?.constructor?.name === "AnimationAction") return false;
|
|
126
|
+
// dont clone AnimationClip
|
|
127
|
+
if (_value["tracks"] !== undefined) return false;
|
|
128
|
+
return true;
|
|
129
|
+
}) as AnimatorControllerModel;
|
|
130
|
+
console.assert(clonedModel !== this.model);
|
|
131
|
+
const controller = new AnimatorController(clonedModel);
|
|
132
|
+
return controller;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
update() {
|
|
136
|
+
if (!this.animator) return;
|
|
137
|
+
this.evaluateTransitions();
|
|
138
|
+
this.updateActiveStates();
|
|
139
|
+
const dt = this.animator.context.time.deltaTime;
|
|
140
|
+
if (this.animator.applyRootMotion) {
|
|
141
|
+
this.rootMotionHandler?.onBeforeUpdate();
|
|
142
|
+
}
|
|
143
|
+
this._mixer.update(dt);
|
|
144
|
+
if (this.animator.applyRootMotion) {
|
|
145
|
+
this.rootMotionHandler?.onAfterUpdate();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
private _mixer!: THREE.AnimationMixer;
|
|
151
|
+
private _activeState?: State;
|
|
152
|
+
|
|
153
|
+
constructor(model: AnimatorControllerModel) {
|
|
154
|
+
this.model = model;
|
|
155
|
+
if (debug) console.log(this);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
private _activeStates: State[] = [];
|
|
159
|
+
|
|
160
|
+
private updateActiveStates() {
|
|
161
|
+
for (let i = 0; i < this._activeStates.length; i++) {
|
|
162
|
+
const state = this._activeStates[i];
|
|
163
|
+
const motion = state.motion;
|
|
164
|
+
if (!motion.action) {
|
|
165
|
+
this._activeStates.splice(i, 1);
|
|
166
|
+
i--;
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
const action = motion.action;
|
|
170
|
+
// console.log(action.getClip().name, action.getEffectiveWeight(), action.isScheduled());
|
|
171
|
+
if ((action.getEffectiveWeight() <= 0 && !action.isRunning())) {
|
|
172
|
+
if (debug)
|
|
173
|
+
console.debug("REMOVE", state.name, action.getEffectiveWeight(), action.isRunning(), action.isScheduled())
|
|
174
|
+
this._activeStates.splice(i, 1);
|
|
175
|
+
i--;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
private setStartTransition() {
|
|
182
|
+
for (const layer of this.model.layers) {
|
|
183
|
+
const sm = layer.stateMachine;
|
|
184
|
+
const start = sm.states[sm.defaultState];
|
|
185
|
+
this.transitionTo(start, 0, this.normalizedStartOffset);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
private evaluateTransitions() {
|
|
190
|
+
|
|
191
|
+
let didEnterStateThisFrame = false;
|
|
192
|
+
if (!this._activeState) {
|
|
193
|
+
this.setStartTransition();
|
|
194
|
+
if (!this._activeState) return;
|
|
195
|
+
didEnterStateThisFrame = true;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const state = this._activeState;
|
|
199
|
+
const action = state.motion.action;
|
|
200
|
+
let index = 0;
|
|
201
|
+
for (const transition of state.transitions) {
|
|
202
|
+
++index;
|
|
203
|
+
// transition without exit time and without condition are ignored
|
|
204
|
+
if (!transition.hasExitTime && transition.conditions.length <= 0) continue;
|
|
205
|
+
|
|
206
|
+
let allConditionsAreMet = true;
|
|
207
|
+
for (const cond of transition.conditions) {
|
|
208
|
+
if (!this.evaluateCondition(cond)) {
|
|
209
|
+
allConditionsAreMet = false;
|
|
210
|
+
break;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
if (!allConditionsAreMet) continue;
|
|
214
|
+
|
|
215
|
+
if (debug && allConditionsAreMet) {
|
|
216
|
+
console.log("All conditions are met", transition.conditions, action);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// disable triggers
|
|
220
|
+
for (const cond of transition.conditions) {
|
|
221
|
+
const param = this.model.parameters.find(p => p.name === cond.parameter);
|
|
222
|
+
if (param?.type === AnimatorControllerParameterType.Trigger) {
|
|
223
|
+
param.value = false;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if (action) {
|
|
228
|
+
const dur = state.motion.clip!.duration;
|
|
229
|
+
const normalizedTime = dur <= 0 ? 1 : action.time / dur;
|
|
230
|
+
if (!transition.hasExitTime
|
|
231
|
+
|| (normalizedTime >= transition.exitTime && action.time >= action.getClip().duration
|
|
232
|
+
)
|
|
233
|
+
) {
|
|
234
|
+
// if (transition.hasExitTime && transition.exitTime >= .9999)
|
|
235
|
+
action.clampWhenFinished = true;
|
|
236
|
+
// else action.clampWhenFinished = false;
|
|
237
|
+
if (debug) {
|
|
238
|
+
console.log("transition to " + transition.destinationState, transition);
|
|
239
|
+
console.log(action.time, transition.exitTime);
|
|
240
|
+
}
|
|
241
|
+
this.transitionTo(transition.destinationState as State, transition.duration, transition.offset);
|
|
242
|
+
// use the first transition that matches all conditions and make the transition as soon as in range
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
this.transitionTo(transition.destinationState as State, transition.duration, transition.offset);
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
break;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
let didTriggerLooping = false;
|
|
254
|
+
if (state.motion.isLooping && action) {
|
|
255
|
+
// we dont use the three loop state here because it prevents the transition check above
|
|
256
|
+
// it is easier if we re-trigger loop here.
|
|
257
|
+
// We also can easily add the cycle offset settings from unity later
|
|
258
|
+
if (action.time >= action.getClip().duration) {
|
|
259
|
+
didTriggerLooping = true;
|
|
260
|
+
action.reset();
|
|
261
|
+
action.time = 0;
|
|
262
|
+
action.play();
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// call update state behaviours:
|
|
267
|
+
if (!didTriggerLooping && state && !didEnterStateThisFrame && action && this.animator) {
|
|
268
|
+
if (state.behaviours) {
|
|
269
|
+
const duration = action?.getClip().duration;
|
|
270
|
+
const normalizedTime = action.time / duration;
|
|
271
|
+
const info = new AnimatorStateInfo(this._activeState, normalizedTime, duration, this._speed)
|
|
272
|
+
for (const beh of state.behaviours) {
|
|
273
|
+
if (beh.instance) {
|
|
274
|
+
beh.instance.onStateUpdate?.call(beh.instance, this.animator, info, 0);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
private transitionTo(state: State | number, durationInSec: number, offsetNormalized: number) {
|
|
283
|
+
|
|
284
|
+
if (!this.animator) return;
|
|
285
|
+
|
|
286
|
+
const layerIndex = 0;
|
|
287
|
+
|
|
288
|
+
if (typeof state === "number") {
|
|
289
|
+
if (state == -1) state = this.model.layers[layerIndex].stateMachine.defaultState; // exit state -> entry state
|
|
290
|
+
state = this.model.layers[layerIndex].stateMachine.states[state];
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
if (!state?.motion || !state.motion.clip) {
|
|
294
|
+
// if(debug) console.warn("State has no clip or motion", state);
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
const isSelf = this._activeState === state;
|
|
299
|
+
if (isSelf) {
|
|
300
|
+
const motion = state.motion;
|
|
301
|
+
if (!motion.action_loopback && motion.clip) {
|
|
302
|
+
this._mixer.uncacheAction(motion.clip, this.animator.gameObject);
|
|
303
|
+
motion.action_loopback = this.createAction(motion.clip);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// call exit state behaviours
|
|
308
|
+
if (this._activeState?.behaviours && this._activeState.motion.action) {
|
|
309
|
+
const duration = this._activeState?.motion.clip!.duration;
|
|
310
|
+
const normalizedTime = this._activeState.motion.action.time / duration;
|
|
311
|
+
const info = new AnimatorStateInfo(this._activeState, normalizedTime, duration, this._speed);
|
|
312
|
+
for (const beh of this._activeState.behaviours) {
|
|
313
|
+
beh.instance?.onStateExit?.call(beh.instance, this.animator, info, layerIndex);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
const prevAction = this._activeState?.motion.action;
|
|
318
|
+
if (prevAction) {
|
|
319
|
+
prevAction!.fadeOut(durationInSec);
|
|
320
|
+
}
|
|
321
|
+
if (isSelf) {
|
|
322
|
+
state.motion.action = state.motion.action_loopback;
|
|
323
|
+
state.motion.action_loopback = prevAction;
|
|
324
|
+
}
|
|
325
|
+
const prev = this._activeState;
|
|
326
|
+
this._activeState = state;
|
|
327
|
+
|
|
328
|
+
const action = state.motion?.action;
|
|
329
|
+
if (action) {
|
|
330
|
+
|
|
331
|
+
offsetNormalized = Math.max(0, Math.min(1, offsetNormalized));
|
|
332
|
+
if (action.isRunning())
|
|
333
|
+
action.stop();
|
|
334
|
+
action.reset();
|
|
335
|
+
action.timeScale = this._speed;
|
|
336
|
+
action.enabled = true;
|
|
337
|
+
const duration = state.motion.clip!.duration;
|
|
338
|
+
action.time = offsetNormalized * duration;
|
|
339
|
+
action.clampWhenFinished = true;
|
|
340
|
+
action.setLoop(LoopOnce, 0);
|
|
341
|
+
if (durationInSec > 0)
|
|
342
|
+
action.fadeIn(durationInSec);
|
|
343
|
+
else action.setEffectiveWeight(1);
|
|
344
|
+
action.play();
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
if (this.rootMotionHandler) {
|
|
348
|
+
this.rootMotionHandler.onStart(action);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
if (!this._activeStates.includes(state))
|
|
352
|
+
this._activeStates.push(state);
|
|
353
|
+
|
|
354
|
+
// call enter state behaviours
|
|
355
|
+
if (this._activeState.behaviours) {
|
|
356
|
+
const info = new AnimatorStateInfo(state, offsetNormalized, duration, this._speed);
|
|
357
|
+
for (const beh of this._activeState.behaviours) {
|
|
358
|
+
beh.instance?.onStateEnter?.call(beh.instance, this.animator, info, layerIndex);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
else console.warn("No action", state.motion, this);
|
|
363
|
+
|
|
364
|
+
if (debug)
|
|
365
|
+
console.log("TRANSITION FROM " + prev?.name + " TO " + state.name, durationInSec, prevAction, action, action?.getEffectiveTimeScale(), action?.getEffectiveWeight(), action?.isRunning(), action?.isScheduled(), action?.paused);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
private createAction(clip: AnimationClip) {
|
|
369
|
+
this._mixer.uncacheClip(clip);
|
|
370
|
+
|
|
371
|
+
if (this.animator?.applyRootMotion) {
|
|
372
|
+
if (!this.rootMotionHandler) {
|
|
373
|
+
this.rootMotionHandler = new RootMotionHandler(this);
|
|
374
|
+
}
|
|
375
|
+
// TODO: find root bone properly
|
|
376
|
+
const root = this.animator.gameObject;
|
|
377
|
+
return this.rootMotionHandler.createClip(this._mixer, root, clip);
|
|
378
|
+
}
|
|
379
|
+
else {
|
|
380
|
+
|
|
381
|
+
const action = this._mixer.clipAction(clip);
|
|
382
|
+
return action;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
private evaluateCondition(cond: Condition): boolean {
|
|
387
|
+
const param = this.model.parameters.find(p => p.name === cond.parameter);
|
|
388
|
+
if (!param) return false;
|
|
389
|
+
// console.log(param.name, param.value);
|
|
390
|
+
switch (cond.mode) {
|
|
391
|
+
case AnimatorConditionMode.If:
|
|
392
|
+
return param.value === true;
|
|
393
|
+
case AnimatorConditionMode.IfNot:
|
|
394
|
+
return param.value === false;
|
|
395
|
+
case AnimatorConditionMode.Greater:
|
|
396
|
+
return param.value > cond.threshold;
|
|
397
|
+
case AnimatorConditionMode.Less:
|
|
398
|
+
return param.value < cond.threshold;
|
|
399
|
+
case AnimatorConditionMode.Equals:
|
|
400
|
+
return param.value === cond.threshold;
|
|
401
|
+
case AnimatorConditionMode.NotEqual:
|
|
402
|
+
return param.value !== cond.threshold;
|
|
403
|
+
}
|
|
404
|
+
return false;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
private createActions(_animator: Animator) {
|
|
408
|
+
for (const layer of this.model.layers) {
|
|
409
|
+
const sm = layer.stateMachine;
|
|
410
|
+
for (let index = 0; index < sm.states.length; index++) {
|
|
411
|
+
const state = sm.states[index];
|
|
412
|
+
|
|
413
|
+
// ensure we have a motion even if none was exported
|
|
414
|
+
if (!state.motion) {
|
|
415
|
+
state.motion = createMotion(state.name);
|
|
416
|
+
// console.warn("Missing motion", "AnimatorController: " + this.model.name, state);
|
|
417
|
+
// sm.states.splice(index, 1);
|
|
418
|
+
// index -= 1;
|
|
419
|
+
// continue;
|
|
420
|
+
}
|
|
421
|
+
// the clips array contains which animator has which animationclip
|
|
422
|
+
if (this.animator && state.motion.clips) {
|
|
423
|
+
// TODO: we have to compare by name because on instantiate we clone objects but not the node object
|
|
424
|
+
const mapping = state.motion.clips?.find(e => e.node.name === this.animator?.gameObject?.name);
|
|
425
|
+
// console.log(state.name, mapping?.clip);
|
|
426
|
+
state.motion.clip = mapping?.clip;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
// ensure we have a clip to blend to
|
|
430
|
+
if (!state.motion.clip) {
|
|
431
|
+
const clip = new AnimationClip();
|
|
432
|
+
state.motion.clip = clip;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
if (state.motion?.clip) {
|
|
436
|
+
const clip = state.motion.clip;
|
|
437
|
+
const action = this.createAction(clip);
|
|
438
|
+
state.motion.action = action;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
// create state machine behaviours
|
|
442
|
+
if (state.behaviours && Array.isArray(state.behaviours)) {
|
|
443
|
+
for (const behaviour of state.behaviours) {
|
|
444
|
+
if (!behaviour?.typeName) continue;
|
|
445
|
+
const type = TypeStore.get(behaviour.typeName);
|
|
446
|
+
const instance: StateMachineBehaviour = new type() as StateMachineBehaviour;
|
|
447
|
+
if (instance.isStateMachineBehaviour) {
|
|
448
|
+
instance._context = this.context ?? undefined;
|
|
449
|
+
assign(instance, behaviour.properties);
|
|
450
|
+
behaviour.instance = instance;
|
|
451
|
+
}
|
|
452
|
+
if (debug) console.log("Created animator controller behaviour", state.name, behaviour.typeName, behaviour.properties, instance);
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
private *enumerateActions() {
|
|
460
|
+
|
|
461
|
+
for (const layer of this.model.layers) {
|
|
462
|
+
const sm = layer.stateMachine;
|
|
463
|
+
for (let index = 0; index < sm.states.length; index++) {
|
|
464
|
+
const state = sm.states[index];
|
|
465
|
+
if (state?.motion) {
|
|
466
|
+
if (state.motion.action)
|
|
467
|
+
yield state.motion.action;
|
|
468
|
+
if (state.motion.action_loopback)
|
|
469
|
+
yield state.motion.action_loopback;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
|
|
476
|
+
// https://docs.unity3d.com/Manual/RootMotion.html
|
|
477
|
+
private rootMotionHandler?: RootMotionHandler;
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
// private findRootBone(obj: THREE.Object3D): THREE.Object3D | null {
|
|
481
|
+
// if (this.animationRoot) return this.animationRoot;
|
|
482
|
+
// if (obj.type === "Bone") {
|
|
483
|
+
// this.animationRoot = obj as THREE.Bone;
|
|
484
|
+
// return this.animationRoot;
|
|
485
|
+
// }
|
|
486
|
+
// if (obj.children) {
|
|
487
|
+
// for (const ch of obj.children) {
|
|
488
|
+
// const res = this.findRootBone(ch);
|
|
489
|
+
// if (res) return res;
|
|
490
|
+
// }
|
|
491
|
+
// }
|
|
492
|
+
// return null;
|
|
493
|
+
// }
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
class TrackEvaluationWrapper {
|
|
497
|
+
|
|
498
|
+
track?: KeyframeTrack;
|
|
499
|
+
createdInterpolant?: any;
|
|
500
|
+
originalEvaluate?: Function;
|
|
501
|
+
private customEvaluate?: (time: number) => any;
|
|
502
|
+
|
|
503
|
+
constructor(track: KeyframeTrack, evaluate: (time: number, value: any) => any) {
|
|
504
|
+
this.track = track;
|
|
505
|
+
const t = track as any;
|
|
506
|
+
const createOriginalInterpolator = t.createInterpolant.bind(track);
|
|
507
|
+
t.createInterpolant = () => {
|
|
508
|
+
t.createInterpolant = createOriginalInterpolator;
|
|
509
|
+
this.createdInterpolant = createOriginalInterpolator();
|
|
510
|
+
this.originalEvaluate = this.createdInterpolant.evaluate.bind(this.createdInterpolant);
|
|
511
|
+
this.customEvaluate = time => {
|
|
512
|
+
if (!this.originalEvaluate) return;
|
|
513
|
+
const res = this.originalEvaluate(time);
|
|
514
|
+
return evaluate(time, res);
|
|
515
|
+
};
|
|
516
|
+
this.createdInterpolant.evaluate = this.customEvaluate;
|
|
517
|
+
return this.createdInterpolant;
|
|
518
|
+
}
|
|
519
|
+
};
|
|
520
|
+
|
|
521
|
+
evaluate(time) {
|
|
522
|
+
if (this.customEvaluate) {
|
|
523
|
+
this.customEvaluate(time);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
dispose() {
|
|
528
|
+
if (this.createdInterpolant && this.originalEvaluate) {
|
|
529
|
+
this.createdInterpolant.evaluate = this.originalEvaluate;
|
|
530
|
+
}
|
|
531
|
+
this.track = undefined;
|
|
532
|
+
this.createdInterpolant = null;
|
|
533
|
+
this.originalEvaluate = undefined;
|
|
534
|
+
this.customEvaluate = undefined;
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
class RootMotionAction {
|
|
539
|
+
|
|
540
|
+
private static lastObjPosition: { [key: string]: THREE.Vector3 } = {};
|
|
541
|
+
static lastObjRotation: { [key: string]: THREE.Quaternion } = {};
|
|
542
|
+
|
|
543
|
+
// we remove the first keyframe rotation from the space rotation when updating
|
|
544
|
+
private static firstKeyframeRotation: { [key: string]: THREE.Quaternion } = {};
|
|
545
|
+
// this is used to rotate the space on clip end / start (so the transform direction is correct)
|
|
546
|
+
private static spaceRotation: { [key: string]: THREE.Quaternion } = {};
|
|
547
|
+
private static effectiveSpaceRotation: { [key: string]: THREE.Quaternion } = {};
|
|
548
|
+
|
|
549
|
+
private static clipOffsetRotation: { [key: string]: THREE.Quaternion } = {};
|
|
550
|
+
|
|
551
|
+
|
|
552
|
+
set action(val: AnimationAction) {
|
|
553
|
+
this._action = val;
|
|
554
|
+
}
|
|
555
|
+
get action() {
|
|
556
|
+
return this._action;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
private _action!: AnimationAction;
|
|
560
|
+
|
|
561
|
+
private root: Object3D;
|
|
562
|
+
private clip: AnimationClip;
|
|
563
|
+
private positionWrapper: TrackEvaluationWrapper | null = null;
|
|
564
|
+
private rotationWrapper: TrackEvaluationWrapper | null = null;
|
|
565
|
+
private context: Context;
|
|
566
|
+
|
|
567
|
+
positionChange: Vector3 = new Vector3();
|
|
568
|
+
rotationChange: Quaternion = new Quaternion();
|
|
569
|
+
|
|
570
|
+
constructor(context: Context, root: THREE.Object3D, clip: AnimationClip, positionTrack: KeyframeTrack | null, rotationTrack: KeyframeTrack | null) {
|
|
571
|
+
// console.log(this, positionTrack, rotationTrack);
|
|
572
|
+
this.context = context;
|
|
573
|
+
this.root = root;
|
|
574
|
+
this.clip = clip;
|
|
575
|
+
|
|
576
|
+
if (!RootMotionAction.firstKeyframeRotation[clip.uuid])
|
|
577
|
+
RootMotionAction.firstKeyframeRotation[clip.uuid] = new THREE.Quaternion();
|
|
578
|
+
if (rotationTrack) {
|
|
579
|
+
const values = rotationTrack.values;
|
|
580
|
+
RootMotionAction.firstKeyframeRotation[clip.uuid]
|
|
581
|
+
.set(values[0], values[1], values[2], values[3])
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
if (!RootMotionAction.spaceRotation[clip.uuid])
|
|
585
|
+
RootMotionAction.spaceRotation[clip.uuid] = new Quaternion();
|
|
586
|
+
|
|
587
|
+
if (!RootMotionAction.effectiveSpaceRotation[clip.uuid])
|
|
588
|
+
RootMotionAction.effectiveSpaceRotation[clip.uuid] = new Quaternion();
|
|
589
|
+
|
|
590
|
+
RootMotionAction.clipOffsetRotation[clip.uuid] = new Quaternion();
|
|
591
|
+
if (rotationTrack) {
|
|
592
|
+
RootMotionAction.clipOffsetRotation[clip.uuid]
|
|
593
|
+
.set(rotationTrack.values[0], rotationTrack.values[1], rotationTrack.values[2], rotationTrack.values[3])
|
|
594
|
+
.invert();
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
this.handlePosition(clip, positionTrack);
|
|
598
|
+
this.handleRotation(clip, rotationTrack);
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
onStart(action: AnimationAction) {
|
|
602
|
+
if (action.getClip() !== this.clip) return;
|
|
603
|
+
|
|
604
|
+
const lastRotation = RootMotionAction.lastObjRotation[this.root.uuid];
|
|
605
|
+
// const firstKeyframe = RootMotionAction.firstKeyframeRotation[this.clip.uuid];
|
|
606
|
+
// lastRotation.invert().premultiply(firstKeyframe).invert();
|
|
607
|
+
RootMotionAction.spaceRotation[this.clip.uuid].copy(lastRotation);
|
|
608
|
+
|
|
609
|
+
// if (debugRootMotion)
|
|
610
|
+
{
|
|
611
|
+
const euler = new THREE.Euler().setFromQuaternion(lastRotation);
|
|
612
|
+
console.log("START", this.clip.name, Mathf.toDegrees(euler.y));
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
private getClipRotationOffset() {
|
|
617
|
+
return RootMotionAction.clipOffsetRotation[this.clip.uuid];
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
private handlePosition(_clip: AnimationClip, track: KeyframeTrack | null) {
|
|
621
|
+
if (track) {
|
|
622
|
+
const root = this.root;
|
|
623
|
+
if (debugRootMotion)
|
|
624
|
+
root.add(new AxesHelper());
|
|
625
|
+
if (!RootMotionAction.lastObjPosition[root.uuid]) RootMotionAction.lastObjPosition[root.uuid] = new Vector3();
|
|
626
|
+
const valuesDiff = new Vector3();
|
|
627
|
+
const valuesPrev = new Vector3();
|
|
628
|
+
let prevTime: number = 0;
|
|
629
|
+
// const rotation = new Quaternion();
|
|
630
|
+
this.positionWrapper = new TrackEvaluationWrapper(track, (time, value: Float64Array) => {
|
|
631
|
+
|
|
632
|
+
const weight = this.action.getEffectiveWeight();
|
|
633
|
+
|
|
634
|
+
// root.position.copy(RootMotionAction.lastObjPosition[root.uuid]);
|
|
635
|
+
|
|
636
|
+
// reset for testing
|
|
637
|
+
if (debugRootMotion) {
|
|
638
|
+
if (root.position.length() > 8)
|
|
639
|
+
root.position.set(0, root.position.y, 0);
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
|
|
643
|
+
if (time > prevTime) {
|
|
644
|
+
valuesDiff.set(value[0], value[1], value[2]);
|
|
645
|
+
valuesDiff.sub(valuesPrev);
|
|
646
|
+
valuesDiff.multiplyScalar(weight);
|
|
647
|
+
valuesDiff.applyQuaternion(this.getClipRotationOffset());
|
|
648
|
+
|
|
649
|
+
const id = this.clip.uuid;
|
|
650
|
+
// RootMotionAction.effectiveSpaceRotation[id].slerp(RootMotionAction.spaceRotation[id], weight);
|
|
651
|
+
valuesDiff.applyQuaternion(RootMotionAction.spaceRotation[id]);
|
|
652
|
+
this.positionChange.copy(valuesDiff);
|
|
653
|
+
// root.position.add(valuesDiff);
|
|
654
|
+
}
|
|
655
|
+
// RootMotionAction.lastObjPosition[root.uuid].copy(root.position);
|
|
656
|
+
valuesPrev.fromArray(value);
|
|
657
|
+
prevTime = time;
|
|
658
|
+
value[0] = 0;
|
|
659
|
+
value[1] = 0;
|
|
660
|
+
value[2] = 0;
|
|
661
|
+
return value;
|
|
662
|
+
|
|
663
|
+
});
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
private static identityQuaternion = new Quaternion();
|
|
668
|
+
|
|
669
|
+
private handleRotation(clip: AnimationClip, track: KeyframeTrack | null) {
|
|
670
|
+
if (track) {
|
|
671
|
+
if (debugRootMotion) {
|
|
672
|
+
const arr = track.values;
|
|
673
|
+
const firstKeyframe = new Euler().setFromQuaternion(new Quaternion(arr[0], arr[1], arr[2], arr[3]));
|
|
674
|
+
console.log(clip.name, track.name, "FIRST ROTATION IN TRACK", Mathf.toDegrees(firstKeyframe.y));
|
|
675
|
+
const i = track.values.length - 4;
|
|
676
|
+
const lastKeyframe = new Quaternion().set(arr[i], arr[i + 1], arr[i + 2], arr[i + 3]);
|
|
677
|
+
const euler = new Euler().setFromQuaternion(lastKeyframe);
|
|
678
|
+
console.log(clip.name, track.name, "LAST ROTATION IN TRACK", Mathf.toDegrees(euler.y));
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
|
|
682
|
+
const root = this.root;
|
|
683
|
+
if (!RootMotionAction.lastObjRotation[root.uuid]) RootMotionAction.lastObjRotation[root.uuid] = new Quaternion();
|
|
684
|
+
// const temp = new Quaternion();
|
|
685
|
+
let prevTime: number = 0;
|
|
686
|
+
const valuesPrev = new Quaternion();
|
|
687
|
+
const valuesDiff = new Quaternion();
|
|
688
|
+
// const summedRot = new Quaternion();
|
|
689
|
+
this.rotationWrapper = new TrackEvaluationWrapper(track, (time, value: Float64Array) => {
|
|
690
|
+
// root.quaternion.copy(RootMotionAction.lastObjRotation[root.uuid]);
|
|
691
|
+
if (time > prevTime) {
|
|
692
|
+
valuesDiff.set(value[0], value[1], value[2], value[3]);
|
|
693
|
+
valuesPrev.invert();
|
|
694
|
+
valuesDiff.multiply(valuesPrev);
|
|
695
|
+
// if(weight < .99) valuesDiff.slerp(RootMotionAction.identityQuaternion, 1 - weight);
|
|
696
|
+
this.rotationChange.copy(valuesDiff);
|
|
697
|
+
// root.quaternion.multiply(valuesDiff);
|
|
698
|
+
}
|
|
699
|
+
// else
|
|
700
|
+
// root.quaternion.multiply(this.getClipRotationOffset());
|
|
701
|
+
|
|
702
|
+
// RootMotionAction.lastObjRotation[root.uuid].copy(root.quaternion);
|
|
703
|
+
valuesPrev.fromArray(value);
|
|
704
|
+
prevTime = time;
|
|
705
|
+
value[0] = 0;
|
|
706
|
+
value[1] = 0;
|
|
707
|
+
value[2] = 0;
|
|
708
|
+
value[3] = 1;
|
|
709
|
+
return value;
|
|
710
|
+
});
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
// private lastPos: Vector3 = new Vector3();
|
|
715
|
+
|
|
716
|
+
onBeforeUpdate() {
|
|
717
|
+
this.positionChange.set(0, 0, 0);
|
|
718
|
+
this.rotationChange.set(0, 0, 0, 1);
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
onAfterUpdate() {
|
|
722
|
+
const weight = this.action.getEffectiveWeight();
|
|
723
|
+
this.positionChange.multiplyScalar(weight);
|
|
724
|
+
this.rotationChange.slerp(RootMotionAction.identityQuaternion, 1 - weight);
|
|
725
|
+
// const root = this.root;
|
|
726
|
+
// RootMotionAction.lastObjRotation[root.uuid].slerp(root.quaternion, weight);
|
|
727
|
+
// if (weight > .5) {
|
|
728
|
+
// }
|
|
729
|
+
// this.obj.position.copy(this.lastPos).add(this.positionDiff);
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
class RootMotionHandler {
|
|
734
|
+
|
|
735
|
+
private controller: AnimatorController;
|
|
736
|
+
private handler: RootMotionAction[] = [];
|
|
737
|
+
private root!: THREE.Object3D;
|
|
738
|
+
|
|
739
|
+
constructor(controller: AnimatorController) {
|
|
740
|
+
this.controller = controller;
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
createClip(mixer: AnimationMixer, root: THREE.Object3D, clip: AnimationClip): AnimationAction {
|
|
744
|
+
this.root = root;
|
|
745
|
+
let rootName = "";
|
|
746
|
+
if (root && "name" in root) {
|
|
747
|
+
rootName = root.name;
|
|
748
|
+
}
|
|
749
|
+
const positionTrack = this.findRootTrack(clip, ".position");
|
|
750
|
+
const rotationTrack = this.findRootTrack(clip, ".quaternion");
|
|
751
|
+
const handler = new RootMotionAction(this.controller.context!, root, clip, positionTrack, rotationTrack);
|
|
752
|
+
this.handler.push(handler);
|
|
753
|
+
|
|
754
|
+
// it is important we do this after the handler is created
|
|
755
|
+
// otherwise we can not hook into threejs interpolators
|
|
756
|
+
const action = mixer.clipAction(clip);
|
|
757
|
+
handler.action = action;
|
|
758
|
+
return action;
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
onStart(action: AnimationAction) {
|
|
762
|
+
for (const handler of this.handler) {
|
|
763
|
+
handler.onStart(action);
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
onBeforeUpdate() {
|
|
768
|
+
for (const hand of this.handler)
|
|
769
|
+
hand.onBeforeUpdate();
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
private summedPosition: Vector3 = new Vector3();
|
|
773
|
+
private summedRotation: Quaternion = new Quaternion();
|
|
774
|
+
|
|
775
|
+
onAfterUpdate() {
|
|
776
|
+
this.summedPosition.set(0, 0, 0);
|
|
777
|
+
this.summedRotation.set(0, 0, 0, 1);
|
|
778
|
+
for (const entry of this.handler) {
|
|
779
|
+
entry.onAfterUpdate();
|
|
780
|
+
this.summedPosition.add(entry.positionChange);
|
|
781
|
+
this.summedRotation.multiply(entry.rotationChange);
|
|
782
|
+
}
|
|
783
|
+
this.root.position.add(this.summedPosition);
|
|
784
|
+
this.root.quaternion.multiply(this.summedRotation);
|
|
785
|
+
RootMotionAction.lastObjRotation[this.root.uuid].copy(this.root.quaternion);
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
private findRootTrack(clip: AnimationClip, name: string) {
|
|
789
|
+
const tracks = clip.tracks;
|
|
790
|
+
for (const track of tracks) {
|
|
791
|
+
if (track.name.endsWith(name)) {
|
|
792
|
+
// if (track.name.includes("Hips"))
|
|
793
|
+
// return track;
|
|
794
|
+
return track;
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
return null;
|
|
798
|
+
}
|
|
799
|
+
}
|