GLTF Meshes/NodeByName and separate 'meshes'

Hello babylon community,
again me, another question :slight_smile:

I’m trying separate one GLTF model into different mesh parts.
image
But, If i try call variable with NodeByName or MeshByName - console always return nulll
image
Did I miss something, and what would you do with applying materials? Thank you ! :kiss:

Console should show you the Cases_Closed transformNode. Could you reproduce this in a playground?

About materials, you can assign one on transformNodes, but on meshes, which in your case are probably children of Cases_Closed (and named Cases_Closed_primitive1, Cases_Closed_primitive2, etc)

1 Like

You need to call it from the onload callback or use the async version of loading :slight_smile:

Or you will look into the scene before it has been loaded.

1 Like

This is working.

    BABYLON.SceneLoader.AppendAsync('Assets/Meshes/', 'model.gltf', scene).then(function (scene) {

        let casesClosed;
        let casesOpen;
        let pens;
    
        casesClosed = scene.getNodeByName('Cases_Closed');
        casesOpen = scene.getNodeByName('Cases_Open');
        pens = scene.getNodeByName('Pens');
        
    });

@sebavan

But if try get specific mesh inside node with method getMeshByName.

  let caseOpen1 = scene.getMeshByName('CaseOpen1');
        console.log(caseOpen1);

return null.