Using the AssetContainer to clone meshes later

Now V5 is out and I have some free time, I thought I would try this again. I use the following code to load a mesh. I can see the mesh is loaded in the asset container’s meshes array in the callback. But when I call the asset container later, the meshes array is empty. I must be missing something, I thought the asset container would be persisted. What am I missing?

let assetContainer = null;

function DoSomething() {
assetContainer = new BABYLON.AssetContainer(scene);
        BABYLON.SceneLoader.LoadAssetContainer("./Meshes/Articles/", "1DoorFixed_1145.glb", scene, function (assetContainer) {

           // Contains my mesh
            let meshes = assetContainer.meshes;


function DoSomethingLater() {

            // Is Empty
            let meshes = assetContainer.meshes;


Ignore this. I’m being stupid. The asset container in the callback is not the same as the one I have defined. Doh.

However, when I use scene.addMesh in the callback (because I don’t want to add everything), I can see it in the scene, but the debuglayer inspector never shows the mesh as a node. Any ideas?

Scrap that as well. It was because the callback had loaded all the meshes of the model into separate entries in the meshes list. I had to use merge meshes to recombine them into a single mesh.

How do you delete a question :slight_smile:

If you actually do want to delete it, I think there’s a way, but I’m not familiar with it; I think @carolhmj is the best person to ask about that. However, I don’t think you need to delete this question unless you want to; people answer their own questions all the time. :slightly_smiling_face: All you need to do is mark your reply to yourself as the solution, and that’s that!

@syntheticmagus is right, no need to delete it, you can mark your own answer as a solution, and it will be helpful for future people with the same problem! :smiley:

1 Like