@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,418 @@
|
|
|
1
|
+
import { Behaviour, GameObject } from "./Component";
|
|
2
|
+
import * as THREE from "three";
|
|
3
|
+
import { getParam } from "../engine/engine_utils";
|
|
4
|
+
import { setWorldPositionXYZ } from "../engine/engine_three_utils";
|
|
5
|
+
import { FrameEvent } from "../engine/engine_setup";
|
|
6
|
+
import { serializeable } from "../engine/engine_serialization_decorator";
|
|
7
|
+
import { Color, DirectionalLight, OrthographicCamera } from "three";
|
|
8
|
+
import { WebXR, WebXREvent } from "./WebXR";
|
|
9
|
+
import { WebARSessionRoot } from "./WebARSessionRoot";
|
|
10
|
+
|
|
11
|
+
// https://threejs.org/examples/webgl_shadowmap_csm.html
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
function toDegrees(radians) {
|
|
15
|
+
return radians * 180 / Math.PI;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function toRadians(degrees) {
|
|
19
|
+
return degrees * Math.PI / 180;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const shadowMaxDistance = 300;
|
|
23
|
+
const debug = getParam("debuglights");
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
/// <summary>
|
|
27
|
+
/// <para>The type of a Light.</para>
|
|
28
|
+
/// </summary>
|
|
29
|
+
export enum LightType {
|
|
30
|
+
/// <summary>
|
|
31
|
+
/// <para>The light is a spot light.</para>
|
|
32
|
+
/// </summary>
|
|
33
|
+
Spot = 0,
|
|
34
|
+
/// <summary>
|
|
35
|
+
/// <para>The light is a directional light.</para>
|
|
36
|
+
/// </summary>
|
|
37
|
+
Directional = 1,
|
|
38
|
+
/// <summary>
|
|
39
|
+
/// <para>The light is a point light.</para>
|
|
40
|
+
/// </summary>
|
|
41
|
+
Point = 2,
|
|
42
|
+
Area = 3,
|
|
43
|
+
/// <summary>
|
|
44
|
+
/// <para>The light is a rectangle shaped area light. It affects only baked lightmaps and lightprobes.</para>
|
|
45
|
+
/// </summary>
|
|
46
|
+
Rectangle = 3,
|
|
47
|
+
/// <summary>
|
|
48
|
+
/// <para>The light is a disc shaped area light. It affects only baked lightmaps and lightprobes.</para>
|
|
49
|
+
/// </summary>
|
|
50
|
+
Disc = 4,
|
|
51
|
+
}
|
|
52
|
+
export enum LightmapBakeType {
|
|
53
|
+
/// <summary>
|
|
54
|
+
/// <para>Realtime lights cast run time light and shadows. They can change position, orientation, color, brightness, and many other properties at run time. No lighting gets baked into lightmaps or light probes..</para>
|
|
55
|
+
/// </summary>
|
|
56
|
+
Realtime = 4,
|
|
57
|
+
/// <summary>
|
|
58
|
+
/// <para>Baked lights cannot move or change in any way during run time. All lighting for static objects gets baked into lightmaps. Lighting and shadows for dynamic objects gets baked into Light Probes.</para>
|
|
59
|
+
/// </summary>
|
|
60
|
+
Baked = 2,
|
|
61
|
+
/// <summary>
|
|
62
|
+
/// <para>Mixed lights allow a mix of realtime and baked lighting, based on the Mixed Lighting Mode used. These lights cannot move, but can change color and intensity at run time. Changes to color and intensity only affect direct lighting as indirect lighting gets baked. If using Subtractive mode, changes to color or intensity are not calculated at run time on static objects.</para>
|
|
63
|
+
/// </summary>
|
|
64
|
+
Mixed = 1,
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/// <summary>
|
|
68
|
+
/// <para>Shadow casting options for a Light.</para>
|
|
69
|
+
/// </summary>
|
|
70
|
+
enum LightShadows {
|
|
71
|
+
/// <summary>
|
|
72
|
+
/// <para>Do not cast shadows (default).</para>
|
|
73
|
+
/// </summary>
|
|
74
|
+
None = 0,
|
|
75
|
+
/// <summary>
|
|
76
|
+
/// <para>Cast "hard" shadows (with no shadow filtering).</para>
|
|
77
|
+
/// </summary>
|
|
78
|
+
Hard = 1,
|
|
79
|
+
/// <summary>
|
|
80
|
+
/// <para>Cast "soft" shadows (with 4x PCF filtering).</para>
|
|
81
|
+
/// </summary>
|
|
82
|
+
Soft = 2,
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export class Light extends Behaviour {
|
|
86
|
+
|
|
87
|
+
@serializeable()
|
|
88
|
+
private type: LightType = 0;
|
|
89
|
+
public range: number = 1;
|
|
90
|
+
public spotAngle: number = 1;
|
|
91
|
+
public innerSpotAngle: number = 1;
|
|
92
|
+
|
|
93
|
+
@serializeable(Color)
|
|
94
|
+
public color: THREE.Color = new THREE.Color(0xffffff);
|
|
95
|
+
|
|
96
|
+
@serializeable()
|
|
97
|
+
set shadowNearPlane(val: number) {
|
|
98
|
+
if (val === this._shadowNearPlane) return;
|
|
99
|
+
this._shadowNearPlane = val;
|
|
100
|
+
if (this.light?.shadow?.camera !== undefined) {
|
|
101
|
+
const cam = this.light.shadow.camera as THREE.OrthographicCamera;
|
|
102
|
+
cam.near = val;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
get shadowNearPlane(): number { return this._shadowNearPlane; }
|
|
106
|
+
private _shadowNearPlane: number = .1;
|
|
107
|
+
|
|
108
|
+
@serializeable()
|
|
109
|
+
set shadowBias(val: number) {
|
|
110
|
+
if (val === this._shadowBias) return;
|
|
111
|
+
this._shadowBias = val;
|
|
112
|
+
if (this.light?.shadow?.bias !== undefined) {
|
|
113
|
+
this.light.shadow.bias = val;
|
|
114
|
+
this.light.shadow.needsUpdate = true;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
get shadowBias(): number { return this._shadowBias; }
|
|
118
|
+
private _shadowBias: number = 0;
|
|
119
|
+
|
|
120
|
+
@serializeable()
|
|
121
|
+
set shadowNormalBias(val: number) {
|
|
122
|
+
if (val === this._shadowNormalBias) return;
|
|
123
|
+
this._shadowNormalBias = val;
|
|
124
|
+
if (this.light?.shadow?.normalBias !== undefined) {
|
|
125
|
+
this.light.shadow.normalBias = val;
|
|
126
|
+
this.light.shadow.needsUpdate = true;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
get shadowNormalBias(): number { return this._shadowNormalBias; }
|
|
130
|
+
private _shadowNormalBias: number = 1;
|
|
131
|
+
|
|
132
|
+
@serializeable()
|
|
133
|
+
set shadows(val: LightShadows) {
|
|
134
|
+
this._shadows = val;
|
|
135
|
+
if (this.light) {
|
|
136
|
+
this.light.castShadow = val === LightShadows.Hard || val === LightShadows.Soft;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
get shadows(): LightShadows { return this._shadows; }
|
|
140
|
+
private _shadows: LightShadows = 1;
|
|
141
|
+
|
|
142
|
+
@serializeable()
|
|
143
|
+
private lightmapBakeType: LightmapBakeType = LightmapBakeType.Realtime;
|
|
144
|
+
|
|
145
|
+
@serializeable()
|
|
146
|
+
set intensity(val: number) {
|
|
147
|
+
this._intensity = val;
|
|
148
|
+
if (this.light) {
|
|
149
|
+
let factor: number = 1;
|
|
150
|
+
if (this.context.isInXR && this._webARRoot) {
|
|
151
|
+
const scaleFactor = this._webARRoot?.arScale;
|
|
152
|
+
if (typeof scaleFactor === "number" && scaleFactor > 0) {
|
|
153
|
+
factor /= scaleFactor;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
this.light.intensity = val * factor;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
get intensity(): number { return this._intensity; }
|
|
160
|
+
private _intensity: number = 1;
|
|
161
|
+
|
|
162
|
+
@serializeable()
|
|
163
|
+
get shadowDistance(): number {
|
|
164
|
+
const light = this.light;
|
|
165
|
+
if (light) {
|
|
166
|
+
const cam = light.shadow.camera as OrthographicCamera;
|
|
167
|
+
return cam.far;
|
|
168
|
+
}
|
|
169
|
+
return -1;
|
|
170
|
+
}
|
|
171
|
+
set shadowDistance(val: number) {
|
|
172
|
+
this._shadowDistance = val;
|
|
173
|
+
const light = this.light;
|
|
174
|
+
if (light) {
|
|
175
|
+
const cam = light.shadow.camera as OrthographicCamera;
|
|
176
|
+
cam.far = val;
|
|
177
|
+
cam.updateProjectionMatrix();
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
private _shadowDistance?: number;
|
|
181
|
+
// set from additional component
|
|
182
|
+
private shadowWidth?: number;
|
|
183
|
+
private shadowHeight?: number;
|
|
184
|
+
|
|
185
|
+
@serializeable()
|
|
186
|
+
get shadowResolution(): number {
|
|
187
|
+
const light = this.light;
|
|
188
|
+
if (light) {
|
|
189
|
+
return light.shadow.mapSize.x;
|
|
190
|
+
}
|
|
191
|
+
return -1;
|
|
192
|
+
}
|
|
193
|
+
set shadowResolution(val: number) {
|
|
194
|
+
if (val === this._shadowResolution) return;
|
|
195
|
+
this._shadowResolution = val;
|
|
196
|
+
const light = this.light;
|
|
197
|
+
if (light) {
|
|
198
|
+
light.shadow.mapSize.set(val, val);
|
|
199
|
+
light.shadow.needsUpdate = true;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
private _shadowResolution?: number = undefined;
|
|
203
|
+
|
|
204
|
+
get isBaked() {
|
|
205
|
+
return this.lightmapBakeType === LightmapBakeType.Baked;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
private get selfIsLight(): boolean {
|
|
209
|
+
if (this.gameObject["isLight"] === true) return true;
|
|
210
|
+
switch (this.gameObject.type) {
|
|
211
|
+
case "SpotLight":
|
|
212
|
+
case "PointLight":
|
|
213
|
+
case "DirectionalLight":
|
|
214
|
+
return true;
|
|
215
|
+
}
|
|
216
|
+
return false;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
private light: THREE.Light | undefined = undefined;
|
|
220
|
+
|
|
221
|
+
public getWorldPosition(vec: THREE.Vector3): THREE.Vector3 {
|
|
222
|
+
if (this.light) {
|
|
223
|
+
if (this.type === LightType.Directional) {
|
|
224
|
+
return this.light.getWorldPosition(vec).multiplyScalar(1);
|
|
225
|
+
}
|
|
226
|
+
return this.light.getWorldPosition(vec);
|
|
227
|
+
}
|
|
228
|
+
return vec;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
public updateIntensity() {
|
|
232
|
+
this.intensity = this._intensity;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
awake() {
|
|
236
|
+
this.color = new THREE.Color(this.color ?? 0xffffff);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
onEnable(): void {
|
|
240
|
+
this.createLight();
|
|
241
|
+
if (this.isBaked) return;
|
|
242
|
+
else if (this.light) {
|
|
243
|
+
if (this.selfIsLight) {
|
|
244
|
+
// nothing to do
|
|
245
|
+
}
|
|
246
|
+
else if (this.light.parent !== this.gameObject)
|
|
247
|
+
this.gameObject.add(this.light);
|
|
248
|
+
}
|
|
249
|
+
if (this.type === LightType.Directional)
|
|
250
|
+
this.startCoroutine(this.updateMainLightRoutine(), FrameEvent.LateUpdate);
|
|
251
|
+
|
|
252
|
+
this._webXRStartedListener = WebXR.addEventListener(WebXREvent.XRStarted, this.onWebXRStarted.bind(this));
|
|
253
|
+
this._webXREndedListener = WebXR.addEventListener(WebXREvent.XRStopped, this.onWebXREnded.bind(this));
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
onDisable() {
|
|
257
|
+
WebXR.removeEventListener(WebXREvent.XRStarted, this._webXRStartedListener);
|
|
258
|
+
WebXR.removeEventListener(WebXREvent.XRStopped, this._webXREndedListener);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
private _webXRStartedListener?: Function;
|
|
262
|
+
private _webXREndedListener?: Function;
|
|
263
|
+
private _webARRoot?: WebARSessionRoot;
|
|
264
|
+
|
|
265
|
+
private onWebXRStarted() {
|
|
266
|
+
this._webARRoot = this.gameObject.getComponentInParent(WebARSessionRoot) ?? undefined;
|
|
267
|
+
this.startCoroutine(this._updateLightIntensityInARRoutine());
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
private *_updateLightIntensityInARRoutine() {
|
|
271
|
+
while (this.context.isInXR) {
|
|
272
|
+
yield;
|
|
273
|
+
this.updateIntensity();
|
|
274
|
+
for (let i = 0; i < 30; i++) yield;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
private onWebXREnded() {
|
|
279
|
+
this.updateIntensity();
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
createLight() {
|
|
283
|
+
if (this.light) return;
|
|
284
|
+
let lightAlreadyCreated = this.selfIsLight;
|
|
285
|
+
if (lightAlreadyCreated) {
|
|
286
|
+
this.light = this.gameObject as unknown as THREE.Light;
|
|
287
|
+
|
|
288
|
+
switch (this.type) {
|
|
289
|
+
case LightType.Directional:
|
|
290
|
+
this.setDirectionalLight(this.light as DirectionalLight);
|
|
291
|
+
break;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
switch (this.type) {
|
|
296
|
+
case LightType.Directional:
|
|
297
|
+
// console.log(this);
|
|
298
|
+
const dirLight = new THREE.DirectionalLight(this.color, this.intensity * Math.PI);
|
|
299
|
+
// directional light target is at 0 0 0 by default
|
|
300
|
+
dirLight.position.set(0, 0, -shadowMaxDistance * .5).applyQuaternion(this.gameObject.quaternion);
|
|
301
|
+
this.gameObject.add(dirLight.target);
|
|
302
|
+
setWorldPositionXYZ(dirLight.target, 0, 0, 0);
|
|
303
|
+
this.light = dirLight;
|
|
304
|
+
this.gameObject.position.set(0, 0, 0);
|
|
305
|
+
this.gameObject.rotation.set(0, 0, 0);
|
|
306
|
+
|
|
307
|
+
if (debug) {
|
|
308
|
+
const spotLightHelper = new THREE.DirectionalLightHelper(this.light as THREE.DirectionalLight, .2, this.color);
|
|
309
|
+
this.context.scene.add(spotLightHelper);
|
|
310
|
+
// const bh = new THREE.BoxHelper(this.context.scene, 0xfff0000);
|
|
311
|
+
// this.context.scene.add(bh);
|
|
312
|
+
}
|
|
313
|
+
break;
|
|
314
|
+
|
|
315
|
+
case LightType.Spot:
|
|
316
|
+
const spotLight = new THREE.SpotLight(this.color, this.intensity * Math.PI, this.range, toRadians(this.spotAngle / 2), 1 - toRadians(this.innerSpotAngle / 2) / toRadians(this.spotAngle / 2), 2);
|
|
317
|
+
spotLight.position.set(0, 0, 0);
|
|
318
|
+
spotLight.rotation.set(0, 0, 0);
|
|
319
|
+
|
|
320
|
+
this.light = spotLight;
|
|
321
|
+
const spotLightTarget = spotLight.target;
|
|
322
|
+
spotLight.add(spotLightTarget);
|
|
323
|
+
spotLightTarget.position.set(0, 0, this.range);
|
|
324
|
+
spotLightTarget.rotation.set(0, 0, 0);
|
|
325
|
+
break;
|
|
326
|
+
|
|
327
|
+
case LightType.Point:
|
|
328
|
+
const pointLight = new THREE.PointLight(this.color, this.intensity * Math.PI, this.range);
|
|
329
|
+
this.light = pointLight;
|
|
330
|
+
|
|
331
|
+
// const pointHelper = new THREE.PointLightHelper(pointLight, this.range, this.color);
|
|
332
|
+
// scene.add(pointHelper);
|
|
333
|
+
break;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
if (this.light !== undefined) {
|
|
338
|
+
if (this.shadows !== LightShadows.None) {
|
|
339
|
+
this.light.castShadow = true;
|
|
340
|
+
}
|
|
341
|
+
else this.light.castShadow = false;
|
|
342
|
+
|
|
343
|
+
// shadow intensity is currently not a thing: https://github.com/mrdoob/three.js/pull/14087
|
|
344
|
+
if (this._shadowResolution !== undefined && this._shadowResolution > 4) {
|
|
345
|
+
this.light.shadow.mapSize.width = this._shadowResolution;
|
|
346
|
+
this.light.shadow.mapSize.height = this._shadowResolution;
|
|
347
|
+
}
|
|
348
|
+
else {
|
|
349
|
+
this.light.shadow.mapSize.width = 2048;
|
|
350
|
+
this.light.shadow.mapSize.height = 2048;
|
|
351
|
+
}
|
|
352
|
+
this.light.shadow.bias = this.shadowBias * 0.00001;
|
|
353
|
+
this.light.shadow.normalBias = this.shadowNormalBias * .0001;
|
|
354
|
+
|
|
355
|
+
// console.log(this.light.shadow, this);
|
|
356
|
+
const cam = this.light.shadow.camera as THREE.OrthographicCamera;
|
|
357
|
+
cam.near = this.shadowNearPlane;
|
|
358
|
+
// use shadow distance that was set explictly (if any)
|
|
359
|
+
if (this._shadowDistance !== undefined && typeof this._shadowDistance === "number")
|
|
360
|
+
cam.far = this._shadowDistance;
|
|
361
|
+
else // otherwise fallback to object scale and max distance
|
|
362
|
+
cam.far = shadowMaxDistance * Math.abs(this.gameObject.scale.z);
|
|
363
|
+
|
|
364
|
+
// width and height
|
|
365
|
+
this.gameObject.scale.set(1, 1, 1);
|
|
366
|
+
if (this.shadowWidth !== undefined) {
|
|
367
|
+
cam.left = -this.shadowWidth / 2;
|
|
368
|
+
cam.right = this.shadowWidth / 2;
|
|
369
|
+
}
|
|
370
|
+
else {
|
|
371
|
+
const sx = this.gameObject.scale.x;
|
|
372
|
+
cam.left *= sx;
|
|
373
|
+
cam.right *= sx;
|
|
374
|
+
}
|
|
375
|
+
if (this.shadowHeight !== undefined) {
|
|
376
|
+
cam.top = this.shadowHeight / 2;
|
|
377
|
+
cam.bottom = -this.shadowHeight / 2;
|
|
378
|
+
}
|
|
379
|
+
else {
|
|
380
|
+
const sy = this.gameObject.scale.y;
|
|
381
|
+
cam.top *= sy;
|
|
382
|
+
cam.bottom *= sy;
|
|
383
|
+
}
|
|
384
|
+
this.light.shadow.needsUpdate = true;
|
|
385
|
+
if (debug)
|
|
386
|
+
this.context.scene.add(new THREE.CameraHelper(cam));
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
if (this.isBaked) {
|
|
390
|
+
this.light.removeFromParent();
|
|
391
|
+
}
|
|
392
|
+
else if (!lightAlreadyCreated)
|
|
393
|
+
this.gameObject.add(this.light);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
*updateMainLightRoutine() {
|
|
399
|
+
while (true) {
|
|
400
|
+
if (this.type === LightType.Directional) {
|
|
401
|
+
if (!this.context.mainLight || this.intensity > this.context.mainLight.intensity) {
|
|
402
|
+
this.context.mainLight = this;
|
|
403
|
+
}
|
|
404
|
+
yield;
|
|
405
|
+
}
|
|
406
|
+
break;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
private setDirectionalLight(dirLight: DirectionalLight) {
|
|
411
|
+
dirLight.add(dirLight.target);
|
|
412
|
+
dirLight.target.position.set(0, 0, -1);
|
|
413
|
+
// dirLight.position.add(vec.set(0,0,1).multiplyScalar(shadowMaxDistance*.1).applyQuaternion(this.gameObject.quaternion));
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
const vec = new THREE.Vector3(0, 0, 0);
|
|
418
|
+
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Behaviour, GameObject } from "./Component";
|
|
2
|
+
import * as THREE from "three";
|
|
3
|
+
import { serializeable } from "../engine/engine_serialization_decorator";
|
|
4
|
+
import { Object3D } from "three";
|
|
5
|
+
|
|
6
|
+
export class LookAtConstraint extends Behaviour {
|
|
7
|
+
|
|
8
|
+
constraintActive: boolean = true;
|
|
9
|
+
locked: boolean = false;
|
|
10
|
+
@serializeable(Object3D)
|
|
11
|
+
sources: THREE.Object3D[] = [];
|
|
12
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
|
|
2
|
+
import { Behaviour } from "./Component";
|
|
3
|
+
import { Physics } from '../engine/engine_physics'
|
|
4
|
+
import * as THREE from 'three';
|
|
5
|
+
|
|
6
|
+
export class MeshCollider extends Behaviour {
|
|
7
|
+
|
|
8
|
+
onEnable() {
|
|
9
|
+
if (this.enabled)
|
|
10
|
+
this.context.physics.addMeshCollider(this.gameObject);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
|
|
2
|
+
import { Behaviour, GameObject } from "./Component";
|
|
3
|
+
/*
|
|
4
|
+
import { Pathfinding, PathfindingHelper } from 'three-pathfinding';
|
|
5
|
+
import * as THREE from 'three';
|
|
6
|
+
import { mergeBufferGeometries } from 'three/examples/jsm/utils/BufferGeometryUtils'
|
|
7
|
+
*/
|
|
8
|
+
export class NavMesh extends Behaviour {
|
|
9
|
+
/*
|
|
10
|
+
public meshes: THREE.Object3D[] = [];
|
|
11
|
+
|
|
12
|
+
private pathfinding: Pathfinding | null = null;
|
|
13
|
+
private zones: string[] = [];
|
|
14
|
+
|
|
15
|
+
onEnable(): void {
|
|
16
|
+
|
|
17
|
+
this.pathfinding = new Pathfinding();
|
|
18
|
+
const ZONE = 'zone';
|
|
19
|
+
const geometries : THREE.BufferGeometry[] = [];
|
|
20
|
+
if (this.meshes && this.meshes.length > 0) {
|
|
21
|
+
for (let i = 0; i < this.meshes.length; i++) {
|
|
22
|
+
const obj = this.meshes[i] as THREE.Mesh;
|
|
23
|
+
if (!obj) continue;
|
|
24
|
+
const geo = obj.geometry;
|
|
25
|
+
if (!geo) continue;
|
|
26
|
+
const copy : THREE.BufferGeometry = {...geo};
|
|
27
|
+
// const copy = geo;
|
|
28
|
+
const attributesCopy = {...copy.attributes};
|
|
29
|
+
copy.attributes = attributesCopy;
|
|
30
|
+
if(attributesCopy.uv2) delete attributesCopy.uv2;
|
|
31
|
+
// copy.applyMatrix4(obj.matrixWorld);
|
|
32
|
+
geometries.push(copy);
|
|
33
|
+
// obj.updateMatrixWorld();
|
|
34
|
+
// singleGeometry.merge(geo);
|
|
35
|
+
// console.log(singleGeometry, geo);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const mesh = mergeBufferGeometries(geometries);
|
|
39
|
+
const zone = Pathfinding.createZone(mesh);
|
|
40
|
+
const name = ZONE;
|
|
41
|
+
this.zones.push(name);
|
|
42
|
+
this.pathfinding.setZoneData(name, zone);
|
|
43
|
+
|
|
44
|
+
// const target = new THREE.Vector3(2, 0, 2);
|
|
45
|
+
// const groupID = this.pathfinding.getGroup(ZONE, target);
|
|
46
|
+
// const path = this.pathfinding.findPath(this.worldPosition, target, ZONE, groupID);
|
|
47
|
+
// console.log(path, this.pathfinding);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public tryFindPath(from: THREE.Vector3, to: THREE.Vector3): THREE.Vector3[] | null {
|
|
51
|
+
const zone = this.zones[0];
|
|
52
|
+
const groupId = this.pathfinding.getGroup(zone, to);
|
|
53
|
+
const path = this.pathfinding.findPath(from, to, zone, groupId);
|
|
54
|
+
return path;
|
|
55
|
+
}
|
|
56
|
+
*/
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// import { input } from "../engine/engine_input";
|
|
60
|
+
import { Physics, RaycastOptions } from "../engine/engine_physics"
|
|
61
|
+
// import { time } from "../engine/engine_time";
|
|
62
|
+
// import { scene } from "../engine/engine_setup";
|
|
63
|
+
import { Quaternion } from "math/Quaternion";
|
|
64
|
+
import {SyncedTransform} from "./SyncedTransform";
|
|
65
|
+
|
|
66
|
+
export class NavMeshAgent extends Behaviour {
|
|
67
|
+
/*
|
|
68
|
+
public navMesh: NavMesh | null = null;
|
|
69
|
+
|
|
70
|
+
private currentPath: THREE.Vector3[] | null = null;
|
|
71
|
+
private helper : PathfindingHelper | null = null;
|
|
72
|
+
|
|
73
|
+
onEnable(): void {
|
|
74
|
+
this.helper = new PathfindingHelper();
|
|
75
|
+
scene.add(this.helper);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
update(): void {
|
|
79
|
+
if (input.mouseClick) {
|
|
80
|
+
if (this.navMesh) {
|
|
81
|
+
const from = this.worldPosition;
|
|
82
|
+
const opts = new RaycastOptions();
|
|
83
|
+
opts.setMask(RaycastOptions.AllLayers);
|
|
84
|
+
const hits = Physics.raycast(opts);
|
|
85
|
+
if (hits.length > 0) {
|
|
86
|
+
const to = hits[0].point;
|
|
87
|
+
this.helper.setPlayerPosition(from);
|
|
88
|
+
this.helper.setTargetPosition(to);
|
|
89
|
+
this.currentPath = this.navMesh.tryFindPath(from, to);
|
|
90
|
+
this.helper.setPath(this.currentPath);
|
|
91
|
+
// console.log(...this.currentPath);
|
|
92
|
+
|
|
93
|
+
const sync = GameObject.getComponent(this.gameObject, SyncedTransform);
|
|
94
|
+
if(sync) sync.requestOwnership();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (this.currentPath && this.currentPath.length > 0) {
|
|
100
|
+
|
|
101
|
+
const wp = this.worldPosition;
|
|
102
|
+
const target = this.currentPath[0];
|
|
103
|
+
this.worldPosition = wp.lerp(target, time.deltaTime*2);
|
|
104
|
+
|
|
105
|
+
this.gameObject.lookAt(target);
|
|
106
|
+
// const vec = target.clone().sub(wp);
|
|
107
|
+
// const wr = this.worldQuaternion;
|
|
108
|
+
// wr.slerp(rot, time.deltaTime*5);
|
|
109
|
+
// this.worldQuaternion = wr;
|
|
110
|
+
|
|
111
|
+
if (wp.distanceTo(this.currentPath[0]) < 0.1)
|
|
112
|
+
this.currentPath.shift();
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
*/
|
|
118
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { getParam } from "../engine/engine_utils";
|
|
2
|
+
import { Behaviour, InstantiateOptions } from "../engine-components/Component";
|
|
3
|
+
import { AssetReference, ProgressCallback } from "../engine/engine_addressables";
|
|
4
|
+
import { serializeable } from "../engine/engine_serialization_decorator";
|
|
5
|
+
import { InstantiateIdProvider } from "../engine/engine_networking_instantiate";
|
|
6
|
+
|
|
7
|
+
const debug = getParam("debugnestedgltf");
|
|
8
|
+
|
|
9
|
+
export class NestedGltf extends Behaviour {
|
|
10
|
+
@serializeable(AssetReference)
|
|
11
|
+
filePath?: AssetReference;
|
|
12
|
+
|
|
13
|
+
private _isLoadingOrDoneLoading: boolean = false;
|
|
14
|
+
|
|
15
|
+
listenToProgress(evt: ProgressCallback) {
|
|
16
|
+
this.filePath?.beginListenDownload(evt)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
preload() {
|
|
20
|
+
this.filePath?.preload();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async start() {
|
|
24
|
+
if (this._isLoadingOrDoneLoading) return;
|
|
25
|
+
if (debug) console.log(this, this.guid);
|
|
26
|
+
|
|
27
|
+
const parent = this.gameObject.parent;
|
|
28
|
+
if (parent) {
|
|
29
|
+
this._isLoadingOrDoneLoading = true;
|
|
30
|
+
const opts = new InstantiateOptions();
|
|
31
|
+
// we need to provide stable guids for creating nested gltfs
|
|
32
|
+
opts.idProvider = new InstantiateIdProvider(this.hash(this.guid));
|
|
33
|
+
opts.parent = parent;
|
|
34
|
+
this.gameObject.updateMatrix();
|
|
35
|
+
const matrix = this.gameObject.matrix;
|
|
36
|
+
if (debug) console.log("Load nested:", this.filePath?.uri ?? this.filePath, this.gameObject.position)
|
|
37
|
+
const res = await this.filePath?.instantiate?.call(this.filePath, opts);
|
|
38
|
+
if (res) {
|
|
39
|
+
res.matrixAutoUpdate = false;
|
|
40
|
+
res.matrix.identity();
|
|
41
|
+
res.applyMatrix4(matrix);
|
|
42
|
+
res.matrixAutoUpdate = true;
|
|
43
|
+
}
|
|
44
|
+
this.destroy();
|
|
45
|
+
if (debug) console.log("Nested loading done:", this.filePath?.uri ?? this.filePath, res);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
hash(str: string): number {
|
|
50
|
+
let hash = 0;
|
|
51
|
+
for (let i = 0; i < str.length; i++) {
|
|
52
|
+
hash = str.charCodeAt(i) + ((hash << 5) - hash);
|
|
53
|
+
}
|
|
54
|
+
return hash;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { isLocalNetwork } from "../engine/engine_networking_utils";
|
|
2
|
+
import { getParam } from "../engine/engine_utils";
|
|
3
|
+
import { Behaviour } from "./Component";
|
|
4
|
+
|
|
5
|
+
export class Networking extends Behaviour {
|
|
6
|
+
|
|
7
|
+
url: string | null = null;
|
|
8
|
+
urlParameterName: string | null = null;
|
|
9
|
+
|
|
10
|
+
// used when local host is detected
|
|
11
|
+
localhost: string | null = null;
|
|
12
|
+
|
|
13
|
+
getWebsocketUrl(): string | null {
|
|
14
|
+
|
|
15
|
+
let socketurl = this.url ? Networking.GetUrl(this.url, this.localhost) : null;
|
|
16
|
+
|
|
17
|
+
if (this.urlParameterName) {
|
|
18
|
+
const res = getParam(this.urlParameterName);
|
|
19
|
+
if (res && typeof res === "string") {
|
|
20
|
+
socketurl = res;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (!socketurl) return null;
|
|
25
|
+
|
|
26
|
+
// regex https://regex101.com/r/JQ5WqB/1
|
|
27
|
+
const regex = new RegExp("(((https?)|(?<socket_prefix>wss?)):\/\/)?(www\.)?(?<url>.+)", "gm");
|
|
28
|
+
const match = regex.exec(socketurl);
|
|
29
|
+
if (!match?.groups) return null;
|
|
30
|
+
// if the url has a ws or wss prefix already assume the whole url is in the correct format
|
|
31
|
+
const socketPrefix = match?.groups["socket_prefix"];
|
|
32
|
+
if (socketPrefix) return socketurl;
|
|
33
|
+
// otherwise add the ws prefix
|
|
34
|
+
return "wss://" + match?.groups["url"];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
public static GetUrl(url: string, localhostFallback?: string | null): string {
|
|
39
|
+
|
|
40
|
+
let result = url;
|
|
41
|
+
|
|
42
|
+
const useLocalHostUrl = Networking.IsLocalNetwork() && localhostFallback;
|
|
43
|
+
if (useLocalHostUrl) {
|
|
44
|
+
result = localhostFallback;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (url?.startsWith("/")) {
|
|
48
|
+
const base = useLocalHostUrl ? result : window.location.origin;
|
|
49
|
+
result = base + url;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
public static IsLocalNetwork(hostname = window.location.hostname) {
|
|
56
|
+
return isLocalNetwork(hostname);
|
|
57
|
+
}
|
|
58
|
+
}
|