hcmetal Posted October 19, 2018 Share Posted October 19, 2018 Hello, everyone, I am trying to make a custom loading screen without using the built-in loading UI. So I set up an assetsManager: const assetsManager = new BABYLON.AssetsManager(scene); assetsManager.useDefaultLoadingScreen = false; const meshTask = assetsManager.addMeshTask( "load meshes", "", "/assets/", "hotel.babylon" ); and try to use: assetsManager.onProgress = function(remainingCount, totalCount) { // Some calculation logic and sent the result to other UI components... }; It works but there are two problems: 1. The counting does not take the texture (related to the exported materials in the .babylon file) loading into consideration, so the loading process is not fully covered. Do I need to set up textureTask for every single texture and re-assign them to the respective materials? I cannot wrap my mind around it... The built-in loading UI seems to take texture loading into account and disappears after all the textures are loaded. 2. The counting is based on file number rather than file size. I know in SceneLoader call back function there is an eval object that can calculate file size. Is it possible to do something similar with assetsManager? Hope someone can point me to the right direction. Thanks alot! Quote Link to comment Share on other sites More sharing options...
kcoley Posted October 19, 2018 Share Posted October 19, 2018 Hi @hcmetal. The assetsManager updates onProgress based on the number of remaining tasks, not necessarily on all the assets associated with a mesh. When loading multiple meshes, it may not know how many textures or submeshes are associated with it until it gets to the task. Though you may be able to query the number of meshes and materials present and use that in calculating your update, this wouldn't really handle file size, number of textures, etc. unless you already know how many textures and files you are expecting to load and can compare against that number. hcmetal 1 Quote Link to comment Share on other sites More sharing options...
hcmetal Posted October 19, 2018 Author Share Posted October 19, 2018 @kcoley, thanks for making it clear. I am wondering, assetsManager aside, is there a more "wholesome" way to cover all the various loading scenarios? For example, we need to load multiple .babylon files and additional texture files (not included in the .babylon files but later used in the scene, such as ao and lightmaps). Is creating tasks for every single asset and counting the number of tasks the best we can do, or with some combination of techniques, a more idea way of calculating loading progress can be achieved. By "idea" I mean evaluate loaded file size and show progress based on it. (for the sake of convenience let's suppose the total file size is known before hand) From the users' perspective, most of the loading time is spent on networking (downloading various files from a remote-server). Maybe this is an issue beyond Babylon and should be solved with some network magic (code) ? Quote Link to comment Share on other sites More sharing options...
Guest Posted October 22, 2018 Share Posted October 22, 2018 On 10/19/2018 at 4:29 PM, hcmetal said: Is creating tasks for every single asset and counting the number of tasks the best we can do This is probably the best way to get an accurate number 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.