mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 09:44:21 +02:00
Use Clara.io API for FBX downloads
This commit is contained in:
parent
93beaa81c0
commit
667a777695
2 changed files with 24 additions and 5 deletions
|
@ -56,7 +56,7 @@ Rectangle {
|
|||
property var simpleDownload: 'var element = $("a.download-file");
|
||||
element.removeClass("download-file");
|
||||
element.removeAttr("download");'
|
||||
|
||||
|
||||
function displayErrorStatus() {
|
||||
alertTimer.handler = function() {
|
||||
statusLabel.text = claraMessage;
|
||||
|
@ -69,12 +69,23 @@ Rectangle {
|
|||
property var notFbxHandler: 'var element = $("a.btn.btn-primary.viewer-button.download-file")
|
||||
element.click();'
|
||||
|
||||
// this code is for removing other file types from Clara.io's download options
|
||||
//property var checkFileType: "$('[data-extension]:not([data-extension=\"fbx\"])').parent().remove()"
|
||||
// Replace Clara FBX download link action with Cara API action.
|
||||
property string replaceFBXDownload: 'var element = $("a[data-extension=\'fbx\']:first");
|
||||
element.unbind("click");
|
||||
element.bind("click", function(event) {
|
||||
console.log("Initiate Clara.io FBX file download");
|
||||
window.open("https://clara.io/api/scenes/{uuid}/export/fbx?fbxVersion=7.4&fbxEmbedTextures=true¢erScene=true&alignSceneGound=true");
|
||||
return false;
|
||||
});'
|
||||
|
||||
onLinkHovered: {
|
||||
desktop.currentUrl = hoveredUrl;
|
||||
//runJavaScript(checkFileType, function(){console.log("Remove filetypes JS injection");});
|
||||
|
||||
if (desktop.isClaraFBXZipDownload(desktop.currentUrl)) {
|
||||
var doReplaceFBXDownload = replaceFBXDownload.replace("{uuid}", desktop.currentUrl.slice(desktop.currentUrl.lastIndexOf("/") + 1, -1));
|
||||
runJavaScript(doReplaceFBXDownload);
|
||||
}
|
||||
|
||||
if (File.isZippedFbx(desktop.currentUrl)) {
|
||||
runJavaScript(simpleDownload, function(){console.log("Download JS injection");});
|
||||
return;
|
||||
|
@ -110,7 +121,7 @@ Rectangle {
|
|||
newWindow.height = 0;
|
||||
|
||||
request.openIn(newWindow.webView);
|
||||
if (File.isZippedFbx(desktop.currentUrl)) {
|
||||
if (desktop.isClaraFBXZipDownload(desktop.currentUrl)) {
|
||||
newWindow.setAutoAdd(true);
|
||||
runJavaScript(autoCancel);
|
||||
newWindow.loadingChanged.connect(function(status) {
|
||||
|
|
|
@ -90,6 +90,11 @@ OriginalDesktop.Desktop {
|
|||
property string tempDir: ""
|
||||
property bool autoAdd: false
|
||||
|
||||
function isClaraFBXZipDownload(url) {
|
||||
// Clara.io FBX file: Original URL that is ovrridden in JavaScript to download using API.
|
||||
return url.indexOf("clara.io/view/") !== -1 && url.slice(-1) === "#";
|
||||
}
|
||||
|
||||
function initWebviewProfileHandlers(profile) {
|
||||
console.log("The webview url in desktop is: " + currentUrl);
|
||||
if (webViewProfileSetup) return;
|
||||
|
@ -101,6 +106,9 @@ OriginalDesktop.Desktop {
|
|||
tempDir = File.getTempDir();
|
||||
console.log("Temp dir created: " + tempDir);
|
||||
download.path = tempDir + "/" + adaptedPath;
|
||||
if (isClaraFBXZipDownload(currentUrl)) {
|
||||
download.path += "fbx.zip";
|
||||
}
|
||||
console.log("Path where object should download: " + download.path);
|
||||
console.log("Auto add: " + autoAdd);
|
||||
download.accept();
|
||||
|
|
Loading…
Reference in a new issue