scene.onMeshImportedObservable does not work for gltf files.
This is a recurring pg.
Checking the console, you can see that the callback function is not executed.
And I tried the .babylon file, and it works
scene.onMeshImportedObservable does not work for gltf files.
This is a recurring pg.
Checking the console, you can see that the callback function is not executed.
And I tried the .babylon file, and it works
great catch!
This observable is notified by the mesh’s Parse function, which is not used in the glTF loader. I’ll ping @bghgary for his opinion on adding a notify call during glTF loading
Hmm, interesting. I didn’t know about this observable. It seems like an odd place for a callback. I’m not sure we should continue this pattern for future code.
For glTF, you can do this: https://playground.babylonjs.com/#EYM3P3#7
Indeed.
I wasn’t actually looking for this, but for an observable after the model file is loaded.
Because I saw that someone wanted to change the name of the “root” node to the name of the model file after the model file was loaded.
I found this observer by accident, and it’s actually not very helpful for my purposes.
But your playground example made me learn something new.
If you want to know when the model is loaded, you can just wait for the promise to complete.
PG: https://playground.babylonjs.com/#EYM3P3#8
EDIT: Actually, your code already has a continuation (e.g., .then
), so you can also simply add code there.
Agree with both statements