I’ve been building a game for a while now, and am starting to get closer to release. During development I’ve had all assets (3d models, images, materials, etc.) on the client. But I’ve now moved these to the server, and my strategy is as follows:
On the client, I have a list of all the URLs for the assets. I then use the fetch API to get every .obj, .mtl, .png, and .json file. (I use cache: ‘force-cache’, so the client doesn’t need to download each time). After they are downloaded (cached locally), I let the garbage collector delete themfrom memory, as I simply want to them to be cached client-side at this point. This way, the files are cached locally and can be quickly imported on the fly during gameplay, when entering a new area, level, etc.) Essentially, I am ‘downloading’ the entire game at the start.
It works, but in total there are about 150 assets to get, and I don’t want to call fetch that many times. Most of the assets are .obj and .mtl files.
I understand a single .babylon file can hold all the mesh files, but again I don’t need to load every single object at once, so I can’t use a babylon file to represent a ‘scene’ in my game.
Are there any tips anyone can give?