I want add a material/color to a loaded object but i dont know the exact syntax better said what vars and function should i add. If i take this line above then it shows the object but the line with material is ignoring.
//object loader
var loader = new THREE.OBJLoader();
loader.load( '3D4.obj', function ( object ) {
// what should I add here to assign an obj material color?
var mesh = new THREE.Mesh(geometry, new THREE.MeshLambertMaterial( {color: 0xFF0000} ));
// add object to scene
scene.add( object );
});
I want add a material/color to a loaded object but i dont know the exact syntax better said what vars and function should i add. If i take this line above then it shows the object but the line with material is ignoring.
//object loader
var loader = new THREE.OBJLoader();
loader.load( '3D4.obj', function ( object ) {
// what should I add here to assign an obj material color?
var mesh = new THREE.Mesh(geometry, new THREE.MeshLambertMaterial( {color: 0xFF0000} ));
// add object to scene
scene.add( object );
});
Share
Improve this question
edited Jul 4, 2015 at 8:27
Purag
17.1k4 gold badges56 silver badges78 bronze badges
asked May 10, 2013 at 21:44
dA_uNknOwNdA_uNknOwN
9812 gold badges14 silver badges23 bronze badges
1 Answer
Reset to default 7var loader = new THREE.OBJLoader();
loader.addEventListener( 'load', function ( event )
{
var object = event.content;
object.traverse( function ( child )
{
if ( child instanceof THREE.Mesh )
child.material.color.setRGB (1, 0, 0);
});
scene.add( object );
});
loader.load( '3D4.obj' );
will give you a red object.