I want to search for the material called COIN and assign a new texture to it. I know it’s material number 0, but what I want is to search through the materials and if it finds a name match, assign the texture.
object.traverse( function( node ) {
if (node.isMesh) {
if ( node.material[0].name == 'COIN' ) {
node.material = textura
}
}
})
// Works perfect
Looking something like:
if ( node.material[].name == 'COIN' )
// Error
How can I loop through the object’s textures to find the one I’m interested in without knowing the material index?
Just in case it matters, the object format is FBX.
Thanks!!!
2
Answers
Found a solution on the spanish stackoverflow:
You can use the
.getObjectByName
method and work with parts using it.Look here
For example you can search one part:
or arrays of parts
Example: