/**
 *
 * @param {number[]|ArrayLike<number>|Float32Array} source
 * @param {number} source_x
 * @param {number} source_y
 * @param {number} source_width
 * @param {number} source_height
 * @param {number[]|ArrayLike<number>|Float32Array} destination
 * @param {number} destination_x
 * @param {number} destination_y
 * @param {number} destination_width
 * @param {number} destination_height
 * @param {number} width
 * @param {number} height
 * @param {number} depth
 */
export function texture_array_2d_copy(
    source, source_x, source_y, source_width, source_height,
    destination, destination_x, destination_y, destination_width, destination_height,
    width, height, depth
) {

    const source_layer_size = source_height * source_width;
    const destination_layer_size = destination_width * destination_height;

    for (let k = 0; k < depth; k++) {
        for (let y = 0; y < height; y++) {

            const s_y = y + source_y;
            const d_y = y + destination_y;

            for (let x = 0; x < width; x++) {

                const s_x = x + source_x;
                const d_x = x + destination_x;

                const source_address = k * source_layer_size + s_y * source_width + s_x;
                const destination_address = k * destination_layer_size + d_y * destination_width + d_x;

                destination[destination_address] = source[source_address];
            }
        }
    }

}
