Hello,
I’m not sure if I’m making it right or not but how can we use async await with this ?
I tried it be it makes my code not working.
Is this implemented or will it ask some work to be done ?
Hello,
I’m not sure if I’m making it right or not but how can we use async await with this ?
I tried it be it makes my code not working.
Is this implemented or will it ask some work to be done ?
The scene loader is async await compatible (Promise based),
Maybe that is what you are looking for?
https://doc.babylonjs.com/api/classes/babylon.sceneloader#importmeshasync
I’m not sure I could use completely this.
Internally I use addMeshTask & addMeshTask to load every assets I have.
I can definitely add some promises on the AssetsManager.
Do you want something like that?
await assetManager.loadAsync()
That would be perfect !
Would you be kind to open an issue on our repo detailing all the xxxAsync functions you would like on the AssetsManager?
I could work on it this week
Sure, here is the issue : Feature Request - make assetsManager await compatible · Issue #5937 · BabylonJS/Babylon.js · GitHub
I’m not sure we would need more async function from the assetManager.
I will work on that already
How does it work?
I dont succeed to get it to run here:
https://www.babylonjs-playground.com/#ZJYNY#144
Woot! this is a big bug!!! I’ll fix it for net nightly
Thanks for the heads up!
thanks
ran into this as well… in the mean time doing… sleep is an async wrapped fn.
const wrapLoad = async () => {
let loaded = false;
const meshTask = this.assetManager.addMeshTask(
entityId,
"",
rootURL,
sceneFilename
);
meshTask.onSuccess = function(task) {
log.debug(task);
loaded = true;
};
meshTask.onError = function(task, message, exception) {
console.log(task, message, exception);
debugger;
};
this.assetManager.load();
while (!loaded) {
await sleep(10);
}
};
await wrapLoad();