Perform function on import success

I am importing a photo dome through a button click. On mobile phones the import works slower due to lower RAM. So I am trying to trigger a function such that when the photo dome has completed importing, this function will be called. How do I achieve this?

According to your benchmarks, what specific operation takes time and why. If its the loading of the texture, try:

     var photoDome = new BABYLON.PhotoDome("example", "", {}, scene);
     var domeTexture = new BABYLON.Texture("./textures/360photo.jpg", scene);
     domeTexture.onLoadObservable.add(( texture ) => photoDome.texture = texture);

But if its the parsing of the PhotoDome itself, try attaching a callback:

var photoDome = new BABYLON.PhotoDome("example", "./textures/360photo.jpg", {}, scene);
photoDome.onReady = () => { /* Do something */ }

To be honest, I too do not know why there is an onLoadErrorObservable on the PhotoDome instance but no onLoadObservable. Also, maybe a { enabled: false } option would be useful, so that the photoDome can be manually enabled via dome.setEnabled(true) in the onLoadObservable Observer callback. So someone could do something like this:

     var photoDome = new BABYLON.PhotoDome("exampleDome", "./textures/360photo.jpg", { enabled: false }, scene);
     photoDome.onLoadObservable.add(( dome ) => { dome.setEnabled(true) });
2 Likes

I agree we need a onload observable :slight_smile: Adding @RaananW to track it :slight_smile:

1 Like

Thiws obviously make sense :slight_smile:
Here it is - OnLoadObservable for *dome by RaananW · Pull Request #9750 · BabylonJS/Babylon.js (github.com)