'use strict';

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

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 _view = require('./view');

var _view2 = _interopRequireDefault(_view);

var _viewport = require('../viewports/viewport');

var _viewport2 = _interopRequireDefault(_viewport);

var _lookAt = require('gl-mat4/lookAt');

var _lookAt2 = _interopRequireDefault(_lookAt);

var _ortho = require('gl-mat4/ortho');

var _ortho2 = _interopRequireDefault(_ortho);

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; }

var OrthographicView = function (_View) {
  _inherits(OrthographicView, _View);

  function OrthographicView() {
    _classCallCheck(this, OrthographicView);

    return _possibleConstructorReturn(this, (OrthographicView.__proto__ || Object.getPrototypeOf(OrthographicView)).apply(this, arguments));
  }

  _createClass(OrthographicView, [{
    key: '_getViewport',
    value: function _getViewport(_ref) {
      var x = _ref.x,
          y = _ref.y,
          width = _ref.width,
          height = _ref.height,
          viewState = _ref.viewState;
      var _viewState$eye = viewState.eye,
          eye = _viewState$eye === undefined ? [0, 0, 1] : _viewState$eye,
          _viewState$lookAt = viewState.lookAt,
          lookAt = _viewState$lookAt === undefined ? [0, 0, 0] : _viewState$lookAt,
          _viewState$up = viewState.up,
          up = _viewState$up === undefined ? [0, 1, 0] : _viewState$up,
          left = viewState.left,
          top = viewState.top;
      var _viewState$right = viewState.right,
          right = _viewState$right === undefined ? null : _viewState$right,
          _viewState$bottom = viewState.bottom,
          bottom = _viewState$bottom === undefined ? null : _viewState$bottom;
      var _props = this.props,
          _props$near = _props.near,
          near = _props$near === undefined ? 1 : _props$near,
          _props$far = _props.far,
          far = _props$far === undefined ? 100 : _props$far;


      right = Number.isFinite(right) ? right : left + width;
      bottom = Number.isFinite(bottom) ? bottom : top + height;
      return new _viewport2.default({
        x: x,
        y: y,
        width: width,
        height: height,
        viewMatrix: (0, _lookAt2.default)([], eye, lookAt, up),
        projectionMatrix: (0, _ortho2.default)([], left, right, bottom, top, near, far)
      });
    }
  }]);

  return OrthographicView;
}(_view2.default);

exports.default = OrthographicView;


OrthographicView.displayName = 'OrthographicView';
//# sourceMappingURL=orthographic-view.js.map