Scene external readiness checking

I was wondering whether something like this could be added to scene.ts?

I saw doc talking about readiness & parallel shader compilation, which is the reason I am going the Feature Request route instead of PR. Anytime, there are side effects related to the way something is done, those who understand what the side effects are should probably be making the actual coding change.

If I understand correctly you want to give your go for the scene to be declared ready right?

One way to do it today is with scene._addPendingData(). Maybe we could make that function public?

Yes, there can be things that are wished to be loaded that are not directly under the control of BJS, but want scene.executeWhenReady() to take that into account as well.

Examples might be loading instrument or voice font files for Web Audio Fonts (my fork converts them to JSON format). There are also audio files (.mp3 etc) to be used as Input response for a Convolver node (think adding reverb to audio). These have their own call to audioContext.decodeAudioData(), which is async.

Even Files for Babylon.Sound are not taken into account in scene.isReady(). I do not know about .ENV files either. It does not have to even be audio related. Those are just off the top of my head.

A quick look, _addPendingData and _removePendingData could be possibly work. Due to additional async stuff that could happen after the file is in memory, I am going to have to see if this is going to work by trying code it as if they were public, first. I’ll let you know.


Ok, this will work out. While you are close by, putting a comment in about why you are not stopping with the first failed material to be ready, wouldn’t hurt.

Should be accessible with Expose pendingData Apis publicly by sebavan · Pull Request #12760 · BabylonJS/Babylon.js · GitHub

1 Like