mirror of
https://github.com/overte-org/overte.git
synced 2025-08-03 22:43:15 +02:00
hide tablet by making it not visible rather than destroying it
This commit is contained in:
parent
aa4cbe2892
commit
371c20ee25
2 changed files with 101 additions and 19 deletions
|
@ -45,6 +45,10 @@ function calcSpawnInfo(hand, height) {
|
|||
var headPos = (HMD.active && Camera.mode === "first person") ? HMD.position : Camera.position;
|
||||
var headRot = (HMD.active && Camera.mode === "first person") ? HMD.orientation : Camera.orientation;
|
||||
|
||||
if (!hand) {
|
||||
hand = NO_HANDS;
|
||||
}
|
||||
|
||||
if (HMD.active && hand !== NO_HANDS) {
|
||||
var handController = getControllerWorldLocation(hand, true);
|
||||
var controllerPosition = handController.position;
|
||||
|
@ -96,7 +100,7 @@ function calcSpawnInfo(hand, height) {
|
|||
* @param hand [number] -1 indicates no hand, Controller.Standard.RightHand or Controller.Standard.LeftHand
|
||||
* @param clientOnly [bool] true indicates tablet model is only visible to client.
|
||||
*/
|
||||
WebTablet = function (url, width, dpi, hand, clientOnly) {
|
||||
WebTablet = function (url, width, dpi, hand, clientOnly, location, invisisble) {
|
||||
|
||||
var _this = this;
|
||||
|
||||
|
@ -129,11 +133,16 @@ WebTablet = function (url, width, dpi, hand, clientOnly) {
|
|||
"grabbableKey": {"grabbable": true}
|
||||
}),
|
||||
dimensions: {x: this.width, y: this.height, z: this.depth},
|
||||
parentID: AVATAR_SELF_ID
|
||||
parentID: AVATAR_SELF_ID,
|
||||
visible: !invisisble
|
||||
};
|
||||
|
||||
// compute position, rotation & parentJointIndex of the tablet
|
||||
this.calculateTabletAttachmentProperties(hand, true, tabletProperties);
|
||||
if (location) {
|
||||
tabletProperties.localPosition = location.localPosition;
|
||||
tabletProperties.localRotation = location.localRotation;
|
||||
}
|
||||
|
||||
this.cleanUpOldTablets();
|
||||
|
||||
|
@ -164,7 +173,8 @@ WebTablet = function (url, width, dpi, hand, clientOnly) {
|
|||
parentID: this.tabletEntityID,
|
||||
parentJointIndex: -1,
|
||||
showKeyboardFocusHighlight: false,
|
||||
isAA: HMD.active
|
||||
isAA: HMD.active,
|
||||
visible: !invisisble
|
||||
});
|
||||
|
||||
var HOME_BUTTON_Y_OFFSET = (this.height / 2) - 0.009;
|
||||
|
@ -177,7 +187,8 @@ WebTablet = function (url, width, dpi, hand, clientOnly) {
|
|||
visible: true,
|
||||
drawInFront: false,
|
||||
parentID: this.tabletEntityID,
|
||||
parentJointIndex: -1
|
||||
parentJointIndex: -1,
|
||||
visible: !invisisble
|
||||
});
|
||||
|
||||
this.receive = function (channel, senderID, senderUUID, localOnly) {
|
||||
|
|
|
@ -12,21 +12,22 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
/* global Script, HMD, WebTablet, UIWebTablet, UserActivityLogger, Settings, Entities, Messages, Tablet, Overlays, MyAvatar */
|
||||
/* global Script, HMD, WebTablet, UIWebTablet, UserActivityLogger, Settings, Entities, Messages, Tablet, Overlays,
|
||||
MyAvatar, Menu, Vec3 */
|
||||
|
||||
(function() { // BEGIN LOCAL_SCOPE
|
||||
var tabletShown = false;
|
||||
var tabletRezzed = false;
|
||||
var tabletLocation = null;
|
||||
var activeHand = null;
|
||||
var DEFAULT_WIDTH = 0.4375;
|
||||
var DEFAULT_TABLET_SCALE = 100;
|
||||
UIWebTablet = null;
|
||||
|
||||
Script.include("../libraries/WebTablet.js");
|
||||
|
||||
function showTabletUI() {
|
||||
tabletShown = true;
|
||||
print("show tablet-ui");
|
||||
|
||||
var DEFAULT_WIDTH = 0.4375;
|
||||
var DEFAULT_TABLET_SCALE = 100;
|
||||
function rezTablet(invisible) {
|
||||
print("XXX show tablet-ui, not rezzed. position is " + JSON.stringify(tabletLocation));
|
||||
var toolbarMode = Tablet.getTablet("com.highfidelity.interface.tablet.system").toolbarMode;
|
||||
var TABLET_SCALE = DEFAULT_TABLET_SCALE;
|
||||
if (toolbarMode) {
|
||||
|
@ -34,37 +35,88 @@
|
|||
} else {
|
||||
TABLET_SCALE = Settings.getValue("hmdTabletScale") || DEFAULT_TABLET_SCALE;
|
||||
}
|
||||
UIWebTablet = new WebTablet("qml/hifi/tablet/TabletRoot.qml", DEFAULT_WIDTH * (TABLET_SCALE / 100), null, activeHand, true);
|
||||
|
||||
UIWebTablet = new WebTablet("qml/hifi/tablet/TabletRoot.qml",
|
||||
DEFAULT_WIDTH * (TABLET_SCALE / 100),
|
||||
null, activeHand, true, tabletLocation, invisible);
|
||||
UIWebTablet.register();
|
||||
HMD.tabletID = UIWebTablet.tabletEntityID;
|
||||
HMD.homeButtonID = UIWebTablet.homeButtonID;
|
||||
HMD.tabletScreenID = UIWebTablet.webOverlayID;
|
||||
tabletRezzed = true;
|
||||
}
|
||||
|
||||
function showTabletUI() {
|
||||
tabletShown = true;
|
||||
|
||||
if (!tabletRezzed) {
|
||||
rezTablet(false);
|
||||
}
|
||||
|
||||
if (UIWebTablet && tabletRezzed) {
|
||||
if (tabletLocation) {
|
||||
print("XXX show tablet-ui, already rezzed, already position: " + JSON.stringify(tabletLocation));
|
||||
Overlays.editOverlay(HMD.tabletID, {
|
||||
localPosition: tabletLocation.localPosition,
|
||||
localRotation: tabletLocation.localRotation,
|
||||
visible: true
|
||||
});
|
||||
} else {
|
||||
print("XXX show tablet-ui, already rezzed, no position");
|
||||
var tabletProperties = {};
|
||||
UIWebTablet.calculateTabletAttachmentProperties(activeHand, true, tabletProperties);
|
||||
tabletProperties.visible = true;
|
||||
Overlays.editOverlay(HMD.tabletID, tabletProperties);
|
||||
}
|
||||
Overlays.editOverlay(HMD.homeButtonID, { visible: true });
|
||||
Overlays.editOverlay(HMD.tabletScreenID, { visible: true });
|
||||
}
|
||||
}
|
||||
|
||||
function hideTabletUI() {
|
||||
tabletShown = false;
|
||||
print("hide tablet-ui");
|
||||
if (UIWebTablet) {
|
||||
tabletLocation = UIWebTablet.getLocation();
|
||||
print("XXX hide tablet-ui, position was " + JSON.stringify(tabletLocation));
|
||||
// Overlays.editOverlay(HMD.tabletID, { localPosition: { x: -1000, y: 0, z:0 } });
|
||||
Overlays.editOverlay(HMD.tabletID, { visible: false });
|
||||
Overlays.editOverlay(HMD.homeButtonID, { visible: false });
|
||||
Overlays.editOverlay(HMD.tabletScreenID, { visible: false });
|
||||
} else {
|
||||
print("XXX hide tablet-ui, UIWebTablet is null");
|
||||
}
|
||||
}
|
||||
|
||||
function closeTabletUI() {
|
||||
tabletShown = false;
|
||||
if (UIWebTablet) {
|
||||
if (UIWebTablet.onClose) {
|
||||
UIWebTablet.onClose();
|
||||
}
|
||||
|
||||
tabletLocation = UIWebTablet.getLocation();
|
||||
print("XXX close tablet-ui, position was " + JSON.stringify(tabletLocation));
|
||||
UIWebTablet.unregister();
|
||||
UIWebTablet.destroy();
|
||||
UIWebTablet = null;
|
||||
HMD.tabletID = null;
|
||||
HMD.homeButtonID = null;
|
||||
HMD.tabletScreenID = null;
|
||||
} else {
|
||||
print("XXX close tablet-ui, UIWebTablet is null");
|
||||
}
|
||||
tabletRezzed = false;
|
||||
}
|
||||
|
||||
|
||||
function updateShowTablet() {
|
||||
|
||||
// close the WebTablet if it we go into toolbar mode.
|
||||
var toolbarMode = Tablet.getTablet("com.highfidelity.interface.tablet.system").toolbarMode;
|
||||
var visibleToOthers = Settings.getValue("tabletVisibleToOthers");
|
||||
|
||||
if (tabletShown && toolbarMode) {
|
||||
hideTabletUI();
|
||||
closeTabletUI();
|
||||
HMD.closeTablet();
|
||||
return;
|
||||
}
|
||||
|
@ -78,18 +130,37 @@
|
|||
tablet.updateAudioBar(currentMicLevel);
|
||||
}
|
||||
|
||||
if (tabletShown && UIWebTablet && Overlays.getOverlayType(UIWebTablet.webOverlayID) != "web3d") {
|
||||
// XXX don't do this check every time?
|
||||
if (tabletRezzed && UIWebTablet && Overlays.getOverlayType(UIWebTablet.webOverlayID) != "web3d") {
|
||||
// when we switch domains, the tablet entity gets destroyed and recreated. this causes
|
||||
// the overlay to be deleted, but not recreated. If the overlay is deleted for this or any
|
||||
// other reason, close the tablet.
|
||||
hideTabletUI();
|
||||
closeTabletUI();
|
||||
HMD.closeTablet();
|
||||
} else if (HMD.showTablet && !tabletShown && !toolbarMode) {
|
||||
UserActivityLogger.openedTablet(Settings.getValue("tabletVisibleToOthers"));
|
||||
print("XXX autodestroying tablet");
|
||||
}
|
||||
|
||||
|
||||
if (HMD.showTablet && !tabletShown && !toolbarMode) {
|
||||
UserActivityLogger.openedTablet(visibleToOthers);
|
||||
showTabletUI();
|
||||
} else if (!HMD.showTablet && tabletShown) {
|
||||
UserActivityLogger.closedTablet();
|
||||
hideTabletUI();
|
||||
if (visibleToOthers) {
|
||||
closeTabletUI();
|
||||
} else {
|
||||
hideTabletUI();
|
||||
}
|
||||
} else if (!toolbarMode && !visibleToOthers && !tabletRezzed) {
|
||||
// pre-make the tablet so it will appear quickly
|
||||
tabletLocation = {
|
||||
localPosition: Vec3.sum(MyAvatar.position, { x: -1000, y: 0, z: 0 }),
|
||||
localRotation: { x: 0, y: 0, z: 0, w: 1 }
|
||||
};
|
||||
print("XXX pre-creating tablet at " + JSON.stringify(tabletLocation));
|
||||
rezTablet(true);
|
||||
tabletLocation = null;
|
||||
tabletShown = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue