I have an obj file that I display with OBJloader2. I am looking for a way to apply a MeshLambertMaterial on it.
I can do that with OBJLoader, with the following code called in the onLoadedCallback function :
material = new THREE.MeshLambertMaterial(
{
color:0x6e6e6e,
emissive:0x282727
});
// called when resource is loaded
function ( object ) {
object.traverse( function ( child ) {
if ( child instanceof THREE.Mesh ) {
child.material = material;
}
});
scene.add( object );
Unfortunately I can't do the same with OBJLoader2. Am I missing something? All examples I have found are importing material from .mtl files, is it the only way?
Thanks.