mirror of
https://github.com/overte-org/overte.git
synced 2025-06-27 10:29:41 +02:00
merge from upstream, don't hold up enabling of physics if a collision hull fails to load
This commit is contained in:
commit
ad4fc8c656
12 changed files with 213 additions and 169 deletions
|
@ -35,7 +35,6 @@ WebEngineView {
|
||||||
}
|
}
|
||||||
|
|
||||||
onUrlChanged: {
|
onUrlChanged: {
|
||||||
console.log("Url changed to " + url);
|
|
||||||
var originalUrl = url.toString();
|
var originalUrl = url.toString();
|
||||||
newUrl = urlHandler.fixupUrl(originalUrl).toString();
|
newUrl = urlHandler.fixupUrl(originalUrl).toString();
|
||||||
if (newUrl !== originalUrl) {
|
if (newUrl !== originalUrl) {
|
||||||
|
|
|
@ -26,7 +26,6 @@ WebEngineView {
|
||||||
}
|
}
|
||||||
|
|
||||||
onUrlChanged: {
|
onUrlChanged: {
|
||||||
console.log("Url changed to " + url);
|
|
||||||
var originalUrl = url.toString();
|
var originalUrl = url.toString();
|
||||||
newUrl = urlHandler.fixupUrl(originalUrl).toString();
|
newUrl = urlHandler.fixupUrl(originalUrl).toString();
|
||||||
if (newUrl !== originalUrl) {
|
if (newUrl !== originalUrl) {
|
||||||
|
|
|
@ -87,6 +87,15 @@ ModalWindow {
|
||||||
currentSelection.text = d.capitalizeDrive(helper.urlToPath(initialFolder));
|
currentSelection.text = d.capitalizeDrive(helper.urlToPath(initialFolder));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
helper.contentsChanged.connect(function() {
|
||||||
|
if (folderListModel) {
|
||||||
|
// Make folderListModel refresh.
|
||||||
|
var save = folderListModel.folder;
|
||||||
|
folderListModel.folder = "";
|
||||||
|
folderListModel.folder = save;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
fileTableView.forceActiveFocus();
|
fileTableView.forceActiveFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -343,12 +352,14 @@ ModalWindow {
|
||||||
onFolderChanged: {
|
onFolderChanged: {
|
||||||
if (folder === rootFolder) {
|
if (folder === rootFolder) {
|
||||||
model = driveListModel;
|
model = driveListModel;
|
||||||
|
helper.monitorDirectory("");
|
||||||
update();
|
update();
|
||||||
} else {
|
} else {
|
||||||
var needsUpdate = model === driveListModel && folder === folderListModel.folder;
|
var needsUpdate = model === driveListModel && folder === folderListModel.folder;
|
||||||
|
|
||||||
model = folderListModel;
|
model = folderListModel;
|
||||||
folderListModel.folder = folder;
|
folderListModel.folder = folder;
|
||||||
|
helper.monitorDirectory(helper.urlToPath(folder));
|
||||||
|
|
||||||
if (needsUpdate) {
|
if (needsUpdate) {
|
||||||
update();
|
update();
|
||||||
|
|
|
@ -916,6 +916,18 @@ bool RenderableModelEntityItem::contains(const glm::vec3& point) const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RenderableModelEntityItem::shouldBePhysical() const {
|
||||||
|
// If we have a model, make sure it hasn't failed to download.
|
||||||
|
// If it has, we'll report back that we shouldn't be physical so that physics aren't held waiting for us to be ready.
|
||||||
|
if (_model && getShapeType() == SHAPE_TYPE_COMPOUND && _model->didCollisionGeometryRequestFail()) {
|
||||||
|
return false;
|
||||||
|
} else if (_model && getShapeType() != SHAPE_TYPE_NONE && _model->didVisualGeometryRequestFail()) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return ModelEntityItem::shouldBePhysical();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
glm::quat RenderableModelEntityItem::getAbsoluteJointRotationInObjectFrame(int index) const {
|
glm::quat RenderableModelEntityItem::getAbsoluteJointRotationInObjectFrame(int index) const {
|
||||||
if (_model) {
|
if (_model) {
|
||||||
glm::quat result;
|
glm::quat result;
|
||||||
|
|
|
@ -65,6 +65,8 @@ public:
|
||||||
|
|
||||||
virtual bool contains(const glm::vec3& point) const override;
|
virtual bool contains(const glm::vec3& point) const override;
|
||||||
|
|
||||||
|
virtual bool shouldBePhysical() const override;
|
||||||
|
|
||||||
// these are in the frame of this object (model space)
|
// these are in the frame of this object (model space)
|
||||||
virtual glm::quat getAbsoluteJointRotationInObjectFrame(int index) const override;
|
virtual glm::quat getAbsoluteJointRotationInObjectFrame(int index) const override;
|
||||||
virtual glm::vec3 getAbsoluteJointTranslationInObjectFrame(int index) const override;
|
virtual glm::vec3 getAbsoluteJointTranslationInObjectFrame(int index) const override;
|
||||||
|
|
|
@ -102,7 +102,8 @@ Model::Model(RigPointer rig, QObject* parent) :
|
||||||
_calculatedMeshTrianglesValid(false),
|
_calculatedMeshTrianglesValid(false),
|
||||||
_meshGroupsKnown(false),
|
_meshGroupsKnown(false),
|
||||||
_isWireframe(false),
|
_isWireframe(false),
|
||||||
_rig(rig) {
|
_rig(rig)
|
||||||
|
{
|
||||||
// we may have been created in the network thread, but we live in the main thread
|
// we may have been created in the network thread, but we live in the main thread
|
||||||
if (_viewState) {
|
if (_viewState) {
|
||||||
moveToThread(_viewState->getMainThread());
|
moveToThread(_viewState->getMainThread());
|
||||||
|
@ -821,6 +822,7 @@ void Model::setURL(const QUrl& url) {
|
||||||
_needsReload = true;
|
_needsReload = true;
|
||||||
_needsUpdateTextures = true;
|
_needsUpdateTextures = true;
|
||||||
_meshGroupsKnown = false;
|
_meshGroupsKnown = false;
|
||||||
|
_visualGeometryRequestFailed = false;
|
||||||
invalidCalculatedMeshBoxes();
|
invalidCalculatedMeshBoxes();
|
||||||
deleteGeometry();
|
deleteGeometry();
|
||||||
|
|
||||||
|
@ -829,6 +831,9 @@ void Model::setURL(const QUrl& url) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Model::loadURLFinished(bool success) {
|
void Model::loadURLFinished(bool success) {
|
||||||
|
if (!success) {
|
||||||
|
_visualGeometryRequestFailed = true;
|
||||||
|
}
|
||||||
emit setURLFinished(success);
|
emit setURLFinished(success);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -837,10 +842,15 @@ void Model::setCollisionModelURL(const QUrl& url) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_collisionUrl = url;
|
_collisionUrl = url;
|
||||||
|
_collisionGeometryRequestFailed = false;
|
||||||
_collisionWatcher.setResource(DependencyManager::get<ModelCache>()->getGeometryResource(url));
|
_collisionWatcher.setResource(DependencyManager::get<ModelCache>()->getGeometryResource(url));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Model::loadCollisionModelURLFinished(bool success) {
|
void Model::loadCollisionModelURLFinished(bool success) {
|
||||||
|
if (!success) {
|
||||||
|
_collisionGeometryRequestFailed = true;
|
||||||
|
}
|
||||||
|
|
||||||
emit setCollisionModelURLFinished(success);
|
emit setCollisionModelURLFinished(success);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -147,9 +147,11 @@ public:
|
||||||
Q_INVOKABLE void setCollisionModelURL(const QUrl& url);
|
Q_INVOKABLE void setCollisionModelURL(const QUrl& url);
|
||||||
const QUrl& getCollisionURL() const { return _collisionUrl; }
|
const QUrl& getCollisionURL() const { return _collisionUrl; }
|
||||||
|
|
||||||
|
|
||||||
bool isActive() const { return isLoaded(); }
|
bool isActive() const { return isLoaded(); }
|
||||||
|
|
||||||
|
bool didVisualGeometryRequestFail() const { return _visualGeometryRequestFailed; }
|
||||||
|
bool didCollisionGeometryRequestFail() const { return _collisionGeometryRequestFailed; }
|
||||||
|
|
||||||
bool convexHullContains(glm::vec3 point);
|
bool convexHullContains(glm::vec3 point);
|
||||||
|
|
||||||
QStringList getJointNames() const;
|
QStringList getJointNames() const;
|
||||||
|
@ -400,6 +402,9 @@ protected:
|
||||||
RigPointer _rig;
|
RigPointer _rig;
|
||||||
|
|
||||||
uint32_t _deleteGeometryCounter { 0 };
|
uint32_t _deleteGeometryCounter { 0 };
|
||||||
|
|
||||||
|
bool _visualGeometryRequestFailed { false };
|
||||||
|
bool _collisionGeometryRequestFailed { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(ModelPointer)
|
Q_DECLARE_METATYPE(ModelPointer)
|
||||||
|
|
|
@ -115,3 +115,15 @@ QList<QUrl> FileDialogHelper::urlToList(const QUrl& url) {
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FileDialogHelper::monitorDirectory(const QString& path) {
|
||||||
|
if (!_fsWatcherPath.isEmpty()) {
|
||||||
|
_fsWatcher.removePath(_fsWatcherPath);
|
||||||
|
_fsWatcherPath = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!path.isEmpty()) {
|
||||||
|
_fsWatcher.addPath(path);
|
||||||
|
_fsWatcherPath = path;
|
||||||
|
connect(&_fsWatcher, &QFileSystemWatcher::directoryChanged, this, &FileDialogHelper::contentsChanged);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -9,11 +9,12 @@
|
||||||
#ifndef hifi_ui_FileDialogHelper_h
|
#ifndef hifi_ui_FileDialogHelper_h
|
||||||
#define hifi_ui_FileDialogHelper_h
|
#define hifi_ui_FileDialogHelper_h
|
||||||
|
|
||||||
|
#include <QtCore/QFileSystemWatcher>
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
#include <QtCore/QStandardPaths>
|
#include <QtCore/QStandardPaths>
|
||||||
#include <QtCore/QUrl>
|
|
||||||
#include <QtCore/QString>
|
#include <QtCore/QString>
|
||||||
#include <QtCore/QStringList>
|
#include <QtCore/QStringList>
|
||||||
|
#include <QtCore/QUrl>
|
||||||
|
|
||||||
|
|
||||||
class FileDialogHelper : public QObject {
|
class FileDialogHelper : public QObject {
|
||||||
|
@ -61,6 +62,15 @@ public:
|
||||||
Q_INVOKABLE QList<QUrl> urlToList(const QUrl& url);
|
Q_INVOKABLE QList<QUrl> urlToList(const QUrl& url);
|
||||||
|
|
||||||
Q_INVOKABLE void openDirectory(const QString& path);
|
Q_INVOKABLE void openDirectory(const QString& path);
|
||||||
|
|
||||||
|
Q_INVOKABLE void monitorDirectory(const QString& path);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void contentsChanged();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QFileSystemWatcher _fsWatcher;
|
||||||
|
QString _fsWatcherPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="540" height="90" viewBox="0 0 540.00 90.00" enable-background="new 0 0 540.00 90.00" xml:space="preserve">
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="520" height="50" viewBox="0 0 520.00 50.00" enable-background="new 0 0 540.00 50.00" xml:space="preserve">
|
||||||
<path fill="#343434" fill-opacity="0.803922" stroke-width="0.2" stroke-linejoin="round" d="M 8.00003,2.28882e-005L 532,2.28882e-005C 536.418,2.28882e-005 540,3.58175 540,8.00002L 540,82C 540,86.4183 536.418,90 532,90L 8.00003,90C 3.58174,90 2.48421e-005,86.4183 2.48421e-005,82L 2.48421e-005,8.00002C 2.48421e-005,3.58175 3.58174,2.28882e-005 8.00003,2.28882e-005 Z "/>
|
<rect x="0" y="0" rx="8" ry="8" width="520" height="50" style="fille:black;opacity:0.6" />
|
||||||
</svg>
|
</svg>
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!-- Generator: Adobe Illustrator 18.1.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
|
||||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||||
viewBox="-159 536 960 30" enable-background="new -159 536 960 30" xml:space="preserve">
|
viewBox="0 0 960 10" enable-background="new -159 536 960 30" xml:space="preserve">
|
||||||
<rect x="-159" y="536" fill="#4CC1B8" fill-opacity="0.8039" width="480" height="30"/>
|
<defs>
|
||||||
<rect x="321" y="536" fill="#FFFFFF" fill-opacity="0.8039" width="480" height="30"/>
|
<linearGradient id="loadingGrad" x1="0%" y1="0%" x2="100%" y2="0%">
|
||||||
|
<stop offset="0%" style="stop-color:rgb(16,128,184);stop-opacity:1" />
|
||||||
|
<stop offset="100%" style="stop-color:rgb(0,180,239);stop-opacity:1" />
|
||||||
|
</linearGradient>
|
||||||
|
</defs>
|
||||||
|
<rect x="0" y="0" fill="url(#loadingGrad)" width="480" height="10"/>
|
||||||
|
<rect x="480" y="0" fill="#000000" fill-opacity="0.8039" width="480" height="10"/>
|
||||||
</svg>
|
</svg>
|
||||||
|
|
Before Width: | Height: | Size: 535 B After Width: | Height: | Size: 671 B |
|
@ -13,6 +13,11 @@
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
function debug() {
|
||||||
|
return;
|
||||||
|
print.apply(null, arguments);
|
||||||
|
}
|
||||||
|
|
||||||
var rawProgress = 100, // % raw value.
|
var rawProgress = 100, // % raw value.
|
||||||
displayProgress = 100, // % smoothed value to display.
|
displayProgress = 100, // % smoothed value to display.
|
||||||
DISPLAY_PROGRESS_MINOR_MAXIMUM = 8, // % displayed progress bar goes up to while 0% raw progress.
|
DISPLAY_PROGRESS_MINOR_MAXIMUM = 8, // % displayed progress bar goes up to while 0% raw progress.
|
||||||
|
@ -28,35 +33,18 @@
|
||||||
FADE_OUT_WAIT = 1000, // Wait before starting to fade out after progress 100%.
|
FADE_OUT_WAIT = 1000, // Wait before starting to fade out after progress 100%.
|
||||||
visible = false,
|
visible = false,
|
||||||
BAR_WIDTH = 480, // Dimension of SVG in pixels of visible portion (half) of the bar.
|
BAR_WIDTH = 480, // Dimension of SVG in pixels of visible portion (half) of the bar.
|
||||||
BAR_HEIGHT = 30,
|
BAR_HEIGHT = 10,
|
||||||
|
BAR_Y_OFFSET_2D = -10, // Offset of progress bar while in desktop mode
|
||||||
|
BAR_Y_OFFSET_HMD = -300, // Offset of progress bar while in HMD
|
||||||
BAR_URL = Script.resolvePath("assets/images/progress-bar.svg"),
|
BAR_URL = Script.resolvePath("assets/images/progress-bar.svg"),
|
||||||
BACKGROUND_WIDTH = 540,
|
BACKGROUND_WIDTH = 520,
|
||||||
BACKGROUND_HEIGHT = 90,
|
BACKGROUND_HEIGHT = 50,
|
||||||
BACKGROUND_URL = Script.resolvePath("assets/images/progress-bar-background.svg"),
|
BACKGROUND_URL = Script.resolvePath("assets/images/progress-bar-background.svg"),
|
||||||
isOnHMD = false,
|
|
||||||
windowWidth = 0,
|
windowWidth = 0,
|
||||||
windowHeight = 0,
|
windowHeight = 0,
|
||||||
background2D = {},
|
background2D = {},
|
||||||
bar2D = {},
|
bar2D = {},
|
||||||
SCALE_2D = 0.35, // Scale the SVGs for 2D display.
|
SCALE_2D = 0.35; // Scale the SVGs for 2D display.
|
||||||
background3D = {},
|
|
||||||
bar3D = {},
|
|
||||||
PROGRESS_3D_DIRECTION = 0.0, // Degrees from avatar orientation.
|
|
||||||
PROGRESS_3D_DISTANCE = 0.602, // Horizontal distance from avatar position.
|
|
||||||
PROGRESS_3D_ELEVATION = -0.8, // Height of top middle of top notification relative to avatar eyes.
|
|
||||||
PROGRESS_3D_YAW = 0.0, // Degrees relative to notifications direction.
|
|
||||||
PROGRESS_3D_PITCH = -60.0, // Degrees from vertical.
|
|
||||||
SCALE_3D = 0.0011, // Scale the bar SVG for 3D display.
|
|
||||||
BACKGROUND_3D_SIZE = {
|
|
||||||
x: 0.76,
|
|
||||||
y: 0.08
|
|
||||||
}, // Match up with the 3D background with those of notifications.js notices.
|
|
||||||
BACKGROUND_3D_COLOR = {
|
|
||||||
red: 2,
|
|
||||||
green: 2,
|
|
||||||
blue: 2
|
|
||||||
},
|
|
||||||
BACKGROUND_3D_ALPHA = 0.7;
|
|
||||||
|
|
||||||
function fade() {
|
function fade() {
|
||||||
|
|
||||||
|
@ -64,9 +52,7 @@
|
||||||
|
|
||||||
if (alpha < 0) {
|
if (alpha < 0) {
|
||||||
alpha = 0;
|
alpha = 0;
|
||||||
}
|
} else if (alpha > 1) {
|
||||||
|
|
||||||
if (alpha > 1) {
|
|
||||||
alpha = 1;
|
alpha = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,115 +65,123 @@
|
||||||
visible = false;
|
visible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isOnHMD) {
|
Overlays.editOverlay(background2D.overlay, {
|
||||||
Overlays.editOverlay(background3D.overlay, {
|
alpha: alpha,
|
||||||
backgroundAlpha: alpha * BACKGROUND_3D_ALPHA,
|
visible: visible
|
||||||
visible: visible
|
});
|
||||||
});
|
Overlays.editOverlay(bar2D.overlay, {
|
||||||
} else {
|
|
||||||
Overlays.editOverlay(background2D.overlay, {
|
|
||||||
alpha: alpha,
|
|
||||||
visible: visible
|
|
||||||
});
|
|
||||||
}
|
|
||||||
Overlays.editOverlay(isOnHMD ? bar3D.overlay : bar2D.overlay, {
|
|
||||||
alpha: alpha,
|
alpha: alpha,
|
||||||
visible: visible
|
visible: visible
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Window.domainChanged.connect(function() {
|
||||||
|
isDownloading = false;
|
||||||
|
bestRawProgress = 100;
|
||||||
|
rawProgress = 100;
|
||||||
|
displayProgress = 100;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Max seen since downloads started. This is reset when all downloads have completed.
|
||||||
|
var maxSeen = 0;
|
||||||
|
|
||||||
|
// Progress is defined as: (pending_downloads + active_downloads) / max_seen
|
||||||
|
// We keep track of both the current progress (rawProgress) and the
|
||||||
|
// best progress we've seen (bestRawProgress). As you are downloading, you may
|
||||||
|
// encounter new assets that require downloads, increasing the number of
|
||||||
|
// pending downloads and thus decreasing your overall progress.
|
||||||
|
var bestRawProgress = 0;
|
||||||
|
|
||||||
|
// True if we have known active downloads
|
||||||
|
var isDownloading = false;
|
||||||
|
|
||||||
|
// Entities are streamed to users, so you don't receive them all at once; instead, you
|
||||||
|
// receive them over a period of time. In many cases we end up in a situation where
|
||||||
|
//
|
||||||
|
// The initial delay cooldown keeps us from tracking progress before the allotted time
|
||||||
|
// has passed.
|
||||||
|
var INITIAL_DELAY_COOLDOWN_TIME = 1000;
|
||||||
|
var initialDelayCooldown = 0;
|
||||||
function onDownloadInfoChanged(info) {
|
function onDownloadInfoChanged(info) {
|
||||||
var i;
|
var i;
|
||||||
|
|
||||||
|
debug("PROGRESS: Download info changed ", info.downloading.length, info.pending, maxSeen);
|
||||||
|
|
||||||
// Update raw progress value
|
// Update raw progress value
|
||||||
if (info.downloading.length + info.pending === 0) {
|
if (info.downloading.length + info.pending === 0) {
|
||||||
|
isDownloading = false;
|
||||||
rawProgress = 100;
|
rawProgress = 100;
|
||||||
|
bestRawProgress = 100;
|
||||||
|
initialDelayCooldown = INITIAL_DELAY_COOLDOWN_TIME;
|
||||||
} else {
|
} else {
|
||||||
rawProgress = 0;
|
var count = info.downloading.length + info.pending;
|
||||||
for (i = 0; i < info.downloading.length; i += 1) {
|
if (!isDownloading) {
|
||||||
rawProgress += info.downloading[i];
|
isDownloading = true;
|
||||||
|
bestRawProgress = 0;
|
||||||
|
rawProgress = 0;
|
||||||
|
initialDelayCooldown = INITIAL_DELAY_COOLDOWN_TIME;
|
||||||
|
displayProgress = 0;
|
||||||
|
maxSeen = count;
|
||||||
|
}
|
||||||
|
if (count > maxSeen) {
|
||||||
|
maxSeen = count;
|
||||||
|
}
|
||||||
|
if (initialDelayCooldown <= 0) {
|
||||||
|
rawProgress = ((maxSeen - count) / maxSeen) * 100;
|
||||||
|
|
||||||
|
if (rawProgress > bestRawProgress) {
|
||||||
|
bestRawProgress = rawProgress;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
rawProgress = rawProgress / (info.downloading.length + info.pending);
|
|
||||||
}
|
}
|
||||||
|
debug("PROGRESS:", rawProgress, bestRawProgress, maxSeen);
|
||||||
}
|
}
|
||||||
|
|
||||||
function createOverlays() {
|
function createOverlays() {
|
||||||
if (isOnHMD) {
|
background2D.overlay = Overlays.addOverlay("image", {
|
||||||
|
imageURL: BACKGROUND_URL,
|
||||||
background3D.overlay = Overlays.addOverlay("rectangle3d", {
|
width: background2D.width,
|
||||||
size: BACKGROUND_3D_SIZE,
|
height: background2D.height,
|
||||||
color: BACKGROUND_3D_COLOR,
|
visible: false,
|
||||||
alpha: BACKGROUND_3D_ALPHA,
|
alpha: 0.0
|
||||||
solid: true,
|
});
|
||||||
isFacingAvatar: false,
|
bar2D.overlay = Overlays.addOverlay("image", {
|
||||||
visible: false,
|
imageURL: BAR_URL,
|
||||||
ignoreRayIntersection: true
|
subImage: {
|
||||||
});
|
x: 0,
|
||||||
bar3D.overlay = Overlays.addOverlay("image3d", {
|
y: 0,
|
||||||
url: BAR_URL,
|
width: BAR_WIDTH,
|
||||||
subImage: {
|
height: BAR_HEIGHT
|
||||||
x: BAR_WIDTH,
|
},
|
||||||
y: 0,
|
width: bar2D.width,
|
||||||
width: BAR_WIDTH,
|
height: bar2D.height,
|
||||||
height: BAR_HEIGHT
|
visible: false,
|
||||||
},
|
alpha: 0.0
|
||||||
scale: SCALE_3D * BAR_WIDTH,
|
});
|
||||||
isFacingAvatar: false,
|
|
||||||
visible: false,
|
|
||||||
alpha: 0.0,
|
|
||||||
ignoreRayIntersection: true
|
|
||||||
});
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
background2D.overlay = Overlays.addOverlay("image", {
|
|
||||||
imageURL: BACKGROUND_URL,
|
|
||||||
width: background2D.width,
|
|
||||||
height: background2D.height,
|
|
||||||
visible: false,
|
|
||||||
alpha: 0.0
|
|
||||||
});
|
|
||||||
bar2D.overlay = Overlays.addOverlay("image", {
|
|
||||||
imageURL: BAR_URL,
|
|
||||||
subImage: {
|
|
||||||
x: BAR_WIDTH,
|
|
||||||
y: 0,
|
|
||||||
width: BAR_WIDTH,
|
|
||||||
height: BAR_HEIGHT
|
|
||||||
},
|
|
||||||
width: bar2D.width,
|
|
||||||
height: bar2D.height,
|
|
||||||
visible: false,
|
|
||||||
alpha: 0.0
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteOverlays() {
|
function deleteOverlays() {
|
||||||
Overlays.deleteOverlay(isOnHMD ? background3D.overlay : background2D.overlay);
|
Overlays.deleteOverlay(background2D.overlay);
|
||||||
Overlays.deleteOverlay(isOnHMD ? bar3D.overlay : bar2D.overlay);
|
Overlays.deleteOverlay(bar2D.overlay);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var b = 0;
|
||||||
|
var currentOrientation = null;
|
||||||
function update() {
|
function update() {
|
||||||
|
initialDelayCooldown -= 30;
|
||||||
var viewport,
|
var viewport,
|
||||||
eyePosition,
|
eyePosition,
|
||||||
avatarOrientation;
|
avatarOrientation;
|
||||||
|
|
||||||
if (isOnHMD !== HMD.active) {
|
if (displayProgress < rawProgress) {
|
||||||
deleteOverlays();
|
var diff = rawProgress - displayProgress;
|
||||||
isOnHMD = !isOnHMD;
|
if (diff < 0.5) {
|
||||||
createOverlays();
|
displayProgress = rawProgress;
|
||||||
|
} else {
|
||||||
|
displayProgress += diff * 0.05;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate progress value to display
|
|
||||||
if (rawProgress === 0 && displayProgress <= DISPLAY_PROGRESS_MINOR_MAXIMUM) {
|
|
||||||
displayProgress = Math.min(displayProgress + DISPLAY_PROGRESS_MINOR_INCREMENT, DISPLAY_PROGRESS_MINOR_MAXIMUM);
|
|
||||||
} else if (rawProgress < displayProgress) {
|
|
||||||
displayProgress = rawProgress;
|
|
||||||
} else if (rawProgress > displayProgress) {
|
|
||||||
displayProgress = Math.min(rawProgress, displayProgress + DISPLAY_PROGRESS_MAJOR_INCREMENT);
|
|
||||||
} // else (rawProgress === displayProgress); do nothing.
|
|
||||||
|
|
||||||
// Update state
|
// Update state
|
||||||
if (!visible) { // Not visible because no recent downloads
|
if (!visible) { // Not visible because no recent downloads
|
||||||
if (displayProgress < 100) { // Have started downloading so fade in
|
if (displayProgress < 100) { // Have started downloading so fade in
|
||||||
|
@ -197,7 +191,7 @@
|
||||||
}
|
}
|
||||||
} else if (alphaDelta !== 0.0) { // Fading in or out
|
} else if (alphaDelta !== 0.0) { // Fading in or out
|
||||||
if (alphaDelta > 0) {
|
if (alphaDelta > 0) {
|
||||||
if (displayProgress === 100) { // Was downloading but now have finished so fade out
|
if (rawProgress === 100) { // Was downloading but now have finished so fade out
|
||||||
alphaDelta = ALPHA_DELTA_OUT;
|
alphaDelta = ALPHA_DELTA_OUT;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -207,7 +201,7 @@
|
||||||
}
|
}
|
||||||
} else { // Fully visible because downloading or recently so
|
} else { // Fully visible because downloading or recently so
|
||||||
if (fadeWaitTimer === null) {
|
if (fadeWaitTimer === null) {
|
||||||
if (displayProgress === 100) { // Was downloading but have finished so fade out soon
|
if (rawProgress === 100) { // Was downloading but have finished so fade out soon
|
||||||
fadeWaitTimer = Script.setTimeout(function() {
|
fadeWaitTimer = Script.setTimeout(function() {
|
||||||
alphaDelta = ALPHA_DELTA_OUT;
|
alphaDelta = ALPHA_DELTA_OUT;
|
||||||
fadeTimer = Script.setInterval(fade, FADE_INTERVAL);
|
fadeTimer = Script.setInterval(fade, FADE_INTERVAL);
|
||||||
|
@ -225,73 +219,58 @@
|
||||||
if (visible) {
|
if (visible) {
|
||||||
|
|
||||||
// Update progress bar
|
// Update progress bar
|
||||||
Overlays.editOverlay(isOnHMD ? bar3D.overlay : bar2D.overlay, {
|
Overlays.editOverlay(bar2D.overlay, {
|
||||||
visible: visible,
|
visible: true,
|
||||||
subImage: {
|
subImage: {
|
||||||
x: BAR_WIDTH * (1 - displayProgress / 100),
|
x: BAR_WIDTH * (1 - displayProgress / 100),
|
||||||
y: 0,
|
y: 0,
|
||||||
width: BAR_WIDTH,
|
width: BAR_WIDTH,
|
||||||
height: BAR_HEIGHT
|
height: BAR_HEIGHT
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// Update position
|
Overlays.editOverlay(background2D.overlay, {
|
||||||
if (isOnHMD) {
|
visible: true,
|
||||||
// Update 3D overlays to maintain positions relative to avatar
|
});
|
||||||
eyePosition = MyAvatar.getDefaultEyePosition();
|
|
||||||
avatarOrientation = MyAvatar.orientation;
|
|
||||||
|
|
||||||
Overlays.editOverlay(background3D.overlay, {
|
// Update 2D overlays to maintain positions at bottom middle of window
|
||||||
position: Vec3.sum(eyePosition, Vec3.multiplyQbyV(avatarOrientation, background3D.offset)),
|
viewport = Controller.getViewportDimensions();
|
||||||
rotation: Quat.multiply(avatarOrientation, background3D.orientation)
|
|
||||||
});
|
|
||||||
Overlays.editOverlay(bar3D.overlay, {
|
|
||||||
position: Vec3.sum(eyePosition, Vec3.multiplyQbyV(avatarOrientation, bar3D.offset)),
|
|
||||||
rotation: Quat.multiply(avatarOrientation, bar3D.orientation)
|
|
||||||
});
|
|
||||||
|
|
||||||
} else {
|
if (viewport.x !== windowWidth || viewport.y !== windowHeight) {
|
||||||
// Update 2D overlays to maintain positions at bottom middle of window
|
updateProgressBarLocation();
|
||||||
viewport = Controller.getViewportDimensions();
|
|
||||||
|
|
||||||
if (viewport.x !== windowWidth || viewport.y !== windowHeight) {
|
|
||||||
windowWidth = viewport.x;
|
|
||||||
windowHeight = viewport.y;
|
|
||||||
|
|
||||||
Overlays.editOverlay(background2D.overlay, {
|
|
||||||
x: windowWidth / 2 - background2D.width / 2,
|
|
||||||
y: windowHeight - background2D.height - bar2D.height
|
|
||||||
});
|
|
||||||
|
|
||||||
Overlays.editOverlay(bar2D.overlay, {
|
|
||||||
x: windowWidth / 2 - bar2D.width / 2,
|
|
||||||
y: windowHeight - background2D.height - bar2D.height + (background2D.height - bar2D.height) / 2
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateProgressBarLocation() {
|
||||||
|
viewport = Controller.getViewportDimensions();
|
||||||
|
windowWidth = viewport.x;
|
||||||
|
windowHeight = viewport.y;
|
||||||
|
|
||||||
|
var yOffset = HMD.active ? BAR_Y_OFFSET_HMD : BAR_Y_OFFSET_2D;
|
||||||
|
|
||||||
|
background2D.width = SCALE_2D * BACKGROUND_WIDTH;
|
||||||
|
background2D.height = SCALE_2D * BACKGROUND_HEIGHT;
|
||||||
|
bar2D.width = SCALE_2D * BAR_WIDTH;
|
||||||
|
bar2D.height = SCALE_2D * BAR_HEIGHT;
|
||||||
|
|
||||||
|
Overlays.editOverlay(background2D.overlay, {
|
||||||
|
x: windowWidth / 2 - background2D.width / 2,
|
||||||
|
y: windowHeight - background2D.height - bar2D.height + yOffset
|
||||||
|
});
|
||||||
|
|
||||||
|
Overlays.editOverlay(bar2D.overlay, {
|
||||||
|
x: windowWidth / 2 - bar2D.width / 2,
|
||||||
|
y: windowHeight - background2D.height - bar2D.height + (background2D.height - bar2D.height) / 2 + yOffset
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function setUp() {
|
function setUp() {
|
||||||
background2D.width = SCALE_2D * BACKGROUND_WIDTH;
|
background2D.width = SCALE_2D * BACKGROUND_WIDTH;
|
||||||
background2D.height = SCALE_2D * BACKGROUND_HEIGHT;
|
background2D.height = SCALE_2D * BACKGROUND_HEIGHT;
|
||||||
bar2D.width = SCALE_2D * BAR_WIDTH;
|
bar2D.width = SCALE_2D * BAR_WIDTH;
|
||||||
bar2D.height = SCALE_2D * BAR_HEIGHT;
|
bar2D.height = SCALE_2D * BAR_HEIGHT;
|
||||||
|
|
||||||
background3D.offset = Vec3.multiplyQbyV(Quat.fromPitchYawRollDegrees(0, PROGRESS_3D_DIRECTION, 0), {
|
|
||||||
x: 0,
|
|
||||||
y: 0,
|
|
||||||
z: -PROGRESS_3D_DISTANCE
|
|
||||||
});
|
|
||||||
background3D.offset.y += PROGRESS_3D_ELEVATION;
|
|
||||||
background3D.orientation = Quat.fromPitchYawRollDegrees(PROGRESS_3D_PITCH, PROGRESS_3D_DIRECTION + PROGRESS_3D_YAW, 0);
|
|
||||||
bar3D.offset = Vec3.sum(background3D.offset, {
|
|
||||||
x: 0,
|
|
||||||
y: 0,
|
|
||||||
z: 0.001
|
|
||||||
}); // Just in front of background
|
|
||||||
bar3D.orientation = background3D.orientation;
|
|
||||||
|
|
||||||
createOverlays();
|
createOverlays();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,6 +281,6 @@
|
||||||
setUp();
|
setUp();
|
||||||
GlobalServices.downloadInfoChanged.connect(onDownloadInfoChanged);
|
GlobalServices.downloadInfoChanged.connect(onDownloadInfoChanged);
|
||||||
GlobalServices.updateDownloadInfo();
|
GlobalServices.updateDownloadInfo();
|
||||||
Script.update.connect(update);
|
Script.setInterval(update, 1000/60);
|
||||||
Script.scriptEnding.connect(tearDown);
|
Script.scriptEnding.connect(tearDown);
|
||||||
}());
|
}());
|
||||||
|
|
Loading…
Reference in a new issue