@antv/l7-layers 2.25.10 → 2.28.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/es/citybuilding/models/build.d.ts +3 -2
  2. package/es/core/BaseModel.js +32 -6
  3. package/es/core/CommonStyleAttribute.d.ts +2 -1
  4. package/es/core/CommonStyleAttribute.js +23 -1
  5. package/es/core/constant.js +4 -2
  6. package/es/core/interface.d.ts +1 -0
  7. package/es/earth/models/atmosphere.d.ts +3 -2
  8. package/es/earth/models/base.d.ts +3 -2
  9. package/es/earth/models/bloomsphere.d.ts +3 -2
  10. package/es/geometry/models/billboard.d.ts +3 -2
  11. package/es/geometry/models/plane.d.ts +3 -2
  12. package/es/heatmap/models/grid.d.ts +3 -2
  13. package/es/heatmap/models/grid3d.d.ts +3 -2
  14. package/es/heatmap/models/heatmap.d.ts +3 -2
  15. package/es/heatmap/models/hexagon.d.ts +3 -2
  16. package/es/image/models/image.d.ts +3 -2
  17. package/es/line/models/arc.d.ts +3 -2
  18. package/es/line/models/arc_3d.d.ts +3 -2
  19. package/es/line/models/flow.d.ts +3 -2
  20. package/es/line/models/great_circle.d.ts +3 -2
  21. package/es/line/models/line.d.ts +3 -2
  22. package/es/line/models/simple_line.d.ts +3 -2
  23. package/es/line/models/wall.d.ts +3 -2
  24. package/es/point/index.js +2 -2
  25. package/es/point/models/billboard_point.d.ts +3 -2
  26. package/es/point/models/earthExtrude.d.ts +3 -2
  27. package/es/point/models/earthFill.d.ts +3 -2
  28. package/es/point/models/extrude.d.ts +3 -2
  29. package/es/point/models/fill.d.ts +3 -2
  30. package/es/point/models/fillImage.d.ts +3 -2
  31. package/es/point/models/image.d.ts +3 -2
  32. package/es/point/models/normal.d.ts +3 -2
  33. package/es/point/models/radar.d.ts +3 -2
  34. package/es/point/models/text.d.ts +3 -2
  35. package/es/point/shaders/billboard/billboard_point_vert.glsl +33 -1
  36. package/es/point/shaders/earthFill/earthFill_vert.glsl +37 -3
  37. package/es/point/shaders/fill/fill_vert.glsl +38 -3
  38. package/es/point/shaders/fillImage/fillImage_vert.glsl +34 -1
  39. package/es/point/shaders/image/image_vert.glsl +31 -0
  40. package/es/point/shaders/normal/normal_vert.glsl +30 -0
  41. package/es/point/shaders/radar/radar_vert.glsl +34 -3
  42. package/es/polygon/models/extrude.d.ts +3 -2
  43. package/es/polygon/models/extrusion.d.ts +3 -2
  44. package/es/polygon/models/fill.d.ts +3 -2
  45. package/es/polygon/models/ocean.d.ts +3 -2
  46. package/es/polygon/models/water.d.ts +3 -2
  47. package/es/raster/models/raster.d.ts +3 -2
  48. package/es/raster/models/rasterRgb.d.ts +3 -2
  49. package/es/raster/models/rasterTerrainRgb.d.ts +3 -2
  50. package/es/tile/tile/Tile.d.ts +1 -1
  51. package/es/tile/tile/util.d.ts +1 -1
  52. package/es/utils/symbol-layout.d.ts +1 -1
  53. package/es/utils/symbol-layout.js +19 -9
  54. package/es/wind/models/wind.d.ts +3 -2
  55. package/lib/citybuilding/models/build.d.ts +3 -2
  56. package/lib/core/BaseModel.js +32 -6
  57. package/lib/core/CommonStyleAttribute.d.ts +2 -1
  58. package/lib/core/CommonStyleAttribute.js +23 -1
  59. package/lib/core/constant.js +4 -2
  60. package/lib/core/interface.d.ts +1 -0
  61. package/lib/earth/models/atmosphere.d.ts +3 -2
  62. package/lib/earth/models/base.d.ts +3 -2
  63. package/lib/earth/models/bloomsphere.d.ts +3 -2
  64. package/lib/geometry/models/billboard.d.ts +3 -2
  65. package/lib/geometry/models/plane.d.ts +3 -2
  66. package/lib/heatmap/models/grid.d.ts +3 -2
  67. package/lib/heatmap/models/grid3d.d.ts +3 -2
  68. package/lib/heatmap/models/heatmap.d.ts +3 -2
  69. package/lib/heatmap/models/hexagon.d.ts +3 -2
  70. package/lib/image/models/image.d.ts +3 -2
  71. package/lib/line/models/arc.d.ts +3 -2
  72. package/lib/line/models/arc_3d.d.ts +3 -2
  73. package/lib/line/models/flow.d.ts +3 -2
  74. package/lib/line/models/great_circle.d.ts +3 -2
  75. package/lib/line/models/line.d.ts +3 -2
  76. package/lib/line/models/simple_line.d.ts +3 -2
  77. package/lib/line/models/wall.d.ts +3 -2
  78. package/lib/point/index.js +2 -2
  79. package/lib/point/models/billboard_point.d.ts +3 -2
  80. package/lib/point/models/earthExtrude.d.ts +3 -2
  81. package/lib/point/models/earthFill.d.ts +3 -2
  82. package/lib/point/models/extrude.d.ts +3 -2
  83. package/lib/point/models/fill.d.ts +3 -2
  84. package/lib/point/models/fillImage.d.ts +3 -2
  85. package/lib/point/models/image.d.ts +3 -2
  86. package/lib/point/models/normal.d.ts +3 -2
  87. package/lib/point/models/radar.d.ts +3 -2
  88. package/lib/point/models/text.d.ts +3 -2
  89. package/lib/point/shaders/billboard/billboard_point_vert.glsl +33 -1
  90. package/lib/point/shaders/earthFill/earthFill_vert.glsl +37 -3
  91. package/lib/point/shaders/fill/fill_vert.glsl +38 -3
  92. package/lib/point/shaders/fillImage/fillImage_vert.glsl +34 -1
  93. package/lib/point/shaders/image/image_vert.glsl +31 -0
  94. package/lib/point/shaders/normal/normal_vert.glsl +30 -0
  95. package/lib/point/shaders/radar/radar_vert.glsl +34 -3
  96. package/lib/polygon/models/extrude.d.ts +3 -2
  97. package/lib/polygon/models/extrusion.d.ts +3 -2
  98. package/lib/polygon/models/fill.d.ts +3 -2
  99. package/lib/polygon/models/ocean.d.ts +3 -2
  100. package/lib/polygon/models/water.d.ts +3 -2
  101. package/lib/raster/models/raster.d.ts +3 -2
  102. package/lib/raster/models/rasterRgb.d.ts +3 -2
  103. package/lib/raster/models/rasterTerrainRgb.d.ts +3 -2
  104. package/lib/tile/tile/Tile.d.ts +1 -1
  105. package/lib/tile/tile/util.d.ts +1 -1
  106. package/lib/utils/symbol-layout.d.ts +1 -1
  107. package/lib/utils/symbol-layout.js +19 -9
  108. package/lib/wind/models/wind.d.ts +3 -2
  109. package/package.json +6 -6
