Closed mnoven closed 5 years ago
That's absolutely something that the lib should support, thank you for filing this issue. It's non-trivial, but there are some well known algorithms to do this (see https://en.wikipedia.org/wiki/Polygon_triangulation).
@frenchtoast747: The code for the quad triangulation should be tossed and a generic triangulation function should take its place:
for each face in faces:
for each triangle in triangulate(faces):
// ....
Here are baby steps:
triangulate(...)
as a quad2tri algorithmtriangulate(...)
inside of constructortriangulate(...)
with the a proper triangulation algorithm+1
Added v2.0.3 which provides initial support for N-gons. I will create another issue to provide a better triangulate()
algorithm.
Much appreciated. I will report back with any potential issues.
Right now the lib seems to convert quads to triangles and thus assumes 3 or 4 vertices per face. The .obj format has however no limit on how many vertices there should be per face and some models break because of this.
An example of an .obj which sometimes has more than 4 vertices per face rendered in my engine using
gl.drawElements
:(Model taken from https://casual-effects.com/g3d/data10/research/model/breakfast_room/breakfast_room.zip)