ozRocker Posted December 29, 2016 Share Posted December 29, 2016 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? Quote Link to comment Share on other sites More sharing options...
jellix Posted December 29, 2016 Share Posted December 29, 2016 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. Quote Link to comment Share on other sites More sharing options...
aWeirdo Posted December 29, 2016 Share Posted December 29, 2016 Hi @ozRocker What i did was to split my progress bar into equally big bits per asset, so if you have 10 assets, each asset would increase the progress bar by 10% as they finish loading, etc, It's not as accurate, but it's much simpler to work with. Quote Link to comment Share on other sites More sharing options...
ozRocker Posted December 29, 2016 Author Share Posted December 29, 2016 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 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 4, 2017 Share Posted January 4, 2017 Hey you can check scene.getWaitingItemsCount() This value is maintained by the scene while loading scene resources Quote Link to comment Share on other sites More sharing options...
ozRocker Posted January 5, 2017 Author Share Posted January 5, 2017 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. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 5, 2017 Share Posted January 5, 2017 It is tough to get the total value as the waiting items count is populated as we load the scene. I would recommend a wait ring instead of a progress bar actually Quote Link to comment Share on other sites More sharing options...
ozRocker Posted January 5, 2017 Author Share Posted January 5, 2017 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); Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 5, 2017 Share Posted January 5, 2017 really good idea! Love it Quote Link to comment Share on other sites More sharing options...
ozRocker Posted January 5, 2017 Author Share Posted January 5, 2017 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 Quote Link to comment Share on other sites More sharing options...
aWeirdo Posted January 5, 2017 Share Posted January 5, 2017 @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 Quote Link to comment Share on other sites More sharing options...
ozRocker Posted January 5, 2017 Author Share Posted January 5, 2017 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.