Throttle processing power/bandwidth to keep stable FPS during loading

Applying it to a property (like material.diffuseTexture) basically takes no time, it’s just setting a variable to the value of another variable.

Everything is done when creating the texture by new BABYLON.Texture("dropbox url").

You should check that by simply creating an empty raw RGBA texture (const texture = BABYLON.RawTexture.CreateRGBATexture(null, width, height, scene)) you don’t experience the hiccups. If there are still some hiccups, you can’t do anything against them. If not, then you can try this:

  • create an empty RGBA texture in the main thread
  • download your picture from a worker thread, see for eg Loading Images with Web Workers - DEV Community. You will need to generate raw RGBA data, though, not a blob as it is done in this link (maybe you can create an ImageBitmap from the blob, then draw this bitmap in an offscreen canvas and finally get the RGBA data from the canvas)
  • pass the raw RGBA data from the worker thread to the main thread and update the raw RGBA texture with those data

I think it’s the fastest it can be. If there are still some hiccups, it’s because of the texture update processing, which is unavoidable.

5 Likes