@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,924 @@
|
|
|
1
|
+
import { Behaviour, GameObject } from "./Component";
|
|
2
|
+
import * as THREE from "three";
|
|
3
|
+
import { SyncedTransform } from "./SyncedTransform";
|
|
4
|
+
import { RaycastOptions } from "../engine/engine_physics";
|
|
5
|
+
import { XRControllerModelFactory } from 'three/examples/jsm/webxr/XRControllerModelFactory.js';
|
|
6
|
+
import { OculusHandModel } from 'three/examples/jsm/webxr/OculusHandModel.js';
|
|
7
|
+
import { OculusHandPointerModel } from 'three/examples/jsm/webxr/OculusHandPointerModel.js';
|
|
8
|
+
import { Avatar_POI } from "./avatar/Avatar_Brain_LookAt";
|
|
9
|
+
import { Mathf } from "../engine/engine_math";
|
|
10
|
+
import * as utils from "../engine/engine_three_utils";
|
|
11
|
+
import { Interactable, UsageMarker } from "./Interactable";
|
|
12
|
+
import { InstancingUtil } from "./Renderer";
|
|
13
|
+
import { Rigidbody } from "./RigidBody";
|
|
14
|
+
export var ControllerType;
|
|
15
|
+
(function (ControllerType) {
|
|
16
|
+
ControllerType[ControllerType["PhysicalDevice"] = 0] = "PhysicalDevice";
|
|
17
|
+
ControllerType[ControllerType["Touch"] = 1] = "Touch";
|
|
18
|
+
})(ControllerType || (ControllerType = {}));
|
|
19
|
+
export var ControllerEvents;
|
|
20
|
+
(function (ControllerEvents) {
|
|
21
|
+
ControllerEvents["SelectStart"] = "select-start";
|
|
22
|
+
ControllerEvents["SelectEnd"] = "select-end";
|
|
23
|
+
ControllerEvents["Update"] = "update";
|
|
24
|
+
})(ControllerEvents || (ControllerEvents = {}));
|
|
25
|
+
export class TeleportTarget extends Behaviour {
|
|
26
|
+
}
|
|
27
|
+
export class WebXRController extends Behaviour {
|
|
28
|
+
static Factory = new XRControllerModelFactory();
|
|
29
|
+
static raycastColor = new THREE.Color(.9, .3, .3);
|
|
30
|
+
static raycastNoHitColor = new THREE.Color(.6, .6, .6);
|
|
31
|
+
static geometry = new THREE.BufferGeometry().setFromPoints([new THREE.Vector3(0, 0, 0), new THREE.Vector3(0, 0, -1)]);
|
|
32
|
+
static handModels = {};
|
|
33
|
+
static CreateRaycastLine() {
|
|
34
|
+
const line = new THREE.Line(this.geometry);
|
|
35
|
+
const mat = line.material;
|
|
36
|
+
mat.color = this.raycastColor;
|
|
37
|
+
// mat.linewidth = 10;
|
|
38
|
+
line.layers.set(1);
|
|
39
|
+
line.name = 'line';
|
|
40
|
+
line.scale.z = 1;
|
|
41
|
+
return line;
|
|
42
|
+
}
|
|
43
|
+
static CreateRaycastHitPoint() {
|
|
44
|
+
const geometry = new THREE.SphereGeometry(.5, 22, 22);
|
|
45
|
+
const material = new THREE.MeshBasicMaterial({ color: this.raycastColor });
|
|
46
|
+
const sphere = new THREE.Mesh(geometry, material);
|
|
47
|
+
sphere.visible = false;
|
|
48
|
+
sphere.layers.set(1);
|
|
49
|
+
return sphere;
|
|
50
|
+
}
|
|
51
|
+
static Create(owner, index, addTo, type) {
|
|
52
|
+
const ctrl = addTo ? GameObject.addNewComponent(addTo, WebXRController, false) : new WebXRController();
|
|
53
|
+
ctrl.webXR = owner;
|
|
54
|
+
ctrl.index = index;
|
|
55
|
+
ctrl.type = type;
|
|
56
|
+
const context = owner.context;
|
|
57
|
+
// from https://github.com/mrdoob/three.js/blob/master/examples/webxr_vr_dragging.html
|
|
58
|
+
// controllers
|
|
59
|
+
ctrl.controller = context.renderer.xr.getController(index);
|
|
60
|
+
ctrl.controllerGrip = context.renderer.xr.getControllerGrip(index);
|
|
61
|
+
ctrl.controllerModel = this.Factory.createControllerModel(ctrl.controller);
|
|
62
|
+
ctrl.controllerGrip.add(ctrl.controllerModel);
|
|
63
|
+
ctrl.hand = context.renderer.xr.getHand(index);
|
|
64
|
+
ctrl.hand.add(new OculusHandModel(ctrl.hand));
|
|
65
|
+
ctrl.hand.traverse(x => x.layers.set(2));
|
|
66
|
+
ctrl.handPointerModel = new OculusHandPointerModel(ctrl.hand, ctrl.controller);
|
|
67
|
+
// TODO remove all these once https://github.com/mrdoob/three.js/pull/23279 lands
|
|
68
|
+
ctrl.controller.addEventListener('connected', (_) => {
|
|
69
|
+
ctrl.setControllerLayers(ctrl.controllerModel, 2);
|
|
70
|
+
ctrl.setControllerLayers(ctrl.controllerGrip, 2);
|
|
71
|
+
setTimeout(() => {
|
|
72
|
+
ctrl.setControllerLayers(ctrl.controllerGrip, 2);
|
|
73
|
+
}, 1000);
|
|
74
|
+
});
|
|
75
|
+
// TODO: unsubscribe! this should be moved into onenable and ondisable!
|
|
76
|
+
// TODO remove all these once https://github.com/mrdoob/three.js/pull/23279 lands
|
|
77
|
+
ctrl.hand.addEventListener('connected', (event) => {
|
|
78
|
+
const xrInputSource = event.data;
|
|
79
|
+
if (xrInputSource.hand) {
|
|
80
|
+
if (owner.Rig)
|
|
81
|
+
owner.Rig.add(ctrl.hand);
|
|
82
|
+
ctrl.type = ControllerType.PhysicalDevice;
|
|
83
|
+
ctrl.handPointerModel.traverse(x => x.layers.set(2)); // ignore raycast
|
|
84
|
+
ctrl.handPointerModel.pointerObject?.traverse(x => x.layers.set(2));
|
|
85
|
+
// when exiting and re-entering xr the joints are not parented to the hand anymore
|
|
86
|
+
// this is a workaround to fix that temporarely
|
|
87
|
+
// see https://github.com/needle-tools/needle-tiny-playground/issues/123
|
|
88
|
+
const jnts = ctrl.hand["joints"];
|
|
89
|
+
if (jnts) {
|
|
90
|
+
for (const key of Object.keys(jnts)) {
|
|
91
|
+
const joint = jnts[key];
|
|
92
|
+
if (joint.parent)
|
|
93
|
+
continue;
|
|
94
|
+
ctrl.hand.add(joint);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
return ctrl;
|
|
100
|
+
}
|
|
101
|
+
static addEventListener(evt, callback) {
|
|
102
|
+
const list = this.eventSubs[evt] ?? [];
|
|
103
|
+
list.push(callback);
|
|
104
|
+
this.eventSubs[evt] = list;
|
|
105
|
+
}
|
|
106
|
+
static eventSubs = {};
|
|
107
|
+
webXR;
|
|
108
|
+
index = -1;
|
|
109
|
+
controllerModel;
|
|
110
|
+
controller;
|
|
111
|
+
controllerGrip;
|
|
112
|
+
hand;
|
|
113
|
+
handPointerModel;
|
|
114
|
+
grabbed = null;
|
|
115
|
+
input = null;
|
|
116
|
+
type = ControllerType.PhysicalDevice;
|
|
117
|
+
get isUsingHands() {
|
|
118
|
+
const r = this.input?.hand;
|
|
119
|
+
return r !== null && r !== undefined;
|
|
120
|
+
}
|
|
121
|
+
get wrist() {
|
|
122
|
+
if (!this.hand)
|
|
123
|
+
return null;
|
|
124
|
+
const jnts = this.hand["joints"];
|
|
125
|
+
if (!jnts)
|
|
126
|
+
return null;
|
|
127
|
+
return jnts["wrist"];
|
|
128
|
+
}
|
|
129
|
+
_wristQuaternion = null;
|
|
130
|
+
getWristQuaternion() {
|
|
131
|
+
const wrist = this.wrist;
|
|
132
|
+
if (!wrist)
|
|
133
|
+
return null;
|
|
134
|
+
if (!this._wristQuaternion)
|
|
135
|
+
this._wristQuaternion = new THREE.Quaternion();
|
|
136
|
+
const wr = utils.getWorldQuaternion(wrist).multiply(this._wristQuaternion.setFromEuler(new THREE.Euler(-Math.PI / 4, 0, 0)));
|
|
137
|
+
return wr;
|
|
138
|
+
}
|
|
139
|
+
movementVector = new THREE.Vector3();
|
|
140
|
+
worldRot = new THREE.Quaternion();
|
|
141
|
+
joystick = new THREE.Vector2();
|
|
142
|
+
didRotate = false;
|
|
143
|
+
didTeleport = false;
|
|
144
|
+
didChangeScale = false;
|
|
145
|
+
static PreviousCameraFarDistance = undefined;
|
|
146
|
+
static MovementSpeedFactor = 1;
|
|
147
|
+
lastHit = null;
|
|
148
|
+
raycastLine = null;
|
|
149
|
+
_raycastHitPoint = null;
|
|
150
|
+
_connnectedCallback = null;
|
|
151
|
+
_disconnectedCallback = null;
|
|
152
|
+
_selectStartEvt = null;
|
|
153
|
+
_selectEndEvt = null;
|
|
154
|
+
get selectionDown() { return this._selectionPressed && !this._selectionPressedLastFrame; }
|
|
155
|
+
get selectionUp() { return !this._selectionPressed && this._selectionPressedLastFrame; }
|
|
156
|
+
get selectionPressed() { return this._selectionPressed; }
|
|
157
|
+
get selectionClick() { return this._selectionEndTime - this._selectionStartTime < 0.3; }
|
|
158
|
+
get raycastHitPoint() { return this._raycastHitPoint; }
|
|
159
|
+
_selectionPressed = false;
|
|
160
|
+
_selectionPressedLastFrame = false;
|
|
161
|
+
_selectionStartTime = 0;
|
|
162
|
+
_selectionEndTime = 0;
|
|
163
|
+
get useSmoothing() { return this._useSmoothing; }
|
|
164
|
+
;
|
|
165
|
+
_useSmoothing = true;
|
|
166
|
+
awake() {
|
|
167
|
+
if (!this.controller) {
|
|
168
|
+
console.warn("Missing Controller!!!", this);
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
this._connnectedCallback = this.onSourceConnected.bind(this);
|
|
172
|
+
this._disconnectedCallback = this.onSourceDisconnected.bind(this);
|
|
173
|
+
this._selectStartEvt = this.onSelectStart.bind(this);
|
|
174
|
+
this._selectEndEvt = this.onSelectEnd.bind(this);
|
|
175
|
+
if (this.type === ControllerType.Touch) {
|
|
176
|
+
this.controllerGrip.addEventListener("connected", this._connnectedCallback);
|
|
177
|
+
this.controllerGrip.addEventListener("disconnected", this._disconnectedCallback);
|
|
178
|
+
this.controller.addEventListener('selectstart', this._selectStartEvt);
|
|
179
|
+
this.controller.addEventListener('selectend', this._selectEndEvt);
|
|
180
|
+
}
|
|
181
|
+
if (this.type === ControllerType.PhysicalDevice) {
|
|
182
|
+
this.controller.addEventListener('selectstart', this._selectStartEvt);
|
|
183
|
+
this.controller.addEventListener('selectend', this._selectEndEvt);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
onDestroy() {
|
|
187
|
+
if (this.type === ControllerType.Touch) {
|
|
188
|
+
this.controllerGrip.removeEventListener("connected", this._connnectedCallback);
|
|
189
|
+
this.controllerGrip.removeEventListener("disconnected", this._disconnectedCallback);
|
|
190
|
+
this.controller.removeEventListener('selectstart', this._selectStartEvt);
|
|
191
|
+
this.controller.removeEventListener('selectend', this._selectEndEvt);
|
|
192
|
+
}
|
|
193
|
+
if (this.type === ControllerType.PhysicalDevice) {
|
|
194
|
+
this.controller.removeEventListener('selectstart', this._selectStartEvt);
|
|
195
|
+
this.controller.removeEventListener('selectend', this._selectEndEvt);
|
|
196
|
+
}
|
|
197
|
+
this.hand?.clear();
|
|
198
|
+
this.controllerGrip?.clear();
|
|
199
|
+
this.controller?.clear();
|
|
200
|
+
}
|
|
201
|
+
onEnable() {
|
|
202
|
+
if (this.hand)
|
|
203
|
+
this.hand.name = "Hand";
|
|
204
|
+
if (this.controllerGrip)
|
|
205
|
+
this.controllerGrip.name = "ControllerGrip";
|
|
206
|
+
if (this.controller)
|
|
207
|
+
this.controller.name = "Controller";
|
|
208
|
+
if (this.raycastLine)
|
|
209
|
+
this.raycastLine.name = "RaycastLine;";
|
|
210
|
+
if (this.webXR.Controllers.indexOf(this) < 0)
|
|
211
|
+
this.webXR.Controllers.push(this);
|
|
212
|
+
if (!this.raycastLine)
|
|
213
|
+
this.raycastLine = WebXRController.CreateRaycastLine();
|
|
214
|
+
if (!this._raycastHitPoint)
|
|
215
|
+
this._raycastHitPoint = WebXRController.CreateRaycastHitPoint();
|
|
216
|
+
this.webXR.Rig?.add(this.hand);
|
|
217
|
+
this.webXR.Rig?.add(this.controllerGrip);
|
|
218
|
+
this.webXR.Rig?.add(this.controller);
|
|
219
|
+
this.webXR.Rig?.add(this.raycastLine);
|
|
220
|
+
this.raycastLine?.add(this._raycastHitPoint);
|
|
221
|
+
this.hand.add(this.handPointerModel);
|
|
222
|
+
console.log("ADDED TO RIG", this.webXR.Rig);
|
|
223
|
+
// // console.log("enable", this.index, this.controllerGrip.uuid)
|
|
224
|
+
}
|
|
225
|
+
onDisable() {
|
|
226
|
+
// console.log("XR controller disabled", this);
|
|
227
|
+
this.hand?.removeFromParent();
|
|
228
|
+
this.controllerGrip?.removeFromParent();
|
|
229
|
+
this.controller?.removeFromParent();
|
|
230
|
+
this.raycastLine?.removeFromParent();
|
|
231
|
+
this._raycastHitPoint?.removeFromParent();
|
|
232
|
+
// console.log("Disable", this._connnectedCallback, this._disconnectedCallback);
|
|
233
|
+
// this.controllerGrip.removeEventListener("connected", this._connnectedCallback);
|
|
234
|
+
// this.controllerGrip.removeEventListener("disconnected", this._disconnectedCallback);
|
|
235
|
+
const i = this.webXR.Controllers.indexOf(this);
|
|
236
|
+
if (i >= 0)
|
|
237
|
+
this.webXR.Controllers.splice(i, 1);
|
|
238
|
+
}
|
|
239
|
+
// onDestroy(): void {
|
|
240
|
+
// console.log("destroyed", this.index);
|
|
241
|
+
// }
|
|
242
|
+
_isConnected = false;
|
|
243
|
+
onSourceConnected(e) {
|
|
244
|
+
if (this._isConnected) {
|
|
245
|
+
console.warn("Received connected event for controller that is already connected", this.index, e);
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
this._isConnected = true;
|
|
249
|
+
this.input = e.data;
|
|
250
|
+
if (this.type === ControllerType.Touch) {
|
|
251
|
+
this.onSelectStart();
|
|
252
|
+
this.createPointerEvent("down");
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
onSourceDisconnected(_e) {
|
|
256
|
+
if (!this._isConnected) {
|
|
257
|
+
console.warn("Received discnnected event for controller that is not connected", _e);
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
this._isConnected = false;
|
|
261
|
+
if (this.type === ControllerType.Touch) {
|
|
262
|
+
this.onSelectEnd();
|
|
263
|
+
this.createPointerEvent("up");
|
|
264
|
+
}
|
|
265
|
+
this.input = null;
|
|
266
|
+
}
|
|
267
|
+
createPointerEvent(type) {
|
|
268
|
+
switch (type) {
|
|
269
|
+
case "down":
|
|
270
|
+
this.context.input.createPointerDown({ pointerId: this.index, clientX: 0, clientY: 0, button: this.index, pointerType: "touch" });
|
|
271
|
+
break;
|
|
272
|
+
case "move":
|
|
273
|
+
break;
|
|
274
|
+
case "up":
|
|
275
|
+
this.context.input.createPointerUp({ pointerId: this.index, clientX: 0, clientY: 0, button: this.index, pointerType: "touch" });
|
|
276
|
+
break;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
rayRotation = new THREE.Quaternion();
|
|
280
|
+
update() {
|
|
281
|
+
// TODO: we should wait until we actually have models, this is just a workaround
|
|
282
|
+
if (this.context.time.frameCount % 60 === 0) {
|
|
283
|
+
this.setControllerLayers(this.controller, 2);
|
|
284
|
+
this.setControllerLayers(this.controllerGrip, 2);
|
|
285
|
+
this.setControllerLayers(this.hand, 2);
|
|
286
|
+
}
|
|
287
|
+
const subs = WebXRController.eventSubs[ControllerEvents.Update];
|
|
288
|
+
if (subs && subs.length > 0) {
|
|
289
|
+
for (const sub of subs) {
|
|
290
|
+
sub(this);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
let t = 1;
|
|
294
|
+
if (this.type === ControllerType.PhysicalDevice)
|
|
295
|
+
t = this.context.time.deltaTime / .1;
|
|
296
|
+
else if (this.isUsingHands && this.handPointerModel.pinched)
|
|
297
|
+
t = this.context.time.deltaTime / .3;
|
|
298
|
+
this.rayRotation.slerp(utils.getWorldQuaternion(this.controller), this.useSmoothing ? t : 1.0);
|
|
299
|
+
const wp = utils.getWorldPosition(this.controller);
|
|
300
|
+
if (this.raycastLine) {
|
|
301
|
+
if (this.type === ControllerType.Touch) {
|
|
302
|
+
this.raycastLine.visible = false;
|
|
303
|
+
}
|
|
304
|
+
else if (this.isUsingHands) {
|
|
305
|
+
this.raycastLine.visible = !this.grabbed;
|
|
306
|
+
utils.setWorldPosition(this.raycastLine, wp);
|
|
307
|
+
const jnts = this.hand['joints'];
|
|
308
|
+
if (jnts) {
|
|
309
|
+
const wrist = jnts['wrist'];
|
|
310
|
+
if (wrist && this.grabbed && this.grabbed.isCloseGrab) {
|
|
311
|
+
const wr = this.getWristQuaternion();
|
|
312
|
+
if (wr)
|
|
313
|
+
this.rayRotation.copy(wr);
|
|
314
|
+
// this.rayRotation.slerp(wr, this.useSmoothing ? t * 2 : 1);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
utils.setWorldQuaternion(this.raycastLine, this.rayRotation);
|
|
318
|
+
}
|
|
319
|
+
else {
|
|
320
|
+
this.raycastLine.visible = true;
|
|
321
|
+
utils.setWorldQuaternion(this.raycastLine, this.rayRotation);
|
|
322
|
+
utils.setWorldPosition(this.raycastLine, wp);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
this.lastHit = this.updateLastHit();
|
|
326
|
+
if (this.grabbed) {
|
|
327
|
+
this.grabbed.update();
|
|
328
|
+
}
|
|
329
|
+
this._selectionPressedLastFrame = this._selectionPressed;
|
|
330
|
+
if (this.selectStartCallback) {
|
|
331
|
+
this.selectStartCallback();
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
_pinchStartTime = undefined;
|
|
335
|
+
onUpdate(session) {
|
|
336
|
+
this.lastHit = null;
|
|
337
|
+
if (!session || session.inputSources.length <= this.index) {
|
|
338
|
+
this.input = null;
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
if (this.type === ControllerType.PhysicalDevice)
|
|
342
|
+
this.input = session.inputSources[this.index];
|
|
343
|
+
if (!this.input)
|
|
344
|
+
return;
|
|
345
|
+
const rig = this.webXR.Rig;
|
|
346
|
+
if (!rig)
|
|
347
|
+
return;
|
|
348
|
+
if (this._didNotEndSelection && !this.handPointerModel.pinched) {
|
|
349
|
+
this._didNotEndSelection = false;
|
|
350
|
+
this.onSelectEnd();
|
|
351
|
+
}
|
|
352
|
+
this.updateStick(this.input);
|
|
353
|
+
const buttons = this.input?.gamepad?.buttons;
|
|
354
|
+
switch (this.input.handedness) {
|
|
355
|
+
case "left":
|
|
356
|
+
const speedFactor = 3 * WebXRController.MovementSpeedFactor;
|
|
357
|
+
const powFactor = 2;
|
|
358
|
+
const speed = Mathf.clamp01(this.joystick.length() * 2);
|
|
359
|
+
const sideDir = this.joystick.x > 0 ? 1 : -1;
|
|
360
|
+
let side = Math.pow(this.joystick.x, powFactor);
|
|
361
|
+
side *= sideDir;
|
|
362
|
+
side *= speed;
|
|
363
|
+
const forwardDir = this.joystick.y > 0 ? 1 : -1;
|
|
364
|
+
let forward = Math.pow(this.joystick.y, powFactor);
|
|
365
|
+
forward *= forwardDir;
|
|
366
|
+
side *= speed;
|
|
367
|
+
rig.getWorldQuaternion(this.worldRot);
|
|
368
|
+
this.movementVector.set(side, 0, forward);
|
|
369
|
+
this.movementVector.applyQuaternion(this.webXR.TransformOrientation);
|
|
370
|
+
this.movementVector.y = 0;
|
|
371
|
+
this.movementVector.applyQuaternion(this.worldRot);
|
|
372
|
+
rig.position.add(this.movementVector.multiplyScalar(speedFactor * this.context.time.deltaTime));
|
|
373
|
+
if (this.isUsingHands)
|
|
374
|
+
this.runTeleport(rig, buttons);
|
|
375
|
+
break;
|
|
376
|
+
case "right":
|
|
377
|
+
const rotate = this.joystick.x;
|
|
378
|
+
const rotAbs = Math.abs(rotate);
|
|
379
|
+
if (rotAbs < 0.4) {
|
|
380
|
+
this.didRotate = false;
|
|
381
|
+
}
|
|
382
|
+
else if (rotAbs > .5 && !this.didRotate) {
|
|
383
|
+
const dir = rotate > 0 ? -1 : 1;
|
|
384
|
+
rig.rotateY(Mathf.toRadians(30 * dir));
|
|
385
|
+
this.didRotate = true;
|
|
386
|
+
}
|
|
387
|
+
this.runTeleport(rig, buttons);
|
|
388
|
+
break;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
runTeleport(rig, buttons) {
|
|
392
|
+
let teleport = -this.joystick.y;
|
|
393
|
+
if (this.hand?.visible && !this.grabbed) {
|
|
394
|
+
const pinched = this.handPointerModel.isPinched();
|
|
395
|
+
if (pinched && this._pinchStartTime === undefined) {
|
|
396
|
+
this._pinchStartTime = this.context.time.time;
|
|
397
|
+
}
|
|
398
|
+
if (pinched && this._pinchStartTime && this.context.time.time - this._pinchStartTime > .8) {
|
|
399
|
+
// hacky approach for basic hand teleportation -
|
|
400
|
+
// we teleport if we pinch and the back of the hand points down (open hand gesture)
|
|
401
|
+
// const v1 = new THREE.Vector3();
|
|
402
|
+
// const worldQuaternion = new THREE.Quaternion();
|
|
403
|
+
// this.controller.getWorldQuaternion(worldQuaternion);
|
|
404
|
+
// v1.copy(this.controller.up).applyQuaternion(worldQuaternion);
|
|
405
|
+
// const dotPr = -v1.dot(this.controller.up);
|
|
406
|
+
teleport = this.handPointerModel.isPinched() ? 1 : 0;
|
|
407
|
+
}
|
|
408
|
+
if (!pinched)
|
|
409
|
+
this._pinchStartTime = undefined;
|
|
410
|
+
}
|
|
411
|
+
else
|
|
412
|
+
this._pinchStartTime = undefined;
|
|
413
|
+
let doTeleport = teleport > .5;
|
|
414
|
+
let isInMiniatureMode = this.webXR.Rig ? this.webXR.Rig?.scale?.x < .999 : false;
|
|
415
|
+
let newRigScale = null;
|
|
416
|
+
if (buttons && this.input && !this.input.hand) {
|
|
417
|
+
for (let i = 0; i < buttons.length; i++) {
|
|
418
|
+
const btn = buttons[i];
|
|
419
|
+
// button[4] seems to be the A button if it exists. On hololens it's randomly pressed though for hands
|
|
420
|
+
// see https://www.w3.org/TR/webxr-gamepads-module-1/#xr-standard-gamepad-mapping
|
|
421
|
+
if (i === 4) {
|
|
422
|
+
if (btn.pressed && !this.didChangeScale) {
|
|
423
|
+
this.didChangeScale = true;
|
|
424
|
+
const rig = this.webXR.Rig;
|
|
425
|
+
if (rig) {
|
|
426
|
+
if (!isInMiniatureMode) {
|
|
427
|
+
isInMiniatureMode = true;
|
|
428
|
+
doTeleport = true;
|
|
429
|
+
newRigScale = .1;
|
|
430
|
+
WebXRController.MovementSpeedFactor = newRigScale * 2;
|
|
431
|
+
const cam = this.context.mainCamera;
|
|
432
|
+
WebXRController.PreviousCameraFarDistance = cam.far;
|
|
433
|
+
cam.far /= newRigScale;
|
|
434
|
+
}
|
|
435
|
+
else {
|
|
436
|
+
isInMiniatureMode = false;
|
|
437
|
+
rig.scale.set(1, 1, 1);
|
|
438
|
+
newRigScale = 1;
|
|
439
|
+
WebXRController.MovementSpeedFactor = 1;
|
|
440
|
+
const cam = this.context.mainCamera;
|
|
441
|
+
if (WebXRController.PreviousCameraFarDistance)
|
|
442
|
+
cam.far = WebXRController.PreviousCameraFarDistance;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
else if (!btn.pressed)
|
|
447
|
+
this.didChangeScale = false;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
if (doTeleport) {
|
|
452
|
+
if (!this.didTeleport) {
|
|
453
|
+
const rc = this.raycast();
|
|
454
|
+
this.didTeleport = true;
|
|
455
|
+
if (rc && rc.length > 0) {
|
|
456
|
+
const hit = rc[0];
|
|
457
|
+
if (isInMiniatureMode || this.isValidTeleportTarget(hit.object)) {
|
|
458
|
+
const point = hit.point;
|
|
459
|
+
utils.setWorldPosition(rig, point);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
else if (teleport < .1) {
|
|
465
|
+
this.didTeleport = false;
|
|
466
|
+
}
|
|
467
|
+
if (newRigScale !== null) {
|
|
468
|
+
rig.scale.set(newRigScale, newRigScale, newRigScale);
|
|
469
|
+
rig.updateMatrixWorld();
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
isValidTeleportTarget(obj) {
|
|
473
|
+
return GameObject.getComponentInParent(obj, TeleportTarget) != null;
|
|
474
|
+
}
|
|
475
|
+
updateStick(inputSource) {
|
|
476
|
+
if (!inputSource || !inputSource.gamepad || inputSource.gamepad.axes?.length < 4)
|
|
477
|
+
return;
|
|
478
|
+
this.joystick.x = inputSource.gamepad.axes[2];
|
|
479
|
+
this.joystick.y = inputSource.gamepad.axes[3];
|
|
480
|
+
}
|
|
481
|
+
updateLastHit() {
|
|
482
|
+
const rc = this.raycast();
|
|
483
|
+
const hit = rc ? rc[0] : null;
|
|
484
|
+
this.lastHit = hit;
|
|
485
|
+
let factor = 1;
|
|
486
|
+
if (this.webXR.Rig) {
|
|
487
|
+
factor /= this.webXR.Rig.scale.x;
|
|
488
|
+
}
|
|
489
|
+
if (this.raycastLine) {
|
|
490
|
+
this.raycastLine.scale.z = factor * (this.lastHit?.distance ?? 9999);
|
|
491
|
+
const mat = this.raycastLine.material;
|
|
492
|
+
if (hit != null)
|
|
493
|
+
mat.color = WebXRController.raycastColor;
|
|
494
|
+
else
|
|
495
|
+
mat.color = WebXRController.raycastNoHitColor;
|
|
496
|
+
}
|
|
497
|
+
if (this._raycastHitPoint) {
|
|
498
|
+
if (this.lastHit != null) {
|
|
499
|
+
this._raycastHitPoint.position.z = -1; // -this.lastHit.distance;
|
|
500
|
+
const scale = Mathf.clamp(this.lastHit.distance * .01 * factor, .015, .1);
|
|
501
|
+
this._raycastHitPoint.scale.set(scale, scale, scale);
|
|
502
|
+
}
|
|
503
|
+
this._raycastHitPoint.visible = this.lastHit !== null;
|
|
504
|
+
}
|
|
505
|
+
return hit;
|
|
506
|
+
}
|
|
507
|
+
onSelectStart() {
|
|
508
|
+
if (!this.context.connection.allowEditing)
|
|
509
|
+
return;
|
|
510
|
+
// console.log("SELECT START", _event);
|
|
511
|
+
// if we process the event immediately the controller
|
|
512
|
+
// world positions are not yet correctly updated and we have info from the last frame
|
|
513
|
+
// so we delay the event processing one frame
|
|
514
|
+
// only necessary for AR - ideally we can get it to work right here
|
|
515
|
+
// but should be fine as a workaround for now
|
|
516
|
+
this.selectStartCallback = () => this.onHandleSelectStart();
|
|
517
|
+
}
|
|
518
|
+
selectStartCallback = null;
|
|
519
|
+
lastSelectStartObject = null;
|
|
520
|
+
;
|
|
521
|
+
onHandleSelectStart() {
|
|
522
|
+
this.selectStartCallback = null;
|
|
523
|
+
this._selectionPressed = true;
|
|
524
|
+
this._selectionStartTime = this.context.time.time;
|
|
525
|
+
this._selectionEndTime = 1000;
|
|
526
|
+
// console.log("DOWN", this.index, WebXRController.eventSubs);
|
|
527
|
+
// let maxDistance = this.isUsingHands ? .1 : undefined;
|
|
528
|
+
let intersections = null;
|
|
529
|
+
let closeGrab = false;
|
|
530
|
+
if (this.isUsingHands) {
|
|
531
|
+
intersections = this.overlap();
|
|
532
|
+
if (intersections.length <= 0) {
|
|
533
|
+
intersections = this.raycast();
|
|
534
|
+
closeGrab = false;
|
|
535
|
+
}
|
|
536
|
+
else {
|
|
537
|
+
closeGrab = true;
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
else
|
|
541
|
+
intersections = this.raycast();
|
|
542
|
+
if (intersections && intersections.length > 0) {
|
|
543
|
+
for (const intersection of intersections) {
|
|
544
|
+
const object = intersection.object;
|
|
545
|
+
if (!this.testIsVisible(object)) {
|
|
546
|
+
console.log("not visible");
|
|
547
|
+
continue;
|
|
548
|
+
}
|
|
549
|
+
this.lastSelectStartObject = object;
|
|
550
|
+
const args = { selected: object, grab: object };
|
|
551
|
+
const subs = WebXRController.eventSubs[ControllerEvents.SelectStart];
|
|
552
|
+
if (subs && subs.length > 0) {
|
|
553
|
+
for (const sub of subs) {
|
|
554
|
+
sub(this, args);
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
if (args.grab !== object)
|
|
558
|
+
console.log("Grabbed object changed", "original", object, "new", args.grab);
|
|
559
|
+
if (args.grab) {
|
|
560
|
+
this.grabbed = AttachedObject.TryTake(this, args.grab, intersection, closeGrab);
|
|
561
|
+
}
|
|
562
|
+
break;
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
else {
|
|
566
|
+
const subs = WebXRController.eventSubs[ControllerEvents.SelectStart];
|
|
567
|
+
const args = { selected: null, grab: null };
|
|
568
|
+
if (subs && subs.length > 0) {
|
|
569
|
+
for (const sub of subs) {
|
|
570
|
+
sub(this, args);
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
_didNotEndSelection = false;
|
|
576
|
+
onSelectEnd() {
|
|
577
|
+
if (this.isUsingHands) {
|
|
578
|
+
if (this.handPointerModel.pinched) {
|
|
579
|
+
this._didNotEndSelection = true;
|
|
580
|
+
return;
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
if (!this._selectionPressed)
|
|
584
|
+
return;
|
|
585
|
+
this.selectStartCallback = null;
|
|
586
|
+
this._selectionPressed = false;
|
|
587
|
+
this._selectionEndTime = this.context.time.time;
|
|
588
|
+
const args = { grab: this.grabbed?.selected ?? this.lastSelectStartObject };
|
|
589
|
+
const subs = WebXRController.eventSubs[ControllerEvents.SelectEnd];
|
|
590
|
+
if (subs && subs.length > 0) {
|
|
591
|
+
for (const sub of subs) {
|
|
592
|
+
sub(this, args);
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
if (this.grabbed) {
|
|
596
|
+
this.grabbed.free();
|
|
597
|
+
this.grabbed = null;
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
testIsVisible(obj) {
|
|
601
|
+
if (!obj)
|
|
602
|
+
return true;
|
|
603
|
+
return GameObject.isActiveInHierarchy(obj);
|
|
604
|
+
// if (!obj.visible) return false;
|
|
605
|
+
// return this.testIsVisible(obj.parent);
|
|
606
|
+
}
|
|
607
|
+
setControllerLayers(obj, layer) {
|
|
608
|
+
if (!obj)
|
|
609
|
+
return;
|
|
610
|
+
obj.layers.set(layer);
|
|
611
|
+
if (obj.children) {
|
|
612
|
+
for (const ch of obj.children) {
|
|
613
|
+
if (this.grabbed?.selected === ch || this.grabbed?.selectedMesh === ch) {
|
|
614
|
+
continue;
|
|
615
|
+
}
|
|
616
|
+
this.setControllerLayers(ch, layer);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
getRay() {
|
|
621
|
+
const ray = new THREE.Ray();
|
|
622
|
+
// this.tempMatrix.identity().extractRotation(this.controller.matrixWorld);
|
|
623
|
+
// ray.origin.setFromMatrixPosition(this.controller.matrixWorld);
|
|
624
|
+
ray.origin.copy(utils.getWorldPosition(this.controller));
|
|
625
|
+
ray.direction.set(0, 0, -1).applyQuaternion(this.rayRotation);
|
|
626
|
+
return ray;
|
|
627
|
+
}
|
|
628
|
+
overlap() {
|
|
629
|
+
const overlapCenter = (this.isUsingHands && this.handPointerModel) ? this.handPointerModel.pointerObject : this.controllerGrip;
|
|
630
|
+
if (!overlapCenter)
|
|
631
|
+
return new Array();
|
|
632
|
+
const wp = utils.getWorldPosition(overlapCenter).clone();
|
|
633
|
+
return this.context.physics.sphereOverlap(wp, .02);
|
|
634
|
+
}
|
|
635
|
+
raycast() {
|
|
636
|
+
const opts = new RaycastOptions();
|
|
637
|
+
opts.layerMask = new THREE.Layers();
|
|
638
|
+
opts.layerMask.set(0);
|
|
639
|
+
opts.ray = this.getRay();
|
|
640
|
+
return this.context.physics.raycast(opts);
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
export var AttachedObjectEvents;
|
|
644
|
+
(function (AttachedObjectEvents) {
|
|
645
|
+
AttachedObjectEvents["WillTake"] = "WillTake";
|
|
646
|
+
AttachedObjectEvents["DidTake"] = "DidTake";
|
|
647
|
+
AttachedObjectEvents["WillFree"] = "WillFree";
|
|
648
|
+
AttachedObjectEvents["DidFree"] = "DidFree";
|
|
649
|
+
})(AttachedObjectEvents || (AttachedObjectEvents = {}));
|
|
650
|
+
export class AttachedObject {
|
|
651
|
+
static Events = {};
|
|
652
|
+
static AddEventListener(event, callback) {
|
|
653
|
+
if (!AttachedObject.Events[event])
|
|
654
|
+
AttachedObject.Events[event] = [];
|
|
655
|
+
AttachedObject.Events[event].push(callback);
|
|
656
|
+
return callback;
|
|
657
|
+
}
|
|
658
|
+
static RemoveEventListener(event, callback) {
|
|
659
|
+
if (!callback)
|
|
660
|
+
return;
|
|
661
|
+
if (!AttachedObject.Events[event])
|
|
662
|
+
return;
|
|
663
|
+
const idx = AttachedObject.Events[event].indexOf(callback);
|
|
664
|
+
if (idx >= 0)
|
|
665
|
+
AttachedObject.Events[event].splice(idx, 1);
|
|
666
|
+
}
|
|
667
|
+
static Current = [];
|
|
668
|
+
static Register(obj) {
|
|
669
|
+
if (!this.Current.find(x => x === obj)) {
|
|
670
|
+
this.Current.push(obj);
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
static Remove(obj) {
|
|
674
|
+
const i = this.Current.indexOf(obj);
|
|
675
|
+
if (i >= 0) {
|
|
676
|
+
this.Current.splice(i, 1);
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
static TryTake(controller, candidate, intersection, closeGrab) {
|
|
680
|
+
const interactable = GameObject.getComponentInParent(candidate, Interactable);
|
|
681
|
+
if (!interactable) {
|
|
682
|
+
console.warn("Prevented taking object that is not interactable", candidate);
|
|
683
|
+
return null;
|
|
684
|
+
}
|
|
685
|
+
let objectToAttach = candidate;
|
|
686
|
+
const sync = GameObject.getComponentInParent(candidate, SyncedTransform);
|
|
687
|
+
if (sync) {
|
|
688
|
+
sync.requestOwnership();
|
|
689
|
+
objectToAttach = sync.gameObject;
|
|
690
|
+
}
|
|
691
|
+
for (const o of this.Current) {
|
|
692
|
+
if (o.selected === objectToAttach) {
|
|
693
|
+
if (o.controller === controller)
|
|
694
|
+
return o;
|
|
695
|
+
o.free();
|
|
696
|
+
o.Take(controller, objectToAttach, candidate, sync, interactable, intersection, closeGrab);
|
|
697
|
+
return o;
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
const att = new AttachedObject();
|
|
701
|
+
att.Take(controller, objectToAttach, candidate, sync, interactable, intersection, closeGrab);
|
|
702
|
+
return att;
|
|
703
|
+
}
|
|
704
|
+
sync = null;
|
|
705
|
+
selected = null;
|
|
706
|
+
selectedParent = null;
|
|
707
|
+
selectedMesh = null;
|
|
708
|
+
controller = null;
|
|
709
|
+
grabTime = 0;
|
|
710
|
+
grabUUID = "";
|
|
711
|
+
isCloseGrab = false; // when taken via sphere cast with hands
|
|
712
|
+
originalMaterial = null;
|
|
713
|
+
usageMarker = null;
|
|
714
|
+
rigidbodies = null;
|
|
715
|
+
didReparent = false;
|
|
716
|
+
grabDistance = 0;
|
|
717
|
+
interactable = null;
|
|
718
|
+
positionSource = null;
|
|
719
|
+
Take(controller, take, hit, sync, _interactable, intersection, closeGrab) {
|
|
720
|
+
console.assert(take !== null, "Expected object to be taken but was", take);
|
|
721
|
+
if (controller.isUsingHands) {
|
|
722
|
+
this.positionSource = closeGrab ? controller.wrist : controller.controller;
|
|
723
|
+
}
|
|
724
|
+
else {
|
|
725
|
+
this.positionSource = controller.controller;
|
|
726
|
+
}
|
|
727
|
+
if (!this.positionSource) {
|
|
728
|
+
console.warn("No position source");
|
|
729
|
+
return this;
|
|
730
|
+
}
|
|
731
|
+
const args = { controller, take, hit, sync, interactable: _interactable };
|
|
732
|
+
AttachedObject.Events.WillTake?.forEach(x => x(this, args));
|
|
733
|
+
const mesh = hit;
|
|
734
|
+
if (mesh?.material) {
|
|
735
|
+
this.originalMaterial = mesh.material;
|
|
736
|
+
if (!Array.isArray(mesh.material)) {
|
|
737
|
+
mesh.material = mesh.material.clone();
|
|
738
|
+
if (mesh.material && mesh.material["emissive"])
|
|
739
|
+
mesh.material["emissive"].b = .2;
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
this.selected = take;
|
|
743
|
+
if (!this.selectedParent) {
|
|
744
|
+
this.selectedParent = take.parent;
|
|
745
|
+
}
|
|
746
|
+
this.selectedMesh = mesh;
|
|
747
|
+
this.controller = controller;
|
|
748
|
+
this.interactable = _interactable;
|
|
749
|
+
this.isCloseGrab = closeGrab;
|
|
750
|
+
// if (interactable.canGrab) {
|
|
751
|
+
// this.didReparent = true;
|
|
752
|
+
// this.device.controller.attach(take);
|
|
753
|
+
// }
|
|
754
|
+
// else
|
|
755
|
+
this.didReparent = false;
|
|
756
|
+
this.sync = sync;
|
|
757
|
+
this.grabTime = controller.context.time.time;
|
|
758
|
+
this.grabUUID = Date.now().toString();
|
|
759
|
+
this.usageMarker = GameObject.addNewComponent(this.selected, UsageMarker);
|
|
760
|
+
this.rigidbodies = GameObject.getComponentsInChildren(this.selected, Rigidbody);
|
|
761
|
+
utils.getWorldPosition(this.positionSource, this.lastControllerWorldPos);
|
|
762
|
+
const getGrabPoint = () => closeGrab ? this.lastControllerWorldPos.clone() : intersection.point.clone();
|
|
763
|
+
this.grabDistance = getGrabPoint().distanceTo(this.lastControllerWorldPos);
|
|
764
|
+
this.totalChangeAlongDirection = 0.0;
|
|
765
|
+
// we're storing position relative to the grab point
|
|
766
|
+
// we're storing rotation relative to the ray
|
|
767
|
+
this.localPositionOffsetToGrab = this.selected.worldToLocal(getGrabPoint());
|
|
768
|
+
const rot = controller.isUsingHands && closeGrab ? this.controller.getWristQuaternion().clone() : controller.rayRotation.clone();
|
|
769
|
+
utils.getWorldQuaternion(this.selected, this.localQuaternionToGrab).premultiply(rot.invert());
|
|
770
|
+
const rig = this.controller.webXR.Rig;
|
|
771
|
+
if (rig)
|
|
772
|
+
this.rigPositionLastFrame.copy(utils.getWorldPosition(rig));
|
|
773
|
+
Avatar_POI.Add(controller.context, this.selected);
|
|
774
|
+
AttachedObject.Register(this);
|
|
775
|
+
if (this.sync) {
|
|
776
|
+
this.sync.fastMode = true;
|
|
777
|
+
}
|
|
778
|
+
AttachedObject.Events.DidTake?.forEach(x => x(this, args));
|
|
779
|
+
return this;
|
|
780
|
+
}
|
|
781
|
+
free() {
|
|
782
|
+
if (!this.selected)
|
|
783
|
+
return;
|
|
784
|
+
const args = { controller: this.controller, take: this.selected, hit: this.selected, sync: this.sync, interactable: null };
|
|
785
|
+
AttachedObject.Events.WillFree?.forEach(x => x(this, args));
|
|
786
|
+
Avatar_POI.Remove(this.controller.context, this.selected);
|
|
787
|
+
AttachedObject.Remove(this);
|
|
788
|
+
if (this.sync) {
|
|
789
|
+
this.sync.fastMode = false;
|
|
790
|
+
}
|
|
791
|
+
const mesh = this.selectedMesh;
|
|
792
|
+
if (mesh && this.originalMaterial && mesh.material) {
|
|
793
|
+
mesh.material = this.originalMaterial;
|
|
794
|
+
}
|
|
795
|
+
const object = this.selected;
|
|
796
|
+
// only attach the object back if it has a parent
|
|
797
|
+
// no parent means it was destroyed while holding it!
|
|
798
|
+
if (this.didReparent && object.parent) {
|
|
799
|
+
const prevParent = this.selectedParent;
|
|
800
|
+
if (prevParent)
|
|
801
|
+
prevParent.attach(object);
|
|
802
|
+
else
|
|
803
|
+
this.controller?.context.scene.attach(object);
|
|
804
|
+
}
|
|
805
|
+
this.usageMarker?.destroy();
|
|
806
|
+
if (this.controller)
|
|
807
|
+
this.controller.grabbed = null;
|
|
808
|
+
this.selected = null;
|
|
809
|
+
this.selectedParent = null;
|
|
810
|
+
this.selectedMesh = null;
|
|
811
|
+
this.sync = null;
|
|
812
|
+
// TODO: this doesnt work yet
|
|
813
|
+
if (this.rigidbodies) {
|
|
814
|
+
for (const rb of this.rigidbodies) {
|
|
815
|
+
rb.wakeUp();
|
|
816
|
+
if (!rb.smoothedVelocity)
|
|
817
|
+
continue;
|
|
818
|
+
rb.setVelocity(rb.smoothedVelocity.x, rb.smoothedVelocity.y, rb.smoothedVelocity.z);
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
this.rigidbodies = null;
|
|
822
|
+
this.localPositionOffsetToGrab = null;
|
|
823
|
+
this.quaternionLerp = null;
|
|
824
|
+
AttachedObject.Events.DidFree?.forEach(x => x(this, args));
|
|
825
|
+
}
|
|
826
|
+
grabPoint = new THREE.Vector3();
|
|
827
|
+
localPositionOffsetToGrab = null;
|
|
828
|
+
localPositionOffsetToGrab_worldSpace = new THREE.Vector3();
|
|
829
|
+
localQuaternionToGrab = new THREE.Quaternion(0, 0, 0, 1);
|
|
830
|
+
targetDir = null;
|
|
831
|
+
quaternionLerp = null;
|
|
832
|
+
controllerDir = new THREE.Vector3();
|
|
833
|
+
controllerWorldPos = new THREE.Vector3();
|
|
834
|
+
lastControllerWorldPos = new THREE.Vector3();
|
|
835
|
+
controllerPosDelta = new THREE.Vector3();
|
|
836
|
+
totalChangeAlongDirection = 0.0;
|
|
837
|
+
rigPositionLastFrame = new THREE.Vector3();
|
|
838
|
+
controllerMovementSinceLastFrame() {
|
|
839
|
+
if (!this.positionSource || !this.controller)
|
|
840
|
+
return 0.0;
|
|
841
|
+
// controller direction
|
|
842
|
+
this.controllerDir.set(0, 0, -1);
|
|
843
|
+
this.controllerDir.applyQuaternion(this.controller.rayRotation);
|
|
844
|
+
// controller delta
|
|
845
|
+
utils.getWorldPosition(this.positionSource, this.controllerWorldPos);
|
|
846
|
+
this.controllerPosDelta.copy(this.controllerWorldPos);
|
|
847
|
+
this.controllerPosDelta.sub(this.lastControllerWorldPos);
|
|
848
|
+
this.lastControllerWorldPos.copy(this.controllerWorldPos);
|
|
849
|
+
const rig = this.controller.webXR.Rig;
|
|
850
|
+
if (rig) {
|
|
851
|
+
const rigPos = utils.getWorldPosition(rig);
|
|
852
|
+
const rigDelta = this.rigPositionLastFrame.sub(rigPos);
|
|
853
|
+
this.controllerPosDelta.add(rigDelta);
|
|
854
|
+
this.rigPositionLastFrame.copy(rigPos);
|
|
855
|
+
}
|
|
856
|
+
// calculate delta along direction
|
|
857
|
+
const changeAlongControllerDirection = this.controllerDir.dot(this.controllerPosDelta);
|
|
858
|
+
return changeAlongControllerDirection;
|
|
859
|
+
}
|
|
860
|
+
update() {
|
|
861
|
+
// TODO: add/use sync lost ownership event
|
|
862
|
+
if (this.sync && this.controller && this.controller.context.connection.isInRoom) {
|
|
863
|
+
const td = this.controller.context.time.time - this.grabTime;
|
|
864
|
+
// if (time.frameCount % 60 === 0) {
|
|
865
|
+
// console.log("ownership?", this.selected.name, this.sync.hasOwnership(), td)
|
|
866
|
+
// }
|
|
867
|
+
if (td > 3) {
|
|
868
|
+
// if (time.frameCount % 60 === 0) {
|
|
869
|
+
// console.log(this.sync.hasOwnership())
|
|
870
|
+
// }
|
|
871
|
+
if (this.sync.hasOwnership() === false) {
|
|
872
|
+
console.log("no ownership, will leave", this.sync.guid);
|
|
873
|
+
this.free();
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
if (this.interactable && !this.interactable.canGrab)
|
|
878
|
+
return;
|
|
879
|
+
if (!this.didReparent && this.selected && this.controller) {
|
|
880
|
+
const rigScale = this.controller.webXR.Rig?.scale.x ?? 1.0;
|
|
881
|
+
this.totalChangeAlongDirection += this.controllerMovementSinceLastFrame();
|
|
882
|
+
// console.log(this.totalChangeAlongDirection);
|
|
883
|
+
// alert("yo: " + this.controller.webXR.Rig?.scale.x); // this is 0.1 on Hololens
|
|
884
|
+
let currentDist = 1.0;
|
|
885
|
+
if (this.controller.type === ControllerType.PhysicalDevice) // only for controllers and not on touch (AR touches are controllers)
|
|
886
|
+
{
|
|
887
|
+
currentDist = Math.max(0.0, 1 + this.totalChangeAlongDirection * 2.0 / rigScale);
|
|
888
|
+
currentDist = currentDist * currentDist * currentDist;
|
|
889
|
+
}
|
|
890
|
+
if (this.grabDistance / rigScale < 0.8)
|
|
891
|
+
currentDist = 1.0; // don't accelerate if this is a close grab, want full control
|
|
892
|
+
if (!this.targetDir) {
|
|
893
|
+
this.targetDir = new THREE.Vector3();
|
|
894
|
+
}
|
|
895
|
+
this.targetDir.set(0, 0, -this.grabDistance * currentDist);
|
|
896
|
+
const target = this.targetDir.applyQuaternion(this.controller.rayRotation).add(this.controllerWorldPos);
|
|
897
|
+
// apply rotation
|
|
898
|
+
const targetQuat = this.controller.rayRotation.clone().multiplyQuaternions(this.controller.rayRotation, this.localQuaternionToGrab);
|
|
899
|
+
if (!this.quaternionLerp) {
|
|
900
|
+
this.quaternionLerp = targetQuat.clone();
|
|
901
|
+
}
|
|
902
|
+
this.quaternionLerp.slerp(targetQuat, this.controller.useSmoothing ? this.controller.context.time.deltaTime / .03 : 1.0);
|
|
903
|
+
utils.setWorldQuaternion(this.selected, this.quaternionLerp);
|
|
904
|
+
this.selected.updateWorldMatrix(false, false); // necessary so that rotation is correct for the following position update
|
|
905
|
+
// apply position
|
|
906
|
+
this.grabPoint.copy(target);
|
|
907
|
+
// apply local grab offset
|
|
908
|
+
if (this.localPositionOffsetToGrab) {
|
|
909
|
+
this.localPositionOffsetToGrab_worldSpace.copy(this.localPositionOffsetToGrab);
|
|
910
|
+
this.selected.localToWorld(this.localPositionOffsetToGrab_worldSpace).sub(utils.getWorldPosition(this.selected));
|
|
911
|
+
target.sub(this.localPositionOffsetToGrab_worldSpace);
|
|
912
|
+
}
|
|
913
|
+
utils.setWorldPosition(this.selected, target);
|
|
914
|
+
}
|
|
915
|
+
if (this.rigidbodies != null) {
|
|
916
|
+
for (const rb of this.rigidbodies) {
|
|
917
|
+
rb.wakeUp();
|
|
918
|
+
rb.setBodyFromGameObject({ x: 0, y: 0, z: 0 });
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
InstancingUtil.markDirty(this.selected, true);
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
//# sourceMappingURL=WebXRController.js.map
|