@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,206 @@
|
|
|
1
|
+
import { NetworkConnection } from "../engine/engine_networking";
|
|
2
|
+
import { Behaviour, GameObject, InstantiateOptions } from "./Component";
|
|
3
|
+
import { Camera } from "./Camera";
|
|
4
|
+
import * as utils from "../engine/engine_three_utils"
|
|
5
|
+
import { WebXR } from "./WebXR";
|
|
6
|
+
import { Builder } from "flatbuffers";
|
|
7
|
+
import { SyncedCameraModel } from "../engine-schemes/synced-camera-model";
|
|
8
|
+
import { Vec3 } from "../engine-schemes/vec3";
|
|
9
|
+
import { registerType } from "../engine-schemes/schemes";
|
|
10
|
+
import { InstancingUtil } from "./Renderer";
|
|
11
|
+
import { serializeable } from "../engine/engine_serialization_decorator";
|
|
12
|
+
import { Object3D } from "three";
|
|
13
|
+
import { AvatarMarker } from "./WebXRAvatar";
|
|
14
|
+
import { AssetReference } from "../engine/engine_addressables";
|
|
15
|
+
|
|
16
|
+
const SyncedCameraModelIdentifier = "SCAM";
|
|
17
|
+
registerType(SyncedCameraModelIdentifier, SyncedCameraModel.getRootAsSyncedCameraModel);
|
|
18
|
+
const builder = new Builder();
|
|
19
|
+
|
|
20
|
+
// enum CameraSyncEvent {
|
|
21
|
+
// Update = "sync-update-camera",
|
|
22
|
+
// }
|
|
23
|
+
|
|
24
|
+
class CameraModel {
|
|
25
|
+
userId: string;
|
|
26
|
+
guid: string;
|
|
27
|
+
// dontSave: boolean = true;
|
|
28
|
+
// pos: { x: number, y: number, z: number } = { x: 0, y: 0, z: 0 };
|
|
29
|
+
// rot: { x: number, y: number, z: number } = { x: 0, y: 0, z: 0 };
|
|
30
|
+
|
|
31
|
+
constructor(connectionId: string, guid: string) {
|
|
32
|
+
this.guid = guid;
|
|
33
|
+
this.userId = connectionId;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
send(sync: SyncedCamera, con: NetworkConnection) {
|
|
37
|
+
const cam = sync.cam?.cam;
|
|
38
|
+
if (cam) {
|
|
39
|
+
builder.clear();
|
|
40
|
+
const guid = builder.createString(this.guid);
|
|
41
|
+
const userId = builder.createString(this.userId);
|
|
42
|
+
SyncedCameraModel.startSyncedCameraModel(builder);
|
|
43
|
+
SyncedCameraModel.addGuid(builder, guid);
|
|
44
|
+
SyncedCameraModel.addUserId(builder, userId);
|
|
45
|
+
const p = utils.getWorldPosition(cam);
|
|
46
|
+
const r = utils.getWorldRotation(cam);
|
|
47
|
+
SyncedCameraModel.addPos(builder, Vec3.createVec3(builder, p.x, p.y, p.z));
|
|
48
|
+
SyncedCameraModel.addRot(builder, Vec3.createVec3(builder, r.x, r.y, r.z));
|
|
49
|
+
const offset = SyncedCameraModel.endSyncedCameraModel(builder);
|
|
50
|
+
builder.finish(offset, SyncedCameraModelIdentifier);
|
|
51
|
+
con.sendBinary(builder.asUint8Array());
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
declare type UserCamInfo =
|
|
57
|
+
{
|
|
58
|
+
obj: THREE.Object3D,
|
|
59
|
+
lastUpdate: number;
|
|
60
|
+
userId: string;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export class SyncedCamera extends Behaviour {
|
|
64
|
+
|
|
65
|
+
getUserCamera(userId: string): THREE.Object3D | null {
|
|
66
|
+
const guid = this.userToCamMap[userId];
|
|
67
|
+
if (!guid) return null;
|
|
68
|
+
return this.remoteCams[guid].obj;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
@serializeable(Camera)
|
|
72
|
+
public cam: Camera | null = null;
|
|
73
|
+
@serializeable([Object3D, AssetReference])
|
|
74
|
+
public cameraPrefab: THREE.Object3D | null | AssetReference = null;
|
|
75
|
+
|
|
76
|
+
private _lastWorldPosition!: THREE.Vector3;
|
|
77
|
+
private _lastWorldQuaternion!: THREE.Quaternion;
|
|
78
|
+
private _model: CameraModel | null = null;
|
|
79
|
+
private _needsUpdate: boolean = true;
|
|
80
|
+
private _lastUpdateTime: number = 0;
|
|
81
|
+
|
|
82
|
+
private remoteCams: { [id: string]: UserCamInfo } = {};
|
|
83
|
+
private userToCamMap: { [id: string]: string } = {};
|
|
84
|
+
private _camTimeoutInSeconds = 10;
|
|
85
|
+
private _receiveCallback: Function | null = null;
|
|
86
|
+
|
|
87
|
+
async awake() {
|
|
88
|
+
this._lastWorldPosition = this.worldPosition.clone();
|
|
89
|
+
this._lastWorldQuaternion = this.worldQuaternion.clone();
|
|
90
|
+
|
|
91
|
+
if (this.cameraPrefab) {
|
|
92
|
+
|
|
93
|
+
if ("uri" in this.cameraPrefab) {
|
|
94
|
+
this.cameraPrefab = await this.cameraPrefab.instantiate(this.gameObject);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (this.cameraPrefab && "isObject3D" in this.cameraPrefab) {
|
|
98
|
+
this.cameraPrefab.visible = false;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
start() {
|
|
105
|
+
if (!this.cam) {
|
|
106
|
+
console.warn("Missing camera, fallback to main camera", this);
|
|
107
|
+
this.cam = this.context.mainCameraComponent as Camera ?? null;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
onEnable(): void {
|
|
112
|
+
this._receiveCallback = this.context.connection.beginListenBinrary(SyncedCameraModelIdentifier, this.onReceivedRemoteCameraInfoBin.bind(this));
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
onDisable(): void {
|
|
116
|
+
this.context.connection.stopListenBinary(SyncedCameraModelIdentifier, this._receiveCallback);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
update(): void {
|
|
120
|
+
|
|
121
|
+
for (const guid in this.remoteCams) {
|
|
122
|
+
const cam = this.remoteCams[guid];
|
|
123
|
+
const timeDiff = this.context.time.realtimeSinceStartup - cam.lastUpdate;
|
|
124
|
+
if (!cam || (timeDiff) > this._camTimeoutInSeconds) {
|
|
125
|
+
console.log("Remote cam timeout", cam, timeDiff);
|
|
126
|
+
if (cam?.obj) {
|
|
127
|
+
GameObject.destroy(cam.obj);
|
|
128
|
+
}
|
|
129
|
+
delete this.remoteCams[guid];
|
|
130
|
+
if (cam)
|
|
131
|
+
delete this.userToCamMap[cam.userId];
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (WebXR.IsInWebXR) return;
|
|
137
|
+
|
|
138
|
+
if (this.cam === null) {
|
|
139
|
+
this.enabled = false;
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (!this.context.connection.isConnected || this.context.connection.connectionId === null) return;
|
|
144
|
+
|
|
145
|
+
if (this._model === null) {
|
|
146
|
+
this._model = new CameraModel(this.context.connection.connectionId, this.context.connection.connectionId + "_camera");
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const wp = utils.getWorldPosition(this.cam.cam);
|
|
150
|
+
const wq = utils.getWorldQuaternion(this.cam.cam);
|
|
151
|
+
if (wp.distanceTo(this._lastWorldPosition) > 0.001 || wq.angleTo(this._lastWorldQuaternion) > 0.01) {
|
|
152
|
+
this._needsUpdate = true;
|
|
153
|
+
}
|
|
154
|
+
this._lastWorldPosition.copy(wp);
|
|
155
|
+
this._lastWorldQuaternion.copy(wq);
|
|
156
|
+
|
|
157
|
+
if (!this._needsUpdate || this.context.time.frameCount % 2 !== 0) {
|
|
158
|
+
if (this.context.time.realtimeSinceStartup - this._lastUpdateTime > this._camTimeoutInSeconds * .5) {
|
|
159
|
+
// send update anyways to avoid timeout
|
|
160
|
+
}
|
|
161
|
+
else return;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
this._lastUpdateTime = this.context.time.realtimeSinceStartup;
|
|
165
|
+
this._needsUpdate = false;
|
|
166
|
+
this._model.send(this, this.context.connection);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
private onReceivedRemoteCameraInfoBin(model: SyncedCameraModel) {
|
|
170
|
+
const guid = model.guid();
|
|
171
|
+
if (!guid) return;
|
|
172
|
+
const userId = model.userId();
|
|
173
|
+
if (!userId) return;
|
|
174
|
+
if (!this.context.connection.userIsInRoom(userId)) return;
|
|
175
|
+
if (!this.cameraPrefab) return;
|
|
176
|
+
let rc = this.remoteCams[guid];
|
|
177
|
+
if (!rc) {
|
|
178
|
+
if ("isObject3D" in this.cameraPrefab) {
|
|
179
|
+
const opt = new InstantiateOptions();
|
|
180
|
+
opt.context = this.context;
|
|
181
|
+
const instance = GameObject.instantiate(this.cameraPrefab, opt) as GameObject;
|
|
182
|
+
rc = this.remoteCams[guid] = { obj: instance, lastUpdate: this.context.time.realtimeSinceStartup, userId: userId };
|
|
183
|
+
rc.obj.visible = true;
|
|
184
|
+
this.gameObject.add(instance);
|
|
185
|
+
this.userToCamMap[userId] = guid;
|
|
186
|
+
|
|
187
|
+
const marker = GameObject.getOrAddComponent(instance, AvatarMarker);
|
|
188
|
+
marker.connectionId = userId;
|
|
189
|
+
marker.avatar = instance;
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
// console.log(this.remoteCams);
|
|
195
|
+
}
|
|
196
|
+
const obj = rc.obj;
|
|
197
|
+
rc.lastUpdate = this.context.time.realtimeSinceStartup;
|
|
198
|
+
InstancingUtil.markDirty(obj);
|
|
199
|
+
const pos = model.pos();
|
|
200
|
+
if (pos)
|
|
201
|
+
utils.setWorldPositionXYZ(obj, pos.x(), pos.y(), pos.z());
|
|
202
|
+
const rot = model.rot();
|
|
203
|
+
if (rot)
|
|
204
|
+
utils.setWorldRotationXYZ(obj, rot.x(), rot.y(), rot.z());
|
|
205
|
+
}
|
|
206
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { Behaviour } from "./Component";
|
|
2
|
+
import * as utils from "../engine/engine_utils"
|
|
3
|
+
import { serializeable } from "../engine/engine_serialization_decorator";
|
|
4
|
+
|
|
5
|
+
const viewParamName = "view";
|
|
6
|
+
const debug = utils.getParam("debugsyncedroom");
|
|
7
|
+
|
|
8
|
+
export class SyncedRoom extends Behaviour {
|
|
9
|
+
|
|
10
|
+
@serializeable()
|
|
11
|
+
public roomName!: string;
|
|
12
|
+
@serializeable()
|
|
13
|
+
public urlParameterName!: string;
|
|
14
|
+
@serializeable()
|
|
15
|
+
public joinRandomRoom: boolean = true;
|
|
16
|
+
@serializeable()
|
|
17
|
+
public requireRoomParameter: boolean = false;
|
|
18
|
+
@serializeable()
|
|
19
|
+
public autoRejoin: boolean = true;
|
|
20
|
+
|
|
21
|
+
private _roomPrefix?: string;
|
|
22
|
+
|
|
23
|
+
awake() {
|
|
24
|
+
if (this._roomPrefix === undefined) {
|
|
25
|
+
this._roomPrefix = this.roomName;
|
|
26
|
+
this.roomName = "";
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
onEnable() {
|
|
31
|
+
// if the url contains a view parameter override room and join in view mode
|
|
32
|
+
const viewId = utils.getParam(viewParamName);
|
|
33
|
+
if (viewId && typeof viewId === "string" && viewId.length > 0) {
|
|
34
|
+
console.log("Join as viewer");
|
|
35
|
+
this.context.connection.joinRoom(viewId, true);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
this.tryJoinRoom();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
onDisable(): void {
|
|
42
|
+
if (this.roomName && this.roomName.length > 0)
|
|
43
|
+
this.context.connection.leaveRoom(this.roomName);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
tryJoinRoom(call: number = 0): boolean {
|
|
47
|
+
let hasRoomParameter = false;
|
|
48
|
+
if (this.urlParameterName) {
|
|
49
|
+
const val = utils.getParam(this.urlParameterName);
|
|
50
|
+
if (val && typeof val === "string") {
|
|
51
|
+
hasRoomParameter = true;
|
|
52
|
+
const roomNameParam = utils.sanitizeString(val);
|
|
53
|
+
this.roomName = roomNameParam;
|
|
54
|
+
}
|
|
55
|
+
else if (this.joinRandomRoom) {
|
|
56
|
+
console.log("No room name found in url, generating random one");
|
|
57
|
+
this.setRandomRoomUrlParameter();
|
|
58
|
+
if (call < 1)
|
|
59
|
+
return this.tryJoinRoom(call + 1);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
if (this.joinRandomRoom && (this.roomName === null || this.roomName === undefined || this.roomName.length <= 0)) {
|
|
64
|
+
console.log("generate room name");
|
|
65
|
+
this.roomName = this.generateRoomName();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (this.requireRoomParameter && !hasRoomParameter) {
|
|
70
|
+
if (debug)
|
|
71
|
+
console.log("No required room parameter \"" + this.urlParameterName + "\" in url - will not connect to networking backend.");
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (!this.roomName || this.roomName.length <= 0) {
|
|
76
|
+
if (debug)
|
|
77
|
+
console.error("Missing room name on \"" + this.name + "\". Make sure this is correctly configured in Unity", this.context.connection.isDebugEnabled ? this : "");
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (!this.context.connection.isConnected) {
|
|
82
|
+
this.context.connection.connect();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (this._roomPrefix)
|
|
86
|
+
this.roomName = this._roomPrefix + this.roomName;
|
|
87
|
+
|
|
88
|
+
this.context.connection.joinRoom(this.roomName);
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
private _lastPingTime: number = 0;
|
|
93
|
+
private _lastRoomTime: number = -1;
|
|
94
|
+
|
|
95
|
+
update(): void {
|
|
96
|
+
if (this.context.connection.isConnected) {
|
|
97
|
+
if (this.context.time.time - this._lastPingTime > 3) {
|
|
98
|
+
this._lastPingTime = this.context.time.time;
|
|
99
|
+
// console.log("PING");
|
|
100
|
+
this.context.connection.send("ping", { time: this.context.time.time });
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (this.context.connection.isInRoom) {
|
|
104
|
+
this._lastRoomTime = this.context.time.time;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (this._lastRoomTime > 0 && this.context.time.time - this._lastRoomTime > .3) {
|
|
109
|
+
this._lastRoomTime = -1;
|
|
110
|
+
|
|
111
|
+
if (this.autoRejoin) {
|
|
112
|
+
console.log("Disconnected from networking backend - attempt reconnecting now")
|
|
113
|
+
this.tryJoinRoom();
|
|
114
|
+
}
|
|
115
|
+
else
|
|
116
|
+
console.warn("You are not connected to a room anymore (possibly because the tab was inactive for too long and the server kicked you)");
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
get currentRoomName(): string | null {
|
|
121
|
+
const view = utils.getParam(viewParamName);
|
|
122
|
+
if (view) return view as string;
|
|
123
|
+
return utils.getParam(this.urlParameterName) as string;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
setRandomRoomUrlParameter() {
|
|
127
|
+
const params = utils.getUrlParams();
|
|
128
|
+
const room = this.generateRoomName();
|
|
129
|
+
// if we already have this parameter
|
|
130
|
+
if (utils.getParam(this.urlParameterName)) {
|
|
131
|
+
params.set(this.urlParameterName, room);
|
|
132
|
+
}
|
|
133
|
+
else
|
|
134
|
+
params.append(this.urlParameterName, room);
|
|
135
|
+
utils.setState(room, params);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
generateRoomName(): string {
|
|
139
|
+
const words = utils.makeIdFromRandomWords();
|
|
140
|
+
const roomName = words + "_" + utils.randomNumber(100, 999);
|
|
141
|
+
return roomName;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
getViewOnlyUrl(): string | null {
|
|
145
|
+
if (this.context.connection.isConnected && this.context.connection.currentRoomViewId) {
|
|
146
|
+
const url = window.location.search;
|
|
147
|
+
const urlParams = new URLSearchParams(url);
|
|
148
|
+
if (urlParams.has(this.urlParameterName))
|
|
149
|
+
urlParams.delete(this.urlParameterName);
|
|
150
|
+
urlParams.set(viewParamName, this.context.connection.currentRoomViewId);
|
|
151
|
+
return window.location.origin + window.location.pathname + "?" + urlParams.toString();
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
import * as THREE from 'three'
|
|
2
|
+
import { IModel, OwnershipModel, RoomEvents } from "../engine/engine_networking"
|
|
3
|
+
import { Behaviour, GameObject } from "./Component";
|
|
4
|
+
import { Rigidbody } from "./RigidBody";
|
|
5
|
+
import * as utils from "../engine/engine_utils"
|
|
6
|
+
import { sendDestroyed } from '../engine/engine_networking_instantiate';
|
|
7
|
+
import { InstancingUtil } from './Renderer';
|
|
8
|
+
import { SyncedTransformModel } from '../engine-schemes/synced-transform-model';
|
|
9
|
+
import * as flatbuffers from "flatbuffers";
|
|
10
|
+
import { Transform } from '../engine-schemes/transform';
|
|
11
|
+
import { registerType } from '../engine-schemes/schemes';
|
|
12
|
+
import { setWorldEuler } from '../engine/engine_three_utils';
|
|
13
|
+
|
|
14
|
+
const debug = utils.getParam("debugsync");
|
|
15
|
+
export const SyncedTransformIdentifier = "STRS";
|
|
16
|
+
registerType(SyncedTransformIdentifier, SyncedTransformModel.getRootAsSyncedTransformModel);
|
|
17
|
+
|
|
18
|
+
const builder = new flatbuffers.Builder();
|
|
19
|
+
|
|
20
|
+
export function createTransformModel(guid: string, b: Behaviour, fast: boolean = true): Uint8Array {
|
|
21
|
+
builder.clear();
|
|
22
|
+
const guidObj = builder.createString(guid);
|
|
23
|
+
SyncedTransformModel.startSyncedTransformModel(builder);
|
|
24
|
+
SyncedTransformModel.addGuid(builder, guidObj);
|
|
25
|
+
SyncedTransformModel.addFast(builder, fast);
|
|
26
|
+
const p = b.worldPosition;
|
|
27
|
+
const r = b.worldEuler;
|
|
28
|
+
const s = b.gameObject.scale; // todo: world scale
|
|
29
|
+
// console.log(p, r, s);
|
|
30
|
+
SyncedTransformModel.addTransform(builder, Transform.createTransform(builder, p.x, p.y, p.z, r.x, r.y, r.z, s.x, s.y, s.z));
|
|
31
|
+
const res = SyncedTransformModel.endSyncedTransformModel(builder);
|
|
32
|
+
// SyncedTransformModel.finishSyncedTransformModelBuffer(builder, res);
|
|
33
|
+
builder.finish(res, SyncedTransformIdentifier);
|
|
34
|
+
return builder.asUint8Array();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
export class SyncedTransform extends Behaviour {
|
|
39
|
+
|
|
40
|
+
// public autoOwnership: boolean = true;
|
|
41
|
+
public overridePhysics: boolean = true
|
|
42
|
+
public interpolatePosition: boolean = true;
|
|
43
|
+
public interpolateRotation: boolean = true;
|
|
44
|
+
public fastMode: boolean = false;
|
|
45
|
+
public syncDestroy: boolean = false;
|
|
46
|
+
|
|
47
|
+
// private _state!: SyncedTransformModel;
|
|
48
|
+
private _model: OwnershipModel | null = null;
|
|
49
|
+
private _needsUpdate: boolean = true;
|
|
50
|
+
private rb: Rigidbody | null = null;
|
|
51
|
+
private _wasKinematic: boolean | undefined = false;
|
|
52
|
+
private _receivedDataBefore: boolean = false;
|
|
53
|
+
|
|
54
|
+
private _targetPosition!: THREE.Vector3;
|
|
55
|
+
private _targetRotation!: THREE.Quaternion;
|
|
56
|
+
|
|
57
|
+
private _receivedFastUpdate: boolean = false;
|
|
58
|
+
private _shouldRequestOwnership: boolean = false;
|
|
59
|
+
|
|
60
|
+
public requestOwnership() {
|
|
61
|
+
if (debug)
|
|
62
|
+
console.log("Request ownership");
|
|
63
|
+
if (!this._model) {
|
|
64
|
+
this._shouldRequestOwnership = true;
|
|
65
|
+
this._needsUpdate = true;
|
|
66
|
+
}
|
|
67
|
+
else
|
|
68
|
+
this._model.requestOwnership();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public hasOwnership(): boolean | undefined {
|
|
72
|
+
return this._model?.hasOwnership ?? undefined;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
public isOwned(): boolean | undefined {
|
|
76
|
+
return this._model?.isOwned;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
private joinedRoomCallback: any = null;
|
|
80
|
+
private receivedDataCallback: any = null;
|
|
81
|
+
|
|
82
|
+
awake() {
|
|
83
|
+
if (debug)
|
|
84
|
+
console.log("new instance", this.guid, this);
|
|
85
|
+
this._receivedDataBefore = false;
|
|
86
|
+
this._targetPosition = new THREE.Vector3();
|
|
87
|
+
this._targetRotation = new THREE.Quaternion();
|
|
88
|
+
|
|
89
|
+
// sync instantiate issue was because they shared the same last pos vector!
|
|
90
|
+
this.lastWorldPos = new THREE.Vector3();
|
|
91
|
+
this.lastWorldRotation = new THREE.Quaternion();
|
|
92
|
+
|
|
93
|
+
this.rb = GameObject.getComponentInChildren(this.gameObject, Rigidbody);
|
|
94
|
+
if (this.rb) {
|
|
95
|
+
this._wasKinematic = this.rb.isKinematic;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
this.receivedUpdate = true;
|
|
99
|
+
// this._state = new TransformModel(this.guid, this);
|
|
100
|
+
this._model = new OwnershipModel(this.context.connection, this.guid);
|
|
101
|
+
if (this.context.connection.isConnected) {
|
|
102
|
+
this.tryGetLastState();
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
this.joinedRoomCallback = this.tryGetLastState.bind(this);
|
|
106
|
+
this.context.connection.beginListen(RoomEvents.JoinedRoom, this.joinedRoomCallback);
|
|
107
|
+
this.receivedDataCallback = this.onReceivedData.bind(this);
|
|
108
|
+
this.context.connection.beginListenBinrary(SyncedTransformIdentifier, this.receivedDataCallback);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
onDestroy(): void {
|
|
112
|
+
// TODO: can we add a new component for this?! do we really need this?!
|
|
113
|
+
if (this.syncDestroy)
|
|
114
|
+
sendDestroyed(this.guid, this.context.connection);
|
|
115
|
+
this._model = null;
|
|
116
|
+
this.context.connection.stopListening(RoomEvents.JoinedRoom, this.joinedRoomCallback);
|
|
117
|
+
this.context.connection.stopListenBinary(SyncedTransformIdentifier, this.receivedDataCallback);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
private tryGetLastState() {
|
|
121
|
+
const model = this.context.connection.tryGetState(this.guid) as unknown as SyncedTransformModel;
|
|
122
|
+
if (model) this.onReceivedData(model);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
private tempEuler: THREE.Euler = new THREE.Euler();
|
|
126
|
+
|
|
127
|
+
private onReceivedData(data: SyncedTransformModel) {
|
|
128
|
+
if (this.destroyed) return;
|
|
129
|
+
if (typeof data.guid === "function" && data.guid() === this.guid) {
|
|
130
|
+
if (debug)
|
|
131
|
+
console.log("new data", this.context.connection.connectionId, this.context.time.frameCount, this.guid, data);
|
|
132
|
+
this.receivedUpdate = true;
|
|
133
|
+
this._receivedFastUpdate = data.fast();
|
|
134
|
+
const transform = data.transform();
|
|
135
|
+
if (transform) {
|
|
136
|
+
InstancingUtil.markDirty(this.gameObject, true);
|
|
137
|
+
const position = transform.position();
|
|
138
|
+
if (position) {
|
|
139
|
+
if (this.interpolatePosition)
|
|
140
|
+
this._targetPosition?.set(position.x(), position.y(), position.z());
|
|
141
|
+
if (!this.interpolatePosition || !this._receivedDataBefore)
|
|
142
|
+
this.setWorldPosition(position.x(), position.y(), position.z());
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const rotation = transform.rotation();
|
|
146
|
+
if (rotation) {
|
|
147
|
+
this.tempEuler.set(rotation.x(), rotation.y(), rotation.z());
|
|
148
|
+
if (this.interpolateRotation) {
|
|
149
|
+
this._targetRotation.setFromEuler(this.tempEuler);
|
|
150
|
+
}
|
|
151
|
+
if (!this.interpolateRotation || !this._receivedDataBefore)
|
|
152
|
+
setWorldEuler(this.gameObject, this.tempEuler);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
this._receivedDataBefore = true;
|
|
156
|
+
|
|
157
|
+
// if (this.rb && !this._model?.hasOwnership) {
|
|
158
|
+
// this.rb.setBodyFromGameObject(data.velocity)
|
|
159
|
+
// }
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
onEnable(): void {
|
|
164
|
+
this.lastWorldPos.copy(this.worldPosition);
|
|
165
|
+
this.lastWorldRotation.copy(this.worldQuaternion);
|
|
166
|
+
this._needsUpdate = true;
|
|
167
|
+
// console.log("ENABLE", this.guid, this.gameObject.guid, this.lastWorldPos);
|
|
168
|
+
if (this._model) {
|
|
169
|
+
this._model.updateIsOwned();
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
onDisable(): void {
|
|
174
|
+
if (this._model)
|
|
175
|
+
this._model.freeOwnership();
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
private receivedUpdate = false;
|
|
180
|
+
private lastWorldPos!: THREE.Vector3;
|
|
181
|
+
private lastWorldRotation!: THREE.Quaternion;
|
|
182
|
+
|
|
183
|
+
onBeforeRender() {
|
|
184
|
+
if (!this.activeAndEnabled || !this.context.connection.isConnected) return;
|
|
185
|
+
// console.log("BEFORE RENDER", this.destroyed, this.guid, this._model?.isOwned, this.name, this.gameObject);
|
|
186
|
+
|
|
187
|
+
if (!this.context.connection.isInRoom || !this._model) {
|
|
188
|
+
if (debug)
|
|
189
|
+
console.log("no model or room", this.name, this.guid, this.context.connection.isInRoom);
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (this._shouldRequestOwnership) {
|
|
194
|
+
this._shouldRequestOwnership = false;
|
|
195
|
+
this._model.requestOwnership();
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
let wp = this.worldPosition;
|
|
199
|
+
let wr = this.worldQuaternion;
|
|
200
|
+
if (this._model.isOwned && !this.receivedUpdate) {
|
|
201
|
+
const worlddiff = wp.distanceTo(this.lastWorldPos);
|
|
202
|
+
const worldRot = wr.angleTo(this.lastWorldRotation);
|
|
203
|
+
const threshold = this._model.hasOwnership || this.fastMode ? .0001 : .001;
|
|
204
|
+
if (worlddiff > threshold || worldRot > threshold) {
|
|
205
|
+
// console.log(worlddiff, worldRot);
|
|
206
|
+
if (!this._model.hasOwnership) {
|
|
207
|
+
|
|
208
|
+
if (debug)
|
|
209
|
+
console.log(this.guid, "reset because not owned but", this.gameObject.name, this.lastWorldPos);
|
|
210
|
+
|
|
211
|
+
this.worldPosition = this.lastWorldPos;
|
|
212
|
+
wp.copy(this.lastWorldPos);
|
|
213
|
+
|
|
214
|
+
this.worldQuaternion = this.lastWorldRotation;
|
|
215
|
+
wr.copy(this.lastWorldRotation);
|
|
216
|
+
|
|
217
|
+
InstancingUtil.markDirty(this.gameObject, true);
|
|
218
|
+
this._needsUpdate = false;
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
this._needsUpdate = true;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
// else if (this._model.isOwned === false) {
|
|
226
|
+
// if (!this._didRequestOwnershipOnce && this.autoOwnership) {
|
|
227
|
+
// this._didRequestOwnershipOnce = true;
|
|
228
|
+
// this._model.requestOwnershipIfNotOwned();
|
|
229
|
+
// }
|
|
230
|
+
// }
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
if (this._model && !this._model.hasOwnership && this._model.isOwned) {
|
|
234
|
+
if (this._receivedDataBefore) {
|
|
235
|
+
const factor = this._receivedFastUpdate || this.fastMode ? .5 : .3;
|
|
236
|
+
const t = factor;//Mathf.clamp01(this.context.time.deltaTime * factor);
|
|
237
|
+
let requireMarkDirty = false;
|
|
238
|
+
if (this.interpolatePosition && this._targetPosition) {
|
|
239
|
+
const pos = this.worldPosition;
|
|
240
|
+
pos.lerp(this._targetPosition, t);
|
|
241
|
+
this.worldPosition = pos;
|
|
242
|
+
requireMarkDirty = true;
|
|
243
|
+
}
|
|
244
|
+
if (this.interpolateRotation && this._targetRotation) {
|
|
245
|
+
const rot = this.worldQuaternion;
|
|
246
|
+
rot.slerp(this._targetRotation, t);
|
|
247
|
+
this.worldQuaternion = rot;
|
|
248
|
+
requireMarkDirty = true;
|
|
249
|
+
}
|
|
250
|
+
if (requireMarkDirty)
|
|
251
|
+
InstancingUtil.markDirty(this.gameObject, true);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
this.receivedUpdate = false;
|
|
257
|
+
this.lastWorldPos.copy(wp);
|
|
258
|
+
this.lastWorldRotation.copy(wr);
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
// if (this._model.isOwned === false && this.autoOwnership) {
|
|
262
|
+
// this.requestOwnership();
|
|
263
|
+
// }
|
|
264
|
+
|
|
265
|
+
if (!this._model) return;
|
|
266
|
+
// only run if we are the owner
|
|
267
|
+
if (!this._model || this._model.hasOwnership === undefined || !this._model.hasOwnership) {
|
|
268
|
+
if (this.rb) {
|
|
269
|
+
this.rb.isKinematic = this._model.isOwned ?? false;
|
|
270
|
+
this.rb.setVelocity(0, 0, 0);
|
|
271
|
+
this.rb.setBodyFromGameObject();
|
|
272
|
+
}
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// local user is owner:
|
|
277
|
+
|
|
278
|
+
if (this.rb) {
|
|
279
|
+
if (this._wasKinematic !== undefined) {
|
|
280
|
+
if (debug)
|
|
281
|
+
console.log("reset kinematic", this.rb.name, this._wasKinematic);
|
|
282
|
+
this.rb.isKinematic = this._wasKinematic;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// hacky reset if too far off
|
|
286
|
+
if (this.gameObject.position.distanceTo(new THREE.Vector3(0, 0, 0)) > 1000) {
|
|
287
|
+
if (debug)
|
|
288
|
+
console.log("RESET", this.name)
|
|
289
|
+
this.gameObject.position.set(0, 1, 0);
|
|
290
|
+
this.rb.setVelocity(0, 0, 0);
|
|
291
|
+
this.rb.setBodyFromGameObject();
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
const updateInterval = 10;
|
|
296
|
+
const fastUpdate = this.rb || this.fastMode;
|
|
297
|
+
if (this._needsUpdate && (updateInterval <= 0 || updateInterval > 0 && this.context.time.frameCount % updateInterval === 0 || fastUpdate)) {
|
|
298
|
+
|
|
299
|
+
if (debug)
|
|
300
|
+
console.log("send update", this.context.connection.connectionId, this.guid, this.gameObject.name, this.gameObject.guid);
|
|
301
|
+
|
|
302
|
+
if (this.overridePhysics && this.rb) {
|
|
303
|
+
this.rb.setBodyFromGameObject();
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
this._needsUpdate = false;
|
|
307
|
+
const st = createTransformModel(this.guid, this, fastUpdate ? true : false);
|
|
308
|
+
// this._state.update(this, this.rb);
|
|
309
|
+
// this._state.fast = fastUpdate ? true : false;
|
|
310
|
+
this.context.connection.sendBinary(st);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
// private lastPosition: THREE.Vector3 = new THREE.Vector3();
|
|
316
|
+
|
|
317
|
+
// private async setPosition(pt: THREE.Vector3) {
|
|
318
|
+
|
|
319
|
+
// if (this._model.isConnected && !this._model?.hasOwnership) {
|
|
320
|
+
// await this._model?.requestOwnershipAsync();
|
|
321
|
+
// }
|
|
322
|
+
|
|
323
|
+
// if (pt.distanceTo(this.lastPosition) < .001) {
|
|
324
|
+
// return;
|
|
325
|
+
// }
|
|
326
|
+
// this.lastPosition.copy(pt);
|
|
327
|
+
|
|
328
|
+
// if(this.gameObject.parent) this.gameObject.parent.worldToLocal(pt);
|
|
329
|
+
// // this.gameObject.position.copy(pt);
|
|
330
|
+
// this.gameObject.position.set(pt.x, pt.y, pt.z);
|
|
331
|
+
// this._target.set(pt.x, pt.y, pt.z);
|
|
332
|
+
// this._needsUpdate = true;
|
|
333
|
+
// if (this.rb) {
|
|
334
|
+
// this.gameObject.position.set(pt.x, pt.y + .5, pt.z);
|
|
335
|
+
// this.rb.setVelocity(0, 0, 0);
|
|
336
|
+
// this.rb.setBodyFromGameObject();
|
|
337
|
+
// }
|
|
338
|
+
// }
|
|
339
|
+
}
|