Closed fcpauldiaz closed 7 years ago
Yes, solid colors are possible using the meshes loaded with webgl-obj-loader.
In the gh-pages page of this project there is an demo that uses this loader to load various OBJ models. One of the models that is loaded is the Blender monkey, Suzanne. While most of the other models have their texture files loaded in manually, the Suzanne model has a solid color.
I created a helper function in this demo project, drawObject(), that takes in an OBJ mesh created from this loader and draws the given mesh to the screen. There is an optional parameter, color
, that takes in a 4 element vector that is passed in to the shader program as an attribute named modelColor
. Later on, Suzanne is drawn to the screen here with the drawObject()
function passing in a specific color (gold in this case).
You can do something similar in your own project so that you can map a solid color to your meshes.
Thanks @frenchtoast747
You're welcome, hope that helps!
Since mtl format is not supported I want to set a fixed color to my mesh. Would it work to create a new program with color shaders enable the attribute?