Code structure recommendation

Hello, I need expert advice on how I should structure my code.

Objective:
I am creating a very big interactive property inspector, which has a range of floor plans ranging from 3 to 6 separate floor plans for each property. The goal is to make a seamless transition from one floor plan to another without compromising performance for each property.

Each floor plan is different, so they have different sets of:
-animations
-different types of customizations (swappable models)
-different custom-made scene optimization’s

All floor plans will share same;
-material
-texture
-swappable models (furnishing items/room decor)

Option 1:
-Use a single Babylon.js engine
-Floor plans will import without textures or materials pre-assigned (meaning just as plane mesh)
-Create reusable function that can handle all the floorplans
-Functions will handle:
-Applying Material (babylon material or blender exported material if possible)
-Applying texture
-Setting up animations based on each floor plan
-Setting up mesh optimizations based on each floor plan
-much more
GUI/Buttons will stay the same, only changing names to accommodate for each floorplans

Option 2:
-Create separate babylon.js engine for each floorplan
-Engines don’t run simultaneously

I have already set up most of Option 1, outside of material and texture assignment, which i haven’t touched yet. Please, no chatGPT response. I want people who have done lots of experiments with using a single engine and separate engines configurations and have a good understanding of the pros and cons. I am not sure if the engine is faster with a single engine setup or separate engine calls (separate codebase).

Having separate engines will result in each engine having to compile its own materials, taking longer than compiling the material once and reusing it.

3 Likes