Added loading animation
This commit is contained in:
21
src/loading.js
Normal file
21
src/loading.js
Normal file
@@ -0,0 +1,21 @@
|
||||
'use strict';
|
||||
// Small script used for the loading screen
|
||||
|
||||
import $ from 'jquery';
|
||||
|
||||
async function loadingOneCycle(){
|
||||
$("#loading").fadeOut(600, ()=>{
|
||||
$("#loading").fadeIn(600);
|
||||
})
|
||||
};
|
||||
|
||||
let timeoutID;
|
||||
function startLoadingAnimation(){
|
||||
timeoutID = setInterval(loadingOneCycle, 200);
|
||||
}
|
||||
|
||||
function stopLoadingAnimation(){
|
||||
clearInterval(timeoutID);
|
||||
}
|
||||
document.startLoadingAnimation = startLoadingAnimation;//So that's accessible from everywhere
|
||||
document.stopLoadingAnimation = stopLoadingAnimation;
|
||||
@@ -60,6 +60,7 @@ function startThreeJS(quality){
|
||||
|
||||
}
|
||||
console.log("Ready to render scene, placed objects : "+scene.children.length);
|
||||
document.stopLoadingAnimation();
|
||||
animate();
|
||||
|
||||
});
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import $ from 'jquery';
|
||||
|
||||
$("#menu button").on("click", event=>{
|
||||
$("#menu").fadeOut(300);
|
||||
$("#menu").fadeOut(300, ()=>document.startLoadingAnimation());
|
||||
const quality = $("#quality-select").val();
|
||||
console.log(`Starting Three.Js, with quality setting ${quality} !`);
|
||||
document.startThreeJS(quality);
|
||||
|
||||
Reference in New Issue
Block a user