const BABYLON = require("babylonjs");

class RenderLoader {

    constructor(engine, scene, onFinish) {
        let music = new BABYLON.Sound("Loading", "assets/audio/intro.ogg", scene, null, { loop: false, autoplay: true });
        engine.displayLoadingUI();
        engine.loadingUIText = "From the creators of the epic Lineage 2 C2 - BloodRage Server...";


        this.scene = scene;
        this.loader = new BABYLON.AssetsManager(this.scene);
        //this.loader.useDefaultLoadingScreen = false;
        this.loader.onFinish = onFinish;
        this.assets = {};
        this.animations = {};
    }

    preloadAssets() {
        this.loadMesh('shirt', 'lady.babylon', this.onLoaded.bind(this));
        this.loadMesh('viking', 'viking.babylon', this.onVikingLoaded.bind(this));
        //var music = new BABYLON.Sound("Music", "assets/audio/music.mp3", this.scene, null, { loop: true, autoplay: true });

        this.loader.load();
    }

    onVikingLoaded(t) {
        this.onLoaded(t);
        this.addAnimation('viking', 'idle', 0, 320);
        this.addAnimation('viking', 'walk', 323, 364);
        this.addAnimation('viking', 'dance', 367, 738);
    }

    /**
     * Add an animation to this character
     */
    addAnimation(mesh, name, from, to) {
        this.animations[mesh] = this.animations[mesh] || {};
        this.animations[mesh][name] = {from:from, to:to};
        console.log('addAnimation', this.animations, name, from, to);
    }

    onLoaded (t) {
        this.assets[t.name] = [];
        console.group();
        for (let m of t.loadedMeshes) {
            m.setEnabled(false);
            m.isPickable = true;
            this.assets[t.name].push(m);
            console.log(`%c Loaded : ${m.name}`, 'background: #333; color: #bada55');
        }
        console.log(`%c Finished : ${t.name}`, 'background: #333; color: #bada55');

        console.groupEnd();

    }

    loadMesh(name, file, callback) {
        var mesh = this.loader.addMeshTask(name, "", "assets/meshes/", file);
        mesh.onSuccess = callback;

    }
}

module.exports = RenderLoader;

@@ -354,16 +354,604 @@
 r...%22;%0A%0A
+        setTimeout(function() %7B%0A            engine.loadingUIText = %22Alberto aka 'Valanar', the game master...%22;%0A        %7D.bind(this), 1500);%0A%0A        setTimeout(function() %7B%0A            engine.loadingUIText = %22Javier aka 'p0w3rf1y', the bsoe's master...%22;%0A        %7D.bind(this), 3200);%0A%0A        setTimeout(function() %7B%0A            engine.loadingUIText = %22An innovative creation, defying the laws of nature...%22;%0A        %7D.bind(this), 4800);%0A%0A        setTimeout(function() %7B%0A            engine.loadingUIText = %22Get ready for an unforeseen gaming experience...%22;%0A        %7D.bind(this), 6000);%0A
 %0A       
@@ -1509,25 +1509,90 @@
     
-this.loader.load(
+setTimeout(function() %7B%0A            this.loader.load();%0A        %7D.bind(this), 6000
 );%0A 

Add loading screen