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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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
@@ -1,14 +1,21 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
2
  import { AttributeType, gl } from '@antv/l7-core';
3
3
  import BaseModel from "../../core/BaseModel";
4
- import { ShaderLocation } from "../../core/CommonStyleAttribute";
5
4
  import { PointFillTriangulation } from "../../core/triangulation";
6
5
  /* babel-plugin-inline-import '../shaders/fill/fill_frag.glsl' */
7
6
  const pointFillFrag = "\nlayout(std140) uniform commonUniforms {\n vec3 u_blur_height_fixed;\n float u_stroke_width;\n float u_additive;\n float u_stroke_opacity;\n float u_size_unit;\n float u_time;\n vec4 u_animate;\n};\n\nin vec4 v_color;\nin vec4 v_stroke;\nin vec4 v_data;\nin float v_radius;\n\n#pragma include \"scene_uniforms\"\n#pragma include \"sdf_2d\"\n#pragma include \"picking\"\n\nout vec4 outputColor;\n\nvoid main() {\n int shape = int(floor(v_data.w + 0.5));\n lowp float antialiasblur = v_data.z;\n float r = v_radius / (v_radius + u_stroke_width);\n\n float outer_df;\n float inner_df;\n // 'circle', 'triangle', 'square', 'pentagon', 'hexagon', 'octogon', 'hexagram', 'rhombus', 'vesica'\n if (shape == 0) {\n outer_df = sdCircle(v_data.xy, 1.0);\n inner_df = sdCircle(v_data.xy, r);\n } else if (shape == 1) {\n outer_df = sdEquilateralTriangle(1.1 * v_data.xy);\n inner_df = sdEquilateralTriangle(1.1 / r * v_data.xy);\n } else if (shape == 2) {\n outer_df = sdBox(v_data.xy, vec2(1.));\n inner_df = sdBox(v_data.xy, vec2(r));\n } else if (shape == 3) {\n outer_df = sdPentagon(v_data.xy, 0.8);\n inner_df = sdPentagon(v_data.xy, r * 0.8);\n } else if (shape == 4) {\n outer_df = sdHexagon(v_data.xy, 0.8);\n inner_df = sdHexagon(v_data.xy, r * 0.8);\n } else if (shape == 5) {\n outer_df = sdOctogon(v_data.xy, 1.0);\n inner_df = sdOctogon(v_data.xy, r);\n } else if (shape == 6) {\n outer_df = sdHexagram(v_data.xy, 0.52);\n inner_df = sdHexagram(v_data.xy, r * 0.52);\n } else if (shape == 7) {\n outer_df = sdRhombus(v_data.xy, vec2(1.0));\n inner_df = sdRhombus(v_data.xy, vec2(r));\n } else if (shape == 8) {\n outer_df = sdVesica(v_data.xy, 1.1, 0.8);\n inner_df = sdVesica(v_data.xy, r * 1.1, r * 0.8);\n }\n\n float opacity_t = smoothstep(0.0, antialiasblur, outer_df);\n\n float color_t = u_stroke_width < 0.01 ? 0.0 : smoothstep(\n antialiasblur,\n 0.0,\n inner_df\n );\n\n float PI = 3.14159;\n float N_RINGS = 3.0;\n float FREQ = 1.0;\n\n if(u_stroke_width < 0.01) {\n outputColor = v_color;\n } else {\n outputColor = mix(v_color, v_stroke * u_stroke_opacity, color_t);\n }\n float intensity = 1.0;\n if(u_time!=-1.0){\n //wave\u76F8\u5173\u903B\u8F91\n float d = length(v_data.xy);\n if(d > 0.5) {\n discard;\n }\n intensity = clamp(cos(d * PI), 0.0, 1.0) * clamp(cos(2.0 * PI * (d * 2.0 * u_animate.z - u_animate.y * u_time)), 0.0, 1.0);\n }\n\n if(u_additive > 0.0) {\n outputColor *= opacity_t;\n outputColor *= intensity;//wave\n outputColor = filterColorAlpha(outputColor, outputColor.a);\n } else {\n outputColor.a *= opacity_t;\n outputColor.a *= intensity;//wave \n outputColor = filterColor(outputColor);\n }\n // \u4F5C\u4E3A mask \u6A21\u677F\u65F6\u9700\u8981\u4E22\u5F03\u900F\u660E\u7684\u50CF\u7D20\n if(outputColor.a < 0.01) {\n discard;\n } \n}\n";
8
7
  /* babel-plugin-inline-import '../shaders/fill/fill_vert.glsl' */
