Different Color on Different Parts by Functions

So basically I have an OBJ file with its MTL file loaded in with threejs on my page. There are like 7 different parts on the module and I am wondering if it is possible to draw color on every single part of the module with the target part id and color.

Plus, I am working on the front-end and all I know about the module itself are the part id and which part is bound to each id.

Coloring different parts of a model can be done in two ways. Both usually require some preparations of the model.

  • Each part is represented as a separate mesh with an own material. In this way, you can define Material.color with the desired values.
  • You use vertex colors. However this only works if the different parts of the model share no vertices otherwise you can’t define unique color values.

In both cases, it’s best if you prepare the model in a tool like Blender and then import it in your app. Instead of using OBJ/MTL, I highly recommend glTF.

Hi. Based on your suggestion and other researches, I have completed this. Thanks for your help.

1 Like