Search code examples
javascriptautodesk-forge

Out of memory error in loading multiple models in Forge Viewer


I am working on a project that has 14 Navisworks (NWC) models. I am able to load the composite model into the viewer (which takes some time but works).

However, when I am loading models one by one into Viewer, I get out of memory error before all 14 are loaded. Total file size is about 500MB.

I observed that viewer is very responsive right until browser crashes (while model loading was taking place in the background).

I suspect this to be an issue of total number of polygons & geometry. I tied to use NOP_VIEWER.initDebugTools() extension but it doesn't seem to show total count from all models. It seems to show the details of only first model.

  1. Is there a way to stop Viewer creating more geometry before it runs out of memory?
  2. Is there a way to find statistics of all models with DebugTools extension?
  3. Is there another way to count polygons of loaded models?

Thanks Bandu


Solution

  • Is there a way to stop Viewer creating more geometry before it runs out of memory?

    Try and limit the memory consumption in your load options:

    var config3d = {
        memory: {
            limit: 1024 // in MB
        }
    };
    var viewer = new Autodesk.Viewing.Viewer3D(container, config3d);
    

    BTW the default limits are:

    Desktop 600 MB
    Mobile  195 MB
    

    Is there a way to find statistics of all models with DebugTools extension?

    Unfortunately the built-in DebugTools does not work with multiple models.

    But that shouldn't stop you from querying stats on a per model basis:

    let modelArray = viewer.impl.modelQueue().getModels();
    let targetModel = modelArray[index];
    targetModel.getGeometryList() // retrieves geometry info about a specific model
    

    You can even bake an extension of your own to suit multiple models.

    Is there another way to count polygons of loaded models?

    model.getGeometryList().geomPolyCount