mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 12:04:18 +02:00
Merge pull request #9297 from druiz17/homeBug
home button fix and tablet updates
This commit is contained in:
commit
d85ecc2b79
5 changed files with 39 additions and 27 deletions
|
@ -44,7 +44,7 @@ void TabletScriptingInterface::setQmlTabletRoot(QString tabletId, QQuickItem* qm
|
|||
|
||||
static const char* TABLET_SOURCE_URL = "Tablet.qml";
|
||||
static const char* WEB_VIEW_SOURCE_URL = "TabletWebView.qml";
|
||||
static const char* LOADER_SOURCE_PROPERTY_NAME = "loaderSource";
|
||||
static const char* LOADER_SOURCE_PROPERTY_NAME = "LoaderSource";
|
||||
|
||||
TabletProxy::TabletProxy(QString name) : _name(name) {
|
||||
;
|
||||
|
@ -88,8 +88,10 @@ void TabletProxy::gotoHomeScreen() {
|
|||
if (_qmlTabletRoot) {
|
||||
QString tabletSource = _qmlTabletRoot->property(LOADER_SOURCE_PROPERTY_NAME).toString();
|
||||
if (tabletSource != TABLET_SOURCE_URL) {
|
||||
_qmlTabletRoot->setProperty(LOADER_SOURCE_PROPERTY_NAME, TABLET_SOURCE_URL);
|
||||
auto loader = _qmlTabletRoot->findChild<QQuickItem*>("loader");
|
||||
QObject::connect(loader, SIGNAL(loaded()), this, SLOT(addButtonsToHomeScreen()));
|
||||
QMetaObject::invokeMethod(_qmlTabletRoot, "loadSource", Q_ARG(const QVariant&, QVariant(TABLET_SOURCE_URL)));
|
||||
addButtonsToHomeScreen();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -99,6 +101,7 @@ void TabletProxy::gotoWebScreen(const QString& url) {
|
|||
removeButtonsFromHomeScreen();
|
||||
QString tabletSource = _qmlTabletRoot->property(LOADER_SOURCE_PROPERTY_NAME).toString();
|
||||
if (tabletSource != WEB_VIEW_SOURCE_URL) {
|
||||
_qmlTabletRoot->setProperty(LOADER_SOURCE_PROPERTY_NAME, WEB_VIEW_SOURCE_URL);
|
||||
QMetaObject::invokeMethod(_qmlTabletRoot, "loadSource", Q_ARG(const QVariant&, QVariant(WEB_VIEW_SOURCE_URL)));
|
||||
// TABLET_UI_HACK: TODO: addEventBridge to tablet....
|
||||
}
|
||||
|
@ -168,6 +171,8 @@ void TabletProxy::addButtonsToHomeScreen() {
|
|||
for (auto& buttonProxy : _tabletButtonProxies) {
|
||||
addButtonProxyToQmlTablet(tablet, buttonProxy.data());
|
||||
}
|
||||
auto loader = _qmlTabletRoot->findChild<QQuickItem*>("loader");
|
||||
QObject::disconnect(loader, SIGNAL(loaded()), this, SLOT(addButtonsToHomeScreen()));
|
||||
}
|
||||
|
||||
void TabletProxy::removeButtonsFromHomeScreen() {
|
||||
|
|
|
@ -109,9 +109,9 @@ signals:
|
|||
*/
|
||||
void webEventReceived(QVariant msg);
|
||||
|
||||
protected:
|
||||
|
||||
private slots:
|
||||
void addButtonsToHomeScreen();
|
||||
protected:
|
||||
void removeButtonsFromHomeScreen();
|
||||
QQuickItem* getQmlTablet() const;
|
||||
|
||||
|
|
|
@ -437,12 +437,14 @@ clickMapping.from(function () { return wantsMenu; }).to(Controller.Actions.Conte
|
|||
clickMapping.from(Controller.Standard.RightSecondaryThumb).peek().to(function (clicked) {
|
||||
if (clicked) {
|
||||
activeHudPoint2d(Controller.Standard.RightHand);
|
||||
Messages.sendLocalMessage("toggleHand", Controller.Standard.RightHand);
|
||||
}
|
||||
wantsMenu = clicked;
|
||||
});
|
||||
clickMapping.from(Controller.Standard.LeftSecondaryThumb).peek().to(function (clicked) {
|
||||
if (clicked) {
|
||||
activeHudPoint2d(Controller.Standard.LeftHand);
|
||||
Messages.sendLocalMessage("toggleHand", Controller.Standard.LeftHand);
|
||||
}
|
||||
wantsMenu = clicked;
|
||||
});
|
||||
|
|
|
@ -10,28 +10,31 @@
|
|||
|
||||
|
||||
Script.include(Script.resolvePath("../libraries/utils.js"));
|
||||
Script.include(Script.resolvePath("../libraries/controllers.js"));
|
||||
var RAD_TO_DEG = 180 / Math.PI;
|
||||
var X_AXIS = {x: 1, y: 0, z: 0};
|
||||
var Y_AXIS = {x: 0, y: 1, z: 0};
|
||||
var DEFAULT_DPI = 30;
|
||||
var DEFAULT_WIDTH = 0.5;
|
||||
var DEFAULT_DPI = 32;
|
||||
var DEFAULT_WIDTH = 0.43;
|
||||
|
||||
var TABLET_URL = "https://s3.amazonaws.com/hifi-public/tony/tablet.fbx";
|
||||
var TABLET_URL = "http://hifi-content.s3.amazonaws.com/alan/dev/Tablet-Model-v1-x.fbx";
|
||||
// returns object with two fields:
|
||||
// * position - position in front of the user
|
||||
// * rotation - rotation of entity so it faces the user.
|
||||
function calcSpawnInfo() {
|
||||
var front;
|
||||
function calcSpawnInfo(hand) {
|
||||
var pitchBackRotation = Quat.angleAxis(20.0, X_AXIS);
|
||||
if (HMD.active) {
|
||||
front = Quat.getFront(HMD.orientation);
|
||||
var yawOnlyRotation = Quat.angleAxis(Math.atan2(front.x, front.z) * RAD_TO_DEG, Y_AXIS);
|
||||
var handController = getControllerWorldLocation(hand, false);
|
||||
var front = Quat.getFront(handController.orientation);
|
||||
var up = Quat.getUp(handController.orientation);
|
||||
var frontOffset = Vec3.sum(handController.position, Vec3.multiply(0.4, up));
|
||||
var finalOffset = Vec3.sum(frontOffset, Vec3.multiply(-0.3, front));
|
||||
return {
|
||||
position: Vec3.sum(Vec3.sum(HMD.position, Vec3.multiply(0.6, front)), Vec3.multiply(-0.5, Y_AXIS)),
|
||||
rotation: Quat.multiply(yawOnlyRotation, pitchBackRotation)
|
||||
position: finalOffset,
|
||||
rotation: Quat.lookAt(finalOffset, HMD.position, Y_AXIS)
|
||||
};
|
||||
} else {
|
||||
front = Quat.getFront(MyAvatar.orientation);
|
||||
var front = Quat.getFront(MyAvatar.orientation);
|
||||
return {
|
||||
position: Vec3.sum(Vec3.sum(MyAvatar.position, Vec3.multiply(0.6, front)), {x: 0, y: 0.6, z: 0}),
|
||||
rotation: Quat.multiply(MyAvatar.orientation, pitchBackRotation)
|
||||
|
@ -40,18 +43,18 @@ function calcSpawnInfo() {
|
|||
}
|
||||
|
||||
// ctor
|
||||
WebTablet = function (url, width, dpi, location, clientOnly) {
|
||||
WebTablet = function (url, width, dpi, hand, clientOnly) {
|
||||
|
||||
var _this = this;
|
||||
var ASPECT = 4.0 / 3.0;
|
||||
var WIDTH = width || DEFAULT_WIDTH;
|
||||
var TABLET_HEIGHT_SCALE = 640 / 680; // Screen size of tablet entity isn't quite the desired aspect.
|
||||
var TABLET_HEIGHT_SCALE = 650 / 680; // Screen size of tablet entity isn't quite the desired aspect.
|
||||
var HEIGHT = WIDTH * ASPECT * TABLET_HEIGHT_SCALE;
|
||||
var DEPTH = 0.025;
|
||||
var DPI = dpi || DEFAULT_DPI;
|
||||
var SENSOR_TO_ROOM_MATRIX = -2;
|
||||
|
||||
var spawnInfo = calcSpawnInfo();
|
||||
var spawnInfo = calcSpawnInfo(hand);
|
||||
var tabletEntityPosition = spawnInfo.position;
|
||||
var tabletEntityRotation = spawnInfo.rotation;
|
||||
|
||||
|
@ -67,14 +70,8 @@ WebTablet = function (url, width, dpi, location, clientOnly) {
|
|||
parentJointIndex: SENSOR_TO_ROOM_MATRIX
|
||||
}
|
||||
|
||||
if (location) {
|
||||
tabletProperties.localPosition = location.localPosition;
|
||||
tabletProperties.localRotation = location.localRotation;
|
||||
} else {
|
||||
var spawnInfo = calcSpawnInfo();
|
||||
tabletProperties.position = spawnInfo.position;
|
||||
tabletProperties.rotation = spawnInfo.rotation;
|
||||
}
|
||||
tabletProperties.position = spawnInfo.position;
|
||||
tabletProperties.rotation = spawnInfo.rotation;
|
||||
|
||||
this.tabletEntityID = Entities.addEntity(tabletProperties, clientOnly);
|
||||
|
||||
|
@ -96,7 +93,7 @@ WebTablet = function (url, width, dpi, location, clientOnly) {
|
|||
parentJointIndex: -1
|
||||
});
|
||||
|
||||
var HOME_BUTTON_Y_OFFSET = -0.32;
|
||||
var HOME_BUTTON_Y_OFFSET = -0.25;
|
||||
this.homeButtonEntity = Entities.addEntity({
|
||||
name: "homeButton",
|
||||
type: "Sphere",
|
||||
|
|
|
@ -17,13 +17,14 @@
|
|||
(function() { // BEGIN LOCAL_SCOPE
|
||||
var tabletShown = false;
|
||||
var tabletLocation = null;
|
||||
var activeHand = null;
|
||||
|
||||
Script.include("../libraries/WebTablet.js");
|
||||
|
||||
function showTabletUI() {
|
||||
tabletShown = true;
|
||||
print("show tablet-ui");
|
||||
UIWebTablet = new WebTablet("qml/hifi/tablet/TabletRoot.qml", null, null, tabletLocation);
|
||||
UIWebTablet = new WebTablet("qml/hifi/tablet/TabletRoot.qml", null, null, activeHand);
|
||||
UIWebTablet.register();
|
||||
HMD.tabletID = UIWebTablet.webEntityID;
|
||||
}
|
||||
|
@ -52,6 +53,13 @@
|
|||
}
|
||||
}
|
||||
|
||||
function toggleHand(channel, hand, senderUUID, localOnly) {
|
||||
activeHand = JSON.parse(hand);
|
||||
}
|
||||
|
||||
Messages.subscribe("toggleHand");
|
||||
Messages.messageReceived.connect(toggleHand);
|
||||
|
||||
Script.update.connect(updateShowTablet);
|
||||
// Script.setInterval(updateShowTablet, 1000);
|
||||
|
||||
|
|
Loading…
Reference in a new issue