import * as Core from "@intelligentgraphics/ig.gfx.core";
/** An operation for the translation in a plane. */
var TranslationOperation = /** @class */ (function () {
    /** The constructor.
     * @param componentIds The ids of the components
     */
    function TranslationOperation(componentIds) {
        this.componentIds = componentIds.slice(0);
        this.initialPositions = this.componentIds.map(function (id) {
            return Core.State.API.GetPosition(id);
        });
        this.initialRotations = this.componentIds.map(function (id) {
            return {
                x: Core.State.API.GetXRotation(id) * Core.Deg2Rad,
                y: Core.State.API.GetYRotation(id) * Core.Deg2Rad,
                z: Core.State.API.GetZRotation(id) * Core.Deg2Rad,
            };
        });
    }
    TranslationOperation.prototype.executeStart = function (request) {
        this.lastPositions = this.initialPositions.slice(0);
    };
    TranslationOperation.prototype.executeMotion = function (request) {
        this.lastPositions = this.initialPositions.map(function (pos) {
            return Core.Vector.Add3(request, pos);
        });
        var resultTransformations = this.makeTransformations();
        return {
            transformations: resultTransformations,
            isInvalid: false,
            snapMatches: [],
        };
    };
    TranslationOperation.prototype.makeTransformations = function () {
        var _this = this;
        var result = this.lastPositions.map(function (pos, index) { return ({
            position: pos,
            rotation: _this.initialRotations[index],
        }); });
        return result;
    };
    TranslationOperation.prototype.executeEnd = function (request) {
        var resultTransformations = this.makeTransformations();
        return {
            transformations: resultTransformations,
            isInvalid: false,
            snapMatches: [],
        };
    };
    return TranslationOperation;
}());
export { TranslationOperation };
