From 0f80a8b7af6991a5873fafd220fde1600f2b9d27 Mon Sep 17 00:00:00 2001 From: Vladyslav Stelmakhovskyi Date: Tue, 30 May 2017 16:51:04 +0200 Subject: [PATCH 1/3] On create button, switch Tablet to landscape mode --- scripts/system/edit.js | 6 +++++- scripts/system/tablet-ui/tabletUI.js | 8 ++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/system/edit.js b/scripts/system/edit.js index f39165f3df..79064a02df 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -564,6 +564,8 @@ var toolBar = (function () { enabled: active })); isActive = active; + var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); + if (!isActive) { entityListTool.setVisible(false); gridTool.setVisible(false); @@ -572,8 +574,8 @@ var toolBar = (function () { selectionManager.clearSelections(); cameraManager.disable(); selectionDisplay.triggerMapping.disable(); + tablet.landscape = false; } else { - var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); tablet.loadQMLSource("Edit.qml"); UserActivityLogger.enabledEdit(); entityListTool.setVisible(true); @@ -581,6 +583,8 @@ var toolBar = (function () { grid.setEnabled(true); propertiesTool.setVisible(true); selectionDisplay.triggerMapping.enable(); + print("starting tablet in landscape mode") + tablet.landscape = true; // Not sure what the following was meant to accomplish, but it currently causes // everybody else to think that Interface has lost focus overall. fogbugzid:558 // Window.setFocus(); diff --git a/scripts/system/tablet-ui/tabletUI.js b/scripts/system/tablet-ui/tabletUI.js index f83e8d9550..e45fc8d87b 100644 --- a/scripts/system/tablet-ui/tabletUI.js +++ b/scripts/system/tablet-ui/tabletUI.js @@ -191,16 +191,12 @@ gTablet.updateAudioBar(currentMicLevel); } - if (validCheckTime - now > MSECS_PER_SEC/4) { - //each 250ms should be just fine + if (now - validCheckTime > MSECS_PER_SEC) { + validCheckTime = now; updateTabletWidthFromSettings(); if (UIWebTablet) { UIWebTablet.setLandscape(landscape); } - } - - if (validCheckTime - now > MSECS_PER_SEC) { - validCheckTime = now; if (tabletRezzed && UIWebTablet && !tabletIsValid()) { // 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 From b0e4b752d5c58208b2a8d0028177727d3a70af69 Mon Sep 17 00:00:00 2001 From: Vladyslav Stelmakhovskyi Date: Thu, 1 Jun 2017 19:07:17 +0200 Subject: [PATCH 2/3] Implements landscape mode for tablet as rotation instead of stretching --- scripts/system/libraries/WebTablet.js | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/scripts/system/libraries/WebTablet.js b/scripts/system/libraries/WebTablet.js index 757743accc..7545575127 100644 --- a/scripts/system/libraries/WebTablet.js +++ b/scripts/system/libraries/WebTablet.js @@ -22,7 +22,9 @@ var DEFAULT_WIDTH = 0.4375; var DEFAULT_VERTICAL_FIELD_OF_VIEW = 45; // degrees var SENSOR_TO_ROOM_MATRIX = -2; var CAMERA_MATRIX = -7; -var ROT_Y_180 = {x: 0, y: 1, z: 0, w: 0}; +var ROT_Y_180 = {x: 0.0, y: 1.0, z: 0, w: 0}; +var ROT_LANDSCAPE = {x: 1.0, y: 1.0, z: 0, w: 0}; +var ROT_LANDSCAPE_WINDOW = {x: 0.0, y: 0.0, z: 0.0, w: 0}; var ROT_IDENT = {x: 0, y: 0, z: 0, w: 1}; var TABLET_TEXTURE_RESOLUTION = { x: 480, y: 706 }; var INCHES_TO_METERS = 1 / 39.3701; @@ -243,29 +245,30 @@ WebTablet = function (url, width, dpi, hand, clientOnly, location, visible) { }; WebTablet.prototype.getDimensions = function() { - if (this.landscape) { - return { x: this.width * 2, y: this.height, z: this.depth }; - } else { - return { x: this.width, y: this.height, z: this.depth }; - } + return { x: this.width, y: this.height, z: this.depth }; }; WebTablet.prototype.getTabletTextureResolution = function() { if (this.landscape) { - return { x: TABLET_TEXTURE_RESOLUTION.x * 2, y: TABLET_TEXTURE_RESOLUTION.y }; + return { x: TABLET_TEXTURE_RESOLUTION.y , y: TABLET_TEXTURE_RESOLUTION.x }; } else { return TABLET_TEXTURE_RESOLUTION; } }; WebTablet.prototype.setLandscape = function(newLandscapeValue) { - if (this.landscape == newLandscapeValue) { + if (this.landscape === newLandscapeValue) { return; } + + var tabletProperties = {}; + tabletProperties.visible = true; this.landscape = newLandscapeValue; - Overlays.editOverlay(this.tabletEntityID, { dimensions: this.getDimensions() }); + this.calculateTabletAttachmentProperties(NO_HANDS, false, tabletProperties); + Overlays.editOverlay(this.tabletEntityID, tabletProperties); Overlays.editOverlay(this.webOverlayID, { - resolution: this.getTabletTextureResolution() + resolution: this.getTabletTextureResolution(), + rotation: Quat.multiply(Camera.orientation, ROT_LANDSCAPE_WINDOW) }); }; @@ -407,7 +410,7 @@ WebTablet.prototype.calculateWorldAttitudeRelativeToCamera = function (windowPos return { position: worldMousePosition, - rotation: Quat.multiply(Camera.orientation, ROT_Y_180) + rotation: this.landscape ? Quat.multiply(Camera.orientation, ROT_LANDSCAPE) : Quat.multiply(Camera.orientation, ROT_Y_180) }; }; From 8068e7201d764986b4633ae1148610d45c02db3d Mon Sep 17 00:00:00 2001 From: Vladyslav Stelmakhovskyi Date: Fri, 2 Jun 2017 18:58:18 +0200 Subject: [PATCH 3/3] Fix position after rotation. May be fix rotation in HMD mode --- scripts/system/libraries/WebTablet.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/scripts/system/libraries/WebTablet.js b/scripts/system/libraries/WebTablet.js index 7545575127..8c3f5d03bb 100644 --- a/scripts/system/libraries/WebTablet.js +++ b/scripts/system/libraries/WebTablet.js @@ -261,11 +261,10 @@ WebTablet.prototype.setLandscape = function(newLandscapeValue) { return; } - var tabletProperties = {}; - tabletProperties.visible = true; this.landscape = newLandscapeValue; - this.calculateTabletAttachmentProperties(NO_HANDS, false, tabletProperties); - Overlays.editOverlay(this.tabletEntityID, tabletProperties); + Overlays.editOverlay(this.tabletEntityID, + { rotation: this.landscape ? Quat.multiply(Camera.orientation, ROT_LANDSCAPE) : + Quat.multiply(Camera.orientation, ROT_Y_180) }); Overlays.editOverlay(this.webOverlayID, { resolution: this.getTabletTextureResolution(), rotation: Quat.multiply(Camera.orientation, ROT_LANDSCAPE_WINDOW)