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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (283) hide show
  1. package/es/citybuliding/models/build.d.ts +0 -16
  2. package/es/citybuliding/models/build.js +20 -18
  3. package/es/citybuliding/shaders/build_frag.glsl +6 -6
  4. package/es/citybuliding/shaders/build_vert.glsl +14 -8
  5. package/es/core/BaseLayer.js +8 -12
  6. package/es/core/BaseModel.d.ts +2 -15
  7. package/es/core/BaseModel.js +62 -94
  8. package/es/core/CommonStyleAttribute.d.ts +18 -14
  9. package/es/core/CommonStyleAttribute.js +67 -23
  10. package/es/core/triangulation.js +39 -13
  11. package/es/earth/models/atmosphere.d.ts +0 -15
  12. package/es/earth/models/atmosphere.js +24 -30
  13. package/es/earth/models/base.d.ts +0 -15
  14. package/es/earth/models/base.js +24 -30
  15. package/es/earth/models/bloomsphere.d.ts +0 -15
  16. package/es/earth/models/bloomsphere.js +24 -30
  17. package/es/earth/shaders/atmosphere/atmosphere_vert.glsl +5 -7
  18. package/es/earth/shaders/base/base_vert.glsl +3 -3
  19. package/es/earth/shaders/bloomshpere/bloomsphere_vert.glsl +4 -5
  20. package/es/geometry/models/billboard.d.ts +0 -15
  21. package/es/geometry/models/billboard.js +8 -14
  22. package/es/geometry/models/plane.d.ts +0 -14
  23. package/es/geometry/models/plane.js +10 -10
  24. package/es/geometry/models/sprite.js +9 -3
  25. package/es/geometry/shaders/billboard_vert.glsl +25 -28
  26. package/es/geometry/shaders/plane_vert.glsl +6 -6
  27. package/es/geometry/shaders/sprite_vert.glsl +9 -7
  28. package/es/heatmap/models/grid.d.ts +0 -14
  29. package/es/heatmap/models/grid.js +3 -10
  30. package/es/heatmap/models/grid3d.d.ts +0 -16
  31. package/es/heatmap/models/grid3d.js +6 -14
  32. package/es/heatmap/models/heatmap.d.ts +1 -20
  33. package/es/heatmap/models/heatmap.js +83 -96
  34. package/es/heatmap/models/hexagon.d.ts +0 -14
  35. package/es/heatmap/models/hexagon.js +3 -9
  36. package/es/heatmap/shaders/grid/grid_vert.glsl +42 -30
  37. package/es/heatmap/shaders/grid3d/grid_3d_vert.glsl +26 -14
  38. package/es/heatmap/shaders/heatmap/heatmap_3d_vert.glsl +16 -19
  39. package/es/heatmap/shaders/heatmap/heatmap_framebuffer_vert.glsl +22 -16
  40. package/es/heatmap/shaders/heatmap/heatmap_vert.glsl +4 -3
  41. package/es/heatmap/shaders/hexagon/hexagon_vert.glsl +23 -13
  42. package/es/image/models/image.d.ts +0 -14
  43. package/es/image/models/image.js +3 -11
  44. package/es/image/shaders/image_vert.glsl +6 -7
  45. package/es/line/models/arc.d.ts +0 -18
  46. package/es/line/models/arc.js +8 -57
  47. package/es/line/models/arc_3d.d.ts +0 -18
  48. package/es/line/models/arc_3d.js +7 -55
  49. package/es/line/models/flow.d.ts +0 -17
  50. package/es/line/models/flow.js +7 -35
  51. package/es/line/models/great_circle.d.ts +0 -17
  52. package/es/line/models/great_circle.js +6 -34
  53. package/es/line/models/line.d.ts +0 -17
  54. package/es/line/models/line.js +8 -17
  55. package/es/line/models/simple_line.d.ts +0 -14
  56. package/es/line/models/simple_line.js +47 -12
  57. package/es/line/models/wall.d.ts +0 -17
  58. package/es/line/models/wall.js +48 -22
  59. package/es/line/shaders/arc/line_arc_vert.glsl +48 -42
  60. package/es/line/shaders/arc3d/line_arc_3d_vert.glsl +20 -15
  61. package/es/line/shaders/flow/flow_line_vert.glsl +48 -30
  62. package/es/line/shaders/greatCircle/line_arc_great_circle_vert.glsl +72 -56
  63. package/es/line/shaders/line/line_vert.glsl +48 -31
  64. package/es/line/shaders/simple/simpleline_vert.glsl +23 -18
  65. package/es/line/shaders/wall/wall_vert.glsl +45 -36
  66. package/es/mask/models/fill.js +1 -2
  67. package/es/mask/shaders/mask_vert.glsl +7 -2
  68. package/es/plugins/DataMappingPlugin.d.ts +1 -0
  69. package/es/plugins/DataMappingPlugin.js +24 -1
  70. package/es/plugins/PixelPickingPlugin.js +2 -2
  71. package/es/plugins/RegisterStyleAttributePlugin.d.ts +1 -0
  72. package/es/plugins/RegisterStyleAttributePlugin.js +25 -3
  73. package/es/plugins/ShaderUniformPlugin.d.ts +5 -0
  74. package/es/plugins/ShaderUniformPlugin.js +34 -2
  75. package/es/point/models/billboard_point.d.ts +0 -14
  76. package/es/point/models/billboard_point.js +3 -11
  77. package/es/point/models/earthExtrude.d.ts +0 -16
  78. package/es/point/models/earthExtrude.js +8 -15
  79. package/es/point/models/earthFill.d.ts +0 -16
  80. package/es/point/models/earthFill.js +5 -13
  81. package/es/point/models/extrude.d.ts +0 -16
  82. package/es/point/models/extrude.js +12 -19
  83. package/es/point/models/fill.d.ts +0 -16
  84. package/es/point/models/fill.js +5 -16
  85. package/es/point/models/fillImage.d.ts +0 -16
  86. package/es/point/models/fillImage.js +16 -16
  87. package/es/point/models/image.d.ts +0 -15
  88. package/es/point/models/image.js +4 -14
  89. package/es/point/models/normal.d.ts +0 -14
  90. package/es/point/models/normal.js +3 -11
  91. package/es/point/models/radar.d.ts +0 -15
  92. package/es/point/models/radar.js +4 -13
  93. package/es/point/models/text.d.ts +0 -16
  94. package/es/point/models/text.js +11 -18
  95. package/es/point/shaders/billboard/billboard_point_vert.glsl +13 -10
  96. package/es/point/shaders/earthExtrude/earthExtrude_vert.glsl +25 -15
  97. package/es/point/shaders/earthFill/earthFill_vert.glsl +6 -6
  98. package/es/point/shaders/extrude/extrude_vert.glsl +39 -35
  99. package/es/point/shaders/fill/fill_vert.glsl +14 -12
  100. package/es/point/shaders/fillImage/fillImage_vert.glsl +28 -16
  101. package/es/point/shaders/image/image_vert.glsl +12 -15
  102. package/es/point/shaders/normal/normal_vert.glsl +10 -7
  103. package/es/point/shaders/radar/radar_vert.glsl +11 -11
  104. package/es/point/shaders/text/text_vert.glsl +9 -10
  105. package/es/polygon/models/extrude.d.ts +0 -16
  106. package/es/polygon/models/extrude.js +26 -26
  107. package/es/polygon/models/extrusion.d.ts +0 -16
  108. package/es/polygon/models/extrusion.js +4 -34
  109. package/es/polygon/models/fill.d.ts +0 -14
  110. package/es/polygon/models/fill.js +4 -12
  111. package/es/polygon/models/ocean.d.ts +0 -14
  112. package/es/polygon/models/ocean.js +6 -11
  113. package/es/polygon/models/water.d.ts +0 -14
  114. package/es/polygon/models/water.js +6 -11
  115. package/es/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +15 -17
  116. package/es/polygon/shaders/extrude/polygon_extrude_vert.glsl +20 -22
  117. package/es/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +17 -17
  118. package/es/polygon/shaders/extrusion/polygon_extrusion_vert.glsl +8 -8
  119. package/es/polygon/shaders/fill/fill_linear_vert.glsl +6 -7
  120. package/es/polygon/shaders/fill/fill_vert.glsl +12 -10
  121. package/es/polygon/shaders/ocean/ocean_vert.glsl +4 -3
  122. package/es/polygon/shaders/water/polygon_water_vert.glsl +5 -5
  123. package/es/raster/index.d.ts +1 -1
  124. package/es/raster/index.js +1 -1
  125. package/es/raster/models/raster.d.ts +0 -14
  126. package/es/raster/models/raster.js +3 -12
  127. package/es/raster/models/rasterRgb.d.ts +0 -14
  128. package/es/raster/models/rasterRgb.js +3 -12
  129. package/es/raster/models/rasterTerrainRgb.d.ts +0 -14
  130. package/es/raster/models/rasterTerrainRgb.js +3 -11
  131. package/es/raster/shaders/raster/raster_2d_vert.glsl +6 -6
  132. package/es/raster/shaders/rgb/raster_rgb_vert.glsl +11 -11
  133. package/es/raster/shaders/terrain/terrain_rgb_vert.glsl +11 -11
  134. package/es/tile/core/BaseLayer.js +16 -0
  135. package/es/tile/tile/Tile.d.ts +0 -2
  136. package/es/utils/extrude_polyline.d.ts +15 -0
  137. package/es/utils/extrude_polyline.js +217 -0
  138. package/es/utils/multiPassRender.js +2 -10
  139. package/es/wind/models/wind.d.ts +0 -14
  140. package/es/wind/models/wind.js +1 -9
  141. package/es/wind/shaders/wind_vert.glsl +5 -6
  142. package/lib/citybuliding/models/build.d.ts +0 -16
  143. package/lib/citybuliding/models/build.js +20 -18
  144. package/lib/citybuliding/shaders/build_frag.glsl +6 -6
  145. package/lib/citybuliding/shaders/build_vert.glsl +14 -8
  146. package/lib/core/BaseLayer.js +8 -12
  147. package/lib/core/BaseModel.d.ts +2 -15
  148. package/lib/core/BaseModel.js +60 -92
  149. package/lib/core/CommonStyleAttribute.d.ts +18 -14
  150. package/lib/core/CommonStyleAttribute.js +68 -23
  151. package/lib/core/triangulation.js +39 -13
  152. package/lib/earth/models/atmosphere.d.ts +0 -15
  153. package/lib/earth/models/atmosphere.js +24 -30
  154. package/lib/earth/models/base.d.ts +0 -15
  155. package/lib/earth/models/base.js +24 -30
  156. package/lib/earth/models/bloomsphere.d.ts +0 -15
  157. package/lib/earth/models/bloomsphere.js +24 -30
  158. package/lib/earth/shaders/atmosphere/atmosphere_vert.glsl +5 -7
  159. package/lib/earth/shaders/base/base_vert.glsl +3 -3
  160. package/lib/earth/shaders/bloomshpere/bloomsphere_vert.glsl +4 -5
  161. package/lib/geometry/models/billboard.d.ts +0 -15
  162. package/lib/geometry/models/billboard.js +8 -14
  163. package/lib/geometry/models/plane.d.ts +0 -14
  164. package/lib/geometry/models/plane.js +10 -10
  165. package/lib/geometry/models/sprite.js +9 -3
  166. package/lib/geometry/shaders/billboard_vert.glsl +25 -28
  167. package/lib/geometry/shaders/plane_vert.glsl +6 -6
  168. package/lib/geometry/shaders/sprite_vert.glsl +9 -7
  169. package/lib/heatmap/models/grid.d.ts +0 -14
  170. package/lib/heatmap/models/grid.js +3 -10
  171. package/lib/heatmap/models/grid3d.d.ts +0 -16
  172. package/lib/heatmap/models/grid3d.js +6 -14
  173. package/lib/heatmap/models/heatmap.d.ts +1 -20
  174. package/lib/heatmap/models/heatmap.js +82 -95
  175. package/lib/heatmap/models/hexagon.d.ts +0 -14
  176. package/lib/heatmap/models/hexagon.js +3 -9
  177. package/lib/heatmap/shaders/grid/grid_vert.glsl +42 -30
  178. package/lib/heatmap/shaders/grid3d/grid_3d_vert.glsl +26 -14
  179. package/lib/heatmap/shaders/heatmap/heatmap_3d_vert.glsl +16 -19
  180. package/lib/heatmap/shaders/heatmap/heatmap_framebuffer_vert.glsl +22 -16
  181. package/lib/heatmap/shaders/heatmap/heatmap_vert.glsl +4 -3
  182. package/lib/heatmap/shaders/hexagon/hexagon_vert.glsl +23 -13
  183. package/lib/image/models/image.d.ts +0 -14
  184. package/lib/image/models/image.js +3 -11
  185. package/lib/image/shaders/image_vert.glsl +6 -7
  186. package/lib/line/models/arc.d.ts +0 -18
  187. package/lib/line/models/arc.js +7 -56
  188. package/lib/line/models/arc_3d.d.ts +0 -18
  189. package/lib/line/models/arc_3d.js +7 -55
  190. package/lib/line/models/flow.d.ts +0 -17
  191. package/lib/line/models/flow.js +7 -35
  192. package/lib/line/models/great_circle.d.ts +0 -17
  193. package/lib/line/models/great_circle.js +5 -33
  194. package/lib/line/models/line.d.ts +0 -17
  195. package/lib/line/models/line.js +8 -17
  196. package/lib/line/models/simple_line.d.ts +0 -14
  197. package/lib/line/models/simple_line.js +47 -12
  198. package/lib/line/models/wall.d.ts +0 -17
  199. package/lib/line/models/wall.js +48 -22
  200. package/lib/line/shaders/arc/line_arc_vert.glsl +48 -42
  201. package/lib/line/shaders/arc3d/line_arc_3d_vert.glsl +20 -15
  202. package/lib/line/shaders/flow/flow_line_vert.glsl +48 -30
  203. package/lib/line/shaders/greatCircle/line_arc_great_circle_vert.glsl +72 -56
  204. package/lib/line/shaders/line/line_vert.glsl +48 -31
  205. package/lib/line/shaders/simple/simpleline_vert.glsl +23 -18
  206. package/lib/line/shaders/wall/wall_vert.glsl +45 -36
  207. package/lib/mask/models/fill.js +1 -2
  208. package/lib/mask/shaders/mask_vert.glsl +7 -2
  209. package/lib/plugins/DataMappingPlugin.d.ts +1 -0
  210. package/lib/plugins/DataMappingPlugin.js +23 -0
  211. package/lib/plugins/PixelPickingPlugin.js +1 -1
  212. package/lib/plugins/RegisterStyleAttributePlugin.d.ts +1 -0
  213. package/lib/plugins/RegisterStyleAttributePlugin.js +24 -2
  214. package/lib/plugins/ShaderUniformPlugin.d.ts +5 -0
  215. package/lib/plugins/ShaderUniformPlugin.js +34 -2
  216. package/lib/point/models/billboard_point.d.ts +0 -14
  217. package/lib/point/models/billboard_point.js +3 -11
  218. package/lib/point/models/earthExtrude.d.ts +0 -16
  219. package/lib/point/models/earthExtrude.js +7 -14
  220. package/lib/point/models/earthFill.d.ts +0 -16
  221. package/lib/point/models/earthFill.js +5 -13
  222. package/lib/point/models/extrude.d.ts +0 -16
  223. package/lib/point/models/extrude.js +11 -18
  224. package/lib/point/models/fill.d.ts +0 -16
  225. package/lib/point/models/fill.js +5 -16
  226. package/lib/point/models/fillImage.d.ts +0 -16
  227. package/lib/point/models/fillImage.js +16 -16
  228. package/lib/point/models/image.d.ts +0 -15
  229. package/lib/point/models/image.js +4 -14
  230. package/lib/point/models/normal.d.ts +0 -14
  231. package/lib/point/models/normal.js +3 -11
  232. package/lib/point/models/radar.d.ts +0 -15
  233. package/lib/point/models/radar.js +4 -13
  234. package/lib/point/models/text.d.ts +0 -16
  235. package/lib/point/models/text.js +11 -18
  236. package/lib/point/shaders/billboard/billboard_point_vert.glsl +13 -10
  237. package/lib/point/shaders/earthExtrude/earthExtrude_vert.glsl +25 -15
  238. package/lib/point/shaders/earthFill/earthFill_vert.glsl +6 -6
  239. package/lib/point/shaders/extrude/extrude_vert.glsl +39 -35
  240. package/lib/point/shaders/fill/fill_vert.glsl +14 -12
  241. package/lib/point/shaders/fillImage/fillImage_vert.glsl +28 -16
  242. package/lib/point/shaders/image/image_vert.glsl +12 -15
  243. package/lib/point/shaders/normal/normal_vert.glsl +10 -7
  244. package/lib/point/shaders/radar/radar_vert.glsl +11 -11
  245. package/lib/point/shaders/text/text_vert.glsl +9 -10
  246. package/lib/polygon/models/extrude.d.ts +0 -16
  247. package/lib/polygon/models/extrude.js +25 -25
  248. package/lib/polygon/models/extrusion.d.ts +0 -16
  249. package/lib/polygon/models/extrusion.js +4 -34
  250. package/lib/polygon/models/fill.d.ts +0 -14
  251. package/lib/polygon/models/fill.js +4 -12
  252. package/lib/polygon/models/ocean.d.ts +0 -14
  253. package/lib/polygon/models/ocean.js +6 -11
  254. package/lib/polygon/models/water.d.ts +0 -14
  255. package/lib/polygon/models/water.js +6 -11
  256. package/lib/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +15 -17
  257. package/lib/polygon/shaders/extrude/polygon_extrude_vert.glsl +20 -22
  258. package/lib/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +17 -17
  259. package/lib/polygon/shaders/extrusion/polygon_extrusion_vert.glsl +8 -8
  260. package/lib/polygon/shaders/fill/fill_linear_vert.glsl +6 -7
  261. package/lib/polygon/shaders/fill/fill_vert.glsl +12 -10
  262. package/lib/polygon/shaders/ocean/ocean_vert.glsl +4 -3
  263. package/lib/polygon/shaders/water/polygon_water_vert.glsl +5 -5
  264. package/lib/raster/index.d.ts +1 -1
  265. package/lib/raster/index.js +2 -2
  266. package/lib/raster/models/raster.d.ts +0 -14
  267. package/lib/raster/models/raster.js +3 -12
  268. package/lib/raster/models/rasterRgb.d.ts +0 -14
  269. package/lib/raster/models/rasterRgb.js +3 -12
  270. package/lib/raster/models/rasterTerrainRgb.d.ts +0 -14
  271. package/lib/raster/models/rasterTerrainRgb.js +3 -11
  272. package/lib/raster/shaders/raster/raster_2d_vert.glsl +6 -6
  273. package/lib/raster/shaders/rgb/raster_rgb_vert.glsl +11 -11
  274. package/lib/raster/shaders/terrain/terrain_rgb_vert.glsl +11 -11
  275. package/lib/tile/core/BaseLayer.js +16 -0
  276. package/lib/tile/tile/Tile.d.ts +0 -2
  277. package/lib/utils/extrude_polyline.d.ts +15 -0
  278. package/lib/utils/extrude_polyline.js +217 -0
  279. package/lib/utils/multiPassRender.js +2 -10
  280. package/lib/wind/models/wind.d.ts +0 -14
  281. package/lib/wind/models/wind.js +1 -9
  282. package/lib/wind/shaders/wind_vert.glsl +5 -6
  283. package/package.json +9 -9
