Closed Amoki closed 4 years ago
An async function is a function that always returns a Promise. Meaning we can use it as a Promise and call a .then().
loadGLTFIntoModel().then(() => {
})
In your example, you can also do
utils.loadJSON("my_model.gltf", async (json) => {
await loadGLTFIntoModel();
});
Aha cool. BTW I'd like to remove the parsingCtx
argument from getAttachment
if that's OK with you? Just to keep that parsing context private to loadGLTFIntoXKTModel
.
OK!
Would you be able to fix up the examples pages in ./examples?
examples/XKTModel_load_glTF_Duplex.html examples/XKTModel_load_glTF_MAP.html examples/XKTModel_load_glTF_Schependomlaan.html
They just need to be tweaked to use the asynch bits, and need an getAttachment
callback.
It seems that we can't have
await
inside a non-asynch function's callback, ie.This could be a problem making this code integrate with other utilities within examples - not quite sure how to resolve this - either to make functions like
utils.loadJSON
use promises, or makeloadGLTFIntoXKTModel
use a callback?