hit2501 Posted July 24, 2018 Share Posted July 24, 2018 Hi, I was playing with a model exported from Blender and I can retrieve its submeshes with: var my_model = newMeshes[0]; var my_submesh = my_model.subMeshes[0]; But now I would like to know how can I retrieve a submesh from its name instead its number (like I can see in Blender). Can anybody help me? Thanks in advance. Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted July 24, 2018 Share Posted July 24, 2018 Not sure what you are seeing in Blender, but submesh does not have a name. You might be able to something to retrieve by corresponding material name. Going the opposite direction is let matName = my_model.materials[my_model.subMeshes[0].materialIndex].name; getSubMesh(mesh, name) { let mat = mesh.materials; let idx; for (let i = 0, len = mat.length; i < len; i++) { if (mat[i].name === name) { idx = i; break; } } return idx ? mesh.submeshes[idx] : null; } hit2501 1 Quote Link to comment Share on other sites More sharing options...
hit2501 Posted July 24, 2018 Author Share Posted July 24, 2018 Thank you JC, yes, I think I must recheck the documentation but the material (and subMaterials) thing helped me to achieve what I was looking for. Thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.