@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
@@ -3,11 +3,12 @@ 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";
6
7
  import { PointImageTriangulation } from "../../core/triangulation";
7
8
  /* babel-plugin-inline-import '../shaders/image/image_frag.glsl' */
8
9
  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";
9
10
  /* babel-plugin-inline-import '../shaders/image/image_vert.glsl' */
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";
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";
11
12
  export default class ImageModel extends BaseModel {
12
13
  constructor(...args) {
13
14
  super(...args);
@@ -42,13 +43,6 @@ export default class ImageModel extends BaseModel {
42
43
  });
43
44
  });
44
45
  }
45
- get attributeLocation() {
46
- return Object.assign(super.attributeLocation, {
47
- MAX: super.attributeLocation.MAX,
48
- SIZE: 9,
49
- UV: 10
50
- });
51
- }
52
46
  getUninforms() {
53
47
  // ThreeJS 图层兼容
54
48
  if (this.rendererService.getDirty()) {
@@ -97,7 +91,6 @@ export default class ImageModel extends BaseModel {
97
91
  vertexShader: pointImageVert,
98
92
  fragmentShader: pointImageFrag,
99
93
  triangulation: PointImageTriangulation,
100
- defines: _this2.getDefines(),
101
94
  inject: _this2.getInject(),
102
95
  depth: {
103
96
  enable: false
@@ -108,16 +101,13 @@ export default class ImageModel extends BaseModel {
108
101
  })();
109
102
  }
110
103
  registerBuiltinAttributes() {
111
- // 注册 Position 属性 64 位地位部分,经纬度数据开启双精度,避免大于 20层级以上出现数据偏移
112
- this.registerPosition64LowAttribute();
113
-
114
104
  // point layer size;
115
105
  this.styleAttributeService.registerStyleAttribute({
116
106
  name: 'size',
117
107
  type: AttributeType.Attribute,
118
108
  descriptor: {
119
109
  name: 'a_Size',
120
- shaderLocation: this.attributeLocation.SIZE,
110
+ shaderLocation: ShaderLocation.SIZE,
121
111
  buffer: {
122
112
  // give the WebGL driver a hint that this buffer may change
123
113
  usage: gl.DYNAMIC_DRAW,
@@ -140,7 +130,7 @@ export default class ImageModel extends BaseModel {
140
130
  type: AttributeType.Attribute,
141
131
  descriptor: {
142
132
  name: 'a_Uv',
143
- shaderLocation: this.attributeLocation.UV,
133
+ shaderLocation: ShaderLocation.UV,
144
134
  buffer: {
145
135
  // give the WebGL driver a hint that this buffer may change
146
136
  usage: gl.DYNAMIC_DRAW,
@@ -7,20 +7,6 @@ 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
- };
24
10
  getDefaultStyle(): Partial<IPointLayerStyleOptions>;
25
11
  protected getCommonUniformsInfo(): {
26
12
  uniformsArray: number[];
@@ -1,10 +1,11 @@
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";
4
5
  /* babel-plugin-inline-import '../shaders/normal/normal_frag.glsl' */
5
6
  const normalFrag = "in vec4 v_color;\nout vec4 outputColor;\nvoid main() {\n outputColor = v_color;\n}";
6
7
  /* babel-plugin-inline-import '../shaders/normal/normal_vert.glsl' */
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";
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";
8
9
  export function PointTriangulation(feature) {
9
10
  const coordinates = feature.coordinates;
10
11
  return {
@@ -14,12 +15,6 @@ export function PointTriangulation(feature) {
14
15
  };
15
16
  }
16
17
  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
- }
23
18
  getDefaultStyle() {
24
19
  return {
25
20
  blend: 'additive'
@@ -48,7 +43,6 @@ export default class NormalModel extends BaseModel {
48
43
  vertexShader: normalVert,
49
44
  fragmentShader: normalFrag,
50
45
  triangulation: PointTriangulation,
51
- defines: _this2.getDefines(),
52
46
  inject: _this2.getInject(),
53
47
  depth: {
54
48
  enable: false
@@ -63,14 +57,12 @@ export default class NormalModel extends BaseModel {
63
57
  return;
64
58
  }
65
59
  registerBuiltinAttributes() {
66
- // 注册 Position 属性 64 位地位部分,经纬度数据开启双精度,避免大于 20层级以上出现数据偏移
67
- this.registerPosition64LowAttribute();
68
60
  this.styleAttributeService.registerStyleAttribute({
69
61
  name: 'size',
70
62
  type: AttributeType.Attribute,
71
63
  descriptor: {
72
64
  name: 'a_Size',
73
- shaderLocation: this.attributeLocation.SIZE,
65
+ shaderLocation: ShaderLocation.SIZE,
74
66
  buffer: {
75
67
  usage: gl.DYNAMIC_DRAW,
76
68
  data: [],
@@ -1,21 +1,6 @@
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
- };
19
4
  protected getCommonUniformsInfo(): {
20
5
  uniformsArray: number[];
21
6
  uniformsLength: number;
@@ -3,18 +3,12 @@ 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";
6
7
  /* babel-plugin-inline-import '../shaders/radar/radar_frag.glsl' */
7
8
  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";
8
9
  /* babel-plugin-inline-import '../shaders/radar/radar_vert.glsl' */
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";
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";
10
11
  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
- }
18
12
  getCommonUniformsInfo() {
19
13
  const {
20
14
  blend,
@@ -51,7 +45,6 @@ export default class RadarModel extends BaseModel {
51
45
  vertexShader: pointFillVert,
52
46
  fragmentShader: pointFillFrag,
53
47
  triangulation: PointFillTriangulation,
54
- defines: _this2.getDefines(),
55
48
  inject: _this2.getInject(),
56
49
  depth: {
57
50
  enable: false
@@ -66,14 +59,12 @@ export default class RadarModel extends BaseModel {
66
59
  return [option.enable ? 0 : 1.0, option.speed || 1, option.rings || 3, 0];
67
60
  }
68
61
  registerBuiltinAttributes() {
69
- // 注册 Position 属性 64 位地位部分,经纬度数据开启双精度,避免大于 20层级以上出现数据偏移
70
- this.registerPosition64LowAttribute();
71
62
  this.styleAttributeService.registerStyleAttribute({
72
63
  name: 'extrude',
73
64
  type: AttributeType.Attribute,
74
65
  descriptor: {
75
66
  name: 'a_Extrude',
76
- shaderLocation: this.attributeLocation.EXTRUDE,
67
+ shaderLocation: ShaderLocation.EXTRUDE,
77
68
  buffer: {
78
69
  // give the WebGL driver a hint that this buffer may change
79
70
  usage: gl.DYNAMIC_DRAW,
@@ -94,7 +85,7 @@ export default class RadarModel extends BaseModel {
94
85
  name: 'size',
95
86
  type: AttributeType.Attribute,
96
87
  descriptor: {
97
- shaderLocation: this.attributeLocation.SIZE,
88
+ shaderLocation: ShaderLocation.SIZE,
98
89
  name: 'a_Size',
99
90
  buffer: {
100
91
  // give the WebGL driver a hint that this buffer may change
@@ -7,22 +7,6 @@ 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
- };
26
10
  glyphInfo: IEncodeFeature[];
27
11
  glyphInfoMap: {
28
12
  [key: string]: {
@@ -4,12 +4,13 @@ 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";
7
8
  import CollisionIndex from "../../utils/collision-index";
8
9
  import { getGlyphQuads, shapeText } from "../../utils/symbol-layout";
9
10
  /* babel-plugin-inline-import '../shaders/text/text_frag.glsl' */
10
11
  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";
11
12
  /* babel-plugin-inline-import '../shaders/text/text_vert.glsl' */
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";
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";
13
14
  const {
14
15
  isEqual
15
16
  } = lodashUtil;
@@ -60,14 +61,6 @@ export default class TextModel extends BaseModel {
60
61
  yield _this.reBuildModel();
61
62
  }));
62
63
  }
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
- }
71
64
  getUninforms() {
72
65
  const commoninfo = this.getCommonUniformsInfo();
73
66
  const attributeInfo = this.getUniformsBufferInfo(this.getStyleAttribute());
@@ -131,7 +124,6 @@ export default class TextModel extends BaseModel {
131
124
  moduleName: 'pointText',
132
125
  vertexShader: textVert,
133
126
  fragmentShader: textFrag,
134
- defines: _this3.getDefines(),
135
127
  inject: _this3.getInject(),
136
128
  triangulation: TextTrianglation.bind(_this3),
137
129
  depth: {
@@ -187,13 +179,11 @@ export default class TextModel extends BaseModel {
187
179
  this.layer.off('remapping', this.mapping);
188
180
  }
189
181
  registerBuiltinAttributes() {
190
- // 注册 Position 属性 64 位地位部分,经纬度数据开启双精度,避免大于 20层级以上出现数据偏移
191
- this.registerPosition64LowAttribute();
192
182
  this.styleAttributeService.registerStyleAttribute({
193
183
  name: 'textOffsets',
194
184
  type: AttributeType.Attribute,
195
185
  descriptor: {
196
- shaderLocation: this.attributeLocation.TEXT_OFFSETS,
186
+ shaderLocation: 10,
197
187
  name: 'a_textOffsets',
198
188
  // 文字偏移量
199
189
  buffer: {
@@ -213,7 +203,7 @@ export default class TextModel extends BaseModel {
213
203
  type: AttributeType.Attribute,
214
204
  descriptor: {
215
205
  name: 'a_tex',
216
- shaderLocation: this.attributeLocation.UV,
206
+ shaderLocation: ShaderLocation.UV,
217
207
  buffer: {
218
208
  usage: gl.DYNAMIC_DRAW,
219
209
  data: [],
@@ -225,14 +215,13 @@ export default class TextModel extends BaseModel {
225
215
  }
226
216
  }
227
217
  });
228
-
229
218
  // point layer size;
230
219
  this.styleAttributeService.registerStyleAttribute({
231
220
  name: 'size',
232
221
  type: AttributeType.Attribute,
233
222
  descriptor: {
234
223
  name: 'a_Size',
235
- shaderLocation: this.attributeLocation.SIZE,
224
+ shaderLocation: ShaderLocation.SIZE,
236
225
  buffer: {
237
226
  // give the WebGL driver a hint that this buffer may change
238
227
  usage: gl.DYNAMIC_DRAW,
@@ -372,6 +361,9 @@ export default class TextModel extends BaseModel {
372
361
  // feature.centroid = calculteCentroid(coordinates);
373
362
 
374
363
  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;
375
367
  this.glyphInfoMap[id] = {
376
368
  shaping,
377
369
  glyphQuads,
@@ -421,7 +413,9 @@ export default class TextModel extends BaseModel {
421
413
  shaping,
422
414
  id = 0
423
415
  } = feature;
424
- const centroid = feature.centroid;
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;
425
419
  const size = feature.size;
426
420
  const fontScale = size / 16;
427
421
  const pixels = this.mapService.lngLatToContainer(centroid);
@@ -490,7 +484,6 @@ export default class TextModel extends BaseModel {
490
484
  vertexShader: textVert,
491
485
  fragmentShader: textFrag,
492
486
  triangulation: TextTrianglation.bind(_this5),
493
- defines: _this5.getDefines(),
494
487
  inject: _this5.getInject(),
495
488
  depth: {
496
489
  enable: false
@@ -1,8 +1,7 @@
1
1
 
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;
2
+ layout(location = 0) in vec3 a_Position;
3
+ layout(location = 1) in vec4 a_Color;
4
+ layout(location = 9) in float a_Size;
6
5
 
7
6
  layout(std140) uniform commonUniorm {
8
7
  vec4 u_stroke_color;
@@ -20,14 +19,18 @@ out float v_innerRadius;
20
19
  #pragma include "project"
21
20
  void main() {
22
21
  v_color = vec4(a_Color.xyz, a_Color.w * opacity);
23
- v_blur = 1.0 - max(2.0 / a_Size, 0.05);
22
+ v_blur = 1.0 - max(2.0/a_Size, 0.05);
24
23
  v_innerRadius = max((a_Size - u_stroke_width) / a_Size, 0.0);
25
-
24
+
26
25
  vec2 offset = project_pixel(u_offsets);
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
-
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
+
31
34
  gl_PointSize = a_Size * 2.0 * u_DevicePixelRatio;
32
35
  setPickingColor(a_PickingColor);
33
36
  }
@@ -5,11 +5,13 @@ precision highp float;
5
5
  #define diffuseRatio 0.3
6
6
  #define specularRatio 0.2
7
7
 
8
- layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;
9
- layout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;
10
- layout(location = ATTRIBUTE_LOCATION_SIZE) in vec3 a_Size;
11
- layout(location = ATTRIBUTE_LOCATION_POS) in vec3 a_Pos;
12
- layout(location = ATTRIBUTE_LOCATION_NORMAL) in vec3 a_Normal;
8
+
9
+ layout(location = 0) in vec3 a_Position;
10
+ layout(location = 1) in vec4 a_Color;
11
+ layout(location = 9) in vec3 a_Size;
12
+ layout(location = 11) in vec3 a_Pos;
13
+ layout(location = 13) in vec3 a_Normal;
14
+
13
15
 
14
16
  layout(std140) uniform commonUniform {
15
17
  vec4 u_sourceColor;
@@ -40,7 +42,7 @@ float getYRadian(float x, float z) {
40
42
  } else if(x > 0.0 && z <= 0.0){
41
43
  return atan(-z/x) + pi/2.0;
42
44
  } else if(x <= 0.0 && z <= 0.0) {
43
- return pi + atan(x/z); //atan(x/z) +
45
+ return pi + atan(x/z); //atan(x/z) +
44
46
  } else {
45
47
  return atan(z/-x) + pi*3.0/2.0;
46
48
  }
@@ -60,7 +62,15 @@ void main() {
60
62
 
61
63
  vec3 offset = size; // 控制圆柱体的大小 - 从标准单位圆柱体进行偏移
62
64
  if(u_heightfixed < 1.0) { // 圆柱体不固定高度
63
- //
65
+
66
+ if (u_CoordinateSystem == COORDINATE_SYSTEM_P20 || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {
67
+ // P20 坐标系下,为了和 Web 墨卡托坐标系统一,zoom 默认减1
68
+ offset = offset * pow(2.0, (19.0 - u_Zoom));
69
+ }
70
+ if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {
71
+ // P20_2 坐标系下,为了和 Web 墨卡托坐标系统一,zoom 默认减3
72
+ offset = offset * pow(2.0, (19.0 - 3.0 - u_Zoom));
73
+ }
64
74
  } else {// 圆柱体固定高度 ( 处理 mapbox )
65
75
  if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {
66
76
  offset *= 4.0/pow(2.0, 21.0 - u_Zoom);
@@ -88,7 +98,7 @@ void main() {
88
98
  }
89
99
  v_color.a *= u_opacity;
90
100
 
91
-
101
+
92
102
  // 在地球模式下,将原本垂直于 xy 平面的圆柱调整姿态到适应圆的角度
93
103
  //旋转矩阵mx,创建绕x轴旋转矩阵
94
104
  float r = sqrt(a_Pos.z*a_Pos.z + a_Pos.x*a_Pos.x);
@@ -96,9 +106,9 @@ void main() {
96
106
  float xcos = cos(xRadian);//求解旋转角度余弦值
97
107
  float xsin = sin(xRadian);//求解旋转角度正弦值
98
108
  mat4 mx = mat4(
99
- 1,0,0,0,
100
- 0,xcos,-xsin,0,
101
- 0,xsin,xcos,0,
109
+ 1,0,0,0,
110
+ 0,xcos,-xsin,0,
111
+ 0,xsin,xcos,0,
102
112
  0,0,0,1);
103
113
 
104
114
  //旋转矩阵my,创建绕y轴旋转矩阵
@@ -106,13 +116,13 @@ void main() {
106
116
  float ycos = cos(yRadian);//求解旋转角度余弦值
107
117
  float ysin = sin(yRadian);//求解旋转角度正弦值
108
118
  mat4 my = mat4(
109
- ycos,0,-ysin,0,
110
- 0,1,0,0,
111
- ysin,0,ycos,0,
119
+ ycos,0,-ysin,0,
120
+ 0,1,0,0,
121
+ ysin,0,ycos,0,
112
122
  0,0,0,1);
113
123
 
114
124
  gl_Position = u_ViewProjectionMatrix * vec4(( my * mx * vec4(a_Position * a_Size, 1.0)).xyz + a_Pos, 1.0);
115
-
125
+
116
126
 
117
127
  setPickingColor(a_PickingColor);
118
128
  }
@@ -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_SHAPE) in float a_Shape;
5
- layout(location = ATTRIBUTE_LOCATION_EXTRUDE) in vec3 a_Extrude;
1
+ layout(location = 0) in vec3 a_Position;
2
+ layout(location = 1) in vec4 a_Color;
3
+ layout(location = 9) in float a_Size;
4
+ layout(location = 10) in float a_Shape;
5
+ layout(location = 11) in vec3 a_Extrude;
6
6
 
7
7
  layout(std140) uniform commonUniform {
8
8
  float u_additive;
@@ -43,4 +43,4 @@ void main() {
43
43
  gl_Position = u_ViewProjectionMatrix * vec4(a_Position + extrude * newSize * 0.1 + vec3(u_offsets,0.0), 1.0);
44
44
 
45
45
  setPickingColor(a_PickingColor);
46
- }
46
+ }
@@ -1,10 +1,10 @@
1
- #define pi (3.1415926535)
1
+ #define pi 3.1415926535
2
2
 
3
- layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;
4
- layout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;
5
- layout(location = ATTRIBUTE_LOCATION_SIZE) in vec3 a_Size;
6
- layout(location = ATTRIBUTE_LOCATION_EXTRUDE) in vec4 a_Extrude;
7
- layout(location = ATTRIBUTE_LOCATION_NORMAL) in vec3 a_Normal;
3
+ layout(location = 0) in vec3 a_Position;
4
+ layout(location = 1) in vec4 a_Color;
5
+ layout(location = 9) in vec3 a_Size;
6
+ layout(location = 11) in vec3 a_Extrude;
7
+ layout(location = 13) in vec3 a_Normal;
8
8
 
9
9
  layout(std140) uniform commonUniforms {
10
10
  float u_pickLight;
@@ -25,41 +25,46 @@ out float v_lightWeight;
25
25
  #pragma include "picking"
26
26
 
27
27
  float getYRadian(float x, float z) {
28
- if (x > 0.0 && z > 0.0) {
29
- return atan(x / z);
30
- } else if (x > 0.0 && z <= 0.0) {
31
- return atan(-z / x) + pi / 2.0;
32
- } else if (x <= 0.0 && z <= 0.0) {
33
- return pi + atan(x / z); //atan(x/z) +
28
+ if(x > 0.0 && z > 0.0) {
29
+ return atan(x/z);
30
+ } else if(x > 0.0 && z <= 0.0){
31
+ return atan(-z/x) + pi/2.0;
32
+ } else if(x <= 0.0 && z <= 0.0) {
33
+ return pi + atan(x/z); //atan(x/z) +
34
34
  } else {
35
- return atan(z / -x) + pi * 3.0 / 2.0;
35
+ return atan(z/-x) + pi*3.0/2.0;
36
36
  }
37
37
  }
38
38
 
39
39
  float getXRadian(float y, float r) {
40
- return atan(y / r);
40
+ return atan(y/r);
41
41
  }
42
42
 
43
43
  void main() {
44
+
45
+
44
46
  vec3 size = a_Size * a_Position;
45
47
 
46
48
  vec3 offset = size; // 控制圆柱体的大小 - 从标准单位圆柱体进行偏移
47
49
 
48
- if (u_heightfixed < 1.0) {
49
- // 圆柱体不固定高度
50
- } else {
51
- // 圆柱体固定高度 处理 mapbox
52
- if (
53
- u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT ||
54
- u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET
55
- ) {
56
- offset *= 4.0 / pow(2.0, 21.0 - u_Zoom);
50
+ if(u_heightfixed < 1.0) { // 圆柱体不固定高度
51
+
52
+ if (u_CoordinateSystem == COORDINATE_SYSTEM_P20 || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {
53
+ // P20 坐标系下,为了和 Web 墨卡托坐标系统一,zoom 默认减1
54
+ offset = offset * pow(2.0, (19.0 - u_Zoom));
55
+ }
56
+ if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {
57
+ // P20_2 坐标系下,为了和 Web 墨卡托坐标系统一,zoom 默认减3
58
+ offset = offset * pow(2.0, (19.0 - 3.0 - u_Zoom));
59
+ }
60
+ } else {// 圆柱体固定高度 ( 处理 mapbox )
61
+ if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {
62
+ offset *= 4.0/pow(2.0, 21.0 - u_Zoom);
57
63
  }
58
64
  }
59
65
 
60
- vec2 positions = a_Extrude.xy;
61
- vec2 positions64Low = a_Extrude.zw;
62
- vec4 project_pos = project_position(vec4(positions, 0.0, 1.0), positions64Low);
66
+
67
+ vec4 project_pos = project_position(vec4(a_Extrude.xy, 0., 1.0));
63
68
 
64
69
  // u_r 控制圆柱的生长
65
70
  vec4 pos = vec4(project_pos.xy + offset.xy, offset.z * u_r, 1.0);
@@ -67,8 +72,7 @@ void main() {
67
72
  // // 圆柱光照效果
68
73
  float lightWeight = 1.0;
69
74
 
70
- if (u_lightEnable > 0.0) {
71
- // 取消三元表达式,增强健壮性
75
+ if(u_lightEnable > 0.0) { // 取消三元表达式,增强健壮性
72
76
  lightWeight = calc_lighting(pos);
73
77
  }
74
78
 
@@ -76,20 +80,20 @@ void main() {
76
80
 
77
81
  v_color = a_Color;
78
82
 
79
- // 设置圆柱的底色
80
- if (u_linearColor == 1.0) {
81
- // 使用渐变颜色
83
+ // 设置圆柱的底色
84
+ if(u_linearColor == 1.0) { // 使用渐变颜色
82
85
  v_color = mix(u_sourceColor, u_targetColor, a_Position.z);
83
- v_color.a = v_color.a * opacity;
86
+ v_color.a = v_color.a * opacity;
84
87
  } else {
85
88
  v_color = vec4(a_Color.rgb * lightWeight, a_Color.w * opacity);
86
89
  }
87
90
 
88
- if (u_opacitylinear > 0.0) {
89
- v_color.a *= u_opacitylinear_dir > 0.0 ? 1.0 - a_Position.z : a_Position.z;
91
+ if(u_opacitylinear > 0.0) {
92
+ v_color.a *= u_opacitylinear_dir > 0.0 ? (1.0 - a_Position.z): a_Position.z;
90
93
  }
91
94
 
92
- gl_Position = project_common_position_to_clipspace(pos);
95
+
96
+ gl_Position = project_common_position_to_clipspace_v2(pos);
93
97
 
94
98
  setPickingColor(a_PickingColor);
95
99
  }