Hi!
I have a little problem with texture changing. I clone a OBJ loaded object and i changed his texture. But all cloned object still have the same texture.
Here my code:
var loader = new THREE.OBJLoader( manager );
loader.load( 'models/L200-OBJ/L200-OBJ.obj', function ( object ) {
for(var i=0; i<5; i++)
{
for(var j=0; j<5; j++)
{
var car = object.clone();
for(var c in car.children)
{
if ( car.children[c] instanceof THREE.Mesh ) {
var t = Math.round(Math.random()*(textures_car.length-1));
car.children[c].material.map = textures_car[t];
car.children[c].material.map.needsUpdate = true;
car.children[c].material.needsUpdate = true;
}
}
car.position.x = -200+j*100;
car.position.z = 200+i*100;
car.position.y = -100;
car.rotation.y = Math.PI;
scene.add( car );
}
}
});
Thanks you for your help!