@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
@@ -9,13 +9,18 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
9
9
  var _l7Core = require("@antv/l7-core");
10
10
  var _l7Utils = require("@antv/l7-utils");
11
11
  var _BaseModel = _interopRequireDefault(require("../../core/BaseModel"));
12
- var _CommonStyleAttribute = require("../../core/CommonStyleAttribute");
13
12
  var _triangulation = require("../../core/triangulation");
14
13
  /* babel-plugin-inline-import '../shaders/simple/simpleline_frag.glsl' */
15
14
  const simple_line_frag = "\nlayout(std140) uniform commonUniorm {\n vec4 u_sourceColor;\n vec4 u_targetColor;\n vec4 u_dash_array;\n float u_vertexScale: 1.0;\n float u_linearColor: 0;\n};\nin float v_distanceScale;\nin vec4 v_color;\n//dash\nin vec4 v_dash_array;\n\nout vec4 outputColor;\nvoid main() {\n if(u_dash_array!=vec4(0.0)){\n float dashLength = mod(v_distanceScale, v_dash_array.x + v_dash_array.y + v_dash_array.z + v_dash_array.w);\n if(!(dashLength < v_dash_array.x || (dashLength > (v_dash_array.x + v_dash_array.y) && dashLength < v_dash_array.x + v_dash_array.y + v_dash_array.z))) {\n // \u865A\u7EBF\u90E8\u5206\n discard;\n };\n }\n if(u_linearColor==1.0){\n outputColor = mix(u_sourceColor, u_targetColor, v_distanceScale);\n outputColor.a *= v_color.a; // \u5168\u5C40\u900F\u660E\u5EA6\n }\n else{\n outputColor = v_color;\n }\n}\n";
16
15
  /* babel-plugin-inline-import '../shaders/simple/simpleline_vert.glsl' */
