diff --git a/CHANGES.md b/CHANGES.md index 29e7f72c11b6..d304617eacf7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -18,6 +18,7 @@ Change Log * Reduces size of approximateTerrainHeights.json by rounding the numbers [#7959](https://github.com/AnalyticalGraphicsInc/cesium/pull/7959) * Fixed undefined `quadDetails` error from zooming into the map really close. [#8011](https://github.com/AnalyticalGraphicsInc/cesium/pull/8011) * Fixed triangulation bug in polygons using `ArcType.RHUMB`. [#8042](https://github.com/AnalyticalGraphicsInc/cesium/issues/8042) +* Fixed a bug where extruded polygons would sometimes be missing segments. [#8035](https://github.com/AnalyticalGraphicsInc/cesium/pull/8035) ### 1.61 - 2019-09-03 diff --git a/Source/Core/PolygonGeometryLibrary.js b/Source/Core/PolygonGeometryLibrary.js index aac66f9cda90..fdfe649fd360 100644 --- a/Source/Core/PolygonGeometryLibrary.js +++ b/Source/Core/PolygonGeometryLibrary.js @@ -579,7 +579,9 @@ define([ } length = edgePositions.length; - var indices = IndexDatatype.createTypedArray(length / 3, length - positions.length * 6); + var vertexCount = length / 3; + var indices = IndexDatatype.createTypedArray(vertexCount, vertexCount * 3); // Assuming no vertices drop, each segment takes 6 indices and there are vertexCount / 2 walls + var edgeIndex = 0; length /= 6; @@ -603,6 +605,10 @@ define([ indices[edgeIndex++] = LR; } + if (edgeIndex !== indices.length) { + indices = indices.slice(0, edgeIndex); + } + return new Geometry({ attributes : new GeometryAttributes({ position : new GeometryAttribute({ diff --git a/Specs/Core/PolygonGeometrySpec.js b/Specs/Core/PolygonGeometrySpec.js index 52402873f7df..cb0ba4fb153b 100644 --- a/Specs/Core/PolygonGeometrySpec.js +++ b/Specs/Core/PolygonGeometrySpec.js @@ -622,6 +622,44 @@ describe('Core/PolygonGeometry', function() { expect(p.indices.length).toEqual(numTriangles * 3); }); + it('does not include indices for extruded walls that are too small', function() { + var positions = Cartesian3.fromDegreesArray([ + 7.757161063097392, 48.568676799636634, + 7.753968290229146, 48.571796467099077, + 7.755340073906587, 48.571948854067948, + 7.756263393414589, 48.571947951609708, + 7.756894446412183, 48.569396703043992 + ]); + + var pRhumb = PolygonGeometry.createGeometry(PolygonGeometry.fromPositions({ + vertexFormat : VertexFormat.POSITION_ONLY, + positions : positions, + extrudedHeight: 1000, + closeTop: false, + closeBottom: false, + arcType: ArcType.RHUMB + })); + + var numVertices = 20; + var numTriangles = 12; + expect(pRhumb.attributes.position.values.length).toEqual(numVertices * 3); + expect(pRhumb.indices.length).toEqual(numTriangles * 3); + + var pGeodesic = PolygonGeometry.createGeometry(PolygonGeometry.fromPositions({ + vertexFormat : VertexFormat.POSITION_ONLY, + positions : positions, + extrudedHeight: 1000, + closeTop: false, + closeBottom: false, + arcType: ArcType.GEODESIC + })); + + numVertices = 20; + numTriangles = 10; + expect(pGeodesic.attributes.position.values.length).toEqual(numVertices * 3); + expect(pGeodesic.indices.length).toEqual(numTriangles * 3); + }); + it('computes offset attribute', function() { var p = PolygonGeometry.createGeometry(PolygonGeometry.fromPositions({ vertexFormat : VertexFormat.POSITION_ONLY,