"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var State_1 = require("./State");
var Vector_1 = require("./Math/Vector");
var MathUtils_1 = require("./Math/MathUtils");
/** Convenience function for creating a Ray, cloning the parameters */
function createRay(origin, direction) {
    return {
        origin: Vector_1.Vector.CloneVec3(origin),
        direction: Vector_1.Vector.CloneVec3(direction),
    };
}
exports.createRay = createRay;
/** Convenience function for cloning a Ray */
function cloneRay(ray) {
    return createRay(ray.origin, ray.direction);
}
exports.cloneRay = cloneRay;
/**
 * Returns the current Transformation of a component. Slightly smoothed for values near 0.
 * @param id the component id
 * @param setPositionCompatibility if true: ignore the movement of t3 itself, i.e.
 * @returns {Transformation}
 */
function getWorldTransformation(id, setPositionCompatibility) {
    if (setPositionCompatibility === void 0) { setPositionCompatibility = false; }
    var transformation = State_1.State.API.GetBasicWorldTransformation(id, setPositionCompatibility);
    if (MathUtils_1.isCloseTo(Math.abs(transformation.rotation.x), Math.PI) &&
        MathUtils_1.isCloseTo(Math.abs(transformation.rotation.z), Math.PI)) {
        transformation.rotation = Vector_1.Vector.CreateVec3(0, Math.PI - transformation.rotation.y, 0);
    }
    return transformation;
}
exports.getWorldTransformation = getWorldTransformation;
/** Representation of two-dimensional numbers. */
var Float2 = /** @class */ (function () {
    function Float2(x, y) {
        this.x = x === undefined ? 0 : x;
        this.y = y === undefined ? 0 : y;
    }
    return Float2;
}());
exports.Float2 = Float2;
/** Same as Float2, but introduced for better compatibility with ThreeJS. */
// TODO 2019-10-02 eliminate
var Vector2 = /** @class */ (function (_super) {
    tslib_1.__extends(Vector2, _super);
    function Vector2() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return Vector2;
}(Float2));
exports.Vector2 = Vector2;
/** Representation of three-dimensional numbers. */
var Float3 = /** @class */ (function () {
    function Float3(x, y, z) {
        this.x = x === undefined ? 0 : x;
        this.y = y === undefined ? 0 : y;
        this.z = z === undefined ? 0 : z;
    }
    /**
     * Takes two Float3's and returns the sum of them.
     * @param s1 First summand
     * @param s2 Second summand
     */
    Float3.add = function (s1, s2) {
        return new Float3(s1.x + s2.x, s1.y + s2.y, s1.z + s2.z);
    };
    /**
     * Compare two Float3's on equality (with optional deviation)
     * @param pF1 First Float3
     * @param pF2 Second Float3
     * @param pDeviation allowed deviation
     */
    Float3.isEqual = function (pF1, pF2, pDeviation) {
        if (pDeviation === void 0) { pDeviation = 0; }
        return (Math.abs(pF1.x - pF2.x) <= pDeviation &&
            Math.abs(pF1.y - pF2.y) <= pDeviation &&
            Math.abs(pF1.z - pF2.z) <= pDeviation);
    };
    return Float3;
}());
exports.Float3 = Float3;
/** Same as Float3, but introduced for better compatibility with Unity-3D. */
// TODO 2019-10-02 eliminate
var Vector3 = /** @class */ (function (_super) {
    tslib_1.__extends(Vector3, _super);
    function Vector3() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return Vector3;
}(Float3));
exports.Vector3 = Vector3;
/** Representation of RGB colors. */
var ColorRGB = /** @class */ (function () {
    function ColorRGB(r, g, b) {
        this.r = r === undefined ? 0 : r;
        this.g = g === undefined ? 0 : g;
        this.b = b === undefined ? 0 : b;
    }
    return ColorRGB;
}());
exports.ColorRGB = ColorRGB;
/** Enumeration of ghost modes. */
var EGhostMode;
(function (EGhostMode) {
    /** No ghost. */
    EGhostMode["None"] = "None";
    /** Global box. */
    EGhostMode["Box"] = "Box";
    /** Hierarchy of boxes. */
    EGhostMode["Boxes"] = "Boxes";
    /** 1:1 geometric representation. */
    EGhostMode["Geometric"] = "Geometric";
    /** No display: if a ghost exists, do not display it but keep in scene */
    EGhostMode["NoDisplay"] = "NoDisplay";
})(EGhostMode = exports.EGhostMode || (exports.EGhostMode = {}));
exports.VisibleGhostModes = [
    EGhostMode.Box,
    EGhostMode.Geometric,
];
exports.RENDERKNECHT_PERSPECTIVE = "RENDERKNECHT_PERSPECTIVE";
exports.RENDERKNECHT_ORTHOGRAPHIC = "RENDERKNECHT_ORTHOGRAPHIC";
/** Representing setup information for a perspective camera */
var PerspCameraSetup = /** @class */ (function () {
    function PerspCameraSetup() {
        this.near = 0.1;
        this.far = 100;
        this.position = Vector_1.Vector.CreateVec3(0, 1.5, 4);
        this.rotation = Vector_1.Vector.CreateVec3(0, 0, 0);
        this.lookAt = Vector_1.Vector.CreateVec3(0, 0, 0);
        /** the left value of the ortho rectangle, defaults to 45 */
        this.fov = 45;
    }
    return PerspCameraSetup;
}());
exports.PerspCameraSetup = PerspCameraSetup;
/** Representing setup information for a OrthographicsCamera */
var OrthoCameraSetup = /** @class */ (function () {
    function OrthoCameraSetup() {
        this.near = 0.1;
        this.far = 50;
        this.position = Vector_1.Vector.CreateVec3(0, 20, 0);
        this.rotation = Vector_1.Vector.CreateVec3(0, 0, 0);
        this.lookAt = Vector_1.Vector.CreateVec3(0, 0, 0);
        /** The left value of the ortho rectangle, defaults to -5 */
        this.left = -5;
        /** The right value of the ortho rectangle, defaults to 5 */
        this.right = 5;
        /** The top value of the ortho rectangle, defaults to 5 */
        this.top = 5;
        /** The bottom value of the ortho rectangle, defaults to -5 */
        this.bottom = -5;
        /** Up vector of the camera */
        this.up = Vector_1.Vector.CreateVec3(0, 0, -1);
    }
    return OrthoCameraSetup;
}());
exports.OrthoCameraSetup = OrthoCameraSetup;
var CameraType;
(function (CameraType) {
    CameraType[CameraType["Perspective"] = 0] = "Perspective";
    CameraType[CameraType["Orthographic"] = 1] = "Orthographic";
})(CameraType = exports.CameraType || (exports.CameraType = {}));
