I can`t change material on runtime I can change the materials while loading mesh/materials by MTLLoader.
objLoader.load( settings.OBJName + '.obj', function ( object ) {
geodesic = object; // reference doesnt work outside the function
object.traverse(function(node) {
//node.geometry.computeVertexNormals();
if(node.material !== undefined) { // przebieg po wszystkich obiektach MeshPhongMaterial
node.material.side = THREE.DoubleSide;
//console.log(node.material);
if(node.material.name == 'tubes') {
node.material.shading = THREE.FlatShading;
node.material.shininess = 20;
node.material.reflectivity = 0.5;
node.material.specular = new THREE.Color(0xffffff);
}
else if(node.material instanceof Array) // przebieg po tablicach obiektow MeshPhongMaterial
{
var arrayLen = node.material.length;
for(var i=0; i<arrayLen; i++) {
node.material[i].side = THREE.DoubleSide;
}
}
}
});
OK and how to change loaded materials on runtime ? Is there any way ? Refference object inside function is invisible outside the function.