Load meshes progressively

Recommended Posts

Thanks @JCPalmer and @JonhK

Obviously I disabled the loading screen and started the rendering cycle, but the meshes were still displayed only once the whole file had been processed.

Unfortunately it is not a .babylon file but a custom file that must be read sequentially.

I solved the problem by using an async function with a wait function (Promise) of 1ms each cycle(mesh)

Share this post

Link to post
Share on other sites

This might also have to do with textures which are done after geometry.  One other way to create the effect is to not start the render loop till ready, disable all meshes (in Blender you can disable in the .babylon file).  When everything is ready, start the render loop which enables one mesh disabled per render.  When none still disabled found, stop checking.

var allLoaded = false;
engine.runRenderLoop(function () {
     if (!allLoaded){
         var foundDisabled = true;
         for (var i = 0, n = scene.meshes.length; i < n; i++){
             if (!scene.meshes[i].isEnabled) {
                 scene.meshes[i].setEnabled = true;
                 foundDisabled  = true;
         allLoaded = !foundDisabled;


Share this post

Link to post
Share on other sites

Thanks, @JCPalmer, that solution may be good in some cases but it is an aesthetic solution.

With the async function the meshes are loaded as soon as they are processed and therefore there is a perception of higher loading speed , which was my goal.

function sleep(ms) {
        return new Promise(resolve => setTimeout(resolve, ms));

    async function MeshManagerLoadMeshes(binaryBuffer) {
        while (binaryBuffer.offset < binaryBuffer.buffer.length) {
            <read and parse mesh>
            await sleep(1);


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.