@antv/l7-layers 2.21.9-beta.0 → 2.21.10

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 (283) hide show
  1. package/es/citybuliding/models/build.d.ts +0 -16
  2. package/es/citybuliding/models/build.js +20 -18
  3. package/es/citybuliding/shaders/build_frag.glsl +6 -6
  4. package/es/citybuliding/shaders/build_vert.glsl +14 -8
  5. package/es/core/BaseLayer.js +8 -12
  6. package/es/core/BaseModel.d.ts +2 -15
  7. package/es/core/BaseModel.js +62 -94
  8. package/es/core/CommonStyleAttribute.d.ts +18 -14
  9. package/es/core/CommonStyleAttribute.js +67 -23
  10. package/es/core/triangulation.js +39 -13
  11. package/es/earth/models/atmosphere.d.ts +0 -15
  12. package/es/earth/models/atmosphere.js +24 -30
  13. package/es/earth/models/base.d.ts +0 -15
  14. package/es/earth/models/base.js +24 -30
  15. package/es/earth/models/bloomsphere.d.ts +0 -15
  16. package/es/earth/models/bloomsphere.js +24 -30
  17. package/es/earth/shaders/atmosphere/atmosphere_vert.glsl +5 -7
  18. package/es/earth/shaders/base/base_vert.glsl +3 -3
  19. package/es/earth/shaders/bloomshpere/bloomsphere_vert.glsl +4 -5
  20. package/es/geometry/models/billboard.d.ts +0 -15
  21. package/es/geometry/models/billboard.js +8 -14
  22. package/es/geometry/models/plane.d.ts +0 -14
  23. package/es/geometry/models/plane.js +10 -10
  24. package/es/geometry/models/sprite.js +9 -3
  25. package/es/geometry/shaders/billboard_vert.glsl +25 -28
  26. package/es/geometry/shaders/plane_vert.glsl +6 -6
  27. package/es/geometry/shaders/sprite_vert.glsl +9 -7
  28. package/es/heatmap/models/grid.d.ts +0 -14
  29. package/es/heatmap/models/grid.js +3 -10
  30. package/es/heatmap/models/grid3d.d.ts +0 -16
  31. package/es/heatmap/models/grid3d.js +6 -14
  32. package/es/heatmap/models/heatmap.d.ts +1 -20
  33. package/es/heatmap/models/heatmap.js +83 -96
  34. package/es/heatmap/models/hexagon.d.ts +0 -14
  35. package/es/heatmap/models/hexagon.js +3 -9
  36. package/es/heatmap/shaders/grid/grid_vert.glsl +42 -30
  37. package/es/heatmap/shaders/grid3d/grid_3d_vert.glsl +26 -14
  38. package/es/heatmap/shaders/heatmap/heatmap_3d_vert.glsl +16 -19
  39. package/es/heatmap/shaders/heatmap/heatmap_framebuffer_vert.glsl +22 -16
  40. package/es/heatmap/shaders/heatmap/heatmap_vert.glsl +4 -3
  41. package/es/heatmap/shaders/hexagon/hexagon_vert.glsl +23 -13
  42. package/es/image/models/image.d.ts +0 -14
  43. package/es/image/models/image.js +3 -11
  44. package/es/image/shaders/image_vert.glsl +6 -7
  45. package/es/line/models/arc.d.ts +0 -18
  46. package/es/line/models/arc.js +8 -57
  47. package/es/line/models/arc_3d.d.ts +0 -18
  48. package/es/line/models/arc_3d.js +7 -55
  49. package/es/line/models/flow.d.ts +0 -17
  50. package/es/line/models/flow.js +7 -35
  51. package/es/line/models/great_circle.d.ts +0 -17
  52. package/es/line/models/great_circle.js +6 -34
  53. package/es/line/models/line.d.ts +0 -17
  54. package/es/line/models/line.js +8 -17
  55. package/es/line/models/simple_line.d.ts +0 -14
  56. package/es/line/models/simple_line.js +47 -12
  57. package/es/line/models/wall.d.ts +0 -17
  58. package/es/line/models/wall.js +48 -22
  59. package/es/line/shaders/arc/line_arc_vert.glsl +48 -42
  60. package/es/line/shaders/arc3d/line_arc_3d_vert.glsl +20 -15
  61. package/es/line/shaders/flow/flow_line_vert.glsl +48 -30
  62. package/es/line/shaders/greatCircle/line_arc_great_circle_vert.glsl +72 -56
  63. package/es/line/shaders/line/line_vert.glsl +48 -31
  64. package/es/line/shaders/simple/simpleline_vert.glsl +23 -18
  65. package/es/line/shaders/wall/wall_vert.glsl +45 -36
  66. package/es/mask/models/fill.js +1 -2
  67. package/es/mask/shaders/mask_vert.glsl +7 -2
  68. package/es/plugins/DataMappingPlugin.d.ts +1 -0
  69. package/es/plugins/DataMappingPlugin.js +24 -1
  70. package/es/plugins/PixelPickingPlugin.js +2 -2
  71. package/es/plugins/RegisterStyleAttributePlugin.d.ts +1 -0
  72. package/es/plugins/RegisterStyleAttributePlugin.js +25 -3
  73. package/es/plugins/ShaderUniformPlugin.d.ts +5 -0
  74. package/es/plugins/ShaderUniformPlugin.js +34 -2
  75. package/es/point/models/billboard_point.d.ts +0 -14
  76. package/es/point/models/billboard_point.js +3 -11
  77. package/es/point/models/earthExtrude.d.ts +0 -16
  78. package/es/point/models/earthExtrude.js +8 -15
  79. package/es/point/models/earthFill.d.ts +0 -16
  80. package/es/point/models/earthFill.js +5 -13
  81. package/es/point/models/extrude.d.ts +0 -16
  82. package/es/point/models/extrude.js +12 -19
  83. package/es/point/models/fill.d.ts +0 -16
  84. package/es/point/models/fill.js +5 -16
  85. package/es/point/models/fillImage.d.ts +0 -16
  86. package/es/point/models/fillImage.js +16 -16
  87. package/es/point/models/image.d.ts +0 -15
  88. package/es/point/models/image.js +4 -14
  89. package/es/point/models/normal.d.ts +0 -14
  90. package/es/point/models/normal.js +3 -11
  91. package/es/point/models/radar.d.ts +0 -15
  92. package/es/point/models/radar.js +4 -13
  93. package/es/point/models/text.d.ts +0 -16
  94. package/es/point/models/text.js +11 -18
  95. package/es/point/shaders/billboard/billboard_point_vert.glsl +13 -10
  96. package/es/point/shaders/earthExtrude/earthExtrude_vert.glsl +25 -15
  97. package/es/point/shaders/earthFill/earthFill_vert.glsl +6 -6
  98. package/es/point/shaders/extrude/extrude_vert.glsl +39 -35
  99. package/es/point/shaders/fill/fill_vert.glsl +14 -12
  100. package/es/point/shaders/fillImage/fillImage_vert.glsl +28 -16
  101. package/es/point/shaders/image/image_vert.glsl +12 -15
  102. package/es/point/shaders/normal/normal_vert.glsl +10 -7
  103. package/es/point/shaders/radar/radar_vert.glsl +11 -11
  104. package/es/point/shaders/text/text_vert.glsl +9 -10
  105. package/es/polygon/models/extrude.d.ts +0 -16
  106. package/es/polygon/models/extrude.js +26 -26
  107. package/es/polygon/models/extrusion.d.ts +0 -16
  108. package/es/polygon/models/extrusion.js +4 -34
  109. package/es/polygon/models/fill.d.ts +0 -14
  110. package/es/polygon/models/fill.js +4 -12
  111. package/es/polygon/models/ocean.d.ts +0 -14
  112. package/es/polygon/models/ocean.js +6 -11
  113. package/es/polygon/models/water.d.ts +0 -14
  114. package/es/polygon/models/water.js +6 -11
  115. package/es/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +15 -17
  116. package/es/polygon/shaders/extrude/polygon_extrude_vert.glsl +20 -22
  117. package/es/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +17 -17
  118. package/es/polygon/shaders/extrusion/polygon_extrusion_vert.glsl +8 -8
  119. package/es/polygon/shaders/fill/fill_linear_vert.glsl +6 -7
  120. package/es/polygon/shaders/fill/fill_vert.glsl +12 -10
  121. package/es/polygon/shaders/ocean/ocean_vert.glsl +4 -3
  122. package/es/polygon/shaders/water/polygon_water_vert.glsl +5 -5
  123. package/es/raster/index.d.ts +1 -1
  124. package/es/raster/index.js +1 -1
  125. package/es/raster/models/raster.d.ts +0 -14
  126. package/es/raster/models/raster.js +3 -12
  127. package/es/raster/models/rasterRgb.d.ts +0 -14
  128. package/es/raster/models/rasterRgb.js +3 -12
  129. package/es/raster/models/rasterTerrainRgb.d.ts +0 -14
  130. package/es/raster/models/rasterTerrainRgb.js +3 -11
  131. package/es/raster/shaders/raster/raster_2d_vert.glsl +6 -6
  132. package/es/raster/shaders/rgb/raster_rgb_vert.glsl +11 -11
  133. package/es/raster/shaders/terrain/terrain_rgb_vert.glsl +11 -11
  134. package/es/tile/core/BaseLayer.js +16 -0
  135. package/es/tile/tile/Tile.d.ts +0 -2
  136. package/es/utils/extrude_polyline.d.ts +15 -0
  137. package/es/utils/extrude_polyline.js +217 -0
  138. package/es/utils/multiPassRender.js +2 -10
  139. package/es/wind/models/wind.d.ts +0 -14
  140. package/es/wind/models/wind.js +1 -9
  141. package/es/wind/shaders/wind_vert.glsl +5 -6
  142. package/lib/citybuliding/models/build.d.ts +0 -16
  143. package/lib/citybuliding/models/build.js +20 -18
  144. package/lib/citybuliding/shaders/build_frag.glsl +6 -6
  145. package/lib/citybuliding/shaders/build_vert.glsl +14 -8
  146. package/lib/core/BaseLayer.js +8 -12
  147. package/lib/core/BaseModel.d.ts +2 -15
  148. package/lib/core/BaseModel.js +60 -92
  149. package/lib/core/CommonStyleAttribute.d.ts +18 -14
  150. package/lib/core/CommonStyleAttribute.js +68 -23
  151. package/lib/core/triangulation.js +39 -13
  152. package/lib/earth/models/atmosphere.d.ts +0 -15
  153. package/lib/earth/models/atmosphere.js +24 -30
  154. package/lib/earth/models/base.d.ts +0 -15
  155. package/lib/earth/models/base.js +24 -30
  156. package/lib/earth/models/bloomsphere.d.ts +0 -15
  157. package/lib/earth/models/bloomsphere.js +24 -30
  158. package/lib/earth/shaders/atmosphere/atmosphere_vert.glsl +5 -7
  159. package/lib/earth/shaders/base/base_vert.glsl +3 -3
  160. package/lib/earth/shaders/bloomshpere/bloomsphere_vert.glsl +4 -5
  161. package/lib/geometry/models/billboard.d.ts +0 -15
  162. package/lib/geometry/models/billboard.js +8 -14
  163. package/lib/geometry/models/plane.d.ts +0 -14
  164. package/lib/geometry/models/plane.js +10 -10
  165. package/lib/geometry/models/sprite.js +9 -3
  166. package/lib/geometry/shaders/billboard_vert.glsl +25 -28
  167. package/lib/geometry/shaders/plane_vert.glsl +6 -6
  168. package/lib/geometry/shaders/sprite_vert.glsl +9 -7
  169. package/lib/heatmap/models/grid.d.ts +0 -14
  170. package/lib/heatmap/models/grid.js +3 -10
  171. package/lib/heatmap/models/grid3d.d.ts +0 -16
  172. package/lib/heatmap/models/grid3d.js +6 -14
  173. package/lib/heatmap/models/heatmap.d.ts +1 -20
  174. package/lib/heatmap/models/heatmap.js +82 -95
  175. package/lib/heatmap/models/hexagon.d.ts +0 -14
  176. package/lib/heatmap/models/hexagon.js +3 -9
  177. package/lib/heatmap/shaders/grid/grid_vert.glsl +42 -30
  178. package/lib/heatmap/shaders/grid3d/grid_3d_vert.glsl +26 -14
  179. package/lib/heatmap/shaders/heatmap/heatmap_3d_vert.glsl +16 -19
  180. package/lib/heatmap/shaders/heatmap/heatmap_framebuffer_vert.glsl +22 -16
  181. package/lib/heatmap/shaders/heatmap/heatmap_vert.glsl +4 -3
  182. package/lib/heatmap/shaders/hexagon/hexagon_vert.glsl +23 -13
  183. package/lib/image/models/image.d.ts +0 -14
  184. package/lib/image/models/image.js +3 -11
  185. package/lib/image/shaders/image_vert.glsl +6 -7
  186. package/lib/line/models/arc.d.ts +0 -18
  187. package/lib/line/models/arc.js +7 -56
  188. package/lib/line/models/arc_3d.d.ts +0 -18
  189. package/lib/line/models/arc_3d.js +7 -55
  190. package/lib/line/models/flow.d.ts +0 -17
  191. package/lib/line/models/flow.js +7 -35
  192. package/lib/line/models/great_circle.d.ts +0 -17
  193. package/lib/line/models/great_circle.js +5 -33
  194. package/lib/line/models/line.d.ts +0 -17
  195. package/lib/line/models/line.js +8 -17
  196. package/lib/line/models/simple_line.d.ts +0 -14
  197. package/lib/line/models/simple_line.js +47 -12
  198. package/lib/line/models/wall.d.ts +0 -17
  199. package/lib/line/models/wall.js +48 -22
  200. package/lib/line/shaders/arc/line_arc_vert.glsl +48 -42
  201. package/lib/line/shaders/arc3d/line_arc_3d_vert.glsl +20 -15
  202. package/lib/line/shaders/flow/flow_line_vert.glsl +48 -30
  203. package/lib/line/shaders/greatCircle/line_arc_great_circle_vert.glsl +72 -56
  204. package/lib/line/shaders/line/line_vert.glsl +48 -31
  205. package/lib/line/shaders/simple/simpleline_vert.glsl +23 -18
  206. package/lib/line/shaders/wall/wall_vert.glsl +45 -36
  207. package/lib/mask/models/fill.js +1 -2
  208. package/lib/mask/shaders/mask_vert.glsl +7 -2
  209. package/lib/plugins/DataMappingPlugin.d.ts +1 -0
  210. package/lib/plugins/DataMappingPlugin.js +23 -0
  211. package/lib/plugins/PixelPickingPlugin.js +1 -1
  212. package/lib/plugins/RegisterStyleAttributePlugin.d.ts +1 -0
  213. package/lib/plugins/RegisterStyleAttributePlugin.js +24 -2
  214. package/lib/plugins/ShaderUniformPlugin.d.ts +5 -0
  215. package/lib/plugins/ShaderUniformPlugin.js +34 -2
  216. package/lib/point/models/billboard_point.d.ts +0 -14
  217. package/lib/point/models/billboard_point.js +3 -11
  218. package/lib/point/models/earthExtrude.d.ts +0 -16
  219. package/lib/point/models/earthExtrude.js +7 -14
  220. package/lib/point/models/earthFill.d.ts +0 -16
  221. package/lib/point/models/earthFill.js +5 -13
  222. package/lib/point/models/extrude.d.ts +0 -16
  223. package/lib/point/models/extrude.js +11 -18
  224. package/lib/point/models/fill.d.ts +0 -16
  225. package/lib/point/models/fill.js +5 -16
  226. package/lib/point/models/fillImage.d.ts +0 -16
  227. package/lib/point/models/fillImage.js +16 -16
  228. package/lib/point/models/image.d.ts +0 -15
  229. package/lib/point/models/image.js +4 -14
  230. package/lib/point/models/normal.d.ts +0 -14
  231. package/lib/point/models/normal.js +3 -11
  232. package/lib/point/models/radar.d.ts +0 -15
  233. package/lib/point/models/radar.js +4 -13
  234. package/lib/point/models/text.d.ts +0 -16
  235. package/lib/point/models/text.js +11 -18
  236. package/lib/point/shaders/billboard/billboard_point_vert.glsl +13 -10
  237. package/lib/point/shaders/earthExtrude/earthExtrude_vert.glsl +25 -15
  238. package/lib/point/shaders/earthFill/earthFill_vert.glsl +6 -6
  239. package/lib/point/shaders/extrude/extrude_vert.glsl +39 -35
  240. package/lib/point/shaders/fill/fill_vert.glsl +14 -12
  241. package/lib/point/shaders/fillImage/fillImage_vert.glsl +28 -16
  242. package/lib/point/shaders/image/image_vert.glsl +12 -15
  243. package/lib/point/shaders/normal/normal_vert.glsl +10 -7
  244. package/lib/point/shaders/radar/radar_vert.glsl +11 -11
  245. package/lib/point/shaders/text/text_vert.glsl +9 -10
  246. package/lib/polygon/models/extrude.d.ts +0 -16
  247. package/lib/polygon/models/extrude.js +25 -25
  248. package/lib/polygon/models/extrusion.d.ts +0 -16
  249. package/lib/polygon/models/extrusion.js +4 -34
  250. package/lib/polygon/models/fill.d.ts +0 -14
  251. package/lib/polygon/models/fill.js +4 -12
  252. package/lib/polygon/models/ocean.d.ts +0 -14
  253. package/lib/polygon/models/ocean.js +6 -11
  254. package/lib/polygon/models/water.d.ts +0 -14
  255. package/lib/polygon/models/water.js +6 -11
  256. package/lib/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +15 -17
  257. package/lib/polygon/shaders/extrude/polygon_extrude_vert.glsl +20 -22
  258. package/lib/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +17 -17
  259. package/lib/polygon/shaders/extrusion/polygon_extrusion_vert.glsl +8 -8
  260. package/lib/polygon/shaders/fill/fill_linear_vert.glsl +6 -7
  261. package/lib/polygon/shaders/fill/fill_vert.glsl +12 -10
  262. package/lib/polygon/shaders/ocean/ocean_vert.glsl +4 -3
  263. package/lib/polygon/shaders/water/polygon_water_vert.glsl +5 -5
  264. package/lib/raster/index.d.ts +1 -1
  265. package/lib/raster/index.js +2 -2
  266. package/lib/raster/models/raster.d.ts +0 -14
  267. package/lib/raster/models/raster.js +3 -12
  268. package/lib/raster/models/rasterRgb.d.ts +0 -14
  269. package/lib/raster/models/rasterRgb.js +3 -12
  270. package/lib/raster/models/rasterTerrainRgb.d.ts +0 -14
  271. package/lib/raster/models/rasterTerrainRgb.js +3 -11
  272. package/lib/raster/shaders/raster/raster_2d_vert.glsl +6 -6
  273. package/lib/raster/shaders/rgb/raster_rgb_vert.glsl +11 -11
  274. package/lib/raster/shaders/terrain/terrain_rgb_vert.glsl +11 -11
  275. package/lib/tile/core/BaseLayer.js +16 -0
  276. package/lib/tile/tile/Tile.d.ts +0 -2
  277. package/lib/utils/extrude_polyline.d.ts +15 -0
  278. package/lib/utils/extrude_polyline.js +217 -0
  279. package/lib/utils/multiPassRender.js +2 -10
  280. package/lib/wind/models/wind.d.ts +0 -14
  281. package/lib/wind/models/wind.js +1 -9
  282. package/lib/wind/shaders/wind_vert.glsl +5 -6
  283. package/package.json +9 -9
