"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
exports.createMatrix4 = function () { return ({
    //prettier-ignore
    elements: [
        1, 0, 0, 0,
        0, 1, 0, 0,
        0, 0, 1, 0,
        0, 0, 0, 1
    ]
}); };
exports.cloneMatrix4 = function (matrix) { return (tslib_1.__assign(tslib_1.__assign({}, matrix), { elements: tslib_1.__spread(matrix.elements) })); };
exports.createMatrix4FromQuaternion = function (quaternion) {
    var matrix = exports.createMatrix4();
    return exports.makeRotationFromQuaternion(matrix, quaternion);
};
exports.makeRotationFromQuaternion = function (matrix, quaternion) {
    var x = quaternion.x, y = quaternion.y, z = quaternion.z, w = quaternion.w;
    var x2 = x + x, y2 = y + y, z2 = z + z;
    var xx = x * x2, xy = x * y2, xz = x * z2;
    var yy = y * y2, yz = y * z2, zz = z * z2;
    var wx = w * x2, wy = w * y2, wz = w * z2;
    matrix.elements[0] = 1 - (yy + zz);
    matrix.elements[4] = xy - wz;
    matrix.elements[8] = xz + wy;
    matrix.elements[1] = xy + wz;
    matrix.elements[5] = 1 - (xx + zz);
    matrix.elements[9] = yz - wx;
    matrix.elements[2] = xz - wy;
    matrix.elements[6] = yz + wx;
    matrix.elements[10] = 1 - (xx + yy);
    // last column
    matrix.elements[3] = 0;
    matrix.elements[7] = 0;
    matrix.elements[11] = 0;
    // bottom row
    matrix.elements[12] = 0;
    matrix.elements[13] = 0;
    matrix.elements[14] = 0;
    matrix.elements[15] = 1;
    return matrix;
};
