@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,138 @@
|
|
|
1
|
+
import { IExtensionReferenceResolver } from "./extension_resolver";
|
|
2
|
+
import { GLTFParser } from "three/examples/jsm/loaders/GLTFLoader";
|
|
3
|
+
import { debugExtension } from "../engine_default_parameters";
|
|
4
|
+
import { getParam } from "../engine_utils";
|
|
5
|
+
|
|
6
|
+
const debug = getParam("debugresolvedependencies");
|
|
7
|
+
|
|
8
|
+
declare type DependencyInfo = {
|
|
9
|
+
prefix: string,
|
|
10
|
+
dependencyName: string,
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const defaultDependencies = [
|
|
14
|
+
{ prefix: "nodes/", dependencyName: "node" },
|
|
15
|
+
{ prefix: "meshes/", dependencyName: "mesh" },
|
|
16
|
+
{ prefix: "materials/", dependencyName: "material" },
|
|
17
|
+
{ prefix: "textures/", dependencyName: "texture" },
|
|
18
|
+
{ prefix: "animations/", dependencyName: "animation" }
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
export async function resolveReferences(parser: GLTFParser, obj) {
|
|
22
|
+
if(debug) console.log(parser, obj);
|
|
23
|
+
const arr: Promise<void>[] = [];
|
|
24
|
+
internalResolve(defaultDependencies, parser, obj, arr);
|
|
25
|
+
const res = await Promise.all(arr);
|
|
26
|
+
if (typeof obj === "string" && res.length === 1) return res[0];
|
|
27
|
+
return res;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
function internalResolve(paths: DependencyInfo[], parser: GLTFParser, obj, promises: Promise<void>[]) {
|
|
32
|
+
if (typeof obj === "object" && obj !== undefined && obj !== null) {
|
|
33
|
+
for (const key of Object.keys(obj)) {
|
|
34
|
+
const val = obj[key];
|
|
35
|
+
// handle json pointer in string variable
|
|
36
|
+
if (typeof val === "string") {
|
|
37
|
+
const ext = resolveExtension(parser, val);
|
|
38
|
+
if (ext !== null) {
|
|
39
|
+
if (typeof ext.then === "function")
|
|
40
|
+
promises.push(ext.then(res => obj[key] = res));
|
|
41
|
+
else obj[key] = ext;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
// e.g. prefix = "materials/";
|
|
45
|
+
for (const dep of paths) {
|
|
46
|
+
const index = tryGetIndex(dep.prefix, val);
|
|
47
|
+
if (index >= 0) {
|
|
48
|
+
// e.g. dependencyName = "material"
|
|
49
|
+
if (debug) console.log(dep, index, dep.dependencyName);
|
|
50
|
+
promises.push(parser?.getDependency(dep.dependencyName, index).then(res => {
|
|
51
|
+
obj[key] = res;
|
|
52
|
+
return res;
|
|
53
|
+
}));
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
// handle json pointers in arrays
|
|
60
|
+
else if (Array.isArray(val)) {
|
|
61
|
+
for (let i = 0; i < val.length; i++) {
|
|
62
|
+
const entry = val[i];
|
|
63
|
+
const ext = resolveExtension(parser, entry);
|
|
64
|
+
if (ext !== null) {
|
|
65
|
+
if (typeof ext.then === "function")
|
|
66
|
+
promises.push(ext.then(res => val[i] = res));
|
|
67
|
+
else val[i] = ext;
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
for (const dep of paths) {
|
|
71
|
+
const index = tryGetIndex(dep.prefix, entry);
|
|
72
|
+
if (index >= 0) {
|
|
73
|
+
if (debug) console.log(dep, index, dep.dependencyName);
|
|
74
|
+
promises.push(parser?.getDependency(dep.dependencyName, index).then(res => val[i] = res));
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
// recurse
|
|
79
|
+
if (typeof entry === "object") {
|
|
80
|
+
internalResolve(paths, parser, entry, promises);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
// recurse
|
|
85
|
+
else if (typeof val === "object") {
|
|
86
|
+
internalResolve(paths, parser, val, promises);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
else if (typeof obj === "string") {
|
|
91
|
+
tryResolveDependency(paths, parser, obj, promises);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
const rootExtensionPrefix = "extensions/";
|
|
97
|
+
function resolveExtension(parser: GLTFParser, str): Promise<void> | null {
|
|
98
|
+
if (parser && parser.plugins && typeof str === "string" && str.startsWith(rootExtensionPrefix)) {
|
|
99
|
+
let name = str.substring(rootExtensionPrefix.length);
|
|
100
|
+
const endIndex = name.indexOf("/");
|
|
101
|
+
if (endIndex >= 0) name = name.substring(0, endIndex);
|
|
102
|
+
const ext = parser.plugins[name] as IExtensionReferenceResolver;
|
|
103
|
+
if (debugExtension)
|
|
104
|
+
console.log(name, ext);
|
|
105
|
+
if (typeof ext?.resolve === "function") {
|
|
106
|
+
const path = str.substring(rootExtensionPrefix.length + name.length + 1);
|
|
107
|
+
return ext.resolve(parser, path);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function tryResolveDependency(paths: DependencyInfo[], parser: GLTFParser, str: string, promises: Promise<void>[]): boolean {
|
|
114
|
+
for (const dep of paths) {
|
|
115
|
+
const index = tryGetIndex(dep.prefix, str);
|
|
116
|
+
if (index >= 0) {
|
|
117
|
+
// e.g. dependencyName = "material"
|
|
118
|
+
if (debug) console.log(dep, index, dep.dependencyName);
|
|
119
|
+
promises.push(parser?.getDependency(dep.dependencyName, index).then(res => {
|
|
120
|
+
return res;
|
|
121
|
+
}));
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function tryGetIndex(prefix: string, str: string): number {
|
|
129
|
+
|
|
130
|
+
if (typeof str === "string" && str.startsWith(prefix)) {
|
|
131
|
+
const part = str.substring(prefix.length);
|
|
132
|
+
const index = Number.parseInt(part);
|
|
133
|
+
if (index >= 0) {
|
|
134
|
+
return index;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return -1;
|
|
138
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { NEEDLE_techniques_webgl } from "./NEEDLE_techniques_webgl";
|
|
2
|
+
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader";
|
|
3
|
+
import { NEEDLE_components } from "./NEEDLE_components";
|
|
4
|
+
import { EXT_texture_exr } from "./EXT_texture_exr";
|
|
5
|
+
import { NEEDLE_gameobject_data } from "./NEEDLE_gameobject_data";
|
|
6
|
+
// import { NEEDLE_timeline } from "./NEEDLE_timeline";
|
|
7
|
+
// import { NEEDLE_animator_controller } from "./NEEDLE_animator_controller";
|
|
8
|
+
import { NEEDLE_persistent_assets } from "./NEEDLE_persistent_assets";
|
|
9
|
+
// import { KHR_animation_pointer } from "./KHR_animation_pointer";
|
|
10
|
+
import { NEEDLE_lightmaps } from "../extensions/NEEDLE_lightmaps";
|
|
11
|
+
import { SourceIdentifier } from "../engine_gltf";
|
|
12
|
+
import { Context } from "../engine_setup";
|
|
13
|
+
import { NEEDLE_lighting_settings } from "./NEEDLE_lighting_settings";
|
|
14
|
+
import { NEEDLE_render_objects } from "./NEEDLE_render_objects";
|
|
15
|
+
import { NEEDLE_deferred_texture } from "./NEEDLE_deferred_texture";
|
|
16
|
+
|
|
17
|
+
export function registerComponentExtension(loader: GLTFLoader): NEEDLE_components {
|
|
18
|
+
const ext = new NEEDLE_components();
|
|
19
|
+
loader.register(p => {
|
|
20
|
+
ext.parser = p;
|
|
21
|
+
return ext;
|
|
22
|
+
});
|
|
23
|
+
return ext;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
class PointerResolver {
|
|
27
|
+
resolvePath(path: string) {
|
|
28
|
+
if (path.includes('/extensions/builtin_components/'))
|
|
29
|
+
path = path.replace('/extensions/builtin_components/', '/userData/components/');
|
|
30
|
+
|
|
31
|
+
return path;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function registerExtensions(loader: GLTFLoader, context: Context, sourceId: SourceIdentifier) {
|
|
36
|
+
loader.register(p => new NEEDLE_gameobject_data(p));
|
|
37
|
+
loader.register(p => new NEEDLE_persistent_assets(p));
|
|
38
|
+
loader.register(p => new NEEDLE_lightmaps(p, context.lightmaps, sourceId));
|
|
39
|
+
loader.register(p => new NEEDLE_lighting_settings(p, sourceId, context));
|
|
40
|
+
loader.register(p => new NEEDLE_techniques_webgl(p, sourceId));
|
|
41
|
+
loader.register(p => new NEEDLE_render_objects(p, sourceId));
|
|
42
|
+
loader.register(p => new NEEDLE_deferred_texture(p, sourceId, context));
|
|
43
|
+
loader.register(p => new EXT_texture_exr(p));
|
|
44
|
+
|
|
45
|
+
const setPointerResolverFunction = loader["setAnimationPointerResolver"];
|
|
46
|
+
if (typeof setPointerResolverFunction === "function")
|
|
47
|
+
setPointerResolverFunction.bind(loader)(new PointerResolver());
|
|
48
|
+
|
|
49
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export class ShaderData {
|
|
5
|
+
programs: Array<ShaderProgram> = [];
|
|
6
|
+
shaders: Array<Shader> = [];
|
|
7
|
+
techniques: Array<Technique> = [];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export class ShaderProgram {
|
|
11
|
+
vertexShader: number | undefined;
|
|
12
|
+
fragmentShader: number | undefined;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export enum ShaderType {
|
|
16
|
+
|
|
17
|
+
Fragment = 35632,
|
|
18
|
+
Vertex = 35633,
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export class Shader {
|
|
22
|
+
name: string | undefined;
|
|
23
|
+
type: ShaderType | undefined;
|
|
24
|
+
uri: string | null | undefined;
|
|
25
|
+
code: string | null | undefined;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export class Technique {
|
|
29
|
+
program: number | undefined;
|
|
30
|
+
attributes: Map<string, ShaderAttribute> = new Map();;
|
|
31
|
+
uniforms: Map<string, ShaderUniform> = new Map();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export class ShaderAttribute {
|
|
35
|
+
semantic: string | undefined;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export class ShaderUniform {
|
|
39
|
+
name: string = "";
|
|
40
|
+
type: UniformType | undefined;
|
|
41
|
+
semantic: string | undefined;
|
|
42
|
+
count : number = 0;
|
|
43
|
+
node : number = 0;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
export enum UniformType {
|
|
49
|
+
INT = 5124,
|
|
50
|
+
FLOAT = 5126,
|
|
51
|
+
FLOAT_VEC2 = 35664,
|
|
52
|
+
FLOAT_VEC3 = 35665,
|
|
53
|
+
FLOAT_VEC4 = 35666,
|
|
54
|
+
INT_VEC2 = 35667,
|
|
55
|
+
INT_VEC3 = 35668,
|
|
56
|
+
INT_VEC4 = 35669,
|
|
57
|
+
BOOL = 35670, // exported as int
|
|
58
|
+
BOOL_VEC2 = 35671,
|
|
59
|
+
BOOL_VEC3 = 35672,
|
|
60
|
+
BOOL_VEC4 = 35673,
|
|
61
|
+
FLOAT_MAT2 = 35674, // exported as vec2[2]
|
|
62
|
+
FLOAT_MAT3 = 35675, // exported as vec3[3]
|
|
63
|
+
FLOAT_MAT4 = 35676, // exported as vec4[4]
|
|
64
|
+
SAMPLER_2D = 35678,
|
|
65
|
+
SAMPLER_3D = 35680, // added, not in the proposed extension
|
|
66
|
+
SAMPLER_CUBE = 35681, // added, not in the proposed extension
|
|
67
|
+
UNKNOWN = 0,
|
|
68
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
|
|
2
|
+
import * as utils from "../engine_utils";
|
|
3
|
+
import { noVoip } from "../../engine-components/Voip";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export function detect_run_tests(){
|
|
7
|
+
const count = (utils.getParam("testwindowcount") || 0) as number;
|
|
8
|
+
if(count && count > 0){
|
|
9
|
+
spawnWindows(count);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function spawnWindows(count: number): Window[] | null {
|
|
14
|
+
|
|
15
|
+
if(utils.getParam("testwindow")) return null;
|
|
16
|
+
|
|
17
|
+
const url = new URL(window.location.href);
|
|
18
|
+
utils.setOrAddParamsToUrl(url.searchParams, noVoip, 1);
|
|
19
|
+
utils.setOrAddParamsToUrl(url.searchParams, "testwindow", 1);
|
|
20
|
+
const str = url.toString();
|
|
21
|
+
|
|
22
|
+
const windows : Window[] = [];
|
|
23
|
+
|
|
24
|
+
window.onbeforeunload = () =>{
|
|
25
|
+
for(const w of windows) w.close();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const spacing = .05;
|
|
29
|
+
const size = 128;// (Math.min(window.innerWidth, window.innerHeight) / Math.sqrt(count)) * (1-spacing);
|
|
30
|
+
let x = 0;
|
|
31
|
+
let y = 0;
|
|
32
|
+
for (let i = 0; i < count; i++) {
|
|
33
|
+
|
|
34
|
+
if ((x * size + size*.01) >= window.innerWidth) {
|
|
35
|
+
y += 1;
|
|
36
|
+
x = 0;
|
|
37
|
+
}
|
|
38
|
+
const px = x * (size * (1+spacing)) + window.screenLeft;
|
|
39
|
+
const py = y * (size * (1+spacing)) + window.screenTop + 90 + 60 * y;
|
|
40
|
+
x += 1;
|
|
41
|
+
|
|
42
|
+
// console.log(size, px, py);
|
|
43
|
+
const testWindow = window.open(str, "test window " + i, `popup=yes width=${size} height=${size} top=${py} left=${px}`);
|
|
44
|
+
|
|
45
|
+
if(!testWindow){
|
|
46
|
+
console.warn("Failed to open window");
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
windows.push(testWindow);
|
|
50
|
+
testWindow.onload = () => {
|
|
51
|
+
testWindow.onbeforeunload = () => {
|
|
52
|
+
for (let i = 0; i < windows.length; i++) {
|
|
53
|
+
const w = windows[i];
|
|
54
|
+
if (w === testWindow) continue;
|
|
55
|
+
w.close();
|
|
56
|
+
}
|
|
57
|
+
windows.length = 0;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return windows;
|
|
63
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Behaviour, GameObject } from "./Component";
|
|
2
|
+
import * as utils from "./../engine/engine_three_utils";
|
|
3
|
+
import * as THREE from "three";
|
|
4
|
+
|
|
5
|
+
export class AlignmentConstraint extends Behaviour {
|
|
6
|
+
|
|
7
|
+
private from!: GameObject;
|
|
8
|
+
private to!: GameObject;
|
|
9
|
+
private width: number = 0;
|
|
10
|
+
private centered: boolean = true;
|
|
11
|
+
|
|
12
|
+
private _centerPos!: THREE.Vector3;
|
|
13
|
+
|
|
14
|
+
awake(): void {
|
|
15
|
+
this._centerPos = new THREE.Vector3();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
update() {
|
|
19
|
+
if (!this.from || !this.to) return;
|
|
20
|
+
|
|
21
|
+
const fromWorldPos = utils.getWorldPosition(this.from).clone();
|
|
22
|
+
const toWorldPos = utils.getWorldPosition(this.to).clone();
|
|
23
|
+
const dist = fromWorldPos.distanceTo(toWorldPos);
|
|
24
|
+
|
|
25
|
+
this._centerPos.copy(fromWorldPos);
|
|
26
|
+
this._centerPos.add(toWorldPos);
|
|
27
|
+
this._centerPos.multiplyScalar(0.5);
|
|
28
|
+
|
|
29
|
+
utils.setWorldPosition(this.gameObject, this.centered ? this._centerPos : fromWorldPos);
|
|
30
|
+
this.gameObject.lookAt(utils.getWorldPosition(this.to).clone());
|
|
31
|
+
this.gameObject.scale.set(this.width, this.width, dist);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import { Behaviour } from "./Component";
|
|
2
|
+
import * as THREE from 'three'
|
|
3
|
+
import { AnimationAction, AnimationClip } from "three";
|
|
4
|
+
import { MixerEvent } from "./Animator";
|
|
5
|
+
import { InstancingUtil } from "./Renderer";
|
|
6
|
+
import { serializeable } from "../engine/engine_serialization_decorator";
|
|
7
|
+
|
|
8
|
+
export declare class PlayOptions {
|
|
9
|
+
fadeDuration?: number;
|
|
10
|
+
loop?: boolean;
|
|
11
|
+
exclusive?: boolean;
|
|
12
|
+
startTime?: number;
|
|
13
|
+
endTime?: number;
|
|
14
|
+
clampWhenFinished?: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export class Animation extends Behaviour {
|
|
18
|
+
|
|
19
|
+
@serializeable()
|
|
20
|
+
playAutomatically: boolean = true;
|
|
21
|
+
@serializeable()
|
|
22
|
+
randomStartTime: boolean = true;
|
|
23
|
+
|
|
24
|
+
private _tempAnimationClipBeforeGameObjectExisted: AnimationClip | null = null;
|
|
25
|
+
get clip(): AnimationClip | null {
|
|
26
|
+
return this.animations?.length ? this.animations[0] : null;
|
|
27
|
+
}
|
|
28
|
+
set clip(val: AnimationClip | null) {
|
|
29
|
+
if (!this.gameObject) {
|
|
30
|
+
this._tempAnimationClipBeforeGameObjectExisted = val;
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (!val) return;
|
|
34
|
+
if (!this.gameObject.animations) this.gameObject.animations = [];
|
|
35
|
+
this.gameObject.animations.push(val);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
set animations(animations: THREE.AnimationClip[]) {
|
|
39
|
+
this.gameObject.animations = animations;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
get animations(): THREE.AnimationClip[] {
|
|
43
|
+
return this.gameObject.animations;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* @deprecated Currently unsupported
|
|
47
|
+
*/
|
|
48
|
+
get currentAction(): THREE.AnimationAction | null {
|
|
49
|
+
return this._currentActions[0];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @deprecated Currently unsupported
|
|
54
|
+
*/
|
|
55
|
+
get currentActions(): THREE.AnimationAction[] {
|
|
56
|
+
return this._currentActions;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
private mixer: THREE.AnimationMixer | undefined = undefined;
|
|
60
|
+
get actions(): Array<THREE.AnimationAction> {
|
|
61
|
+
return this._actions;
|
|
62
|
+
}
|
|
63
|
+
set actions(val: Array<THREE.AnimationAction>) {
|
|
64
|
+
this._actions = val;
|
|
65
|
+
}
|
|
66
|
+
private _actions: Array<THREE.AnimationAction> = [];
|
|
67
|
+
|
|
68
|
+
// private _currentAction: THREE.AnimationAction | null = null;
|
|
69
|
+
|
|
70
|
+
private _currentActions: THREE.AnimationAction[] = [];
|
|
71
|
+
private _handles: AnimationHandle[] = [];
|
|
72
|
+
|
|
73
|
+
awake() {
|
|
74
|
+
if (this._tempAnimationClipBeforeGameObjectExisted) {
|
|
75
|
+
this.clip = this._tempAnimationClipBeforeGameObjectExisted;
|
|
76
|
+
this._tempAnimationClipBeforeGameObjectExisted = null;
|
|
77
|
+
}
|
|
78
|
+
if (this.playAutomatically)
|
|
79
|
+
this.init();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
onEnable(): void {
|
|
83
|
+
if (this.playAutomatically && this.actions.length > 0 && this.currentActions.length <= 0) {
|
|
84
|
+
const index = Math.floor(Math.random() * this.actions.length);
|
|
85
|
+
this.play(index);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
start() {
|
|
90
|
+
if (this.randomStartTime && this.currentAction)
|
|
91
|
+
this.currentAction.time = Math.random() * this.currentAction.getClip().duration;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
update() {
|
|
95
|
+
if (!this.mixer) return;
|
|
96
|
+
this.mixer.update(this.context.time.deltaTime);
|
|
97
|
+
for (const handle of this._handles) {
|
|
98
|
+
handle._update();
|
|
99
|
+
}
|
|
100
|
+
if (this._handles?.length > 0)
|
|
101
|
+
InstancingUtil.markDirty(this.gameObject);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
getAction(name: string): THREE.AnimationAction | undefined | null {
|
|
105
|
+
return this.actions?.find(a => a.getClip().name === name);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
play(clipOrNumber: AnimationClip | number | string, options?: PlayOptions): Promise<AnimationAction> | void {
|
|
109
|
+
this.init();
|
|
110
|
+
if (!this.mixer) return;
|
|
111
|
+
let clip: AnimationClip | undefined = clipOrNumber as AnimationClip;
|
|
112
|
+
if (typeof clipOrNumber === 'number') {
|
|
113
|
+
if (clipOrNumber >= this.animations.length) return;
|
|
114
|
+
clip = this.animations[clipOrNumber];
|
|
115
|
+
}
|
|
116
|
+
else if (typeof clipOrNumber === "string") {
|
|
117
|
+
clip = this.animations.find(a => a.name === clipOrNumber);
|
|
118
|
+
}
|
|
119
|
+
if (!clip) {
|
|
120
|
+
console.error("Could not find clip", clipOrNumber)
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
for (const act of this.actions) {
|
|
124
|
+
if (act.getClip() === clip) {
|
|
125
|
+
return this.internalOnPlay(act, options);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
const act = this.mixer.clipAction(clip);
|
|
129
|
+
this.actions.push(act);
|
|
130
|
+
return this.internalOnPlay(act, options);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
internalOnPlay(action: AnimationAction, options?: PlayOptions): Promise<AnimationAction> {
|
|
134
|
+
var prev = this.currentAction;
|
|
135
|
+
if (prev === action && prev.isRunning() && prev.time < prev.getClip().duration) {
|
|
136
|
+
const handle = this.tryFindHandle(action);
|
|
137
|
+
if (handle) return handle.getPromise();
|
|
138
|
+
}
|
|
139
|
+
const stopOther = options?.exclusive ?? true;
|
|
140
|
+
if (options?.fadeDuration) {
|
|
141
|
+
if (stopOther)
|
|
142
|
+
prev?.fadeOut(options.fadeDuration);
|
|
143
|
+
action.fadeIn(options.fadeDuration);
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
if (stopOther)
|
|
147
|
+
prev?.stop();
|
|
148
|
+
}
|
|
149
|
+
action.reset();
|
|
150
|
+
action.enabled = true;
|
|
151
|
+
action.time = 0;
|
|
152
|
+
action.timeScale = 1;
|
|
153
|
+
if (options?.clampWhenFinished) action.clampWhenFinished = true;
|
|
154
|
+
if (options?.startTime !== undefined) action.time = options.startTime;
|
|
155
|
+
|
|
156
|
+
if (options?.loop !== undefined)
|
|
157
|
+
action.loop = options.loop ? THREE.LoopRepeat : THREE.LoopOnce;
|
|
158
|
+
action.play();
|
|
159
|
+
// console.log("PLAY", action.getClip().name, action)
|
|
160
|
+
|
|
161
|
+
const handle = new AnimationHandle(action, this.mixer!, options, _ => {
|
|
162
|
+
this._handles.splice(this._handles.indexOf(handle), 1);
|
|
163
|
+
// console.log(this._handles);
|
|
164
|
+
});
|
|
165
|
+
this._handles.push(handle);
|
|
166
|
+
return handle.getPromise();
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
private tryFindHandle(action: AnimationAction): AnimationHandle | undefined {
|
|
170
|
+
for (const handle of this._handles) {
|
|
171
|
+
if (handle.action === action)
|
|
172
|
+
return handle;
|
|
173
|
+
}
|
|
174
|
+
return undefined;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
private _didInit = false;
|
|
179
|
+
init() {
|
|
180
|
+
if (this._didInit) return;
|
|
181
|
+
this._didInit = true;
|
|
182
|
+
if (!this.gameObject) return;
|
|
183
|
+
this.actions = [];
|
|
184
|
+
this.mixer = new THREE.AnimationMixer(this.gameObject);
|
|
185
|
+
|
|
186
|
+
for (let i = 0; i < this.animations.length; i++) {
|
|
187
|
+
const action = this.mixer.clipAction(this.animations[i]);
|
|
188
|
+
this.actions.push(action);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
class AnimationHandle {
|
|
195
|
+
mixer: THREE.AnimationMixer;
|
|
196
|
+
action: THREE.AnimationAction;
|
|
197
|
+
promise: Promise<AnimationAction> | null = null;
|
|
198
|
+
resolve: Function | null = null;
|
|
199
|
+
reject: Function | null = null;
|
|
200
|
+
|
|
201
|
+
private _options?: PlayOptions | undefined;
|
|
202
|
+
private _resolveCallback: Function | null = null;
|
|
203
|
+
private _rejectCallback: Function | null = null;
|
|
204
|
+
private _loopCallback?: any;
|
|
205
|
+
private _finishedCallback?: any;
|
|
206
|
+
private _resolvedOrRejectedCallback?: (AnimationHandle) => void;
|
|
207
|
+
|
|
208
|
+
constructor(action: THREE.AnimationAction, mixer: THREE.AnimationMixer, opts?: PlayOptions, cb?: (handle: AnimationHandle) => void) {
|
|
209
|
+
this.action = action;
|
|
210
|
+
this.mixer = mixer;
|
|
211
|
+
this._resolvedOrRejectedCallback = cb;
|
|
212
|
+
this._options = opts;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
getPromise(): Promise<AnimationAction> {
|
|
216
|
+
if (this.promise) return this.promise;
|
|
217
|
+
|
|
218
|
+
this.promise = new Promise((res, rej) => {
|
|
219
|
+
this._resolveCallback = res;
|
|
220
|
+
this._rejectCallback = rej;
|
|
221
|
+
this.resolve = this.onResolve.bind(this);
|
|
222
|
+
this.reject = this.onReject.bind(this);
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
this._loopCallback = this.onLoop.bind(this);
|
|
226
|
+
this._finishedCallback = this.onFinished.bind(this);
|
|
227
|
+
this.mixer.addEventListener('loop', this._loopCallback);
|
|
228
|
+
this.mixer.addEventListener('finished', this._finishedCallback);
|
|
229
|
+
|
|
230
|
+
return this.promise;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
_update() {
|
|
234
|
+
|
|
235
|
+
if (!this._options) return;
|
|
236
|
+
if (this._options.endTime !== undefined && this.action.time > this._options.endTime) {
|
|
237
|
+
if (this._options.loop === true) {
|
|
238
|
+
this.action.time = this._options.startTime ?? 0;
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
// this.action.stop();
|
|
242
|
+
this.action.time = this._options.endTime;
|
|
243
|
+
this.action.timeScale = 0;
|
|
244
|
+
// if (!this._options.clampWhenFinished)
|
|
245
|
+
// this.action.stop();
|
|
246
|
+
this.onResolve();
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
private onResolve() {
|
|
252
|
+
this.dispose();
|
|
253
|
+
this._resolvedOrRejectedCallback?.call(this, this);
|
|
254
|
+
this._resolveCallback?.call(this, this.action);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
private onReject(reason: any) {
|
|
258
|
+
this.dispose();
|
|
259
|
+
this._resolvedOrRejectedCallback?.call(this, this);
|
|
260
|
+
this._rejectCallback?.call(this, reason);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
private onLoop(_evt: MixerEvent) {
|
|
264
|
+
// console.log("LOOP");
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
private onFinished(evt: MixerEvent) {
|
|
268
|
+
if (evt.action === this.action) {
|
|
269
|
+
// console.log("FINISHED", evt, this.action);
|
|
270
|
+
this.onResolve();
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
private dispose() {
|
|
275
|
+
if (this._loopCallback)
|
|
276
|
+
this.mixer.removeEventListener('loop', this._loopCallback);
|
|
277
|
+
if (this._finishedCallback)
|
|
278
|
+
this.mixer.removeEventListener('finished', this._finishedCallback);
|
|
279
|
+
this._loopCallback = undefined;
|
|
280
|
+
this._finishedCallback = undefined;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Mathf } from "../engine/engine_math";
|
|
2
|
+
import { serializeable } from "../engine/engine_serialization_decorator";
|
|
3
|
+
|
|
4
|
+
class Keyframe {
|
|
5
|
+
@serializeable()
|
|
6
|
+
time!: number;
|
|
7
|
+
@serializeable()
|
|
8
|
+
value!: number;
|
|
9
|
+
@serializeable()
|
|
10
|
+
inTangent!: number;
|
|
11
|
+
@serializeable()
|
|
12
|
+
inWeight!: number;
|
|
13
|
+
@serializeable()
|
|
14
|
+
outTangent!: number;
|
|
15
|
+
@serializeable()
|
|
16
|
+
outWeight!: number;
|
|
17
|
+
@serializeable()
|
|
18
|
+
weightedMode!: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export class AnimationCurve {
|
|
22
|
+
|
|
23
|
+
@serializeable(Keyframe)
|
|
24
|
+
keys!: Array<Keyframe>;
|
|
25
|
+
|
|
26
|
+
get duration() : number {
|
|
27
|
+
if(!this.keys || this.keys.length == 0) return 0;
|
|
28
|
+
return this.keys[this.keys.length - 1].time;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
evaluate(time: number): number {
|
|
32
|
+
if(!this.keys || this.keys.length == 0) return 0;
|
|
33
|
+
let lastKeyframe : Keyframe | null = null;
|
|
34
|
+
for (const kf of this.keys) {
|
|
35
|
+
if (lastKeyframe && kf.time > time && time > lastKeyframe!.time) {
|
|
36
|
+
return Mathf.lerp(lastKeyframe!.value, kf.value, (time - lastKeyframe!.time) / (kf.time - lastKeyframe!.time));
|
|
37
|
+
}
|
|
38
|
+
lastKeyframe = kf;
|
|
39
|
+
}
|
|
40
|
+
return this.keys[this.keys.length-1].value;
|
|
41
|
+
}
|
|
42
|
+
}
|