true
if left and right are equal, false
otherwise.
*/
Credit.prototype.equals = function(credit) {
diff --git a/Source/Core/EllipseGeometry.js b/Source/Core/EllipseGeometry.js
index 59193cf043d3..3faca9185f5d 100644
--- a/Source/Core/EllipseGeometry.js
+++ b/Source/Core/EllipseGeometry.js
@@ -81,12 +81,15 @@ define([
var ellipsoid = options.ellipsoid;
var stRotation = options.stRotation;
var size = (extrude) ? positions.length / 3 * 2 : positions.length / 3;
+ var shadowVolume = options.shadowVolume;
var textureCoordinates = (vertexFormat.st) ? new Float32Array(size * 2) : undefined;
var normals = (vertexFormat.normal) ? new Float32Array(size * 3) : undefined;
var tangents = (vertexFormat.tangent) ? new Float32Array(size * 3) : undefined;
var binormals = (vertexFormat.binormal) ? new Float32Array(size * 3) : undefined;
+ var extrudeNormals = (shadowVolume) ? new Float32Array(size * 3) : undefined;
+
var textureCoordIndex = 0;
// Raise positions to a height above the ellipsoid and compute the
@@ -136,44 +139,52 @@ define([
textureCoordinates[textureCoordIndex++] = texCoordScratch.y;
}
- normal = ellipsoid.geodeticSurfaceNormal(position, normal);
+ if (vertexFormat.normal || vertexFormat.tangent || vertexFormat.binormal || shadowVolume) {
+ normal = ellipsoid.geodeticSurfaceNormal(position, normal);
- if (vertexFormat.normal || vertexFormat.tangent || vertexFormat.binormal) {
- if (vertexFormat.tangent || vertexFormat.binormal) {
- tangent = Cartesian3.normalize(Cartesian3.cross(Cartesian3.UNIT_Z, normal, tangent), tangent);
- Matrix3.multiplyByVector(textureMatrix, tangent, tangent);
+ if (shadowVolume) {
+ extrudeNormals[i + bottomOffset] = -normal.x;
+ extrudeNormals[i1 + bottomOffset] = -normal.y;
+ extrudeNormals[i2 + bottomOffset] = -normal.z;
}
- if (vertexFormat.normal) {
- normals[i] = normal.x;
- normals[i1] = normal.y;
- normals[i2] = normal.z;
- if (extrude) {
- normals[i + bottomOffset] = -normal.x;
- normals[i1 + bottomOffset] = -normal.y;
- normals[i2 + bottomOffset] = -normal.z;
+
+ if (vertexFormat.normal || vertexFormat.tangent || vertexFormat.binormal) {
+ if (vertexFormat.tangent || vertexFormat.binormal) {
+ tangent = Cartesian3.normalize(Cartesian3.cross(Cartesian3.UNIT_Z, normal, tangent), tangent);
+ Matrix3.multiplyByVector(textureMatrix, tangent, tangent);
+ }
+ if (vertexFormat.normal) {
+ normals[i] = normal.x;
+ normals[i1] = normal.y;
+ normals[i2] = normal.z;
+ if (extrude) {
+ normals[i + bottomOffset] = -normal.x;
+ normals[i1 + bottomOffset] = -normal.y;
+ normals[i2 + bottomOffset] = -normal.z;
+ }
}
- }
- if (vertexFormat.tangent) {
- tangents[i] = tangent.x;
- tangents[i1] = tangent.y;
- tangents[i2] = tangent.z;
- if (extrude) {
- tangents[i + bottomOffset] = -tangent.x;
- tangents[i1 + bottomOffset] = -tangent.y;
- tangents[i2 + bottomOffset] = -tangent.z;
+ if (vertexFormat.tangent) {
+ tangents[i] = tangent.x;
+ tangents[i1] = tangent.y;
+ tangents[i2] = tangent.z;
+ if (extrude) {
+ tangents[i + bottomOffset] = -tangent.x;
+ tangents[i1 + bottomOffset] = -tangent.y;
+ tangents[i2 + bottomOffset] = -tangent.z;
+ }
}
- }
- if (vertexFormat.binormal) {
- binormal = Cartesian3.normalize(Cartesian3.cross(normal, tangent, binormal), binormal);
- binormals[i] = binormal.x;
- binormals[i1] = binormal.y;
- binormals[i2] = binormal.z;
- if (extrude) {
- binormals[i + bottomOffset] = binormal.x;
- binormals[i1 + bottomOffset] = binormal.y;
- binormals[i2 + bottomOffset] = binormal.z;
+ if (vertexFormat.binormal) {
+ binormal = Cartesian3.normalize(Cartesian3.cross(normal, tangent, binormal), binormal);
+ binormals[i] = binormal.x;
+ binormals[i1] = binormal.y;
+ binormals[i2] = binormal.z;
+ if (extrude) {
+ binormals[i + bottomOffset] = binormal.x;
+ binormals[i1 + bottomOffset] = binormal.y;
+ binormals[i2 + bottomOffset] = binormal.z;
+ }
}
}
}
@@ -229,6 +240,15 @@ define([
values : binormals
});
}
+
+ if (shadowVolume) {
+ attributes.extrudeDirection = new GeometryAttribute({
+ componentDatatype : ComponentDatatype.FLOAT,
+ componentsPerAttribute : 3,
+ values : extrudeNormals
+ });
+ }
+
return attributes;
}
@@ -371,6 +391,9 @@ define([
var tangents = (vertexFormat.tangent) ? new Float32Array(size * 3) : undefined;
var binormals = (vertexFormat.binormal) ? new Float32Array(size * 3) : undefined;
+ var shadowVolume = options.shadowVolume;
+ var extrudeNormals = (shadowVolume) ? new Float32Array(size * 3) : undefined;
+
var textureCoordIndex = 0;
// Raise positions to a height above the ellipsoid and compute the
@@ -421,6 +444,13 @@ define([
position = ellipsoid.scaleToGeodeticSurface(position, position);
extrudedPosition = Cartesian3.clone(position, scratchCartesian2);
normal = ellipsoid.geodeticSurfaceNormal(position, normal);
+
+ if (shadowVolume) {
+ extrudeNormals[i + length] = -normal.x;
+ extrudeNormals[i1 + length] = -normal.y;
+ extrudeNormals[i2 + length] = -normal.z;
+ }
+
var scaledNormal = Cartesian3.multiplyByScalar(normal, height, scratchCartesian4);
position = Cartesian3.add(position, scaledNormal, position);
scaledNormal = Cartesian3.multiplyByScalar(normal, extrudedHeight, scaledNormal);
@@ -527,6 +557,15 @@ define([
values : binormals
});
}
+
+ if (shadowVolume) {
+ attributes.extrudeDirection = new GeometryAttribute({
+ componentDatatype : ComponentDatatype.FLOAT,
+ componentsPerAttribute : 3,
+ values : extrudeNormals
+ });
+ }
+
return attributes;
}
@@ -724,6 +763,7 @@ define([
this._vertexFormat = VertexFormat.clone(vertexFormat);
this._extrudedHeight = defaultValue(extrudedHeight, height);
this._extrude = extrude;
+ this._shadowVolume = defaultValue(options.shadowVolume, false);
this._workerName = 'createEllipseGeometry';
this._rectangle = computeRectangle(this._center, this._ellipsoid, semiMajorAxis, semiMinorAxis, this._rotation);
@@ -733,7 +773,7 @@ define([
* The number of elements used to pack the object into an array.
* @type {Number}
*/
- EllipseGeometry.packedLength = Cartesian3.packedLength + Ellipsoid.packedLength + VertexFormat.packedLength + Rectangle.packedLength + 8;
+ EllipseGeometry.packedLength = Cartesian3.packedLength + Ellipsoid.packedLength + VertexFormat.packedLength + Rectangle.packedLength + 9;
/**
* Stores the provided instance into the provided array.
@@ -775,7 +815,8 @@ define([
array[startingIndex++] = value._height;
array[startingIndex++] = value._granularity;
array[startingIndex++] = value._extrudedHeight;
- array[startingIndex] = value._extrude ? 1.0 : 0.0;
+ array[startingIndex++] = value._extrude ? 1.0 : 0.0;
+ array[startingIndex] = value._shadowVolume ? 1.0 : 0.0;
return array;
};
@@ -794,7 +835,8 @@ define([
stRotation : undefined,
height : undefined,
granularity : undefined,
- extrudedHeight : undefined
+ extrudedHeight : undefined,
+ shadowVolume: undefined
};
/**
@@ -833,7 +875,8 @@ define([
var height = array[startingIndex++];
var granularity = array[startingIndex++];
var extrudedHeight = array[startingIndex++];
- var extrude = array[startingIndex] === 1.0;
+ var extrude = array[startingIndex++] === 1.0;
+ var shadowVolume = array[startingIndex] === 1.0;
if (!defined(result)) {
scratchOptions.height = height;
@@ -843,6 +886,7 @@ define([
scratchOptions.rotation = rotation;
scratchOptions.semiMajorAxis = semiMajorAxis;
scratchOptions.semiMinorAxis = semiMinorAxis;
+ scratchOptions.shadowVolume = shadowVolume;
return new EllipseGeometry(scratchOptions);
}
@@ -857,6 +901,7 @@ define([
result._granularity = granularity;
result._extrudedHeight = extrudedHeight;
result._extrude = extrude;
+ result._shadowVolume = shadowVolume;
result._rectangle = Rectangle.clone(rectangle);
return result;
@@ -890,6 +935,7 @@ define([
if (ellipseGeometry._extrude) {
options.extrudedHeight = Math.min(ellipseGeometry._extrudedHeight, ellipseGeometry._height);
options.height = Math.max(ellipseGeometry._extrudedHeight, ellipseGeometry._height);
+ options.shadowVolume = ellipseGeometry._shadowVolume;
geometry = computeExtrudedEllipse(options);
} else {
geometry = computeEllipse(options);
@@ -923,7 +969,8 @@ define([
granularity : granularity,
extrudedHeight : minHeight,
height : maxHeight,
- vertexFormat : VertexFormat.POSITION_ONLY
+ vertexFormat : VertexFormat.POSITION_ONLY,
+ shadowVolume: true
});
};
diff --git a/Source/Core/Ellipsoid.js b/Source/Core/Ellipsoid.js
index deca2629e1ae..6f3eba4bcfcb 100644
--- a/Source/Core/Ellipsoid.js
+++ b/Source/Core/Ellipsoid.js
@@ -208,7 +208,9 @@ define([
/**
* Computes an Ellipsoid from a Cartesian specifying the radii in x, y, and z directions.
*
- * @param {Cartesian3} [radii=Cartesian3.ZERO] The ellipsoid's radius in the x, y, and z directions.
+ * @param {Cartesian3} [cartesian=Cartesian3.ZERO] The ellipsoid's radius in the x, y, and z directions.
+ * @param {Ellipsoid} [result] The object onto which to store the result, or undefined if a new
+ * instance should be created.
* @returns {Ellipsoid} A new Ellipsoid instance.
*
* @exception {DeveloperError} All radii components must be greater than or equal to zero.
diff --git a/Source/Core/EllipsoidGeodesic.js b/Source/Core/EllipsoidGeodesic.js
index 8db8aa6ed9b5..4a84a85b7d04 100644
--- a/Source/Core/EllipsoidGeodesic.js
+++ b/Source/Core/EllipsoidGeodesic.js
@@ -337,6 +337,7 @@ define([
* Provides the location of a point at the indicated portion along the geodesic.
*
* @param {Number} fraction The portion of the distance between the initial and final points.
+ * @param {Cartographic} result The object in which to store the result.
* @returns {Cartographic} The location of the point along the geodesic.
*/
EllipsoidGeodesic.prototype.interpolateUsingFraction = function(fraction, result) {
@@ -347,6 +348,7 @@ define([
* Provides the location of a point at the indicated distance along the geodesic.
*
* @param {Number} distance The distance from the inital point to the point of interest along the geodesic
+ * @param {Cartographic} result The object in which to store the result.
* @returns {Cartographic} The location of the point along the geodesic.
*
* @exception {DeveloperError} start and end must be set before calling function interpolateUsingSurfaceDistance
diff --git a/Source/Core/GeometryPipeline.js b/Source/Core/GeometryPipeline.js
index c27a9dda80cd..23bbeb25a91a 100644
--- a/Source/Core/GeometryPipeline.js
+++ b/Source/Core/GeometryPipeline.js
@@ -282,6 +282,9 @@ define([
'binormal',
'tangent',
+ // For shadow volumes
+ 'extrudeDirection',
+
// From compressing texture coordinates and normals
'compressedAttributes'
];
@@ -1343,7 +1346,7 @@ define([
var toEncode1 = new Cartesian3();
var toEncode2 = new Cartesian3();
var toEncode3 = new Cartesian3();
-
+ var encodeResult2 = new Cartesian2();
/**
* Compresses and packs geometry normal attribute values to save memory.
*
@@ -1360,53 +1363,89 @@ define([
}
//>>includeEnd('debug');
+ var extrudeAttribute = geometry.attributes.extrudeDirection;
+ var i;
+ var numVertices;
+ if (defined(extrudeAttribute)) {
+ //only shadow volumes use extrudeDirection, and shadow volumes use vertexFormat: POSITION_ONLY so we don't need to check other attributes
+ var extrudeDirections = extrudeAttribute.values;
+ numVertices = extrudeDirections.length / 3.0;
+ var compressedDirections = new Float32Array(numVertices * 2);
+
+ var i2 = 0;
+ for (i = 0; i < numVertices; ++i) {
+ Cartesian3.fromArray(extrudeDirections, i * 3.0, toEncode1);
+ if (Cartesian3.equals(toEncode1, Cartesian3.ZERO)) {
+ i2 += 2;
+ continue;
+ }
+ encodeResult2 = AttributeCompression.octEncodeInRange(toEncode1, 65535, encodeResult2);
+ compressedDirections[i2++] = encodeResult2.x;
+ compressedDirections[i2++] = encodeResult2.y;
+ }
+
+ geometry.attributes.compressedAttributes = new GeometryAttribute({
+ componentDatatype : ComponentDatatype.FLOAT,
+ componentsPerAttribute : 2,
+ values : compressedDirections
+ });
+ delete geometry.attributes.extrudeDirection;
+ return geometry;
+ }
+
var normalAttribute = geometry.attributes.normal;
var stAttribute = geometry.attributes.st;
- if (!defined(normalAttribute) && !defined(stAttribute)) {
+
+ var hasNormal = defined(normalAttribute);
+ var hasSt = defined(stAttribute);
+ if (!hasNormal && !hasSt) {
return geometry;
}
var tangentAttribute = geometry.attributes.tangent;
var binormalAttribute = geometry.attributes.binormal;
+ var hasTangent = defined(tangentAttribute);
+ var hasBinormal = defined(binormalAttribute);
+
var normals;
var st;
var tangents;
var binormals;
- if (defined(normalAttribute)) {
+ if (hasNormal) {
normals = normalAttribute.values;
}
- if (defined(stAttribute)) {
+ if (hasSt) {
st = stAttribute.values;
}
- if (defined(tangentAttribute)) {
+ if (hasTangent) {
tangents = tangentAttribute.values;
}
- if (binormalAttribute) {
+ if (hasBinormal) {
binormals = binormalAttribute.values;
}
- var length = defined(normals) ? normals.length : st.length;
- var numComponents = defined(normals) ? 3.0 : 2.0;
- var numVertices = length / numComponents;
+ var length = hasNormal ? normals.length : st.length;
+ var numComponents = hasNormal ? 3.0 : 2.0;
+ numVertices = length / numComponents;
var compressedLength = numVertices;
- var numCompressedComponents = defined(st) && defined(normals) ? 2.0 : 1.0;
- numCompressedComponents += defined(tangents) || defined(binormals) ? 1.0 : 0.0;
+ var numCompressedComponents = hasSt && hasNormal ? 2.0 : 1.0;
+ numCompressedComponents += hasTangent || hasBinormal ? 1.0 : 0.0;
compressedLength *= numCompressedComponents;
var compressedAttributes = new Float32Array(compressedLength);
var normalIndex = 0;
- for (var i = 0; i < numVertices; ++i) {
- if (defined(st)) {
+ for (i = 0; i < numVertices; ++i) {
+ if (hasSt) {
Cartesian2.fromArray(st, i * 2.0, scratchCartesian2);
compressedAttributes[normalIndex++] = AttributeCompression.compressTextureCoordinates(scratchCartesian2);
}
var index = i * 3.0;
- if (defined(normals) && defined(tangents) && defined(binormals)) {
+ if (hasNormal && defined(tangents) && defined(binormals)) {
Cartesian3.fromArray(normals, index, toEncode1);
Cartesian3.fromArray(tangents, index, toEncode2);
Cartesian3.fromArray(binormals, index, toEncode3);
@@ -1415,17 +1454,17 @@ define([
compressedAttributes[normalIndex++] = scratchCartesian2.x;
compressedAttributes[normalIndex++] = scratchCartesian2.y;
} else {
- if (defined(normals)) {
+ if (hasNormal) {
Cartesian3.fromArray(normals, index, toEncode1);
compressedAttributes[normalIndex++] = AttributeCompression.octEncodeFloat(toEncode1);
}
- if (defined(tangents)) {
+ if (hasTangent) {
Cartesian3.fromArray(tangents, index, toEncode1);
compressedAttributes[normalIndex++] = AttributeCompression.octEncodeFloat(toEncode1);
}
- if (defined(binormals)) {
+ if (hasBinormal) {
Cartesian3.fromArray(binormals, index, toEncode1);
compressedAttributes[normalIndex++] = AttributeCompression.octEncodeFloat(toEncode1);
}
@@ -1438,16 +1477,16 @@ define([
values : compressedAttributes
});
- if (defined(normals)) {
+ if (hasNormal) {
delete geometry.attributes.normal;
}
- if (defined(st)) {
+ if (hasSt) {
delete geometry.attributes.st;
}
- if (defined(tangents)) {
+ if (hasTangent) {
delete geometry.attributes.tangent;
}
- if (defined(binormals)) {
+ if (hasBinormal) {
delete geometry.attributes.binormal;
}
@@ -1877,8 +1916,8 @@ define([
var s1Scratch = new Cartesian2();
var s2Scratch = new Cartesian2();
- function computeTriangleAttributes(i0, i1, i2, point, positions, normals, binormals, tangents, texCoords, currentAttributes, insertedIndex) {
- if (!defined(normals) && !defined(binormals) && !defined(tangents) && !defined(texCoords)) {
+ function computeTriangleAttributes(i0, i1, i2, point, positions, normals, binormals, tangents, texCoords, extrudeDirections, currentAttributes, insertedIndex) {
+ if (!defined(normals) && !defined(binormals) && !defined(tangents) && !defined(texCoords) && !defined(extrudeDirections)) {
return;
}
@@ -1903,6 +1942,29 @@ define([
Cartesian3.pack(normal, currentAttributes.normal.values, insertedIndex * 3);
}
+ if (defined(extrudeDirections)) {
+ var d0 = Cartesian3.fromArray(extrudeDirections, i0 * 3, p0Scratch);
+ var d1 = Cartesian3.fromArray(extrudeDirections, i1 * 3, p1Scratch);
+ var d2 = Cartesian3.fromArray(extrudeDirections, i2 * 3, p2Scratch);
+
+ Cartesian3.multiplyByScalar(d0, coords.x, d0);
+ Cartesian3.multiplyByScalar(d1, coords.y, d1);
+ Cartesian3.multiplyByScalar(d2, coords.z, d2);
+
+ var direction;
+ if (!Cartesian3.equals(d0, Cartesian3.ZERO) || !Cartesian3.equals(d1, Cartesian3.ZERO) || !Cartesian3.equals(d2, Cartesian3.ZERO)) {
+ direction = Cartesian3.add(d0, d1, d0);
+ Cartesian3.add(direction, d2, direction);
+ Cartesian3.normalize(direction, direction);
+ } else {
+ direction = p0Scratch;
+ direction.x = 0;
+ direction.y = 0;
+ direction.z = 0;
+ }
+ Cartesian3.pack(direction, currentAttributes.extrudeDirection.values, insertedIndex * 3);
+ }
+
if (defined(binormals)) {
var b0 = Cartesian3.fromArray(binormals, i0 * 3, p0Scratch);
var b1 = Cartesian3.fromArray(binormals, i1 * 3, p1Scratch);
@@ -1982,6 +2044,7 @@ define([
var binormals = (defined(attributes.binormal)) ? attributes.binormal.values : undefined;
var tangents = (defined(attributes.tangent)) ? attributes.tangent.values : undefined;
var texCoords = (defined(attributes.st)) ? attributes.st.values : undefined;
+ var extrudeDirections = (defined(attributes.extrudeDirection)) ? attributes.extrudeDirection.values : undefined;
var indices = geometry.indices;
var eastGeometry = copyGeometryForSplit(geometry);
@@ -2035,7 +2098,7 @@ define([
}
insertedIndex = insertSplitPoint(currentAttributes, currentIndices, currentIndexMap, indices, resultIndex < 3 ? i + resultIndex : -1, point);
- computeTriangleAttributes(i0, i1, i2, point, positions, normals, binormals, tangents, texCoords, currentAttributes, insertedIndex);
+ computeTriangleAttributes(i0, i1, i2, point, positions, normals, binormals, tangents, texCoords, extrudeDirections, currentAttributes, insertedIndex);
}
} else {
if (defined(result)) {
@@ -2055,13 +2118,13 @@ define([
}
insertedIndex = insertSplitPoint(currentAttributes, currentIndices, currentIndexMap, indices, i, p0);
- computeTriangleAttributes(i0, i1, i2, p0, positions, normals, binormals, tangents, texCoords, currentAttributes, insertedIndex);
+ computeTriangleAttributes(i0, i1, i2, p0, positions, normals, binormals, tangents, texCoords, extrudeDirections, currentAttributes, insertedIndex);
insertedIndex = insertSplitPoint(currentAttributes, currentIndices, currentIndexMap, indices, i + 1, p1);
- computeTriangleAttributes(i0, i1, i2, p1, positions, normals, binormals, tangents, texCoords, currentAttributes, insertedIndex);
+ computeTriangleAttributes(i0, i1, i2, p1, positions, normals, binormals, tangents, texCoords, extrudeDirections, currentAttributes, insertedIndex);
insertedIndex = insertSplitPoint(currentAttributes, currentIndices, currentIndexMap, indices, i + 2, p2);
- computeTriangleAttributes(i0, i1, i2, p2, positions, normals, binormals, tangents, texCoords, currentAttributes, insertedIndex);
+ computeTriangleAttributes(i0, i1, i2, p2, positions, normals, binormals, tangents, texCoords, extrudeDirections, currentAttributes, insertedIndex);
}
}
diff --git a/Source/Core/IntersectionTests.js b/Source/Core/IntersectionTests.js
index e468763c9ff0..3bde8428fed3 100644
--- a/Source/Core/IntersectionTests.js
+++ b/Source/Core/IntersectionTests.js
@@ -5,6 +5,7 @@ define([
'./defaultValue',
'./defined',
'./DeveloperError',
+ './Interval',
'./Math',
'./Matrix3',
'./QuadraticRealPolynomial',
@@ -16,6 +17,7 @@ define([
defaultValue,
defined,
DeveloperError,
+ Interval,
CesiumMath,
Matrix3,
QuadraticRealPolynomial,
@@ -293,7 +295,7 @@ define([
function raySphere(ray, sphere, result) {
if (!defined(result)) {
- result = {};
+ result = new Interval();
}
var origin = ray.origin;
@@ -324,8 +326,8 @@ define([
*
* @param {Ray} ray The ray.
* @param {BoundingSphere} sphere The sphere.
- * @param {Object} [result] The result onto which to store the result.
- * @returns {Object} An object with the first (start
) and the second (stop
) intersection scalars for points along the ray or undefined if there are no intersections.
+ * @param {Interval} [result] The result onto which to store the result.
+ * @returns {Interval} The interval containing scalar points along the ray or undefined if there are no intersections.
*/
IntersectionTests.raySphere = function(ray, sphere, result) {
//>>includeStart('debug', pragmas.debug);
@@ -355,8 +357,8 @@ define([
* @param {Cartesian3} p0 An end point of the line segment.
* @param {Cartesian3} p1 The other end point of the line segment.
* @param {BoundingSphere} sphere The sphere.
- * @param {Object} [result] The result onto which to store the result.
- * @returns {Object} An object with the first (start
) and the second (stop
) intersection scalars for points along the line segment or undefined if there are no intersections.
+ * @param {Interval} [result] The result onto which to store the result.
+ * @returns {Interval} The interval containing scalar points along the ray or undefined if there are no intersections.
*/
IntersectionTests.lineSegmentSphere = function(p0, p1, sphere, result) {
//>>includeStart('debug', pragmas.debug);
@@ -396,7 +398,7 @@ define([
*
* @param {Ray} ray The ray.
* @param {Ellipsoid} ellipsoid The ellipsoid.
- * @returns {Object} An object with the first (start
) and the second (stop
) intersection scalars for points along the ray or undefined if there are no intersections.
+ * @returns {Interval} The interval containing scalar points along the ray or undefined if there are no intersections.
*/
IntersectionTests.rayEllipsoid = function(ray, ellipsoid) {
//>>includeStart('debug', pragmas.debug);
@@ -440,10 +442,7 @@ define([
var root0 = temp / w2;
var root1 = difference / temp;
if (root0 < root1) {
- return {
- start : root0,
- stop : root1
- };
+ return new Interval(root0, root1);
}
return {
@@ -453,10 +452,7 @@ define([
} else {
// qw2 == product. Repeated roots (2 intersections).
var root = Math.sqrt(difference / w2);
- return {
- start : root,
- stop : root
- };
+ return new Interval(root, root);
}
} else if (q2 < 1.0) {
// Inside ellipsoid (2 intersections).
@@ -466,19 +462,13 @@ define([
discriminant = qw * qw - product;
temp = -qw + Math.sqrt(discriminant); // Positively valued.
- return {
- start : 0.0,
- stop : temp / w2
- };
+ return new Interval(0.0, temp / w2);
} else {
// q2 == 1.0. On ellipsoid.
if (qw < 0.0) {
// Looking inward.
w2 = Cartesian3.magnitudeSquared(w);
- return {
- start : 0.0,
- stop : -qw / w2
- };
+ return new Interval(0.0, -qw / w2);
}
// qw >= 0.0. Looking outward or tangent.
diff --git a/Source/Core/Math.js b/Source/Core/Math.js
index 7c9952c522b5..b3bd96701bd4 100644
--- a/Source/Core/Math.js
+++ b/Source/Core/Math.js
@@ -486,7 +486,7 @@ define([
throw new DeveloperError('angle is required.');
}
//>>includeEnd('debug');
-
+
return CesiumMath.clamp(angle, -1*CesiumMath.PI_OVER_TWO, CesiumMath.PI_OVER_TWO);
};
@@ -496,13 +496,13 @@ define([
* @param {Number} angle in radians
* @returns {Number} The angle in the range [-CesiumMath.PI
, CesiumMath.PI
].
*/
- CesiumMath.negativePiToPi = function(x) {
+ CesiumMath.negativePiToPi = function(angle) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(x)) {
- throw new DeveloperError('x is required.');
+ if (!defined(angle)) {
+ throw new DeveloperError('angle is required.');
}
//>>includeEnd('debug');
- return CesiumMath.zeroToTwoPi(x + CesiumMath.PI) - CesiumMath.PI;
+ return CesiumMath.zeroToTwoPi(angle + CesiumMath.PI) - CesiumMath.PI;
};
/**
@@ -511,14 +511,14 @@ define([
* @param {Number} angle in radians
* @returns {Number} The angle in the range [0, CesiumMath.TWO_PI
].
*/
- CesiumMath.zeroToTwoPi = function(x) {
+ CesiumMath.zeroToTwoPi = function(angle) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(x)) {
- throw new DeveloperError('x is required.');
+ if (!defined(angle)) {
+ throw new DeveloperError('angle is required.');
}
//>>includeEnd('debug');
- var mod = CesiumMath.mod(x, CesiumMath.TWO_PI);
- if (Math.abs(mod) < CesiumMath.EPSILON14 && Math.abs(x) > CesiumMath.EPSILON14) {
+ var mod = CesiumMath.mod(angle, CesiumMath.TWO_PI);
+ if (Math.abs(mod) < CesiumMath.EPSILON14 && Math.abs(angle) > CesiumMath.EPSILON14) {
return CesiumMath.TWO_PI;
}
return mod;
@@ -592,7 +592,7 @@ define([
* @example
* //Compute 7!, which is equal to 5040
* var computedFactorial = Cesium.Math.factorial(7);
- *
+ *
* @see {@link http://en.wikipedia.org/wiki/Factorial|Factorial on Wikipedia}
*/
CesiumMath.factorial = function(n) {
diff --git a/Source/Core/Matrix2.js b/Source/Core/Matrix2.js
index ead1b25b2aa8..ad6bcaa18abc 100644
--- a/Source/Core/Matrix2.js
+++ b/Source/Core/Matrix2.js
@@ -1,6 +1,7 @@
/*global define*/
define([
'./Cartesian2',
+ './Check',
'./defaultValue',
'./defined',
'./defineProperties',
@@ -8,6 +9,7 @@ define([
'./freezeObject'
], function(
Cartesian2,
+ Check,
defaultValue,
defined,
defineProperties,
@@ -57,13 +59,8 @@ define([
*/
Matrix2.pack = function(value, array, startingIndex) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(value)) {
- throw new DeveloperError('value is required');
- }
-
- if (!defined(array)) {
- throw new DeveloperError('array is required');
- }
+ Check.typeOf.object(value, 'value');
+ Check.defined(array, 'array');
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
@@ -86,9 +83,7 @@ define([
*/
Matrix2.unpack = function(array, startingIndex, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(array)) {
- throw new DeveloperError('array is required');
- }
+ Check.defined(array, 'array');
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
@@ -111,18 +106,18 @@ define([
* @param {Matrix2} [result] The object onto which to store the result.
* @returns {Matrix2} The modified result parameter or a new Matrix2 instance if one was not provided. (Returns undefined if matrix is undefined)
*/
- Matrix2.clone = function(values, result) {
- if (!defined(values)) {
+ Matrix2.clone = function(matrix, result) {
+ if (!defined(matrix)) {
return undefined;
}
if (!defined(result)) {
- return new Matrix2(values[0], values[2],
- values[1], values[3]);
+ return new Matrix2(matrix[0], matrix[2],
+ matrix[1], matrix[3]);
}
- result[0] = values[0];
- result[1] = values[1];
- result[2] = values[2];
- result[3] = values[3];
+ result[0] = matrix[0];
+ result[1] = matrix[1];
+ result[2] = matrix[2];
+ result[3] = matrix[3];
return result;
};
@@ -148,9 +143,7 @@ define([
*/
Matrix2.fromArray = function(array, startingIndex, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(array)) {
- throw new DeveloperError('array is required');
- }
+ Check.defined(array, 'array');
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
@@ -175,9 +168,7 @@ define([
*/
Matrix2.fromColumnMajorArray = function(values, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(values)) {
- throw new DeveloperError('values parameter is required');
- }
+ Check.defined(values, 'values');
//>>includeEnd('debug');
return Matrix2.clone(values, result);
@@ -193,9 +184,7 @@ define([
*/
Matrix2.fromRowMajorArray = function(values, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(values)) {
- throw new DeveloperError('values is required.');
- }
+ Check.defined(values, 'values');
//>>includeEnd('debug');
if (!defined(result)) {
@@ -224,9 +213,7 @@ define([
*/
Matrix2.fromScale = function(scale, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(scale)) {
- throw new DeveloperError('scale is required.');
- }
+ Check.typeOf.object(scale, 'scale');
//>>includeEnd('debug');
if (!defined(result)) {
@@ -257,9 +244,7 @@ define([
*/
Matrix2.fromUniformScale = function(scale, result) {
//>>includeStart('debug', pragmas.debug);
- if (typeof scale !== 'number') {
- throw new DeveloperError('scale is required.');
- }
+ Check.typeOf.number(scale, 'scale');
//>>includeEnd('debug');
if (!defined(result)) {
@@ -290,9 +275,7 @@ define([
*/
Matrix2.fromRotation = function(angle, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(angle)) {
- throw new DeveloperError('angle is required.');
- }
+ Check.typeOf.number(angle, 'angle');
//>>includeEnd('debug');
var cosAngle = Math.cos(angle);
@@ -320,9 +303,7 @@ define([
*/
Matrix2.toArray = function(matrix, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(matrix)) {
- throw new DeveloperError('matrix is required');
- }
+ Check.typeOf.object(matrix, 'matrix');
//>>includeEnd('debug');
if (!defined(result)) {
@@ -353,12 +334,13 @@ define([
*/
Matrix2.getElementIndex = function(column, row) {
//>>includeStart('debug', pragmas.debug);
- if (typeof row !== 'number' || row < 0 || row > 1) {
- throw new DeveloperError('row must be 0 or 1.');
- }
- if (typeof column !== 'number' || column < 0 || column > 1) {
- throw new DeveloperError('column must be 0 or 1.');
- }
+ Check.typeOf.number(row, 'row');
+ Check.numeric.minimum(row, 0);
+ Check.numeric.maximum(row, 1);
+
+ Check.typeOf.number(column, 'column');
+ Check.numeric.minimum(column, 0);
+ Check.numeric.maximum(column, 1);
//>>includeEnd('debug');
return column * 2 + row;
@@ -376,15 +358,13 @@ define([
*/
Matrix2.getColumn = function(matrix, index, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(matrix)) {
- throw new DeveloperError('matrix is required.');
- }
- if (typeof index !== 'number' || index < 0 || index > 1) {
- throw new DeveloperError('index must be 0 or 1.');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(matrix, 'matrix');
+
+ Check.typeOf.number(index, 'index');
+ Check.numeric.minimum(index, 0);
+ Check.numeric.maximum(index, 1);
+
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
var startIndex = index * 2;
@@ -409,18 +389,14 @@ define([
*/
Matrix2.setColumn = function(matrix, index, cartesian, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(matrix)) {
- throw new DeveloperError('matrix is required');
- }
- if (!defined(cartesian)) {
- throw new DeveloperError('cartesian is required');
- }
- if (typeof index !== 'number' || index < 0 || index > 1) {
- throw new DeveloperError('index must be 0 or 1.');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(matrix, 'matrix');
+
+ Check.typeOf.number(index, 'index');
+ Check.numeric.minimum(index, 0);
+ Check.numeric.maximum(index, 1);
+
+ Check.typeOf.object(cartesian, 'cartesian');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
result = Matrix2.clone(matrix, result);
@@ -442,15 +418,13 @@ define([
*/
Matrix2.getRow = function(matrix, index, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(matrix)) {
- throw new DeveloperError('matrix is required.');
- }
- if (typeof index !== 'number' || index < 0 || index > 1) {
- throw new DeveloperError('index must be 0 or 1.');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(matrix, 'matrix');
+
+ Check.typeOf.number(index, 'index');
+ Check.numeric.minimum(index, 0);
+ Check.numeric.maximum(index, 1);
+
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
var x = matrix[index];
@@ -474,18 +448,14 @@ define([
*/
Matrix2.setRow = function(matrix, index, cartesian, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(matrix)) {
- throw new DeveloperError('matrix is required');
- }
- if (!defined(cartesian)) {
- throw new DeveloperError('cartesian is required');
- }
- if (typeof index !== 'number' || index < 0 || index > 1) {
- throw new DeveloperError('index must be 0 or 1.');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(matrix, 'matrix');
+
+ Check.typeOf.number(index, 'index');
+ Check.numeric.minimum(index, 0);
+ Check.numeric.maximum(index, 1);
+
+ Check.typeOf.object(cartesian, 'cartesian');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
result = Matrix2.clone(matrix, result);
@@ -505,12 +475,8 @@ define([
*/
Matrix2.getScale = function(matrix, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(matrix)) {
- throw new DeveloperError('matrix is required.');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(matrix, 'matrix');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
result.x = Cartesian2.magnitude(Cartesian2.fromElements(matrix[0], matrix[1], scratchColumn));
@@ -542,15 +508,9 @@ define([
*/
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');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(left, 'left');
+ Check.typeOf.object(right, 'right');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
var column0Row0 = left[0] * right[0] + left[2] * right[1];
@@ -575,15 +535,9 @@ define([
*/
Matrix2.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');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(left, 'left');
+ Check.typeOf.object(right, 'right');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
result[0] = left[0] + right[0];
@@ -603,15 +557,9 @@ define([
*/
Matrix2.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');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(left, 'left');
+ Check.typeOf.object(right, 'right');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
result[0] = left[0] - right[0];
@@ -631,15 +579,9 @@ define([
*/
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');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(matrix, 'matrix');
+ Check.typeOf.object(cartesian, 'cartesian');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
var x = matrix[0] * cartesian.x + matrix[2] * cartesian.y;
@@ -660,15 +602,9 @@ define([
*/
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');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(matrix, 'matrix');
+ Check.typeOf.number(scalar, 'scalar');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
result[0] = matrix[0] * scalar;
@@ -696,15 +632,9 @@ define([
*/
Matrix2.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');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(matrix, 'matrix');
+ Check.typeOf.object(scale, 'scale');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
result[0] = matrix[0] * scale.x;
@@ -723,12 +653,8 @@ define([
*/
Matrix2.negate = function(matrix, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(matrix)) {
- throw new DeveloperError('matrix is required');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(matrix, 'matrix');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
result[0] = -matrix[0];
@@ -747,12 +673,8 @@ define([
*/
Matrix2.transpose = function(matrix, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(matrix)) {
- throw new DeveloperError('matrix is required');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(matrix, 'matrix');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
var column0Row0 = matrix[0];
@@ -776,12 +698,8 @@ define([
*/
Matrix2.abs = function(matrix, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(matrix)) {
- throw new DeveloperError('matrix is required');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(matrix, 'matrix');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
result[0] = Math.abs(matrix[0]);
@@ -832,9 +750,7 @@ define([
*/
Matrix2.equalsEpsilon = function(left, right, epsilon) {
//>>includeStart('debug', pragmas.debug);
- if (typeof epsilon !== 'number') {
- throw new DeveloperError('epsilon must be a number');
- }
+ Check.typeOf.number(epsilon, 'epsilon');
//>>includeEnd('debug');
return (left === right) ||
diff --git a/Source/Core/Matrix3.js b/Source/Core/Matrix3.js
index 2faff37a7283..0b63e2eb9a7a 100644
--- a/Source/Core/Matrix3.js
+++ b/Source/Core/Matrix3.js
@@ -1,6 +1,7 @@
/*global define*/
define([
'./Cartesian3',
+ './Check',
'./defaultValue',
'./defined',
'./defineProperties',
@@ -9,6 +10,7 @@ define([
'./Math'
], function(
Cartesian3,
+ Check,
defaultValue,
defined,
defineProperties,
@@ -72,13 +74,8 @@ define([
*/
Matrix3.pack = function(value, array, startingIndex) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(value)) {
- throw new DeveloperError('value is required');
- }
-
- if (!defined(array)) {
- throw new DeveloperError('array is required');
- }
+ Check.typeOf.object(value, 'value');
+ Check.defined(array, 'array');
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
@@ -106,9 +103,7 @@ define([
*/
Matrix3.unpack = function(array, startingIndex, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(array)) {
- throw new DeveloperError('array is required');
- }
+ Check.defined(array, 'array');
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
@@ -136,24 +131,24 @@ define([
* @param {Matrix3} [result] The object onto which to store the result.
* @returns {Matrix3} The modified result parameter or a new Matrix3 instance if one was not provided. (Returns undefined if matrix is undefined)
*/
- Matrix3.clone = function(values, result) {
- if (!defined(values)) {
+ Matrix3.clone = function(matrix, result) {
+ if (!defined(matrix)) {
return undefined;
}
if (!defined(result)) {
- return new Matrix3(values[0], values[3], values[6],
- values[1], values[4], values[7],
- values[2], values[5], values[8]);
+ return new Matrix3(matrix[0], matrix[3], matrix[6],
+ matrix[1], matrix[4], matrix[7],
+ matrix[2], matrix[5], matrix[8]);
}
- result[0] = values[0];
- result[1] = values[1];
- result[2] = values[2];
- result[3] = values[3];
- result[4] = values[4];
- result[5] = values[5];
- result[6] = values[6];
- result[7] = values[7];
- result[8] = values[8];
+ result[0] = matrix[0];
+ result[1] = matrix[1];
+ result[2] = matrix[2];
+ result[3] = matrix[3];
+ result[4] = matrix[4];
+ result[5] = matrix[5];
+ result[6] = matrix[6];
+ result[7] = matrix[7];
+ result[8] = matrix[8];
return result;
};
@@ -180,9 +175,7 @@ define([
*/
Matrix3.fromArray = function(array, startingIndex, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(array)) {
- throw new DeveloperError('array is required');
- }
+ Check.defined(array, 'array');
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
@@ -212,9 +205,7 @@ define([
*/
Matrix3.fromColumnMajorArray = function(values, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(values)) {
- throw new DeveloperError('values parameter is required');
- }
+ Check.defined(values, 'values');
//>>includeEnd('debug');
return Matrix3.clone(values, result);
@@ -230,9 +221,7 @@ define([
*/
Matrix3.fromRowMajorArray = function(values, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(values)) {
- throw new DeveloperError('values is required.');
- }
+ Check.defined(values, 'values');
//>>includeEnd('debug');
if (!defined(result)) {
@@ -261,9 +250,7 @@ define([
*/
Matrix3.fromQuaternion = function(quaternion, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(quaternion)) {
- throw new DeveloperError('quaternion is required');
- }
+ Check.typeOf.object(quaternion, 'quaternion');
//>>includeEnd('debug');
var x2 = quaternion.x * quaternion.x;
@@ -315,10 +302,9 @@ define([
*/
Matrix3.fromHeadingPitchRoll = function(headingPitchRoll, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(headingPitchRoll)) {
- throw new DeveloperError('headingPitchRoll is required');
- }
+ Check.typeOf.object(headingPitchRoll, 'headingPitchRoll');
//>>includeEnd('debug');
+
var cosTheta = Math.cos(-headingPitchRoll.pitch);
var cosPsi = Math.cos(-headingPitchRoll.heading);
var cosPhi = Math.cos(headingPitchRoll.roll);
@@ -371,9 +357,7 @@ define([
*/
Matrix3.fromScale = function(scale, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(scale)) {
- throw new DeveloperError('scale is required.');
- }
+ Check.typeOf.object(scale, 'scale');
//>>includeEnd('debug');
if (!defined(result)) {
@@ -411,9 +395,7 @@ define([
*/
Matrix3.fromUniformScale = function(scale, result) {
//>>includeStart('debug', pragmas.debug);
- if (typeof scale !== 'number') {
- throw new DeveloperError('scale is required.');
- }
+ Check.typeOf.number(scale, 'scale');
//>>includeEnd('debug');
if (!defined(result)) {
@@ -438,7 +420,7 @@ define([
/**
* Computes a Matrix3 instance representing the cross product equivalent matrix of a Cartesian3 vector.
*
- * @param {Cartesian3} the vector on the left hand side of the cross product operation.
+ * @param {Cartesian3} vector the vector on the left hand side of the cross product operation.
* @param {Matrix3} [result] The object in which the result will be stored, if undefined a new instance will be created.
* @returns {Matrix3} The modified result parameter, or a new Matrix3 instance if one was not provided.
*
@@ -451,9 +433,7 @@ define([
*/
Matrix3.fromCrossProduct = function(vector, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(vector)) {
- throw new DeveloperError('vector is required.');
- }
+ Check.typeOf.object(vector, 'vector');
//>>includeEnd('debug');
if (!defined(result)) {
@@ -490,9 +470,7 @@ define([
*/
Matrix3.fromRotationX = function(angle, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(angle)) {
- throw new DeveloperError('angle is required.');
- }
+ Check.typeOf.number(angle, 'angle');
//>>includeEnd('debug');
var cosAngle = Math.cos(angle);
@@ -533,9 +511,7 @@ define([
*/
Matrix3.fromRotationY = function(angle, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(angle)) {
- throw new DeveloperError('angle is required.');
- }
+ Check.typeOf.number(angle, 'angle');
//>>includeEnd('debug');
var cosAngle = Math.cos(angle);
@@ -576,9 +552,7 @@ define([
*/
Matrix3.fromRotationZ = function(angle, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(angle)) {
- throw new DeveloperError('angle is required.');
- }
+ Check.typeOf.number(angle, 'angle');
//>>includeEnd('debug');
var cosAngle = Math.cos(angle);
@@ -614,9 +588,7 @@ define([
*/
Matrix3.toArray = function(matrix, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(matrix)) {
- throw new DeveloperError('matrix is required');
- }
+ Check.typeOf.object(matrix, 'matrix');
//>>includeEnd('debug');
if (!defined(result)) {
@@ -652,12 +624,12 @@ define([
*/
Matrix3.getElementIndex = function(column, row) {
//>>includeStart('debug', pragmas.debug);
- if (typeof row !== 'number' || row < 0 || row > 2) {
- throw new DeveloperError('row must be 0, 1, or 2.');
- }
- if (typeof column !== 'number' || column < 0 || column > 2) {
- throw new DeveloperError('column must be 0, 1, or 2.');
- }
+ Check.typeOf.number(column, 'column');
+ Check.typeOf.number(row, 'row');
+ Check.numeric.minimum(row, 0);
+ Check.numeric.maximum(row, 2);
+ Check.numeric.minimum(column, 0);
+ Check.numeric.maximum(column, 2);
//>>includeEnd('debug');
return column * 3 + row;
@@ -675,16 +647,11 @@ define([
*/
Matrix3.getColumn = function(matrix, index, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(matrix)) {
- throw new DeveloperError('matrix is required.');
- }
-
- if (typeof index !== 'number' || index < 0 || index > 2) {
- throw new DeveloperError('index must be 0, 1, or 2.');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(matrix, 'matrix');
+ Check.typeOf.number(index, 'index');
+ Check.numeric.minimum(index, 0);
+ Check.numeric.maximum(index, 2);
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
var startIndex = index * 3;
@@ -711,18 +678,12 @@ define([
*/
Matrix3.setColumn = function(matrix, index, cartesian, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(matrix)) {
- throw new DeveloperError('matrix is required');
- }
- if (!defined(cartesian)) {
- throw new DeveloperError('cartesian is required');
- }
- if (typeof index !== 'number' || index < 0 || index > 2) {
- throw new DeveloperError('index must be 0, 1, or 2.');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(matrix, 'matrix');
+ Check.typeOf.number(index, 'index');
+ Check.numeric.minimum(index, 0);
+ Check.numeric.maximum(index, 2);
+ Check.typeOf.object(cartesian, 'cartesian');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
result = Matrix3.clone(matrix, result);
@@ -745,15 +706,11 @@ define([
*/
Matrix3.getRow = function(matrix, index, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(matrix)) {
- throw new DeveloperError('matrix is required.');
- }
- if (typeof index !== 'number' || index < 0 || index > 2) {
- throw new DeveloperError('index must be 0, 1, or 2.');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(matrix, 'matrix');
+ Check.typeOf.number(index, 'index');
+ Check.numeric.minimum(index, 0);
+ Check.numeric.maximum(index, 2);
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
var x = matrix[index];
@@ -779,18 +736,12 @@ define([
*/
Matrix3.setRow = function(matrix, index, cartesian, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(matrix)) {
- throw new DeveloperError('matrix is required');
- }
- if (!defined(cartesian)) {
- throw new DeveloperError('cartesian is required');
- }
- if (typeof index !== 'number' || index < 0 || index > 2) {
- throw new DeveloperError('index must be 0, 1, or 2.');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(matrix, 'matrix');
+ Check.typeOf.number(index, 'index');
+ Check.numeric.minimum(index, 0);
+ Check.numeric.maximum(index, 2);
+ Check.typeOf.object(cartesian, 'cartesian');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
result = Matrix3.clone(matrix, result);
@@ -811,12 +762,8 @@ define([
*/
Matrix3.getScale = function(matrix, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(matrix)) {
- throw new DeveloperError('matrix is required.');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(matrix, 'matrix');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
result.x = Cartesian3.magnitude(Cartesian3.fromElements(matrix[0], matrix[1], matrix[2], scratchColumn));
@@ -849,15 +796,9 @@ define([
*/
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');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(left, 'left');
+ Check.typeOf.object(right, 'right');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
var column0Row0 = left[0] * right[0] + left[3] * right[1] + left[6] * right[2];
@@ -894,15 +835,9 @@ define([
*/
Matrix3.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');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(left, 'left');
+ Check.typeOf.object(right, 'right');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
result[0] = left[0] + right[0];
@@ -927,15 +862,9 @@ define([
*/
Matrix3.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');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(left, 'left');
+ Check.typeOf.object(right, 'right');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
result[0] = left[0] - right[0];
@@ -960,15 +889,9 @@ define([
*/
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');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(matrix, 'matrix');
+ Check.typeOf.object(cartesian, 'cartesian');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
var vX = cartesian.x;
@@ -995,15 +918,9 @@ define([
*/
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 must be a number');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(matrix, 'matrix');
+ Check.typeOf.number(scalar, 'scalar');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
result[0] = matrix[0] * scalar;
@@ -1036,15 +953,9 @@ define([
*/
Matrix3.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');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(matrix, 'matrix');
+ Check.typeOf.object(scale, 'scale');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
result[0] = matrix[0] * scale.x;
@@ -1068,12 +979,8 @@ define([
*/
Matrix3.negate = function(matrix, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(matrix)) {
- throw new DeveloperError('matrix is required');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(matrix, 'matrix');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
result[0] = -matrix[0];
@@ -1097,12 +1004,8 @@ define([
*/
Matrix3.transpose = function(matrix, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(matrix)) {
- throw new DeveloperError('matrix is required');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(matrix, 'matrix');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
var column0Row0 = matrix[0];
@@ -1244,9 +1147,7 @@ define([
*/
Matrix3.computeEigenDecomposition = function(matrix, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(matrix)) {
- throw new DeveloperError('matrix is required.');
- }
+ Check.typeOf.object(matrix, 'matrix');
//>>includeEnd('debug');
// This routine was created based upon Matrix Computations, 3rd ed., by Golub and Van Loan,
@@ -1292,12 +1193,8 @@ define([
*/
Matrix3.abs = function(matrix, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(matrix)) {
- throw new DeveloperError('matrix is required');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(matrix, 'matrix');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
result[0] = Math.abs(matrix[0]);
@@ -1321,9 +1218,7 @@ define([
*/
Matrix3.determinant = function(matrix) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(matrix)) {
- throw new DeveloperError('matrix is required');
- }
+ Check.typeOf.object(matrix, 'matrix');
//>>includeEnd('debug');
var m11 = matrix[0];
@@ -1350,12 +1245,8 @@ define([
*/
Matrix3.inverse = function(matrix, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(matrix)) {
- throw new DeveloperError('matrix is required');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(matrix, 'matrix');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
var m11 = matrix[0];
@@ -1425,9 +1316,7 @@ define([
*/
Matrix3.equalsEpsilon = function(left, right, epsilon) {
//>>includeStart('debug', pragmas.debug);
- if (typeof epsilon !== 'number') {
- throw new DeveloperError('epsilon must be a number');
- }
+ Check.typeOf.number(epsilon, 'epsilon');
//>>includeEnd('debug');
return (left === right) ||
diff --git a/Source/Core/Matrix4.js b/Source/Core/Matrix4.js
index 53ed1241f682..0ea3319be262 100644
--- a/Source/Core/Matrix4.js
+++ b/Source/Core/Matrix4.js
@@ -2,6 +2,7 @@
define([
'./Cartesian3',
'./Cartesian4',
+ './Check',
'./defaultValue',
'./defined',
'./defineProperties',
@@ -13,6 +14,7 @@ define([
], function(
Cartesian3,
Cartesian4,
+ Check,
defaultValue,
defined,
defineProperties,
@@ -104,13 +106,8 @@ define([
*/
Matrix4.pack = function(value, array, startingIndex) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(value)) {
- throw new DeveloperError('value is required');
- }
-
- if (!defined(array)) {
- throw new DeveloperError('array is required');
- }
+ Check.typeOf.object(value, 'value');
+ Check.defined(array, 'array');
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
@@ -145,9 +142,7 @@ define([
*/
Matrix4.unpack = function(array, startingIndex, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(array)) {
- throw new DeveloperError('array is required');
- }
+ Check.defined(array, 'array');
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
@@ -245,9 +240,7 @@ define([
*/
Matrix4.fromColumnMajorArray = function(values, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(values)) {
- throw new DeveloperError('values is required');
- }
+ Check.defined(values, 'values');
//>>includeEnd('debug');
return Matrix4.clone(values, result);
@@ -263,9 +256,7 @@ define([
*/
Matrix4.fromRowMajorArray = function(values, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(values)) {
- throw new DeveloperError('values is required.');
- }
+ Check.defined(values, 'values');
//>>includeEnd('debug');
if (!defined(result)) {
@@ -304,9 +295,7 @@ define([
*/
Matrix4.fromRotationTranslation = function(rotation, translation, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(rotation)) {
- throw new DeveloperError('rotation is required.');
- }
+ Check.typeOf.object(rotation, 'rotation');
//>>includeEnd('debug');
translation = defaultValue(translation, Cartesian3.ZERO);
@@ -356,15 +345,9 @@ define([
*/
Matrix4.fromTranslationQuaternionRotationScale = function(translation, rotation, scale, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(translation)) {
- throw new DeveloperError('translation is required.');
- }
- if (!defined(rotation)) {
- throw new DeveloperError('rotation is required.');
- }
- if (!defined(scale)) {
- throw new DeveloperError('scale is required.');
- }
+ Check.typeOf.object(translation, 'translation');
+ Check.typeOf.object(rotation, 'rotation');
+ Check.typeOf.object(scale, 'scale');
//>>includeEnd('debug');
if (!defined(result)) {
@@ -427,9 +410,7 @@ define([
*/
Matrix4.fromTranslationRotationScale = function(translationRotationScale, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(translationRotationScale)) {
- throw new DeveloperError('translationRotationScale is required.');
- }
+ Check.typeOf.object(translationRotationScale, 'translationRotationScale');
//>>includeEnd('debug');
return Matrix4.fromTranslationQuaternionRotationScale(translationRotationScale.translation, translationRotationScale.rotation, translationRotationScale.scale, result);
@@ -446,9 +427,7 @@ define([
*/
Matrix4.fromTranslation = function(translation, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(translation)) {
- throw new DeveloperError('translation is required.');
- }
+ Check.typeOf.object(translation, 'translation');
//>>includeEnd('debug');
return Matrix4.fromRotationTranslation(Matrix3.IDENTITY, translation, result);
@@ -471,9 +450,7 @@ define([
*/
Matrix4.fromScale = function(scale, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(scale)) {
- throw new DeveloperError('scale is required.');
- }
+ Check.typeOf.object(scale, 'scale');
//>>includeEnd('debug');
if (!defined(result)) {
@@ -520,9 +497,7 @@ define([
*/
Matrix4.fromUniformScale = function(scale, result) {
//>>includeStart('debug', pragmas.debug);
- if (typeof scale !== 'number') {
- throw new DeveloperError('scale is required.');
- }
+ Check.typeOf.number(scale, 'scale');
//>>includeEnd('debug');
if (!defined(result)) {
@@ -564,9 +539,7 @@ define([
*/
Matrix4.fromCamera = function(camera, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(camera)) {
- throw new DeveloperError('camera is required.');
- }
+ Check.typeOf.object(camera, 'camera');
//>>includeEnd('debug');
var position = camera.position;
@@ -574,15 +547,9 @@ define([
var up = camera.up;
//>>includeStart('debug', pragmas.debug);
- if (!defined(position)) {
- throw new DeveloperError('camera.position is required.');
- }
- if (!defined(direction)) {
- throw new DeveloperError('camera.direction is required.');
- }
- if (!defined(up)) {
- throw new DeveloperError('camera.up is required.');
- }
+ Check.typeOf.object(position, 'camera.position');
+ Check.typeOf.object(direction, 'camera.direction');
+ Check.typeOf.object(up, 'camera.up');
//>>includeEnd('debug');
Cartesian3.normalize(direction, fromCameraF);
@@ -675,9 +642,7 @@ define([
if (far <= 0.0) {
throw new DeveloperError('far must be greater than zero.');
}
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
var bottom = Math.tan(fovY * 0.5);
@@ -720,27 +685,13 @@ define([
*/
Matrix4.computeOrthographicOffCenter = function(left, right, bottom, top, near, far, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(left)) {
- throw new DeveloperError('left is required.');
- }
- if (!defined(right)) {
- throw new DeveloperError('right is required.');
- }
- if (!defined(bottom)) {
- throw new DeveloperError('bottom is required.');
- }
- if (!defined(top)) {
- throw new DeveloperError('top is required.');
- }
- if (!defined(near)) {
- throw new DeveloperError('near is required.');
- }
- if (!defined(far)) {
- throw new DeveloperError('far is required.');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.number(left, 'left');
+ Check.typeOf.number(right, 'right');
+ Check.typeOf.number(bottom, 'bottom');
+ Check.typeOf.number(top, 'top');
+ Check.typeOf.number(near, 'near');
+ Check.typeOf.number(far, 'far');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
var a = 1.0 / (right - left);
@@ -787,27 +738,13 @@ define([
*/
Matrix4.computePerspectiveOffCenter = function(left, right, bottom, top, near, far, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(left)) {
- throw new DeveloperError('left is required.');
- }
- if (!defined(right)) {
- throw new DeveloperError('right is required.');
- }
- if (!defined(bottom)) {
- throw new DeveloperError('bottom is required.');
- }
- if (!defined(top)) {
- throw new DeveloperError('top is required.');
- }
- if (!defined(near)) {
- throw new DeveloperError('near is required.');
- }
- if (!defined(far)) {
- throw new DeveloperError('far is required.');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.number(left, 'left');
+ Check.typeOf.number(right, 'right');
+ Check.typeOf.number(bottom, 'bottom');
+ Check.typeOf.number(top, 'top');
+ Check.typeOf.number(near, 'near');
+ Check.typeOf.number(far, 'far');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
var column0Row0 = 2.0 * near / (right - left);
@@ -850,24 +787,12 @@ define([
*/
Matrix4.computeInfinitePerspectiveOffCenter = function(left, right, bottom, top, near, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(left)) {
- throw new DeveloperError('left is required.');
- }
- if (!defined(right)) {
- throw new DeveloperError('right is required.');
- }
- if (!defined(bottom)) {
- throw new DeveloperError('bottom is required.');
- }
- if (!defined(top)) {
- throw new DeveloperError('top is required.');
- }
- if (!defined(near)) {
- throw new DeveloperError('near is required.');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.number(left, 'left');
+ Check.typeOf.number(right, 'right');
+ Check.typeOf.number(bottom, 'bottom');
+ Check.typeOf.number(top, 'top');
+ Check.typeOf.number(near, 'near');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
var column0Row0 = 2.0 * near / (right - left);
@@ -917,9 +842,7 @@ define([
*/
Matrix4.computeViewportTransformation = function(viewport, nearDepthRange, farDepthRange, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
viewport = defaultValue(viewport, defaultValue.EMPTY_OBJECT);
@@ -973,21 +896,11 @@ define([
*/
Matrix4.computeView = function(position, direction, up, right, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(position)) {
- throw new DeveloperError('position is required');
- }
- if (!defined(direction)) {
- throw new DeveloperError('direction is required');
- }
- if (!defined(up)) {
- throw new DeveloperError('up is required');
- }
- if (!defined(right)) {
- throw new DeveloperError('right is required');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(position, 'position');
+ Check.typeOf.object(direction, 'direction');
+ Check.typeOf.object(up, 'up');
+ Check.typeOf.object(right, 'right');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
result[0] = right.x;
@@ -1030,9 +943,7 @@ define([
*/
Matrix4.toArray = function(matrix, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(matrix)) {
- throw new DeveloperError('matrix is required');
- }
+ Check.typeOf.object(matrix, 'matrix');
//>>includeEnd('debug');
if (!defined(result)) {
@@ -1078,12 +989,13 @@ define([
*/
Matrix4.getElementIndex = function(column, row) {
//>>includeStart('debug', pragmas.debug);
- if (typeof row !== 'number' || row < 0 || row > 3) {
- throw new DeveloperError('row must be 0, 1, 2, or 3.');
- }
- if (typeof column !== 'number' || column < 0 || column > 3) {
- throw new DeveloperError('column must be 0, 1, 2, or 3.');
- }
+ Check.typeOf.number(row, 'row');
+ Check.numeric.minimum(row, 0);
+ Check.numeric.maximum(row, 3);
+
+ Check.typeOf.number(column, 'column');
+ Check.numeric.minimum(column, 0);
+ Check.numeric.maximum(column, 3);
//>>includeEnd('debug');
return column * 4 + row;
@@ -1118,16 +1030,13 @@ define([
*/
Matrix4.getColumn = function(matrix, index, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(matrix)) {
- throw new DeveloperError('matrix is required.');
- }
+ Check.typeOf.object(matrix, 'matrix');
- if (typeof index !== 'number' || index < 0 || index > 3) {
- throw new DeveloperError('index must be 0, 1, 2, or 3.');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.number(index, 'index');
+ Check.numeric.minimum(index, 0);
+ Check.numeric.maximum(index, 3);
+
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
var startIndex = index * 4;
@@ -1171,18 +1080,14 @@ define([
*/
Matrix4.setColumn = function(matrix, index, cartesian, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(matrix)) {
- throw new DeveloperError('matrix is required');
- }
- if (!defined(cartesian)) {
- throw new DeveloperError('cartesian is required');
- }
- if (typeof index !== 'number' || index < 0 || index > 3) {
- throw new DeveloperError('index must be 0, 1, 2, or 3.');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(matrix, 'matrix');
+
+ Check.typeOf.number(index, 'index');
+ Check.numeric.minimum(index, 0);
+ Check.numeric.maximum(index, 3);
+
+ Check.typeOf.object(cartesian, 'cartesian');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
result = Matrix4.clone(matrix, result);
@@ -1205,15 +1110,9 @@ define([
*/
Matrix4.setTranslation = 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');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(matrix, 'matrix');
+ Check.typeOf.object(translation, 'translation');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
result[0] = matrix[0];
@@ -1268,16 +1167,13 @@ define([
*/
Matrix4.getRow = function(matrix, index, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(matrix)) {
- throw new DeveloperError('matrix is required.');
- }
+ Check.typeOf.object(matrix, 'matrix');
- if (typeof index !== 'number' || index < 0 || index > 3) {
- throw new DeveloperError('index must be 0, 1, 2, or 3.');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.number(index, 'index');
+ Check.numeric.minimum(index, 0);
+ Check.numeric.maximum(index, 3);
+
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
var x = matrix[index];
@@ -1320,18 +1216,14 @@ define([
*/
Matrix4.setRow = function(matrix, index, cartesian, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(matrix)) {
- throw new DeveloperError('matrix is required');
- }
- if (!defined(cartesian)) {
- throw new DeveloperError('cartesian is required');
- }
- if (typeof index !== 'number' || index < 0 || index > 3) {
- throw new DeveloperError('index must be 0, 1, 2, or 3.');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(matrix, 'matrix');
+
+ Check.typeOf.number(index, 'index');
+ Check.numeric.minimum(index, 0);
+ Check.numeric.maximum(index, 3);
+
+ Check.typeOf.object(cartesian, 'cartesian');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
result = Matrix4.clone(matrix, result);
@@ -1353,12 +1245,8 @@ define([
*/
Matrix4.getScale = function(matrix, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(matrix)) {
- throw new DeveloperError('matrix is required.');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(matrix, 'matrix');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
result.x = Cartesian3.magnitude(Cartesian3.fromElements(matrix[0], matrix[1], matrix[2], scratchColumn));
@@ -1392,15 +1280,9 @@ define([
*/
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');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(left, 'left');
+ Check.typeOf.object(right, 'right');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
var left0 = left[0];
@@ -1486,15 +1368,9 @@ define([
*/
Matrix4.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');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(left, 'left');
+ Check.typeOf.object(right, 'right');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
result[0] = left[0] + right[0];
@@ -1526,15 +1402,9 @@ define([
*/
Matrix4.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');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(left, 'left');
+ Check.typeOf.object(right, 'right');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
result[0] = left[0] - right[0];
@@ -1577,15 +1447,9 @@ define([
*/
Matrix4.multiplyTransformation = 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');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(left, 'left');
+ Check.typeOf.object(right, 'right');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
var left0 = left[0];
@@ -1665,15 +1529,9 @@ define([
*/
Matrix4.multiplyByMatrix3 = function(matrix, rotation, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(matrix)) {
- throw new DeveloperError('matrix is required');
- }
- if (!defined(rotation)) {
- throw new DeveloperError('rotation is required');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(matrix, 'matrix');
+ Check.typeOf.object(rotation, 'rotation');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
var left0 = matrix[0];
@@ -1743,15 +1601,9 @@ define([
*/
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');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(matrix, 'matrix');
+ Check.typeOf.object(translation, 'translation');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
var x = translation.x;
@@ -1805,15 +1657,9 @@ define([
*/
Matrix4.multiplyByUniformScale = function(matrix, scale, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(matrix)) {
- throw new DeveloperError('matrix is required');
- }
- if (typeof scale !== 'number') {
- throw new DeveloperError('scale is required');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(matrix, 'matrix');
+ Check.typeOf.number(scale, 'scale');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
uniformScaleScratch.x = scale;
@@ -1844,15 +1690,9 @@ define([
*/
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');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(matrix, 'matrix');
+ Check.typeOf.object(scale, 'scale');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
var scaleX = scale.x;
@@ -1893,15 +1733,9 @@ define([
*/
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');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(matrix, 'matrix');
+ Check.typeOf.object(cartesian, 'cartesian');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
var vX = cartesian.x;
@@ -1939,15 +1773,9 @@ define([
*/
Matrix4.multiplyByPointAsVector = 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');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(matrix, 'matrix');
+ Check.typeOf.object(cartesian, 'cartesian');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
var vX = cartesian.x;
@@ -1979,16 +1807,9 @@ define([
*/
Matrix4.multiplyByPoint = 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');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(matrix, 'matrix');
+ Check.typeOf.object(cartesian, 'cartesian');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
var vX = cartesian.x;
@@ -2030,15 +1851,9 @@ 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 must be a number');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(matrix, 'matrix');
+ Check.typeOf.number(scalar, 'scalar');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
result[0] = matrix[0] * scalar;
@@ -2084,12 +1899,8 @@ define([
*/
Matrix4.negate = function(matrix, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(matrix)) {
- throw new DeveloperError('matrix is required');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(matrix, 'matrix');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
result[0] = -matrix[0];
@@ -2135,12 +1946,8 @@ define([
*/
Matrix4.transpose = function(matrix, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(matrix)) {
- throw new DeveloperError('matrix is required');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(matrix, 'matrix');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
var matrix1 = matrix[1];
@@ -2178,12 +1985,8 @@ define([
*/
Matrix4.abs = function(matrix, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(matrix)) {
- throw new DeveloperError('matrix is required');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(matrix, 'matrix');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
result[0] = Math.abs(matrix[0]);
@@ -2299,9 +2102,7 @@ define([
*/
Matrix4.equalsEpsilon = function(left, right, epsilon) {
//>>includeStart('debug', pragmas.debug);
- if (typeof epsilon !== 'number') {
- throw new DeveloperError('epsilon must be a number');
- }
+ Check.typeOf.number(epsilon, 'epsilon');
//>>includeEnd('debug');
return (left === right) ||
@@ -2334,12 +2135,8 @@ define([
*/
Matrix4.getTranslation = function(matrix, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(matrix)) {
- throw new DeveloperError('matrix is required');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(matrix, 'matrix');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
result.x = matrix[12];
@@ -2372,12 +2169,8 @@ define([
*/
Matrix4.getRotation = function(matrix, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(matrix)) {
- throw new DeveloperError('matrix is required');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(matrix, 'matrix');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
result[0] = matrix[0];
@@ -2411,12 +2204,8 @@ define([
*/
Matrix4.inverse = function(matrix, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(matrix)) {
- throw new DeveloperError('matrix is required');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(matrix, 'matrix');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
// Special case for a zero scale matrix that can occur, for example,
@@ -2556,12 +2345,8 @@ define([
*/
Matrix4.inverseTransformation = function(matrix, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(matrix)) {
- throw new DeveloperError('matrix is required');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(matrix, 'matrix');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
//This function is an optimized version of the below 4 lines.
diff --git a/Source/Core/OrientedBoundingBox.js b/Source/Core/OrientedBoundingBox.js
index 15c6b332ee08..53e0f48e28ee 100644
--- a/Source/Core/OrientedBoundingBox.js
+++ b/Source/Core/OrientedBoundingBox.js
@@ -199,6 +199,7 @@ define([
/**
* Computes an OrientedBoundingBox given extents in the east-north-up space of the tangent plane.
*
+ * @param {Plane} tangentPlane The tangent place corresponding to east-north-up.
* @param {Number} minimumX Minimum X extent in tangent plane space.
* @param {Number} maximumX Maximum X extent in tangent plane space.
* @param {Number} minimumY Minimum Y extent in tangent plane space.
diff --git a/Source/Core/PolygonGeometry.js b/Source/Core/PolygonGeometry.js
index f8276fa5880b..44c569bde91d 100644
--- a/Source/Core/PolygonGeometry.js
+++ b/Source/Core/PolygonGeometry.js
@@ -123,7 +123,8 @@ define([
function computeAttributes(options) {
var vertexFormat = options.vertexFormat;
var geometry = options.geometry;
- if (vertexFormat.st || vertexFormat.normal || vertexFormat.tangent || vertexFormat.binormal) {
+ var shadowVolume = options.shadowVolume;
+ if (vertexFormat.st || vertexFormat.normal || vertexFormat.tangent || vertexFormat.binormal || shadowVolume) {
// PERFORMANCE_IDEA: Compute before subdivision, then just interpolate during subdivision.
// PERFORMANCE_IDEA: Compute with createGeometryFromPositions() for fast path when there's no holes.
var boundingRectangle = options.boundingRectangle;
@@ -153,6 +154,7 @@ define([
}
var tangents = vertexFormat.tangent ? new Float32Array(length) : undefined;
var binormals = vertexFormat.binormal ? new Float32Array(length) : undefined;
+ var extrudeNormals = shadowVolume ? new Float32Array(length) : undefined;
var textureCoordIndex = 0;
var attrIndex = 0;
@@ -198,7 +200,7 @@ define([
textureCoordIndex += 2;
}
- if (vertexFormat.normal || vertexFormat.tangent || vertexFormat.binormal) {
+ if (vertexFormat.normal || vertexFormat.tangent || vertexFormat.binormal || shadowVolume) {
var attrIndex1 = attrIndex + 1;
var attrIndex2 = attrIndex + 2;
@@ -266,6 +268,15 @@ define([
}
}
+ if (shadowVolume) {
+ if (wall) {
+ normal = ellipsoid.geodeticSurfaceNormal(position, normal);
+ }
+ extrudeNormals[attrIndex + bottomOffset] = -normal.x;
+ extrudeNormals[attrIndex1 + bottomOffset] = -normal.y;
+ extrudeNormals[attrIndex2 + bottomOffset] = -normal.z;
+ }
+
if (vertexFormat.tangent) {
if (options.wall) {
tangents[attrIndex + bottomOffset] = tangent.x;
@@ -343,6 +354,14 @@ define([
values : binormals
});
}
+
+ if (shadowVolume) {
+ geometry.attributes.extrudeDirection = new GeometryAttribute({
+ componentDatatype : ComponentDatatype.FLOAT,
+ componentsPerAttribute : 3,
+ values : extrudeNormals
+ });
+ }
}
return geometry;
}
@@ -365,13 +384,13 @@ define([
if (closeTop && closeBottom) {
var topBottomPositions = edgePoints.concat(edgePoints);
+
numPositions = topBottomPositions.length / 3;
newIndices = IndexDatatype.createTypedArray(numPositions, indices.length * 2);
newIndices.set(indices);
var ilength = indices.length;
-
var length = numPositions / 2;
for (i = 0; i < ilength; i += 3) {
@@ -579,6 +598,7 @@ define([
this._closeBottom = defaultValue(options.closeBottom, true);
this._polygonHierarchy = polygonHierarchy;
this._perPositionHeight = perPositionHeight;
+ this._shadowVolume = defaultValue(options.shadowVolume, false);
this._workerName = 'createPolygonGeometry';
var positions = polygonHierarchy.positions;
@@ -592,7 +612,7 @@ define([
* The number of elements used to pack the object into an array.
* @type {Number}
*/
- this.packedLength = PolygonGeometryLibrary.computeHierarchyPackedLength(polygonHierarchy) + Ellipsoid.packedLength + VertexFormat.packedLength + Rectangle.packedLength + 9;
+ this.packedLength = PolygonGeometryLibrary.computeHierarchyPackedLength(polygonHierarchy) + Ellipsoid.packedLength + VertexFormat.packedLength + Rectangle.packedLength + 10;
}
/**
@@ -693,6 +713,7 @@ define([
array[startingIndex++] = value._perPositionHeight ? 1.0 : 0.0;
array[startingIndex++] = value._closeTop ? 1.0 : 0.0;
array[startingIndex++] = value._closeBottom ? 1.0 : 0.0;
+ array[startingIndex++] = value._shadowVolume ? 1.0 : 0.0;
array[startingIndex] = value.packedLength;
return array;
@@ -744,6 +765,7 @@ define([
var perPositionHeight = array[startingIndex++] === 1.0;
var closeTop = array[startingIndex++] === 1.0;
var closeBottom = array[startingIndex++] === 1.0;
+ var shadowVolume = array[startingIndex++] === 1.0;
var packedLength = array[startingIndex];
if (!defined(result)) {
@@ -762,6 +784,7 @@ define([
result._closeTop = closeTop;
result._closeBottom = closeBottom;
result._rectangle = Rectangle.clone(rectangle);
+ result._shadowVolume = shadowVolume;
result.packedLength = packedLength;
return result;
};
@@ -824,6 +847,7 @@ define([
if (extrude) {
options.top = closeTop;
options.bottom = closeBottom;
+ options.shadowVolume = polygonGeometry._shadowVolume;
for (i = 0; i < polygons.length; i++) {
geometry = createGeometryFromPositionsExtruded(ellipsoid, polygons[i], granularity, hierarchy[i], perPositionHeight, closeTop, closeBottom, vertexFormat);
@@ -904,7 +928,8 @@ define([
perPositionHeight : false,
extrudedHeight : minHeight,
height : maxHeight,
- vertexFormat : VertexFormat.POSITION_ONLY
+ vertexFormat : VertexFormat.POSITION_ONLY,
+ shadowVolume: true
});
};
diff --git a/Source/Core/PolylinePipeline.js b/Source/Core/PolylinePipeline.js
index 99422e918513..51f642a88fd8 100644
--- a/Source/Core/PolylinePipeline.js
+++ b/Source/Core/PolylinePipeline.js
@@ -202,10 +202,10 @@ define([
/**
* Subdivides polyline and raises all points to the specified height. Returns an array of numbers to represent the positions.
- * @param {Cartesian3[]} positions The array of type {Cartesian3} representing positions.
- * @param {Number|Number[]} [height=0.0] A number or array of numbers representing the heights of each position.
- * @param {Number} [granularity = CesiumMath.RADIANS_PER_DEGREE] The distance, in radians, between each latitude and longitude. Determines the number of positions in the buffer.
- * @param {Ellipsoid} [ellipsoid=Ellipsoid.WGS84] The ellipsoid on which the positions lie.
+ * @param {Cartesian3[]} options.positions The array of type {Cartesian3} representing positions.
+ * @param {Number|Number[]} [options.height=0.0] A number or array of numbers representing the heights of each position.
+ * @param {Number} [options.granularity = CesiumMath.RADIANS_PER_DEGREE] The distance, in radians, between each latitude and longitude. Determines the number of positions in the buffer.
+ * @param {Ellipsoid} [options.ellipsoid=Ellipsoid.WGS84] The ellipsoid on which the positions lie.
* @returns {Number[]} A new array of positions of type {Number} that have been subdivided and raised to the surface of the ellipsoid.
*
* @example
@@ -289,10 +289,10 @@ define([
/**
* Subdivides polyline and raises all points to the specified height. Returns an array of new {Cartesian3} positions.
- * @param {Cartesian3[]} positions The array of type {Cartesian3} representing positions.
- * @param {Number|Number[]} [height=0.0] A number or array of numbers representing the heights of each position.
- * @param {Number} [granularity = CesiumMath.RADIANS_PER_DEGREE] The distance, in radians, between each latitude and longitude. Determines the number of positions in the buffer.
- * @param {Ellipsoid} [ellipsoid=Ellipsoid.WGS84] The ellipsoid on which the positions lie.
+ * @param {Cartesian3[]} options.positions The array of type {Cartesian3} representing positions.
+ * @param {Number|Number[]} [options.height=0.0] A number or array of numbers representing the heights of each position.
+ * @param {Number} [options.granularity = CesiumMath.RADIANS_PER_DEGREE] The distance, in radians, between each latitude and longitude. Determines the number of positions in the buffer.
+ * @param {Ellipsoid} [options.ellipsoid=Ellipsoid.WGS84] The ellipsoid on which the positions lie.
* @returns {Cartesian3[]} A new array of cartesian3 positions that have been subdivided and raised to the surface of the ellipsoid.
*
* @example
diff --git a/Source/Core/Quaternion.js b/Source/Core/Quaternion.js
index bef64c819ff8..ea095baf1e23 100644
--- a/Source/Core/Quaternion.js
+++ b/Source/Core/Quaternion.js
@@ -1,6 +1,7 @@
/*global define*/
define([
'./Cartesian3',
+ './Check',
'./defaultValue',
'./defined',
'./DeveloperError',
@@ -10,6 +11,7 @@ define([
'./Matrix3'
], function(
Cartesian3,
+ Check,
defaultValue,
defined,
DeveloperError,
@@ -73,12 +75,8 @@ define([
*/
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.');
- }
+ Check.typeOf.object(axis, 'axis');
+ Check.typeOf.number(angle, 'angle');
//>>includeEnd('debug');
var halfAngle = angle / 2.0;
@@ -112,9 +110,7 @@ define([
*/
Quaternion.fromRotationMatrix = function(matrix, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(matrix)) {
- throw new DeveloperError('matrix is required.');
- }
+ Check.typeOf.object(matrix, 'matrix');
//>>includeEnd('debug');
var root;
@@ -190,15 +186,9 @@ define([
*/
Quaternion.fromHeadingPitchRoll = function(heading, pitch, roll, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(heading)) {
- throw new DeveloperError('heading is required.');
- }
- if (!defined(pitch)) {
- throw new DeveloperError('pitch is required.');
- }
- if (!defined(roll)) {
- throw new DeveloperError('roll is required.');
- }
+ Check.typeOf.number(heading, 'heading');
+ Check.typeOf.number(pitch, 'pitch');
+ Check.typeOf.number(roll, 'roll');
//>>includeEnd('debug');
var rollQuaternion = Quaternion.fromAxisAngle(Cartesian3.UNIT_X, roll, scratchHPRQuaternion);
@@ -231,13 +221,8 @@ define([
*/
Quaternion.pack = function(value, array, startingIndex) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(value)) {
- throw new DeveloperError('value is required');
- }
-
- if (!defined(array)) {
- throw new DeveloperError('array is required');
- }
+ Check.typeOf.object(value, 'value');
+ Check.defined(array, 'array');
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
@@ -260,9 +245,7 @@ define([
*/
Quaternion.unpack = function(array, startingIndex, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(array)) {
- throw new DeveloperError('array is required');
- }
+ Check.defined(array, 'array');
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
@@ -318,7 +301,7 @@ define([
*
* @param {Number[]} array The array previously packed for interpolation.
* @param {Number[]} sourceArray The original packed array.
- * @param {Number} [startingIndex=0] The startingIndex used to convert the array.
+ * @param {Number} [firstIndex=0] The firstIndex used to convert the array.
* @param {Number} [lastIndex=packedArray.length] The lastIndex used to convert the array.
* @param {Quaternion} [result] The object into which to store the result.
* @returns {Quaternion} The modified result parameter or a new Quaternion instance if one was not provided.
@@ -373,12 +356,8 @@ define([
*/
Quaternion.conjugate = function(quaternion, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(quaternion)) {
- throw new DeveloperError('quaternion is required');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(quaternion, 'quaternion');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
result.x = -quaternion.x;
@@ -396,9 +375,7 @@ define([
*/
Quaternion.magnitudeSquared = function(quaternion) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(quaternion)) {
- throw new DeveloperError('quaternion is required');
- }
+ Check.typeOf.object(quaternion, 'quaternion');
//>>includeEnd('debug');
return quaternion.x * quaternion.x + quaternion.y * quaternion.y + quaternion.z * quaternion.z + quaternion.w * quaternion.w;
@@ -423,9 +400,7 @@ define([
*/
Quaternion.normalize = function(quaternion, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
var inverseMagnitude = 1.0 / Quaternion.magnitude(quaternion);
@@ -450,9 +425,7 @@ define([
*/
Quaternion.inverse = function(quaternion, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
var magnitudeSquared = Quaternion.magnitudeSquared(quaternion);
@@ -470,15 +443,9 @@ define([
*/
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');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(left, 'left');
+ Check.typeOf.object(right, 'right');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
result.x = left.x + right.x;
@@ -498,15 +465,9 @@ define([
*/
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');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(left, 'left');
+ Check.typeOf.object(right, 'right');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
result.x = left.x - right.x;
@@ -525,12 +486,8 @@ define([
*/
Quaternion.negate = function(quaternion, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(quaternion)) {
- throw new DeveloperError('quaternion is required');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(quaternion, 'quaternion');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
result.x = -quaternion.x;
@@ -549,12 +506,8 @@ define([
*/
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');
- }
+ Check.typeOf.object(left, 'left');
+ Check.typeOf.object(right, 'right');
//>>includeEnd('debug');
return left.x * right.x + left.y * right.y + left.z * right.z + left.w * right.w;
@@ -570,15 +523,9 @@ define([
*/
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');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(left, 'left');
+ Check.typeOf.object(right, 'right');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
var leftX = left.x;
@@ -613,15 +560,9 @@ define([
*/
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.');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(quaternion, 'quaternion');
+ Check.typeOf.number(scalar, 'scalar');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
result.x = quaternion.x * scalar;
@@ -641,15 +582,9 @@ define([
*/
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.');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(quaternion, 'quaternion');
+ Check.typeOf.number(scalar, 'scalar');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
result.x = quaternion.x / scalar;
@@ -668,12 +603,8 @@ define([
*/
Quaternion.computeAxis = function(quaternion, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(quaternion)) {
- throw new DeveloperError('quaternion is required');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(quaternion, 'quaternion');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
var w = quaternion.w;
@@ -698,9 +629,7 @@ define([
*/
Quaternion.computeAngle = function(quaternion) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(quaternion)) {
- throw new DeveloperError('quaternion is required');
- }
+ Check.typeOf.object(quaternion, 'quaternion');
//>>includeEnd('debug');
if (Math.abs(quaternion.w - 1.0) < CesiumMath.EPSILON6) {
@@ -721,18 +650,10 @@ define([
*/
Quaternion.lerp = function(start, end, t, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(start)) {
- throw new DeveloperError('start is required.');
- }
- if (!defined(end)) {
- throw new DeveloperError('end is required.');
- }
- if (typeof t !== 'number') {
- throw new DeveloperError('t is required and must be a number.');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(start, 'start');
+ Check.typeOf.object(end, 'end');
+ Check.typeOf.number(t, 't');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
lerpScratch = Quaternion.multiplyByScalar(end, t, lerpScratch);
@@ -756,18 +677,10 @@ define([
*/
Quaternion.slerp = function(start, end, t, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(start)) {
- throw new DeveloperError('start is required.');
- }
- if (!defined(end)) {
- throw new DeveloperError('end is required.');
- }
- if (typeof t !== 'number') {
- throw new DeveloperError('t is required and must be a number.');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(start, 'start');
+ Check.typeOf.object(end, 'end');
+ Check.typeOf.number(t, 't');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
var dot = Quaternion.dot(start, end);
@@ -802,12 +715,8 @@ define([
*/
Quaternion.log = function(quaternion, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(quaternion)) {
- throw new DeveloperError('quaternion is required.');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(quaternion, 'quaternion');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
var theta = CesiumMath.acosClamped(quaternion.w);
@@ -829,12 +738,8 @@ define([
*/
Quaternion.exp = function(cartesian, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(cartesian)) {
- throw new DeveloperError('cartesian is required.');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(cartesian, 'cartesian');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
var theta = Cartesian3.magnitude(cartesian);
@@ -871,12 +776,10 @@ define([
*/
Quaternion.computeInnerQuadrangle = 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.');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(q0, 'q0');
+ Check.typeOf.object(q1, 'q1');
+ Check.typeOf.object(q2, 'q2');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
var qInv = Quaternion.conjugate(q1, squadScratchQuaternion0);
@@ -920,15 +823,12 @@ define([
*/
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.');
- }
- if (typeof t !== 'number') {
- throw new DeveloperError('t is required and must be a number.');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(q0, 'q0');
+ Check.typeOf.object(q1, 'q1');
+ Check.typeOf.object(s0, 's0');
+ Check.typeOf.object(s1, 's1');
+ Check.typeOf.number(t, 't');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
var slerp0 = Quaternion.slerp(q0, q1, t, squadScratchQuaternion0);
@@ -967,18 +867,10 @@ define([
*/
Quaternion.fastSlerp = function(start, end, t, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(start)) {
- throw new DeveloperError('start is required.');
- }
- if (!defined(end)) {
- throw new DeveloperError('end is required.');
- }
- if (typeof t !== 'number') {
- throw new DeveloperError('t is required and must be a number.');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(start, 'start');
+ Check.typeOf.object(end, 'end');
+ Check.typeOf.number(t, 't');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
var x = Quaternion.dot(start, end);
@@ -1029,15 +921,12 @@ define([
*/
Quaternion.fastSquad = 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.');
- }
- if (typeof t !== 'number') {
- throw new DeveloperError('t is required and must be a number.');
- }
- if (!defined(result)) {
- throw new DeveloperError('result is required');
- }
+ Check.typeOf.object(q0, 'q0');
+ Check.typeOf.object(q1, 'q1');
+ Check.typeOf.object(s0, 's0');
+ Check.typeOf.object(s1, 's1');
+ Check.typeOf.number(t, 't');
+ Check.typeOf.object(result, 'result');
//>>includeEnd('debug');
var slerp0 = Quaternion.fastSlerp(q0, q1, t, squadScratchQuaternion0);
@@ -1075,9 +964,7 @@ define([
*/
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.');
- }
+ Check.typeOf.number(epsilon, 'epsilon');
//>>includeEnd('debug');
return (left === right) ||
diff --git a/Source/Core/Rectangle.js b/Source/Core/Rectangle.js
index e8b8ea1d1888..bc6a5df3e041 100644
--- a/Source/Core/Rectangle.js
+++ b/Source/Core/Rectangle.js
@@ -1,6 +1,7 @@
/*global define*/
define([
'./Cartographic',
+ './Check',
'./defaultValue',
'./defined',
'./defineProperties',
@@ -10,6 +11,7 @@ define([
'./Math'
], function(
Cartographic,
+ Check,
defaultValue,
defined,
defineProperties,
@@ -107,13 +109,8 @@ define([
*/
Rectangle.pack = function(value, array, startingIndex) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(value)) {
- throw new DeveloperError('value is required');
- }
-
- if (!defined(array)) {
- throw new DeveloperError('array is required');
- }
+ Check.typeOf.object(value, 'value');
+ Check.defined(array, 'array');
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
@@ -136,9 +133,7 @@ define([
*/
Rectangle.unpack = function(array, startingIndex, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(array)) {
- throw new DeveloperError('array is required');
- }
+ Check.defined(array, 'array');
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
@@ -161,9 +156,7 @@ define([
*/
Rectangle.computeWidth = function(rectangle) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(rectangle)) {
- throw new DeveloperError('rectangle is required.');
- }
+ Check.typeOf.object(rectangle, 'rectangle');
//>>includeEnd('debug');
var east = rectangle.east;
var west = rectangle.west;
@@ -180,9 +173,7 @@ define([
*/
Rectangle.computeHeight = function(rectangle) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(rectangle)) {
- throw new DeveloperError('rectangle is required.');
- }
+ Check.typeOf.object(rectangle, 'rectangle');
//>>includeEnd('debug');
return rectangle.north - rectangle.south;
};
@@ -227,9 +218,7 @@ define([
*/
Rectangle.fromCartographicArray = function(cartographics, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(cartographics)) {
- throw new DeveloperError('cartographics is required.');
- }
+ Check.defined(cartographics, 'cartographics');
//>>includeEnd('debug');
var west = Number.MAX_VALUE;
@@ -284,9 +273,7 @@ define([
*/
Rectangle.fromCartesianArray = function(cartesians, ellipsoid, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(cartesians)) {
- throw new DeveloperError('cartesians is required.');
- }
+ Check.defined(cartesians, 'cartesians');
//>>includeEnd('debug');
var west = Number.MAX_VALUE;
@@ -404,9 +391,7 @@ define([
*/
Rectangle.prototype.equalsEpsilon = function(other, epsilon) {
//>>includeStart('debug', pragmas.debug);
- if (typeof epsilon !== 'number') {
- throw new DeveloperError('epsilon is required and must be a number.');
- }
+ Check.typeOf.number(epsilon, 'epsilon');
//>>includeEnd('debug');
return defined(other) &&
@@ -428,45 +413,27 @@ define([
*/
Rectangle.validate = function(rectangle) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(rectangle)) {
- throw new DeveloperError('rectangle is required');
- }
+ Check.typeOf.object(rectangle, 'rectangle');
var north = rectangle.north;
- if (typeof north !== 'number') {
- throw new DeveloperError('north is required to be a number.');
- }
-
- if (north < -CesiumMath.PI_OVER_TWO || north > CesiumMath.PI_OVER_TWO) {
- throw new DeveloperError('north must be in the interval [-Pi/2, Pi/2].');
- }
+ Check.typeOf.number(north, 'north');
+ Check.numeric.minimum(north, -CesiumMath.PI_OVER_TWO);
+ Check.numeric.maximum(north, CesiumMath.PI_OVER_TWO);
var south = rectangle.south;
- if (typeof south !== 'number') {
- throw new DeveloperError('south is required to be a number.');
- }
-
- if (south < -CesiumMath.PI_OVER_TWO || south > CesiumMath.PI_OVER_TWO) {
- throw new DeveloperError('south must be in the interval [-Pi/2, Pi/2].');
- }
+ Check.typeOf.number(south, 'south');
+ Check.numeric.minimum(south, -CesiumMath.PI_OVER_TWO);
+ Check.numeric.maximum(south, CesiumMath.PI_OVER_TWO);
var west = rectangle.west;
- if (typeof west !== 'number') {
- throw new DeveloperError('west is required to be a number.');
- }
-
- if (west < -Math.PI || west > Math.PI) {
- throw new DeveloperError('west must be in the interval [-Pi, Pi].');
- }
+ Check.typeOf.number(west, 'west');
+ Check.numeric.minimum(west, -Math.PI);
+ Check.numeric.maximum(west, Math.PI);
var east = rectangle.east;
- if (typeof east !== 'number') {
- throw new DeveloperError('east is required to be a number.');
- }
-
- if (east < -Math.PI || east > Math.PI) {
- throw new DeveloperError('east must be in the interval [-Pi, Pi].');
- }
+ Check.typeOf.number(east, 'east');
+ Check.numeric.minimum(east, -Math.PI);
+ Check.numeric.maximum(east, Math.PI);
//>>includeEnd('debug');
};
@@ -479,9 +446,7 @@ define([
*/
Rectangle.southwest = function(rectangle, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(rectangle)) {
- throw new DeveloperError('rectangle is required');
- }
+ Check.typeOf.object(rectangle, 'rectangle');
//>>includeEnd('debug');
if (!defined(result)) {
@@ -502,9 +467,7 @@ define([
*/
Rectangle.northwest = function(rectangle, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(rectangle)) {
- throw new DeveloperError('rectangle is required');
- }
+ Check.typeOf.object(rectangle, 'rectangle');
//>>includeEnd('debug');
if (!defined(result)) {
@@ -525,9 +488,7 @@ define([
*/
Rectangle.northeast = function(rectangle, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(rectangle)) {
- throw new DeveloperError('rectangle is required');
- }
+ Check.typeOf.object(rectangle, 'rectangle');
//>>includeEnd('debug');
if (!defined(result)) {
@@ -548,9 +509,7 @@ define([
*/
Rectangle.southeast = function(rectangle, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(rectangle)) {
- throw new DeveloperError('rectangle is required');
- }
+ Check.typeOf.object(rectangle, 'rectangle');
//>>includeEnd('debug');
if (!defined(result)) {
@@ -571,9 +530,7 @@ define([
*/
Rectangle.center = function(rectangle, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(rectangle)) {
- throw new DeveloperError('rectangle is required');
- }
+ Check.typeOf.object(rectangle, 'rectangle');
//>>includeEnd('debug');
var east = rectangle.east;
@@ -610,12 +567,8 @@ define([
*/
Rectangle.intersection = function(rectangle, otherRectangle, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(rectangle)) {
- throw new DeveloperError('rectangle is required');
- }
- if (!defined(otherRectangle)) {
- throw new DeveloperError('otherRectangle is required.');
- }
+ Check.typeOf.object(rectangle, 'rectangle');
+ Check.typeOf.object(otherRectangle, 'otherRectangle');
//>>includeEnd('debug');
var rectangleEast = rectangle.east;
@@ -673,12 +626,8 @@ define([
*/
Rectangle.simpleIntersection = function(rectangle, otherRectangle, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(rectangle)) {
- throw new DeveloperError('rectangle is required');
- }
- if (!defined(otherRectangle)) {
- throw new DeveloperError('otherRectangle is required.');
- }
+ Check.typeOf.object(rectangle, 'rectangle');
+ Check.typeOf.object(otherRectangle, 'otherRectangle');
//>>includeEnd('debug');
var west = Math.max(rectangle.west, otherRectangle.west);
@@ -711,12 +660,8 @@ define([
*/
Rectangle.union = function(rectangle, otherRectangle, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(rectangle)) {
- throw new DeveloperError('rectangle is required');
- }
- if (!defined(otherRectangle)) {
- throw new DeveloperError('otherRectangle is required.');
- }
+ Check.typeOf.object(rectangle, 'rectangle');
+ Check.typeOf.object(otherRectangle, 'otherRectangle');
//>>includeEnd('debug');
if (!defined(result)) {
@@ -762,12 +707,8 @@ define([
*/
Rectangle.expand = function(rectangle, cartographic, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(rectangle)) {
- throw new DeveloperError('rectangle is required.');
- }
- if (!defined(cartographic)) {
- throw new DeveloperError('cartographic is required.');
- }
+ Check.typeOf.object(rectangle, 'rectangle');
+ Check.typeOf.object(cartographic, 'cartographic');
//>>includeEnd('debug');
if (!defined(result)) {
@@ -791,12 +732,8 @@ define([
*/
Rectangle.contains = function(rectangle, cartographic) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(rectangle)) {
- throw new DeveloperError('rectangle is required');
- }
- if (!defined(cartographic)) {
- throw new DeveloperError('cartographic is required.');
- }
+ Check.typeOf.object(rectangle, 'rectangle');
+ Check.typeOf.object(cartographic, 'cartographic');
//>>includeEnd('debug');
var longitude = cartographic.longitude;
@@ -831,9 +768,7 @@ define([
*/
Rectangle.subsample = function(rectangle, ellipsoid, surfaceHeight, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(rectangle)) {
- throw new DeveloperError('rectangle is required');
- }
+ Check.typeOf.object(rectangle, 'rectangle');
//>>includeEnd('debug');
ellipsoid = defaultValue(ellipsoid, Ellipsoid.WGS84);
diff --git a/Source/Core/RectangleGeometry.js b/Source/Core/RectangleGeometry.js
index 420b95cceeb4..4ee7ff3bb69d 100644
--- a/Source/Core/RectangleGeometry.js
+++ b/Source/Core/RectangleGeometry.js
@@ -330,7 +330,9 @@ define([
return wallTextures;
}
+ var scratchVertexFormat = new VertexFormat();
function constructExtrudedRectangle(options) {
+ var shadowVolume = options.shadowVolume;
var vertexFormat = options.vertexFormat;
var surfaceHeight = options.surfaceHeight;
var extrudedHeight = options.extrudedHeight;
@@ -342,10 +344,15 @@ define([
var ellipsoid = options.ellipsoid;
var i;
+ if (shadowVolume) {
+ options.vertexFormat = VertexFormat.clone(vertexFormat, scratchVertexFormat);
+ options.vertexFormat.normal = true;
+ }
var topBottomGeo = constructRectangle(options);
if (CesiumMath.equalsEpsilon(minHeight, maxHeight, CesiumMath.EPSILON10)) {
return topBottomGeo;
}
+
var topPositions = PolygonPipeline.scaleToGeodeticHeight(topBottomGeo.attributes.position.values, maxHeight, ellipsoid, false);
topPositions = new Float64Array(topPositions);
var length = topPositions.length;
@@ -361,8 +368,9 @@ define([
var binormals = (vertexFormat.binormal) ? new Float32Array(newLength) : undefined;
var textures = (vertexFormat.st) ? new Float32Array(newLength/3*2) : undefined;
var topSt;
+ var topNormals;
if (vertexFormat.normal) {
- var topNormals = topBottomGeo.attributes.normal.values;
+ topNormals = topBottomGeo.attributes.normal.values;
normals.set(topNormals);
for (i = 0; i < length; i ++) {
topNormals[i] = -topNormals[i];
@@ -370,6 +378,23 @@ define([
normals.set(topNormals, length);
topBottomGeo.attributes.normal.values = normals;
}
+ if (shadowVolume) {
+ topNormals = topBottomGeo.attributes.normal.values;
+ if (!vertexFormat.normal) {
+ topBottomGeo.attributes.normal = undefined;
+ }
+ var extrudeNormals = new Float32Array(newLength);
+ for (i = 0; i < length; i ++) {
+ topNormals[i] = -topNormals[i];
+ }
+ extrudeNormals.set(topNormals, length); //only get normals for bottom layer that's going to be pushed down
+ topBottomGeo.attributes.extrudeDirection = new GeometryAttribute({
+ componentDatatype : ComponentDatatype.FLOAT,
+ componentsPerAttribute : 3,
+ values : extrudeNormals
+ });
+ }
+
if (vertexFormat.tangent) {
var topTangents = topBottomGeo.attributes.tangent.values;
tangents.set(topTangents);
@@ -408,45 +433,76 @@ define([
var wallCount = (perimeterPositions + 4) * 2;
var wallPositions = new Float64Array(wallCount * 3);
+ var wallExtrudeNormals = shadowVolume ? new Float32Array(wallCount * 3) : undefined;
var wallTextures = (vertexFormat.st) ? new Float32Array(wallCount * 2) : undefined;
var posIndex = 0;
var stIndex = 0;
+ var extrudeNormalIndex = 0;
var area = width * height;
+ var threeI;
for (i = 0; i < area; i+=width) {
- wallPositions = addWallPositions(wallPositions, posIndex, i*3, topPositions, bottomPositions);
+ threeI = i * 3;
+ wallPositions = addWallPositions(wallPositions, posIndex, threeI, topPositions, bottomPositions);
posIndex += 6;
if (vertexFormat.st) {
wallTextures = addWallTextureCoordinates(wallTextures, stIndex, i*2, topSt);
stIndex += 4;
}
+ if (shadowVolume) {
+ extrudeNormalIndex += 3;
+ wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI];
+ wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI + 1];
+ wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI + 2];
+ }
}
for (i = area-width; i < area; i++) {
- wallPositions = addWallPositions(wallPositions, posIndex, i*3, topPositions, bottomPositions);
+ threeI = i * 3;
+ wallPositions = addWallPositions(wallPositions, posIndex, threeI, topPositions, bottomPositions);
posIndex += 6;
if (vertexFormat.st) {
wallTextures = addWallTextureCoordinates(wallTextures, stIndex, i*2, topSt);
stIndex += 4;
}
+ if (shadowVolume) {
+ extrudeNormalIndex += 3;
+ wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI];
+ wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI + 1];
+ wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI + 2];
+ }
}
for (i = area-1; i > 0; i-=width) {
- wallPositions = addWallPositions(wallPositions, posIndex, i*3, topPositions, bottomPositions);
+ threeI = i * 3;
+ wallPositions = addWallPositions(wallPositions, posIndex, threeI, topPositions, bottomPositions);
posIndex += 6;
if (vertexFormat.st) {
wallTextures = addWallTextureCoordinates(wallTextures, stIndex, i*2, topSt);
stIndex += 4;
}
+ if (shadowVolume) {
+ extrudeNormalIndex += 3;
+ wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI];
+ wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI + 1];
+ wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI + 2];
+ }
}
for (i = width-1; i >= 0; i--) {
- wallPositions = addWallPositions(wallPositions, posIndex, i*3, topPositions, bottomPositions);
+ threeI = i * 3;
+ wallPositions = addWallPositions(wallPositions, posIndex, threeI, topPositions, bottomPositions);
posIndex += 6;
if (vertexFormat.st) {
wallTextures = addWallTextureCoordinates(wallTextures, stIndex, i*2, topSt);
stIndex += 4;
}
+ if (shadowVolume) {
+ extrudeNormalIndex += 3;
+ wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI];
+ wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI + 1];
+ wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI + 2];
+ }
}
var geo = calculateAttributesWall(wallPositions, vertexFormat, ellipsoid);
@@ -458,6 +514,13 @@ define([
values : wallTextures
});
}
+ if (shadowVolume) {
+ geo.attributes.extrudeDirection = new GeometryAttribute({
+ componentDatatype : ComponentDatatype.FLOAT,
+ componentsPerAttribute : 3,
+ values : wallExtrudeNormals
+ });
+ }
var wallIndices = IndexDatatype.createTypedArray(wallCount, perimeterPositions * 6);
@@ -582,16 +645,6 @@ define([
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
var rectangle = options.rectangle;
- var granularity = defaultValue(options.granularity, CesiumMath.RADIANS_PER_DEGREE);
- var ellipsoid = defaultValue(options.ellipsoid, Ellipsoid.WGS84);
- var surfaceHeight = defaultValue(options.height, 0.0);
- var rotation = defaultValue(options.rotation, 0.0);
- var stRotation = defaultValue(options.stRotation, 0.0);
- var vertexFormat = defaultValue(options.vertexFormat, VertexFormat.DEFAULT);
- var extrudedHeight = options.extrudedHeight;
- var extrude = defined(extrudedHeight);
- var closeTop = defaultValue(options.closeTop, true);
- var closeBottom = defaultValue(options.closeBottom, true);
//>>includeStart('debug', pragmas.debug);
if (!defined(rectangle)) {
@@ -603,17 +656,19 @@ define([
}
//>>includeEnd('debug');
+ var rotation = defaultValue(options.rotation, 0.0);
this._rectangle = rectangle;
- this._granularity = granularity;
- this._ellipsoid = Ellipsoid.clone(ellipsoid);
- this._surfaceHeight = surfaceHeight;
+ this._granularity = defaultValue(options.granularity, CesiumMath.RADIANS_PER_DEGREE);
+ this._ellipsoid = Ellipsoid.clone(defaultValue(options.ellipsoid, Ellipsoid.WGS84));
+ this._surfaceHeight = defaultValue(options.height, 0.0);
this._rotation = rotation;
- this._stRotation = stRotation;
- this._vertexFormat = VertexFormat.clone(vertexFormat);
- this._extrudedHeight = defaultValue(extrudedHeight, 0.0);
- this._extrude = extrude;
- this._closeTop = closeTop;
- this._closeBottom = closeBottom;
+ this._stRotation = defaultValue(options.stRotation, 0.0);
+ this._vertexFormat = VertexFormat.clone(defaultValue(options.vertexFormat, VertexFormat.DEFAULT));
+ this._extrudedHeight = defaultValue(options.extrudedHeight, 0.0);
+ this._extrude = defined(options.extrudedHeight);
+ this._closeTop = defaultValue(options.closeTop, true);
+ this._closeBottom = defaultValue(options.closeBottom, true);
+ this._shadowVolume = defaultValue(options.shadowVolume, false);
this._workerName = 'createRectangleGeometry';
this._rotatedRectangle = computeRectangle(this._rectangle, this._ellipsoid, rotation);
}
@@ -622,7 +677,7 @@ define([
* The number of elements used to pack the object into an array.
* @type {Number}
*/
- RectangleGeometry.packedLength = Rectangle.packedLength + Ellipsoid.packedLength + VertexFormat.packedLength + Rectangle.packedLength + 8;
+ RectangleGeometry.packedLength = Rectangle.packedLength + Ellipsoid.packedLength + VertexFormat.packedLength + Rectangle.packedLength + 9;
/**
* Stores the provided instance into the provided array.
@@ -665,7 +720,8 @@ define([
array[startingIndex++] = value._extrudedHeight;
array[startingIndex++] = value._extrude ? 1.0 : 0.0;
array[startingIndex++] = value._closeTop ? 1.0 : 0.0;
- array[startingIndex] = value._closeBottom ? 1.0 : 0.0;
+ array[startingIndex++] = value._closeBottom ? 1.0 : 0.0;
+ array[startingIndex] = value._shadowVolume ? 1.0 : 0.0;
return array;
};
@@ -673,7 +729,6 @@ define([
var scratchRectangle = new Rectangle();
var scratchRotatedRectangle = new Rectangle();
var scratchEllipsoid = Ellipsoid.clone(Ellipsoid.UNIT_SPHERE);
- var scratchVertexFormat = new VertexFormat();
var scratchOptions = {
rectangle : scratchRectangle,
ellipsoid : scratchEllipsoid,
@@ -684,7 +739,8 @@ define([
stRotation : undefined,
extrudedHeight : undefined,
closeTop : undefined,
- closeBottom : undefined
+ closeBottom : undefined,
+ shadowVolume: undefined
};
/**
@@ -723,7 +779,8 @@ define([
var extrudedHeight = array[startingIndex++];
var extrude = array[startingIndex++] === 1.0;
var closeTop = array[startingIndex++] === 1.0;
- var closeBottom = array[startingIndex] === 1.0;
+ var closeBottom = array[startingIndex++] === 1.0;
+ var shadowVolume = array[startingIndex] === 1.0;
if (!defined(result)) {
scratchOptions.granularity = granularity;
@@ -733,6 +790,7 @@ define([
scratchOptions.extrudedHeight = extrude ? extrudedHeight : undefined;
scratchOptions.closeTop = closeTop;
scratchOptions.closeBottom = closeBottom;
+ scratchOptions.shadowVolume = shadowVolume;
return new RectangleGeometry(scratchOptions);
}
@@ -748,6 +806,7 @@ define([
result._closeTop = closeTop;
result._closeBottom = closeBottom;
result._rotatedRectangle = rotatedRectangle;
+ result._shadowVolume = shadowVolume;
return result;
};
@@ -804,6 +863,7 @@ define([
var boundingSphere;
rectangle = rectangleGeometry._rectangle;
if (extrude) {
+ options.shadowVolume = rectangleGeometry._shadowVolume;
geometry = constructExtrudedRectangle(options);
var topBS = BoundingSphere.fromRectangle3D(rectangle, ellipsoid, surfaceHeight, topBoundingSphere);
var bottomBS = BoundingSphere.fromRectangle3D(rectangle, ellipsoid, extrudedHeight, bottomBoundingSphere);
@@ -819,7 +879,7 @@ define([
}
return new Geometry({
- attributes : new GeometryAttributes(geometry.attributes),
+ attributes : geometry.attributes,
indices : geometry.indices,
primitiveType : geometry.primitiveType,
boundingSphere : boundingSphere
@@ -847,7 +907,8 @@ define([
height : minHeight,
closeTop : true,
closeBottom : true,
- vertexFormat : VertexFormat.POSITION_ONLY
+ vertexFormat : VertexFormat.POSITION_ONLY,
+ shadowVolume: true
});
};
diff --git a/Source/Core/Simon1994PlanetaryPositions.js b/Source/Core/Simon1994PlanetaryPositions.js
index 84cc17a037c3..1a824012333e 100644
--- a/Source/Core/Simon1994PlanetaryPositions.js
+++ b/Source/Core/Simon1994PlanetaryPositions.js
@@ -509,9 +509,9 @@ define([
* @param {Cartesian3} [result] The object onto which to store the result.
* @returns {Cartesian3} Calculated sun position
*/
- Simon1994PlanetaryPositions.computeSunPositionInEarthInertialFrame= function(date, result){
- if (!defined(date)) {
- date = JulianDate.now();
+ Simon1994PlanetaryPositions.computeSunPositionInEarthInertialFrame= function(julianDate, result){
+ if (!defined(julianDate)) {
+ julianDate = JulianDate.now();
}
if (!defined(result)) {
@@ -519,11 +519,11 @@ define([
}
//first forward transformation
- translation = computeSimonEarthMoonBarycenter(date, translation);
+ translation = computeSimonEarthMoonBarycenter(julianDate, translation);
result = Cartesian3.negate(translation, result);
//second forward transformation
- computeSimonEarth(date, translation);
+ computeSimonEarth(julianDate, translation);
Cartesian3.subtract(result, translation, result);
Matrix3.multiplyByVector(axesTransformation, result, result);
@@ -538,12 +538,12 @@ define([
* @param {Cartesian3} [result] The object onto which to store the result.
* @returns {Cartesian3} Calculated moon position
*/
- Simon1994PlanetaryPositions.computeMoonPositionInEarthInertialFrame = function(date, result){
- if (!defined(date)) {
- date = JulianDate.now();
+ Simon1994PlanetaryPositions.computeMoonPositionInEarthInertialFrame = function(julianDate, result){
+ if (!defined(julianDate)) {
+ julianDate = JulianDate.now();
}
- result = computeSimonMoon(date, result);
+ result = computeSimonMoon(julianDate, result);
Matrix3.multiplyByVector(axesTransformation, result, result);
return result;
diff --git a/Source/Core/SphereGeometry.js b/Source/Core/SphereGeometry.js
index 4e8ac00ca349..a05f58a854a4 100644
--- a/Source/Core/SphereGeometry.js
+++ b/Source/Core/SphereGeometry.js
@@ -1,6 +1,7 @@
/*global define*/
define([
'./Cartesian3',
+ './Check',
'./defaultValue',
'./defined',
'./DeveloperError',
@@ -8,6 +9,7 @@ define([
'./VertexFormat'
], function(
Cartesian3,
+ Check,
defaultValue,
defined,
DeveloperError,
@@ -70,9 +72,7 @@ define([
*/
SphereGeometry.pack = function(value, array, startingIndex) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(value)) {
- throw new DeveloperError('value is required');
- }
+ Check.typeOf.object(value, 'value');
//>>includeEnd('debug');
return EllipsoidGeometry.pack(value._ellipsoidGeometry, array, startingIndex);
diff --git a/Source/Core/SphereOutlineGeometry.js b/Source/Core/SphereOutlineGeometry.js
index 1d1a627d19fa..e74f9961e727 100644
--- a/Source/Core/SphereOutlineGeometry.js
+++ b/Source/Core/SphereOutlineGeometry.js
@@ -1,12 +1,14 @@
/*global define*/
define([
'./Cartesian3',
+ './Check',
'./defaultValue',
'./defined',
'./DeveloperError',
'./EllipsoidOutlineGeometry'
], function(
Cartesian3,
+ Check,
defaultValue,
defined,
DeveloperError,
@@ -68,9 +70,7 @@ define([
*/
SphereOutlineGeometry.pack = function(value, array, startingIndex) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(value)) {
- throw new DeveloperError('value is required');
- }
+ Check.typeOf.object(value, 'value');
//>>includeEnd('debug');
return EllipsoidOutlineGeometry.pack(value._ellipsoidGeometry, array, startingIndex);
diff --git a/Source/Core/Spherical.js b/Source/Core/Spherical.js
index 0222c247a6cb..b87c7c9466e7 100644
--- a/Source/Core/Spherical.js
+++ b/Source/Core/Spherical.js
@@ -1,9 +1,11 @@
/*global define*/
define([
+ './Check',
'./defaultValue',
'./defined',
'./DeveloperError'
], function(
+ Check,
defaultValue,
defined,
DeveloperError) {
@@ -29,14 +31,12 @@ define([
* Converts the provided Cartesian3 into Spherical coordinates.
*
* @param {Cartesian3} cartesian3 The Cartesian3 to be converted to Spherical.
- * @param {Spherical} [spherical] The object in which the result will be stored, if undefined a new instance will be created.
+ * @param {Spherical} [result] The object in which the result will be stored, if undefined a new instance will be created.
* @returns {Spherical} The modified result parameter, or a new instance if one was not provided.
*/
Spherical.fromCartesian3 = function(cartesian3, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(cartesian3)) {
- throw new DeveloperError('cartesian3 is required');
- }
+ Check.typeOf.object(cartesian3, 'cartesian3');
//>>includeEnd('debug');
var x = cartesian3.x;
@@ -85,9 +85,7 @@ define([
*/
Spherical.normalize = function(spherical, result) {
//>>includeStart('debug', pragmas.debug);
- if (!defined(spherical)) {
- throw new DeveloperError('spherical is required');
- }
+ Check.typeOf.object(spherical, 'spherical');
//>>includeEnd('debug');
if (!defined(result)) {
diff --git a/Source/Core/TerrainMesh.js b/Source/Core/TerrainMesh.js
index de2534d819c9..4c25c7990ecf 100644
--- a/Source/Core/TerrainMesh.js
+++ b/Source/Core/TerrainMesh.js
@@ -27,6 +27,7 @@ define([
* @param {Number} [vertexStride=6] The number of components in each vertex.
* @param {OrientedBoundingBox} [orientedBoundingBox] A bounding box that completely contains the tile.
* @param {TerrainEncoding} encoding Information used to decode the mesh.
+ * @param {Number} exaggeration The amount that this mesh was exaggerated.
*
* @private
*/
diff --git a/Source/Core/TimeIntervalCollection.js b/Source/Core/TimeIntervalCollection.js
index bc1c79ebbd38..0dd6e21784aa 100644
--- a/Source/Core/TimeIntervalCollection.js
+++ b/Source/Core/TimeIntervalCollection.js
@@ -217,8 +217,8 @@ define([
* @param {JulianDate} julianDate The date to check.
* @returns {Boolean} true
if the collection contains the specified date, false
otherwise.
*/
- TimeIntervalCollection.prototype.contains = function(date) {
- return this.indexOf(date) >= 0;
+ TimeIntervalCollection.prototype.contains = function(julianDate) {
+ return this.indexOf(julianDate) >= 0;
};
var indexOfScratch = new TimeInterval();
diff --git a/Source/Core/Transforms.js b/Source/Core/Transforms.js
index b02cd3eb6af2..b9ebfef6f1ff 100644
--- a/Source/Core/Transforms.js
+++ b/Source/Core/Transforms.js
@@ -5,9 +5,9 @@ define([
'./Cartesian3',
'./Cartesian4',
'./Cartographic',
+ './Check',
'./defaultValue',
'./defined',
- './deprecationWarning',
'./DeveloperError',
'./EarthOrientationParameters',
'./EarthOrientationParametersSample',
@@ -27,9 +27,9 @@ define([
Cartesian3,
Cartesian4,
Cartographic,
+ Check,
defaultValue,
defined,
- deprecationWarning,
DeveloperError,
EarthOrientationParameters,
EarthOrientationParametersSample,
@@ -473,19 +473,12 @@ define([
* var hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll);
* var transform = Cesium.Transforms.headingPitchRollToFixedFrame(center, hpr);
*/
- Transforms.headingPitchRollToFixedFrame = function(origin, headingPitchRoll, pitch, roll, ellipsoid, result) {
- var heading;
- if (typeof headingPitchRoll === 'object') {
- // Shift arguments using assignments to encourage JIT optimization.
- ellipsoid = pitch;
- result = roll;
- heading = headingPitchRoll.heading;
- pitch = headingPitchRoll.pitch;
- roll = headingPitchRoll.roll;
- } else {
- deprecationWarning('headingPitchRollToFixedFrame', 'headingPitchRollToFixedFrame with separate heading, pitch, and roll arguments was deprecated in 1.27. It will be removed in 1.30. Use a HeadingPitchRoll object.');
- heading = headingPitchRoll;
- }
+ Transforms.headingPitchRollToFixedFrame = function(origin, headingPitchRoll, ellipsoid, result) {
+ Check.typeOf.object(headingPitchRoll, 'headingPitchRoll');
+ var heading = headingPitchRoll.heading;
+ var pitch = headingPitchRoll.pitch;
+ var roll = headingPitchRoll.roll;
+
// checks for required parameters happen in the called functions
var hprQuaternion = Quaternion.fromHeadingPitchRoll(heading, pitch, roll, scratchHPRQuaternion);
var hprMatrix = Matrix4.fromTranslationQuaternionRotationScale(Cartesian3.ZERO, hprQuaternion, scratchScale, scratchHPRMatrix4);
@@ -493,7 +486,6 @@ define([
return Matrix4.multiply(result, hprMatrix, result);
};
- var scratchHPR = new HeadingPitchRoll();
var scratchENUMatrix4 = new Matrix4();
var scratchHPRMatrix3 = new Matrix3();
@@ -518,22 +510,10 @@ define([
* var hpr = new HeadingPitchRoll(heading, pitch, roll);
* var quaternion = Cesium.Transforms.headingPitchRollQuaternion(center, hpr);
*/
- Transforms.headingPitchRollQuaternion = function(origin, headingPitchRoll, pitch, roll, ellipsoid, result) {
- var hpr;
- if (typeof headingPitchRoll === 'object') {
- // Shift arguments using assignment to encourage JIT optimization.
- hpr = headingPitchRoll;
- ellipsoid = pitch;
- result = roll;
- } else {
- deprecationWarning('headingPitchRollQuaternion', 'headingPitchRollQuaternion with separate heading, pitch, and roll arguments was deprecated in 1.27. It will be removed in 1.30. Use a HeadingPitchRoll object.');
- scratchHPR.heading = headingPitchRoll;
- scratchHPR.pitch = pitch;
- scratchHPR.roll = roll;
- hpr = scratchHPR;
- }
+ Transforms.headingPitchRollQuaternion = function(origin, headingPitchRoll, ellipsoid, result) {
// checks for required parameters happen in the called functions
- var transform = Transforms.headingPitchRollToFixedFrame(origin, hpr, ellipsoid, scratchENUMatrix4);
+ Check.typeOf.object(headingPitchRoll, 'headingPitchRoll');
+ var transform = Transforms.headingPitchRollToFixedFrame(origin, headingPitchRoll, ellipsoid, scratchENUMatrix4);
var rotation = Matrix4.getRotation(transform, scratchHPRMatrix3);
return Quaternion.fromRotationMatrix(rotation, result);
};
diff --git a/Source/Core/VertexFormat.js b/Source/Core/VertexFormat.js
index a1709d6c3206..50a8a0c835b2 100644
--- a/Source/Core/VertexFormat.js
+++ b/Source/Core/VertexFormat.js
@@ -285,7 +285,7 @@ define([
/**
* Duplicates a VertexFormat instance.
*
- * @param {VertexFormat} cartesian The vertex format to duplicate.
+ * @param {VertexFormat} vertexFormat The vertex format to duplicate.
* @param {VertexFormat} [result] The object onto which to store the result.
* @returns {VertexFormat} The modified result parameter or a new VertexFormat instance if one was not provided. (Returns undefined if vertexFormat is undefined)
*/
diff --git a/Source/Core/getImagePixels.js b/Source/Core/getImagePixels.js
index f728c81cb164..e65f025eec84 100644
--- a/Source/Core/getImagePixels.js
+++ b/Source/Core/getImagePixels.js
@@ -14,6 +14,8 @@ define([
* @exports getImagePixels
*
* @param {Image} image The image to extract pixels from.
+ * @param {Number} width The width of the image. If not defined, then image.width is assigned.
+ * @param {Number} height The height of the image. If not defined, then image.height is assigned.
* @returns {CanvasPixelArray} The pixels of the image.
*/
function getImagePixels(image, width, height) {
diff --git a/Source/DataSources/CorridorGeometryUpdater.js b/Source/DataSources/CorridorGeometryUpdater.js
index 79bf46bca8a7..839d47b534e0 100644
--- a/Source/DataSources/CorridorGeometryUpdater.js
+++ b/Source/DataSources/CorridorGeometryUpdater.js
@@ -243,7 +243,7 @@ define([
* Gets the property specifying whether the geometry
* casts or receives shadows from each light source.
* @memberof CorridorGeometryUpdater.prototype
- *
+ *
* @type {Property}
* @readonly
*/
@@ -552,6 +552,7 @@ define([
* Creates the dynamic updater to be used when GeometryUpdater#isDynamic is true.
*
* @param {PrimitiveCollection} primitives The primitive collection to use.
+ * @param {PrimitiveCollection} groundPrimitives The ground primitives collection to use.
* @returns {DynamicGeometryUpdater} The dynamic updater used to update the geometry each frame.
*
* @exception {DeveloperError} This instance does not represent dynamic geometry.
diff --git a/Source/DataSources/CzmlDataSource.js b/Source/DataSources/CzmlDataSource.js
index deae371cca05..e2d4cca84f41 100644
--- a/Source/DataSources/CzmlDataSource.js
+++ b/Source/DataSources/CzmlDataSource.js
@@ -1854,7 +1854,7 @@ define([
/**
* Creates a Promise to a new instance loaded with the provided CZML data.
*
- * @param {String|Object} data A url or CZML object to be processed.
+ * @param {String|Object} czml A url or CZML object to be processed.
* @param {Object} [options] An object with the following properties:
* @param {String} [options.sourceUri] Overrides the url to use for resolving relative links.
* @returns {Promise.Number
defining the size of the buffer in bytes. Required if options.typedArray is not given.
* @param {BufferUsage} options.usage Specifies the expected usage pattern of the buffer. On some GL implementations, this can significantly affect performance. See {@link BufferUsage}.
- * @param {IndexDatatype} indexDatatype The datatype of indices in the buffer.
+ * @param {IndexDatatype} options.indexDatatype The datatype of indices in the buffer.
* @returns {IndexBuffer} The index buffer, ready to be attached to a vertex array.
*
* @exception {DeveloperError} Must specify either true
if the primitive should update for a render pass, false
otherwise.
diff --git a/Source/Scene/GoogleEarthImageryProvider.js b/Source/Scene/GoogleEarthImageryProvider.js
index c85499489183..40dfc0ea0836 100644
--- a/Source/Scene/GoogleEarthImageryProvider.js
+++ b/Source/Scene/GoogleEarthImageryProvider.js
@@ -97,7 +97,7 @@ define([
* url : 'https://earth.localdomain',
* channel : 1008
* });
- *
+ *
* @see {@link http://www.w3.org/TR/cors/|Cross-Origin Resource Sharing}
*/
function GoogleEarthImageryProvider(options) {
@@ -571,7 +571,7 @@ define([
* instances. The array may be empty if no features are found at the given location.
* It may also be undefined if picking is not supported.
*/
- GoogleEarthImageryProvider.prototype.pickFeatures = function() {
+ GoogleEarthImageryProvider.prototype.pickFeatures = function(x, y, level, longitude, latitude) {
return undefined;
};
diff --git a/Source/Scene/GridImageryProvider.js b/Source/Scene/GridImageryProvider.js
index 9741cc731896..a761703b9c49 100644
--- a/Source/Scene/GridImageryProvider.js
+++ b/Source/Scene/GridImageryProvider.js
@@ -37,7 +37,7 @@ define([
* @param {Color} [options.color=Color(1.0, 1.0, 1.0, 0.4)] The color to draw grid lines.
* @param {Color} [options.glowColor=Color(0.0, 1.0, 0.0, 0.05)] The color to draw glow for grid lines.
* @param {Number} [options.glowWidth=6] The width of lines used for rendering the line glow effect.
- * @param {Color} [backgroundColor=Color(0.0, 0.5, 0.0, 0.2)] Background fill color.
+ * @param {Color} [options.backgroundColor=Color(0.0, 0.5, 0.0, 0.2)] Background fill color.
* @param {Number} [options.tileWidth=256] The width of the tile for level-of-detail selection purposes.
* @param {Number} [options.tileHeight=256] The height of the tile for level-of-detail selection purposes.
* @param {Number} [options.canvasSize=256] The size of the canvas used for rendering.
@@ -345,7 +345,7 @@ define([
* instances. The array may be empty if no features are found at the given location.
* It may also be undefined if picking is not supported.
*/
- GridImageryProvider.prototype.pickFeatures = function() {
+ GridImageryProvider.prototype.pickFeatures = function(x, y, level, longitude, latitude) {
return undefined;
};
diff --git a/Source/Scene/GroundPrimitive.js b/Source/Scene/GroundPrimitive.js
index 9939662eea12..eadf4b5cfe50 100644
--- a/Source/Scene/GroundPrimitive.js
+++ b/Source/Scene/GroundPrimitive.js
@@ -5,6 +5,7 @@ define([
'../Core/Cartesian2',
'../Core/Cartesian3',
'../Core/Cartographic',
+ '../Core/clone',
'../Core/Color',
'../Core/ColorGeometryInstanceAttribute',
'../Core/defaultValue',
@@ -40,6 +41,7 @@ define([
Cartesian2,
Cartesian3,
Cartographic,
+ clone,
Color,
ColorGeometryInstanceAttribute,
defaultValue,
@@ -196,9 +198,7 @@ define([
/**
* This property is for debugging only; it is not for production use nor is it optimized.
*
- * Draws the shadow volume for each geometry in the primitive. Must be true
on
- * creation for the volumes to be created before the geometry is released or releaseGeometryInstances
- * must be false
+ * Draws the shadow volume for each geometry in the primitive.
*