game_actor_animation_track_rotation_track.js

import ActorAnimationTrack from "./actor_animation_track.js";
import NumberGradient from "../../../../util/gradient/number_gradient.js";

/**
 * @module RotationTrack
 * @fileoverview Contains RotationTrack class.
 */

/**
 * @class RotationTrack
 * @extends ActorAnimationTrack
 * Manipulates actor rotation over time.
 */
class RotationTrack extends ActorAnimationTrack {
    /**
     * Create a new rotation track.
     * @param {Object.<number, number>} values Values at time intervals
     * @param {boolean} smooth Whether the track should start and end smoothly/gradually (false by default)
     * @constructor
     */
    constructor(values = {}, smooth = false) {
        super();

        this._gradient = new NumberGradient(values, smooth);
    }

    update(actor, progress) {
        actor.rotation = this._gradient.get(progress);
    }
}

export default RotationTrack;