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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (287) hide show
  1. package/es/citybuliding/models/build.d.ts +16 -0
  2. package/es/citybuliding/models/build.js +18 -20
  3. package/es/citybuliding/shaders/build_frag.glsl +6 -6
  4. package/es/citybuliding/shaders/build_vert.glsl +8 -14
  5. package/es/core/BaseLayer.d.ts +0 -1
  6. package/es/core/BaseLayer.js +9 -19
  7. package/es/core/BaseModel.d.ts +15 -2
  8. package/es/core/BaseModel.js +98 -64
  9. package/es/core/CommonStyleAttribute.d.ts +14 -18
  10. package/es/core/CommonStyleAttribute.js +23 -67
  11. package/es/core/shape/extrude.js +6 -3
  12. package/es/core/triangulation.js +22 -50
  13. package/es/core/utils.d.ts +4 -0
  14. package/es/core/utils.js +33 -0
  15. package/es/earth/models/atmosphere.d.ts +15 -0
  16. package/es/earth/models/atmosphere.js +30 -24
  17. package/es/earth/models/base.d.ts +15 -0
  18. package/es/earth/models/base.js +30 -24
  19. package/es/earth/models/bloomsphere.d.ts +15 -0
  20. package/es/earth/models/bloomsphere.js +30 -24
  21. package/es/earth/shaders/atmosphere/atmosphere_vert.glsl +7 -5
  22. package/es/earth/shaders/base/base_vert.glsl +3 -3
  23. package/es/earth/shaders/bloomshpere/bloomsphere_vert.glsl +5 -4
  24. package/es/geometry/models/billboard.d.ts +15 -0
  25. package/es/geometry/models/billboard.js +14 -8
  26. package/es/geometry/models/plane.d.ts +14 -0
  27. package/es/geometry/models/plane.js +10 -10
  28. package/es/geometry/models/sprite.js +3 -9
  29. package/es/geometry/shaders/billboard_vert.glsl +28 -25
  30. package/es/geometry/shaders/plane_vert.glsl +6 -6
  31. package/es/geometry/shaders/sprite_vert.glsl +7 -9
  32. package/es/heatmap/models/grid.d.ts +14 -0
  33. package/es/heatmap/models/grid.js +10 -3
  34. package/es/heatmap/models/grid3d.d.ts +16 -0
  35. package/es/heatmap/models/grid3d.js +14 -6
  36. package/es/heatmap/models/heatmap.d.ts +20 -1
  37. package/es/heatmap/models/heatmap.js +96 -83
  38. package/es/heatmap/models/hexagon.d.ts +14 -0
  39. package/es/heatmap/models/hexagon.js +9 -3
  40. package/es/heatmap/shaders/grid/grid_vert.glsl +30 -42
  41. package/es/heatmap/shaders/grid3d/grid_3d_vert.glsl +14 -26
  42. package/es/heatmap/shaders/heatmap/heatmap_3d_vert.glsl +19 -16
  43. package/es/heatmap/shaders/heatmap/heatmap_framebuffer_vert.glsl +16 -22
  44. package/es/heatmap/shaders/heatmap/heatmap_vert.glsl +3 -4
  45. package/es/heatmap/shaders/hexagon/hexagon_vert.glsl +13 -23
  46. package/es/image/models/image.d.ts +14 -0
  47. package/es/image/models/image.js +11 -7
  48. package/es/image/shaders/image_vert.glsl +7 -6
  49. package/es/line/models/arc.d.ts +18 -0
  50. package/es/line/models/arc.js +57 -8
  51. package/es/line/models/arc_3d.d.ts +18 -0
  52. package/es/line/models/arc_3d.js +55 -7
  53. package/es/line/models/flow.d.ts +17 -0
  54. package/es/line/models/flow.js +35 -7
  55. package/es/line/models/great_circle.d.ts +17 -0
  56. package/es/line/models/great_circle.js +34 -6
  57. package/es/line/models/line.d.ts +17 -0
  58. package/es/line/models/line.js +17 -8
  59. package/es/line/models/simple_line.d.ts +14 -0
  60. package/es/line/models/simple_line.js +12 -47
  61. package/es/line/models/wall.d.ts +17 -0
  62. package/es/line/models/wall.js +22 -48
  63. package/es/line/shaders/arc/line_arc_vert.glsl +44 -52
  64. package/es/line/shaders/arc3d/line_arc_3d_vert.glsl +15 -20
  65. package/es/line/shaders/flow/flow_line_vert.glsl +30 -48
  66. package/es/line/shaders/greatCircle/line_arc_great_circle_vert.glsl +53 -74
  67. package/es/line/shaders/line/line_vert.glsl +31 -48
  68. package/es/line/shaders/simple/simpleline_vert.glsl +18 -23
  69. package/es/line/shaders/wall/wall_vert.glsl +36 -45
  70. package/es/mask/models/fill.js +2 -1
  71. package/es/mask/shaders/mask_vert.glsl +2 -7
  72. package/es/plugins/DataMappingPlugin.d.ts +0 -1
  73. package/es/plugins/DataMappingPlugin.js +1 -24
  74. package/es/plugins/PixelPickingPlugin.js +2 -2
  75. package/es/plugins/RegisterStyleAttributePlugin.d.ts +0 -1
  76. package/es/plugins/RegisterStyleAttributePlugin.js +3 -25
  77. package/es/plugins/ShaderUniformPlugin.d.ts +0 -5
  78. package/es/plugins/ShaderUniformPlugin.js +4 -35
  79. package/es/point/models/billboard_point.d.ts +14 -0
  80. package/es/point/models/billboard_point.js +11 -3
  81. package/es/point/models/earthExtrude.d.ts +16 -0
  82. package/es/point/models/earthExtrude.js +15 -8
  83. package/es/point/models/earthFill.d.ts +16 -0
  84. package/es/point/models/earthFill.js +13 -5
  85. package/es/point/models/extrude.d.ts +16 -0
  86. package/es/point/models/extrude.js +19 -12
  87. package/es/point/models/fill.d.ts +16 -0
  88. package/es/point/models/fill.js +16 -5
  89. package/es/point/models/fillImage.d.ts +16 -0
  90. package/es/point/models/fillImage.js +16 -16
  91. package/es/point/models/image.d.ts +15 -0
  92. package/es/point/models/image.js +14 -4
  93. package/es/point/models/normal.d.ts +14 -0
  94. package/es/point/models/normal.js +11 -3
  95. package/es/point/models/radar.d.ts +15 -0
  96. package/es/point/models/radar.js +13 -4
  97. package/es/point/models/text.d.ts +16 -0
  98. package/es/point/models/text.js +18 -11
  99. package/es/point/shaders/billboard/billboard_point_vert.glsl +10 -13
  100. package/es/point/shaders/earthExtrude/earthExtrude_vert.glsl +15 -25
  101. package/es/point/shaders/earthFill/earthFill_vert.glsl +6 -6
  102. package/es/point/shaders/extrude/extrude_vert.glsl +35 -39
  103. package/es/point/shaders/fill/fill_vert.glsl +12 -14
  104. package/es/point/shaders/fillImage/fillImage_vert.glsl +16 -28
  105. package/es/point/shaders/image/image_vert.glsl +15 -12
  106. package/es/point/shaders/normal/normal_vert.glsl +7 -10
  107. package/es/point/shaders/radar/radar_vert.glsl +11 -11
  108. package/es/point/shaders/text/text_vert.glsl +10 -9
  109. package/es/polygon/models/extrude.d.ts +16 -0
  110. package/es/polygon/models/extrude.js +26 -26
  111. package/es/polygon/models/extrusion.d.ts +16 -0
  112. package/es/polygon/models/extrusion.js +34 -4
  113. package/es/polygon/models/fill.d.ts +14 -0
  114. package/es/polygon/models/fill.js +12 -4
  115. package/es/polygon/models/ocean.d.ts +14 -0
  116. package/es/polygon/models/ocean.js +11 -6
  117. package/es/polygon/models/water.d.ts +14 -0
  118. package/es/polygon/models/water.js +11 -6
  119. package/es/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +17 -15
  120. package/es/polygon/shaders/extrude/polygon_extrude_vert.glsl +22 -20
  121. package/es/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +17 -17
  122. package/es/polygon/shaders/extrusion/polygon_extrusion_vert.glsl +8 -8
  123. package/es/polygon/shaders/fill/fill_linear_vert.glsl +7 -6
  124. package/es/polygon/shaders/fill/fill_vert.glsl +10 -12
  125. package/es/polygon/shaders/ocean/ocean_vert.glsl +3 -4
  126. package/es/polygon/shaders/water/polygon_water_vert.glsl +5 -5
  127. package/es/raster/index.d.ts +1 -1
  128. package/es/raster/index.js +1 -1
  129. package/es/raster/models/raster.d.ts +14 -0
  130. package/es/raster/models/raster.js +13 -3
  131. package/es/raster/models/rasterRgb.d.ts +14 -0
  132. package/es/raster/models/rasterRgb.js +12 -3
  133. package/es/raster/models/rasterTerrainRgb.d.ts +14 -0
  134. package/es/raster/models/rasterTerrainRgb.js +11 -3
  135. package/es/raster/shaders/raster/raster_2d_vert.glsl +6 -6
  136. package/es/raster/shaders/rgb/raster_rgb_vert.glsl +11 -11
  137. package/es/raster/shaders/terrain/terrain_rgb_vert.glsl +11 -11
  138. package/es/tile/core/BaseLayer.js +0 -16
  139. package/es/utils/extrude_polyline.d.ts +0 -15
  140. package/es/utils/extrude_polyline.js +0 -217
  141. package/es/wind/models/wind.d.ts +14 -0
  142. package/es/wind/models/wind.js +9 -1
  143. package/es/wind/shaders/wind_vert.glsl +6 -5
  144. package/lib/citybuliding/models/build.d.ts +16 -0
  145. package/lib/citybuliding/models/build.js +18 -20
  146. package/lib/citybuliding/shaders/build_frag.glsl +6 -6
  147. package/lib/citybuliding/shaders/build_vert.glsl +8 -14
  148. package/lib/core/BaseLayer.d.ts +0 -1
  149. package/lib/core/BaseLayer.js +9 -19
  150. package/lib/core/BaseModel.d.ts +15 -2
  151. package/lib/core/BaseModel.js +96 -62
  152. package/lib/core/CommonStyleAttribute.d.ts +14 -18
  153. package/lib/core/CommonStyleAttribute.js +23 -68
  154. package/lib/core/shape/extrude.js +6 -3
  155. package/lib/core/triangulation.js +22 -50
  156. package/lib/core/utils.d.ts +4 -0
  157. package/lib/core/utils.js +35 -0
  158. package/lib/earth/models/atmosphere.d.ts +15 -0
  159. package/lib/earth/models/atmosphere.js +30 -24
  160. package/lib/earth/models/base.d.ts +15 -0
  161. package/lib/earth/models/base.js +30 -24
  162. package/lib/earth/models/bloomsphere.d.ts +15 -0
  163. package/lib/earth/models/bloomsphere.js +30 -24
  164. package/lib/earth/shaders/atmosphere/atmosphere_vert.glsl +7 -5
  165. package/lib/earth/shaders/base/base_vert.glsl +3 -3
  166. package/lib/earth/shaders/bloomshpere/bloomsphere_vert.glsl +5 -4
  167. package/lib/geometry/models/billboard.d.ts +15 -0
  168. package/lib/geometry/models/billboard.js +14 -8
  169. package/lib/geometry/models/plane.d.ts +14 -0
  170. package/lib/geometry/models/plane.js +10 -10
  171. package/lib/geometry/models/sprite.js +3 -9
  172. package/lib/geometry/shaders/billboard_vert.glsl +28 -25
  173. package/lib/geometry/shaders/plane_vert.glsl +6 -6
  174. package/lib/geometry/shaders/sprite_vert.glsl +7 -9
  175. package/lib/heatmap/models/grid.d.ts +14 -0
  176. package/lib/heatmap/models/grid.js +10 -3
  177. package/lib/heatmap/models/grid3d.d.ts +16 -0
  178. package/lib/heatmap/models/grid3d.js +14 -6
  179. package/lib/heatmap/models/heatmap.d.ts +20 -1
  180. package/lib/heatmap/models/heatmap.js +95 -82
  181. package/lib/heatmap/models/hexagon.d.ts +14 -0
  182. package/lib/heatmap/models/hexagon.js +9 -3
  183. package/lib/heatmap/shaders/grid/grid_vert.glsl +30 -42
  184. package/lib/heatmap/shaders/grid3d/grid_3d_vert.glsl +14 -26
  185. package/lib/heatmap/shaders/heatmap/heatmap_3d_vert.glsl +19 -16
  186. package/lib/heatmap/shaders/heatmap/heatmap_framebuffer_vert.glsl +16 -22
  187. package/lib/heatmap/shaders/heatmap/heatmap_vert.glsl +3 -4
  188. package/lib/heatmap/shaders/hexagon/hexagon_vert.glsl +13 -23
  189. package/lib/image/models/image.d.ts +14 -0
  190. package/lib/image/models/image.js +11 -7
  191. package/lib/image/shaders/image_vert.glsl +7 -6
  192. package/lib/line/models/arc.d.ts +18 -0
  193. package/lib/line/models/arc.js +56 -7
  194. package/lib/line/models/arc_3d.d.ts +18 -0
  195. package/lib/line/models/arc_3d.js +55 -7
  196. package/lib/line/models/flow.d.ts +17 -0
  197. package/lib/line/models/flow.js +35 -7
  198. package/lib/line/models/great_circle.d.ts +17 -0
  199. package/lib/line/models/great_circle.js +33 -5
  200. package/lib/line/models/line.d.ts +17 -0
  201. package/lib/line/models/line.js +17 -8
  202. package/lib/line/models/simple_line.d.ts +14 -0
  203. package/lib/line/models/simple_line.js +12 -47
  204. package/lib/line/models/wall.d.ts +17 -0
  205. package/lib/line/models/wall.js +22 -48
  206. package/lib/line/shaders/arc/line_arc_vert.glsl +44 -52
  207. package/lib/line/shaders/arc3d/line_arc_3d_vert.glsl +15 -20
  208. package/lib/line/shaders/flow/flow_line_vert.glsl +30 -48
  209. package/lib/line/shaders/greatCircle/line_arc_great_circle_vert.glsl +53 -74
  210. package/lib/line/shaders/line/line_vert.glsl +31 -48
  211. package/lib/line/shaders/simple/simpleline_vert.glsl +18 -23
  212. package/lib/line/shaders/wall/wall_vert.glsl +36 -45
  213. package/lib/mask/models/fill.js +2 -1
  214. package/lib/mask/shaders/mask_vert.glsl +2 -7
  215. package/lib/plugins/DataMappingPlugin.d.ts +0 -1
  216. package/lib/plugins/DataMappingPlugin.js +0 -23
  217. package/lib/plugins/PixelPickingPlugin.js +1 -1
  218. package/lib/plugins/RegisterStyleAttributePlugin.d.ts +0 -1
  219. package/lib/plugins/RegisterStyleAttributePlugin.js +2 -24
  220. package/lib/plugins/ShaderUniformPlugin.d.ts +0 -5
  221. package/lib/plugins/ShaderUniformPlugin.js +4 -35
  222. package/lib/point/models/billboard_point.d.ts +14 -0
  223. package/lib/point/models/billboard_point.js +11 -3
  224. package/lib/point/models/earthExtrude.d.ts +16 -0
  225. package/lib/point/models/earthExtrude.js +14 -7
  226. package/lib/point/models/earthFill.d.ts +16 -0
  227. package/lib/point/models/earthFill.js +13 -5
  228. package/lib/point/models/extrude.d.ts +16 -0
  229. package/lib/point/models/extrude.js +18 -11
  230. package/lib/point/models/fill.d.ts +16 -0
  231. package/lib/point/models/fill.js +16 -5
  232. package/lib/point/models/fillImage.d.ts +16 -0
  233. package/lib/point/models/fillImage.js +16 -16
  234. package/lib/point/models/image.d.ts +15 -0
  235. package/lib/point/models/image.js +14 -4
  236. package/lib/point/models/normal.d.ts +14 -0
  237. package/lib/point/models/normal.js +11 -3
  238. package/lib/point/models/radar.d.ts +15 -0
  239. package/lib/point/models/radar.js +13 -4
  240. package/lib/point/models/text.d.ts +16 -0
  241. package/lib/point/models/text.js +18 -11
  242. package/lib/point/shaders/billboard/billboard_point_vert.glsl +10 -13
  243. package/lib/point/shaders/earthExtrude/earthExtrude_vert.glsl +15 -25
  244. package/lib/point/shaders/earthFill/earthFill_vert.glsl +6 -6
  245. package/lib/point/shaders/extrude/extrude_vert.glsl +35 -39
  246. package/lib/point/shaders/fill/fill_vert.glsl +12 -14
  247. package/lib/point/shaders/fillImage/fillImage_vert.glsl +16 -28
  248. package/lib/point/shaders/image/image_vert.glsl +15 -12
  249. package/lib/point/shaders/normal/normal_vert.glsl +7 -10
  250. package/lib/point/shaders/radar/radar_vert.glsl +11 -11
  251. package/lib/point/shaders/text/text_vert.glsl +10 -9
  252. package/lib/polygon/models/extrude.d.ts +16 -0
  253. package/lib/polygon/models/extrude.js +25 -25
  254. package/lib/polygon/models/extrusion.d.ts +16 -0
  255. package/lib/polygon/models/extrusion.js +34 -4
  256. package/lib/polygon/models/fill.d.ts +14 -0
  257. package/lib/polygon/models/fill.js +12 -4
  258. package/lib/polygon/models/ocean.d.ts +14 -0
  259. package/lib/polygon/models/ocean.js +11 -6
  260. package/lib/polygon/models/water.d.ts +14 -0
  261. package/lib/polygon/models/water.js +11 -6
  262. package/lib/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +17 -15
  263. package/lib/polygon/shaders/extrude/polygon_extrude_vert.glsl +22 -20
  264. package/lib/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +17 -17
  265. package/lib/polygon/shaders/extrusion/polygon_extrusion_vert.glsl +8 -8
  266. package/lib/polygon/shaders/fill/fill_linear_vert.glsl +7 -6
  267. package/lib/polygon/shaders/fill/fill_vert.glsl +10 -12
  268. package/lib/polygon/shaders/ocean/ocean_vert.glsl +3 -4
  269. package/lib/polygon/shaders/water/polygon_water_vert.glsl +5 -5
  270. package/lib/raster/index.d.ts +1 -1
  271. package/lib/raster/index.js +2 -2
  272. package/lib/raster/models/raster.d.ts +14 -0
  273. package/lib/raster/models/raster.js +13 -3
  274. package/lib/raster/models/rasterRgb.d.ts +14 -0
  275. package/lib/raster/models/rasterRgb.js +12 -3
  276. package/lib/raster/models/rasterTerrainRgb.d.ts +14 -0
  277. package/lib/raster/models/rasterTerrainRgb.js +11 -3
  278. package/lib/raster/shaders/raster/raster_2d_vert.glsl +6 -6
  279. package/lib/raster/shaders/rgb/raster_rgb_vert.glsl +11 -11
  280. package/lib/raster/shaders/terrain/terrain_rgb_vert.glsl +11 -11
  281. package/lib/tile/core/BaseLayer.js +0 -16
  282. package/lib/utils/extrude_polyline.d.ts +0 -15
  283. package/lib/utils/extrude_polyline.js +0 -217
  284. package/lib/wind/models/wind.d.ts +14 -0
  285. package/lib/wind/models/wind.js +9 -1
  286. package/lib/wind/shaders/wind_vert.glsl +6 -5
  287. package/package.json +6 -6
