How to load Duck's glTF model by specifying the Mesh name

I want to use ImportMesh() to load a mesh with a specified mesh name from within the Duck.gltf file.
Duck.gltf seems to have a mesh name “LOD3spShape”.

However, the Inspector shows “node2” instead of “LOD3spShape”.

Below is a display example in Blender. It seems that “LOD3spShape” is displayed as the name.

In babylon the name used is the one from the node, not the mesh

cc @bghgary to see if there are any easy ways

1 Like

The code is actually here:

Yes, we load via glTF node name. The Duck.gltf doesn’t provide node names. I guess we can also try to use the mesh name if the node name doesn’t exist, but it may cause confusion.

I don’t see an easy way to do this without adding a new feature to the glTF loader. @cx20 Why you want to do this?

1 Like

Thanks for explaining how the glTF Loader works.

Why you want to do this?

I simply wanted to know how to easily access a specific mesh from a glTF file.
For example, in the following example, I can retrieve it by specifying ‘King_B’.

I mistakenly thought that I could retrieve it by specifying a name in Duck.gltf as well, but it seems that I was mistaken. Although the argument name of the ImportMesh function is meshNames , the actual access requires specifying node names. However, I now understand that Duck.gltf does not even have node names, so it cannot be accessed in that way.

Passing meshNames will filter the loader such that other nodes will not be loaded at all. I think you are saying you want to access the mesh after it has loaded. If that’s the case, you can probably call importMesh with "" for the meshNames and use the resulting meshes array to filter for the mesh. Another option, if you are loading only one glTF per scene, is to use scene.getMeshByName.

1 Like

Thank you for your advice. I think I have probably achieved what I wanted to do.

const duck = scene.getMeshByName("node2");

Below is an application example.

babylonjs_havok_test_007_002