# Change the color of a object's child or material

**URL:** <https://discourse.threejs.org/t/change-the-color-of-a-objects-child-or-material/4185>\
**Category:** Questions\
**Tags:** color, materials\
**Created:** [September 19, 2018, 1:29pm UTC](https://discourse.threejs.org/t/change-the-color-of-a-objects-child-or-material/4185 "2018-09-19T13:29:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abdul\_Basit\_Ikram](https://avatars.discourse-cdn.com/v4/letter/a/b782af/32.png) [@Abdul\_Basit\_Ikram](https://discourse.threejs.org/u/Abdul_Basit_Ikram)\
**Post date:** [September 19, 2018, 1:29pm UTC](https://discourse.threejs.org/t/change-the-color-of-a-objects-child-or-material/4185/1 "2018-09-19T13:29:48Z")

</div>

I want to change the color of objects child means i want to change the color of materials by name Please do some help Here sample photo is attached for you refrence ![description](https://cdck-file-uploads-canada1.s3.dualstack.ca-central-1.amazonaws.com/flex035/uploads/threejs/original/2X/f/f362d949b13bd59d25f4b4482a8e01cf351d3a67.png)  
I write this code but it’s change the color of object but not the color materials or its child.

```auto
object.traverse( function ( child ) {
					if ( child instanceof THREE.Object3D ) {
						// console.log(child.name +"test");

    					console.log("~ materials ~");
						console.log(child.material);
						//console.log(child);
						//console.log(object);
						
					if(child.name==='010001_Autoscale'){
						alert("010001_Autoscale");
						child.material.color.setHex(0xffff00);
					
					}
					}
				} );

```

This code just change the color of object

---

<div class="post-metadata">

**Author:** ![looeee](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/looeee/32/59_2.png) [@looeee](https://discourse.threejs.org/u/looeee)\
**Post date:** [September 20, 2018, 4:40pm UTC](https://discourse.threejs.org/t/change-the-color-of-a-objects-child-or-material/4185/2 "2018-09-20T16:40:40Z")

</div>

The material defines what the surface of the object looks like. This means that the material’s color _is_ the object’s color.

---

<div class="post-metadata">

**Author:** ![Abdul\_Basit\_Ikram](https://avatars.discourse-cdn.com/v4/letter/a/b782af/32.png) [@Abdul\_Basit\_Ikram](https://discourse.threejs.org/u/Abdul_Basit_Ikram)\
**Post date:** [September 24, 2018, 12:29pm UTC](https://discourse.threejs.org/t/change-the-color-of-a-objects-child-or-material/4185/3 "2018-09-24T12:29:03Z")

</div>

its mean i just have option of change the color of objects?
