import { Quaternion, Vector3 } from "@vived/core";
import { DispatchStateChangeUC } from "../../Dispatcher";
import { UndoRedoEntity } from "../../UndoRedo";
export class MoveTransformUndoRedo {
    constructor(dto, transform, appObjects) {
        this.dto = dto;
        this.transform = transform;
        this.undoAction = () => {
            this.transform.localPosition = this.dto.startPosition;
            this.transform.localRotation = this.dto.startRotation;
            this.dispatchStateChange?.doDispatch();
        };
        this.redoAction = () => {
            this.transform.localPosition = this.dto.endPosition;
            this.transform.localRotation = this.dto.endRotation;
            this.dispatchStateChange?.doDispatch();
        };
        if (Vector3.Close(dto.startPosition, dto.endPosition) &&
            Quaternion.Close(dto.startRotation, dto.endRotation)) {
            return;
        }
        this.dispatchStateChange = DispatchStateChangeUC.get(appObjects);
        if (!this.dispatchStateChange) {
            appObjects.submitWarning("MoveTransformUndoRedo", "Unable to find DispatchStateChangeUC");
            return;
        }
        const undoRedo = UndoRedoEntity.get(appObjects);
        if (!undoRedo) {
            appObjects.submitWarning("MoveTransformUndoRedo", "Unable to find UndoRedoEntity");
            return;
        }
        undoRedo.submitAction(this);
    }
}
//# sourceMappingURL=MoveTransformUndoRedo.js.map