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: mapbox 线图层的贴图变形 #2474

Merged
merged 3 commits into from
May 16, 2024
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: 5 additions & 0 deletions .changeset/clean-beers-try.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@antv/l7-layers': patch
---

fix: mapbox 线图层的贴图变形
Binary file modified __tests__/integration/snapshots/Line_arc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified __tests__/integration/snapshots/Line_arc3D.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified __tests__/integration/snapshots/Line_normal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified __tests__/integration/snapshots/Line_simple.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified __tests__/integration/snapshots/Line_wall.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified __tests__/integration/snapshots/Mask_multi.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified __tests__/integration/snapshots/Mask_single.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified __tests__/integration/snapshots/Point_billboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified __tests__/integration/snapshots/Point_column.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified __tests__/integration/snapshots/Point_fill_image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified __tests__/integration/snapshots/Point_text.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified __tests__/integration/snapshots/Polygon_extrude.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified __tests__/integration/snapshots/Polygon_extrusion.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified __tests__/integration/snapshots/Polygon_fill.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion examples/demos/gallery/vari-flight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export function MapRender(options: RenderDemoOptions) {
id: 'map',
renderer: options.renderer,
map: new allMap[options.map]({
style: 'light',
style: 'dark',
center: [40, 40.16797],
zoom: 2.5,
}),
Expand Down
7 changes: 0 additions & 7 deletions packages/core/src/shaders/projection.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,6 @@ vec2 project_pixel_size_to_clipspace(vec2 pixels) {
return offset * u_FocalDistance;
}

float project_pixel_allmap(float pixel) {
if (u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT) {
return pixel * pow(2.0, u_Zoom);
}
return pixel * u_FocalDistance;
}

// 适配纹理贴图的等像素大小
float project_pixel_texture(float pixel) {
// mapbox zoom > 12
Expand Down
6 changes: 2 additions & 4 deletions packages/layers/src/line/shaders/arc/line_arc_vert.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,8 @@ void main() {

if(LineTexture == u_line_texture) { // 开启贴图模式
float arcDistrance = length(source - target); // 起始点和终点的距离
if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) { // mapbox
// arcDistrance *= 8.0;
arcDistrance = project_pixel_allmap(arcDistrance);
}
arcDistrance = project_pixel(arcDistrance);

v_iconMapUV = a_iconMapUV;

float pixelLen = project_pixel_texture(u_icon_step); // 贴图沿弧线方向的长度 - 随地图缩放改变
Expand Down
4 changes: 2 additions & 2 deletions packages/layers/src/line/shaders/flow/flow_line_vert.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void main() {
vec2 source_world = a_Instance.rg; // 起点
vec2 target_world = a_Instance.ba; // 终点
vec2 flowlineDir = line_dir(target_world, source_world);
vec2 perpendicularDir = vec2(-flowlineDir.y, flowlineDir.x); // mapbox || 高德
vec2 perpendicularDir = vec2(-flowlineDir.y, flowlineDir.x);

vec2 position = mix(source_world, target_world, a_Position.x);
vec2 position64Low = mix(a_Instance64Low.rg, a_Instance64Low.ba, a_Position.x);
Expand All @@ -56,7 +56,7 @@ void main() {
a_Position.x
);

vec2 normalsCommon = u_stroke_width * project_pixel_offset(vec2(a_Normal.x, a_Normal.y)); // mapbox || 高德
vec2 normalsCommon = u_stroke_width * project_pixel_offset(vec2(a_Normal.x, a_Normal.y));

float gapCommon = -1. * project_pixel(u_gap_width);
vec3 offsetCommon = vec3(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,8 @@ void main() {
v_line_data.g = a_Position.x; // 该顶点在弧线上的分段排序
if (LineTexture == u_line_texture) {
float d_arcDistrance = length(source - target);
if (
u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT ||
u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET
) {
// mapbox
d_arcDistrance = project_pixel_allmap(d_arcDistrance);
}
d_arcDistrance = project_pixel(d_arcDistrance);

float d_pixelLen = project_pixel(u_icon_step) / 8.0;
v_line_data.b = floor(d_arcDistrance / d_pixelLen); // 贴图在弧线上重复的数量

Expand Down
Loading