export class AnimationClip {
    /**
     * Human-readable label
     * @type {string}
     */
    name = ""

    /**
     *
     * @type {AnimationTrack[]}
     */
    tracks = []

    /**
     *
     * @returns {number}
     */
    get start_time() {
        const tracks = this.tracks;
        const curve_count = tracks.length;

        if (curve_count <= 0) {
            return 0;
        }

        let r = Infinity;
        for (let i = 0; i < curve_count; i++) {
            const track = tracks[i];
            const s = track.start_time;

            if (r > s) {
                r = s;
            }

        }

        return r;
    }

    get end_time() {
        const tracks = this.tracks;
        const curve_count = tracks.length;

        if (curve_count <= 0) {
            return 0;
        }

        let r = -Infinity;
        for (let i = 0; i < curve_count; i++) {
            const track = tracks[i];
            const s = track.end_time;

            if (r < s) {
                r = s;
            }

        }

        return r;
    }

    /**
     *
     * @return {number}
     */
    get duration() {
        return this.end_time - this.start_time;
    }
}