@@ -1,12 +1,12 @@
1
- #define Animate (0.0)
2
1
 
3
- layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;
4
- layout(location = ATTRIBUTE_LOCATION_POSITION_64LOW) in vec2 a_Position64Low;
5
- layout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;
6
- layout(location = ATTRIBUTE_LOCATION_SIZE) in vec2 a_Size;
7
- layout(location = ATTRIBUTE_LOCATION_DISTANCE_INDEX) in vec3 a_DistanceAndIndexAndMiter;
8
- layout(location = ATTRIBUTE_LOCATION_NORMAL) in vec4 a_Normal_Total_Distance;
9
- layout(location = ATTRIBUTE_LOCATION_UV) in vec2 a_iconMapUV;
2
+ #define Animate 0.0
3
+
4
+ layout(location = 0) in vec3 a_Position;
5
+ layout(location = 1) in vec4 a_Color;
6
+ layout(location = 9) in vec2 a_Size;
7
+ layout(location = 10) in vec3 a_DistanceAndIndexAndMiter;
8
+ layout(location = 13) in vec4 a_Normal_Total_Distance;
9
+ layout(location = 14) in vec2 a_iconMapUV;
10
10
 
11
11
  layout(std140) uniform commonUniorm {
12
12
  vec4 u_animate: [ 1., 2., 1.0, 0.2 ];
@@ -27,6 +27,7 @@ layout(std140) uniform commonUniorm {
27
27
  float u_time;
28
28
  };
29
29
 
30
+
30
31
  out vec4 v_color;
31
32
  out vec4 v_stroke;
32
33
  //dash
@@ -49,53 +50,69 @@ void main() {
49
50
  v_d_distance_ratio = a_DistanceAndIndex.x / a_Total_Distance;
50
51
 
51
52
  // cal style mapping - 数据纹理映射部分的计算
52
- float d_texPixelLen; // 贴图的像素长度,根据地图层级缩放
53
+ float d_texPixelLen; // 贴图的像素长度,根据地图层级缩放
53
54
  v_iconMapUV = a_iconMapUV;
54
55
  d_texPixelLen = project_float_pixel(u_icon_step);
56
+ if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {
57
+ d_texPixelLen *= 10.0;
58
+ }
55
59
 
56
60
  v_color = a_Color;
57
61
  v_color.a *= opacity;
58
62
  v_stroke = stroke;
59
63
 
60
- vec3 size = a_Miter * setPickingSize(a_Size.x) * a_Normal;
61
-
64
+ vec3 size = a_Miter * setPickingSize(a_Size.x) * reverse_offset_normal(a_Normal);
65
+
62
66
  vec2 offset = project_pixel(size.xy);
63
67
 
64
68
  float lineDistance = a_DistanceAndIndex.x;
65
69
  float currentLinePointRatio = lineDistance / a_Total_Distance;
70
+
66
71
 
67
72
  float lineOffsetWidth = length(offset + offset * sign(a_Miter)); // 线横向偏移的距离(向两侧偏移的和)
68
- float linePixelSize = project_pixel(a_Size.x) * 2.0; // 定点位置偏移,按地图等级缩放后的距离 单侧 * 2
69
- float texV = lineOffsetWidth / linePixelSize; // 线图层贴图部分的 v 坐标值
70
-
73
+ float linePixelSize = project_pixel(a_Size.x) * 2.0; // 定点位置偏移,按地图等级缩放后的距离 单侧 * 2
74
+ float texV = lineOffsetWidth/linePixelSize; // 线图层贴图部分的 v 坐标值
75
+
71
76
  v_texture_data = vec4(currentLinePointRatio, lineDistance, d_texPixelLen, texV);
72
77
  // 设置数据集的参数
73
78
 
74
- vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0), a_Position64Low);
79
+ vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));
75
80
 
