mirror of
https://github.com/overte-org/overte.git
synced 2025-07-24 01:23:55 +02:00
fix create, working on mini tablet
This commit is contained in:
parent
d988de4a17
commit
f53ccf7363
5 changed files with 43 additions and 26 deletions
|
@ -581,7 +581,15 @@ EntityItemProperties Overlays::convertOverlayToEntityProperties(QVariantMap& ove
|
||||||
{
|
{
|
||||||
auto iter = overlayProps.find("dimensions");
|
auto iter = overlayProps.find("dimensions");
|
||||||
if (iter != overlayProps.end()) {
|
if (iter != overlayProps.end()) {
|
||||||
dimensions = vec3FromVariant(iter.value());
|
bool valid = false;
|
||||||
|
dimensions = vec3FromVariant(iter.value(), valid);
|
||||||
|
if (!valid) {
|
||||||
|
dimensions = glm::vec3(vec2FromVariant(iter.value()), 0.0f);
|
||||||
|
}
|
||||||
|
} else if (!add) {
|
||||||
|
EntityPropertyFlags desiredProperties;
|
||||||
|
desiredProperties += PROP_DIMENSIONS;
|
||||||
|
dimensions = DependencyManager::get<EntityScriptingInterface>()->getEntityProperties(id, desiredProperties).getDimensions();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -452,5 +452,5 @@ QObject* WebEntityRenderer::getEventHandler() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebEntityRenderer::emitScriptEvent(const QVariant& message) {
|
void WebEntityRenderer::emitScriptEvent(const QVariant& message) {
|
||||||
QMetaObject::invokeMethod(this, "scriptEventReceived", Q_ARG(QVariant, message));
|
emit scriptEventReceived(message);
|
||||||
}
|
}
|
|
@ -716,11 +716,7 @@ void OffscreenQmlSurface::setKeyboardRaised(QObject* object, bool raised, bool n
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffscreenQmlSurface::emitScriptEvent(const QVariant& message) {
|
void OffscreenQmlSurface::emitScriptEvent(const QVariant& message) {
|
||||||
if (QThread::currentThread() != thread()) {
|
|
||||||
QMetaObject::invokeMethod(this, "emitScriptEvent", Qt::QueuedConnection, Q_ARG(QVariant, message));
|
|
||||||
} else {
|
|
||||||
emit scriptEventReceived(message);
|
emit scriptEventReceived(message);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffscreenQmlSurface::emitWebEvent(const QVariant& message) {
|
void OffscreenQmlSurface::emitWebEvent(const QVariant& message) {
|
||||||
|
|
|
@ -23,7 +23,6 @@ var SENSOR_TO_ROOM_MATRIX = -2;
|
||||||
var CAMERA_MATRIX = -7;
|
var CAMERA_MATRIX = -7;
|
||||||
var ROT_Y_180 = {x: 0.0, y: 1.0, 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 = {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 TABLET_TEXTURE_RESOLUTION = { x: 480, y: 706 };
|
var TABLET_TEXTURE_RESOLUTION = { x: 480, y: 706 };
|
||||||
var INCHES_TO_METERS = 1 / 39.3701;
|
var INCHES_TO_METERS = 1 / 39.3701;
|
||||||
|
|
||||||
|
@ -286,16 +285,19 @@ WebTablet.prototype.setLandscape = function(newLandscapeValue) {
|
||||||
|
|
||||||
this.landscape = newLandscapeValue;
|
this.landscape = newLandscapeValue;
|
||||||
var cameraOrientation = Quat.cancelOutRollAndPitch(Camera.orientation);
|
var cameraOrientation = Quat.cancelOutRollAndPitch(Camera.orientation);
|
||||||
Overlays.editOverlay(this.tabletEntityID,
|
var tabletRotation = Quat.multiply(cameraOrientation, this.landscape ? ROT_LANDSCAPE : ROT_Y_180);
|
||||||
{ rotation: Quat.multiply(cameraOrientation, this.landscape ? ROT_LANDSCAPE : ROT_Y_180) });
|
Overlays.editOverlay(this.tabletEntityID, {
|
||||||
|
rotation: tabletRotation
|
||||||
|
});
|
||||||
|
|
||||||
var tabletWidth = getTabletWidthFromSettings() * MyAvatar.sensorToWorldScale;
|
var tabletWidth = getTabletWidthFromSettings() * MyAvatar.sensorToWorldScale;
|
||||||
var tabletScaleFactor = tabletWidth / TABLET_NATURAL_DIMENSIONS.x;
|
var tabletScaleFactor = tabletWidth / TABLET_NATURAL_DIMENSIONS.x;
|
||||||
var tabletHeight = TABLET_NATURAL_DIMENSIONS.y * tabletScaleFactor;
|
var tabletHeight = TABLET_NATURAL_DIMENSIONS.y * tabletScaleFactor;
|
||||||
var screenWidth = 0.9275 * tabletWidth;
|
var screenWidth = 0.9275 * tabletWidth;
|
||||||
var screenHeight = 0.8983 * tabletHeight;
|
var screenHeight = 0.8983 * tabletHeight;
|
||||||
|
var screenRotation = Quat.angleAxis(180, Vec3.UP);
|
||||||
Overlays.editOverlay(this.webOverlayID, {
|
Overlays.editOverlay(this.webOverlayID, {
|
||||||
rotation: Quat.multiply(cameraOrientation, ROT_LANDSCAPE_WINDOW),
|
localRotation: this.landscape ? Quat.multiply(screenRotation, Quat.angleAxis(-90, Vec3.FRONT)) : screenRotation,
|
||||||
dimensions: {x: this.landscape ? screenHeight : screenWidth, y: this.landscape ? screenWidth : screenHeight, z: 0.1}
|
dimensions: {x: this.landscape ? screenHeight : screenWidth, y: this.landscape ? screenWidth : screenHeight, z: 0.1}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -114,7 +114,7 @@
|
||||||
uiHand = LEFT_HAND,
|
uiHand = LEFT_HAND,
|
||||||
miniUIOverlay = null,
|
miniUIOverlay = null,
|
||||||
MINI_UI_HTML = Script.resolvePath("./html/miniTablet.html"),
|
MINI_UI_HTML = Script.resolvePath("./html/miniTablet.html"),
|
||||||
MINI_UI_DIMENSIONS = { x: 0.059, y: 0.0865 },
|
MINI_UI_DIMENSIONS = { x: 0.059, y: 0.0865, z: 0.01 },
|
||||||
MINI_UI_WIDTH_PIXELS = 150,
|
MINI_UI_WIDTH_PIXELS = 150,
|
||||||
METERS_TO_INCHES = 39.3701,
|
METERS_TO_INCHES = 39.3701,
|
||||||
MINI_UI_DPI = MINI_UI_WIDTH_PIXELS / (MINI_UI_DIMENSIONS.x * METERS_TO_INCHES),
|
MINI_UI_DPI = MINI_UI_WIDTH_PIXELS / (MINI_UI_DIMENSIONS.x * METERS_TO_INCHES),
|
||||||
|
@ -172,19 +172,23 @@
|
||||||
|
|
||||||
function updateMutedStatus() {
|
function updateMutedStatus() {
|
||||||
var isMuted = Audio.muted;
|
var isMuted = Audio.muted;
|
||||||
|
if (miniOverlayObject) {
|
||||||
miniOverlayObject.emitScriptEvent(JSON.stringify({
|
miniOverlayObject.emitScriptEvent(JSON.stringify({
|
||||||
type: MUTE_MESSAGE,
|
type: MUTE_MESSAGE,
|
||||||
on: isMuted,
|
on: isMuted,
|
||||||
icon: isMuted ? MUTE_ON_ICON : MUTE_OFF_ICON
|
icon: isMuted ? MUTE_ON_ICON : MUTE_OFF_ICON
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function setGotoIcon() {
|
function setGotoIcon() {
|
||||||
|
if (miniOverlayObject) {
|
||||||
miniOverlayObject.emitScriptEvent(JSON.stringify({
|
miniOverlayObject.emitScriptEvent(JSON.stringify({
|
||||||
type: GOTO_MESSAGE,
|
type: GOTO_MESSAGE,
|
||||||
icon: GOTO_ICON
|
icon: GOTO_ICON
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function onWebEventReceived(data) {
|
function onWebEventReceived(data) {
|
||||||
var message;
|
var message;
|
||||||
|
@ -452,7 +456,7 @@
|
||||||
solid: true,
|
solid: true,
|
||||||
grabbable: true,
|
grabbable: true,
|
||||||
showKeyboardFocusHighlight: false,
|
showKeyboardFocusHighlight: false,
|
||||||
displayInFront: true,
|
drawInFront: true,
|
||||||
visible: false
|
visible: false
|
||||||
});
|
});
|
||||||
miniUIOverlay = Overlays.addOverlay("web3d", {
|
miniUIOverlay = Overlays.addOverlay("web3d", {
|
||||||
|
@ -465,14 +469,11 @@
|
||||||
alpha: 0, // Hide overlay while its content is being created.
|
alpha: 0, // Hide overlay while its content is being created.
|
||||||
grabbable: false,
|
grabbable: false,
|
||||||
showKeyboardFocusHighlight: false,
|
showKeyboardFocusHighlight: false,
|
||||||
displayInFront: true,
|
drawInFront: true,
|
||||||
visible: false
|
visible: false
|
||||||
});
|
});
|
||||||
|
|
||||||
miniUIOverlayEnabled = false; // This and alpha = 0 hides overlay while its content is being created.
|
miniUIOverlayEnabled = false; // This and alpha = 0 hides overlay while its content is being created.
|
||||||
|
|
||||||
miniOverlayObject = Overlays.getOverlayObject(miniUIOverlay);
|
|
||||||
miniOverlayObject.webEventReceived.connect(onWebEventReceived);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function destroy() {
|
function destroy() {
|
||||||
|
@ -978,6 +979,16 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateState() {
|
function updateState() {
|
||||||
|
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);
|
||||||
|
ui.updateMutedStatus();
|
||||||
|
ui.setGotoIcon();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (STATE_MACHINE[STATE_STRINGS[miniState]].update) {
|
if (STATE_MACHINE[STATE_STRINGS[miniState]].update) {
|
||||||
STATE_MACHINE[STATE_STRINGS[miniState]].update();
|
STATE_MACHINE[STATE_STRINGS[miniState]].update();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue