Duplicate Asset Container

Hello Everyone!

I understand how to assign items to an asset container (example: container.lights.push(light)), however, I’m running into issues duplicating a container that doesn’t contain an external mesh (like the alien example).

I modified and merged two of the demos here.

The sphere is clearly in “container,” and the loaded alien meshes are being duplicated. However, I can’t seem to figure out how to duplicate the sphere container like the alien container is being duplicated. I thought this would work, but it didn’t:

 var duplicate = function(container, offset, delay) {
    
   let entries = container.instantiateModelsToScene();

    for (var node of entries.rootNodes) {
        node.position.x += offset;
    }
    
    container.addAllToScene();

    duplicate(container, 1.0, 1500);
    duplicate(container, -1.0, 3000);
}

It clearly has something to do with the line below, but I’m not sure how to make that line reference the sphere container.

BABYLON.SceneLoader.LoadAssetContainer(“https://models.babylonjs.com/”, “alien.glb”, scene, function (container) {};

Is this what you’re trying to accomplish?

https://www.babylonjs-playground.com/#5NFRVE#38

1 Like

That’s exactly right :smiley: :+1:
I appreciate the help, thanks!