/**
 *
 * @param {StreamGeometryBuilder} out
 * @param {number} index_offset
 * @param {number} path_segments
 * @param {number} profile_segments
 */
export function make_ring_faces(out, index_offset, path_segments, profile_segments) {
    const indices = out.indices;

    let i = 0, j = 0;

    for (j = 1; j <= path_segments; j++) {

        for (i = 1; i <= profile_segments; i++) {

            const s_1 = profile_segments + 1;

            const a = index_offset + s_1 * (j - 1) + (i - 1);
            const b = index_offset + s_1 * j + (i - 1);
            const c = index_offset + s_1 * j + i;
            const d = index_offset + s_1 * (j - 1) + i;

            // faces

            const ci = out.cursor_indices;

            indices[ci] = a;
            indices[ci + 1] = b;
            indices[ci + 2] = d;

            indices[ci + 3] = b;
            indices[ci + 4] = c;
            indices[ci + 5] = d;

            out.cursor_indices += 6;
        }

    }
}
