text: <!DOCTYPE html>
  <html lang="en">
  <head>
      <meta charset="utf-8">
      <title>JSDoc: Source: projection/fisheye.js</title>
  
      <script src="scripts/prettify/prettify.js"> </script>
      <script src="scripts/prettify/lang-css.js"> </script>
      <!--[if lt IE 9]>
        <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
      <![endif]-->
      <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
      <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
  </head>
  
  <body>
  
  <div id="main">
  
      <h1 class="page-title">Source: projection/fisheye.js</h1>
  
      
  
  
  
      
      <section>
          <article>
              <pre class="prettyprint source linenums"><code>
  'use strict';
  
  /**
   * @license
   * Copyright Little Star Media Inc. and other contributors.
   *
   * Permission is hereby granted, free of charge, to any person obtaining a
   * copy of this software and associated documentation files (the
   * 'Software'), to deal in the Software without restriction, including
   * without limitation the rights to use, copy, modify, merge, publish,
   * distribute, sublicense, and/or sell copies of the Software, and to permit
   * persons to whom the Software is furnished to do so, subject to the
   * following conditions:
   *
   * The above copyright notice and this permission notice shall be included
   * in all copies or substantial portions of the Software.
   *
   * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS
   * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
   * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
   * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
   * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
   * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
   * USE OR OTHER DEALINGS IN THE SOFTWARE.
   */
  
  /**
   * The fisheye projection mode.
   *
   * @public
   * @module scope/projection/fisheye
   * @type {Function}
   */
  
  /**
   * Module dependencies
   * @private
   */
  
  var three = require('three.js')
  
  /**
   * Local dependencies
   * @private
   */
  
  var constants = require('../constants')
  
  // animation factor
  var ANIMATION_FACTOR = constants.ANIMATION_FACTOR;
  var DEFAULT_FOV = constants.DEFAULT_FOV;
  
  /**
   * Fisheye projection constraints.
   *
   * @public
   * @type {Object}
   */
  
  var constraints = fisheye.constraints = {};
  
  /**
   * Applies a fisheye projection to scope frame
   *
   * @api public
   * @param {Axis} scope
   */
  
  module.exports = fisheye;
  function fisheye (scope) {
  
    // this projection requires an already initialized
    // camera on the `scope' instance
    var camera = scope.camera;
  
    // bail if camera not initialized
    if (null == camera) { return false; }
  
    // bail if not ready
    if (false == this.isReady()) { return false; }
  
    // bail if geometry is a cylinder because fisheye
    // projection is only supported in a spherical geometry
    if ('cylinder' == scope.geometry()) { return false; }
  
    // max Z and FOV
    var maxZ = (scope.height() / 100) | 0;
    var fov = DEFAULT_FOV + 20;
    var current = this.current;
  
    this.constraints = {};
  
    if ('cylinder' == scope.geometry()) {
      scope.orientation.x = 0;
      this.constraints.y = true;
      this.constraints.x = false;
    }
  
    // begin animation
    scope.debug("animate: FISHEYE begin");
    this.animate(function () {
      scope.fov(fov);
      scope.camera.position.z = maxZ;
  
      if ('tinyplanet' == current) {
        scope.lookAt(0, 0, 0);
      }
  
      if ('equilinear' != current) {
        scope.orientation.x = (Math.PI/180);
      }
  
      this.cancel();
    });
  };
  </code></pre>
          </article>
      </section>
  
  
  
  
  </div>
  
  <nav>
      <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-axis.html">axis</a></li><li><a href="module-axis_constants.html">axis/constants</a></li><li><a href="module-axis_controls_controller.html">axis/controls/controller</a></li><li><a href="module-axis_controls_keyboard.html">axis/controls/keyboard</a></li><li><a href="module-axis_controls_orientation.html">axis/controls/orientation</a></li><li><a href="module-axis_controls_touch.html">axis/controls/touch</a></li><li><a href="module-axis_projection.html">axis/projection</a></li><li><a href="module-axis_projection_flat.html">axis/projection/flat</a></li><li><a href="module-axis_state.html">axis/state</a></li><li><a href="module-scope_projection_equilinear.html">scope/projection/equilinear</a></li><li><a href="module-scope_projection_fisheye.html">scope/projection/fisheye</a></li><li><a href="module-scope_projection_tinyplanet.html">scope/projection/tinyplanet</a></li></ul><h3>Classes</h3><ul><li><a href="module-axis_controls_controller.html">axis/controls/controller</a></li><li><a href="module-axis_controls_keyboard.KeyboardController.html">KeyboardController</a></li><li><a href="module-axis_controls_orientation.OrientationController.html">OrientationController</a></li><li><a href="module-axis_controls_touch.TouchController.html">TouchController</a></li><li><a href="module-axis_projection-Projections.html">Projections</a></li><li><a href="module-axis_state-State.html">State</a></li><li><a href="module-axis-Axis.html">Axis</a></li></ul><h3>Events</h3><ul><li><a href="module-axis_state-State.html#event:ready">ready</a></li><li><a href="module-axis_state-State.html#event:update">update</a></li><li><a href="module-axis-Axis.html#event:click">click</a></li><li><a href="module-axis-Axis.html#event:fullscreenchange">fullscreenchange</a></li><li><a href="module-axis-Axis.html#event:keydown">keydown</a></li><li><a href="module-axis-Axis.html#event:ready">ready</a></li><li><a href="module-axis-Axis.html#event:vrhmdavailable">vrhmdavailable</a></li></ul><h3>Global</h3><ul><li><a href="global.html#createCamera">createCamera</a></li><li><a href="global.html#three">three</a></li></ul>
  </nav>
  
  <br class="clear">
  
  <footer>
      Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.2</a> on Wed Jul 08 2015 10:13:51 GMT-0400 (EDT)
  </footer>
  
  <script> prettyPrint(); </script>
  <script src="scripts/linenumber.js"> </script>
  </body>
  </html>
  