mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 11:07:07 +02:00
updated tablet position
This commit is contained in:
parent
0c06832be4
commit
2d8d5401dc
1 changed files with 9 additions and 8 deletions
|
@ -26,17 +26,18 @@ var TABLET_URL = "http://hifi-content.s3.amazonaws.com/alan/dev/Tablet-Model-v1-
|
||||||
// returns object with two fields:
|
// returns object with two fields:
|
||||||
// * position - position in front of the user
|
// * position - position in front of the user
|
||||||
// * rotation - rotation of entity so it faces the user.
|
// * rotation - rotation of entity so it faces the user.
|
||||||
function calcSpawnInfo(hand) {
|
function calcSpawnInfo(hand, height) {
|
||||||
var noHands = -1;
|
var noHands = -1;
|
||||||
if (HMD.active && hand != noHands) {
|
if (HMD.active && hand != noHands) {
|
||||||
var handController = getControllerWorldLocation(hand, false);
|
var handController = getControllerWorldLocation(hand, false);
|
||||||
var front = Quat.getFront(handController.orientation);
|
var controllerPosition = handController.position;
|
||||||
var up = Quat.getUp(handController.orientation);
|
var originalOrientation = Quat.lookAt(controllerPosition, HMD.position, Y_AXIS);
|
||||||
var frontOffset = Vec3.sum(handController.position, Vec3.multiply(0.4, up));
|
var yDisplacement = (height/2) + 0.2;
|
||||||
var finalOffset = Vec3.sum(frontOffset, Vec3.multiply(-0.3, front));
|
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 {
|
return {
|
||||||
position: finalOffset,
|
position: finalPosition,
|
||||||
rotation: Quat.lookAt(finalOffset, HMD.position, Y_AXIS)
|
rotation: Quat.lookAt(finalPosition, HMD.position, Y_AXIS)
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
var front = Quat.getFront(MyAvatar.orientation);
|
var front = Quat.getFront(MyAvatar.orientation);
|
||||||
|
@ -174,7 +175,7 @@ WebTablet.prototype.calculateTabletAttachmentProperties = function (hand, tablet
|
||||||
tabletProperties.parentJointIndex = SENSOR_TO_ROOM_MATRIX;
|
tabletProperties.parentJointIndex = SENSOR_TO_ROOM_MATRIX;
|
||||||
|
|
||||||
// compute the appropriate position of the tablet, near the hand controller that was used to spawn it.
|
// 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.position = spawnInfo.position;
|
||||||
tabletProperties.rotation = spawnInfo.rotation;
|
tabletProperties.rotation = spawnInfo.rotation;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue