# Add materials to obj

**URL:** <https://discourse.threejs.org/t/add-materials-to-obj/12074>\
**Category:** Questions\
**Tags:** obj-loader, mtl-loader\
**Created:** [January 14, 2020, 7:00am UTC](https://discourse.threejs.org/t/add-materials-to-obj/12074 "2020-01-14T07:00:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![k2dhananjaya](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/k2dhananjaya/32/8715_2.png) [@k2dhananjaya](https://discourse.threejs.org/u/k2dhananjaya)\
**Post date:** [January 14, 2020, 7:00am UTC](https://discourse.threejs.org/t/add-materials-to-obj/12074/1 "2020-01-14T07:00:31Z")

</div>

cant find how to add mtl file to obj(need to replace child.material.color with MTL file )

this is my code,plz help

```auto
    var loadOBJ = function(){
	var manager = new THREE.LoadingManager();
	var loader = new THREE.OBJLoader( manager );
	loader.load( 'box.obj', addBoxInScene);

};

var addBoxInScene = function(object){
	Box = object;
	Box.position.x = -3;
	Box.position.y = -1;
	Box.position.z = 490;
	//Go through all children of the loaded object and search for a Mesh
	object.traverse( function ( child ) {
		//This allow us to check if the children is an instance of the Mesh constructor
		if(child instanceof THREE.Mesh){
			child.material.color = new THREE.Color(0Xf25922);
			
			//Sometimes there are some vertex normals missing in the .obj files, ThreeJs will compute them
			child.geometry.computeVertexNormals();
		}
	});
	//Add the 3D object in the scene
	scene.add(Box);
	render();
};

```

---

<div class="post-metadata">

**Author:** ![Mugen87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mugen87/32/5645_2.png) [@Mugen87](https://discourse.threejs.org/u/Mugen87)\
**Post date:** [January 14, 2020, 10:32am UTC](https://discourse.threejs.org/t/add-materials-to-obj/12074/2 "2020-01-14T10:32:39Z")

</div>

The following official example demonstrates how to load an `OBJ` along its `MTL` file using `OBJLoader` and `MTLLoader`:

[https://threejs.org/examples/webgl\_loader\_obj\_mtl](https://threejs.org/examples/webgl_loader_obj_mtl)
