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

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 (279) hide show
  1. package/es/citybuliding/models/build.d.ts +16 -0
  2. package/es/citybuliding/models/build.js +18 -20
  3. package/es/citybuliding/shaders/build_frag.glsl +6 -6
  4. package/es/citybuliding/shaders/build_vert.glsl +8 -14
  5. package/es/core/BaseLayer.js +9 -8
  6. package/es/core/BaseModel.d.ts +15 -2
  7. package/es/core/BaseModel.js +94 -62
  8. package/es/core/CommonStyleAttribute.d.ts +14 -18
  9. package/es/core/CommonStyleAttribute.js +23 -67
  10. package/es/core/triangulation.js +13 -39
  11. package/es/earth/models/atmosphere.d.ts +15 -0
  12. package/es/earth/models/atmosphere.js +30 -24
  13. package/es/earth/models/base.d.ts +15 -0
  14. package/es/earth/models/base.js +30 -24
  15. package/es/earth/models/bloomsphere.d.ts +15 -0
  16. package/es/earth/models/bloomsphere.js +30 -24
  17. package/es/earth/shaders/atmosphere/atmosphere_vert.glsl +7 -5
  18. package/es/earth/shaders/base/base_vert.glsl +3 -3
  19. package/es/earth/shaders/bloomshpere/bloomsphere_vert.glsl +5 -4
  20. package/es/geometry/models/billboard.d.ts +15 -0
  21. package/es/geometry/models/billboard.js +14 -8
  22. package/es/geometry/models/plane.d.ts +14 -0
  23. package/es/geometry/models/plane.js +10 -10
  24. package/es/geometry/models/sprite.js +3 -9
  25. package/es/geometry/shaders/billboard_vert.glsl +28 -25
  26. package/es/geometry/shaders/plane_vert.glsl +6 -6
  27. package/es/geometry/shaders/sprite_vert.glsl +7 -9
  28. package/es/heatmap/models/grid.d.ts +14 -0
  29. package/es/heatmap/models/grid.js +10 -3
  30. package/es/heatmap/models/grid3d.d.ts +16 -0
  31. package/es/heatmap/models/grid3d.js +14 -6
  32. package/es/heatmap/models/heatmap.d.ts +20 -1
  33. package/es/heatmap/models/heatmap.js +96 -83
  34. package/es/heatmap/models/hexagon.d.ts +14 -0
  35. package/es/heatmap/models/hexagon.js +9 -3
  36. package/es/heatmap/shaders/grid/grid_vert.glsl +30 -42
  37. package/es/heatmap/shaders/grid3d/grid_3d_vert.glsl +14 -26
  38. package/es/heatmap/shaders/heatmap/heatmap_3d_vert.glsl +19 -16
  39. package/es/heatmap/shaders/heatmap/heatmap_framebuffer_vert.glsl +16 -22
  40. package/es/heatmap/shaders/heatmap/heatmap_vert.glsl +3 -4
  41. package/es/heatmap/shaders/hexagon/hexagon_vert.glsl +13 -23
  42. package/es/image/models/image.d.ts +14 -0
  43. package/es/image/models/image.js +11 -3
  44. package/es/image/shaders/image_vert.glsl +7 -6
  45. package/es/line/models/arc.d.ts +18 -0
  46. package/es/line/models/arc.js +57 -8
  47. package/es/line/models/arc_3d.d.ts +18 -0
  48. package/es/line/models/arc_3d.js +55 -7
  49. package/es/line/models/flow.d.ts +17 -0
  50. package/es/line/models/flow.js +35 -7
  51. package/es/line/models/great_circle.d.ts +17 -0
  52. package/es/line/models/great_circle.js +34 -6
  53. package/es/line/models/line.d.ts +17 -0
  54. package/es/line/models/line.js +17 -8
  55. package/es/line/models/simple_line.d.ts +14 -0
  56. package/es/line/models/simple_line.js +12 -47
  57. package/es/line/models/wall.d.ts +17 -0
  58. package/es/line/models/wall.js +22 -48
  59. package/es/line/shaders/arc/line_arc_vert.glsl +42 -48
  60. package/es/line/shaders/arc3d/line_arc_3d_vert.glsl +15 -20
  61. package/es/line/shaders/flow/flow_line_vert.glsl +30 -48
  62. package/es/line/shaders/greatCircle/line_arc_great_circle_vert.glsl +56 -72
  63. package/es/line/shaders/line/line_vert.glsl +31 -48
  64. package/es/line/shaders/simple/simpleline_vert.glsl +18 -23
  65. package/es/line/shaders/wall/wall_vert.glsl +36 -45
  66. package/es/mask/models/fill.js +2 -1
  67. package/es/mask/shaders/mask_vert.glsl +2 -7
  68. package/es/plugins/DataMappingPlugin.d.ts +0 -1
  69. package/es/plugins/DataMappingPlugin.js +1 -24
  70. package/es/plugins/PixelPickingPlugin.js +2 -2
  71. package/es/plugins/RegisterStyleAttributePlugin.d.ts +0 -1
  72. package/es/plugins/RegisterStyleAttributePlugin.js +3 -25
  73. package/es/plugins/ShaderUniformPlugin.d.ts +0 -5
  74. package/es/plugins/ShaderUniformPlugin.js +2 -34
  75. package/es/point/models/billboard_point.d.ts +14 -0
  76. package/es/point/models/billboard_point.js +11 -3
  77. package/es/point/models/earthExtrude.d.ts +16 -0
  78. package/es/point/models/earthExtrude.js +15 -8
  79. package/es/point/models/earthFill.d.ts +16 -0
  80. package/es/point/models/earthFill.js +13 -5
  81. package/es/point/models/extrude.d.ts +16 -0
  82. package/es/point/models/extrude.js +19 -12
  83. package/es/point/models/fill.d.ts +16 -0
  84. package/es/point/models/fill.js +16 -5
  85. package/es/point/models/fillImage.d.ts +16 -0
  86. package/es/point/models/fillImage.js +16 -16
  87. package/es/point/models/image.d.ts +15 -0
  88. package/es/point/models/image.js +14 -4
  89. package/es/point/models/normal.d.ts +14 -0
  90. package/es/point/models/normal.js +11 -3
  91. package/es/point/models/radar.d.ts +15 -0
  92. package/es/point/models/radar.js +13 -4
  93. package/es/point/models/text.d.ts +16 -0
  94. package/es/point/models/text.js +18 -11
  95. package/es/point/shaders/billboard/billboard_point_vert.glsl +10 -13
  96. package/es/point/shaders/earthExtrude/earthExtrude_vert.glsl +15 -25
  97. package/es/point/shaders/earthFill/earthFill_vert.glsl +6 -6
  98. package/es/point/shaders/extrude/extrude_vert.glsl +35 -39
  99. package/es/point/shaders/fill/fill_vert.glsl +12 -14
  100. package/es/point/shaders/fillImage/fillImage_vert.glsl +16 -28
  101. package/es/point/shaders/image/image_vert.glsl +15 -12
  102. package/es/point/shaders/normal/normal_vert.glsl +7 -10
  103. package/es/point/shaders/radar/radar_vert.glsl +11 -11
  104. package/es/point/shaders/text/text_vert.glsl +10 -9
  105. package/es/polygon/models/extrude.d.ts +16 -0
  106. package/es/polygon/models/extrude.js +26 -26
  107. package/es/polygon/models/extrusion.d.ts +16 -0
  108. package/es/polygon/models/extrusion.js +34 -4
  109. package/es/polygon/models/fill.d.ts +14 -0
  110. package/es/polygon/models/fill.js +12 -4
  111. package/es/polygon/models/ocean.d.ts +14 -0
  112. package/es/polygon/models/ocean.js +11 -6
  113. package/es/polygon/models/water.d.ts +14 -0
  114. package/es/polygon/models/water.js +11 -6
  115. package/es/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +17 -15
  116. package/es/polygon/shaders/extrude/polygon_extrude_vert.glsl +22 -20
  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 +7 -6
  120. package/es/polygon/shaders/fill/fill_vert.glsl +10 -12
  121. package/es/polygon/shaders/ocean/ocean_vert.glsl +3 -4
  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 +14 -0
  126. package/es/raster/models/raster.js +12 -3
  127. package/es/raster/models/rasterRgb.d.ts +14 -0
  128. package/es/raster/models/rasterRgb.js +12 -3
  129. package/es/raster/models/rasterTerrainRgb.d.ts +14 -0
  130. package/es/raster/models/rasterTerrainRgb.js +11 -3
  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 +0 -16
  135. package/es/utils/extrude_polyline.d.ts +0 -15
  136. package/es/utils/extrude_polyline.js +0 -217
  137. package/es/wind/models/wind.d.ts +14 -0
  138. package/es/wind/models/wind.js +9 -1
  139. package/es/wind/shaders/wind_vert.glsl +6 -5
  140. package/lib/citybuliding/models/build.d.ts +16 -0
  141. package/lib/citybuliding/models/build.js +18 -20
  142. package/lib/citybuliding/shaders/build_frag.glsl +6 -6
  143. package/lib/citybuliding/shaders/build_vert.glsl +8 -14
  144. package/lib/core/BaseLayer.js +9 -8
  145. package/lib/core/BaseModel.d.ts +15 -2
  146. package/lib/core/BaseModel.js +92 -60
  147. package/lib/core/CommonStyleAttribute.d.ts +14 -18
  148. package/lib/core/CommonStyleAttribute.js +23 -68
  149. package/lib/core/triangulation.js +13 -39
  150. package/lib/earth/models/atmosphere.d.ts +15 -0
  151. package/lib/earth/models/atmosphere.js +30 -24
  152. package/lib/earth/models/base.d.ts +15 -0
  153. package/lib/earth/models/base.js +30 -24
  154. package/lib/earth/models/bloomsphere.d.ts +15 -0
  155. package/lib/earth/models/bloomsphere.js +30 -24
  156. package/lib/earth/shaders/atmosphere/atmosphere_vert.glsl +7 -5
  157. package/lib/earth/shaders/base/base_vert.glsl +3 -3
  158. package/lib/earth/shaders/bloomshpere/bloomsphere_vert.glsl +5 -4
  159. package/lib/geometry/models/billboard.d.ts +15 -0
  160. package/lib/geometry/models/billboard.js +14 -8
  161. package/lib/geometry/models/plane.d.ts +14 -0
  162. package/lib/geometry/models/plane.js +10 -10
  163. package/lib/geometry/models/sprite.js +3 -9
  164. package/lib/geometry/shaders/billboard_vert.glsl +28 -25
  165. package/lib/geometry/shaders/plane_vert.glsl +6 -6
  166. package/lib/geometry/shaders/sprite_vert.glsl +7 -9
  167. package/lib/heatmap/models/grid.d.ts +14 -0
  168. package/lib/heatmap/models/grid.js +10 -3
  169. package/lib/heatmap/models/grid3d.d.ts +16 -0
  170. package/lib/heatmap/models/grid3d.js +14 -6
  171. package/lib/heatmap/models/heatmap.d.ts +20 -1
  172. package/lib/heatmap/models/heatmap.js +95 -82
  173. package/lib/heatmap/models/hexagon.d.ts +14 -0
  174. package/lib/heatmap/models/hexagon.js +9 -3
  175. package/lib/heatmap/shaders/grid/grid_vert.glsl +30 -42
  176. package/lib/heatmap/shaders/grid3d/grid_3d_vert.glsl +14 -26
  177. package/lib/heatmap/shaders/heatmap/heatmap_3d_vert.glsl +19 -16
  178. package/lib/heatmap/shaders/heatmap/heatmap_framebuffer_vert.glsl +16 -22
  179. package/lib/heatmap/shaders/heatmap/heatmap_vert.glsl +3 -4
  180. package/lib/heatmap/shaders/hexagon/hexagon_vert.glsl +13 -23
  181. package/lib/image/models/image.d.ts +14 -0
  182. package/lib/image/models/image.js +11 -3
  183. package/lib/image/shaders/image_vert.glsl +7 -6
  184. package/lib/line/models/arc.d.ts +18 -0
  185. package/lib/line/models/arc.js +56 -7
  186. package/lib/line/models/arc_3d.d.ts +18 -0
  187. package/lib/line/models/arc_3d.js +55 -7
  188. package/lib/line/models/flow.d.ts +17 -0
  189. package/lib/line/models/flow.js +35 -7
  190. package/lib/line/models/great_circle.d.ts +17 -0
  191. package/lib/line/models/great_circle.js +33 -5
  192. package/lib/line/models/line.d.ts +17 -0
  193. package/lib/line/models/line.js +17 -8
  194. package/lib/line/models/simple_line.d.ts +14 -0
  195. package/lib/line/models/simple_line.js +12 -47
  196. package/lib/line/models/wall.d.ts +17 -0
  197. package/lib/line/models/wall.js +22 -48
  198. package/lib/line/shaders/arc/line_arc_vert.glsl +42 -48
  199. package/lib/line/shaders/arc3d/line_arc_3d_vert.glsl +15 -20
  200. package/lib/line/shaders/flow/flow_line_vert.glsl +30 -48
  201. package/lib/line/shaders/greatCircle/line_arc_great_circle_vert.glsl +56 -72
  202. package/lib/line/shaders/line/line_vert.glsl +31 -48
  203. package/lib/line/shaders/simple/simpleline_vert.glsl +18 -23
  204. package/lib/line/shaders/wall/wall_vert.glsl +36 -45
  205. package/lib/mask/models/fill.js +2 -1
  206. package/lib/mask/shaders/mask_vert.glsl +2 -7
  207. package/lib/plugins/DataMappingPlugin.d.ts +0 -1
  208. package/lib/plugins/DataMappingPlugin.js +0 -23
  209. package/lib/plugins/PixelPickingPlugin.js +1 -1
  210. package/lib/plugins/RegisterStyleAttributePlugin.d.ts +0 -1
  211. package/lib/plugins/RegisterStyleAttributePlugin.js +2 -24
  212. package/lib/plugins/ShaderUniformPlugin.d.ts +0 -5
  213. package/lib/plugins/ShaderUniformPlugin.js +2 -34
  214. package/lib/point/models/billboard_point.d.ts +14 -0
  215. package/lib/point/models/billboard_point.js +11 -3
  216. package/lib/point/models/earthExtrude.d.ts +16 -0
  217. package/lib/point/models/earthExtrude.js +14 -7
  218. package/lib/point/models/earthFill.d.ts +16 -0
  219. package/lib/point/models/earthFill.js +13 -5
  220. package/lib/point/models/extrude.d.ts +16 -0
  221. package/lib/point/models/extrude.js +18 -11
  222. package/lib/point/models/fill.d.ts +16 -0
  223. package/lib/point/models/fill.js +16 -5
  224. package/lib/point/models/fillImage.d.ts +16 -0
  225. package/lib/point/models/fillImage.js +16 -16
  226. package/lib/point/models/image.d.ts +15 -0
  227. package/lib/point/models/image.js +14 -4
  228. package/lib/point/models/normal.d.ts +14 -0
  229. package/lib/point/models/normal.js +11 -3
  230. package/lib/point/models/radar.d.ts +15 -0
  231. package/lib/point/models/radar.js +13 -4
  232. package/lib/point/models/text.d.ts +16 -0
  233. package/lib/point/models/text.js +18 -11
  234. package/lib/point/shaders/billboard/billboard_point_vert.glsl +10 -13
  235. package/lib/point/shaders/earthExtrude/earthExtrude_vert.glsl +15 -25
  236. package/lib/point/shaders/earthFill/earthFill_vert.glsl +6 -6
  237. package/lib/point/shaders/extrude/extrude_vert.glsl +35 -39
  238. package/lib/point/shaders/fill/fill_vert.glsl +12 -14
  239. package/lib/point/shaders/fillImage/fillImage_vert.glsl +16 -28
  240. package/lib/point/shaders/image/image_vert.glsl +15 -12
  241. package/lib/point/shaders/normal/normal_vert.glsl +7 -10
  242. package/lib/point/shaders/radar/radar_vert.glsl +11 -11
  243. package/lib/point/shaders/text/text_vert.glsl +10 -9
  244. package/lib/polygon/models/extrude.d.ts +16 -0
  245. package/lib/polygon/models/extrude.js +25 -25
  246. package/lib/polygon/models/extrusion.d.ts +16 -0
  247. package/lib/polygon/models/extrusion.js +34 -4
  248. package/lib/polygon/models/fill.d.ts +14 -0
  249. package/lib/polygon/models/fill.js +12 -4
  250. package/lib/polygon/models/ocean.d.ts +14 -0
  251. package/lib/polygon/models/ocean.js +11 -6
  252. package/lib/polygon/models/water.d.ts +14 -0
  253. package/lib/polygon/models/water.js +11 -6
  254. package/lib/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +17 -15
  255. package/lib/polygon/shaders/extrude/polygon_extrude_vert.glsl +22 -20
  256. package/lib/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +17 -17
  257. package/lib/polygon/shaders/extrusion/polygon_extrusion_vert.glsl +8 -8
  258. package/lib/polygon/shaders/fill/fill_linear_vert.glsl +7 -6
  259. package/lib/polygon/shaders/fill/fill_vert.glsl +10 -12
  260. package/lib/polygon/shaders/ocean/ocean_vert.glsl +3 -4
  261. package/lib/polygon/shaders/water/polygon_water_vert.glsl +5 -5
  262. package/lib/raster/index.d.ts +1 -1
  263. package/lib/raster/index.js +2 -2
  264. package/lib/raster/models/raster.d.ts +14 -0
  265. package/lib/raster/models/raster.js +12 -3
  266. package/lib/raster/models/rasterRgb.d.ts +14 -0
  267. package/lib/raster/models/rasterRgb.js +12 -3
  268. package/lib/raster/models/rasterTerrainRgb.d.ts +14 -0
  269. package/lib/raster/models/rasterTerrainRgb.js +11 -3
  270. package/lib/raster/shaders/raster/raster_2d_vert.glsl +6 -6
  271. package/lib/raster/shaders/rgb/raster_rgb_vert.glsl +11 -11
  272. package/lib/raster/shaders/terrain/terrain_rgb_vert.glsl +11 -11
  273. package/lib/tile/core/BaseLayer.js +0 -16
  274. package/lib/utils/extrude_polyline.d.ts +0 -15
  275. package/lib/utils/extrude_polyline.js +0 -217
  276. package/lib/wind/models/wind.d.ts +14 -0
  277. package/lib/wind/models/wind.js +9 -1
  278. package/lib/wind/shaders/wind_vert.glsl +6 -5
  279. package/package.json +6 -6
