Waiting for a material to be completely ready

Hello!

In this playground, I load a model, wait one second and then load a new material and apply to the model.

It gives a short flash when the materials are swapped, even when using scene.whenReadyAsync()

Playground: https://playground.babylonjs.com/#0OS3RL#7

In case It isn’t clear, I captured the frames. I basically want to avoid the two middle frames, so the material is swapped directly.




It may be possible by stopping the render, but I don’t want too much lack if the camera is moving.

Is there another way to “prepare” the new material before swapping?

Thanks

Material readiness is not part of scene.whenReadyAsync because the compilation of a material is relative to a mesh. You can use Material.forceCompilationAsync to make sure a material is ready to be used for a given mesh:

1 Like

Thanks!

That makes sense, although I had to include scene.whenReadyAsync in the promises for it to work