mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 17:30:37 +02:00
Reorient and reposition mini tablet
This commit is contained in:
parent
a5c3450bfc
commit
ec20fb7edb
1 changed files with 30 additions and 29 deletions
|
@ -20,24 +20,22 @@
|
||||||
proxyOverlay = null,
|
proxyOverlay = null,
|
||||||
PROXY_MODEL = Script.resolvePath("./assets/models/tinyTablet.fbx"),
|
PROXY_MODEL = Script.resolvePath("./assets/models/tinyTablet.fbx"),
|
||||||
PROXY_DIMENSIONS = { x: 0.0637, y: 0.0965, z: 0.0045 }, // Proportional to tablet proper.
|
PROXY_DIMENSIONS = { x: 0.0637, y: 0.0965, z: 0.0045 }, // Proportional to tablet proper.
|
||||||
PROXY_POSITION_LEFT_HAND = {
|
PROXY_POSITIONS = [
|
||||||
x: 0,
|
{
|
||||||
y: 0.1, // Distance from joint.
|
x: -0.03, // Distance across hand.
|
||||||
z: 0.07 // Distance above palm.
|
y: 0.08, // Distance from joint.
|
||||||
},
|
z: 0.06 // Distance above palm.
|
||||||
PROXY_POSITION_RIGHT_HAND = {
|
},
|
||||||
x: 0,
|
{
|
||||||
y: 0.1, // Distance from joint.
|
x: 0.03, // Distance across hand.
|
||||||
z: 0.07 // Distance above palm.
|
y: 0.08, // Distance from joint.
|
||||||
},
|
z: 0.06 // Distance above palm.
|
||||||
/*
|
}
|
||||||
// Aligned cross-palm.
|
],
|
||||||
PROXY_ROTATION_LEFT_HAND = Quat.fromVec3Degrees({ x: 0, y: 180, z: 90 }),
|
PROXY_ROTATIONS = [
|
||||||
PROXY_ROTATION_RIGHT_HAND = Quat.fromVec3Degrees({ x: 0, y: 180, z: -90 }),
|
Quat.fromVec3Degrees({ x: 0, y: 180 - 40, z: 90 }),
|
||||||
*/
|
Quat.fromVec3Degrees({ x: 0, y: 180 + 40, z: -90 }),
|
||||||
// Aligned with palm.
|
],
|
||||||
PROXY_ROTATION_LEFT_HAND = Quat.fromVec3Degrees({ x: -40, y: 180, z: 0 }),
|
|
||||||
PROXY_ROTATION_RIGHT_HAND = Quat.fromVec3Degrees({ x: -40, y: 180, z: 0 }),
|
|
||||||
|
|
||||||
// UI overlay.
|
// UI overlay.
|
||||||
proxyUIOverlay = null,
|
proxyUIOverlay = null,
|
||||||
|
@ -76,10 +74,10 @@
|
||||||
proxyScaleTimer = null,
|
proxyScaleTimer = null,
|
||||||
proxyScaleStart,
|
proxyScaleStart,
|
||||||
PROXY_EXPAND_HANDLES = [ // Normalized coordinates in range [-0.5, 0.5] about center of mini tablet.
|
PROXY_EXPAND_HANDLES = [ // Normalized coordinates in range [-0.5, 0.5] about center of mini tablet.
|
||||||
{ x: 0.5, y: -0.75, z: 0 },
|
{ x: 0.5, y: -0.65, z: 0 },
|
||||||
{ x: -0.5, y: -0.75, z: 0 }
|
{ x: -0.5, y: -0.65, z: 0 }
|
||||||
],
|
],
|
||||||
PROXY_EXPAND_DELTA_ROTATION = Quat.fromVec3Degrees({ x: -5, y: 0, z: 0 }),
|
PROXY_EXPAND_DELTA_ROTATION = Quat.fromVec3Degrees({ x: 0, y: 0, z: 0 }),
|
||||||
proxyExpandHand,
|
proxyExpandHand,
|
||||||
proxyExpandLocalPosition,
|
proxyExpandLocalPosition,
|
||||||
proxyExpandLocalRotation = Quat.IDENTITY,
|
proxyExpandLocalRotation = Quat.IDENTITY,
|
||||||
|
@ -284,9 +282,8 @@
|
||||||
Overlays.editOverlay(proxyOverlay, {
|
Overlays.editOverlay(proxyOverlay, {
|
||||||
parentID: MyAvatar.SELF_ID,
|
parentID: MyAvatar.SELF_ID,
|
||||||
parentJointIndex: handJointIndex(proxyHand),
|
parentJointIndex: handJointIndex(proxyHand),
|
||||||
localPosition: Vec3.multiply(avatarScale,
|
localPosition: Vec3.multiply(avatarScale, PROXY_POSITIONS[proxyHand]),
|
||||||
proxyHand === LEFT_HAND ? PROXY_POSITION_LEFT_HAND : PROXY_POSITION_RIGHT_HAND),
|
localRotation: PROXY_ROTATIONS[proxyHand],
|
||||||
localRotation: proxyHand === LEFT_HAND ? PROXY_ROTATION_LEFT_HAND : PROXY_ROTATION_RIGHT_HAND,
|
|
||||||
dimensions: Vec3.multiply(initialScale, PROXY_DIMENSIONS),
|
dimensions: Vec3.multiply(initialScale, PROXY_DIMENSIONS),
|
||||||
visible: true
|
visible: true
|
||||||
});
|
});
|
||||||
|
@ -402,12 +399,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function shouldShowProxy(hand) {
|
function shouldShowProxy(hand) {
|
||||||
// Should show tablet proxy if hand is oriented toward the camera and the camera is oriented toward the proxy tablet.
|
// Should show proxy if it would be oriented toward the camera.
|
||||||
var pose,
|
var pose,
|
||||||
jointIndex,
|
jointIndex,
|
||||||
handPosition,
|
handPosition,
|
||||||
handOrientation,
|
handOrientation,
|
||||||
cameraToHandDirection;
|
proxyPosition,
|
||||||
|
proxyOrientation,
|
||||||
|
proxyToCameraDirection;
|
||||||
|
|
||||||
pose = Controller.getPoseValue(hand === LEFT_HAND ? Controller.Standard.LeftHand : Controller.Standard.RightHand);
|
pose = Controller.getPoseValue(hand === LEFT_HAND ? Controller.Standard.LeftHand : Controller.Standard.RightHand);
|
||||||
if (!pose.valid) {
|
if (!pose.valid) {
|
||||||
|
@ -418,9 +417,11 @@
|
||||||
handPosition = Vec3.sum(MyAvatar.position,
|
handPosition = Vec3.sum(MyAvatar.position,
|
||||||
Vec3.multiplyQbyV(MyAvatar.orientation, MyAvatar.getAbsoluteJointTranslationInObjectFrame(jointIndex)));
|
Vec3.multiplyQbyV(MyAvatar.orientation, MyAvatar.getAbsoluteJointTranslationInObjectFrame(jointIndex)));
|
||||||
handOrientation = Quat.multiply(MyAvatar.orientation, MyAvatar.getAbsoluteJointRotationInObjectFrame(jointIndex));
|
handOrientation = Quat.multiply(MyAvatar.orientation, MyAvatar.getAbsoluteJointRotationInObjectFrame(jointIndex));
|
||||||
cameraToHandDirection = Vec3.normalize(Vec3.subtract(handPosition, Camera.position));
|
proxyPosition = Vec3.sum(handPosition, Vec3.multiply(avatarScale,
|
||||||
|
Vec3.multiplyQbyV(handOrientation, PROXY_POSITIONS[hand])));
|
||||||
return Vec3.dot(cameraToHandDirection, Quat.getForward(handOrientation)) > MIN_HAND_CAMERA_ANGLE_COS;
|
proxyOrientation = Quat.multiply(handOrientation, PROXY_ROTATIONS[hand]);
|
||||||
|
proxyToCameraDirection = Vec3.normalize(Vec3.subtract(Camera.position, proxyPosition));
|
||||||
|
return Vec3.dot(proxyToCameraDirection, Quat.getForward(proxyOrientation)) > MIN_HAND_CAMERA_ANGLE_COS;
|
||||||
}
|
}
|
||||||
|
|
||||||
function enterProxyHidden() {
|
function enterProxyHidden() {
|
||||||
|
|
Loading…
Reference in a new issue