9
- const pointFillVert = "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 float a_Shape;\nlayout(location = 11) in vec3 a_Extrude;\n\nlayout(std140) uniform commonUniforms {\n vec3 u_blur_height_fixed;\n float u_stroke_width;\n float u_additive;\n float u_stroke_opacity;\n float u_size_unit;\n float u_time;\n vec4 u_animate; \n};\n\nout vec4 v_color;\nout vec4 v_stroke;\nout vec4 v_data;\nout float v_radius;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n#pragma include \"rotation_2d\"\n\nvoid main() {\n // \u900F\u660E\u5EA6\u8BA1\u7B97\n v_stroke = stroke; \n vec3 extrude = a_Extrude;\n float shape_type = a_Shape;\n /*\n * setPickingSize \u8BBE\u7F6E\u62FE\u53D6\u5927\u5C0F\n * u_meter2coord \u5728\u7B49\u9762\u79EF\u5927\u5C0F\u7684\u65F6\u5019\u8BBE\u7F6E\u5355\u4F4D\n */\n float newSize = setPickingSize(a_Size);\n // float newSize = setPickingSize(a_Size) * 0.00001038445708445579;\n\n\n\n // unpack color(vec2)\n v_color = vec4(a_Color.xyz, a_Color.w * opacity);\n\n if(u_size_unit == 1.0) {\n newSize = newSize * u_PixelsPerMeter.z;\n }\n\n v_radius = newSize;\n\n // anti-alias\n // float antialiased_blur = -max(u_blur, antialiasblur);\n float antialiasblur = -max(2.0 / u_DevicePixelRatio / newSize, u_blur_height_fixed.x);\n\n vec2 offset = (extrude.xy * (newSize + u_stroke_width) + u_offsets);\n vec3 aPosition = a_Position;\n\n offset = project_pixel(offset);\n offset = rotate_matrix(offset,rotation);\n \n // TODP: /abs(extrude.x) \u662F\u4E3A\u4E86\u517C\u5BB9\u5730\u7403\u6A21\u5F0F\n v_data = vec4(extrude.x/abs(extrude.x), extrude.y/abs(extrude.y), antialiasblur,shape_type);\n\n\n // vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0));\n vec4 project_pos = project_position(vec4(aPosition.xy, 0.0, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, project_pixel(setPickingOrder(0.0)), 1.0));\n\n float raisingHeight = u_blur_height_fixed.y;\n\n if(u_blur_height_fixed.z < 1.0) { // false\n raisingHeight = project_pixel(u_blur_height_fixed.y);\n } else {\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n raisingHeight = u_blur_height_fixed.y * mapboxZoomScale;\n }\n }\n \n gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xy + offset, raisingHeight, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
8
+ const pointFillVert = "layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_POSITION_64LOW) in vec2 a_Position64Low;\nlayout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;\nlayout(location = ATTRIBUTE_LOCATION_SIZE) in float a_Size;\nlayout(location = ATTRIBUTE_LOCATION_SHAPE) in float a_Shape;\nlayout(location = ATTRIBUTE_LOCATION_EXTRUDE) in vec3 a_Extrude;\n\nlayout(std140) uniform commonUniforms {\n vec3 u_blur_height_fixed;\n float u_stroke_width;\n float u_additive;\n float u_stroke_opacity;\n float u_size_unit;\n float u_time;\n vec4 u_animate;\n};\n\nout vec4 v_color;\nout vec4 v_stroke;\nout vec4 v_data;\nout float v_radius;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n#pragma include \"rotation_2d\"\n\nvoid main() {\n // \u900F\u660E\u5EA6\u8BA1\u7B97\n v_stroke = stroke;\n vec3 extrude = a_Extrude;\n float shape_type = a_Shape;\n /*\n * setPickingSize \u8BBE\u7F6E\u62FE\u53D6\u5927\u5C0F\n * u_meter2coord \u5728\u7B49\u9762\u79EF\u5927\u5C0F\u7684\u65F6\u5019\u8BBE\u7F6E\u5355\u4F4D\n */\n float newSize = setPickingSize(a_Size);\n // float newSize = setPickingSize(a_Size) * 0.00001038445708445579;\n\n\n\n // unpack color(vec2)\n v_color = vec4(a_Color.xyz, a_Color.w * opacity);\n\n if(u_size_unit == 1.0) {\n newSize = newSize * u_PixelsPerMeter.z;\n }\n\n v_radius = newSize;\n\n // anti-alias\n // float antialiased_blur = -max(u_blur, antialiasblur);\n float antialiasblur = -max(2.0 / u_DevicePixelRatio / newSize, u_blur_height_fixed.x);\n\n vec2 offset = (extrude.xy * (newSize + u_stroke_width) + u_offsets);\n\n offset = project_pixel(offset);\n offset = rotate_matrix(offset,rotation);\n\n // TODP: /abs(extrude.x) \u662F\u4E3A\u4E86\u517C\u5BB9\u5730\u7403\u6A21\u5F0F\n v_data = vec4(extrude.x/abs(extrude.x), extrude.y/abs(extrude.y), antialiasblur,shape_type);\n\n vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0), a_Position64Low);\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, project_pixel(setPickingOrder(0.0)), 1.0));\n\n float raisingHeight = u_blur_height_fixed.y;\n\n if(u_blur_height_fixed.z < 1.0) { // false\n raisingHeight = project_pixel(u_blur_height_fixed.y);\n } else {\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n raisingHeight = u_blur_height_fixed.y * mapboxZoomScale;\n }\n }\n\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, raisingHeight, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
10
9
  import { SizeUnitType } from "../../core/interface";