@@ -3,12 +3,11 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
3
3
  import { AttributeType, gl } from '@antv/l7-core';
4
4
  import { rgb2arr } from '@antv/l7-utils';
5
5
  import BaseModel from "../../core/BaseModel";
6
- import { ShaderLocation } from "../../core/CommonStyleAttribute";
7
6
  import { LineTriangulation } from "../../core/triangulation";
8
7
  /* babel-plugin-inline-import '../shaders/wall/wall_frag.glsl' */
9
8
  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";
10
9
  /* babel-plugin-inline-import '../shaders/wall/wall_vert.glsl' */
11
- 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";
10
+ 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";
12
11
  export default class LineWallModel extends BaseModel {
13
12
  constructor(...args) {
14
13
  super(...args);
@@ -35,6 +34,15 @@ export default class LineWallModel extends BaseModel {
35
34
  this.textures = [this.texture];
36
35
  });
37
36
  }
37
+ get attributeLocation() {
38
+ return Object.assign(super.attributeLocation, {
39
+ MAX: super.attributeLocation.MAX,
40
+ SIZE: 9,
41
+ NORMAL: 12,
42
+ UV: 13,
43
+ DISTANCE_MITER_TOTAL: 15
44
+ });
45
+ }
38
46
  getCommonUniformsInfo() {
39
47
  const {
40
48
  sourceColor,
@@ -110,6 +118,7 @@ export default class LineWallModel extends BaseModel {
110
118
  vertexShader: line_vert,
111
119
  fragmentShader: line_frag,
112
120
  triangulation: LineTriangulation,
121
+ defines: _this2.getDefines(),
113
122
  inject: _this2.getInject(),
114
123
  depth: {
115
124
  enable: false
@@ -120,48 +129,14 @@ export default class LineWallModel extends BaseModel {
120
129
  })();
121
130
  }
122
131
  registerBuiltinAttributes() {
123
- this.styleAttributeService.registerStyleAttribute({
124
- name: 'distance',
125
- type: AttributeType.Attribute,
126
- descriptor: {
127
- name: 'a_Distance',
128
- shaderLocation: 15,
129
- buffer: {
130
- // give the WebGL driver a hint that this buffer may change
131
- usage: gl.STATIC_DRAW,
132
- data: [],
133
- type: gl.FLOAT
134
- },
135
- size: 1,
136
- update: (feature, featureIdx, vertex) => {
137
- return [vertex[3]];
138
- }
139
- }
140
- });
141
- this.styleAttributeService.registerStyleAttribute({
142
- name: 'total_distance',
143
- type: AttributeType.Attribute,
144
- descriptor: {
145
- name: 'a_Total_Distance',
146
- shaderLocation: 11,
147
- buffer: {
148
- // give the WebGL driver a hint that this buffer may change
149
- usage: gl.STATIC_DRAW,
150
- data: [],
151
- type: gl.FLOAT
152
- },
153
- size: 1,
154
- update: (feature, featureIdx, vertex) => {
155
- return [vertex[5]];
156
- }
157
- }
158
- });
132
+ // 注册 Position 属性 64 位地位部分,经纬度数据开启双精度,避免大于 20层级以上出现数据偏移
133
+ this.registerPosition64LowAttribute();
159
134
  this.styleAttributeService.registerStyleAttribute({
160
135
  name: 'size',
161
136
  type: AttributeType.Attribute,
162
137
  descriptor: {
163
138
  name: 'a_Size',
164
- shaderLocation: ShaderLocation.SIZE,
139
+ shaderLocation: this.attributeLocation.SIZE,
165
140
  buffer: {
166
141
  // give the WebGL driver a hint that this buffer may change
167
142
  usage: gl.DYNAMIC_DRAW,
@@ -177,14 +152,12 @@ export default class LineWallModel extends BaseModel {
177
152
  }
178
153
  }
179
154
  });
180
-
181
- // point layer size;
182
155
  this.styleAttributeService.registerStyleAttribute({
183
156
  name: 'normal',
184
157
  type: AttributeType.Attribute,
185
158
  descriptor: {
186
159
  name: 'a_Normal',
187
- shaderLocation: ShaderLocation.NORMAL,
160
+ shaderLocation: this.attributeLocation.NORMAL,
188
161
  buffer: {
189
162
  // give the WebGL driver a hint that this buffer may change
190
163
  usage: gl.STATIC_DRAW,
@@ -199,20 +172,21 @@ export default class LineWallModel extends BaseModel {
199
172
  }
200
173
  });
201
174
  this.styleAttributeService.registerStyleAttribute({
202
- name: 'miter',
175
+ name: 'distanceAndTotalAndMiter',
203
176
  type: AttributeType.Attribute,
204
177
  descriptor: {
205
- name: 'a_Miter',
206
- shaderLocation: 10,
178
+ name: 'a_Distance_Total_Miter',
179
+ shaderLocation: this.attributeLocation.DISTANCE_MITER_TOTAL,
207
180
  buffer: {
208
181
  // give the WebGL driver a hint that this buffer may change
209
182
  usage: gl.STATIC_DRAW,
210
183
  data: [],
211
184
  type: gl.FLOAT
212
185
  },
213
- size: 1,
186
+ size: 3,
214
187
  update: (feature, featureIdx, vertex) => {
215
- return [vertex[4]];
188
+ // [distance, miter, total_distance]
189
+ return [vertex[3], vertex[4], vertex[5]];
216
190
  }
217
191
  }
218
192
  });
@@ -221,7 +195,7 @@ export default class LineWallModel extends BaseModel {
221
195
  type: AttributeType.Attribute,
222
196
  descriptor: {
223
197
  name: 'a_iconMapUV',
224
- shaderLocation: 14,
198
+ shaderLocation: this.attributeLocation.UV,
225
199
  buffer: {
226
200
  // give the WebGL driver a hint that this buffer may change
227
201
  usage: 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
  }
@@ -1,8 +1,9 @@
1
- layout(location = 0) in vec3 a_Position;
2
- layout(location = 1) in vec4 a_Color;
3
- layout(location = 9) in vec2 a_Size;
4
- layout(location = 12) in vec4 a_Instance;
5
- layout(location = 13) in vec3 a_Normal;
1
+ layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;
2
+ layout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;
3
+ layout(location = ATTRIBUTE_LOCATION_SIZE) in vec2 a_Size;
4
+ layout(location = ATTRIBUTE_LOCATION_INSTANCE) in vec4 a_Instance;
5
+ layout(location = ATTRIBUTE_LOCATION_INSTANCE_64LOW) in vec4 a_Instance64Low;
6
+ layout(location = ATTRIBUTE_LOCATION_NORMAL) in vec3 a_Normal;
6
7
 
7
8
  layout(std140) uniform commonUniorm {
8
9
  float u_gap_width: 1.0;
@@ -17,78 +18,59 @@ layout(std140) uniform commonUniorm {
17
18
  out vec4 v_color;
18
19
 
19
20
  vec2 project_pixel_offset(vec2 offsets) {
21
+ vec2 data = project_pixel(offsets);
20
22
 
21
- vec2 data = project_pixel(offsets);
22
- if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {
23
- // P20_2 坐标系下,为了和 Web 墨卡托坐标系统一,zoom 默认减3
24
- return data;
25
- }
26
-
27
- return vec2(data.x, -data.y);;
23
+ return vec2(data.x, -data.y);
28
24
  }
29
25
 
30
26
  vec2 line_dir(vec2 target, vec2 source) {
31
-
32
- if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {
33
- // P20_2 坐标系下,为了和 Web 墨卡托坐标系统一,zoom 默认减3
34
- return normalize(target - source);
35
- }
36
27
  return normalize(ProjectFlat(target) - ProjectFlat(source));
37
28
  }
38
29
 
39
- float flag_gap() {
40
- if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {
41
- // P20_2 坐标系下,为了和 Web 墨卡托坐标系统一,zoom 默认减3
42
- return 1.;
43
- }
44
- return -1.;
45
-
46
- }
47
-
48
30
 
49
31
  void main() {
32
+ // 透明度计算
33
+ vec2 source_world = a_Instance.rg; // 起点
34
+ vec2 target_world = a_Instance.ba; // 终点
35
+ vec2 flowlineDir = line_dir(target_world, source_world);
36
+ vec2 perpendicularDir = vec2(-flowlineDir.y, flowlineDir.x);
50
37
 
51
- // 透明度计算
52
- vec2 source = a_Instance.rg; // 起始点
53
- vec2 target = a_Instance.ba; // 终点
54
- vec2 flowlineDir = line_dir(target,source);
55
- vec2 perpendicularDir = vec2(-flowlineDir.y, flowlineDir.x); // mapbox || 高德
56
-
57
- vec2 position = mix(source, target, a_Position.x);
58
-
59
- float lengthCommon = length(project_position(vec4(target,0,1)) - project_position(vec4(source,0,1))); //
38
+ vec2 position = mix(source_world, target_world, a_Position.x);
39
+ vec2 position64Low = mix(a_Instance64Low.rg, a_Instance64Low.ba, a_Position.x);
40
+
41
+ float lengthCommon = length(
42
+ project_position(vec4(target_world, 0, 1)) - project_position(vec4(source_world, 0, 1))
43
+ );
60
44
  vec2 offsetDistances = a_Size.x * project_pixel_offset(vec2(a_Position.y, a_Position.z)); // Mapbox || 高德
61
- vec2 limitedOffsetDistances = clamp(
62
- offsetDistances,
63
- project_pixel(-lengthCommon*.2), project_pixel(lengthCommon*.2)
45
+ vec2 limitedOffsetDistances = clamp(
46
+ offsetDistances,
47
+ project_pixel(-lengthCommon * 0.2),
48
+ project_pixel(lengthCommon * 0.2)
64
49
  );
65
50
 
66
-
67
51
  float startOffsetCommon = project_pixel(offsets[0]);
68
52
  float endOffsetCommon = project_pixel(offsets[1]);
69
53
  float endpointOffset = mix(
70
- clamp(startOffsetCommon, 0.0, lengthCommon*.2),
71
- -clamp(endOffsetCommon, 0.0, lengthCommon*.2),
54
+ clamp(startOffsetCommon, 0.0, lengthCommon * 0.2),
55
+ -clamp(endOffsetCommon, 0.0, lengthCommon * 0.2),
72
56
  a_Position.x
73
57
  );
74
58
 
75
- vec2 normalsCommon = u_stroke_width * project_pixel_offset(vec2(a_Normal.x, a_Normal.y)); // mapbox || 高德
59
+ vec2 normalsCommon = u_stroke_width * project_pixel_offset(vec2(a_Normal.x, a_Normal.y));
76
60
 
77
- float gapCommon = flag_gap() * project_pixel(u_gap_width);
61
+ float gapCommon = -1. * project_pixel(u_gap_width);
78
62
  vec3 offsetCommon = vec3(
79
63
  flowlineDir * (limitedOffsetDistances[1] + normalsCommon.y + endpointOffset * 1.05) -
80
- perpendicularDir * (limitedOffsetDistances[0] + gapCommon + normalsCommon.x),
64
+ perpendicularDir * (limitedOffsetDistances[0] + gapCommon + normalsCommon.x),
81
65
  0.0
82
66
  );
83
67
 
84
- vec4 project_pos = project_position(vec4(position.xy, 0, 1.0));
68
+ vec4 project_pos = project_position(vec4(position.xy, 0, 1.0), position64Low);
85
69
 
86
70
  vec4 fillColor = vec4(a_Color.rgb, a_Color.a * opacity);
87
71
  v_color = mix(fillColor, vec4(u_stroke.xyz, u_stroke.w * fillColor.w * u_stroke_opacity), a_Normal.z);
88
72
 
89
- gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xy + offsetCommon.xy, 0., 1.0));
90
-
91
-
73
+ gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offsetCommon.xy, 0., 1.0));
92
74
 
93
75
  setPickingColor(a_PickingColor);
94
76
  }