From af7a83909c1bd01ffffab9cddb63d86b646df6e8 Mon Sep 17 00:00:00 2001 From: ggetz Date: Tue, 13 Oct 2015 20:31:25 -0400 Subject: [PATCH 01/20] added fromAxisBoundingBox function to boxOutlineGeometry and boxGeometry --- Source/Core/BoxGeometry.js | 83 +++++++++++++++++++++++-------- Source/Core/BoxOutlineGeometry.js | 64 +++++++++++++++++++----- 2 files changed, 115 insertions(+), 32 deletions(-) diff --git a/Source/Core/BoxGeometry.js b/Source/Core/BoxGeometry.js index ee262c151be7..acbb8329eb17 100644 --- a/Source/Core/BoxGeometry.js +++ b/Source/Core/BoxGeometry.js @@ -34,8 +34,8 @@ define([ * @constructor * * @param {Object} options Object with the following properties: - * @param {Cartesian3} options.minimumCorner The minimum x, y, and z coordinates of the box. - * @param {Cartesian3} options.maximumCorner The maximum x, y, and z coordinates of the box. + * @param {Cartesian3} options.minimum The minimum x, y, and z coordinates of the box. + * @param {Cartesian3} options.maximum The maximum x, y, and z coordinates of the box. * @param {VertexFormat} [options.vertexFormat=VertexFormat.DEFAULT] The vertex attributes to be computed. * * @see BoxGeometry.fromDimensions @@ -47,29 +47,29 @@ define([ * @example * var box = new Cesium.BoxGeometry({ * vertexFormat : Cesium.VertexFormat.POSITION_ONLY, - * maximumCorner : new Cesium.Cartesian3(250000.0, 250000.0, 250000.0), - * minimumCorner : new Cesium.Cartesian3(-250000.0, -250000.0, -250000.0) + * maximum : new Cesium.Cartesian3(250000.0, 250000.0, 250000.0), + * minimum : new Cesium.Cartesian3(-250000.0, -250000.0, -250000.0) * }); * var geometry = Cesium.BoxGeometry.createGeometry(box); */ var BoxGeometry = function(options) { options = defaultValue(options, defaultValue.EMPTY_OBJECT); - var min = options.minimumCorner; - var max = options.maximumCorner; + var min = options.minimum; + var max = options.maximum; //>>includeStart('debug', pragmas.debug); if (!defined(min)) { - throw new DeveloperError('options.minimumCorner is required.'); + throw new DeveloperError('options.minimum is required.'); } if (!defined(max)) { - throw new DeveloperError('options.maximumCorner is required'); + throw new DeveloperError('options.maximum is required'); } //>>includeEnd('debug'); var vertexFormat = defaultValue(options.vertexFormat, VertexFormat.DEFAULT); - this._minimumCorner = Cartesian3.clone(min); - this._maximumCorner = Cartesian3.clone(max); + this._minimum = Cartesian3.clone(min); + this._maximum = Cartesian3.clone(max); this._vertexFormat = vertexFormat; this._workerName = 'createBoxGeometry'; }; @@ -111,8 +111,51 @@ define([ var max = corner; var newOptions = { - minimumCorner : min, - maximumCorner : max, + minimum : min, + maximum : max, + vertexFormat : options.vertexFormat + }; + return new BoxGeometry(newOptions); + }; + + /** + * Creates a cube from the dimensions of an AxisAlignedBoundingBox. + * + * @param {Object} options Object with the following properties: + * @param {AxisAlignedBoundingBox} options.boundingBox A description of the AxisAlignedBoundingBox. + * @returns {BoxGeometry} + * + * @exception {DeveloperError} AxisAlignedBoundingBox must be defined. + * + * @see BoxGeometry.createGeometry + * + * @example + * var aabb = Cesium.AxisAlignedBoundingBox.fromPoints(Cesium.Cartesian3.fromDegreesArray([ + * -72.0, 40.0, + * -70.0, 35.0, + * -75.0, 30.0, + * -70.0, 30.0, + * -68.0, 40.0 + * ])); + * var box = Cesium.BoxGeometry.fromAxisAlignedBoundingBox({ + * boundingBox: aabb + * }); + * var geometry = Cesium.BoxGeometry.createGeometry(box); + */ + BoxOutlineGeometry.fromAxisAlignedBoundingBox = function(options) { + options = defaultValue(options, defaultValue.EMPTY_OBJECT); + var boundingBox = options.boundingBox; + + if (!defined(boundingBox)) { + throw new DeveloperError('boundingBox is required.'); + } + + var min = boundingBox.minimum; + var max = boundingBox.maximum; + + var newOptions = { + minimum : min, + maximum : max, vertexFormat : options.vertexFormat }; return new BoxGeometry(newOptions); @@ -144,8 +187,8 @@ define([ startingIndex = defaultValue(startingIndex, 0); - Cartesian3.pack(value._minimumCorner, array, startingIndex); - Cartesian3.pack(value._maximumCorner, array, startingIndex + Cartesian3.packedLength); + Cartesian3.pack(value._minimum, array, startingIndex); + Cartesian3.pack(value._maximum, array, startingIndex + Cartesian3.packedLength); VertexFormat.pack(value._vertexFormat, array, startingIndex + 2 * Cartesian3.packedLength); }; @@ -153,8 +196,8 @@ define([ var scratchMax = new Cartesian3(); var scratchVertexFormat = new VertexFormat(); var scratchOptions = { - minimumCorner : scratchMin, - maximumCorner : scratchMax, + minimum : scratchMin, + maximum : scratchMax, vertexFormat : scratchVertexFormat }; @@ -183,8 +226,8 @@ define([ return new BoxGeometry(scratchOptions); } - result._minimumCorner = Cartesian3.clone(min, result._minimumCorner); - result._maximumCorner = Cartesian3.clone(max, result._maximumCorner); + result._minimum = Cartesian3.clone(min, result._minimum); + result._maximum = Cartesian3.clone(max, result._maximum); result._vertexFormat = VertexFormat.clone(vertexFormat, result._vertexFormat); return result; @@ -197,8 +240,8 @@ define([ * @returns {Geometry} The computed vertices and indices. */ BoxGeometry.createGeometry = function(boxGeometry) { - var min = boxGeometry._minimumCorner; - var max = boxGeometry._maximumCorner; + var min = boxGeometry._minimum; + var max = boxGeometry._maximum; var vertexFormat = boxGeometry._vertexFormat; var attributes = new GeometryAttributes(); diff --git a/Source/Core/BoxOutlineGeometry.js b/Source/Core/BoxOutlineGeometry.js index 6a62b08c26d1..57a99b4e25dd 100644 --- a/Source/Core/BoxOutlineGeometry.js +++ b/Source/Core/BoxOutlineGeometry.js @@ -32,8 +32,8 @@ define([ * @constructor * * @param {Object} options Object with the following properties: - * @param {Cartesian3} options.minimumCorner The minimum x, y, and z coordinates of the box. - * @param {Cartesian3} options.maximumCorner The maximum x, y, and z coordinates of the box. + * @param {Cartesian3} options.minimum The minimum x, y, and z coordinates of the box. + * @param {Cartesian3} options.maximum The maximum x, y, and z coordinates of the box. * * @see BoxOutlineGeometry.fromDimensions * @see BoxOutlineGeometry.createGeometry @@ -43,23 +43,23 @@ define([ * * @example * var box = new Cesium.BoxOutlineGeometry({ - * maximumCorner : new Cesium.Cartesian3(250000.0, 250000.0, 250000.0), - * minimumCorner : new Cesium.Cartesian3(-250000.0, -250000.0, -250000.0) + * maximum : new Cesium.Cartesian3(250000.0, 250000.0, 250000.0), + * minimum : new Cesium.Cartesian3(-250000.0, -250000.0, -250000.0) * }); * var geometry = Cesium.BoxOutlineGeometry.createGeometry(box); */ var BoxOutlineGeometry = function(options) { options = defaultValue(options, defaultValue.EMPTY_OBJECT); - var min = options.minimumCorner; - var max = options.maximumCorner; + var min = options.minimum; + var max = options.maximum; //>>includeStart('debug', pragmas.debug); if (!defined(min)) { - throw new DeveloperError('options.minimumCorner is required.'); + throw new DeveloperError('options.minimum is required.'); } if (!defined(max)) { - throw new DeveloperError('options.maximumCorner is required'); + throw new DeveloperError('options.maximum is required'); } //>>includeEnd('debug'); @@ -103,8 +103,48 @@ define([ var max = corner; var newOptions = { - minimumCorner : min, - maximumCorner : max + minimum : min, + maximum : max + }; + return new BoxOutlineGeometry(newOptions); + }; + + /** + * Creates an outline of a cube from the dimensions of an AxisAlignedBoundingBox. + * + * @param {Object} options Object with the following properties: + * @param {AxisAlignedBoundingBox} options.boundingBox A description of the AxisAlignedBoundingBox. + * @returns {BoxOutlineGeometry} + * + * @exception {DeveloperError} AxisAlignedBoundingBox must be defined. + * + * @see BoxOutlineGeometry.createGeometry + * + * @example + * var aabb = Cesium.AxisAlignedBoundingBox.fromPoints(Cesium.Cartesian3.fromDegreesArray([ + * -72.0, 40.0, + * -70.0, 35.0, + * -75.0, 30.0, + * -70.0, 30.0, + * -68.0, 40.0 + * ])); + * var box = Cesium.BoxOutlineGeometry.fromAxisAlignedBoundingBox(aabb); + * var geometry = Cesium.BoxOutlineGeometry.createGeometry(box); + */ + BoxOutlineGeometry.fromAxisAlignedBoundingBox = function(options) { + options = defaultValue(options, defaultValue.EMPTY_OBJECT); + var boundingBox = options.boundingBox; + + if (!defined(boundingBox)) { + throw new DeveloperError('boundingBox is required.'); + } + + var min = boundingBox.minimum; + var max = boundingBox.maximum; + + var newOptions = { + minimum : min, + maximum : max }; return new BoxOutlineGeometry(newOptions); }; @@ -142,8 +182,8 @@ define([ var scratchMin = new Cartesian3(); var scratchMax = new Cartesian3(); var scratchOptions = { - minimumCorner : scratchMin, - maximumCorner : scratchMax + minimum : scratchMin, + maximum : scratchMax }; /** From fda28bfb0faeac50baae402c0c5f3bb79174e02a Mon Sep 17 00:00:00 2001 From: ggetz Date: Tue, 13 Oct 2015 20:42:37 -0400 Subject: [PATCH 02/20] Fixed error in boxGeometry --- Source/Core/BoxGeometry.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/BoxGeometry.js b/Source/Core/BoxGeometry.js index acbb8329eb17..27c04112074f 100644 --- a/Source/Core/BoxGeometry.js +++ b/Source/Core/BoxGeometry.js @@ -142,7 +142,7 @@ define([ * }); * var geometry = Cesium.BoxGeometry.createGeometry(box); */ - BoxOutlineGeometry.fromAxisAlignedBoundingBox = function(options) { + BoxGeometry.fromAxisAlignedBoundingBox = function(options) { options = defaultValue(options, defaultValue.EMPTY_OBJECT); var boundingBox = options.boundingBox; From aaa6be2d21d7184d61ec688f2e056865a7f1c7bc Mon Sep 17 00:00:00 2001 From: ggetz Date: Tue, 13 Oct 2015 21:08:26 -0400 Subject: [PATCH 03/20] updated CHANGES --- CHANGES.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 7b4eaa81f6e7..20cda60e8d1e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,11 +7,13 @@ Change Log * Deleted old `/package.json` and `*.profile.js` files, not used since we moved away from a Dojo-based build years ago. This should allow future compatibility with newer systems like Browserify and Webpack. * ... * Deprecated - * ... + * Depreciated `BoxGeometry.minimumCorner` and `BoxGeometry.maximumCorner`, use `BoxGeometry.minimum` and `BoxGeometry.maximum` instead. These will be removed in 1.17. + * Depreciated `BoxOutlineGeometry.minimumCorner` and `BoxOutlineGeometry.maximumCorner`, use `BoxOutlineGeometry.minimum` and `BoxOutlineGeometry.maximum` instead. These will be removed in 1.17. * Decreased GPU memory usage in `BillboardCollection` and `LabelCollection` by using the WebGL ANGLE_instanced_arrays extension. * Added CZML examples to Sandcastle. See the new CZML tab. * Fixed token issue in ArcGisMapServerImageryProvider. * `ImageryLayerFeatureInfo` now has an `imageryLayer` property, indicating the layer that contains the feature. +* ### 1.14 - 2015-10-01 From add6c9f85e923263f6c7276aec021a9fa0b61334 Mon Sep 17 00:00:00 2001 From: ggetz Date: Tue, 13 Oct 2015 21:09:46 -0400 Subject: [PATCH 04/20] updated CHANGES --- CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 20cda60e8d1e..8763855df150 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -13,7 +13,7 @@ Change Log * Added CZML examples to Sandcastle. See the new CZML tab. * Fixed token issue in ArcGisMapServerImageryProvider. * `ImageryLayerFeatureInfo` now has an `imageryLayer` property, indicating the layer that contains the feature. -* +* Added `BoxOutlineGeometry.fromAxisAlignedBoundingBox` and `BoxGeometry.fromAxisAlignedBoundingBox` functtions ### 1.14 - 2015-10-01 From f6eff1de70a7230e0e6592fe82e57569d608ad6c Mon Sep 17 00:00:00 2001 From: ggetz Date: Tue, 13 Oct 2015 21:22:38 -0400 Subject: [PATCH 05/20] removed option parameter --- Source/Core/BoxGeometry.js | 9 ++------- Source/Core/BoxOutlineGeometry.js | 6 +----- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/Source/Core/BoxGeometry.js b/Source/Core/BoxGeometry.js index 27c04112074f..622dd5dab7d1 100644 --- a/Source/Core/BoxGeometry.js +++ b/Source/Core/BoxGeometry.js @@ -140,12 +140,8 @@ define([ * var box = Cesium.BoxGeometry.fromAxisAlignedBoundingBox({ * boundingBox: aabb * }); - * var geometry = Cesium.BoxGeometry.createGeometry(box); */ - BoxGeometry.fromAxisAlignedBoundingBox = function(options) { - options = defaultValue(options, defaultValue.EMPTY_OBJECT); - var boundingBox = options.boundingBox; - + BoxGeometry.fromAxisAlignedBoundingBox = function(boundingBox) { if (!defined(boundingBox)) { throw new DeveloperError('boundingBox is required.'); } @@ -155,8 +151,7 @@ define([ var newOptions = { minimum : min, - maximum : max, - vertexFormat : options.vertexFormat + maximum : max }; return new BoxGeometry(newOptions); }; diff --git a/Source/Core/BoxOutlineGeometry.js b/Source/Core/BoxOutlineGeometry.js index 57a99b4e25dd..9140cc446493 100644 --- a/Source/Core/BoxOutlineGeometry.js +++ b/Source/Core/BoxOutlineGeometry.js @@ -129,12 +129,8 @@ define([ * -68.0, 40.0 * ])); * var box = Cesium.BoxOutlineGeometry.fromAxisAlignedBoundingBox(aabb); - * var geometry = Cesium.BoxOutlineGeometry.createGeometry(box); */ - BoxOutlineGeometry.fromAxisAlignedBoundingBox = function(options) { - options = defaultValue(options, defaultValue.EMPTY_OBJECT); - var boundingBox = options.boundingBox; - + BoxOutlineGeometry.fromAxisAlignedBoundingBox = function(boundingBox) { if (!defined(boundingBox)) { throw new DeveloperError('boundingBox is required.'); } From bf56a4a616487a9d09816743e83afc4f3727c87a Mon Sep 17 00:00:00 2001 From: ggetz Date: Wed, 14 Oct 2015 09:57:46 -0400 Subject: [PATCH 06/20] Added unit tests --- Source/Core/BoxGeometry.js | 25 +++++++++++++++++++++---- Source/Core/BoxOutlineGeometry.js | 23 +++++++++++++++++++---- Specs/Core/BoxGeometrySpec.js | 18 ++++++++++++++++++ Specs/Core/BoxOutlineGeometrySpec.js | 18 ++++++++++++++++++ 4 files changed, 76 insertions(+), 8 deletions(-) diff --git a/Source/Core/BoxGeometry.js b/Source/Core/BoxGeometry.js index 622dd5dab7d1..260dfad46990 100644 --- a/Source/Core/BoxGeometry.js +++ b/Source/Core/BoxGeometry.js @@ -5,6 +5,7 @@ define([ './ComponentDatatype', './defaultValue', './defined', + './deprecationWarning', './DeveloperError', './Geometry', './GeometryAttribute', @@ -17,6 +18,7 @@ define([ ComponentDatatype, defaultValue, defined, + deprecationWarning, DeveloperError, Geometry, GeometryAttribute, @@ -36,6 +38,8 @@ define([ * @param {Object} options Object with the following properties: * @param {Cartesian3} options.minimum The minimum x, y, and z coordinates of the box. * @param {Cartesian3} options.maximum The maximum x, y, and z coordinates of the box. + * @param {Cartesian3} options.minimumCorner The minimum x, y, and z coordinates of the box. + * @param {Cartesian3} options.maximumCorner The maximum x, y, and z coordinates of the box. * @param {VertexFormat} [options.vertexFormat=VertexFormat.DEFAULT] The vertex attributes to be computed. * * @see BoxGeometry.fromDimensions @@ -54,15 +58,28 @@ define([ */ var BoxGeometry = function(options) { options = defaultValue(options, defaultValue.EMPTY_OBJECT); + var min = options.minimum; var max = options.maximum; //>>includeStart('debug', pragmas.debug); if (!defined(min)) { - throw new DeveloperError('options.minimum is required.'); + if (defined(options.minimumCorner)) { + min = options.minimumCorner; + deprecationWarning('boxGeometry', 'options.minimumCorner is deprecated. Use options.minimum instead'); + } + else { + throw new DeveloperError('options.minimum is required.'); + } } if (!defined(max)) { - throw new DeveloperError('options.maximum is required'); + if (defined(options.maximumCorner)) { + max = options.maximumCorner; + deprecationWarning('boxGeometry', 'options.maximumCorner is deprecated. Use options.maximum instead'); + } + else { + throw new DeveloperError('options.maximum is required'); + } } //>>includeEnd('debug'); @@ -121,8 +138,8 @@ define([ /** * Creates a cube from the dimensions of an AxisAlignedBoundingBox. * - * @param {Object} options Object with the following properties: - * @param {AxisAlignedBoundingBox} options.boundingBox A description of the AxisAlignedBoundingBox. + * @param {AxisAlignedBoundingBox} boundingBox A description of the AxisAlignedBoundingBox. + * @deprecated @param * @returns {BoxGeometry} * * @exception {DeveloperError} AxisAlignedBoundingBox must be defined. diff --git a/Source/Core/BoxOutlineGeometry.js b/Source/Core/BoxOutlineGeometry.js index 9140cc446493..fe7e2b5353cb 100644 --- a/Source/Core/BoxOutlineGeometry.js +++ b/Source/Core/BoxOutlineGeometry.js @@ -5,6 +5,7 @@ define([ './ComponentDatatype', './defaultValue', './defined', + './deprecationWarning', './DeveloperError', './Geometry', './GeometryAttribute', @@ -16,6 +17,7 @@ define([ ComponentDatatype, defaultValue, defined, + deprecationWarning, DeveloperError, Geometry, GeometryAttribute, @@ -34,6 +36,8 @@ define([ * @param {Object} options Object with the following properties: * @param {Cartesian3} options.minimum The minimum x, y, and z coordinates of the box. * @param {Cartesian3} options.maximum The maximum x, y, and z coordinates of the box. + * @param {Cartesian3} options.minimumCorner The minimum x, y, and z coordinates of the box. + * @param {Cartesian3} options.maximumCorner The maximum x, y, and z coordinates of the box. * * @see BoxOutlineGeometry.fromDimensions * @see BoxOutlineGeometry.createGeometry @@ -56,10 +60,22 @@ define([ //>>includeStart('debug', pragmas.debug); if (!defined(min)) { - throw new DeveloperError('options.minimum is required.'); + if (defined(options.minimumCorner)) { + min = options.minimumCorner; + deprecationWarning('boxOutlineGeometry', 'options.minimumCorner is deprecated. Use options.minimum instead'); + } + else { + throw new DeveloperError('options.minimum is required.'); + } } if (!defined(max)) { - throw new DeveloperError('options.maximum is required'); + if (defined(options.maximumCorner)) { + max = options.maximumCorner; + deprecationWarning('boxOutlineGeometry', 'options.maximumCorner is deprecated. Use options.maximum instead'); + } + else { + throw new DeveloperError('options.maximum is required'); + } } //>>includeEnd('debug'); @@ -112,8 +128,7 @@ define([ /** * Creates an outline of a cube from the dimensions of an AxisAlignedBoundingBox. * - * @param {Object} options Object with the following properties: - * @param {AxisAlignedBoundingBox} options.boundingBox A description of the AxisAlignedBoundingBox. + * @param {AxisAlignedBoundingBox} boundingBox A description of the AxisAlignedBoundingBox. * @returns {BoxOutlineGeometry} * * @exception {DeveloperError} AxisAlignedBoundingBox must be defined. diff --git a/Specs/Core/BoxGeometrySpec.js b/Specs/Core/BoxGeometrySpec.js index 1c0e55c4e87a..6fea46daf908 100644 --- a/Specs/Core/BoxGeometrySpec.js +++ b/Specs/Core/BoxGeometrySpec.js @@ -1,10 +1,12 @@ /*global defineSuite*/ defineSuite([ + 'Core/AxisAlignedBoundingBox', 'Core/BoxGeometry', 'Core/Cartesian3', 'Core/VertexFormat', 'Specs/createPackableSpecs' ], function( + AxisAlignedBoundingBox, BoxGeometry, Cartesian3, VertexFormat, @@ -84,6 +86,22 @@ defineSuite([ expect(m.indices.length).toEqual(12 * 3); }); + it('fromAxisAlignedBoundingBox throws with no boundingBox', function() { + expect(function() { + return BoxGeometry.fromAxisAlignedBoundingBox(undefined); + }).toThrowDeveloperError(); + }); + + it('fromAxisAlignedBoundingBox', function() { + var min = new Cartesian3(-1, -2, -3); + var max = new Cartesian3(1, 2, 3); + var m = BoxGeometry.createGeometry(BoxGeometry.fromAxisAlignedBoundingBox( + new AxisAlignedBoundingBox(min, max) + )); + expect(m.attributes.position.values.length).toEqual(8 * 3); + expect(m.indices.length).toEqual(12 * 2); + }); + createPackableSpecs(BoxGeometry, new BoxGeometry({ minimumCorner : new Cartesian3(1.0, 2.0, 3.0), maximumCorner : new Cartesian3(4.0, 5.0, 6.0), diff --git a/Specs/Core/BoxOutlineGeometrySpec.js b/Specs/Core/BoxOutlineGeometrySpec.js index 292d2db7232b..6612e1930c6d 100644 --- a/Specs/Core/BoxOutlineGeometrySpec.js +++ b/Specs/Core/BoxOutlineGeometrySpec.js @@ -1,9 +1,11 @@ /*global defineSuite*/ defineSuite([ + 'Core/AxisAlignedBoundingBox', 'Core/BoxOutlineGeometry', 'Core/Cartesian3', 'Specs/createPackableSpecs' ], function( + AxisAlignedBoundingBox, BoxOutlineGeometry, Cartesian3, createPackableSpecs) { @@ -59,6 +61,22 @@ defineSuite([ expect(m.indices.length).toEqual(12 * 2); }); + it('fromAxisAlignedBoundingBox throws with no boundingBox', function() { + expect(function() { + return BoxOutlineGeometry.fromAxisAlignedBoundingBox(undefined); + }).toThrowDeveloperError(); + }); + + it('fromAxisAlignedBoundingBox', function() { + var min = new Cartesian3(-1, -2, -3); + var max = new Cartesian3(1, 2, 3); + var m = BoxOutlineGeometry.createGeometry(BoxOutlineGeometry.fromAxisAlignedBoundingBox( + new AxisAlignedBoundingBox(min, max) + )); + expect(m.attributes.position.values.length).toEqual(8 * 3); + expect(m.indices.length).toEqual(12 * 2); + }); + createPackableSpecs(BoxOutlineGeometry, new BoxOutlineGeometry({ minimumCorner : new Cartesian3(1.0, 2.0, 3.0), maximumCorner : new Cartesian3(4.0, 5.0, 6.0) From 8712156e7b8a55c626ede4bda5450b4e367f446c Mon Sep 17 00:00:00 2001 From: ggetz Date: Wed, 14 Oct 2015 10:09:30 -0400 Subject: [PATCH 07/20] Fixed error in documentation --- Source/Core/BoxGeometry.js | 1 - 1 file changed, 1 deletion(-) diff --git a/Source/Core/BoxGeometry.js b/Source/Core/BoxGeometry.js index 260dfad46990..3bf62bd57983 100644 --- a/Source/Core/BoxGeometry.js +++ b/Source/Core/BoxGeometry.js @@ -139,7 +139,6 @@ define([ * Creates a cube from the dimensions of an AxisAlignedBoundingBox. * * @param {AxisAlignedBoundingBox} boundingBox A description of the AxisAlignedBoundingBox. - * @deprecated @param * @returns {BoxGeometry} * * @exception {DeveloperError} AxisAlignedBoundingBox must be defined. From 4c3dc6dafc049b99b4daf3eb33e26448a8860ae7 Mon Sep 17 00:00:00 2001 From: ggetz Date: Wed, 14 Oct 2015 10:22:18 -0400 Subject: [PATCH 08/20] Fixed error in CHANGES and updated documentation --- CHANGES.md | 2 +- Source/Core/BoxGeometry.js | 205 +++++++++++++++--------------- Source/Core/BoxOutlineGeometry.js | 2 - 3 files changed, 102 insertions(+), 107 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 8763855df150..3b74040bd164 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -13,7 +13,7 @@ Change Log * Added CZML examples to Sandcastle. See the new CZML tab. * Fixed token issue in ArcGisMapServerImageryProvider. * `ImageryLayerFeatureInfo` now has an `imageryLayer` property, indicating the layer that contains the feature. -* Added `BoxOutlineGeometry.fromAxisAlignedBoundingBox` and `BoxGeometry.fromAxisAlignedBoundingBox` functtions +* Added `BoxOutlineGeometry.fromAxisAlignedBoundingBox` and `BoxGeometry.fromAxisAlignedBoundingBox` functions ### 1.14 - 2015-10-01 diff --git a/Source/Core/BoxGeometry.js b/Source/Core/BoxGeometry.js index 3bf62bd57983..8bd087ff7977 100644 --- a/Source/Core/BoxGeometry.js +++ b/Source/Core/BoxGeometry.js @@ -1,30 +1,29 @@ /*global define*/ define([ - './BoundingSphere', - './Cartesian3', - './ComponentDatatype', - './defaultValue', - './defined', - './deprecationWarning', - './DeveloperError', - './Geometry', - './GeometryAttribute', - './GeometryAttributes', - './PrimitiveType', - './VertexFormat' - ], function( - BoundingSphere, - Cartesian3, - ComponentDatatype, - defaultValue, - defined, - deprecationWarning, - DeveloperError, - Geometry, - GeometryAttribute, - GeometryAttributes, - PrimitiveType, - VertexFormat) { + './BoundingSphere', + './Cartesian3', + './ComponentDatatype', + './defaultValue', + './defined', + './deprecationWarning', + './DeveloperError', + './Geometry', + './GeometryAttribute', + './GeometryAttributes', + './PrimitiveType', + './VertexFormat' +], function (BoundingSphere, + Cartesian3, + ComponentDatatype, + defaultValue, + defined, + deprecationWarning, + DeveloperError, + Geometry, + GeometryAttribute, + GeometryAttributes, + PrimitiveType, + VertexFormat) { "use strict"; var diffScratch = new Cartesian3(); @@ -38,8 +37,6 @@ define([ * @param {Object} options Object with the following properties: * @param {Cartesian3} options.minimum The minimum x, y, and z coordinates of the box. * @param {Cartesian3} options.maximum The maximum x, y, and z coordinates of the box. - * @param {Cartesian3} options.minimumCorner The minimum x, y, and z coordinates of the box. - * @param {Cartesian3} options.maximumCorner The maximum x, y, and z coordinates of the box. * @param {VertexFormat} [options.vertexFormat=VertexFormat.DEFAULT] The vertex attributes to be computed. * * @see BoxGeometry.fromDimensions @@ -56,7 +53,7 @@ define([ * }); * var geometry = Cesium.BoxGeometry.createGeometry(box); */ - var BoxGeometry = function(options) { + var BoxGeometry = function (options) { options = defaultValue(options, defaultValue.EMPTY_OBJECT); var min = options.minimum; @@ -110,7 +107,7 @@ define([ * }); * var geometry = Cesium.BoxGeometry.createGeometry(box); */ - BoxGeometry.fromDimensions = function(options) { + BoxGeometry.fromDimensions = function (options) { options = defaultValue(options, defaultValue.EMPTY_OBJECT); var dimensions = options.dimensions; @@ -128,9 +125,9 @@ define([ var max = corner; var newOptions = { - minimum : min, - maximum : max, - vertexFormat : options.vertexFormat + minimum: min, + maximum: max, + vertexFormat: options.vertexFormat }; return new BoxGeometry(newOptions); }; @@ -157,7 +154,7 @@ define([ * boundingBox: aabb * }); */ - BoxGeometry.fromAxisAlignedBoundingBox = function(boundingBox) { + BoxGeometry.fromAxisAlignedBoundingBox = function (boundingBox) { if (!defined(boundingBox)) { throw new DeveloperError('boundingBox is required.'); } @@ -166,8 +163,8 @@ define([ var max = boundingBox.maximum; var newOptions = { - minimum : min, - maximum : max + minimum: min, + maximum: max }; return new BoxGeometry(newOptions); }; @@ -186,7 +183,7 @@ define([ * @param {Number[]} array The array to pack into. * @param {Number} [startingIndex=0] The index into the array at which to start packing the elements. */ - BoxGeometry.pack = function(value, array, startingIndex) { + BoxGeometry.pack = function (value, array, startingIndex) { //>>includeStart('debug', pragmas.debug); if (!defined(value)) { throw new DeveloperError('value is required'); @@ -207,9 +204,9 @@ define([ var scratchMax = new Cartesian3(); var scratchVertexFormat = new VertexFormat(); var scratchOptions = { - minimum : scratchMin, - maximum : scratchMax, - vertexFormat : scratchVertexFormat + minimum: scratchMin, + maximum: scratchMax, + vertexFormat: scratchVertexFormat }; /** @@ -220,7 +217,7 @@ define([ * @param {BoxGeometry} [result] The object into which to store the result. * @returns {BoxGeometry} The modified result parameter or a new BoxGeometry instance if one was not provided. */ - BoxGeometry.unpack = function(array, startingIndex, result) { + BoxGeometry.unpack = function (array, startingIndex, result) { //>>includeStart('debug', pragmas.debug); if (!defined(array)) { throw new DeveloperError('array is required'); @@ -250,7 +247,7 @@ define([ * @param {BoxGeometry} boxGeometry A description of the box. * @returns {Geometry} The computed vertices and indices. */ - BoxGeometry.createGeometry = function(boxGeometry) { + BoxGeometry.createGeometry = function (boxGeometry) { var min = boxGeometry._minimum; var max = boxGeometry._maximum; var vertexFormat = boxGeometry._vertexFormat; @@ -260,22 +257,22 @@ define([ var positions; if (vertexFormat.position && - (vertexFormat.st || vertexFormat.normal || vertexFormat.binormal || vertexFormat.tangent)) { + (vertexFormat.st || vertexFormat.normal || vertexFormat.binormal || vertexFormat.tangent)) { if (vertexFormat.position) { // 8 corner points. Duplicated 3 times each for each incident edge/face. positions = new Float64Array(6 * 4 * 3); // +z face - positions[0] = min.x; - positions[1] = min.y; - positions[2] = max.z; - positions[3] = max.x; - positions[4] = min.y; - positions[5] = max.z; - positions[6] = max.x; - positions[7] = max.y; - positions[8] = max.z; - positions[9] = min.x; + positions[0] = min.x; + positions[1] = min.y; + positions[2] = max.z; + positions[3] = max.x; + positions[4] = min.y; + positions[5] = max.z; + positions[6] = max.x; + positions[7] = max.y; + positions[8] = max.z; + positions[9] = min.x; positions[10] = max.y; positions[11] = max.z; @@ -350,9 +347,9 @@ define([ positions[71] = max.z; attributes.position = new GeometryAttribute({ - componentDatatype : ComponentDatatype.DOUBLE, - componentsPerAttribute : 3, - values : positions + componentDatatype: ComponentDatatype.DOUBLE, + componentsPerAttribute: 3, + values: positions }); } @@ -360,16 +357,16 @@ define([ var normals = new Float32Array(6 * 4 * 3); // +z face - normals[0] = 0.0; - normals[1] = 0.0; - normals[2] = 1.0; - normals[3] = 0.0; - normals[4] = 0.0; - normals[5] = 1.0; - normals[6] = 0.0; - normals[7] = 0.0; - normals[8] = 1.0; - normals[9] = 0.0; + normals[0] = 0.0; + normals[1] = 0.0; + normals[2] = 1.0; + normals[3] = 0.0; + normals[4] = 0.0; + normals[5] = 1.0; + normals[6] = 0.0; + normals[7] = 0.0; + normals[8] = 1.0; + normals[9] = 0.0; normals[10] = 0.0; normals[11] = 1.0; @@ -444,9 +441,9 @@ define([ normals[71] = 0.0; attributes.normal = new GeometryAttribute({ - componentDatatype : ComponentDatatype.FLOAT, - componentsPerAttribute : 3, - values : normals + componentDatatype: ComponentDatatype.FLOAT, + componentsPerAttribute: 3, + values: normals }); } @@ -454,18 +451,18 @@ define([ var texCoords = new Float32Array(6 * 4 * 2); // +z face - texCoords[0] = 0.0; - texCoords[1] = 0.0; - texCoords[2] = 1.0; - texCoords[3] = 0.0; - texCoords[4] = 1.0; - texCoords[5] = 1.0; - texCoords[6] = 0.0; - texCoords[7] = 1.0; + texCoords[0] = 0.0; + texCoords[1] = 0.0; + texCoords[2] = 1.0; + texCoords[3] = 0.0; + texCoords[4] = 1.0; + texCoords[5] = 1.0; + texCoords[6] = 0.0; + texCoords[7] = 1.0; // -z face - texCoords[8] = 1.0; - texCoords[9] = 0.0; + texCoords[8] = 1.0; + texCoords[9] = 0.0; texCoords[10] = 0.0; texCoords[11] = 0.0; texCoords[12] = 0.0; @@ -514,9 +511,9 @@ define([ texCoords[47] = 1.0; attributes.st = new GeometryAttribute({ - componentDatatype : ComponentDatatype.FLOAT, - componentsPerAttribute : 2, - values : texCoords + componentDatatype: ComponentDatatype.FLOAT, + componentsPerAttribute: 2, + values: texCoords }); } @@ -524,16 +521,16 @@ define([ var tangents = new Float32Array(6 * 4 * 3); // +z face - tangents[0] = 1.0; - tangents[1] = 0.0; - tangents[2] = 0.0; - tangents[3] = 1.0; - tangents[4] = 0.0; - tangents[5] = 0.0; - tangents[6] = 1.0; - tangents[7] = 0.0; - tangents[8] = 0.0; - tangents[9] = 1.0; + tangents[0] = 1.0; + tangents[1] = 0.0; + tangents[2] = 0.0; + tangents[3] = 1.0; + tangents[4] = 0.0; + tangents[5] = 0.0; + tangents[6] = 1.0; + tangents[7] = 0.0; + tangents[8] = 0.0; + tangents[9] = 1.0; tangents[10] = 0.0; tangents[11] = 0.0; @@ -608,9 +605,9 @@ define([ tangents[71] = 0.0; attributes.tangent = new GeometryAttribute({ - componentDatatype : ComponentDatatype.FLOAT, - componentsPerAttribute : 3, - values : tangents + componentDatatype: ComponentDatatype.FLOAT, + componentsPerAttribute: 3, + values: tangents }); } @@ -702,9 +699,9 @@ define([ binormals[71] = 1.0; attributes.binormal = new GeometryAttribute({ - componentDatatype : ComponentDatatype.FLOAT, - componentsPerAttribute : 3, - values : binormals + componentDatatype: ComponentDatatype.FLOAT, + componentsPerAttribute: 3, + values: binormals }); } @@ -788,9 +785,9 @@ define([ positions[23] = max.z; attributes.position = new GeometryAttribute({ - componentDatatype : ComponentDatatype.DOUBLE, - componentsPerAttribute : 3, - values : positions + componentDatatype: ComponentDatatype.DOUBLE, + componentsPerAttribute: 3, + values: positions }); // 12 triangles: 6 faces, 2 triangles each. @@ -849,10 +846,10 @@ define([ var radius = Cartesian3.magnitude(diff) * 0.5; return new Geometry({ - attributes : attributes, - indices : indices, - primitiveType : PrimitiveType.TRIANGLES, - boundingSphere : new BoundingSphere(Cartesian3.ZERO, radius) + attributes: attributes, + indices: indices, + primitiveType: PrimitiveType.TRIANGLES, + boundingSphere: new BoundingSphere(Cartesian3.ZERO, radius) }); }; diff --git a/Source/Core/BoxOutlineGeometry.js b/Source/Core/BoxOutlineGeometry.js index fe7e2b5353cb..febb29dfc849 100644 --- a/Source/Core/BoxOutlineGeometry.js +++ b/Source/Core/BoxOutlineGeometry.js @@ -36,8 +36,6 @@ define([ * @param {Object} options Object with the following properties: * @param {Cartesian3} options.minimum The minimum x, y, and z coordinates of the box. * @param {Cartesian3} options.maximum The maximum x, y, and z coordinates of the box. - * @param {Cartesian3} options.minimumCorner The minimum x, y, and z coordinates of the box. - * @param {Cartesian3} options.maximumCorner The maximum x, y, and z coordinates of the box. * * @see BoxOutlineGeometry.fromDimensions * @see BoxOutlineGeometry.createGeometry From d18d6af2dcb7d3b4fd3b2ffa43946d3c4d0234db Mon Sep 17 00:00:00 2001 From: ggetz Date: Wed, 14 Oct 2015 10:50:25 -0400 Subject: [PATCH 09/20] Fixed Unit Tests --- Source/Core/BoxGeometry.js | 12 ++++-------- Source/Core/BoxOutlineGeometry.js | 12 ++++-------- Specs/Core/BoxGeometrySpec.js | 12 +++++------- Specs/Core/BoxOutlineGeometrySpec.js | 12 +++++------- 4 files changed, 18 insertions(+), 30 deletions(-) diff --git a/Source/Core/BoxGeometry.js b/Source/Core/BoxGeometry.js index 8bd087ff7977..47482d8e1a59 100644 --- a/Source/Core/BoxGeometry.js +++ b/Source/Core/BoxGeometry.js @@ -63,7 +63,7 @@ define([ if (!defined(min)) { if (defined(options.minimumCorner)) { min = options.minimumCorner; - deprecationWarning('boxGeometry', 'options.minimumCorner is deprecated. Use options.minimum instead'); + deprecationWarning('BoxGeometry', 'options.minimumCorner is deprecated. Use options.minimum instead'); } else { throw new DeveloperError('options.minimum is required.'); @@ -72,7 +72,7 @@ define([ if (!defined(max)) { if (defined(options.maximumCorner)) { max = options.maximumCorner; - deprecationWarning('boxGeometry', 'options.maximumCorner is deprecated. Use options.maximum instead'); + deprecationWarning('BoxGeometry', 'options.maximumCorner is deprecated. Use options.maximum instead'); } else { throw new DeveloperError('options.maximum is required'); @@ -158,13 +158,9 @@ define([ if (!defined(boundingBox)) { throw new DeveloperError('boundingBox is required.'); } - - var min = boundingBox.minimum; - var max = boundingBox.maximum; - var newOptions = { - minimum: min, - maximum: max + minimum: boundingBox.minimum, + maximum: boundingBox.maximum }; return new BoxGeometry(newOptions); }; diff --git a/Source/Core/BoxOutlineGeometry.js b/Source/Core/BoxOutlineGeometry.js index febb29dfc849..b7a7fe86157e 100644 --- a/Source/Core/BoxOutlineGeometry.js +++ b/Source/Core/BoxOutlineGeometry.js @@ -60,7 +60,7 @@ define([ if (!defined(min)) { if (defined(options.minimumCorner)) { min = options.minimumCorner; - deprecationWarning('boxOutlineGeometry', 'options.minimumCorner is deprecated. Use options.minimum instead'); + deprecationWarning('BoxOutlineGeometry', 'options.minimumCorner is deprecated. Use options.minimum instead'); } else { throw new DeveloperError('options.minimum is required.'); @@ -69,7 +69,7 @@ define([ if (!defined(max)) { if (defined(options.maximumCorner)) { max = options.maximumCorner; - deprecationWarning('boxOutlineGeometry', 'options.maximumCorner is deprecated. Use options.maximum instead'); + deprecationWarning('BoxOutlineGeometry', 'options.maximumCorner is deprecated. Use options.maximum instead'); } else { throw new DeveloperError('options.maximum is required'); @@ -147,13 +147,9 @@ define([ if (!defined(boundingBox)) { throw new DeveloperError('boundingBox is required.'); } - - var min = boundingBox.minimum; - var max = boundingBox.maximum; - var newOptions = { - minimum : min, - maximum : max + minimum : boundingBox.minimum, + maximum : boundingBox.maximum }; return new BoxOutlineGeometry(newOptions); }; diff --git a/Specs/Core/BoxGeometrySpec.js b/Specs/Core/BoxGeometrySpec.js index 6fea46daf908..f73bd0abd031 100644 --- a/Specs/Core/BoxGeometrySpec.js +++ b/Specs/Core/BoxGeometrySpec.js @@ -1,13 +1,13 @@ /*global defineSuite*/ defineSuite([ - 'Core/AxisAlignedBoundingBox', 'Core/BoxGeometry', + 'Core/AxisAlignedBoundingBox', 'Core/Cartesian3', 'Core/VertexFormat', 'Specs/createPackableSpecs' ], function( - AxisAlignedBoundingBox, BoxGeometry, + AxisAlignedBoundingBox, Cartesian3, VertexFormat, createPackableSpecs) { @@ -95,11 +95,9 @@ defineSuite([ it('fromAxisAlignedBoundingBox', function() { var min = new Cartesian3(-1, -2, -3); var max = new Cartesian3(1, 2, 3); - var m = BoxGeometry.createGeometry(BoxGeometry.fromAxisAlignedBoundingBox( - new AxisAlignedBoundingBox(min, max) - )); - expect(m.attributes.position.values.length).toEqual(8 * 3); - expect(m.indices.length).toEqual(12 * 2); + var m = BoxGeometry.fromAxisAlignedBoundingBox(new AxisAlignedBoundingBox(min, max)); + expect(m._minimum).toEqual(min); + expect(m._maximum).toEqual(max); }); createPackableSpecs(BoxGeometry, new BoxGeometry({ diff --git a/Specs/Core/BoxOutlineGeometrySpec.js b/Specs/Core/BoxOutlineGeometrySpec.js index 6612e1930c6d..d8a77ec2b2ad 100644 --- a/Specs/Core/BoxOutlineGeometrySpec.js +++ b/Specs/Core/BoxOutlineGeometrySpec.js @@ -1,12 +1,12 @@ /*global defineSuite*/ defineSuite([ - 'Core/AxisAlignedBoundingBox', 'Core/BoxOutlineGeometry', + 'Core/AxisAlignedBoundingBox', 'Core/Cartesian3', 'Specs/createPackableSpecs' ], function( - AxisAlignedBoundingBox, BoxOutlineGeometry, + AxisAlignedBoundingBox, Cartesian3, createPackableSpecs) { "use strict"; @@ -70,11 +70,9 @@ defineSuite([ it('fromAxisAlignedBoundingBox', function() { var min = new Cartesian3(-1, -2, -3); var max = new Cartesian3(1, 2, 3); - var m = BoxOutlineGeometry.createGeometry(BoxOutlineGeometry.fromAxisAlignedBoundingBox( - new AxisAlignedBoundingBox(min, max) - )); - expect(m.attributes.position.values.length).toEqual(8 * 3); - expect(m.indices.length).toEqual(12 * 2); + var m = BoxOutlineGeometry.fromAxisAlignedBoundingBox(new AxisAlignedBoundingBox(min, max)); + expect(m._min).toEqual(min); + expect(m._max).toEqual(max); }); createPackableSpecs(BoxOutlineGeometry, new BoxOutlineGeometry({ From a76fecc571ba793e8ee12c60158841094bb6b47a Mon Sep 17 00:00:00 2001 From: Patrick Cozzi Date: Wed, 14 Oct 2015 11:07:56 -0400 Subject: [PATCH 10/20] Tweak CHANGES.md --- CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 3b74040bd164..c27628afefa9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -13,7 +13,7 @@ Change Log * Added CZML examples to Sandcastle. See the new CZML tab. * Fixed token issue in ArcGisMapServerImageryProvider. * `ImageryLayerFeatureInfo` now has an `imageryLayer` property, indicating the layer that contains the feature. -* Added `BoxOutlineGeometry.fromAxisAlignedBoundingBox` and `BoxGeometry.fromAxisAlignedBoundingBox` functions +* Added `BoxOutlineGeometry.fromAxisAlignedBoundingBox` and `BoxGeometry.fromAxisAlignedBoundingBox` functions. ### 1.14 - 2015-10-01 From f905d2ef75a5106a4e23f18f473828eddd29cd4f Mon Sep 17 00:00:00 2001 From: ggetz Date: Wed, 14 Oct 2015 11:21:19 -0400 Subject: [PATCH 11/20] Removed formatting error --- CHANGES.md | 4 +- CONTRIBUTORS.md | 1 + Source/Core/BoxGeometry.js | 226 ++++++++++++++++---------- Source/Core/BoxOutlineGeometry.js | 69 ++++++-- Source/Core/PolygonOutlineGeometry.js | 6 +- Specs/Core/BoxGeometrySpec.js | 16 ++ Specs/Core/BoxOutlineGeometrySpec.js | 16 ++ 7 files changed, 232 insertions(+), 106 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 7b4eaa81f6e7..c27628afefa9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,11 +7,13 @@ Change Log * Deleted old `/package.json` and `*.profile.js` files, not used since we moved away from a Dojo-based build years ago. This should allow future compatibility with newer systems like Browserify and Webpack. * ... * Deprecated - * ... + * Depreciated `BoxGeometry.minimumCorner` and `BoxGeometry.maximumCorner`, use `BoxGeometry.minimum` and `BoxGeometry.maximum` instead. These will be removed in 1.17. + * Depreciated `BoxOutlineGeometry.minimumCorner` and `BoxOutlineGeometry.maximumCorner`, use `BoxOutlineGeometry.minimum` and `BoxOutlineGeometry.maximum` instead. These will be removed in 1.17. * Decreased GPU memory usage in `BillboardCollection` and `LabelCollection` by using the WebGL ANGLE_instanced_arrays extension. * Added CZML examples to Sandcastle. See the new CZML tab. * Fixed token issue in ArcGisMapServerImageryProvider. * `ImageryLayerFeatureInfo` now has an `imageryLayer` property, indicating the layer that contains the feature. +* Added `BoxOutlineGeometry.fromAxisAlignedBoundingBox` and `BoxGeometry.fromAxisAlignedBoundingBox` functions. ### 1.14 - 2015-10-01 diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 3ccf4b6a80f0..5041e73b2863 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -26,6 +26,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu * [Kai Ninomiya](https://github.com/kainino0x) * [Sean Lilley](https://github.com/lilleyse) * [Katherina Lim](https://github.com/klim705) + * [Gabrielle Getz](https://github.com/ggetz) * [NICTA](http://www.nicta.com.au/) * [Chris Cooper](https://github.com/chris-cooper) * [Kevin Ring](https://github.com/kring) diff --git a/Source/Core/BoxGeometry.js b/Source/Core/BoxGeometry.js index ee262c151be7..1bb44f78d1ff 100644 --- a/Source/Core/BoxGeometry.js +++ b/Source/Core/BoxGeometry.js @@ -34,8 +34,8 @@ define([ * @constructor * * @param {Object} options Object with the following properties: - * @param {Cartesian3} options.minimumCorner The minimum x, y, and z coordinates of the box. - * @param {Cartesian3} options.maximumCorner The maximum x, y, and z coordinates of the box. + * @param {Cartesian3} options.minimum The minimum x, y, and z coordinates of the box. + * @param {Cartesian3} options.maximum The maximum x, y, and z coordinates of the box. * @param {VertexFormat} [options.vertexFormat=VertexFormat.DEFAULT] The vertex attributes to be computed. * * @see BoxGeometry.fromDimensions @@ -47,29 +47,42 @@ define([ * @example * var box = new Cesium.BoxGeometry({ * vertexFormat : Cesium.VertexFormat.POSITION_ONLY, - * maximumCorner : new Cesium.Cartesian3(250000.0, 250000.0, 250000.0), - * minimumCorner : new Cesium.Cartesian3(-250000.0, -250000.0, -250000.0) + * maximum : new Cesium.Cartesian3(250000.0, 250000.0, 250000.0), + * minimum : new Cesium.Cartesian3(-250000.0, -250000.0, -250000.0) * }); * var geometry = Cesium.BoxGeometry.createGeometry(box); */ - var BoxGeometry = function(options) { + var BoxGeometry = function (options) { options = defaultValue(options, defaultValue.EMPTY_OBJECT); - var min = options.minimumCorner; - var max = options.maximumCorner; + + var min = options.minimum; + var max = options.maximum; //>>includeStart('debug', pragmas.debug); if (!defined(min)) { - throw new DeveloperError('options.minimumCorner is required.'); + if (defined(options.minimumCorner)) { + min = options.minimumCorner; + deprecationWarning('BoxGeometry', 'options.minimumCorner is deprecated. Use options.minimum instead'); + } + else { + throw new DeveloperError('options.minimum is required.'); + } } if (!defined(max)) { - throw new DeveloperError('options.maximumCorner is required'); + if (defined(options.maximumCorner)) { + max = options.maximumCorner; + deprecationWarning('BoxGeometry', 'options.maximumCorner is deprecated. Use options.maximum instead'); + } + else { + throw new DeveloperError('options.maximum is required'); + } } //>>includeEnd('debug'); var vertexFormat = defaultValue(options.vertexFormat, VertexFormat.DEFAULT); - this._minimumCorner = Cartesian3.clone(min); - this._maximumCorner = Cartesian3.clone(max); + this._minimum = Cartesian3.clone(min); + this._maximum = Cartesian3.clone(max); this._vertexFormat = vertexFormat; this._workerName = 'createBoxGeometry'; }; @@ -93,7 +106,7 @@ define([ * }); * var geometry = Cesium.BoxGeometry.createGeometry(box); */ - BoxGeometry.fromDimensions = function(options) { + BoxGeometry.fromDimensions = function (options) { options = defaultValue(options, defaultValue.EMPTY_OBJECT); var dimensions = options.dimensions; @@ -111,9 +124,42 @@ define([ var max = corner; var newOptions = { - minimumCorner : min, - maximumCorner : max, - vertexFormat : options.vertexFormat + minimum: min, + maximum: max, + vertexFormat: options.vertexFormat + }; + return new BoxGeometry(newOptions); + }; + + /** + * Creates a cube from the dimensions of an AxisAlignedBoundingBox. + * + * @param {AxisAlignedBoundingBox} boundingBox A description of the AxisAlignedBoundingBox. + * @returns {BoxGeometry} + * + * @exception {DeveloperError} AxisAlignedBoundingBox must be defined. + * + * @see BoxGeometry.createGeometry + * + * @example + * var aabb = Cesium.AxisAlignedBoundingBox.fromPoints(Cesium.Cartesian3.fromDegreesArray([ + * -72.0, 40.0, + * -70.0, 35.0, + * -75.0, 30.0, + * -70.0, 30.0, + * -68.0, 40.0 + * ])); + * var box = Cesium.BoxGeometry.fromAxisAlignedBoundingBox({ + * boundingBox: aabb + * }); + */ + BoxGeometry.fromAxisAlignedBoundingBox = function (boundingBox) { + if (!defined(boundingBox)) { + throw new DeveloperError('boundingBox is required.'); + } + var newOptions = { + minimum: boundingBox.minimum, + maximum: boundingBox.maximum }; return new BoxGeometry(newOptions); }; @@ -132,7 +178,7 @@ define([ * @param {Number[]} array The array to pack into. * @param {Number} [startingIndex=0] The index into the array at which to start packing the elements. */ - BoxGeometry.pack = function(value, array, startingIndex) { + BoxGeometry.pack = function (value, array, startingIndex) { //>>includeStart('debug', pragmas.debug); if (!defined(value)) { throw new DeveloperError('value is required'); @@ -144,8 +190,8 @@ define([ startingIndex = defaultValue(startingIndex, 0); - Cartesian3.pack(value._minimumCorner, array, startingIndex); - Cartesian3.pack(value._maximumCorner, array, startingIndex + Cartesian3.packedLength); + Cartesian3.pack(value._minimum, array, startingIndex); + Cartesian3.pack(value._maximum, array, startingIndex + Cartesian3.packedLength); VertexFormat.pack(value._vertexFormat, array, startingIndex + 2 * Cartesian3.packedLength); }; @@ -153,9 +199,9 @@ define([ var scratchMax = new Cartesian3(); var scratchVertexFormat = new VertexFormat(); var scratchOptions = { - minimumCorner : scratchMin, - maximumCorner : scratchMax, - vertexFormat : scratchVertexFormat + minimum: scratchMin, + maximum: scratchMax, + vertexFormat: scratchVertexFormat }; /** @@ -166,7 +212,7 @@ define([ * @param {BoxGeometry} [result] The object into which to store the result. * @returns {BoxGeometry} The modified result parameter or a new BoxGeometry instance if one was not provided. */ - BoxGeometry.unpack = function(array, startingIndex, result) { + BoxGeometry.unpack = function (array, startingIndex, result) { //>>includeStart('debug', pragmas.debug); if (!defined(array)) { throw new DeveloperError('array is required'); @@ -183,8 +229,8 @@ define([ return new BoxGeometry(scratchOptions); } - result._minimumCorner = Cartesian3.clone(min, result._minimumCorner); - result._maximumCorner = Cartesian3.clone(max, result._maximumCorner); + result._minimum = Cartesian3.clone(min, result._minimum); + result._maximum = Cartesian3.clone(max, result._maximum); result._vertexFormat = VertexFormat.clone(vertexFormat, result._vertexFormat); return result; @@ -196,9 +242,9 @@ define([ * @param {BoxGeometry} boxGeometry A description of the box. * @returns {Geometry} The computed vertices and indices. */ - BoxGeometry.createGeometry = function(boxGeometry) { - var min = boxGeometry._minimumCorner; - var max = boxGeometry._maximumCorner; + BoxGeometry.createGeometry = function (boxGeometry) { + var min = boxGeometry._minimum; + var max = boxGeometry._maximum; var vertexFormat = boxGeometry._vertexFormat; var attributes = new GeometryAttributes(); @@ -206,22 +252,22 @@ define([ var positions; if (vertexFormat.position && - (vertexFormat.st || vertexFormat.normal || vertexFormat.binormal || vertexFormat.tangent)) { + (vertexFormat.st || vertexFormat.normal || vertexFormat.binormal || vertexFormat.tangent)) { if (vertexFormat.position) { // 8 corner points. Duplicated 3 times each for each incident edge/face. positions = new Float64Array(6 * 4 * 3); // +z face - positions[0] = min.x; - positions[1] = min.y; - positions[2] = max.z; - positions[3] = max.x; - positions[4] = min.y; - positions[5] = max.z; - positions[6] = max.x; - positions[7] = max.y; - positions[8] = max.z; - positions[9] = min.x; + positions[0] = min.x; + positions[1] = min.y; + positions[2] = max.z; + positions[3] = max.x; + positions[4] = min.y; + positions[5] = max.z; + positions[6] = max.x; + positions[7] = max.y; + positions[8] = max.z; + positions[9] = min.x; positions[10] = max.y; positions[11] = max.z; @@ -296,9 +342,9 @@ define([ positions[71] = max.z; attributes.position = new GeometryAttribute({ - componentDatatype : ComponentDatatype.DOUBLE, - componentsPerAttribute : 3, - values : positions + componentDatatype: ComponentDatatype.DOUBLE, + componentsPerAttribute: 3, + values: positions }); } @@ -306,16 +352,16 @@ define([ var normals = new Float32Array(6 * 4 * 3); // +z face - normals[0] = 0.0; - normals[1] = 0.0; - normals[2] = 1.0; - normals[3] = 0.0; - normals[4] = 0.0; - normals[5] = 1.0; - normals[6] = 0.0; - normals[7] = 0.0; - normals[8] = 1.0; - normals[9] = 0.0; + normals[0] = 0.0; + normals[1] = 0.0; + normals[2] = 1.0; + normals[3] = 0.0; + normals[4] = 0.0; + normals[5] = 1.0; + normals[6] = 0.0; + normals[7] = 0.0; + normals[8] = 1.0; + normals[9] = 0.0; normals[10] = 0.0; normals[11] = 1.0; @@ -390,9 +436,9 @@ define([ normals[71] = 0.0; attributes.normal = new GeometryAttribute({ - componentDatatype : ComponentDatatype.FLOAT, - componentsPerAttribute : 3, - values : normals + componentDatatype: ComponentDatatype.FLOAT, + componentsPerAttribute: 3, + values: normals }); } @@ -400,18 +446,18 @@ define([ var texCoords = new Float32Array(6 * 4 * 2); // +z face - texCoords[0] = 0.0; - texCoords[1] = 0.0; - texCoords[2] = 1.0; - texCoords[3] = 0.0; - texCoords[4] = 1.0; - texCoords[5] = 1.0; - texCoords[6] = 0.0; - texCoords[7] = 1.0; + texCoords[0] = 0.0; + texCoords[1] = 0.0; + texCoords[2] = 1.0; + texCoords[3] = 0.0; + texCoords[4] = 1.0; + texCoords[5] = 1.0; + texCoords[6] = 0.0; + texCoords[7] = 1.0; // -z face - texCoords[8] = 1.0; - texCoords[9] = 0.0; + texCoords[8] = 1.0; + texCoords[9] = 0.0; texCoords[10] = 0.0; texCoords[11] = 0.0; texCoords[12] = 0.0; @@ -460,9 +506,9 @@ define([ texCoords[47] = 1.0; attributes.st = new GeometryAttribute({ - componentDatatype : ComponentDatatype.FLOAT, - componentsPerAttribute : 2, - values : texCoords + componentDatatype: ComponentDatatype.FLOAT, + componentsPerAttribute: 2, + values: texCoords }); } @@ -470,16 +516,16 @@ define([ var tangents = new Float32Array(6 * 4 * 3); // +z face - tangents[0] = 1.0; - tangents[1] = 0.0; - tangents[2] = 0.0; - tangents[3] = 1.0; - tangents[4] = 0.0; - tangents[5] = 0.0; - tangents[6] = 1.0; - tangents[7] = 0.0; - tangents[8] = 0.0; - tangents[9] = 1.0; + tangents[0] = 1.0; + tangents[1] = 0.0; + tangents[2] = 0.0; + tangents[3] = 1.0; + tangents[4] = 0.0; + tangents[5] = 0.0; + tangents[6] = 1.0; + tangents[7] = 0.0; + tangents[8] = 0.0; + tangents[9] = 1.0; tangents[10] = 0.0; tangents[11] = 0.0; @@ -554,9 +600,9 @@ define([ tangents[71] = 0.0; attributes.tangent = new GeometryAttribute({ - componentDatatype : ComponentDatatype.FLOAT, - componentsPerAttribute : 3, - values : tangents + componentDatatype: ComponentDatatype.FLOAT, + componentsPerAttribute: 3, + values: tangents }); } @@ -648,9 +694,9 @@ define([ binormals[71] = 1.0; attributes.binormal = new GeometryAttribute({ - componentDatatype : ComponentDatatype.FLOAT, - componentsPerAttribute : 3, - values : binormals + componentDatatype: ComponentDatatype.FLOAT, + componentsPerAttribute: 3, + values: binormals }); } @@ -734,9 +780,9 @@ define([ positions[23] = max.z; attributes.position = new GeometryAttribute({ - componentDatatype : ComponentDatatype.DOUBLE, - componentsPerAttribute : 3, - values : positions + componentDatatype: ComponentDatatype.DOUBLE, + componentsPerAttribute: 3, + values: positions }); // 12 triangles: 6 faces, 2 triangles each. @@ -795,10 +841,10 @@ define([ var radius = Cartesian3.magnitude(diff) * 0.5; return new Geometry({ - attributes : attributes, - indices : indices, - primitiveType : PrimitiveType.TRIANGLES, - boundingSphere : new BoundingSphere(Cartesian3.ZERO, radius) + attributes: attributes, + indices: indices, + primitiveType: PrimitiveType.TRIANGLES, + boundingSphere: new BoundingSphere(Cartesian3.ZERO, radius) }); }; diff --git a/Source/Core/BoxOutlineGeometry.js b/Source/Core/BoxOutlineGeometry.js index 6a62b08c26d1..b7a7fe86157e 100644 --- a/Source/Core/BoxOutlineGeometry.js +++ b/Source/Core/BoxOutlineGeometry.js @@ -5,6 +5,7 @@ define([ './ComponentDatatype', './defaultValue', './defined', + './deprecationWarning', './DeveloperError', './Geometry', './GeometryAttribute', @@ -16,6 +17,7 @@ define([ ComponentDatatype, defaultValue, defined, + deprecationWarning, DeveloperError, Geometry, GeometryAttribute, @@ -32,8 +34,8 @@ define([ * @constructor * * @param {Object} options Object with the following properties: - * @param {Cartesian3} options.minimumCorner The minimum x, y, and z coordinates of the box. - * @param {Cartesian3} options.maximumCorner The maximum x, y, and z coordinates of the box. + * @param {Cartesian3} options.minimum The minimum x, y, and z coordinates of the box. + * @param {Cartesian3} options.maximum The maximum x, y, and z coordinates of the box. * * @see BoxOutlineGeometry.fromDimensions * @see BoxOutlineGeometry.createGeometry @@ -43,23 +45,35 @@ define([ * * @example * var box = new Cesium.BoxOutlineGeometry({ - * maximumCorner : new Cesium.Cartesian3(250000.0, 250000.0, 250000.0), - * minimumCorner : new Cesium.Cartesian3(-250000.0, -250000.0, -250000.0) + * maximum : new Cesium.Cartesian3(250000.0, 250000.0, 250000.0), + * minimum : new Cesium.Cartesian3(-250000.0, -250000.0, -250000.0) * }); * var geometry = Cesium.BoxOutlineGeometry.createGeometry(box); */ var BoxOutlineGeometry = function(options) { options = defaultValue(options, defaultValue.EMPTY_OBJECT); - var min = options.minimumCorner; - var max = options.maximumCorner; + var min = options.minimum; + var max = options.maximum; //>>includeStart('debug', pragmas.debug); if (!defined(min)) { - throw new DeveloperError('options.minimumCorner is required.'); + if (defined(options.minimumCorner)) { + min = options.minimumCorner; + deprecationWarning('BoxOutlineGeometry', 'options.minimumCorner is deprecated. Use options.minimum instead'); + } + else { + throw new DeveloperError('options.minimum is required.'); + } } if (!defined(max)) { - throw new DeveloperError('options.maximumCorner is required'); + if (defined(options.maximumCorner)) { + max = options.maximumCorner; + deprecationWarning('BoxOutlineGeometry', 'options.maximumCorner is deprecated. Use options.maximum instead'); + } + else { + throw new DeveloperError('options.maximum is required'); + } } //>>includeEnd('debug'); @@ -103,8 +117,39 @@ define([ var max = corner; var newOptions = { - minimumCorner : min, - maximumCorner : max + minimum : min, + maximum : max + }; + return new BoxOutlineGeometry(newOptions); + }; + + /** + * Creates an outline of a cube from the dimensions of an AxisAlignedBoundingBox. + * + * @param {AxisAlignedBoundingBox} boundingBox A description of the AxisAlignedBoundingBox. + * @returns {BoxOutlineGeometry} + * + * @exception {DeveloperError} AxisAlignedBoundingBox must be defined. + * + * @see BoxOutlineGeometry.createGeometry + * + * @example + * var aabb = Cesium.AxisAlignedBoundingBox.fromPoints(Cesium.Cartesian3.fromDegreesArray([ + * -72.0, 40.0, + * -70.0, 35.0, + * -75.0, 30.0, + * -70.0, 30.0, + * -68.0, 40.0 + * ])); + * var box = Cesium.BoxOutlineGeometry.fromAxisAlignedBoundingBox(aabb); + */ + BoxOutlineGeometry.fromAxisAlignedBoundingBox = function(boundingBox) { + if (!defined(boundingBox)) { + throw new DeveloperError('boundingBox is required.'); + } + var newOptions = { + minimum : boundingBox.minimum, + maximum : boundingBox.maximum }; return new BoxOutlineGeometry(newOptions); }; @@ -142,8 +187,8 @@ define([ var scratchMin = new Cartesian3(); var scratchMax = new Cartesian3(); var scratchOptions = { - minimumCorner : scratchMin, - maximumCorner : scratchMax + minimum : scratchMin, + maximum : scratchMax }; /** diff --git a/Source/Core/PolygonOutlineGeometry.js b/Source/Core/PolygonOutlineGeometry.js index 9a623f5d03db..2c5f40d134dd 100644 --- a/Source/Core/PolygonOutlineGeometry.js +++ b/Source/Core/PolygonOutlineGeometry.js @@ -276,9 +276,9 @@ define([ * -75.0, 30.0, * -70.0, 30.0, * -68.0, 40.0 - * ]), - * extrudedHeight: 300000 - * } + * ]) + * }, + * extrudedHeight: 300000 * }); * var geometry = Cesium.PolygonOutlineGeometry.createGeometry(extrudedPolygon); */ diff --git a/Specs/Core/BoxGeometrySpec.js b/Specs/Core/BoxGeometrySpec.js index 1c0e55c4e87a..f73bd0abd031 100644 --- a/Specs/Core/BoxGeometrySpec.js +++ b/Specs/Core/BoxGeometrySpec.js @@ -1,11 +1,13 @@ /*global defineSuite*/ defineSuite([ 'Core/BoxGeometry', + 'Core/AxisAlignedBoundingBox', 'Core/Cartesian3', 'Core/VertexFormat', 'Specs/createPackableSpecs' ], function( BoxGeometry, + AxisAlignedBoundingBox, Cartesian3, VertexFormat, createPackableSpecs) { @@ -84,6 +86,20 @@ defineSuite([ expect(m.indices.length).toEqual(12 * 3); }); + it('fromAxisAlignedBoundingBox throws with no boundingBox', function() { + expect(function() { + return BoxGeometry.fromAxisAlignedBoundingBox(undefined); + }).toThrowDeveloperError(); + }); + + it('fromAxisAlignedBoundingBox', function() { + var min = new Cartesian3(-1, -2, -3); + var max = new Cartesian3(1, 2, 3); + var m = BoxGeometry.fromAxisAlignedBoundingBox(new AxisAlignedBoundingBox(min, max)); + expect(m._minimum).toEqual(min); + expect(m._maximum).toEqual(max); + }); + createPackableSpecs(BoxGeometry, new BoxGeometry({ minimumCorner : new Cartesian3(1.0, 2.0, 3.0), maximumCorner : new Cartesian3(4.0, 5.0, 6.0), diff --git a/Specs/Core/BoxOutlineGeometrySpec.js b/Specs/Core/BoxOutlineGeometrySpec.js index 292d2db7232b..d8a77ec2b2ad 100644 --- a/Specs/Core/BoxOutlineGeometrySpec.js +++ b/Specs/Core/BoxOutlineGeometrySpec.js @@ -1,10 +1,12 @@ /*global defineSuite*/ defineSuite([ 'Core/BoxOutlineGeometry', + 'Core/AxisAlignedBoundingBox', 'Core/Cartesian3', 'Specs/createPackableSpecs' ], function( BoxOutlineGeometry, + AxisAlignedBoundingBox, Cartesian3, createPackableSpecs) { "use strict"; @@ -59,6 +61,20 @@ defineSuite([ expect(m.indices.length).toEqual(12 * 2); }); + it('fromAxisAlignedBoundingBox throws with no boundingBox', function() { + expect(function() { + return BoxOutlineGeometry.fromAxisAlignedBoundingBox(undefined); + }).toThrowDeveloperError(); + }); + + it('fromAxisAlignedBoundingBox', function() { + var min = new Cartesian3(-1, -2, -3); + var max = new Cartesian3(1, 2, 3); + var m = BoxOutlineGeometry.fromAxisAlignedBoundingBox(new AxisAlignedBoundingBox(min, max)); + expect(m._min).toEqual(min); + expect(m._max).toEqual(max); + }); + createPackableSpecs(BoxOutlineGeometry, new BoxOutlineGeometry({ minimumCorner : new Cartesian3(1.0, 2.0, 3.0), maximumCorner : new Cartesian3(4.0, 5.0, 6.0) From 8e365a1d716da9154db5aeda07575ae20543ee9a Mon Sep 17 00:00:00 2001 From: ggetz Date: Wed, 14 Oct 2015 11:24:20 -0400 Subject: [PATCH 12/20] included deprecationWarning --- Source/Core/BoxGeometry.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/Core/BoxGeometry.js b/Source/Core/BoxGeometry.js index 1bb44f78d1ff..de9cadedf531 100644 --- a/Source/Core/BoxGeometry.js +++ b/Source/Core/BoxGeometry.js @@ -5,6 +5,7 @@ define([ './ComponentDatatype', './defaultValue', './defined', + './deprecationWarning', './DeveloperError', './Geometry', './GeometryAttribute', @@ -17,6 +18,7 @@ define([ ComponentDatatype, defaultValue, defined, + deprecationWarning, DeveloperError, Geometry, GeometryAttribute, From 26804296d14f1b52bd6ccc4e83cf1db63aa32557 Mon Sep 17 00:00:00 2001 From: ggetz Date: Wed, 14 Oct 2015 11:40:02 -0400 Subject: [PATCH 13/20] Fixed formatting issues --- CHANGES.md | 4 +- CONTRIBUTORS.md | 1 + Source/Core/BoxGeometry.js | 118 +++++++++++++++++++-------- Source/Core/BoxOutlineGeometry.js | 69 +++++++++++++--- Specs/Core/BoxGeometrySpec.js | 16 ++++ Specs/Core/BoxOutlineGeometrySpec.js | 16 ++++ 6 files changed, 176 insertions(+), 48 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 7b4eaa81f6e7..c27628afefa9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,11 +7,13 @@ Change Log * Deleted old `/package.json` and `*.profile.js` files, not used since we moved away from a Dojo-based build years ago. This should allow future compatibility with newer systems like Browserify and Webpack. * ... * Deprecated - * ... + * Depreciated `BoxGeometry.minimumCorner` and `BoxGeometry.maximumCorner`, use `BoxGeometry.minimum` and `BoxGeometry.maximum` instead. These will be removed in 1.17. + * Depreciated `BoxOutlineGeometry.minimumCorner` and `BoxOutlineGeometry.maximumCorner`, use `BoxOutlineGeometry.minimum` and `BoxOutlineGeometry.maximum` instead. These will be removed in 1.17. * Decreased GPU memory usage in `BillboardCollection` and `LabelCollection` by using the WebGL ANGLE_instanced_arrays extension. * Added CZML examples to Sandcastle. See the new CZML tab. * Fixed token issue in ArcGisMapServerImageryProvider. * `ImageryLayerFeatureInfo` now has an `imageryLayer` property, indicating the layer that contains the feature. +* Added `BoxOutlineGeometry.fromAxisAlignedBoundingBox` and `BoxGeometry.fromAxisAlignedBoundingBox` functions. ### 1.14 - 2015-10-01 diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 3ccf4b6a80f0..5041e73b2863 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -26,6 +26,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu * [Kai Ninomiya](https://github.com/kainino0x) * [Sean Lilley](https://github.com/lilleyse) * [Katherina Lim](https://github.com/klim705) + * [Gabrielle Getz](https://github.com/ggetz) * [NICTA](http://www.nicta.com.au/) * [Chris Cooper](https://github.com/chris-cooper) * [Kevin Ring](https://github.com/kring) diff --git a/Source/Core/BoxGeometry.js b/Source/Core/BoxGeometry.js index ee262c151be7..97d6eecc25cd 100644 --- a/Source/Core/BoxGeometry.js +++ b/Source/Core/BoxGeometry.js @@ -5,6 +5,7 @@ define([ './ComponentDatatype', './defaultValue', './defined', + './deprecationWarning', './DeveloperError', './Geometry', './GeometryAttribute', @@ -17,6 +18,7 @@ define([ ComponentDatatype, defaultValue, defined, + deprecationWarning, DeveloperError, Geometry, GeometryAttribute, @@ -34,8 +36,8 @@ define([ * @constructor * * @param {Object} options Object with the following properties: - * @param {Cartesian3} options.minimumCorner The minimum x, y, and z coordinates of the box. - * @param {Cartesian3} options.maximumCorner The maximum x, y, and z coordinates of the box. + * @param {Cartesian3} options.minimum The minimum x, y, and z coordinates of the box. + * @param {Cartesian3} options.maximum The maximum x, y, and z coordinates of the box. * @param {VertexFormat} [options.vertexFormat=VertexFormat.DEFAULT] The vertex attributes to be computed. * * @see BoxGeometry.fromDimensions @@ -47,29 +49,42 @@ define([ * @example * var box = new Cesium.BoxGeometry({ * vertexFormat : Cesium.VertexFormat.POSITION_ONLY, - * maximumCorner : new Cesium.Cartesian3(250000.0, 250000.0, 250000.0), - * minimumCorner : new Cesium.Cartesian3(-250000.0, -250000.0, -250000.0) + * maximum : new Cesium.Cartesian3(250000.0, 250000.0, 250000.0), + * minimum : new Cesium.Cartesian3(-250000.0, -250000.0, -250000.0) * }); * var geometry = Cesium.BoxGeometry.createGeometry(box); */ - var BoxGeometry = function(options) { + var BoxGeometry = function (options) { options = defaultValue(options, defaultValue.EMPTY_OBJECT); - var min = options.minimumCorner; - var max = options.maximumCorner; + + var min = options.minimum; + var max = options.maximum; //>>includeStart('debug', pragmas.debug); if (!defined(min)) { - throw new DeveloperError('options.minimumCorner is required.'); + if (defined(options.minimumCorner)) { + min = options.minimumCorner; + deprecationWarning('BoxGeometry', 'options.minimumCorner is deprecated. Use options.minimum instead'); + } + else { + throw new DeveloperError('options.minimum is required.'); + } } if (!defined(max)) { - throw new DeveloperError('options.maximumCorner is required'); + if (defined(options.maximumCorner)) { + max = options.maximumCorner; + deprecationWarning('BoxGeometry', 'options.maximumCorner is deprecated. Use options.maximum instead'); + } + else { + throw new DeveloperError('options.maximum is required'); + } } //>>includeEnd('debug'); var vertexFormat = defaultValue(options.vertexFormat, VertexFormat.DEFAULT); - this._minimumCorner = Cartesian3.clone(min); - this._maximumCorner = Cartesian3.clone(max); + this._minimum = Cartesian3.clone(min); + this._maximum = Cartesian3.clone(max); this._vertexFormat = vertexFormat; this._workerName = 'createBoxGeometry'; }; @@ -111,13 +126,46 @@ define([ var max = corner; var newOptions = { - minimumCorner : min, - maximumCorner : max, + minimum : min, + maximum : max, vertexFormat : options.vertexFormat }; return new BoxGeometry(newOptions); }; + /** + * Creates a cube from the dimensions of an AxisAlignedBoundingBox. + * + * @param {AxisAlignedBoundingBox} boundingBox A description of the AxisAlignedBoundingBox. + * @returns {BoxGeometry} + * + * @exception {DeveloperError} AxisAlignedBoundingBox must be defined. + * + * @see BoxGeometry.createGeometry + * + * @example + * var aabb = Cesium.AxisAlignedBoundingBox.fromPoints(Cesium.Cartesian3.fromDegreesArray([ + * -72.0, 40.0, + * -70.0, 35.0, + * -75.0, 30.0, + * -70.0, 30.0, + * -68.0, 40.0 + * ])); + * var box = Cesium.BoxGeometry.fromAxisAlignedBoundingBox({ + * boundingBox: aabb + * }); + */ + BoxGeometry.fromAxisAlignedBoundingBox = function (boundingBox) { + if (!defined(boundingBox)) { + throw new DeveloperError('boundingBox is required.'); + } + var newOptions = { + minimum : boundingBox.minimum, + maximum : boundingBox.maximum + }; + return new BoxGeometry(newOptions); + }; + /** * The number of elements used to pack the object into an array. * @type {Number} @@ -144,8 +192,8 @@ define([ startingIndex = defaultValue(startingIndex, 0); - Cartesian3.pack(value._minimumCorner, array, startingIndex); - Cartesian3.pack(value._maximumCorner, array, startingIndex + Cartesian3.packedLength); + Cartesian3.pack(value._minimum, array, startingIndex); + Cartesian3.pack(value._maximum, array, startingIndex + Cartesian3.packedLength); VertexFormat.pack(value._vertexFormat, array, startingIndex + 2 * Cartesian3.packedLength); }; @@ -153,9 +201,9 @@ define([ var scratchMax = new Cartesian3(); var scratchVertexFormat = new VertexFormat(); var scratchOptions = { - minimumCorner : scratchMin, - maximumCorner : scratchMax, - vertexFormat : scratchVertexFormat + minimum: scratchMin, + maximum: scratchMax, + vertexFormat: scratchVertexFormat }; /** @@ -166,7 +214,7 @@ define([ * @param {BoxGeometry} [result] The object into which to store the result. * @returns {BoxGeometry} The modified result parameter or a new BoxGeometry instance if one was not provided. */ - BoxGeometry.unpack = function(array, startingIndex, result) { + BoxGeometry.unpack = function (array, startingIndex, result) { //>>includeStart('debug', pragmas.debug); if (!defined(array)) { throw new DeveloperError('array is required'); @@ -183,8 +231,8 @@ define([ return new BoxGeometry(scratchOptions); } - result._minimumCorner = Cartesian3.clone(min, result._minimumCorner); - result._maximumCorner = Cartesian3.clone(max, result._maximumCorner); + result._minimum = Cartesian3.clone(min, result._minimum); + result._maximum = Cartesian3.clone(max, result._maximum); result._vertexFormat = VertexFormat.clone(vertexFormat, result._vertexFormat); return result; @@ -196,9 +244,9 @@ define([ * @param {BoxGeometry} boxGeometry A description of the box. * @returns {Geometry} The computed vertices and indices. */ - BoxGeometry.createGeometry = function(boxGeometry) { - var min = boxGeometry._minimumCorner; - var max = boxGeometry._maximumCorner; + BoxGeometry.createGeometry = function (boxGeometry) { + var min = boxGeometry._minimum; + var max = boxGeometry._maximum; var vertexFormat = boxGeometry._vertexFormat; var attributes = new GeometryAttributes(); @@ -206,22 +254,22 @@ define([ var positions; if (vertexFormat.position && - (vertexFormat.st || vertexFormat.normal || vertexFormat.binormal || vertexFormat.tangent)) { + (vertexFormat.st || vertexFormat.normal || vertexFormat.binormal || vertexFormat.tangent)) { if (vertexFormat.position) { // 8 corner points. Duplicated 3 times each for each incident edge/face. positions = new Float64Array(6 * 4 * 3); // +z face - positions[0] = min.x; - positions[1] = min.y; - positions[2] = max.z; - positions[3] = max.x; - positions[4] = min.y; - positions[5] = max.z; - positions[6] = max.x; - positions[7] = max.y; - positions[8] = max.z; - positions[9] = min.x; + positions[0] = min.x; + positions[1] = min.y; + positions[2] = max.z; + positions[3] = max.x; + positions[4] = min.y; + positions[5] = max.z; + positions[6] = max.x; + positions[7] = max.y; + positions[8] = max.z; + positions[9] = min.x; positions[10] = max.y; positions[11] = max.z; diff --git a/Source/Core/BoxOutlineGeometry.js b/Source/Core/BoxOutlineGeometry.js index 6a62b08c26d1..b7a7fe86157e 100644 --- a/Source/Core/BoxOutlineGeometry.js +++ b/Source/Core/BoxOutlineGeometry.js @@ -5,6 +5,7 @@ define([ './ComponentDatatype', './defaultValue', './defined', + './deprecationWarning', './DeveloperError', './Geometry', './GeometryAttribute', @@ -16,6 +17,7 @@ define([ ComponentDatatype, defaultValue, defined, + deprecationWarning, DeveloperError, Geometry, GeometryAttribute, @@ -32,8 +34,8 @@ define([ * @constructor * * @param {Object} options Object with the following properties: - * @param {Cartesian3} options.minimumCorner The minimum x, y, and z coordinates of the box. - * @param {Cartesian3} options.maximumCorner The maximum x, y, and z coordinates of the box. + * @param {Cartesian3} options.minimum The minimum x, y, and z coordinates of the box. + * @param {Cartesian3} options.maximum The maximum x, y, and z coordinates of the box. * * @see BoxOutlineGeometry.fromDimensions * @see BoxOutlineGeometry.createGeometry @@ -43,23 +45,35 @@ define([ * * @example * var box = new Cesium.BoxOutlineGeometry({ - * maximumCorner : new Cesium.Cartesian3(250000.0, 250000.0, 250000.0), - * minimumCorner : new Cesium.Cartesian3(-250000.0, -250000.0, -250000.0) + * maximum : new Cesium.Cartesian3(250000.0, 250000.0, 250000.0), + * minimum : new Cesium.Cartesian3(-250000.0, -250000.0, -250000.0) * }); * var geometry = Cesium.BoxOutlineGeometry.createGeometry(box); */ var BoxOutlineGeometry = function(options) { options = defaultValue(options, defaultValue.EMPTY_OBJECT); - var min = options.minimumCorner; - var max = options.maximumCorner; + var min = options.minimum; + var max = options.maximum; //>>includeStart('debug', pragmas.debug); if (!defined(min)) { - throw new DeveloperError('options.minimumCorner is required.'); + if (defined(options.minimumCorner)) { + min = options.minimumCorner; + deprecationWarning('BoxOutlineGeometry', 'options.minimumCorner is deprecated. Use options.minimum instead'); + } + else { + throw new DeveloperError('options.minimum is required.'); + } } if (!defined(max)) { - throw new DeveloperError('options.maximumCorner is required'); + if (defined(options.maximumCorner)) { + max = options.maximumCorner; + deprecationWarning('BoxOutlineGeometry', 'options.maximumCorner is deprecated. Use options.maximum instead'); + } + else { + throw new DeveloperError('options.maximum is required'); + } } //>>includeEnd('debug'); @@ -103,8 +117,39 @@ define([ var max = corner; var newOptions = { - minimumCorner : min, - maximumCorner : max + minimum : min, + maximum : max + }; + return new BoxOutlineGeometry(newOptions); + }; + + /** + * Creates an outline of a cube from the dimensions of an AxisAlignedBoundingBox. + * + * @param {AxisAlignedBoundingBox} boundingBox A description of the AxisAlignedBoundingBox. + * @returns {BoxOutlineGeometry} + * + * @exception {DeveloperError} AxisAlignedBoundingBox must be defined. + * + * @see BoxOutlineGeometry.createGeometry + * + * @example + * var aabb = Cesium.AxisAlignedBoundingBox.fromPoints(Cesium.Cartesian3.fromDegreesArray([ + * -72.0, 40.0, + * -70.0, 35.0, + * -75.0, 30.0, + * -70.0, 30.0, + * -68.0, 40.0 + * ])); + * var box = Cesium.BoxOutlineGeometry.fromAxisAlignedBoundingBox(aabb); + */ + BoxOutlineGeometry.fromAxisAlignedBoundingBox = function(boundingBox) { + if (!defined(boundingBox)) { + throw new DeveloperError('boundingBox is required.'); + } + var newOptions = { + minimum : boundingBox.minimum, + maximum : boundingBox.maximum }; return new BoxOutlineGeometry(newOptions); }; @@ -142,8 +187,8 @@ define([ var scratchMin = new Cartesian3(); var scratchMax = new Cartesian3(); var scratchOptions = { - minimumCorner : scratchMin, - maximumCorner : scratchMax + minimum : scratchMin, + maximum : scratchMax }; /** diff --git a/Specs/Core/BoxGeometrySpec.js b/Specs/Core/BoxGeometrySpec.js index 1c0e55c4e87a..f73bd0abd031 100644 --- a/Specs/Core/BoxGeometrySpec.js +++ b/Specs/Core/BoxGeometrySpec.js @@ -1,11 +1,13 @@ /*global defineSuite*/ defineSuite([ 'Core/BoxGeometry', + 'Core/AxisAlignedBoundingBox', 'Core/Cartesian3', 'Core/VertexFormat', 'Specs/createPackableSpecs' ], function( BoxGeometry, + AxisAlignedBoundingBox, Cartesian3, VertexFormat, createPackableSpecs) { @@ -84,6 +86,20 @@ defineSuite([ expect(m.indices.length).toEqual(12 * 3); }); + it('fromAxisAlignedBoundingBox throws with no boundingBox', function() { + expect(function() { + return BoxGeometry.fromAxisAlignedBoundingBox(undefined); + }).toThrowDeveloperError(); + }); + + it('fromAxisAlignedBoundingBox', function() { + var min = new Cartesian3(-1, -2, -3); + var max = new Cartesian3(1, 2, 3); + var m = BoxGeometry.fromAxisAlignedBoundingBox(new AxisAlignedBoundingBox(min, max)); + expect(m._minimum).toEqual(min); + expect(m._maximum).toEqual(max); + }); + createPackableSpecs(BoxGeometry, new BoxGeometry({ minimumCorner : new Cartesian3(1.0, 2.0, 3.0), maximumCorner : new Cartesian3(4.0, 5.0, 6.0), diff --git a/Specs/Core/BoxOutlineGeometrySpec.js b/Specs/Core/BoxOutlineGeometrySpec.js index 292d2db7232b..d8a77ec2b2ad 100644 --- a/Specs/Core/BoxOutlineGeometrySpec.js +++ b/Specs/Core/BoxOutlineGeometrySpec.js @@ -1,10 +1,12 @@ /*global defineSuite*/ defineSuite([ 'Core/BoxOutlineGeometry', + 'Core/AxisAlignedBoundingBox', 'Core/Cartesian3', 'Specs/createPackableSpecs' ], function( BoxOutlineGeometry, + AxisAlignedBoundingBox, Cartesian3, createPackableSpecs) { "use strict"; @@ -59,6 +61,20 @@ defineSuite([ expect(m.indices.length).toEqual(12 * 2); }); + it('fromAxisAlignedBoundingBox throws with no boundingBox', function() { + expect(function() { + return BoxOutlineGeometry.fromAxisAlignedBoundingBox(undefined); + }).toThrowDeveloperError(); + }); + + it('fromAxisAlignedBoundingBox', function() { + var min = new Cartesian3(-1, -2, -3); + var max = new Cartesian3(1, 2, 3); + var m = BoxOutlineGeometry.fromAxisAlignedBoundingBox(new AxisAlignedBoundingBox(min, max)); + expect(m._min).toEqual(min); + expect(m._max).toEqual(max); + }); + createPackableSpecs(BoxOutlineGeometry, new BoxOutlineGeometry({ minimumCorner : new Cartesian3(1.0, 2.0, 3.0), maximumCorner : new Cartesian3(4.0, 5.0, 6.0) From 3af93ef6aa77417db05543d8df4ce1394ede0fd4 Mon Sep 17 00:00:00 2001 From: ggetz Date: Wed, 14 Oct 2015 11:43:00 -0400 Subject: [PATCH 14/20] Fixed deprecation warnings --- Source/Core/BoxGeometry.js | 4 ++-- Source/Core/BoxOutlineGeometry.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/Core/BoxGeometry.js b/Source/Core/BoxGeometry.js index 97d6eecc25cd..23f42e973a91 100644 --- a/Source/Core/BoxGeometry.js +++ b/Source/Core/BoxGeometry.js @@ -64,7 +64,7 @@ define([ if (!defined(min)) { if (defined(options.minimumCorner)) { min = options.minimumCorner; - deprecationWarning('BoxGeometry', 'options.minimumCorner is deprecated. Use options.minimum instead'); + deprecationWarning('BoxGeometry', 'options.minimumCorner is deprecated. Use options.minimum instead.'); } else { throw new DeveloperError('options.minimum is required.'); @@ -73,7 +73,7 @@ define([ if (!defined(max)) { if (defined(options.maximumCorner)) { max = options.maximumCorner; - deprecationWarning('BoxGeometry', 'options.maximumCorner is deprecated. Use options.maximum instead'); + deprecationWarning('BoxGeometry', 'options.maximumCorner is deprecated. Use options.maximum instead.'); } else { throw new DeveloperError('options.maximum is required'); diff --git a/Source/Core/BoxOutlineGeometry.js b/Source/Core/BoxOutlineGeometry.js index b7a7fe86157e..63cf1515b625 100644 --- a/Source/Core/BoxOutlineGeometry.js +++ b/Source/Core/BoxOutlineGeometry.js @@ -60,7 +60,7 @@ define([ if (!defined(min)) { if (defined(options.minimumCorner)) { min = options.minimumCorner; - deprecationWarning('BoxOutlineGeometry', 'options.minimumCorner is deprecated. Use options.minimum instead'); + deprecationWarning('BoxOutlineGeometry', 'options.minimumCorner is deprecated. Use options.minimum instead.'); } else { throw new DeveloperError('options.minimum is required.'); @@ -69,7 +69,7 @@ define([ if (!defined(max)) { if (defined(options.maximumCorner)) { max = options.maximumCorner; - deprecationWarning('BoxOutlineGeometry', 'options.maximumCorner is deprecated. Use options.maximum instead'); + deprecationWarning('BoxOutlineGeometry', 'options.maximumCorner is deprecated. Use options.maximum instead.'); } else { throw new DeveloperError('options.maximum is required'); From 98a32e5212c797e0da88b35bbbd796742aae16ec Mon Sep 17 00:00:00 2001 From: ggetz Date: Wed, 14 Oct 2015 12:06:13 -0400 Subject: [PATCH 15/20] Fixed Formatting --- CHANGES.md | 4 +- CONTRIBUTORS.md | 1 + Source/Core/BoxGeometry.js | 123 ++++++++++++++++++++++----- Source/Core/BoxOutlineGeometry.js | 69 ++++++++++++--- Specs/Core/BoxGeometrySpec.js | 16 ++++ Specs/Core/BoxOutlineGeometrySpec.js | 16 ++++ 6 files changed, 195 insertions(+), 34 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 7b4eaa81f6e7..c27628afefa9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,11 +7,13 @@ Change Log * Deleted old `/package.json` and `*.profile.js` files, not used since we moved away from a Dojo-based build years ago. This should allow future compatibility with newer systems like Browserify and Webpack. * ... * Deprecated - * ... + * Depreciated `BoxGeometry.minimumCorner` and `BoxGeometry.maximumCorner`, use `BoxGeometry.minimum` and `BoxGeometry.maximum` instead. These will be removed in 1.17. + * Depreciated `BoxOutlineGeometry.minimumCorner` and `BoxOutlineGeometry.maximumCorner`, use `BoxOutlineGeometry.minimum` and `BoxOutlineGeometry.maximum` instead. These will be removed in 1.17. * Decreased GPU memory usage in `BillboardCollection` and `LabelCollection` by using the WebGL ANGLE_instanced_arrays extension. * Added CZML examples to Sandcastle. See the new CZML tab. * Fixed token issue in ArcGisMapServerImageryProvider. * `ImageryLayerFeatureInfo` now has an `imageryLayer` property, indicating the layer that contains the feature. +* Added `BoxOutlineGeometry.fromAxisAlignedBoundingBox` and `BoxGeometry.fromAxisAlignedBoundingBox` functions. ### 1.14 - 2015-10-01 diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 3ccf4b6a80f0..5041e73b2863 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -26,6 +26,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu * [Kai Ninomiya](https://github.com/kainino0x) * [Sean Lilley](https://github.com/lilleyse) * [Katherina Lim](https://github.com/klim705) + * [Gabrielle Getz](https://github.com/ggetz) * [NICTA](http://www.nicta.com.au/) * [Chris Cooper](https://github.com/chris-cooper) * [Kevin Ring](https://github.com/kring) diff --git a/Source/Core/BoxGeometry.js b/Source/Core/BoxGeometry.js index ee262c151be7..2786e29e8221 100644 --- a/Source/Core/BoxGeometry.js +++ b/Source/Core/BoxGeometry.js @@ -5,6 +5,7 @@ define([ './ComponentDatatype', './defaultValue', './defined', + './deprecationWarning', './DeveloperError', './Geometry', './GeometryAttribute', @@ -17,6 +18,7 @@ define([ ComponentDatatype, defaultValue, defined, + deprecationWarning, DeveloperError, Geometry, GeometryAttribute, @@ -34,8 +36,8 @@ define([ * @constructor * * @param {Object} options Object with the following properties: - * @param {Cartesian3} options.minimumCorner The minimum x, y, and z coordinates of the box. - * @param {Cartesian3} options.maximumCorner The maximum x, y, and z coordinates of the box. + * @param {Cartesian3} options.minimum The minimum x, y, and z coordinates of the box. + * @param {Cartesian3} options.maximum The maximum x, y, and z coordinates of the box. * @param {VertexFormat} [options.vertexFormat=VertexFormat.DEFAULT] The vertex attributes to be computed. * * @see BoxGeometry.fromDimensions @@ -47,29 +49,42 @@ define([ * @example * var box = new Cesium.BoxGeometry({ * vertexFormat : Cesium.VertexFormat.POSITION_ONLY, - * maximumCorner : new Cesium.Cartesian3(250000.0, 250000.0, 250000.0), - * minimumCorner : new Cesium.Cartesian3(-250000.0, -250000.0, -250000.0) + * maximum : new Cesium.Cartesian3(250000.0, 250000.0, 250000.0), + * minimum : new Cesium.Cartesian3(-250000.0, -250000.0, -250000.0) * }); * var geometry = Cesium.BoxGeometry.createGeometry(box); */ var BoxGeometry = function(options) { options = defaultValue(options, defaultValue.EMPTY_OBJECT); - var min = options.minimumCorner; - var max = options.maximumCorner; + + var min = options.minimum; + var max = options.maximum; //>>includeStart('debug', pragmas.debug); if (!defined(min)) { - throw new DeveloperError('options.minimumCorner is required.'); + if (defined(options.minimumCorner)) { + min = options.minimumCorner; + deprecationWarning('BoxGeometry', 'options.minimumCorner is deprecated. Use options.minimum instead.'); + } + else { + throw new DeveloperError('options.minimum is required.'); + } } if (!defined(max)) { - throw new DeveloperError('options.maximumCorner is required'); + if (defined(options.maximumCorner)) { + max = options.maximumCorner; + deprecationWarning('BoxGeometry', 'options.maximumCorner is deprecated. Use options.maximum instead.'); + } + else { + throw new DeveloperError('options.maximum is required'); + } } //>>includeEnd('debug'); var vertexFormat = defaultValue(options.vertexFormat, VertexFormat.DEFAULT); - this._minimumCorner = Cartesian3.clone(min); - this._maximumCorner = Cartesian3.clone(max); + this._minimum = Cartesian3.clone(min); + this._maximum = Cartesian3.clone(max); this._vertexFormat = vertexFormat; this._workerName = 'createBoxGeometry'; }; @@ -111,13 +126,79 @@ define([ var max = corner; var newOptions = { - minimumCorner : min, - maximumCorner : max, + minimum : min, + maximum : max, vertexFormat : options.vertexFormat }; return new BoxGeometry(newOptions); }; + /** + * Creates a cube from the dimensions of an AxisAlignedBoundingBox. + * + * @param {AxisAlignedBoundingBox} boundingBox A description of the AxisAlignedBoundingBox. + * @returns {BoxGeometry} + * + * @exception {DeveloperError} AxisAlignedBoundingBox must be defined. + * + * @see BoxGeometry.createGeometry + * + * @example + * var aabb = Cesium.AxisAlignedBoundingBox.fromPoints(Cesium.Cartesian3.fromDegreesArray([ + * -72.0, 40.0, + * -70.0, 35.0, + * -75.0, 30.0, + * -70.0, 30.0, + * -68.0, 40.0 + * ])); + * var box = Cesium.BoxGeometry.fromAxisAlignedBoundingBox({ + * boundingBox: aabb + * }); + */ + BoxGeometry.fromAxisAlignedBoundingBox = function (boundingBox) { + if (!defined(boundingBox)) { + throw new DeveloperError('boundingBox is required.'); + } + var newOptions = { + minimum: boundingBox.minimum, + maximum: boundingBox.maximum + }; + return new BoxGeometry(newOptions); + }; + + /** + * Creates a cube from the dimensions of an AxisAlignedBoundingBox. + * + * @param {AxisAlignedBoundingBox} boundingBox A description of the AxisAlignedBoundingBox. + * @returns {BoxGeometry} + * + * @exception {DeveloperError} AxisAlignedBoundingBox must be defined. + * + * @see BoxGeometry.createGeometry + * + * @example + * var aabb = Cesium.AxisAlignedBoundingBox.fromPoints(Cesium.Cartesian3.fromDegreesArray([ + * -72.0, 40.0, + * -70.0, 35.0, + * -75.0, 30.0, + * -70.0, 30.0, + * -68.0, 40.0 + * ])); + * var box = Cesium.BoxGeometry.fromAxisAlignedBoundingBox({ + * boundingBox: aabb + * }); + */ + BoxGeometry.fromAxisAlignedBoundingBox = function (boundingBox) { + if (!defined(boundingBox)) { + throw new DeveloperError('boundingBox is required.'); + } + var newOptions = { + minimum : boundingBox.minimum, + maximum : boundingBox.maximum + }; + return new BoxGeometry(newOptions); + }; + /** * The number of elements used to pack the object into an array. * @type {Number} @@ -144,8 +225,8 @@ define([ startingIndex = defaultValue(startingIndex, 0); - Cartesian3.pack(value._minimumCorner, array, startingIndex); - Cartesian3.pack(value._maximumCorner, array, startingIndex + Cartesian3.packedLength); + Cartesian3.pack(value._minimum, array, startingIndex); + Cartesian3.pack(value._maximum, array, startingIndex + Cartesian3.packedLength); VertexFormat.pack(value._vertexFormat, array, startingIndex + 2 * Cartesian3.packedLength); }; @@ -153,9 +234,9 @@ define([ var scratchMax = new Cartesian3(); var scratchVertexFormat = new VertexFormat(); var scratchOptions = { - minimumCorner : scratchMin, - maximumCorner : scratchMax, - vertexFormat : scratchVertexFormat + minimum: scratchMin, + maximum: scratchMax, + vertexFormat: scratchVertexFormat }; /** @@ -183,8 +264,8 @@ define([ return new BoxGeometry(scratchOptions); } - result._minimumCorner = Cartesian3.clone(min, result._minimumCorner); - result._maximumCorner = Cartesian3.clone(max, result._maximumCorner); + result._minimum = Cartesian3.clone(min, result._minimum); + result._maximum = Cartesian3.clone(max, result._maximum); result._vertexFormat = VertexFormat.clone(vertexFormat, result._vertexFormat); return result; @@ -197,8 +278,8 @@ define([ * @returns {Geometry} The computed vertices and indices. */ BoxGeometry.createGeometry = function(boxGeometry) { - var min = boxGeometry._minimumCorner; - var max = boxGeometry._maximumCorner; + var min = boxGeometry._minimum; + var max = boxGeometry._maximum; var vertexFormat = boxGeometry._vertexFormat; var attributes = new GeometryAttributes(); diff --git a/Source/Core/BoxOutlineGeometry.js b/Source/Core/BoxOutlineGeometry.js index 6a62b08c26d1..63cf1515b625 100644 --- a/Source/Core/BoxOutlineGeometry.js +++ b/Source/Core/BoxOutlineGeometry.js @@ -5,6 +5,7 @@ define([ './ComponentDatatype', './defaultValue', './defined', + './deprecationWarning', './DeveloperError', './Geometry', './GeometryAttribute', @@ -16,6 +17,7 @@ define([ ComponentDatatype, defaultValue, defined, + deprecationWarning, DeveloperError, Geometry, GeometryAttribute, @@ -32,8 +34,8 @@ define([ * @constructor * * @param {Object} options Object with the following properties: - * @param {Cartesian3} options.minimumCorner The minimum x, y, and z coordinates of the box. - * @param {Cartesian3} options.maximumCorner The maximum x, y, and z coordinates of the box. + * @param {Cartesian3} options.minimum The minimum x, y, and z coordinates of the box. + * @param {Cartesian3} options.maximum The maximum x, y, and z coordinates of the box. * * @see BoxOutlineGeometry.fromDimensions * @see BoxOutlineGeometry.createGeometry @@ -43,23 +45,35 @@ define([ * * @example * var box = new Cesium.BoxOutlineGeometry({ - * maximumCorner : new Cesium.Cartesian3(250000.0, 250000.0, 250000.0), - * minimumCorner : new Cesium.Cartesian3(-250000.0, -250000.0, -250000.0) + * maximum : new Cesium.Cartesian3(250000.0, 250000.0, 250000.0), + * minimum : new Cesium.Cartesian3(-250000.0, -250000.0, -250000.0) * }); * var geometry = Cesium.BoxOutlineGeometry.createGeometry(box); */ var BoxOutlineGeometry = function(options) { options = defaultValue(options, defaultValue.EMPTY_OBJECT); - var min = options.minimumCorner; - var max = options.maximumCorner; + var min = options.minimum; + var max = options.maximum; //>>includeStart('debug', pragmas.debug); if (!defined(min)) { - throw new DeveloperError('options.minimumCorner is required.'); + if (defined(options.minimumCorner)) { + min = options.minimumCorner; + deprecationWarning('BoxOutlineGeometry', 'options.minimumCorner is deprecated. Use options.minimum instead.'); + } + else { + throw new DeveloperError('options.minimum is required.'); + } } if (!defined(max)) { - throw new DeveloperError('options.maximumCorner is required'); + if (defined(options.maximumCorner)) { + max = options.maximumCorner; + deprecationWarning('BoxOutlineGeometry', 'options.maximumCorner is deprecated. Use options.maximum instead.'); + } + else { + throw new DeveloperError('options.maximum is required'); + } } //>>includeEnd('debug'); @@ -103,8 +117,39 @@ define([ var max = corner; var newOptions = { - minimumCorner : min, - maximumCorner : max + minimum : min, + maximum : max + }; + return new BoxOutlineGeometry(newOptions); + }; + + /** + * Creates an outline of a cube from the dimensions of an AxisAlignedBoundingBox. + * + * @param {AxisAlignedBoundingBox} boundingBox A description of the AxisAlignedBoundingBox. + * @returns {BoxOutlineGeometry} + * + * @exception {DeveloperError} AxisAlignedBoundingBox must be defined. + * + * @see BoxOutlineGeometry.createGeometry + * + * @example + * var aabb = Cesium.AxisAlignedBoundingBox.fromPoints(Cesium.Cartesian3.fromDegreesArray([ + * -72.0, 40.0, + * -70.0, 35.0, + * -75.0, 30.0, + * -70.0, 30.0, + * -68.0, 40.0 + * ])); + * var box = Cesium.BoxOutlineGeometry.fromAxisAlignedBoundingBox(aabb); + */ + BoxOutlineGeometry.fromAxisAlignedBoundingBox = function(boundingBox) { + if (!defined(boundingBox)) { + throw new DeveloperError('boundingBox is required.'); + } + var newOptions = { + minimum : boundingBox.minimum, + maximum : boundingBox.maximum }; return new BoxOutlineGeometry(newOptions); }; @@ -142,8 +187,8 @@ define([ var scratchMin = new Cartesian3(); var scratchMax = new Cartesian3(); var scratchOptions = { - minimumCorner : scratchMin, - maximumCorner : scratchMax + minimum : scratchMin, + maximum : scratchMax }; /** diff --git a/Specs/Core/BoxGeometrySpec.js b/Specs/Core/BoxGeometrySpec.js index 1c0e55c4e87a..f73bd0abd031 100644 --- a/Specs/Core/BoxGeometrySpec.js +++ b/Specs/Core/BoxGeometrySpec.js @@ -1,11 +1,13 @@ /*global defineSuite*/ defineSuite([ 'Core/BoxGeometry', + 'Core/AxisAlignedBoundingBox', 'Core/Cartesian3', 'Core/VertexFormat', 'Specs/createPackableSpecs' ], function( BoxGeometry, + AxisAlignedBoundingBox, Cartesian3, VertexFormat, createPackableSpecs) { @@ -84,6 +86,20 @@ defineSuite([ expect(m.indices.length).toEqual(12 * 3); }); + it('fromAxisAlignedBoundingBox throws with no boundingBox', function() { + expect(function() { + return BoxGeometry.fromAxisAlignedBoundingBox(undefined); + }).toThrowDeveloperError(); + }); + + it('fromAxisAlignedBoundingBox', function() { + var min = new Cartesian3(-1, -2, -3); + var max = new Cartesian3(1, 2, 3); + var m = BoxGeometry.fromAxisAlignedBoundingBox(new AxisAlignedBoundingBox(min, max)); + expect(m._minimum).toEqual(min); + expect(m._maximum).toEqual(max); + }); + createPackableSpecs(BoxGeometry, new BoxGeometry({ minimumCorner : new Cartesian3(1.0, 2.0, 3.0), maximumCorner : new Cartesian3(4.0, 5.0, 6.0), diff --git a/Specs/Core/BoxOutlineGeometrySpec.js b/Specs/Core/BoxOutlineGeometrySpec.js index 292d2db7232b..d8a77ec2b2ad 100644 --- a/Specs/Core/BoxOutlineGeometrySpec.js +++ b/Specs/Core/BoxOutlineGeometrySpec.js @@ -1,10 +1,12 @@ /*global defineSuite*/ defineSuite([ 'Core/BoxOutlineGeometry', + 'Core/AxisAlignedBoundingBox', 'Core/Cartesian3', 'Specs/createPackableSpecs' ], function( BoxOutlineGeometry, + AxisAlignedBoundingBox, Cartesian3, createPackableSpecs) { "use strict"; @@ -59,6 +61,20 @@ defineSuite([ expect(m.indices.length).toEqual(12 * 2); }); + it('fromAxisAlignedBoundingBox throws with no boundingBox', function() { + expect(function() { + return BoxOutlineGeometry.fromAxisAlignedBoundingBox(undefined); + }).toThrowDeveloperError(); + }); + + it('fromAxisAlignedBoundingBox', function() { + var min = new Cartesian3(-1, -2, -3); + var max = new Cartesian3(1, 2, 3); + var m = BoxOutlineGeometry.fromAxisAlignedBoundingBox(new AxisAlignedBoundingBox(min, max)); + expect(m._min).toEqual(min); + expect(m._max).toEqual(max); + }); + createPackableSpecs(BoxOutlineGeometry, new BoxOutlineGeometry({ minimumCorner : new Cartesian3(1.0, 2.0, 3.0), maximumCorner : new Cartesian3(4.0, 5.0, 6.0) From 6e97913edaad6677aa2903b8d248223812307c5c Mon Sep 17 00:00:00 2001 From: Patrick Cozzi Date: Wed, 14 Oct 2015 12:15:51 -0400 Subject: [PATCH 16/20] Tweak --- Source/Core/BoxGeometry.js | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/Source/Core/BoxGeometry.js b/Source/Core/BoxGeometry.js index 2786e29e8221..49803c3f84e8 100644 --- a/Source/Core/BoxGeometry.js +++ b/Source/Core/BoxGeometry.js @@ -122,15 +122,12 @@ define([ //>>includeEnd('debug'); var corner = Cartesian3.multiplyByScalar(dimensions, 0.5, new Cartesian3()); - var min = Cartesian3.negate(corner, new Cartesian3()); - var max = corner; - var newOptions = { - minimum : min, - maximum : max, + return new BoxGeometry({ + minimum : Cartesian3.negate(corner, new Cartesian3()), + maximum : corner, vertexFormat : options.vertexFormat - }; - return new BoxGeometry(newOptions); + }); }; /** @@ -159,11 +156,11 @@ define([ if (!defined(boundingBox)) { throw new DeveloperError('boundingBox is required.'); } - var newOptions = { + + return new BoxGeometry({ minimum: boundingBox.minimum, maximum: boundingBox.maximum - }; - return new BoxGeometry(newOptions); + }); }; /** @@ -192,11 +189,11 @@ define([ if (!defined(boundingBox)) { throw new DeveloperError('boundingBox is required.'); } - var newOptions = { + + return new BoxGeometry({ minimum : boundingBox.minimum, maximum : boundingBox.maximum - }; - return new BoxGeometry(newOptions); + }); }; /** From 716f8a69624bd89f238f7675433b48164bd1e838 Mon Sep 17 00:00:00 2001 From: Patrick Cozzi Date: Wed, 14 Oct 2015 12:17:31 -0400 Subject: [PATCH 17/20] Tweak --- Source/Core/BoxOutlineGeometry.js | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/Source/Core/BoxOutlineGeometry.js b/Source/Core/BoxOutlineGeometry.js index 63cf1515b625..6b1a5740aa95 100644 --- a/Source/Core/BoxOutlineGeometry.js +++ b/Source/Core/BoxOutlineGeometry.js @@ -113,14 +113,11 @@ define([ //>>includeEnd('debug'); var corner = Cartesian3.multiplyByScalar(dimensions, 0.5, new Cartesian3()); - var min = Cartesian3.negate(corner, new Cartesian3()); - var max = corner; - - var newOptions = { - minimum : min, - maximum : max - }; - return new BoxOutlineGeometry(newOptions); + + return new BoxOutlineGeometry({ + minimum : Cartesian3.negate(corner, new Cartesian3()), + maximum : corner + }); }; /** @@ -147,11 +144,11 @@ define([ if (!defined(boundingBox)) { throw new DeveloperError('boundingBox is required.'); } - var newOptions = { + + return new BoxOutlineGeometry({ minimum : boundingBox.minimum, maximum : boundingBox.maximum - }; - return new BoxOutlineGeometry(newOptions); + }); }; /** From b7b89aecb62337fdf9313e2346628a114503d094 Mon Sep 17 00:00:00 2001 From: Gabby Getz Date: Wed, 14 Oct 2015 12:32:17 -0400 Subject: [PATCH 18/20] Redo PolygonOutlineGeometry Fix --- Source/Core/PolygonOutlineGeometry.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Core/PolygonOutlineGeometry.js b/Source/Core/PolygonOutlineGeometry.js index 9a623f5d03db..2c5f40d134dd 100644 --- a/Source/Core/PolygonOutlineGeometry.js +++ b/Source/Core/PolygonOutlineGeometry.js @@ -276,9 +276,9 @@ define([ * -75.0, 30.0, * -70.0, 30.0, * -68.0, 40.0 - * ]), - * extrudedHeight: 300000 - * } + * ]) + * }, + * extrudedHeight: 300000 * }); * var geometry = Cesium.PolygonOutlineGeometry.createGeometry(extrudedPolygon); */ From 3c22be6bf38a9f4a9c811d43297e88946162b263 Mon Sep 17 00:00:00 2001 From: ggetz Date: Wed, 14 Oct 2015 14:10:32 -0400 Subject: [PATCH 19/20] fixed issue in unit test --- Specs/DataSources/BoxGeometryUpdaterSpec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Specs/DataSources/BoxGeometryUpdaterSpec.js b/Specs/DataSources/BoxGeometryUpdaterSpec.js index 386ca74e6b1a..9fbde34caf92 100644 --- a/Specs/DataSources/BoxGeometryUpdaterSpec.js +++ b/Specs/DataSources/BoxGeometryUpdaterSpec.js @@ -163,7 +163,7 @@ defineSuite([ if (options.fill) { instance = updater.createFillGeometryInstance(time); geometry = instance.geometry; - expect(geometry._maximumCorner).toEqual(Cartesian3.multiplyByScalar(options.dimensions, 0.5, new Cartesian3())); + expect(geometry._maximum).toEqual(Cartesian3.multiplyByScalar(options.dimensions, 0.5, new Cartesian3())); attributes = instance.attributes; if (options.material instanceof ColorMaterialProperty) { From 4e2c18889bf2bf9669acb0908204ec65b530e87c Mon Sep 17 00:00:00 2001 From: Gabby Getz Date: Wed, 14 Oct 2015 14:55:49 -0400 Subject: [PATCH 20/20] Corrected Spelling error --- CHANGES.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index f8347986298a..7a53b5e8c3db 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,8 +6,8 @@ Change Log * Breaking changes * Deleted old `/package.json` and `*.profile.js` files, not used since we moved away from a Dojo-based build years ago. This should allow future compatibility with newer systems like Browserify and Webpack. * Deprecated - * Depreciated `BoxGeometry.minimumCorner` and `BoxGeometry.maximumCorner`, use `BoxGeometry.minimum` and `BoxGeometry.maximum` instead. These will be removed in 1.17. - * Depreciated `BoxOutlineGeometry.minimumCorner` and `BoxOutlineGeometry.maximumCorner`, use `BoxOutlineGeometry.minimum` and `BoxOutlineGeometry.maximum` instead. These will be removed in 1.17. + * Deprecated `BoxGeometry.minimumCorner` and `BoxGeometry.maximumCorner`, use `BoxGeometry.minimum` and `BoxGeometry.maximum` instead. These will be removed in 1.17. + * Deprecated `BoxOutlineGeometry.minimumCorner` and `BoxOutlineGeometry.maximumCorner`, use `BoxOutlineGeometry.minimum` and `BoxOutlineGeometry.maximum` instead. These will be removed in 1.17. * Made `EllipsoidPrimitive` private, use `EllipsoidGeometry` or `Entity.ellipsoid` instead. * Deprecated `RectanglePrimitive`, use `RectangleGeometry` or `Entity.rectangle` instead. It will be removed in 1.17. * Deprecated `EllipsoidPrimitive`, use `EllipsoidGeometry` or `Entity.ellipsoid` instead. It will be removed in 1.17.