I have implemented a custom loading screen ( a simple div with higher z-index and span the entire canvas ) that is activated on load and gets deactivated by adding display: none after the scene is loaded.
First, I create and register two prototype functions for enabling and hiding the loading UI like so…
function customLoadingScreen() {
}
customLoadingScreen.prototype.displayLoadingUI = function () {
loadingScreenDiv.innerHTML = 'loading';
};
customLoadingScreen.prototype.hideLoadingUI = function () {
loadingScreenDiv.style.display = 'none';
};
Second, I register the customLoadingScreen in the engine like so…
var loadingScreen = new customLoadingScreen();
engine.loadingScreen = loadingScreen;
Third, I enable the loading screen right before calling the createScene() function like so…
engine.displayLoadingUI();
startRenderLoop(engine, canvas);
window.scene = delayCreateScene();
Fourth, I disable the loading screen right before I return the scene in delayCreateScene() function like so…
engine.hideLoadingUI();
return scene;
Yet, the loading screen doesn’t appear and my UI is all white till the model loads.
Here’s the codepen…