Jump to content

onProgress can't run second time


syed samoon
 Share

Recommended Posts

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???

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

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...