import { AnimationInterpolationKind } from "./AnimationInterpolationKind.js";
import { curve_from_track_data_cubic_tangents } from "./curve_from_track_data_cubic_tangents.js";
import { curve_from_track_data_discrete } from "./curve_from_track_data_discrete.js";
import { curve_from_track_data_linear } from "./curve_from_track_data_linear.js";

/**
 *
 * @param {AnimationCurve} curve
 * @param {AnimationInterpolationKind} type
 * @param {number[]|Float32Array} values
 * @param {number[]|Float32Array} times
 * @param {number} component_count
 * @param {number} component_index
 */
export function curve_from_track_data(
    curve,
    type,
    values,
    times,
    component_count,
    component_index
) {

    switch (type) {
        case AnimationInterpolationKind.Discrete:
            return curve_from_track_data_discrete(curve, values, times, component_count, component_index);
        case AnimationInterpolationKind.Linear:
            return curve_from_track_data_linear(curve, values, times, component_count, component_index);
        case AnimationInterpolationKind.CubicTangents:
            return curve_from_track_data_cubic_tangents(curve, values, times, component_count, component_index);
        default:
            throw new Error(`Unsupported type '${type}'`);
    }

}