@@ -1,8 +1,9 @@
1
- layout(location = 0) in vec3 a_Position;
2
- layout(location = 1) in vec4 a_Color;
3
- layout(location = 9) in float a_Size;
4
- layout(location = 10) in float a_Shape;
5
- layout(location = 11) in vec3 a_Extrude;
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 float a_Size;
5
+ layout(location = ATTRIBUTE_LOCATION_SHAPE) in float a_Shape;
6
+ layout(location = ATTRIBUTE_LOCATION_EXTRUDE) in vec3 a_Extrude;
6
7
 
7
8
  layout(std140) uniform commonUniforms {
8
9
  vec3 u_blur_height_fixed;
@@ -11,7 +12,7 @@ layout(std140) uniform commonUniforms {
11
12
  float u_stroke_opacity;
12
13
  float u_size_unit;
13
14
  float u_time;
14
- vec4 u_animate;
15
+ vec4 u_animate;
15
16
  };
16
17
 
17
18
  out vec4 v_color;
@@ -25,7 +26,7 @@ out float v_radius;
25
26
 
26
27
  void main() {
27
28
  // 透明度计算
28
- v_stroke = stroke;
29
+ v_stroke = stroke;
29
30
  vec3 extrude = a_Extrude;
30
31
  float shape_type = a_Shape;
31
32
  /*
@@ -51,17 +52,14 @@ void main() {
51
52
  float antialiasblur = -max(2.0 / u_DevicePixelRatio / newSize, u_blur_height_fixed.x);
52
53
 
53
54
  vec2 offset = (extrude.xy * (newSize + u_stroke_width) + u_offsets);
54
- vec3 aPosition = a_Position;
55
55
 
56
56
  offset = project_pixel(offset);
57
57
  offset = rotate_matrix(offset,rotation);
58
-
58
+
59
59
  // TODP: /abs(extrude.x) 是为了兼容地球模式
60
60
  v_data = vec4(extrude.x/abs(extrude.x), extrude.y/abs(extrude.y), antialiasblur,shape_type);
61
61
 
62
-
63
- // vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0));
64
- vec4 project_pos = project_position(vec4(aPosition.xy, 0.0, 1.0));
62
+ vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0), a_Position64Low);
65
63
  // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, project_pixel(setPickingOrder(0.0)), 1.0));
66
64
 
67
65
  float raisingHeight = u_blur_height_fixed.y;
@@ -74,8 +72,8 @@ void main() {
74
72
  raisingHeight = u_blur_height_fixed.y * mapboxZoomScale;
75
73
  }
76
74
  }
77
-
78
- gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xy + offset, raisingHeight, 1.0));
75
+
76
+ gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, raisingHeight, 1.0));
79
77
 
80
78
  setPickingColor(a_PickingColor);
81
79
  }
@@ -1,13 +1,14 @@
1
- layout(location = 0) in vec3 a_Position;
2
- layout(location = 1) in vec4 a_Color;
3
- layout(location = 9) in float a_Size;
4
- layout(location = 11) in vec3 a_Extrude;
5
- layout(location = 14) in vec2 a_Uv;
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 float a_Size;
5
+ layout(location = ATTRIBUTE_LOCATION_EXTRUDE) in vec3 a_Extrude;
6
+ layout(location = ATTRIBUTE_LOCATION_UV) in vec2 a_Uv;
6
7
 
7
8
  layout(std140) uniform commonUniform {
8
9
  vec2 u_textSize;
9
- float u_heightfixed: 0.0;
10
- float u_raisingHeight: 0.0;
10
+ float u_heightfixed;
11
+ float u_raisingHeight;
11
12
  float u_size_unit;
12
13
  };
13
14
 
@@ -15,43 +16,30 @@ out vec2 v_uv;
15
16
  out vec2 v_Iconuv;
16
17
  out float v_opacity;
17
18
 
18
-
19
19
  #pragma include "projection"
20
20
  #pragma include "picking"
21
21
  #pragma include "rotation_2d"
22
22
 
23
23
  void main() {
24
24
  vec3 extrude = a_Extrude;
25
- v_uv = (a_Extrude.xy + 1.0)/2.0;
25
+ v_uv = (a_Extrude.xy + 1.0) / 2.0;
26
26
  v_uv.y = 1.0 - v_uv.y;
27
27
  v_Iconuv = a_Uv;
28
28
  v_opacity = opacity;
29
29
  float newSize = a_Size;
30
- if(u_size_unit == 1.0) {
31
- newSize = newSize * u_PixelsPerMeter.z;
30
+ if (u_size_unit == 1.0) {
31
+ newSize = newSize * u_PixelsPerMeter.z;
32
32
  }
33
-
34
- // vec2 offset = (u_RotateMatrix * extrude.xy * (a_Size) + textrueOffsets);
35
- vec2 offset = (extrude.xy * (newSize) + offsets);
36
33
 
37
- offset = rotate_matrix(offset,rotation);
34
+ // vec2 offset = (u_RotateMatrix * extrude.xy * (a_Size) + textrueOffsets);
35
+ vec2 offset = extrude.xy * newSize + offsets;
38
36
 
39
- vec3 aPosition = a_Position;
37
+ offset = rotate_matrix(offset, rotation);
40
38
 
41
39
  offset = project_pixel(offset);
42
40
 
43
- vec4 project_pos = project_position(vec4(aPosition.xy, 0.0, 1.0));
44
- float raisingHeight = u_raisingHeight;
45
- if(u_heightfixed < 1.0) { // height fixed
46
- raisingHeight = project_pixel(u_raisingHeight);
47
- } else {
48
- if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {
49
- float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);
50
- raisingHeight = u_raisingHeight * mapboxZoomScale;
51
- }
52
- }
53
-
54
- gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xy + offset, 0.0, 1.0));
41
+ vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0), a_Position64Low);
42
+ gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));
55
43
 
56
44
  setPickingColor(a_PickingColor);
57
45
  }
@@ -1,7 +1,8 @@
1
- layout(location = 0) in vec3 a_Position;
2
- layout(location = 1) in vec4 a_Color;
3
- layout(location = 9) in float a_Size;
4
- layout(location = 14) in vec2 a_Uv;
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 float a_Size;
5
+ layout(location = ATTRIBUTE_LOCATION_UV) in vec2 a_Uv;
5
6
 
6
7
  layout(std140) uniform commonUniforms {
7
8
  vec2 u_textSize;
@@ -17,27 +18,29 @@ out float v_opacity;
17
18
  #pragma include "picking"
18
19
 
19
20
  void main() {
20
-
21
21
  // cal style mapping - 数据纹理映射部分的计算
22
22
  v_color = a_Color;
23
23
  v_opacity = opacity;
24
24
  v_uv = a_Uv;
25
- vec4 project_pos = project_position(vec4(a_Position, 1.0));
26
-
25
+ vec4 project_pos = project_position(vec4(a_Position, 1.0), a_Position64Low);
26
+
27
27
  vec2 offset = project_pixel(offsets);
28
28
 
29
29
  float raisingHeight = u_raisingHeight;
30
- if(u_heightfixed < 1.0) { // false
30
+ if (u_heightfixed < 1.0) {
31
+ // false
31
32
  raisingHeight = project_pixel(u_raisingHeight);
32
33
  } else {
33
- if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {
34
- float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);
34
+ if (
35
+ u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT ||
36
+ u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET
37
+ ) {
38
+ float mapboxZoomScale = 4.0 / pow(2.0, 21.0 - u_Zoom);
35
39
  raisingHeight = u_raisingHeight * mapboxZoomScale;
36
40
  }
37
41
  }
38
42
 
39
-
40
- gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xy + offset, raisingHeight, 1.0));
43
+ gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, raisingHeight, 1.0));
41
44
 
42
45
  gl_PointSize = a_Size * 2.0 * u_DevicePixelRatio;
43
46
  setPickingColor(a_PickingColor);
@@ -1,6 +1,7 @@
1
- layout(location = 0) in vec3 a_Position;
2
- layout(location = 1) in vec4 a_Color;
3
- layout(location = 9) in float a_Size;
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 float a_Size;
4
5
 
5
6
  layout(std140) uniform u_Common {
6
7
  float u_size_scale;
@@ -14,12 +15,8 @@ out vec4 v_color;
14
15
  void main() {
15
16
  v_color = vec4(a_Color.xyz, a_Color.w * opacity);
16
17
 
17
- if (u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
18
- gl_Position = u_Mvp * vec4(a_Position, 1.0);
19
- } else {
20
- vec4 project_pos = project_position(vec4(a_Position, 1.0)) + vec4(a_Size / 2., -a_Size /2., 0., 0.);
21
- gl_Position = project_common_position_to_clipspace(project_pos);
22
- }
18
+ vec4 project_pos = project_position(vec4(a_Position, 1.0), a_Position64Low);
19
+ gl_Position = project_common_position_to_clipspace(project_pos);
23
20
 
24
- gl_PointSize = a_Size * u_size_scale * 2.0 * u_DevicePixelRatio;
21
+ gl_PointSize = a_Size * u_size_scale * 2.0 * u_DevicePixelRatio;
25
22
  }
@@ -1,7 +1,8 @@
1
- layout(location = 0) in vec3 a_Position;
2
- layout(location = 1) in vec4 a_Color;
3
- layout(location = 9) in float a_Size;
4
- layout(location = 11) in vec3 a_Extrude;
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 float a_Size;
5
+ layout(location = ATTRIBUTE_LOCATION_EXTRUDE) in vec3 a_Extrude;
5
6
 
6
7
  layout(std140) uniform commonUniorm {
7
8
  float u_additive;
@@ -22,8 +23,8 @@ void main() {
22
23
  float newSize = setPickingSize(a_Size);
23
24
 
24
25
  float time = u_time * u_speed;
25
- mat2 rotateMatrix = mat2(
26
- cos(time), sin(time),
26
+ mat2 rotateMatrix = mat2(
27
+ cos(time), sin(time),
27
28
  -sin(time), cos(time)
28
29
  );
29
30
  v_extrude = rotateMatrix * a_Extrude.xy;
@@ -40,14 +41,13 @@ void main() {
40
41
  v_radius = newSize;
41
42
 
42
43
  vec2 offset = (a_Extrude.xy * (newSize));
43
- vec3 aPosition = a_Position;
44
-
44
+
45
45
  offset = project_pixel(offset);
46
-
46
+
47
47
  v_data = vec4(a_Extrude.x, a_Extrude.y, antialiasblur, -1.0);
48
48
 
49
- vec4 project_pos = project_position(vec4(aPosition.xy, 0.0, 1.0));
50
- gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xy + offset, project_pixel(setPickingOrder(0.0)), 1.0));
49
+ vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0), a_Position64Low);
50
+ gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, project_pixel(setPickingOrder(0.0)), 1.0));
51
51
 
52
52
  setPickingColor(a_PickingColor);
53
53
  }
@@ -2,11 +2,12 @@
2
2
  #define EDGE_GAMMA 0.105
3
3
  #define FONT_SIZE 24.0
4
4
 
5
- layout(location = 0) in vec3 a_Position;
6
- layout(location = 1) in vec4 a_Color;
7
- layout(location = 9) in float a_Size;
8
- layout(location = 10) in vec2 a_textOffsets;
9
- layout(location = 14) in vec2 a_tex;
5
+ layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;
6
+ layout(location = ATTRIBUTE_LOCATION_POSITION_64LOW) in vec2 a_Position64Low;
7
+ layout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;
8
+ layout(location = ATTRIBUTE_LOCATION_SIZE) in float a_Size;
9
+ layout(location = ATTRIBUTE_LOCATION_TEXT_OFFSETS) in vec2 a_textOffsets;
10
+ layout(location = ATTRIBUTE_LOCATION_UV) in vec2 a_tex;
10
11
 
11
12
  layout(std140) uniform commonUniforms {
12
13
  vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];
@@ -29,7 +30,7 @@ out float v_fontScale;
29
30
 
30
31
  void main() {
31
32
  // cal style mapping - 数据纹理映射部分的计算
32
-
33
+
33
34
  v_uv = a_tex / u_sdf_map_size;
34
35
 
35
36
 
@@ -41,11 +42,11 @@ void main() {
41
42
  float fontScale = a_Size / FONT_SIZE;
42
43
  v_fontScale = fontScale;
43
44
 
44
- vec4 project_pos = project_position(vec4(a_Position, 1.0));
45
+ vec4 project_pos = project_position(vec4(a_Position, 1.0), a_Position64Low);
45
46
  // vec4 projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));
46
47
 
47
48
  vec2 offset = rotate_matrix(a_textOffsets,rotation);
48
-
49
+
49
50
  // gl_Position = vec4(projected_position.xy / projected_position.w + rotation_matrix * a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);
50
51
 
51
52
  float raiseHeight = u_raisingHeight;
@@ -54,7 +55,7 @@ void main() {
54
55
  raiseHeight = u_raisingHeight * mapboxZoomScale;
55
56
  }
56
57
 
57
- vec4 projected_position = project_common_position_to_clipspace_v2(vec4(project_pos.xyz + vec3(0.0, 0.0, raiseHeight), 1.0));
58
+ vec4 projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz + vec3(0.0, 0.0, raiseHeight), 1.0));
58
59
 
59
60
  gl_Position = vec4(
60
61
  projected_position.xy / projected_position.w + offset * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);
@@ -1,6 +1,22 @@
1
1
  import type { IModel, ITexture2D } from '@antv/l7-core';
2
2
  import BaseModel from '../../core/BaseModel';
3
3
  export default class ExtrudeModel extends BaseModel {
4
+ protected get attributeLocation(): {
5
+ readonly POSITION: 0;
6
+ readonly POSITION_64LOW: 1;
7
+ readonly COLOR: 2;
8
+ readonly PICKING_COLOR: 3;
9
+ readonly STROKE: 4;
10
+ readonly OPACITY: 5;
11
+ readonly OFFSETS: 6;
12
+ readonly ROTATION: 7;
13
+ readonly MAX: 8;
14
+ } & Record<string, number> & {
15
+ MAX: 8;
16
+ SIZE: number;
17
+ NORMAL: number;
18
+ UV: number;
19
+ };
4
20
  protected texture: ITexture2D;
5
21
  getUninforms(): {
6
22
  [x: string]: any;
@@ -5,25 +5,32 @@ import { AttributeType, gl } from '@antv/l7-core';
5
5
  import { rgb2arr } from '@antv/l7-utils';
6
6
  import BaseModel from "../../core/BaseModel";
7
7
  import { PolygonExtrudeTriangulation } from "../../core/triangulation";
8
+ import { loadImage } from "../../utils/load-image";
8
9
  /* babel-plugin-inline-import '../shaders/extrude/polygon_extrude_frag.glsl' */
9
10
  const polygonExtrudeFrag = "layout(std140) uniform commonUniforms {\n vec4 u_sourceColor;\n vec4 u_targetColor;\n float u_linearColor;\n float u_topsurface;\n float u_sidesurface;\n float u_heightfixed; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\n float u_raisingHeight;\n};\n\nin vec4 v_Color;\n#pragma include \"scene_uniforms\"\n#pragma include \"picking\"\nout vec4 outputColor;\nvoid main() {\n\n // top face\n if(u_topsurface < 1.0) {\n discard;\n }\n\n outputColor = v_Color;\n \n outputColor = filterColor(outputColor);\n}\n";
10
- /* babel-plugin-inline-import '../shaders/extrude/polygon_extrude_vert.glsl' */
11
- const polygonExtrudeVert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in float a_Size;\nlayout(location = 13) in vec3 a_Normal;\nlayout(location = 14) in vec3 a_uvs;\n\nlayout(std140) uniform commonUniforms {\n vec4 u_sourceColor;\n vec4 u_targetColor;\n float u_linearColor;\n float u_topsurface;\n float u_sidesurface;\n float u_heightfixed; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\n float u_raisingHeight;\n};\n\nout vec4 v_Color;\n\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\nvoid main() {\n \nfloat isSide = a_Position.z;\n float topU = a_uvs[0];\n float topV = 1.0 - a_uvs[1];\n float sidey = a_uvs[2];\n\n vec4 pos = vec4(a_Position.xy, a_Position.z * a_Size, 1.0);\n float lightWeight = calc_lighting(pos);\n\n vec4 project_pos = project_position(pos);\n\n if(u_heightfixed > 0.0) { // \u5224\u65AD\u51E0\u4F55\u4F53\u662F\u5426\u56FA\u5B9A\u9AD8\u5EA6\n project_pos.z = a_Position.z * a_Size;\n project_pos.z += u_raisingHeight;\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n project_pos.z *= mapboxZoomScale;\n project_pos.z += u_raisingHeight * mapboxZoomScale;\n }\n }\n\n\n gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xyz, 1.0));\n\n // Tip: \u90E8\u5206\u673A\u578B GPU \u8BA1\u7B97\u7CBE\u5EA6\u517C\u5BB9\n if(isSide < 0.999) {\n // side face\n // if(u_sidesurface < 1.0) {\n // discard;\n // }\n\n if(u_linearColor == 1.0) {\n vec4 linearColor = mix(u_targetColor, u_sourceColor, sidey);\n linearColor.rgb *= lightWeight;\n v_Color = linearColor;\n } else {\n v_Color = a_Color;\n }\n\n } else {\n v_Color = a_Color;\n }\n\n v_Color = vec4(v_Color.rgb * lightWeight, v_Color.w * opacity);\n\n\n setPickingColor(a_PickingColor);\n}\n"; // extrude
12
- /* babel-plugin-inline-import '../shaders/extrude/polygon_extrudetex_frag.glsl' */
13
- const polygonExtrudeTexFrag = "uniform sampler2D u_texture;\n\nlayout(std140) uniform commonUniforms {\n vec4 u_sourceColor;\n vec4 u_targetColor;\n float u_linearColor;\n float u_topsurface;\n float u_sidesurface;\n float u_heightfixed; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\n float u_raisingHeight;\n};\n\nin vec4 v_Color;\nin vec3 v_uvs;\nin vec2 v_texture_data;\n\n#pragma include \"scene_uniforms\"\n#pragma include \"picking\"\n\nout vec4 outputColor;\n\nvoid main() {\n float opacity = u_opacity;\n float isSide = v_texture_data.x;\n float lightWeight = v_texture_data.y;\n float topU = v_uvs[0];\n float topV = 1.0 - v_uvs[1];\n float sidey = v_uvs[2];\n\n outputColor = texture(SAMPLER_2D(u_texture), vec2(topU, topV));\n // Tip: \u90E8\u5206\u673A\u578B GPU \u8BA1\u7B97\u7CBE\u5EA6\u517C\u5BB9\n if (isSide < 0.999) {// \u662F\u5426\u662F\u8FB9\u7F18\n // side face\n if (u_sidesurface < 1.0) {\n discard;\n }\n\n if (u_linearColor == 1.0) {\n vec4 linearColor = mix(u_targetColor, u_sourceColor, sidey);\n linearColor.rgb *= lightWeight;\n outputColor = linearColor;\n } else {\n outputColor = v_Color;\n }\n } else {\n // top face\n if (u_topsurface < 1.0) {\n discard;\n }\n }\n \n outputColor.a *= opacity;\n outputColor = filterColor(outputColor);\n}\n"; // texture
14
- /* babel-plugin-inline-import '../shaders/extrude/polygon_extrudetex_vert.glsl' */
15
- const polygonExtrudeTexVert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in float a_Size;\nlayout(location = 13) in vec3 a_Normal;\nlayout(location = 14) in vec3 a_uvs;\n\n\nlayout(std140) uniform commonUniforms {\n vec4 u_sourceColor;\n vec4 u_targetColor;\n float u_linearColor;\n float u_topsurface;\n float u_sidesurface;\n float u_heightfixed; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\n float u_raisingHeight;\n};\n\nout vec4 v_Color;\nout vec3 v_uvs;\nout vec2 v_texture_data;\n\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\nvoid main() {\n \n vec4 pos = vec4(a_Position.xy, a_Position.z * a_Size, 1.0);\n float lightWeight = calc_lighting(pos);\n vec4 project_pos = project_position(pos);\n v_uvs = a_uvs;\n v_Color = a_Color;\n v_Color.a *= opacity;\n \n v_texture_data = vec2(a_Position.z, lightWeight);\n\n if(u_heightfixed > 0.0) { // \u5224\u65AD\u51E0\u4F55\u4F53\u662F\u5426\u56FA\u5B9A\u9AD8\u5EA6\n project_pos.z = a_Position.z * a_Size;\n project_pos.z += u_raisingHeight;\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n project_pos.z *= mapboxZoomScale;\n project_pos.z += u_raisingHeight * mapboxZoomScale;\n }\n }\n\n\n gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xyz, 1.0));\n\n\n\n setPickingColor(a_PickingColor);\n}\n"; // extrude picking
16
- import { ShaderLocation } from "../../core/CommonStyleAttribute";
17
- import { loadImage } from "../../utils/load-image";
18
11
  /* babel-plugin-inline-import '../shaders/extrude/polygon_extrude_picklight_frag.glsl' */
19
12
  const polygonExtrudePickLightFrag = "\nlayout(std140) uniform commonUniforms {\n vec4 u_sourceColor;\n vec4 u_targetColor;\n float u_linearColor;\n float u_topsurface;\n float u_sidesurface;\n float u_heightfixed; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\n float u_raisingHeight;\n};\n\nin vec4 v_Color;\nin vec3 v_uvs;\nin vec2 v_texture_data;\nout vec4 outputColor;\n\n#pragma include \"scene_uniforms\"\n#pragma include \"picking\"\n\nvoid main() {\n float isSide = v_texture_data.x;\n float sidey = v_uvs[2];\n float lightWeight = v_texture_data.y;\n\n // Tip: \u90E8\u5206\u673A\u578B GPU \u8BA1\u7B97\u7CBE\u5EA6\u517C\u5BB9\n if(isSide < 0.999) {\n // side face\n if(u_sidesurface < 1.0) {\n discard;\n }\n \n if( u_linearColor == 1.0) {\n // side use linear\n vec4 linearColor = mix(u_targetColor, u_sourceColor, sidey);\n linearColor.rgb *= lightWeight;\n outputColor = linearColor;\n } else {\n // side notuse linear\n outputColor = v_Color;\n }\n } else {\n // top face\n if(u_topsurface < 1.0) {\n discard;\n }\n outputColor = v_Color;\n }\n\n outputColor = filterColorAlpha(outputColor, lightWeight);\n}\n";
20
13
  /* babel-plugin-inline-import '../shaders/extrude/polygon_extrude_picklight_vert.glsl' */
21
- const polygonExtrudePickLightVert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in float a_Size;\nlayout(location = 13) in vec3 a_Normal;\nlayout(location = 14) in vec3 a_uvs;\n\n\nlayout(std140) uniform commonUniforms {\n vec4 u_sourceColor;\n vec4 u_targetColor;\n float u_linearColor;\n float u_topsurface;\n float u_sidesurface;\n float u_heightfixed; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\n float u_raisingHeight;\n};\n\nout vec4 v_Color;\nout vec3 v_uvs;\nout vec2 v_texture_data;\n\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\nvoid main() {\n\n\n v_uvs = a_uvs;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n vec4 pos = vec4(a_Position.xy, a_Position.z * a_Size, 1.0);\n vec4 project_pos = project_position(pos);\n\n if(u_heightfixed > 0.0) { // \u5224\u65AD\u51E0\u4F55\u4F53\u662F\u5426\u56FA\u5B9A\u9AD8\u5EA6\n project_pos.z = a_Position.z * a_Size;\n project_pos.z += u_raisingHeight;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n project_pos.z *= mapboxZoomScale;\n project_pos.z += u_raisingHeight * mapboxZoomScale;\n }\n }\n\n gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xyz, 1.0));\n float lightWeight = calc_lighting(pos);\n v_texture_data = vec2(a_Position.z,lightWeight);\n\n v_Color = vec4(a_Color.rgb * lightWeight, a_Color.w * opacity);\n\n setPickingColor(a_PickingColor);\n}\n";
14
+ const polygonExtrudePickLightVert = "layout(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;\nlayout(location = ATTRIBUTE_LOCATION_NORMAL) in vec3 a_Normal;\nlayout(location = ATTRIBUTE_LOCATION_UV) in vec3 a_uvs;\n\nlayout(std140) uniform commonUniforms {\n vec4 u_sourceColor;\n vec4 u_targetColor;\n float u_linearColor;\n float u_topsurface;\n float u_sidesurface;\n float u_heightfixed; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\n float u_raisingHeight;\n};\n\nout vec4 v_Color;\nout vec3 v_uvs;\nout vec2 v_texture_data;\n\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\nvoid main() {\n v_uvs = a_uvs;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n vec4 pos = vec4(a_Position.xy, a_Position.z * a_Size, 1.0);\n vec4 project_pos = project_position(pos, a_Position64Low);\n\n if (u_heightfixed > 0.0) {\n // \u5224\u65AD\u51E0\u4F55\u4F53\u662F\u5426\u56FA\u5B9A\u9AD8\u5EA6\n project_pos.z = a_Position.z * a_Size;\n project_pos.z += u_raisingHeight;\n if (\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT ||\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET\n ) {\n float mapboxZoomScale = 4.0 / pow(2.0, 21.0 - u_Zoom);\n project_pos.z *= mapboxZoomScale;\n project_pos.z += u_raisingHeight * mapboxZoomScale;\n }\n }\n\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n float lightWeight = calc_lighting(project_pos);\n v_texture_data = vec2(a_Position.z, lightWeight);\n\n v_Color = vec4(a_Color.rgb * lightWeight, a_Color.w * opacity);\n\n setPickingColor(a_PickingColor);\n}\n";
15
+ /* babel-plugin-inline-import '../shaders/extrude/polygon_extrude_vert.glsl' */
16
+ const polygonExtrudeVert = "layout(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;\nlayout(location = ATTRIBUTE_LOCATION_NORMAL) in vec3 a_Normal;\nlayout(location = ATTRIBUTE_LOCATION_UV) in vec3 a_uvs;\n\nlayout(std140) uniform commonUniforms {\n vec4 u_sourceColor;\n vec4 u_targetColor;\n float u_linearColor;\n float u_topsurface;\n float u_sidesurface;\n float u_heightfixed; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\n float u_raisingHeight;\n};\n\nout vec4 v_Color;\n\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\nvoid main() {\n float isSide = a_Position.z;\n float topU = a_uvs[0];\n float topV = 1.0 - a_uvs[1];\n float sidey = a_uvs[2];\n\n vec4 pos = vec4(a_Position.xy, a_Position.z * a_Size, 1.0);\n\n vec4 project_pos = project_position(pos, a_Position64Low);\n float lightWeight = calc_lighting(project_pos);\n\n if (u_heightfixed > 0.0) {\n // \u5224\u65AD\u51E0\u4F55\u4F53\u662F\u5426\u56FA\u5B9A\u9AD8\u5EA6\n project_pos.z = a_Position.z * a_Size;\n project_pos.z += u_raisingHeight;\n\n if (\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT ||\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET\n ) {\n float mapboxZoomScale = 4.0 / pow(2.0, 21.0 - u_Zoom);\n project_pos.z *= mapboxZoomScale;\n project_pos.z += u_raisingHeight * mapboxZoomScale;\n }\n }\n\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n // Tip: \u90E8\u5206\u673A\u578B GPU \u8BA1\u7B97\u7CBE\u5EA6\u517C\u5BB9\n if (isSide < 0.999) {\n // side face\n // if(u_sidesurface < 1.0) {\n // discard;\n // }\n\n if (u_linearColor == 1.0) {\n vec4 linearColor = mix(u_targetColor, u_sourceColor, sidey);\n linearColor.rgb *= lightWeight;\n v_Color = linearColor;\n } else {\n v_Color = a_Color;\n }\n\n } else {\n v_Color = a_Color;\n }\n\n v_Color = vec4(v_Color.rgb * lightWeight, v_Color.w * opacity);\n\n setPickingColor(a_PickingColor);\n}\n";
17
+ /* babel-plugin-inline-import '../shaders/extrude/polygon_extrudetex_frag.glsl' */
18
+ const polygonExtrudeTexFrag = "uniform sampler2D u_texture;\n\nlayout(std140) uniform commonUniforms {\n vec4 u_sourceColor;\n vec4 u_targetColor;\n float u_linearColor;\n float u_topsurface;\n float u_sidesurface;\n float u_heightfixed; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\n float u_raisingHeight;\n};\n\nin vec4 v_Color;\nin vec3 v_uvs;\nin vec2 v_texture_data;\n\n#pragma include \"scene_uniforms\"\n#pragma include \"picking\"\n\nout vec4 outputColor;\n\nvoid main() {\n float opacity = u_opacity;\n float isSide = v_texture_data.x;\n float lightWeight = v_texture_data.y;\n float topU = v_uvs[0];\n float topV = 1.0 - v_uvs[1];\n float sidey = v_uvs[2];\n\n outputColor = texture(SAMPLER_2D(u_texture), vec2(topU, topV));\n // Tip: \u90E8\u5206\u673A\u578B GPU \u8BA1\u7B97\u7CBE\u5EA6\u517C\u5BB9\n if (isSide < 0.999) {// \u662F\u5426\u662F\u8FB9\u7F18\n // side face\n if (u_sidesurface < 1.0) {\n discard;\n }\n\n if (u_linearColor == 1.0) {\n vec4 linearColor = mix(u_targetColor, u_sourceColor, sidey);\n linearColor.rgb *= lightWeight;\n outputColor = linearColor;\n } else {\n outputColor = v_Color;\n }\n } else {\n // top face\n if (u_topsurface < 1.0) {\n discard;\n }\n }\n \n outputColor.a *= opacity;\n outputColor = filterColor(outputColor);\n}\n";
19
+ /* babel-plugin-inline-import '../shaders/extrude/polygon_extrudetex_vert.glsl' */
20
+ const polygonExtrudeTexVert = "layout(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;\nlayout(location = ATTRIBUTE_LOCATION_NORMAL) in vec3 a_Normal;\nlayout(location = ATTRIBUTE_LOCATION_UV) in vec3 a_uvs;\n\nlayout(std140) uniform commonUniforms {\n vec4 u_sourceColor;\n vec4 u_targetColor;\n float u_linearColor;\n float u_topsurface;\n float u_sidesurface;\n float u_heightfixed; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\n float u_raisingHeight;\n};\n\nout vec4 v_Color;\nout vec3 v_uvs;\nout vec2 v_texture_data;\n\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\nvoid main() {\n vec4 pos = vec4(a_Position.xy, a_Position.z * a_Size, 1.0);\n vec4 project_pos = project_position(pos, a_Position64Low);\n float lightWeight = calc_lighting(project_pos);\n v_uvs = a_uvs;\n v_Color = a_Color;\n v_Color.a *= opacity;\n\n v_texture_data = vec2(a_Position.z, lightWeight);\n\n if (u_heightfixed > 0.0) {\n // \u5224\u65AD\u51E0\u4F55\u4F53\u662F\u5426\u56FA\u5B9A\u9AD8\u5EA6\n project_pos.z = a_Position.z * a_Size;\n project_pos.z += u_raisingHeight;\n\n if (\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT ||\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET\n ) {\n float mapboxZoomScale = 4.0 / pow(2.0, 21.0 - u_Zoom);\n project_pos.z *= mapboxZoomScale;\n project_pos.z += u_raisingHeight * mapboxZoomScale;\n }\n }\n\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
22
21
  export default class ExtrudeModel extends BaseModel {
23
22
  constructor(...args) {
24
23
  super(...args);
25
24
  _defineProperty(this, "texture", void 0);
26
25
  }
26
+ get attributeLocation() {
27
+ return Object.assign(super.attributeLocation, {
28
+ MAX: super.attributeLocation.MAX,
29
+ SIZE: 9,
30
+ NORMAL: 10,
31
+ UV: 11
32
+ });
33
+ }
27
34
  getUninforms() {
28
35
  const commoninfo = this.getCommonUniformsInfo();
29
36
  const attributeInfo = this.getUniformsBufferInfo(this.getStyleAttribute());
@@ -91,6 +98,7 @@ export default class ExtrudeModel extends BaseModel {
91
98
  depth: {
92
99
  enable: true
93
100
  },
101
+ defines: _this2.getDefines(),
94
102
  inject: _this2.getInject(),
95
103
  triangulation: PolygonExtrudeTriangulation
96
104
  });
@@ -129,26 +137,18 @@ export default class ExtrudeModel extends BaseModel {
129
137
  this.textures = [];
130
138
  }
131
139
  registerBuiltinAttributes() {
132
- const bbox = this.layer.getSource().extent;
133
- let bounds = bbox;
134
- const layerCenter = this.layer.coordCenter || this.layer.getSource().center;
135
- let lngLen = bounds[2] - bounds[0];
136
- let latLen = bounds[3] - bounds[1];
137
- if (this.mapService.version === 'GAODE2.x') {
138
- // @ts-ignore
139
- const [minX, minY] = this.mapService.coordToAMap2RelativeCoordinates([bbox[0], bbox[1]], layerCenter);
140
- // @ts-ignore
141
- const [maxX, maxY] = this.mapService.coordToAMap2RelativeCoordinates([bbox[2], bbox[3]], layerCenter);
142
- lngLen = maxX - minX;
143
- latLen = maxY - minY;
144
- bounds = [minX, minY, maxX, maxY];
145
- }
140
+ const bounds = this.layer.getSource().extent;
141
+ const lngLen = bounds[2] - bounds[0];
142
+ const latLen = bounds[3] - bounds[1];
143
+
144
+ // 注册 Position 属性 64 位地位部分,经纬度数据开启双精度,避免大于 22 层级以上出现数据偏移
145
+ this.registerPosition64LowAttribute();
146
146
  this.styleAttributeService.registerStyleAttribute({
147
147
  name: 'uvs',
148
148
  type: AttributeType.Attribute,
149
149
  descriptor: {
150
150
  name: 'a_uvs',
151
- shaderLocation: ShaderLocation.UV,
151
+ shaderLocation: this.attributeLocation.UV,
152
152
  buffer: {
153
153
  // give the WebGL driver a hint that this buffer may change
154
154
  usage: gl.STATIC_DRAW,
@@ -169,7 +169,7 @@ export default class ExtrudeModel extends BaseModel {
169
169
  type: AttributeType.Attribute,
170
170
  descriptor: {
171
171
  name: 'a_Normal',
172
- shaderLocation: ShaderLocation.NORMAL,
172
+ shaderLocation: this.attributeLocation.NORMAL,
173
173
  buffer: {
174
174
  // give the WebGL driver a hint that this buffer may change
175
175
  usage: gl.STATIC_DRAW,
@@ -187,7 +187,7 @@ export default class ExtrudeModel extends BaseModel {
187
187
  type: AttributeType.Attribute,
188
188
  descriptor: {
189
189
  name: 'a_Size',
190
- shaderLocation: ShaderLocation.SIZE,
190
+ shaderLocation: this.attributeLocation.SIZE,
191
191
  buffer: {
192
192
  usage: gl.DYNAMIC_DRAW,
193
193
  data: [],
@@ -1,6 +1,22 @@
1
1
  import type { IModel, ITexture2D } from '@antv/l7-core';
2
2
  import BaseModel from '../../core/BaseModel';
3
3
  export default class ExtrusionModel extends BaseModel {
4
+ protected get attributeLocation(): {
5
+ readonly POSITION: 0;
6
+ readonly POSITION_64LOW: 1;
7
+ readonly COLOR: 2;
8
+ readonly PICKING_COLOR: 3;
9
+ readonly STROKE: 4;
10
+ readonly OPACITY: 5;
11
+ readonly OFFSETS: 6;
12
+ readonly ROTATION: 7;
13
+ readonly MAX: 8;
14
+ } & Record<string, number> & {
15
+ MAX: 8;
16
+ SIZE: number;
17
+ NORMAL: number;
18
+ EXTRUSION_BASE: number;
19
+ };
4
20
  protected texture: ITexture2D;
5
21
  getUninforms(): {
6
22
  [x: string]: any;
@@ -3,17 +3,24 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
3
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
4
  import { AttributeType, gl } from '@antv/l7-core';
5
5
  import BaseModel from "../../core/BaseModel";
6
- import { ShaderLocation } from "../../core/CommonStyleAttribute";
7
6
  import { PolygonExtrudeTriangulation } from "../../core/triangulation";
8
7
  /* babel-plugin-inline-import '../shaders/extrusion/polygon_extrusion_frag.glsl' */
9
8
  const polygonExtrudeFrag = "\nin vec4 v_Color;\n#pragma include \"scene_uniforms\"\n#pragma include \"picking\"\nout vec4 outputColor;\nvoid main() {\n\n outputColor = v_Color;\n outputColor = filterColor(outputColor);\n}\n";
10
9
  /* babel-plugin-inline-import '../shaders/extrusion/polygon_extrusion_vert.glsl' */
11
- const polygonExtrudeVert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in float a_Size;\nlayout(location = 13) in vec3 a_Normal;\n\nout vec4 v_Color;\n\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\nvoid main() {\n \n vec4 pos = vec4(a_Position.xy, a_Position.z * a_Size + (1.0 - a_Position.z) * extrusionBase, 1.0);\n\n vec4 project_pos = project_position(pos);\n float lightWeight = calc_lighting(project_pos);\n v_Color = a_Color;\n v_Color = vec4(v_Color.rgb * lightWeight, v_Color.w * opacity);\n\n gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xyz, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
10
+ const polygonExtrudeVert = "layout(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;\nlayout(location = ATTRIBUTE_LOCATION_NORMAL) in vec3 a_Normal;\n\nout vec4 v_Color;\n\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\nvoid main() {\n vec4 pos = vec4(a_Position.xy, a_Position.z * a_Size + (1.0 - a_Position.z) * extrusionBase, 1.0);\n\n vec4 project_pos = project_position(pos, a_Position64Low);\n float lightWeight = calc_lighting(project_pos);\n v_Color = a_Color;\n v_Color = vec4(v_Color.rgb * lightWeight, v_Color.w * opacity);\n\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
12
11
  export default class ExtrusionModel extends BaseModel {
13
12
  constructor(...args) {
14
13
  super(...args);
15
14
  _defineProperty(this, "texture", void 0);
16
15
  }
16
+ get attributeLocation() {
17
+ return Object.assign(super.attributeLocation, {
18
+ MAX: super.attributeLocation.MAX,
19
+ SIZE: 9,
20
+ NORMAL: 10,
21
+ EXTRUSION_BASE: 11
22
+ });
23
+ }
17
24
  getUninforms() {
18
25
  const commoninfo = this.getCommonUniformsInfo();
19
26
  const attributeInfo = this.getUniformsBufferInfo(this.getStyleAttribute());
@@ -44,6 +51,7 @@ export default class ExtrusionModel extends BaseModel {
44
51
  moduleName: type,
45
52
  vertexShader: vert,
46
53
  fragmentShader: frag,
54
+ defines: _this2.getDefines(),
47
55
  inject: _this2.getInject(),
48
56
  triangulation: PolygonExtrudeTriangulation,
49
57
  depth: {
@@ -65,12 +73,14 @@ export default class ExtrusionModel extends BaseModel {
65
73
  (_this$texture = this.texture) === null || _this$texture === void 0 || _this$texture.destroy();
66
74
  }
67
75
  registerBuiltinAttributes() {
76
+ // 注册 Position 属性 64 位地位部分,经纬度数据开启双精度,避免大于 22 层级以上出现数据偏移
77
+ this.registerPosition64LowAttribute();
68
78
  this.styleAttributeService.registerStyleAttribute({
69
79
  name: 'normal',
70
80
  type: AttributeType.Attribute,
71
81
  descriptor: {
72
82
  name: 'a_Normal',
73
- shaderLocation: ShaderLocation.NORMAL,
83
+ shaderLocation: this.attributeLocation.NORMAL,
74
84
  buffer: {
75
85
  // give the WebGL driver a hint that this buffer may change
76
86
  usage: gl.STATIC_DRAW,
@@ -88,7 +98,7 @@ export default class ExtrusionModel extends BaseModel {
88
98
  type: AttributeType.Attribute,
89
99
  descriptor: {
90
100
  name: 'a_Size',
91
- shaderLocation: ShaderLocation.SIZE,
101
+ shaderLocation: this.attributeLocation.SIZE,
92
102
  buffer: {
93
103
  usage: gl.DYNAMIC_DRAW,
94
104
  data: [],
@@ -103,5 +113,25 @@ export default class ExtrusionModel extends BaseModel {
103
113
  }
104
114
  }
105
115
  });
116
+ this.styleAttributeService.registerStyleAttribute({
117
+ name: 'extrusionBase',
118
+ type: AttributeType.Attribute,
119
+ descriptor: {
120
+ name: 'a_ExtrusionBase',
121
+ shaderLocation: this.attributeLocation.EXTRUSION_BASE,
122
+ buffer: {
123
+ usage: gl.STATIC_DRAW,
124
+ data: [],
125
+ type: gl.FLOAT
126
+ },
127
+ size: 1,
128
+ update: feature => {
129
+ const {
130
+ extrusionBase: op = 0
131
+ } = feature;
132
+ return [op];
133
+ }
134
+ }
135
+ });
106
136
  }
107
137
  }
@@ -1,6 +1,20 @@
1
1
  import type { IModel } from '@antv/l7-core';
2
2
  import BaseModel from '../../core/BaseModel';
3
3
  export default class FillModel extends BaseModel {
4
+ protected get attributeLocation(): {
5
+ readonly POSITION: 0;
6
+ readonly POSITION_64LOW: 1;
7
+ readonly COLOR: 2;
8
+ readonly PICKING_COLOR: 3;
9
+ readonly STROKE: 4;
10
+ readonly OPACITY: 5;
11
+ readonly OFFSETS: 6;
12
+ readonly ROTATION: 7;
13
+ readonly MAX: 8;
14
+ } & Record<string, number> & {
15
+ MAX: 8;
16
+ LINEAR: number;
17
+ };
4
18
  getUninforms(): {
5
19
  [x: string]: any;
6
20
  };