frenchtoast747 / webgl-obj-loader

A simple OBJ model loader to help facilitate the learning of WebGL.
http://frenchtoast747.github.io/webgl-obj-loader/
MIT License
281 stars 59 forks source link

how do I load a model in webgl2 with multiple material/objects? #75

Open manueldun opened 4 years ago

manueldun commented 4 years ago

Hello

I've been trying this method:

1) Create a one global array buffer for each type of data (position, uv, normal, etc).

2) Then create one element buffer array (index) for each material index data.

3) Create one VAO for each material index array. Every VAO is going to be bound to all the global array buffer and one respective element buffer.

4) Lastly I draw every VAO.

I tried this approach with Drovaric sponza from https://casual-effects.com/data/ and it works fine, but it does not have normal data, so I used blender to generate the normals and I get a bad result when drawing the mesh, like the the vertices are out of order.

in the case of using OBJ.initMeshBuffers, how would i go about it?

Thanks.