From 5ecc680726a09cc7796f5f9e153bd11c6a276a55 Mon Sep 17 00:00:00 2001 From: Srinivas Prabhu Date: Fri, 19 Feb 2021 17:19:42 +0530 Subject: [PATCH 1/3] Ability to move the XR camera 1mtr below the ground. --- src/js/xr/src/use-interactions-manager.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/js/xr/src/use-interactions-manager.js b/src/js/xr/src/use-interactions-manager.js index b7541454d7..3cc2527d0e 100644 --- a/src/js/xr/src/use-interactions-manager.js +++ b/src/js/xr/src/use-interactions-manager.js @@ -764,12 +764,19 @@ const useInteractionsManager = ({ let worldScale = useStoreApi.getState().worldScale let hmd = camera.parent let elevationDisplacement = 0.5 + //Value of -1.6 is used since the XR camera is already 1.6 mtrs above the ground by default. + let minHeight = -1.6; if (event.target.uuid === rightController.uuid) { hmd.position.y += elevationDisplacement } else { - if (hmd.position.y !== 0) { + + //This makes sure that the camera moves upto 1mtr below the surface + if (hmd.position.y > minHeight) { hmd.position.y -= elevationDisplacement + //Clamp the value to 1.6mtrs below the ground in case the y values becomes lesser. + if(hmd.position.y < minHeight) + hmd.position.y = minHeight } } From 8431b8fb509944403de5c9f0391ceccfc191aae6 Mon Sep 17 00:00:00 2001 From: Srinivas Prabhu Date: Sun, 21 Feb 2021 11:05:42 +0530 Subject: [PATCH 2/3] Review Fixes. --- src/js/xr/src/use-interactions-manager.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/js/xr/src/use-interactions-manager.js b/src/js/xr/src/use-interactions-manager.js index 3cc2527d0e..f8bfb2d7b2 100644 --- a/src/js/xr/src/use-interactions-manager.js +++ b/src/js/xr/src/use-interactions-manager.js @@ -764,19 +764,19 @@ const useInteractionsManager = ({ let worldScale = useStoreApi.getState().worldScale let hmd = camera.parent let elevationDisplacement = 0.5 - //Value of -1.6 is used since the XR camera is already 1.6 mtrs above the ground by default. - let minHeight = -1.6; + // Value of -2.6 is used since the XR camera is already 1.6 mtrs above the ground by default. + let minHeight = -2.6 - if (event.target.uuid === rightController.uuid) { + if ( event.target.uuid === rightController.uuid ) { hmd.position.y += elevationDisplacement } else { - - //This makes sure that the camera moves upto 1mtr below the surface - if (hmd.position.y > minHeight) { + // This makes sure that the camera moves upto 1mtr below the surface + if ( hmd.position.y > minHeight ) { hmd.position.y -= elevationDisplacement - //Clamp the value to 1.6mtrs below the ground in case the y values becomes lesser. - if(hmd.position.y < minHeight) + // Clamp the value to 2.6mtrs below the ground in case the y values becomes lesser. + if( hmd.position.y < minHeight ) { hmd.position.y = minHeight + } } } From 186075864bd0490e9602ada026e1b3f86cdfb943 Mon Sep 17 00:00:00 2001 From: Srinivas Prabhu Date: Thu, 4 Mar 2021 12:22:24 +0530 Subject: [PATCH 3/3] Added spaces as per the review. --- src/js/xr/src/use-interactions-manager.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/js/xr/src/use-interactions-manager.js b/src/js/xr/src/use-interactions-manager.js index f8bfb2d7b2..ee05c73c54 100644 --- a/src/js/xr/src/use-interactions-manager.js +++ b/src/js/xr/src/use-interactions-manager.js @@ -767,14 +767,14 @@ const useInteractionsManager = ({ // Value of -2.6 is used since the XR camera is already 1.6 mtrs above the ground by default. let minHeight = -2.6 - if ( event.target.uuid === rightController.uuid ) { + if (event.target.uuid === rightController.uuid) { hmd.position.y += elevationDisplacement } else { // This makes sure that the camera moves upto 1mtr below the surface - if ( hmd.position.y > minHeight ) { + if (hmd.position.y > minHeight) { hmd.position.y -= elevationDisplacement // Clamp the value to 2.6mtrs below the ground in case the y values becomes lesser. - if( hmd.position.y < minHeight ) { + if (hmd.position.y < minHeight) { hmd.position.y = minHeight } }