Create assets from remote source without loading the resource

Hello,

I have a remote folder with a huge number of textures. I would like to parse it insert the textures as assets in the Asset Registry so I can later search and filter the assets using the build in functions (so powerful). But without initially loading the image (issuing the http request).

Is it possible? The loadFromUrl function is efficient into automatically creating everything from a simple url but how would I use it without downloading the image initially?

And another question, when exactly a resource (texture) is loaded in VRAM? I assume the moment it is assigned in a material map. Is that correct?

So you have a folder somewhere outside PlayCanvas and you want to load all the names and probably URLs of these textures but not the actual images? It sounds like you need to make an HTTP request to get a listing of all the files in that folder (the server that hosts those images should provide such a method). Then given that you can either add assets to the Asset Registry procedurally (create a new asset and add it to the registry) making sure that you have preload set to false for each new asset.

Then you can load the actual images manually or automatically if you assign them to a material (texture assets that are referenced but not yet loaded will be loaded automatically).

Regarding when a texture is loaded in VRAM if you look in the engine’s source code on github that seems to be done when the texture is used by a shader and it’s done inside the uploadTexture method of the graphics device ( https://github.com/playcanvas/engine/blob/master/src/graphics/device.js#L1070 ).

2 Likes

Thank you very much @vaios.