In react-babylonjs suspense smooth transition on model load

Is there any to add smooth transition between suspense fallback and loaded model?

cc @brianzinn

What did you have in mind?

You can useEffect with an empty dependency array and return what would be called when the fallback component unmounts.

Another possibility is to override the dispose method on your fallback component. ie:

const originalDispose = fallbackModel.dispose
fallbackModel.dispose = () => {
  // put your code here?
  // call original at some point - ie: when an animation completes?
  originalDispose.call(fallbackModel)
}

You could trigger code as well when the model is loaded. There’s a callback you can provide to the available hooks or Model component depending on how you are loading the model.

edit: There’s also a disposeOnUnmount={false} prop you can add to let the renderer know that you are managing the lifetime of an object yourself, but you will lose that ref yourself, so will need long running code as above.

2 Likes