@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,47 @@
|
|
|
1
|
+
import { isLocalNetwork } from "../engine/engine_networking_utils";
|
|
2
|
+
import { getParam } from "../engine/engine_utils";
|
|
3
|
+
import { Behaviour } from "./Component";
|
|
4
|
+
export class Networking extends Behaviour {
|
|
5
|
+
url = null;
|
|
6
|
+
urlParameterName = null;
|
|
7
|
+
// used when local host is detected
|
|
8
|
+
localhost = null;
|
|
9
|
+
getWebsocketUrl() {
|
|
10
|
+
let socketurl = this.url ? Networking.GetUrl(this.url, this.localhost) : null;
|
|
11
|
+
if (this.urlParameterName) {
|
|
12
|
+
const res = getParam(this.urlParameterName);
|
|
13
|
+
if (res && typeof res === "string") {
|
|
14
|
+
socketurl = res;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
if (!socketurl)
|
|
18
|
+
return null;
|
|
19
|
+
// regex https://regex101.com/r/JQ5WqB/1
|
|
20
|
+
const regex = new RegExp("(((https?)|(?<socket_prefix>wss?)):\/\/)?(www\.)?(?<url>.+)", "gm");
|
|
21
|
+
const match = regex.exec(socketurl);
|
|
22
|
+
if (!match?.groups)
|
|
23
|
+
return null;
|
|
24
|
+
// if the url has a ws or wss prefix already assume the whole url is in the correct format
|
|
25
|
+
const socketPrefix = match?.groups["socket_prefix"];
|
|
26
|
+
if (socketPrefix)
|
|
27
|
+
return socketurl;
|
|
28
|
+
// otherwise add the ws prefix
|
|
29
|
+
return "wss://" + match?.groups["url"];
|
|
30
|
+
}
|
|
31
|
+
static GetUrl(url, localhostFallback) {
|
|
32
|
+
let result = url;
|
|
33
|
+
const useLocalHostUrl = Networking.IsLocalNetwork() && localhostFallback;
|
|
34
|
+
if (useLocalHostUrl) {
|
|
35
|
+
result = localhostFallback;
|
|
36
|
+
}
|
|
37
|
+
if (url?.startsWith("/")) {
|
|
38
|
+
const base = useLocalHostUrl ? result : window.location.origin;
|
|
39
|
+
result = base + url;
|
|
40
|
+
}
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
43
|
+
static IsLocalNetwork(hostname = window.location.hostname) {
|
|
44
|
+
return isLocalNetwork(hostname);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=Networking.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Networking.js","sourceRoot":"","sources":["../../../engine-components/Networking.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,OAAO,UAAW,SAAQ,SAAS;IAErC,GAAG,GAAkB,IAAI,CAAC;IAC1B,gBAAgB,GAAkB,IAAI,CAAC;IAEvC,mCAAmC;IACnC,SAAS,GAAkB,IAAI,CAAC;IAEhC,eAAe;QAEX,IAAI,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,C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,GAAG,MAAM,CAAC,QAAQ,CAAC,QAAQ;QAC5D,OAAO,cAAc,CAAC,QAAQ,CAAC,CAAC;IACpC,CAAC;CACJ"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Behaviour } from "./Component";
|
|
2
|
+
export declare class OffsetConstraint extends Behaviour {
|
|
3
|
+
private from;
|
|
4
|
+
private affectPosition;
|
|
5
|
+
private affectRotation;
|
|
6
|
+
private alignLookDirection;
|
|
7
|
+
private levelLookDirection;
|
|
8
|
+
private positionOffset;
|
|
9
|
+
private rotationOffset;
|
|
10
|
+
update(): void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Behaviour } from "./Component";
|
|
2
|
+
import * as utils from "./../engine/engine_three_utils";
|
|
3
|
+
import * as THREE from "three";
|
|
4
|
+
export class OffsetConstraint extends Behaviour {
|
|
5
|
+
from;
|
|
6
|
+
affectPosition;
|
|
7
|
+
affectRotation;
|
|
8
|
+
alignLookDirection;
|
|
9
|
+
levelLookDirection;
|
|
10
|
+
positionOffset;
|
|
11
|
+
rotationOffset;
|
|
12
|
+
update() {
|
|
13
|
+
if (!this.from)
|
|
14
|
+
return;
|
|
15
|
+
var pos = utils.getWorldPosition(this.from);
|
|
16
|
+
var rot = utils.getWorldQuaternion(this.from);
|
|
17
|
+
if (this.affectPosition)
|
|
18
|
+
utils.setWorldPosition(this.gameObject, pos.add(this.positionOffset));
|
|
19
|
+
const euler = new THREE.Euler(this.rotationOffset.x, this.rotationOffset.y, this.rotationOffset.z);
|
|
20
|
+
const quat = new THREE.Quaternion().setFromEuler(euler);
|
|
21
|
+
if (this.affectRotation)
|
|
22
|
+
utils.setWorldQuaternion(this.gameObject, rot.multiply(quat));
|
|
23
|
+
let lookDirection = new THREE.Vector3();
|
|
24
|
+
this.from.getWorldDirection(lookDirection).multiplyScalar(50);
|
|
25
|
+
if (this.levelLookDirection)
|
|
26
|
+
lookDirection.y = 0;
|
|
27
|
+
if (this.alignLookDirection)
|
|
28
|
+
this.gameObject.lookAt(lookDirection);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=OffsetConstraint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OffsetConstraint.js","sourceRoot":"","sources":["../../../engine-components/OffsetConstraint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAc,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,KAAK,MAAM,gCAAgC,CAAC;AACxD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,MAAM,OAAO,gBAAiB,SAAQ,SAAS;IAEnC,IAAI,CAAc;IAClB,cAAc,CAAW;IACzB,cAAc,CAAW;IACzB,kBAAkB,CAAW;IAC7B,kBAAkB,CAAW;IAC7B,cAAc,CAAiB;IAC/B,cAAc,CAAiB;IAEvC,MAAM;QACF,IAAI,CAAC,IAAI,CAAC,IAAI;YAAE,OAAO;QAEvB,IAAI,GAAG,GAAG,KAAK,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC5C,IAAI,GAAG,GAAqB,KAAK,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEhE,IAAG,IAAI,CAAC,cAAc;YAAE,KAAK,CAAC,gBAAgB,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC;QAE9F,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;QACnG,MAAM,IAAI,GAAG,IAAI,KAAK,CAAC,UAAU,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QACxD,IAAG,IAAI,CAAC,cAAc;YAAE,KAAK,CAAC,kBAAkB,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;QAEtF,IAAI,aAAa,GAAG,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;QACxC,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,aAAa,CAAC,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;QAC9D,IAAI,IAAI,CAAC,kBAAkB;YAAE,aAAa,CAAC,CAAC,GAAG,CAAC,CAAC;QACjD,IAAI,IAAI,CAAC,kBAAkB;YAAE,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;IACvE,CAAC;CACJ"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Behaviour } from "./Component";
|
|
2
|
+
import { OrbitControls as ThreeOrbitControls } from "three/examples/jsm/controls/OrbitControls";
|
|
3
|
+
import { LookAtConstraint } from "./LookAtConstraint";
|
|
4
|
+
import * as THREE from "three";
|
|
5
|
+
export declare class OrbitControls extends Behaviour {
|
|
6
|
+
get controls(): ThreeOrbitControls | null;
|
|
7
|
+
get controllerObject(): THREE.Object3D | null;
|
|
8
|
+
onStartInteraction(func: Function): void;
|
|
9
|
+
autoRotate: boolean;
|
|
10
|
+
autoRotateSpeed: number;
|
|
11
|
+
enableKeys: boolean;
|
|
12
|
+
enableDamping: boolean;
|
|
13
|
+
dampingFactor: number;
|
|
14
|
+
enableZoom: boolean;
|
|
15
|
+
minZoom: number;
|
|
16
|
+
maxZoom: number;
|
|
17
|
+
enablePan: boolean;
|
|
18
|
+
lookAtConstraint: LookAtConstraint | null;
|
|
19
|
+
lookAtConstraint01: number;
|
|
20
|
+
middleClickToFocus: boolean;
|
|
21
|
+
doubleClickToFocus: boolean;
|
|
22
|
+
useSlerp: boolean;
|
|
23
|
+
debugLog: boolean;
|
|
24
|
+
targetLerpSpeed: number;
|
|
25
|
+
private _lookTargetPosition;
|
|
26
|
+
private _controls;
|
|
27
|
+
private _cameraObject;
|
|
28
|
+
private _lerpToTargetPosition;
|
|
29
|
+
private _lerpCameraToTarget;
|
|
30
|
+
private _cameraTargetPosition;
|
|
31
|
+
private _inputs;
|
|
32
|
+
private _enableTime;
|
|
33
|
+
awake(): void;
|
|
34
|
+
onEnable(): void;
|
|
35
|
+
onDisable(): void;
|
|
36
|
+
start(): void;
|
|
37
|
+
private startRaycastDelayed;
|
|
38
|
+
onBeforeRender(): void;
|
|
39
|
+
setCameraTarget(position?: THREE.Vector3 | null, immediate?: boolean): void;
|
|
40
|
+
setFromTargetPosition(index?: number, t?: number): boolean;
|
|
41
|
+
setTarget(position?: THREE.Vector3 | null, immediate?: boolean): void;
|
|
42
|
+
lerpTarget(position: THREE.Vector3, delta: number): void;
|
|
43
|
+
distanceToTarget(position: THREE.Vector3): number;
|
|
44
|
+
private setTargetFromRaycast;
|
|
45
|
+
}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { Behaviour, GameObject } from "./Component";
|
|
8
|
+
import { Camera } from "./Camera";
|
|
9
|
+
import { OrbitControls as ThreeOrbitControls } from "three/examples/jsm/controls/OrbitControls";
|
|
10
|
+
import { LookAtConstraint } from "./LookAtConstraint";
|
|
11
|
+
import * as THREE from "three";
|
|
12
|
+
import { getWorldPosition } from "../engine/engine_three_utils";
|
|
13
|
+
import { RaycastOptions } from "../engine/engine_physics";
|
|
14
|
+
import { serializeable } from "../engine/engine_serialization_decorator";
|
|
15
|
+
export class OrbitControls extends Behaviour {
|
|
16
|
+
get controls() {
|
|
17
|
+
return this._controls;
|
|
18
|
+
}
|
|
19
|
+
get controllerObject() {
|
|
20
|
+
return this._cameraObject;
|
|
21
|
+
}
|
|
22
|
+
onStartInteraction(func) {
|
|
23
|
+
this.controls?.addEventListener("start", func);
|
|
24
|
+
}
|
|
25
|
+
autoRotate = false;
|
|
26
|
+
autoRotateSpeed = 1.0;
|
|
27
|
+
enableKeys = true;
|
|
28
|
+
enableDamping = true;
|
|
29
|
+
dampingFactor = 0.1;
|
|
30
|
+
enableZoom = true;
|
|
31
|
+
minZoom = 0;
|
|
32
|
+
maxZoom = Infinity;
|
|
33
|
+
enablePan = true;
|
|
34
|
+
lookAtConstraint = null;
|
|
35
|
+
lookAtConstraint01 = 1;
|
|
36
|
+
middleClickToFocus = true;
|
|
37
|
+
doubleClickToFocus = true;
|
|
38
|
+
// remove once slerp works correctly
|
|
39
|
+
useSlerp = false;
|
|
40
|
+
debugLog = false;
|
|
41
|
+
targetLerpSpeed = 5;
|
|
42
|
+
_lookTargetPosition;
|
|
43
|
+
_controls = null;
|
|
44
|
+
_cameraObject = null;
|
|
45
|
+
_lerpToTargetPosition = false;
|
|
46
|
+
_lerpCameraToTarget = false;
|
|
47
|
+
_cameraTargetPosition = null;
|
|
48
|
+
_inputs = 0;
|
|
49
|
+
_enableTime = 0; // use to disable double click when double clicking on UI
|
|
50
|
+
awake() {
|
|
51
|
+
this._lookTargetPosition = new THREE.Vector3();
|
|
52
|
+
}
|
|
53
|
+
onEnable() {
|
|
54
|
+
this._enableTime = this.context.time.time;
|
|
55
|
+
const camGo = GameObject.getComponent(this.gameObject, Camera);
|
|
56
|
+
const cam = camGo?.cam;
|
|
57
|
+
if (!this._controls) {
|
|
58
|
+
console.assert(cam !== null && cam !== undefined, "Missing camera", this);
|
|
59
|
+
if (cam)
|
|
60
|
+
this._cameraObject = cam;
|
|
61
|
+
this._controls = new ThreeOrbitControls(cam, this.context.renderer.domElement);
|
|
62
|
+
}
|
|
63
|
+
if (this._controls) {
|
|
64
|
+
this._controls.enableDamping = this.enableDamping;
|
|
65
|
+
this._controls.enableKeys = this.enableKeys;
|
|
66
|
+
this._controls.autoRotate = this.autoRotate;
|
|
67
|
+
this._controls.autoRotateSpeed = this.autoRotateSpeed;
|
|
68
|
+
this._controls.enableZoom = this.enableZoom;
|
|
69
|
+
if (cam?.type === "PerspectiveCamera") {
|
|
70
|
+
this._controls.minDistance = this.minZoom;
|
|
71
|
+
this._controls.maxDistance = this.maxZoom;
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
this._controls.minZoom = this.minZoom;
|
|
75
|
+
this._controls.maxZoom = this.maxZoom;
|
|
76
|
+
}
|
|
77
|
+
this._controls.dampingFactor = this.dampingFactor;
|
|
78
|
+
this._controls.enablePan = this.enablePan;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
onDisable() {
|
|
82
|
+
if (this._controls) {
|
|
83
|
+
this._controls.enabled = false;
|
|
84
|
+
this._controls.autoRotate = false;
|
|
85
|
+
// this._controls.reset();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
start() {
|
|
89
|
+
if (this._controls) {
|
|
90
|
+
const camGo = GameObject.getComponent(this.gameObject, Camera);
|
|
91
|
+
if (camGo && !this.setFromTargetPosition()) {
|
|
92
|
+
console.log("NO TARGET");
|
|
93
|
+
const forward = new THREE.Vector3(0, 0, -1).applyMatrix4(camGo.cam.matrixWorld);
|
|
94
|
+
this.setTarget(forward, true);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
this.startCoroutine(this.startRaycastDelayed());
|
|
98
|
+
}
|
|
99
|
+
// we need to wait one frame (when starting the scene for the very first time)
|
|
100
|
+
*startRaycastDelayed() {
|
|
101
|
+
yield;
|
|
102
|
+
if (!this.setFromTargetPosition()) {
|
|
103
|
+
const opts = new RaycastOptions();
|
|
104
|
+
// center of the screen:
|
|
105
|
+
opts.screenPoint = new THREE.Vector2(0, 0);
|
|
106
|
+
opts.lineThreshold = 0.1;
|
|
107
|
+
const hits = this.context.physics.raycast(opts);
|
|
108
|
+
if (hits.length > 0) {
|
|
109
|
+
this.setTarget(hits[0].point, true);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
onBeforeRender() {
|
|
114
|
+
if (!this._controls)
|
|
115
|
+
return;
|
|
116
|
+
if (this.context.input.getPointerDown(0) || this.context.input.getPointerDown(1) || this.context.input.getPointerDown(2)) {
|
|
117
|
+
this._inputs += 1;
|
|
118
|
+
}
|
|
119
|
+
if (this._inputs > 0) {
|
|
120
|
+
this._controls.autoRotate = false;
|
|
121
|
+
this._lerpCameraToTarget = false;
|
|
122
|
+
this._lerpToTargetPosition = false;
|
|
123
|
+
}
|
|
124
|
+
this._inputs = 0;
|
|
125
|
+
// if (this.context.input.getPointerLongPress(0) && this.context.time.frameCount % 20 === 0) console.log("LP", this.context.alias);
|
|
126
|
+
let focusAtPointer = (this.middleClickToFocus && this.context.input.getPointerClicked(1));
|
|
127
|
+
focusAtPointer ||= (this.doubleClickToFocus && this.context.input.getPointerDoubleClicked(0) && this.context.time.time - this._enableTime > .3);
|
|
128
|
+
if (focusAtPointer) {
|
|
129
|
+
this.setTargetFromRaycast();
|
|
130
|
+
}
|
|
131
|
+
else if (this.context.input.getPointerDown(0) || this.context.input.mouseWheelChanged) {
|
|
132
|
+
this._lerpToTargetPosition = false;
|
|
133
|
+
this._lerpCameraToTarget = false;
|
|
134
|
+
}
|
|
135
|
+
if (this._lerpToTargetPosition || this._lerpCameraToTarget) {
|
|
136
|
+
const step = this.context.time.deltaTime * this.targetLerpSpeed;
|
|
137
|
+
// confusing naming ahead:
|
|
138
|
+
// _targetObject: the target where the camera moves to
|
|
139
|
+
// targetPosition: the target where the look target moves to
|
|
140
|
+
// lerp the camera
|
|
141
|
+
if (this._lerpCameraToTarget && this._cameraTargetPosition && this._cameraObject) {
|
|
142
|
+
if (this.useSlerp && typeof this._cameraObject?.position["slerp"] === "function") {
|
|
143
|
+
const position = this._cameraObject?.position;
|
|
144
|
+
position
|
|
145
|
+
// TODO fix the offset here
|
|
146
|
+
// .sub(this._cameraTargetPosition)
|
|
147
|
+
//@ts-ignore
|
|
148
|
+
.slerp(this._cameraTargetPosition, step);
|
|
149
|
+
// .add(this._cameraTargetPosition);
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
this._cameraObject?.position.lerp(this._cameraTargetPosition, step);
|
|
153
|
+
}
|
|
154
|
+
if (this._cameraObject.position.distanceTo(this._cameraTargetPosition) < .01) {
|
|
155
|
+
this._lerpCameraToTarget = false;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
// lerp the look target
|
|
159
|
+
if (this._lerpToTargetPosition) {
|
|
160
|
+
this.lerpTarget(this._lookTargetPosition, step);
|
|
161
|
+
if (this._lookTargetPosition.distanceTo(this._controls.target) < .005) {
|
|
162
|
+
this._lerpToTargetPosition = false;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (this.lookAtConstraint?.locked)
|
|
167
|
+
this.setFromTargetPosition(0, this.lookAtConstraint01);
|
|
168
|
+
if (this._controls) {
|
|
169
|
+
if (this.debugLog)
|
|
170
|
+
this._controls.domElement = this.context.renderer.domElement;
|
|
171
|
+
this._controls.enabled = true;
|
|
172
|
+
this._controls.update();
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
setCameraTarget(position, immediate = false) {
|
|
176
|
+
if (!position)
|
|
177
|
+
this._lerpCameraToTarget = false;
|
|
178
|
+
else {
|
|
179
|
+
this._lerpCameraToTarget = true;
|
|
180
|
+
this._cameraTargetPosition = position.clone();
|
|
181
|
+
if (immediate && this._cameraTargetPosition) {
|
|
182
|
+
this.controllerObject?.position.copy(this._cameraTargetPosition);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
setFromTargetPosition(index = 0, t = 1) {
|
|
187
|
+
if (!this._controls)
|
|
188
|
+
return false;
|
|
189
|
+
const sources = this.lookAtConstraint?.sources;
|
|
190
|
+
if (sources && sources.length > 0) {
|
|
191
|
+
const target = sources[index];
|
|
192
|
+
if (target) {
|
|
193
|
+
target.getWorldPosition(this._lookTargetPosition);
|
|
194
|
+
this.lerpTarget(this._lookTargetPosition, t);
|
|
195
|
+
return true;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return false;
|
|
199
|
+
}
|
|
200
|
+
setTarget(position = null, immediate = false) {
|
|
201
|
+
if (!this._controls)
|
|
202
|
+
return;
|
|
203
|
+
if (position !== null)
|
|
204
|
+
this._lookTargetPosition.copy(position);
|
|
205
|
+
if (immediate)
|
|
206
|
+
this._controls.target.copy(this._lookTargetPosition);
|
|
207
|
+
else
|
|
208
|
+
this._lerpToTargetPosition = true;
|
|
209
|
+
}
|
|
210
|
+
lerpTarget(position, delta) {
|
|
211
|
+
if (!this._controls)
|
|
212
|
+
return;
|
|
213
|
+
this._controls.target.lerp(position, delta);
|
|
214
|
+
}
|
|
215
|
+
distanceToTarget(position) {
|
|
216
|
+
if (!this._controls)
|
|
217
|
+
return -1;
|
|
218
|
+
return this._controls.target.distanceTo(position);
|
|
219
|
+
}
|
|
220
|
+
setTargetFromRaycast() {
|
|
221
|
+
if (!this.controls)
|
|
222
|
+
return;
|
|
223
|
+
const rc = this.context.physics.raycast();
|
|
224
|
+
for (const hit of rc) {
|
|
225
|
+
if (hit.distance > 0 && GameObject.isActiveInHierarchy(hit.object)) {
|
|
226
|
+
// if (hit.object && hit.object.parent) {
|
|
227
|
+
// const par: any = hit.object.parent;
|
|
228
|
+
// if (par.isUI) continue;
|
|
229
|
+
// }
|
|
230
|
+
// console.log("Set target", this.targetPosition, hit.object.name, hit.object);
|
|
231
|
+
this._lookTargetPosition.copy(hit.point);
|
|
232
|
+
this._lerpToTargetPosition = true;
|
|
233
|
+
this._cameraTargetPosition = null;
|
|
234
|
+
if (this.context.mainCamera) {
|
|
235
|
+
this._lerpCameraToTarget = true;
|
|
236
|
+
const pos = getWorldPosition(this.context.mainCamera);
|
|
237
|
+
this._cameraTargetPosition = pos.clone().sub(this.controls.target).add(this._lookTargetPosition);
|
|
238
|
+
}
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
__decorate([
|
|
245
|
+
serializeable(LookAtConstraint)
|
|
246
|
+
], OrbitControls.prototype, "lookAtConstraint", void 0);
|
|
247
|
+
//# sourceMappingURL=OrbitControls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OrbitControls.js","sourceRoot":"","sources":["../../../engine-components/OrbitControls.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,aAAa,IAAI,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAChG,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAW,cAAc,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAC;AAGzE,MAAM,OAAO,aAAc,SAAQ,SAAS;IAExC,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED,IAAW,gBAAgB;QACvB,OAAO,IAAI,CAAC,aAAa,CAAC;IAC9B,CAAC;IAEM,kBAAkB,CAAC,IAAc;QACpC,IAAI,CAAC,QAAQ,EAAE,gBAAgB,CAAC,OAAO,EAAE,IAAW,CAAC,CAAC;IAC1D,CAAC;IAED,UAAU,GAAY,KAAK,CAAC;IAC5B,eAAe,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AU,EAAE;oBACzB,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC;oBAChC,MAAM,GAAG,GAAG,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;oBACtD,IAAI,CAAC,qBAAqB,GAAG,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;iBACpG;gBACD,MAAM;aACT;SACJ;IACL,CAAC;CAKJ;AA3OG;IADC,aAAa,CAAC,gBAAgB,CAAC;uDACiB"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Behaviour } from "./Component";
|
|
2
|
+
import * as THREE from "three";
|
|
3
|
+
import * as Modules from "./ParticleSystemModules";
|
|
4
|
+
export declare class ParticleSystemRenderer extends Behaviour {
|
|
5
|
+
get mainTexture(): THREE.Texture | null;
|
|
6
|
+
getMesh(_index: number): THREE.Mesh | null;
|
|
7
|
+
private sharedMaterial?;
|
|
8
|
+
private mesh?;
|
|
9
|
+
awake(): void;
|
|
10
|
+
}
|
|
11
|
+
export declare class ParticleSystem extends Behaviour {
|
|
12
|
+
main: Modules.MainModule;
|
|
13
|
+
emission: Modules.EmissionModule;
|
|
14
|
+
shape: Modules.ShapeModule;
|
|
15
|
+
private renderer;
|
|
16
|
+
private geometry;
|
|
17
|
+
private material;
|
|
18
|
+
private particlesMesh;
|
|
19
|
+
private positions;
|
|
20
|
+
private positionsArray;
|
|
21
|
+
private particleStates;
|
|
22
|
+
private activeCount;
|
|
23
|
+
private shapeRotation;
|
|
24
|
+
private tempVec3;
|
|
25
|
+
private tempQuat;
|
|
26
|
+
awake(): void;
|
|
27
|
+
onEnable(): void;
|
|
28
|
+
update(): void;
|
|
29
|
+
emit(deltaTime: number): void;
|
|
30
|
+
private initializeParticle;
|
|
31
|
+
private updateOverLifetime;
|
|
32
|
+
private assignPosition;
|
|
33
|
+
private assignVelocity;
|
|
34
|
+
}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { Behaviour, GameObject } from "./Component";
|
|
2
|
+
import * as THREE from "three";
|
|
3
|
+
import * as Modules from "./ParticleSystemModules";
|
|
4
|
+
import { Mathf } from "../engine/engine_math";
|
|
5
|
+
import { getParam } from "../engine/engine_utils";
|
|
6
|
+
const debug = getParam("debugparticles");
|
|
7
|
+
class ParticleState {
|
|
8
|
+
age = 0;
|
|
9
|
+
lifetime = 0;
|
|
10
|
+
position;
|
|
11
|
+
velocity;
|
|
12
|
+
color;
|
|
13
|
+
}
|
|
14
|
+
export class ParticleSystemRenderer extends Behaviour {
|
|
15
|
+
get mainTexture() {
|
|
16
|
+
if (this.sharedMaterial) {
|
|
17
|
+
const tex = this.context.assets.findTexture(this.sharedMaterial);
|
|
18
|
+
if (tex)
|
|
19
|
+
return tex;
|
|
20
|
+
}
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
getMesh(_index) {
|
|
24
|
+
if (!this.mesh)
|
|
25
|
+
return null;
|
|
26
|
+
return this.context.assets.findMesh(this.mesh);
|
|
27
|
+
}
|
|
28
|
+
sharedMaterial;
|
|
29
|
+
mesh;
|
|
30
|
+
awake() {
|
|
31
|
+
if (debug)
|
|
32
|
+
console.log(this);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export class ParticleSystem extends Behaviour {
|
|
36
|
+
main;
|
|
37
|
+
emission;
|
|
38
|
+
shape;
|
|
39
|
+
renderer;
|
|
40
|
+
geometry;
|
|
41
|
+
material;
|
|
42
|
+
particlesMesh;
|
|
43
|
+
positions;
|
|
44
|
+
positionsArray;
|
|
45
|
+
particleStates = [];
|
|
46
|
+
activeCount = 0;
|
|
47
|
+
shapeRotation = new THREE.Quaternion();
|
|
48
|
+
tempVec3 = new THREE.Vector3();
|
|
49
|
+
tempQuat = new THREE.Quaternion();
|
|
50
|
+
awake() {
|
|
51
|
+
this.renderer = GameObject.getComponent(this.gameObject, ParticleSystemRenderer);
|
|
52
|
+
if (debug)
|
|
53
|
+
console.log(this);
|
|
54
|
+
}
|
|
55
|
+
onEnable() {
|
|
56
|
+
// console.trace();
|
|
57
|
+
if (this.geometry) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
// console.log(this);
|
|
61
|
+
this.particleStates = [];
|
|
62
|
+
this.shapeRotation.setFromEuler(new THREE.Euler(this.shape.rotation.x, this.shape.rotation.y, this.shape.rotation.z));
|
|
63
|
+
// TODO: how to render particle mesh
|
|
64
|
+
// const assignedMesh = this.renderer?.getMesh(0);
|
|
65
|
+
// console.log(assignedMesh);
|
|
66
|
+
this.geometry = new THREE.BufferGeometry();
|
|
67
|
+
this.positionsArray = new Float32Array(this.main.maxParticles * 3);
|
|
68
|
+
this.positions = new THREE.Float32BufferAttribute(this.positionsArray, 3);
|
|
69
|
+
this.geometry.setAttribute('position', this.positions);
|
|
70
|
+
// const color = new THREE.Color();
|
|
71
|
+
const colorsArray = new Float32Array(this.main.maxParticles * 3);
|
|
72
|
+
for (let i = 0; i < colorsArray.length; i++) {
|
|
73
|
+
colorsArray[i * 3] = 1;
|
|
74
|
+
colorsArray[i * 3 + 1] = 1;
|
|
75
|
+
colorsArray[i * 3 + 2] = 1;
|
|
76
|
+
}
|
|
77
|
+
const colors = new THREE.Float32BufferAttribute(colorsArray, 3);
|
|
78
|
+
this.geometry.setAttribute('color', colors);
|
|
79
|
+
this.material = new THREE.PointsMaterial({ size: this.main.startSize, color: 0xffffff, vertexColors: true });
|
|
80
|
+
this.material.map = this.renderer.mainTexture;
|
|
81
|
+
// this.material.onBeforeCompile = (shader) => {
|
|
82
|
+
// shader.
|
|
83
|
+
// });
|
|
84
|
+
this.particlesMesh = new THREE.Points(this.geometry, this.material);
|
|
85
|
+
this.particlesMesh.layers.enable(2);
|
|
86
|
+
this.gameObject.add(this.particlesMesh);
|
|
87
|
+
this.activeCount = this.main.prewarm ? this.main.maxParticles : 0;
|
|
88
|
+
}
|
|
89
|
+
update() {
|
|
90
|
+
if (!this.geometry)
|
|
91
|
+
return;
|
|
92
|
+
const t = this.context.time.deltaTime;
|
|
93
|
+
this.emit(t);
|
|
94
|
+
for (let i = 0; i < this.activeCount; i += 1) {
|
|
95
|
+
const ps = this.particleStates[i];
|
|
96
|
+
if (!ps)
|
|
97
|
+
continue;
|
|
98
|
+
const vx = ps.velocity.x * t;
|
|
99
|
+
const vy = ps.velocity.y * t;
|
|
100
|
+
const vz = ps.velocity.z * t;
|
|
101
|
+
ps.position.x += vx;
|
|
102
|
+
ps.position.y += vy;
|
|
103
|
+
ps.position.z += vz;
|
|
104
|
+
this.updateOverLifetime(i, ps);
|
|
105
|
+
this.geometry.attributes.position.setXYZ(i, ps.position.x, ps.position.y, ps.position.z);
|
|
106
|
+
this.geometry.attributes.color.setXYZ(i, ps.color.r, ps.color.g, ps.color.b);
|
|
107
|
+
}
|
|
108
|
+
if (this.geometry) {
|
|
109
|
+
this.geometry.attributes.position.needsUpdate = true;
|
|
110
|
+
this.geometry.setDrawRange(0, this.activeCount);
|
|
111
|
+
}
|
|
112
|
+
// console.log(this.activeCount);
|
|
113
|
+
}
|
|
114
|
+
emit(deltaTime) {
|
|
115
|
+
const count = this.activeCount;
|
|
116
|
+
for (let i = 0; i < count; i += 1) {
|
|
117
|
+
if (i >= this.particleStates.length) {
|
|
118
|
+
const ps = new ParticleState();
|
|
119
|
+
ps.lifetime = this.main.startLifetime ?? 1;
|
|
120
|
+
ps.position = new THREE.Vector3();
|
|
121
|
+
ps.velocity = new THREE.Vector3();
|
|
122
|
+
ps.color = new THREE.Color(1, 0, 0);
|
|
123
|
+
this.particleStates.push(ps);
|
|
124
|
+
this.initializeParticle(i, ps);
|
|
125
|
+
ps.age = ps.lifetime * Math.random();
|
|
126
|
+
}
|
|
127
|
+
const ps = this.particleStates[i];
|
|
128
|
+
if (ps.age > ps.lifetime) {
|
|
129
|
+
this.activeCount -= 1;
|
|
130
|
+
this.activeCount = Math.max(0, this.activeCount);
|
|
131
|
+
this.initializeParticle(i, ps);
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
ps.age += deltaTime;
|
|
135
|
+
this.particleStates[i] = ps;
|
|
136
|
+
}
|
|
137
|
+
this.activeCount += deltaTime * (this.emission.rate);
|
|
138
|
+
this.activeCount = Math.min(this.main.maxParticles, this.activeCount);
|
|
139
|
+
}
|
|
140
|
+
initializeParticle(index, particle) {
|
|
141
|
+
if (!this.geometry)
|
|
142
|
+
return;
|
|
143
|
+
particle.age = 0;
|
|
144
|
+
particle.color.set(this.main.startColor);
|
|
145
|
+
if (this.main.startColor1) {
|
|
146
|
+
particle.color.lerp(this.main.startColor1, Math.random());
|
|
147
|
+
}
|
|
148
|
+
this.geometry.attributes.color.needsUpdate = true;
|
|
149
|
+
this.assignPosition(particle.position);
|
|
150
|
+
this.assignVelocity(particle.position, particle.velocity);
|
|
151
|
+
const position = particle.position;
|
|
152
|
+
position.multiply(this.shape.scale);
|
|
153
|
+
position.applyQuaternion(this.shapeRotation);
|
|
154
|
+
position.add(this.shape.position);
|
|
155
|
+
// push back
|
|
156
|
+
this.particleStates.splice(index, 1);
|
|
157
|
+
this.particleStates.push(particle);
|
|
158
|
+
}
|
|
159
|
+
updateOverLifetime(_index, _particle) {
|
|
160
|
+
// particle.position.multiplyScalar()
|
|
161
|
+
}
|
|
162
|
+
assignPosition(position) {
|
|
163
|
+
switch (this.shape.shapeType) {
|
|
164
|
+
case Modules.ParticleSystemShapeType.Sphere:
|
|
165
|
+
position.set(Math.random() - .5, Math.random() - .5, Math.random() - .5).multiplyScalar(this.shape.radius);
|
|
166
|
+
break;
|
|
167
|
+
case Modules.ParticleSystemShapeType.Box:
|
|
168
|
+
position.set(Math.random() - .5, Math.random() - .5, Math.random() - .5);
|
|
169
|
+
break;
|
|
170
|
+
default:
|
|
171
|
+
position.set(0, 0, 0);
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
assignVelocity(position, velocity) {
|
|
176
|
+
switch (this.shape.shapeType) {
|
|
177
|
+
case Modules.ParticleSystemShapeType.Sphere:
|
|
178
|
+
velocity.set(position.x, position.y, position.z);
|
|
179
|
+
break;
|
|
180
|
+
case Modules.ParticleSystemShapeType.Box:
|
|
181
|
+
velocity.set(0, 0, 1);
|
|
182
|
+
if (this.shape.sphericalDirectionAmount > 0) {
|
|
183
|
+
this.tempVec3.set(position.x, position.y, position.z).multiply(this.shape.scale).normalize();
|
|
184
|
+
velocity.lerp(this.tempVec3, this.shape.sphericalDirectionAmount);
|
|
185
|
+
}
|
|
186
|
+
break;
|
|
187
|
+
case Modules.ParticleSystemShapeType.Cone:
|
|
188
|
+
// const maxAngle = 90;
|
|
189
|
+
// const fwd = this.shape.angle / maxAngle;
|
|
190
|
+
// const side = 1 - fwd;
|
|
191
|
+
// const angle = Mathf.toRadians(this.shape.angle);
|
|
192
|
+
// const upDir = Math.random();
|
|
193
|
+
// const sideDir = 1 - upDir;
|
|
194
|
+
// const quat = new THREE.Quaternion().setFromAxisAngle(this.tempVec3.set(side, 0, fwd), angle * Math.random())
|
|
195
|
+
const dir = new THREE.Vector3(0, 1, 0); //.applyQuaternion(quat);
|
|
196
|
+
velocity.copy(dir);
|
|
197
|
+
break;
|
|
198
|
+
case Modules.ParticleSystemShapeType.Circle:
|
|
199
|
+
this.tempQuat.setFromAxisAngle(this.tempVec3.set(0, 0, 1), Math.random() * Mathf.toRadians(this.shape.arc));
|
|
200
|
+
velocity.copy(this.tempVec3.set(1, 0, 0).applyQuaternion(this.tempQuat));
|
|
201
|
+
break;
|
|
202
|
+
default:
|
|
203
|
+
velocity.set(Math.random() * 2 - 1, Math.random() * 2 - 1, Math.random() * 2 - 1);
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
206
|
+
velocity.normalize();
|
|
207
|
+
// set position
|
|
208
|
+
switch (this.shape.shapeType) {
|
|
209
|
+
case Modules.ParticleSystemShapeType.Circle:
|
|
210
|
+
position.add(velocity).multiplyScalar(this.shape.radius);
|
|
211
|
+
break;
|
|
212
|
+
}
|
|
213
|
+
velocity.multiplyScalar(this.main.startSpeedMultiplier);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
//# sourceMappingURL=ParticleSystem.js.map
|