@antv/l7-layers 2.21.10 → 2.21.11-beta.1

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 (287) 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.d.ts +0 -1
  6. package/es/core/BaseLayer.js +9 -19
  7. package/es/core/BaseModel.d.ts +15 -2
  8. package/es/core/BaseModel.js +98 -64
  9. package/es/core/CommonStyleAttribute.d.ts +14 -18
  10. package/es/core/CommonStyleAttribute.js +23 -67
  11. package/es/core/shape/extrude.js +6 -3
  12. package/es/core/triangulation.js +22 -50
  13. package/es/core/utils.d.ts +4 -0
  14. package/es/core/utils.js +33 -0
  15. package/es/earth/models/atmosphere.d.ts +15 -0
  16. package/es/earth/models/atmosphere.js +30 -24
  17. package/es/earth/models/base.d.ts +15 -0
  18. package/es/earth/models/base.js +30 -24
  19. package/es/earth/models/bloomsphere.d.ts +15 -0
  20. package/es/earth/models/bloomsphere.js +30 -24
  21. package/es/earth/shaders/atmosphere/atmosphere_vert.glsl +7 -5
  22. package/es/earth/shaders/base/base_vert.glsl +3 -3
  23. package/es/earth/shaders/bloomshpere/bloomsphere_vert.glsl +5 -4
  24. package/es/geometry/models/billboard.d.ts +15 -0
  25. package/es/geometry/models/billboard.js +14 -8
  26. package/es/geometry/models/plane.d.ts +14 -0
  27. package/es/geometry/models/plane.js +10 -10
  28. package/es/geometry/models/sprite.js +3 -9
  29. package/es/geometry/shaders/billboard_vert.glsl +28 -25
  30. package/es/geometry/shaders/plane_vert.glsl +6 -6
  31. package/es/geometry/shaders/sprite_vert.glsl +7 -9
  32. package/es/heatmap/models/grid.d.ts +14 -0
  33. package/es/heatmap/models/grid.js +10 -3
  34. package/es/heatmap/models/grid3d.d.ts +16 -0
  35. package/es/heatmap/models/grid3d.js +14 -6
  36. package/es/heatmap/models/heatmap.d.ts +20 -1
  37. package/es/heatmap/models/heatmap.js +96 -83
  38. package/es/heatmap/models/hexagon.d.ts +14 -0
  39. package/es/heatmap/models/hexagon.js +9 -3
  40. package/es/heatmap/shaders/grid/grid_vert.glsl +30 -42
  41. package/es/heatmap/shaders/grid3d/grid_3d_vert.glsl +14 -26
  42. package/es/heatmap/shaders/heatmap/heatmap_3d_vert.glsl +19 -16
  43. package/es/heatmap/shaders/heatmap/heatmap_framebuffer_vert.glsl +16 -22
  44. package/es/heatmap/shaders/heatmap/heatmap_vert.glsl +3 -4
  45. package/es/heatmap/shaders/hexagon/hexagon_vert.glsl +13 -23
  46. package/es/image/models/image.d.ts +14 -0
  47. package/es/image/models/image.js +11 -7
  48. package/es/image/shaders/image_vert.glsl +7 -6
  49. package/es/line/models/arc.d.ts +18 -0
  50. package/es/line/models/arc.js +57 -8
  51. package/es/line/models/arc_3d.d.ts +18 -0
  52. package/es/line/models/arc_3d.js +55 -7
  53. package/es/line/models/flow.d.ts +17 -0
  54. package/es/line/models/flow.js +35 -7
  55. package/es/line/models/great_circle.d.ts +17 -0
  56. package/es/line/models/great_circle.js +34 -6
  57. package/es/line/models/line.d.ts +17 -0
  58. package/es/line/models/line.js +17 -8
  59. package/es/line/models/simple_line.d.ts +14 -0
  60. package/es/line/models/simple_line.js +12 -47
  61. package/es/line/models/wall.d.ts +17 -0
  62. package/es/line/models/wall.js +22 -48
  63. package/es/line/shaders/arc/line_arc_vert.glsl +44 -52
  64. package/es/line/shaders/arc3d/line_arc_3d_vert.glsl +15 -20
  65. package/es/line/shaders/flow/flow_line_vert.glsl +30 -48
  66. package/es/line/shaders/greatCircle/line_arc_great_circle_vert.glsl +53 -74
  67. package/es/line/shaders/line/line_vert.glsl +31 -48
  68. package/es/line/shaders/simple/simpleline_vert.glsl +18 -23
  69. package/es/line/shaders/wall/wall_vert.glsl +36 -45
  70. package/es/mask/models/fill.js +2 -1
  71. package/es/mask/shaders/mask_vert.glsl +2 -7
  72. package/es/plugins/DataMappingPlugin.d.ts +0 -1
  73. package/es/plugins/DataMappingPlugin.js +1 -24
  74. package/es/plugins/PixelPickingPlugin.js +2 -2
  75. package/es/plugins/RegisterStyleAttributePlugin.d.ts +0 -1
  76. package/es/plugins/RegisterStyleAttributePlugin.js +3 -25
  77. package/es/plugins/ShaderUniformPlugin.d.ts +0 -5
  78. package/es/plugins/ShaderUniformPlugin.js +4 -35
  79. package/es/point/models/billboard_point.d.ts +14 -0
  80. package/es/point/models/billboard_point.js +11 -3
  81. package/es/point/models/earthExtrude.d.ts +16 -0
  82. package/es/point/models/earthExtrude.js +15 -8
  83. package/es/point/models/earthFill.d.ts +16 -0
  84. package/es/point/models/earthFill.js +13 -5
  85. package/es/point/models/extrude.d.ts +16 -0
  86. package/es/point/models/extrude.js +19 -12
  87. package/es/point/models/fill.d.ts +16 -0
  88. package/es/point/models/fill.js +16 -5
  89. package/es/point/models/fillImage.d.ts +16 -0
  90. package/es/point/models/fillImage.js +16 -16
  91. package/es/point/models/image.d.ts +15 -0
  92. package/es/point/models/image.js +14 -4
  93. package/es/point/models/normal.d.ts +14 -0
  94. package/es/point/models/normal.js +11 -3
  95. package/es/point/models/radar.d.ts +15 -0
  96. package/es/point/models/radar.js +13 -4
  97. package/es/point/models/text.d.ts +16 -0
  98. package/es/point/models/text.js +18 -11
  99. package/es/point/shaders/billboard/billboard_point_vert.glsl +10 -13
  100. package/es/point/shaders/earthExtrude/earthExtrude_vert.glsl +15 -25
  101. package/es/point/shaders/earthFill/earthFill_vert.glsl +6 -6
  102. package/es/point/shaders/extrude/extrude_vert.glsl +35 -39
  103. package/es/point/shaders/fill/fill_vert.glsl +12 -14
  104. package/es/point/shaders/fillImage/fillImage_vert.glsl +16 -28
  105. package/es/point/shaders/image/image_vert.glsl +15 -12
  106. package/es/point/shaders/normal/normal_vert.glsl +7 -10
  107. package/es/point/shaders/radar/radar_vert.glsl +11 -11
  108. package/es/point/shaders/text/text_vert.glsl +10 -9
  109. package/es/polygon/models/extrude.d.ts +16 -0
  110. package/es/polygon/models/extrude.js +26 -26
  111. package/es/polygon/models/extrusion.d.ts +16 -0
  112. package/es/polygon/models/extrusion.js +34 -4
  113. package/es/polygon/models/fill.d.ts +14 -0
  114. package/es/polygon/models/fill.js +12 -4
  115. package/es/polygon/models/ocean.d.ts +14 -0
  116. package/es/polygon/models/ocean.js +11 -6
  117. package/es/polygon/models/water.d.ts +14 -0
  118. package/es/polygon/models/water.js +11 -6
  119. package/es/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +17 -15
  120. package/es/polygon/shaders/extrude/polygon_extrude_vert.glsl +22 -20
  121. package/es/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +17 -17
  122. package/es/polygon/shaders/extrusion/polygon_extrusion_vert.glsl +8 -8
  123. package/es/polygon/shaders/fill/fill_linear_vert.glsl +7 -6
  124. package/es/polygon/shaders/fill/fill_vert.glsl +10 -12
  125. package/es/polygon/shaders/ocean/ocean_vert.glsl +3 -4
  126. package/es/polygon/shaders/water/polygon_water_vert.glsl +5 -5
  127. package/es/raster/index.d.ts +1 -1
  128. package/es/raster/index.js +1 -1
  129. package/es/raster/models/raster.d.ts +14 -0
  130. package/es/raster/models/raster.js +13 -3
  131. package/es/raster/models/rasterRgb.d.ts +14 -0
  132. package/es/raster/models/rasterRgb.js +12 -3
  133. package/es/raster/models/rasterTerrainRgb.d.ts +14 -0
  134. package/es/raster/models/rasterTerrainRgb.js +11 -3
  135. package/es/raster/shaders/raster/raster_2d_vert.glsl +6 -6
  136. package/es/raster/shaders/rgb/raster_rgb_vert.glsl +11 -11
  137. package/es/raster/shaders/terrain/terrain_rgb_vert.glsl +11 -11
  138. package/es/tile/core/BaseLayer.js +0 -16
  139. package/es/utils/extrude_polyline.d.ts +0 -15
  140. package/es/utils/extrude_polyline.js +0 -217
  141. package/es/wind/models/wind.d.ts +14 -0
  142. package/es/wind/models/wind.js +9 -1
  143. package/es/wind/shaders/wind_vert.glsl +6 -5
  144. package/lib/citybuliding/models/build.d.ts +16 -0
  145. package/lib/citybuliding/models/build.js +18 -20
  146. package/lib/citybuliding/shaders/build_frag.glsl +6 -6
  147. package/lib/citybuliding/shaders/build_vert.glsl +8 -14
  148. package/lib/core/BaseLayer.d.ts +0 -1
  149. package/lib/core/BaseLayer.js +9 -19
  150. package/lib/core/BaseModel.d.ts +15 -2
  151. package/lib/core/BaseModel.js +96 -62
  152. package/lib/core/CommonStyleAttribute.d.ts +14 -18
  153. package/lib/core/CommonStyleAttribute.js +23 -68
  154. package/lib/core/shape/extrude.js +6 -3
  155. package/lib/core/triangulation.js +22 -50
  156. package/lib/core/utils.d.ts +4 -0
  157. package/lib/core/utils.js +35 -0
  158. package/lib/earth/models/atmosphere.d.ts +15 -0
  159. package/lib/earth/models/atmosphere.js +30 -24
  160. package/lib/earth/models/base.d.ts +15 -0
  161. package/lib/earth/models/base.js +30 -24
  162. package/lib/earth/models/bloomsphere.d.ts +15 -0
  163. package/lib/earth/models/bloomsphere.js +30 -24
  164. package/lib/earth/shaders/atmosphere/atmosphere_vert.glsl +7 -5
  165. package/lib/earth/shaders/base/base_vert.glsl +3 -3
  166. package/lib/earth/shaders/bloomshpere/bloomsphere_vert.glsl +5 -4
  167. package/lib/geometry/models/billboard.d.ts +15 -0
  168. package/lib/geometry/models/billboard.js +14 -8
  169. package/lib/geometry/models/plane.d.ts +14 -0
  170. package/lib/geometry/models/plane.js +10 -10
  171. package/lib/geometry/models/sprite.js +3 -9
  172. package/lib/geometry/shaders/billboard_vert.glsl +28 -25
  173. package/lib/geometry/shaders/plane_vert.glsl +6 -6
  174. package/lib/geometry/shaders/sprite_vert.glsl +7 -9
  175. package/lib/heatmap/models/grid.d.ts +14 -0
  176. package/lib/heatmap/models/grid.js +10 -3
  177. package/lib/heatmap/models/grid3d.d.ts +16 -0
  178. package/lib/heatmap/models/grid3d.js +14 -6
  179. package/lib/heatmap/models/heatmap.d.ts +20 -1
  180. package/lib/heatmap/models/heatmap.js +95 -82
  181. package/lib/heatmap/models/hexagon.d.ts +14 -0
  182. package/lib/heatmap/models/hexagon.js +9 -3
  183. package/lib/heatmap/shaders/grid/grid_vert.glsl +30 -42
  184. package/lib/heatmap/shaders/grid3d/grid_3d_vert.glsl +14 -26
  185. package/lib/heatmap/shaders/heatmap/heatmap_3d_vert.glsl +19 -16
  186. package/lib/heatmap/shaders/heatmap/heatmap_framebuffer_vert.glsl +16 -22
  187. package/lib/heatmap/shaders/heatmap/heatmap_vert.glsl +3 -4
  188. package/lib/heatmap/shaders/hexagon/hexagon_vert.glsl +13 -23
  189. package/lib/image/models/image.d.ts +14 -0
  190. package/lib/image/models/image.js +11 -7
  191. package/lib/image/shaders/image_vert.glsl +7 -6
  192. package/lib/line/models/arc.d.ts +18 -0
  193. package/lib/line/models/arc.js +56 -7
  194. package/lib/line/models/arc_3d.d.ts +18 -0
  195. package/lib/line/models/arc_3d.js +55 -7
  196. package/lib/line/models/flow.d.ts +17 -0
  197. package/lib/line/models/flow.js +35 -7
  198. package/lib/line/models/great_circle.d.ts +17 -0
  199. package/lib/line/models/great_circle.js +33 -5
  200. package/lib/line/models/line.d.ts +17 -0
  201. package/lib/line/models/line.js +17 -8
  202. package/lib/line/models/simple_line.d.ts +14 -0
  203. package/lib/line/models/simple_line.js +12 -47
  204. package/lib/line/models/wall.d.ts +17 -0
  205. package/lib/line/models/wall.js +22 -48
  206. package/lib/line/shaders/arc/line_arc_vert.glsl +44 -52
  207. package/lib/line/shaders/arc3d/line_arc_3d_vert.glsl +15 -20
  208. package/lib/line/shaders/flow/flow_line_vert.glsl +30 -48
  209. package/lib/line/shaders/greatCircle/line_arc_great_circle_vert.glsl +53 -74
  210. package/lib/line/shaders/line/line_vert.glsl +31 -48
  211. package/lib/line/shaders/simple/simpleline_vert.glsl +18 -23
  212. package/lib/line/shaders/wall/wall_vert.glsl +36 -45
  213. package/lib/mask/models/fill.js +2 -1
  214. package/lib/mask/shaders/mask_vert.glsl +2 -7
  215. package/lib/plugins/DataMappingPlugin.d.ts +0 -1
  216. package/lib/plugins/DataMappingPlugin.js +0 -23
  217. package/lib/plugins/PixelPickingPlugin.js +1 -1
  218. package/lib/plugins/RegisterStyleAttributePlugin.d.ts +0 -1
  219. package/lib/plugins/RegisterStyleAttributePlugin.js +2 -24
  220. package/lib/plugins/ShaderUniformPlugin.d.ts +0 -5
  221. package/lib/plugins/ShaderUniformPlugin.js +4 -35
  222. package/lib/point/models/billboard_point.d.ts +14 -0
  223. package/lib/point/models/billboard_point.js +11 -3
  224. package/lib/point/models/earthExtrude.d.ts +16 -0
  225. package/lib/point/models/earthExtrude.js +14 -7
  226. package/lib/point/models/earthFill.d.ts +16 -0
  227. package/lib/point/models/earthFill.js +13 -5
  228. package/lib/point/models/extrude.d.ts +16 -0
  229. package/lib/point/models/extrude.js +18 -11
  230. package/lib/point/models/fill.d.ts +16 -0
  231. package/lib/point/models/fill.js +16 -5
  232. package/lib/point/models/fillImage.d.ts +16 -0
  233. package/lib/point/models/fillImage.js +16 -16
  234. package/lib/point/models/image.d.ts +15 -0
  235. package/lib/point/models/image.js +14 -4
  236. package/lib/point/models/normal.d.ts +14 -0
  237. package/lib/point/models/normal.js +11 -3
  238. package/lib/point/models/radar.d.ts +15 -0
  239. package/lib/point/models/radar.js +13 -4
  240. package/lib/point/models/text.d.ts +16 -0
  241. package/lib/point/models/text.js +18 -11
  242. package/lib/point/shaders/billboard/billboard_point_vert.glsl +10 -13
  243. package/lib/point/shaders/earthExtrude/earthExtrude_vert.glsl +15 -25
  244. package/lib/point/shaders/earthFill/earthFill_vert.glsl +6 -6
  245. package/lib/point/shaders/extrude/extrude_vert.glsl +35 -39
  246. package/lib/point/shaders/fill/fill_vert.glsl +12 -14
  247. package/lib/point/shaders/fillImage/fillImage_vert.glsl +16 -28
  248. package/lib/point/shaders/image/image_vert.glsl +15 -12
  249. package/lib/point/shaders/normal/normal_vert.glsl +7 -10
  250. package/lib/point/shaders/radar/radar_vert.glsl +11 -11
  251. package/lib/point/shaders/text/text_vert.glsl +10 -9
  252. package/lib/polygon/models/extrude.d.ts +16 -0
  253. package/lib/polygon/models/extrude.js +25 -25
  254. package/lib/polygon/models/extrusion.d.ts +16 -0
  255. package/lib/polygon/models/extrusion.js +34 -4
  256. package/lib/polygon/models/fill.d.ts +14 -0
  257. package/lib/polygon/models/fill.js +12 -4
  258. package/lib/polygon/models/ocean.d.ts +14 -0
  259. package/lib/polygon/models/ocean.js +11 -6
  260. package/lib/polygon/models/water.d.ts +14 -0
  261. package/lib/polygon/models/water.js +11 -6
  262. package/lib/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +17 -15
  263. package/lib/polygon/shaders/extrude/polygon_extrude_vert.glsl +22 -20
  264. package/lib/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +17 -17
  265. package/lib/polygon/shaders/extrusion/polygon_extrusion_vert.glsl +8 -8
  266. package/lib/polygon/shaders/fill/fill_linear_vert.glsl +7 -6
  267. package/lib/polygon/shaders/fill/fill_vert.glsl +10 -12
  268. package/lib/polygon/shaders/ocean/ocean_vert.glsl +3 -4
  269. package/lib/polygon/shaders/water/polygon_water_vert.glsl +5 -5
  270. package/lib/raster/index.d.ts +1 -1
  271. package/lib/raster/index.js +2 -2
  272. package/lib/raster/models/raster.d.ts +14 -0
  273. package/lib/raster/models/raster.js +13 -3
  274. package/lib/raster/models/rasterRgb.d.ts +14 -0
  275. package/lib/raster/models/rasterRgb.js +12 -3
  276. package/lib/raster/models/rasterTerrainRgb.d.ts +14 -0
  277. package/lib/raster/models/rasterTerrainRgb.js +11 -3
  278. package/lib/raster/shaders/raster/raster_2d_vert.glsl +6 -6
  279. package/lib/raster/shaders/rgb/raster_rgb_vert.glsl +11 -11
  280. package/lib/raster/shaders/terrain/terrain_rgb_vert.glsl +11 -11
  281. package/lib/tile/core/BaseLayer.js +0 -16
  282. package/lib/utils/extrude_polyline.d.ts +0 -15
  283. package/lib/utils/extrude_polyline.js +0 -217
  284. package/lib/wind/models/wind.d.ts +14 -0
  285. package/lib/wind/models/wind.js +9 -1
  286. package/lib/wind/shaders/wind_vert.glsl +6 -5
  287. package/package.json +6 -6
