diff --git a/scripts/system/controllers/handControllerPointer.js b/scripts/system/controllers/handControllerPointer.js index 1fc0a7a82c..80f8976810 100644 --- a/scripts/system/controllers/handControllerPointer.js +++ b/scripts/system/controllers/handControllerPointer.js @@ -204,7 +204,7 @@ function overlayFromWorldPoint(point) { } function activeHudPoint2d(activeHand) { // if controller is valid, update reticle position and answer 2d point. Otherwise falsey. - var controllerPose = getControllerWorldLocation(activeHand, true); + var controllerPose = getControllerWorldLocation(activeHand, true); // note: this will use head pose of hand pose is invalid (third eye) if (!controllerPose.valid) { return; // Controller is cradled. } diff --git a/scripts/system/libraries/controllers.js b/scripts/system/libraries/controllers.js index 8b5c1bc2fb..adee156248 100644 --- a/scripts/system/libraries/controllers.js +++ b/scripts/system/libraries/controllers.js @@ -39,6 +39,7 @@ getControllerWorldLocation = function (handController, doOffset) { var orientation; var position; var pose = Controller.getPoseValue(handController); + var valid = pose.valid; if (pose.valid) { orientation = Quat.multiply(MyAvatar.orientation, pose.rotation); position = Vec3.sum(Vec3.multiplyQbyV(MyAvatar.orientation, pose.translation), MyAvatar.position); @@ -46,10 +47,15 @@ getControllerWorldLocation = function (handController, doOffset) { if (doOffset) { position = Vec3.sum(position, Vec3.multiplyQbyV(orientation, getGrabPointSphereOffset(handController))); } + } else if (!HMD.isHandControllerAvailable()){ + position = MyAvatar.getHeadPosition(); + orientation = Quat.multiply(MyAvatar.headOrientation, Quat.angleAxis(-90, { x: 1, y: 0, z: 0 })); + valid = true; } + return {position: position, translation: position, orientation: orientation, rotation: orientation, - valid: pose.valid}; + valid: valid}; };