mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 13:28:16 +02:00
Expand from lower left/right of proxy tablet
This commit is contained in:
parent
7a1a86f182
commit
40f7914aae
1 changed files with 26 additions and 8 deletions
|
@ -48,6 +48,13 @@
|
||||||
STATE_MACHINE,
|
STATE_MACHINE,
|
||||||
rezzerState = PROXY_HIDDEN,
|
rezzerState = PROXY_HIDDEN,
|
||||||
proxyHand,
|
proxyHand,
|
||||||
|
PROXY_GRAB_HANDLES = [
|
||||||
|
{ x: 0.5, y: -0.4, z: 0 },
|
||||||
|
{ x: -0.5, y: -0.4, z: 0 }
|
||||||
|
],
|
||||||
|
proxyGrabHand,
|
||||||
|
proxyGrabHandleLocalPosition,
|
||||||
|
proxyGrabLocalRotation = Quat.IDENTITY,
|
||||||
PROXY_EXPAND_DURATION = 250,
|
PROXY_EXPAND_DURATION = 250,
|
||||||
PROXY_EXPAND_TIMEOUT = 25,
|
PROXY_EXPAND_TIMEOUT = 25,
|
||||||
proxyExpandTimer = null,
|
proxyExpandTimer = null,
|
||||||
|
@ -109,6 +116,10 @@
|
||||||
return MyAvatar.getJointIndex(handJointName(hand));
|
return MyAvatar.getJointIndex(handJointName(hand));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function otherHand(hand) {
|
||||||
|
return hand === LEFT_HAND ? RIGHT_HAND : LEFT_HAND;
|
||||||
|
}
|
||||||
|
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
// #region State Machine ===================================================================================================
|
// #region State Machine ===================================================================================================
|
||||||
|
@ -164,11 +175,16 @@
|
||||||
|
|
||||||
function expandProxy() {
|
function expandProxy() {
|
||||||
var scaleFactor = (Date.now() - proxyExpandStart) / PROXY_EXPAND_DURATION;
|
var scaleFactor = (Date.now() - proxyExpandStart) / PROXY_EXPAND_DURATION;
|
||||||
|
var tabletScaleFactor = avatarScale * (1 + scaleFactor * (proxyTargetWidth - proxyInitialWidth) / proxyInitialWidth);
|
||||||
if (scaleFactor < 1) {
|
if (scaleFactor < 1) {
|
||||||
Overlays.editOverlay(proxyOverlay, {
|
Overlays.editOverlay(proxyOverlay, {
|
||||||
dimensions: Vec3.multiply(
|
dimensions: Vec3.multiply(tabletScaleFactor, TABLET_PROXY_DIMENSIONS),
|
||||||
avatarScale * (1 + scaleFactor * (proxyTargetWidth - proxyInitialWidth) / proxyInitialWidth),
|
localPosition:
|
||||||
TABLET_PROXY_DIMENSIONS)
|
Vec3.sum(proxyGrabHandleLocalPosition,
|
||||||
|
Vec3.multiplyQbyV(proxyGrabLocalRotation,
|
||||||
|
Vec3.multiply(-tabletScaleFactor,
|
||||||
|
Vec3.multiplyVbyV(PROXY_GRAB_HANDLES[proxyGrabHand], TABLET_PROXY_DIMENSIONS)))
|
||||||
|
)
|
||||||
});
|
});
|
||||||
proxyExpandTimer = Script.setTimeout(expandProxy, PROXY_EXPAND_TIMEOUT);
|
proxyExpandTimer = Script.setTimeout(expandProxy, PROXY_EXPAND_TIMEOUT);
|
||||||
return;
|
return;
|
||||||
|
@ -179,11 +195,12 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function enterProxyExpanding() {
|
function enterProxyExpanding() {
|
||||||
// Detach from hand.
|
// Grab details.
|
||||||
Overlays.editOverlay(proxyOverlay, {
|
var properties = Overlays.getProperties(proxyOverlay, ["localPosition", "localRotation"]);
|
||||||
parentID: Uuid.NULL,
|
proxyGrabLocalRotation = properties.localRotation;
|
||||||
parentJointIndex: -1
|
proxyGrabHandleLocalPosition = Vec3.sum(properties.localPosition,
|
||||||
});
|
Vec3.multiplyQbyV(proxyGrabLocalRotation,
|
||||||
|
Vec3.multiplyVbyV(PROXY_GRAB_HANDLES[proxyGrabHand], TABLET_PROXY_DIMENSIONS)));
|
||||||
|
|
||||||
// Start expanding.
|
// Start expanding.
|
||||||
proxyInitialWidth = TABLET_PROXY_DIMENSIONS.x;
|
proxyInitialWidth = TABLET_PROXY_DIMENSIONS.x;
|
||||||
|
@ -316,6 +333,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message.action === "grab" && rezzerState === PROXY_VISIBLE) {
|
if (message.action === "grab" && rezzerState === PROXY_VISIBLE) {
|
||||||
|
proxyGrabHand = message.joint === HAND_NAMES[proxyHand] ? proxyHand : otherHand(proxyHand);
|
||||||
setState(PROXY_EXPANDING);
|
setState(PROXY_EXPANDING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue