pichou Posted October 1, 2018 Share Posted October 1, 2018 Hello babylonjs community, Is there a way to have the file weight uploaded with the assetManager whatever the type of file? Cheerz, Pichou Quote Link to comment Share on other sites More sharing options...
Guest Posted October 1, 2018 Share Posted October 1, 2018 What do you mean? Getting the file size before loading to get progess into? This is dependent on your server Quote Link to comment Share on other sites More sharing options...
pichou Posted October 1, 2018 Author Share Posted October 1, 2018 Nope to be more specific, the exact thing I am looking for is to know the entire scene weight. Meaning what is the total of data in bytes that need to be loaded in order to render the scene. So after everything has been loaded and not during the progress. Maybe a way to reach the "Content-Length" header of each asset request? Quote Link to comment Share on other sites More sharing options...
Guest Posted October 1, 2018 Share Posted October 1, 2018 Not sure if this is supported by XHR. So far if the xhr has a content length we will use it to report progress so we could also expose it but this is not always supported by the server Quote Link to comment Share on other sites More sharing options...
pichou Posted October 1, 2018 Author Share Posted October 1, 2018 Hum I see! I found we could get the length with the xhr like this : ```parseInt(xhr.getResponseHeader("Content-Length"))``` if you already use it for the progress, I guess we can also have it somehow when the loading is finished? If some task/file doesn't have Content-Length indicated by the server it is ok because the result I want doesn't have to be exact. Quote Link to comment Share on other sites More sharing options...
pichou Posted October 1, 2018 Author Share Posted October 1, 2018 When I go to my network console and look at the headers, there is always the Content-Length. Maybe there is a way to get the xhr of a task in the assetManager? This way I could calculate the weight I am looking for? Quote Link to comment Share on other sites More sharing options...
Guest Posted October 1, 2018 Share Posted October 1, 2018 This is not exposed actually So it should be easier to do on your side for now Quote Link to comment Share on other sites More sharing options...
pichou Posted October 1, 2018 Author Share Posted October 1, 2018 Ok I know how to do it then. But that means I will have to load the files twice and I don't want to do that both for the servers and clients. Guess I will find another way! Thanks for your help @Deltakosh Quote Link to comment Share on other sites More sharing options...
brianzinn Posted October 2, 2018 Share Posted October 2, 2018 If you are just using MeshAssetTask , you could use SceneLoader.ImportMesh directly, which has a SceneLoaderProgressEvent, which tells you how many bytes have been downloaded. If you know already how big your scene is in total, you could then work backwards and build your own custom asset manager with realistic progress based on bytes downloaded/total. That event has a property 'lengthComputable', which is often false. Progress is, if lengthComputable == true evt.loaded / evt.total. If not lengthComputable then it's evt.loaded / knownFileSize. At least that strategy works for models, so maybe that is useful. Cheers. pichou and GameMonetize 2 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.