@@ -17,6 +17,35 @@ out float v_radius;
17
17
  #pragma include "projection"
18
18
  #pragma include "picking"
19
19
 
20
+ // 根据 anchor 值计算 extrude 偏移
21
+ // anchor: 0=center, 1=top, 2=top-right, 3=right, 4=bottom-right, 5=bottom, 6=bottom-left, 7=left, 8=top-left, 9=bottom-center
22
+ vec2 applyAnchor(vec2 extrude, float anchor) {
23
+ if (anchor < 0.5) {
24
+ return extrude;
25
+ }
26
+
27
+ vec2 offset = vec2(0.0);
28
+
29
+ // horizontal alignment: 左边缘对准坐标 -> 向右移; 右边缘对准坐标 -> 向左移
30
+ if (anchor == 2.0 || anchor == 3.0 || anchor == 4.0) {
31
+ // top-right, right, bottom-right -> shift left
32
+ offset.x = -1.0;
33
+ } else if (anchor == 6.0 || anchor == 7.0 || anchor == 8.0) {
34
+ // bottom-left, left, top-left -> shift right
35
+ offset.x = 1.0;
36
+ }
37
+
38
+ // vertical alignment: 上边缘对准坐标 -> 向下移(图形在坐标下方); 下边缘对准坐标 -> 向上移(图形在坐标上方)
39
+ if (anchor == 1.0 || anchor == 2.0 || anchor == 8.0) {
40
+ // top, top-right, top-left -> shift down
41
+ offset.y = -1.0;
42
+ } else if (anchor == 4.0 || anchor == 5.0 || anchor == 6.0 || anchor == 9.0) {
43
+ // bottom-right, bottom, bottom-left, bottom-center -> shift up
44
+ offset.y = 1.0;
45
+ }
46
+
47
+ return extrude + offset;
48
+ }
20
49
 