76
81
  // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, a_Size.y, 1.0));
77
82
 
78
83
  float h = float(a_Position.z) * u_vertexScale; // 线顶点的高度 - 兼容不存在第三个数值的情况 vertex height
79
84
  float lineHeight = a_Size.y; // size 第二个参数代表的高度 [linewidth, lineheight]
80
85
 
81
- // 兼容 mapbox 在线高度上的效果表现基本一致
82
- if (
83
- u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT ||
84
- u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET
85
- ) {
86
- // mapbox
87
- // 保持高度相对不变
88
- float mapboxZoomScale = 4.0 / pow(2.0, 21.0 - u_Zoom);
89
- h *= mapboxZoomScale;
90
- h += u_raisingHeight * mapboxZoomScale;
91
- if (u_heightfixed > 0.0) {
92
- lineHeight *= mapboxZoomScale;
86
+ if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
87
+ lineHeight *= 0.2; // 保持和 amap/mapbox 一致的效果
88
+ h *= 0.2;
89
+ if(u_heightfixed < 1.0) {
90
+ lineHeight = project_pixel(a_Size.y);
91
+ }
92
+ gl_Position = u_Mvp * (vec4(project_pos.xy + offset, lineHeight + h + u_raisingHeight, 1.0));
93
+ } else {
94
+ // 兼容 mapbox 在线高度上的效果表现基本一致
95
+ if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {
96
+ // mapbox
97
+ // 保持高度相对不变
98
+ float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);
99
+ h *= mapboxZoomScale;
100
+ h += u_raisingHeight * mapboxZoomScale;
101
+ if(u_heightfixed > 0.0) {
102
+ lineHeight *= mapboxZoomScale;
103
+ }
104
+
105
+ } else {
106
+ // amap
107
+ h += u_raisingHeight;
108
+ // lineHeight 顶点偏移高度
109
+ if(u_heightfixed < 1.0) {
110
+ lineHeight *= pow(2.0, 20.0 - u_Zoom);
111
+ }
93
112
  }
94
- }
95
113
 