17
- const simple_line_vert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in vec4 a_SizeDistanceAndTotalDistance;\n\nlayout(std140) uniform commonUniorm {\n vec4 u_sourceColor;\n vec4 u_targetColor;\n vec4 u_dash_array;\n float u_vertexScale: 1.0;\n float u_linearColor: 0;\n};\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nout vec4 v_color;\nout float v_distanceScale;\nout vec4 v_dash_array;\n\nvoid main() {\n //dash\u8F93\u51FA\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / a_SizeDistanceAndTotalDistance.a;\n\n v_color = a_Color; \n v_distanceScale = a_SizeDistanceAndTotalDistance.b / a_SizeDistanceAndTotalDistance.a;\n v_color.a = v_color.a * opacity;\n vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));\n\n float h = float(a_Position.z) * u_vertexScale; // \u7EBF\u9876\u70B9\u7684\u9AD8\u5EA6 - \u517C\u5BB9\u4E0D\u5B58\u5728\u7B2C\u4E09\u4E2A\u6570\u503C\u7684\u60C5\u51B5\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xy, project_pixel(a_SizeDistanceAndTotalDistance.y) + h * 0.2, 1.0));\n } else {\n float lineHeight = a_SizeDistanceAndTotalDistance.y;\n // \u517C\u5BB9 mapbox \u5728\u7EBF\u9AD8\u5EA6\u4E0A\u7684\u6548\u679C\u8868\u73B0\u57FA\u672C\u4E00\u81F4\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // \u4FDD\u6301\u9AD8\u5EA6\u76F8\u5BF9\u4E0D\u53D8\n h *= 2.0/pow(2.0, 20.0 - u_Zoom);\n }\n\n // amap1.x\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20 || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n // \u4FDD\u6301\u9AD8\u5EA6\u76F8\u5BF9\u4E0D\u53D8\n lineHeight *= pow(2.0, 20.0 - u_Zoom);\n }\n\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy, lineHeight + h, 1.0));\n gl_PointSize = 10.0;\n }\n}\n";
16
+ const simple_line_vert = "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 vec4 a_SizeDistanceAndTotalDistance;\n\nlayout(std140) uniform commonUniorm {\n vec4 u_sourceColor;\n vec4 u_targetColor;\n vec4 u_dash_array;\n float u_vertexScale: 1.0;\n float u_linearColor: 0;\n};\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nout vec4 v_color;\nout float v_distanceScale;\nout vec4 v_dash_array;\n\nvoid main() {\n //dash\u8F93\u51FA\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / a_SizeDistanceAndTotalDistance.a;\n\n v_color = a_Color;\n v_distanceScale = a_SizeDistanceAndTotalDistance.b / a_SizeDistanceAndTotalDistance.a;\n v_color.a = v_color.a * opacity;\n vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0), a_Position64Low);\n\n float h = float(a_Position.z) * u_vertexScale; // \u7EBF\u9876\u70B9\u7684\u9AD8\u5EA6 - \u517C\u5BB9\u4E0D\u5B58\u5728\u7B2C\u4E09\u4E2A\u6570\u503C\u7684\u60C5\u51B5\n\n float lineHeight = a_SizeDistanceAndTotalDistance.y;\n // \u517C\u5BB9 mapbox \u5728\u7EBF\u9AD8\u5EA6\u4E0A\u7684\u6548\u679C\u8868\u73B0\u57FA\u672C\u4E00\u81F4\n if (\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT ||\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET\n ) {\n // \u4FDD\u6301\u9AD8\u5EA6\u76F8\u5BF9\u4E0D\u53D8\n h *= 2.0 / pow(2.0, 20.0 - u_Zoom);\n }\n\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy, lineHeight + h, 1.0));\n gl_PointSize = 10.0;\n\n}\n";
18
17
  class SimpleLineModel extends _BaseModel.default {
18
+ get attributeLocation() {
19
+ return Object.assign(super.attributeLocation, {
20
+ MAX: super.attributeLocation.MAX,
21
+ SIZE: 9
22
+ });
23
+ }
19
24
  getCommonUniformsInfo() {
20
25
  const {
21
26
  sourceColor,
@@ -79,6 +84,7 @@ class SimpleLineModel extends _BaseModel.default {
79
84
  vertexShader: vert,
80
85
  fragmentShader: frag,
81
86
  triangulation: _triangulation.SimpleLineTriangulation,
87
+ defines: _this2.getDefines(),
82
88
  inject: _this2.getInject(),
83
89
  primitive: _l7Core.gl.LINES,
84
90
  depth: {
@@ -90,57 +96,16 @@ class SimpleLineModel extends _BaseModel.default {
90
96
  })();
91
97
  }
92
98
  registerBuiltinAttributes() {
93
- // this.styleAttributeService.registerStyleAttribute({
94
- // name: 'distance',
95
- // type: AttributeType.Attribute,
96
- // descriptor: {
97
- // name: 'a_Distance',
98
- // shaderLocation: 14,
99
- // buffer: {
100
- // // give the WebGL driver a hint that this buffer may change
101
- // usage: gl.STATIC_DRAW,
102
- // data: [],
103
- // type: gl.FLOAT,
104
- // },
105
- // size: 1,
106
- // update: (
107
- // feature: IEncodeFeature,
108
- // featureIdx: number,
109
- // vertex: number[],
110
- // ) => {
111
- // return [vertex[3]];
112
- // },
113
- // },
114
- // });
115
- // this.styleAttributeService.registerStyleAttribute({
116
- // name: 'total_distance',
117
- // type: AttributeType.Attribute,
118
- // descriptor: {
119
- // name: 'a_Total_Distance',
120
- // shaderLocation: 13,//枚举不够了,先固定写值吧,在shader中location也成一致的并且不与其他的重复就行了
121
- // buffer: {
122
- // // give the WebGL driver a hint that this buffer may change
123
- // usage: gl.STATIC_DRAW,
124
- // data: [],
125
- // type: gl.FLOAT,
126
- // },
127
- // size: 1,
128
- // update: (
129
- // feature: IEncodeFeature,
130
- // featureIdx: number,
131
- // vertex: number[],
132
- // ) => {
133
- // return [vertex[5]];
134
- // },
135
- // },
136
- // });
99
+ // 注册 Position 属性 64 位地位部分,经纬度数据开启双精度,避免大于 20层级以上出现数据偏移
100
+ this.registerPosition64LowAttribute();
101
+
137
102
  //size.x,size,y,distance,totalDistance
138
103
  this.styleAttributeService.registerStyleAttribute({
139
104
  name: 'sizeDistanceAndTotalDistance',
140
105
  type: _l7Core.AttributeType.Attribute,
141
106
  descriptor: {
142
107
  name: 'a_SizeDistanceAndTotalDistance',
143
- shaderLocation: _CommonStyleAttribute.ShaderLocation.SIZE,
108
+ shaderLocation: this.attributeLocation.SIZE,
144
109
  buffer: {
145
110
  usage: _l7Core.gl.STATIC_DRAW,
146
111
  data: [],
@@ -1,6 +1,23 @@
1
1
  import type { IModel, ITexture2D } from '@antv/l7-core';
2
2
  import BaseModel from '../../core/BaseModel';
3
3
  export default class LineWallModel extends BaseModel {
4
+ protected get attributeLocation(): {
5
+ readonly POSITION: 0;
6
+ readonly POSITION_64LOW: 1;
7
+ readonly COLOR: 2;
8
+ readonly PICKING_COLOR: 3;
9
+ readonly STROKE: 4;
10
+ readonly OPACITY: 5;
11
+ readonly OFFSETS: 6;
12
+ readonly ROTATION: 7;
13
+ readonly MAX: 8;
14
+ } & Record<string, number> & {
15
+ MAX: 8;
16
+ SIZE: number;
17
+ NORMAL: number;
18
+ UV: number;
19
+ DISTANCE_MITER_TOTAL: number;
20
+ };
4
21
  protected texture: ITexture2D;
5
22
  protected getCommonUniformsInfo(): {
6
23
  uniformsArray: number[];
@@ -10,12 +10,11 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
10
10
  var _l7Core = require("@antv/l7-core");
11
11
  var _l7Utils = require("@antv/l7-utils");
12
12
  var _BaseModel = _interopRequireDefault(require("../../core/BaseModel"));
13
- var _CommonStyleAttribute = require("../../core/CommonStyleAttribute");
14
13
  var _triangulation = require("../../core/triangulation");
15
14
  /* babel-plugin-inline-import '../shaders/wall/wall_frag.glsl' */
16
15
  const line_frag = "#define Animate 0.0\n#define LineTexture 1.0\n\n// line texture\n\nuniform sampler2D u_texture;\nlayout(std140) uniform commonUniorm {\n vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\n vec4 u_sourceColor;\n vec4 u_targetColor;\n vec2 u_textSize;\n float u_icon_step: 100;\n float u_heightfixed;\n float u_linearColor: 0;\n float u_line_texture;\n float u_textureBlend;\n float u_iconStepCount;\n float u_time;\n};\nin vec2 v_iconMapUV;\nin float v_blur;\nin float v_radio;\nin vec4 v_color;\nin vec4 v_dataset;\n\nout vec4 outputColor;\n#pragma include \"picking\"\n\nvoid main() {\n float animateSpeed = 0.0; // \u8FD0\u52A8\u901F\u5EA6\n float d_distance_ratio = v_dataset.r; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n float v = v_dataset.a;\n\n if(u_linearColor == 1.0) { // \u4F7F\u7528\u6E10\u53D8\u989C\u8272\n outputColor = mix(u_sourceColor, u_targetColor, v);\n } else { // \u4F7F\u7528 color \u65B9\u6CD5\u4F20\u5165\u7684\u989C\u8272\n outputColor = v_color;\n }\n\n outputColor.a *= v_color.a; // \u5168\u5C40\u900F\u660E\u5EA6\n if(u_animate.x == Animate) {\n animateSpeed = u_time / u_animate.y;\n float alpha =1.0 - fract( mod(1.0- d_distance_ratio, u_animate.z)* (1.0/ u_animate.z) + animateSpeed);\n alpha = (alpha + u_animate.w -1.0) / u_animate.w;\n alpha = smoothstep(0., 1., alpha);\n outputColor.a *= alpha;\n }\n\n if(u_line_texture == LineTexture) { // while load texture\n float aDistance = v_dataset.g; // \u5F53\u524D\u9876\u70B9\u7684\u8DDD\u79BB\n float d_texPixelLen = v_dataset.b; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n float u = fract(mod(aDistance, d_texPixelLen)/d_texPixelLen - animateSpeed);\n float v = v_dataset.a; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n // \u8BA1\u7B97\u7EB9\u7406\u95F4\u9694 start\n float flag = 0.0;\n if(u > 1.0/u_iconStepCount) {\n flag = 1.0;\n }\n u = fract(u*u_iconStepCount);\n // \u8BA1\u7B97\u7EB9\u7406\u95F4\u9694 end\n\n vec2 uv= v_iconMapUV / u_textSize + vec2(u, v) / u_textSize * 64.;\n vec4 pattern = texture(SAMPLER_2D(u_texture), uv);\n\n // Tip: \u5224\u65AD\u7EB9\u7406\u95F4\u9694\n if(flag > 0.0) {\n pattern = vec4(0.0);\n }\n\n if(u_textureBlend == 0.0) { // normal\n pattern.a = 0.0;\n outputColor = filterColor(outputColor + pattern);\n } else { // replace\n pattern.a *= v_color.a;\n if(outputColor.a <= 0.0) {\n pattern.a = 0.0;\n }\n outputColor = filterColor(pattern);\n }\n }\n \n\n // blur - AA\n if(v < v_blur) {\n outputColor.a = mix(0.0, outputColor.a, v/v_blur);\n } else if(v > 1.0 - v_blur) {\n outputColor.a = mix(outputColor.a, 0.0, (v - (1.0 - v_blur))/v_blur);\n }\n\n outputColor = filterColor(outputColor);\n}\n";
17
16
  /* babel-plugin-inline-import '../shaders/wall/wall_vert.glsl' */
18
- const line_vert = "#define Animate 0.0\nlayout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in vec2 a_Size;\nlayout(location = 10) in float a_Miter;\nlayout(location = 11) in float a_Total_Distance;\nlayout(location = 12) in vec4 a_Instance;\nlayout(location = 13) in vec3 a_Normal;\nlayout(location = 14) in vec2 a_iconMapUV;\nlayout(location = 15) in float a_Distance;\n\n\nlayout(std140) uniform commonUniorm {\n vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\n vec4 u_sourceColor;\n vec4 u_targetColor;\n vec2 u_textSize;\n float u_icon_step: 100;\n float u_heightfixed;\n float u_linearColor: 0;\n float u_line_texture;\n float u_textureBlend;\n float u_iconStepCount;\n float u_time;\n};\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\n// texV \u7EBF\u56FE\u5C42 - \u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\uFF08\u7EBF\u7684\u5BBD\u5EA6\u65B9\u5411\uFF09\nout vec2 v_iconMapUV;\nout vec4 v_color;\nout float v_blur;\nout float v_radio;\nout vec4 v_dataset;\n\nvoid main() {\n\n\n float d_distance_ratio; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n float d_texPixelLen; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n\n v_iconMapUV = a_iconMapUV;\n if(u_heightfixed < 1.0) { // \u9AD8\u5EA6\u968F zoom \u8C03\u6574\n d_texPixelLen = project_pixel(u_icon_step);\n } else {\n d_texPixelLen = u_icon_step;\n }\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n d_texPixelLen *= 10.0;\n }\n\n if(u_animate.x == Animate || u_linearColor == 1.0) {\n d_distance_ratio = a_Distance / a_Total_Distance;\n }\n\n float miter = (a_Miter + 1.0)/2.0;\n // \u8BBE\u7F6E\u6570\u636E\u96C6\u7684\u53C2\u6570\n v_dataset[0] = d_distance_ratio; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n v_dataset[1] = a_Distance; // \u5F53\u524D\u9876\u70B9\u7684\u8DDD\u79BB\n v_dataset[2] = d_texPixelLen; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n v_dataset[3] = miter; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C 0 - 1\n\n vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));\n\n float originSize = a_Size.x; // \u56FA\u5B9A\u9AD8\u5EA6\n if(u_heightfixed < 1.0) { \n originSize = project_float_meter(a_Size.x); // \u9AD8\u5EA6\u968F zoom \u8C03\u6574\n }\n\n\n float wallHeight = originSize * miter;\n float lightWeight = calc_lighting(vec4(project_pos.xy, wallHeight, 1.0));\n\n v_blur = min(project_float_pixel(2.0) / originSize, 0.05);\n v_color = vec4(a_Color.rgb * lightWeight, a_Color.w * opacity);\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xy, wallHeight, 1.0));\n } else {\n// \u517C\u5BB9 mapbox \u5728\u7EBF\u9AD8\u5EA6\u4E0A\u7684\u6548\u679C\u8868\u73B0\u57FA\u672C\u4E00\u81F4\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // mapbox\n // \u4FDD\u6301\u9AD8\u5EA6\u76F8\u5BF9\u4E0D\u53D8\n float mapboxZoomScale = 4.0 / pow(2.0, 21.0 - u_Zoom);\n if(u_heightfixed > 0.0) {\n wallHeight *= mapboxZoomScale;\n }\n \n } else {\n // lineHeight \u9876\u70B9\u504F\u79FB\u9AD8\u5EA6\n if(u_heightfixed < 1.0) {\n wallHeight *= pow(2.0, 20.0 - u_Zoom);\n }\n }\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy, wallHeight, 1.0));\n }\n\n setPickingColor(a_PickingColor);\n}\n";
17
+ const line_vert = "#define Animate 0.0\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 vec2 a_Size;\nlayout(location = ATTRIBUTE_LOCATION_NORMAL) in vec3 a_Normal;\nlayout(location = ATTRIBUTE_LOCATION_UV) in vec2 a_iconMapUV;\nlayout(location = ATTRIBUTE_LOCATION_DISTANCE_MITER_TOTAL) in vec3 a_Distance_Total_Miter;\n\nlayout(std140) uniform commonUniorm {\n vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\n vec4 u_sourceColor;\n vec4 u_targetColor;\n vec2 u_textSize;\n float u_icon_step: 100;\n float u_heightfixed;\n float u_linearColor: 0;\n float u_line_texture;\n float u_textureBlend;\n float u_iconStepCount;\n float u_time;\n};\n\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\n// texV \u7EBF\u56FE\u5C42 - \u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\uFF08\u7EBF\u7684\u5BBD\u5EA6\u65B9\u5411\uFF09\nout vec2 v_iconMapUV;\nout vec4 v_color;\nout float v_blur;\nout float v_radio;\nout vec4 v_dataset;\n\nvoid main() {\n float a_Distance = a_Distance_Total_Miter.x;\n float a_Miter = a_Distance_Total_Miter.y;\n float a_Total_Distance = a_Distance_Total_Miter.z;\n\n float d_distance_ratio; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n float d_texPixelLen; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n\n v_iconMapUV = a_iconMapUV;\n if (u_heightfixed < 1.0) {\n // \u9AD8\u5EA6\u968F zoom \u8C03\u6574\n d_texPixelLen = project_pixel(u_icon_step);\n } else {\n d_texPixelLen = u_icon_step;\n }\n\n if (u_animate.x == Animate || u_linearColor == 1.0) {\n d_distance_ratio = a_Distance / a_Total_Distance;\n }\n\n float miter = (a_Miter + 1.0) / 2.0;\n // \u8BBE\u7F6E\u6570\u636E\u96C6\u7684\u53C2\u6570\n v_dataset[0] = d_distance_ratio; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n v_dataset[1] = a_Distance; // \u5F53\u524D\u9876\u70B9\u7684\u8DDD\u79BB\n v_dataset[2] = d_texPixelLen; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n v_dataset[3] = miter; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C 0 - 1\n\n vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0), a_Position64Low);\n\n float originSize = a_Size.x; // \u56FA\u5B9A\u9AD8\u5EA6\n if (u_heightfixed < 1.0) {\n originSize = project_float_meter(a_Size.x); // \u9AD8\u5EA6\u968F zoom \u8C03\u6574\n }\n\n float wallHeight = originSize * miter;\n float lightWeight = calc_lighting(vec4(project_pos.xy, wallHeight, 1.0));\n\n v_blur = min(project_float_pixel(2.0) / originSize, 0.05);\n v_color = vec4(a_Color.rgb * lightWeight, a_Color.w * opacity);\n\n // \u517C\u5BB9 mapbox \u5728\u7EBF\u9AD8\u5EA6\u4E0A\u7684\u6548\u679C\u8868\u73B0\u57FA\u672C\u4E00\u81F4\n if (\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT ||\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET\n ) {\n // mapbox\n // \u4FDD\u6301\u9AD8\u5EA6\u76F8\u5BF9\u4E0D\u53D8\n float mapboxZoomScale = 4.0 / pow(2.0, 21.0 - u_Zoom);\n if (u_heightfixed > 0.0) {\n wallHeight *= mapboxZoomScale;\n }\n }\n\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy, wallHeight, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
19
18
  class LineWallModel extends _BaseModel.default {
20
19
  constructor(...args) {
21
20
  super(...args);
@@ -42,6 +41,15 @@ class LineWallModel extends _BaseModel.default {
42
41
  this.textures = [this.texture];
43
42
  });
44
43
  }
44
+ get attributeLocation() {
45
+ return Object.assign(super.attributeLocation, {
46
+ MAX: super.attributeLocation.MAX,
47
+ SIZE: 9,
48
+ NORMAL: 12,
49
+ UV: 13,
50
+ DISTANCE_MITER_TOTAL: 15
51
+ });
52
+ }
45
53
  getCommonUniformsInfo() {
46
54
  const {
47
55
  sourceColor,
@@ -117,6 +125,7 @@ class LineWallModel extends _BaseModel.default {
117
125
  vertexShader: line_vert,
118
126
  fragmentShader: line_frag,
119
127
  triangulation: _triangulation.LineTriangulation,
128
+ defines: _this2.getDefines(),
120
129
  inject: _this2.getInject(),
121
130
  depth: {
122
131
  enable: false
@@ -127,48 +136,14 @@ class LineWallModel extends _BaseModel.default {
127
136
  })();
128
137
  }
129
138
  registerBuiltinAttributes() {
130
- this.styleAttributeService.registerStyleAttribute({
131
- name: 'distance',
132
- type: _l7Core.AttributeType.Attribute,
133
- descriptor: {
134
- name: 'a_Distance',
135
- shaderLocation: 15,
136
- buffer: {
137
- // give the WebGL driver a hint that this buffer may change
138
- usage: _l7Core.gl.STATIC_DRAW,
139
- data: [],
140
- type: _l7Core.gl.FLOAT
141
- },
142
- size: 1,
143
- update: (feature, featureIdx, vertex) => {
144
- return [vertex[3]];
145
- }
146
- }
147
- });
148
- this.styleAttributeService.registerStyleAttribute({
149
- name: 'total_distance',
150
- type: _l7Core.AttributeType.Attribute,
151
- descriptor: {
152
- name: 'a_Total_Distance',
153
- shaderLocation: 11,
154
- buffer: {
155
- // give the WebGL driver a hint that this buffer may change
156
- usage: _l7Core.gl.STATIC_DRAW,
157
- data: [],
158
- type: _l7Core.gl.FLOAT
159
- },
160
- size: 1,
161
- update: (feature, featureIdx, vertex) => {
162
- return [vertex[5]];
163
- }
164
- }
165
- });
139
+ // 注册 Position 属性 64 位地位部分,经纬度数据开启双精度,避免大于 20层级以上出现数据偏移
140
+ this.registerPosition64LowAttribute();
166
141
  this.styleAttributeService.registerStyleAttribute({
167
142
  name: 'size',
168
143
  type: _l7Core.AttributeType.Attribute,
169
144
  descriptor: {
170
145
  name: 'a_Size',
171
- shaderLocation: _CommonStyleAttribute.ShaderLocation.SIZE,
146
+ shaderLocation: this.attributeLocation.SIZE,
172
147
  buffer: {
173
148
  // give the WebGL driver a hint that this buffer may change
174
149
  usage: _l7Core.gl.DYNAMIC_DRAW,
@@ -184,14 +159,12 @@ class LineWallModel extends _BaseModel.default {
184
159
  }
185
160
  }
186
161
  });
187
-
188
- // point layer size;
189
162
  this.styleAttributeService.registerStyleAttribute({
190
163
  name: 'normal',
191
164
  type: _l7Core.AttributeType.Attribute,
192
165
  descriptor: {
193
166
  name: 'a_Normal',
194
- shaderLocation: _CommonStyleAttribute.ShaderLocation.NORMAL,
167
+ shaderLocation: this.attributeLocation.NORMAL,
195
168
  buffer: {
196
169
  // give the WebGL driver a hint that this buffer may change
197
170
  usage: _l7Core.gl.STATIC_DRAW,
@@ -206,20 +179,21 @@ class LineWallModel extends _BaseModel.default {
206
179
  }
207
180
  });
208
181
  this.styleAttributeService.registerStyleAttribute({
209
- name: 'miter',
182
+ name: 'distanceAndTotalAndMiter',
210
183
  type: _l7Core.AttributeType.Attribute,
211
184
  descriptor: {
212
- name: 'a_Miter',
213
- shaderLocation: 10,
185
+ name: 'a_Distance_Total_Miter',
186
+ shaderLocation: this.attributeLocation.DISTANCE_MITER_TOTAL,
214
187
  buffer: {
215
188
  // give the WebGL driver a hint that this buffer may change
216
189
  usage: _l7Core.gl.STATIC_DRAW,
217
190
  data: [],
218
191
  type: _l7Core.gl.FLOAT
219
192
  },
220
- size: 1,
193
+ size: 3,
221
194
  update: (feature, featureIdx, vertex) => {
222
- return [vertex[4]];
195
+ // [distance, miter, total_distance]
196
+ return [vertex[3], vertex[4], vertex[5]];
223
197
  }
224
198
  }
225
199
  });
@@ -228,7 +202,7 @@ class LineWallModel extends _BaseModel.default {
228
202
  type: _l7Core.AttributeType.Attribute,
229
203
  descriptor: {
230
204
  name: 'a_iconMapUV',
231
- shaderLocation: 14,
205
+ shaderLocation: this.attributeLocation.UV,
232
206
  buffer: {
233
207
  // give the WebGL driver a hint that this buffer may change
234
208
  usage: _l7Core.gl.DYNAMIC_DRAW,
@@ -1,10 +1,12 @@
1
- #define Animate 0.0
2
- #define LineTexture 1.0
3
- layout(location = 0) in vec3 a_Position;
4
- layout(location = 1) in vec4 a_Color;
5
- layout(location = 9) in float a_Size;
6
- layout(location = 12) in vec4 a_Instance;
7
- layout(location = 14) in vec2 a_iconMapUV;
1
+ #define Animate (0.0)
2
+ #define LineTexture (1.0)
3
+
4
+ layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;
5
+ layout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;
6
+ layout(location = ATTRIBUTE_LOCATION_SIZE) in float a_Size;
7
+ layout(location = ATTRIBUTE_LOCATION_INSTANCE) in vec4 a_Instance;
8
+ layout(location = ATTRIBUTE_LOCATION_INSTANCE_64LOW) in vec4 a_Instance64Low;
9
+ layout(location = ATTRIBUTE_LOCATION_UV) in vec2 a_iconMapUV;
8
10
 
9
11
  layout(std140) uniform commonUniorm {
10
12
  vec4 u_animate: [ 1., 2., 1.0, 0.2 ];
@@ -22,6 +24,7 @@ layout(std140) uniform commonUniorm {
22
24
  float u_time;
23
25
  float u_linearColor: 0.0;
24
26
  };
27
+
25
28
  out vec4 v_color;
26
29
  out vec2 v_iconMapUV;
27
30
  out vec4 v_lineData;
@@ -29,13 +32,12 @@ out vec4 v_lineData;
29
32
  out vec4 v_dash_array;
30
33
  out float v_distance_ratio;
31
34
 
32
-
33
35
  #pragma include "projection"
34
36
  #pragma include "project"
35
37
  #pragma include "picking"
36
38
 
37
39
  float bezier3(vec3 arr, float t) {
38
- float ut = 1. - t;
40
+ float ut = 1.0 - t;
39
41
  return (arr.x * ut + arr.y * t) * ut + (arr.y * ut + arr.z * t) * t;
40
42
  }
41
43
  vec2 midPoint(vec2 source, vec2 target, float arcThetaOffset) {
@@ -45,10 +47,12 @@ vec2 midPoint(vec2 source, vec2 target, float arcThetaOffset) {
45
47
  float thetaOffset = arcThetaOffset;
46
48
  float r2 = r / 2.0 / cos(thetaOffset);
47
49
  float theta2 = theta + thetaOffset;
48
- vec2 mid = vec2(r2*cos(theta2) + source.x, r2*sin(theta2) + source.y);
49
- if(u_lineDir == 1.0) { // 正向
50
+ vec2 mid = vec2(r2 * cos(theta2) + source.x, r2 * sin(theta2) + source.y);
51
+ if (u_lineDir == 1.0) {
52
+ // 正向
50
53
  return mid;
51
- } else { // 逆向
54
+ } else {
55
+ // 逆向
52
56
  // (mid + vmin)/2 = (s + t)/2
53
57
  vec2 vmid = source + target - mid;
54
58
  return vmid;
@@ -56,23 +60,23 @@ vec2 midPoint(vec2 source, vec2 target, float arcThetaOffset) {
56
60
  // return mid;
57
61
  }
58
62
  float getSegmentRatio(float index) {
59
- // dash: index / (segmentNumber - 1.);
60
- // normal: smoothstep(0.0, 1.0, index / (segmentNumber - 1.));
61
- return smoothstep(0.0, 1.0, index / (segmentNumber - 1.));
62
- // return index / (segmentNumber - 1.);
63
+ // dash: index / (segmentNumber - 1.);
64
+ // normal: smoothstep(0.0, 1.0, index / (segmentNumber - 1.));
65
+ return smoothstep(0.0, 1.0, index / (segmentNumber - 1.0));
66
+ // return index / (segmentNumber - 1.);
63
67
  }
64
- vec2 interpolate (vec2 source, vec2 target, float t, float arcThetaOffset) {
68
+ vec2 interpolate(vec2 source, vec2 target, float t, float arcThetaOffset) {
65
69
  // if the angularDist is PI, linear interpolation is applied. otherwise, use spherical interpolation
66
70
  vec2 mid = midPoint(source, target, arcThetaOffset);
67
71
  vec3 x = vec3(source.x, mid.x, target.x);
68
72
  vec3 y = vec3(source.y, mid.y, target.y);
69
- return vec2(bezier3(x ,t), bezier3(y,t));
73
+ return vec2(bezier3(x, t), bezier3(y, t));
70
74
  }
71
75
  vec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction) {
72
76
  // normalized direction of the line
73
77
  vec2 dir_screenspace = normalize(line_clipspace);
74
78
  // rotate by 90 degrees
75
- dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);
79
+ dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);
76
80
  vec2 offset = dir_screenspace * offset_direction * setPickingSize(a_Size) / 2.0;
77
81
  return offset;
78
82
  }
@@ -81,43 +85,34 @@ vec2 getNormal(vec2 line_clipspace, float offset_direction) {
81
85
  vec2 dir_screenspace = normalize(line_clipspace);
82
86
  // rotate by 90 degrees
83
87
  dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);
84
- return reverse_offset_normal(vec3(dir_screenspace,1.0)).xy * sign(offset_direction);
88
+ return dir_screenspace.xy * sign(offset_direction);
85
89
  }
86
90
 
87
91
  void main() {
88
92
  //vs中计算渐变色
89
- if(u_linearColor==1.0){
93
+ if (u_linearColor == 1.0) {
90
94
  float d_segmentIndex = a_Position.x + 1.0; // 当前顶点在弧线中所处的分段位置
91
- v_color = mix(u_sourceColor, u_targetColor, d_segmentIndex/segmentNumber);
92
- }
93
- else{
95
+ v_color = mix(u_sourceColor, u_targetColor, d_segmentIndex / segmentNumber);
96
+ } else {
94
97
  v_color = a_Color;
95
98
  }
96
99
  v_color.a = v_color.a * opacity;
97
100
 
98
- vec2 source = a_Instance.rg; // 起始点
99
- vec2 target = a_Instance.ba; // 终点
100
-
101
-
101
+ vec2 source_world = a_Instance.rg; // 起始点
102
+ vec2 target_world = a_Instance.ba; // 终点
102
103
 
103
104
  float segmentIndex = a_Position.x;
104
105
  float segmentRatio = getSegmentRatio(segmentIndex);
105
106
 
106
- //计算dashArray和distanceRatio 输出到片元
107
- vec2 s = source;
108
- vec2 t = target;
109
- if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
110
- s = unProjCustomCoord(source);
111
- t = unProjCustomCoord(target);
112
- }
113
- float total_Distance = pixelDistance(s, t) / 2.0 * PI;
107
+ // 计算 dashArray distanceRatio 输出到片元
108
+ float total_Distance = pixelDistance(source_world, target_world) / 2.0 * PI;
114
109
  v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / total_Distance;
115
110
  v_distance_ratio = segmentIndex / segmentNumber;
116
111
 
117
112
  float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));
118
113
  float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);
119
114
  float d_distance_ratio;
120
-
115
+
121
116
  if(u_animate.x == Animate) {
122
117
  d_distance_ratio = segmentIndex / segmentNumber;
123
118
  if(u_lineDir != 1.0) {
@@ -127,38 +122,35 @@ void main() {
127
122
 
128
123
  v_lineData.b = d_distance_ratio;
129
124
 
130
- vec4 curr = project_position(vec4(interpolate(source, target, segmentRatio, thetaOffset), 0.0, 1.0));
131
- vec4 next = project_position(vec4(interpolate(source, target, nextSegmentRatio, thetaOffset), 0.0, 1.0));
125
+ vec4 source = project_position(vec4(source_world, 0, 1.), a_Instance64Low.xy);
126
+ vec4 target = project_position(vec4(target_world, 0, 1.), a_Instance64Low.zw);
132
127
 
133
-
134
- vec2 offset = project_pixel(getExtrusionOffset((next.xy - curr.xy) * indexDir, a_Position.y));
128
+ vec2 currPos = interpolate(source.xy, target.xy, segmentRatio, thetaOffset);
129
+ vec2 nextPos = interpolate(source.xy, target.xy, nextSegmentRatio, thetaOffset);
135
130
 
131
+ vec2 offset = project_pixel(
132
+ getExtrusionOffset((nextPos.xy - currPos.xy) * indexDir, a_Position.y)
133
+ );
136
134
 
137
135
  float d_segmentIndex = a_Position.x + 1.0; // 当前顶点在弧线中所处的分段位置
138
136
  v_lineData.r = d_segmentIndex;
139
137
 
140
138
  if(LineTexture == u_line_texture) { // 开启贴图模式
141
-
142
139
  float arcDistrance = length(source - target); // 起始点和终点的距离
143
- if(u_CoordinateSystem == COORDINATE_SYSTEM_P20) { // amap
144
- arcDistrance *= 1000000.0;
145
- }
146
- if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) { // mapbox
147
- // arcDistrance *= 8.0;
148
- arcDistrance = project_pixel_allmap(arcDistrance);
149
- }
140
+ arcDistrance = project_pixel(arcDistrance);
141
+
150
142
  v_iconMapUV = a_iconMapUV;
151
143
 
152
144
  float pixelLen = project_pixel_texture(u_icon_step); // 贴图沿弧线方向的长度 - 随地图缩放改变
153
- float texCount = floor(arcDistrance/pixelLen); // 贴图在弧线上重复的数量
145
+ float texCount = floor(arcDistrance / pixelLen); // 贴图在弧线上重复的数量
154
146
  v_lineData.g = texCount;
155
147
 
156
148
  float lineOffsetWidth = length(offset + offset * sign(a_Position.y)); // 线横向偏移的距离
157
149
  float linePixelSize = project_pixel(a_Size); // 定点位置偏移
158
- v_lineData.a = lineOffsetWidth/linePixelSize; // 线图层贴图部分的 v 坐标值
150
+ v_lineData.a = lineOffsetWidth / linePixelSize; // 线图层贴图部分的 v 坐标值
159
151
  }
160
152
 
161
- gl_Position = project_common_position_to_clipspace_v2(vec4(curr.xy + offset, 0, 1.0));
153
+ gl_Position = project_common_position_to_clipspace(vec4(currPos.xy + offset, 0, 1.0));
162
154
 
163
155
  setPickingColor(a_PickingColor);
164
156
  }
@@ -2,11 +2,13 @@
2
2
  #define LineTypeDash 1.0
3
3
  #define Animate 0.0
4
4
  #define LineTexture 1.0
5
- layout(location = 0) in vec3 a_Position;
6
- layout(location = 1) in vec4 a_Color;
7
- layout(location = 9) in float a_Size;
8
- layout(location = 12) in vec4 a_Instance;
9
- layout(location = 14) in vec2 a_iconMapUV;
5
+
6
+ layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;
7
+ layout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;
8
+ layout(location = ATTRIBUTE_LOCATION_SIZE) in float a_Size;
9
+ layout(location = ATTRIBUTE_LOCATION_INSTANCE) in vec4 a_Instance;
10
+ layout(location = ATTRIBUTE_LOCATION_INSTANCE_64LOW) in vec4 a_Instance64Low;
11
+ layout(location = ATTRIBUTE_LOCATION_UV) in vec2 a_iconMapUV;
10
12
 
11
13
 
12
14
  layout(std140) uniform commonUniorm {
@@ -75,7 +77,7 @@ vec2 getNormal(vec2 line_clipspace, float offset_direction) {
75
77
  vec2 dir_screenspace = normalize(line_clipspace);
76
78
  // rotate by 90 degrees
77
79
  dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);
78
- return reverse_offset_normal(vec3(dir_screenspace,1.0)).xy * sign(offset_direction);
80
+ return dir_screenspace.xy * sign(offset_direction);
79
81
  }
80
82
 
81
83
  float torad(float deg) {
@@ -107,8 +109,8 @@ void main() {
107
109
  v_color = a_Color;
108
110
  }
109
111
  v_color.a = v_color.a * opacity;
110
- vec2 source = project_position(vec4(a_Instance.rg, 0, 0)).xy;
111
- vec2 target = project_position(vec4(a_Instance.ba, 0, 0)).xy;
112
+ vec2 source = project_position(vec4(a_Instance.rg, 0, 0), a_Instance64Low.xy).xy;
113
+ vec2 target = project_position(vec4(a_Instance.ba, 0, 0), a_Instance64Low.zw).xy;
112
114
  float segmentIndex = a_Position.x;
113
115
  float segmentRatio = getSegmentRatio(segmentIndex);
114
116
  float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));
@@ -116,14 +118,7 @@ void main() {
116
118
  float d_distance_ratio;
117
119
  if(u_line_type == LineTypeDash) {
118
120
  d_distance_ratio = segmentIndex / segmentNumber;
119
- vec2 s = source;
120
- vec2 t = target;
121
-
122
- if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
123
- s = unProjCustomCoord(source);
124
- t = unProjCustomCoord(target);
125
- }
126
- float total_Distance = pixelDistance(s, t) / 2.0 * PI;
121
+ float total_Distance = pixelDistance(source, target) / 2.0 * PI;
127
122
  v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / (total_Distance / segmentNumber * segmentIndex);
128
123
  }
129
124
  if(u_animate.x == Animate) {
@@ -139,7 +134,7 @@ void main() {
139
134
 
140
135
 
141
136
  v_segmentIndex = a_Position.x;
142
- if(LineTexture == u_line_texture && u_line_type != LineTypeDash) { // 开启贴图模式
137
+ if(LineTexture == u_line_texture && u_line_type != LineTypeDash) { // 开启贴图模式
143
138
 
144
139
  float arcDistrance = length(source - target);
145
140
  float pixelLen = project_pixel_texture(u_icon_step);
@@ -154,7 +149,7 @@ void main() {
154
149
  }
155
150
 
156
151
 
157
- gl_Position = project_common_position_to_clipspace_v2(vec4(curr.xy + project_pixel(offset), curr.z * thetaOffset, 1.0));
152
+ gl_Position = project_common_position_to_clipspace(vec4(curr.xy + project_pixel(offset), curr.z * thetaOffset, 1.0));
158
153
 
159
154
  // 地球模式
160
155
  if(u_globel > 0.0) {
@@ -173,10 +168,10 @@ void main() {
173
168
  float lineHeight = u_global_height * (-4.0*segmentRatio*segmentRatio + 4.0 * segmentRatio) * lnglatLength;
174
169
  // 地球点位
175
170
  vec3 globalPoint = normalize(mix(startLngLat, endLngLat, segmentRatio)) * (globalRadius + lineHeight) + lnglatOffset * a_Size;
176
-
171
+
177
172
  gl_Position = u_ViewProjectionMatrix * vec4(globalPoint, 1.0);
178
173
  }
179
-
174
+
180
175
 
181
176
  setPickingColor(a_PickingColor);
182
177
  }