21
50
  void main() {
22
51
  vec3 extrude = a_Extrude;
@@ -37,10 +66,15 @@ void main() {
37
66
  // float antialiased_blur = -max(u_blur, antialiasblur);
38
67
  float antialiasblur = -max(2.0 / u_DevicePixelRatio / newSize, u_blur);
39
68
 
40
- // TODP: /abs(extrude.x) 是为了兼容地球模式
41
- v_data = vec4(extrude.x/abs(extrude.x), extrude.y/abs(extrude.y), antialiasblur,shape_type);
69
+ // apply anchor to extrude direction
70
+ vec2 anchoredExtrude = applyAnchor(extrude.xy, anchor);
71
+
72
+ // TODP: sign() 是为了兼容地球模式,同时避免 anchor 偏移后为 0 时除以零产生 NaN
73
+ // 注意:v_data 必须使用原始 extrude 而非 anchoredExtrude,因为 SDF 形状计算需要基于原始形状坐标系
74
+ // anchoredExtrude 只用于位置偏移,不改变形状本身的 SDF 采样
75
+ v_data = vec4(sign(extrude.x), sign(extrude.y), antialiasblur,shape_type);
42
76
 
43
- gl_Position = u_ViewProjectionMatrix * vec4(a_Position + extrude * newSize * 0.1 + vec3(u_offsets,0.0), 1.0);
77
+ gl_Position = u_ViewProjectionMatrix * vec4(a_Position + anchoredExtrude * newSize * 0.1 + vec3(offsets,0.0), 1.0);
44
78
 
45
79
  setPickingColor(a_PickingColor);
46
80
  }
@@ -24,6 +24,36 @@ out float v_radius;
24
24
  #pragma include "picking"
25
25
  #pragma include "rotation_2d"
26
26
 
27
+ // 根据 anchor 值计算 extrude 偏移
28
+ // anchor: 0=center, 1=top, 2=top-right, 3=right, 4=bottom-right, 5=bottom, 6=bottom-left, 7=left, 8=top-left, 9=bottom-center
29
+ vec2 applyAnchor(vec2 extrude, float anchor) {
30
+ if (anchor < 0.5) {
31
+ return extrude;
32
+ }
33
+
34
+ vec2 offset = vec2(0.0);
35
+
36
+ // horizontal alignment: 左边缘对准坐标 -> 向右移; 右边缘对准坐标 -> 向左移
37
+ if (anchor == 2.0 || anchor == 3.0 || anchor == 4.0) {
38
+ // top-right, right, bottom-right -> shift left
39
+ offset.x = -1.0;
40
+ } else if (anchor == 6.0 || anchor == 7.0 || anchor == 8.0) {
41
+ // bottom-left, left, top-left -> shift right
42
+ offset.x = 1.0;
43
+ }
44
+
45
+ // vertical alignment: 上边缘对准坐标 -> 向下移(图形在坐标下方); 下边缘对准坐标 -> 向上移(图形在坐标上方)
46
+ if (anchor == 1.0 || anchor == 2.0 || anchor == 8.0) {
47
+ // top, top-right, top-left -> shift down
48
+ offset.y = -1.0;
49
+ } else if (anchor == 4.0 || anchor == 5.0 || anchor == 6.0 || anchor == 9.0) {
50
+ // bottom-right, bottom, bottom-left, bottom-center -> shift up
51
+ offset.y = 1.0;
52
+ }
53
+
54
+ return extrude + offset;
55
+ }
56
+
27
57
  void main() {
28
58
  // 透明度计算
29
59
  v_stroke = stroke;
@@ -51,13 +81,18 @@ void main() {
51
81
  // float antialiased_blur = -max(u_blur, antialiasblur);
52
82
  float antialiasblur = -max(2.0 / u_DevicePixelRatio / newSize, u_blur_height_fixed.x);
53
83
 
54
- vec2 offset = (extrude.xy * (newSize + u_stroke_width) + u_offsets);
84
+ // apply anchor to extrude direction
85
+ vec2 anchoredExtrude = applyAnchor(extrude.xy, anchor);
86
+
87
+ vec2 offset = (anchoredExtrude * (newSize + u_stroke_width) + offsets);
55
88
 
56
89
  offset = project_pixel(offset);
57
90
  offset = rotate_matrix(offset,rotation);
58
91
 
59
- // TODP: /abs(extrude.x) 是为了兼容地球模式
60
- v_data = vec4(extrude.x/abs(extrude.x), extrude.y/abs(extrude.y), antialiasblur,shape_type);
92
+ // TODP: sign() 是为了兼容地球模式,同时避免 anchor 偏移后为 0 时除以零产生 NaN
93
+ // 注意:v_data 必须使用原始 extrude 而非 anchoredExtrude,因为 SDF 形状计算需要基于原始形状坐标系
94
+ // anchoredExtrude 只用于位置偏移,不改变形状本身的 SDF 采样
95
+ v_data = vec4(sign(extrude.x), sign(extrude.y), antialiasblur,shape_type);
61
96
 
62
97
  vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0), a_Position64Low);
63
98
  // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, project_pixel(setPickingOrder(0.0)), 1.0));
@@ -20,6 +20,36 @@ out float v_opacity;
20
20
  #pragma include "picking"
21
21
  #pragma include "rotation_2d"
22
22
 
23
+ // 根据 anchor 值计算 extrude 偏移
24
+ // anchor: 0=center, 1=top, 2=top-right, 3=right, 4=bottom-right, 5=bottom, 6=bottom-left, 7=left, 8=top-left, 9=bottom-center
25
+ vec2 applyAnchor(vec2 extrude, float anchor) {
26
+ if (anchor < 0.5) {
27
+ return extrude;
28
+ }
29
+
30
+ vec2 offset = vec2(0.0);
31
+
32
+ // horizontal alignment: 左边缘对准坐标 -> 向右移; 右边缘对准坐标 -> 向左移
33
+ if (anchor == 2.0 || anchor == 3.0 || anchor == 4.0) {
34
+ // top-right, right, bottom-right -> shift left
35
+ offset.x = -1.0;
36
+ } else if (anchor == 6.0 || anchor == 7.0 || anchor == 8.0) {
37
+ // bottom-left, left, top-left -> shift right
38
+ offset.x = 1.0;
39
+ }
40
+
41
+ // vertical alignment: 上边缘对准坐标 -> 向下移(图形在坐标下方); 下边缘对准坐标 -> 向上移(图形在坐标上方)
42
+ if (anchor == 1.0 || anchor == 2.0 || anchor == 8.0) {
43
+ // top, top-right, top-left -> shift down
44
+ offset.y = -1.0;
45
+ } else if (anchor == 4.0 || anchor == 5.0 || anchor == 6.0 || anchor == 9.0) {
46
+ // bottom-right, bottom, bottom-left, bottom-center -> shift up
47
+ offset.y = 1.0;
48
+ }
49
+
50
+ return extrude + offset;
51
+ }
52
+
23
53
  void main() {
24
54
  vec3 extrude = a_Extrude;
25
55
  v_uv = (a_Extrude.xy + 1.0) / 2.0;
@@ -32,8 +62,11 @@ void main() {
32
62
  newSize = newSize * u_PixelsPerMeter.z;
33
63
  }
34
64
 
65
+ // apply anchor to extrude direction
66
+ vec2 anchoredExtrude = applyAnchor(extrude.xy, anchor);
67
+
35
68
  // vec2 offset = (u_RotateMatrix * extrude.xy * (a_Size) + textrueOffsets);
36
- vec2 offset = extrude.xy * newSize + offsets;
69
+ vec2 offset = anchoredExtrude.xy * newSize + offsets;
37
70
 
38
71
  offset = rotate_matrix(offset, rotation);
39
72
 
@@ -17,6 +17,32 @@ out float v_opacity;
17
17
  #pragma include "projection"
18
18
  #pragma include "picking"
19
19
 
20
+ // 根据 anchor 值计算点精灵的像素偏移
21
+ // anchor: 0=center, 1=top, 2=top-right, 3=right, 4=bottom-right, 5=bottom, 6=bottom-left, 7=left, 8=top-left, 9=bottom-center
22
+ vec2 applyAnchorPoint(float anchor, float pointSize) {
23
+ if (anchor < 0.5) {
24
+ return vec2(0.0);
25
+ }
26
+
27
+ vec2 offset = vec2(0.0);
28
+
29
+ // horizontal alignment: 左边缘对准坐标 -> 向右移; 右边缘对准坐标 -> 向左移
30
+ if (anchor == 2.0 || anchor == 3.0 || anchor == 4.0) {
31
+ offset.x = -pointSize * 0.5;
32
+ } else if (anchor == 6.0 || anchor == 7.0 || anchor == 8.0) {
33
+ offset.x = pointSize * 0.5;
34
+ }
35
+
36
+ // vertical alignment: 上边缘对准坐标 -> 向下移(图形在坐标下方); 下边缘对准坐标 -> 向上移(图形在坐标上方)
37
+ if (anchor == 1.0 || anchor == 2.0 || anchor == 8.0) {
38
+ offset.y = -pointSize * 0.5;
39
+ } else if (anchor == 4.0 || anchor == 5.0 || anchor == 6.0 || anchor == 9.0) {
40
+ offset.y = pointSize * 0.5;
41
+ }
42
+
43
+ return offset;
44
+ }
45
+
20
46
  void main() {
21
47
  // cal style mapping - 数据纹理映射部分的计算
22
48
  v_color = a_Color;
@@ -43,5 +69,10 @@ void main() {
43
69
  gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, raisingHeight, 1.0));
44
70
 
45
71
  gl_PointSize = a_Size * 2.0 * u_DevicePixelRatio;
72
+
73
+ // apply anchor offset in screen space
74
+ vec2 anchorOffset = applyAnchorPoint(anchor, gl_PointSize);
75
+ gl_Position.xy += anchorOffset / u_ViewportSize * 2.0 * gl_Position.w;
76
+
46
77
  setPickingColor(a_PickingColor);
47
78
  }
@@ -12,6 +12,32 @@ out vec4 v_color;
12
12
  #pragma include "projection"
13
13
  #pragma include "project"
14
14
 
15
+ // 根据 anchor 值计算点精灵的像素偏移
16
+ // anchor: 0=center, 1=top, 2=top-right, 3=right, 4=bottom-right, 5=bottom, 6=bottom-left, 7=left, 8=top-left, 9=bottom-center
17
+ vec2 applyAnchorPoint(float anchor, float pointSize) {
18
+ if (anchor < 0.5) {
19
+ return vec2(0.0);
20
+ }
21
+
22
+ vec2 offset = vec2(0.0);
23
+
24
+ // horizontal alignment: 左边缘对准坐标 -> 向右移; 右边缘对准坐标 -> 向左移
25
+ if (anchor == 2.0 || anchor == 3.0 || anchor == 4.0) {
26
+ offset.x = -pointSize * 0.5;
27
+ } else if (anchor == 6.0 || anchor == 7.0 || anchor == 8.0) {
28
+ offset.x = pointSize * 0.5;
29
+ }
30
+
31
+ // vertical alignment: 上边缘对准坐标 -> 向下移(图形在坐标下方); 下边缘对准坐标 -> 向上移(图形在坐标上方)
32
+ if (anchor == 1.0 || anchor == 2.0 || anchor == 8.0) {
33
+ offset.y = -pointSize * 0.5;
34
+ } else if (anchor == 4.0 || anchor == 5.0 || anchor == 6.0 || anchor == 9.0) {
35
+ offset.y = pointSize * 0.5;
36
+ }
37
+
38
+ return offset;
39
+ }
40
+
15
41
  void main() {
16
42
  v_color = vec4(a_Color.xyz, a_Color.w * opacity);
17
43
 
@@ -19,4 +45,8 @@ void main() {
19
45
  gl_Position = project_common_position_to_clipspace(project_pos);
20
46
 
21
47
  gl_PointSize = a_Size * u_size_scale * 2.0 * u_DevicePixelRatio;
48
+
49
+ // apply anchor offset in screen space
50
+ vec2 anchorOffset = applyAnchorPoint(anchor, gl_PointSize);
51
+ gl_Position.xy += anchorOffset / u_ViewportSize * 2.0 * gl_Position.w;
22
52
  }
@@ -19,6 +19,34 @@ out vec2 v_extrude;
19
19
  #pragma include "projection"
20
20
  #pragma include "picking"
21
21
 
22
+ // 根据 anchor 值计算 extrude 偏移
23
+ // anchor: 0=center, 1=top, 2=top-right, 3=right, 4=bottom-right, 5=bottom, 6=bottom-left, 7=left, 8=top-left, 9=bottom-center
24
+ vec2 applyAnchor(vec2 extrude, float anchor) {
25
+ if (anchor < 0.5) {
26
+ return extrude;
27
+ }
28
+
29
+ vec2 offset = vec2(0.0);
30
+
31
+ // horizontal alignment: 左边缘对准坐标 -> 向右移; 右边缘对准坐标 -> 向左移
32
+ if (anchor == 2.0 || anchor == 3.0 || anchor == 4.0) {
33
+ offset.x = -1.0;
34
+ } else if (anchor == 6.0 || anchor == 7.0 || anchor == 8.0) {
35
+ offset.x = 1.0;
36
+ }
37
+
38
+ // vertical alignment: 上边缘对准坐标 -> 向下移(图形在坐标下方); 下边缘对准坐标 -> 向上移(图形在坐标上方)
39
+ if (anchor == 1.0 || anchor == 2.0 || anchor == 8.0) {
40
+ // top, top-right, top-left -> shift down
41
+ offset.y = -1.0;
42
+ } else if (anchor == 4.0 || anchor == 5.0 || anchor == 6.0 || anchor == 9.0) {
43
+ // bottom-right, bottom, bottom-left, bottom-center -> shift up
44
+ offset.y = 1.0;
45
+ }
46
+
47
+ return extrude + offset;
48
+ }
49
+
22
50
  void main() {
23
51
  float newSize = setPickingSize(a_Size);
24
52
 
@@ -27,7 +55,10 @@ void main() {
27
55
  cos(time), sin(time),
28
56
  -sin(time), cos(time)
29
57
  );
30
- v_extrude = rotateMatrix * a_Extrude.xy;
58
+
59
+ // apply anchor to extrude direction before rotation
60
+ vec2 anchoredExtrude = applyAnchor(a_Extrude.xy, anchor);
61
+ v_extrude = rotateMatrix * anchoredExtrude;
31
62
 
32
63
  v_color = a_Color;
33
64
  v_color.a *= opacity;
@@ -40,11 +71,11 @@ void main() {
40
71
  }
41
72
  v_radius = newSize;
42
73
 
43
- vec2 offset = (a_Extrude.xy * (newSize));
74
+ vec2 offset = (anchoredExtrude * (newSize));
44
75
 
45
76
  offset = project_pixel(offset);
46
77
 
47
- v_data = vec4(a_Extrude.x, a_Extrude.y, antialiasblur, -1.0);
78
+ v_data = vec4(anchoredExtrude.x, anchoredExtrude.y, antialiasblur, -1.0);
48
79
 
49
80
  vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0), a_Position64Low);
50
81
  gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, project_pixel(setPickingOrder(0.0)), 1.0));
