Hello,
What would be the best way to preload videoTexture from a file server (URL)? I need to pre-load video clips but play them in the scene only when I need. I see at least two competing ways preloading videoTexture - (1) using AssetContainers and (2) using Blobs. Which one is more preferable?
There are advantages to each method, and it really depend on your usecase.
The asset container is a great caching mechanism! What it does is create the resources for you already, attaching it to an engine AND a scene. The caching here is in Babylon objects - you already have an object, ready to be used. Everything, including the processing of the data, was already done for you. The downside here is the same. It is bound to a scene and already created the assets. Depending on the use-case, you might not want to do that. For example, if you are loading a LOT of meshes, but only going to use 2 or 3. In this case you will use a lot of memory for cached assets that you will never use.
Using blobs is more lower-level. a Blob is a browser concept, and a blob can provide you with a URL that you can use at a future time. In this case, you can decide when to initialize a babylon object. So, for example, if you have a large mesh that might not be needed, you could generate a blob for it in the background, and only generate the mesh/material at a later point. The downside? This is technically using double (ca. a double? ) the memory. Because you create a blob, and then pass it to babylon, which in turn uses it internally to generate babylon objects.
It also depends what kind of objects you want to cache. The assets container is more oriented towards meshes. It is technically possible to generate a video texture and move it to an assets container, but that would stretch its abilities a little. In case of a texture (if you only want to cache textures) i would use a blob to temporarily cache it.