@@ -2,13 +2,20 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
2
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
3
  import { AttributeType, gl } from '@antv/l7-core';
4
4
  import BaseModel from "../../core/BaseModel";
5
- import { ShaderLocation } from "../../core/CommonStyleAttribute";
6
5
  import { PointExtrudeTriangulation } from "../../core/triangulation";
7
6
  /* babel-plugin-inline-import '../shaders/grid3d/grid_3d_frag.glsl' */
8
7
  const grid_3d_frag = "in vec4 v_color;\n\nlayout(std140) uniform commonUniforms {\n vec2 u_radius;\n float u_opacity;\n float u_coverage;\n float u_angle;\n};\n\n#pragma include \"scene_uniforms\"\n#pragma include \"picking\"\n\nout vec4 outputColor;\nvoid main() {\n outputColor = v_color;\n outputColor = filterColor(outputColor);\n}\n";
9
8
  /* babel-plugin-inline-import '../shaders/grid3d/grid_3d_vert.glsl' */
10
- const grid_3d_vert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in float a_Size;\nlayout(location = 10) in vec3 a_Pos;\nlayout(location = 13) in vec3 a_Normal;\n\nlayout(std140) uniform commonUniforms {\n vec2 u_radius;\n float u_opacity;\n float u_coverage;\n float u_angle;\n};\n\nout vec4 v_color;\n\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\nvoid main() {\n mat2 rotationMatrix = mat2(cos(u_angle), sin(u_angle), -sin(u_angle), cos(u_angle));\n vec2 offset =(vec2(a_Position.xy * u_radius * rotationMatrix * u_coverage));\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n \n vec2 lnglat = unProjectFlat(a_Pos.xy + offset); // \u7ECF\u7EAC\u5EA6\n vec2 customLnglat = customProject(lnglat) - u_sceneCenterMercator; // \u5C06\u7ECF\u7EAC\u5EA6\u8F6C\u6362\u4E3A\u9AD8\u5FB72.0\u9700\u8981\u7684\u5E73\u9762\u5750\u6807\n vec4 project_pos = project_position(vec4(customLnglat, a_Position.z * a_Size, 1.0));\n\n float lightWeight = calc_lighting(project_pos);\n v_color =vec4(a_Color.rgb*lightWeight, a_Color.w * u_opacity);\n \n gl_Position = u_Mvp * vec4(customLnglat , a_Position.z * a_Size, 1.0);\n } else {\n vec2 lnglat = unProjectFlat(a_Pos.xy + offset); // \u5B9E\u9645\u7684\u7ECF\u7EAC\u5EA6\n vec4 project_pos = project_position(vec4(lnglat, a_Position.z * a_Size, 1.0));\n \n float lightWeight = calc_lighting(project_pos);\n v_color =vec4(a_Color.rgb*lightWeight, a_Color.w);\n \n gl_Position = project_common_position_to_clipspace(project_pos);\n }\n\n setPickingColor(a_PickingColor);\n}\n";
9
+ const grid_3d_vert = "layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;\nlayout(location = ATTRIBUTE_LOCATION_SIZE) in float a_Size;\nlayout(location = ATTRIBUTE_LOCATION_POS) in vec3 a_Pos;\nlayout(location = ATTRIBUTE_LOCATION_NORMAL) in vec3 a_Normal;\n\nlayout(std140) uniform commonUniforms {\n vec2 u_radius;\n float u_opacity;\n float u_coverage;\n float u_angle;\n};\n\nout vec4 v_color;\n\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\nvoid main() {\n mat2 rotationMatrix = mat2(cos(u_angle), sin(u_angle), -sin(u_angle), cos(u_angle));\n vec2 offset = vec2(a_Position.xy * u_radius * rotationMatrix * u_coverage);\n\n vec2 lnglat = unProjectFlat(a_Pos.xy + offset); // \u5B9E\u9645\u7684\u7ECF\u7EAC\u5EA6\n vec4 project_pos = project_position(vec4(lnglat, a_Position.z * a_Size, 1.0));\n\n float lightWeight = calc_lighting(project_pos);\n v_color = vec4(a_Color.rgb * lightWeight, a_Color.w);\n\n gl_Position = project_common_position_to_clipspace(project_pos);\n\n setPickingColor(a_PickingColor);\n}\n";
11
10
  export default class Grid3DModel extends BaseModel {
11
+ get attributeLocation() {
12
+ return Object.assign(super.attributeLocation, {
13
+ MAX: super.attributeLocation.MAX,
14
+ SIZE: 9,
15
+ POS: 10,
16
+ NORMAL: 11
17
+ });
18
+ }
12
19
  getUninforms() {
13
20
  const commoninfo = this.getCommonUniformsInfo();
14
21
  const attributeInfo = this.getUniformsBufferInfo(this.getStyleAttribute());
@@ -44,6 +51,7 @@ export default class Grid3DModel extends BaseModel {
44
51
  moduleName: 'heatmapGrid3d',
45
52
  vertexShader: grid_3d_vert,
46
53
  fragmentShader: grid_3d_frag,
54
+ defines: _this2.getDefines(),
47
55
  triangulation: PointExtrudeTriangulation,
48
56
  primitive: gl.TRIANGLES,
49
57
  depth: {
@@ -58,7 +66,7 @@ export default class Grid3DModel extends BaseModel {
58
66
  name: 'size',
59
67
  type: AttributeType.Attribute,
60
68
  descriptor: {
61
- shaderLocation: ShaderLocation.SIZE,
69
+ shaderLocation: this.attributeLocation.SIZE,
62
70
  name: 'a_Size',
63
71
  buffer: {
64
72
  usage: gl.DYNAMIC_DRAW,
@@ -79,7 +87,7 @@ export default class Grid3DModel extends BaseModel {
79
87
  type: AttributeType.Attribute,
80
88
  descriptor: {
81
89
  name: 'a_Normal',
82
- shaderLocation: ShaderLocation.NORMAL,
90
+ shaderLocation: this.attributeLocation.NORMAL,
83
91
  buffer: {
84
92
  usage: gl.STATIC_DRAW,
85
93
  data: [],
@@ -97,7 +105,7 @@ export default class Grid3DModel extends BaseModel {
97
105
  type: AttributeType.Attribute,
98
106
  descriptor: {
99
107
  name: 'a_Pos',
100
- shaderLocation: 10,
108
+ shaderLocation: this.attributeLocation.POS,
101
109
  buffer: {
102
110
  usage: gl.DYNAMIC_DRAW,
103
111
  data: [],
@@ -105,7 +113,7 @@ export default class Grid3DModel extends BaseModel {
105
113
  },
106
114
  size: 3,
107
115
  update: feature => {
108
- const coordinates = feature.version === 'GAODE2.x' ? feature.originCoordinates : feature.coordinates;
116
+ const coordinates = feature.coordinates;
109
117
  return [coordinates[0], coordinates[1], 0];
110
118
  }
111
119
  }
@@ -1,6 +1,22 @@
1
1
  import type { IFramebuffer, IModel, IModelUniform, IRenderOptions, ITexture2D } from '@antv/l7-core';
2
2
  import BaseModel from '../../core/BaseModel';
3
3
  export default class HeatMapModel 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
+ UV: number;
18
+ DIR: number;
19
+ };
4
20
  protected texture: ITexture2D;
5
21
  protected colorTexture: ITexture2D;
6
22
  protected heatmapFramerBuffer: IFramebuffer;
@@ -17,11 +33,14 @@ export default class HeatMapModel extends BaseModel {
17
33
  initModels(): Promise<IModel[]>;
18
34
  buildModels(): Promise<IModel[]>;
19
35
  protected registerBuiltinAttributes(): void;
36
+ /**
37
+ * 热力图密度图
38
+ */
20
39
  private buildHeatMapIntensity;
21
40
  private buildHeatmap;
41
+ private build3dHeatMap;
22
42
  private drawIntensityMode;
23
43
  private drawHeatMap;
24
44
  private draw3DHeatMap;
25
- private build3dHeatMap;
26
45
  private updateColorTexture;
27
46
  }
@@ -2,23 +2,22 @@ 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 { AttributeType, TextureUsage, gl } from '@antv/l7-core';
5
- import { generateColorRamp, getCullFace, lodashUtil } from '@antv/l7-utils';
5
+ import { generateColorRamp, lodashUtil } from '@antv/l7-utils';
6
6
  import { mat4 } from 'gl-matrix';
7
7
  import BaseModel from "../../core/BaseModel";
8
8
  import { HeatmapTriangulation } from "../../core/triangulation";
9
9
  /* babel-plugin-inline-import '../shaders/heatmap/heatmap_3d_frag.glsl' */
10
10
  const heatmap_3d_frag = "layout(std140) uniform commonUniforms {\n mat4 u_ViewProjectionMatrixUncentered;\n mat4 u_InverseViewProjectionMatrix;\n float u_opacity;\n float u_common_uniforms_padding1;\n float u_common_uniforms_padding2;\n float u_common_uniforms_padding3;\n};\n\nuniform sampler2D u_texture;\nuniform sampler2D u_colorTexture;\n\nin vec2 v_texCoord;\nin float v_intensity;\nout vec4 outputColor;\n\nvoid main(){\n \n float intensity = texture(SAMPLER_2D(u_texture), v_texCoord).r;\n vec4 color = texture(SAMPLER_2D(u_colorTexture),vec2(intensity, 0));\n outputColor = color;\n // gl_FragColor.a = color.a * smoothstep(0.1,0.2,intensity)* u_opacity;\n outputColor.a = color.a * smoothstep(0.,0.1,intensity) * u_opacity;\n}\n";
11
11
  /* babel-plugin-inline-import '../shaders/heatmap/heatmap_3d_vert.glsl' */
12
- const heatmap_3d_vert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 14) in vec2 a_Uv;\n\nlayout(std140) uniform commonUniforms {\n mat4 u_ViewProjectionMatrixUncentered;\n mat4 u_InverseViewProjectionMatrix;\n float u_opacity;\n float u_common_uniforms_padding1;\n float u_common_uniforms_padding2;\n float u_common_uniforms_padding3;\n};\n\nuniform sampler2D u_texture;\nuniform sampler2D u_colorTexture;\n\nout vec2 v_texCoord;\nout float v_intensity;\n\nvec2 toBezier(float t, vec2 P0, vec2 P1, vec2 P2, vec2 P3) {\n float t2 = t * t;\n float one_minus_t = 1.0 - t;\n float one_minus_t2 = one_minus_t * one_minus_t;\n return (P0 * one_minus_t2 * one_minus_t + P1 * 3.0 * t * one_minus_t2 + P2 * 3.0 * t2 * one_minus_t + P3 * t2 * t);\n}\nvec2 toBezier(float t, vec4 p){\n return toBezier(t, vec2(0.0, 0.0), vec2(p.x, p.y), vec2(p.z, p.w), vec2(1.0, 1.0));\n}\n\n#pragma include \"projection\"\n#pragma include \"project\"\n\nvoid main() {\n v_texCoord = a_Uv;\n\n vec2 pos = a_Uv * vec2(2.0) - vec2(1.0); // \u5C06\u539F\u672C 0 -> 1 \u7684 uv \u8F6C\u6362\u4E3A -1 -> 1 \u7684\u6807\u51C6\u5750\u6807\u7A7A\u95F4\uFF08NDC\uFF09\n\n vec4 p1 = vec4(pos, 0.0, 1.0); // x/y \u5E73\u9762\u4E0A\u7684\u70B9\uFF08z == 0\uFF09\u53EF\u4EE5\u8BA4\u4E3A\u662F\u4E09\u7EF4\u4E0A\u7684\u70B9\u88AB\u6295\u5F71\u5230\u5E73\u9762\u540E\u7684\u70B9\n\tvec4 p2 = vec4(pos, 1.0, 1.0); // \u5E73\u884C\u4E8Ex/y\u5E73\u9762\u3001z==1 \u7684\u5E73\u9762\u4E0A\u7684\u70B9\n\n\tvec4 inverseP1 = u_InverseViewProjectionMatrix * p1; // \u6839\u636E\u89C6\u56FE\u6295\u5F71\u77E9\u9635\u7684\u9006\u77E9\u9635\u5E73\u9762\u4E0A\u7684\u53CD\u7B97\u51FA\u4E09\u7EF4\u7A7A\u95F4\u4E2D\u7684\u70B9\uFF08p1\u5E73\u9762\u4E0A\u7684\u70B9\uFF09\n\tvec4 inverseP2 = u_InverseViewProjectionMatrix * p2;\n\n inverseP1 = inverseP1 / inverseP1.w; // \u5F52\u4E00\u5316\u64CD\u4F5C\uFF08\u5F52\u4E00\u5316\u540E\u4E3A\u4E16\u754C\u5750\u6807\uFF09\n\tinverseP2 = inverseP2 / inverseP2.w;\n\n\tfloat zPos = (0.0 - inverseP1.z) / (inverseP2.z - inverseP1.z); // ??\n\tvec4 position = inverseP1 + zPos * (inverseP2 - inverseP1);\n\n vec4 b= vec4(0.5000, 0.0, 1.0, 0.5000);\n float fh;\n\n v_intensity = texture(SAMPLER_2D(u_texture), v_texCoord).r;\n fh = toBezier(v_intensity, b).y;\n gl_Position = u_ViewProjectionMatrixUncentered * vec4(position.xy, fh * project_pixel(50.), 1.0);\n \n}\n"; // 绘制平面热力的 shader
12
+ const heatmap_3d_vert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 10) in vec2 a_Uv;\n\nlayout(std140) uniform commonUniforms {\n mat4 u_ViewProjectionMatrixUncentered;\n mat4 u_InverseViewProjectionMatrix;\n float u_opacity;\n float u_common_uniforms_padding1;\n float u_common_uniforms_padding2;\n float u_common_uniforms_padding3;\n};\n\nuniform sampler2D u_texture;\nuniform sampler2D u_colorTexture;\n\nout vec2 v_texCoord;\nout float v_intensity;\n\nvec2 toBezier(float t, vec2 P0, vec2 P1, vec2 P2, vec2 P3) {\n float t2 = t * t;\n float one_minus_t = 1.0 - t;\n float one_minus_t2 = one_minus_t * one_minus_t;\n return P0 * one_minus_t2 * one_minus_t +\n P1 * 3.0 * t * one_minus_t2 +\n P2 * 3.0 * t2 * one_minus_t +\n P3 * t2 * t;\n}\nvec2 toBezier(float t, vec4 p) {\n return toBezier(t, vec2(0.0, 0.0), vec2(p.x, p.y), vec2(p.z, p.w), vec2(1.0, 1.0));\n}\n\n#pragma include \"projection\"\n#pragma include \"project\"\n\nvoid main() {\n v_texCoord = a_Uv;\n\n vec2 pos = a_Uv * vec2(2.0) - vec2(1.0); // \u5C06\u539F\u672C 0 -> 1 \u7684 uv \u8F6C\u6362\u4E3A -1 -> 1 \u7684\u6807\u51C6\u5750\u6807\u7A7A\u95F4\uFF08NDC\uFF09\n\n vec4 p1 = vec4(pos, 0.0, 1.0); // x/y \u5E73\u9762\u4E0A\u7684\u70B9\uFF08z == 0\uFF09\u53EF\u4EE5\u8BA4\u4E3A\u662F\u4E09\u7EF4\u4E0A\u7684\u70B9\u88AB\u6295\u5F71\u5230\u5E73\u9762\u540E\u7684\u70B9\n vec4 p2 = vec4(pos, 1.0, 1.0); // \u5E73\u884C\u4E8Ex/y\u5E73\u9762\u3001z==1 \u7684\u5E73\u9762\u4E0A\u7684\u70B9\n\n vec4 inverseP1 = u_InverseViewProjectionMatrix * p1; // \u6839\u636E\u89C6\u56FE\u6295\u5F71\u77E9\u9635\u7684\u9006\u77E9\u9635\u5E73\u9762\u4E0A\u7684\u53CD\u7B97\u51FA\u4E09\u7EF4\u7A7A\u95F4\u4E2D\u7684\u70B9\uFF08p1\u5E73\u9762\u4E0A\u7684\u70B9\uFF09\n vec4 inverseP2 = u_InverseViewProjectionMatrix * p2;\n\n inverseP1 = inverseP1 / inverseP1.w; // \u5F52\u4E00\u5316\u64CD\u4F5C\uFF08\u5F52\u4E00\u5316\u540E\u4E3A\u4E16\u754C\u5750\u6807\uFF09\n inverseP2 = inverseP2 / inverseP2.w;\n\n float zPos = (0.0 - inverseP1.z) / (inverseP2.z - inverseP1.z); // ??\n vec4 position = inverseP1 + zPos * (inverseP2 - inverseP1);\n\n vec4 b = vec4(0.5, 0.0, 1.0, 0.5);\n float fh;\n\n v_intensity = texture(SAMPLER_2D(u_texture), v_texCoord).r;\n fh = toBezier(v_intensity, b).y;\n gl_Position = u_ViewProjectionMatrixUncentered * vec4(position.xy, fh * project_pixel(50.0), 1.0);\n\n}\n"; // 绘制平面热力的 shader
13
13
  /* babel-plugin-inline-import '../shaders/heatmap/heatmap_frag.glsl' */
14
14
  const heatmap_frag = "uniform sampler2D u_texture; // \u70ED\u529B\u5F3A\u5EA6\u56FE\nuniform sampler2D u_colorTexture; // \u6839\u636E\u5F3A\u5EA6\u5206\u5E03\u7684\u8272\u5E26\n\nlayout(std140) uniform commonUniforms {\n float u_opacity;\n float u_common_uniforms_padding1;\n float u_common_uniforms_padding2;\n float u_common_uniforms_padding3;\n};\nin vec2 v_texCoord;\nout vec4 outputColor;\n\n#pragma include \"scene_uniforms\"\n\nfloat getBlurIndusty() {\n float vW = 2.0/ u_ViewportSize.x;\n float vH = 2.0/ u_ViewportSize.y;\n vec2 vUv = v_texCoord;\n float i11 = texture(SAMPLER_2D(u_texture), vec2( vUv.x - 1.0 * vW, vUv.y + 1.0 * vH) ).r;\n float i12 = texture(SAMPLER_2D(u_texture), vec2( vUv.x - 0.0 * vW, vUv.y + 1.0 * vH) ).r;\n float i13 = texture(SAMPLER_2D(u_texture), vec2( vUv.x + 1.0 * vW, vUv.y + 1.0 * vH) ).r;\n\n float i21 = texture(SAMPLER_2D(u_texture), vec2( vUv.x - 1.0 * vW, vUv.y) ).r;\n float i22 = texture(SAMPLER_2D(u_texture), vec2( vUv.x , vUv.y) ).r;\n float i23 = texture(SAMPLER_2D(u_texture), vec2( vUv.x + 1.0 * vW, vUv.y) ).r;\n\n float i31 = texture(SAMPLER_2D(u_texture), vec2( vUv.x - 1.0 * vW, vUv.y-1.0*vH) ).r;\n float i32 = texture(SAMPLER_2D(u_texture), vec2( vUv.x - 0.0 * vW, vUv.y-1.0*vH) ).r;\n float i33 = texture(SAMPLER_2D(u_texture), vec2( vUv.x + 1.0 * vW, vUv.y-1.0*vH) ).r;\n\n return(\n i11 + \n i12 + \n i13 + \n i21 + \n i21 + \n i22 + \n i23 + \n i31 + \n i32 + \n i33\n )/9.0;\n}\n\n\nvoid main(){\n // float intensity = texture(u_texture, v_texCoord).r;\n float intensity = getBlurIndusty();\n vec4 color = texture(SAMPLER_2D(u_colorTexture), vec2(intensity, 0.0));\n outputColor = color;\n outputColor.a = color.a * smoothstep(0.,0.1,intensity) * u_opacity;\n}\n";
15
15
  /* babel-plugin-inline-import '../shaders/heatmap/heatmap_vert.glsl' */
16
- const heatmap_vert = "\nlayout(location = 0) in vec3 a_Position;\nlayout(location = 14) in vec2 a_Uv;\n\nlayout(std140) uniform commonUniforms {\n float u_opacity;\n float u_common_uniforms_padding1;\n float u_common_uniforms_padding2;\n float u_common_uniforms_padding3;\n};\n\n#pragma include \"scene_uniforms\"\n\nout vec2 v_texCoord;\nvoid main() {\n v_texCoord = a_Uv;\n #ifdef VIEWPORT_ORIGIN_TL\n v_texCoord.y = 1.0 - v_texCoord.y;\n #endif\n\n gl_Position = vec4(a_Position.xy, 0, 1.);\n}\n";
17
- import { ShaderLocation } from "../../core/CommonStyleAttribute";
16
+ const heatmap_vert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 10) in vec2 a_Uv;\n\nlayout(std140) uniform commonUniforms {\n float u_opacity;\n float u_common_uniforms_padding1;\n float u_common_uniforms_padding2;\n float u_common_uniforms_padding3;\n};\n\n#pragma include \"scene_uniforms\"\n\nout vec2 v_texCoord;\nvoid main() {\n v_texCoord = a_Uv;\n #ifdef VIEWPORT_ORIGIN_TL\n v_texCoord.y = 1.0 - v_texCoord.y;\n #endif\n\n gl_Position = vec4(a_Position.xy, 0, 1.0);\n}\n";
18
17
  /* babel-plugin-inline-import '../shaders/heatmap/heatmap_framebuffer_frag.glsl' */
19
18
  const heatmap_framebuffer_frag = "layout(std140) uniform commonUniforms {\n float u_radius;\n float u_intensity;\n float u_common_uniforms_padding1;\n float u_common_uniforms_padding2;\n};\n\nin vec2 v_extrude;\nin float v_weight;\nout vec4 outputColor;\n#define GAUSS_COEF 0.3989422804014327\n\nvoid main(){\n float d = -0.5 * 3.0 * 3.0 * dot(v_extrude, v_extrude);\n float val = v_weight * u_intensity * GAUSS_COEF * exp(d);\n outputColor = vec4(val, 1., 1., 1.);\n}\n";
20
19
  /* babel-plugin-inline-import '../shaders/heatmap/heatmap_framebuffer_vert.glsl' */
21
- const heatmap_framebuffer_vert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 9) in float a_Size;\nlayout(location = 10) in vec2 a_Dir;\n\n\nlayout(std140) uniform commonUniforms {\n float u_radius;\n float u_intensity;\n float u_common_uniforms_padding1;\n float u_common_uniforms_padding2;\n};\n\nout vec2 v_extrude;\nout float v_weight;\n\n#define GAUSS_COEF 0.3989422804014327\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main(){\n vec3 picking_color_placeholder = u_PickingColor;\n\n v_weight = a_Size;\n float ZERO = 1.0 / 255.0 / 16.0;\n float extrude_x = a_Dir.x * 2.0 -1.0;\n float extrude_y = a_Dir.y * 2.0 -1.0;\n vec2 extrude_dir = normalize(vec2(extrude_x,extrude_y));\n float S = sqrt(-2.0 * log(ZERO / a_Size / u_intensity / GAUSS_COEF)) / 2.5;\n v_extrude = extrude_dir * S;\n\n vec2 offset = project_pixel(v_extrude * u_radius);\n vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0));\n\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xy + offset, 0.0, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));\n }\n}\n";
20
+ const heatmap_framebuffer_vert = "layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_SIZE) in float a_Size;\nlayout(location = ATTRIBUTE_LOCATION_DIR) in vec2 a_Dir;\n\nlayout(std140) uniform commonUniforms {\n float u_radius;\n float u_intensity;\n float u_common_uniforms_padding1;\n float u_common_uniforms_padding2;\n};\n\nout vec2 v_extrude;\nout float v_weight;\n\n#define GAUSS_COEF (0.3989422804014327)\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n vec3 picking_color_placeholder = u_PickingColor;\n\n v_weight = a_Size;\n float ZERO = 1.0 / 255.0 / 16.0;\n float extrude_x = a_Dir.x * 2.0 - 1.0;\n float extrude_y = a_Dir.y * 2.0 - 1.0;\n vec2 extrude_dir = normalize(vec2(extrude_x, extrude_y));\n float S = sqrt(-2.0 * log(ZERO / a_Size / u_intensity / GAUSS_COEF)) / 2.5;\n v_extrude = extrude_dir * S;\n\n vec2 offset = project_pixel(v_extrude * u_radius);\n vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0));\n\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));\n\n}\n";
22
21
  import { heatMap3DTriangulation } from "../triangulation";
23
22
  const {
24
23
  isEqual
@@ -37,6 +36,14 @@ export default class HeatMapModel extends BaseModel {
37
36
  _defineProperty(this, "colorModelUniformBuffer", []);
38
37
  _defineProperty(this, "heat3DModelUniformBuffer", []);
39
38
  }
39
+ get attributeLocation() {
40
+ return Object.assign(super.attributeLocation, {
41
+ MAX: super.attributeLocation.MAX,
42
+ SIZE: 9,
43
+ UV: 10,
44
+ DIR: 11
45
+ });
46
+ }
40
47
  prerender() {
41
48
  const {
42
49
  clear,
@@ -120,7 +127,7 @@ export default class HeatMapModel extends BaseModel {
120
127
  type: AttributeType.Attribute,
121
128
  descriptor: {
122
129
  name: 'a_Dir',
123
- shaderLocation: 10,
130
+ shaderLocation: this.attributeLocation.DIR,
124
131
  buffer: {
125
132
  usage: gl.DYNAMIC_DRAW,
126
133
  data: [],
@@ -137,7 +144,7 @@ export default class HeatMapModel extends BaseModel {
137
144
  type: AttributeType.Attribute,
138
145
  descriptor: {
139
146
  name: 'a_Size',
140
- shaderLocation: ShaderLocation.SIZE,
147
+ shaderLocation: this.attributeLocation.SIZE,
141
148
  buffer: {
142
149
  // give the WebGL driver a hint that this buffer may change
143
150
  usage: gl.DYNAMIC_DRAW,
@@ -154,6 +161,10 @@ export default class HeatMapModel extends BaseModel {
154
161
  }
155
162
  });
156
163
  }
164
+
165
+ /**
166
+ * 热力图密度图
167
+ */
157
168
  buildHeatMapIntensity() {
158
169
  var _this3 = this;
159
170
  return _asyncToGenerator(function* () {
@@ -169,12 +180,13 @@ export default class HeatMapModel extends BaseModel {
169
180
  vertexShader: heatmap_framebuffer_vert,
170
181
  fragmentShader: heatmap_framebuffer_frag,
171
182
  triangulation: HeatmapTriangulation,
183
+ defines: _this3.getDefines(),
172
184
  depth: {
173
185
  enable: false
174
186
  },
175
187
  cull: {
176
188
  enable: true,
177
- face: getCullFace(_this3.mapService.version)
189
+ face: gl.FRONT
178
190
  }
179
191
  });
180
192
  return model;
@@ -208,7 +220,7 @@ export default class HeatMapModel extends BaseModel {
208
220
  uniformBuffers: [...this.colorModelUniformBuffer, ...this.rendererService.uniformBuffers],
209
221
  attributes: {
210
222
  a_Position: createAttribute({
211
- shaderLocation: ShaderLocation.POSITION,
223
+ shaderLocation: this.attributeLocation.POSITION,
212
224
  buffer: createBuffer({
213
225
  data: [-1, 1, 0, 1, 1, 0, -1, -1, 0, 1, -1, 0],
214
226
  type: gl.FLOAT
@@ -216,7 +228,7 @@ export default class HeatMapModel extends BaseModel {
216
228
  size: 3
217
229
  }),
218
230
  a_Uv: createAttribute({
219
- shaderLocation: ShaderLocation.UV,
231
+ shaderLocation: this.attributeLocation.UV,
220
232
  buffer: createBuffer({
221
233
  data: [0, 1, 1, 1, 0, 0, 1, 0],
222
234
  type: gl.FLOAT
@@ -235,6 +247,80 @@ export default class HeatMapModel extends BaseModel {
235
247
  })
236
248
  });
237
249
  }
250
+ build3dHeatMap() {
251
+ const {
252
+ getViewportSize
253
+ } = this.rendererService;
254
+ const {
255
+ width,
256
+ height
257
+ } = getViewportSize();
258
+ const triangulation = heatMap3DTriangulation(width / 4.0, height / 4.0);
259
+ this.shaderModuleService.registerModule('heatmap3dColor', {
260
+ vs: heatmap_3d_vert,
261
+ fs: heatmap_3d_frag
262
+ });
263
+ this.heat3DModelUniformBuffer = [this.rendererService.createBuffer({
264
+ // opacity
265
+ data: new Float32Array(16 * 2 + 4).fill(0),
266
+ // 长度需要大于等于 4
267
+ isUBO: true
268
+ })];
269
+ const {
270
+ vs,
271
+ fs,
272
+ uniforms
273
+ } = this.shaderModuleService.getModule('heatmap3dColor');
274
+ const {
275
+ createAttribute,
276
+ createElements,
277
+ createBuffer,
278
+ createModel
279
+ } = this.rendererService;
280
+ return createModel({
281
+ vs,
282
+ fs,
283
+ attributes: {
284
+ a_Position: createAttribute({
285
+ shaderLocation: this.attributeLocation.POSITION,
286
+ buffer: createBuffer({
287
+ data: triangulation.vertices,
288
+ type: gl.FLOAT
289
+ }),
290
+ size: 3
291
+ }),
292
+ a_Uv: createAttribute({
293
+ shaderLocation: this.attributeLocation.UV,
294
+ buffer: createBuffer({
295
+ data: triangulation.uvs,
296
+ type: gl.FLOAT
297
+ }),
298
+ size: 2
299
+ })
300
+ },
301
+ primitive: gl.TRIANGLES,
302
+ uniformBuffers: [...this.heat3DModelUniformBuffer, ...this.rendererService.uniformBuffers],
303
+ uniforms: _objectSpread({}, uniforms),
304
+ depth: {
305
+ enable: true
306
+ },
307
+ blend: {
308
+ enable: true,
309
+ func: {
310
+ srcRGB: gl.SRC_ALPHA,
311
+ srcAlpha: 1,
312
+ dstRGB: gl.ONE_MINUS_SRC_ALPHA,
313
+ dstAlpha: 1
314
+ }
315
+ },
316
+ elements: createElements({
317
+ data: triangulation.indices,
318
+ type: gl.UNSIGNED_INT,
319
+ count: triangulation.indices.length
320
+ })
321
+ });
322
+ }
323
+
238
324
  // 绘制密度图
239
325
  drawIntensityMode() {
240
326
  var _this$intensityModel;
@@ -334,79 +420,6 @@ export default class HeatMapModel extends BaseModel {
334
420
  stencil: this.getStencil(options)
335
421
  });
336
422
  }
337
- build3dHeatMap() {
338
- const {
339
- getViewportSize
340
- } = this.rendererService;
341
- const {
342
- width,
343
- height
344
- } = getViewportSize();
345
- const triangulation = heatMap3DTriangulation(width / 4.0, height / 4.0);
346
- this.shaderModuleService.registerModule('heatmap3dColor', {
347
- vs: heatmap_3d_vert,
348
- fs: heatmap_3d_frag
349
- });
350
- this.heat3DModelUniformBuffer = [this.rendererService.createBuffer({
351
- // opacity
352
- data: new Float32Array(16 * 2 + 4).fill(0),
353
- // 长度需要大于等于 4
354
- isUBO: true
355
- })];
356
- const {
357
- vs,
358
- fs,
359
- uniforms
360
- } = this.shaderModuleService.getModule('heatmap3dColor');
361
- const {
362
- createAttribute,
363
- createElements,
364
- createBuffer,
365
- createModel
366
- } = this.rendererService;
367
- return createModel({
368
- vs,
369
- fs,
370
- attributes: {
371
- a_Position: createAttribute({
372
- shaderLocation: ShaderLocation.POSITION,
373
- buffer: createBuffer({
374
- data: triangulation.vertices,
375
- type: gl.FLOAT
376
- }),
377
- size: 3
378
- }),
379
- a_Uv: createAttribute({
380
- shaderLocation: ShaderLocation.UV,
381
- buffer: createBuffer({
382
- data: triangulation.uvs,
383
- type: gl.FLOAT
384
- }),
385
- size: 2
386
- })
387
- },
388
- primitive: gl.TRIANGLES,
389
- uniformBuffers: [...this.heat3DModelUniformBuffer, ...this.rendererService.uniformBuffers],
390
- uniforms: _objectSpread({}, uniforms),
391
- depth: {
392
- enable: true
393
- },
394
- blend: {
395
- enable: true,
396
- func: {
397
- srcRGB: gl.SRC_ALPHA,
398
- srcAlpha: 1,
399
- dstRGB: gl.ONE_MINUS_SRC_ALPHA,
400
- dstAlpha: 1
401
- }
402
- },
403
- elements: createElements({
404
- data: triangulation.indices,
405
- type: gl.UNSIGNED_INT,
406
- count: triangulation.indices.length
407
- })
408
- });
409
- }
410
423
  updateColorTexture() {
411
424
  const {
412
425
  createTexture2D
@@ -1,6 +1,20 @@
1
1
  import type { IModel, IModelUniform } from '@antv/l7-core';
2
2
  import BaseModel from '../../core/BaseModel';
3
3
  export default class HexagonModel 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
+ POS: number;
17
+ };
4
18
  getUninforms(): IModelUniform;
5
19
  protected getCommonUniformsInfo(): {
6
20
  uniformsArray: number[];
@@ -6,8 +6,14 @@ import { HeatmapGridTriangulation } from "../../core/triangulation";
6
6
  /* babel-plugin-inline-import '../shaders/hexagon/hexagon_frag.glsl' */
7
7
  const hexagon_frag = "in vec4 v_color;\n\n#pragma include \"picking\"\nout vec4 outputColor;\nvoid main() {\n outputColor = v_color;\n outputColor = filterColor(outputColor);\n}\n";
8
8
  /* babel-plugin-inline-import '../shaders/hexagon/hexagon_vert.glsl' */
9
- const hexagon_vert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 10) in vec3 a_Pos;\n\nlayout(std140) uniform commonUniforms {\n vec2 u_radius;\n float u_opacity;\n float u_coverage;\n float u_angle;\n};\n\nout vec4 v_color;\n\n\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"picking\"\n\nvoid main() {\n v_color = a_Color;\n v_color.a *= u_opacity;\n \n mat2 rotationMatrix = mat2(cos(u_angle), sin(u_angle), -sin(u_angle), cos(u_angle));\n vec2 offset =(vec2(a_Position.xy * u_radius * rotationMatrix * u_coverage));\n vec2 lnglat = unProjectFlat(a_Pos.xy + offset);\n \n // vec4 project_pos = project_position(vec4(lnglat, 0, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy, 0., 1.0));\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n // gl_Position = u_Mvp * (vec4(project_pos.xy, 0., 1.0));\n // gl_Position = u_Mvp * (vec4(a_Pos.xy + offset, 0., 1.0));\n vec2 customLnglat = customProject(lnglat) - u_sceneCenterMercator;\n vec4 project_pos = project_position(vec4(customLnglat, 0, 1.0));\n gl_Position = u_Mvp * vec4(project_pos.xy, 0.0, 1.0);\n } else {\n vec4 project_pos = project_position(vec4(lnglat, 0, 1.0));\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy, 0., 1.0));\n }\n setPickingColor(a_PickingColor);\n}\n";
9
+ const hexagon_vert = "layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;\nlayout(location = ATTRIBUTE_LOCATION_POS) in vec3 a_Pos;\n\nlayout(std140) uniform commonUniforms {\n vec2 u_radius;\n float u_opacity;\n float u_coverage;\n float u_angle;\n};\n\nout vec4 v_color;\n\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"picking\"\n\nvoid main() {\n v_color = a_Color;\n v_color.a *= u_opacity;\n\n mat2 rotationMatrix = mat2(cos(u_angle), sin(u_angle), -sin(u_angle), cos(u_angle));\n vec2 offset = vec2(a_Position.xy * u_radius * rotationMatrix * u_coverage);\n vec2 lnglat = unProjectFlat(a_Pos.xy + offset);\n\n vec4 project_pos = project_position(vec4(lnglat, 0, 1.0));\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy, 0.0, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
10
10
  export default class HexagonModel extends BaseModel {
11
+ get attributeLocation() {
12
+ return Object.assign(super.attributeLocation, {
13
+ MAX: super.attributeLocation.MAX,
14
+ POS: 9
15
+ });
16
+ }
11
17
  getUninforms() {
12
18
  const commoninfo = this.getCommonUniformsInfo();
13
19
  const attributeInfo = this.getUniformsBufferInfo(this.getStyleAttribute());
@@ -59,7 +65,7 @@ export default class HexagonModel extends BaseModel {
59
65
  type: AttributeType.Attribute,
60
66
  descriptor: {
61
67
  name: 'a_Pos',
62
- shaderLocation: 10,
68
+ shaderLocation: this.attributeLocation.POS,
63
69
  buffer: {
64
70
  usage: gl.DYNAMIC_DRAW,
65
71
  data: [],
@@ -67,7 +73,7 @@ export default class HexagonModel extends BaseModel {
67
73
  },
68
74
  size: 3,
69
75
  update: feature => {
70
- const coordinates = feature.version === 'GAODE2.x' ? feature.originCoordinates : feature.coordinates;
76
+ const coordinates = feature.coordinates;
71
77
  return [coordinates[0], coordinates[1], 0];
72
78
  }
73
79
  }
@@ -1,42 +1,30 @@
1
- layout(location = 0) in vec3 a_Position;
2
- layout(location = 1) in vec4 a_Color;
3
- layout(location = 10) in vec3 a_Pos;
4
-
5
- layout(std140) uniform commonUniforms {
6
- vec2 u_radius;
7
- float u_opacity;
8
- float u_coverage;
9
- float u_angle;
10
- };
11
-
12
-
13
- out vec4 v_color;
14
-
15
-
16
- #pragma include "projection"
17
- #pragma include "project"
18
- #pragma include "picking"
19
-
20
- void main() {
21
- v_color = a_Color;
22
- v_color.a *= u_opacity;
23
-
24
- mat2 rotationMatrix = mat2(cos(u_angle), sin(u_angle), -sin(u_angle), cos(u_angle));
25
- vec2 offset = a_Position.xy * u_radius * rotationMatrix * u_coverage ;
26
- // vec2 lnglat = unProjectFlat(a_Pos.xy + offset);
27
- // vec4 project_pos = project_position(vec4(lnglat, 0, 1.0));
28
- // gl_Position = project_common_position_to_clipspace(project_pos);
29
-
30
- if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
31
- vec2 lnglat = unProjectFlat(a_Pos.xy + offset);
32
- vec2 customLnglat = customProject(lnglat) - u_sceneCenterMercator; // 将经纬度转换为高德2.0需要的平面坐标
33
- vec4 project_pos = project_position(vec4(customLnglat, 0, 1.0));
34
- gl_Position = u_Mvp * (project_pos);
35
- } else {
36
- vec2 lnglat = unProjectFlat(a_Pos.xy + offset);
37
- vec4 project_pos = project_position(vec4(lnglat, 0, 1.0));
38
- gl_Position = project_common_position_to_clipspace(project_pos);
39
- }
40
-
41
- setPickingColor(a_PickingColor);
42
- }
1
+ layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;
2
+ layout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;
3
+ layout(location = ATTRIBUTE_LOCATION_POS) in vec3 a_Pos;
4
+
5
+ layout(std140) uniform commonUniforms {
6
+ vec2 u_radius;
7
+ float u_opacity;
8
+ float u_coverage;
9
+ float u_angle;
10
+ };
11
+
12
+ out vec4 v_color;
13
+
14
+ #pragma include "projection"
15
+ #pragma include "project"
16
+ #pragma include "picking"
17
+
18
+ void main() {
19
+ v_color = a_Color;
20
+ v_color.a *= u_opacity;
21
+
22
+ mat2 rotationMatrix = mat2(cos(u_angle), sin(u_angle), -sin(u_angle), cos(u_angle));
23
+ vec2 offset = a_Position.xy * u_radius * rotationMatrix * u_coverage;
24
+
25
+ vec2 lnglat = unProjectFlat(a_Pos.xy + offset);
26
+ vec4 project_pos = project_position(vec4(lnglat, 0, 1.0));
27
+ gl_Position = project_common_position_to_clipspace(project_pos);
28
+
29
+ setPickingColor(a_PickingColor);
30
+ }
@@ -1,8 +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 = 10) in vec3 a_Pos;
5
- layout(location = 13) in vec3 a_Normal;
1
+ layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;
2
+ layout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;
3
+ layout(location = ATTRIBUTE_LOCATION_SIZE) in float a_Size;
4
+ layout(location = ATTRIBUTE_LOCATION_POS) in vec3 a_Pos;
5
+ layout(location = ATTRIBUTE_LOCATION_NORMAL) in vec3 a_Normal;
6
6
 
7
7
  layout(std140) uniform commonUniforms {
8
8
  vec2 u_radius;
@@ -20,27 +20,15 @@ out vec4 v_color;
20
20
 
21
21
  void main() {
22
22
  mat2 rotationMatrix = mat2(cos(u_angle), sin(u_angle), -sin(u_angle), cos(u_angle));
23
- vec2 offset =(vec2(a_Position.xy * u_radius * rotationMatrix * u_coverage));
24
-
25
- if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
26
-
27
- vec2 lnglat = unProjectFlat(a_Pos.xy + offset); // 经纬度
28
- vec2 customLnglat = customProject(lnglat) - u_sceneCenterMercator; // 将经纬度转换为高德2.0需要的平面坐标
29
- vec4 project_pos = project_position(vec4(customLnglat, a_Position.z * a_Size, 1.0));
30
-
31
- float lightWeight = calc_lighting(project_pos);
32
- v_color =vec4(a_Color.rgb*lightWeight, a_Color.w * u_opacity);
33
-
34
- gl_Position = u_Mvp * vec4(customLnglat , a_Position.z * a_Size, 1.0);
35
- } else {
36
- vec2 lnglat = unProjectFlat(a_Pos.xy + offset); // 实际的经纬度
37
- vec4 project_pos = project_position(vec4(lnglat, a_Position.z * a_Size, 1.0));
38
-
39
- float lightWeight = calc_lighting(project_pos);
40
- v_color =vec4(a_Color.rgb*lightWeight, a_Color.w);
41
-
42
- gl_Position = project_common_position_to_clipspace(project_pos);
43
- }
23
+ vec2 offset = vec2(a_Position.xy * u_radius * rotationMatrix * u_coverage);
24
+
25
+ vec2 lnglat = unProjectFlat(a_Pos.xy + offset); // 实际的经纬度
26
+ vec4 project_pos = project_position(vec4(lnglat, a_Position.z * a_Size, 1.0));
27
+
28
+ float lightWeight = calc_lighting(project_pos);
29
+ v_color = vec4(a_Color.rgb * lightWeight, a_Color.w);
30
+
31
+ gl_Position = project_common_position_to_clipspace(project_pos);
44
32
 
45
33
  setPickingColor(a_PickingColor);
46
34
  }
@@ -1,5 +1,5 @@
1
1
  layout(location = 0) in vec3 a_Position;
2
- layout(location = 14) in vec2 a_Uv;
2
+ layout(location = 10) in vec2 a_Uv;
3
3
 
4
4
  layout(std140) uniform commonUniforms {
5
5
  mat4 u_ViewProjectionMatrixUncentered;
@@ -17,13 +17,16 @@ out vec2 v_texCoord;
17
17
  out float v_intensity;
18
18
 
19
19
  vec2 toBezier(float t, vec2 P0, vec2 P1, vec2 P2, vec2 P3) {
20
- float t2 = t * t;
21
- float one_minus_t = 1.0 - t;
22
- float one_minus_t2 = one_minus_t * one_minus_t;
23
- return (P0 * one_minus_t2 * one_minus_t + P1 * 3.0 * t * one_minus_t2 + P2 * 3.0 * t2 * one_minus_t + P3 * t2 * t);
20
+ float t2 = t * t;
21
+ float one_minus_t = 1.0 - t;
22
+ float one_minus_t2 = one_minus_t * one_minus_t;
23
+ return P0 * one_minus_t2 * one_minus_t +
24
+ P1 * 3.0 * t * one_minus_t2 +
25
+ P2 * 3.0 * t2 * one_minus_t +
26
+ P3 * t2 * t;
24
27
  }
25
- vec2 toBezier(float t, vec4 p){
26
- return toBezier(t, vec2(0.0, 0.0), vec2(p.x, p.y), vec2(p.z, p.w), vec2(1.0, 1.0));
28
+ vec2 toBezier(float t, vec4 p) {
29
+ return toBezier(t, vec2(0.0, 0.0), vec2(p.x, p.y), vec2(p.z, p.w), vec2(1.0, 1.0));
27
30
  }
28
31
 
29
32
  #pragma include "projection"
@@ -35,22 +38,22 @@ void main() {
35
38
  vec2 pos = a_Uv * vec2(2.0) - vec2(1.0); // 将原本 0 -> 1 的 uv 转换为 -1 -> 1 的标准坐标空间(NDC)
36
39
 
37
40
  vec4 p1 = vec4(pos, 0.0, 1.0); // x/y 平面上的点(z == 0)可以认为是三维上的点被投影到平面后的点
38
- vec4 p2 = vec4(pos, 1.0, 1.0); // 平行于x/y平面、z==1 的平面上的点
41
+ vec4 p2 = vec4(pos, 1.0, 1.0); // 平行于x/y平面、z==1 的平面上的点
39
42
 
40
- vec4 inverseP1 = u_InverseViewProjectionMatrix * p1; // 根据视图投影矩阵的逆矩阵平面上的反算出三维空间中的点(p1平面上的点)
41
- vec4 inverseP2 = u_InverseViewProjectionMatrix * p2;
43
+ vec4 inverseP1 = u_InverseViewProjectionMatrix * p1; // 根据视图投影矩阵的逆矩阵平面上的反算出三维空间中的点(p1平面上的点)
44
+ vec4 inverseP2 = u_InverseViewProjectionMatrix * p2;
42
45
 
43
46
  inverseP1 = inverseP1 / inverseP1.w; // 归一化操作(归一化后为世界坐标)
44
- inverseP2 = inverseP2 / inverseP2.w;
47
+ inverseP2 = inverseP2 / inverseP2.w;
45
48
 
46
- float zPos = (0.0 - inverseP1.z) / (inverseP2.z - inverseP1.z); // ??
47
- vec4 position = inverseP1 + zPos * (inverseP2 - inverseP1);
49
+ float zPos = (0.0 - inverseP1.z) / (inverseP2.z - inverseP1.z); // ??
50
+ vec4 position = inverseP1 + zPos * (inverseP2 - inverseP1);
48
51
 
49
- vec4 b= vec4(0.5000, 0.0, 1.0, 0.5000);
52
+ vec4 b = vec4(0.5, 0.0, 1.0, 0.5);
50
53
  float fh;
51
54
 
52
55
  v_intensity = texture(SAMPLER_2D(u_texture), v_texCoord).r;
53
56
  fh = toBezier(v_intensity, b).y;
54
- gl_Position = u_ViewProjectionMatrixUncentered * vec4(position.xy, fh * project_pixel(50.), 1.0);
55
-
57
+ gl_Position = u_ViewProjectionMatrixUncentered * vec4(position.xy, fh * project_pixel(50.0), 1.0);
58
+
56
59
  }