Best Practice for Organizing Environment Assets in a 3D Scene

Hi everyone,

I’m working on creating an environment for a 3D scene in Babylon.js, and I’m trying to decide the best way to organize my environment assets (such as rocks, trees, mountains, etc.).

Would it be better to model all the environment elements in a single file (e.g., combining all assets into one .glb file) and import them into the scene as a whole, or is it more efficient to separate them into individual files and load them as needed?

Thanks.

Hello :slight_smile:

I would say “it depends” :slight_smile:
→ If it make sense in your scene to have all of them loaded at once, then put all of them in one file.
→ If it make sense to “stream” the assets (e.i. you are moving and won’t see all of them at once), then :

  • Merging file and loading all at start :
    • Pros : easier to handle material sharing (multiple meshes sharing the same material, the material will be written one time only and loaded one time only, whereas by splitting, the materials will be loaded as doubles in BabylonJS)
    • Cons : memory footprint and loading time
  • Separating files and loading on demand :
    • Pros : Limits memory usage, shorter loading time
    • Cons : In case of bandwidth issue, some assets will be late. Material doubles need to be fixed by hand (deleting doubles, reassigning meshes to the remaining ones)
1 Like

@Tricotou good advice

@mmhosein.hp

Of course there is more to say about it especially in regards to what size scene you are expecting to build , then draw calls and object count become important.

eg the CPU/GPU will much prefer a mesh with 50k tri , instead of 50k mesh each with 1k tri :wink:

handling duplicate materials is essential for drawcalls

Even so , the pipeline of development still needs to suit eveyone, if you are a single developer , then it still good to learn to work with best practices.

Eg , mostly the scene objects are best not combined in your authoring files , normally its combined as part of the export process or even doing mesh joins at runtime in the babylon engine.