How to prepare Models to be loaded later

Hello everyone,

i want to ask what the best method of loading DIFFERENT 3D Models into the scene is.
So far, all available Instances are preloaded (from the spec i guess),
and i only show the first (BaseModel) with
viewer.variantInstances.show('WMS01VAV', true);

image

Afterwards, when i want to add a second model, let’s say the table, i am creating a copy of the initial table node.
However the new table node is not visible at all.

Is there maybe a better approach to load different Models into the scene?

Thanks in advance!

Hello,

You are correct, the instances are preloaded from the spec. You can prevent the initial load of all assets stored in the asset manager into the scene by changing the respective lazy property of each instance to false (see following code snippet):

viewerCtrl.onAfterSpecCreated(spec => {
    spec.setup.instances.forEach(instance => {
      instance.parameters[Parameter.VISIBLE] = false; // hide all base instances
      instance.lazy = true; // prevent the initial load of all instances into the scene
    });
  });

With the following line of code, the viewer checks if the instance is already loaded into the scene, if not it will do it automatically.

const instance = await viewer.variantInstances.get(INSTANCE_NAME);

If you want to create a modular configurator, I would suggest to create a parent node to store all the BaseInstances and make them invisible (see first code snippet above). You can then clone the respective BaseNode and reposition it correctly.

I’ve attached a screenshot, where you can see what I mean. In that example, the furniture system consists of two elements. Each element however also consists of severyl parts and each part is a seperate 3D model stored in the asste manager.

Whenever a new element is being added, the viewer gets the respective 3d model (see second code snippet above), stores it in the BaseInstances TransformNode (only if it was not already loaded already → because of the parameter “lazy = false”) and clones it. The clone of the BaseInstance then is stored in another TransformNode “StackingShelf” and repositioned respectively.

Let me know if that solves your problem!

Best Regards,
Thomas