Skip to content

Commit

Permalink
fix rectangle rotate missing z value render by gl (#2160)
Browse files Browse the repository at this point in the history
* fix rectangle rotate missing z value render by gl

* spec
  • Loading branch information
deyihu authored Dec 25, 2023
1 parent 1933c86 commit 1456349
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/renderer/geometry/VectorRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,11 @@ function getRotatedShell() {
return [];
}
const projection = this._getProjection();
const coordinates = this.getCoordinates() || {};
return prjs.map(prj => {
return projection.unproject(prj);
const c = projection.unproject(prj);
c.z = coordinates.z || 0;
return c;
});
}

Expand Down
56 changes: 56 additions & 0 deletions test/geometry/PolygonSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -510,4 +510,60 @@ describe('Geometry.Polygon', function () {
}
load();
});

it('#2159 polygon sub geometries(Rectange/Ellipse/Sector) rotate missing z', function (done) {
layer.config('drawImmediate', true);
layer.clear();
map.config({ centerCross: true });
map.setCenter(center);
map.setZoom(17);

const symbol = {
polygonFill: '#fff',
lineWidth: 8
// polygonFill: '#fff'
};

const altitude = 100;
const center1 = center.copy();
center1.z = altitude;
const center2 = center.copy();
center2.z = altitude;
const center3 = center.copy();
center3.z = altitude;

const rectangle = new maptalks.Rectangle(center1, 200, 100, {
symbol
});
const ellipse = new maptalks.Ellipse(center2, 200, 100, {
symbol
});
const sector = new maptalks.Sector(center3, 100, 0, 90, {
symbol
});

const geos = [rectangle, ellipse, sector];
layer.addGeometry(geos);

setTimeout(() => {
geos.forEach(geo => {
const shell = geo.getShell();
const z = shell[0].z;
expect(z).to.be(altitude);
//rotate geometry
geo.rotate(Math.random() * 90);
})

setTimeout(() => {
geos.forEach(geo => {
const shell = geo.getShell();
const z = shell[0].z;
expect(z).to.be(altitude);
})
done();
}, 40);

}, 40);

});
});

0 comments on commit 1456349

Please sign in to comment.