96
- gl_Position = project_common_position_to_clipspace(
97
- vec4(project_pos.xy + offset, lineHeight + h, 1.0)
98
- );
114
+ gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, lineHeight + h, 1.0));
115
+ }
99
116
 
100
117
  setPickingColor(a_PickingColor);
101
118
  }
@@ -1,7 +1,6 @@
1
- layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;
2
- layout(location = ATTRIBUTE_LOCATION_POSITION_64LOW) in vec2 a_Position64Low;
3
- layout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;
4
- layout(location = ATTRIBUTE_LOCATION_SIZE) in vec4 a_SizeDistanceAndTotalDistance;
1
+ layout(location = 0) in vec3 a_Position;
2
+ layout(location = 1) in vec4 a_Color;
3
+ layout(location = 9) in vec4 a_SizeDistanceAndTotalDistance;
5
4
 
6
5
  layout(std140) uniform commonUniorm {
7
6
  vec4 u_sourceColor;
@@ -22,24 +21,30 @@ void main() {
22
21
  //dash输出
23
22
  v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / a_SizeDistanceAndTotalDistance.a;
24
23
 
25
- v_color = a_Color;
24
+ v_color = a_Color;
26
25
  v_distanceScale = a_SizeDistanceAndTotalDistance.b / a_SizeDistanceAndTotalDistance.a;
27
26
  v_color.a = v_color.a * opacity;
28
- vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0), a_Position64Low);
27
+ vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));
29
28
 
30
29
  float h = float(a_Position.z) * u_vertexScale; // 线顶点的高度 - 兼容不存在第三个数值的情况
31
30
 
