import Vector3 from "../../geom/Vector3.js";
import { computeCatmullRomSplineUniformDistance } from "./computeCatmullRomSplineUniformDistance.js";

/**
 *
 * @param {Vector3[]} inputs
 * @param {number} samples
 * @returns {Vector3[]}
 */
export function v3_computeCatmullRomSplineUniformDistance(
    inputs, samples
) {

    const input_count = inputs.length;

    const inputs_array = new Float32Array(3 * input_count);
    const result_array = new Float32Array(3 * samples);

    for (let i = 0; i < input_count; i++) {
        const v3 = inputs[i];

        v3.toArray(inputs_array, i * 3);
    }

    computeCatmullRomSplineUniformDistance(
        result_array, inputs_array, input_count, 3, samples
    );

    // convert numeric result to array of Vector3 objects
    const result = [];

    for (let i = 0; i < samples; i++) {
        const v3 = new Vector3();

        v3.fromArray(result_array, i * 3);

        result[i] = v3;

    }

    return result;
}