/**
 *
 * @param {number[]} out
 * @param {number} out_offset
 * @param {number} a vertex index 0
 * @param {number} b vertex index 0
 * @param {number} c vertex index 0
 * @param {number[]|ArrayLike<number>|Float32Array} attribute_array
 * @param {number} dimensions
 * @param {number} u Barycentric coordinate
 * @param {number} v Barycentric coordinate
 */
export function sample_triangle_attribute(
    out, out_offset,
    a, b, c,
    attribute_array, dimensions,
    u, v
) {

    const a_address = a * dimensions;
    const b_address = b * dimensions;
    const c_address = c * dimensions;

    for (let i = 0; i < dimensions; i++) {

        // construct edges
        const a_v = attribute_array[a_address + i];

        const edge1_v = attribute_array[b_address + i] - a_v;
        const edge2_v = attribute_array[c_address + i] - a_v;

        // sample edge
        out[out_offset + i] = edge1_v * u + edge2_v * v + a_v;
    }
}
