Hi there,
my application starts with a very basic scene and then, when the user click on some mesh, the current scene is disposed and then assigned to a new one. The problem is that the new scene could be more heavy to load (depending on its dynamic content) and the result is that the user could be waiting fot the new scene loading some seconds and the current scene is freezed until the new one is not loaded (so the final effect is that is all stuck for some seconds).
Is there any best practice to avoid this behaviour?
I’d like to load the new scene in background and show a sort of splash screen during loading or directly inside the scene, and then when the new scene is ready for display, to change the scene.
At the moment i do something like that in my code:
scene.onPointerObservable.add(async function(pointerInfo){
if (pointerInfo.type === BABYLON.PointerEventTypes.POINTERPICK){
// We try to pick an object
try{
let pickResult = pointerInfo.pickInfo;
let nome = pickResult.pickedMesh.name;
if (nome.includes('Mag') || nome.includes('Tetto')){
let numMag = pickResult.pickedMesh.metadata['datiMag']['Codice'];
if(mag!==null){
mag = null;
}
map = null;
mag = new Magazzino(engine,0,0,numMag);
scene.dispose();
scene = null;
scene = await mag.createMag();
}
}catch(evt){
console.log("Click su nessuna mesh ->"+evt.toString());
}
}
});
Thanks in advance