import { system } from "@minecraft/server";
import Vector from "../_Utilities/Vector";
export default class Camera_Manager {
    static clear(camera) {
        camera.clear();
    }
    static video(camera, camera_ID, frames, index) {
        if (index == frames.length)
            return;
        if (frames[index].fade != undefined)
            this.fade(camera, frames[index].fade);
        this.roation(camera, camera_ID, frames[index].roation, frames[index].ease);
        this.location(camera, camera_ID, frames[index].location, frames[index].ease);
        let fade_Time = 0;
        const fade = frames[index].fade;
        if (fade != undefined)
            fade_Time = fade.fadeTime.fadeInTime + fade.fadeTime.fadeOutTime + fade.fadeTime.holdTime;
        const timeout = frames[index].ease.easeTime + fade_Time;
        system.runTimeout(() => {
            Camera_Manager.video(camera, camera_ID, frames, ++index);
        }, timeout * 20);
    }
    static roation(camera, camera_ID, roation, ease) {
        camera.setCamera(camera_ID, { rotation: roation, easeOptions: ease });
    }
    static location(camera, camera_ID, location, ease) {
        camera.setCamera(camera_ID, { location: location, easeOptions: ease });
    }
    static fade(camera, fade) {
        camera.fade(fade);
    }
    static localization(location, frames) {
        const localized = new Array();
        for (let i = 0; i < frames.length; i++) {
            localized.push({
                location: Vector.add(location, frames[i].location),
                roation: frames[i].roation,
                ease: frames[i].ease,
                fade: frames[i].fade,
            });
        }
        return localized;
    }
}
