diff --git a/Source/Core/RectangleOutlineGeometry.js b/Source/Core/RectangleOutlineGeometry.js index d36637df5b8b..58dcd8627845 100644 --- a/Source/Core/RectangleOutlineGeometry.js +++ b/Source/Core/RectangleOutlineGeometry.js @@ -201,7 +201,7 @@ define([ var ellipsoid = defaultValue(options.ellipsoid, Ellipsoid.WGS84); var surfaceHeight = defaultValue(options.height, 0.0); var rotation = defaultValue(options.rotation, 0.0); - var extrudedHeight = defaultValue(options.extrudedHeight, surfaceHeight); + var extrudedHeight = options.extrudedHeight; //>>includeStart('debug', pragmas.debug); if (!defined(rectangle)) { @@ -226,7 +226,7 @@ define([ * The number of elements used to pack the object into an array. * @type {Number} */ - RectangleOutlineGeometry.packedLength = Rectangle.packedLength + Ellipsoid.packedLength + 4; + RectangleOutlineGeometry.packedLength = Rectangle.packedLength + Ellipsoid.packedLength + 5; /** * Stores the provided instance into the provided array. @@ -257,7 +257,8 @@ define([ array[startingIndex++] = value._granularity; array[startingIndex++] = value._surfaceHeight; array[startingIndex++] = value._rotation; - array[startingIndex] = value._extrudedHeight; + array[startingIndex++] = defined(value._extrudedHeight) ? 1.0 : 0.0; + array[startingIndex] = defaultValue(value._extrudedHeight, 0.0); }; var scratchRectangle = new Rectangle(); @@ -296,13 +297,14 @@ define([ var granularity = array[startingIndex++]; var height = array[startingIndex++]; var rotation = array[startingIndex++]; + var hasExtrudedHeight = array[startingIndex++]; var extrudedHeight = array[startingIndex]; if (!defined(result)) { scratchOptions.granularity = granularity; scratchOptions.height = height; scratchOptions.rotation = rotation; - scratchOptions.extrudedHeight = extrudedHeight; + scratchOptions.extrudedHeight = hasExtrudedHeight ? extrudedHeight : undefined; return new RectangleOutlineGeometry(scratchOptions); } @@ -310,7 +312,7 @@ define([ result._ellipsoid = Ellipsoid.clone(ellipsoid, result._ellipsoid); result._surfaceHeight = height; result._rotation = rotation; - result._extrudedHeight = extrudedHeight; + result._extrudedHeight = hasExtrudedHeight ? extrudedHeight : undefined; return result; }; diff --git a/Specs/Core/RectangleOutlineGeometrySpec.js b/Specs/Core/RectangleOutlineGeometrySpec.js index 19366caf43ac..fc316ebc86da 100644 --- a/Specs/Core/RectangleOutlineGeometrySpec.js +++ b/Specs/Core/RectangleOutlineGeometrySpec.js @@ -152,11 +152,24 @@ defineSuite([ }); var rectangle = new RectangleOutlineGeometry({ - rectangle : new Rectangle(-2.0, -1.0, 0.0, 1.0), - granularity : 1.0, - ellipsoid : Ellipsoid.UNIT_SPHERE + rectangle : new Rectangle(0.1, 0.2, 0.3, 0.4), + ellipsoid : new Ellipsoid(5, 6, 7), + granularity : 8, + height : 9, + rotation : 10, + extrudedHeight : 11 }); - var packedInstance = [-2.0, -1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0]; - createPackableSpecs(RectangleOutlineGeometry, rectangle, packedInstance); + var packedInstance = [0.1, 0.2, 0.3, 0.4, 5, 6, 7, 8, 9, 10, 1, 11]; + createPackableSpecs(RectangleOutlineGeometry, rectangle, packedInstance, 'extruded'); + + rectangle = new RectangleOutlineGeometry({ + rectangle : new Rectangle(0.1, 0.2, 0.3, 0.4), + ellipsoid : new Ellipsoid(5, 6, 7), + granularity : 8, + height : 9, + rotation : 10 + }); + packedInstance = [0.1, 0.2, 0.3, 0.4, 5, 6, 7, 8, 9, 10, 0, 0]; + createPackableSpecs(RectangleOutlineGeometry, rectangle, packedInstance, 'at height'); });