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”.
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?
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.