11
10
  export default class FillModel extends BaseModel {
11
+ get attributeLocation() {
12
+ return Object.assign(super.attributeLocation, {
13
+ MAX: super.attributeLocation.MAX,
14
+ SIZE: 9,
15
+ SHAPE: 10,
16
+ EXTRUDE: 11
17
+ });
18
+ }
12
19
  getCommonUniformsInfo() {
13
20
  const {
14
21
  strokeOpacity = 1,
@@ -69,6 +76,7 @@ export default class FillModel extends BaseModel {
69
76
  moduleName: type,
70
77
  vertexShader: vert,
71
78
  fragmentShader: frag,
79
+ defines: _this2.getDefines(),
72
80
  inject: _this2.getInject(),
73
81
  triangulation: PointFillTriangulation,
74
82
  depth: {
@@ -98,12 +106,15 @@ export default class FillModel extends BaseModel {
98
106
  registerBuiltinAttributes() {
99
107
  // 注册 Style 参与数据映射的内置属性
100
108
  const shape2d = this.layer.getLayerConfig().shape2d;
109
+
110
+ // 注册 Position 属性 64 位地位部分,经纬度数据开启双精度,避免大于 20层级以上出现数据偏移
111
+ this.registerPosition64LowAttribute();
101
112
  this.styleAttributeService.registerStyleAttribute({
102
113
  name: 'extrude',
103
114
  type: AttributeType.Attribute,
104
115
  descriptor: {
105
116
  name: 'a_Extrude',
106
- shaderLocation: ShaderLocation.EXTRUDE,
117
+ shaderLocation: this.attributeLocation.EXTRUDE,
107
118
  buffer: {
108
119
  // give the WebGL driver a hint that this buffer may change
109
120
  usage: gl.DYNAMIC_DRAW,
@@ -125,7 +136,7 @@ export default class FillModel extends BaseModel {
125
136
  type: AttributeType.Attribute,
126
137
  descriptor: {
127
138
  name: 'a_Size',
128
- shaderLocation: ShaderLocation.SIZE,
139
+ shaderLocation: this.attributeLocation.SIZE,
129
140
  buffer: {
130
141
  // give the WebGL driver a hint that this buffer may change
131
142
  usage: gl.DYNAMIC_DRAW,
@@ -148,7 +159,7 @@ export default class FillModel extends BaseModel {
148
159
  type: AttributeType.Attribute,
149
160
  descriptor: {
150
161
  name: 'a_Shape',
151
- shaderLocation: ShaderLocation.SHAPE,
162
+ shaderLocation: this.attributeLocation.SHAPE,
152
163
  buffer: {
153
164
  // give the WebGL driver a hint that this buffer may change
154
165
  usage: gl.DYNAMIC_DRAW,
@@ -1,6 +1,22 @@
1
1
  import type { IAttribute, IElements, IModel } from '@antv/l7-core';
2
2
  import BaseModel from '../../core/BaseModel';
3
3
  export default class FillImageModel 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
+ EXTRUDE: number;
18
+ UV: number;
19
+ };
4
20
  private meter2coord;
5
21
  private texture;
6
22
  private isMeter;
@@ -1,16 +1,13 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
2
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
3
3
  import { AttributeType, gl } from '@antv/l7-core';
4
- import { getCullFace } from '@antv/l7-utils';
5
4
  import BaseModel from "../../core/BaseModel";
6
5
  import { SizeUnitType } from "../../core/interface";
7
6
  import { PointFillTriangulation } from "../../core/triangulation";
8
- // static pointLayer shader - not support animate
9
- import { ShaderLocation } from "../../core/CommonStyleAttribute";
10
7
  /* babel-plugin-inline-import '../shaders/fillImage/fillImage_frag.glsl' */
11
8
  const pointFillFrag = "in vec2 v_uv;// \u672C\u8EAB\u7684 uv \u5750\u6807\nin vec2 v_Iconuv;\nin float v_opacity;\nout vec4 outputColor;\n\nuniform sampler2D u_texture;\nlayout(std140) uniform commonUniform {\n vec2 u_textSize;\n float u_heightfixed: 0.0;\n float u_raisingHeight: 0.0;\n float u_size_unit;\n};\n\n#pragma include \"scene_uniforms\"\n#pragma include \"sdf_2d\"\n#pragma include \"picking\"\n\nvoid main() {\n vec2 pos = v_Iconuv / u_textSize + v_uv / u_textSize * 64.;\n outputColor = texture(SAMPLER_2D(u_texture), pos);\n outputColor.a *= v_opacity;\n outputColor = filterColor(outputColor);\n}\n";
12
9
  /* babel-plugin-inline-import '../shaders/fillImage/fillImage_vert.glsl' */
13
- const pointFillVert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in float a_Size;\nlayout(location = 11) in vec3 a_Extrude;\nlayout(location = 14) in vec2 a_Uv;\n\nlayout(std140) uniform commonUniform {\n vec2 u_textSize;\n float u_heightfixed: 0.0;\n float u_raisingHeight: 0.0;\n float u_size_unit;\n};\n\nout vec2 v_uv;\nout vec2 v_Iconuv;\nout float v_opacity;\n\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n#pragma include \"rotation_2d\"\n\nvoid main() {\n vec3 extrude = a_Extrude;\n v_uv = (a_Extrude.xy + 1.0)/2.0;\n v_uv.y = 1.0 - v_uv.y;\n v_Iconuv = a_Uv;\n v_opacity = opacity;\n float newSize = a_Size;\n if(u_size_unit == 1.0) {\n newSize = newSize * u_PixelsPerMeter.z;\n }\n \n // vec2 offset = (u_RotateMatrix * extrude.xy * (a_Size) + textrueOffsets);\n vec2 offset = (extrude.xy * (newSize) + offsets);\n\n offset = rotate_matrix(offset,rotation);\n\n vec3 aPosition = a_Position;\n\n offset = project_pixel(offset);\n\n vec4 project_pos = project_position(vec4(aPosition.xy, 0.0, 1.0));\n float raisingHeight = u_raisingHeight;\n if(u_heightfixed < 1.0) { // height fixed\n raisingHeight = project_pixel(u_raisingHeight);\n } else {\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n raisingHeight = u_raisingHeight * mapboxZoomScale;\n }\n }\n\n gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xy + offset, 0.0, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
10
+ const pointFillVert = "layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_POSITION_64LOW) in vec2 a_Position64Low;\nlayout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;\nlayout(location = ATTRIBUTE_LOCATION_SIZE) in float a_Size;\nlayout(location = ATTRIBUTE_LOCATION_EXTRUDE) in vec3 a_Extrude;\nlayout(location = ATTRIBUTE_LOCATION_UV) in vec2 a_Uv;\n\nlayout(std140) uniform commonUniform {\n vec2 u_textSize;\n float u_heightfixed;\n float u_raisingHeight;\n float u_size_unit;\n};\n\nout vec2 v_uv;\nout vec2 v_Iconuv;\nout float v_opacity;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n#pragma include \"rotation_2d\"\n\nvoid main() {\n vec3 extrude = a_Extrude;\n v_uv = (a_Extrude.xy + 1.0) / 2.0;\n v_uv.y = 1.0 - v_uv.y;\n v_Iconuv = a_Uv;\n v_opacity = opacity;\n float newSize = a_Size;\n if (u_size_unit == 1.0) {\n newSize = newSize * u_PixelsPerMeter.z;\n }\n\n // vec2 offset = (u_RotateMatrix * extrude.xy * (a_Size) + textrueOffsets);\n vec2 offset = extrude.xy * newSize + offsets;\n\n offset = rotate_matrix(offset, rotation);\n\n offset = project_pixel(offset);\n\n vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0), a_Position64Low);\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
14
11
  export default class FillImageModel extends BaseModel {
15
12
  constructor(...args) {
16
13
  super(...args);
@@ -45,6 +42,14 @@ export default class FillImageModel extends BaseModel {
45
42
  this.textures = [this.texture];
46
43
  });
47
44
  }
45
+ get attributeLocation() {
46
+ return Object.assign(super.attributeLocation, {
47
+ MAX: super.attributeLocation.MAX,
48
+ SIZE: 9,
49
+ EXTRUDE: 10,
50
+ UV: 11
51
+ });
52
+ }
48
53
  // 旋转的弧度
49
54
  getCommonUniformsInfo() {
50
55
  const {
@@ -56,14 +61,6 @@ export default class FillImageModel extends BaseModel {
56
61
  var _this$texture;
57
62
  (_this$texture = this.texture) === null || _this$texture === void 0 || _this$texture.bind();
58
63
  }
59
- /**
60
- * rotateFlag
61
- * DEFAULT 1
62
- * MAPBOX 1
63
- * GAODE2.x -1
64
- * GAODE1.x -1
65
- */
66
-
67
64
  const commonOptions = {
68
65
  u_textSize: [1024, this.iconService.canvasHeight || 128],
69
66
  u_heightfixed: Number(heightfixed),
@@ -96,10 +93,11 @@ export default class FillImageModel extends BaseModel {
96
93
  depth: {
97
94
  enable: false
98
95
  },
96
+ defines: _this2.getDefines(),
99
97
  inject: _this2.getInject(),
100
98
  cull: {
101
99
  enable: true,
102
- face: getCullFace(_this2.mapService.version)
100
+ face: gl.FRONT
103
101
  }
104
102
  });
105
103
  return [model];
@@ -113,12 +111,14 @@ export default class FillImageModel extends BaseModel {
113
111
 
114
112
  // overwrite baseModel func
115
113
  registerBuiltinAttributes() {
114
+ // 注册 Position 属性 64 位地位部分,经纬度数据开启双精度,避免大于 20层级以上出现数据偏移
115
+ this.registerPosition64LowAttribute();
116
116
  this.styleAttributeService.registerStyleAttribute({
117
117
  name: 'uv',
118
118
  type: AttributeType.Attribute,
119
119
  descriptor: {
120
120
  name: 'a_Uv',
121
- shaderLocation: ShaderLocation.UV,
121
+ shaderLocation: this.attributeLocation.UV,
122
122
  buffer: {
123
123
  // give the WebGL driver a hint that this buffer may change
124
124
  usage: gl.DYNAMIC_DRAW,
@@ -147,7 +147,7 @@ export default class FillImageModel extends BaseModel {
147
147
  type: AttributeType.Attribute,
148
148
  descriptor: {
149
149
  name: 'a_Extrude',
150
- shaderLocation: ShaderLocation.EXTRUDE,
150
+ shaderLocation: this.attributeLocation.EXTRUDE,
151
151
  buffer: {
152
152
  // give the WebGL driver a hint that this buffer may change
153
153
  usage: gl.DYNAMIC_DRAW,
@@ -169,7 +169,7 @@ export default class FillImageModel extends BaseModel {
169
169
  type: AttributeType.Attribute,
170
170
  descriptor: {
171
171
  name: 'a_Size',
172
- shaderLocation: ShaderLocation.SIZE,
172
+ shaderLocation: this.attributeLocation.SIZE,
173
173
  buffer: {
174
174
  // give the WebGL driver a hint that this buffer may change
175
175
  usage: gl.DYNAMIC_DRAW,
@@ -1,6 +1,21 @@
1
1
  import type { IModel, IModelUniform } from '@antv/l7-core';
2
2
  import BaseModel from '../../core/BaseModel';
3
3
  export default class ImageModel 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
+ };
4
19
  private texture;
5
20
  getUninforms(): IModelUniform;
6
21
  protected getCommonUniformsInfo(): {
@@ -3,12 +3,11 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
3
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
4
  import { AttributeType, gl } from '@antv/l7-core';
5
5
  import BaseModel from "../../core/BaseModel";
6
- import { ShaderLocation } from "../../core/CommonStyleAttribute";
7
6
  import { PointImageTriangulation } from "../../core/triangulation";
8
7
  /* babel-plugin-inline-import '../shaders/image/image_frag.glsl' */
9
8
  const pointImageFrag = "layout(std140) uniform commonUniforms {\n vec2 u_textSize;\n float u_raisingHeight;\n float u_heightfixed;\n};\n\nuniform sampler2D u_texture;\n\nin vec4 v_color;\nin vec2 v_uv;\nin float v_opacity;\n\n#pragma include \"picking\"\n\nout vec4 outputColor;\n\nvoid main(){\n vec2 pos = v_uv / u_textSize + gl_PointCoord / u_textSize * 64.;\n vec4 textureColor;\n\n // Y = 0.299R + 0.587G + 0.114B // \u4EAE\u5EA6\u63D0\u53D6\n \n textureColor = texture(SAMPLER_2D(u_texture), pos);\n\n // Tip: \u53BB\u9664\u8FB9\u7F18\u90E8\u5206 mipmap \u5BFC\u81F4\u7684\u6DF7\u5408\u53D8\u6697\n float fragmengTocenter = distance(vec2(0.5), gl_PointCoord);\n if(fragmengTocenter >= 0.5) {\n float luma = 0.299 * textureColor.r + 0.587 * textureColor.g + 0.114 * textureColor.b;\n textureColor.a *= luma;\n }\n \n if(all(lessThan(v_color, vec4(1.0+0.00001))) && all(greaterThan(v_color, vec4(1.0-0.00001))) || v_color==vec4(1.0)){\n outputColor= textureColor;\n }else {\n outputColor= step(0.01, textureColor.z) * v_color;\n }\n outputColor.a *= v_opacity;\n if (outputColor.a < 0.01) {\n discard;\n }\n outputColor = filterColor(outputColor);\n}\n";
10
9
  /* babel-plugin-inline-import '../shaders/image/image_vert.glsl' */
11
- const pointImageVert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in float a_Size;\nlayout(location = 14) in vec2 a_Uv;\n\nlayout(std140) uniform commonUniforms {\n vec2 u_textSize;\n float u_raisingHeight;\n float u_heightfixed;\n};\n\nout vec4 v_color;\nout vec2 v_uv;\nout float v_opacity;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n v_color = a_Color;\n v_opacity = opacity;\n v_uv = a_Uv;\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n \n vec2 offset = project_pixel(offsets);\n\n float raisingHeight = u_raisingHeight;\n if(u_heightfixed < 1.0) { // false\n raisingHeight = project_pixel(u_raisingHeight);\n } else {\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n raisingHeight = u_raisingHeight * mapboxZoomScale;\n }\n }\n\n\n gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xy + offset, raisingHeight, 1.0));\n\n gl_PointSize = a_Size * 2.0 * u_DevicePixelRatio;\n setPickingColor(a_PickingColor);\n}\n";
10
+ const pointImageVert = "layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_POSITION_64LOW) in vec2 a_Position64Low;\nlayout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;\nlayout(location = ATTRIBUTE_LOCATION_SIZE) in float a_Size;\nlayout(location = ATTRIBUTE_LOCATION_UV) in vec2 a_Uv;\n\nlayout(std140) uniform commonUniforms {\n vec2 u_textSize;\n float u_raisingHeight;\n float u_heightfixed;\n};\n\nout vec4 v_color;\nout vec2 v_uv;\nout float v_opacity;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n v_color = a_Color;\n v_opacity = opacity;\n v_uv = a_Uv;\n vec4 project_pos = project_position(vec4(a_Position, 1.0), a_Position64Low);\n\n vec2 offset = project_pixel(offsets);\n\n float raisingHeight = u_raisingHeight;\n if (u_heightfixed < 1.0) {\n // false\n raisingHeight = project_pixel(u_raisingHeight);\n } else {\n if (\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT ||\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET\n ) {\n float mapboxZoomScale = 4.0 / pow(2.0, 21.0 - u_Zoom);\n raisingHeight = u_raisingHeight * mapboxZoomScale;\n }\n }\n\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, raisingHeight, 1.0));\n\n gl_PointSize = a_Size * 2.0 * u_DevicePixelRatio;\n setPickingColor(a_PickingColor);\n}\n";
12
11
  export default class ImageModel extends BaseModel {
13
12
  constructor(...args) {
14
13
  super(...args);
@@ -43,6 +42,13 @@ export default class ImageModel extends BaseModel {
43
42
  });
44
43
  });
45
44
  }
45
+ get attributeLocation() {
46
+ return Object.assign(super.attributeLocation, {
47
+ MAX: super.attributeLocation.MAX,
48
+ SIZE: 9,
49
+ UV: 10
50
+ });
51
+ }
46
52
  getUninforms() {
47
53
  // ThreeJS 图层兼容
48
54
  if (this.rendererService.getDirty()) {
@@ -91,6 +97,7 @@ export default class ImageModel extends BaseModel {
91
97
  vertexShader: pointImageVert,
92
98
  fragmentShader: pointImageFrag,
93
99
  triangulation: PointImageTriangulation,
100
+ defines: _this2.getDefines(),
94
101
  inject: _this2.getInject(),
95
102
  depth: {
96
103
  enable: false
@@ -101,13 +108,16 @@ export default class ImageModel extends BaseModel {
101
108
  })();
102
109
  }
103
110
  registerBuiltinAttributes() {
111
+ // 注册 Position 属性 64 位地位部分,经纬度数据开启双精度,避免大于 20层级以上出现数据偏移
112
+ this.registerPosition64LowAttribute();
113
+
104
114
  // point layer size;
105
115
  this.styleAttributeService.registerStyleAttribute({
106
116
  name: 'size',
107
117
  type: AttributeType.Attribute,
108
118
  descriptor: {
109
119
  name: 'a_Size',
110
- shaderLocation: ShaderLocation.SIZE,
120
+ shaderLocation: this.attributeLocation.SIZE,
111
121
  buffer: {
112
122
  // give the WebGL driver a hint that this buffer may change
113
123
  usage: gl.DYNAMIC_DRAW,
@@ -130,7 +140,7 @@ export default class ImageModel extends BaseModel {
130
140
  type: AttributeType.Attribute,
131
141
  descriptor: {
132
142
  name: 'a_Uv',
133
- shaderLocation: ShaderLocation.UV,
143
+ shaderLocation: this.attributeLocation.UV,
134
144
  buffer: {
135
145
  // give the WebGL driver a hint that this buffer may change
136
146
  usage: gl.DYNAMIC_DRAW,
@@ -7,6 +7,20 @@ export declare function PointTriangulation(feature: IEncodeFeature): {
7
7
  size: number;
8
8
  };
9
9
  export default class NormalModel extends BaseModel {
10
+ protected get attributeLocation(): {
11
+ readonly POSITION: 0;
12
+ readonly POSITION_64LOW: 1;
13
+ readonly COLOR: 2;
14
+ readonly PICKING_COLOR: 3;
15
+ readonly STROKE: 4;
16
+ readonly OPACITY: 5;
17
+ readonly OFFSETS: 6;
18
+ readonly ROTATION: 7;
19
+ readonly MAX: 8;
20
+ } & Record<string, number> & {
21
+ MAX: 8;
22
+ SIZE: number;
23
+ };
10
24
  getDefaultStyle(): Partial<IPointLayerStyleOptions>;
11
25
  protected getCommonUniformsInfo(): {
12
26
  uniformsArray: number[];
@@ -1,11 +1,10 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
2
  import { AttributeType, gl } from '@antv/l7-core';
3
3
  import BaseModel from "../../core/BaseModel";
4
- import { ShaderLocation } from "../../core/CommonStyleAttribute";
5
4
  /* babel-plugin-inline-import '../shaders/normal/normal_frag.glsl' */
6
5
  const normalFrag = "in vec4 v_color;\nout vec4 outputColor;\nvoid main() {\n outputColor = v_color;\n}";
7
6
  /* babel-plugin-inline-import '../shaders/normal/normal_vert.glsl' */
8
- const normalVert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in float a_Size;\n\nlayout(std140) uniform u_Common {\n float u_size_scale;\n};\n\nout vec4 v_color;\n\n#pragma include \"projection\"\n#pragma include \"project\"\n\nvoid main() {\n v_color = vec4(a_Color.xyz, a_Color.w * opacity);\n\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * vec4(a_Position, 1.0);\n } else {\n vec4 project_pos = project_position(vec4(a_Position, 1.0)) + vec4(a_Size / 2., -a_Size /2., 0., 0.);\n gl_Position = project_common_position_to_clipspace(project_pos);\n }\n\n gl_PointSize = a_Size * u_size_scale * 2.0 * u_DevicePixelRatio;\n}\n";
7
+ const normalVert = "layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_POSITION_64LOW) in vec2 a_Position64Low;\nlayout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;\nlayout(location = ATTRIBUTE_LOCATION_SIZE) in float a_Size;\n\nlayout(std140) uniform u_Common {\n float u_size_scale;\n};\n\nout vec4 v_color;\n\n#pragma include \"projection\"\n#pragma include \"project\"\n\nvoid main() {\n v_color = vec4(a_Color.xyz, a_Color.w * opacity);\n\n vec4 project_pos = project_position(vec4(a_Position, 1.0), a_Position64Low);\n gl_Position = project_common_position_to_clipspace(project_pos);\n\n gl_PointSize = a_Size * u_size_scale * 2.0 * u_DevicePixelRatio;\n}\n";
9
8
  export function PointTriangulation(feature) {
10
9
  const coordinates = feature.coordinates;
11
10
  return {
@@ -15,6 +14,12 @@ export function PointTriangulation(feature) {
15
14
  };
16
15
  }
17
16
  export default class NormalModel extends BaseModel {
17
+ get attributeLocation() {
18
+ return Object.assign(super.attributeLocation, {
19
+ MAX: super.attributeLocation.MAX,
20
+ SIZE: 9
21
+ });
22
+ }
18
23
  getDefaultStyle() {
19
24
  return {
20
25
  blend: 'additive'
@@ -43,6 +48,7 @@ export default class NormalModel extends BaseModel {
43
48
  vertexShader: normalVert,
44
49
  fragmentShader: normalFrag,
45
50
  triangulation: PointTriangulation,
51
+ defines: _this2.getDefines(),
46
52
  inject: _this2.getInject(),
47
53
  depth: {
48
54
  enable: false
@@ -57,12 +63,14 @@ export default class NormalModel extends BaseModel {
57
63
  return;
58
64
  }
59
65
  registerBuiltinAttributes() {
66
+ // 注册 Position 属性 64 位地位部分,经纬度数据开启双精度,避免大于 20层级以上出现数据偏移
67
+ this.registerPosition64LowAttribute();
60
68
  this.styleAttributeService.registerStyleAttribute({
61
69
  name: 'size',
62
70
  type: AttributeType.Attribute,
63
71
  descriptor: {
64
72
  name: 'a_Size',
65
- shaderLocation: ShaderLocation.SIZE,
73
+ shaderLocation: this.attributeLocation.SIZE,
66
74
  buffer: {
67
75
  usage: gl.DYNAMIC_DRAW,
68
76
  data: [],
@@ -1,6 +1,21 @@
1
1
  import type { IAnimateOption, IAttribute, IElements, IModel, IModelUniform } from '@antv/l7-core';
2
2
  import BaseModel from '../../core/BaseModel';
3
3
  export default class RadarModel 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
+ EXTRUDE: number;
18
+ };
4
19
  protected getCommonUniformsInfo(): {
5
20
  uniformsArray: number[];
6
21
  uniformsLength: number;
@@ -3,12 +3,18 @@ import { AttributeType, gl } from '@antv/l7-core';
3
3
  import BaseModel from "../../core/BaseModel";
4
4
  import { SizeUnitType } from "../../core/interface";
5
5
  import { PointFillTriangulation } from "../../core/triangulation";
6
- import { ShaderLocation } from "../../core/CommonStyleAttribute";
7
6
  /* babel-plugin-inline-import '../shaders/radar/radar_frag.glsl' */
8
7
  const pointFillFrag = "\nlayout(std140) uniform commonUniorm{\n float u_additive;\n float u_size_unit;\n float u_speed: 1.0;\n float u_time;\n};\nin vec4 v_data;\nin vec4 v_color;\nin float v_radius;\nin vec2 v_extrude;\n#pragma include \"sdf_2d\"\n#pragma include \"picking\"\n\nout vec4 outputColor;\n\nvoid main() {\n\n lowp float antialiasblur = v_data.z;\n float r = v_radius / (v_radius);\n\n float outer_df = sdCircle(v_data.xy, 1.0);\n float inner_df = sdCircle(v_data.xy, r);\n\n float opacity_t = smoothstep(0.0, antialiasblur, outer_df);\n\n outputColor = vec4(v_color.rgb, v_color.a);\n\n if(u_additive > 0.0) {\n outputColor *= opacity_t;\n } else {\n outputColor.a *= opacity_t;\n }\n\n if(outputColor.a > 0.0) {\n outputColor = filterColor(outputColor);\n }\n\n vec2 extrude = v_extrude;\n vec2 dir = normalize(extrude);\n vec2 baseDir = vec2(1.0, 0.0);\n float pi = 3.14159265359;\n float flag = sign(dir.y);\n float rades = dot(dir, baseDir);\n float radar_v = (flag - 1.0) * -0.5 * acos(rades)/pi;\n // simple AA\n if(radar_v > 0.99) {\n radar_v = 1.0 - (radar_v - 0.99)/0.01;\n }\n\n outputColor.a *= radar_v;\n}\n";
9
8
  /* babel-plugin-inline-import '../shaders/radar/radar_vert.glsl' */
10
- const pointFillVert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in float a_Size;\nlayout(location = 11) in vec3 a_Extrude;\n\nlayout(std140) uniform commonUniorm {\n float u_additive;\n float u_size_unit;\n float u_speed: 1.0;\n float u_time;\n};\n\nout vec4 v_data;\nout vec4 v_color;\nout float v_radius;\nout vec2 v_extrude;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n float newSize = setPickingSize(a_Size);\n\n float time = u_time * u_speed;\n mat2 rotateMatrix = mat2( \n cos(time), sin(time), \n -sin(time), cos(time)\n );\n v_extrude = rotateMatrix * a_Extrude.xy;\n\n v_color = a_Color;\n v_color.a *= opacity;\n\n float blur = 0.0;\n float antialiasblur = -max(2.0 / u_DevicePixelRatio / a_Size, blur);\n\n if(u_size_unit == 1.) {\n newSize = newSize * u_PixelsPerMeter.z;\n }\n v_radius = newSize;\n\n vec2 offset = (a_Extrude.xy * (newSize));\n vec3 aPosition = a_Position;\n \n offset = project_pixel(offset);\n \n v_data = vec4(a_Extrude.x, a_Extrude.y, antialiasblur, -1.0);\n\n vec4 project_pos = project_position(vec4(aPosition.xy, 0.0, 1.0));\n gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xy + offset, project_pixel(setPickingOrder(0.0)), 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
9
+ const pointFillVert = "layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_POSITION_64LOW) in vec2 a_Position64Low;\nlayout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;\nlayout(location = ATTRIBUTE_LOCATION_SIZE) in float a_Size;\nlayout(location = ATTRIBUTE_LOCATION_EXTRUDE) in vec3 a_Extrude;\n\nlayout(std140) uniform commonUniorm {\n float u_additive;\n float u_size_unit;\n float u_speed: 1.0;\n float u_time;\n};\n\nout vec4 v_data;\nout vec4 v_color;\nout float v_radius;\nout vec2 v_extrude;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n float newSize = setPickingSize(a_Size);\n\n float time = u_time * u_speed;\n mat2 rotateMatrix = mat2(\n cos(time), sin(time),\n -sin(time), cos(time)\n );\n v_extrude = rotateMatrix * a_Extrude.xy;\n\n v_color = a_Color;\n v_color.a *= opacity;\n\n float blur = 0.0;\n float antialiasblur = -max(2.0 / u_DevicePixelRatio / a_Size, blur);\n\n if(u_size_unit == 1.) {\n newSize = newSize * u_PixelsPerMeter.z;\n }\n v_radius = newSize;\n\n vec2 offset = (a_Extrude.xy * (newSize));\n\n offset = project_pixel(offset);\n\n v_data = vec4(a_Extrude.x, a_Extrude.y, antialiasblur, -1.0);\n\n vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0), a_Position64Low);\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, project_pixel(setPickingOrder(0.0)), 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
11
10
  export default class RadarModel extends BaseModel {
11
+ get attributeLocation() {
12
+ return Object.assign(super.attributeLocation, {
13
+ MAX: super.attributeLocation.MAX,
14
+ SIZE: 9,
15
+ EXTRUDE: 10
16
+ });
17
+ }
12
18
  getCommonUniformsInfo() {
13
19
  const {
14
20
  blend,
@@ -45,6 +51,7 @@ export default class RadarModel extends BaseModel {
45
51
  vertexShader: pointFillVert,
46
52
  fragmentShader: pointFillFrag,
47
53
  triangulation: PointFillTriangulation,
54
+ defines: _this2.getDefines(),
48
55
  inject: _this2.getInject(),
49
56
  depth: {
50
57
  enable: false
@@ -59,12 +66,14 @@ export default class RadarModel extends BaseModel {
59
66
  return [option.enable ? 0 : 1.0, option.speed || 1, option.rings || 3, 0];
60
67
  }
61
68
  registerBuiltinAttributes() {
69
+ // 注册 Position 属性 64 位地位部分,经纬度数据开启双精度,避免大于 20层级以上出现数据偏移
70
+ this.registerPosition64LowAttribute();
62
71
  this.styleAttributeService.registerStyleAttribute({
63
72
  name: 'extrude',
64
73
  type: AttributeType.Attribute,
65
74
  descriptor: {
66
75
  name: 'a_Extrude',
67
- shaderLocation: ShaderLocation.EXTRUDE,
76
+ shaderLocation: this.attributeLocation.EXTRUDE,
68
77
  buffer: {
69
78
  // give the WebGL driver a hint that this buffer may change
70
79
  usage: gl.DYNAMIC_DRAW,
@@ -85,7 +94,7 @@ export default class RadarModel extends BaseModel {
85
94
  name: 'size',
86
95
  type: AttributeType.Attribute,
87
96
  descriptor: {
88
- shaderLocation: ShaderLocation.SIZE,
97
+ shaderLocation: this.attributeLocation.SIZE,
89
98
  name: 'a_Size',
90
99
  buffer: {
91
100
  // give the WebGL driver a hint that this buffer may change
@@ -7,6 +7,22 @@ export declare function TextTrianglation(feature: IEncodeFeature): {
7
7
  size: number;
8
8
  };
9
9
  export default class TextModel extends BaseModel {
10
+ protected get attributeLocation(): {
11
+ readonly POSITION: 0;
12
+ readonly POSITION_64LOW: 1;
13
+ readonly COLOR: 2;
14
+ readonly PICKING_COLOR: 3;
15
+ readonly STROKE: 4;
16
+ readonly OPACITY: 5;
17
+ readonly OFFSETS: 6;
18
+ readonly ROTATION: 7;
19
+ readonly MAX: 8;
20
+ } & Record<string, number> & {
21
+ MAX: 8;
22
+ SIZE: number;
23
+ TEXT_OFFSETS: number;
24
+ UV: number;
25
+ };
10
26
  glyphInfo: IEncodeFeature[];
11
27
  glyphInfoMap: {
12
28
  [key: string]: {
@@ -4,13 +4,12 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
4
  import { AttributeType, gl } from '@antv/l7-core';
5
5
  import { boundsContains, calculateCentroid, lodashUtil, padBounds, rgb2arr } from '@antv/l7-utils';
6
6
  import BaseModel from "../../core/BaseModel";
7
- import { ShaderLocation } from "../../core/CommonStyleAttribute";
8
7
  import CollisionIndex from "../../utils/collision-index";
9
8
  import { getGlyphQuads, shapeText } from "../../utils/symbol-layout";
10
9
  /* babel-plugin-inline-import '../shaders/text/text_frag.glsl' */
11
10
  const textFrag = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 48.0\n\nuniform sampler2D u_sdf_map;\nlayout(std140) uniform commonUniforms {\n vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\n vec2 u_sdf_map_size;\n float u_raisingHeight: 0.0;\n float u_stroke_width : 2;\n float u_gamma_scale : 0.5;\n float u_halo_blur : 0.5;\n};\n\nin vec2 v_uv;\nin float v_gamma_scale;\nin vec4 v_color;\nin vec4 v_stroke_color;\nin float v_fontScale;\n\nout vec4 outputColor;\n\n#pragma include \"picking\"\nvoid main() {\n // get style data mapping\n\n // get sdf from atlas\n float dist = texture(SAMPLER_2D(u_sdf_map), v_uv).a;\n\n lowp float buff = (6.0 - u_stroke_width / v_fontScale) / SDF_PX;\n highp float gamma = (u_halo_blur * 1.19 / SDF_PX + EDGE_GAMMA) / (v_fontScale * u_gamma_scale) / 1.0;\n\n highp float gamma_scaled = gamma * v_gamma_scale;\n\n highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist);\n\n outputColor = mix(v_color, v_stroke_color, smoothstep(0., 0.5, 1.- dist));\n\n outputColor.a *= alpha;\n // \u4F5C\u4E3A mask \u6A21\u677F\u65F6\u9700\u8981\u4E22\u5F03\u900F\u660E\u7684\u50CF\u7D20\n if (outputColor.a < 0.01) {\n discard;\n }\n outputColor = filterColor(outputColor);\n}\n";
12
11
  /* babel-plugin-inline-import '../shaders/text/text_vert.glsl' */
13
- const textVert = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 24.0\n\nlayout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in float a_Size;\nlayout(location = 10) in vec2 a_textOffsets;\nlayout(location = 14) in vec2 a_tex;\n\nlayout(std140) uniform commonUniforms {\n vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\n vec2 u_sdf_map_size;\n float u_raisingHeight: 0.0;\n float u_stroke_width : 2;\n float u_gamma_scale : 0.5;\n float u_halo_blur : 0.5;\n};\n\nout vec2 v_uv;\nout float v_gamma_scale;\nout vec4 v_color;\nout vec4 v_stroke_color;\nout float v_fontScale;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n#pragma include \"rotation_2d\"\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n \n v_uv = a_tex / u_sdf_map_size;\n\n\n\n v_color = vec4(a_Color.xyz, a_Color.w * opacity);\n v_stroke_color = vec4(u_stroke_color.xyz, u_stroke_color.w * opacity);\n\n // \u6587\u672C\u7F29\u653E\u6BD4\u4F8B\n float fontScale = a_Size / FONT_SIZE;\n v_fontScale = fontScale;\n\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n // vec4 projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n vec2 offset = rotate_matrix(a_textOffsets,rotation);\n \n // gl_Position = vec4(projected_position.xy / projected_position.w + rotation_matrix * a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);\n\n float raiseHeight = u_raisingHeight;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n raiseHeight = u_raisingHeight * mapboxZoomScale;\n }\n\n vec4 projected_position = project_common_position_to_clipspace_v2(vec4(project_pos.xyz + vec3(0.0, 0.0, raiseHeight), 1.0));\n\n gl_Position = vec4(\n projected_position.xy / projected_position.w + offset * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);\n v_gamma_scale = gl_Position.w;\n setPickingColor(a_PickingColor);\n\n}\n";
12
+ const textVert = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 24.0\n\nlayout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_POSITION_64LOW) in vec2 a_Position64Low;\nlayout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;\nlayout(location = ATTRIBUTE_LOCATION_SIZE) in float a_Size;\nlayout(location = ATTRIBUTE_LOCATION_TEXT_OFFSETS) in vec2 a_textOffsets;\nlayout(location = ATTRIBUTE_LOCATION_UV) in vec2 a_tex;\n\nlayout(std140) uniform commonUniforms {\n vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\n vec2 u_sdf_map_size;\n float u_raisingHeight: 0.0;\n float u_stroke_width : 2;\n float u_gamma_scale : 0.5;\n float u_halo_blur : 0.5;\n};\n\nout vec2 v_uv;\nout float v_gamma_scale;\nout vec4 v_color;\nout vec4 v_stroke_color;\nout float v_fontScale;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n#pragma include \"rotation_2d\"\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n v_uv = a_tex / u_sdf_map_size;\n\n\n\n v_color = vec4(a_Color.xyz, a_Color.w * opacity);\n v_stroke_color = vec4(u_stroke_color.xyz, u_stroke_color.w * opacity);\n\n // \u6587\u672C\u7F29\u653E\u6BD4\u4F8B\n float fontScale = a_Size / FONT_SIZE;\n v_fontScale = fontScale;\n\n vec4 project_pos = project_position(vec4(a_Position, 1.0), a_Position64Low);\n // vec4 projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n vec2 offset = rotate_matrix(a_textOffsets,rotation);\n\n // gl_Position = vec4(projected_position.xy / projected_position.w + rotation_matrix * a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);\n\n float raiseHeight = u_raisingHeight;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n raiseHeight = u_raisingHeight * mapboxZoomScale;\n }\n\n vec4 projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz + vec3(0.0, 0.0, raiseHeight), 1.0));\n\n gl_Position = vec4(\n projected_position.xy / projected_position.w + offset * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);\n v_gamma_scale = gl_Position.w;\n setPickingColor(a_PickingColor);\n\n}\n";
14
13
  const {
15
14
  isEqual
16
15
  } = lodashUtil;
@@ -61,6 +60,14 @@ export default class TextModel extends BaseModel {
61
60
  yield _this.reBuildModel();
62
61
  }));
63
62
  }
63
+ get attributeLocation() {
64
+ return Object.assign(super.attributeLocation, {
65
+ MAX: super.attributeLocation.MAX,
66
+ SIZE: 9,
67
+ TEXT_OFFSETS: 10,
68
+ UV: 11
69
+ });
70
+ }
64
71
  getUninforms() {
65
72
  const commoninfo = this.getCommonUniformsInfo();
66
73
  const attributeInfo = this.getUniformsBufferInfo(this.getStyleAttribute());
@@ -124,6 +131,7 @@ export default class TextModel extends BaseModel {
124
131
  moduleName: 'pointText',
125
132
  vertexShader: textVert,
126
133
  fragmentShader: textFrag,
134
+ defines: _this3.getDefines(),
127
135
  inject: _this3.getInject(),
128
136
  triangulation: TextTrianglation.bind(_this3),
129
137
  depth: {
@@ -179,11 +187,13 @@ export default class TextModel extends BaseModel {
179
187
  this.layer.off('remapping', this.mapping);
180
188
  }
181
189
  registerBuiltinAttributes() {
190
+ // 注册 Position 属性 64 位地位部分,经纬度数据开启双精度,避免大于 20层级以上出现数据偏移
191
+ this.registerPosition64LowAttribute();
182
192
  this.styleAttributeService.registerStyleAttribute({
183
193
  name: 'textOffsets',
184
194
  type: AttributeType.Attribute,
185
195
  descriptor: {
186
- shaderLocation: 10,
196
+ shaderLocation: this.attributeLocation.TEXT_OFFSETS,
187
197
  name: 'a_textOffsets',
188
198
  // 文字偏移量
189
199
  buffer: {
@@ -203,7 +213,7 @@ export default class TextModel extends BaseModel {
203
213
  type: AttributeType.Attribute,
204
214
  descriptor: {
205
215
  name: 'a_tex',
206
- shaderLocation: ShaderLocation.UV,
216
+ shaderLocation: this.attributeLocation.UV,
207
217
  buffer: {
208
218
  usage: gl.DYNAMIC_DRAW,
209
219
  data: [],
@@ -215,13 +225,14 @@ export default class TextModel extends BaseModel {
215
225
  }
216
226
  }
217
227
  });
228
+
218
229
  // point layer size;
219
230
  this.styleAttributeService.registerStyleAttribute({
220
231
  name: 'size',
221
232
  type: AttributeType.Attribute,
222
233
  descriptor: {
223
234
  name: 'a_Size',
224
- shaderLocation: ShaderLocation.SIZE,
235
+ shaderLocation: this.attributeLocation.SIZE,
225
236
  buffer: {
226
237
  // give the WebGL driver a hint that this buffer may change
227
238
  usage: gl.DYNAMIC_DRAW,
@@ -361,9 +372,6 @@ export default class TextModel extends BaseModel {
361
372
  // feature.centroid = calculteCentroid(coordinates);
362
373
 
363
374
  feature.centroid = calculateCentroid(feature.coordinates);
364
-
365
- // 此时地图高德2.0 originCentroid == centroid
366
- feature.originCentroid = feature.version === 'GAODE2.x' ? calculateCentroid(feature.originCoordinates) : feature.originCentroid = feature.centroid;
367
375
  this.glyphInfoMap[id] = {
368
376
  shaping,
369
377
  glyphQuads,
@@ -413,9 +421,7 @@ export default class TextModel extends BaseModel {
413
421
  shaping,
414
422
  id = 0
415
423
  } = feature;
416
- // const centroid = feature.centroid as [number, number];
417
- // const centroid = feature.originCentroid as [number, number];
418
- const centroid = feature.version === 'GAODE2.x' ? feature.originCentroid : feature.centroid;
424
+ const centroid = feature.centroid;
419
425
  const size = feature.size;
420
426
  const fontScale = size / 16;
421
427
  const pixels = this.mapService.lngLatToContainer(centroid);
@@ -484,6 +490,7 @@ export default class TextModel extends BaseModel {
484
490
  vertexShader: textVert,
485
491
  fragmentShader: textFrag,
486
492
  triangulation: TextTrianglation.bind(_this5),
493
+ defines: _this5.getDefines(),
487
494
  inject: _this5.getInject(),
488
495
  depth: {
489
496
  enable: false
@@ -1,7 +1,8 @@
1
1
 
2
- layout(location = 0) in vec3 a_Position;
3
- layout(location = 1) in vec4 a_Color;
4
- layout(location = 9) in float a_Size;
2
+ layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;
3
+ layout(location = ATTRIBUTE_LOCATION_POSITION_64LOW) in vec2 a_Position64Low;
4
+ layout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;
5
+ layout(location = ATTRIBUTE_LOCATION_SIZE) in float a_Size;
5
6
 
6
7
  layout(std140) uniform commonUniorm {
7
8
  vec4 u_stroke_color;
@@ -19,18 +20,14 @@ out float v_innerRadius;
19
20
  #pragma include "project"
20
21
  void main() {
21
22
  v_color = vec4(a_Color.xyz, a_Color.w * opacity);
22
- v_blur = 1.0 - max(2.0/a_Size, 0.05);
23
+ v_blur = 1.0 - max(2.0 / a_Size, 0.05);
23
24
  v_innerRadius = max((a_Size - u_stroke_width) / a_Size, 0.0);
24
-
25
+
25
26
  vec2 offset = project_pixel(u_offsets);
26
-
27
- if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
28
- gl_Position = u_Mvp * vec4(a_Position.xy + offset, a_Position.z, 1.0);
29
- } else { // else
30
- vec4 project_pos = project_position(vec4(a_Position, 1.0)) + vec4(a_Size / 2.,-a_Size /2.,0.,0.);
31
- gl_Position = project_common_position_to_clipspace(vec4(vec2(project_pos.xy+offset),project_pos.z,project_pos.w));
32
- }
33
-
27
+
28
+ vec4 project_pos = project_position(vec4(a_Position, 1.0), a_Position64Low);
29
+ gl_Position = project_common_position_to_clipspace(vec4(vec2(project_pos.xy+offset),project_pos.z,project_pos.w));
30
+
34
31
  gl_PointSize = a_Size * 2.0 * u_DevicePixelRatio;
35
32
  setPickingColor(a_PickingColor);
36
33
  }