32
- float lineHeight = a_SizeDistanceAndTotalDistance.y;
33
- // 兼容 mapbox 在线高度上的效果表现基本一致
34
- if (
35
- u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT ||
36
- u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET
37
- ) {
38
- // 保持高度相对不变
39
- h *= 2.0 / pow(2.0, 20.0 - u_Zoom);
31
+ if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
32
+ gl_Position = u_Mvp * (vec4(project_pos.xy, project_pixel(a_SizeDistanceAndTotalDistance.y) + h * 0.2, 1.0));
33
+ } else {
34
+ float lineHeight = a_SizeDistanceAndTotalDistance.y;
35
+ // 兼容 mapbox 在线高度上的效果表现基本一致
36
+ if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {
37
+ // 保持高度相对不变
38
+ h *= 2.0/pow(2.0, 20.0 - u_Zoom);
39
+ }
40
+
41
+ // amap1.x
42
+ if(u_CoordinateSystem == COORDINATE_SYSTEM_P20 || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {
43
+ // 保持高度相对不变
44
+ lineHeight *= pow(2.0, 20.0 - u_Zoom);
45
+ }
46
+
47
+ gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy, lineHeight + h, 1.0));
48
+ gl_PointSize = 10.0;
40
49
  }
41
-
42
- gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy, lineHeight + h, 1.0));
43
- gl_PointSize = 10.0;
44
-
45
50
  }
@@ -1,11 +1,14 @@
1
1
  #define Animate 0.0
2
- layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;
3
- layout(location = ATTRIBUTE_LOCATION_POSITION_64LOW) in vec2 a_Position64Low;
4
- layout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;
5
- layout(location = ATTRIBUTE_LOCATION_SIZE) in vec2 a_Size;
6
- layout(location = ATTRIBUTE_LOCATION_NORMAL) in vec3 a_Normal;
7
- layout(location = ATTRIBUTE_LOCATION_UV) in vec2 a_iconMapUV;
8
- layout(location = ATTRIBUTE_LOCATION_DISTANCE_MITER_TOTAL) in vec3 a_Distance_Total_Miter;
2
+ layout(location = 0) in vec3 a_Position;
3
+ layout(location = 1) in vec4 a_Color;
4
+ layout(location = 9) in vec2 a_Size;
5
+ layout(location = 10) in float a_Miter;
6
+ layout(location = 11) in float a_Total_Distance;
7
+ layout(location = 12) in vec4 a_Instance;
8
+ layout(location = 13) in vec3 a_Normal;
9
+ layout(location = 14) in vec2 a_iconMapUV;
10
+ layout(location = 15) in float a_Distance;
11
+
9
12
 
10
13
  layout(std140) uniform commonUniorm {
11
14
  vec4 u_animate: [ 1., 2., 1.0, 0.2 ];
@@ -20,7 +23,6 @@ layout(std140) uniform commonUniorm {
20
23
  float u_iconStepCount;
21
24
  float u_time;
22
25
  };
23
-
24
26
  #pragma include "projection"
25
27
  #pragma include "light"
26
28
  #pragma include "picking"
@@ -33,59 +35,66 @@ out float v_radio;
33
35
  out vec4 v_dataset;
34
36
 
35
37
  void main() {
36
- float a_Distance = a_Distance_Total_Miter.x;
37
- float a_Miter = a_Distance_Total_Miter.y;
38
- float a_Total_Distance = a_Distance_Total_Miter.z;
38
+
39
39
 
40
40
  float d_distance_ratio; // 当前点位距离占线总长的比例
41
- float d_texPixelLen; // 贴图的像素长度,根据地图层级缩放
41
+ float d_texPixelLen; // 贴图的像素长度,根据地图层级缩放
42
42
 
43
43
  v_iconMapUV = a_iconMapUV;
44
- if (u_heightfixed < 1.0) {
45
- // 高度随 zoom 调整
44
+ if(u_heightfixed < 1.0) { // 高度随 zoom 调整
46
45
  d_texPixelLen = project_pixel(u_icon_step);
47
46
  } else {
48
47
  d_texPixelLen = u_icon_step;
49
48
  }
49
+ if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {
50
+ d_texPixelLen *= 10.0;
51
+ }
50
52
 
51
- if (u_animate.x == Animate || u_linearColor == 1.0) {
52
- d_distance_ratio = a_Distance / a_Total_Distance;
53
+ if(u_animate.x == Animate || u_linearColor == 1.0) {
54
+ d_distance_ratio = a_Distance / a_Total_Distance;
53
55
  }
54
56
 
55
- float miter = (a_Miter + 1.0) / 2.0;
57
+ float miter = (a_Miter + 1.0)/2.0;
56
58
  // 设置数据集的参数
57
59
  v_dataset[0] = d_distance_ratio; // 当前点位距离占线总长的比例
58
- v_dataset[1] = a_Distance; // 当前顶点的距离
59
- v_dataset[2] = d_texPixelLen; // 贴图的像素长度,根据地图层级缩放
60
- v_dataset[3] = miter; // 线图层贴图部分的 v 坐标值 0 - 1
60
+ v_dataset[1] = a_Distance; // 当前顶点的距离
61
+ v_dataset[2] = d_texPixelLen; // 贴图的像素长度,根据地图层级缩放
62
+ v_dataset[3] = miter; // 线图层贴图部分的 v 坐标值 0 - 1
61
63
 
62
- vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0), a_Position64Low);
64
+ vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));
63
65
 
64
- float originSize = a_Size.x; // 固定高度
65
- if (u_heightfixed < 1.0) {
66
- originSize = project_float_meter(a_Size.x); // 高度随 zoom 调整
66
+ float originSize = a_Size.x; // 固定高度
67
+ if(u_heightfixed < 1.0) {
68
+ originSize = project_float_meter(a_Size.x); // 高度随 zoom 调整
67
69
  }
68
70
 
71
+
69
72
  float wallHeight = originSize * miter;
70
73
  float lightWeight = calc_lighting(vec4(project_pos.xy, wallHeight, 1.0));
71
74
 
72
75
  v_blur = min(project_float_pixel(2.0) / originSize, 0.05);
73
76
  v_color = vec4(a_Color.rgb * lightWeight, a_Color.w * opacity);
74
77
 
75
- // 兼容 mapbox 在线高度上的效果表现基本一致
76
- if (
77
- u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT ||
78
- u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET
79
- ) {
80
- // mapbox
81
- // 保持高度相对不变
82
- float mapboxZoomScale = 4.0 / pow(2.0, 21.0 - u_Zoom);
83
- if (u_heightfixed > 0.0) {
84
- wallHeight *= mapboxZoomScale;
78
+ if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
79
+ gl_Position = u_Mvp * (vec4(project_pos.xy, wallHeight, 1.0));
80
+ } else {
81
+ // 兼容 mapbox 在线高度上的效果表现基本一致
82
+ if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {
83
+ // mapbox
84
+ // 保持高度相对不变
85
+ float mapboxZoomScale = 4.0 / pow(2.0, 21.0 - u_Zoom);
86
+ if(u_heightfixed > 0.0) {
87
+ wallHeight *= mapboxZoomScale;
88
+ }
89
+
90
+ } else {
91
+ // lineHeight 顶点偏移高度
92
+ if(u_heightfixed < 1.0) {
93
+ wallHeight *= pow(2.0, 20.0 - u_Zoom);
94
+ }
85
95
  }
96
+ gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy, wallHeight, 1.0));
86
97
  }
87
98
 
88
- gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy, wallHeight, 1.0));
89
-
90
99
  setPickingColor(a_PickingColor);
