mirror of
https://github.com/lubosz/overte.git
synced 2025-04-16 09:46:29 +02:00
ctrlaltdavid's minitablet fix
This commit is contained in:
parent
a9767e4c22
commit
b418e43ef2
2 changed files with 23 additions and 23 deletions
|
@ -61,11 +61,6 @@
|
|||
}
|
||||
|
||||
switch (message.type) {
|
||||
case READY_MESSAGE:
|
||||
EventBridge.emitWebEvent(JSON.stringify({
|
||||
type: READY_MESSAGE
|
||||
}));
|
||||
break;
|
||||
case MUTE_MESSAGE:
|
||||
muteImage.src = message.icon;
|
||||
break;
|
||||
|
@ -119,6 +114,9 @@
|
|||
|
||||
function connectEventBridge() {
|
||||
EventBridge.scriptEventReceived.connect(onScriptEventReceived);
|
||||
EventBridge.emitWebEvent(JSON.stringify({
|
||||
type: READY_MESSAGE
|
||||
}));
|
||||
}
|
||||
|
||||
function disconnectEventBridge() {
|
||||
|
|
|
@ -114,7 +114,7 @@
|
|||
uiHand = LEFT_HAND,
|
||||
miniUIOverlay = null,
|
||||
MINI_UI_HTML = Script.resolvePath("./html/miniTablet.html"),
|
||||
MINI_UI_DIMENSIONS = { x: 0.059, y: 0.0865, z: 0.01 },
|
||||
MINI_UI_DIMENSIONS = { x: 0.059, y: 0.0865, z: 0.001 },
|
||||
MINI_UI_WIDTH_PIXELS = 150,
|
||||
METERS_TO_INCHES = 39.3701,
|
||||
MINI_UI_DPI = MINI_UI_WIDTH_PIXELS / (MINI_UI_DIMENSIONS.x * METERS_TO_INCHES),
|
||||
|
@ -124,7 +124,6 @@
|
|||
miniUIOverlayEnabled = false,
|
||||
MINI_UI_OVERLAY_ENABLED_DELAY = 500,
|
||||
miniOverlayObject = null,
|
||||
isReady = false,
|
||||
|
||||
// Button icons.
|
||||
MUTE_ON_ICON = Script.resourcesPath() + "icons/tablet-icons/mic-mute-a.svg",
|
||||
|
@ -172,8 +171,8 @@
|
|||
|
||||
|
||||
function updateMutedStatus() {
|
||||
var isMuted = Audio.muted;
|
||||
if (miniOverlayObject) {
|
||||
var isMuted = Audio.muted;
|
||||
miniOverlayObject.emitScriptEvent(JSON.stringify({
|
||||
type: MUTE_MESSAGE,
|
||||
on: isMuted,
|
||||
|
@ -204,7 +203,6 @@
|
|||
switch (message.type) {
|
||||
case READY_MESSAGE:
|
||||
// Send initial button statuses.
|
||||
isReady = true;
|
||||
updateMutedStatus();
|
||||
setGotoIcon();
|
||||
break;
|
||||
|
@ -451,6 +449,19 @@
|
|||
});
|
||||
}
|
||||
|
||||
function checkEventBridge() {
|
||||
// The miniUIOverlay overlay's overlay object is not available immediately the overlay is created so we have to
|
||||
// provide a means to check for and connect it when it does become available.
|
||||
if (miniOverlayObject) {
|
||||
return;
|
||||
}
|
||||
|
||||
miniOverlayObject = Overlays.getOverlayObject(miniUIOverlay);
|
||||
if (miniOverlayObject) {
|
||||
miniOverlayObject.webEventReceived.connect(onWebEventReceived);
|
||||
}
|
||||
}
|
||||
|
||||
function create() {
|
||||
miniOverlay = Overlays.addOverlay("model", {
|
||||
url: MINI_MODEL,
|
||||
|
@ -476,6 +487,8 @@
|
|||
});
|
||||
|
||||
miniUIOverlayEnabled = false; // This and alpha = 0 hides overlay while its content is being created.
|
||||
|
||||
checkEventBridge();
|
||||
}
|
||||
|
||||
function destroy() {
|
||||
|
@ -505,6 +518,7 @@
|
|||
updateRotation: updateRotation,
|
||||
release: release,
|
||||
hide: hide,
|
||||
checkEventBridge: checkEventBridge,
|
||||
destroy: destroy
|
||||
};
|
||||
|
||||
|
@ -981,19 +995,7 @@
|
|||
}
|
||||
|
||||
function updateState() {
|
||||
if (!ui.isReady) {
|
||||
if (!ui.miniOverlayObject) {
|
||||
// Keep trying to connect the event bridge until we succeed
|
||||
ui.miniOverlayObject = Overlays.getOverlayObject(ui.miniUIOverlay);
|
||||
if (ui.miniOverlayObject) {
|
||||
ui.miniOverlayObject.webEventReceived.connect(ui.onWebEventReceived);
|
||||
}
|
||||
} else {
|
||||
ui.miniOverlayObject.emitScriptEvent(JSON.stringify({
|
||||
type: READY_MESSAGE
|
||||
}));
|
||||
}
|
||||
}
|
||||
ui.checkEventBridge();
|
||||
|
||||
if (STATE_MACHINE[STATE_STRINGS[miniState]].update) {
|
||||
STATE_MACHINE[STATE_STRINGS[miniState]].update();
|
||||
|
@ -1142,4 +1144,4 @@
|
|||
setUp();
|
||||
Script.scriptEnding.connect(tearDown);
|
||||
|
||||
}());
|
||||
}());
|
Loading…
Reference in a new issue