imporving the interstitial page script

This commit is contained in:
Dante Ruiz 2018-08-06 17:42:21 -07:00
parent cca76f7022
commit 6a4a56cee3
6 changed files with 108 additions and 76 deletions

View File

@ -3458,6 +3458,7 @@ bool Application::isInterstitialMode() const {
void Application::setIsInterstitialMode(bool interstitialMode) { void Application::setIsInterstitialMode(bool interstitialMode) {
if (_interstitialMode != interstitialMode) { if (_interstitialMode != interstitialMode) {
qDebug() << "-------> interstitial mode changed: " << _interstitialMode << " ------------> ";
_interstitialMode = interstitialMode; _interstitialMode = interstitialMode;
emit interstitialModeChanged(_interstitialMode); emit interstitialModeChanged(_interstitialMode);
} }

View File

@ -53,6 +53,9 @@ WindowScriptingInterface::WindowScriptingInterface() {
}); });
connect(qApp->getWindow(), &MainWindow::windowGeometryChanged, this, &WindowScriptingInterface::onWindowGeometryChanged); connect(qApp->getWindow(), &MainWindow::windowGeometryChanged, this, &WindowScriptingInterface::onWindowGeometryChanged);
connect(qApp, &Application::interstitialModeChanged, [this] (bool interstitialStatus) {
emit interstitialStatusChanged(interstitialStatus);
});
} }
WindowScriptingInterface::~WindowScriptingInterface() { WindowScriptingInterface::~WindowScriptingInterface() {

View File

@ -746,6 +746,9 @@ signals:
*/ */
void geometryChanged(QRect geometry); void geometryChanged(QRect geometry);
void interstitialStatusChanged(bool intersititalMode);
private: private:
QString getPreviousBrowseLocation() const; QString getPreviousBrowseLocation() const;
void setPreviousBrowseLocation(const QString& location); void setPreviousBrowseLocation(const QString& location);

View File

@ -105,6 +105,10 @@ extern std::atomic<size_t> DECIMATED_TEXTURE_COUNT;
extern std::atomic<size_t> RECTIFIED_TEXTURE_COUNT; extern std::atomic<size_t> RECTIFIED_TEXTURE_COUNT;
void Stats::updateStats(bool force) { void Stats::updateStats(bool force) {
if (qApp->isInterstitialMode()) {
return;
}
QQuickItem* parent = parentItem(); QQuickItem* parent = parentItem();
if (!force) { if (!force) {
if (!Menu::getInstance()->isOptionChecked(MenuOption::Stats)) { if (!Menu::getInstance()->isOptionChecked(MenuOption::Stats)) {

View File

@ -31,11 +31,11 @@ var DEFAULT_SCRIPTS_COMBINED = [
"system/dialTone.js", "system/dialTone.js",
"system/firstPersonHMD.js", "system/firstPersonHMD.js",
"system/tablet-ui/tabletUI.js", "system/tablet-ui/tabletUI.js",
"system/emote.js", "system/emote.js"
"system/interstitialPage.js"
]; ];
var DEFAULT_SCRIPTS_SEPARATE = [ var DEFAULT_SCRIPTS_SEPARATE = [
"system/controllers/controllerScripts.js", "system/controllers/controllerScripts.js",
"system/interstitialPage.js"
//"system/chat.js" //"system/chat.js"
]; ];

View File

@ -13,9 +13,11 @@
Camera, HMD*/ Camera, HMD*/
(function() { (function() {
var MAX_X_SIZE = 3; var MAX_X_SIZE = 5;
var isVisible = true; var EPSILON = 0.25;
var defaultOffset = 1.5; var isVisible = false;
var STABILITY = 3.0;
var defaultOffset = -0.5;
var VOLUME = 0.4; var VOLUME = 0.4;
var tune = SoundCache.getSound("http://hifi-content.s3.amazonaws.com/alexia/LoadingScreens/crystals_and_voices.wav"); var tune = SoundCache.getSound("http://hifi-content.s3.amazonaws.com/alexia/LoadingScreens/crystals_and_voices.wav");
var sample = null; var sample = null;
@ -50,14 +52,15 @@
var loadingSphereID = Overlays.addOverlay("model", { var loadingSphereID = Overlays.addOverlay("model", {
name: "Loading-Sphere", name: "Loading-Sphere",
position: Vec3.sum(Vec3.sum(MyAvatar.position, {x: 0.0, y: -1.0, z: 0.0}), Vec3.multiplyQbyV(MyAvatar.orientation, {x: 0, y: 0.95, z: 0})), position: Vec3.sum(Vec3.sum(MyAvatar.position, {x: 0.0, y: -1.0, z: 0.0}), Vec3.multiplyQbyV(MyAvatar.orientation, {x: 0, y: 0.95, z: 0})),
orientation: Quat.multiply(Quat.fromVec3Degrees({x: 0, y: 180, z: 0}), MyAvatar.orientation), orientation: Quat.multiply(Quat.fromVec3Degrees({x: 10, y: 180, z: 0}), MyAvatar.orientation),
url: "http://hifi-content.s3.amazonaws.com/alexia/LoadingScreens/black-sphere.fbx", url: "http://hifi-content.s3.amazonaws.com/alexia/LoadingScreens/black-sphere.fbx",
dimensions: { x: 20, y: 20, z: 20 }, dimensions: { x: 20, y: 20, z: 20 },
alpha: 1, alpha: 1,
visible: isVisible, visible: isVisible,
ignoreRayIntersection: true, ignoreRayIntersection: true,
drawInFront: true, drawInFront: true,
grabbable: false grabbable: false,
parentID: MyAvatar.SELF_ID
}); });
@ -128,7 +131,7 @@
var loadingBarPlacard = Overlays.addOverlay("image3d", { var loadingBarPlacard = Overlays.addOverlay("image3d", {
name: "Loading-Bar-Placard", name: "Loading-Bar-Placard",
localPosition: { x: 0.0 , y: DESTINATION_CARD_Y_OFFSET - 0.99, z: 5.45 }, localPosition: { x: 0.0 , y: DESTINATION_CARD_Y_OFFSET - 0.99, z: 5.52 },
url: "http://hifi-content.s3.amazonaws.com/alexia/LoadingScreens/loadingBar_placard.png", url: "http://hifi-content.s3.amazonaws.com/alexia/LoadingScreens/loadingBar_placard.png",
alpha: 1, alpha: 1,
dimensions: { x: 4, y: 2.8}, dimensions: { x: 4, y: 2.8},
@ -161,6 +164,9 @@
var timerset = false; var timerset = false;
var lastInterval = Date.now(); var lastInterval = Date.now();
var timeElapsed = 0; var timeElapsed = 0;
var currentDomain = "";
var timer = null;
var target = 0;
function getLeftMargin(overlayID, text) { function getLeftMargin(overlayID, text) {
@ -171,43 +177,58 @@
} }
function resetValues() {
}
function lerp(a, b, t) {
return ((1 - t) * a + t * b);
}
function startInterstitialPage() {
if (timer === null) {
print("--------> start page <--------");
updateOverlays(Window.isPhysicsEnabled());
target = 0;
currentProgress = 0.1;
timer = Script.setTimeout(update, BASIC_TIMER_INTERVAL_MS);
}
}
function domainChanged(domain) { function domainChanged(domain) {
var name = AddressManager.placename; if (domain !== currentDomain) {
domainName = name.charAt(0).toUpperCase() + name.slice(1); print("----------> domain changed <-------------->");
var domainNameLeftMargin = getLeftMargin(domainNameTextID, domainName); var name = AddressManager.placename;
var textProperties = { domainName = name.charAt(0).toUpperCase() + name.slice(1);
text: domainName, var domainNameLeftMargin = getLeftMargin(domainNameTextID, domainName);
leftMargin: domainNameLeftMargin var textProperties = {
}; text: domainName,
leftMargin: domainNameLeftMargin
};
var BY = "by "; var BY = "by ";
var text = BY var text = BY
var hostLeftMargin = getLeftMargin(domainHostname, text); var hostLeftMargin = getLeftMargin(domainHostname, text);
var hostnameProperties = { var hostnameProperties = {
text: BY, text: BY,
leftMargin: hostLeftMargin leftMargin: hostLeftMargin
}; };
var randomIndex = Math.floor(Math.random() * userTips.length); var randomIndex = Math.floor(Math.random() * userTips.length);
var tip = userTips[randomIndex]; var tip = userTips[randomIndex];
var tipLeftMargin = getLeftMargin(domainToolTip, tip); var tipLeftMargin = getLeftMargin(domainToolTip, tip);
var toolTipProperties = { var toolTipProperties = {
text: tip, text: tip,
leftMargin: tipLeftMargin leftMargin: tipLeftMargin
}; };
var myAvatarDirection = Vec3.UNIT_NEG_Z; Overlays.editOverlay(domainNameTextID, textProperties);
var cardDirectionPrime = {x: 0 , y: 0, z: 5.5}; Overlays.editOverlay(domainHostname, hostnameProperties);
var rotationDelta = Quat.rotationBetween(cardDirectionPrime, myAvatarDirection); Overlays.editOverlay(domainToolTip, toolTipProperties);
var overlayRotation = Quat.multiply(MyAvatar.orientation, rotationDelta);
var mainSphereProperties = {
orientation: overlayRotation
};
Overlays.editOverlay(loadingSphereID, mainSphereProperties);
Overlays.editOverlay(domainNameTextID, textProperties); startInterstitialPage();
Overlays.editOverlay(domainHostname, hostnameProperties); currentDomain = domain;
Overlays.editOverlay(domainToolTip, toolTipProperties); }
} }
var THE_PLACE = "hifi://TheSpot"; var THE_PLACE = "hifi://TheSpot";
@ -222,26 +243,18 @@
} }
} }
var previousPhysicsStatus = 99999; var currentProgress = 0.1;
function updateOverlays(physicsEnabled) { function updateOverlays(physicsEnabled) {
var properties = { var properties = {
visible: !physicsEnabled visible: !physicsEnabled
}; };
var myAvatarDirection = Vec3.UNIT_NEG_Z;
var cardDirectionPrime = {x: 0 , y: 0, z: 5.5};
var rotationDelta = Quat.rotationBetween(cardDirectionPrime, myAvatarDirection);
var overlayRotation = Quat.multiply(MyAvatar.orientation, rotationDelta);
var mainSphereProperties = { var mainSphereProperties = {
visible: !physicsEnabled, visible: !physicsEnabled
orientation: overlayRotation
}; };
if (!HMD.active) { Menu.setIsOptionChecked("Show Overlays", physicsEnabled);
toolbar.writeProperty("visible", physicsEnabled);
MyAvatar.headOrientation = Quat.multiply(Quat.cancelOutRollAndPitch(MyAvatar.headOrientation), Quat.fromPitchYawRollDegrees(2.5, 0, 0));
}
renderViewTask.getConfig("LightingModel")["enableAmbientLight"] = physicsEnabled; renderViewTask.getConfig("LightingModel")["enableAmbientLight"] = physicsEnabled;
renderViewTask.getConfig("LightingModel")["enableDirectionalLight"] = physicsEnabled; renderViewTask.getConfig("LightingModel")["enableDirectionalLight"] = physicsEnabled;
@ -260,38 +273,46 @@
var thisInterval = Date.now(); var thisInterval = Date.now();
var deltaTime = (thisInterval - lastInterval); var deltaTime = (thisInterval - lastInterval);
lastInterval = thisInterval; lastInterval = thisInterval;
if (physicsEnabled !== previousPhysicsStatus) { timeElapsed += deltaTime;
if (!physicsEnabled && !timerset) {
updateOverlays(physicsEnabled); var nearbyEntitiesReadyCount = Window.getPhysicsNearbyEntitiesReadyCount();
sample = Audio.playSound(tune, { var stabilityCount = Window.getPhysicsNearbyEntitiesStabilityCount();
localOnly: true, var nearbyEntitiesCount = Window.getPhysicsNearbyEntitiesCount();
position: MyAvatar.headPosition,
volume: VOLUME var stabilityPercentage = (stabilityCount / STABILITY);
}); if (stabilityPercentage > 1) {
timeElapsed = 0; stabilityPercentage = 1;
timerset = true;
}
previousPhysicsStatus = physicsEnabled;
} }
if (timerset) { var stabilityProgress = (MAX_X_SIZE * 0.75) * stabilityPercentage;
timeElapsed += deltaTime;
if (timeElapsed >= MAX_ELAPSED_TIME) {
updateOverlays(true);
sample.stop();
sample = null;
timerset = false;
}
var entitiesLoadedPercentage = 1;
if (nearbyEntitiesCount > 0) {
entitiesLoadedPercentage = nearbyEntitiesReadyCount / nearbyEntitiesCount;
} }
var entitiesLoadedProgress = (MAX_X_SIZE * 0.25) * entitiesLoadedPercentage;
var progress = stabilityProgress + entitiesLoadedProgress;
if (progress >= target) {
target = progress;
}
currentProgress = lerp(currentProgress, target, 0.2);
var properties = {
localPosition: { x: -(currentProgress / 2) + 2, y: DESTINATION_CARD_Y_OFFSET - 0.99, z: 5.45 },
dimensions: {
x: currentProgress,
y: 2.8
}
};
Overlays.editOverlay(loadingSphereID, { Overlays.editOverlay(loadingBarProgress, properties);
position: Vec3.sum(Vec3.sum(MyAvatar.position, {x: 0.0, y: -1.7, z: 0.0}), Vec3.multiplyQbyV(MyAvatar.orientation, {x: 0, y: 0.95, z: 0})) if (physicsEnabled && (currentProgress >= (MAX_X_SIZE - EPSILON))) {
}); updateOverlays(physicsEnabled);
Script.setTimeout(update, BASIC_TIMER_INTERVAL_MS); timer = null;
return;
}
timer = Script.setTimeout(update, BASIC_TIMER_INTERVAL_MS);
} }
Script.setTimeout(update, BASIC_TIMER_INTERVAL_MS);
Overlays.mouseReleaseOnOverlay.connect(clickedOnOverlay); Overlays.mouseReleaseOnOverlay.connect(clickedOnOverlay);
Window.domainChanged.connect(domainChanged); Window.domainChanged.connect(domainChanged);