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
282 stars 59 forks source link

Add submesh support #59

Open abcthomas opened 5 years ago

abcthomas commented 5 years ago

The parser currently only supports separating submeshes via 'usemtl' statements. However a large part of the OBJ format (and meshes in general) is the ability to split meshes into submeshes or 'groups' via the 'g' option.

Without this support the parser will currently provide single arrays of vertex attributes as opposed to separate arrays of attributes per group, for meshes without 'usemtl' statements.

frenchtoast747 commented 5 years ago

Thanks for bringing this to my attention. I'm not sure how I missed the groups when adding support for MTLs. It's right there in the spec 😞

abcthomas commented 5 years ago

No problem! It shouldn't be much work I don't think as you've already got most of the logic in from the material support. I think it would be very similar by adding an indicesPerGroup that is a map in which the key is the group name or something. You may also want to add object 'o' support, I think Mesh has a name attribute that isn't populated and implementing object support may be one way of solving this