diff --git a/interface/src/scripting/WindowScriptingInterface.h b/interface/src/scripting/WindowScriptingInterface.h
index ef3dfcef4b..c5e558eb3a 100644
--- a/interface/src/scripting/WindowScriptingInterface.h
+++ b/interface/src/scripting/WindowScriptingInterface.h
@@ -41,6 +41,8 @@
* Read-only.
* @property {number} y - The y display coordinate of the top left corner of the drawable area of the Interface window.
* Read-only.
+ * @property {boolean} interstitialModeEnabled=true - true
if the interstitial graphics are displayed when the
+ * domain is loading, otherwise false
.
*/
class WindowScriptingInterface : public QObject, public Dependency {
@@ -620,9 +622,10 @@ signals:
void redirectErrorStateChanged(bool isInErrorState);
/**jsdoc
- * Triggered when interstitial mode changes.
+ * Triggered when the interstitial mode changes.
* @function Window.interstitialModeChanged
- * @param {bool} interstitialMode - The mode of the interstitial is changed to.
+ * @param {bool} interstitialMode - The new interstitial mode value. If true
, the interstitial graphics are
+ * displayed when the domain is loading.
* @returns {Signal}
*/
void interstitialModeChanged(bool interstitialMode);
diff --git a/scripts/defaultScripts.js b/scripts/defaultScripts.js
index 5df1b3e511..bd7e79dffc 100644
--- a/scripts/defaultScripts.js
+++ b/scripts/defaultScripts.js
@@ -40,8 +40,8 @@ var DEFAULT_SCRIPTS_SEPARATE = [
];
if (Window.interstitialModeEnabled) {
- DEFAULT_SCRIPTS_COMBINED.push("system/interstitialPage.js");
- DEFAULT_SCRIPTS_COMBINED.push("system/redirectOverlays.js");
+ // Insert interstitial scripts at front so that they're started first.
+ DEFAULT_SCRIPTS_COMBINED.splice(0, 0, "system/interstitialPage.js", "system/redirectOverlays.js");
}
// add a menu item for debugging
diff --git a/scripts/system/interstitialPage.js b/scripts/system/interstitialPage.js
index e2db032d8c..b7c5809b3a 100644
--- a/scripts/system/interstitialPage.js
+++ b/scripts/system/interstitialPage.js
@@ -62,11 +62,23 @@
var DEFAULT_DIMENSIONS = { x: 24, y: 24, z: 24 };
+ var BLACK_SPHERE = Script.resolvePath("/~/system/assets/models/black-sphere.fbx");
+ var BUTTON = Script.resourcesPath() + "images/interstitialPage/button.png";
+ var BUTTON_HOVER = Script.resourcesPath() + "images/interstitialPage/button_hover.png";
+ var LOADING_BAR_PLACARD = Script.resourcesPath() + "images/loadingBar_placard.png";
+ var LOADING_BAR_PROGRESS = Script.resourcesPath() + "images/loadingBar_progress.png";
+
+ ModelCache.prefetch(BLACK_SPHERE);
+ TextureCache.prefetch(BUTTON);
+ TextureCache.prefetch(BUTTON_HOVER);
+ TextureCache.prefetch(LOADING_BAR_PLACARD);
+ TextureCache.prefetch(LOADING_BAR_PROGRESS);
+
var loadingSphereID = Overlays.addOverlay("model", {
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 })),
orientation: Quat.multiply(Quat.fromVec3Degrees({ x: 0, y: 180, z: 0 }), MyAvatar.orientation),
- url: Script.resolvePath("/~/system/assets/models/black-sphere.fbx"),
+ url: BLACK_SPHERE,
dimensions: DEFAULT_DIMENSIONS,
alpha: 1,
visible: isVisible,
@@ -157,7 +169,7 @@
var loadingToTheSpotID = Overlays.addOverlay("image3d", {
name: "Loading-Destination-Card-GoTo-Image",
localPosition: { x: 0.0, y: -1.75, z: -0.3 },
- url: Script.resourcesPath() + "images/interstitialPage/button.png",
+ url: BUTTON,
alpha: 1,
visible: isVisible,
emissive: true,
@@ -171,7 +183,7 @@
var loadingToTheSpotHoverID = Overlays.addOverlay("image3d", {
name: "Loading-Destination-Card-GoTo-Image-Hover",
localPosition: { x: 0.0, y: -1.75, z: -0.3 },
- url: Script.resourcesPath() + "images/interstitialPage/button_hover.png",
+ url: BUTTON_HOVER,
alpha: 1,
visible: false,
emissive: true,
@@ -186,7 +198,7 @@
var loadingBarProgress = Overlays.addOverlay("image3d", {
name: "Loading-Bar-Progress",
localPosition: { x: 0.0, y: -0.86, z: 0.0 },
- url: Script.resourcesPath() + "images/loadingBar_progress.png",
+ url: LOADING_BAR_PROGRESS,
alpha: 1,
dimensions: { x: TOTAL_LOADING_PROGRESS, y: 0.3},
visible: isVisible,
@@ -202,7 +214,7 @@
var loadingBarPlacard = Overlays.addOverlay("image3d", {
name: "Loading-Bar-Placard",
localPosition: { x: 0.0, y: -0.99, z: 0.4 },
- url: Script.resourcesPath() + "images/loadingBar_placard.png",
+ url: LOADING_BAR_PLACARD,
alpha: 1,
dimensions: { x: 4, y: 2.8 },
visible: isVisible,
@@ -273,12 +285,21 @@
}
}
+ function restartAudio() {
+ tune.ready.disconnect(restartAudio);
+ startAudio();
+ }
+
function startAudio() {
- sample = Audio.playSound(tune, {
- localOnly: true,
- position: MyAvatar.getHeadPosition(),
- volume: VOLUME
- });
+ if (tune.downloaded) {
+ sample = Audio.playSound(tune, {
+ localOnly: true,
+ position: MyAvatar.getHeadPosition(),
+ volume: VOLUME
+ });
+ } else {
+ tune.ready.connect(restartAudio);
+ }
}
function endAudio() {
@@ -614,5 +635,11 @@
}
}
+ // location.hostname may already be set by the time the script is loaded.
+ // Show the interstitial page if the domain isn't loaded.
+ if (!location.isConnected) {
+ domainChanged(location.hostname);
+ }
+
Script.scriptEnding.connect(cleanup);
}());