When trying to call in the array values using the code snippet below, I encountered an issue. Upon clicking, I am able to successfully retrieve the first material in the array, but then it stops looping through the rest of the materials. Can someone please point out where I might be making a mistake?
var White = new THREE.MeshPhongMaterial( {
color:0xf6daa5,
// specular: 0x000000,
roughness: 0.7,
shininess: 0,
// bumpMap: mapHeight,
bumpScale: 12,
emissive: null,
emissiveIntensity : null,
reflectivity: 0.1
} );
var sink = new THREE.MeshPhongMaterial( {
color: 0x224466,
combine: THREE.MixOperation,
reflectivity: 0.8,
side: THREE.DoubleSide,
shininess: 40,
reflectivity:0
opacity:null
} )
var gold = new THREE.MeshPhongMaterial( {
color: 0x529dc3,
specular: 0x508fbb,
shininess: 60,
emissive:0x070606,
reflectivity:0.7,
opacity:0.8,
shading: THREE.FlatShading,
combine: THREE.MultiplyOperation
} ) // have declared these globally
EventsControls.attachEvent('onclick', function() {
var colors = [White, sink, gold];
for (var i = 0; i < colors.length; i++) {
console.log(colors.length);
object.traverse(function(child) {
if (child instanceof THREE.Mesh) {
if (child.material.name == "w__") {
child.material = colors[i];
}
}
})
}
});