Hello,
it does seems you try to manage in the same time all loaded object in function (xhr)
you should try to manage outside .
create a tab
var progressLoading =[]
progressLoading.push({ way : ‘glb/asse1.glb’,name’garden’,shadow:true }) ;
…
progressLoading.push({ way : ‘glb/asse6.glb’,name’house’,shadow:true }) ;
create a new event to manage outside .
var assetLoaded =new Event(‘assetLoaded’);
create importObjet(way,name,shadow ){
…
loader.load( way , function(object){} , function(xhr) , function(error){} )
}
in loader.load( way , function(object){} , function(xhr) , function(error){} )
at the end of function (object) {} put an window.dispatchEvent(assetLoaded);
in function(xhr ) {} use this function only to manage the display of loading progression of only one asset
and manage all the load outside like this
var numberAssetLoaded = 0 ;
window.addEventListener(‘assetLoaded’,(e) => {
numberAssetLoaded += 1;
if ( numberAssetLoaded === progressLoading.length ) {
…
…
init();
}
else{
importObjet(progressLoading[numberAssetLoaded].way,progressLoading[numberAssetLoaded].name,progressLoading[numberAssetLoaded].shadow ); }
});
EDIT: i have to explain my solution ( my English is not good ) . the main idea , is to see that in
loader.load( way , function(object){} , function(xhr) , function(error){} )
function(object){} is to manage once object have been loaded
function(xhr){} is to manage when object is loading but not again loaded
function(error){}
so if you try to manage all object loaded in function(xhr){} it could not work very well