mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-05-08 22:28:20 +02:00
fixed merge conflicts from Howard's webview fix
This commit is contained in:
commit
d16ef521f4
5 changed files with 118 additions and 74 deletions
|
@ -29,7 +29,7 @@ Rectangle {
|
||||||
property int statusBarHeight: 50
|
property int statusBarHeight: 50
|
||||||
property int statusMargin: 50
|
property int statusMargin: 50
|
||||||
|
|
||||||
Controls.WebView {
|
Controls.BaseWebView {
|
||||||
id: webview
|
id: webview
|
||||||
url: currentUrl
|
url: currentUrl
|
||||||
anchors.top: marketplace.top
|
anchors.top: marketplace.top
|
||||||
|
|
68
interface/resources/qml/controls-uit/BaseWebView.qml
Normal file
68
interface/resources/qml/controls-uit/BaseWebView.qml
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
//
|
||||||
|
// WebView.qml
|
||||||
|
//
|
||||||
|
// Created by Bradley Austin Davis on 12 Jan 2016
|
||||||
|
// Copyright 2016 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
import QtQuick 2.5
|
||||||
|
import QtWebEngine 1.1
|
||||||
|
|
||||||
|
WebEngineView {
|
||||||
|
id: root
|
||||||
|
property var newUrl;
|
||||||
|
|
||||||
|
profile.httpUserAgent: "Mozilla/5.0 Chrome/38.0 (HighFidelityInterface)"
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
console.log("Connecting JS messaging to Hifi Logging")
|
||||||
|
// Ensure the JS from the web-engine makes it to our logging
|
||||||
|
root.javaScriptConsoleMessage.connect(function(level, message, lineNumber, sourceID) {
|
||||||
|
console.log("Web Window JS message: " + sourceID + " " + lineNumber + " " + message);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// FIXME hack to get the URL with the auth token included. Remove when we move to Qt 5.6
|
||||||
|
Timer {
|
||||||
|
id: urlReplacementTimer
|
||||||
|
running: false
|
||||||
|
repeat: false
|
||||||
|
interval: 50
|
||||||
|
onTriggered: url = newUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
onUrlChanged: {
|
||||||
|
var originalUrl = url.toString();
|
||||||
|
newUrl = urlHandler.fixupUrl(originalUrl).toString();
|
||||||
|
if (newUrl !== originalUrl) {
|
||||||
|
root.stop();
|
||||||
|
if (urlReplacementTimer.running) {
|
||||||
|
console.warn("Replacement timer already running");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
urlReplacementTimer.start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onLoadingChanged: {
|
||||||
|
// Required to support clicking on "hifi://" links
|
||||||
|
if (WebEngineView.LoadStartedStatus == loadRequest.status) {
|
||||||
|
var url = loadRequest.url.toString();
|
||||||
|
if (urlHandler.canHandleUrl(url)) {
|
||||||
|
if (urlHandler.handleUrl(url)) {
|
||||||
|
root.stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// This breaks the webchannel used for passing messages. Fixed in Qt 5.6
|
||||||
|
// See https://bugreports.qt.io/browse/QTBUG-49521
|
||||||
|
//profile: desktop.browserProfile
|
||||||
|
}
|
|
@ -9,68 +9,12 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
import QtQuick 2.5
|
import QtQuick 2.5
|
||||||
import QtWebEngine 1.1
|
import "."
|
||||||
|
|
||||||
WebEngineView {
|
BaseWebView {
|
||||||
id: root
|
|
||||||
property var newUrl;
|
|
||||||
|
|
||||||
profile.httpUserAgent: "Mozilla/5.0 Chrome/38.0 (HighFidelityInterface)"
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
|
||||||
console.log("Connecting JS messaging to Hifi Logging")
|
|
||||||
// Ensure the JS from the web-engine makes it to our logging
|
|
||||||
root.javaScriptConsoleMessage.connect(function(level, message, lineNumber, sourceID) {
|
|
||||||
console.log("Web Window JS message: " + sourceID + " " + lineNumber + " " + message);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// FIXME hack to get the URL with the auth token included. Remove when we move to Qt 5.6
|
|
||||||
Timer {
|
|
||||||
id: urlReplacementTimer
|
|
||||||
running: false
|
|
||||||
repeat: false
|
|
||||||
interval: 50
|
|
||||||
onTriggered: url = newUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
onUrlChanged: {
|
|
||||||
var originalUrl = url.toString();
|
|
||||||
newUrl = urlHandler.fixupUrl(originalUrl).toString();
|
|
||||||
if (newUrl !== originalUrl) {
|
|
||||||
root.stop();
|
|
||||||
if (urlReplacementTimer.running) {
|
|
||||||
console.warn("Replacement timer already running");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
urlReplacementTimer.start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onLoadingChanged: {
|
|
||||||
// Required to support clicking on "hifi://" links
|
|
||||||
if (WebEngineView.LoadStartedStatus == loadRequest.status) {
|
|
||||||
var url = loadRequest.url.toString();
|
|
||||||
if (urlHandler.canHandleUrl(url)) {
|
|
||||||
if (urlHandler.handleUrl(url)) {
|
|
||||||
root.stop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
property var newWindowHook: function (component, newWindow, request) { }; // override if you need to
|
|
||||||
onNewViewRequested: {
|
onNewViewRequested: {
|
||||||
var component = Qt.createComponent("../Browser.qml");
|
var component = Qt.createComponent("../Browser.qml");
|
||||||
var newWindow = component.createObject(desktop);
|
var newWindow = component.createObject(desktop);
|
||||||
request.openIn(newWindow.webView)
|
request.openIn(newWindow.webView)
|
||||||
newWindowHook(component, newWindow, request);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// This breaks the webchannel used for passing messages. Fixed in Qt 5.6
|
|
||||||
// See https://bugreports.qt.io/browse/QTBUG-49521
|
|
||||||
//profile: desktop.browserProfile
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,17 +140,35 @@ QVariant parseBinaryFBXProperty(QDataStream& in, int& position) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FBXNode parseBinaryFBXNode(QDataStream& in, int& position) {
|
FBXNode parseBinaryFBXNode(QDataStream& in, int& position, bool has64BitPositions = false) {
|
||||||
qint32 endOffset;
|
qint64 endOffset;
|
||||||
quint32 propertyCount;
|
quint64 propertyCount;
|
||||||
quint32 propertyListLength;
|
quint64 propertyListLength;
|
||||||
quint8 nameLength;
|
quint8 nameLength;
|
||||||
|
|
||||||
|
// FBX 2016 and beyond uses 64bit positions in the node headers, pre-2016 used 32bit values
|
||||||
|
// our code generally doesn't care about the size that much, so we will use 64bit values
|
||||||
|
// from here on out, but if the file is an older format we read the stream into temp 32bit
|
||||||
|
// values and then assign to our actual 64bit values.
|
||||||
|
if (has64BitPositions) {
|
||||||
in >> endOffset;
|
in >> endOffset;
|
||||||
in >> propertyCount;
|
in >> propertyCount;
|
||||||
in >> propertyListLength;
|
in >> propertyListLength;
|
||||||
|
position += sizeof(quint64) * 3;
|
||||||
|
} else {
|
||||||
|
qint32 tempEndOffset;
|
||||||
|
quint32 tempPropertyCount;
|
||||||
|
quint32 tempPropertyListLength;
|
||||||
|
in >> tempEndOffset;
|
||||||
|
in >> tempPropertyCount;
|
||||||
|
in >> tempPropertyListLength;
|
||||||
|
position += sizeof(quint32) * 3;
|
||||||
|
endOffset = tempEndOffset;
|
||||||
|
propertyCount = tempPropertyCount;
|
||||||
|
propertyListLength = tempPropertyListLength;
|
||||||
|
}
|
||||||
in >> nameLength;
|
in >> nameLength;
|
||||||
position += sizeof(quint32) * 3 + sizeof(quint8);
|
position += sizeof(quint8);
|
||||||
|
|
||||||
FBXNode node;
|
FBXNode node;
|
||||||
const int MIN_VALID_OFFSET = 40;
|
const int MIN_VALID_OFFSET = 40;
|
||||||
|
@ -166,7 +184,7 @@ FBXNode parseBinaryFBXNode(QDataStream& in, int& position) {
|
||||||
}
|
}
|
||||||
|
|
||||||
while (endOffset > position) {
|
while (endOffset > position) {
|
||||||
FBXNode child = parseBinaryFBXNode(in, position);
|
FBXNode child = parseBinaryFBXNode(in, position, has64BitPositions);
|
||||||
if (child.name.isNull()) {
|
if (child.name.isNull()) {
|
||||||
return node;
|
return node;
|
||||||
|
|
||||||
|
@ -327,15 +345,24 @@ FBXNode FBXReader::parseFBX(QIODevice* device) {
|
||||||
// see http://code.blender.org/index.php/2013/08/fbx-binary-file-format-specification/ for an explanation
|
// see http://code.blender.org/index.php/2013/08/fbx-binary-file-format-specification/ for an explanation
|
||||||
// of the FBX binary format
|
// of the FBX binary format
|
||||||
|
|
||||||
// skip the rest of the header
|
// The first 27 bytes contain the header.
|
||||||
const int HEADER_SIZE = 27;
|
// Bytes 0 - 20: Kaydara FBX Binary \x00(file - magic, with 2 spaces at the end, then a NULL terminator).
|
||||||
in.skipRawData(HEADER_SIZE);
|
// Bytes 21 - 22: [0x1A, 0x00](unknown but all observed files show these bytes).
|
||||||
int position = HEADER_SIZE;
|
// Bytes 23 - 26 : unsigned int, the version number. 7300 for version 7.3 for example.
|
||||||
|
const int HEADER_BEFORE_VERSION = 23;
|
||||||
|
const quint32 VERSION_FBX2016 = 7500;
|
||||||
|
in.skipRawData(HEADER_BEFORE_VERSION);
|
||||||
|
int position = HEADER_BEFORE_VERSION;
|
||||||
|
quint32 fileVersion;
|
||||||
|
in >> fileVersion;
|
||||||
|
position += sizeof(fileVersion);
|
||||||
|
qDebug() << "fileVersion:" << fileVersion;
|
||||||
|
bool has64BitPositions = (fileVersion >= VERSION_FBX2016);
|
||||||
|
|
||||||
// parse the top-level node
|
// parse the top-level node
|
||||||
FBXNode top;
|
FBXNode top;
|
||||||
while (device->bytesAvailable()) {
|
while (device->bytesAvailable()) {
|
||||||
FBXNode next = parseBinaryFBXNode(in, position);
|
FBXNode next = parseBinaryFBXNode(in, position, has64BitPositions);
|
||||||
if (next.name.isNull()) {
|
if (next.name.isNull()) {
|
||||||
return top;
|
return top;
|
||||||
|
|
||||||
|
|
|
@ -1319,6 +1319,11 @@ function MyController(hand) {
|
||||||
|
|
||||||
this.searchEnter = function() {
|
this.searchEnter = function() {
|
||||||
mostRecentSearchingHand = this.hand;
|
mostRecentSearchingHand = this.hand;
|
||||||
|
var rayPickInfo = this.calcRayPickInfo(this.hand);
|
||||||
|
if (rayPickInfo.entityID || rayPickInfo.overlayID) {
|
||||||
|
this.intersectionDistance = rayPickInfo.distance;
|
||||||
|
this.searchSphereDistance = this.intersectionDistance;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.search = function(deltaTime, timestamp) {
|
this.search = function(deltaTime, timestamp) {
|
||||||
|
|
Loading…
Reference in a new issue