gpvigano/AsImpL

Caching a loaded model for quicker subsequent loads

eldamir opened this issue · 2 comments

New features and suggestions

This may be a little out of scope for the project, but I'd love to hear your take. For my specific needs, users will upload .obj file to a server, and then a web player build will pick it up and use your library to load it into the scene asynchronously. Easy peasy.

Trouble is, that files are big. They are representations of BIM models, where the .obj is easily between 200 and 1200 MB in size. With you lib it took me around 10 minutes to load a 500 MB model in the editor, which would probably be OK, if it only happened the first time it was loaded. If the user closes the player and opens it at a later point, I would not want them to have to wait another 10 minutes, but rather <20 secs or something.

Using something like AssetDatabase would be awesome, but it is not available in the runtime; only in the editor, so that is not an option.

I could probably serialize the loaded GameObject into a byte stream and store it on the server for easy retrieval, but I'm not sure I can deserialize it and put it back into the scene? 🤔

Anyway, I don't really expect your library to solve this issue for me, but I was wondering whether you might have some ideas on this topic, since for some use cases, it is a very natural second step to loading a big model

Environment

  • version of AsImpL: 698f024
  • version of Unity3D: 2019.1.8f1

@eldamir Thank you for this issue. This topic sounds very interesting.
As you already know it's not easy to implement this feature, anyway we can start focusing on these facts:

  • most of the time is spent in parsing file and/or building meshes;
  • there is a not direct mapping from OBJ to internal data;
  • there is no data structure (yet) to store mesh data.

So possible suggestions could be:

  • define and serialize data structures for mesh data (e.g., something like Bunny83's proposal);
  • build and serialize mesh data after loading a new object;
  • create a mapping from file URL (and maybe import settings) to the precomputed data;
  • before loading an OBJ model search in the previous map and use precomputed data, if found;
  • add an option to use this feature;
  • add an option to configure the path for the cache.

I am focused on Unreal Engine development right now, thus it's not easy for me to switch to Unity for a long time. Anyway I'm really interested in this topic and I'd like to contribute as far as I can.

Alright, thanks for your input. Greatly appreciated. Your link leads me to an implementation of a MeshSerializer. I'll give that a try, and see if it can work for me