UNPKG

terriajs

Version:

Geospatial data visualization platform.

1,538 lines (1,341 loc) 13.7 MB
/******/ (function(modules) { // webpackBootstrap /******/ // install a JSONP callback for chunk loading /******/ var parentJsonpFunction = window["webpackJsonp"]; /******/ window["webpackJsonp"] = function webpackJsonpCallback(chunkIds, moreModules, executeModules) { /******/ // add "moreModules" to the modules object, /******/ // then flag all "chunkIds" as loaded and fire callback /******/ var moduleId, chunkId, i = 0, resolves = [], result; /******/ for(;i < chunkIds.length; i++) { /******/ chunkId = chunkIds[i]; /******/ if(installedChunks[chunkId]) { /******/ resolves.push(installedChunks[chunkId][0]); /******/ } /******/ installedChunks[chunkId] = 0; /******/ } /******/ for(moduleId in moreModules) { /******/ if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) { /******/ modules[moduleId] = moreModules[moduleId]; /******/ } /******/ } /******/ if(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules, executeModules); /******/ while(resolves.length) { /******/ resolves.shift()(); /******/ } /******/ /******/ }; /******/ /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // objects to store loaded and loading chunks /******/ var installedChunks = { /******/ 1: 0 /******/ }; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ // This file contains only the entry chunk. /******/ // The chunk loading function for additional chunks /******/ __webpack_require__.e = function requireEnsure(chunkId) { /******/ var installedChunkData = installedChunks[chunkId]; /******/ if(installedChunkData === 0) { /******/ return new Promise(function(resolve) { resolve(); }); /******/ } /******/ /******/ // a Promise means "currently loading". /******/ if(installedChunkData) { /******/ return installedChunkData[2]; /******/ } /******/ /******/ // setup Promise in chunk cache /******/ var promise = new Promise(function(resolve, reject) { /******/ installedChunkData = installedChunks[chunkId] = [resolve, reject]; /******/ }); /******/ installedChunkData[2] = promise; /******/ /******/ // start chunk loading /******/ var head = document.getElementsByTagName('head')[0]; /******/ var script = document.createElement('script'); /******/ script.type = "text/javascript"; /******/ script.charset = 'utf-8'; /******/ script.async = true; /******/ script.timeout = 120000; /******/ /******/ if (__webpack_require__.nc) { /******/ script.setAttribute("nonce", __webpack_require__.nc); /******/ } /******/ script.src = __webpack_require__.p + "" + chunkId + ".TerriaJS-specs.js"; /******/ var timeout = setTimeout(onScriptComplete, 120000); /******/ script.onerror = script.onload = onScriptComplete; /******/ function onScriptComplete() { /******/ // avoid mem leaks in IE. /******/ script.onerror = script.onload = null; /******/ clearTimeout(timeout); /******/ var chunk = installedChunks[chunkId]; /******/ if(chunk !== 0) { /******/ if(chunk) { /******/ chunk[1](new Error('Loading chunk ' + chunkId + ' failed.')); /******/ } /******/ installedChunks[chunkId] = undefined; /******/ } /******/ }; /******/ head.appendChild(script); /******/ /******/ return promise; /******/ }; /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { /******/ configurable: false, /******/ enumerable: true, /******/ get: getter /******/ }); /******/ } /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = "build/"; /******/ /******/ // on error function for async loading /******/ __webpack_require__.oe = function(err) { console.error(err); throw err; }; /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 808); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_RESULT__ = (function() { 'use strict'; /** * @exports defined * * @param {*} value The object. * @returns {Boolean} Returns true if the object is defined, returns false otherwise. * * @example * if (Cesium.defined(positions)) { * doSomething(); * } else { * doSomethingElse(); * } */ function defined(value) { return value !== undefined && value !== null; } return defined; }).call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); /***/ }), /* 1 */ /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(6) ], __WEBPACK_AMD_DEFINE_RESULT__ = (function( freezeObject) { 'use strict'; /** * Returns the first parameter if not undefined, otherwise the second parameter. * Useful for setting a default value for a parameter. * * @exports defaultValue * * @param {*} a * @param {*} b * @returns {*} Returns the first parameter if not undefined, otherwise the second parameter. * * @example * param = Cesium.defaultValue(param, 'default'); */ function defaultValue(a, b) { if (a !== undefined && a !== null) { return a; } return b; } /** * A frozen empty object that can be used as the default value for options passed as * an object literal. * @type {Object} */ defaultValue.EMPTY_OBJECT = freezeObject({}); return defaultValue; }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); /***/ }), /* 2 */ /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(0) ], __WEBPACK_AMD_DEFINE_RESULT__ = (function( defined) { 'use strict'; /** * Constructs an exception object that is thrown due to a developer error, e.g., invalid argument, * argument out of range, etc. This exception should only be thrown during development; * it usually indicates a bug in the calling code. This exception should never be * caught; instead the calling code should strive not to generate it. * <br /><br /> * On the other hand, a {@link RuntimeError} indicates an exception that may * be thrown at runtime, e.g., out of memory, that the calling code should be prepared * to catch. * * @alias DeveloperError * @constructor * @extends Error * * @param {String} [message] The error message for this exception. * * @see RuntimeError */ function DeveloperError(message) { /** * 'DeveloperError' indicating that this exception was thrown due to a developer error. * @type {String} * @readonly */ this.name = 'DeveloperError'; /** * The explanation for why this exception was thrown. * @type {String} * @readonly */ this.message = message; //Browsers such as IE don't have a stack property until you actually throw the error. var stack; try { throw new Error(); } catch (e) { stack = e.stack; } /** * The stack trace of this exception, if available. * @type {String} * @readonly */ this.stack = stack; } if (defined(Object.create)) { DeveloperError.prototype = Object.create(Error.prototype); DeveloperError.prototype.constructor = DeveloperError; } DeveloperError.prototype.toString = function() { var str = this.name + ': ' + this.message; if (defined(this.stack)) { str += '\n' + this.stack.toString(); } return str; }; /** * @private */ DeveloperError.throwInstantiationError = function() { throw new DeveloperError('This function defines an interface and should not be called directly.'); }; return DeveloperError; }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); /***/ }), /* 3 */ /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(0) ], __WEBPACK_AMD_DEFINE_RESULT__ = (function( defined) { 'use strict'; var definePropertyWorks = (function() { try { return 'x' in Object.defineProperty({}, 'x', {}); } catch (e) { return false; } })(); /** * Defines properties on an object, using Object.defineProperties if available, * otherwise returns the object unchanged. This function should be used in * setup code to prevent errors from completely halting JavaScript execution * in legacy browsers. * * @private * * @exports defineProperties */ var defineProperties = Object.defineProperties; if (!definePropertyWorks || !defined(defineProperties)) { defineProperties = function(o) { return o; }; } return defineProperties; }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); /***/ }), /* 4 */ /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(874), __webpack_require__(8), __webpack_require__(1), __webpack_require__(0), __webpack_require__(2) ], __WEBPACK_AMD_DEFINE_RESULT__ = (function( MersenneTwister, Check, defaultValue, defined, DeveloperError) { 'use strict'; /** * Math functions. * * @exports CesiumMath * @alias Math */ var CesiumMath = {}; /** * 0.1 * @type {Number} * @constant */ CesiumMath.EPSILON1 = 0.1; /** * 0.01 * @type {Number} * @constant */ CesiumMath.EPSILON2 = 0.01; /** * 0.001 * @type {Number} * @constant */ CesiumMath.EPSILON3 = 0.001; /** * 0.0001 * @type {Number} * @constant */ CesiumMath.EPSILON4 = 0.0001; /** * 0.00001 * @type {Number} * @constant */ CesiumMath.EPSILON5 = 0.00001; /** * 0.000001 * @type {Number} * @constant */ CesiumMath.EPSILON6 = 0.000001; /** * 0.0000001 * @type {Number} * @constant */ CesiumMath.EPSILON7 = 0.0000001; /** * 0.00000001 * @type {Number} * @constant */ CesiumMath.EPSILON8 = 0.00000001; /** * 0.000000001 * @type {Number} * @constant */ CesiumMath.EPSILON9 = 0.000000001; /** * 0.0000000001 * @type {Number} * @constant */ CesiumMath.EPSILON10 = 0.0000000001; /** * 0.00000000001 * @type {Number} * @constant */ CesiumMath.EPSILON11 = 0.00000000001; /** * 0.000000000001 * @type {Number} * @constant */ CesiumMath.EPSILON12 = 0.000000000001; /** * 0.0000000000001 * @type {Number} * @constant */ CesiumMath.EPSILON13 = 0.0000000000001; /** * 0.00000000000001 * @type {Number} * @constant */ CesiumMath.EPSILON14 = 0.00000000000001; /** * 0.000000000000001 * @type {Number} * @constant */ CesiumMath.EPSILON15 = 0.000000000000001; /** * 0.0000000000000001 * @type {Number} * @constant */ CesiumMath.EPSILON16 = 0.0000000000000001; /** * 0.00000000000000001 * @type {Number} * @constant */ CesiumMath.EPSILON17 = 0.00000000000000001; /** * 0.000000000000000001 * @type {Number} * @constant */ CesiumMath.EPSILON18 = 0.000000000000000001; /** * 0.0000000000000000001 * @type {Number} * @constant */ CesiumMath.EPSILON19 = 0.0000000000000000001; /** * 0.00000000000000000001 * @type {Number} * @constant */ CesiumMath.EPSILON20 = 0.00000000000000000001; /** * The gravitational parameter of the Earth in meters cubed * per second squared as defined by the WGS84 model: 3.986004418e14 * @type {Number} * @constant */ CesiumMath.GRAVITATIONALPARAMETER = 3.986004418e14; /** * Radius of the sun in meters: 6.955e8 * @type {Number} * @constant */ CesiumMath.SOLAR_RADIUS = 6.955e8; /** * The mean radius of the moon, according to the "Report of the IAU/IAG Working Group on * Cartographic Coordinates and Rotational Elements of the Planets and satellites: 2000", * Celestial Mechanics 82: 83-110, 2002. * @type {Number} * @constant */ CesiumMath.LUNAR_RADIUS = 1737400.0; /** * 64 * 1024 * @type {Number} * @constant */ CesiumMath.SIXTY_FOUR_KILOBYTES = 64 * 1024; /** * Returns the sign of the value; 1 if the value is positive, -1 if the value is * negative, or 0 if the value is 0. * * @function * @param {Number} value The value to return the sign of. * @returns {Number} The sign of value. */ CesiumMath.sign = defaultValue(Math.sign, function sign(value) { value = +value; // coerce to number if (value === 0 || value !== value) { // zero or NaN return value; } return value > 0 ? 1 : -1; }); /** * Returns 1.0 if the given value is positive or zero, and -1.0 if it is negative. * This is similar to {@link CesiumMath#sign} except that returns 1.0 instead of * 0.0 when the input value is 0.0. * @param {Number} value The value to return the sign of. * @returns {Number} The sign of value. */ CesiumMath.signNotZero = function(value) { return value < 0.0 ? -1.0 : 1.0; }; /** * Converts a scalar value in the range [-1.0, 1.0] to a SNORM in the range [0, rangeMax] * @param {Number} value The scalar value in the range [-1.0, 1.0] * @param {Number} [rangeMax=255] The maximum value in the mapped range, 255 by default. * @returns {Number} A SNORM value, where 0 maps to -1.0 and rangeMax maps to 1.0. * * @see CesiumMath.fromSNorm */ CesiumMath.toSNorm = function(value, rangeMax) { rangeMax = defaultValue(rangeMax, 255); return Math.round((CesiumMath.clamp(value, -1.0, 1.0) * 0.5 + 0.5) * rangeMax); }; /** * Converts a SNORM value in the range [0, rangeMax] to a scalar in the range [-1.0, 1.0]. * @param {Number} value SNORM value in the range [0, 255] * @param {Number} [rangeMax=255] The maximum value in the SNORM range, 255 by default. * @returns {Number} Scalar in the range [-1.0, 1.0]. * * @see CesiumMath.toSNorm */ CesiumMath.fromSNorm = function(value, rangeMax) { rangeMax = defaultValue(rangeMax, 255); return CesiumMath.clamp(value, 0.0, rangeMax) / rangeMax * 2.0 - 1.0; }; /** * Returns the hyperbolic sine of a number. * The hyperbolic sine of <em>value</em> is defined to be * (<em>e<sup>x</sup>&nbsp;-&nbsp;e<sup>-x</sup></em>)/2.0 * where <i>e</i> is Euler's number, approximately 2.71828183. * * <p>Special cases: * <ul> * <li>If the argument is NaN, then the result is NaN.</li> * * <li>If the argument is infinite, then the result is an infinity * with the same sign as the argument.</li> * * <li>If the argument is zero, then the result is a zero with the * same sign as the argument.</li> * </ul> *</p> * * @function * @param {Number} value The number whose hyperbolic sine is to be returned. * @returns {Number} The hyperbolic sine of <code>value</code>. */ CesiumMath.sinh = defaultValue(Math.sinh, function sinh(value) { return (Math.exp(value) - Math.exp(-value)) / 2.0; }); /** * Returns the hyperbolic cosine of a number. * The hyperbolic cosine of <strong>value</strong> is defined to be * (<em>e<sup>x</sup>&nbsp;+&nbsp;e<sup>-x</sup></em>)/2.0 * where <i>e</i> is Euler's number, approximately 2.71828183. * * <p>Special cases: * <ul> * <li>If the argument is NaN, then the result is NaN.</li> * * <li>If the argument is infinite, then the result is positive infinity.</li> * * <li>If the argument is zero, then the result is 1.0.</li> * </ul> *</p> * * @function * @param {Number} value The number whose hyperbolic cosine is to be returned. * @returns {Number} The hyperbolic cosine of <code>value</code>. */ CesiumMath.cosh = defaultValue(Math.cosh, function cosh(value) { return (Math.exp(value) + Math.exp(-value)) / 2.0; }); /** * Computes the linear interpolation of two values. * * @param {Number} p The start value to interpolate. * @param {Number} q The end value to interpolate. * @param {Number} time The time of interpolation generally in the range <code>[0.0, 1.0]</code>. * @returns {Number} The linearly interpolated value. * * @example * var n = Cesium.Math.lerp(0.0, 2.0, 0.5); // returns 1.0 */ CesiumMath.lerp = function(p, q, time) { return ((1.0 - time) * p) + (time * q); }; /** * pi * * @type {Number} * @constant */ CesiumMath.PI = Math.PI; /** * 1/pi * * @type {Number} * @constant */ CesiumMath.ONE_OVER_PI = 1.0 / Math.PI; /** * pi/2 * * @type {Number} * @constant */ CesiumMath.PI_OVER_TWO = Math.PI / 2.0; /** * pi/3 * * @type {Number} * @constant */ CesiumMath.PI_OVER_THREE = Math.PI / 3.0; /** * pi/4 * * @type {Number} * @constant */ CesiumMath.PI_OVER_FOUR = Math.PI / 4.0; /** * pi/6 * * @type {Number} * @constant */ CesiumMath.PI_OVER_SIX = Math.PI / 6.0; /** * 3pi/2 * * @type {Number} * @constant */ CesiumMath.THREE_PI_OVER_TWO = 3.0 * Math.PI / 2.0; /** * 2pi * * @type {Number} * @constant */ CesiumMath.TWO_PI = 2.0 * Math.PI; /** * 1/2pi * * @type {Number} * @constant */ CesiumMath.ONE_OVER_TWO_PI = 1.0 / (2.0 * Math.PI); /** * The number of radians in a degree. * * @type {Number} * @constant * @default Math.PI / 180.0 */ CesiumMath.RADIANS_PER_DEGREE = Math.PI / 180.0; /** * The number of degrees in a radian. * * @type {Number} * @constant * @default 180.0 / Math.PI */ CesiumMath.DEGREES_PER_RADIAN = 180.0 / Math.PI; /** * The number of radians in an arc second. * * @type {Number} * @constant * @default {@link CesiumMath.RADIANS_PER_DEGREE} / 3600.0 */ CesiumMath.RADIANS_PER_ARCSECOND = CesiumMath.RADIANS_PER_DEGREE / 3600.0; /** * Converts degrees to radians. * @param {Number} degrees The angle to convert in degrees. * @returns {Number} The corresponding angle in radians. */ CesiumMath.toRadians = function(degrees) { return degrees * CesiumMath.RADIANS_PER_DEGREE; }; /** * Converts radians to degrees. * @param {Number} radians The angle to convert in radians. * @returns {Number} The corresponding angle in degrees. */ CesiumMath.toDegrees = function(radians) { return radians * CesiumMath.DEGREES_PER_RADIAN; }; /** * Converts a longitude value, in radians, to the range [<code>-Math.PI</code>, <code>Math.PI</code>). * * @param {Number} angle The longitude value, in radians, to convert to the range [<code>-Math.PI</code>, <code>Math.PI</code>). * @returns {Number} The equivalent longitude value in the range [<code>-Math.PI</code>, <code>Math.PI</code>). * * @example * // Convert 270 degrees to -90 degrees longitude * var longitude = Cesium.Math.convertLongitudeRange(Cesium.Math.toRadians(270.0)); */ CesiumMath.convertLongitudeRange = function(angle) { var twoPi = CesiumMath.TWO_PI; var simplified = angle - Math.floor(angle / twoPi) * twoPi; if (simplified < -Math.PI) { return simplified + twoPi; } if (simplified >= Math.PI) { return simplified - twoPi; } return simplified; }; /** * Convenience function that clamps a latitude value, in radians, to the range [<code>-Math.PI/2</code>, <code>Math.PI/2</code>). * Useful for sanitizing data before use in objects requiring correct range. * * @param {Number} angle The latitude value, in radians, to clamp to the range [<code>-Math.PI/2</code>, <code>Math.PI/2</code>). * @returns {Number} The latitude value clamped to the range [<code>-Math.PI/2</code>, <code>Math.PI/2</code>). * * @example * // Clamp 108 degrees latitude to 90 degrees latitude * var latitude = Cesium.Math.clampToLatitudeRange(Cesium.Math.toRadians(108.0)); */ CesiumMath.clampToLatitudeRange = function(angle) { return CesiumMath.clamp(angle, -1*CesiumMath.PI_OVER_TWO, CesiumMath.PI_OVER_TWO); }; /** * Produces an angle in the range -Pi <= angle <= Pi which is equivalent to the provided angle. * * @param {Number} angle in radians * @returns {Number} The angle in the range [<code>-CesiumMath.PI</code>, <code>CesiumMath.PI</code>]. */ CesiumMath.negativePiToPi = function(angle) { return CesiumMath.zeroToTwoPi(angle + CesiumMath.PI) - CesiumMath.PI; }; /** * Produces an angle in the range 0 <= angle <= 2Pi which is equivalent to the provided angle. * * @param {Number} angle in radians * @returns {Number} The angle in the range [0, <code>CesiumMath.TWO_PI</code>]. */ CesiumMath.zeroToTwoPi = function(angle) { var mod = CesiumMath.mod(angle, CesiumMath.TWO_PI); if (Math.abs(mod) < CesiumMath.EPSILON14 && Math.abs(angle) > CesiumMath.EPSILON14) { return CesiumMath.TWO_PI; } return mod; }; /** * The modulo operation that also works for negative dividends. * * @param {Number} m The dividend. * @param {Number} n The divisor. * @returns {Number} The remainder. */ CesiumMath.mod = function(m, n) { return ((m % n) + n) % n; }; /** * Determines if two values are equal using an absolute or relative tolerance test. This is useful * to avoid problems due to roundoff error when comparing floating-point values directly. The values are * first compared using an absolute tolerance test. If that fails, a relative tolerance test is performed. * Use this test if you are unsure of the magnitudes of left and right. * * @param {Number} left The first value to compare. * @param {Number} right The other value to compare. * @param {Number} relativeEpsilon The maximum inclusive delta between <code>left</code> and <code>right</code> for the relative tolerance test. * @param {Number} [absoluteEpsilon=relativeEpsilon] The maximum inclusive delta between <code>left</code> and <code>right</code> for the absolute tolerance test. * @returns {Boolean} <code>true</code> if the values are equal within the epsilon; otherwise, <code>false</code>. * * @example * var a = Cesium.Math.equalsEpsilon(0.0, 0.01, Cesium.Math.EPSILON2); // true * var b = Cesium.Math.equalsEpsilon(0.0, 0.1, Cesium.Math.EPSILON2); // false * var c = Cesium.Math.equalsEpsilon(3699175.1634344, 3699175.2, Cesium.Math.EPSILON7); // true * var d = Cesium.Math.equalsEpsilon(3699175.1634344, 3699175.2, Cesium.Math.EPSILON9); // false */ CesiumMath.equalsEpsilon = function(left, right, relativeEpsilon, absoluteEpsilon) { absoluteEpsilon = defaultValue(absoluteEpsilon, relativeEpsilon); var absDiff = Math.abs(left - right); return absDiff <= absoluteEpsilon || absDiff <= relativeEpsilon * Math.max(Math.abs(left), Math.abs(right)); }; var factorials = [1]; /** * Computes the factorial of the provided number. * * @param {Number} n The number whose factorial is to be computed. * @returns {Number} The factorial of the provided number or undefined if the number is less than 0. * * @exception {DeveloperError} A number greater than or equal to 0 is required. * * * @example * //Compute 7!, which is equal to 5040 * var computedFactorial = Cesium.Math.factorial(7); * * @see {@link http://en.wikipedia.org/wiki/Factorial|Factorial on Wikipedia} */ CesiumMath.factorial = function(n) { var length = factorials.length; if (n >= length) { var sum = factorials[length - 1]; for (var i = length; i <= n; i++) { factorials.push(sum * i); } } return factorials[n]; }; /** * Increments a number with a wrapping to a minimum value if the number exceeds the maximum value. * * @param {Number} [n] The number to be incremented. * @param {Number} [maximumValue] The maximum incremented value before rolling over to the minimum value. * @param {Number} [minimumValue=0.0] The number reset to after the maximum value has been exceeded. * @returns {Number} The incremented number. * * @exception {DeveloperError} Maximum value must be greater than minimum value. * * @example * var n = Cesium.Math.incrementWrap(5, 10, 0); // returns 6 * var n = Cesium.Math.incrementWrap(10, 10, 0); // returns 0 */ CesiumMath.incrementWrap = function(n, maximumValue, minimumValue) { minimumValue = defaultValue(minimumValue, 0.0); ++n; if (n > maximumValue) { n = minimumValue; } return n; }; /** * Determines if a positive integer is a power of two. * * @param {Number} n The positive integer to test. * @returns {Boolean} <code>true</code> if the number if a power of two; otherwise, <code>false</code>. * * @exception {DeveloperError} A number greater than or equal to 0 is required. * * @example * var t = Cesium.Math.isPowerOfTwo(16); // true * var f = Cesium.Math.isPowerOfTwo(20); // false */ CesiumMath.isPowerOfTwo = function(n) { return (n !== 0) && ((n & (n - 1)) === 0); }; /** * Computes the next power-of-two integer greater than or equal to the provided positive integer. * * @param {Number} n The positive integer to test. * @returns {Number} The next power-of-two integer. * * @exception {DeveloperError} A number greater than or equal to 0 is required. * * @example * var n = Cesium.Math.nextPowerOfTwo(29); // 32 * var m = Cesium.Math.nextPowerOfTwo(32); // 32 */ CesiumMath.nextPowerOfTwo = function(n) { // From http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2 --n; n |= n >> 1; n |= n >> 2; n |= n >> 4; n |= n >> 8; n |= n >> 16; ++n; return n; }; /** * Constraint a value to lie between two values. * * @param {Number} value The value to constrain. * @param {Number} min The minimum value. * @param {Number} max The maximum value. * @returns {Number} The value clamped so that min <= value <= max. */ CesiumMath.clamp = function(value, min, max) { return value < min ? min : value > max ? max : value; }; var randomNumberGenerator = new MersenneTwister(); /** * Sets the seed used by the random number generator * in {@link CesiumMath#nextRandomNumber}. * * @param {Number} seed An integer used as the seed. */ CesiumMath.setRandomNumberSeed = function(seed) { randomNumberGenerator = new MersenneTwister(seed); }; /** * Generates a random floating point number in the range of [0.0, 1.0) * using a Mersenne twister. * * @returns {Number} A random number in the range of [0.0, 1.0). * * @see CesiumMath.setRandomNumberSeed * @see {@link http://en.wikipedia.org/wiki/Mersenne_twister|Mersenne twister on Wikipedia} */ CesiumMath.nextRandomNumber = function() { return randomNumberGenerator.random(); }; /** * Generates a random number between two numbers. * * @param {Number} min The minimum value. * @param {Number} max The maximum value. * @returns {Number} A random number between the min and max. */ CesiumMath.randomBetween = function(min, max) { return CesiumMath.nextRandomNumber() * (max - min) + min; }; /** * Computes <code>Math.acos(value)</code>, but first clamps <code>value</code> to the range [-1.0, 1.0] * so that the function will never return NaN. * * @param {Number} value The value for which to compute acos. * @returns {Number} The acos of the value if the value is in the range [-1.0, 1.0], or the acos of -1.0 or 1.0, * whichever is closer, if the value is outside the range. */ CesiumMath.acosClamped = function(value) { return Math.acos(CesiumMath.clamp(value, -1.0, 1.0)); }; /** * Computes <code>Math.asin(value)</code>, but first clamps <code>value</code> to the range [-1.0, 1.0] * so that the function will never return NaN. * * @param {Number} value The value for which to compute asin. * @returns {Number} The asin of the value if the value is in the range [-1.0, 1.0], or the asin of -1.0 or 1.0, * whichever is closer, if the value is outside the range. */ CesiumMath.asinClamped = function(value) { return Math.asin(CesiumMath.clamp(value, -1.0, 1.0)); }; /** * Finds the chord length between two points given the circle's radius and the angle between the points. * * @param {Number} angle The angle between the two points. * @param {Number} radius The radius of the circle. * @returns {Number} The chord length. */ CesiumMath.chordLength = function(angle, radius) { return 2.0 * radius * Math.sin(angle * 0.5); }; /** * Finds the logarithm of a number to a base. * * @param {Number} number The number. * @param {Number} base The base. * @returns {Number} The result. */ CesiumMath.logBase = function(number, base) { return Math.log(number) / Math.log(base); }; /** * Finds the cube root of a number. * Returns NaN if <code>number</code> is not provided. * * @function * @param {Number} [number] The number. * @returns {Number} The result. */ CesiumMath.cbrt = defaultValue(Math.cbrt, function cbrt(number) { var result = Math.pow(Math.abs(number), 1.0 / 3.0); return number < 0.0 ? -result : result; }); /** * Finds the base 2 logarithm of a number. * * @function * @param {Number} number The number. * @returns {Number} The result. */ CesiumMath.log2 = defaultValue(Math.log2, function log2(number) { return Math.log(number) * Math.LOG2E; }); /** * @private */ CesiumMath.fog = function(distanceToCamera, density) { var scalar = distanceToCamera * density; return 1.0 - Math.exp(-(scalar * scalar)); }; /** * Computes a fast approximation of Atan for input in the range [-1, 1]. * * Based on Michal Drobot's approximation from ShaderFastLibs, * which in turn is based on "Efficient approximations for the arctangent function," * Rajan, S. Sichun Wang Inkol, R. Joyal, A., May 2006. * Adapted from ShaderFastLibs under MIT License. * * @param {Number} x An input number in the range [-1, 1] * @returns {Number} An approximation of atan(x) */ CesiumMath.fastApproximateAtan = function(x) { return x * (-0.1784 * Math.abs(x) - 0.0663 * x * x + 1.0301); }; /** * Computes a fast approximation of Atan2(x, y) for arbitrary input scalars. * * Range reduction math based on nvidia's cg reference implementation: http://developer.download.nvidia.com/cg/atan2.html * * @param {Number} x An input number that isn't zero if y is zero. * @param {Number} y An input number that isn't zero if x is zero. * @returns {Number} An approximation of atan2(x, y) */ CesiumMath.fastApproximateAtan2 = function(x, y) { // atan approximations are usually only reliable over [-1, 1] // So reduce the range by flipping whether x or y is on top based on which is bigger. var opposite; var adjacent; var t = Math.abs(x); // t used as swap and atan result. opposite = Math.abs(y); adjacent = Math.max(t, opposite); opposite = Math.min(t, opposite); var oppositeOverAdjacent = opposite / adjacent; t = CesiumMath.fastApproximateAtan(oppositeOverAdjacent); // Undo range reduction t = Math.abs(y) > Math.abs(x) ? CesiumMath.PI_OVER_TWO - t : t; t = x < 0.0 ? CesiumMath.PI - t : t; t = y < 0.0 ? -t : t; return t; }; return CesiumMath; }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); /***/ }), /* 5 */ /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(8), __webpack_require__(1), __webpack_require__(0), __webpack_require__(2), __webpack_require__(6), __webpack_require__(4) ], __WEBPACK_AMD_DEFINE_RESULT__ = (function( Check, defaultValue, defined, DeveloperError, freezeObject, CesiumMath) { 'use strict'; /** * A 3D Cartesian point. * @alias Cartesian3 * @constructor * * @param {Number} [x=0.0] The X component. * @param {Number} [y=0.0] The Y component. * @param {Number} [z=0.0] The Z component. * * @see Cartesian2 * @see Cartesian4 * @see Packable */ function Cartesian3(x, y, z) { /** * The X component. * @type {Number} * @default 0.0 */ this.x = defaultValue(x, 0.0); /** * The Y component. * @type {Number} * @default 0.0 */ this.y = defaultValue(y, 0.0); /** * The Z component. * @type {Number} * @default 0.0 */ this.z = defaultValue(z, 0.0); } /** * Converts the provided Spherical into Cartesian3 coordinates. * * @param {Spherical} spherical The Spherical to be converted to Cartesian3. * @param {Cartesian3} [result] The object onto which to store the result. * @returns {Cartesian3} The modified result parameter or a new Cartesian3 instance if one was not provided. */ Cartesian3.fromSpherical = function(spherical, result) { if (!defined(result)) { result = new Cartesian3(); } var clock = spherical.clock; var cone = spherical.cone; var magnitude = defaultValue(spherical.magnitude, 1.0); var radial = magnitude * Math.sin(cone); result.x = radial * Math.cos(clock); result.y = radial * Math.sin(clock); result.z = magnitude * Math.cos(cone); return result; }; /** * Creates a Cartesian3 instance from x, y and z coordinates. * * @param {Number} x The x coordinate. * @param {Number} y The y coordinate. * @param {Number} z The z coordinate. * @param {Cartesian3} [result] The object onto which to store the result. * @returns {Cartesian3} The modified result parameter or a new Cartesian3 instance if one was not provided. */ Cartesian3.fromElements = function(x, y, z, result) { if (!defined(result)) { return new Cartesian3(x, y, z); } result.x = x; result.y = y; result.z = z; return result; }; /** * Duplicates a Cartesian3 instance. * * @param {Cartesian3} cartesian The Cartesian to duplicate. * @param {Cartesian3} [result] The object onto which to store the result. * @returns {Cartesian3} The modified result parameter or a new Cartesian3 instance if one was not provided. (Returns undefined if cartesian is undefined) */ Cartesian3.clone = function(cartesian, result) { if (!defined(cartesian)) { return undefined; } if (!defined(result)) { return new Cartesian3(cartesian.x, cartesian.y, cartesian.z); } result.x = cartesian.x; result.y = cartesian.y; result.z = cartesian.z; return result; }; /** * Creates a Cartesian3 instance from an existing Cartesian4. This simply takes the * x, y, and z properties of the Cartesian4 and drops w. * @function * * @param {Cartesian4} cartesian The Cartesian4 instance to create a Cartesian3 instance from. * @param {Cartesian3} [result] The object onto which to store the result. * @returns {Cartesian3} The modified result parameter or a new Cartesian3 instance if one was not provided. */ Cartesian3.fromCartesian4 = Cartesian3.clone; /** * The number of elements used to pack the object into an array. * @type {Number} */ Cartesian3.packedLength = 3; /** * Stores the provided instance into the provided array. * * @param {Cartesian3} value The value to pack. * @param {Number[]} array The array to pack into. * @param {Number} [startingIndex=0] The index into the array at which to start packing the elements. * * @returns {Number[]} The array that was packed into */ Cartesian3.pack = function(value, array, startingIndex) { startingIndex = defaultValue(startingIndex, 0); array[startingIndex++] = value.x; array[startingIndex++] = value.y; array[startingIndex] = value.z; return array; }; /** * Retrieves an instance from a packed array. * * @param {Number[]} array The packed array. * @param {Number} [startingIndex=0] The starting index of the element to be unpacked. * @param {Cartesian3} [result] The object into which to store the result. * @returns {Cartesian3} The modified result parameter or a new Cartesian3 instance if one was not provided. */ Cartesian3.unpack = function(array, startingIndex, result) { startingIndex = defaultValue(startingIndex, 0); if (!defined(result)) { result = new Cartesian3(); } result.x = array[startingIndex++]; result.y = array[startingIndex++]; result.z = array[startingIndex]; return result; }; /** * Flattens an array of Cartesian3s into an array of components. * * @param {Cartesian3[]} array The array of cartesians to pack. * @param {Number[]} result The array onto which to store the result. * @returns {Number[]} The packed array. */ Cartesian3.packArray = function(array, result) { var length = array.length; if (!defined(result)) { result = new Array(length * 3); } else { result.length = length * 3; } for (var i = 0; i < length; ++i) { Cartesian3.pack(array[i], result, i * 3); } return result; }; /** * Unpacks an array of cartesian components into an array of Cartesian3s. * * @param {Number[]} array The array of components to unpack. * @param {Cartesian3[]} result The array onto which to store the result. * @returns {Cartesian3[]} The unpacked array. */ Cartesian3.unpackArray = function(array, result) { var length = array.length; if (!defined(result)) { result = new Array(length / 3); } else { result.length = length / 3; } for (var i = 0; i < length; i += 3) { var index = i / 3; result[index] = Cartesian3.unpack(array, i, result[index]); } return result; }; /** * Creates a Cartesian3 from three consecutive elements in an array. * @function * * @param {Number[]} array The array whose three consecutive elements correspond to the x, y, and z components, respectively. * @param {Number} [startingIndex=0] The offset into the array of the first element, which corresponds to the x component. * @param {Cartesian3} [result] The object onto which to store the result. * @returns {Cartesian3} The modified result parameter or a new Cartesian3 instance if one was not provided. * * @example * // Create a Cartesian3 with (1.0, 2.0, 3.0) * var v = [1.0, 2.0, 3.0]; * var p = Cesium.Cartesian3.fromArray(v); * * // Create a Cartesian3 with (1.0, 2.0, 3.0) using an offset into an array * var v2 = [0.0, 0.0, 1.0, 2.0, 3.0]; * var p2 = Cesium.Cartesian3.fromArray(v2, 2); */ Cartesian3.fromArray = Cartesian3.unpack; /** * Computes the value of the maximum component for the supplied Cartesian. * * @param {Cartesian3} cartesian The cartesian to use. * @returns {Number} The value of the maximum component. */ Cartesian3.maximumComponent = function(cartesian) { return Math.max(cartesian.x, cartesian.y, cartesian.z); }; /** * Computes the value of the minimum component for the supplied Cartesian. * * @param {Cartesian3} cartesian The cartesian to use. * @returns {Number} The value of the minimum component. */ Cartesian3.minimumComponent = function(cartesian) { return Math.min(cartesian.x, cartesian.y, cartesian.z); }; /** * Compares two Cartesians and computes a Cartesian which contains the minimum components of the supplied Cartesians. * * @param {Cartesian3} first A cartesian to compare. * @param {Cartesian3} second A cartesian to compare. * @param {Cartesian3} result The object into which to store the result. * @returns {Cartesian3} A cartesian with the minimum components. */ Cartesian3.minimumByComponent = function(first, second, result) { result.x = Math.min(first.x, second.x); result.y = Math.min(first.y, second.y); result.z = Math.min(first.z, second.z); return result; }; /** * Compares two Cartesians and computes a Cartesian which contains the maximum components of the supplied Cartesians. * * @param {Cartesian3} first A cartesian to compare. * @param {Cartesian3} second A cartesian to compare. * @param {Cartesian3} result The object into which to store the result. * @returns {Cartesian3} A cartesian with the maximum components. */ Cartesian3.maximumByComponent = function(first, second, result) { result.x = Math.max(first.x, second.x); result.y = Math.max(first.y, second.y); result.z = Math.max(first.z, second.z); return result; }; /** * Computes the provided Cartesian's squared magnitude. * * @param {Cartesian3} cartesian The Cartesian instance whose squared magnitude is to be computed. * @returns {Number} The squared magnitude. */ Cartesian3.magnitudeSquared = function(cartesian) { return cartesian.x * cartesian.x + cartesian.y * cartesian.y + cartesian.z * cartesian.z; }; /** * Computes the Cartesian's magnitude (length). * * @param {Cartesian3} cartesian The Cartesian instance whose magnitude is to be computed. * @returns {Number} The magnitude. */ Cartesian3.magnitude = function(cartesian) { return Math.sqrt(Cartesian3.magnitudeSquared(cartesian)); }; var distanceScratch = new Cartesian3(); /** * Computes the distance between two points. * * @param {Cartesian3} left The first point to compute the distance from. * @param {Cartesian3} right The second point to compute the distance to. * @returns {Number} The distance between two points. * * @example * // Returns 1.0 * var d = Cesium.Cartesian3.distance(new Cesium.Cartesian3(1.0, 0.0, 0.0), new Cesium.Cartesian3(2.0, 0.0, 0.0)); */ Cartesian3.distance = function(left, right) { Cartesian3.subtract(left, right, distanceScratch); return Cartesian3.magnitude(distanceScratch); }; /** * Computes the squared distance between two points. Comparing squared distances * using this function is more efficient than comparing distances using {@link Cartesian3#distance}. * * @param {Cartesian3} left The first point to compute the distance from. * @param {Cartesian3} right The second point to compute the distance to. * @returns {Number} The distance between two points. * * @example * // Returns 4.0, not 2.0 * var d = Cesium.Cartesian3.distanceSquared(new Cesium.Cartesian3(1.0, 0.0, 0.0), new Cesium.Cartesian3(3.0, 0.0, 0.0)); */ Cartesian3.distanceSquared = function(left, right) { Cartesian3.subtract(left, rig