"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RestoreStoredViewUC = void 0;
exports.makeRestoreStoredViewUC = makeRestoreStoredViewUC;
const core_1 = require("@vived/core");
const SceneRoot_1 = require("../../SceneRoot");
const Entities_1 = require("../Entities");
class RestoreStoredViewUC extends core_1.AppObjectUC {
}
exports.RestoreStoredViewUC = RestoreStoredViewUC;
RestoreStoredViewUC.type = "RestoreStoredViewUC";
RestoreStoredViewUC.get = (appObjects) => (0, core_1.getSingletonComponent)(RestoreStoredViewUC.type, appObjects);
function makeRestoreStoredViewUC(appObject) {
    return new RestoreStoredViewUCImp(appObject);
}
class RestoreStoredViewUCImp extends RestoreStoredViewUC {
    get storedView() {
        return this.getCachedSingleton(Entities_1.StoredView.type);
    }
    get sceneRoot() {
        return this.getCachedSingleton(SceneRoot_1.SceneRootEntity.type);
    }
    constructor(appObject) {
        super(appObject, RestoreStoredViewUC.type);
        this.ease = core_1.cubicInOut;
        this.restoreStoredView = () => {
            if (this.storedView && this.sceneRoot) {
                if (!this.storedView.hasStoredView)
                    return;
                const scale = new core_1.Vector3(this.storedView.scale, this.storedView.scale, this.storedView.scale);
                const lerpDTO = {
                    durationMS: 1000,
                    ease: this.ease,
                    desiredPosition: this.storedView.position,
                    desiredRotation: this.storedView.rotation,
                    desiredScale: scale,
                };
                this.sceneRoot.transform.lerp(lerpDTO);
            }
            else {
                this.warn("Missing necessary entities");
            }
        };
    }
}
//# sourceMappingURL=RestoreStoredViewUC.js.map