91
100
  }
@@ -6,7 +6,7 @@ import { polygonTriangulation } from "../../core/triangulation";
6
6
  /* babel-plugin-inline-import '../../shader/minify_frag.glsl' */
7
7
  const mask_frag = "layout(std140) uniform commonUniorm {\n vec4 u_color;\n float u_opacity;\n};\n\nout vec4 outputColor;\n\nvoid main() {\n outputColor = u_color;\n outputColor.a *= u_opacity;\n}\n";
8
8
  /* babel-plugin-inline-import '../shaders/mask_vert.glsl' */
9
- const mask_vert = "layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\n\nlayout(std140) uniform commonUniorm {\n vec4 u_color;\n float u_opacity;\n};\n\n#pragma include \"projection\"\n\nvoid main() {\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n}\n\n";
9
+ const mask_vert = "layout(location = 0) in vec3 a_Position;\n\nlayout(std140) uniform commonUniorm {\n vec4 u_color;\n float u_opacity;\n};\n\n#pragma include \"projection\"\n\nvoid main() {\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xyz, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n }\n}\n\n";
10
10
  export default class MaskModel extends BaseModel {
11
11
  getUninforms() {
12
12
  const commoninfo = this.getCommonUniformsInfo();
@@ -40,7 +40,6 @@ export default class MaskModel extends BaseModel {
40
40
  moduleName: 'mask',
41
41
  vertexShader: mask_vert,
42
42
  fragmentShader: mask_frag,
43
- defines: _this2.getDefines(),
44
43
  triangulation: polygonTriangulation,
45
44
  depth: {
46
45
  enable: false
@@ -1,4 +1,4 @@
1
- layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;
1
+ layout(location = 0) in vec3 a_Position;
2
2
 
3
3
  layout(std140) uniform commonUniorm {
4
4
  vec4 u_color;
@@ -9,6 +9,11 @@ layout(std140) uniform commonUniorm {
9
9
 
10
10
  void main() {
11
11
  vec4 project_pos = project_position(vec4(a_Position, 1.0));
12
- gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));
12
+
13
+ if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
14
+ gl_Position = u_Mvp * (vec4(project_pos.xyz, 1.0));
15
+ } else {
16
+ gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));
17
+ }
13
18
  }
14
19
 
@@ -5,6 +5,7 @@ export default class DataMappingPlugin implements ILayerPlugin {
5
5
  apply(layer: ILayer, { styleAttributeService, mapService, fontService }: L7Container): void;
6
6
  private generateMaping;
7
7
  private mapping;
8
+ private adjustData2Amap2Coordinates;
8
9
  private adjustData2SimpleCoordinates;
9
10
  private unProjectCoordinates;
10
11
  private applyAttributeMapping;
@@ -2,7 +2,10 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
3
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
4
  import { IDebugLog, ILayerStage } from '@antv/l7-core';
5
- import { normalize, rgb2arr } from '@antv/l7-utils';
5
+ import { lodashUtil, normalize, rgb2arr } from '@antv/l7-utils';
6
+ const {
7
+ cloneDeep
8
+ } = lodashUtil;
6
9
  export default class DataMappingPlugin {
7
10
  constructor() {
8
11
  _defineProperty(this, "mapService", void 0);
@@ -133,11 +136,31 @@ export default class DataMappingPlugin {
133
136
  attributes.forEach(attribute => {
134
137
  attribute.needRemapping = false;
135
138
  });
139
+ // 调整数据兼容 Amap2.0
140
+ this.adjustData2Amap2Coordinates(mappedData, layer);
136
141
 
137
142
  // 调整数据兼容 SimpleCoordinates
138
143
  this.adjustData2SimpleCoordinates(mappedData);
139
144
  return mappedData;
140
145
  }
146
+ adjustData2Amap2Coordinates(mappedData, layer) {
147
+ // 根据地图的类型判断是否需要对点位数据进行处理, 若是高德2.0则需要对坐标进行相对偏移
148
+ if (mappedData.length > 0 && this.mapService.version === 'GAODE2.x') {
149
+ const layerCenter = layer.coordCenter || layer.getSource().center;
150
+ // 单个的点数据
151
+ // @ts-ignore
152
+ mappedData
153
+ // TODO: 避免经纬度被重复计算导致坐标位置偏移
154
+ .filter(d => !d.originCoordinates).map(d => {
155
+ d.version = 'GAODE2.x';
156
+ // @ts-ignore
157
+ d.originCoordinates = cloneDeep(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)
158
+ // @ts-ignore
159
+ // d.coordinates = this.mapService.lngLatToCoord(d.coordinates);
160
+ d.coordinates = this.mapService.coordToAMap2RelativeCoordinates(d.coordinates, layerCenter);
161
+ });
162
+ }
163
+ }
141
164
  adjustData2SimpleCoordinates(mappedData) {
142
165
  if (mappedData.length > 0 && this.mapService.version === 'SIMPLE') {
143
166
  mappedData.map(d => {
@@ -1,7 +1,7 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
2
  import { AttributeType, gl } from '@antv/l7-core';
3
3
  import { decodePickingColor, encodePickingColor, lodashUtil, rgb2arr } from '@antv/l7-utils';
4
- import { COMMON_ATTRIBUTE_LOCATION } from "../core/CommonStyleAttribute";
4
+ import { ShaderLocation } from "../core/CommonStyleAttribute";
5
5
  const {
6
6
  isNumber
7
7
  } = lodashUtil;
@@ -59,7 +59,7 @@ export default class PixelPickingPlugin {
59
59
  type: AttributeType.Attribute,
60
60
  descriptor: {
61
61
  name: 'a_PickingColor',
62
- shaderLocation: COMMON_ATTRIBUTE_LOCATION.PICKING_COLOR,
62
+ shaderLocation: ShaderLocation.PICKING_COLOR,
63
63
  buffer: {
64
64
  data: [],
65
65
  type: gl.FLOAT
@@ -7,4 +7,5 @@ export default class RegisterStyleAttributePlugin implements ILayerPlugin {
7
7
  private registerBuiltinAttributes;
8
8
  private registerPositionAttribute;
9
9
  private registerColorAttribute;
10
+ private registerVertexIdAttribute;
10
11
  }
@@ -1,5 +1,5 @@
1
1
  import { AttributeType, gl } from '@antv/l7-core';
2
- import { COMMON_ATTRIBUTE_LOCATION } from "../core/CommonStyleAttribute";
2
+ import { ShaderLocation } from "../core/CommonStyleAttribute";
3
3
  import { isTileGroup } from "../tile/utils/utils";
4
4
 
5
5
  /**
@@ -27,6 +27,7 @@ export default class RegisterStyleAttributePlugin {
27
27
  this.registerPositionAttribute(styleAttributeService);
28
28
  // this.registerFilterAttribute(styleAttributeService);//数据层数据过滤
29
29
  this.registerColorAttribute(styleAttributeService);
30
+ this.registerVertexIdAttribute(styleAttributeService);
30
31
  }
31
32
  registerPositionAttribute(styleAttributeService) {
32
33
  styleAttributeService.registerStyleAttribute({
@@ -34,7 +35,7 @@ export default class RegisterStyleAttributePlugin {
34
35
  type: AttributeType.Attribute,
35
36
  descriptor: {
36
37
  name: 'a_Position',
37
- shaderLocation: COMMON_ATTRIBUTE_LOCATION.POSITION,
38
+ shaderLocation: ShaderLocation.POSITION,
38
39
  buffer: {
39
40
  data: [],
40
41
  type: gl.FLOAT
@@ -52,7 +53,7 @@ export default class RegisterStyleAttributePlugin {
52
53
  type: AttributeType.Attribute,
53
54
  descriptor: {
54
55
  name: 'a_Color',
55
- shaderLocation: COMMON_ATTRIBUTE_LOCATION.COLOR,
56
+ shaderLocation: ShaderLocation.COLOR,
56
57
  buffer: {
57
58
  // give the WebGL driver a hint that this buffer may change
58
59
  usage: gl.DYNAMIC_DRAW,
@@ -69,4 +70,25 @@ export default class RegisterStyleAttributePlugin {
69
70
  }
70
71
  });
71
72
  }
73
+ registerVertexIdAttribute(styleAttributeService) {
74
+ styleAttributeService.registerStyleAttribute({
75
+ // 统一注册每个顶点的唯一编号(目前用于样式的数据映射计算使用)
76
+ name: 'vertexId',
77
+ type: AttributeType.Attribute,
78
+ descriptor: {
79
+ name: 'a_vertexId',
80
+ shaderLocation: ShaderLocation.VERTEX_ID,
81
+ buffer: {
82
+ // give the WebGL driver a hint that this buffer may change
83
+ usage: gl.DYNAMIC_DRAW,
84
+ data: [],
85
+ type: gl.FLOAT
86
+ },
87
+ size: 1,
88
+ update: (feature, featureIdx) => {
89
+ return [featureIdx];
90
+ }
91
+ }
92
+ });
93
+ }
72
94
  }
@@ -13,5 +13,10 @@ export default class ShaderUniformPlugin implements ILayerPlugin {
13
13
  private mapService;
14
14
  private layerService;
15
15
  apply(layer: ILayer, { rendererService, mapService, layerService, coordinateSystemService, cameraService, }: L7Container): void;
16
+ /**
17
+ * 对于每个 layer 都有不同的几何中心点,因此在绘制每个 layer 的时候都需要重新设置
18
+ * @param layer
19
+ */
20
+ private setLayerCenter;
16
21
  private generateUBO;
17
22
  }
@@ -29,6 +29,9 @@ export default class ShaderUniformPlugin {
29
29
  this.layerService = layerService;
30
30
  this.coordinateSystemService = coordinateSystemService;
31
31
  this.cameraService = cameraService;
32
+ const version = this.mapService.version;
33
+ let mvp = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]; // default matrix (for gaode2.x)
34
+ let sceneCenterMercator = [0, 0];
32
35
  let uniformBuffer;
33
36
  if (!this.rendererService.uniformBuffers[0]) {
34
37
  // Create a Uniform Buffer Object(UBO).
@@ -43,6 +46,19 @@ export default class ShaderUniformPlugin {
43
46
  const offset = layer.getLayerConfig().tileOrigin;
44
47
  // 重新计算坐标系参数
45
48
  this.coordinateSystemService.refresh(offset);
49
+ if (version === 'GAODE2.x') {
50
+ this.setLayerCenter(layer);
51
+ // @ts-ignore
52
+ mvp = this.mapService.map.customCoords.getMVPMatrix();
53
+ // mvp = amapCustomCoords.getMVPMatrix()
54
+ // @ts-ignore
55
+ sceneCenterMercator = this.mapService.getCustomCoordCenter();
56
+ const uniformBuffer = layer.getLayerUniformBuffer();
57
+ uniformBuffer.subData({
58
+ offset: 0,
59
+ data: new Uint8Array(new Float32Array([...mvp, ...sceneCenterMercator]).buffer)
60
+ });
61
+ }
46
62
  const {
47
63
  width,
48
64
  height
@@ -50,7 +66,7 @@ export default class ShaderUniformPlugin {
50
66
  const {
51
67
  data,
52
68
  uniforms
53
- } = this.generateUBO(width, height);
69
+ } = this.generateUBO(mvp, sceneCenterMercator, width, height);
54
70
  if (this.layerService.alreadyInRendering && this.rendererService.uniformBuffers[0]) {
55
71
  const renderUniformBuffer = this.rendererService.uniformBuffers[0];
56
72
  // Update only once since all models can share one UBO.
@@ -74,7 +90,20 @@ export default class ShaderUniformPlugin {
74
90
  }
75
91
  });
76
92
  }
77
- generateUBO(width, height) {
93
+
94
+ /**
95
+ * 对于每个 layer 都有不同的几何中心点,因此在绘制每个 layer 的时候都需要重新设置
96
+ * @param layer
97
+ */
98
+ setLayerCenter(layer) {
99
+ if (layer.coordCenter === undefined) {
100
+ layer.coordCenter = layer.getSource().center;
101
+ }
102
+ if (this.mapService.setCoordCenter) {
103
+ this.mapService.setCoordCenter(layer.coordCenter);
104
+ }
105
+ }
106
+ generateUBO(u_Mvp, sceneCenterMercator, width, height) {
78
107
  const u_ProjectionMatrix = this.cameraService.getProjectionMatrix();
79
108
  const u_ViewMatrix = this.cameraService.getViewMatrix();
80
109
  const u_ViewProjectionMatrix = this.cameraService.getViewProjectionMatrix();
@@ -134,6 +163,9 @@ export default class ShaderUniformPlugin {
134
163
  [CoordinateUniform.PixelsPerDegree]: u_PixelsPerDegree,
135
164
  [CoordinateUniform.PixelsPerDegree2]: u_PixelsPerDegree2,
136
165
  [CoordinateUniform.PixelsPerMeter]: u_PixelsPerMeter,
166
+ // 坐标系是高德2.0的时候单独计算
167
+ [CoordinateUniform.Mvp]: u_Mvp,
168
+ u_sceneCenterMercator: sceneCenterMercator,
137
169
  // 其他参数,例如视口大小、DPR 等
138
170
  u_ViewportSize: u_ViewportSize,
139
171
  u_ModelMatrix,
@@ -7,20 +7,6 @@ export declare function PointTriangulation(feature: IEncodeFeature): {
7
7
  size: number;
8
8
  };
9
9
  export default class SimplePointModel extends BaseModel {
10
- protected get attributeLocation(): {
11
- readonly POSITION: 0;
12
- readonly POSITION_64LOW: 1;
13
- readonly COLOR: 2;
14
- readonly PICKING_COLOR: 3;
15
- readonly STROKE: 4;
16
- readonly OPACITY: 5;
17
- readonly OFFSETS: 6;
18
- readonly ROTATION: 7;
19
- readonly MAX: 8;
20
- } & Record<string, number> & {
21
- MAX: 8;
22
- SIZE: number;
23
- };
24
10
  getDefaultStyle(): Partial<IPointLayerStyleOptions>;
25
11
  protected getCommonUniformsInfo(): {
26
12
  uniformsArray: number[];
@@ -2,10 +2,11 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
2
  import { AttributeType, gl } from '@antv/l7-core';
3
3
  import BaseModel from "../../core/BaseModel";
4
4
  import { rgb2arr } from '@antv/l7-utils';
5
+ import { ShaderLocation } from "../../core/CommonStyleAttribute";
5
6
  /* babel-plugin-inline-import '../shaders/billboard/billboard_point_frag.glsl' */
6
7
  const simplePointFrag = "\nlayout(std140) uniform commonUniorm {\n vec4 u_stroke_color;\n float u_additive;\n float u_stroke_opacity;\n float u_stroke_width;\n};\n\nin vec4 v_color;\nin float v_blur;\nin float v_innerRadius;\n\nout vec4 outputColor;\n\n#pragma include \"picking\"\nvoid main() {\n vec2 center = vec2(0.5);\n\n // Tip: \u7247\u5143\u5230\u4E2D\u5FC3\u70B9\u7684\u8DDD\u79BB 0 - 1\n float fragmengTocenter = distance(center, gl_PointCoord) * 2.0;\n // Tip: \u7247\u5143\u7684\u526A\u5207\u6210\u5706\u5F62\n float circleClipOpacity = 1.0 - smoothstep(v_blur, 1.0, fragmengTocenter);\n\n\n if(v_innerRadius < 0.99) {\n // \u5F53\u5B58\u5728 stroke \u4E14 stroke > 0.01\n float blurWidth = (1.0 - v_blur)/2.0;\n vec4 stroke = vec4(u_stroke_color.rgb, u_stroke_opacity);\n if(fragmengTocenter > v_innerRadius + blurWidth) {\n outputColor = stroke;\n } else if(fragmengTocenter > v_innerRadius - blurWidth){\n float mixR = (fragmengTocenter - (v_innerRadius - blurWidth)) / (blurWidth * 2.0);\n outputColor = mix(v_color, stroke, mixR);\n } else {\n outputColor = v_color;\n }\n } else {\n // \u5F53\u4E0D\u5B58\u5728 stroke \u6216 stroke <= 0.01\n outputColor = v_color;\n }\n\n outputColor = filterColor(outputColor);\n \n if(u_additive > 0.0) {\n outputColor *= circleClipOpacity;\n } else {\n outputColor.a *= circleClipOpacity;\n }\n\n}\n";
7
8
  /* babel-plugin-inline-import '../shaders/billboard/billboard_point_vert.glsl' */
8
- const simplePointVert = "\nlayout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_POSITION_64LOW) in vec2 a_Position64Low;\nlayout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;\nlayout(location = ATTRIBUTE_LOCATION_SIZE) in float a_Size;\n\nlayout(std140) uniform commonUniorm {\n vec4 u_stroke_color;\n float u_additive;\n float u_stroke_opacity;\n float u_stroke_width;\n};\n\nout vec4 v_color;\nout float v_blur;\nout float v_innerRadius;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n#pragma include \"project\"\nvoid main() {\n v_color = vec4(a_Color.xyz, a_Color.w * opacity);\n v_blur = 1.0 - max(2.0 / a_Size, 0.05);\n v_innerRadius = max((a_Size - u_stroke_width) / a_Size, 0.0);\n\n vec2 offset = project_pixel(u_offsets);\n\n vec4 project_pos = project_position(vec4(a_Position, 1.0), a_Position64Low);\n gl_Position = project_common_position_to_clipspace(vec4(vec2(project_pos.xy+offset),project_pos.z,project_pos.w));\n\n gl_PointSize = a_Size * 2.0 * u_DevicePixelRatio;\n setPickingColor(a_PickingColor);\n}\n";
9
+ const simplePointVert = "\nlayout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in float a_Size;\n\nlayout(std140) uniform commonUniorm {\n vec4 u_stroke_color;\n float u_additive;\n float u_stroke_opacity;\n float u_stroke_width;\n};\n\nout vec4 v_color;\nout float v_blur;\nout float v_innerRadius;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n#pragma include \"project\"\nvoid main() {\n v_color = vec4(a_Color.xyz, a_Color.w * opacity);\n v_blur = 1.0 - max(2.0/a_Size, 0.05);\n v_innerRadius = max((a_Size - u_stroke_width) / a_Size, 0.0);\n \n vec2 offset = project_pixel(u_offsets);\n \n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * vec4(a_Position.xy + offset, a_Position.z, 1.0);\n } else { // else\n vec4 project_pos = project_position(vec4(a_Position, 1.0)) + vec4(a_Size / 2.,-a_Size /2.,0.,0.);\n gl_Position = project_common_position_to_clipspace(vec4(vec2(project_pos.xy+offset),project_pos.z,project_pos.w));\n }\n \n gl_PointSize = a_Size * 2.0 * u_DevicePixelRatio;\n setPickingColor(a_PickingColor);\n}\n";
9
10
  export function PointTriangulation(feature) {
10
11
  const coordinates = feature.coordinates;
11
12
  return {
@@ -15,12 +16,6 @@ export function PointTriangulation(feature) {
15
16
  };
16
17
  }
17
18
  export default class SimplePointModel extends BaseModel {
18
- get attributeLocation() {
19
- return Object.assign(super.attributeLocation, {
20
- MAX: super.attributeLocation.MAX,
21
- SIZE: 9
22
- });
23
- }
24
19
  getDefaultStyle() {
25
20
  return {
26
21
  blend: 'additive'
@@ -57,7 +52,6 @@ export default class SimplePointModel extends BaseModel {
57
52
  moduleName: 'pointSimple',
58
53
  vertexShader: simplePointVert,
59
54
  fragmentShader: simplePointFrag,
60
- defines: _this2.getDefines(),
61
55
  inject: _this2.getInject(),
62
56
  triangulation: PointTriangulation,
63
57
  depth: {
@@ -69,14 +63,12 @@ export default class SimplePointModel extends BaseModel {
69
63
  })();
70
64
  }
71
65
  registerBuiltinAttributes() {
72
- // 注册 Position 属性 64 位地位部分,经纬度数据开启双精度,避免大于 22 层级以上出现数据偏移
73
- this.registerPosition64LowAttribute();
74
66
  this.styleAttributeService.registerStyleAttribute({
75
67
  name: 'size',
76
68
  type: AttributeType.Attribute,
77
69
  descriptor: {
78
70
  name: 'a_Size',
79
- shaderLocation: this.attributeLocation.SIZE,
71
+ shaderLocation: ShaderLocation.SIZE,
80
72
  buffer: {
81
73
  usage: gl.DYNAMIC_DRAW,
82
74
  data: [],