Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix rectangle rotate missing z value render by gl #2160

Merged
merged 2 commits into from
Dec 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);

});
});