Jump to content

Progress bar for mesh and texture


ozRocker
 Share

Recommended Posts

I know how to get the progress of the mesh as its being loaded from the callback for BABYLON.SceneLoader.Load() however this only counts the .babylon file and not the textures.  I end up with a misleading progress bar because my textures are about 3 times the size of the babylon.js file.  It looks like everything has frozen when the progress bar reaches the end.  Is there a way to also include loading times for all textures?

Link to comment
Share on other sites

8 hours ago, jellix said:

A way could be to prelad the textures via the AssetManager and afterwards to load the meshes. The textures shouldn't take the same time to load again.

the AssetManager looked promising, but I can't seem to find a progress callback

Link to comment
Share on other sites

4 hours ago, Deltakosh said:

Hey you can check scene.getWaitingItemsCount()

This value is maintained by the scene while loading scene resources

Do you know how I can get download progress from that function?  Because getWaitingItemsCount will always return 2 (diffuse map and normal map) and the diffuse map is the one that can take a while to load.

Link to comment
Share on other sites

I figured out a way, but I'm not sure if its the best way.

I can preload the diffuse texture using XHR 'cos with XHR I can get a progress event.

diffuseXHR = new XMLHttpRequest()
diffuseXHR.open("GET", scanID+"/diffuse.jpg")
diffuseXHR.responseType = 'arraybuffer';
diffuseXHR.onprogress = function(e) {
	if(e.lengthComputable) {
		console.log("diffuse progress: "+e.loaded);
	}
}
diffuseXHR.onload = function(e) {
	if (this.status == 200) {
		diffuseData = this.response;
		loadScene();
	}
}
diffuseXHR.send()

then after the scene is loaded I can use:

mesh.material.diffuseTexture = BABYLON.Texture.LoadFromDataString("diffuse",diffuseData,scene);

Link to comment
Share on other sites

I'm using a .manifest file to cache the scene.  I'm wondering, is there a way to check if the .babylon file exists in browser cache  without loading the scene?  I'm trying to determine the amount of bytes to be loaded before the images start downloading so I can determine total progress bar size

Link to comment
Share on other sites

@ozRocker 

You should be able to do that using the BABYLON.Database functions, sceneloader uses these to do it.

https://raw.githubusercontent.com/BabylonJS/Babylon.js/master/dist/babylon.2.5.max.js ctrl + f  & search for "Database" to locate it all.

http://doc.babylonjs.com/classes/2.5/Database



Also, a simple PG, it checks if a manifest exists, checking if the babylon file is already cached & up-to-date would be the next step.
http://www.babylonjs-playground.com/#17FHRO#1

best of luck :)

Link to comment
Share on other sites

3 hours ago, aWeirdo said:

@ozRocker 

You should be able to do that using the BABYLON.Database functions, sceneloader uses these to do it.

https://raw.githubusercontent.com/BabylonJS/Babylon.js/master/dist/babylon.2.5.max.js ctrl + f  & search for "Database" to locate it all.

http://doc.babylonjs.com/classes/2.5/Database



Also, a simple PG, it checks if a manifest exists, checking if the babylon file is already cached & up-to-date would be the next step.
http://www.babylonjs-playground.com/#17FHRO#1

best of luck :)

Thanks for the tip!  I've been playing around with BABYLON.Database, including the "private" functions that I can see in the GIT raw file.  It seems that to get the version number of the scene file in the database you have to load the scene file.  I was hoping to get the version number before loading the scene so I can figure out the size of the progress bar before loading the .babylon file.  Basically, I'm trying to find out if the scene is cached (.manifest file matches database file) before any scene loading is done.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...