@@ -13,19 +13,20 @@ var _l7Utils = require("@antv/l7-utils");
13
13
  var _glMatrix = require("gl-matrix");
14
14
  var _BaseModel = _interopRequireDefault(require("../../core/BaseModel"));
15
15
  var _triangulation = require("../../core/triangulation");
16
+ var _CommonStyleAttribute = require("../../core/CommonStyleAttribute");
16
17
  var _triangulation2 = require("../triangulation");
17
18
  /* babel-plugin-inline-import '../shaders/heatmap/heatmap_3d_frag.glsl' */
18
19
  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";
19
20
  /* babel-plugin-inline-import '../shaders/heatmap/heatmap_3d_vert.glsl' */
20
- 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
21
+ 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
21
22
  /* babel-plugin-inline-import '../shaders/heatmap/heatmap_frag.glsl' */
22
23
  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";
23
24
  /* babel-plugin-inline-import '../shaders/heatmap/heatmap_vert.glsl' */
24
- 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";
25
+ 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";
25
26
  /* babel-plugin-inline-import '../shaders/heatmap/heatmap_framebuffer_frag.glsl' */
26
27
  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";
27
28
  /* babel-plugin-inline-import '../shaders/heatmap/heatmap_framebuffer_vert.glsl' */
28
- 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";
29
+ 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";
29
30
  const {
30
31
  isEqual
31
32
  } = _l7Utils.lodashUtil;
