From 5b3d92e8167e7bcab5a3ed697993288eef8b5938 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sun, 16 Sep 2018 08:09:26 +1200 Subject: [PATCH] Persist showing mini tablet for a while after it would otherwise hide --- scripts/system/miniTablet.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/system/miniTablet.js b/scripts/system/miniTablet.js index bda5909491..2e5a5d86a2 100644 --- a/scripts/system/miniTablet.js +++ b/scripts/system/miniTablet.js @@ -565,7 +565,9 @@ MAX_CAMERA_HAND_ANGLE = 30, DEGREES_180 = 180, MIN_HAND_CAMERA_ANGLE_COS = Math.cos(Math.PI * MIN_HAND_CAMERA_ANGLE / DEGREES_180), - MAX_CAMERA_HAND_ANGLE_COS = Math.cos(Math.PI * MAX_CAMERA_HAND_ANGLE / DEGREES_180); + MAX_CAMERA_HAND_ANGLE_COS = Math.cos(Math.PI * MAX_CAMERA_HAND_ANGLE / DEGREES_180), + HIDING_DELAY = 1000, // ms + lastVisible = [0, 0]; function enterMiniDisabled() { @@ -646,6 +648,7 @@ // Should show mini tablet if it would be oriented toward the camera. if (show) { + // Calculate current visibility of mini tablet. jointIndex = handJointIndex(hand); handPosition = Vec3.sum(MyAvatar.position, Vec3.multiplyQbyV(MyAvatar.orientation, MyAvatar.getAbsoluteJointTranslationInObjectFrame(jointIndex))); @@ -660,6 +663,13 @@ show = show || (-Vec3.dot(miniToCameraDirection, Quat.getForward(handOrientation)) > MIN_HAND_CAMERA_ANGLE_COS); cameraToHand = -Vec3.dot(miniToCameraDirection, Quat.getForward(Camera.orientation)); show = show && (cameraToHand > MAX_CAMERA_HAND_ANGLE_COS); + + // Persist showing for a while after it would otherwise be hidden. + if (show) { + lastVisible[hand] = Date.now(); + } else { + show = Date.now() - lastVisible[hand] <= HIDING_DELAY; + } } return {