I’m trying to change the materials on specific objects without affecting other objects with the same material.
This is what I’m trying…
const material = viewer.findMaterial("Wood")
const group = viewer.findNodesOfType("Group1")
applyMaterial(material, nodes) {
nodes.forEach(n => {
if (n.mesh) {
viewer.setMaterialForMesh(material, n.mesh)
}
applyMaterial(material, n.children)
})
}
applyMaterial(material, group)
viewer.requestFrame()
The code doesn’t seem to change anything. I’m able to change all meshes with a material using findMeshesWithMaterial and then using setMaterialForMesh, but in this case I’d like to target specific meshes instead. I’ve set material and object group to be editable as well.
Is there a step I’m missing? Should this work?