Switching textures using the .name property

I have an array of textures loaded, each with their own .name property.
what I want to do is access one of the textures using a name and map the texture that corresponds to the specified name to a material.

something like this:

textureArray = [texture{name:‘a’…},texture{name:‘b’…},texture{name:‘c’…}]
nameId = c
material.map = // switch to the texture with the corresponding nameId

What blocking you from doing so :eyes:?

const setTextureByName = (name) => {
  material.map = textureArray.find(match => match.name === name);
}

It will switch automatically.

1 Like

awesome, that works. thank you