diff --git a/CHANGES.md b/CHANGES.md index 8d963323f8df..05946b3e3a2d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -9,7 +9,7 @@ Beta Releases * Breaking changes: * Added `allowTextureFilterAnisotropic` (default: `true`) and `failIfMajorPerformanceCaveat` (default: `true`) properties to the `contextOption` property passed to `Viewer`, `CesiumWidget`, and `Scene` constructors and moved the existing properties to a new `webgl` sub-property. For example, code that looked like: - var viewer = new Viewer('cesiumContainer', { + var viewer = new Viewer('cesiumContainer', { alpha : true }); @@ -23,6 +23,7 @@ Beta Releases * The CSS files for individual widgets, e.g. `BaseLayerPicker.css`, no longer import other CSS files. Most applications should import `widgets.css` (and optionally `lighter.css`). * `SvgPath` has been replaced by a Knockout binding: `cesiumSvgPath`. * `DynamicObject.availability` is now a `TimeIntervalCollection` instead of a `TimeInterval`. +* The minified, combined `Cesium.js` file now omits certain `DeveloperError` checks, to increase performance and reduce file size. When developing your application, we recommend using the unminified version locally for early error detection, then deploying the minified version to production. * Added `CentralBody.maximumScreenSpaceError`. * Added `translateEventTypes`, `zoomEventTypes`, `rotateEventTypes`, `tiltEventTypes`, and `lookEventTypes` properties to `ScreenSpaceCameraController` to change the default mouse inputs. * Added `Billboard.setPixelOffsetScaleByDistance`, `Label.setPixelOffsetScaleByDistance`, `DynamicBillboard.pixelOffsetScaleByDistance`, and `DynamicLabel.pixelOffsetScaleByDistance` to control minimum/maximum pixelOffset scaling based on camera distance. diff --git a/Source/Core/BoundingSphere.js b/Source/Core/BoundingSphere.js index 9d27ef114d99..714fa16ffa9c 100644 --- a/Source/Core/BoundingSphere.js +++ b/Source/Core/BoundingSphere.js @@ -352,9 +352,11 @@ define([ stride = defaultValue(stride, 3); + //>>includeStart('debug', pragmas.debug); if (stride < 3) { throw new DeveloperError('stride must be 3 or greater.'); } + //>>includeEnd('debug'); var currentPos = fromPointsCurrentPos; currentPos.x = positions[0] + center.x; @@ -506,9 +508,11 @@ define([ * var sphere = BoundingSphere.fromCornerPoints(new Cartesian3(-0.5, -0.5, -0.5), new Cartesian3(0.5, 0.5, 0.5)); */ BoundingSphere.fromCornerPoints = function(corner, oppositeCorner, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(corner) || !defined(oppositeCorner)) { throw new DeveloperError('corner and oppositeCorner are required.'); } + //>>includeEnd('debug'); if (!defined(result)) { result = new BoundingSphere(); @@ -537,9 +541,11 @@ define([ * var boundingSphere = BoundingSphere.fromEllipsoid(ellipsoid); */ BoundingSphere.fromEllipsoid = function(ellipsoid, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(ellipsoid)) { throw new DeveloperError('ellipsoid is required.'); } + //>>includeEnd('debug'); if (!defined(result)) { result = new BoundingSphere(); @@ -587,6 +593,7 @@ define([ * @exception {DeveloperError} right is required. */ BoundingSphere.union = function(left, right, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(left)) { throw new DeveloperError('left is required.'); } @@ -594,6 +601,7 @@ define([ if (!defined(right)) { throw new DeveloperError('right is required.'); } + //>>includeEnd('debug'); if (!defined(result)) { result = new BoundingSphere(); @@ -628,6 +636,7 @@ define([ * @exception {DeveloperError} point is required. */ BoundingSphere.expand = function(sphere, point, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(sphere)) { throw new DeveloperError('sphere is required.'); } @@ -635,6 +644,7 @@ define([ if (!defined(point)) { throw new DeveloperError('point is required.'); } + //>>includeEnd('debug'); result = BoundingSphere.clone(sphere, result); @@ -662,6 +672,7 @@ define([ * @exception {DeveloperError} plane is required. */ BoundingSphere.intersect = function(sphere, plane) { + //>>includeStart('debug', pragmas.debug); if (!defined(sphere)) { throw new DeveloperError('sphere is required.'); } @@ -669,6 +680,7 @@ define([ if (!defined(plane)) { throw new DeveloperError('plane is required.'); } + //>>includeEnd('debug'); var center = sphere.center; var radius = sphere.radius; @@ -699,6 +711,7 @@ define([ * @exception {DeveloperError} transform is required. */ BoundingSphere.transform = function(sphere, transform, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(sphere)) { throw new DeveloperError('sphere is required.'); } @@ -706,6 +719,7 @@ define([ if (!defined(transform)) { throw new DeveloperError('transform is required.'); } + //>>includeEnd('debug'); if (!defined(result)) { result = new BoundingSphere(); @@ -741,6 +755,7 @@ define([ * @exception {DeveloperError} direction is required. */ BoundingSphere.getPlaneDistances = function(sphere, position, direction, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(sphere)) { throw new DeveloperError('sphere is required.'); } @@ -752,6 +767,7 @@ define([ if (!defined(direction)) { throw new DeveloperError('direction is required.'); } + //>>includeEnd('debug'); if (!defined(result)) { result = new Interval(); @@ -789,9 +805,11 @@ define([ * @exception {DeveloperError} sphere is required. */ BoundingSphere.projectTo2D = function(sphere, projection, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(sphere)) { throw new DeveloperError('sphere is required.'); } + //>>includeEnd('debug'); projection = defaultValue(projection, projectTo2DProjection); diff --git a/Source/Core/Cartesian2.js b/Source/Core/Cartesian2.js index 8232895ffd7e..36797decf063 100644 --- a/Source/Core/Cartesian2.js +++ b/Source/Core/Cartesian2.js @@ -125,6 +125,7 @@ define([ * @exception {DeveloperError} array is required. */ Cartesian2.pack = function(value, array, startingIndex) { + //>>includeStart('debug', pragmas.debug); if (!defined(value)) { throw new DeveloperError('value is required'); } @@ -132,6 +133,7 @@ define([ if (!defined(array)) { throw new DeveloperError('array is required'); } + //>>includeEnd('debug'); startingIndex = defaultValue(startingIndex, 0); @@ -150,9 +152,11 @@ define([ * @exception {DeveloperError} array is required. */ Cartesian2.unpack = function(array, startingIndex, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(array)) { throw new DeveloperError('array is required'); } + //>>includeEnd('debug'); startingIndex = defaultValue(startingIndex, 0); @@ -197,9 +201,12 @@ define([ * @exception {DeveloperError} cartesian is required. */ Cartesian2.getMaximumComponent = function(cartesian) { + //>>includeStart('debug', pragmas.debug); if (!defined(cartesian)) { throw new DeveloperError('cartesian is required'); } + //>>includeEnd('debug'); + return Math.max(cartesian.x, cartesian.y); }; @@ -213,9 +220,12 @@ define([ * @exception {DeveloperError} cartesian is required. */ Cartesian2.getMinimumComponent = function(cartesian) { + //>>includeStart('debug', pragmas.debug); if (!defined(cartesian)) { throw new DeveloperError('cartesian is required'); } + //>>includeEnd('debug'); + return Math.min(cartesian.x, cartesian.y); }; @@ -228,16 +238,19 @@ define([ * @param {Cartesian2} [result] The object into which to store the result. * @returns {Cartesian2} A cartesian with the minimum components. * - * @exception {DeveloperError} first cartesian is missing. - * @exception {DeveloperError} second cartesian is missing. + * @exception {DeveloperError} first is required. + * @exception {DeveloperError} second is required. */ Cartesian2.getMinimumByComponent = function(first, second, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(first)) { - throw new DeveloperError('first cartesian is missing'); + throw new DeveloperError('first is required.'); } if (!defined(second)) { - throw new DeveloperError('second cartesian is missing'); + throw new DeveloperError('second is required.'); } + //>>includeEnd('debug'); + if (!defined(result)) { result = new Cartesian2(); } @@ -257,16 +270,18 @@ define([ * @param {Cartesian2} [result] The object into which to store the result. * @returns {Cartesian2} A cartesian with the maximum components. * - * @exception {DeveloperError} first cartesian is missing. - * @exception {DeveloperError} second cartesian is missing. + * @exception {DeveloperError} first is required. + * @exception {DeveloperError} second is required. */ Cartesian2.getMaximumByComponent = function(first, second, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(first)) { - throw new DeveloperError('first cartesian is missing'); + throw new DeveloperError('first is required.'); } if (!defined(second)) { - throw new DeveloperError('second cartesian is missing'); + throw new DeveloperError('second is required.'); } + //>>includeEnd('debug'); if (!defined(result)) { result = new Cartesian2(); @@ -287,9 +302,12 @@ define([ * @exception {DeveloperError} cartesian is required. */ Cartesian2.magnitudeSquared = function(cartesian) { + //>>includeStart('debug', pragmas.debug); if (!defined(cartesian)) { throw new DeveloperError('cartesian is required'); } + //>>includeEnd('debug'); + return cartesian.x * cartesian.x + cartesian.y * cartesian.y; }; @@ -324,9 +342,11 @@ define([ * var d = Cartesian2.distance(new Cartesian2(1.0, 0.0), new Cartesian2(2.0, 0.0)); */ Cartesian2.distance = function(left, right) { + //>>includeStart('debug', pragmas.debug); if (!defined(left) || !defined(right)) { throw new DeveloperError('left and right are required.'); } + //>>includeEnd('debug'); Cartesian2.subtract(left, right, distanceScratch); return Cartesian2.magnitude(distanceScratch); @@ -343,9 +363,12 @@ define([ * @exception {DeveloperError} cartesian is required. */ Cartesian2.normalize = function(cartesian, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(cartesian)) { throw new DeveloperError('cartesian is required'); } + //>>includeEnd('debug'); + var magnitude = Cartesian2.magnitude(cartesian); if (!defined(result)) { return new Cartesian2(cartesian.x / magnitude, cartesian.y / magnitude); @@ -367,12 +390,15 @@ define([ * @exception {DeveloperError} right is required. */ Cartesian2.dot = function(left, right) { + //>>includeStart('debug', pragmas.debug); if (!defined(left)) { throw new DeveloperError('left is required'); } if (!defined(right)) { throw new DeveloperError('right is required'); } + //>>includeEnd('debug'); + return left.x * right.x + left.y * right.y; }; @@ -389,12 +415,15 @@ define([ * @exception {DeveloperError} right is required. */ Cartesian2.multiplyComponents = function(left, right, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(left)) { throw new DeveloperError('left is required'); } if (!defined(right)) { throw new DeveloperError('right is required'); } + //>>includeEnd('debug'); + if (!defined(result)) { return new Cartesian2(left.x * right.x, left.y * right.y); } @@ -416,12 +445,15 @@ define([ * @exception {DeveloperError} right is required. */ Cartesian2.add = function(left, right, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(left)) { throw new DeveloperError('left is required'); } if (!defined(right)) { throw new DeveloperError('right is required'); } + //>>includeEnd('debug'); + if (!defined(result)) { return new Cartesian2(left.x + right.x, left.y + right.y); } @@ -443,12 +475,15 @@ define([ * @exception {DeveloperError} right is required. */ Cartesian2.subtract = function(left, right, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(left)) { throw new DeveloperError('left is required'); } if (!defined(right)) { throw new DeveloperError('right is required'); } + //>>includeEnd('debug'); + if (!defined(result)) { return new Cartesian2(left.x - right.x, left.y - right.y); } @@ -470,12 +505,15 @@ define([ * @exception {DeveloperError} scalar is required and must be a number. */ Cartesian2.multiplyByScalar = function(cartesian, scalar, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(cartesian)) { throw new DeveloperError('cartesian is required'); } if (typeof scalar !== 'number') { throw new DeveloperError('scalar is required and must be a number.'); } + //>>includeEnd('debug'); + if (!defined(result)) { return new Cartesian2(cartesian.x * scalar, cartesian.y * scalar); } @@ -497,12 +535,15 @@ define([ * @exception {DeveloperError} scalar is required and must be a number. */ Cartesian2.divideByScalar = function(cartesian, scalar, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(cartesian)) { throw new DeveloperError('cartesian is required'); } if (typeof scalar !== 'number') { throw new DeveloperError('scalar is required and must be a number.'); } + //>>includeEnd('debug'); + if (!defined(result)) { return new Cartesian2(cartesian.x / scalar, cartesian.y / scalar); } @@ -522,9 +563,12 @@ define([ * @exception {DeveloperError} cartesian is required. */ Cartesian2.negate = function(cartesian, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(cartesian)) { throw new DeveloperError('cartesian is required'); } + //>>includeEnd('debug'); + if (!defined(result)) { return new Cartesian2(-cartesian.x, -cartesian.y); } @@ -544,9 +588,12 @@ define([ * @exception {DeveloperError} cartesian is required. */ Cartesian2.abs = function(cartesian, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(cartesian)) { throw new DeveloperError('cartesian is required'); } + //>>includeEnd('debug'); + if (!defined(result)) { return new Cartesian2(Math.abs(cartesian.x), Math.abs(cartesian.y)); } @@ -571,6 +618,7 @@ define([ * @exception {DeveloperError} t is required and must be a number. */ Cartesian2.lerp = function(start, end, t, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(start)) { throw new DeveloperError('start is required.'); } @@ -580,6 +628,8 @@ define([ if (typeof t !== 'number') { throw new DeveloperError('t is required and must be a number.'); } + //>>includeEnd('debug'); + Cartesian2.multiplyByScalar(end, t, lerpScratch); result = Cartesian2.multiplyByScalar(start, 1.0 - t, result); return Cartesian2.add(lerpScratch, result, result); @@ -599,12 +649,15 @@ define([ * @exception {DeveloperError} right is required. */ Cartesian2.angleBetween = function(left, right) { + //>>includeStart('debug', pragmas.debug); if (!defined(left)) { throw new DeveloperError('left is required'); } if (!defined(right)) { throw new DeveloperError('right is required'); } + //>>includeEnd('debug'); + Cartesian2.normalize(left, angleBetweenScratch); Cartesian2.normalize(right, angleBetweenScratch2); return Math.acos(Cartesian2.dot(angleBetweenScratch, angleBetweenScratch2)); @@ -622,9 +675,11 @@ define([ * @exception {DeveloperError} cartesian is required. */ Cartesian2.mostOrthogonalAxis = function(cartesian, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(cartesian)) { throw new DeveloperError('cartesian is required.'); } + //>>includeEnd('debug'); var f = Cartesian2.normalize(cartesian, mostOrthogonalAxisScratch); Cartesian2.abs(f, f); @@ -669,9 +724,12 @@ define([ * @exception {DeveloperError} epsilon is required and must be a number. */ Cartesian2.equalsEpsilon = function(left, right, epsilon) { + //>>includeStart('debug', pragmas.debug); if (typeof epsilon !== 'number') { throw new DeveloperError('epsilon is required and must be a number.'); } + //>>includeEnd('debug'); + return (left === right) || ((defined(left)) && (defined(right)) && diff --git a/Source/Core/Cartesian3.js b/Source/Core/Cartesian3.js index 748b6bcd1b1e..174befffd9ad 100644 --- a/Source/Core/Cartesian3.js +++ b/Source/Core/Cartesian3.js @@ -58,9 +58,12 @@ define([ * @exception {DeveloperError} spherical is required. */ Cartesian3.fromSpherical = function(spherical, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(spherical)) { throw new DeveloperError('spherical is required'); } + //>>includeEnd('debug'); + if (!defined(result)) { result = new Cartesian3(); } @@ -149,6 +152,7 @@ define([ * @exception {DeveloperError} array is required. */ Cartesian3.pack = function(value, array, startingIndex) { + //>>includeStart('debug', pragmas.debug); if (!defined(value)) { throw new DeveloperError('value is required'); } @@ -156,6 +160,7 @@ define([ if (!defined(array)) { throw new DeveloperError('array is required'); } + //>>includeEnd('debug'); startingIndex = defaultValue(startingIndex, 0); @@ -175,9 +180,11 @@ define([ * @exception {DeveloperError} array is required. */ Cartesian3.unpack = function(array, startingIndex, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(array)) { throw new DeveloperError('array is required'); } + //>>includeEnd('debug'); startingIndex = defaultValue(startingIndex, 0); @@ -223,9 +230,12 @@ define([ * @exception {DeveloperError} cartesian is required. */ Cartesian3.getMaximumComponent = function(cartesian) { + //>>includeStart('debug', pragmas.debug); if (!defined(cartesian)) { throw new DeveloperError('cartesian is required'); } + //>>includeEnd('debug'); + return Math.max(cartesian.x, cartesian.y, cartesian.z); }; @@ -239,9 +249,12 @@ define([ * @exception {DeveloperError} cartesian is required. */ Cartesian3.getMinimumComponent = function(cartesian) { + //>>includeStart('debug', pragmas.debug); if (!defined(cartesian)) { throw new DeveloperError('cartesian is required'); } + //>>includeEnd('debug'); + return Math.min(cartesian.x, cartesian.y, cartesian.z); }; @@ -254,16 +267,19 @@ define([ * @param {Cartesian3} [result] The object into which to store the result. * @returns {Cartesian3} A cartesian with the minimum components. * - * @exception {DeveloperError} first cartesian is missing. - * @exception {DeveloperError} second cartesian is missing. + * @exception {DeveloperError} first is required. + * @exception {DeveloperError} second is required. */ Cartesian3.getMinimumByComponent = function(first, second, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(first)) { - throw new DeveloperError('first cartesian is missing'); + throw new DeveloperError('first is required.'); } if (!defined(second)) { - throw new DeveloperError('second cartesian is missing'); + throw new DeveloperError('second is required.'); } + //>>includeEnd('debug'); + if (!defined(result)) { result = new Cartesian3(); } @@ -284,16 +300,18 @@ define([ * @param {Cartesian3} [result] The object into which to store the result. * @returns {Cartesian3} A cartesian with the maximum components. * - * @exception {DeveloperError} first cartesian is missing. - * @exception {DeveloperError} second cartesian is missing. + * @exception {DeveloperError} first is required. + * @exception {DeveloperError} second is required. */ Cartesian3.getMaximumByComponent = function(first, second, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(first)) { - throw new DeveloperError('first cartesian is missing'); + throw new DeveloperError('first is required.'); } if (!defined(second)) { - throw new DeveloperError('second cartesian is missing'); + throw new DeveloperError('second is required.'); } + //>>includeEnd('debug'); if (!defined(result)) { result = new Cartesian3(); @@ -315,9 +333,12 @@ define([ * @exception {DeveloperError} cartesian is required. */ Cartesian3.magnitudeSquared = function(cartesian) { + //>>includeStart('debug', pragmas.debug); if (!defined(cartesian)) { throw new DeveloperError('cartesian is required'); } + //>>includeEnd('debug'); + return cartesian.x * cartesian.x + cartesian.y * cartesian.y + cartesian.z * cartesian.z; }; @@ -352,9 +373,11 @@ define([ * var d = Cartesian3.distance(new Cartesian3(1.0, 0.0, 0.0), new Cartesian3(2.0, 0.0, 0.0)); */ Cartesian3.distance = function(left, right) { + //>>includeStart('debug', pragmas.debug); if (!defined(left) || !defined(right)) { throw new DeveloperError('left and right are required.'); } + //>>includeEnd('debug'); Cartesian3.subtract(left, right, distanceScratch); return Cartesian3.magnitude(distanceScratch); @@ -371,9 +394,12 @@ define([ * @exception {DeveloperError} cartesian is required. */ Cartesian3.normalize = function(cartesian, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(cartesian)) { throw new DeveloperError('cartesian is required'); } + //>>includeEnd('debug'); + var magnitude = Cartesian3.magnitude(cartesian); if (!defined(result)) { return new Cartesian3(cartesian.x / magnitude, cartesian.y / magnitude, cartesian.z / magnitude); @@ -396,12 +422,15 @@ define([ * @exception {DeveloperError} right is required. */ Cartesian3.dot = function(left, right) { + //>>includeStart('debug', pragmas.debug); if (!defined(left)) { throw new DeveloperError('left is required'); } if (!defined(right)) { throw new DeveloperError('right is required'); } + //>>includeEnd('debug'); + return left.x * right.x + left.y * right.y + left.z * right.z; }; @@ -418,12 +447,15 @@ define([ * @exception {DeveloperError} right is required. */ Cartesian3.multiplyComponents = function(left, right, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(left)) { throw new DeveloperError('left is required'); } if (!defined(right)) { throw new DeveloperError('right is required'); } + //>>includeEnd('debug'); + if (!defined(result)) { return new Cartesian3(left.x * right.x, left.y * right.y, left.z * right.z); } @@ -446,12 +478,15 @@ define([ * @exception {DeveloperError} right is required. */ Cartesian3.add = function(left, right, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(left)) { throw new DeveloperError('left is required'); } if (!defined(right)) { throw new DeveloperError('right is required'); } + //>>includeEnd('debug'); + if (!defined(result)) { return new Cartesian3(left.x + right.x, left.y + right.y, left.z + right.z); } @@ -474,12 +509,15 @@ define([ * @exception {DeveloperError} right is required. */ Cartesian3.subtract = function(left, right, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(left)) { throw new DeveloperError('left is required'); } if (!defined(right)) { throw new DeveloperError('right is required'); } + //>>includeEnd('debug'); + if (!defined(result)) { return new Cartesian3(left.x - right.x, left.y - right.y, left.z - right.z); } @@ -502,12 +540,15 @@ define([ * @exception {DeveloperError} scalar is required and must be a number. */ Cartesian3.multiplyByScalar = function(cartesian, scalar, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(cartesian)) { throw new DeveloperError('cartesian is required'); } if (typeof scalar !== 'number') { throw new DeveloperError('scalar is required and must be a number.'); } + //>>includeEnd('debug'); + if (!defined(result)) { return new Cartesian3(cartesian.x * scalar, cartesian.y * scalar, cartesian.z * scalar); } @@ -530,12 +571,15 @@ define([ * @exception {DeveloperError} scalar is required and must be a number. */ Cartesian3.divideByScalar = function(cartesian, scalar, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(cartesian)) { throw new DeveloperError('cartesian is required'); } if (typeof scalar !== 'number') { throw new DeveloperError('scalar is required and must be a number.'); } + //>>includeEnd('debug'); + if (!defined(result)) { return new Cartesian3(cartesian.x / scalar, cartesian.y / scalar, cartesian.z / scalar); } @@ -556,9 +600,12 @@ define([ * @exception {DeveloperError} cartesian is required. */ Cartesian3.negate = function(cartesian, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(cartesian)) { throw new DeveloperError('cartesian is required'); } + //>>includeEnd('debug'); + if (!defined(result)) { return new Cartesian3(-cartesian.x, -cartesian.y, -cartesian.z); } @@ -579,9 +626,12 @@ define([ * @exception {DeveloperError} cartesian is required. */ Cartesian3.abs = function(cartesian, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(cartesian)) { throw new DeveloperError('cartesian is required'); } + //>>includeEnd('debug'); + if (!defined(result)) { return new Cartesian3(Math.abs(cartesian.x), Math.abs(cartesian.y), Math.abs(cartesian.z)); } @@ -607,6 +657,7 @@ define([ * @exception {DeveloperError} t is required and must be a number. */ Cartesian3.lerp = function(start, end, t, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(start)) { throw new DeveloperError('start is required.'); } @@ -616,6 +667,8 @@ define([ if (typeof t !== 'number') { throw new DeveloperError('t is required and must be a number.'); } + //>>includeEnd('debug'); + Cartesian3.multiplyByScalar(end, t, lerpScratch); result = Cartesian3.multiplyByScalar(start, 1.0 - t, result); return Cartesian3.add(lerpScratch, result, result); @@ -635,12 +688,15 @@ define([ * @exception {DeveloperError} right is required. */ Cartesian3.angleBetween = function(left, right) { + //>>includeStart('debug', pragmas.debug); if (!defined(left)) { throw new DeveloperError('left is required'); } if (!defined(right)) { throw new DeveloperError('right is required'); } + //>>includeEnd('debug'); + Cartesian3.normalize(left, angleBetweenScratch); Cartesian3.normalize(right, angleBetweenScratch2); var cosine = Cartesian3.dot(angleBetweenScratch, angleBetweenScratch2); @@ -660,9 +716,11 @@ define([ * @exception {DeveloperError} cartesian is required. */ Cartesian3.mostOrthogonalAxis = function(cartesian, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(cartesian)) { throw new DeveloperError('cartesian is required.'); } + //>>includeEnd('debug'); var f = Cartesian3.normalize(cartesian, mostOrthogonalAxisScratch); Cartesian3.abs(f, f); @@ -716,9 +774,12 @@ define([ * @exception {DeveloperError} epsilon is required and must be a number. */ Cartesian3.equalsEpsilon = function(left, right, epsilon) { + //>>includeStart('debug', pragmas.debug); if (typeof epsilon !== 'number') { throw new DeveloperError('epsilon is required and must be a number.'); } + //>>includeEnd('debug'); + return (left === right) || ((defined(left)) && (defined(right)) && @@ -740,12 +801,14 @@ define([ * @exception {DeveloperError} right is required. */ Cartesian3.cross = function(left, right, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(left)) { throw new DeveloperError('left is required'); } if (!defined(right)) { throw new DeveloperError('right is required'); } + //>>includeEnd('debug'); var leftX = left.x; var leftY = left.y; diff --git a/Source/Core/Cartesian4.js b/Source/Core/Cartesian4.js index 30591bd287e8..87d750d21b71 100644 --- a/Source/Core/Cartesian4.js +++ b/Source/Core/Cartesian4.js @@ -121,6 +121,7 @@ define([ * @exception {DeveloperError} array is required. */ Cartesian4.pack = function(value, array, startingIndex) { + //>>includeStart('debug', pragmas.debug); if (!defined(value)) { throw new DeveloperError('value is required'); } @@ -128,6 +129,7 @@ define([ if (!defined(array)) { throw new DeveloperError('array is required'); } + //>>includeEnd('debug'); startingIndex = defaultValue(startingIndex, 0); @@ -148,9 +150,11 @@ define([ * @exception {DeveloperError} array is required. */ Cartesian4.unpack = function(array, startingIndex, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(array)) { throw new DeveloperError('array is required'); } + //>>includeEnd('debug'); startingIndex = defaultValue(startingIndex, 0); @@ -199,9 +203,12 @@ define([ * @exception {DeveloperError} cartesian is required. */ Cartesian4.getMaximumComponent = function(cartesian) { + //>>includeStart('debug', pragmas.debug); if (!defined(cartesian)) { throw new DeveloperError('cartesian is required'); } + //>>includeEnd('debug'); + return Math.max(cartesian.x, cartesian.y, cartesian.z, cartesian.w); }; @@ -215,9 +222,12 @@ define([ * @exception {DeveloperError} cartesian is required. */ Cartesian4.getMinimumComponent = function(cartesian) { + //>>includeStart('debug', pragmas.debug); if (!defined(cartesian)) { throw new DeveloperError('cartesian is required'); } + //>>includeEnd('debug'); + return Math.min(cartesian.x, cartesian.y, cartesian.z, cartesian.w); }; @@ -230,16 +240,19 @@ define([ * @param {Cartesian4} [result] The object into which to store the result. * @returns {Cartesian4} A cartesian with the minimum components. * - * @exception {DeveloperError} first cartesian is missing. - * @exception {DeveloperError} second cartesian is missing. + * @exception {DeveloperError} first is required. + * @exception {DeveloperError} second is required. */ Cartesian4.getMinimumByComponent = function(first, second, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(first)) { - throw new DeveloperError('first cartesian is missing'); + throw new DeveloperError('first is required.'); } if (!defined(second)) { - throw new DeveloperError('second cartesian is missing'); + throw new DeveloperError('second is required.'); } + //>>includeEnd('debug'); + if (!defined(result)) { result = new Cartesian4(); } @@ -261,16 +274,18 @@ define([ * @param {Cartesian4} [result] The object into which to store the result. * @returns {Cartesian4} A cartesian with the maximum components. * - * @exception {DeveloperError} first cartesian is missing. - * @exception {DeveloperError} second cartesian is missing. + * @exception {DeveloperError} first is required. + * @exception {DeveloperError} second is required. */ Cartesian4.getMaximumByComponent = function(first, second, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(first)) { - throw new DeveloperError('first cartesian is missing'); + throw new DeveloperError('first is required.'); } if (!defined(second)) { - throw new DeveloperError('second cartesian is missing'); + throw new DeveloperError('second is required.'); } + //>>includeEnd('debug'); if (!defined(result)) { result = new Cartesian4(); @@ -294,9 +309,12 @@ define([ * @exception {DeveloperError} cartesian is required. */ Cartesian4.magnitudeSquared = function(cartesian) { + //>>includeStart('debug', pragmas.debug); if (!defined(cartesian)) { throw new DeveloperError('cartesian is required'); } + //>>includeEnd('debug'); + return cartesian.x * cartesian.x + cartesian.y * cartesian.y + cartesian.z * cartesian.z + cartesian.w * cartesian.w; }; @@ -331,9 +349,11 @@ define([ * var d = Cartesian4.distance(new Cartesian4(1.0, 0.0, 0.0, 0.0), new Cartesian4(2.0, 0.0, 0.0, 0.0)); */ Cartesian4.distance = function(left, right) { + //>>includeStart('debug', pragmas.debug); if (!defined(left) || !defined(right)) { throw new DeveloperError('left and right are required.'); } + //>>includeEnd('debug'); Cartesian4.subtract(left, right, distanceScratch); return Cartesian4.magnitude(distanceScratch); @@ -350,9 +370,12 @@ define([ * @exception {DeveloperError} cartesian is required. */ Cartesian4.normalize = function(cartesian, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(cartesian)) { throw new DeveloperError('cartesian is required'); } + //>>includeEnd('debug'); + var magnitude = Cartesian4.magnitude(cartesian); if (!defined(result)) { return new Cartesian4(cartesian.x / magnitude, cartesian.y / magnitude, cartesian.z / magnitude, cartesian.w / magnitude); @@ -376,12 +399,15 @@ define([ * @exception {DeveloperError} right is required. */ Cartesian4.dot = function(left, right) { + //>>includeStart('debug', pragmas.debug); if (!defined(left)) { throw new DeveloperError('left is required'); } if (!defined(right)) { throw new DeveloperError('right is required'); } + //>>includeEnd('debug'); + return left.x * right.x + left.y * right.y + left.z * right.z + left.w * right.w; }; @@ -398,12 +424,15 @@ define([ * @exception {DeveloperError} right is required. */ Cartesian4.multiplyComponents = function(left, right, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(left)) { throw new DeveloperError('left is required'); } if (!defined(right)) { throw new DeveloperError('right is required'); } + //>>includeEnd('debug'); + if (!defined(result)) { return new Cartesian4(left.x * right.x, left.y * right.y, left.z * right.z, left.w * right.w); } @@ -427,12 +456,15 @@ define([ * @exception {DeveloperError} right is required. */ Cartesian4.add = function(left, right, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(left)) { throw new DeveloperError('left is required'); } if (!defined(right)) { throw new DeveloperError('right is required'); } + //>>includeEnd('debug'); + if (!defined(result)) { return new Cartesian4(left.x + right.x, left.y + right.y, left.z + right.z, left.w + right.w); } @@ -456,12 +488,15 @@ define([ * @exception {DeveloperError} right is required. */ Cartesian4.subtract = function(left, right, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(left)) { throw new DeveloperError('left is required'); } if (!defined(right)) { throw new DeveloperError('right is required'); } + //>>includeEnd('debug'); + if (!defined(result)) { return new Cartesian4(left.x - right.x, left.y - right.y, left.z - right.z, left.w - right.w); } @@ -485,12 +520,15 @@ define([ * @exception {DeveloperError} scalar is required and must be a number. */ Cartesian4.multiplyByScalar = function(cartesian, scalar, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(cartesian)) { throw new DeveloperError('cartesian is required'); } if (typeof scalar !== 'number') { throw new DeveloperError('scalar is required and must be a number.'); } + //>>includeEnd('debug'); + if (!defined(result)) { return new Cartesian4(cartesian.x * scalar, cartesian.y * scalar, cartesian.z * scalar, cartesian.w * scalar); } @@ -514,12 +552,15 @@ define([ * @exception {DeveloperError} scalar is required and must be a number. */ Cartesian4.divideByScalar = function(cartesian, scalar, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(cartesian)) { throw new DeveloperError('cartesian is required'); } if (typeof scalar !== 'number') { throw new DeveloperError('scalar is required and must be a number.'); } + //>>includeEnd('debug'); + if (!defined(result)) { return new Cartesian4(cartesian.x / scalar, cartesian.y / scalar, cartesian.z / scalar, cartesian.w / scalar); } @@ -541,9 +582,12 @@ define([ * @exception {DeveloperError} cartesian is required. */ Cartesian4.negate = function(cartesian, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(cartesian)) { throw new DeveloperError('cartesian is required'); } + //>>includeEnd('debug'); + if (!defined(result)) { return new Cartesian4(-cartesian.x, -cartesian.y, -cartesian.z, -cartesian.w); } @@ -565,9 +609,12 @@ define([ * @exception {DeveloperError} cartesian is required. */ Cartesian4.abs = function(cartesian, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(cartesian)) { throw new DeveloperError('cartesian is required'); } + //>>includeEnd('debug'); + if (!defined(result)) { return new Cartesian4(Math.abs(cartesian.x), Math.abs(cartesian.y), Math.abs(cartesian.z), Math.abs(cartesian.w)); } @@ -594,6 +641,7 @@ define([ * @exception {DeveloperError} t is required and must be a number. */ Cartesian4.lerp = function(start, end, t, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(start)) { throw new DeveloperError('start is required.'); } @@ -603,6 +651,8 @@ define([ if (typeof t !== 'number') { throw new DeveloperError('t is required and must be a number.'); } + //>>includeEnd('debug'); + Cartesian4.multiplyByScalar(end, t, lerpScratch); result = Cartesian4.multiplyByScalar(start, 1.0 - t, result); return Cartesian4.add(lerpScratch, result, result); @@ -620,9 +670,11 @@ define([ * @exception {DeveloperError} cartesian is required. */ Cartesian4.mostOrthogonalAxis = function(cartesian, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(cartesian)) { throw new DeveloperError('cartesian is required.'); } + //>>includeEnd('debug'); var f = Cartesian4.normalize(cartesian, mostOrthogonalAxisScratch); Cartesian4.abs(f, f); @@ -687,9 +739,12 @@ define([ * @exception {DeveloperError} epsilon is required and must be a number. */ Cartesian4.equalsEpsilon = function(left, right, epsilon) { + //>>includeStart('debug', pragmas.debug); if (typeof epsilon !== 'number') { throw new DeveloperError('epsilon is required and must be a number.'); } + //>>includeEnd('debug'); + return (left === right) || ((defined(left)) && (defined(right)) && diff --git a/Source/Core/Math.js b/Source/Core/Math.js index 4248a829716a..df8b784e7c87 100644 --- a/Source/Core/Math.js +++ b/Source/Core/Math.js @@ -486,9 +486,11 @@ define([ * @exception {DeveloperError} A number greater than or equal to 0 is required. */ CesiumMath.factorial = function(n) { + //>>includeStart('debug', pragmas.debug); if (typeof n !== 'number' || n < 0) { throw new DeveloperError('A number greater than or equal to 0 is required.'); } + //>>includeEnd('debug'); var length = factorials.length; if (n >= length) { @@ -520,9 +522,11 @@ define([ CesiumMath.incrementWrap = function(n, maximumValue, minimumValue) { minimumValue = defaultValue(minimumValue, 0.0); + //>>includeStart('debug', pragmas.debug); if (maximumValue <= minimumValue) { throw new DeveloperError('Maximum value must be greater than minimum value.'); } + //>>includeEnd('debug'); ++n; if (n > maximumValue) { @@ -547,9 +551,11 @@ define([ * var f = CesiumMath.isPowerOfTwo(20); // false */ CesiumMath.isPowerOfTwo = function(n) { + //>>includeStart('debug', pragmas.debug); if (typeof n !== 'number' || n < 0) { throw new DeveloperError('A number greater than or equal to 0 is required.'); } + //>>includeEnd('debug'); return (n !== 0) && ((n & (n - 1)) === 0); }; @@ -570,9 +576,11 @@ define([ * var m = CesiumMath.nextPowerOfTwo(32); // 32 */ CesiumMath.nextPowerOfTwo = function(n) { + //>>includeStart('debug', pragmas.debug); if (typeof n !== 'number' || n < 0) { throw new DeveloperError('A number greater than or equal to 0 is required.'); } + //>>includeEnd('debug'); // From http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2 --n; @@ -613,9 +621,12 @@ define([ * @exception {DeveloperError} seed is required. */ CesiumMath.setRandomNumberSeed = function(seed) { + //>>includeStart('debug', pragmas.debug); if (!defined(seed)) { throw new DeveloperError('seed is required.'); } + //>>includeEnd('debug'); + randomNumberGenerator = new MersenneTwister(seed); }; diff --git a/Source/Core/Matrix2.js b/Source/Core/Matrix2.js index dedcfb4b5433..87e4e13aa19c 100644 --- a/Source/Core/Matrix2.js +++ b/Source/Core/Matrix2.js @@ -73,9 +73,12 @@ define([ * @exception {DeveloperError} values is required. */ Matrix2.fromColumnMajorArray = function(values, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(values)) { throw new DeveloperError('values parameter is required'); } + //>>includeEnd('debug'); + return Matrix2.clone(values, result); }; @@ -91,9 +94,12 @@ define([ * @exception {DeveloperError} values is required. */ Matrix2.fromRowMajorArray = function(values, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(values)) { throw new DeveloperError('values is required.'); } + //>>includeEnd('debug'); + if (!defined(result)) { return new Matrix2(values[0], values[1], values[2], values[3]); @@ -122,9 +128,12 @@ define([ * var m = Matrix2.fromScale(new Cartesian2(7.0, 8.0)); */ Matrix2.fromScale = function(scale, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(scale)) { throw new DeveloperError('scale is required.'); } + //>>includeEnd('debug'); + if (!defined(result)) { return new Matrix2( scale.x, 0.0, @@ -155,9 +164,12 @@ define([ * var m = Matrix2.fromUniformScale(2.0); */ Matrix2.fromUniformScale = function(scale, result) { + //>>includeStart('debug', pragmas.debug); if (typeof scale !== 'number') { throw new DeveloperError('scale is required.'); } + //>>includeEnd('debug'); + if (!defined(result)) { return new Matrix2( scale, 0.0, @@ -188,9 +200,11 @@ define([ * var rotated = Matrix2.multiplyByVector(m, p); */ Matrix2.fromRotation = function(angle, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(angle)) { throw new DeveloperError('angle is required.'); } + //>>includeEnd('debug'); var cosAngle = Math.cos(angle); var sinAngle = Math.sin(angle); @@ -219,9 +233,12 @@ define([ * @exception {DeveloperError} matrix is required. */ Matrix2.toArray = function(matrix, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(matrix)) { throw new DeveloperError('matrix is required'); } + //>>includeEnd('debug'); + if (!defined(result)) { return [matrix[0], matrix[1], matrix[2], matrix[3]]; } @@ -250,12 +267,15 @@ define([ * myMatrix[column1Row0Index] = 10.0; */ Matrix2.getElementIndex = function(column, row) { + //>>includeStart('debug', pragmas.debug); if (typeof row !== 'number' || row < 0 || row > 1) { throw new DeveloperError('row is required and must be 0 or 1.'); } if (typeof column !== 'number' || column < 0 || column > 1) { throw new DeveloperError('column is required and must be 0 or 1.'); } + //>>includeEnd('debug'); + return column * 2 + row; }; @@ -274,6 +294,7 @@ define([ * @see Cartesian2 */ Matrix2.getColumn = function(matrix, index, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(matrix)) { throw new DeveloperError('matrix is required.'); } @@ -281,6 +302,7 @@ define([ if (typeof index !== 'number' || index < 0 || index > 1) { throw new DeveloperError('index is required and must be 0 or 1.'); } + //>>includeEnd('debug'); var startIndex = index * 2; var x = matrix[startIndex]; @@ -311,6 +333,7 @@ define([ * @see Cartesian2 */ Matrix2.setColumn = function(matrix, index, cartesian, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(matrix)) { throw new DeveloperError('matrix is required'); } @@ -320,6 +343,8 @@ define([ if (typeof index !== 'number' || index < 0 || index > 1) { throw new DeveloperError('index is required and must be 0 or 1.'); } + //>>includeEnd('debug'); + result = Matrix2.clone(matrix, result); var startIndex = index * 2; result[startIndex] = cartesian.x; @@ -342,6 +367,7 @@ define([ * @see Cartesian2 */ Matrix2.getRow = function(matrix, index, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(matrix)) { throw new DeveloperError('matrix is required.'); } @@ -349,6 +375,7 @@ define([ if (typeof index !== 'number' || index < 0 || index > 1) { throw new DeveloperError('index is required and must be 0 or 1.'); } + //>>includeEnd('debug'); var x = matrix[index]; var y = matrix[index + 2]; @@ -378,6 +405,7 @@ define([ * @see Cartesian2 */ Matrix2.setRow = function(matrix, index, cartesian, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(matrix)) { throw new DeveloperError('matrix is required'); } @@ -387,6 +415,7 @@ define([ if (typeof index !== 'number' || index < 0 || index > 1) { throw new DeveloperError('index is required and must be 0 or 1.'); } + //>>includeEnd('debug'); result = Matrix2.clone(matrix, result); result[index] = cartesian.x; @@ -407,12 +436,14 @@ define([ * @exception {DeveloperError} right is required. */ Matrix2.multiply = function(left, right, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(left)) { throw new DeveloperError('left is required'); } if (!defined(right)) { throw new DeveloperError('right is required'); } + //>>includeEnd('debug'); var column0Row0 = left[0] * right[0] + left[2] * right[1]; var column1Row0 = left[0] * right[2] + left[2] * right[3]; @@ -443,12 +474,14 @@ define([ * @exception {DeveloperError} cartesian is required. */ Matrix2.multiplyByVector = function(matrix, cartesian, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(matrix)) { throw new DeveloperError('matrix is required'); } if (!defined(cartesian)) { throw new DeveloperError('cartesian is required'); } + //>>includeEnd('debug'); var x = matrix[0] * cartesian.x + matrix[2] * cartesian.y; var y = matrix[1] * cartesian.x + matrix[3] * cartesian.y; @@ -474,12 +507,14 @@ define([ * @exception {DeveloperError} scalar is required and must be a number. */ Matrix2.multiplyByScalar = function(matrix, scalar, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(matrix)) { throw new DeveloperError('matrix is required'); } if (typeof scalar !== 'number') { throw new DeveloperError('scalar is required and must be a number'); } + //>>includeEnd('debug'); if (!defined(result)) { return new Matrix2(matrix[0] * scalar, matrix[2] * scalar, @@ -503,9 +538,11 @@ define([ * @exception {DeveloperError} matrix is required. */ Matrix2.negate = function(matrix, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(matrix)) { throw new DeveloperError('matrix is required'); } + //>>includeEnd('debug'); if (!defined(result)) { return new Matrix2(-matrix[0], -matrix[2], @@ -529,9 +566,11 @@ define([ * @exception {DeveloperError} matrix is required. */ Matrix2.transpose = function(matrix, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(matrix)) { throw new DeveloperError('matrix is required'); } + //>>includeEnd('debug'); var column0Row0 = matrix[0]; var column0Row1 = matrix[2]; @@ -560,9 +599,12 @@ define([ * @exception {DeveloperError} matrix is required. */ Matrix2.abs = function(matrix, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(matrix)) { throw new DeveloperError('matrix is required'); } + //>>includeEnd('debug'); + if (!defined(result)) { return new Matrix2(Math.abs(matrix[0]), Math.abs(matrix[2]), Math.abs(matrix[1]), Math.abs(matrix[3])); @@ -608,9 +650,11 @@ define([ * @exception {DeveloperError} epsilon is required and must be a number. */ Matrix2.equalsEpsilon = function(left, right, epsilon) { + //>>includeStart('debug', pragmas.debug); if (typeof epsilon !== 'number') { throw new DeveloperError('epsilon is required and must be a number'); } + //>>includeEnd('debug'); return (left === right) || (defined(left) && diff --git a/Source/Core/Matrix3.js b/Source/Core/Matrix3.js index 10a9c09be85f..ce1859e26e70 100644 --- a/Source/Core/Matrix3.js +++ b/Source/Core/Matrix3.js @@ -94,9 +94,12 @@ define([ * @exception {DeveloperError} values is required. */ Matrix3.fromColumnMajorArray = function(values, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(values)) { throw new DeveloperError('values parameter is required'); } + //>>includeEnd('debug'); + return Matrix3.clone(values, result); }; @@ -112,9 +115,12 @@ define([ * @exception {DeveloperError} values is required. */ Matrix3.fromRowMajorArray = function(values, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(values)) { throw new DeveloperError('values is required.'); } + //>>includeEnd('debug'); + if (!defined(result)) { return new Matrix3(values[0], values[1], values[2], values[3], values[4], values[5], @@ -141,9 +147,12 @@ define([ * @returns {Matrix3} The 3x3 rotation matrix from this quaternion. */ Matrix3.fromQuaternion = function(quaternion, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(quaternion)) { throw new DeveloperError('quaternion is required'); } + //>>includeEnd('debug'); + var x2 = quaternion.x * quaternion.x; var xy = quaternion.x * quaternion.y; var xz = quaternion.x * quaternion.z; @@ -202,9 +211,12 @@ define([ * var m = Matrix3.fromScale(new Cartesian3(7.0, 8.0, 9.0)); */ Matrix3.fromScale = function(scale, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(scale)) { throw new DeveloperError('scale is required.'); } + //>>includeEnd('debug'); + if (!defined(result)) { return new Matrix3( scale.x, 0.0, 0.0, @@ -242,9 +254,12 @@ define([ * var m = Matrix3.fromUniformScale(2.0); */ Matrix3.fromUniformScale = function(scale, result) { + //>>includeStart('debug', pragmas.debug); if (typeof scale !== 'number') { throw new DeveloperError('scale is required.'); } + //>>includeEnd('debug'); + if (!defined(result)) { return new Matrix3( scale, 0.0, 0.0, @@ -281,9 +296,11 @@ define([ * var rotated = Matrix3.multiplyByVector(m, p); */ Matrix3.fromRotationX = function(angle, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(angle)) { throw new DeveloperError('angle is required.'); } + //>>includeEnd('debug'); var cosAngle = Math.cos(angle); var sinAngle = Math.sin(angle); @@ -325,9 +342,11 @@ define([ * var rotated = Matrix3.multiplyByVector(m, p); */ Matrix3.fromRotationY = function(angle, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(angle)) { throw new DeveloperError('angle is required.'); } + //>>includeEnd('debug'); var cosAngle = Math.cos(angle); var sinAngle = Math.sin(angle); @@ -369,9 +388,11 @@ define([ * var rotated = Matrix3.multiplyByVector(m, p); */ Matrix3.fromRotationZ = function(angle, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(angle)) { throw new DeveloperError('angle is required.'); } + //>>includeEnd('debug'); var cosAngle = Math.cos(angle); var sinAngle = Math.sin(angle); @@ -408,9 +429,12 @@ define([ * @exception {DeveloperError} matrix is required. */ Matrix3.toArray = function(matrix, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(matrix)) { throw new DeveloperError('matrix is required'); } + //>>includeEnd('debug'); + if (!defined(result)) { return [matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5], matrix[6], matrix[7], matrix[8]]; } @@ -444,12 +468,15 @@ define([ * myMatrix[column1Row0Index] = 10.0; */ Matrix3.getElementIndex = function(column, row) { + //>>includeStart('debug', pragmas.debug); if (typeof row !== 'number' || row < 0 || row > 2) { throw new DeveloperError('row is required and must be 0, 1, or 2.'); } if (typeof column !== 'number' || column < 0 || column > 2) { throw new DeveloperError('column is required and must be 0, 1, or 2.'); } + //>>includeEnd('debug'); + return column * 3 + row; }; @@ -468,6 +495,7 @@ define([ * @see Cartesian3 */ Matrix3.getColumn = function(matrix, index, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(matrix)) { throw new DeveloperError('matrix is required.'); } @@ -475,6 +503,7 @@ define([ if (typeof index !== 'number' || index < 0 || index > 2) { throw new DeveloperError('index is required and must be 0, 1, or 2.'); } + //>>includeEnd('debug'); var startIndex = index * 3; var x = matrix[startIndex]; @@ -507,6 +536,7 @@ define([ * @see Cartesian3 */ Matrix3.setColumn = function(matrix, index, cartesian, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(matrix)) { throw new DeveloperError('matrix is required'); } @@ -516,6 +546,8 @@ define([ if (typeof index !== 'number' || index < 0 || index > 2) { throw new DeveloperError('index is required and must be 0, 1, or 2.'); } + //>>includeEnd('debug'); + result = Matrix3.clone(matrix, result); var startIndex = index * 3; result[startIndex] = cartesian.x; @@ -539,6 +571,7 @@ define([ * @see Cartesian3 */ Matrix3.getRow = function(matrix, index, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(matrix)) { throw new DeveloperError('matrix is required.'); } @@ -546,6 +579,7 @@ define([ if (typeof index !== 'number' || index < 0 || index > 2) { throw new DeveloperError('index is required and must be 0, 1, or 2.'); } + //>>includeEnd('debug'); var x = matrix[index]; var y = matrix[index + 3]; @@ -577,6 +611,7 @@ define([ * @see Cartesian3 */ Matrix3.setRow = function(matrix, index, cartesian, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(matrix)) { throw new DeveloperError('matrix is required'); } @@ -586,6 +621,7 @@ define([ if (typeof index !== 'number' || index < 0 || index > 2) { throw new DeveloperError('index is required and must be 0, 1, or 2.'); } + //>>includeEnd('debug'); result = Matrix3.clone(matrix, result); result[index] = cartesian.x; @@ -607,12 +643,14 @@ define([ * @exception {DeveloperError} right is required. */ Matrix3.multiply = function(left, right, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(left)) { throw new DeveloperError('left is required'); } if (!defined(right)) { throw new DeveloperError('right is required'); } + //>>includeEnd('debug'); var column0Row0 = left[0] * right[0] + left[3] * right[1] + left[6] * right[2]; var column0Row1 = left[1] * right[0] + left[4] * right[1] + left[7] * right[2]; @@ -656,12 +694,14 @@ define([ * @exception {DeveloperError} cartesian is required. */ Matrix3.multiplyByVector = function(matrix, cartesian, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(matrix)) { throw new DeveloperError('matrix is required'); } if (!defined(cartesian)) { throw new DeveloperError('cartesian is required'); } + //>>includeEnd('debug'); var vX = cartesian.x; var vY = cartesian.y; @@ -693,12 +733,14 @@ define([ * @exception {DeveloperError} scalar is required and must be a number. */ Matrix3.multiplyByScalar = function(matrix, scalar, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(matrix)) { throw new DeveloperError('matrix is required'); } if (typeof scalar !== 'number') { throw new DeveloperError('scalar is required and must be a number'); } + //>>includeEnd('debug'); if (!defined(result)) { return new Matrix3(matrix[0] * scalar, matrix[3] * scalar, matrix[6] * scalar, @@ -728,9 +770,11 @@ define([ * @exception {DeveloperError} matrix is required. */ Matrix3.negate = function(matrix, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(matrix)) { throw new DeveloperError('matrix is required'); } + //>>includeEnd('debug'); if (!defined(result)) { return new Matrix3(-matrix[0], -matrix[3], -matrix[6], @@ -760,9 +804,11 @@ define([ * @exception {DeveloperError} matrix is required. */ Matrix3.transpose = function(matrix, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(matrix)) { throw new DeveloperError('matrix is required'); } + //>>includeEnd('debug'); var column0Row0 = matrix[0]; var column0Row1 = matrix[3]; @@ -908,9 +954,11 @@ define([ * var c = Cartesian3.multiplyByScalar(v, lambda); // equal to Matrix3.multiplyByVector(a, v) */ Matrix3.getEigenDecomposition = function(matrix, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(matrix)) { throw new DeveloperError('matrix is required.'); } + //>>includeEnd('debug'); // This routine was created based upon Matrix Computations, 3rd ed., by Golub and Van Loan, // section 8.4.3 The Classical Jacobi Algorithm @@ -957,9 +1005,12 @@ define([ * @exception {DeveloperError} matrix is required. */ Matrix3.abs = function(matrix, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(matrix)) { throw new DeveloperError('matrix is required'); } + //>>includeEnd('debug'); + if (!defined(result)) { return new Matrix3(Math.abs(matrix[0]), Math.abs(matrix[3]), Math.abs(matrix[6]), Math.abs(matrix[1]), Math.abs(matrix[4]), Math.abs(matrix[7]), @@ -1082,9 +1133,11 @@ define([ * @exception {DeveloperError} epsilon is required and must be a number. */ Matrix3.equalsEpsilon = function(left, right, epsilon) { + //>>includeStart('debug', pragmas.debug); if (typeof epsilon !== 'number') { throw new DeveloperError('epsilon is required and must be a number'); } + //>>includeEnd('debug'); return (left === right) || (defined(left) && diff --git a/Source/Core/Matrix4.js b/Source/Core/Matrix4.js index dc48263bd954..bb5fac46ad65 100644 --- a/Source/Core/Matrix4.js +++ b/Source/Core/Matrix4.js @@ -131,9 +131,12 @@ define([ * @exception {DeveloperError} values is required. */ Matrix4.fromColumnMajorArray = function(values, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(values)) { throw new DeveloperError('values parameter is required'); } + //>>includeEnd('debug'); + return Matrix4.clone(values, result); }; @@ -149,9 +152,12 @@ define([ * @exception {DeveloperError} values is required. */ Matrix4.fromRowMajorArray = function(values, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(values)) { throw new DeveloperError('values is required.'); } + //>>includeEnd('debug'); + if (!defined(result)) { return new Matrix4(values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7], @@ -191,12 +197,15 @@ define([ * @exception {DeveloperError} translation is required. */ Matrix4.fromRotationTranslation = function(rotation, translation, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(rotation)) { throw new DeveloperError('rotation is required.'); } if (!defined(translation)) { throw new DeveloperError('translation is required.'); } + //>>includeEnd('debug'); + if (!defined(result)) { return new Matrix4(rotation[0], rotation[3], rotation[6], translation.x, rotation[1], rotation[4], rotation[7], translation.y, @@ -249,6 +258,7 @@ define([ * result); */ Matrix4.fromTranslationQuaternionRotationScale = function(translation, rotation, scale, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(translation)) { throw new DeveloperError('translation is required.'); } @@ -258,6 +268,7 @@ define([ if (!defined(scale)) { throw new DeveloperError('scale is required.'); } + //>>includeEnd('debug'); if (!defined(result)) { result = new Matrix4(); @@ -345,9 +356,12 @@ define([ * var m = Matrix4.fromScale(new Cartesian3(7.0, 8.0, 9.0)); */ Matrix4.fromScale = function(scale, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(scale)) { throw new DeveloperError('scale is required.'); } + //>>includeEnd('debug'); + if (!defined(result)) { return new Matrix4( scale.x, 0.0, 0.0, 0.0, @@ -394,9 +408,12 @@ define([ * var m = Matrix4.fromScale(2.0); */ Matrix4.fromUniformScale = function(scale, result) { + //>>includeStart('debug', pragmas.debug); if (typeof scale !== 'number') { throw new DeveloperError('scale is required.'); } + //>>includeEnd('debug'); + if (!defined(result)) { return new Matrix4(scale, 0.0, 0.0, 0.0, 0.0, scale, 0.0, 0.0, @@ -441,14 +458,17 @@ define([ * @exception {DeveloperError} camera.up is required. */ Matrix4.fromCamera = function(camera, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(camera)) { throw new DeveloperError('camera is required.'); } + //>>includeEnd('debug'); var eye = camera.eye; var target = camera.target; var up = camera.up; + //>>includeStart('debug', pragmas.debug); if (!defined(eye)) { throw new DeveloperError('camera.eye is required.'); } @@ -458,6 +478,7 @@ define([ if (!defined(up)) { throw new DeveloperError('camera.up is required.'); } + //>>includeEnd('debug'); Cartesian3.normalize(Cartesian3.subtract(target, eye, fromCameraF), fromCameraF); Cartesian3.normalize(Cartesian3.cross(fromCameraF, up, fromCameraS), fromCameraS); @@ -538,6 +559,7 @@ define([ * @exception {DeveloperError} far must be greater than zero. */ Matrix4.computePerspectiveFieldOfView = function(fovY, aspectRatio, near, far, result) { + //>>includeStart('debug', pragmas.debug); if (fovY <= 0.0 || fovY > Math.PI) { throw new DeveloperError('fovY must be in [0, PI).'); } @@ -553,6 +575,7 @@ define([ if (far <= 0.0) { throw new DeveloperError('far must be greater than zero.'); } + //>>includeEnd('debug'); var bottom = Math.tan(fovY * 0.5); @@ -608,6 +631,7 @@ define([ * @exception {DeveloperError} far is required. */ Matrix4.computeOrthographicOffCenter = function(left, right, bottom, top, near, far, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(left)) { throw new DeveloperError('left is required.'); } @@ -626,6 +650,7 @@ define([ if (!defined(far)) { throw new DeveloperError('far is required.'); } + //>>includeEnd('debug'); var a = 1.0 / (right - left); var b = 1.0 / (top - bottom); @@ -685,6 +710,7 @@ define([ * @exception {DeveloperError} far is required. */ Matrix4.computePerspectiveOffCenter = function(left, right, bottom, top, near, far, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(left)) { throw new DeveloperError('left is required.'); } @@ -703,6 +729,7 @@ define([ if (!defined(far)) { throw new DeveloperError('far is required.'); } + //>>includeEnd('debug'); var column0Row0 = 2.0 * near / (right - left); var column1Row1 = 2.0 * near / (top - bottom); @@ -758,6 +785,7 @@ define([ * @exception {DeveloperError} near is required. */ Matrix4.computeInfinitePerspectiveOffCenter = function(left, right, bottom, top, near, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(left)) { throw new DeveloperError('left is required.'); } @@ -773,6 +801,7 @@ define([ if (!defined(near)) { throw new DeveloperError('near is required.'); } + //>>includeEnd('debug'); var column0Row0 = 2.0 * near / (right - left); var column1Row1 = 2.0 * near / (top - bottom); @@ -903,9 +932,12 @@ define([ * */ Matrix4.toArray = function(matrix, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(matrix)) { throw new DeveloperError('matrix is required'); } + //>>includeEnd('debug'); + if (!defined(result)) { return [matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5], matrix[6], matrix[7], @@ -949,12 +981,15 @@ define([ * myMatrix[column1Row0Index] = 10.0; */ Matrix4.getElementIndex = function(column, row) { + //>>includeStart('debug', pragmas.debug); if (typeof row !== 'number' || row < 0 || row > 3) { throw new DeveloperError('row is required and must be 0, 1, 2, or 3.'); } if (typeof column !== 'number' || column < 0 || column > 3) { throw new DeveloperError('column is required and must be 0, 1, 2, or 3.'); } + //>>includeEnd('debug'); + return column * 4 + row; }; @@ -990,6 +1025,7 @@ define([ * */ Matrix4.getColumn = function(matrix, index, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(matrix)) { throw new DeveloperError('matrix is required.'); } @@ -997,6 +1033,7 @@ define([ if (typeof index !== 'number' || index < 0 || index > 3) { throw new DeveloperError('index is required and must be 0, 1, 2, or 3.'); } + //>>includeEnd('debug'); var startIndex = index * 4; var x = matrix[startIndex]; @@ -1047,6 +1084,7 @@ define([ * */ Matrix4.setColumn = function(matrix, index, cartesian, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(matrix)) { throw new DeveloperError('matrix is required'); } @@ -1056,6 +1094,8 @@ define([ if (typeof index !== 'number' || index < 0 || index > 3) { throw new DeveloperError('index is required and must be 0, 1, 2, or 3.'); } + //>>includeEnd('debug'); + result = Matrix4.clone(matrix, result); var startIndex = index * 4; result[startIndex] = cartesian.x; @@ -1096,6 +1136,7 @@ define([ * // a.x = 18.0; a.y = 19.0; a.z = 20.0; a.w = 21.0; */ Matrix4.getRow = function(matrix, index, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(matrix)) { throw new DeveloperError('matrix is required.'); } @@ -1103,6 +1144,7 @@ define([ if (typeof index !== 'number' || index < 0 || index > 3) { throw new DeveloperError('index is required and must be 0, 1, 2, or 3.'); } + //>>includeEnd('debug'); var x = matrix[index]; var y = matrix[index + 4]; @@ -1152,6 +1194,7 @@ define([ * */ Matrix4.setRow = function(matrix, index, cartesian, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(matrix)) { throw new DeveloperError('matrix is required'); } @@ -1161,6 +1204,7 @@ define([ if (typeof index !== 'number' || index < 0 || index > 3) { throw new DeveloperError('index is required and must be 0, 1, 2, or 3.'); } + //>>includeEnd('debug'); result = Matrix4.clone(matrix, result); result[index] = cartesian.x; @@ -1183,12 +1227,14 @@ define([ * @exception {DeveloperError} right is required. */ Matrix4.multiply = function(left, right, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(left)) { throw new DeveloperError('left is required'); } if (!defined(right)) { throw new DeveloperError('right is required'); } + //>>includeEnd('debug'); var left0 = left[0]; var left1 = left[1]; @@ -1292,12 +1338,14 @@ define([ * Matrix4.multiplyByTranslation(m, position, m); */ Matrix4.multiplyByTranslation = function(matrix, translation, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(matrix)) { throw new DeveloperError('matrix is required'); } if (!defined(translation)) { throw new DeveloperError('translation is required'); } + //>>includeEnd('debug'); var x = translation.x; var y = translation.y; @@ -1359,9 +1407,11 @@ define([ * Matrix4.multiplyByUniformScale(m, scale, m); */ Matrix4.multiplyByUniformScale = function(matrix, scale, result) { + //>>includeStart('debug', pragmas.debug); if (typeof scale !== 'number') { throw new DeveloperError('scale is required'); } + //>>includeEnd('debug'); uniformScaleScratch.x = scale; uniformScaleScratch.y = scale; @@ -1393,12 +1443,14 @@ define([ * Matrix4.multiplyByUniformScale(m, scale, m); */ Matrix4.multiplyByScale = function(matrix, scale, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(matrix)) { throw new DeveloperError('matrix is required'); } if (!defined(scale)) { throw new DeveloperError('scale is required'); } + //>>includeEnd('debug'); var scaleX = scale.x; var scaleY = scale.y; @@ -1449,12 +1501,14 @@ define([ * @exception {DeveloperError} cartesian is required. */ Matrix4.multiplyByVector = function(matrix, cartesian, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(matrix)) { throw new DeveloperError('matrix is required'); } if (!defined(cartesian)) { throw new DeveloperError('cartesian is required'); } + //>>includeEnd('debug'); var vX = cartesian.x; var vY = cartesian.y; @@ -1499,9 +1553,11 @@ define([ * // Matrix4.multiplyByVector(matrix, new Cartesian4(p.x, p.y, p.z, 1.0), result); */ Matrix4.multiplyByPoint = function(matrix, cartesian, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(cartesian)) { throw new DeveloperError('cartesian is required'); } + //>>includeEnd('debug'); scratchPoint.x = cartesian.x; scratchPoint.y = cartesian.y; @@ -1540,12 +1596,14 @@ define([ * */ Matrix4.multiplyByScalar = function(matrix, scalar, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(matrix)) { throw new DeveloperError('matrix is required'); } if (typeof scalar !== 'number') { throw new DeveloperError('scalar is required and must be a number'); } + //>>includeEnd('debug'); if (!defined(result)) { return new Matrix4(matrix[0] * scalar, matrix[4] * scalar, matrix[8] * scalar, matrix[12] * scalar, @@ -1599,9 +1657,11 @@ define([ * */ Matrix4.negate = function(matrix, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(matrix)) { throw new DeveloperError('matrix is required'); } + //>>includeEnd('debug'); if (!defined(result)) { return new Matrix4(-matrix[0], -matrix[4], -matrix[8], -matrix[12], @@ -1655,9 +1715,12 @@ define([ * */ Matrix4.transpose = function(matrix, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(matrix)) { throw new DeveloperError('matrix is required'); } + //>>includeEnd('debug'); + if (!defined(result)) { return new Matrix4(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5], matrix[6], matrix[7], @@ -1702,9 +1765,12 @@ define([ * @exception {DeveloperError} matrix is required. */ Matrix4.abs = function(matrix, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(matrix)) { throw new DeveloperError('matrix is required'); } + //>>includeEnd('debug'); + if (!defined(result)) { return new Matrix4(Math.abs(matrix[0]), Math.abs(matrix[4]), Math.abs(matrix[8]), Math.abs(matrix[12]), Math.abs(matrix[1]), Math.abs(matrix[5]), Math.abs(matrix[9]), Math.abs(matrix[13]), @@ -1822,9 +1888,11 @@ define([ * */ Matrix4.equalsEpsilon = function(left, right, epsilon) { + //>>includeStart('debug', pragmas.debug); if (typeof epsilon !== 'number') { throw new DeveloperError('epsilon is required and must be a number'); } + //>>includeEnd('debug'); return (left === right) || (defined(left) && @@ -1860,9 +1928,12 @@ define([ * @see Cartesian3 */ Matrix4.getTranslation = function(matrix, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(matrix)) { throw new DeveloperError('matrix is required'); } + //>>includeEnd('debug'); + if (!defined(result)) { return new Cartesian3(matrix[12], matrix[13], matrix[14]); } @@ -1901,9 +1972,12 @@ define([ * */ Matrix4.getRotation = function(matrix, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(matrix)) { throw new DeveloperError('matrix is required'); } + //>>includeEnd('debug'); + if (!defined(result)) { return new Matrix3(matrix[0], matrix[4], matrix[8], matrix[1], matrix[5], matrix[9], @@ -1936,9 +2010,11 @@ define([ * @exception {RuntimeError} matrix is not invertible because its determinate is zero. */ Matrix4.inverse = function(matrix, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(matrix)) { throw new DeveloperError('matrix is required'); } + //>>includeEnd('debug'); // // Ported from: @@ -2061,9 +2137,11 @@ define([ * @exception {DeveloperError} matrix is required. */ Matrix4.inverseTransformation = function(matrix, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(matrix)) { throw new DeveloperError('matrix is required'); } + //>>includeEnd('debug'); //This function is an optimized version of the below 4 lines. //var rT = Matrix3.transpose(Matrix4.getRotation(matrix)); diff --git a/Source/Core/Quaternion.js b/Source/Core/Quaternion.js index 14fc25dda219..ca43ed1e7680 100644 --- a/Source/Core/Quaternion.js +++ b/Source/Core/Quaternion.js @@ -74,12 +74,14 @@ define([ * @exception {DeveloperError} angle is required and must be a number. */ Quaternion.fromAxisAngle = function(axis, angle, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(axis)) { throw new DeveloperError('axis is required.'); } if (typeof angle !== 'number') { throw new DeveloperError('angle is required and must be a number.'); } + //>>includeEnd('debug'); var halfAngle = angle / 2.0; var s = Math.sin(halfAngle); @@ -114,9 +116,11 @@ define([ * @see Matrix3.fromQuaternion */ Quaternion.fromRotationMatrix = function(matrix, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(matrix)) { throw new DeveloperError('matrix is required.'); } + //>>includeEnd('debug'); var root; var x; @@ -200,6 +204,7 @@ define([ * @exception {DeveloperError} array is required. */ Quaternion.pack = function(value, array, startingIndex) { + //>>includeStart('debug', pragmas.debug); if (!defined(value)) { throw new DeveloperError('value is required'); } @@ -207,6 +212,7 @@ define([ if (!defined(array)) { throw new DeveloperError('array is required'); } + //>>includeEnd('debug'); startingIndex = defaultValue(startingIndex, 0); @@ -227,9 +233,11 @@ define([ * @exception {DeveloperError} array is required. */ Quaternion.unpack = function(array, startingIndex, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(array)) { throw new DeveloperError('array is required'); } + //>>includeEnd('debug'); startingIndex = defaultValue(startingIndex, 0); @@ -348,9 +356,12 @@ define([ * @exception {DeveloperError} quaternion is required. */ Quaternion.conjugate = function(quaternion, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(quaternion)) { throw new DeveloperError('quaternion is required'); } + //>>includeEnd('debug'); + if (!defined(result)) { return new Quaternion(-quaternion.x, -quaternion.y, -quaternion.z, quaternion.w); } @@ -371,9 +382,12 @@ define([ * @exception {DeveloperError} quaternion is required. */ Quaternion.magnitudeSquared = function(quaternion) { + //>>includeStart('debug', pragmas.debug); if (!defined(quaternion)) { throw new DeveloperError('quaternion is required'); } + //>>includeEnd('debug'); + return quaternion.x * quaternion.x + quaternion.y * quaternion.y + quaternion.z * quaternion.z + quaternion.w * quaternion.w; }; @@ -387,9 +401,6 @@ define([ * @exception {DeveloperError} quaternion is required. */ Quaternion.magnitude = function(quaternion) { - if (!defined(quaternion)) { - throw new DeveloperError('quaternion is required'); - } return Math.sqrt(Quaternion.magnitudeSquared(quaternion)); }; @@ -449,12 +460,15 @@ define([ * @exception {DeveloperError} right is required. */ Quaternion.add = function(left, right, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(left)) { throw new DeveloperError('left is required'); } if (!defined(right)) { throw new DeveloperError('right is required'); } + //>>includeEnd('debug'); + if (!defined(result)) { return new Quaternion(left.x + right.x, left.y + right.y, left.z + right.z, left.w + right.w); } @@ -478,12 +492,15 @@ define([ * @exception {DeveloperError} right is required. */ Quaternion.subtract = function(left, right, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(left)) { throw new DeveloperError('left is required'); } if (!defined(right)) { throw new DeveloperError('right is required'); } + //>>includeEnd('debug'); + if (!defined(result)) { return new Quaternion(left.x - right.x, left.y - right.y, left.z - right.z, left.w - right.w); } @@ -505,9 +522,12 @@ define([ * @exception {DeveloperError} quaternion is required. */ Quaternion.negate = function(quaternion, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(quaternion)) { throw new DeveloperError('quaternion is required'); } + //>>includeEnd('debug'); + if (!defined(result)) { return new Quaternion(-quaternion.x, -quaternion.y, -quaternion.z, -quaternion.w); } @@ -530,12 +550,15 @@ define([ * @exception {DeveloperError} right is required. */ Quaternion.dot = function(left, right) { + //>>includeStart('debug', pragmas.debug); if (!defined(left)) { throw new DeveloperError('left is required'); } if (!defined(right)) { throw new DeveloperError('right is required'); } + //>>includeEnd('debug'); + return left.x * right.x + left.y * right.y + left.z * right.z + left.w * right.w; }; @@ -553,12 +576,15 @@ define([ * @exception {DeveloperError} right is required. */ Quaternion.multiply = function(left, right, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(left)) { throw new DeveloperError('left is required'); } if (!defined(right)) { throw new DeveloperError('right is required'); } + //>>includeEnd('debug'); + var leftX = left.x; var leftY = left.y; var leftZ = left.z; @@ -597,12 +623,15 @@ define([ * @exception {DeveloperError} scalar is required and must be a number. */ Quaternion.multiplyByScalar = function(quaternion, scalar, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(quaternion)) { throw new DeveloperError('quaternion is required'); } if (typeof scalar !== 'number') { throw new DeveloperError('scalar is required and must be a number.'); } + //>>includeEnd('debug'); + if (!defined(result)) { return new Quaternion(quaternion.x * scalar, quaternion.y * scalar, quaternion.z * scalar, quaternion.w * scalar); } @@ -626,12 +655,15 @@ define([ * @exception {DeveloperError} scalar is required and must be a number. */ Quaternion.divideByScalar = function(quaternion, scalar, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(quaternion)) { throw new DeveloperError('quaternion is required'); } if (typeof scalar !== 'number') { throw new DeveloperError('scalar is required and must be a number.'); } + //>>includeEnd('debug'); + if (!defined(result)) { return new Quaternion(quaternion.x / scalar, quaternion.y / scalar, quaternion.z / scalar, quaternion.w / scalar); } @@ -653,9 +685,11 @@ define([ * @exception {DeveloperError} quaternion is required. */ Quaternion.getAxis = function(quaternion, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(quaternion)) { throw new DeveloperError('quaternion is required'); } + //>>includeEnd('debug'); var w = quaternion.w; if (Math.abs(w - 1.0) < CesiumMath.EPSILON6) { @@ -686,9 +720,11 @@ define([ * @exception {DeveloperError} quaternion is required. */ Quaternion.getAngle = function(quaternion) { + //>>includeStart('debug', pragmas.debug); if (!defined(quaternion)) { throw new DeveloperError('quaternion is required'); } + //>>includeEnd('debug'); if (Math.abs(quaternion.w - 1.0) < CesiumMath.EPSILON6) { return 0.0; @@ -712,6 +748,7 @@ define([ * @exception {DeveloperError} t is required and must be a number. */ Quaternion.lerp = function(start, end, t, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(start)) { throw new DeveloperError('start is required.'); } @@ -721,6 +758,8 @@ define([ if (typeof t !== 'number') { throw new DeveloperError('t is required and must be a number.'); } + //>>includeEnd('debug'); + lerpScratch = Quaternion.multiplyByScalar(end, t, lerpScratch); result = Quaternion.multiplyByScalar(start, 1.0 - t, result); return Quaternion.add(lerpScratch, result, result); @@ -744,6 +783,7 @@ define([ * @exception {DeveloperError} t is required and must be a number. */ Quaternion.slerp = function(start, end, t, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(start)) { throw new DeveloperError('start is required.'); } @@ -753,6 +793,7 @@ define([ if (typeof t !== 'number') { throw new DeveloperError('t is required and must be a number.'); } + //>>includeEnd('debug'); var dot = Quaternion.dot(start, end); @@ -788,9 +829,11 @@ define([ * @exception {DeveloperError} quaternion is required. */ Quaternion.log = function(quaternion, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(quaternion)) { throw new DeveloperError('quaternion is required.'); } + //>>includeEnd('debug'); var theta = Math.acos(CesiumMath.clamp(quaternion.w, -1.0, 1.0)); var thetaOverSinTheta = 0.0; @@ -819,9 +862,11 @@ define([ * @exception {DeveloperError} cartesian is required. */ Quaternion.exp = function(cartesian, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(cartesian)) { throw new DeveloperError('cartesian is required.'); } + //>>includeEnd('debug'); var theta = Cartesian3.magnitude(cartesian); var sinThetaOverTheta = 0.0; @@ -863,9 +908,11 @@ define([ * @see Quaternion#squad */ Quaternion.innerQuadrangle = function(q0, q1, q2, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(q0) || !defined(q1) || !defined(q2)) { throw new DeveloperError('q0, q1, and q2 are required.'); } + //>>includeEnd('debug'); var qInv = Quaternion.conjugate(q1, squadScratchQuaternion0); Quaternion.multiply(qInv, q2, squadScratchQuaternion1); @@ -910,6 +957,7 @@ define([ * var q = Quaternion.squad(quaternions[0], quaternions[1], quaternions[0], s1, t); */ Quaternion.squad = function(q0, q1, s0, s1, t, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(q0) || !defined(q1) || !defined(s0) || !defined(s1)) { throw new DeveloperError('q0, q1, s0, and s1 are required.'); } @@ -917,6 +965,7 @@ define([ if (typeof t !== 'number') { throw new DeveloperError('t is required and must be a number.'); } + //>>includeEnd('debug'); var slerp0 = Quaternion.slerp(q0, q1, t, squadScratchQuaternion0); var slerp1 = Quaternion.slerp(s0, s1, t, squadScratchQuaternion1); @@ -956,9 +1005,12 @@ define([ * @exception {DeveloperError} epsilon is required and must be a number. */ Quaternion.equalsEpsilon = function(left, right, epsilon) { + //>>includeStart('debug', pragmas.debug); if (typeof epsilon !== 'number') { throw new DeveloperError('epsilon is required and must be a number.'); } + //>>includeEnd('debug'); + return (left === right) || ((defined(left)) && (defined(right)) && diff --git a/Source/Core/TaskProcessor.js b/Source/Core/TaskProcessor.js index 1aa92eaa60e9..99b0f50008e0 100644 --- a/Source/Core/TaskProcessor.js +++ b/Source/Core/TaskProcessor.js @@ -79,7 +79,9 @@ define([ workerModule : TaskProcessor._workerModulePrefix + processor._workerName }; - if (defined(require.toUrl)) { + if (defined(TaskProcessor._loaderConfig)) { + bootstrapMessage.loaderConfig = TaskProcessor._loaderConfig; + } else if (defined(require.toUrl)) { var baseUrl = new Uri('..').resolve(new Uri(buildModuleUrl('Workers/cesiumWorkerBootstrapper.js'))).toString(); bootstrapMessage.loaderConfig.baseUrl = baseUrl; } else { @@ -205,6 +207,7 @@ define([ // exposed for testing purposes TaskProcessor._defaultWorkerModulePrefix = 'Workers/'; TaskProcessor._workerModulePrefix = TaskProcessor._defaultWorkerModulePrefix; + TaskProcessor._loaderConfig = undefined; return TaskProcessor; }); diff --git a/Source/Core/Transforms.js b/Source/Core/Transforms.js index cd299d143398..dd067d92de86 100644 --- a/Source/Core/Transforms.js +++ b/Source/Core/Transforms.js @@ -72,9 +72,11 @@ define([ * var transform = Transforms.eastNorthUpToFixedFrame(center); */ Transforms.eastNorthUpToFixedFrame = function(origin, ellipsoid, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(origin)) { throw new DeveloperError('origin is required.'); } + //>>includeEnd('debug'); // If x and y are zero, assume origin is at a pole, which is a special case. if (CesiumMath.equalsEpsilon(origin.x, 0.0, CesiumMath.EPSILON14) && @@ -176,9 +178,11 @@ define([ * var transform = Transforms.northEastDownToFixedFrame(center); */ Transforms.northEastDownToFixedFrame = function(origin, ellipsoid, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(origin)) { throw new DeveloperError('origin is required.'); } + //>>includeEnd('debug'); if (CesiumMath.equalsEpsilon(origin.x, 0.0, CesiumMath.EPSILON14) && CesiumMath.equalsEpsilon(origin.y, 0.0, CesiumMath.EPSILON14)) { @@ -282,9 +286,11 @@ define([ * updateAndRender(); */ Transforms.computeTemeToPseudoFixedMatrix = function (date, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(date)) { throw new DeveloperError('date is required.'); } + //>>includeEnd('debug'); // GMST is actually computed using UT1. We're using UTC as an approximation of UT1. // We do not want to use the function like convertTaiToUtc in JulianDate because @@ -422,9 +428,11 @@ define([ * updateAndRender(); */ Transforms.computeIcrfToFixedMatrix = function(date, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(date)) { throw new DeveloperError('date is required.'); } + //>>includeEnd('debug'); var fixedToIcrfMtx = Transforms.computeFixedToIcrfMatrix(date, result); if (!defined(fixedToIcrfMtx)) { @@ -468,9 +476,11 @@ define([ * } */ Transforms.computeFixedToIcrfMatrix = function(date, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(date)) { throw new DeveloperError('date is required.'); } + //>>includeEnd('debug'); // Compute pole wander var eop = Transforms.earthOrientationParameters.compute(date, eopScratch); @@ -588,6 +598,7 @@ define([ * @see czm_viewportTransformation */ Transforms.pointToWindowCoordinates = function (modelViewProjectionMatrix, viewportTransformation, point, result) { + //>>includeStart('debug', pragmas.debug); if (!defined(modelViewProjectionMatrix)) { throw new DeveloperError('modelViewProjectionMatrix is required.'); } @@ -599,6 +610,7 @@ define([ if (!defined(point)) { throw new DeveloperError('point is required.'); } + //>>includeEnd('debug'); var tmp = pointToWindowCoordinatesTemp; diff --git a/Source/Renderer/Context.js b/Source/Renderer/Context.js index 3aa91d1b82a9..82e57fba9d28 100644 --- a/Source/Renderer/Context.js +++ b/Source/Renderer/Context.js @@ -196,9 +196,11 @@ define([ throw new RuntimeError('The browser does not support WebGL. Visit http://get.webgl.org.'); } + //>>includeStart('debug', pragmas.debug); if (!defined(canvas)) { throw new DeveloperError('canvas is required.'); } + //>>includeEnd('debug'); this._canvas = canvas; @@ -1130,9 +1132,12 @@ define([ } else if (typeof typedArrayOrSizeInBytes === 'object' && typeof typedArrayOrSizeInBytes.byteLength === 'number') { sizeInBytes = typedArrayOrSizeInBytes.byteLength; } else { + //>>includeStart('debug', pragmas.debug); throw new DeveloperError('typedArrayOrSizeInBytes must be either a typed array or a number.'); + //>>includeEnd('debug'); } + //>>includeStart('debug', pragmas.debug); if (sizeInBytes <= 0) { throw new DeveloperError('typedArrayOrSizeInBytes must be greater than zero.'); } @@ -1140,6 +1145,7 @@ define([ if (!BufferUsage.validate(usage)) { throw new DeveloperError('usage is invalid.'); } + //>>includeEnd('debug'); var buffer = gl.createBuffer(); gl.bindBuffer(bufferTarget, buffer); @@ -1228,9 +1234,11 @@ define([ * BufferUsage.STATIC_DRAW, IndexDatatype.UNSIGNED_SHORT) */ Context.prototype.createIndexBuffer = function(typedArrayOrSizeInBytes, usage, indexDatatype) { + //>>includeStart('debug', pragmas.debug); if (!IndexDatatype.validate(indexDatatype)) { throw new DeveloperError('Invalid indexDatatype.'); } + //>>includeEnd('debug'); if ((indexDatatype === IndexDatatype.UNSIGNED_INT) && !this.getElementIndexUint()) { throw new RuntimeError('IndexDatatype.UNSIGNED_INT requires OES_element_index_uint, which is not supported on this system.'); @@ -1358,7 +1366,6 @@ define([ * * @exception {RuntimeError} When options.pixelFormat is DEPTH_COMPONENT or DEPTH_STENCIL, this WebGL implementation must support WEBGL_depth_texture. * @exception {RuntimeError} When options.pixelDatatype is FLOAT, this WebGL implementation must support the OES_texture_float extension. - * @exception {DeveloperError} options is required. * @exception {DeveloperError} options requires a source field to create an initialized texture or width and height fields to create a blank texture. * @exception {DeveloperError} Width must be greater than zero. * @exception {DeveloperError} Width must be less than or equal to the maximum texture size. @@ -1375,14 +1382,15 @@ define([ * @see Context#createSampler */ Context.prototype.createTexture2D = function(options) { - if (!defined(options)) { - throw new DeveloperError('options is required.'); - } + options = defaultValue(options, defaultValue.EMPTY_OBJECT); var source = options.source; var width = defined(source) ? source.width : options.width; var height = defined(source) ? source.height : options.height; + var pixelFormat = defaultValue(options.pixelFormat, PixelFormat.RGBA); + var pixelDatatype = defaultValue(options.pixelDatatype, PixelDatatype.UNSIGNED_BYTE); + //>>includeStart('debug', pragmas.debug); if (!defined(width) || !defined(height)) { throw new DeveloperError('options requires a source field to create an initialized texture or width and height fields to create a blank texture.'); } @@ -1403,20 +1411,14 @@ define([ throw new DeveloperError('Height must be less than or equal to the maximum texture size (' + this._maximumTextureSize + '). Check getMaximumTextureSize().'); } - var pixelFormat = defaultValue(options.pixelFormat, PixelFormat.RGBA); if (!PixelFormat.validate(pixelFormat)) { throw new DeveloperError('Invalid options.pixelFormat.'); } - var pixelDatatype = defaultValue(options.pixelDatatype, PixelDatatype.UNSIGNED_BYTE); if (!PixelDatatype.validate(pixelDatatype)) { throw new DeveloperError('Invalid options.pixelDatatype.'); } - if ((pixelDatatype === PixelDatatype.FLOAT) && !this.getFloatingPointTexture()) { - throw new RuntimeError('When options.pixelDatatype is FLOAT, this WebGL implementation must support the OES_texture_float extension.'); - } - if ((pixelFormat === PixelFormat.DEPTH_COMPONENT) && ((pixelDatatype !== PixelDatatype.UNSIGNED_SHORT) && (pixelDatatype !== PixelDatatype.UNSIGNED_INT))) { throw new DeveloperError('When options.pixelFormat is DEPTH_COMPONENT, options.pixelDatatype must be UNSIGNED_SHORT or UNSIGNED_INT.'); @@ -1425,11 +1427,18 @@ define([ if ((pixelFormat === PixelFormat.DEPTH_STENCIL) && (pixelDatatype !== PixelDatatype.UNSIGNED_INT_24_8_WEBGL)) { throw new DeveloperError('When options.pixelFormat is DEPTH_STENCIL, options.pixelDatatype must be UNSIGNED_INT_24_8_WEBGL.'); } + //>>includeEnd('debug'); + + if ((pixelDatatype === PixelDatatype.FLOAT) && !this.getFloatingPointTexture()) { + throw new RuntimeError('When options.pixelDatatype is FLOAT, this WebGL implementation must support the OES_texture_float extension.'); + } if (PixelFormat.isDepthFormat(pixelFormat)) { + //>>includeStart('debug', pragmas.debug); if (defined(source)) { throw new DeveloperError('When options.pixelFormat is DEPTH_COMPONENT or DEPTH_STENCIL, source cannot be provided.'); } + //>>includeEnd('debug'); if (!this.getDepthTexture()) { throw new RuntimeError('When options.pixelFormat is DEPTH_COMPONENT or DEPTH_STENCIL, this WebGL implementation must support WEBGL_depth_texture. Check getDepthTexture().'); @@ -1506,6 +1515,7 @@ define([ width = defaultValue(width, gl.drawingBufferWidth); height = defaultValue(height, gl.drawingBufferHeight); + //>>includeStart('debug', pragmas.debug); if (!PixelFormat.validate(pixelFormat)) { throw new DeveloperError('Invalid pixelFormat.'); } @@ -1529,6 +1539,7 @@ define([ if (framebufferYOffset + height > gl.drawingBufferHeight) { throw new DeveloperError('framebufferYOffset + height must be less than or equal to drawingBufferHeight.'); } + //>>includeEnd('debug'); var textureTarget = gl.TEXTURE_2D; var texture = gl.createTexture(); @@ -1572,7 +1583,6 @@ define([ * @returns {CubeMap} DOC_TBA. * * @exception {RuntimeError} When options.pixelDatatype is FLOAT, this WebGL implementation must support the OES_texture_float extension. - * @exception {DeveloperError} options is required. * @exception {DeveloperError} options.source requires positiveX, negativeX, positiveY, negativeY, positiveZ, and negativeZ faces. * @exception {DeveloperError} Each face in options.sources must have the same width and height. * @exception {DeveloperError} options requires a source field to create an initialized cube map or width and height fields to create a blank cube map. @@ -1588,9 +1598,7 @@ define([ * @see Context#createSampler */ Context.prototype.createCubeMap = function(options) { - if (!defined(options)) { - throw new DeveloperError('options is required.'); - } + options = defaultValue(options, defaultValue.EMPTY_OBJECT); var source = options.source; var width; @@ -1599,23 +1607,32 @@ define([ if (defined(source)) { var faces = [source.positiveX, source.negativeX, source.positiveY, source.negativeY, source.positiveZ, source.negativeZ]; + //>>includeStart('debug', pragmas.debug); if (!faces[0] || !faces[1] || !faces[2] || !faces[3] || !faces[4] || !faces[5]) { throw new DeveloperError('options.source requires positiveX, negativeX, positiveY, negativeY, positiveZ, and negativeZ faces.'); } + //>>includeEnd('debug'); width = faces[0].width; height = faces[0].height; + //>>includeStart('debug', pragmas.debug); for ( var i = 1; i < 6; ++i) { if ((Number(faces[i].width) !== width) || (Number(faces[i].height) !== height)) { throw new DeveloperError('Each face in options.source must have the same width and height.'); } } + //>>includeEnd('debug'); } else { width = options.width; height = options.height; } + var size = width; + var pixelFormat = defaultValue(options.pixelFormat, PixelFormat.RGBA); + var pixelDatatype = defaultValue(options.pixelDatatype, PixelDatatype.UNSIGNED_BYTE); + + //>>includeStart('debug', pragmas.debug); if (!defined(width) || !defined(height)) { throw new DeveloperError('options requires a source field to create an initialized cube map or width and height fields to create a blank cube map.'); } @@ -1624,8 +1641,6 @@ define([ throw new DeveloperError('Width must equal height.'); } - var size = width; - if (size <= 0) { throw new DeveloperError('Width and height must be greater than zero.'); } @@ -1634,7 +1649,6 @@ define([ throw new DeveloperError('Width and height must be less than or equal to the maximum cube map size (' + this._maximumCubeMapSize + '). Check getMaximumCubeMapSize().'); } - var pixelFormat = defaultValue(options.pixelFormat, PixelFormat.RGBA); if (!PixelFormat.validate(pixelFormat)) { throw new DeveloperError('Invalid options.pixelFormat.'); } @@ -1643,10 +1657,10 @@ define([ throw new DeveloperError('options.pixelFormat cannot be DEPTH_COMPONENT or DEPTH_STENCIL.'); } - var pixelDatatype = defaultValue(options.pixelDatatype, PixelDatatype.UNSIGNED_BYTE); if (!PixelDatatype.validate(pixelDatatype)) { throw new DeveloperError('Invalid options.pixelDatatype.'); } + //>>includeEnd('debug'); if ((pixelDatatype === PixelDatatype.FLOAT) && !this.getFloatingPointTexture()) { throw new RuntimeError('When options.pixelDatatype is FLOAT, this WebGL implementation must support the OES_texture_float extension.'); @@ -1778,6 +1792,7 @@ define([ var width = defined(options.width) ? options.width : gl.drawingBufferWidth; var height = defined(options.height) ? options.height : gl.drawingBufferHeight; + //>>includeStart('debug', pragmas.debug); if (!RenderbufferFormat.validate(format)) { throw new DeveloperError('Invalid format.'); } @@ -1797,6 +1812,7 @@ define([ if (height > this.getMaximumRenderbufferSize()) { throw new DeveloperError('Height must be less than or equal to the maximum renderbuffer size (' + this.getMaximumRenderbufferSize() + '). Check getMaximumRenderbufferSize().'); } + //>>includeEnd('debug'); return new Renderbuffer(gl, format, width, height); }; @@ -1973,6 +1989,7 @@ define([ maximumAnisotropy : (defined(sampler.maximumAnisotropy)) ? sampler.maximumAnisotropy : 1.0 }; + //>>includeStart('debug', pragmas.debug); if (!TextureWrap.validate(s.wrapS)) { throw new DeveloperError('Invalid sampler.wrapS.'); } @@ -1992,6 +2009,7 @@ define([ if (s.maximumAnisotropy < 1.0) { throw new DeveloperError('sampler.maximumAnisotropy must be greater than or equal to one.'); } + //>>includeEnd('debug'); return s; }; @@ -2103,13 +2121,13 @@ define([ function beginDraw(context, framebuffer, drawCommand, passState) { var rs = defined(drawCommand.renderState) ? drawCommand.renderState : context._defaultRenderState; + //>>includeStart('debug', pragmas.debug); if (defined(framebuffer) && rs.depthTest) { if (rs.depthTest.enabled && !framebuffer.hasDepthAttachment()) { throw new DeveloperError('The depth test can not be enabled (drawCommand.renderState.depthTest.enabled) because the framebuffer (drawCommand.framebuffer) does not have a depth or depth-stencil renderbuffer.'); } } - - /////////////////////////////////////////////////////////////////////// + //>>includeEnd('debug'); if (defined(framebuffer)) { framebuffer._bind(); @@ -2129,6 +2147,7 @@ define([ var offset = drawCommand.offset; var count = drawCommand.count; + //>>includeStart('debug', pragmas.debug); if (!PrimitiveType.validate(primitiveType)) { throw new DeveloperError('drawCommand.primitiveType is required and must be valid.'); } @@ -2144,6 +2163,7 @@ define([ if (count < 0) { throw new DeveloperError('drawCommand.count must be omitted or greater than or equal to zero.'); } + //>>includeEnd('debug'); context._us.setModel(defaultValue(drawCommand.modelMatrix, Matrix4.IDENTITY)); drawCommand.shaderProgram._setUniforms(drawCommand.uniformMap, context._us, context._validateSP); @@ -2218,6 +2238,7 @@ define([ * @see Context#createRenderState */ Context.prototype.draw = function(drawCommand, passState) { + //>>includeStart('debug', pragmas.debug); if (!defined(drawCommand)) { throw new DeveloperError('drawCommand is required.'); } @@ -2225,6 +2246,7 @@ define([ if (!defined(drawCommand.shaderProgram)) { throw new DeveloperError('drawCommand.shaderProgram is required.'); } + //>>includeEnd('debug'); passState = defaultValue(passState, this._defaultPassState); // The command's framebuffer takes presidence over the pass' framebuffer, e.g., for off-screen rendering. @@ -2270,6 +2292,7 @@ define([ var height = readState.height || gl.drawingBufferHeight; var framebuffer = readState.framebuffer || null; + //>>includeStart('debug', pragmas.debug); if (width <= 0) { throw new DeveloperError('readState.width must be greater than zero.'); } @@ -2277,6 +2300,7 @@ define([ if (height <= 0) { throw new DeveloperError('readState.height must be greater than zero.'); } + //>>includeEnd('debug'); var pixels = new Uint8Array(4 * width * height); @@ -2598,9 +2622,11 @@ define([ * @see Context#createPickId */ Context.prototype.getObjectByPickColor = function(pickColor) { + //>>includeStart('debug', pragmas.debug); if (!defined(pickColor)) { throw new DeveloperError('pickColor is required.'); } + //>>includeEnd('debug'); return this._pickObjects[pickColor.toRgba()]; }; @@ -2639,9 +2665,11 @@ define([ * }); */ Context.prototype.createPickId = function(object) { + //>>includeStart('debug', pragmas.debug); if (!defined(object)) { throw new DeveloperError('object is required.'); } + //>>includeEnd('debug'); // the increment and assignment have to be separate statements to // actually detect overflow in the Uint32 value diff --git a/Source/Scene/PerspectiveFrustum.js b/Source/Scene/PerspectiveFrustum.js index cd9c6acde293..c58b7462f5da 100644 --- a/Source/Scene/PerspectiveFrustum.js +++ b/Source/Scene/PerspectiveFrustum.js @@ -66,14 +66,17 @@ define([ }; function update(frustum) { + //>>includeStart('debug', pragmas.debug); if (!defined(frustum.fovy) || !defined(frustum.aspectRatio) || !defined(frustum.near) || !defined(frustum.far)) { throw new DeveloperError('fovy, aspectRatio, near, or far parameters are not set.'); } + //>>includeEnd('debug'); var f = frustum._offCenterFrustum; if (frustum.fovy !== frustum._fovy || frustum.aspectRatio !== frustum._aspectRatio || frustum.near !== frustum._near || frustum.far !== frustum._far) { + //>>includeStart('debug', pragmas.debug); if (frustum.fovy < 0 || frustum.fovy >= Math.PI) { throw new DeveloperError('fovy must be in the range [0, PI).'); } @@ -85,6 +88,7 @@ define([ if (frustum.near < 0 || frustum.near > frustum.far) { throw new DeveloperError('near must be greater than zero and less than far.'); } + //>>includeEnd('debug'); frustum._fovy = frustum.fovy; frustum._aspectRatio = frustum.aspectRatio; diff --git a/Source/Scene/PerspectiveOffCenterFrustum.js b/Source/Scene/PerspectiveOffCenterFrustum.js index 68be7c02b68f..47cb701de6a8 100644 --- a/Source/Scene/PerspectiveOffCenterFrustum.js +++ b/Source/Scene/PerspectiveOffCenterFrustum.js @@ -96,11 +96,13 @@ define([ }; function update(frustum) { + //>>includeStart('debug', pragmas.debug); if (!defined(frustum.right) || !defined(frustum.left) || !defined(frustum.top) || !defined(frustum.bottom) || !defined(frustum.near) || !defined(frustum.far)) { throw new DeveloperError('right, left, top, bottom, near, or far parameters are not set.'); } + //>>includeEnd('debug'); var t = frustum.top; var b = frustum.bottom; @@ -113,9 +115,11 @@ define([ l !== frustum._left || r !== frustum._right || n !== frustum._near || f !== frustum._far) { + //>>includeStart('debug', pragmas.debug); if (frustum.near <= 0 || frustum.near > frustum.far) { throw new DeveloperError('near must be greater than zero and less than far.'); } + //>>includeEnd('debug'); frustum._left = l; frustum._right = r; @@ -183,6 +187,7 @@ define([ * var intersect = cullingVolume.getVisibility(boundingVolume); */ PerspectiveOffCenterFrustum.prototype.computeCullingVolume = function(position, direction, up) { + //>>includeStart('debug', pragmas.debug); if (!defined(position)) { throw new DeveloperError('position is required.'); } @@ -194,6 +199,7 @@ define([ if (!defined(up)) { throw new DeveloperError('up is required.'); } + //>>includeEnd('debug'); var planes = this._cullingVolume.planes; @@ -337,13 +343,16 @@ define([ PerspectiveOffCenterFrustum.prototype.getPixelSize = function(drawingBufferDimensions, distance) { update(this); + //>>includeStart('debug', pragmas.debug); if (!defined(drawingBufferDimensions)) { throw new DeveloperError('drawingBufferDimensions is required.'); } + //>>includeEnd('debug'); var width = drawingBufferDimensions.x; var height = drawingBufferDimensions.y; + //>>includeStart('debug', pragmas.debug); if (width <= 0) { throw new DeveloperError('drawingBufferDimensions.x must be greater than zero.'); } @@ -351,6 +360,7 @@ define([ if (height <= 0) { throw new DeveloperError('drawingBufferDimensions.y must be greater than zero.'); } + //>>includeEnd('debug'); distance = defaultValue(distance, this.near); diff --git a/Specs/Core/BoundingSphereSpec.js b/Specs/Core/BoundingSphereSpec.js index 66acc86d575e..4f1c70e371b9 100644 --- a/Specs/Core/BoundingSphereSpec.js +++ b/Specs/Core/BoundingSphereSpec.js @@ -253,7 +253,7 @@ defineSuite([ function callWithStrideOf2() { BoundingSphere.fromVertices(getPositionsAsFlatArray(), undefined, 2); } - expect(callWithStrideOf2).toThrow(); + expect(callWithStrideOf2).toThrowDeveloperError(); }); it('fromVertices fills result parameter if specified', function() { @@ -315,13 +315,13 @@ defineSuite([ it('fromCornerPoints throws without corner', function() { expect(function() { BoundingSphere.fromCornerPoints(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('fromCornerPoints throws without oppositeCorner', function() { expect(function() { BoundingSphere.fromCornerPoints(Cartesian3.UNIT_X); - }).toThrow(); + }).toThrowDeveloperError(); }); it('fromEllipsoid', function() { @@ -342,7 +342,7 @@ defineSuite([ it('fromEllipsoid throws without ellipsoid', function() { expect(function() { BoundingSphere.fromEllipsoid(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('sphere on the positive side of a plane', function() { @@ -458,7 +458,7 @@ defineSuite([ it('static projectTo2D throws without sphere', function() { expect(function() { BoundingSphere.projectTo2D(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static clone returns undefined with no parameter', function() { @@ -469,73 +469,73 @@ defineSuite([ var right = new BoundingSphere(); expect(function() { BoundingSphere.union(undefined, right); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static union throws with no right parameter', function() { var left = new BoundingSphere(); expect(function() { BoundingSphere.union(left, undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static expand throws without a sphere', function() { var plane = new Cartesian3(); expect(function() { BoundingSphere.expand(undefined, plane); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static expand throws without a point', function() { var sphere = new BoundingSphere(); expect(function() { BoundingSphere.expand(sphere, undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static intersect throws without a sphere', function() { var plane = new Cartesian4(); expect(function() { BoundingSphere.intersect(undefined, plane); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static intersect throws without a plane', function() { var sphere = new BoundingSphere(); expect(function() { BoundingSphere.intersect(sphere, undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static transform throws without a sphere', function() { expect(function() { BoundingSphere.transform(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static transform throws without a transform', function() { var sphere = new BoundingSphere(); expect(function() { BoundingSphere.transform(sphere); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static getPlaneDistances throws without a sphere', function() { expect(function() { BoundingSphere.getPlaneDistances(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static getPlaneDistances throws without a position', function() { expect(function() { BoundingSphere.getPlaneDistances(new BoundingSphere()); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static getPlaneDistances throws without a direction', function() { expect(function() { BoundingSphere.getPlaneDistances(new BoundingSphere(), new Cartesian3()); - }).toThrow(); + }).toThrowDeveloperError(); }); function expectBoundingSphereToContainPoint(boundingSphere, point, projection) { diff --git a/Specs/Core/Cartesian2Spec.js b/Specs/Core/Cartesian2Spec.js index fcc7b6c41f3c..c4a0cea0b124 100644 --- a/Specs/Core/Cartesian2Spec.js +++ b/Specs/Core/Cartesian2Spec.js @@ -48,7 +48,7 @@ defineSuite([ it('fromArray throws without values', function() { expect(function() { Cartesian2.fromArray(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('clone without a result parameter', function() { @@ -152,13 +152,13 @@ defineSuite([ it('getMinimumByComponent throws without first', function() { expect(function() { Cartesian2.getMinimumByComponent(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('getMinimumByComponent throws without second', function() { expect(function() { Cartesian2.getMinimumByComponent(new Cartesian2()); - }).toThrow(); + }).toThrowDeveloperError(); }); it('getMinimumByComponent works when first\'s or second\'s X is lesser', function() { @@ -240,13 +240,13 @@ defineSuite([ it('getMaximumByComponent throws without first', function() { expect(function() { Cartesian2.getMaximumByComponent(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('getMaximumByComponent throws without second', function() { expect(function() { Cartesian2.getMaximumByComponent(new Cartesian2()); - }).toThrow(); + }).toThrowDeveloperError(); }); it('getMaximumByComponent works when first\'s or second\'s X is greater', function() { @@ -287,13 +287,13 @@ defineSuite([ it('distance throws without left', function() { expect(function() { Cartesian2.distance(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('distance throws without right', function() { expect(function() { Cartesian2.distance(Cartesian2.UNIT_X); - }).toThrow(); + }).toThrowDeveloperError(); }); it('normalize works without a result parameter', function() { @@ -626,117 +626,117 @@ defineSuite([ it('static getMaximumComponent throws with no parameter', function() { expect(function() { Cartesian2.getMaximumComponent(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static getMinimumComponent throws with no parameter', function() { expect(function() { Cartesian2.getMinimumComponent(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static magnitudeSquared throws with no parameter', function() { expect(function() { Cartesian2.magnitudeSquared(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static magnitude throws with no parameter', function() { expect(function() { Cartesian2.magnitude(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static normalize throws with no parameter', function() { expect(function() { Cartesian2.normalize(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static dot throws with no left parameter', function() { expect(function() { Cartesian2.dot(undefined, new Cartesian2()); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static dot throws with no right parameter', function() { expect(function() { Cartesian2.dot(new Cartesian2(), undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static multiplyComponents throw with no left parameter', function() { var right = new Cartesian2(4.0, 5.0); expect(function() { Cartesian2.multiplyComponents(undefined, right); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static multiplyComponents throw with no right parameter', function() { var left = new Cartesian2(4.0, 5.0); expect(function() { Cartesian2.multiplyComponents(left, undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static add throws with no left parameter', function() { expect(function() { Cartesian2.add(undefined, new Cartesian2()); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static add throws with no right parameter', function() { expect(function() { Cartesian2.add(new Cartesian2(), undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static subtract throws with no left parameter', function() { expect(function() { Cartesian2.subtract(undefined, new Cartesian2()); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static subtract throws with no right parameter', function() { expect(function() { Cartesian2.subtract(new Cartesian2(), undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static multiplyByScalar throws with no cartesian parameter', function() { expect(function() { Cartesian2.multiplyByScalar(undefined, 2.0); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static multiplyByScalar throws with no scalar parameter', function() { expect(function() { Cartesian2.multiplyByScalar(new Cartesian2(), undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static divideByScalar throws with no cartesian parameter', function() { expect(function() { Cartesian2.divideByScalar(undefined, 2.0); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static divideByScalar throws with no scalar parameter', function() { expect(function() { Cartesian2.divideByScalar(new Cartesian2(), undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static negate throws with no cartesian parameter', function() { expect(function() { Cartesian2.negate(undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static abs throws with no cartesian parameter', function() { expect(function() { Cartesian2.abs(undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static lerp throws with no start parameter', function() { @@ -744,7 +744,7 @@ defineSuite([ var t = 0.25; expect(function() { Cartesian2.lerp(undefined, end, t); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static lerp throws with no end parameter', function() { @@ -752,7 +752,7 @@ defineSuite([ var t = 0.25; expect(function() { Cartesian2.lerp(start, undefined, t); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static lerp throws with no t parameter', function() { @@ -760,33 +760,33 @@ defineSuite([ var end = new Cartesian2(8.0, 20.0); expect(function() { Cartesian2.lerp(start, end, undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static angleBetween throws with no left parameter', function() { var right = new Cartesian2(8.0, 20.0); expect(function() { Cartesian2.angleBetween(undefined, right); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static angleBetween throws with no right parameter', function() { var left = new Cartesian2(4.0, 8.0); expect(function() { Cartesian2.angleBetween(left, undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static mostOrthogonalAxis throws with no cartesian parameter', function() { expect(function() { Cartesian2.mostOrthogonalAxis(undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static equalsEpsilon throws with no epsilon', function() { expect(function() { Cartesian2.equalsEpsilon(new Cartesian2(), new Cartesian2(), undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('fromElements returns a cartesian2 with corrrect coordinates', function(){ diff --git a/Specs/Core/Cartesian3Spec.js b/Specs/Core/Cartesian3Spec.js index 747b43878d94..887d1c5aadbe 100644 --- a/Specs/Core/Cartesian3Spec.js +++ b/Specs/Core/Cartesian3Spec.js @@ -63,7 +63,7 @@ defineSuite([ it('fromArray throws without values', function() { expect(function() { Cartesian3.fromArray(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('clone without a result parameter', function() { @@ -177,13 +177,13 @@ defineSuite([ it('getMinimumByComponent throws without first', function() { expect(function() { Cartesian3.getMinimumByComponent(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('getMinimumByComponent throws without second', function() { expect(function() { Cartesian3.getMinimumByComponent(new Cartesian3()); - }).toThrow(); + }).toThrowDeveloperError(); }); it('getMinimumByComponent works when first\'s or second\'s X is lesser', function() { @@ -275,13 +275,13 @@ defineSuite([ it('getMaximumByComponent throws without first', function() { expect(function() { Cartesian3.getMaximumByComponent(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('getMaximumByComponent throws without second', function() { expect(function() { Cartesian3.getMaximumByComponent(new Cartesian3()); - }).toThrow(); + }).toThrowDeveloperError(); }); it('getMaximumByComponent works when first\'s or second\'s X is greater', function() { @@ -332,13 +332,13 @@ defineSuite([ it('distance throws without left', function() { expect(function() { Cartesian3.distance(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('distance throws without right', function() { expect(function() { Cartesian3.distance(Cartesian3.UNIT_X); - }).toThrow(); + }).toThrowDeveloperError(); }); it('normalize works without a result parameter', function() { @@ -705,7 +705,7 @@ defineSuite([ it('fromSpherical throws with no spherical parameter', function() { expect(function() { Cartesian3.fromSpherical(undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); @@ -716,117 +716,117 @@ defineSuite([ it('static getMaximumComponent throws with no parameter', function() { expect(function() { Cartesian3.getMaximumComponent(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static getMinimumComponent throws with no parameter', function() { expect(function() { Cartesian3.getMinimumComponent(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static magnitudeSquared throws with no parameter', function() { expect(function() { Cartesian3.magnitudeSquared(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static magnitude throws with no parameter', function() { expect(function() { Cartesian3.magnitude(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static normalize throws with no parameter', function() { expect(function() { Cartesian3.normalize(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static dot throws with no left parameter', function() { expect(function() { Cartesian3.dot(undefined, new Cartesian3()); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static multiplyComponents throw with no left parameter', function() { var right = new Cartesian3(4.0, 5.0, 6.0); expect(function() { Cartesian3.multiplyComponents(undefined, right); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static multiplyComponents throw with no right parameter', function() { var left = new Cartesian3(4.0, 5.0, 6.0); expect(function() { Cartesian3.multiplyComponents(left, undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static dot throws with no right parameter', function() { expect(function() { Cartesian3.dot(new Cartesian3(), undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static add throws with no left parameter', function() { expect(function() { Cartesian3.add(undefined, new Cartesian3()); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static add throws with no right parameter', function() { expect(function() { Cartesian3.add(new Cartesian3(), undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static subtract throws with no left parameter', function() { expect(function() { Cartesian3.subtract(undefined, new Cartesian3()); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static subtract throws with no right parameter', function() { expect(function() { Cartesian3.subtract(new Cartesian3(), undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static multiplyByScalar throws with no cartesian parameter', function() { expect(function() { Cartesian3.multiplyByScalar(undefined, 2.0); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static multiplyByScalar throws with no scalar parameter', function() { expect(function() { Cartesian3.multiplyByScalar(new Cartesian3(), undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static divideByScalar throws with no cartesian parameter', function() { expect(function() { Cartesian3.divideByScalar(undefined, 2.0); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static divideByScalar throws with no scalar parameter', function() { expect(function() { Cartesian3.divideByScalar(new Cartesian3(), undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static negate throws with no cartesian parameter', function() { expect(function() { Cartesian3.negate(undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static abs throws with no cartesian parameter', function() { expect(function() { Cartesian3.abs(undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static lerp throws with no start parameter', function() { @@ -834,7 +834,7 @@ defineSuite([ var t = 0.25; expect(function() { Cartesian3.lerp(undefined, end, t); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static lerp throws with no end parameter', function() { @@ -842,7 +842,7 @@ defineSuite([ var t = 0.25; expect(function() { Cartesian3.lerp(start, undefined, t); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static lerp throws with no t parameter', function() { @@ -850,47 +850,47 @@ defineSuite([ var end = new Cartesian3(8.0, 20.0, 6.0); expect(function() { Cartesian3.lerp(start, end, undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static angleBetween throws with no left parameter', function() { var right = new Cartesian3(8.0, 20.0, 6.0); expect(function() { Cartesian3.angleBetween(undefined, right); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static angleBetween throws with no right parameter', function() { var left = new Cartesian3(4.0, 8.0, 6.0); expect(function() { Cartesian3.angleBetween(left, undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static mostOrthogonalAxis throws with no cartesian parameter', function() { expect(function() { Cartesian3.mostOrthogonalAxis(undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static equalsEpsilon throws with no epsilon', function() { expect(function() { Cartesian3.equalsEpsilon(new Cartesian3(), new Cartesian3(), undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static cross throw with no left paramater', function() { var right = new Cartesian3(4, 3, 6); expect(function() { Cartesian3.cross(undefined, right); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static cross throw with no left paramater', function() { var left = new Cartesian3(1, 2, 5); expect(function() { Cartesian3.cross(left, undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('fromElements returns a cartesian3 with corrrect coordinates', function(){ diff --git a/Specs/Core/Cartesian4Spec.js b/Specs/Core/Cartesian4Spec.js index 7edf6a1a6548..3e74d384583b 100644 --- a/Specs/Core/Cartesian4Spec.js +++ b/Specs/Core/Cartesian4Spec.js @@ -44,7 +44,7 @@ defineSuite([ it('fromArray throws without values', function() { expect(function() { Cartesian4.fromArray(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('clone without a result parameter', function() { @@ -176,13 +176,13 @@ defineSuite([ it('getMinimumByComponent throws without first', function() { expect(function() { Cartesian4.getMinimumByComponent(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('getMinimumByComponent throws without second', function() { expect(function() { Cartesian4.getMinimumByComponent(new Cartesian4()); - }).toThrow(); + }).toThrowDeveloperError(); }); it('getMinimumByComponent works when first\'s or second\'s X is lesser', function() { @@ -292,13 +292,13 @@ defineSuite([ it('getMaximumByComponent throws without first', function() { expect(function() { Cartesian4.getMaximumByComponent(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('getMaximumByComponent throws without second', function() { expect(function() { Cartesian4.getMaximumByComponent(new Cartesian4()); - }).toThrow(); + }).toThrowDeveloperError(); }); it('getMaximumByComponent works when first\'s or second\'s X is greater', function() { @@ -359,13 +359,13 @@ defineSuite([ it('distance throws without left', function() { expect(function() { Cartesian4.distance(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('distance throws without right', function() { expect(function() { Cartesian4.distance(Cartesian4.UNIT_X); - }).toThrow(); + }).toThrowDeveloperError(); }); it('normalize works without a result parameter', function() { @@ -700,117 +700,117 @@ defineSuite([ it('static getMaximumComponent throws with no parameter', function() { expect(function() { Cartesian4.getMaximumComponent(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static getMinimumComponent throws with no parameter', function() { expect(function() { Cartesian4.getMinimumComponent(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static magnitudeSquared throws with no parameter', function() { expect(function() { Cartesian4.magnitudeSquared(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static magnitude throws with no parameter', function() { expect(function() { Cartesian4.magnitude(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static normalize throws with no parameter', function() { expect(function() { Cartesian4.normalize(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static dot throws with no left parameter', function() { expect(function() { Cartesian4.dot(undefined, new Cartesian4()); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static multiplyComponents throw with no left parameter', function() { var right = new Cartesian4(4.0, 5.0, 6.0, 7.0); expect(function() { Cartesian4.multiplyComponents(undefined, right); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static multiplyComponents throw with no right parameter', function() { var left = new Cartesian4(4.0, 5.0, 6.0, 7.0); expect(function() { Cartesian4.multiplyComponents(left, undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static dot throws with no right parameter', function() { expect(function() { Cartesian4.dot(new Cartesian4(), undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static add throws with no left parameter', function() { expect(function() { Cartesian4.add(undefined, new Cartesian4()); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static add throws with no right parameter', function() { expect(function() { Cartesian4.add(new Cartesian4(), undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static subtract throws with no left parameter', function() { expect(function() { Cartesian4.subtract(undefined, new Cartesian4()); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static subtract throws with no right parameter', function() { expect(function() { Cartesian4.subtract(new Cartesian4(), undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static multiplyByScalar throws with no cartesian parameter', function() { expect(function() { Cartesian4.multiplyByScalar(undefined, 2.0); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static multiplyByScalar throws with no scalar parameter', function() { expect(function() { Cartesian4.multiplyByScalar(new Cartesian4(), undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static divideByScalar throws with no cartesian parameter', function() { expect(function() { Cartesian4.divideByScalar(undefined, 2.0); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static divideByScalar throws with no scalar parameter', function() { expect(function() { Cartesian4.divideByScalar(new Cartesian4(), undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static negate throws with no cartesian parameter', function() { expect(function() { Cartesian4.negate(undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static abs throws with no cartesian parameter', function() { expect(function() { Cartesian4.abs(undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static lerp throws with no start parameter', function() { @@ -818,7 +818,7 @@ defineSuite([ var t = 0.25; expect(function() { Cartesian4.lerp(undefined, end, t); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static lerp throws with no end parameter', function() { @@ -826,7 +826,7 @@ defineSuite([ var t = 0.25; expect(function() { Cartesian4.lerp(start, undefined, t); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static lerp throws with no t parameter', function() { @@ -834,19 +834,19 @@ defineSuite([ var end = new Cartesian4(8.0, 20.0, 6.0, 7.0); expect(function() { Cartesian4.lerp(start, end, undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static mostOrthogonalAxis throws with no cartesian parameter', function() { expect(function() { Cartesian4.mostOrthogonalAxis(undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static equalsEpsilon throws with no epsilon', function() { expect(function() { Cartesian4.equalsEpsilon(new Cartesian4(), new Cartesian4(), undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('fromElements returns a cartesian4 with corrrect coordinates', function(){ diff --git a/Specs/Core/MathSpec.js b/Specs/Core/MathSpec.js index 19e0f27d08ba..957841a8b75f 100644 --- a/Specs/Core/MathSpec.js +++ b/Specs/Core/MathSpec.js @@ -150,63 +150,63 @@ defineSuite([ it('factorial throws for non-numbers', function() { expect(function() { CesiumMath.factorial({}); - }).toThrow(); + }).toThrowDeveloperError(); }); it('factorial throws for negative numbers', function() { expect(function() { CesiumMath.factorial(-1); - }).toThrow(); + }).toThrowDeveloperError(); }); it('factorial throws for undefined', function() { expect(function() { CesiumMath.factorial(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('incrementWrap throws for minimum value >= maximum value', function() { expect(function() { CesiumMath.incrementWrap(5, 0, 10); - }).toThrow(); + }).toThrowDeveloperError(); expect(function() { CesiumMath.incrementWrap(5, 10, 10); - }).toThrow(); + }).toThrowDeveloperError(); }); it('isPowerOfTwo throws for non-numbers', function() { expect(function() { CesiumMath.isPowerOfTwo({}); - }).toThrow(); + }).toThrowDeveloperError(); }); it('isPowerOfTwo throws for negative numbers', function() { expect(function() { CesiumMath.isPowerOfTwo(-1); - }).toThrow(); + }).toThrowDeveloperError(); }); it('isPowerOfTwo throws for undefined', function() { expect(function() { CesiumMath.isPowerOfTwo(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('nextPowerOfTwo throws for non-numbers', function() { expect(function() { CesiumMath.nextPowerOfTwo({}); - }).toThrow(); + }).toThrowDeveloperError(); }); it('nextPowerOfTwo throws for negative numbers', function() { expect(function() { CesiumMath.nextPowerOfTwo(-1); - }).toThrow(); + }).toThrowDeveloperError(); }); it('nextPowerOfTwo throws for undefined', function() { expect(function() { CesiumMath.nextPowerOfTwo(); - }).toThrow(); + }).toThrowDeveloperError(); }); }); diff --git a/Specs/Core/Matrix2Spec.js b/Specs/Core/Matrix2Spec.js index daa75a8797d3..4adf0b6580b7 100644 --- a/Specs/Core/Matrix2Spec.js +++ b/Specs/Core/Matrix2Spec.js @@ -108,7 +108,7 @@ defineSuite([ it('fromRotation throws without angle', function() { expect(function() { Matrix2.fromRotation(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('clone works without a result parameter', function() { @@ -378,7 +378,7 @@ defineSuite([ it('abs throws without a matrix', function() { expect(function() { return Matrix2.abs(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('abs works without a result parameter', function() { @@ -482,25 +482,25 @@ defineSuite([ it('fromRowMajorArray throws with undefined parameter', function() { expect(function() { Matrix2.fromRowMajorArray(undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('fromColumnMajorArray throws with undefined parameter', function() { expect(function() { Matrix2.fromColumnMajorArray(undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static fromScale throws without scale parameter', function() { expect(function() { Matrix2.fromScale(undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static fromUniformScale throws without scale parameter', function() { expect(function() { Matrix2.fromUniformScale(undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static clone returns undefined without matrix parameter', function() { @@ -510,13 +510,13 @@ defineSuite([ it('static toArray throws without matrix parameter', function() { expect(function() { Matrix2.toArray(undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static getColumn throws without matrix parameter', function() { expect(function() { Matrix2.getColumn(undefined, 1); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static getElement throws without row parameter', function() { @@ -524,7 +524,7 @@ defineSuite([ var col = 0.0; expect(function() { Matrix2.getElementIndex(col, row); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static getElement throws without column parameter', function() { @@ -532,28 +532,28 @@ defineSuite([ var col; expect(function() { Matrix2.getElementIndex(col, row); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static getColumn throws without of range index parameter', function() { var matrix = new Matrix2(); expect(function() { Matrix2.getColumn(matrix, 2); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static setColumn throws without matrix parameter', function() { var cartesian = new Cartesian2(); expect(function() { Matrix2.setColumn(undefined, 2, cartesian); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static setColumn throws without cartesian parameter', function() { var matrix = new Matrix2(); expect(function() { Matrix2.setColumn(matrix, 1, undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static setColumn throws without of range index parameter', function() { @@ -561,34 +561,34 @@ defineSuite([ var cartesian = new Cartesian2(); expect(function() { Matrix2.setColumn(matrix, 2, cartesian); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static getRow throws without matrix parameter', function() { expect(function() { Matrix2.getRow(undefined, 1); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static getRow throws without of range index parameter', function() { var matrix = new Matrix2(); expect(function() { Matrix2.getRow(matrix, 2); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static setRow throws without matrix parameter', function() { var cartesian = new Cartesian2(); expect(function() { Matrix2.setRow(undefined, 2, cartesian); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static setRow throws without cartesian parameter', function() { var matrix = new Matrix2(); expect(function() { Matrix2.setRow(matrix, 1, undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static setRow throws without of range index parameter', function() { @@ -596,65 +596,65 @@ defineSuite([ var cartesian = new Cartesian2(); expect(function() { Matrix2.setRow(matrix, 2, cartesian); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static multiply throws with no left parameter', function() { var right = new Matrix2(); expect(function() { Matrix2.multiply(undefined, right); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static multiply throws with no right parameter', function() { var left = new Matrix2(); expect(function() { Matrix2.multiply(left, undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static multiplyByVector throws with no matrix parameter', function() { var cartesian = new Cartesian2(); expect(function() { Matrix2.multiplyByVector(undefined, cartesian); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static multiplyByVector throws with no cartesian parameter', function() { var matrix = new Matrix2(); expect(function() { Matrix2.multiplyByVector(matrix, undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static multiplyByScalar throws with no matrix parameter', function() { expect(function() { Matrix2.multiplyByScalar(undefined, 2); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static multiplyByScalar throws with non-numeric scalar parameter', function() { var matrix = new Matrix2(); expect(function() { Matrix2.multiplyByScalar(matrix, {}); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static negate throws with matrix parameter', function() { expect(function() { Matrix2.negate(undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static transpose throws with matrix parameter', function() { expect(function() { Matrix2.transpose(undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static equalsEpsilon throws with non-number parameter', function() { expect(function() { Matrix2.equalsEpsilon(new Matrix2(), new Matrix2(), {}); - }).toThrow(); + }).toThrowDeveloperError(); }); }); diff --git a/Specs/Core/Matrix3Spec.js b/Specs/Core/Matrix3Spec.js index 63962ff25b68..745867d40bb6 100644 --- a/Specs/Core/Matrix3Spec.js +++ b/Specs/Core/Matrix3Spec.js @@ -157,7 +157,7 @@ defineSuite([ it('fromRotationX throws without angle', function() { expect(function() { Matrix3.fromRotationX(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('fromRotationY works without a result parameter', function() { @@ -179,7 +179,7 @@ defineSuite([ it('fromRotationY throws without angle', function() { expect(function() { Matrix3.fromRotationY(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('fromRotationZ works without a result parameter', function() { @@ -201,7 +201,7 @@ defineSuite([ it('fromRotationZ throws without angle', function() { expect(function() { Matrix3.fromRotationZ(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('clone works without a result parameter', function() { @@ -536,7 +536,7 @@ defineSuite([ it('getEigenDecomposition throws without a matrix', function() { expect(function() { return Matrix3.getEigenDecomposition(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('computes eigenvalues and eigenvectors', function() { @@ -597,7 +597,7 @@ defineSuite([ it('abs throws without a matrix', function() { expect(function() { return Matrix3.abs(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('abs works without a result parameter', function() { @@ -746,13 +746,13 @@ defineSuite([ it('fromRowMajorArray throws with undefined parameter', function() { expect(function() { Matrix3.fromRowMajorArray(undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('fromColumnMajorArray throws with undefined parameter', function() { expect(function() { Matrix3.fromColumnMajorArray(undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static clone returns undefined without matrix parameter', function() { @@ -762,7 +762,7 @@ defineSuite([ it('static toArray throws without matrix parameter', function() { expect(function() { Matrix3.toArray(undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static getElement throws without row parameter', function() { @@ -770,7 +770,7 @@ defineSuite([ var col = 0.0; expect(function() { Matrix3.getElementIndex(col, row); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static getElement throws without column parameter', function() { @@ -778,34 +778,34 @@ defineSuite([ var col; expect(function() { Matrix3.getElementIndex(col, row); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static getColumn throws without matrix parameter', function() { expect(function() { Matrix3.getColumn(undefined, 1); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static getColumn throws without of range index parameter', function() { var matrix = new Matrix3(); expect(function() { Matrix3.getColumn(matrix, 3); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static setColumn throws without matrix parameter', function() { var cartesian = new Cartesian3(); expect(function() { Matrix3.setColumn(undefined, 2, cartesian); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static setColumn throws without cartesian parameter', function() { var matrix = new Matrix3(); expect(function() { Matrix3.setColumn(matrix, 1, undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static setColumn throws without of range index parameter', function() { @@ -813,34 +813,34 @@ defineSuite([ var cartesian = new Cartesian3(); expect(function() { Matrix3.setColumn(matrix, 3, cartesian); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static getRow throws without matrix parameter', function() { expect(function() { Matrix3.getRow(undefined, 1); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static getRow throws without of range index parameter', function() { var matrix = new Matrix3(); expect(function() { Matrix3.getRow(matrix, 3); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static setRow throws without matrix parameter', function() { var cartesian = new Cartesian3(); expect(function() { Matrix3.setRow(undefined, 2, cartesian); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static setRow throws without cartesian parameter', function() { var matrix = new Matrix3(); expect(function() { Matrix3.setRow(matrix, 1, undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static setRow throws without of range index parameter', function() { @@ -848,101 +848,101 @@ defineSuite([ var cartesian = new Cartesian3(); expect(function() { Matrix3.setRow(matrix, 3, cartesian); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static multiply throws with no left parameter', function() { var right = new Matrix3(); expect(function() { Matrix3.multiply(undefined, right); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static multiply throws with no right parameter', function() { var left = new Matrix3(); expect(function() { Matrix3.multiply(left, undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static multiplyByVector throws with no matrix parameter', function() { var cartesian = new Cartesian3(); expect(function() { Matrix3.multiplyByVector(undefined, cartesian); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static multiplyByVector throws with no cartesian parameter', function() { var matrix = new Matrix3(); expect(function() { Matrix3.multiplyByVector(matrix, undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static multiplyByScalar throws with no matrix parameter', function() { expect(function() { Matrix3.multiplyByScalar(undefined, 2); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static multiplyByScalar throws with non-numeric scalar parameter', function() { var matrix = new Matrix3(); expect(function() { Matrix3.multiplyByScalar(matrix, {}); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static negate throws without matrix parameter', function() { expect(function() { Matrix3.negate(undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static transpose throws without matrix parameter', function() { expect(function() { Matrix3.transpose(undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static determinant throws without matrix parameter', function() { expect(function() { Matrix3.determinant(undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static inverse throws without matrix parameter', function() { expect(function() { Matrix3.inverse(undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static inverse throws when matrix is not invertible', function() { expect(function() { Matrix3.inverse(new Matrix3(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static fromQuaternion throws without quaternion parameter', function() { expect(function() { Matrix3.fromQuaternion(undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static fromScale throws without scale parameter', function() { expect(function() { Matrix3.fromScale(undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static fromUniformScale throws without scale parameter', function() { expect(function() { Matrix3.fromUniformScale(undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static equalsEpsilon throws with non-number parameter', function() { expect(function() { Matrix3.equalsEpsilon(new Matrix3(), new Matrix3(), {}); - }).toThrow(); + }).toThrowDeveloperError(); }); }); diff --git a/Specs/Core/Matrix4Spec.js b/Specs/Core/Matrix4Spec.js index ef3a8735caec..60ec82c02c99 100644 --- a/Specs/Core/Matrix4Spec.js +++ b/Specs/Core/Matrix4Spec.js @@ -988,7 +988,7 @@ defineSuite([ it('abs throws without a matrix', function() { expect(function() { return Matrix4.abs(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('abs works without a result parameter', function() { @@ -1027,67 +1027,67 @@ defineSuite([ it('fromRowMajorArray throws with undefined parameter', function() { expect(function() { Matrix4.fromRowMajorArray(undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('fromColumnMajorArray throws with undefined parameter', function() { expect(function() { Matrix4.fromColumnMajorArray(undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('fromRotationTranslation throws without rotation parameter', function() { expect(function() { Matrix4.fromRotationTranslation(undefined, new Cartesian3()); - }).toThrow(); + }).toThrowDeveloperError(); }); it('fromRotationTranslation throws without translation parameter', function() { expect(function() { Matrix4.fromRotationTranslation(new Matrix4(), undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('fromTranslationQuaternionRotationScale throws without translation parameter', function() { expect(function() { Matrix4.fromTranslationQuaternionRotationScale(undefined, new Quaternion(), new Cartesian3()); - }).toThrow(); + }).toThrowDeveloperError(); }); it('fromTranslationQuaternionRotationScale throws without rotation parameter', function() { expect(function() { Matrix4.fromTranslationQuaternionRotationScale(new Matrix3(), undefined, new Cartesian3()); - }).toThrow(); + }).toThrowDeveloperError(); }); it('fromTranslationQuaternionRotationScale throws without scale parameter', function() { expect(function() { Matrix4.fromTranslationQuaternionRotationScale(new Matrix3(), new Quaternion(), undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('fromTranslation throws without translation parameter', function() { expect(function() { Matrix4.fromTranslation(undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('fromScale throws without scale parameter', function() { expect(function() { Matrix4.fromScale(undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('fromUniformScale throws without scale parameter', function() { expect(function() { Matrix4.fromUniformScale(undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('fromCamera throws without camera', function() { expect(function() { Matrix4.fromCamera(undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('fromCamera throws without eye', function() { @@ -1096,7 +1096,7 @@ defineSuite([ target : Cartesian3.negate(Cartesian3.UNIT_Z), up : Cartesian3.UNIT_Y }); - }).toThrow(); + }).toThrowDeveloperError(); }); it('fromCamera throws without target', function() { @@ -1105,7 +1105,7 @@ defineSuite([ eye : Cartesian3.ZERO, up : Cartesian3.UNIT_Y }); - }).toThrow(); + }).toThrowDeveloperError(); }); it('fromCamera throws without up', function() { @@ -1114,149 +1114,149 @@ defineSuite([ eye : Cartesian3.ZERO, target : Cartesian3.negate(Cartesian3.UNIT_Z) }); - }).toThrow(); + }).toThrowDeveloperError(); }); it('createOrthographicOffCenter throws without left', function() { expect(function() { var right = 0, bottom = 0, top = 0, near = 0, far = 0; Matrix4.computeOrthographicOffCenter(undefined, right, bottom, top, near, far); - }).toThrow(); + }).toThrowDeveloperError(); }); it('createOrthographicOffCenter throws without right', function() { expect(function() { var left = 0, bottom = 0, top = 0, near = 0, far = 0; Matrix4.computeOrthographicOffCenter(left, undefined, bottom, top, near, far); - }).toThrow(); + }).toThrowDeveloperError(); }); it('createOrthographicOffCenter throws without bottom', function() { expect(function() { var left = 0, right = 0, top = 0, near = 0, far = 0; Matrix4.computeOrthographicOffCenter(left, right, undefined, top, near, far); - }).toThrow(); + }).toThrowDeveloperError(); }); it('createOrthographicOffCenter throws without top', function() { expect(function() { var left = 0, right = 0, bottom = 0, near = 0, far = 0; Matrix4.computeOrthographicOffCenter(left, right, bottom, undefined, near, far); - }).toThrow(); + }).toThrowDeveloperError(); }); it('createOrthographicOffCenter throws without near', function() { expect(function() { var left = 0, right = 0, bottom = 0, top = 0, far = 0; Matrix4.computeOrthographicOffCenter(left, right, bottom, top, undefined, far); - }).toThrow(); + }).toThrowDeveloperError(); }); it('createOrthographicOffCenter throws without far', function() { expect(function() { var left = 0, right = 0, bottom = 0, top = 0, near = 0; Matrix4.computeOrthographicOffCenter(left, right, bottom, top, near, undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('createPerspectiveOffCenter throws without left', function() { expect(function() { var right = 0, bottom = 0, top = 0, near = 0, far = 0; Matrix4.computePerspectiveOffCenter (undefined, right, bottom, top, near, far); - }).toThrow(); + }).toThrowDeveloperError(); }); it('createPerspectiveOffCenter throws without right', function() { expect(function() { var left = 0, bottom = 0, top = 0, near = 0, far = 0; Matrix4.computePerspectiveOffCenter (left, undefined, bottom, top, near, far); - }).toThrow(); + }).toThrowDeveloperError(); }); it('createPerspectiveOffCenter throws without bottom', function() { expect(function() { var left = 0, right = 0, top = 0, near = 0, far = 0; Matrix4.computePerspectiveOffCenter (left, right, undefined, top, near, far); - }).toThrow(); + }).toThrowDeveloperError(); }); it('createPerspectiveOffCenter throws without top', function() { expect(function() { var left = 0, right = 0, bottom = 0, near = 0, far = 0; Matrix4.computePerspectiveOffCenter (left, right, bottom, undefined, near, far); - }).toThrow(); + }).toThrowDeveloperError(); }); it('createPerspectiveOffCenter throws without near', function() { expect(function() { var left = 0, right = 0, bottom = 0, top = 0, far = 0; Matrix4.computePerspectiveOffCenter (left, right, bottom, top, undefined, far); - }).toThrow(); + }).toThrowDeveloperError(); }); it('createPerspectiveOffCenter throws without far', function() { expect(function() { var left = 0, right = 0, bottom = 0, top = 0, near = 0; Matrix4.computePerspectiveOffCenter (left, right, bottom, top, near, undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('createInfinitePerspectiveOffCenter throws without left', function() { expect(function() { var right = 0, bottom = 0, top = 0, near = 0, far = 0; Matrix4.computeInfinitePerspectiveOffCenter (undefined, right, bottom, top, near, far); - }).toThrow(); + }).toThrowDeveloperError(); }); it('createInfinitePerspectiveOffCenter throws without right', function() { expect(function() { var left = 0, bottom = 0, top = 0, near = 0, far = 0; Matrix4.computeInfinitePerspectiveOffCenter (left, undefined, bottom, top, near, far); - }).toThrow(); + }).toThrowDeveloperError(); }); it('createInfinitePerspectiveOffCenter throws without bottom', function() { expect(function() { var left = 0, right = 0, top = 0, near = 0, far = 0; Matrix4.computeInfinitePerspectiveOffCenter (left, right, undefined, top, near, far); - }).toThrow(); + }).toThrowDeveloperError(); }); it('createInfinitePerspectiveOffCenter throws without top', function() { expect(function() { var left = 0, right = 0, bottom = 0, near = 0, far = 0; Matrix4.computeInfinitePerspectiveOffCenter (left, right, bottom, undefined, near, far); - }).toThrow(); + }).toThrowDeveloperError(); }); it('createInfinitePerspectiveOffCenter throws without near', function() { expect(function() { var left = 0, right = 0, bottom = 0, top = 0, far = 0; Matrix4.computeInfinitePerspectiveOffCenter (left, right, bottom, top, undefined, far); - }).toThrow(); + }).toThrowDeveloperError(); }); it('createPerspectiveFieldOfView throws with out of range y field of view', function() { expect(function() { Matrix4.computePerspectiveFieldOfView(0, 1, 2, 3); - }).toThrow(); + }).toThrowDeveloperError(); }); it('createPerspectiveFieldOfView throws with out of range aspect', function() { expect(function() { Matrix4.computePerspectiveFieldOfView(1, 0, 2, 3); - }).toThrow(); + }).toThrowDeveloperError(); }); it('createPerspectiveFieldOfView throws with out of range near', function() { expect(function() { Matrix4.computePerspectiveFieldOfView(1, 1, 0, 3); - }).toThrow(); + }).toThrowDeveloperError(); }); it('createPerspectiveFieldOfView throws with out of range far', function() { expect(function() { Matrix4.computePerspectiveFieldOfView(1, 1, 2, 0); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static clone returns undefined without matrix parameter', function() { @@ -1266,7 +1266,7 @@ defineSuite([ it('static toArray throws without matrix parameter', function() { expect(function() { Matrix4.toArray(undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static getElement throws without row parameter', function() { @@ -1274,7 +1274,7 @@ defineSuite([ var col = 0.0; expect(function() { Matrix4.getElementIndex(col, row); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static getElement throws without column parameter', function() { @@ -1282,34 +1282,34 @@ defineSuite([ var col; expect(function() { Matrix4.getElementIndex(col, row); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static getColumn throws without matrix parameter', function() { expect(function() { Matrix4.getColumn(undefined, 1); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static getColumn throws without of range index parameter', function() { var matrix = new Matrix4(); expect(function() { Matrix4.getColumn(matrix, 4); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static setColumn throws without matrix parameter', function() { var cartesian = new Cartesian4(); expect(function() { Matrix4.setColumn(undefined, 2, cartesian); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static setColumn throws without cartesian parameter', function() { var matrix = new Matrix4(); expect(function() { Matrix4.setColumn(matrix, 1, undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static setColumn throws without of range index parameter', function() { @@ -1317,34 +1317,34 @@ defineSuite([ var cartesian = new Cartesian4(); expect(function() { Matrix4.setColumn(matrix, 4, cartesian); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static getRow throws without matrix parameter', function() { expect(function() { Matrix4.getRow(undefined, 1); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static getRow throws without of range index parameter', function() { var matrix = new Matrix4(); expect(function() { Matrix4.getRow(matrix, 4); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static setRow throws without matrix parameter', function() { var cartesian = new Cartesian4(); expect(function() { Matrix4.setRow(undefined, 2, cartesian); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static setRow throws without cartesian parameter', function() { var matrix = new Matrix4(); expect(function() { Matrix4.setRow(matrix, 1, undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static setRow throws without of range index parameter', function() { @@ -1352,138 +1352,138 @@ defineSuite([ var cartesian = new Cartesian4(); expect(function() { Matrix4.setRow(matrix, 4, cartesian); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static multiply throws with no left parameter', function() { var right = new Matrix4(); expect(function() { Matrix4.multiply(undefined, right); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static multiply throws with no right parameter', function() { var left = new Matrix4(); expect(function() { Matrix4.multiply(left, undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static multiplyByTranslation throws with no matrix parameter', function() { var translation = new Cartesian3(); expect(function() { Matrix4.multiplyByTranslation(undefined, translation); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static multiplyByTranslation throws with no translation parameter', function() { var m = new Matrix4(); expect(function() { Matrix4.multiplyByTranslation(m, undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static multiplyByUniformScale throws with no matrix parameter', function() { expect(function() { Matrix4.multiplyByUniformScale(undefined, 2.0); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static multiplyByUniformScale throws with no scale parameter', function() { var m = new Matrix4(); expect(function() { Matrix4.multiplyByUniformScale(m, undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static multiplyByScale throws with no matrix parameter', function() { expect(function() { Matrix4.multiplyByScale(undefined, new Cartesian3()); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static multiplyByScale throws with no scale parameter', function() { var m = new Matrix4(); expect(function() { Matrix4.multiplyByScale(m, undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static multiplyByVector throws with no matrix parameter', function() { var cartesian = new Cartesian4(); expect(function() { Matrix4.multiplyByVector(undefined, cartesian); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static multiplyByVector throws with no cartesian parameter', function() { var matrix = new Matrix4(); expect(function() { Matrix4.multiplyByVector(matrix, undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static multiplyByPoint throws with no matrix parameter', function() { var cartesian = new Cartesian4(); expect(function() { Matrix4.multiplyByPoint(undefined, cartesian); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static multiplyByPoint throws with no cartesian parameter', function() { var matrix = new Matrix4(); expect(function() { Matrix4.multiplyByPoint(matrix, undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static multiplyByScalar throws with no matrix parameter', function() { expect(function() { Matrix4.multiplyByScalar(undefined, 2); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static multiplyByScalar throws with non-numeric scalar parameter', function() { var matrix = new Matrix4(); expect(function() { Matrix4.multiplyByScalar(matrix, {}); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static negate throws without matrix parameter', function() { expect(function() { Matrix4.negate(undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static transpose throws without matrix parameter', function() { expect(function() { Matrix4.transpose(undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static equalsEpsilon throws with non-number parameter', function() { expect(function() { Matrix4.equalsEpsilon(new Matrix4(), new Matrix4(), {}); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static getTranslation throws without matrix parameter', function() { expect(function() { Matrix4.getTranslation(undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static getRotation throws without matrix parameter', function() { expect(function() { Matrix4.getRotation(undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static inverse throws without matrix parameter', function() { expect(function() { Matrix4.inverse(undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static inverse throws with non-inversable matrix', function() { @@ -1496,6 +1496,6 @@ defineSuite([ it('static inverseTransformation throws without matrix parameter', function() { expect(function() { Matrix4.inverseTransformation(undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); }); diff --git a/Specs/Core/QuaternionSpec.js b/Specs/Core/QuaternionSpec.js index 66c31f207bfa..c94a45b85fae 100644 --- a/Specs/Core/QuaternionSpec.js +++ b/Specs/Core/QuaternionSpec.js @@ -659,19 +659,19 @@ defineSuite([ it('fromAxisAngle throws with undefined axis', function() { expect(function() { Quaternion.fromAxisAngle(undefined, 1.0); - }).toThrow(); + }).toThrowDeveloperError(); }); it('fromAxisAngle throws with non-numeric angle', function() { expect(function() { Quaternion.fromAxisAngle(Cartesian3.UNIT_X, {}); - }).toThrow(); + }).toThrowDeveloperError(); }); it('fromRotationMatrix throws with undefined matrix', function() { expect(function() { Quaternion.fromRotationMatrix(undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static clone returns undefined with no parameter', function() { @@ -681,121 +681,121 @@ defineSuite([ it('static conjugate throws with no parameter', function() { expect(function() { Quaternion.conjugate(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static magnitudeSquared throws with no parameter', function() { expect(function() { Quaternion.magnitudeSquared(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static magnitude throws with no parameter', function() { expect(function() { Quaternion.magnitude(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static normalize throws with no parameter', function() { expect(function() { Quaternion.normalize(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static inverse throws with no parameter', function() { expect(function() { Quaternion.inverse(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static dot throws with no left parameter', function() { expect(function() { Quaternion.dot(undefined, new Quaternion()); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static dot throws with no right parameter', function() { expect(function() { Quaternion.dot(new Quaternion(), undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static multiply throws with no right parameter', function() { expect(function() { Quaternion.multiply(new Quaternion(), undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static multiply throws with no left parameter', function() { expect(function() { Quaternion.multiply(undefined, new Quaternion()); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static add throws with no left parameter', function() { expect(function() { Quaternion.add(undefined, new Quaternion()); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static add throws with no right parameter', function() { expect(function() { Quaternion.add(new Quaternion(), undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static subtract throws with no left parameter', function() { expect(function() { Quaternion.subtract(undefined, new Quaternion()); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static subtract throws with no right parameter', function() { expect(function() { Quaternion.subtract(new Quaternion(), undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static multiplyByScalar throws with no quaternion parameter', function() { expect(function() { Quaternion.multiplyByScalar(undefined, 2.0); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static multiplyByScalar throws with no scalar parameter', function() { expect(function() { Quaternion.multiplyByScalar(new Quaternion(), undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static divideByScalar throws with no quaternion parameter', function() { expect(function() { Quaternion.divideByScalar(undefined, 2.0); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static divideByScalar throws with no scalar parameter', function() { expect(function() { Quaternion.divideByScalar(new Quaternion(), undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static getAxis throws with no parameter', function() { expect(function() { Quaternion.getAxis(undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static getAngle throws with no parameter', function() { expect(function() { Quaternion.getAngle(undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static negate throws with no quaternion parameter', function() { expect(function() { Quaternion.negate(undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static lerp throws with no start parameter', function() { @@ -803,7 +803,7 @@ defineSuite([ var t = 0.25; expect(function() { Quaternion.lerp(undefined, end, t); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static lerp throws with no end parameter', function() { @@ -811,7 +811,7 @@ defineSuite([ var t = 0.25; expect(function() { Quaternion.lerp(start, undefined, t); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static lerp throws with no t parameter', function() { @@ -819,7 +819,7 @@ defineSuite([ var end = new Quaternion(8.0, 20.0, 6.0, 7.0); expect(function() { Quaternion.lerp(start, end, undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static slerp throws with no start parameter', function() { @@ -827,7 +827,7 @@ defineSuite([ var t = 0.25; expect(function() { Quaternion.slerp(undefined, end, t); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static slerp throws with no end parameter', function() { @@ -835,7 +835,7 @@ defineSuite([ var t = 0.25; expect(function() { Quaternion.slerp(start, undefined, t); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static slerp throws with no t parameter', function() { @@ -843,43 +843,43 @@ defineSuite([ var end = new Quaternion(8.0, 20.0, 6.0, 7.0); expect(function() { Quaternion.slerp(start, end, undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static log throws with no quaternion parameter', function() { expect(function() { Quaternion.log(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static exp throws with no cartesian parameter', function() { expect(function() { Quaternion.exp(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static innerQuadrangle throws without q0, q1, or q2 parameter', function() { expect(function() { Quaternion.innerQuadrangle(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static squad throws without q0, q1, s0, or s1 parameter', function() { expect(function() { Quaternion.squad(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static squad throws without t parameter', function() { expect(function() { Quaternion.squad(new Quaternion(), new Quaternion(), new Quaternion(), new Quaternion()); - }).toThrow(); + }).toThrowDeveloperError(); }); it('static equalsEpsilon throws with no epsilon', function() { expect(function() { Quaternion.equalsEpsilon(new Quaternion(), new Quaternion(), undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); createPackableSpecs(Quaternion, new Quaternion(1, 2, 3, 4), [1, 2, 3, 4]); diff --git a/Specs/Core/TaskProcessorSpec.js b/Specs/Core/TaskProcessorSpec.js index 3da88540882a..37fb799e097b 100644 --- a/Specs/Core/TaskProcessorSpec.js +++ b/Specs/Core/TaskProcessorSpec.js @@ -1,9 +1,11 @@ /*global defineSuite*/ defineSuite([ 'Core/TaskProcessor', + 'require', 'Specs/waitsForPromise' ], function( TaskProcessor, + require, waitsForPromise) { "use strict"; /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn,runs,waits,waitsFor*/ @@ -12,10 +14,22 @@ defineSuite([ beforeEach(function() { TaskProcessor._workerModulePrefix = '../Specs/TestWorkers/'; + + function absolutize(url) { + var a = document.createElement('a'); + a.href = url; + a.href = a.href; // IE only absolutizes href on get, not set + return a.href; + } + + TaskProcessor._loaderConfig = { + baseUrl : absolutize(require.toUrl('Specs/../Source')) + }; }); afterEach(function() { TaskProcessor._workerModulePrefix = TaskProcessor._defaultWorkerModulePrefix; + TaskProcessor._loaderConfig = undefined; if (taskProcessor && !taskProcessor.isDestroyed()) { taskProcessor = taskProcessor.destroy(); diff --git a/Specs/Core/TransformsSpec.js b/Specs/Core/TransformsSpec.js index 0becd9ebaa5c..c958d75bceb5 100644 --- a/Specs/Core/TransformsSpec.js +++ b/Specs/Core/TransformsSpec.js @@ -232,11 +232,11 @@ defineSuite([ it('throws if the date parameter is not specified', function() { expect(function() { Transforms.computeIcrfToFixedMatrix(undefined); - }).toThrow(); + }).toThrowDeveloperError(); expect(function() { Transforms.computeFixedToIcrfMatrix(undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('works with data from STK Components', function() { @@ -571,36 +571,36 @@ defineSuite([ it('eastNorthUpToFixedFrame throws without an origin', function() { expect(function() { Transforms.eastNorthUpToFixedFrame(undefined, Ellipsoid.WGS84); - }).toThrow(); + }).toThrowDeveloperError(); }); it('northEastDownToFixedFrame throws without an origin', function() { expect(function() { Transforms.northEastDownToFixedFrame(undefined, Ellipsoid.WGS84); - }).toThrow(); + }).toThrowDeveloperError(); }); it('computeTemeToPseudoFixedMatrix throws without a date', function() { expect(function() { Transforms.computeTemeToPseudoFixedMatrix(undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('pointToWindowCoordinates throws without modelViewProjectionMatrix', function() { expect(function() { Transforms.pointToWindowCoordinates(undefined, Matrix4.IDENTITY, Cartesian3.ZERO); - }).toThrow(); + }).toThrowDeveloperError(); }); it('pointToWindowCoordinates throws without viewportTransformation', function() { expect(function() { Transforms.pointToWindowCoordinates(Matrix4.IDENTITY, undefined, Cartesian3.ZERO); - }).toThrow(); + }).toThrowDeveloperError(); }); it('pointToWindowCoordinates throws without a point', function() { expect(function() { Transforms.pointToWindowCoordinates(Matrix4.IDENTITY, Matrix4.IDENTITY, undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); }); diff --git a/Specs/Core/buildModuleUrlSpec.js b/Specs/Core/buildModuleUrlSpec.js index 21c659503fd4..465f9e69f7fc 100644 --- a/Specs/Core/buildModuleUrlSpec.js +++ b/Specs/Core/buildModuleUrlSpec.js @@ -11,9 +11,9 @@ defineSuite([ /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn,runs,waits,waitsFor*/ it('produces an absolute URL for a module', function() { - var url = buildModuleUrl('Core/buildModuleUrl.js'); + var url = buildModuleUrl('Workers/taskDispatcher.js'); - expect(url).toMatch(/Core\/buildModuleUrl.js$/); + expect(url).toMatch(/Workers\/taskDispatcher.js$/); expect(new Uri(url).isAbsolute()).toBe(true); // make sure it actually exists at that URL diff --git a/Specs/Renderer/BufferSpec.js b/Specs/Renderer/BufferSpec.js index efa423363081..3b46a209776e 100644 --- a/Specs/Renderer/BufferSpec.js +++ b/Specs/Renderer/BufferSpec.js @@ -64,7 +64,7 @@ defineSuite([ it('only allows typed array or size when creating a vertex buffer', function() { expect(function() { buffer = context.createVertexBuffer({}, BufferUsage.STATIC_DRAW); - }).toThrow(); + }).toThrowDeveloperError(); }); it('creates index buffer', function() { @@ -105,7 +105,7 @@ defineSuite([ it('only allows typed array or size when creating a vertex buffer', function() { expect(function() { buffer = context.createIndexBuffer({}, BufferUsage.STATIC_DRAW, IndexDatatype.UNSIGNED_SHORT); - }).toThrow(); + }).toThrowDeveloperError(); }); it('destroys', function() { @@ -118,13 +118,13 @@ defineSuite([ it('fails to create', function() { expect(function() { buffer = context.createVertexBuffer(0, BufferUsage.STATIC_DRAW); - }).toThrow(); + }).toThrowDeveloperError(); }); it('fails to create again', function() { expect(function() { buffer = context.createVertexBuffer(4, 0); - }).toThrow(); + }).toThrowDeveloperError(); }); it('fails to provide an array view', function() { diff --git a/Specs/Renderer/ContextSpec.js b/Specs/Renderer/ContextSpec.js index 80818002a54f..cb4c32dbd3be 100644 --- a/Specs/Renderer/ContextSpec.js +++ b/Specs/Renderer/ContextSpec.js @@ -286,7 +286,7 @@ defineSuite([ it('throws when creating a pick ID without an object', function() { expect(function() { context.createPickId(undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('returns undefined when retrieving an object by unknown pick color', function() { @@ -296,13 +296,13 @@ defineSuite([ it('throws when getObjectByPickColor is called without a color', function() { expect(function() { context.getObjectByPickColor(undefined); - }).toThrow(); + }).toThrowDeveloperError(); }); it('fails to construct (null canvas)', function() { expect(function() { return new Context(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('isDestroyed', function() { diff --git a/Specs/Renderer/CubeMapSpec.js b/Specs/Renderer/CubeMapSpec.js index 624ef463d5aa..a1a16802bb15 100644 --- a/Specs/Renderer/CubeMapSpec.js +++ b/Specs/Renderer/CubeMapSpec.js @@ -885,13 +885,13 @@ defineSuite([ it('fails to create (description)', function() { expect(function() { cubeMap = context.createCubeMap(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('fails to create (source)', function() { expect(function() { cubeMap = context.createCubeMap({}); - }).toThrow(); + }).toThrowDeveloperError(); }); it('fails to create (width, no height)', function() { @@ -899,7 +899,7 @@ defineSuite([ cubeMap = context.createCubeMap({ width : 16 }); - }).toThrow(); + }).toThrowDeveloperError(); }); it('fails to create (width != height)', function() { @@ -908,7 +908,7 @@ defineSuite([ width : 16, height : 32 }); - }).toThrow(); + }).toThrowDeveloperError(); }); it('fails to create (small width)', function() { @@ -917,7 +917,7 @@ defineSuite([ width : 0, height : 0 }); - }).toThrow(); + }).toThrowDeveloperError(); }); it('fails to create (large width)', function() { @@ -926,7 +926,7 @@ defineSuite([ width : context.getMaximumCubeMapSize() + 1, height : context.getMaximumCubeMapSize() + 1 }); - }).toThrow(); + }).toThrowDeveloperError(); }); it('fails to create (PixelFormat)', function() { @@ -936,7 +936,7 @@ defineSuite([ height : 16, pixelFormat : 'invalid PixelFormat' }); - }).toThrow(); + }).toThrowDeveloperError(); }); it('throws during creation if pixel format is depth or depth-stencil', function() { @@ -946,7 +946,7 @@ defineSuite([ height : 16, pixelFormat : PixelFormat.DEPTH_COMPONENT }); - }).toThrow(); + }).toThrowDeveloperError(); }); it('throws during creation if pixelDatatype is FLOAT, and OES_texture_float is not supported', function() { @@ -969,7 +969,7 @@ defineSuite([ pixelFormat : PixelFormat.RGBA, pixelDatatype : 'invalid pixelDatatype' }); - }).toThrow(); + }).toThrowDeveloperError(); }); it('fails to create (source)', function() { @@ -977,7 +977,7 @@ defineSuite([ cubeMap = context.createCubeMap({ source : {} }); - }).toThrow(); + }).toThrowDeveloperError(); }); it('fails to create (source width and height)', function() { @@ -992,7 +992,7 @@ defineSuite([ negativeZ : blueOverRedImage // 1x2 } }); - }).toThrow(); + }).toThrowDeveloperError(); }); it('fails to copy from an image (source)', function() { diff --git a/Specs/Renderer/FramebufferSpec.js b/Specs/Renderer/FramebufferSpec.js index 1c1414ab9c3b..a7019f377720 100644 --- a/Specs/Renderer/FramebufferSpec.js +++ b/Specs/Renderer/FramebufferSpec.js @@ -563,7 +563,7 @@ defineSuite([ } }) }); - }).toThrow(); + }).toThrowDeveloperError(); }); it('fails to destroy', function() { diff --git a/Specs/Renderer/RenderbufferSpec.js b/Specs/Renderer/RenderbufferSpec.js index e93c5077b1db..cdcd30297997 100644 --- a/Specs/Renderer/RenderbufferSpec.js +++ b/Specs/Renderer/RenderbufferSpec.js @@ -57,7 +57,7 @@ defineSuite([ renderbuffer = context.createRenderbuffer({ format : 'invalid format' }); - }).toThrow(); + }).toThrowDeveloperError(); }); it('fails to create (small width)', function() { @@ -65,7 +65,7 @@ defineSuite([ renderbuffer = context.createRenderbuffer({ width : 0 }); - }).toThrow(); + }).toThrowDeveloperError(); }); it('fails to create (large width)', function() { @@ -73,7 +73,7 @@ defineSuite([ renderbuffer = context.createRenderbuffer({ width : context.getMaximumRenderbufferSize() + 1 }); - }).toThrow(); + }).toThrowDeveloperError(); }); it('fails to create (small height)', function() { @@ -81,7 +81,7 @@ defineSuite([ renderbuffer = context.createRenderbuffer({ height : 0 }); - }).toThrow(); + }).toThrowDeveloperError(); }); it('fails to create (large height)', function() { @@ -89,7 +89,7 @@ defineSuite([ renderbuffer = context.createRenderbuffer({ height : context.getMaximumRenderbufferSize() + 1 }); - }).toThrow(); + }).toThrowDeveloperError(); }); it('fails to destroy', function() { diff --git a/Specs/Renderer/SamplerSpec.js b/Specs/Renderer/SamplerSpec.js index 2bac555594a4..269e72385bda 100644 --- a/Specs/Renderer/SamplerSpec.js +++ b/Specs/Renderer/SamplerSpec.js @@ -23,7 +23,7 @@ defineSuite([ context.createSampler({ wrapS : 'invalid wrap' }); - }).toThrow(); + }).toThrowDeveloperError(); }); it('throws when creating a sampler with invalid wrapT', function() { @@ -31,7 +31,7 @@ defineSuite([ context.createSampler({ wrapT : 'invalid wrap' }); - }).toThrow(); + }).toThrowDeveloperError(); }); it('throws when creating a sampler with invalid minificationFilter', function() { @@ -39,7 +39,7 @@ defineSuite([ context.createSampler({ minificationFilter : 'invalid filter' }); - }).toThrow(); + }).toThrowDeveloperError(); }); it('throws when creating a sampler with invalid magnificationFilter', function() { @@ -47,7 +47,7 @@ defineSuite([ context.createSampler({ magnificationFilter : 'invalid filter' }); - }).toThrow(); + }).toThrowDeveloperError(); }); it('throws when creating a sampler with invalid maximumAnisotropy', function() { @@ -55,7 +55,7 @@ defineSuite([ context.createSampler({ maximumAnisotropy : 0.0 }); - }).toThrow(); + }).toThrowDeveloperError(); }); }, 'WebGL'); diff --git a/Specs/Renderer/TextureSpec.js b/Specs/Renderer/TextureSpec.js index 160352dbb6eb..ed4e58deb335 100644 --- a/Specs/Renderer/TextureSpec.js +++ b/Specs/Renderer/TextureSpec.js @@ -439,13 +439,13 @@ defineSuite([ it('throws when creating a texture without a description', function() { expect(function() { texture = context.createTexture2D(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('throws when creating a texture without a source', function() { expect(function() { texture = context.createTexture2D({}); - }).toThrow(); + }).toThrowDeveloperError(); }); it('throws when creating a texture with width and no height', function() { @@ -453,7 +453,7 @@ defineSuite([ texture = context.createTexture2D({ width : 16 }); - }).toThrow(); + }).toThrowDeveloperError(); }); it('throws when creating a texture with height and no width', function() { @@ -461,7 +461,7 @@ defineSuite([ texture = context.createTexture2D({ height : 16 }); - }).toThrow(); + }).toThrowDeveloperError(); }); it('throws when creating a texture with zero width', function() { @@ -470,7 +470,7 @@ defineSuite([ width : 0, height : 16 }); - }).toThrow(); + }).toThrowDeveloperError(); }); it('throws when creating a texture with width larger than the maximum texture size', function() { @@ -479,7 +479,7 @@ defineSuite([ width : context.getMaximumTextureSize() + 1, height : 16 }); - }).toThrow(); + }).toThrowDeveloperError(); }); it('throws when creating a texture with zero height', function() { @@ -488,7 +488,7 @@ defineSuite([ width : 16, height : 0 }); - }).toThrow(); + }).toThrowDeveloperError(); }); it('throws when creating a texture with height larger than the maximum texture size', function() { @@ -497,7 +497,7 @@ defineSuite([ width : 16, height : context.getMaximumTextureSize() + 1 }); - }).toThrow(); + }).toThrowDeveloperError(); }); it('throws when creating a texture with an invalid pixel format', function() { @@ -506,7 +506,7 @@ defineSuite([ source : blueImage, pixelFormat : 'invalid PixelFormat' }); - }).toThrow(); + }).toThrowDeveloperError(); }); it('throws when creating a texture with an invalid pixel datatype', function() { @@ -516,7 +516,7 @@ defineSuite([ pixelFormat : PixelFormat.RGBA, pixelDatatype : 'invalid pixelDatatype' }); - }).toThrow(); + }).toThrowDeveloperError(); }); it('throws when creating if pixelFormat is DEPTH_COMPONENT and pixelDatatype is not UNSIGNED_SHORT or UNSIGNED_INT', function() { @@ -525,7 +525,7 @@ defineSuite([ pixelFormat : PixelFormat.DEPTH_COMPONENT, pixelDatatype : PixelDatatype.UNSIGNED_BYTE }); - }).toThrow(); + }).toThrowDeveloperError(); }); it('throws when creating if pixelFormat is DEPTH_STENCIL and pixelDatatype is not UNSIGNED_INT_24_8_WEBGL', function() { @@ -534,7 +534,7 @@ defineSuite([ pixelFormat : PixelFormat.DEPTH_STENCIL, pixelDatatype : PixelDatatype.UNSIGNED_BYTE }); - }).toThrow(); + }).toThrowDeveloperError(); }); it('throws when creating if pixelFormat is DEPTH_COMPONENT or DEPTH_STENCIL, and source is provided', function() { @@ -544,7 +544,7 @@ defineSuite([ pixelFormat : PixelFormat.DEPTH_COMPONENT, pixelDatatype : PixelDatatype.UNSIGNED_SHORT }); - }).toThrow(); + }).toThrowDeveloperError(); }); it('throws when creating if pixelFormat is DEPTH_COMPONENT or DEPTH_STENCIL, and WEBGL_depth_texture is not supported', function() { @@ -576,37 +576,37 @@ defineSuite([ it('throws when creating from the framebuffer with an invalid pixel format', function() { expect(function() { texture = context.createTexture2DFromFramebuffer('invalid PixelFormat'); - }).toThrow(); + }).toThrowDeveloperError(); }); it('throws when creating from the framebuffer if PixelFormat is DEPTH_COMPONENT or DEPTH_STENCIL', function() { expect(function() { texture = context.createTexture2DFromFramebuffer(PixelFormat.DEPTH_COMPONENT); - }).toThrow(); + }).toThrowDeveloperError(); }); it('throws when creating from the framebuffer with a negative framebufferXOffset', function() { expect(function() { texture = context.createTexture2DFromFramebuffer(PixelFormat.RGB, -1); - }).toThrow(); + }).toThrowDeveloperError(); }); it('throws when creating from the framebuffer with a negative framebufferYOffset', function() { expect(function() { texture = context.createTexture2DFromFramebuffer(PixelFormat.RGB, 0, -1); - }).toThrow(); + }).toThrowDeveloperError(); }); it('throws when creating from the framebuffer with a width greater than the canvas clientWidth', function() { expect(function() { texture = context.createTexture2DFromFramebuffer(PixelFormat.RGB, 0, 0, context.getCanvas().clientWidth + 1); - }).toThrow(); + }).toThrowDeveloperError(); }); it('throws when creating from the framebuffer with a height greater than the canvas clientHeight', function() { expect(function() { texture = context.createTexture2DFromFramebuffer(PixelFormat.RGB, 0, 0, 1, context.getCanvas().clientHeight + 1); - }).toThrow(); + }).toThrowDeveloperError(); }); it('throws when copying to a texture from the framebuffer with a DEPTH_COMPONENT or DEPTH_STENCIL pixel format', function() { diff --git a/Specs/Scene/PerspectiveFrustumSpec.js b/Specs/Scene/PerspectiveFrustumSpec.js index 640f4f108fa1..6aac587e7775 100644 --- a/Specs/Scene/PerspectiveFrustumSpec.js +++ b/Specs/Scene/PerspectiveFrustumSpec.js @@ -31,51 +31,51 @@ defineSuite([ frustum.fovy = -1.0; expect(function() { return frustum.projectionMatrix; - }).toThrow(); + }).toThrowDeveloperError(); frustum.fovy = CesiumMath.TWO_PI; expect(function() { return frustum.projectionMatrix; - }).toThrow(); + }).toThrowDeveloperError(); }); it('negative aspect ratio throws an exception', function() { frustum.aspectRatio = -1.0; expect(function() { return frustum.projectionMatrix; - }).toThrow(); + }).toThrowDeveloperError(); }); it('out of range near plane throws an exception', function() { frustum.near = -1.0; expect(function() { return frustum.projectionMatrix; - }).toThrow(); + }).toThrowDeveloperError(); }); it('negative far plane throws an exception', function() { frustum.far = -1.0; expect(function() { return frustum.projectionMatrix; - }).toThrow(); + }).toThrowDeveloperError(); }); it('computeCullingVolume with no position throws an exception', function() { expect(function() { return frustum.computeCullingVolume(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('computeCullingVolume with no direction throws an exception', function() { expect(function() { return frustum.computeCullingVolume(new Cartesian3()); - }).toThrow(); + }).toThrowDeveloperError(); }); it('computeCullingVolume with no up throws an exception', function() { expect(function() { return frustum.computeCullingVolume(new Cartesian3(), new Cartesian3()); - }).toThrow(); + }).toThrowDeveloperError(); }); it('get frustum left plane', function() { @@ -134,7 +134,7 @@ defineSuite([ it('get pixel size throws without canvas dimensions', function() { expect(function() { return frustum.getPixelSize(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('get pixel size', function() { @@ -165,7 +165,7 @@ defineSuite([ var frustum = new PerspectiveFrustum(); expect(function() { return frustum.infiniteProjectionMatrix; - }).toThrow(); + }).toThrowDeveloperError(); }); it('clone', function() { diff --git a/Specs/Scene/PerspectiveOffCenterFrustumSpec.js b/Specs/Scene/PerspectiveOffCenterFrustumSpec.js index a46fdacd23ec..d2fa7e155d46 100644 --- a/Specs/Scene/PerspectiveOffCenterFrustumSpec.js +++ b/Specs/Scene/PerspectiveOffCenterFrustumSpec.js @@ -33,32 +33,32 @@ defineSuite([ frustum.near = -1.0; expect(function() { return frustum.projectionMatrix; - }).toThrow(); + }).toThrowDeveloperError(); }); it('negative far plane throws an exception', function() { frustum.far = -1.0; expect(function() { return frustum.projectionMatrix; - }).toThrow(); + }).toThrowDeveloperError(); }); it('computeCullingVolume with no position throws an exception', function() { expect(function() { return frustum.computeCullingVolume(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('computeCullingVolume with no direction throws an exception', function() { expect(function() { return frustum.computeCullingVolume(new Cartesian3()); - }).toThrow(); + }).toThrowDeveloperError(); }); it('computeCullingVolume with no up throws an exception', function() { expect(function() { return frustum.computeCullingVolume(new Cartesian3(), new Cartesian3()); - }).toThrow(); + }).toThrowDeveloperError(); }); it('get frustum left plane', function() { @@ -129,19 +129,19 @@ defineSuite([ it('get pixel size throws without canvas dimensions', function() { expect(function() { return frustum.getPixelSize(); - }).toThrow(); + }).toThrowDeveloperError(); }); it('get pixel size throws without canvas width less than or equal to zero', function() { expect(function() { return frustum.getPixelSize(new Cartesian2(0.0, 1.0)); - }).toThrow(); + }).toThrowDeveloperError(); }); it('get pixel size throws without canvas height less than or equal to zero', function() { expect(function() { return frustum.getPixelSize(new Cartesian2(1.0, 0.0)); - }).toThrow(); + }).toThrowDeveloperError(); }); it('get pixel size', function() { @@ -169,7 +169,7 @@ defineSuite([ var frustum = new PerspectiveOffCenterFrustum(); expect(function() { return frustum.infiniteProjectionMatrix; - }).toThrow(); + }).toThrowDeveloperError(); }); it('clone', function() { diff --git a/Specs/SpecRunner.js b/Specs/SpecRunner.js index b99c9ce3974a..246d153904ff 100644 --- a/Specs/SpecRunner.js +++ b/Specs/SpecRunner.js @@ -176,16 +176,50 @@ var afterAll; var readyToCreateTests = false; var createTests; + var built = getQueryParameter('built'); + var release = getQueryParameter('release'); + var loadTests = true; + require.config({ - baseUrl : getQueryParameter('baseUrl') || '../Source', - paths : { - 'Specs' : '../Specs' - }, waitSeconds : 30 }); - //start loading all of Cesium early, so it's all available for code coverage calculations. - require(['Cesium']); + // set up require for AMD, combined or minified and + // start loading all of Cesium early, so it's all available for code coverage calculations. + if (built) { + require.config({ + baseUrl : getQueryParameter('baseUrl') || '../Build/Cesium', + paths : { + 'Stubs' : '../Stubs' + }, + shim : { + 'Cesium' : { + exports : 'Cesium' + } + } + }); + + require(['Cesium', 'Stubs/paths'], function(BuiltCesium, paths) { + paths.Specs = '../../Specs'; + + require.config({ + paths : paths + }); + + requireTests(); + }); + + loadTests = false; + } else { + require.config({ + baseUrl : getQueryParameter('baseUrl') || '../Source', + paths : { + 'Specs' : '../Specs' + } + }); + + require(['Cesium']); + } function allTestsReady() { return tests.every(function(test) { @@ -243,39 +277,45 @@ var afterAll; xdefineSuite = function(deps, name, suite, categories) { }; - //specs is an array defined by SpecList.js - require([ - 'Specs/addDefaultMatchers', - 'Specs/equalsMethodEqualityTester' - ].concat(specs), function( - addDefaultMatchers, - equalsMethodEqualityTester) { - var env = jasmine.getEnv(); - - env.beforeEach(addDefaultMatchers); - env.addEqualityTester(equalsMethodEqualityTester); - - createTests = function() { - var reporter = new jasmine.HtmlReporter(); - var isSuiteFocused = jasmine.HtmlReporterHelpers.isSuiteFocused; - var suites = jasmine.getEnv().currentRunner().suites(); - - for ( var i = 1, insertPoint = 0, len = suites.length; i < len; i++) { - var suite = suites[i]; - if (isSuiteFocused(suite)) { - suites.splice(i, 1); - suites.splice(insertPoint, 0, suite); - insertPoint++; - i--; + function requireTests() { + //specs is an array defined by SpecList.js + require([ + 'Specs/addDefaultMatchers', + 'Specs/equalsMethodEqualityTester' + ].concat(specs), function( + addDefaultMatchers, + equalsMethodEqualityTester) { + var env = jasmine.getEnv(); + + env.beforeEach(addDefaultMatchers(!release)); + env.addEqualityTester(equalsMethodEqualityTester); + + createTests = function() { + var reporter = new jasmine.HtmlReporter(); + var isSuiteFocused = jasmine.HtmlReporterHelpers.isSuiteFocused; + var suites = jasmine.getEnv().currentRunner().suites(); + + for ( var i = 1, insertPoint = 0, len = suites.length; i < len; i++) { + var suite = suites[i]; + if (isSuiteFocused(suite)) { + suites.splice(i, 1); + suites.splice(insertPoint, 0, suite); + insertPoint++; + i--; + } } - } - env.addReporter(reporter); - env.specFilter = reporter.specFilter; - env.execute(); - }; + env.addReporter(reporter); + env.specFilter = reporter.specFilter; + env.execute(); + }; - readyToCreateTests = true; - createTestsIfReady(); - }); + readyToCreateTests = true; + createTestsIfReady(); + }); + } + + if (loadTests) { + requireTests(); + } }()); \ No newline at end of file diff --git a/Specs/addDefaultMatchers.js b/Specs/addDefaultMatchers.js index 2ad3029ec168..a54706086f67 100644 --- a/Specs/addDefaultMatchers.js +++ b/Specs/addDefaultMatchers.js @@ -1,9 +1,11 @@ /*global define*/ define([ 'Core/defined', + 'Core/DeveloperError', './equals' ], function( defined, + DeveloperError, equals) { "use strict"; @@ -13,93 +15,137 @@ define([ }; } - var defaultMatchers = { - toBeGreaterThanOrEqualTo : function(value, epsilon) { - return this.actual >= value; - }, - - toBeLessThanOrEqualTo : function(value, epsilon) { - return this.actual <= value; - }, - - toBeBetween : function(lower, upper) { - if (lower > upper) { - var tmp = upper; - upper = lower; - lower = tmp; - } - return this.actual >= lower && this.actual <= upper; - }, - - toEqual : function(expected) { - return equals(this.env, this.actual, expected); - }, - - toEqualEpsilon : function(expected, epsilon) { - function equalityTester(a, b) { - var to_run; - if (defined(a)) { - if (typeof a.equalsEpsilon === 'function') { - return a.equalsEpsilon(b, epsilon); - } else if(a instanceof Object) { - // Check if the current object has a static function named 'equalsEpsilon' - to_run = Object.getPrototypeOf(a).constructor.equalsEpsilon; - if( typeof to_run === 'function') { - return to_run(a, b, epsilon); + function createDefaultMatchers(debug) { + return { + toBeGreaterThanOrEqualTo : function(value, epsilon) { + return this.actual >= value; + }, + + toBeLessThanOrEqualTo : function(value, epsilon) { + return this.actual <= value; + }, + + toBeBetween : function(lower, upper) { + if (lower > upper) { + var tmp = upper; + upper = lower; + lower = tmp; + } + return this.actual >= lower && this.actual <= upper; + }, + + toEqual : function(expected) { + return equals(this.env, this.actual, expected); + }, + + toEqualEpsilon : function(expected, epsilon) { + function equalityTester(a, b) { + var to_run; + if (defined(a)) { + if (typeof a.equalsEpsilon === 'function') { + return a.equalsEpsilon(b, epsilon); + } else if(a instanceof Object) { + // Check if the current object has a static function named 'equalsEpsilon' + to_run = Object.getPrototypeOf(a).constructor.equalsEpsilon; + if( typeof to_run === 'function') { + return to_run(a, b, epsilon); + } } } - } - - if (defined(b)) { - if (typeof b.equalsEpsilon === 'function') { - return b.equalsEpsilon(a, epsilon); - } else if(b instanceof Object) { - // Check if the current object has a static function named 'equalsEpsilon' - to_run = Object.getPrototypeOf(b).constructor.equalsEpsilon; - if( typeof to_run === 'function') { - return to_run(b, a, epsilon); + + if (defined(b)) { + if (typeof b.equalsEpsilon === 'function') { + return b.equalsEpsilon(a, epsilon); + } else if(b instanceof Object) { + // Check if the current object has a static function named 'equalsEpsilon' + to_run = Object.getPrototypeOf(b).constructor.equalsEpsilon; + if( typeof to_run === 'function') { + return to_run(b, a, epsilon); + } } } + + if (typeof a === 'number' || typeof b === 'number') { + return Math.abs(a - b) <= epsilon; + } + + return undefined; } - if (typeof a === 'number' || typeof b === 'number') { - return Math.abs(a - b) <= epsilon; + var origTesters = this.env.equalityTesters_; + this.env.equalityTesters_ = [equalityTester]; + + var result = equals(this.env, this.actual, expected); + + this.env.equalityTesters_ = origTesters; + + return result; + }, + + toConformToInterface : function(expectedInterface) { + // All function properties on the prototype should also exist on the actual's prototype. + var actualPrototype = this.actual.prototype; + var expectedInterfacePrototype = expectedInterface.prototype; + + for ( var item in expectedInterfacePrototype) { + if (expectedInterfacePrototype.hasOwnProperty(item) && typeof expectedInterfacePrototype[item] === 'function' && !actualPrototype.hasOwnProperty(item)) { + this.message = createMissingFunctionMessageFunction(item, actualPrototype, expectedInterfacePrototype); + return false; + } } - return undefined; - } + return true; + }, - var origTesters = this.env.equalityTesters_; - this.env.equalityTesters_ = [equalityTester]; + toBeInstanceOf : function(expectedConstructor) { + return this.actual instanceof expectedConstructor; + }, - var result = equals(this.env, this.actual, expected); + toThrowDeveloperError : (function() { + if (debug) { + return function(expected) { + // based on the built-in Jasmine toThrow matcher + var result = false; + var exception; - this.env.equalityTesters_ = origTesters; + if (typeof this.actual !== 'function') { + throw new Error('Actual is not a function'); + } - return result; - }, + try { + this.actual(); + } catch (e) { + exception = e; + } - toConformToInterface : function(expectedInterface) { - // All function properties on the prototype should also exist on the actual's prototype. - var actualPrototype = this.actual.prototype; - var expectedInterfacePrototype = expectedInterface.prototype; + if (exception) { + result = exception instanceof DeveloperError; + } - for ( var item in expectedInterfacePrototype) { - if (expectedInterfacePrototype.hasOwnProperty(item) && typeof expectedInterfacePrototype[item] === 'function' && !actualPrototype.hasOwnProperty(item)) { - this.message = createMissingFunctionMessageFunction(item, actualPrototype, expectedInterfacePrototype); - return false; - } - } + var not = this.isNot ? "not " : ""; - return true; - }, + this.message = function() { + if (result) { + return ["Expected function " + not + "to throw DeveloperError, but it threw", exception.message || exception].join(' '); + } else { + return "Expected function to throw DeveloperError."; + } + }; - toBeInstanceOf : function(expectedConstructor) { - return this.actual instanceof expectedConstructor; - } - }; + return result; + }; + } - return function() { - this.addMatchers(defaultMatchers); + return function() { + return true; + }; + }()) + }; + } + + return function(debug) { + return function() { + this.addMatchers(createDefaultMatchers(debug)); + }; }; }); diff --git a/ThirdParty/jasmine-1.3.1/jasmine-html.js b/ThirdParty/jasmine-1.3.1/jasmine-html.js index 469b79775041..0808373bad2b 100644 --- a/ThirdParty/jasmine-1.3.1/jasmine-html.js +++ b/ThirdParty/jasmine-1.3.1/jasmine-html.js @@ -1,3 +1,12 @@ +function getQueryParameter(name) { + var match = new RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search); + + if (match) { + return decodeURIComponent(match[1].replace(/\+/g, ' ')); + } + return null; +} + jasmine.HtmlReporterHelpers = {}; jasmine.HtmlReporterHelpers.createDom = function(type, attrs, childrenVarArgs) { @@ -175,6 +184,14 @@ jasmine.HtmlReporter = function(_doc) { doc.body.appendChild(dom.reporter); setExceptionHandling(); + var params = ''; + if (getQueryParameter('built')) { + params += '&built=true'; + } + if (getQueryParameter('release')) { + params += '&release=true'; + } + var runButton = document.getElementById('runButton'); runButton.onclick = function() { if (document.getElementById('no_try_catch').checked) { @@ -184,10 +201,10 @@ jasmine.HtmlReporter = function(_doc) { var select = document.getElementById('categorySelect'); if (document.getElementById('categoryException').checked) { - top.location.href = '?category=All¬=' + encodeURIComponent(select.options[select.selectedIndex].value); + top.location.href = '?category=All¬=' + encodeURIComponent(select.options[select.selectedIndex].value) + params; return false; } - top.location.href = '?category=' + encodeURIComponent(select.options[select.selectedIndex].value); + top.location.href = '?category=' + encodeURIComponent(select.options[select.selectedIndex].value) + params; return false; } @@ -198,10 +215,10 @@ jasmine.HtmlReporter = function(_doc) { var select = document.getElementById('categorySelect'); if (document.getElementById('categoryException').checked) { - top.location.href = baseInstrumentUrl + window.encodeURIComponent('&category=All¬=' + select.options[select.selectedIndex].value); + top.location.href = baseInstrumentUrl + window.encodeURIComponent('&category=All¬=' + select.options[select.selectedIndex].value) + params; return false; } - top.location.href = baseInstrumentUrl + window.encodeURIComponent('&category=' + select.options[select.selectedIndex].value); + top.location.href = baseInstrumentUrl + window.encodeURIComponent('&category=' + select.options[select.selectedIndex].value) + params; return false; } @@ -444,6 +461,12 @@ jasmine.HtmlReporter.sectionLink = function(sectionName) { if (!jasmine.CATCH_EXCEPTIONS) { params.push("catch=false"); } + if (getQueryParameter('built')) { + params.push('built=true'); + } + if (getQueryParameter('release')) { + params.push('release=true'); + } if (params.length > 0) { link += params.join("&"); } @@ -589,11 +612,19 @@ jasmine.HtmlReporter.ReporterView = function(dom) { specView.summary.className += " specSkipped"; } + var params = ''; + if (getQueryParameter('built')) { + params += '&built=true'; + } + if (getQueryParameter('release')) { + params += '&release=true'; + } + specView.summary.appendChild(this.createDom('span', {className: 'specTime'}, - this.createDom('a', {className: 'run_spec', href: '?spec=' + name, target: '_top'}, 'run'), + this.createDom('a', {className: 'run_spec', href: '?spec=' + name + params, target: '_top'}, 'run'), this.createDom('a', {className: 'run_spec', href: '../Instrumented/jscoverage.html?../Specs/SpecRunner.html' + - window.encodeURIComponent('?baseUrl=../Instrumented&spec=' + name), target: '_top' }, "coverage"), - this.createDom('a', {className: 'run_spec', href: '?spec=' + name + '&debug=' + name, target: '_top'}, 'debug'), + window.encodeURIComponent('?baseUrl=../Instrumented&spec=' + name) + params, target: '_top' }, "coverage"), + this.createDom('a', {className: 'run_spec', href: '?spec=' + name + '&debug=' + name + params, target: '_top'}, 'debug'), runTime)); switch (status) { @@ -631,11 +662,19 @@ jasmine.HtmlReporter.ReporterView = function(dom) { runTime = ' (' + (suite.runTime / 1000) + 's)'; } + var params = ''; + if (getQueryParameter('built')) { + params += '&built=true'; + } + if (getQueryParameter('release')) { + params += '&release=true'; + } + var name = encodeURIComponent(suite.getFullName()); suiteView.element.insertBefore(this.createDom('span', {className: 'suiteTime'}, - this.createDom('a', {className: 'run_spec', href: '?spec=' + name, target: '_top'}, 'run'), + this.createDom('a', {className: 'run_spec', href: '?spec=' + name + params, target: '_top'}, 'run'), this.createDom('a', {className: 'run_spec', href: '../Instrumented/jscoverage.html?../Specs/SpecRunner.html' + - window.encodeURIComponent('?baseUrl=../Instrumented&spec=' + name), target: '_top' }, "coverage"), + window.encodeURIComponent('?baseUrl=../Instrumented&spec=' + name) + params, target: '_top' }, "coverage"), runTime), suiteView.element.getElementsByTagName('a')[2].nextSibling); if (suite.beforeSpec_ && !suite.beforeSpec_.results().passed()) { diff --git a/Tools/build.js b/Tools/build.js index 3de84b2c1b1e..81ddd043af6e 100644 --- a/Tools/build.js +++ b/Tools/build.js @@ -1,5 +1,8 @@ ({ wrap : true, useStrict : true, - optimizeCss : 'standard' + optimizeCss : 'standard', + pragmas : { + debug : true + } }) \ No newline at end of file diff --git a/Tools/buildTasks/createCesiumJs.js b/Tools/buildTasks/createCesiumJs.js index c9f78822494d..e6247d1566e8 100644 --- a/Tools/buildTasks/createCesiumJs.js +++ b/Tools/buildTasks/createCesiumJs.js @@ -19,22 +19,23 @@ forEachFile('sourcefiles', function(relativePath, file) { var baseName = file.getName(); var assignmentName = baseName.substring(0, baseName.lastIndexOf('.')); - assignmentName = String(assignmentName).replace(nonIdentifierRegexp, '_'); + assignmentName = "['" + String(assignmentName) + "']"; if (/Shaders\//.test(moduleId)) { - assignmentName = '_shaders.' + assignmentName; + assignmentName = '._shaders' + assignmentName; } var parameterName = String(moduleId).replace(nonIdentifierRegexp, '_'); moduleIds.push("'./" + moduleId + "'"); parameters.push(parameterName); - assignments.push('Cesium.' + assignmentName + ' = ' + parameterName + ';'); + assignments.push('Cesium' + assignmentName + ' = ' + parameterName + ';'); }); var contents = '\ /*global define*/\n\ define([' + moduleIds.join(', ') + '], function(' + parameters.join(', ') + ') {\n\ "use strict";\n\ + /*jshint sub:true*/\n\ var Cesium = {\n\ _shaders : {}\n\ };\n\ diff --git a/Tools/buildTasks/generateStubs.js b/Tools/buildTasks/generateStubs.js new file mode 100644 index 000000000000..629b92f44008 --- /dev/null +++ b/Tools/buildTasks/generateStubs.js @@ -0,0 +1,44 @@ +/*global importClass,project,attributes,elements,java,Packages*/ +importClass(Packages.org.mozilla.javascript.tools.shell.Main); /*global Main*/ +Main.exec(['-e', '{}']); +var load = Main.global.load; + +load(project.getProperty('tasksDirectory') + '/shared.js'); /*global forEachFile,readFileContents,writeFileContents,File,FileReader,FileWriter,FileUtils*/ + +var contents = '\ +/*global define,Cesium*/\n\ +(function() {\n\ +"use strict";\n\ +/*jshint sub:true*/\n'; +var modulePathMappings = []; + +forEachFile('sourcefiles', function(relativePath, file) { + "use strict"; + + var moduleId = relativePath.replace('\\', '/'); + moduleId = moduleId.substring(0, moduleId.lastIndexOf('.')); + + var baseName = file.getName(); + var propertyName = baseName.substring(0, baseName.lastIndexOf('.')); + propertyName = "['" + String(propertyName) + "']"; + + contents += '\ +define(\'' + moduleId + '\', function() {\n\ + return Cesium' + propertyName + ';\n\ +});\n\n'; + + modulePathMappings.push(' \'' + moduleId + '\' : \'../Stubs/Cesium\''); +}); + +contents += '})();'; + +var paths = '\ +/*global define*/\n\ +define(function() {\n\ + "use strict";\ + return {\n' + modulePathMappings.join(',\n') + '\n\ + };\n\ +});'; + +writeFileContents(attributes.get('stuboutput'), contents); +writeFileContents(attributes.get('pathsoutput'), paths); diff --git a/build.xml b/build.xml index cf148dca0207..8b8fd4c1138d 100644 --- a/build.xml +++ b/build.xml @@ -22,7 +22,7 @@ - + @@ -30,8 +30,8 @@ - - + + @@ -41,8 +41,23 @@ + + + + + + + + + + + + - + + + + @@ -57,11 +72,10 @@ - + - - + @@ -70,7 +84,14 @@ - + + + + + + + + @@ -144,6 +165,7 @@ + @@ -151,12 +173,22 @@ - - - - - - + + + + + + + + + + + + + + + + @@ -204,6 +236,12 @@ + + + + + + @@ -287,6 +325,11 @@ + + + + + @@ -312,10 +355,15 @@ + + + + + @@ -326,11 +374,16 @@ + + + + + @@ -345,6 +398,7 @@ + @@ -384,7 +438,16 @@ - + + + + + + + + + + @@ -472,10 +535,6 @@ - - - - @@ -491,6 +550,7 @@ + diff --git a/index.html b/index.html index 7ee518eac032..fd4ee74b437b 100644 --- a/index.html +++ b/index.html @@ -7,7 +7,7 @@ body { font-family: sans-serif; } li { margin-top: 5px; } .outer > li { margin-top: 1.4em; } - .smallFont { font-size: 50%; } + .smallFont { font-size: 60%; } @@ -40,7 +40,8 @@ Tests - + \ No newline at end of file