"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var Core = tslib_1.__importStar(require("@intelligentgraphics/ig.gfx.core"));
var Environment_1 = tslib_1.__importDefault(require("../Environment"));
/** Class for placing objects in the middle of the room. */
var MiddleOfRoomPlacement = /** @class */ (function () {
    /**
     * The constructor.
     * @param insertedId
     */
    function MiddleOfRoomPlacement(insertedId) {
        this.insertedId = insertedId;
    }
    MiddleOfRoomPlacement.prototype.getTransformation = function () {
        if (!Environment_1.default.getInstance().getRoot()) {
            return undefined;
        }
        var tRoomBounds = Core.State.API.GetBounds(Environment_1.default.getInstance().getRoot(), "World", true);
        var tObjectBounds = Core.State.API.GetBounds(this.insertedId, "Local", true);
        var middleOfBounds = function (bounds) {
            return Core.Vector.ScalarMultiply3(0.5, Core.Vector.Sub3(bounds.max, bounds.min));
        };
        var position = middleOfBounds(tRoomBounds);
        position = Core.Vector.Sub3(position, middleOfBounds(tObjectBounds));
        position.y = 0;
        return {
            position: position,
            rotation: {
                x: 0,
                y: 0,
                z: 0,
            },
        };
    };
    return MiddleOfRoomPlacement;
}());
exports.default = MiddleOfRoomPlacement;
