@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,34 @@
|
|
|
1
|
+
|
|
2
|
+
import * as THREE from "three";
|
|
3
|
+
import { syncDestroy } from "../engine/engine_networking_instantiate";
|
|
4
|
+
import { BoxHelperComponent } from "./BoxHelperComponent";
|
|
5
|
+
import { Behaviour, GameObject } from "./Component";
|
|
6
|
+
import { UsageMarker } from "./Interactable";
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export class DeleteBox extends BoxHelperComponent {}
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
export class Deletable extends Behaviour {
|
|
13
|
+
|
|
14
|
+
private deleteBoxes: DeleteBox[] = [];
|
|
15
|
+
|
|
16
|
+
awake() {
|
|
17
|
+
this.deleteBoxes = GameObject.findObjectsOfType(DeleteBox, this.context);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
update(): void {
|
|
21
|
+
for (const box of this.deleteBoxes) {
|
|
22
|
+
const obj = this.gameObject as unknown as THREE.Mesh;
|
|
23
|
+
const res = box.isInBox(obj);
|
|
24
|
+
// console.log(res);
|
|
25
|
+
if (res === true) {
|
|
26
|
+
const marker = GameObject.getComponentInParent(this.gameObject, UsageMarker);
|
|
27
|
+
if (!marker) {
|
|
28
|
+
// console.log("DESTROY");
|
|
29
|
+
syncDestroy(this.gameObject, this.context.connection);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { serializeable } from "../engine/engine_serialization_decorator";
|
|
2
|
+
import { Behaviour, GameObject } from "./Component";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export enum DeviceType {
|
|
6
|
+
Never = 0,
|
|
7
|
+
Desktop = 1 << 0,
|
|
8
|
+
Mobile = 2 << 0,
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export class DeviceFlag extends Behaviour {
|
|
12
|
+
|
|
13
|
+
@serializeable()
|
|
14
|
+
visibleOn!: DeviceType;
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
onEnable() {
|
|
18
|
+
this.apply();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
apply() {
|
|
22
|
+
if (!this.test()) {
|
|
23
|
+
GameObject.setActive(this.gameObject, false);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
private test() : boolean {
|
|
28
|
+
if(this.visibleOn < 0) return true;
|
|
29
|
+
if(isMobile()){
|
|
30
|
+
return (this.visibleOn & (DeviceType.Mobile)) !== 0;
|
|
31
|
+
}
|
|
32
|
+
const allowDesktop = (this.visibleOn & (DeviceType.Desktop)) !== 0;
|
|
33
|
+
return allowDesktop;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// shamelessly taken from https://stackoverflow.com/a/11381730
|
|
39
|
+
let _isMobile: boolean | undefined = undefined;
|
|
40
|
+
function isMobile() {
|
|
41
|
+
if (_isMobile === true || _isMobile === false) return _isMobile;
|
|
42
|
+
let check = false;
|
|
43
|
+
(function (a) { if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))) check = true; })(navigator.userAgent || navigator.vendor || window["opera"]);
|
|
44
|
+
_isMobile = check;
|
|
45
|
+
return check;
|
|
46
|
+
};
|
|
@@ -0,0 +1,534 @@
|
|
|
1
|
+
import { Behaviour, GameObject } from "./Component";
|
|
2
|
+
// import { DragControls as Control } from "../include/three/DragControls";
|
|
3
|
+
import { SyncedTransform } from "./SyncedTransform";
|
|
4
|
+
import * as THREE from "three";
|
|
5
|
+
import { IPointerClickHandler, IPointerDownHandler, IPointerEnterHandler, IPointerExitHandler, IPointerUpHandler, PointerEventData } from "./ui/PointerEvents";
|
|
6
|
+
import { Context } from "../engine/engine_setup";
|
|
7
|
+
import { Interactable, UsageMarker } from "./Interactable";
|
|
8
|
+
import { Rigidbody } from "./RigidBody";
|
|
9
|
+
import { WebXR } from "./WebXR";
|
|
10
|
+
import { InstancingUtil } from "./Renderer";
|
|
11
|
+
import { Avatar_POI } from "./avatar/Avatar_Brain_LookAt";
|
|
12
|
+
import { RaycastOptions } from "../engine/engine_physics";
|
|
13
|
+
import { getWorldPosition, getWorldQuaternion, setWorldPosition } from "../engine/engine_three_utils";
|
|
14
|
+
import { KeyCode } from "../engine/engine_input";
|
|
15
|
+
import { nameofFactory } from "../engine/engine_utils";
|
|
16
|
+
|
|
17
|
+
const debug = false;
|
|
18
|
+
|
|
19
|
+
export enum DragEvents {
|
|
20
|
+
SelectStart = "selectstart",
|
|
21
|
+
SelectEnd = "selectend",
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface SelectArgs {
|
|
25
|
+
selected: THREE.Object3D;
|
|
26
|
+
attached: THREE.Object3D | GameObject | null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
export interface IDragEventListener {
|
|
31
|
+
onDragStart?();
|
|
32
|
+
onDragEnd?();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export class DragControls extends Interactable implements IPointerDownHandler, IPointerUpHandler, IPointerEnterHandler, IPointerExitHandler {
|
|
36
|
+
|
|
37
|
+
private static _active: DragControls | null = null;
|
|
38
|
+
public static get HasAnySelected(): boolean { return this._active !== null; }
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
public transformSelf: boolean = true;
|
|
42
|
+
// public transformGroup: boolean = true;
|
|
43
|
+
// public targets: THREE.Object3D[] | null = null;
|
|
44
|
+
|
|
45
|
+
// private controls: Control | null = null;
|
|
46
|
+
// private orbit: OrbitControls | null = null;
|
|
47
|
+
|
|
48
|
+
private selectStartEventListener: ((controls: DragControls, args: SelectArgs) => void)[] = [];
|
|
49
|
+
private selectEndEventListener: Array<Function> = [];
|
|
50
|
+
|
|
51
|
+
constructor() {
|
|
52
|
+
super();
|
|
53
|
+
this.selectStartEventListener = [];
|
|
54
|
+
this.selectEndEventListener = [];
|
|
55
|
+
this._dragDelta = new THREE.Vector2();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
addDragEventListener(type: DragEvents, cb: (ctrls: DragControls, args: SelectArgs) => void | Function) {
|
|
59
|
+
switch (type) {
|
|
60
|
+
case DragEvents.SelectStart:
|
|
61
|
+
this.selectStartEventListener.push(cb);
|
|
62
|
+
break;
|
|
63
|
+
case DragEvents.SelectEnd:
|
|
64
|
+
this.selectEndEventListener.push(cb);
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
private _dragHelper: DragHelper | null = null;
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
start() {
|
|
73
|
+
// this.orbit = GameObject.findObjectOfType(OrbitControls, this.context);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
private static lastHovered: THREE.Object3D;
|
|
77
|
+
private _draggingRigidbodies: Rigidbody[] = [];
|
|
78
|
+
|
|
79
|
+
private allowEdit(_obj: THREE.Object3D | null = null) {
|
|
80
|
+
return this.context.connection.allowEditing;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
onPointerEnter(evt: PointerEventData) {
|
|
84
|
+
if (!this.allowEdit(this.gameObject)) return;
|
|
85
|
+
if (WebXR.IsInWebXR) return;
|
|
86
|
+
// const interactable = GameObject.getComponentInParent(evt.object, Interactable);
|
|
87
|
+
// if (!interactable) return;
|
|
88
|
+
const dc = GameObject.getComponentInParent(evt.object, DragControls);
|
|
89
|
+
if (!dc || dc !== this) return;
|
|
90
|
+
DragControls.lastHovered = evt.object;
|
|
91
|
+
this.context.domElement.style.cursor = 'pointer';
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
onPointerExit(evt: PointerEventData) {
|
|
95
|
+
if (!this.allowEdit(this.gameObject)) return;
|
|
96
|
+
if (WebXR.IsInWebXR) return;
|
|
97
|
+
if (DragControls.lastHovered !== evt.object) return;
|
|
98
|
+
// const interactable = GameObject.getComponentInParent(evt.object, Interactable);
|
|
99
|
+
// if (!interactable) return;
|
|
100
|
+
this.context.domElement.style.cursor = 'auto';
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
private _waitingForDragStart: PointerEventData | null = null;
|
|
104
|
+
|
|
105
|
+
onPointerDown(args: PointerEventData) {
|
|
106
|
+
if (!this.allowEdit(this.gameObject)) return;
|
|
107
|
+
if (WebXR.IsInWebXR) return;
|
|
108
|
+
this._dragDelta.set(0, 0);
|
|
109
|
+
this._didDrag = false;
|
|
110
|
+
this._waitingForDragStart = args;
|
|
111
|
+
args.StopPropagation();
|
|
112
|
+
// if (this.orbit) this.orbit.enabled = false;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
onPointerUp(args: PointerEventData) {
|
|
116
|
+
this._waitingForDragStart = null;
|
|
117
|
+
if (!this.allowEdit(this.gameObject)) return;
|
|
118
|
+
if (WebXR.IsInWebXR) return;
|
|
119
|
+
this.onDragEnd(args);
|
|
120
|
+
args.StopPropagation();
|
|
121
|
+
// if (this.orbit) this.orbit.enabled = true;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
update(): void {
|
|
126
|
+
if (WebXR.IsInWebXR) return;
|
|
127
|
+
|
|
128
|
+
// drag start only after having dragged for some pixels
|
|
129
|
+
if (this._waitingForDragStart) {
|
|
130
|
+
|
|
131
|
+
if (!this._didDrag) {
|
|
132
|
+
// this is so we can e.g. process clicks without having a drag change the position
|
|
133
|
+
// e.g. a click to rotate the object
|
|
134
|
+
const delta = this.context.input.getPointerPositionDelta(0);
|
|
135
|
+
if (delta)
|
|
136
|
+
this._dragDelta.add(delta);
|
|
137
|
+
if (this._dragDelta.length() > 2)
|
|
138
|
+
this._didDrag = true;
|
|
139
|
+
else return;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const args = this._waitingForDragStart;
|
|
143
|
+
this._waitingForDragStart = null;
|
|
144
|
+
this.onDragStart(args);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (this._dragHelper && this._dragHelper.hasSelected) {
|
|
148
|
+
this.onUpdateDrag();
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (this._isDragging && !this._dragHelper?.hasSelected) {
|
|
152
|
+
this.onDragEnd(null);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
private _isDragging: boolean = false;
|
|
157
|
+
private _marker: UsageMarker | null = null;
|
|
158
|
+
private _dragDelta!: THREE.Vector2;
|
|
159
|
+
private _didDrag: boolean = false;
|
|
160
|
+
|
|
161
|
+
private onDragStart(evt: PointerEventData) {
|
|
162
|
+
if (!this._dragHelper) {
|
|
163
|
+
if (this.context.mainCamera)
|
|
164
|
+
this._dragHelper = new DragHelper(this.context.mainCamera);
|
|
165
|
+
else
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
if (!evt || !evt.object) return;
|
|
169
|
+
|
|
170
|
+
const dc = GameObject.getComponentInParent(evt.object, DragControls);
|
|
171
|
+
if (!dc || dc !== this) return;
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
let object: THREE.Object3D = evt.object;
|
|
175
|
+
|
|
176
|
+
if (this.transformSelf) {
|
|
177
|
+
object = this.gameObject;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// raise event
|
|
181
|
+
const args: { selected: THREE.Object3D, attached: THREE.Object3D | null } = { selected: object, attached: object };
|
|
182
|
+
for (const listener of this.selectStartEventListener) {
|
|
183
|
+
listener(this, args);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if (!args.attached) return;
|
|
187
|
+
if (args.attached !== object) {
|
|
188
|
+
// if duplicatable changes the object being dragged
|
|
189
|
+
// should it also change the active drag controls (e.g. if it has a own one)
|
|
190
|
+
// const drag = GameObject.getComponentInParent(args.attached, DragControls);
|
|
191
|
+
// if(drag !== this){
|
|
192
|
+
// console.log(args.attached, object);
|
|
193
|
+
// drag?.onDragStart(evt);
|
|
194
|
+
// return;
|
|
195
|
+
// }
|
|
196
|
+
}
|
|
197
|
+
object = args.attached;
|
|
198
|
+
this._isDragging = true;
|
|
199
|
+
this._dragHelper.setSelected(object, this.context);
|
|
200
|
+
// if (this.orbit) this.orbit.enabled = false;
|
|
201
|
+
|
|
202
|
+
const sync = GameObject.getComponentInChildren(object, SyncedTransform);
|
|
203
|
+
if (debug)
|
|
204
|
+
console.log("DRAG START", sync, object);
|
|
205
|
+
if (sync) {
|
|
206
|
+
sync.fastMode = true;
|
|
207
|
+
sync?.requestOwnership();
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
this._marker = GameObject.addNewComponent(object, UsageMarker);
|
|
211
|
+
|
|
212
|
+
// console.log(object, this._marker);
|
|
213
|
+
|
|
214
|
+
this._draggingRigidbodies.length = 0;
|
|
215
|
+
const rbs = GameObject.getComponentsInChildren(object, Rigidbody);
|
|
216
|
+
if (rbs)
|
|
217
|
+
this._draggingRigidbodies.push(...rbs);
|
|
218
|
+
|
|
219
|
+
const l = nameofFactory<IDragEventListener>();
|
|
220
|
+
GameObject.invokeOnChildren(this._dragHelper.selected, l("onDragStart"));
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
private onUpdateDrag() {
|
|
224
|
+
if (!this._dragHelper) return;
|
|
225
|
+
|
|
226
|
+
this._dragHelper.onUpdate(this.context);
|
|
227
|
+
for (const rb of this._draggingRigidbodies) {
|
|
228
|
+
rb.wakeUp();
|
|
229
|
+
rb.setBodyFromGameObject();
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
private onDragEnd(evt: PointerEventData | null) {
|
|
234
|
+
if (!this || !this._isDragging) return;
|
|
235
|
+
this._isDragging = false;
|
|
236
|
+
if (!this._dragHelper) return;
|
|
237
|
+
this._draggingRigidbodies.length = 0;
|
|
238
|
+
const selected = this._dragHelper.selected;
|
|
239
|
+
if (debug)
|
|
240
|
+
console.log("DRAG END", selected, selected?.visible)
|
|
241
|
+
this._dragHelper.setSelected(null, this.context);
|
|
242
|
+
// if (this.orbit) this.orbit.enabled = true;
|
|
243
|
+
if (evt?.object) {
|
|
244
|
+
const sync = GameObject.getComponentInChildren(evt.object, SyncedTransform);
|
|
245
|
+
if (sync) {
|
|
246
|
+
sync.fastMode = false;
|
|
247
|
+
// sync?.requestOwnership();
|
|
248
|
+
}
|
|
249
|
+
if (this._marker) {
|
|
250
|
+
this._marker.destroy();
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
// raise event
|
|
254
|
+
for (const listener of this.selectEndEventListener) {
|
|
255
|
+
listener(this);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
const l = nameofFactory<IDragEventListener>();
|
|
259
|
+
GameObject.invokeOnChildren(selected, l("onDragEnd"));
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
class DragHelper {
|
|
266
|
+
|
|
267
|
+
public get hasSelected(): boolean {
|
|
268
|
+
return this._selected !== null && this._selected !== undefined;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
public get selected(): THREE.Object3D | null {
|
|
272
|
+
return this._selected;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
private _selected: THREE.Object3D | null = null;
|
|
276
|
+
private _context: Context | null = null;
|
|
277
|
+
private _camera: THREE.Camera;;
|
|
278
|
+
private _cameraPlane: THREE.Plane = new THREE.Plane();
|
|
279
|
+
|
|
280
|
+
private _hasGroundPlane: boolean = false;
|
|
281
|
+
private _groundPlane: THREE.Plane = new THREE.Plane();
|
|
282
|
+
private _groundOffset: THREE.Vector3 = new THREE.Vector3();
|
|
283
|
+
private _groundOffsetFactor: number = 0;
|
|
284
|
+
private _groundDistance: number = 0;
|
|
285
|
+
private _groundPlanePoint: THREE.Vector3 = new THREE.Vector3();
|
|
286
|
+
|
|
287
|
+
private _raycaster = new THREE.Raycaster();
|
|
288
|
+
private _cameraPlaneOffset = new THREE.Vector3();
|
|
289
|
+
private _intersection = new THREE.Vector3();
|
|
290
|
+
private _worldPosition = new THREE.Vector3();
|
|
291
|
+
private _inverseMatrix = new THREE.Matrix4();
|
|
292
|
+
private _rbs: Rigidbody[] = [];
|
|
293
|
+
|
|
294
|
+
private _groundLine: THREE.Line;
|
|
295
|
+
private _groundMarker: THREE.Object3D;
|
|
296
|
+
private static geometry = new THREE.BufferGeometry().setFromPoints([new THREE.Vector3(0, 0, 0), new THREE.Vector3(0, -1, 0)]);
|
|
297
|
+
|
|
298
|
+
constructor(camera: THREE.Camera) {
|
|
299
|
+
this._camera = camera;
|
|
300
|
+
|
|
301
|
+
const line = new THREE.Line(DragHelper.geometry);
|
|
302
|
+
const mat = line.material as THREE.LineBasicMaterial;
|
|
303
|
+
mat.color = new THREE.Color(.4, .4, .4);
|
|
304
|
+
line.layers.set(2);
|
|
305
|
+
line.name = 'line';
|
|
306
|
+
line.scale.y = 1;
|
|
307
|
+
// line.matrixAutoUpdate = false;
|
|
308
|
+
this._groundLine = line;
|
|
309
|
+
|
|
310
|
+
const geometry = new THREE.SphereGeometry(.5, 22, 22);
|
|
311
|
+
const material = new THREE.MeshBasicMaterial({ color: mat.color });
|
|
312
|
+
const sphere = new THREE.Mesh(geometry, material);
|
|
313
|
+
sphere.visible = false;
|
|
314
|
+
sphere.layers.set(2);
|
|
315
|
+
this._groundMarker = sphere;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
setSelected(newSelected: THREE.Object3D | null, context: Context) {
|
|
319
|
+
|
|
320
|
+
if (this._selected && context) {
|
|
321
|
+
for (const rb of this._rbs) {
|
|
322
|
+
rb.wakeUp();
|
|
323
|
+
if (!rb.smoothedVelocity) continue;
|
|
324
|
+
rb.setVelocity(rb.smoothedVelocity.x, rb.smoothedVelocity.y, rb.smoothedVelocity.z);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
if (this._selected) {
|
|
329
|
+
|
|
330
|
+
Avatar_POI.Remove(context, this._selected);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
this._selected = newSelected;
|
|
334
|
+
this._context = context;
|
|
335
|
+
this._rbs.length = 0;
|
|
336
|
+
|
|
337
|
+
if (newSelected) {
|
|
338
|
+
context.scene.add(this._groundLine);
|
|
339
|
+
context.scene.add(this._groundMarker);
|
|
340
|
+
}
|
|
341
|
+
else {
|
|
342
|
+
this._groundLine.removeFromParent();
|
|
343
|
+
this._groundMarker.removeFromParent();
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
if (this._selected) {
|
|
348
|
+
if (!context) {
|
|
349
|
+
console.error("DragHelper: no context");
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
Avatar_POI.Add(context, this._selected, null);
|
|
353
|
+
|
|
354
|
+
this._groundOffsetFactor = 0;
|
|
355
|
+
this._hasGroundPlane = true;
|
|
356
|
+
this._groundOffset.set(0, 0, 0);
|
|
357
|
+
this._requireUpdateGroundPlane = true;
|
|
358
|
+
|
|
359
|
+
this._rbs = GameObject.getComponentsInChildren(this._selected, Rigidbody);
|
|
360
|
+
this.onUpdateScreenSpacePlane();
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
private _groundOffsetVector = new THREE.Vector3(0, 1, 0);
|
|
365
|
+
private _requireUpdateGroundPlane = true;
|
|
366
|
+
private _didDragOnGroundPlaneLastFrame: boolean = false;
|
|
367
|
+
|
|
368
|
+
onUpdate(_context: Context) {
|
|
369
|
+
if (!this._context) return;
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
const mainKey = KeyCode.SPACE;
|
|
373
|
+
const secondaryKey = KeyCode.KEY_D;
|
|
374
|
+
const scaleKey = KeyCode.KEY_S;
|
|
375
|
+
|
|
376
|
+
const isRotateKeyPressed = this._context?.input.isKeyPressed(mainKey) || this._context?.input.isKeyPressed(secondaryKey);
|
|
377
|
+
const isRotating = this._context.input.getTouchesPressedCount() >= 2 || isRotateKeyPressed;
|
|
378
|
+
if (isRotating) {
|
|
379
|
+
const dt = this._context.input.getPointerPositionDelta(0);
|
|
380
|
+
if (dt) {
|
|
381
|
+
this._groundOffsetVector.set(0, 1, 0);
|
|
382
|
+
this._selected?.rotateOnWorldAxis(this._groundOffsetVector, dt.x * this._context.time.deltaTime);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
// todo: allow this once synced transform sends world scale
|
|
387
|
+
// const isScaling = this._context?.input.isKeyPressed(scaleKey);
|
|
388
|
+
// if(isScaling){
|
|
389
|
+
// const dt = this._context.input.getPointerPositionDelta(0);
|
|
390
|
+
// if(dt){
|
|
391
|
+
// this._selected?.scale.multiplyScalar(1 + (dt.x * this._context.time.deltaTime));
|
|
392
|
+
// return;
|
|
393
|
+
// }
|
|
394
|
+
// }
|
|
395
|
+
|
|
396
|
+
const rc = this._context.input.getPointerPositionRC(0);
|
|
397
|
+
if (!rc) return;
|
|
398
|
+
this._raycaster.setFromCamera(rc, this._camera);
|
|
399
|
+
|
|
400
|
+
if (this._selected) {
|
|
401
|
+
if (debug) console.log("UPDATE DRAG", this._selected);
|
|
402
|
+
this._groundOffsetVector.set(0, 1, 0);
|
|
403
|
+
const lookDirection = getWorldPosition(this._camera).clone().sub(getWorldPosition(this._selected)).normalize();
|
|
404
|
+
const lookDot = Math.abs(lookDirection.dot(this._groundOffsetVector));
|
|
405
|
+
|
|
406
|
+
const switchModeKeyPressed = this._context?.input.isKeyPressed(mainKey) || this._context?.input.isKeyPressed(secondaryKey);
|
|
407
|
+
const dragOnGroundPlane = !isRotating && lookDot > .2 && !switchModeKeyPressed && this._context!.input.getPointerPressedCount() <= 1;
|
|
408
|
+
const changed = this._didDragOnGroundPlaneLastFrame !== dragOnGroundPlane;
|
|
409
|
+
this._didDragOnGroundPlaneLastFrame = dragOnGroundPlane;
|
|
410
|
+
|
|
411
|
+
if (!this._hasGroundPlane) this._requireUpdateGroundPlane = true;
|
|
412
|
+
if (this._requireUpdateGroundPlane || !dragOnGroundPlane || changed)
|
|
413
|
+
this.onUpdateGroundPlane();
|
|
414
|
+
|
|
415
|
+
this._requireUpdateGroundPlane = false;
|
|
416
|
+
if (this._hasGroundPlane) {
|
|
417
|
+
// const wp = getWorldPosition(this._selected);
|
|
418
|
+
// const ray = new THREE.Ray(wp, new THREE.Vector3(0, -1, 0));
|
|
419
|
+
|
|
420
|
+
if (this._raycaster.ray.intersectPlane(this._groundPlane, this._intersection)) {
|
|
421
|
+
const y = this._intersection.y;
|
|
422
|
+
this._groundPlanePoint.copy(this._intersection).sub(this._groundOffset);
|
|
423
|
+
this._groundPlanePoint.y = y;
|
|
424
|
+
|
|
425
|
+
if (dragOnGroundPlane) {
|
|
426
|
+
this._groundOffsetVector.set(0, 1, 0);
|
|
427
|
+
// console.log(this._groundOffset);
|
|
428
|
+
const wp = this._intersection.sub(this._groundOffset).add(this._groundOffsetVector.multiplyScalar(this._groundOffsetFactor));
|
|
429
|
+
this.onUpdateWorldPosition(wp, this._groundPlanePoint, false);
|
|
430
|
+
this.onDidUpdate();
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
// TODO: fix this
|
|
435
|
+
else this._groundPlanePoint.set(0, 99999, 0);
|
|
436
|
+
// else if (ray.intersectPlane(this._groundPlane, this._intersection)) {
|
|
437
|
+
// const y = this._intersection.y;
|
|
438
|
+
// this._groundPlanePoint.copy(this._intersection).sub(this._groundOffset);
|
|
439
|
+
// this._groundPlanePoint.y = y;
|
|
440
|
+
// }
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
if (changed) {
|
|
444
|
+
this.onUpdateScreenSpacePlane();
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
this._requireUpdateGroundPlane = true;
|
|
448
|
+
if (this._raycaster.ray.intersectPlane(this._cameraPlane, this._intersection)) {
|
|
449
|
+
this.onUpdateWorldPosition(this._intersection.sub(this._cameraPlaneOffset), this._groundPlanePoint, true);
|
|
450
|
+
this.onDidUpdate();
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
private onUpdateWorldPosition(wp: THREE.Vector3, pointOnPlane: THREE.Vector3 | null, heightOnly: boolean) {
|
|
456
|
+
if (!this._selected) return;
|
|
457
|
+
if (heightOnly) {
|
|
458
|
+
const cur = getWorldPosition(this._selected);
|
|
459
|
+
cur.y = wp.y;
|
|
460
|
+
wp = cur;
|
|
461
|
+
}
|
|
462
|
+
setWorldPosition(this._selected, wp);
|
|
463
|
+
setWorldPosition(this._groundLine, wp);
|
|
464
|
+
if (this._hasGroundPlane) {
|
|
465
|
+
this._groundLine.scale.y = this._groundDistance;
|
|
466
|
+
}
|
|
467
|
+
else this._groundLine.scale.y = 1000;
|
|
468
|
+
|
|
469
|
+
this._groundMarker.visible = pointOnPlane !== null;
|
|
470
|
+
if (pointOnPlane) {
|
|
471
|
+
const s = getWorldPosition(this._camera).distanceTo(pointOnPlane) * .01;
|
|
472
|
+
this._groundMarker.scale.set(s, s, s);
|
|
473
|
+
setWorldPosition(this._groundMarker, pointOnPlane);
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
private onUpdateScreenSpacePlane() {
|
|
478
|
+
if (!this._selected || !this._context) return;
|
|
479
|
+
const rc = this._context.input.getPointerPositionRC(0);
|
|
480
|
+
if (!rc) return;
|
|
481
|
+
this._raycaster.setFromCamera(rc, this._camera);
|
|
482
|
+
this._cameraPlane.setFromNormalAndCoplanarPoint(this._camera.getWorldDirection(this._cameraPlane.normal), this._worldPosition.setFromMatrixPosition(this._selected.matrixWorld));
|
|
483
|
+
if (this._raycaster.ray.intersectPlane(this._cameraPlane, this._intersection) && this._selected.parent) {
|
|
484
|
+
this._inverseMatrix.copy(this._selected.parent.matrixWorld).invert();
|
|
485
|
+
this._cameraPlaneOffset.copy(this._intersection).sub(this._worldPosition.setFromMatrixPosition(this._selected.matrixWorld));
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
private onUpdateGroundPlane() {
|
|
490
|
+
if (!this._selected || !this._context) return;
|
|
491
|
+
const wp = getWorldPosition(this._selected);
|
|
492
|
+
const ray = new THREE.Ray(new THREE.Vector3(0, .1, 0).add(wp), new THREE.Vector3(0, -1, 0));
|
|
493
|
+
const opts = new RaycastOptions();
|
|
494
|
+
opts.ignore = [this._selected];
|
|
495
|
+
const hits = this._context.physics.raycastFromRay(ray, opts);
|
|
496
|
+
for (let i = 0; i < hits.length; i++) {
|
|
497
|
+
const hit = hits[i];
|
|
498
|
+
if (!hit.face || this.contains(this._selected, hit.object)) {
|
|
499
|
+
continue;
|
|
500
|
+
}
|
|
501
|
+
const normal = new THREE.Vector3(0, 1, 0); // hit.face.normal
|
|
502
|
+
this._groundPlane.setFromNormalAndCoplanarPoint(normal, hit.point);
|
|
503
|
+
break;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
this._hasGroundPlane = true;
|
|
507
|
+
this._groundPlane.setFromNormalAndCoplanarPoint(ray.direction.multiplyScalar(-1), ray.origin);
|
|
508
|
+
this._raycaster.ray.intersectPlane(this._groundPlane, this._intersection);
|
|
509
|
+
this._groundDistance = this._intersection.distanceTo(wp);
|
|
510
|
+
this._groundOffset.copy(this._intersection).sub(wp);
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
private onDidUpdate() {
|
|
514
|
+
// todo: when using instancing we need to mark the matrix to update
|
|
515
|
+
InstancingUtil.markDirty(this._selected);
|
|
516
|
+
|
|
517
|
+
for (const rb of this._rbs) {
|
|
518
|
+
rb.wakeUp();
|
|
519
|
+
rb.setBodyFromGameObject({ x: 0, y: 0, z: 0 });
|
|
520
|
+
rb.setAngularVelocity(0, 0, 0);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
private contains(obj: THREE.Object3D, toSearch: THREE.Object3D): boolean {
|
|
525
|
+
if (obj === toSearch) return true;
|
|
526
|
+
if (obj.children) {
|
|
527
|
+
for (const child of obj.children) {
|
|
528
|
+
if (this.contains(child, toSearch)) return true;
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
return false;
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
|