in my ThreeJS application I load a .OBJ file from my local server. I now want for example to give every sub-mesh (sub-component) a different color.
Doing the following, ThreeJS is always coloring more than one meshes:
var counter = 0;
object.traverse(function (child) {
if (child instanceof THREE.Mesh) {
//Also tested with if(counter == 300) or if (child.name == '625')...
if(child.id == 635){
var randomColor = '#' + (Math.random().toString(16)+'00000').slice(2,8)
child.material.color.set(randomColor);
}
counter++;
}
});
The result is:
However in a 3D model viewer of your choice (I tested FreeCAD, Blender, Autodesk and Creo) every component seems to be single as it should be...:
How does this happen? Or is there maybe an export option I did not see? Full code: https://www.toptal.com/developers/hastebin/fosugibuni.php (Not very spectacular)...