@@ -10,9 +10,10 @@ export default class ExtrudeModel extends BaseModel {
10
10
  readonly OPACITY: 5;
11
11
  readonly OFFSETS: 6;
12
12
  readonly ROTATION: 7;
13
- readonly MAX: 8;
13
+ readonly ANCHOR: 8;
14
+ readonly MAX: 9;
14
15
  } & Record<string, number> & {
15
- MAX: 8;
16
+ MAX: 9;
16
17
  SIZE: number;
17
18
  NORMAL: number;
18
19
  UV: number;
@@ -10,9 +10,10 @@ export default class ExtrusionModel extends BaseModel {
10
10
  readonly OPACITY: 5;
11
11
  readonly OFFSETS: 6;
12
12
  readonly ROTATION: 7;
13
- readonly MAX: 8;
13
+ readonly ANCHOR: 8;
14
+ readonly MAX: 9;
14
15
  } & Record<string, number> & {
15
- MAX: 8;
16
+ MAX: 9;
16
17
  SIZE: number;
17
18
  NORMAL: number;
18
19
  EXTRUSION_BASE: number;
@@ -10,9 +10,10 @@ export default class FillModel extends BaseModel {
10
10
  readonly OPACITY: 5;
11
11
  readonly OFFSETS: 6;
12
12
  readonly ROTATION: 7;
13
- readonly MAX: 8;
13
+ readonly ANCHOR: 8;
14
+ readonly MAX: 9;
14
15
  } & Record<string, number> & {
15
- MAX: 8;
16
+ MAX: 9;
16
17
  LINEAR: number;
17
18
  };
18
19
  getUninforms(): {
@@ -10,9 +10,10 @@ export default class OceanModel extends BaseModel {
10
10
  readonly OPACITY: 5;
11
11
  readonly OFFSETS: 6;
12
12
  readonly ROTATION: 7;
13
- readonly MAX: 8;
13
+ readonly ANCHOR: 8;
14
+ readonly MAX: 9;
14
15
  } & Record<string, number> & {
15
- MAX: 8;
16
+ MAX: 9;
16
17
  UV: number;
17
18
  };
18
19
  private texture1;
@@ -10,9 +10,10 @@ export default class WaterModel extends BaseModel {
10
10
  readonly OPACITY: 5;
11
11
  readonly OFFSETS: 6;
12
12
  readonly ROTATION: 7;
13
- readonly MAX: 8;
13
+ readonly ANCHOR: 8;
14
+ readonly MAX: 9;
14
15
  } & Record<string, number> & {
15
- MAX: 8;
16
+ MAX: 9;
16
17
  UV: number;
17
18
  };
18
19
  private texture;
@@ -10,9 +10,10 @@ export default class RasterModel extends BaseModel {
10
10
  readonly OPACITY: 5;
11
11
  readonly OFFSETS: 6;
12
12
  readonly ROTATION: 7;
13
- readonly MAX: 8;
13
+ readonly ANCHOR: 8;
14
+ readonly MAX: 9;
14
15
  } & Record<string, number> & {
15
- MAX: 8;
16
+ MAX: 9;
16
17
  UV: number;
17
18
  };
18
19
  protected texture: ITexture2D;
@@ -10,9 +10,10 @@ export default class RasterModel extends BaseModel {
10
10
  readonly OPACITY: 5;
11
11
  readonly OFFSETS: 6;
12
12
  readonly ROTATION: 7;
13
- readonly MAX: 8;
13
+ readonly ANCHOR: 8;
14
+ readonly MAX: 9;
14
15
  } & Record<string, number> & {
15
- MAX: 8;
16
+ MAX: 9;
16
17
  UV: number;
17
18
  };
18
19
  protected texture: ITexture2D;
@@ -10,9 +10,10 @@ export default class RasterTerrainRGB extends BaseModel {
10
10
  readonly OPACITY: 5;
11
11
  readonly OFFSETS: 6;
12
12
  readonly ROTATION: 7;
13
- readonly MAX: 8;
13
+ readonly ANCHOR: 8;
14
+ readonly MAX: 9;
14
15
  } & Record<string, number> & {
15
- MAX: 8;
16
+ MAX: 9;
16
17
  UV: number;
17
18
  };
18
19
  protected texture: ITexture2D;
@@ -85,7 +85,7 @@ export default abstract class Tile extends EventEmitter implements ITile {
85
85
  pickBufferScale?: number | undefined;
86
86
  stencil?: boolean | undefined;
87
87
  debug?: boolean | undefined;
88
- renderer?: "regl" | "device" | undefined;
88
+ renderer?: "device" | "regl" | undefined;
89
89
  antialias?: boolean | undefined;
90
90
  preserveDrawingBuffer?: boolean | undefined;
91
91
  enableWebGPU?: boolean | undefined;
@@ -1,5 +1,5 @@
1
1
  import LineLayer from '../../line';
2
2
  import PointLayer from '../../point/index';
3
3
  import PolygonLayer from '../../polygon';
4
- export declare function getTileLayer(type: string): typeof PolygonLayer | typeof LineLayer | typeof PointLayer;
4
+ export declare function getTileLayer(type: string): typeof PointLayer | typeof PolygonLayer | typeof LineLayer;
5
5
  export declare function isNeedMask(type: string): boolean;
@@ -2,7 +2,7 @@ interface IPoint {
2
2
  x: number;
3
3
  y: number;
4
4
  }
5
- export type anchorType = 'right' | 'top-right' | 'left' | 'bottom-right' | 'left' | 'top-left' | 'bottom-left' | 'bottom' | 'bottom-right' | 'bottom-left' | 'top' | 'top-right' | 'top-left' | 'center';
5
+ export type anchorType = 'center' | 'top' | 'top-right' | 'right' | 'bottom-right' | 'bottom' | 'bottom-left' | 'left' | 'top-left' | 'bottom-center';
6
6
  export interface IGlyphQuad {
7
7
  tr: IPoint;
8
8
  tl: IPoint;
@@ -21,14 +21,15 @@ function getAnchorAlignment(anchor) {
21
21
  horizontalAlign = 0.5;
22
22
  }
23
23
  switch (anchor) {
24
- case 'bottom':
25
- case 'bottom-right':
26
- case 'bottom-left':
27
- verticalAlign = 1;
28
- break;
29
24
  case 'top':
30
25
  case 'top-right':
31
26
  case 'top-left':
27
+ verticalAlign = 1;
28
+ break;
29
+ case 'bottom':
30
+ case 'bottom-right':
31
+ case 'bottom-left':
32
+ case 'bottom-center':
32
33
  verticalAlign = 0;
33
34
  break;
34
35
  default:
@@ -59,9 +60,18 @@ function justifyLine(positionedGlyphs, glyphMap, start, end, justify) {
59
60
  // justify right=1 left=0 center=0.5
60
61
  // horizontalAlign right=1 left=0 center=0.5
61
62
  // verticalAlign right=1 left=0 center=0.5
62
- function align(positionedGlyphs, justify, horizontalAlign, verticalAlign, maxLineLength, lineHeight, lineCount) {
63
+ function align(positionedGlyphs, justify, horizontalAlign, verticalAlign, maxLineLength, lineHeight, lineCount, yOffset) {
63
64
  const shiftX = (justify - horizontalAlign) * maxLineLength;
64
- const shiftY = (-verticalAlign * lineCount + 0.5) * lineHeight;
65
+ let shiftY = (-verticalAlign * lineCount + 0.5) * lineHeight;
66
+
67
+ // 补偿 yOffset 使 top/bottom 锚点正确对齐
68
+ // top: 文字往下移 |yOffset| 像素(远离坐标点)
69
+ // bottom: 文字往上移 |yOffset| 像素(远离坐标点)
70
+ if (verticalAlign === 1) {
71
+ shiftY += yOffset;
72
+ } else if (verticalAlign === 0) {
73
+ shiftY -= yOffset;
74
+ }
65
75
  for (const glyphs of positionedGlyphs) {
66
76
  glyphs.x += shiftX;
67
77
  glyphs.y += shiftY;
@@ -107,7 +117,7 @@ function shapeLines(shaping, glyphMap, lines, lineHeight, textAnchor, textJustif
107
117
  horizontalAlign,
108
118
  verticalAlign
109
119
  } = getAnchorAlignment(textAnchor);
110
- align(positionedGlyphs, justify, horizontalAlign, verticalAlign, maxLineLength, lineHeight, lines.length);
120
+ align(positionedGlyphs, justify, horizontalAlign, verticalAlign, maxLineLength, lineHeight, lines.length, yOffset);
111
121
 
112
122
  // 计算包围盒
113
123
  const height = y - yOffset;
@@ -160,7 +170,7 @@ function shapeIconFont(shaping, glyphMap, iconfonts, lineHeight, textAnchor, tex
160
170
  horizontalAlign,
161
171
  verticalAlign
162
172
  } = getAnchorAlignment(textAnchor);
163
- align(positionedGlyphs, justify, horizontalAlign, verticalAlign, maxLineLength, lineHeight, iconfonts.length);
173
+ align(positionedGlyphs, justify, horizontalAlign, verticalAlign, maxLineLength, lineHeight, iconfonts.length, yOffset);
164
174
 
165
175
  // 计算包围盒
166
176
  const height = y - yOffset;
@@ -10,9 +10,10 @@ export default class WindModel extends BaseModel {
10
10
  readonly OPACITY: 5;
11
11
  readonly OFFSETS: 6;
12
12
  readonly ROTATION: 7;
13
- readonly MAX: 8;
13
+ readonly ANCHOR: 8;
14
+ readonly MAX: 9;
14
15
  } & Record<string, number> & {
15
- MAX: 8;
16
+ MAX: 9;
16
17
  UV: number;
17
18
  };
18
19
  protected texture: ITexture2D;
@@ -10,9 +10,10 @@ export default class CityBuildModel extends BaseModel {
10
10
  readonly OPACITY: 5;
11
11
  readonly OFFSETS: 6;
12
12
  readonly ROTATION: 7;
13
- readonly MAX: 8;
13
+ readonly ANCHOR: 8;
14
+ readonly MAX: 9;
14
15
  } & Record<string, number> & {
15
- MAX: 8;
16
+ MAX: 9;
16
17
  SIZE: number;
17
18
  NORMAL: number;
18
19
  UV: number;
@@ -15,10 +15,37 @@ var _stencil = require("../utils/stencil");
15
15
  var _CommonStyleAttribute = require("./CommonStyleAttribute");
16
16
  var _constant = require("./constant");
17
17
  var _utils = require("./utils");
18
+ function anchorToNumber(anchor) {
19
+ if (typeof anchor === 'number') {
20
+ return anchor;
21
+ }
22
+ switch (anchor) {
23
+ case 'center':
24
+ return 0;
25
+ case 'top':
26
+ return 1;
27
+ case 'top-right':
28
+ return 2;
29
+ case 'right':
30
+ return 3;
31
+ case 'bottom-right':
32
+ return 4;
33
+ case 'bottom':
34
+ return 5;
35
+ case 'bottom-left':
36
+ return 6;
37
+ case 'left':
38
+ return 7;
39
+ case 'top-left':
40
+ return 8;
41
+ case 'bottom-center':
42
+ return 9;
43
+ default:
44
+ return 0;
45
+ }
46
+ }
18
47
  // 属性索引宏定义前缀,使用命名空间避免 define 名称重复情况
19
48
  const DEFINE_ATTRIBUTE_LOCATION_PREFIX = 'ATTRIBUTE_LOCATION_';
20
-
21
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
22
49
  class BaseModel {
23
50
  /**
24
51
  * Attribute Layout Location in Shader
@@ -149,19 +176,16 @@ class BaseModel {
149
176
  return false;
150
177
  })();
151
178
  }
152
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
153
179
  buildModels() {
154
180
  return (0, _asyncToGenerator2.default)(function* () {
155
181
  throw new Error('Method not implemented.');
156
182
  })();
157
183
  }
158
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
159
184
  initModels() {
160
185
  return (0, _asyncToGenerator2.default)(function* () {
161
186
  throw new Error('Method not implemented.');
162
187
  })();
163
188
  }
164
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
165
189
  clearModels(refresh = true) {
166
190
  return;
167
191
  }
@@ -169,7 +193,6 @@ class BaseModel {
169
193
  throw new Error('Method not implemented.');
170
194
  }
171
195
  prerender() {}
172
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
173
196
  render(renderOptions) {
174
197
  throw new Error('Method not implemented.');
175
198
  }
@@ -214,6 +237,9 @@ class BaseModel {
214
237
  if (key === 'stroke') {
215
238
  value = (0, _l7Utils.rgb2arr)(value);
216
239
  }
240
+ if (key === 'anchor') {
241
+ value = anchorToNumber(value);
242
+ }
217
243
  options['u_' + key] = value;
218
244
  }
219
245
  });
@@ -11,6 +11,7 @@ export declare const COMMON_ATTRIBUTE_LOCATION: {
11
11
  readonly OPACITY: 5;
12
12
  readonly OFFSETS: 6;
13
13
  readonly ROTATION: 7;
14
- readonly MAX: 8;
14
+ readonly ANCHOR: 8;
15
+ readonly MAX: 9;
15
16
  };
16
17
  export declare function getCommonStyleAttributeOptions(name: string): Partial<IStyleAttribute> | undefined;
@@ -21,8 +21,9 @@ const COMMON_ATTRIBUTE_LOCATION = exports.COMMON_ATTRIBUTE_LOCATION = {
21
21
  OPACITY: 5,
22
22
  OFFSETS: 6,
23
23
  ROTATION: 7,
24
+ ANCHOR: 8,
24
25
  // last index
25
- MAX: 8
26
+ MAX: 9
26
27
  };
27
28
  function getCommonStyleAttributeOptions(name) {
28
29
  switch (name) {
@@ -114,6 +115,27 @@ function getCommonStyleAttributeOptions(name) {
114
115
  }
115
116
  }
116
117
  };
118
+ case 'anchor':
119
+ return {
120
+ name: 'anchor',
121
+ type: _l7Core.AttributeType.Attribute,
122
+ descriptor: {
123
+ name: 'a_Anchor',
124
+ shaderLocation: COMMON_ATTRIBUTE_LOCATION.ANCHOR,
125
+ buffer: {
126
+ usage: _l7Core.gl.STATIC_DRAW,
127
+ data: [],
128
+ type: _l7Core.gl.FLOAT
129
+ },
130
+ size: 1,
131
+ update: feature => {
132
+ const {
133
+ anchor = 0
134
+ } = feature;
135
+ return [anchor];
136
+ }
137
+ }
138
+ };
117
139
  default:
118
140
  return undefined;
119
141
  }