"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.StoreCurrentViewUC = void 0;
exports.makeStoreCurrentViewUC = makeStoreCurrentViewUC;
const core_1 = require("@vived/core");
const Dispatcher_1 = require("../../Dispatcher");
const SceneRoot_1 = require("../../SceneRoot");
const Entities_1 = require("../Entities");
class StoreCurrentViewUC extends core_1.AppObjectUC {
}
exports.StoreCurrentViewUC = StoreCurrentViewUC;
StoreCurrentViewUC.type = "StoreCurrentViewUC";
StoreCurrentViewUC.get = (appObjects) => (0, core_1.getSingletonComponent)(StoreCurrentViewUC.type, appObjects);
function makeStoreCurrentViewUC(appObject) {
    return new StoreCurrentViewUCImp(appObject);
}
class StoreCurrentViewUCImp extends StoreCurrentViewUC {
    get storedView() {
        return this.getCachedSingleton(Entities_1.StoredView.type);
    }
    get sceneRoot() {
        return this.getCachedSingleton(SceneRoot_1.SceneRootEntity.type);
    }
    constructor(appObject) {
        super(appObject, StoreCurrentViewUC.type);
        this.storeCurrentView = () => {
            if (!this.storedView || !this.sceneRoot)
                return;
            this.storedView.position = this.sceneRoot.position;
            this.storedView.rotation = this.sceneRoot.rotation;
            this.storedView.scale = this.sceneRoot.scale;
            this.storedView.hasStoredView = true;
            (0, Dispatcher_1.dispatchStateChange)(this.appObject.appObjectRepo);
        };
    }
}
//# sourceMappingURL=StoreCurrentViewUC.js.map