added vector based buildTriangles function