HighLight a .glb mesh

Hi !

The code below is not working (not highlighting the mesh) but is not diplaying any errors …

BABYLON.SceneLoader.ImportMesh("", assetsFolder,"T1-Pawn.glb", scene, function(newMeshes) {
            var hl = new BABYLON.HighlightLayer("hl1", scene);
            newMeshes[0].scaling = getScale(10);
            hl.addMesh(newMeshes[0], BABYLON.Color3.Black());
        });

Is there anything wrong with my file because it’s working with a less complexe mesh like a sphere ?
Do I have to scale the HightlightLayer too or something like that ?
Thank you for your time !

Adding @sebavan

hl.addMesh(newMeshes[0], BABYLON.Color3.Black());

will add the tranform node corresponding to the root of your gltf element. It does not represent Meshes containing rendering info. You should add all the meshes from the array containing subMeshes for instances or find by id the loaded part of the meshes you want to highlight.

Thank you !

If I understood correctly newMeshes[0] is only the root element.

You should add all the meshes from the array containing subMeshes for instances

In this case why does it not work?

hl.addMesh(newMeshes, BABYLON.Color3.Black());

(Sorry it’s probably a stupid question but I’m new with BabylonJS)

Because addMesh expect a mesh and not an array of meshes

But then how can I know which mesh I should use in my array if it’s not the first one ?

well you know the mesh you want to hightlight right?

for all:

newMeshes.forEach(m => hl.addMesh(m, BABYLON.Color3.Black()));

newMeshes.forEach(m => hl.addMesh(m, BABYLON.Color3.Black()));

I should have thought about it before! Thank you!