From 6736eefbc11e7932d476d0acecd2624dae06fe13 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Wed, 25 Nov 2015 14:14:22 +1300 Subject: [PATCH] Fix arm and finger joint control in leapHands.js for desktop mode --- examples/controllers/leap/leapHands.js | 33 ++++++++++---------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/examples/controllers/leap/leapHands.js b/examples/controllers/leap/leapHands.js index 6bdca051be..04b65349a9 100644 --- a/examples/controllers/leap/leapHands.js +++ b/examples/controllers/leap/leapHands.js @@ -193,13 +193,12 @@ var leapHands = (function () { } // Set avatar arms vertical, forearms horizontal, as "zero" position for calibration - MyAvatar.setJointData("LeftArm", Quat.fromPitchYawRollDegrees(90.0, 0.0, -90.0)); - MyAvatar.setJointData("LeftForeArm", Quat.fromPitchYawRollDegrees(90.0, 0.0, 180.0)); - MyAvatar.setJointData("LeftHand", Quat.fromPitchYawRollRadians(0.0, 0.0, 0.0)); - MyAvatar.setJointData("RightArm", Quat.fromPitchYawRollDegrees(90.0, 0.0, 90.0)); - MyAvatar.setJointData("RightForeArm", Quat.fromPitchYawRollDegrees(90.0, 0.0, 180.0)); - MyAvatar.setJointData("RightHand", Quat.fromPitchYawRollRadians(0.0, 0.0, 0.0)); - + MyAvatar.setJointRotation("LeftArm", Quat.fromPitchYawRollDegrees(90.0, 0.0, 0.0)); + MyAvatar.setJointRotation("LeftForeArm", Quat.fromPitchYawRollDegrees(0.0, 90.0, 90.0)); + MyAvatar.setJointRotation("LeftHand", Quat.fromPitchYawRollRadians(0.0, 0.0, 0.0)); + MyAvatar.setJointRotation("RightArm", Quat.fromPitchYawRollDegrees(90.0,0.0, 0.0)); + MyAvatar.setJointRotation("RightForeArm", Quat.fromPitchYawRollDegrees(0.0, -90.0, -90.0)); + MyAvatar.setJointRotation("RightHand", Quat.fromPitchYawRollRadians(0.0, 0.0, 0.0)); // Wait for arms to assume their positions before calculating Script.setTimeout(finishCalibration, CALIBRATION_TIME); @@ -421,22 +420,14 @@ var leapHands = (function () { // Hand rotation in camera coordinates ... handRotation = { - x: handRotation.z, - y: handRotation.y, - z: handRotation.x, - w: handRotation.w + x: -handRotation.x, + y: -handRotation.z, + z: -handRotation.y, + w: handRotation.w, }; // Hand rotation in avatar coordinates ... - if (h === 0) { - handRotation.x = -handRotation.x; - handRotation = Quat.multiply(Quat.angleAxis(-90.0, { x: 0, y: 1, z: 0 }), - handRotation); - } else { - handRotation.z = -handRotation.z; - handRotation = Quat.multiply(Quat.angleAxis(90.0, { x: 0, y: 1, z: 0 }), - handRotation); - } + handRotation = Quat.multiply(Quat.angleAxis(90.0, { x: 1, y: 0, z: 0 }), handRotation); } // Set hand position and orientation ... @@ -462,7 +453,7 @@ var leapHands = (function () { w: locRotation.w }; } - MyAvatar.setJointData(fingers[h][i][j].jointName, locRotation); + MyAvatar.setJointRotation(fingers[h][i][j].jointName, locRotation); } } }