import { AppObjectUC, getSingletonComponent, } from "@vived/core";
import { dispatchStateChange } from "../../Dispatcher";
import { SceneRootEntity } from "../../SceneRoot";
import { StoredView } from "../Entities";
export class StoreCurrentViewUC extends AppObjectUC {
}
StoreCurrentViewUC.type = "StoreCurrentViewUC";
StoreCurrentViewUC.get = (appObjects) => getSingletonComponent(StoreCurrentViewUC.type, appObjects);
export function makeStoreCurrentViewUC(appObject) {
    return new StoreCurrentViewUCImp(appObject);
}
class StoreCurrentViewUCImp extends StoreCurrentViewUC {
    get storedView() {
        return this.getCachedSingleton(StoredView.type);
    }
    get sceneRoot() {
        return this.getCachedSingleton(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;
            dispatchStateChange(this.appObject.appObjectRepo);
        };
    }
}
//# sourceMappingURL=StoreCurrentViewUC.js.map