syed samoon Posted February 20, 2018 Share Posted February 20, 2018 Hi Everyone, i have doubt in progressHandler using importmesh BABYLON.SceneLoader.ImportMesh("", "assets/", "meshes.babylon", scenes, function (newMeshes, particleSystems, skeletons) { obstacleBig = scenes.getMeshByName("terminal"); obstacleSmall2 = scenes.getMeshByName("sky_bin"); obstacleSmall = scenes.getMeshByName("round_planter"); coin = scenes.getMeshByName("Coin"); boostObj = scenes.getMeshByName("Boost"); floor[0] = scenes.getMeshByName("Platform001"); floor[1] = scenes.getMeshByName("Platform002"); stLamp = scenes.getMeshByName("lamp"); wideAd = scenes.getMeshByName("Ad_B"); lengthAd = scenes.getMeshByName("Ad_C"); plot = scenes.getMeshByName("platform_LOD_1"); directionArrow = scenes.getMeshByName("Sign_arrow"); }, function (evt) { if (evt.lengthComputable) { loadingProgress = (evt.loaded * 100 / evt.total).toFixed(); } }, function(scenes, msg, exception){ console.log("error while loading assets"); console.log(scenes); console.log(msg); console.log(exception); } ); onprogress functions will be run at 1st time but not in second time means when i run my game at first time on pc it will run after that when i refresh/run the game the onProgress function is not executing. but it will run after clearing the cache file(only for 1st time) i can't clear cache in everytime so anyone have solution for this??? Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted February 20, 2018 Share Posted February 20, 2018 Perhaps evt.lengthComputable is not evaluating to true. The refresh should also be much faster, since there is no network delay. I would make a counter which gets incremented in an else to the evt.lengthComputable if. Then in the success callback write the value to the console. You can then compare between runs. Does not fix, but being able to refine the issue at little cost is always of great importance. If right so far, then investigate the code behind lengthComputable in the repo. It may be that this is really a browser call. In that case, nothing is really doable by the framework. Do not tell anybody, but in that case just fake it. I can remember just incrementing manually a very small amount (not here), then when done shoot the value to 100% at the end. No one will every know. syed samoon 1 Quote Link to comment Share on other sites More sharing options...
Guest Posted February 20, 2018 Share Posted February 20, 2018 I think @JCPalmer is right: the second time the data will be in cache so lengthComputable will be undefined Quote Link to comment Share on other sites More sharing options...
syed samoon Posted February 21, 2018 Author Share Posted February 21, 2018 8 hours ago, Deltakosh said: second time the data will be in cache so lengthComputable will be undefined thank you @Deltakosh & @JCPalmer but my problem is the onProgress function is not executing in second time for example function (evt) { console.log(evt); console.log("hello world"); if (evt.lengthComputable) { loadingProgress = evt.loaded * 100 / evt.total; } else { loadingProgress = 100; console.log("hello world"); dlCount = evt.loaded / (1024 * 1024); console.log("Loading, please wait..." + Math.floor(dlCount * 100.0) / 100.0 + " MB already loaded."); } } the console log line is also not executing is there anything wrong in this script??? && my question Is the onProgress function will be execute at 1st time only? Quote Link to comment Share on other sites More sharing options...
Guest Posted February 21, 2018 Share Posted February 21, 2018 can you share the running code somewhere? 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.