use head pose for controller in case there are no hand controllers available

This commit is contained in:
Brad Hefta-Gaub 2016-10-18 10:01:00 -07:00
parent c50cd865e5
commit c082c74cc0
2 changed files with 8 additions and 2 deletions

View file

@ -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.
}

View file

@ -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};
};