import { MmdCameraAnimationGroup } from "../../Loader/Animation/mmdCameraAnimationGroup";
import { createAnimationState } from "./Common/createAnimationState";
/**
 * Mmd runtime camera animation that use animation container of babylon.js
 *
 * An object with mmd animation group and camera binding information
 */
export class MmdRuntimeCameraAnimationGroup {
    /**
     * The animation data
     */
    animation;
    _positionAnimationState;
    _rotationAnimationState;
    _distanceAnimationState;
    _fovAnimationState;
    _camera;
    constructor(animation, camera) {
        this.animation = animation;
        this._positionAnimationState = createAnimationState();
        this._rotationAnimationState = createAnimationState();
        this._distanceAnimationState = createAnimationState();
        this._fovAnimationState = createAnimationState();
        this._camera = camera;
    }
    /**
     * Update animation
     * @param frameTime Frame time in 30fps
     */
    animate(frameTime) {
        const animation = this.animation;
        const camera = this._camera;
        camera.position.copyFrom(animation.positionAnimation._interpolate(frameTime, this._positionAnimationState));
        camera.rotation.copyFrom(animation.rotationAnimation._interpolate(frameTime, this._rotationAnimationState));
        camera.distance = animation.distanceAnimation._interpolate(frameTime, this._distanceAnimationState);
        camera.fov = animation.fovAnimation._interpolate(frameTime, this._fovAnimationState);
    }
    /**
     * Bind animation to camera
     * @param animation Animation to bind
     * @param camera Bind target
     * @returns MmdRuntimeCameraAnimationGroup instance
     */
    static Create(animation, camera) {
        return new MmdRuntimeCameraAnimationGroup(animation, camera);
    }
}
/**
 * Create runtime camera animation
 * @param camera Bind target
 * @returns MmdRuntimeCameraAnimationGroup instance
 */
MmdCameraAnimationGroup.prototype.createRuntimeCameraAnimation = function (camera) {
    return MmdRuntimeCameraAnimationGroup.Create(this, camera);
};
