Skip to content

Commit

Permalink
Merge pull request #11577 from CesiumGS/fix-polygon-holes
Browse files Browse the repository at this point in the history
Fixes an issue with polygon hole rendering
  • Loading branch information
jjhembd authored Nov 1, 2023
2 parents 397f0b6 + aa5049e commit aa90487
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/engine/Source/Core/PolygonGeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ function createGeometryFromPositionsExtruded(
}

let outerRing = hierarchy.outerRing;
let tangentPlane = EllipsoidTangentPlane.fromPoints(outerRing, ellipsoid);
const tangentPlane = EllipsoidTangentPlane.fromPoints(outerRing, ellipsoid);
let positions2D = tangentPlane.projectPointsOntoPlane(
outerRing,
createGeometryFromPositionsExtrudedPositions
Expand Down Expand Up @@ -664,8 +664,6 @@ function createGeometryFromPositionsExtruded(
const holes = hierarchy.holes;
for (i = 0; i < holes.length; i++) {
let hole = holes[i];

tangentPlane = EllipsoidTangentPlane.fromPoints(hole, ellipsoid);
positions2D = tangentPlane.projectPointsOntoPlane(
hole,
createGeometryFromPositionsExtrudedPositions
Expand Down Expand Up @@ -1331,7 +1329,7 @@ function getTangentPlane(rectangle, positions, ellipsoid) {
}

const scratchCartographicCyllindrical = new Cartographic();
function createProjectTo2d(rectangle, ellipsoid) {
function createProjectTo2d(rectangle, outerPositions, ellipsoid) {
return (positions, results) => {
// If the polygon positions span a large enough extent, use a specialized projection
if (rectangle.height >= CesiumMath.PI || rectangle.width >= CesiumMath.PI) {
Expand Down Expand Up @@ -1360,7 +1358,10 @@ function createProjectTo2d(rectangle, ellipsoid) {
}

// Use a local tangent plane for smaller extents
const tangentPlane = EllipsoidTangentPlane.fromPoints(positions, ellipsoid);
const tangentPlane = EllipsoidTangentPlane.fromPoints(
outerPositions,
ellipsoid
);
return tangentPlane.projectPointsOntoPlane(positions, results);
};
}
Expand Down Expand Up @@ -1466,7 +1467,7 @@ PolygonGeometry.createGeometry = function (polygonGeometry) {
const results = PolygonGeometryLibrary.polygonsFromHierarchy(
polygonHierarchy,
hasTextureCoordinates,
createProjectTo2d(rectangle, ellipsoid),
createProjectTo2d(rectangle, outerPositions, ellipsoid),
!perPositionHeight,
ellipsoid,
createSplitPolygons(rectangle, ellipsoid, arcType, perPositionHeight)
Expand Down

0 comments on commit aa90487

Please sign in to comment.