'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = undefined;

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

var _desc, _value, _class;

var _mathArray = require('./math-array');

var _mathArray2 = _interopRequireDefault(_mathArray);

var _common = require('./common');

var _glMatrix = require('gl-matrix');

var _decorators = require('./utils/decorators');

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) {
  var desc = {};
  Object['ke' + 'ys'](descriptor).forEach(function (key) {
    desc[key] = descriptor[key];
  });
  desc.enumerable = !!desc.enumerable;
  desc.configurable = !!desc.configurable;

  if ('value' in desc || desc.initializer) {
    desc.writable = true;
  }

  desc = decorators.slice().reverse().reduce(function (desc, decorator) {
    return decorator(target, property, desc) || desc;
  }, desc);

  if (context && desc.initializer !== void 0) {
    desc.value = desc.initializer ? desc.initializer.call(context) : void 0;
    desc.initializer = undefined;
  }

  if (desc.initializer === void 0) {
    Object['define' + 'Property'](target, property, desc);
    desc = null;
  }

  return desc;
}

var Vector4 = (_class = function (_MathArray) {
  _inherits(Vector4, _MathArray);

  // Creates a new, empty vec4
  function Vector4() {
    var x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
    var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
    var z = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
    var w = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;

    _classCallCheck(this, Vector4);

    var _this = _possibleConstructorReturn(this, (Vector4.__proto__ || Object.getPrototypeOf(Vector4)).call(this));

    if (Array.isArray(x) && arguments.length === 1) {
      _this.copy(x);
    } else {
      _this.set(x, y, z, w);
    }
    return _this;
  }

  _createClass(Vector4, [{
    key: 'set',
    value: function set(x, y, z, w) {
      _glMatrix.vec4.set(this, x, y, z, w);
      this.check();
      return this;
    }
  }, {
    key: 'equals',
    value: function equals(vector) {
      return _glMatrix.vec4.equals(this, vector);
    }
  }, {
    key: 'exactEquals',
    value: function exactEquals(vector) {
      return _glMatrix.vec4.exactEquals(this, vector);
    }

    // Getters/setters
    /* eslint-disable no-multi-spaces, brace-style, no-return-assign */

  }, {
    key: 'distance',
    value: function distance(vector) {
      return _glMatrix.vec4.distance(vector);
    }
  }, {
    key: 'dist',
    value: function dist(vector) {
      return _glMatrix.vec4.dist(vector);
    }
  }, {
    key: 'angle',
    value: function angle(vector) {
      return _glMatrix.vec4.angle(vector);
    }
  }, {
    key: 'add',
    value: function add() {
      for (var _len = arguments.length, vectors = Array(_len), _key = 0; _key < _len; _key++) {
        vectors[_key] = arguments[_key];
      }

      var _iteratorNormalCompletion = true;
      var _didIteratorError = false;
      var _iteratorError = undefined;

      try {
        for (var _iterator = vectors[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
          var vector = _step.value;

          _glMatrix.vec4.add(this, vector);
        }
      } catch (err) {
        _didIteratorError = true;
        _iteratorError = err;
      } finally {
        try {
          if (!_iteratorNormalCompletion && _iterator.return) {
            _iterator.return();
          }
        } finally {
          if (_didIteratorError) {
            throw _iteratorError;
          }
        }
      }

      this.check();
      return this;
    }
  }, {
    key: 'subtract',
    value: function subtract() {
      for (var _len2 = arguments.length, vectors = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
        vectors[_key2] = arguments[_key2];
      }

      var _iteratorNormalCompletion2 = true;
      var _didIteratorError2 = false;
      var _iteratorError2 = undefined;

      try {
        for (var _iterator2 = vectors[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
          var vector = _step2.value;

          _glMatrix.vec4.subtract(this, vector);
        }
      } catch (err) {
        _didIteratorError2 = true;
        _iteratorError2 = err;
      } finally {
        try {
          if (!_iteratorNormalCompletion2 && _iterator2.return) {
            _iterator2.return();
          }
        } finally {
          if (_didIteratorError2) {
            throw _iteratorError2;
          }
        }
      }

      this.check();
      return this;
    }
  }, {
    key: 'multiply',
    value: function multiply() {
      for (var _len3 = arguments.length, vectors = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
        vectors[_key3] = arguments[_key3];
      }

      var _iteratorNormalCompletion3 = true;
      var _didIteratorError3 = false;
      var _iteratorError3 = undefined;

      try {
        for (var _iterator3 = vectors[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
          var vector = _step3.value;

          _glMatrix.vec4.multiply(this, vector);
        }
      } catch (err) {
        _didIteratorError3 = true;
        _iteratorError3 = err;
      } finally {
        try {
          if (!_iteratorNormalCompletion3 && _iterator3.return) {
            _iterator3.return();
          }
        } finally {
          if (_didIteratorError3) {
            throw _iteratorError3;
          }
        }
      }

      this.check();
      return this;
    }
  }, {
    key: 'divide',
    value: function divide() {
      for (var _len4 = arguments.length, vectors = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
        vectors[_key4] = arguments[_key4];
      }

      var _iteratorNormalCompletion4 = true;
      var _didIteratorError4 = false;
      var _iteratorError4 = undefined;

      try {
        for (var _iterator4 = vectors[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
          var vector = _step4.value;

          _glMatrix.vec4.divide(this, vector);
        }
      } catch (err) {
        _didIteratorError4 = true;
        _iteratorError4 = err;
      } finally {
        try {
          if (!_iteratorNormalCompletion4 && _iterator4.return) {
            _iterator4.return();
          }
        } finally {
          if (_didIteratorError4) {
            throw _iteratorError4;
          }
        }
      }

      this.check();
      return this;
    }
  }, {
    key: 'ceil',
    value: function ceil() {
      _glMatrix.vec4.ceil(this, this);
      this.check();
      return this;
    }
  }, {
    key: 'floor',
    value: function floor() {
      _glMatrix.vec4.floor(this, this);
      this.check();
      return this;
    }
  }, {
    key: 'min',
    value: function min() {
      _glMatrix.vec4.min(this, this);
      this.check();
      return this;
    }
  }, {
    key: 'max',
    value: function max() {
      _glMatrix.vec4.max(this, this);
      this.check();
      return this;
    }
  }, {
    key: 'scale',
    value: function scale(_scale) {
      _glMatrix.vec4.scale(this, this, _scale);
      this.check();
      return this;
    }
  }, {
    key: 'scaleAndAdd',
    value: function scaleAndAdd(vector, scale) {
      _glMatrix.vec4.scaleAndAdd(this, this, vector, scale);
      this.check();
      return this;
    }
  }, {
    key: 'negate',
    value: function negate() {
      _glMatrix.vec4.negate(this, this);
      this.check();
      return this;
    }
  }, {
    key: 'inverse',
    value: function inverse() {
      _glMatrix.vec4.inverse(this, this);
      this.check();
      return this;
    }
  }, {
    key: 'normalize',
    value: function normalize() {
      _glMatrix.vec4.normalize(this, this);
      this.check();
      return this;
    }
  }, {
    key: 'dot',
    value: function dot(scale) {
      _glMatrix.vec4.dot(this, this, scale);
      this.check();
      return this;
    }
  }, {
    key: 'cross',
    value: function cross(scale) {
      _glMatrix.vec4.cross(this, this, scale);
      this.check();
      return this;
    }
  }, {
    key: 'lerp',
    value: function lerp(scale) {
      _glMatrix.vec4.lerp(this, this, scale);
      this.check();
      return this;
    }
  }, {
    key: 'hermite',
    value: function hermite(scale) {
      _glMatrix.vec4.hermite(this, this, scale);
      this.check();
      return this;
    }
  }, {
    key: 'bezier',
    value: function bezier(scale) {
      _glMatrix.vec4.bezier(this, this, scale);
      this.check();
      return this;
    }
  }, {
    key: 'random',
    value: function random(scale) {
      _glMatrix.vec4.random(this, this, scale);
      this.check();
      return this;
    }
  }, {
    key: 'rotateX',
    value: function rotateX(origin, angle) {
      _glMatrix.vec4.rotateX(this, this, origin, angle);
      this.check();
      return this;
    }
  }, {
    key: 'rotateY',
    value: function rotateY(origin, angle) {
      _glMatrix.vec4.rotateY(this, this, origin, angle);
      this.check();
      return this;
    }
  }, {
    key: 'rotateZ',
    value: function rotateZ(origin, angle) {
      _glMatrix.vec4.rotateZ(this, this, origin, angle);
      this.check();
      return this;
    }
  }, {
    key: 'ELEMENTS',
    get: function get() {
      return 4;
    }
  }, {
    key: 'x',
    get: function get() {
      return this[0];
    },
    set: function set(value) {
      return this[0] = (0, _common.checkNumber)(value);
    }
  }, {
    key: 'y',
    get: function get() {
      return this[1];
    },
    set: function set(value) {
      return this[1] = (0, _common.checkNumber)(value);
    }
  }, {
    key: 'z',
    get: function get() {
      return this[2];
    },
    set: function set(value) {
      return this[2] = (0, _common.checkNumber)(value);
    }
  }, {
    key: 'w',
    get: function get() {
      return this[3];
    },
    set: function set(value) {
      return this[3] = (0, _common.checkNumber)(value);
    }
    /* eslint-enable no-multi-spaces, brace-style, no-return-assign */

  }]);

  return Vector4;
}(_mathArray2.default), (_applyDecoratedDescriptor(_class.prototype, 'equals', [_decorators.binary], Object.getOwnPropertyDescriptor(_class.prototype, 'equals'), _class.prototype), _applyDecoratedDescriptor(_class.prototype, 'exactEquals', [_decorators.binary], Object.getOwnPropertyDescriptor(_class.prototype, 'exactEquals'), _class.prototype), _applyDecoratedDescriptor(_class.prototype, 'distance', [_decorators.binary], Object.getOwnPropertyDescriptor(_class.prototype, 'distance'), _class.prototype), _applyDecoratedDescriptor(_class.prototype, 'dist', [_decorators.binary], Object.getOwnPropertyDescriptor(_class.prototype, 'dist'), _class.prototype), _applyDecoratedDescriptor(_class.prototype, 'angle', [_decorators.binary], Object.getOwnPropertyDescriptor(_class.prototype, 'angle'), _class.prototype), _applyDecoratedDescriptor(_class.prototype, 'add', [_decorators.spread], Object.getOwnPropertyDescriptor(_class.prototype, 'add'), _class.prototype), _applyDecoratedDescriptor(_class.prototype, 'subtract', [_decorators.spread], Object.getOwnPropertyDescriptor(_class.prototype, 'subtract'), _class.prototype), _applyDecoratedDescriptor(_class.prototype, 'multiply', [_decorators.spread], Object.getOwnPropertyDescriptor(_class.prototype, 'multiply'), _class.prototype), _applyDecoratedDescriptor(_class.prototype, 'divide', [_decorators.spread], Object.getOwnPropertyDescriptor(_class.prototype, 'divide'), _class.prototype), _applyDecoratedDescriptor(_class.prototype, 'negate', [_decorators.unary], Object.getOwnPropertyDescriptor(_class.prototype, 'negate'), _class.prototype), _applyDecoratedDescriptor(_class.prototype, 'inverse', [_decorators.unary], Object.getOwnPropertyDescriptor(_class.prototype, 'inverse'), _class.prototype), _applyDecoratedDescriptor(_class.prototype, 'normalize', [_decorators.unary], Object.getOwnPropertyDescriptor(_class.prototype, 'normalize'), _class.prototype), _applyDecoratedDescriptor(_class.prototype, 'dot', [_decorators.binary], Object.getOwnPropertyDescriptor(_class.prototype, 'dot'), _class.prototype), _applyDecoratedDescriptor(_class.prototype, 'cross', [_decorators.binary], Object.getOwnPropertyDescriptor(_class.prototype, 'cross'), _class.prototype)), _class);
exports.default = Vector4;
//# sourceMappingURL=data:application/json;base64, 