@@ -43,14 +44,6 @@ class HeatMapModel extends _BaseModel.default {
43
44
  (0, _defineProperty2.default)(this, "colorModelUniformBuffer", []);
44
45
  (0, _defineProperty2.default)(this, "heat3DModelUniformBuffer", []);
45
46
  }
46
- get attributeLocation() {
47
- return Object.assign(super.attributeLocation, {
48
- MAX: super.attributeLocation.MAX,
49
- SIZE: 9,
50
- UV: 10,
51
- DIR: 11
52
- });
53
- }
54
47
  prerender() {
55
48
  const {
56
49
  clear,
@@ -134,7 +127,7 @@ class HeatMapModel extends _BaseModel.default {
134
127
  type: _l7Core.AttributeType.Attribute,
135
128
  descriptor: {
136
129
  name: 'a_Dir',
137
- shaderLocation: this.attributeLocation.DIR,
130
+ shaderLocation: 10,
138
131
  buffer: {
139
132
  usage: _l7Core.gl.DYNAMIC_DRAW,
140
133
  data: [],
@@ -151,7 +144,7 @@ class HeatMapModel extends _BaseModel.default {
151
144
  type: _l7Core.AttributeType.Attribute,
152
145
  descriptor: {
153
146
  name: 'a_Size',
154
- shaderLocation: this.attributeLocation.SIZE,
147
+ shaderLocation: _CommonStyleAttribute.ShaderLocation.SIZE,
155
148
  buffer: {
156
149
  // give the WebGL driver a hint that this buffer may change
157
150
  usage: _l7Core.gl.DYNAMIC_DRAW,
@@ -168,10 +161,6 @@ class HeatMapModel extends _BaseModel.default {
168
161
  }
169
162
  });
170
163
  }
171
-
172
- /**
173
- * 热力图密度图
174
- */
175
164
  buildHeatMapIntensity() {
176
165
  var _this3 = this;
177
166
  return (0, _asyncToGenerator2.default)(function* () {
@@ -187,13 +176,12 @@ class HeatMapModel extends _BaseModel.default {
187
176
  vertexShader: heatmap_framebuffer_vert,
188
177
  fragmentShader: heatmap_framebuffer_frag,
189
178
  triangulation: _triangulation.HeatmapTriangulation,
190
- defines: _this3.getDefines(),
191
179
  depth: {
192
180
  enable: false
193
181
  },
194
182
  cull: {
195
183
  enable: true,
196
- face: _l7Core.gl.FRONT
184
+ face: (0, _l7Utils.getCullFace)(_this3.mapService.version)
197
185
  }
198
186
  });
199
187
  return model;
@@ -227,7 +215,7 @@ class HeatMapModel extends _BaseModel.default {
227
215
  uniformBuffers: [...this.colorModelUniformBuffer, ...this.rendererService.uniformBuffers],
228
216
  attributes: {
229
217
  a_Position: createAttribute({
230
- shaderLocation: this.attributeLocation.POSITION,
218
+ shaderLocation: _CommonStyleAttribute.ShaderLocation.POSITION,
231
219
  buffer: createBuffer({
232
220
  data: [-1, 1, 0, 1, 1, 0, -1, -1, 0, 1, -1, 0],
233
221
  type: _l7Core.gl.FLOAT
@@ -235,7 +223,7 @@ class HeatMapModel extends _BaseModel.default {
235
223
  size: 3
236
224
  }),
237
225
  a_Uv: createAttribute({
238
- shaderLocation: this.attributeLocation.UV,
226
+ shaderLocation: _CommonStyleAttribute.ShaderLocation.UV,
239
227
  buffer: createBuffer({
240
228
  data: [0, 1, 1, 1, 0, 0, 1, 0],
241
229
  type: _l7Core.gl.FLOAT
@@ -254,80 +242,6 @@ class HeatMapModel extends _BaseModel.default {
254
242
  })
255
243
  });
256
244
  }
257
- build3dHeatMap() {
258
- const {
259
- getViewportSize
260
- } = this.rendererService;
261
- const {
262
- width,
263
- height
264
- } = getViewportSize();
265
- const triangulation = (0, _triangulation2.heatMap3DTriangulation)(width / 4.0, height / 4.0);
266
- this.shaderModuleService.registerModule('heatmap3dColor', {
267
- vs: heatmap_3d_vert,
268
- fs: heatmap_3d_frag
269
- });
270
- this.heat3DModelUniformBuffer = [this.rendererService.createBuffer({
271
- // opacity
272
- data: new Float32Array(16 * 2 + 4).fill(0),
273
- // 长度需要大于等于 4
274
- isUBO: true
275
- })];
276
- const {
277
- vs,
278
- fs,
279
- uniforms
280
- } = this.shaderModuleService.getModule('heatmap3dColor');
281
- const {
282
- createAttribute,
283
- createElements,
284
- createBuffer,
285
- createModel
286
- } = this.rendererService;
287
- return createModel({
288
- vs,
289
- fs,
290
- attributes: {
291
- a_Position: createAttribute({
292
- shaderLocation: this.attributeLocation.POSITION,
293
- buffer: createBuffer({
294
- data: triangulation.vertices,
295
- type: _l7Core.gl.FLOAT
296
- }),
297
- size: 3
298
- }),
299
- a_Uv: createAttribute({
300
- shaderLocation: this.attributeLocation.UV,
301
- buffer: createBuffer({
302
- data: triangulation.uvs,
303
- type: _l7Core.gl.FLOAT
304
- }),
305
- size: 2
306
- })
307
- },
308
- primitive: _l7Core.gl.TRIANGLES,
309
- uniformBuffers: [...this.heat3DModelUniformBuffer, ...this.rendererService.uniformBuffers],
310
- uniforms: (0, _objectSpread2.default)({}, uniforms),
311
- depth: {
312
- enable: true
313
- },
314
- blend: {
315
- enable: true,
316
- func: {
317
- srcRGB: _l7Core.gl.SRC_ALPHA,
318
- srcAlpha: 1,
319
- dstRGB: _l7Core.gl.ONE_MINUS_SRC_ALPHA,
320
- dstAlpha: 1
321
- }
322
- },
323
- elements: createElements({
324
- data: triangulation.indices,
325
- type: _l7Core.gl.UNSIGNED_INT,
326
- count: triangulation.indices.length
327
- })
328
- });
329
- }
330
-
331
245
  // 绘制密度图
332
246
  drawIntensityMode() {
333
247
  var _this$intensityModel;
@@ -427,6 +341,79 @@ class HeatMapModel extends _BaseModel.default {
427
341
  stencil: this.getStencil(options)
428
342
  });
429
343
  }
344
+ build3dHeatMap() {
345
+ const {
346
+ getViewportSize
347
+ } = this.rendererService;
348
+ const {
349
+ width,
350
+ height
351
+ } = getViewportSize();
352
+ const triangulation = (0, _triangulation2.heatMap3DTriangulation)(width / 4.0, height / 4.0);
353
+ this.shaderModuleService.registerModule('heatmap3dColor', {
354
+ vs: heatmap_3d_vert,
355
+ fs: heatmap_3d_frag
356
+ });
357
+ this.heat3DModelUniformBuffer = [this.rendererService.createBuffer({
358
+ // opacity
359
+ data: new Float32Array(16 * 2 + 4).fill(0),
360
+ // 长度需要大于等于 4
361
+ isUBO: true
362
+ })];
363
+ const {
364
+ vs,
365
+ fs,
366
+ uniforms
367
+ } = this.shaderModuleService.getModule('heatmap3dColor');
368
+ const {
369
+ createAttribute,
370
+ createElements,
371
+ createBuffer,
372
+ createModel
373
+ } = this.rendererService;
374
+ return createModel({
375
+ vs,
376
+ fs,
377
+ attributes: {
378
+ a_Position: createAttribute({
379
+ shaderLocation: _CommonStyleAttribute.ShaderLocation.POSITION,
380
+ buffer: createBuffer({
381
+ data: triangulation.vertices,
382
+ type: _l7Core.gl.FLOAT
383
+ }),
384
+ size: 3
385
+ }),
386
+ a_Uv: createAttribute({
387
+ shaderLocation: _CommonStyleAttribute.ShaderLocation.UV,
388
+ buffer: createBuffer({
389
+ data: triangulation.uvs,
390
+ type: _l7Core.gl.FLOAT
391
+ }),
392
+ size: 2
393
+ })
394
+ },
395
+ primitive: _l7Core.gl.TRIANGLES,
396
+ uniformBuffers: [...this.heat3DModelUniformBuffer, ...this.rendererService.uniformBuffers],
397
+ uniforms: (0, _objectSpread2.default)({}, uniforms),
398
+ depth: {
399
+ enable: true
400
+ },
401
+ blend: {
402
+ enable: true,
403
+ func: {
404
+ srcRGB: _l7Core.gl.SRC_ALPHA,
405
+ srcAlpha: 1,
406
+ dstRGB: _l7Core.gl.ONE_MINUS_SRC_ALPHA,
407
+ dstAlpha: 1
408
+ }
409
+ },
410
+ elements: createElements({
411
+ data: triangulation.indices,
412
+ type: _l7Core.gl.UNSIGNED_INT,
413
+ count: triangulation.indices.length
414
+ })
415
+ });
416
+ }
430
417
  updateColorTexture() {
431
418
  const {
432
419
  createTexture2D
@@ -1,20 +1,6 @@
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
- };
18
4
  getUninforms(): IModelUniform;
19
5
  protected getCommonUniformsInfo(): {
20
6
  uniformsArray: number[];
@@ -13,14 +13,8 @@ var _triangulation = require("../../core/triangulation");
13
13
  /* babel-plugin-inline-import '../shaders/hexagon/hexagon_frag.glsl' */
14
14
  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";
15
15
  /* babel-plugin-inline-import '../shaders/hexagon/hexagon_vert.glsl' */
16
- 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";
16
+ 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";
17
17
  class HexagonModel extends _BaseModel.default {
18
- get attributeLocation() {
19
- return Object.assign(super.attributeLocation, {
20
- MAX: super.attributeLocation.MAX,
21
- POS: 9
22
- });
23
- }
24
18
  getUninforms() {
25
19
  const commoninfo = this.getCommonUniformsInfo();
26
20
  const attributeInfo = this.getUniformsBufferInfo(this.getStyleAttribute());
@@ -72,7 +66,7 @@ class HexagonModel extends _BaseModel.default {
72
66
  type: _l7Core.AttributeType.Attribute,
73
67
  descriptor: {
74
68
  name: 'a_Pos',
75
- shaderLocation: this.attributeLocation.POS,
69
+ shaderLocation: 10,
76
70
  buffer: {
77
71
  usage: _l7Core.gl.DYNAMIC_DRAW,
78
72
  data: [],
@@ -80,7 +74,7 @@ class HexagonModel extends _BaseModel.default {
80
74
  },
81
75
  size: 3,
82
76
  update: feature => {
83
- const coordinates = feature.coordinates;
77
+ const coordinates = feature.version === 'GAODE2.x' ? feature.originCoordinates : feature.coordinates;
84
78
  return [coordinates[0], coordinates[1], 0];
85
79
  }
86
80
  }
@@ -1,30 +1,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
+ 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,8 +1,8 @@
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;
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;
6
6
 
7
7
  layout(std140) uniform commonUniforms {
8
8
  vec2 u_radius;
@@ -20,15 +20,27 @@ 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
- 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);
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
+ }
32
44
 
33
45
  setPickingColor(a_PickingColor);
34
46
  }
@@ -1,5 +1,5 @@
1
1
  layout(location = 0) in vec3 a_Position;
2
- layout(location = 10) in vec2 a_Uv;
2
+ layout(location = 14) in vec2 a_Uv;
3
3
 
4
4
  layout(std140) uniform commonUniforms {
5
5
  mat4 u_ViewProjectionMatrixUncentered;
@@ -17,16 +17,13 @@ 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 +
24
- P1 * 3.0 * t * one_minus_t2 +
25
- P2 * 3.0 * t2 * one_minus_t +
26
- 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 + P1 * 3.0 * t * one_minus_t2 + P2 * 3.0 * t2 * one_minus_t + P3 * t2 * t);
27
24
  }
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));
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));
30
27
  }
31
28
 
32
29
  #pragma include "projection"
@@ -38,22 +35,22 @@ void main() {
38
35
  vec2 pos = a_Uv * vec2(2.0) - vec2(1.0); // 将原本 0 -> 1 的 uv 转换为 -1 -> 1 的标准坐标空间(NDC)
39
36
 
40
37
  vec4 p1 = vec4(pos, 0.0, 1.0); // x/y 平面上的点(z == 0)可以认为是三维上的点被投影到平面后的点
41
- vec4 p2 = vec4(pos, 1.0, 1.0); // 平行于x/y平面、z==1 的平面上的点
38
+ vec4 p2 = vec4(pos, 1.0, 1.0); // 平行于x/y平面、z==1 的平面上的点
42
39
 
43
- vec4 inverseP1 = u_InverseViewProjectionMatrix * p1; // 根据视图投影矩阵的逆矩阵平面上的反算出三维空间中的点(p1平面上的点)
44
- vec4 inverseP2 = u_InverseViewProjectionMatrix * p2;
40
+ vec4 inverseP1 = u_InverseViewProjectionMatrix * p1; // 根据视图投影矩阵的逆矩阵平面上的反算出三维空间中的点(p1平面上的点)
41
+ vec4 inverseP2 = u_InverseViewProjectionMatrix * p2;
45
42
 
46
43
  inverseP1 = inverseP1 / inverseP1.w; // 归一化操作(归一化后为世界坐标)
47
- inverseP2 = inverseP2 / inverseP2.w;
44
+ inverseP2 = inverseP2 / inverseP2.w;
48
45
 
49
- float zPos = (0.0 - inverseP1.z) / (inverseP2.z - inverseP1.z); // ??
50
- vec4 position = inverseP1 + zPos * (inverseP2 - inverseP1);
46
+ float zPos = (0.0 - inverseP1.z) / (inverseP2.z - inverseP1.z); // ??
47
+ vec4 position = inverseP1 + zPos * (inverseP2 - inverseP1);
51
48
 
52
- vec4 b = vec4(0.5, 0.0, 1.0, 0.5);
49
+ vec4 b= vec4(0.5000, 0.0, 1.0, 0.5000);
53
50
  float fh;
54
51
 
55
52
  v_intensity = texture(SAMPLER_2D(u_texture), v_texCoord).r;
56
53
  fh = toBezier(v_intensity, b).y;
57
- gl_Position = u_ViewProjectionMatrixUncentered * vec4(position.xy, fh * project_pixel(50.0), 1.0);
58
-
54
+ gl_Position = u_ViewProjectionMatrixUncentered * vec4(position.xy, fh * project_pixel(50.), 1.0);
55
+
59
56
  }
@@ -1,6 +1,7 @@
1
- layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;
2
- layout(location = ATTRIBUTE_LOCATION_SIZE) in float a_Size;
3
- layout(location = ATTRIBUTE_LOCATION_DIR) in vec2 a_Dir;
1
+ layout(location = 0) in vec3 a_Position;
2
+ layout(location = 9) in float a_Size;
3
+ layout(location = 10) in vec2 a_Dir;
4
+
4
5
 
5
6
  layout(std140) uniform commonUniforms {
6
7
  float u_radius;
@@ -12,25 +13,30 @@ layout(std140) uniform commonUniforms {
12
13
  out vec2 v_extrude;
13
14
  out float v_weight;
14
15
 
15
- #define GAUSS_COEF (0.3989422804014327)
16
+ #define GAUSS_COEF 0.3989422804014327
16
17
 
17
18
  #pragma include "projection"
18
19
  #pragma include "picking"
19
20
 
20
- void main() {
21
- vec3 picking_color_placeholder = u_PickingColor;
21
+ void main(){
22
+ vec3 picking_color_placeholder = u_PickingColor;
22
23
 
23
- v_weight = a_Size;
24
- float ZERO = 1.0 / 255.0 / 16.0;
25
- float extrude_x = a_Dir.x * 2.0 - 1.0;
26
- float extrude_y = a_Dir.y * 2.0 - 1.0;
27
- vec2 extrude_dir = normalize(vec2(extrude_x, extrude_y));
28
- float S = sqrt(-2.0 * log(ZERO / a_Size / u_intensity / GAUSS_COEF)) / 2.5;
29
- v_extrude = extrude_dir * S;
24
+ v_weight = a_Size;
25
+ float ZERO = 1.0 / 255.0 / 16.0;
26
+ float extrude_x = a_Dir.x * 2.0 -1.0;
27
+ float extrude_y = a_Dir.y * 2.0 -1.0;
28
+ vec2 extrude_dir = normalize(vec2(extrude_x,extrude_y));
29
+ float S = sqrt(-2.0 * log(ZERO / a_Size / u_intensity / GAUSS_COEF)) / 2.5;
30
+ v_extrude = extrude_dir * S;
30
31
 
31
- vec2 offset = project_pixel(v_extrude * u_radius);
32
- vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0));
32
+ vec2 offset = project_pixel(v_extrude * u_radius);
33
+ vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0));
33
34
 
34
- gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));
35
+ // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));
35
36
 
37
+ if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
38
+ gl_Position = u_Mvp * (vec4(project_pos.xy + offset, 0.0, 1.0));
39
+ } else {
40
+ gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));
41
+ }
36
42
  }
@@ -1,5 +1,6 @@
1
+
1
2
  layout(location = 0) in vec3 a_Position;
2
- layout(location = 10) in vec2 a_Uv;
3
+ layout(location = 14) in vec2 a_Uv;
3
4
 
4
5
  layout(std140) uniform commonUniforms {
5
6
  float u_opacity;
@@ -14,8 +15,8 @@ out vec2 v_texCoord;
14
15
  void main() {
15
16
  v_texCoord = a_Uv;
16
17
  #ifdef VIEWPORT_ORIGIN_TL
17
- v_texCoord.y = 1.0 - v_texCoord.y;
18
+ v_texCoord.y = 1.0 - v_texCoord.y;
18
19
  #endif
19
20
 
20
- gl_Position = vec4(a_Position.xy, 0, 1.0);
21
+ gl_Position = vec4(a_Position.xy, 0, 1.);
21
22
  }
@@ -1,16 +1,17 @@
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;
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
4
 
5
5
  layout(std140) uniform commonUniforms {
6
- vec2 u_radius;
7
- float u_opacity;
8
- float u_coverage;
9
- float u_angle;
6
+ vec2 u_radius;
7
+ float u_opacity;
8
+ float u_coverage;
9
+ float u_angle;
10
10
  };
11
11
 
12
12
  out vec4 v_color;
13
13
 
14
+
14
15
  #pragma include "projection"
15
16
  #pragma include "project"
16
17
  #pragma include "picking"
@@ -18,13 +19,22 @@ out vec4 v_color;
18
19
  void main() {
19
20
  v_color = a_Color;
20
21
  v_color.a *= u_opacity;
21
-
22
+
22
23
  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
+ vec2 offset =(vec2(a_Position.xy * u_radius * rotationMatrix * u_coverage));
24
25
  vec2 lnglat = unProjectFlat(a_Pos.xy + offset);
25
-
26
- vec4 project_pos = project_position(vec4(lnglat, 0, 1.0));
27
- gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy, 0.0, 1.0));
28
-
26
+
27
+ // vec4 project_pos = project_position(vec4(lnglat, 0, 1.0));
28
+ // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy, 0., 1.0));
29
+ if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
30
+ // gl_Position = u_Mvp * (vec4(project_pos.xy, 0., 1.0));
31
+ // gl_Position = u_Mvp * (vec4(a_Pos.xy + offset, 0., 1.0));
32
+ vec2 customLnglat = customProject(lnglat) - u_sceneCenterMercator;
33
+ vec4 project_pos = project_position(vec4(customLnglat, 0, 1.0));
34
+ gl_Position = u_Mvp * vec4(project_pos.xy, 0.0, 1.0);
35
+ } else {
36
+ vec4 project_pos = project_position(vec4(lnglat, 0, 1.0));
37
+ gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy, 0., 1.0));
38
+ }
29
39
  setPickingColor(a_PickingColor);
30
40
  }