See image, Suppose in this image three lights are there, 2 sphere and 1 Tours. Now I want to change color of torus grammatically. .
I fetch the torus
var loader = new THREE.OBJMTLLoader();
loader.load( ‘meshes/objNmtl/sign3.obj’, ‘meshes/objNmtl/sign3.mtl’, function ( object ) {
object.position.y = 5;
object.position.z = 5;
object.rotation.y = 4;
object.scale.set(0.5,0.5,0.5);
object.traverse( function ( child ) {
if ( child instanceof THREE.Object3D ) {
// console.log(child.name +"test")
if(child.name=='Torus'){
alert("torus");
console.log(child)
// child.material.color.setHex(0xffff00);
}
}
} );
scene.add( object );
} );