From 2d8d5401dca9d3b63655363cfca69c78ae895039 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Wed, 11 Jan 2017 16:38:09 +0000 Subject: [PATCH] updated tablet position --- scripts/system/libraries/WebTablet.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/scripts/system/libraries/WebTablet.js b/scripts/system/libraries/WebTablet.js index ca1b06f008..493ed07944 100644 --- a/scripts/system/libraries/WebTablet.js +++ b/scripts/system/libraries/WebTablet.js @@ -26,17 +26,18 @@ var TABLET_URL = "http://hifi-content.s3.amazonaws.com/alan/dev/Tablet-Model-v1- // returns object with two fields: // * position - position in front of the user // * rotation - rotation of entity so it faces the user. -function calcSpawnInfo(hand) { +function calcSpawnInfo(hand, height) { var noHands = -1; if (HMD.active && hand != noHands) { var handController = getControllerWorldLocation(hand, false); - var front = Quat.getFront(handController.orientation); - var up = Quat.getUp(handController.orientation); - var frontOffset = Vec3.sum(handController.position, Vec3.multiply(0.4, up)); - var finalOffset = Vec3.sum(frontOffset, Vec3.multiply(-0.3, front)); + var controllerPosition = handController.position; + var originalOrientation = Quat.lookAt(controllerPosition, HMD.position, Y_AXIS); + var yDisplacement = (height/2) + 0.2; + var tabletOffset = Vec3.multiplyQbyV(Quat.lookAt(controllerPosition, HMD.position, Y_AXIS), {x: 0, y: yDisplacement, z: -0.2}); + var finalPosition = Vec3.sum(controllerPosition, tabletOffset); return { - position: finalOffset, - rotation: Quat.lookAt(finalOffset, HMD.position, Y_AXIS) + position: finalPosition, + rotation: Quat.lookAt(finalPosition, HMD.position, Y_AXIS) }; } else { var front = Quat.getFront(MyAvatar.orientation); @@ -174,7 +175,7 @@ WebTablet.prototype.calculateTabletAttachmentProperties = function (hand, tablet tabletProperties.parentJointIndex = SENSOR_TO_ROOM_MATRIX; // compute the appropriate position of the tablet, near the hand controller that was used to spawn it. - var spawnInfo = calcSpawnInfo(hand); + var spawnInfo = calcSpawnInfo(hand, this.height); tabletProperties.position = spawnInfo.position; tabletProperties.rotation = spawnInfo.rotation; } else {