@antv/l7-layers 2.20.5 → 2.20.6

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 (447) hide show
  1. package/es/canvas/index.d.ts +3 -3
  2. package/es/citybuliding/models/build.d.ts +7 -12
  3. package/es/citybuliding/models/build.js +22 -11
  4. package/es/citybuliding/shaders/build_frag.glsl +26 -23
  5. package/es/citybuliding/shaders/build_vert.glsl +24 -16
  6. package/es/core/BaseLayer.d.ts +14 -2
  7. package/es/core/BaseLayer.js +53 -9
  8. package/es/core/BaseModel.d.ts +1 -1
  9. package/es/core/BaseModel.js +41 -15
  10. package/es/core/CommonStyleAttribute.d.ts +4 -2
  11. package/es/core/CommonStyleAttribute.js +3 -0
  12. package/es/core/LayerPickService.d.ts +1 -1
  13. package/es/core/TextureService.d.ts +2 -2
  14. package/es/core/interface.d.ts +7 -3
  15. package/es/core/interface.js +0 -1
  16. package/es/core/line_trangluation.d.ts +1 -1
  17. package/es/core/shape/arrow.d.ts +1 -1
  18. package/es/core/shape/extrude.d.ts +1 -1
  19. package/es/core/triangulation.d.ts +1 -1
  20. package/es/core/triangulation.js +13 -7
  21. package/es/core/utils.js +1 -1
  22. package/es/earth/index.d.ts +1 -1
  23. package/es/earth/models/atmosphere.d.ts +8 -2
  24. package/es/earth/models/atmosphere.js +15 -8
  25. package/es/earth/models/base.d.ts +8 -2
  26. package/es/earth/models/base.js +21 -12
  27. package/es/earth/models/bloomsphere.d.ts +8 -2
  28. package/es/earth/models/bloomsphere.js +15 -8
  29. package/es/earth/shaders/{atmosphere_frag.glsl → atmosphere/atmosphere_frag.glsl} +9 -6
  30. package/es/earth/shaders/atmosphere/atmosphere_vert.glsl +22 -0
  31. package/es/earth/shaders/base/base_frag.glsl +11 -0
  32. package/es/earth/shaders/base/base_vert.glsl +52 -0
  33. package/es/earth/shaders/bloomshpere/bloomsphere_frag.glsl +16 -0
  34. package/es/earth/shaders/bloomshpere/bloomsphere_vert.glsl +19 -0
  35. package/es/geometry/index.d.ts +2 -2
  36. package/es/geometry/models/billboard.d.ts +8 -1
  37. package/es/geometry/models/billboard.js +26 -11
  38. package/es/geometry/models/plane.d.ts +8 -1
  39. package/es/geometry/models/plane.js +23 -6
  40. package/es/geometry/models/sprite.d.ts +12 -2
  41. package/es/geometry/models/sprite.js +44 -18
  42. package/es/geometry/shaders/billboard_frag.glsl +11 -6
  43. package/es/geometry/shaders/billboard_vert.glsl +12 -15
  44. package/es/geometry/shaders/plane_frag.glsl +14 -10
  45. package/es/geometry/shaders/plane_vert.glsl +11 -10
  46. package/es/geometry/shaders/sprite_frag.glsl +11 -7
  47. package/es/geometry/shaders/sprite_vert.glsl +10 -9
  48. package/es/heatmap/index.d.ts +3 -3
  49. package/es/heatmap/models/grid.d.ts +8 -1
  50. package/es/heatmap/models/grid.js +25 -12
  51. package/es/heatmap/models/grid3d.d.ts +8 -1
  52. package/es/heatmap/models/grid3d.js +29 -13
  53. package/es/heatmap/models/heatmap.d.ts +6 -4
  54. package/es/heatmap/models/heatmap.js +123 -75
  55. package/es/heatmap/models/hexagon.d.ts +8 -1
  56. package/es/heatmap/models/hexagon.js +25 -12
  57. package/es/heatmap/shaders/grid/grid_frag.glsl +8 -0
  58. package/es/heatmap/shaders/{grid_vert.glsl → grid/grid_vert.glsl} +15 -15
  59. package/es/heatmap/shaders/grid3d/grid_3d_frag.glsl +8 -0
  60. package/{lib/heatmap/shaders/hexagon_3d_vert.glsl → es/heatmap/shaders/grid3d/grid_3d_vert.glsl} +13 -16
  61. package/es/heatmap/shaders/heatmap/heatmap_3d_frag.glsl +24 -0
  62. package/es/heatmap/shaders/{heatmap_3d_vert.glsl → heatmap/heatmap_3d_vert.glsl} +19 -9
  63. package/es/heatmap/shaders/heatmap/heatmap_frag.glsl +52 -0
  64. package/es/heatmap/shaders/heatmap/heatmap_framebuffer_frag.glsl +16 -0
  65. package/{lib/heatmap/shaders → es/heatmap/shaders/heatmap}/heatmap_framebuffer_vert.glsl +14 -9
  66. package/es/heatmap/shaders/heatmap/heatmap_vert.glsl +19 -0
  67. package/es/heatmap/shaders/hexagon/hexagon_frag.glsl +8 -0
  68. package/es/heatmap/shaders/{hexagon_vert.glsl → hexagon/hexagon_vert.glsl} +12 -13
  69. package/es/image/index.d.ts +2 -2
  70. package/es/image/models/image.d.ts +9 -2
  71. package/es/image/models/image.js +83 -44
  72. package/es/image/shaders/image_frag.glsl +34 -7
  73. package/es/image/shaders/image_vert.glsl +11 -5
  74. package/es/line/index.d.ts +4 -4
  75. package/es/line/index.js +2 -1
  76. package/es/line/models/arc.d.ts +8 -3
  77. package/es/line/models/arc.js +57 -76
  78. package/es/line/models/arc_3d.d.ts +8 -3
  79. package/es/line/models/arc_3d.js +46 -57
  80. package/es/line/models/flow.d.ts +8 -2
  81. package/es/line/models/flow.js +14 -12
  82. package/es/line/models/great_circle.d.ts +8 -3
  83. package/es/line/models/great_circle.js +40 -29
  84. package/es/line/models/index.d.ts +1 -1
  85. package/es/line/models/index.js +3 -6
  86. package/es/line/models/line.d.ts +8 -3
  87. package/es/line/models/line.js +67 -140
  88. package/es/line/models/{simpleLine.d.ts → simple_line.d.ts} +8 -2
  89. package/es/line/models/simple_line.js +204 -0
  90. package/es/line/models/wall.d.ts +8 -3
  91. package/es/line/models/wall.js +35 -27
  92. package/es/line/shaders/{line_arc_frag.glsl → arc/line_arc_frag.glsl} +36 -26
  93. package/es/line/shaders/{line_arc_vert.glsl → arc/line_arc_vert.glsl} +52 -22
  94. package/es/line/shaders/{line_arc_3d_frag.glsl → arc3d/line_arc_3d_frag.glsl} +32 -24
  95. package/{lib/line/shaders → es/line/shaders/arc3d}/line_arc_3d_vert.glsl +37 -27
  96. package/es/line/shaders/flow/flow_line_frag.glsl +5 -4
  97. package/es/line/shaders/flow/flow_line_vert.glsl +17 -18
  98. package/es/line/shaders/{line_arc_great_circle_frag.glsl → greatCircle/line_arc_great_circle_frag.glsl} +30 -30
  99. package/{lib/line/shaders → es/line/shaders/greatCircle}/line_arc_great_circle_vert.glsl +43 -40
  100. package/es/line/shaders/{line_frag.glsl → line/line_frag.glsl} +55 -28
  101. package/es/line/shaders/line/line_vert.glsl +114 -0
  102. package/es/line/shaders/simple/simpleline_frag.glsl +27 -3
  103. package/es/line/shaders/simple/simpleline_vert.glsl +20 -20
  104. package/es/line/shaders/wall/wall_frag.glsl +31 -26
  105. package/es/line/shaders/wall/wall_vert.glsl +29 -22
  106. package/es/mask/index.d.ts +2 -2
  107. package/es/mask/models/fill.d.ts +1 -1
  108. package/es/plugins/DataMappingPlugin.d.ts +1 -1
  109. package/es/plugins/DataMappingPlugin.js +1 -3
  110. package/es/plugins/DataSourcePlugin.d.ts +1 -1
  111. package/es/plugins/FeatureScalePlugin.d.ts +1 -1
  112. package/es/plugins/FeatureScalePlugin.js +14 -3
  113. package/es/plugins/LayerAnimateStylePlugin.d.ts +1 -1
  114. package/es/plugins/LayerMaskPlugin.d.ts +1 -1
  115. package/es/plugins/LayerModelPlugin.d.ts +1 -1
  116. package/es/plugins/LayerStylePlugin.d.ts +1 -1
  117. package/es/plugins/LightingPlugin.d.ts +1 -1
  118. package/es/plugins/MultiPassRendererPlugin.d.ts +1 -1
  119. package/es/plugins/PixelPickingPlugin.d.ts +6 -2
  120. package/es/plugins/PixelPickingPlugin.js +36 -49
  121. package/es/plugins/RegisterStyleAttributePlugin.d.ts +1 -1
  122. package/es/plugins/ShaderUniformPlugin.d.ts +1 -1
  123. package/es/plugins/ShaderUniformPlugin.js +11 -6
  124. package/es/plugins/UpdateModelPlugin.d.ts +1 -1
  125. package/es/plugins/UpdateStyleAttributePlugin.d.ts +1 -1
  126. package/es/point/index.d.ts +2 -2
  127. package/es/point/index.js +1 -0
  128. package/es/point/models/billboard_point.d.ts +9 -3
  129. package/es/point/models/billboard_point.js +18 -18
  130. package/es/point/models/earthExtrude.d.ts +7 -12
  131. package/es/point/models/earthExtrude.js +21 -13
  132. package/es/point/models/earthFill.d.ts +8 -3
  133. package/es/point/models/earthFill.js +18 -30
  134. package/es/point/models/extrude.d.ts +1 -4
  135. package/es/point/models/extrude.js +2 -11
  136. package/es/point/models/fill.d.ts +8 -2
  137. package/es/point/models/fill.js +33 -84
  138. package/es/point/models/{fillmage.d.ts → fillImage.d.ts} +8 -2
  139. package/es/point/models/{fillmage.js → fillImage.js} +23 -15
  140. package/es/point/models/image.d.ts +8 -1
  141. package/es/point/models/image.js +31 -17
  142. package/es/point/models/index.js +1 -1
  143. package/es/point/models/normal.d.ts +9 -3
  144. package/es/point/models/normal.js +13 -30
  145. package/es/point/models/radar.d.ts +8 -2
  146. package/es/point/models/radar.js +23 -45
  147. package/es/point/models/text.d.ts +9 -2
  148. package/es/point/models/text.js +31 -32
  149. package/{lib/point/shaders → es/point/shaders/billboard}/billboard_point_frag.glsl +17 -13
  150. package/{lib/point/shaders → es/point/shaders/billboard}/billboard_point_vert.glsl +13 -14
  151. package/es/point/shaders/earthExtrude/earthExtrude_frag.glsl +36 -0
  152. package/{lib/point/shaders/earth/extrude_vert.glsl → es/point/shaders/earthExtrude/earthExtrude_vert.glsl} +25 -22
  153. package/{lib/point/shaders/earth/fill_frag.glsl → es/point/shaders/earthFill/earthFill_frag.glsl} +20 -18
  154. package/{lib/point/shaders/earth/fill_vert.glsl → es/point/shaders/earthFill/earthFill_vert.glsl} +17 -22
  155. package/es/point/shaders/extrude/extrude_vert.glsl +0 -3
  156. package/{lib/point/shaders → es/point/shaders/fill}/fill_frag.glsl +18 -1
  157. package/es/point/shaders/{fill_vert.glsl → fill/fill_vert.glsl} +5 -4
  158. package/es/point/shaders/fillImage/fillImage_frag.glsl +24 -0
  159. package/{lib/point/shaders/image → es/point/shaders/fillImage}/fillImage_vert.glsl +15 -17
  160. package/es/point/shaders/image/image_frag.glsl +42 -0
  161. package/{lib/point/shaders → es/point/shaders/image}/image_vert.glsl +14 -13
  162. package/es/point/shaders/radar/radar_frag.glsl +19 -14
  163. package/es/point/shaders/radar/radar_vert.glsl +21 -24
  164. package/es/point/shaders/text/text_frag.glsl +44 -0
  165. package/es/point/shaders/{text_vert.glsl → text/text_vert.glsl} +19 -17
  166. package/es/point/shape/extrude.d.ts +1 -1
  167. package/es/polygon/index.d.ts +2 -2
  168. package/es/polygon/models/extrude.d.ts +9 -9
  169. package/es/polygon/models/extrude.js +38 -15
  170. package/es/polygon/models/extrusion.d.ts +8 -1
  171. package/es/polygon/models/extrusion.js +24 -7
  172. package/es/polygon/models/fill.d.ts +9 -4
  173. package/es/polygon/models/fill.js +26 -13
  174. package/es/polygon/models/ocean.d.ts +9 -7
  175. package/es/polygon/models/ocean.js +30 -14
  176. package/es/polygon/models/water.d.ts +9 -4
  177. package/es/polygon/models/water.js +26 -10
  178. package/es/polygon/shaders/extrude/polygon_extrude_frag.glsl +14 -14
  179. package/es/polygon/shaders/extrude/polygon_extrude_picklight_frag.glsl +17 -15
  180. package/es/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +18 -18
  181. package/es/polygon/shaders/extrude/polygon_extrude_vert.glsl +18 -24
  182. package/es/polygon/shaders/extrude/polygon_extrudetex_frag.glsl +19 -15
  183. package/es/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +20 -24
  184. package/es/polygon/shaders/extrusion/polygon_extrusion_frag.glsl +4 -8
  185. package/es/polygon/shaders/extrusion/polygon_extrusion_vert.glsl +7 -16
  186. package/es/polygon/shaders/fill/fill_frag.glsl +7 -0
  187. package/es/polygon/shaders/fill/fill_linear_frag.glsl +20 -0
  188. package/{lib/polygon/shaders/polygon_linear_vert.glsl → es/polygon/shaders/fill/fill_linear_vert.glsl} +12 -11
  189. package/es/polygon/shaders/{polygon_vert.glsl → fill/fill_vert.glsl} +6 -6
  190. package/es/polygon/shaders/{water/polygon_ocean_frag.glsl → ocean/ocean_frag.glsl} +13 -13
  191. package/es/polygon/shaders/ocean/ocean_vert.glsl +22 -0
  192. package/es/polygon/shaders/water/polygon_water_frag.glsl +14 -12
  193. package/es/polygon/shaders/water/polygon_water_vert.glsl +10 -10
  194. package/es/raster/buffers/triangulation.d.ts +1 -1
  195. package/es/raster/index.d.ts +2 -2
  196. package/es/raster/models/raster.d.ts +9 -8
  197. package/es/raster/models/raster.js +54 -38
  198. package/es/raster/models/rasterRgb.d.ts +9 -7
  199. package/es/raster/models/rasterRgb.js +36 -19
  200. package/es/raster/models/rasterTerrainRgb.d.ts +1 -1
  201. package/es/raster/models/rasterTerrainRgb.js +2 -2
  202. package/es/raster/shaders/raster/raster_2d_frag.glsl +34 -0
  203. package/es/raster/shaders/raster/raster_2d_vert.glsl +21 -0
  204. package/es/raster/shaders/rgb/raster_rgb_frag.glsl +26 -0
  205. package/es/raster/shaders/rgb/raster_rgb_vert.glsl +21 -0
  206. package/es/tile/core/BaseLayer.d.ts +2 -2
  207. package/es/tile/core/TileDebugLayer.d.ts +1 -1
  208. package/es/tile/interaction/getRasterData.d.ts +2 -2
  209. package/es/tile/interaction/utils.d.ts +1 -1
  210. package/es/tile/interface.d.ts +2 -2
  211. package/es/tile/service/TileLayerService.d.ts +2 -2
  212. package/es/tile/service/TilePickService.d.ts +2 -2
  213. package/es/tile/service/TileSourceService.d.ts +1 -1
  214. package/es/tile/tile/Tile.d.ts +2 -3
  215. package/es/tile/tile/VectorTile.d.ts +1 -1
  216. package/es/tile/tile/index.d.ts +1 -1
  217. package/es/tile/utils/constants.js +1 -1
  218. package/es/tile/utils/utils.d.ts +1 -1
  219. package/es/utils/blend.d.ts +1 -1
  220. package/es/utils/multiPassRender.d.ts +1 -1
  221. package/es/utils/stencil.d.ts +1 -1
  222. package/es/wind/index.d.ts +3 -3
  223. package/es/wind/models/wind.d.ts +1 -1
  224. package/lib/citybuliding/models/build.js +22 -11
  225. package/lib/citybuliding/shaders/build_frag.glsl +26 -23
  226. package/lib/citybuliding/shaders/build_vert.glsl +24 -16
  227. package/lib/core/BaseLayer.js +53 -9
  228. package/lib/core/BaseModel.js +41 -15
  229. package/lib/core/CommonStyleAttribute.js +3 -0
  230. package/lib/core/triangulation.js +12 -6
  231. package/lib/core/utils.js +1 -1
  232. package/lib/earth/models/atmosphere.js +15 -8
  233. package/lib/earth/models/base.js +21 -12
  234. package/lib/earth/models/bloomsphere.js +15 -8
  235. package/lib/earth/shaders/{atmosphere_frag.glsl → atmosphere/atmosphere_frag.glsl} +9 -6
  236. package/lib/earth/shaders/atmosphere/atmosphere_vert.glsl +22 -0
  237. package/lib/earth/shaders/base/base_frag.glsl +11 -0
  238. package/lib/earth/shaders/base/base_vert.glsl +52 -0
  239. package/lib/earth/shaders/bloomshpere/bloomsphere_frag.glsl +16 -0
  240. package/lib/earth/shaders/bloomshpere/bloomsphere_vert.glsl +19 -0
  241. package/lib/geometry/models/billboard.js +26 -11
  242. package/lib/geometry/models/plane.js +23 -6
  243. package/lib/geometry/models/sprite.js +44 -18
  244. package/lib/geometry/shaders/billboard_frag.glsl +11 -6
  245. package/lib/geometry/shaders/billboard_vert.glsl +12 -15
  246. package/lib/geometry/shaders/plane_frag.glsl +14 -10
  247. package/lib/geometry/shaders/plane_vert.glsl +11 -10
  248. package/lib/geometry/shaders/sprite_frag.glsl +11 -7
  249. package/lib/geometry/shaders/sprite_vert.glsl +10 -9
  250. package/lib/heatmap/models/grid.js +25 -12
  251. package/lib/heatmap/models/grid3d.js +29 -13
  252. package/lib/heatmap/models/heatmap.js +122 -74
  253. package/lib/heatmap/models/hexagon.js +25 -12
  254. package/lib/heatmap/shaders/grid/grid_frag.glsl +8 -0
  255. package/lib/heatmap/shaders/{grid_vert.glsl → grid/grid_vert.glsl} +15 -15
  256. package/lib/heatmap/shaders/grid3d/grid_3d_frag.glsl +8 -0
  257. package/{es/heatmap/shaders/hexagon_3d_vert.glsl → lib/heatmap/shaders/grid3d/grid_3d_vert.glsl} +13 -16
  258. package/lib/heatmap/shaders/heatmap/heatmap_3d_frag.glsl +24 -0
  259. package/lib/heatmap/shaders/{heatmap_3d_vert.glsl → heatmap/heatmap_3d_vert.glsl} +19 -9
  260. package/lib/heatmap/shaders/heatmap/heatmap_frag.glsl +52 -0
  261. package/lib/heatmap/shaders/heatmap/heatmap_framebuffer_frag.glsl +16 -0
  262. package/{es/heatmap/shaders → lib/heatmap/shaders/heatmap}/heatmap_framebuffer_vert.glsl +14 -9
  263. package/lib/heatmap/shaders/heatmap/heatmap_vert.glsl +19 -0
  264. package/lib/heatmap/shaders/hexagon/hexagon_frag.glsl +8 -0
  265. package/lib/heatmap/shaders/{hexagon_vert.glsl → hexagon/hexagon_vert.glsl} +12 -13
  266. package/lib/image/models/image.js +83 -44
  267. package/lib/image/shaders/image_frag.glsl +34 -7
  268. package/lib/image/shaders/image_vert.glsl +11 -5
  269. package/lib/line/index.js +2 -1
  270. package/lib/line/models/arc.js +57 -76
  271. package/lib/line/models/arc_3d.js +47 -59
  272. package/lib/line/models/flow.js +14 -12
  273. package/lib/line/models/great_circle.js +40 -29
  274. package/lib/line/models/index.js +4 -7
  275. package/lib/line/models/line.js +67 -142
  276. package/lib/line/models/{simpleLine.js → simple_line.js} +84 -74
  277. package/lib/line/models/wall.js +35 -27
  278. package/lib/line/shaders/{line_arc_frag.glsl → arc/line_arc_frag.glsl} +36 -26
  279. package/lib/line/shaders/{line_arc_vert.glsl → arc/line_arc_vert.glsl} +52 -22
  280. package/lib/line/shaders/{line_arc_3d_frag.glsl → arc3d/line_arc_3d_frag.glsl} +32 -24
  281. package/{es/line/shaders → lib/line/shaders/arc3d}/line_arc_3d_vert.glsl +37 -27
  282. package/lib/line/shaders/flow/flow_line_frag.glsl +5 -4
  283. package/lib/line/shaders/flow/flow_line_vert.glsl +17 -18
  284. package/lib/line/shaders/{line_arc_great_circle_frag.glsl → greatCircle/line_arc_great_circle_frag.glsl} +30 -30
  285. package/{es/line/shaders → lib/line/shaders/greatCircle}/line_arc_great_circle_vert.glsl +43 -40
  286. package/lib/line/shaders/{line_frag.glsl → line/line_frag.glsl} +55 -28
  287. package/lib/line/shaders/line/line_vert.glsl +114 -0
  288. package/lib/line/shaders/simple/simpleline_frag.glsl +27 -3
  289. package/lib/line/shaders/simple/simpleline_vert.glsl +20 -20
  290. package/lib/line/shaders/wall/wall_frag.glsl +31 -26
  291. package/lib/line/shaders/wall/wall_vert.glsl +29 -22
  292. package/lib/plugins/DataMappingPlugin.js +1 -3
  293. package/lib/plugins/FeatureScalePlugin.js +14 -3
  294. package/lib/plugins/PixelPickingPlugin.js +35 -48
  295. package/lib/plugins/ShaderUniformPlugin.js +11 -6
  296. package/lib/point/index.js +1 -0
  297. package/lib/point/models/billboard_point.js +18 -18
  298. package/lib/point/models/earthExtrude.js +21 -13
  299. package/lib/point/models/earthFill.js +18 -30
  300. package/lib/point/models/extrude.js +2 -11
  301. package/lib/point/models/fill.js +33 -84
  302. package/lib/point/models/{fillmage.js → fillImage.js} +24 -17
  303. package/lib/point/models/image.js +31 -17
  304. package/lib/point/models/index.js +2 -2
  305. package/lib/point/models/normal.js +13 -30
  306. package/lib/point/models/radar.js +23 -45
  307. package/lib/point/models/text.js +31 -32
  308. package/{es/point/shaders → lib/point/shaders/billboard}/billboard_point_frag.glsl +17 -13
  309. package/{es/point/shaders → lib/point/shaders/billboard}/billboard_point_vert.glsl +13 -14
  310. package/lib/point/shaders/earthExtrude/earthExtrude_frag.glsl +36 -0
  311. package/{es/point/shaders/earth/extrude_vert.glsl → lib/point/shaders/earthExtrude/earthExtrude_vert.glsl} +25 -22
  312. package/{es/point/shaders/earth/fill_frag.glsl → lib/point/shaders/earthFill/earthFill_frag.glsl} +20 -18
  313. package/{es/point/shaders/earth/fill_vert.glsl → lib/point/shaders/earthFill/earthFill_vert.glsl} +17 -22
  314. package/lib/point/shaders/extrude/extrude_vert.glsl +0 -3
  315. package/{es/point/shaders → lib/point/shaders/fill}/fill_frag.glsl +18 -1
  316. package/lib/point/shaders/{fill_vert.glsl → fill/fill_vert.glsl} +5 -4
  317. package/lib/point/shaders/fillImage/fillImage_frag.glsl +24 -0
  318. package/{es/point/shaders/image → lib/point/shaders/fillImage}/fillImage_vert.glsl +15 -17
  319. package/lib/point/shaders/image/image_frag.glsl +42 -0
  320. package/{es/point/shaders → lib/point/shaders/image}/image_vert.glsl +14 -13
  321. package/lib/point/shaders/radar/radar_frag.glsl +19 -14
  322. package/lib/point/shaders/radar/radar_vert.glsl +21 -24
  323. package/lib/point/shaders/text/text_frag.glsl +44 -0
  324. package/lib/point/shaders/{text_vert.glsl → text/text_vert.glsl} +19 -17
  325. package/lib/polygon/models/extrude.js +38 -15
  326. package/lib/polygon/models/extrusion.js +24 -7
  327. package/lib/polygon/models/fill.js +26 -13
  328. package/lib/polygon/models/ocean.js +30 -14
  329. package/lib/polygon/models/water.js +26 -10
  330. package/lib/polygon/shaders/extrude/polygon_extrude_frag.glsl +14 -14
  331. package/lib/polygon/shaders/extrude/polygon_extrude_picklight_frag.glsl +17 -15
  332. package/lib/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +18 -18
  333. package/lib/polygon/shaders/extrude/polygon_extrude_vert.glsl +18 -24
  334. package/lib/polygon/shaders/extrude/polygon_extrudetex_frag.glsl +19 -15
  335. package/lib/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +20 -24
  336. package/lib/polygon/shaders/extrusion/polygon_extrusion_frag.glsl +4 -8
  337. package/lib/polygon/shaders/extrusion/polygon_extrusion_vert.glsl +7 -16
  338. package/lib/polygon/shaders/fill/fill_frag.glsl +7 -0
  339. package/lib/polygon/shaders/fill/fill_linear_frag.glsl +20 -0
  340. package/{es/polygon/shaders/polygon_linear_vert.glsl → lib/polygon/shaders/fill/fill_linear_vert.glsl} +12 -11
  341. package/lib/polygon/shaders/{polygon_vert.glsl → fill/fill_vert.glsl} +6 -6
  342. package/lib/polygon/shaders/{water/polygon_ocean_frag.glsl → ocean/ocean_frag.glsl} +13 -13
  343. package/lib/polygon/shaders/ocean/ocean_vert.glsl +22 -0
  344. package/lib/polygon/shaders/water/polygon_water_frag.glsl +14 -12
  345. package/lib/polygon/shaders/water/polygon_water_vert.glsl +10 -10
  346. package/lib/raster/models/raster.js +54 -38
  347. package/lib/raster/models/rasterRgb.js +36 -19
  348. package/lib/raster/models/rasterTerrainRgb.js +2 -2
  349. package/lib/raster/shaders/raster/raster_2d_frag.glsl +34 -0
  350. package/lib/raster/shaders/raster/raster_2d_vert.glsl +21 -0
  351. package/lib/raster/shaders/rgb/raster_rgb_frag.glsl +26 -0
  352. package/lib/raster/shaders/rgb/raster_rgb_vert.glsl +21 -0
  353. package/lib/tile/utils/constants.js +1 -1
  354. package/package.json +7 -7
  355. package/es/earth/shaders/atmosphere_vert.glsl +0 -26
  356. package/es/earth/shaders/base_frag.glsl +0 -13
  357. package/es/earth/shaders/base_vert.glsl +0 -52
  358. package/es/earth/shaders/bloomsphere_frag.glsl +0 -15
  359. package/es/earth/shaders/bloomsphere_vert.glsl +0 -20
  360. package/es/heatmap/shaders/heatmap_3d_frag.glsl +0 -14
  361. package/es/heatmap/shaders/heatmap_frag.glsl +0 -47
  362. package/es/heatmap/shaders/heatmap_framebuffer_frag.glsl +0 -10
  363. package/es/heatmap/shaders/heatmap_vert.glsl +0 -10
  364. package/es/heatmap/shaders/hexagon_frag.glsl +0 -12
  365. package/es/line/models/earthArc_3d.d.ts +0 -17
  366. package/es/line/models/earthArc_3d.js +0 -285
  367. package/es/line/models/linearline.d.ts +0 -11
  368. package/es/line/models/linearline.js +0 -241
  369. package/es/line/models/simpleLine.js +0 -194
  370. package/es/line/shaders/arc_chunks.vert.glsl +0 -21
  371. package/es/line/shaders/dash/arc_dash_frag.glsl +0 -21
  372. package/es/line/shaders/dash/arc_dash_vert.glsl +0 -102
  373. package/es/line/shaders/dash/line_dash_frag.glsl +0 -27
  374. package/es/line/shaders/dash/line_dash_vert.glsl +0 -82
  375. package/es/line/shaders/line_arc2d_vert.glsl +0 -114
  376. package/es/line/shaders/line_bezier_vert.glsl +0 -85
  377. package/es/line/shaders/line_vert.glsl +0 -165
  378. package/es/line/shaders/linear/arc3d_linear_frag.glsl +0 -32
  379. package/es/line/shaders/linear/arc3d_linear_vert.glsl +0 -161
  380. package/es/line/shaders/linear/arc_linear_frag.glsl +0 -10
  381. package/es/line/shaders/linear/arc_linear_vert.glsl +0 -98
  382. package/es/line/shaders/linear/line_linear_frag.glsl +0 -25
  383. package/es/line/shaders/linearLine/line_linear_frag.glsl +0 -8
  384. package/es/line/shaders/linearLine/line_linear_vert.glsl +0 -93
  385. package/es/line/shaders/simple/simpleline_linear_frag.glsl +0 -8
  386. package/es/point/shaders/animate/wave_frag.glsl +0 -55
  387. package/es/point/shaders/earth/extrude_frag.glsl +0 -32
  388. package/es/point/shaders/image/fillImage_frag.glsl +0 -18
  389. package/es/point/shaders/image_frag.glsl +0 -37
  390. package/es/point/shaders/text_frag.glsl +0 -39
  391. package/es/polygon/shaders/polygon_frag.glsl +0 -7
  392. package/es/polygon/shaders/polygon_linear_frag.glsl +0 -15
  393. package/es/polygon/shaders/water/polygon_ocean_vert.glsl +0 -16
  394. package/es/raster/shaders/raster_2d_frag.glsl +0 -32
  395. package/es/raster/shaders/raster_2d_vert.glsl +0 -13
  396. package/es/raster/shaders/raster_frag.glsl +0 -11
  397. package/es/raster/shaders/raster_rgb_frag.glsl +0 -20
  398. package/es/raster/shaders/raster_vert.glsl +0 -34
  399. package/lib/earth/shaders/atmosphere_vert.glsl +0 -26
  400. package/lib/earth/shaders/base_frag.glsl +0 -13
  401. package/lib/earth/shaders/base_vert.glsl +0 -52
  402. package/lib/earth/shaders/bloomsphere_frag.glsl +0 -15
  403. package/lib/earth/shaders/bloomsphere_vert.glsl +0 -20
  404. package/lib/heatmap/shaders/heatmap_3d_frag.glsl +0 -14
  405. package/lib/heatmap/shaders/heatmap_frag.glsl +0 -47
  406. package/lib/heatmap/shaders/heatmap_framebuffer_frag.glsl +0 -10
  407. package/lib/heatmap/shaders/heatmap_vert.glsl +0 -10
  408. package/lib/heatmap/shaders/hexagon_frag.glsl +0 -12
  409. package/lib/line/models/earthArc_3d.js +0 -291
  410. package/lib/line/models/linearline.js +0 -247
  411. package/lib/line/shaders/arc_chunks.vert.glsl +0 -21
  412. package/lib/line/shaders/dash/arc_dash_frag.glsl +0 -21
  413. package/lib/line/shaders/dash/arc_dash_vert.glsl +0 -102
  414. package/lib/line/shaders/dash/line_dash_frag.glsl +0 -27
  415. package/lib/line/shaders/dash/line_dash_vert.glsl +0 -82
  416. package/lib/line/shaders/line_arc2d_vert.glsl +0 -114
  417. package/lib/line/shaders/line_bezier_vert.glsl +0 -85
  418. package/lib/line/shaders/line_vert.glsl +0 -165
  419. package/lib/line/shaders/linear/arc3d_linear_frag.glsl +0 -32
  420. package/lib/line/shaders/linear/arc3d_linear_vert.glsl +0 -161
  421. package/lib/line/shaders/linear/arc_linear_frag.glsl +0 -10
  422. package/lib/line/shaders/linear/arc_linear_vert.glsl +0 -98
  423. package/lib/line/shaders/linear/line_linear_frag.glsl +0 -25
  424. package/lib/line/shaders/linearLine/line_linear_frag.glsl +0 -8
  425. package/lib/line/shaders/linearLine/line_linear_vert.glsl +0 -93
  426. package/lib/line/shaders/simple/simpleline_linear_frag.glsl +0 -8
  427. package/lib/point/shaders/animate/wave_frag.glsl +0 -55
  428. package/lib/point/shaders/earth/extrude_frag.glsl +0 -32
  429. package/lib/point/shaders/image/fillImage_frag.glsl +0 -18
  430. package/lib/point/shaders/image_frag.glsl +0 -37
  431. package/lib/point/shaders/text_frag.glsl +0 -39
  432. package/lib/polygon/shaders/polygon_frag.glsl +0 -7
  433. package/lib/polygon/shaders/polygon_linear_frag.glsl +0 -15
  434. package/lib/polygon/shaders/water/polygon_ocean_vert.glsl +0 -16
  435. package/lib/raster/shaders/raster_2d_frag.glsl +0 -32
  436. package/lib/raster/shaders/raster_2d_vert.glsl +0 -13
  437. package/lib/raster/shaders/raster_frag.glsl +0 -11
  438. package/lib/raster/shaders/raster_rgb_frag.glsl +0 -20
  439. package/lib/raster/shaders/raster_vert.glsl +0 -34
  440. /package/es/point/shaders/{normal_frag.glsl → normal/normal_frag.glsl} +0 -0
  441. /package/es/point/shaders/{normal_vert.glsl → normal/normal_vert.glsl} +0 -0
  442. /package/es/raster/shaders/{raster_terrain_rgb_frag.glsl → terrain/terrain_rgb_frag.glsl} +0 -0
  443. /package/es/raster/shaders/{rater_terrain_rgb_vert.glsl → terrain/terrain_rgb_vert.glsl} +0 -0
  444. /package/lib/point/shaders/{normal_frag.glsl → normal/normal_frag.glsl} +0 -0
  445. /package/lib/point/shaders/{normal_vert.glsl → normal/normal_vert.glsl} +0 -0
  446. /package/lib/raster/shaders/{raster_terrain_rgb_frag.glsl → terrain/terrain_rgb_frag.glsl} +0 -0
  447. /package/lib/raster/shaders/{rater_terrain_rgb_vert.glsl → terrain/terrain_rgb_vert.glsl} +0 -0
@@ -1,5 +1,4 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
2
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
4
3
  import _createClass from "@babel/runtime/helpers/esm/createClass";
5
4
  import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
@@ -13,20 +12,12 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
13
12
  import { AttributeType, gl } from '@antv/l7-core';
14
13
  import { lodashUtil, rgb2arr } from '@antv/l7-utils';
15
14
  import BaseModel from "../../core/BaseModel";
15
+ import { ShaderLocation } from "../../core/CommonStyleAttribute";
16
16
  import { LineArcTriangulation } from "../../core/triangulation";
17
- // arc dash line
18
- /* babel-plugin-inline-import '../shaders/dash/arc_dash_frag.glsl' */
19
- var arc_dash_frag = "varying vec4 v_dash_array;\nvarying vec4 v_color;\nvarying float v_distance_ratio;\n\nuniform float segmentNumber;\n\n\n#pragma include \"picking\"\n\nvoid main() {\n gl_FragColor = v_color;\n\n float flag = 0.;\n float dashLength = mod(v_distance_ratio, 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 flag = 1.;\n };\n gl_FragColor.a *=flag;\n \n gl_FragColor = filterColor(gl_FragColor);\n}";
20
- /* babel-plugin-inline-import '../shaders/dash/arc_dash_vert.glsl' */
21
- var arc_dash_vert = "\nattribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec4 a_Instance;\nattribute float a_Size;\nuniform mat4 u_ModelMatrix;\n\nuniform float segmentNumber;\nvarying vec4 v_color;\n\n\nuniform vec4 u_dash_array: [10.0, 5., 0, 0];\nuniform float u_lineDir: 1.0;\nvarying vec4 v_dash_array;\nvarying float v_distance_ratio;\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"picking\"\n\nfloat bezier3(vec3 arr, float t) {\n float ut = 1. - t;\n return (arr.x * ut + arr.y * t) * ut + (arr.y * ut + arr.z * t) * t;\n}\nvec2 midPoint(vec2 source, vec2 target, float arcThetaOffset) {\n vec2 center = target - source;\n float r = length(center);\n float theta = atan(center.y, center.x);\n float thetaOffset = arcThetaOffset;\n float r2 = r / 2.0 / cos(thetaOffset);\n float theta2 = theta + thetaOffset;\n vec2 mid = vec2(r2*cos(theta2) + source.x, r2*sin(theta2) + source.y);\n if(u_lineDir == 1.0) { // \u6B63\u5411\n return mid;\n } else { // \u9006\u5411\n // (mid + vmin)/2 = (s + t)/2\n vec2 vmid = source + target - mid;\n return vmid;\n }\n // return mid;\n}\nfloat getSegmentRatio(float index) {\n // dash: index / (segmentNumber - 1.);\n // normal: smoothstep(0.0, 1.0, index / (segmentNumber - 1.));\n return index / (segmentNumber - 1.);\n}\nvec2 interpolate (vec2 source, vec2 target, float t, float arcThetaOffset) {\n // if the angularDist is PI, linear interpolation is applied. otherwise, use spherical interpolation\n vec2 mid = midPoint(source, target, arcThetaOffset);\n vec3 x = vec3(source.x, mid.x, target.x);\n vec3 y = vec3(source.y, mid.y, target.y);\n return vec2(bezier3(x ,t), bezier3(y,t));\n}\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n vec2 offset = dir_screenspace * offset_direction * setPickingSize(a_Size) / 2.0;\n return offset;\n}\nvec2 getNormal(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n return reverse_offset_normal(vec3(dir_screenspace,1.0)).xy * sign(offset_direction);\n}\n\nvoid main() {\n v_color = vec4(a_Color.xyz, a_Color.w * opacity);\n \n vec2 source = a_Instance.rg; // \u8D77\u59CB\u70B9\n vec2 target = a_Instance.ba; // \u7EC8\u70B9\n float segmentIndex = a_Position.x;\n float segmentRatio = getSegmentRatio(segmentIndex);\n\n float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n\n vec2 s = source;\n vec2 t = target;\n \n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n s = unProjCustomCoord(source);\n t = unProjCustomCoord(target);\n }\n float total_Distance = pixelDistance(s, t) / 2.0 * PI;\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / total_Distance;\n\n v_distance_ratio = segmentIndex / segmentNumber;\n\n vec4 curr = project_position(vec4(interpolate(source, target, segmentRatio, thetaOffset), 0.0, 1.0));\n vec4 next = project_position(vec4(interpolate(source, target, nextSegmentRatio, thetaOffset), 0.0, 1.0));\n \n \n vec2 offset = project_pixel(getExtrusionOffset((next.xy - curr.xy) * indexDir, a_Position.y));\n\n gl_Position = project_common_position_to_clipspace_v2(vec4(curr.xy + offset, 0, 1.0));\n\n gl_PointSize = 5.0;\n setPickingColor(a_PickingColor);\n}\n"; // arc normal line
22
- /* babel-plugin-inline-import '../shaders/line_arc_frag.glsl' */
23
- var arc_line_frag = "\n#define Animate 0.0\n#define LineTexture 1.0\nuniform float u_textureBlend;\nuniform float u_blur : 0.9;\nuniform float u_line_type: 0.0;\n// varying vec2 v_normal;\nvarying vec4 v_dash_array;\nvarying vec4 v_color;\n\nuniform float u_time;\nuniform vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\n\nuniform float u_line_texture;\nuniform sampler2D u_texture;\nuniform vec2 u_textSize;\n\nuniform float segmentNumber;\nvarying vec2 v_iconMapUV;\nvarying vec4 v_lineData;\n\n\n#pragma include \"picking\"\n\nvoid main() {\n float animateSpeed = 0.0; // \u8FD0\u52A8\u901F\u5EA6\n gl_FragColor = v_color;\n \n\n if(u_animate.x == Animate && u_line_texture != LineTexture) {\n animateSpeed = u_time / u_animate.y;\n float alpha =1.0 - fract( mod(1.0- v_lineData.b, u_animate.z)* (1.0/ u_animate.z) + u_time / u_animate.y);\n alpha = (alpha + u_animate.w -1.0) / u_animate.w;\n // alpha = smoothstep(0., 1., alpha);\n alpha = clamp(alpha, 0.0, 1.0);\n gl_FragColor.a *= alpha;\n }\n\n // \u5F53\u5B58\u5728\u8D34\u56FE\u65F6\u5728\u5E95\u8272\u4E0A\u8D34\u4E0A\u8D34\u56FE\n if(u_line_texture == LineTexture) { // while load texture\n float arcRadio = smoothstep( 0.0, 1.0, (v_lineData.r / segmentNumber));\n // float arcRadio = smoothstep( 0.0, 1.0, d_distance_ratio);\n\n float count = v_lineData.g; // \u8D34\u56FE\u5728\u5F27\u7EBF\u4E0A\u91CD\u590D\u7684\u6570\u91CF\n\n float time = 0.0;\n if(u_animate.x == Animate) {\n time = u_time / u_animate.y;\n }\n float redioCount = arcRadio * count;\n\n float u = fract(redioCount - time);\n float v = v_lineData.a; // \u6A2A\u5411 v\n vec2 uv= v_iconMapUV / u_textSize + vec2(u, v) / u_textSize * 64.;\n\n vec4 pattern = texture2D(u_texture, uv);\n\n if(u_animate.x == Animate) {\n float currentPlane = floor(redioCount - time);\n float textureStep = floor(count * u_animate.z);\n float a = mod(currentPlane, textureStep);\n if(a < textureStep - 1.0) {\n pattern = vec4(0.0);\n }\n }\n\n if(u_textureBlend == 0.0) { // normal\n pattern.a = 0.0;\n gl_FragColor = filterColor(gl_FragColor + pattern);\n } else { // replace\n pattern.a *= v_color.a;\n if(gl_FragColor.a <= 0.0) {\n pattern.a = 0.0;\n }\n gl_FragColor = filterColor(pattern);\n }\n \n } else {\n gl_FragColor = filterColor(gl_FragColor);\n }\n}";
24
- /* babel-plugin-inline-import '../shaders/line_arc_vert.glsl' */
25
- var arc_line_vert = "#define Animate 0.0\n#define LineTexture 1.0\n\nattribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec4 a_Instance;\nattribute float a_Size;\nuniform mat4 u_ModelMatrix;\n\nuniform float segmentNumber;\nuniform vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\nvarying vec4 v_color;\n\nuniform float u_lineDir: 1.0;\n\nuniform float u_icon_step: 100;\nuniform float u_line_texture: 0.0;\nattribute vec2 a_iconMapUV;\nvarying vec2 v_iconMapUV;\nvarying vec4 v_lineData;\nvarying vec2 v_distance_ratio;\n\n\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"picking\"\n\nfloat bezier3(vec3 arr, float t) {\n float ut = 1. - t;\n return (arr.x * ut + arr.y * t) * ut + (arr.y * ut + arr.z * t) * t;\n}\nvec2 midPoint(vec2 source, vec2 target, float arcThetaOffset) {\n vec2 center = target - source;\n float r = length(center);\n float theta = atan(center.y, center.x);\n float thetaOffset = arcThetaOffset;\n float r2 = r / 2.0 / cos(thetaOffset);\n float theta2 = theta + thetaOffset;\n vec2 mid = vec2(r2*cos(theta2) + source.x, r2*sin(theta2) + source.y);\n if(u_lineDir == 1.0) { // \u6B63\u5411\n return mid;\n } else { // \u9006\u5411\n // (mid + vmin)/2 = (s + t)/2\n vec2 vmid = source + target - mid;\n return vmid;\n }\n // return mid;\n}\nfloat getSegmentRatio(float index) {\n // dash: index / (segmentNumber - 1.);\n // normal: smoothstep(0.0, 1.0, index / (segmentNumber - 1.));\n return smoothstep(0.0, 1.0, index / (segmentNumber - 1.));\n // return index / (segmentNumber - 1.);\n}\nvec2 interpolate (vec2 source, vec2 target, float t, float arcThetaOffset) {\n // if the angularDist is PI, linear interpolation is applied. otherwise, use spherical interpolation\n vec2 mid = midPoint(source, target, arcThetaOffset);\n vec3 x = vec3(source.x, mid.x, target.x);\n vec3 y = vec3(source.y, mid.y, target.y);\n return vec2(bezier3(x ,t), bezier3(y,t));\n}\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n vec2 offset = dir_screenspace * offset_direction * setPickingSize(a_Size) / 2.0;\n return offset;\n}\nvec2 getNormal(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n return reverse_offset_normal(vec3(dir_screenspace,1.0)).xy * sign(offset_direction);\n}\n\nvoid main() {\n v_color = a_Color;\n v_color.a = v_color.a * opacity;\n\n vec2 source = a_Instance.rg; // \u8D77\u59CB\u70B9\n vec2 target = a_Instance.ba; // \u7EC8\u70B9\n float segmentIndex = a_Position.x;\n float segmentRatio = getSegmentRatio(segmentIndex);\n\n float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n float d_distance_ratio;\n \n if(u_animate.x == Animate) {\n d_distance_ratio = segmentIndex / segmentNumber;\n if(u_lineDir != 1.0) {\n d_distance_ratio = 1.0 - d_distance_ratio;\n }\n }\n\n v_lineData.b = d_distance_ratio;\n\n vec4 curr = project_position(vec4(interpolate(source, target, segmentRatio, thetaOffset), 0.0, 1.0));\n vec4 next = project_position(vec4(interpolate(source, target, nextSegmentRatio, thetaOffset), 0.0, 1.0));\n\n \n vec2 offset = project_pixel(getExtrusionOffset((next.xy - curr.xy) * indexDir, a_Position.y));\n\n\n float d_segmentIndex = a_Position.x + 1.0; // \u5F53\u524D\u9876\u70B9\u5728\u5F27\u7EBF\u4E2D\u6240\u5904\u7684\u5206\u6BB5\u4F4D\u7F6E\n v_lineData.r = d_segmentIndex;\n\n if(LineTexture == u_line_texture) { // \u5F00\u542F\u8D34\u56FE\u6A21\u5F0F\n\n float arcDistrance = length(source - target); // \u8D77\u59CB\u70B9\u548C\u7EC8\u70B9\u7684\u8DDD\u79BB\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20) { // amap\n arcDistrance *= 1000000.0;\n }\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) { // mapbox\n // arcDistrance *= 8.0;\n arcDistrance = project_pixel_allmap(arcDistrance);\n }\n v_iconMapUV = a_iconMapUV;\n\n float pixelLen = project_pixel_texture(u_icon_step); // \u8D34\u56FE\u6CBF\u5F27\u7EBF\u65B9\u5411\u7684\u957F\u5EA6 - \u968F\u5730\u56FE\u7F29\u653E\u6539\u53D8\n float texCount = floor(arcDistrance/pixelLen); // \u8D34\u56FE\u5728\u5F27\u7EBF\u4E0A\u91CD\u590D\u7684\u6570\u91CF\n v_lineData.g = texCount;\n\n float lineOffsetWidth = length(offset + offset * sign(a_Position.y)); // \u7EBF\u6A2A\u5411\u504F\u79FB\u7684\u8DDD\u79BB\n float linePixelSize = project_pixel(a_Size); // \u5B9A\u70B9\u4F4D\u7F6E\u504F\u79FB\n v_lineData.a = lineOffsetWidth/linePixelSize; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n }\n\n gl_Position = project_common_position_to_clipspace_v2(vec4(curr.xy + offset, 0, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n"; // arc linear line
26
- /* babel-plugin-inline-import '../shaders/linear/arc_linear_frag.glsl' */
27
- var arc_linear_frag = "varying vec4 v_color;\n\n#pragma include \"picking\"\n\nvoid main() {\n// \u5F53\u524D\u9876\u70B9\u5728\u5F27\u7EBF\u4E2D\u6240\u5904\u7684\u5206\u6BB5\u4F4D\u7F6E\n\n gl_FragColor = v_color;\n gl_FragColor = filterColor(gl_FragColor);\n}";
28
- /* babel-plugin-inline-import '../shaders/linear/arc_linear_vert.glsl' */
29
- var arc_linear_vert = "\nattribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec4 a_Instance;\nattribute float a_Size;\nuniform mat4 u_ModelMatrix;\n\nuniform float segmentNumber;\nvarying vec4 v_color;\nvarying float v_segmentIndex;\n\nuniform float u_lineDir: 1.0;\n\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\n\n\n\n\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"picking\"\n\nfloat bezier3(vec3 arr, float t) {\n float ut = 1. - t;\n return (arr.x * ut + arr.y * t) * ut + (arr.y * ut + arr.z * t) * t;\n}\nvec2 midPoint(vec2 source, vec2 target, float arcThetaOffset) {\n vec2 center = target - source;\n float r = length(center);\n float theta = atan(center.y, center.x);\n float thetaOffset = arcThetaOffset;\n float r2 = r / 2.0 / cos(thetaOffset);\n float theta2 = theta + thetaOffset;\n vec2 mid = vec2(r2*cos(theta2) + source.x, r2*sin(theta2) + source.y);\n if(u_lineDir == 1.0) { // \u6B63\u5411\n return mid;\n } else { // \u9006\u5411\n // (mid + vmin)/2 = (s + t)/2\n vec2 vmid = source + target - mid;\n return vmid;\n }\n // return mid;\n}\nfloat getSegmentRatio(float index) {\n return smoothstep(0.0, 1.0, index / (segmentNumber - 1.));\n}\nvec2 interpolate (vec2 source, vec2 target, float t, float arcThetaOffset) {\n // if the angularDist is PI, linear interpolation is applied. otherwise, use spherical interpolation\n vec2 mid = midPoint(source, target, arcThetaOffset);\n vec3 x = vec3(source.x, mid.x, target.x);\n vec3 y = vec3(source.y, mid.y, target.y);\n return vec2(bezier3(x ,t), bezier3(y,t));\n}\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n vec2 offset = dir_screenspace * offset_direction * setPickingSize(a_Size) / 2.0;\n return offset;\n}\nvec2 getNormal(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n return reverse_offset_normal(vec3(dir_screenspace,1.0)).xy * sign(offset_direction);\n}\n\nvoid main() {\n v_color = a_Color;\n\n vec2 source = a_Instance.rg; // \u8D77\u59CB\u70B9\n vec2 target = a_Instance.ba; // \u7EC8\u70B9\n float segmentIndex = a_Position.x;\n float segmentRatio = getSegmentRatio(segmentIndex);\n\n float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n float d_distance_ratio;\n vec4 curr = project_position(vec4(interpolate(source, target, segmentRatio, thetaOffset), 0.0, 1.0));\n vec4 next = project_position(vec4(interpolate(source, target, nextSegmentRatio, thetaOffset), 0.0, 1.0));\n // v_normal = getNormal((next.xy - curr.xy) * indexDir, a_Position.y);\n //unProjCustomCoord\n \n vec2 offset = project_pixel(getExtrusionOffset((next.xy - curr.xy) * indexDir, a_Position.y));\n\n\n float d_segmentIndex = a_Position.x + 1.0; // \u5F53\u524D\u9876\u70B9\u5728\u5F27\u7EBF\u4E2D\u6240\u5904\u7684\u5206\u6BB5\u4F4D\u7F6E\n\n v_color = mix(u_sourceColor, u_targetColor, d_segmentIndex/segmentNumber);\n v_color.a *= opacity;\n\n gl_Position = project_common_position_to_clipspace_v2(vec4(curr.xy + offset, 0, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
17
+ /* babel-plugin-inline-import '../shaders/arc/line_arc_frag.glsl' */
18
+ var arc_line_frag = "\n#define Animate 0.0\n#define LineTexture 1.0\nuniform sampler2D u_texture;\nlayout(std140) uniform commonUniorm {\n vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\n vec4 u_dash_array;\n vec4 u_sourceColor;\n vec4 u_targetColor;\n vec2 u_textSize;\n float segmentNumber;\n float u_lineDir: 1.0;\n float u_icon_step: 100;\n float u_line_texture: 0.0;\n float u_textureBlend;\n float u_blur : 0.9;\n float u_line_type: 0.0;\n float u_time;\n float u_linearColor: 0.0;\n};\nin vec2 v_iconMapUV;\nin vec4 v_lineData;\nin vec4 v_color;\n//dash\nin vec4 v_dash_array;\nin float v_distance_ratio;\n\nout vec4 outputColor;\n#pragma include \"picking\"\n\nvoid main() {\n if(u_dash_array!=vec4(0.0)){\n float dashLength = mod(v_distance_ratio, 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 discard;\n };\n }\n float animateSpeed = 0.0; // \u8FD0\u52A8\u901F\u5EA6\n outputColor = v_color;\n if(u_animate.x == Animate && u_line_texture != LineTexture) {\n animateSpeed = u_time / u_animate.y;\n float alpha =1.0 - fract( mod(1.0- v_lineData.b, u_animate.z)* (1.0/ u_animate.z) + u_time / u_animate.y);\n alpha = (alpha + u_animate.w -1.0) / u_animate.w;\n // alpha = smoothstep(0., 1., alpha);\n alpha = clamp(alpha, 0.0, 1.0);\n outputColor.a *= alpha;\n }\n\n // \u5F53\u5B58\u5728\u8D34\u56FE\u65F6\u5728\u5E95\u8272\u4E0A\u8D34\u4E0A\u8D34\u56FE\n if(u_line_texture == LineTexture) { // while load texture\n float arcRadio = smoothstep( 0.0, 1.0, (v_lineData.r / segmentNumber));\n // float arcRadio = smoothstep( 0.0, 1.0, d_distance_ratio);\n\n float count = v_lineData.g; // \u8D34\u56FE\u5728\u5F27\u7EBF\u4E0A\u91CD\u590D\u7684\u6570\u91CF\n\n float time = 0.0;\n if(u_animate.x == Animate) {\n time = u_time / u_animate.y;\n }\n float redioCount = arcRadio * count;\n\n float u = fract(redioCount - time);\n float v = v_lineData.a; // \u6A2A\u5411 v\n vec2 uv= v_iconMapUV / u_textSize + vec2(u, v) / u_textSize * 64.;\n\n vec4 pattern = texture(SAMPLER_2D(u_texture), uv);\n\n if(u_animate.x == Animate) {\n float currentPlane = floor(redioCount - time);\n float textureStep = floor(count * u_animate.z);\n float a = mod(currentPlane, textureStep);\n if(a < textureStep - 1.0) {\n pattern = vec4(0.0);\n }\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 } else {\n outputColor = filterColor(outputColor);\n }\n}";
19
+ /* babel-plugin-inline-import '../shaders/arc/line_arc_vert.glsl' */
20
+ var arc_line_vert = "#define Animate 0.0\n#define LineTexture 1.0\nlayout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in float a_Size;\nlayout(location = 12) in vec4 a_Instance;\nlayout(location = 14) in vec2 a_iconMapUV;\n\nlayout(std140) uniform commonUniorm {\n vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\n vec4 u_dash_array;\n vec4 u_sourceColor;\n vec4 u_targetColor;\n vec2 u_textSize;\n float segmentNumber;\n float u_lineDir: 1.0;\n float u_icon_step: 100;\n float u_line_texture: 0.0;\n float u_textureBlend;\n float u_blur : 0.9;\n float u_line_type: 0.0;\n float u_time;\n float u_linearColor: 0.0;\n};\nout vec4 v_color;\nout vec2 v_iconMapUV;\nout vec4 v_lineData;\n//dash\nout vec4 v_dash_array;\nout float v_distance_ratio;\n\n\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"picking\"\n\nfloat bezier3(vec3 arr, float t) {\n float ut = 1. - t;\n return (arr.x * ut + arr.y * t) * ut + (arr.y * ut + arr.z * t) * t;\n}\nvec2 midPoint(vec2 source, vec2 target, float arcThetaOffset) {\n vec2 center = target - source;\n float r = length(center);\n float theta = atan(center.y, center.x);\n float thetaOffset = arcThetaOffset;\n float r2 = r / 2.0 / cos(thetaOffset);\n float theta2 = theta + thetaOffset;\n vec2 mid = vec2(r2*cos(theta2) + source.x, r2*sin(theta2) + source.y);\n if(u_lineDir == 1.0) { // \u6B63\u5411\n return mid;\n } else { // \u9006\u5411\n // (mid + vmin)/2 = (s + t)/2\n vec2 vmid = source + target - mid;\n return vmid;\n }\n // return mid;\n}\nfloat getSegmentRatio(float index) {\n // dash: index / (segmentNumber - 1.);\n // normal: smoothstep(0.0, 1.0, index / (segmentNumber - 1.));\n return smoothstep(0.0, 1.0, index / (segmentNumber - 1.));\n // return index / (segmentNumber - 1.);\n}\nvec2 interpolate (vec2 source, vec2 target, float t, float arcThetaOffset) {\n // if the angularDist is PI, linear interpolation is applied. otherwise, use spherical interpolation\n vec2 mid = midPoint(source, target, arcThetaOffset);\n vec3 x = vec3(source.x, mid.x, target.x);\n vec3 y = vec3(source.y, mid.y, target.y);\n return vec2(bezier3(x ,t), bezier3(y,t));\n}\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n vec2 offset = dir_screenspace * offset_direction * setPickingSize(a_Size) / 2.0;\n return offset;\n}\nvec2 getNormal(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n return reverse_offset_normal(vec3(dir_screenspace,1.0)).xy * sign(offset_direction);\n}\n\nvoid main() {\n //vs\u4E2D\u8BA1\u7B97\u6E10\u53D8\u8272\n if(u_linearColor==1.0){\n float d_segmentIndex = a_Position.x + 1.0; // \u5F53\u524D\u9876\u70B9\u5728\u5F27\u7EBF\u4E2D\u6240\u5904\u7684\u5206\u6BB5\u4F4D\u7F6E\n v_color = mix(u_sourceColor, u_targetColor, d_segmentIndex/segmentNumber);\n }\n else{\n v_color = a_Color;\n }\n v_color.a = v_color.a * opacity;\n\n vec2 source = a_Instance.rg; // \u8D77\u59CB\u70B9\n vec2 target = a_Instance.ba; // \u7EC8\u70B9\n\n\n\n float segmentIndex = a_Position.x;\n float segmentRatio = getSegmentRatio(segmentIndex);\n\n //\u8BA1\u7B97dashArray\u548CdistanceRatio \u8F93\u51FA\u5230\u7247\u5143\n vec2 s = source;\n vec2 t = target;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n s = unProjCustomCoord(source);\n t = unProjCustomCoord(target);\n }\n float total_Distance = pixelDistance(s, t) / 2.0 * PI;\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / total_Distance;\n v_distance_ratio = segmentIndex / segmentNumber;\n\n float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n float d_distance_ratio;\n \n if(u_animate.x == Animate) {\n d_distance_ratio = segmentIndex / segmentNumber;\n if(u_lineDir != 1.0) {\n d_distance_ratio = 1.0 - d_distance_ratio;\n }\n }\n\n v_lineData.b = d_distance_ratio;\n\n vec4 curr = project_position(vec4(interpolate(source, target, segmentRatio, thetaOffset), 0.0, 1.0));\n vec4 next = project_position(vec4(interpolate(source, target, nextSegmentRatio, thetaOffset), 0.0, 1.0));\n\n \n vec2 offset = project_pixel(getExtrusionOffset((next.xy - curr.xy) * indexDir, a_Position.y));\n\n\n float d_segmentIndex = a_Position.x + 1.0; // \u5F53\u524D\u9876\u70B9\u5728\u5F27\u7EBF\u4E2D\u6240\u5904\u7684\u5206\u6BB5\u4F4D\u7F6E\n v_lineData.r = d_segmentIndex;\n\n if(LineTexture == u_line_texture) { // \u5F00\u542F\u8D34\u56FE\u6A21\u5F0F\n\n float arcDistrance = length(source - target); // \u8D77\u59CB\u70B9\u548C\u7EC8\u70B9\u7684\u8DDD\u79BB\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20) { // amap\n arcDistrance *= 1000000.0;\n }\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) { // mapbox\n // arcDistrance *= 8.0;\n arcDistrance = project_pixel_allmap(arcDistrance);\n }\n v_iconMapUV = a_iconMapUV;\n\n float pixelLen = project_pixel_texture(u_icon_step); // \u8D34\u56FE\u6CBF\u5F27\u7EBF\u65B9\u5411\u7684\u957F\u5EA6 - \u968F\u5730\u56FE\u7F29\u653E\u6539\u53D8\n float texCount = floor(arcDistrance/pixelLen); // \u8D34\u56FE\u5728\u5F27\u7EBF\u4E0A\u91CD\u590D\u7684\u6570\u91CF\n v_lineData.g = texCount;\n\n float lineOffsetWidth = length(offset + offset * sign(a_Position.y)); // \u7EBF\u6A2A\u5411\u504F\u79FB\u7684\u8DDD\u79BB\n float linePixelSize = project_pixel(a_Size); // \u5B9A\u70B9\u4F4D\u7F6E\u504F\u79FB\n v_lineData.a = lineOffsetWidth/linePixelSize; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n }\n\n gl_Position = project_common_position_to_clipspace_v2(vec4(curr.xy + offset, 0, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
30
21
  var lineStyleObj = {
31
22
  solid: 0.0,
32
23
  dash: 1.0
@@ -59,15 +50,14 @@ var ArcModel = /*#__PURE__*/function (_BaseModel) {
59
50
  width: 1024,
60
51
  height: _this.iconService.canvasHeight || 128
61
52
  });
53
+ _this.textures = [_this.texture];
62
54
  });
63
55
  return _this;
64
56
  }
65
57
  _createClass(ArcModel, [{
66
- key: "getUninforms",
67
- value: function getUninforms() {
58
+ key: "getCommonUniformsInfo",
59
+ value: function getCommonUniformsInfo() {
68
60
  var _ref = this.layer.getLayerConfig(),
69
- _ref$opacity = _ref.opacity,
70
- opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
71
61
  sourceColor = _ref.sourceColor,
72
62
  targetColor = _ref.targetColor,
73
63
  _ref$textureBlend = _ref.textureBlend,
@@ -84,8 +74,14 @@ var ArcModel = /*#__PURE__*/function (_BaseModel) {
84
74
  iconStep = _ref$iconStep === void 0 ? 100 : _ref$iconStep,
85
75
  _ref$segmentNumber = _ref.segmentNumber,
86
76
  segmentNumber = _ref$segmentNumber === void 0 ? 30 : _ref$segmentNumber;
87
- if (dashArray.length === 2) {
88
- dashArray.push(0, 0);
77
+ var _ref2 = this.layer.getLayerConfig(),
78
+ animateOption = _ref2.animateOption;
79
+ var u_dash_array = dashArray;
80
+ if (lineType !== 'dash') {
81
+ u_dash_array = [0, 0];
82
+ }
83
+ if (u_dash_array.length === 2) {
84
+ u_dash_array.push(0, 0);
89
85
  }
90
86
 
91
87
  // 转化渐变色
@@ -100,36 +96,37 @@ var ArcModel = /*#__PURE__*/function (_BaseModel) {
100
96
  if (this.rendererService.getDirty()) {
101
97
  this.texture.bind();
102
98
  }
103
- return _objectSpread({
104
- u_textureBlend: textureBlend === 'normal' ? 0.0 : 1.0,
99
+ var commonOptions = {
100
+ u_animate: this.animateOption2Array(animateOption),
101
+ u_dash_array: u_dash_array,
102
+ u_sourceColor: sourceColorArr,
103
+ u_targetColor: targetColorArr,
104
+ u_textSize: [1024, this.iconService.canvasHeight || 128],
105
105
  segmentNumber: segmentNumber,
106
- u_line_type: lineStyleObj[lineType || 'solid'],
107
- u_dash_array: dashArray,
108
- u_blur: 0.9,
109
106
  u_lineDir: forward ? 1 : -1,
110
- // 纹理支持参数
111
- u_texture: this.texture,
112
- // 贴图
107
+ u_icon_step: iconStep,
113
108
  u_line_texture: lineTexture ? 1.0 : 0.0,
114
109
  // 传入线的标识
115
- u_icon_step: iconStep,
116
- u_textSize: [1024, this.iconService.canvasHeight || 128],
110
+ u_textureBlend: textureBlend === 'normal' ? 0.0 : 1.0,
111
+ u_blur: 0.9,
112
+ u_line_type: lineStyleObj[lineType || 'solid'],
113
+ u_time: this.layer.getLayerAnimateTime() || 0,
114
+ // // 纹理支持参数
115
+ // u_texture: this.texture, // 贴图
117
116
  // 渐变色支持参数
118
- u_linearColor: useLinearColor,
119
- u_sourceColor: sourceColorArr,
120
- u_targetColor: targetColorArr
121
- }, this.getStyleAttribute());
122
- }
123
- }, {
124
- key: "getAnimateUniforms",
125
- value: function getAnimateUniforms() {
126
- var _ref2 = this.layer.getLayerConfig(),
127
- animateOption = _ref2.animateOption;
128
- return {
129
- u_animate: this.animateOption2Array(animateOption),
130
- u_time: this.layer.getLayerAnimateTime()
117
+ u_linearColor: useLinearColor
131
118
  };
119
+ var commonBufferInfo = this.getUniformsBufferInfo(commonOptions);
120
+ return commonBufferInfo;
132
121
  }
122
+
123
+ // public getAnimateUniforms(): IModelUniform {
124
+ // const { animateOption } = this.layer.getLayerConfig() as ILayerConfig;
125
+ // return {
126
+ // u_animate: this.animateOption2Array(animateOption as IAnimateOption),
127
+ // u_time: this.layer.getLayerAnimateTime(),
128
+ // };
129
+ // }
133
130
  }, {
134
131
  key: "initModels",
135
132
  value: function () {
@@ -161,43 +158,24 @@ var ArcModel = /*#__PURE__*/function (_BaseModel) {
161
158
  }, {
162
159
  key: "getShaders",
163
160
  value: function getShaders() {
164
- var _ref3 = this.layer.getLayerConfig(),
165
- sourceColor = _ref3.sourceColor,
166
- targetColor = _ref3.targetColor,
167
- lineType = _ref3.lineType;
168
- if (lineType === 'dash') {
169
- return {
170
- frag: arc_dash_frag,
171
- vert: arc_dash_vert,
172
- type: 'Dash'
173
- };
174
- }
175
- if (sourceColor && targetColor) {
176
- // 分离 linear 功能
177
- return {
178
- frag: arc_linear_frag,
179
- vert: arc_linear_vert,
180
- type: 'Linear'
181
- };
182
- } else {
183
- return {
184
- frag: arc_line_frag,
185
- vert: arc_line_vert,
186
- type: ''
187
- };
188
- }
161
+ return {
162
+ frag: arc_line_frag,
163
+ vert: arc_line_vert,
164
+ type: ''
165
+ };
189
166
  }
190
167
  }, {
191
168
  key: "buildModels",
192
169
  value: function () {
193
170
  var _buildModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
194
- var _ref4, _ref4$segmentNumber, segmentNumber, _this$getShaders, frag, vert, type, model;
171
+ var _ref3, _ref3$segmentNumber, segmentNumber, _this$getShaders, frag, vert, type, model;
195
172
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
196
173
  while (1) switch (_context2.prev = _context2.next) {
197
174
  case 0:
198
- _ref4 = this.layer.getLayerConfig(), _ref4$segmentNumber = _ref4.segmentNumber, segmentNumber = _ref4$segmentNumber === void 0 ? 30 : _ref4$segmentNumber;
175
+ this.initUniformsBuffer();
176
+ _ref3 = this.layer.getLayerConfig(), _ref3$segmentNumber = _ref3.segmentNumber, segmentNumber = _ref3$segmentNumber === void 0 ? 30 : _ref3$segmentNumber;
199
177
  _this$getShaders = this.getShaders(), frag = _this$getShaders.frag, vert = _this$getShaders.vert, type = _this$getShaders.type; //
200
- _context2.next = 4;
178
+ _context2.next = 5;
201
179
  return this.layer.buildLayerModel({
202
180
  moduleName: 'lineArc2d' + type,
203
181
  vertexShader: vert,
@@ -211,10 +189,10 @@ var ArcModel = /*#__PURE__*/function (_BaseModel) {
211
189
  segmentNumber: segmentNumber
212
190
  }
213
191
  });
214
- case 4:
192
+ case 5:
215
193
  model = _context2.sent;
216
194
  return _context2.abrupt("return", [model]);
217
- case 6:
195
+ case 7:
218
196
  case "end":
219
197
  return _context2.stop();
220
198
  }
@@ -234,6 +212,7 @@ var ArcModel = /*#__PURE__*/function (_BaseModel) {
234
212
  type: AttributeType.Attribute,
235
213
  descriptor: {
236
214
  name: 'a_Size',
215
+ shaderLocation: ShaderLocation.SIZE,
237
216
  buffer: {
238
217
  // give the WebGL driver a hint that this buffer may change
239
218
  usage: gl.DYNAMIC_DRAW,
@@ -254,6 +233,7 @@ var ArcModel = /*#__PURE__*/function (_BaseModel) {
254
233
  type: AttributeType.Attribute,
255
234
  descriptor: {
256
235
  name: 'a_Instance',
236
+ shaderLocation: 12,
257
237
  buffer: {
258
238
  usage: gl.STATIC_DRAW,
259
239
  data: [],
@@ -270,6 +250,7 @@ var ArcModel = /*#__PURE__*/function (_BaseModel) {
270
250
  type: AttributeType.Attribute,
271
251
  descriptor: {
272
252
  name: 'a_iconMapUV',
253
+ shaderLocation: 14,
273
254
  buffer: {
274
255
  // give the WebGL driver a hint that this buffer may change
275
256
  usage: gl.DYNAMIC_DRAW,
@@ -280,12 +261,12 @@ var ArcModel = /*#__PURE__*/function (_BaseModel) {
280
261
  update: function update(feature) {
281
262
  var iconMap = _this2.iconService.getIconMap();
282
263
  var texture = feature.texture;
283
- var _ref5 = iconMap[texture] || {
264
+ var _ref4 = iconMap[texture] || {
284
265
  x: 0,
285
266
  y: 0
286
267
  },
287
- x = _ref5.x,
288
- y = _ref5.y;
268
+ x = _ref4.x,
269
+ y = _ref4.y;
289
270
  return [x, y];
290
271
  }
291
272
  }
@@ -1,9 +1,14 @@
1
- import { IModel, IModelUniform, ITexture2D } from '@antv/l7-core';
1
+ import type { IModel, ITexture2D } from '@antv/l7-core';
2
2
  import BaseModel from '../../core/BaseModel';
3
3
  export default class Arc3DModel extends BaseModel {
4
4
  protected texture: ITexture2D;
5
- getUninforms(): IModelUniform;
6
- getAnimateUniforms(): IModelUniform;
5
+ protected getCommonUniformsInfo(): {
6
+ uniformsArray: number[];
7
+ uniformsLength: number;
8
+ uniformsOption: {
9
+ [key: string]: any;
10
+ };
11
+ };
7
12
  initModels(): Promise<IModel[]>;
8
13
  clearModels(): void;
9
14
  getShaders(): {
@@ -1,5 +1,4 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
2
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
4
3
  import _createClass from "@babel/runtime/helpers/esm/createClass";
5
4
  import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
@@ -16,14 +15,11 @@ import BaseModel from "../../core/BaseModel";
16
15
  import { LineArcTriangulation } from "../../core/triangulation";
17
16
  import { EARTH_RADIUS } from "../../earth/utils";
18
17
  // arc3d line layer
19
- /* babel-plugin-inline-import '../shaders/line_arc_3d_frag.glsl' */
20
- var arc3d_line_frag = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n#define LineTexture 1.0\n\nuniform float u_textureBlend;\nuniform float u_blur : 0.9;\nuniform float u_line_type: 0.0;\n// varying vec2 v_normal;\nvarying vec4 v_dash_array;\nvarying vec4 v_color;\nvarying vec4 v_line_data;\n\nuniform float u_line_texture: 0.0;\nuniform sampler2D u_texture;\nuniform vec2 u_textSize;\nvarying float v_segmentIndex;\nuniform float segmentNumber;\n\n\nvarying vec2 v_iconMapUV;\n\nuniform float u_time;\nuniform vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\n\n\n#pragma include \"picking\"\n\nvoid main() {\n float animateSpeed = 0.0; // \u8FD0\u52A8\u901F\u5EA6\n float d_distance_ratio = v_line_data.g; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n gl_FragColor = v_color;\n\n if(u_line_type == LineTypeDash) {\n float flag = 0.;\n float dashLength = mod(d_distance_ratio, 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 flag = 1.;\n }\n gl_FragColor.a *=flag;\n }\n\n if(u_animate.x == Animate && u_line_texture != LineTexture) {\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) + u_time / u_animate.y);\n\n alpha = (alpha + u_animate.w -1.0) / u_animate.w;\n // alpha = smoothstep(0., 1., alpha);\n alpha = clamp(alpha, 0.0, 1.0);\n gl_FragColor.a *= alpha;\n\n // u_animate \n // x enable\n // y duration\n // z interval\n // w trailLength\n }\n\n if(u_line_texture == LineTexture && u_line_type != LineTypeDash) { // while load texture\n // float arcRadio = smoothstep( 0.0, 1.0, (v_segmentIndex / segmentNumber));\n float arcRadio = v_segmentIndex / (segmentNumber - 1.0);\n float count = v_line_data.b; // // \u8D34\u56FE\u5728\u5F27\u7EBF\u4E0A\u91CD\u590D\u7684\u6570\u91CF\n\n float time = 0.0;\n if(u_animate.x == Animate) {\n time = u_time / u_animate.y;\n }\n float redioCount = arcRadio * count;\n\n float u = fract(redioCount - time);\n\n float v = v_line_data.a; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n vec2 uv= v_iconMapUV / u_textSize + vec2(u, v) / u_textSize * 64.;\n vec4 pattern = texture2D(u_texture, uv);\n\n if(u_animate.x == Animate) {\n float currentPlane = floor(redioCount - time);\n float textureStep = floor(count * u_animate.z);\n float a = mod(currentPlane, textureStep);\n if(a < textureStep - 1.0) {\n pattern = vec4(0.0);\n }\n }\n\n if(u_textureBlend == 0.0) { // normal\n pattern.a = 0.0;\n gl_FragColor = filterColor(gl_FragColor + pattern);\n } else { // replace\n pattern.a *= v_color.a;\n if(gl_FragColor.a <= 0.0) {\n pattern.a = 0.0;\n discard;\n } else {\n gl_FragColor = filterColor(pattern);\n }\n }\n\n } else {\n gl_FragColor = filterColor(gl_FragColor);\n }\n}\n";
21
- /* babel-plugin-inline-import '../shaders/line_arc_3d_vert.glsl' */
22
- var arc3d_line_vert = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n#define LineTexture 1.0\nattribute vec3 a_Position;\nattribute vec4 a_Instance;\nattribute vec4 a_Color;\nattribute float a_Size;\n\nuniform float u_globel;\nuniform float u_globel_radius;\nuniform float u_global_height: 10;\nuniform mat4 u_ModelMatrix;\n\nuniform float segmentNumber;\nuniform vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\nvarying vec4 v_color;\n\nuniform float u_line_type: 0.0;\nuniform vec4 u_dash_array: [10.0, 5., 0, 0];\nvarying vec4 v_dash_array;\n\nuniform float u_icon_step: 100;\nuniform float u_line_texture: 0.0;\nvarying float v_segmentIndex;\n\nattribute vec2 a_iconMapUV;\nvarying vec2 v_iconMapUV;\nvarying vec4 v_line_data;\n\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"picking\"\n\nfloat maps (float value, float start1, float stop1, float start2, float stop2) {\n return start2 + (stop2 - start2) * ((value - start1) / (stop1 - start1));\n}\n\nfloat getSegmentRatio(float index) {\n return smoothstep(0.0, 1.0, index / (segmentNumber - 1.0));\n}\n\nfloat paraboloid(vec2 source, vec2 target, float ratio) {\n vec2 x = mix(source, target, ratio);\n vec2 center = mix(source, target, 0.5);\n float dSourceCenter = distance(source, center);\n float dXCenter = distance(x, center);\n return (dSourceCenter + dXCenter) * (dSourceCenter - dXCenter);\n}\n\nvec3 getPos(vec2 source, vec2 target, float segmentRatio) {\n float vertex_height = paraboloid(source, target, segmentRatio);\n\n return vec3(\n mix(source, target, segmentRatio),\n sqrt(max(0.0, vertex_height))\n );\n}\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n\n vec2 offset = dir_screenspace * offset_direction * setPickingSize(a_Size) / 2.0;\n\n return offset;\n}\nvec2 getNormal(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n return reverse_offset_normal(vec3(dir_screenspace,1.0)).xy * sign(offset_direction);\n}\n\nfloat torad(float deg) {\n return (deg / 180.0) * acos(-1.0);\n}\n\nvec3 lglt2xyz(vec2 lnglat) {\n float pi = 3.1415926;\n // + Math.PI/2 \u662F\u4E3A\u4E86\u5BF9\u9F50\u5750\u6807\n float lng = torad(lnglat.x) + pi / 2.0;\n float lat = torad(lnglat.y);\n\n // \u624B\u52A8\u589E\u52A0\u4E00\u4E9B\u504F\u79FB\uFF0C\u51CF\u8F7B\u9762\u7684\u51B2\u7A81\n float radius = u_globel_radius;\n\n float z = radius * cos(lat) * cos(lng);\n float x = radius * cos(lat) * sin(lng);\n float y = radius * sin(lat);\n return vec3(x, y, z);\n}\n\nvoid main() {\n\n v_color = a_Color;\n v_color.a = v_color.a * opacity;\n vec2 source = project_position(vec4(a_Instance.rg, 0, 0)).xy;\n vec2 target = project_position(vec4(a_Instance.ba, 0, 0)).xy;\n float segmentIndex = a_Position.x;\n float segmentRatio = getSegmentRatio(segmentIndex);\n float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\n\n float d_distance_ratio;\n if(u_line_type == LineTypeDash) {\n d_distance_ratio = segmentIndex / segmentNumber;\n vec2 s = source;\n vec2 t = target;\n \n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n s = unProjCustomCoord(source);\n t = unProjCustomCoord(target);\n }\n float total_Distance = pixelDistance(s, t) / 2.0 * PI;\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / (total_Distance / segmentNumber * segmentIndex);\n }\n if(u_animate.x == Animate) {\n d_distance_ratio = segmentIndex / segmentNumber;\n }\n v_line_data.g = d_distance_ratio; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n vec3 curr = getPos(source, target, segmentRatio);\n vec3 next = getPos(source, target, nextSegmentRatio);\n vec2 offset = getExtrusionOffset((next.xy - curr.xy) * indexDir, a_Position.y);\n // v_normal = getNormal((next.xy - curr.xy) * indexDir, a_Position.y);\n\n\n v_segmentIndex = a_Position.x;\n if(LineTexture == u_line_texture && u_line_type != LineTypeDash) { // \u5F00\u542F\u8D34\u56FE\u6A21\u5F0F \n\n float arcDistrance = length(source - target);\n float pixelLen = project_pixel_texture(u_icon_step);\n v_line_data.b = floor(arcDistrance/pixelLen); // \u8D34\u56FE\u5728\u5F27\u7EBF\u4E0A\u91CD\u590D\u7684\u6570\u91CF\n\n vec2 projectOffset = project_pixel(offset);\n float lineOffsetWidth = length(projectOffset + projectOffset * sign(a_Position.y)); // \u7EBF\u6A2A\u5411\u504F\u79FB\u7684\u8DDD\u79BB\n float linePixelSize = project_pixel(a_Size); // \u5B9A\u70B9\u4F4D\u7F6E\u504F\u79FB\uFF0C\u6309\u5730\u56FE\u7B49\u7EA7\u7F29\u653E\u540E\u7684\u8DDD\u79BB\n v_line_data.a = lineOffsetWidth/linePixelSize; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n v_iconMapUV = a_iconMapUV;\n }\n\n\n gl_Position = project_common_position_to_clipspace_v2(vec4(curr.xy + project_pixel(offset), curr.z * thetaOffset, 1.0));\n\n // \u5730\u7403\u6A21\u5F0F\n if(u_globel > 0.0) {\n vec3 startLngLat = lglt2xyz(a_Instance.rg);\n vec3 endLngLat = lglt2xyz(a_Instance.ba);\n float globalRadius = length(startLngLat);\n\n vec3 lineDir = normalize(endLngLat - startLngLat);\n vec3 midPointDir = normalize((startLngLat + endLngLat)/2.0);\n\n // \u7EBF\u7684\u504F\u79FB\n vec3 lnglatOffset = cross(lineDir, midPointDir) * a_Position.y;\n // \u8BA1\u7B97\u8D77\u59CB\u70B9\u548C\u7EC8\u6B62\u70B9\u7684\u8DDD\u79BB\n float lnglatLength = length(a_Instance.rg - a_Instance.ba)/50.0;\n // \u8BA1\u7B97\u98DE\u7EBF\u5404\u4E2A\u8282\u70B9\u76F8\u5E94\u7684\u9AD8\u5EA6\n float lineHeight = u_global_height * (-4.0*segmentRatio*segmentRatio + 4.0 * segmentRatio) * lnglatLength;\n // \u5730\u7403\u70B9\u4F4D\n vec3 globalPoint = normalize(mix(startLngLat, endLngLat, segmentRatio)) * (globalRadius + lineHeight) + lnglatOffset * a_Size;\n \n gl_Position = u_ViewProjectionMatrix * vec4(globalPoint, 1.0);\n }\n \n\n setPickingColor(a_PickingColor);\n}\n"; // arc3d linear layer
23
- /* babel-plugin-inline-import '../shaders/linear/arc3d_linear_frag.glsl' */
24
- var arc3d_linear_frag = "\n#define Animate 0.0\nuniform float u_time;\nuniform vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\nvarying vec4 v_Color;\n\nvarying float v_distance_ratio;\n#pragma include \"picking\"\n\nvoid main() {\n\n float animateSpeed = 0.0; // \u8FD0\u52A8\u901F\u5EA6\n gl_FragColor = v_Color;\n\n if(u_animate.x == Animate) {\n animateSpeed = u_time / u_animate.y;\n float alpha =1.0 - fract( mod(1.0- v_distance_ratio, u_animate.z)* (1.0/ u_animate.z) + u_time / u_animate.y);\n\n alpha = (alpha + u_animate.w -1.0) / u_animate.w;\n // alpha = smoothstep(0., 1., alpha);\n alpha = clamp(alpha, 0.0, 1.0);\n gl_FragColor.a *= alpha;\n\n // u_animate \n // x enable\n // y duration\n // z interval\n // w trailLength\n }\n\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
25
- /* babel-plugin-inline-import '../shaders/linear/arc3d_linear_vert.glsl' */
26
- var arc3d_linear_vert = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n#define LineTexture 1.0\nattribute vec3 a_Position;\nattribute vec4 a_Instance;\nattribute vec4 a_Color;\nattribute float a_Size;\nattribute vec2 a_iconMapUV;\n\nuniform float u_globel;\nuniform float u_globel_radius;\nuniform float u_global_height: 10;\nuniform mat4 u_ModelMatrix;\n\nuniform float segmentNumber;\nuniform vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\n\nuniform float u_line_type: 0.0;\nuniform vec4 u_dash_array: [10.0, 5., 0, 0];\nuniform float u_icon_step: 100;\nuniform float u_line_texture: 0.0;\nvarying float v_distance_ratio;\n\nvarying vec4 v_dash_array;\nvarying vec4 v_color;\nvarying vec2 v_iconMapUV;\nvarying vec4 v_Color;\n\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"picking\"\n\nfloat maps (float value, float start1, float stop1, float start2, float stop2) {\n return start2 + (stop2 - start2) * ((value - start1) / (stop1 - start1));\n}\n\nfloat getSegmentRatio(float index) {\n return smoothstep(0.0, 1.0, index / (segmentNumber - 1.0));\n}\n\nfloat paraboloid(vec2 source, vec2 target, float ratio) {\n vec2 x = mix(source, target, ratio);\n vec2 center = mix(source, target, 0.5);\n float dSourceCenter = distance(source, center);\n float dXCenter = distance(x, center);\n return (dSourceCenter + dXCenter) * (dSourceCenter - dXCenter);\n}\n\nvec3 getPos(vec2 source, vec2 target, float segmentRatio) {\n float vertex_height = paraboloid(source, target, segmentRatio);\n\n return vec3(\n mix(source, target, segmentRatio),\n sqrt(max(0.0, vertex_height))\n );\n}\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n\n vec2 offset = dir_screenspace * offset_direction * setPickingSize(a_Size) / 2.0;\n\n return offset;\n}\nvec2 getNormal(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n return reverse_offset_normal(vec3(dir_screenspace,1.0)).xy * sign(offset_direction);\n}\n\nfloat torad(float deg) {\n return (deg / 180.0) * acos(-1.0);\n}\n\nvec3 lglt2xyz(vec2 lnglat) {\n float pi = 3.1415926;\n // + Math.PI/2 \u662F\u4E3A\u4E86\u5BF9\u9F50\u5750\u6807\n float lng = torad(lnglat.x) + pi / 2.0;\n float lat = torad(lnglat.y);\n\n // \u624B\u52A8\u589E\u52A0\u4E00\u4E9B\u504F\u79FB\uFF0C\u51CF\u8F7B\u9762\u7684\u51B2\u7A81\n float radius = u_globel_radius;\n\n float z = radius * cos(lat) * cos(lng);\n float x = radius * cos(lat) * sin(lng);\n float y = radius * sin(lat);\n return vec3(x, y, z);\n}\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n v_color = a_Color;\n vec2 source = project_position(vec4(a_Instance.rg, 0, 0)).xy;\n vec2 target = project_position(vec4(a_Instance.ba, 0, 0)).xy;\n float segmentIndex = a_Position.x;\n float segmentRatio = getSegmentRatio(segmentIndex);\n float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\n\n float d_distance_ratio;\n if(u_line_type == LineTypeDash) {\n d_distance_ratio = segmentIndex / segmentNumber;\n // float total_Distance = pixelDistance(a_Instance.rg, a_Instance.ba) / 2.0 * PI;\n vec2 s = source;\n vec2 t = target;\n \n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n s = unProjCustomCoord(source);\n t = unProjCustomCoord(target);\n }\n float total_Distance = pixelDistance(s, t) / 2.0 * PI;\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / (total_Distance / segmentNumber * segmentIndex);\n }\n if(u_animate.x == Animate) {\n v_distance_ratio = segmentIndex / segmentNumber;\n }\n\n\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n vec3 curr = getPos(source, target, segmentRatio);\n vec3 next = getPos(source, target, nextSegmentRatio);\n vec2 offset = getExtrusionOffset((next.xy - curr.xy) * indexDir, a_Position.y);\n\n float animateSpeed = 0.0; // \u8FD0\u52A8\u901F\u5EA6\n v_Color = mix(u_sourceColor, u_targetColor, a_Position.x/segmentNumber);\n\n v_Color.a *= opacity;\n\n gl_Position = project_common_position_to_clipspace_v2(vec4(curr.xy + project_pixel(offset), curr.z, 1.0));\n\n // \u5730\u7403\u6A21\u5F0F\n if(u_globel > 0.0) {\n vec3 startLngLat = lglt2xyz(a_Instance.rg);\n vec3 endLngLat = lglt2xyz(a_Instance.ba);\n float globalRadius = length(startLngLat);\n\n vec3 lineDir = normalize(endLngLat - startLngLat);\n vec3 midPointDir = normalize((startLngLat + endLngLat)/2.0);\n\n // \u7EBF\u7684\u504F\u79FB\n vec3 lnglatOffset = cross(lineDir, midPointDir) * a_Position.y;\n // \u8BA1\u7B97\u8D77\u59CB\u70B9\u548C\u7EC8\u6B62\u70B9\u7684\u8DDD\u79BB\n float lnglatLength = length(a_Instance.rg - a_Instance.ba)/50.0;\n // \u8BA1\u7B97\u98DE\u7EBF\u5404\u4E2A\u8282\u70B9\u76F8\u5E94\u7684\u9AD8\u5EA6\n float lineHeight = u_global_height * (-4.0*segmentRatio*segmentRatio + 4.0 * segmentRatio) * lnglatLength;\n // \u5730\u7403\u70B9\u4F4D\n vec3 globalPoint = normalize(mix(startLngLat, endLngLat, segmentRatio)) * (globalRadius + lineHeight) + lnglatOffset * a_Size;\n \n gl_Position = u_ViewProjectionMatrix * vec4(globalPoint, 1.0);\n }\n \n\n setPickingColor(a_PickingColor);\n}\n";
18
+ import { ShaderLocation } from "../../core/CommonStyleAttribute";
19
+ /* babel-plugin-inline-import '../shaders/arc3d/line_arc_3d_frag.glsl' */
20
+ var arc3d_line_frag = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n#define LineTexture 1.0\n\nuniform sampler2D u_texture;\n\nlayout(std140) uniform commonUniorm {\n vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\n vec4 u_dash_array: [10.0, 5., 0, 0];\n vec4 u_sourceColor;\n vec4 u_targetColor;\n vec2 u_textSize;\n float u_globel;\n float u_globel_radius;\n float u_global_height: 10;\n float segmentNumber;\n float u_line_type: 0.0;\n float u_icon_step: 100;\n float u_line_texture: 0.0;\n float u_textureBlend;\n float u_time;\n float u_linearColor: 0.0;\n};\n\n// varying vec2 v_normal;\nin vec4 v_dash_array;\nin vec4 v_color;\nin vec4 v_line_data;\nin float v_segmentIndex;\nin vec2 v_iconMapUV;\n\nout vec4 outputColor;\n\n#pragma include \"picking\"\n\nvoid main() {\n float animateSpeed = 0.0; // \u8FD0\u52A8\u901F\u5EA6\n float d_distance_ratio = v_line_data.g; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n outputColor = v_color;\n\n if(u_line_type == LineTypeDash) {\n float flag = 0.;\n float dashLength = mod(d_distance_ratio, 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 flag = 1.;\n }\n outputColor.a *=flag;\n }\n\n if(u_animate.x == Animate && u_line_texture != LineTexture) {\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) + u_time / u_animate.y);\n\n alpha = (alpha + u_animate.w -1.0) / u_animate.w;\n // alpha = smoothstep(0., 1., alpha);\n alpha = clamp(alpha, 0.0, 1.0);\n outputColor.a *= alpha;\n\n // u_animate \n // x enable\n // y duration\n // z interval\n // w trailLength\n }\n\n if(u_line_texture == LineTexture && u_line_type != LineTypeDash) { // while load texture\n // float arcRadio = smoothstep( 0.0, 1.0, (v_segmentIndex / segmentNumber));\n float arcRadio = v_segmentIndex / (segmentNumber - 1.0);\n float count = v_line_data.b; // // \u8D34\u56FE\u5728\u5F27\u7EBF\u4E0A\u91CD\u590D\u7684\u6570\u91CF\n\n float time = 0.0;\n if(u_animate.x == Animate) {\n time = u_time / u_animate.y;\n }\n float redioCount = arcRadio * count;\n\n float u = fract(redioCount - time);\n\n float v = v_line_data.a; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n vec2 uv= v_iconMapUV / u_textSize + vec2(u, v) / u_textSize * 64.;\n vec4 pattern = texture(SAMPLER_2D(u_texture), uv);\n\n if(u_animate.x == Animate) {\n float currentPlane = floor(redioCount - time);\n float textureStep = floor(count * u_animate.z);\n float a = mod(currentPlane, textureStep);\n if(a < textureStep - 1.0) {\n pattern = vec4(0.0);\n }\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 discard;\n } else {\n outputColor = filterColor(pattern);\n }\n }\n\n } else {\n outputColor = filterColor(outputColor);\n }\n}\n";
21
+ /* babel-plugin-inline-import '../shaders/arc3d/line_arc_3d_vert.glsl' */
22
+ var arc3d_line_vert = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n#define LineTexture 1.0\nlayout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in float a_Size;\nlayout(location = 12) in vec4 a_Instance;\nlayout(location = 14) in vec2 a_iconMapUV;\n\n\nlayout(std140) uniform commonUniorm {\n vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\n vec4 u_dash_array: [10.0, 5., 0, 0];\n vec4 u_sourceColor;\n vec4 u_targetColor;\n vec2 u_textSize;\n float u_globel;\n float u_globel_radius;\n float u_global_height: 10;\n float segmentNumber;\n float u_line_type: 0.0;\n float u_icon_step: 100;\n float u_line_texture: 0.0;\n float u_textureBlend;\n float u_time;\n float u_linearColor: 0.0;\n};\nout vec4 v_color;\nout vec4 v_dash_array;\nout float v_segmentIndex;\nout vec2 v_iconMapUV;\nout vec4 v_line_data;\n\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"picking\"\n\nfloat maps (float value, float start1, float stop1, float start2, float stop2) {\n return start2 + (stop2 - start2) * ((value - start1) / (stop1 - start1));\n}\n\nfloat getSegmentRatio(float index) {\n return smoothstep(0.0, 1.0, index / (segmentNumber - 1.0));\n}\n\nfloat paraboloid(vec2 source, vec2 target, float ratio) {\n vec2 x = mix(source, target, ratio);\n vec2 center = mix(source, target, 0.5);\n float dSourceCenter = distance(source, center);\n float dXCenter = distance(x, center);\n return (dSourceCenter + dXCenter) * (dSourceCenter - dXCenter);\n}\n\nvec3 getPos(vec2 source, vec2 target, float segmentRatio) {\n float vertex_height = paraboloid(source, target, segmentRatio);\n\n return vec3(\n mix(source, target, segmentRatio),\n sqrt(max(0.0, vertex_height))\n );\n}\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n\n vec2 offset = dir_screenspace * offset_direction * setPickingSize(a_Size) / 2.0;\n\n return offset;\n}\nvec2 getNormal(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n return reverse_offset_normal(vec3(dir_screenspace,1.0)).xy * sign(offset_direction);\n}\n\nfloat torad(float deg) {\n return (deg / 180.0) * acos(-1.0);\n}\n\nvec3 lglt2xyz(vec2 lnglat) {\n float pi = 3.1415926;\n // + Math.PI/2 \u662F\u4E3A\u4E86\u5BF9\u9F50\u5750\u6807\n float lng = torad(lnglat.x) + pi / 2.0;\n float lat = torad(lnglat.y);\n\n // \u624B\u52A8\u589E\u52A0\u4E00\u4E9B\u504F\u79FB\uFF0C\u51CF\u8F7B\u9762\u7684\u51B2\u7A81\n float radius = u_globel_radius;\n\n float z = radius * cos(lat) * cos(lng);\n float x = radius * cos(lat) * sin(lng);\n float y = radius * sin(lat);\n return vec3(x, y, z);\n}\n\nvoid main() {\n //vs\u4E2D\u8BA1\u7B97\u6E10\u53D8\u8272\n if(u_linearColor==1.0){\n float d_segmentIndex = a_Position.x + 1.0; // \u5F53\u524D\u9876\u70B9\u5728\u5F27\u7EBF\u4E2D\u6240\u5904\u7684\u5206\u6BB5\u4F4D\u7F6E\n v_color = mix(u_sourceColor, u_targetColor, d_segmentIndex/segmentNumber);\n }\n else{\n v_color = a_Color;\n }\n v_color.a = v_color.a * opacity;\n vec2 source = project_position(vec4(a_Instance.rg, 0, 0)).xy;\n vec2 target = project_position(vec4(a_Instance.ba, 0, 0)).xy;\n float segmentIndex = a_Position.x;\n float segmentRatio = getSegmentRatio(segmentIndex);\n float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\n\n float d_distance_ratio;\n if(u_line_type == LineTypeDash) {\n d_distance_ratio = segmentIndex / segmentNumber;\n vec2 s = source;\n vec2 t = target;\n \n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n s = unProjCustomCoord(source);\n t = unProjCustomCoord(target);\n }\n float total_Distance = pixelDistance(s, t) / 2.0 * PI;\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / (total_Distance / segmentNumber * segmentIndex);\n }\n if(u_animate.x == Animate) {\n d_distance_ratio = segmentIndex / segmentNumber;\n }\n v_line_data.g = d_distance_ratio; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n vec3 curr = getPos(source, target, segmentRatio);\n vec3 next = getPos(source, target, nextSegmentRatio);\n vec2 offset = getExtrusionOffset((next.xy - curr.xy) * indexDir, a_Position.y);\n // v_normal = getNormal((next.xy - curr.xy) * indexDir, a_Position.y);\n\n\n v_segmentIndex = a_Position.x;\n if(LineTexture == u_line_texture && u_line_type != LineTypeDash) { // \u5F00\u542F\u8D34\u56FE\u6A21\u5F0F \n\n float arcDistrance = length(source - target);\n float pixelLen = project_pixel_texture(u_icon_step);\n v_line_data.b = floor(arcDistrance/pixelLen); // \u8D34\u56FE\u5728\u5F27\u7EBF\u4E0A\u91CD\u590D\u7684\u6570\u91CF\n\n vec2 projectOffset = project_pixel(offset);\n float lineOffsetWidth = length(projectOffset + projectOffset * sign(a_Position.y)); // \u7EBF\u6A2A\u5411\u504F\u79FB\u7684\u8DDD\u79BB\n float linePixelSize = project_pixel(a_Size); // \u5B9A\u70B9\u4F4D\u7F6E\u504F\u79FB\uFF0C\u6309\u5730\u56FE\u7B49\u7EA7\u7F29\u653E\u540E\u7684\u8DDD\u79BB\n v_line_data.a = lineOffsetWidth/linePixelSize; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n v_iconMapUV = a_iconMapUV;\n }\n\n\n gl_Position = project_common_position_to_clipspace_v2(vec4(curr.xy + project_pixel(offset), curr.z * thetaOffset, 1.0));\n\n // \u5730\u7403\u6A21\u5F0F\n if(u_globel > 0.0) {\n vec3 startLngLat = lglt2xyz(a_Instance.rg);\n vec3 endLngLat = lglt2xyz(a_Instance.ba);\n float globalRadius = length(startLngLat);\n\n vec3 lineDir = normalize(endLngLat - startLngLat);\n vec3 midPointDir = normalize((startLngLat + endLngLat)/2.0);\n\n // \u7EBF\u7684\u504F\u79FB\n vec3 lnglatOffset = cross(lineDir, midPointDir) * a_Position.y;\n // \u8BA1\u7B97\u8D77\u59CB\u70B9\u548C\u7EC8\u6B62\u70B9\u7684\u8DDD\u79BB\n float lnglatLength = length(a_Instance.rg - a_Instance.ba)/50.0;\n // \u8BA1\u7B97\u98DE\u7EBF\u5404\u4E2A\u8282\u70B9\u76F8\u5E94\u7684\u9AD8\u5EA6\n float lineHeight = u_global_height * (-4.0*segmentRatio*segmentRatio + 4.0 * segmentRatio) * lnglatLength;\n // \u5730\u7403\u70B9\u4F4D\n vec3 globalPoint = normalize(mix(startLngLat, endLngLat, segmentRatio)) * (globalRadius + lineHeight) + lnglatOffset * a_Size;\n \n gl_Position = u_ViewProjectionMatrix * vec4(globalPoint, 1.0);\n }\n \n\n setPickingColor(a_PickingColor);\n}\n";
27
23
  var lineStyleObj = {
28
24
  solid: 0.0,
29
25
  dash: 1.0
@@ -55,14 +51,15 @@ var Arc3DModel = /*#__PURE__*/function (_BaseModel) {
55
51
  width: 1024,
56
52
  height: _this.iconService.canvasHeight || 128
57
53
  });
54
+ _this.textures = [_this.texture];
58
55
  });
59
56
  return _this;
60
57
  }
61
58
  _createClass(Arc3DModel, [{
62
- key: "getUninforms",
59
+ key: "getCommonUniformsInfo",
63
60
  value:
64
61
  // public enableShaderEncodeStyles = ['opacity'];
65
- function getUninforms() {
62
+ function getCommonUniformsInfo() {
66
63
  var _ref = this.layer.getLayerConfig(),
67
64
  sourceColor = _ref.sourceColor,
68
65
  targetColor = _ref.targetColor,
@@ -80,10 +77,11 @@ var Arc3DModel = /*#__PURE__*/function (_BaseModel) {
80
77
  segmentNumber = _ref$segmentNumber === void 0 ? 30 : _ref$segmentNumber,
81
78
  _ref$globalArcHeight = _ref.globalArcHeight,
82
79
  globalArcHeight = _ref$globalArcHeight === void 0 ? 10 : _ref$globalArcHeight;
80
+ var _ref2 = this.layer.getLayerConfig(),
81
+ animateOption = _ref2.animateOption;
83
82
  if (dashArray.length === 2) {
84
83
  dashArray.push(0, 0);
85
84
  }
86
-
87
85
  // 转化渐变色
88
86
  var useLinearColor = 0; // 默认不生效
89
87
  var sourceColorArr = [0, 0, 0, 0];
@@ -96,38 +94,37 @@ var Arc3DModel = /*#__PURE__*/function (_BaseModel) {
96
94
  if (this.rendererService.getDirty()) {
97
95
  this.texture.bind();
98
96
  }
99
- return _objectSpread({
97
+ var commonOptions = {
98
+ u_animate: this.animateOption2Array(animateOption),
99
+ u_dash_array: dashArray,
100
+ u_sourceColor: sourceColorArr,
101
+ u_targetColor: targetColorArr,
102
+ u_textSize: [1024, this.iconService.canvasHeight || 128],
100
103
  u_globel: this.mapService.version === 'GLOBEL' ? 1 : 0,
101
104
  u_globel_radius: EARTH_RADIUS,
102
105
  // 地球半径
103
106
  u_global_height: globalArcHeight,
104
- u_textureBlend: textureBlend === 'normal' ? 0.0 : 1.0,
105
107
  segmentNumber: segmentNumber,
106
108
  u_line_type: lineStyleObj[lineType] || 0.0,
107
- u_dash_array: dashArray,
108
- // 纹理支持参数
109
- u_texture: this.texture,
110
- // 贴图
109
+ u_icon_step: iconStep,
111
110
  u_line_texture: lineTexture ? 1.0 : 0.0,
112
111
  // 传入线的标识
113
- u_icon_step: iconStep,
114
- u_textSize: [1024, this.iconService.canvasHeight || 128],
115
- // 渐变色支持参数
116
- u_linearColor: useLinearColor,
117
- u_sourceColor: sourceColorArr,
118
- u_targetColor: targetColorArr
119
- }, this.getStyleAttribute());
120
- }
121
- }, {
122
- key: "getAnimateUniforms",
123
- value: function getAnimateUniforms() {
124
- var _ref2 = this.layer.getLayerConfig(),
125
- animateOption = _ref2.animateOption;
126
- return {
127
- u_animate: this.animateOption2Array(animateOption),
128
- u_time: this.layer.getLayerAnimateTime()
112
+ u_textureBlend: textureBlend === 'normal' ? 0.0 : 1.0,
113
+ u_time: this.layer.getLayerAnimateTime() || 0,
114
+ u_linearColor: useLinearColor //是否使用渐变色
129
115
  };
116
+
117
+ var commonBufferInfo = this.getUniformsBufferInfo(commonOptions);
118
+ return commonBufferInfo;
130
119
  }
120
+
121
+ // public getAnimateUniforms(): IModelUniform {
122
+ // const { animateOption } = this.layer.getLayerConfig() as ILayerConfig;
123
+ // return {
124
+ // u_animate: this.animateOption2Array(animateOption as IAnimateOption),
125
+ // u_time: this.layer.getLayerAnimateTime(),
126
+ // };
127
+ // }
131
128
  }, {
132
129
  key: "initModels",
133
130
  value: function () {
@@ -135,10 +132,11 @@ var Arc3DModel = /*#__PURE__*/function (_BaseModel) {
135
132
  return _regeneratorRuntime.wrap(function _callee$(_context) {
136
133
  while (1) switch (_context.prev = _context.next) {
137
134
  case 0:
135
+ this.initUniformsBuffer();
138
136
  this.updateTexture();
139
137
  this.iconService.on('imageUpdate', this.updateTexture);
140
138
  return _context.abrupt("return", this.buildModels());
141
- case 3:
139
+ case 4:
142
140
  case "end":
143
141
  return _context.stop();
144
142
  }
@@ -159,33 +157,21 @@ var Arc3DModel = /*#__PURE__*/function (_BaseModel) {
159
157
  }, {
160
158
  key: "getShaders",
161
159
  value: function getShaders() {
162
- var _ref3 = this.layer.getLayerConfig(),
163
- sourceColor = _ref3.sourceColor,
164
- targetColor = _ref3.targetColor;
165
- if (sourceColor && targetColor) {
166
- // 分离 linear 功能
167
- return {
168
- frag: arc3d_linear_frag,
169
- vert: arc3d_linear_vert,
170
- type: 'Linear'
171
- };
172
- } else {
173
- return {
174
- frag: arc3d_line_frag,
175
- vert: arc3d_line_vert,
176
- type: ''
177
- };
178
- }
160
+ return {
161
+ frag: arc3d_line_frag,
162
+ vert: arc3d_line_vert,
163
+ type: ''
164
+ };
179
165
  }
180
166
  }, {
181
167
  key: "buildModels",
182
168
  value: function () {
183
169
  var _buildModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
184
- var _ref4, _ref4$segmentNumber, segmentNumber, _this$getShaders, frag, vert, type, model;
170
+ var _ref3, _ref3$segmentNumber, segmentNumber, _this$getShaders, frag, vert, type, model;
185
171
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
186
172
  while (1) switch (_context2.prev = _context2.next) {
187
173
  case 0:
188
- _ref4 = this.layer.getLayerConfig(), _ref4$segmentNumber = _ref4.segmentNumber, segmentNumber = _ref4$segmentNumber === void 0 ? 30 : _ref4$segmentNumber;
174
+ _ref3 = this.layer.getLayerConfig(), _ref3$segmentNumber = _ref3.segmentNumber, segmentNumber = _ref3$segmentNumber === void 0 ? 30 : _ref3$segmentNumber;
189
175
  _this$getShaders = this.getShaders(), frag = _this$getShaders.frag, vert = _this$getShaders.vert, type = _this$getShaders.type;
190
176
  _context2.next = 4;
191
177
  return this.layer.buildLayerModel({
@@ -221,6 +207,7 @@ var Arc3DModel = /*#__PURE__*/function (_BaseModel) {
221
207
  type: AttributeType.Attribute,
222
208
  descriptor: {
223
209
  name: 'a_Size',
210
+ shaderLocation: ShaderLocation.SIZE,
224
211
  buffer: {
225
212
  // give the WebGL driver a hint that this buffer may change
226
213
  usage: gl.DYNAMIC_DRAW,
@@ -241,6 +228,7 @@ var Arc3DModel = /*#__PURE__*/function (_BaseModel) {
241
228
  type: AttributeType.Attribute,
242
229
  descriptor: {
243
230
  name: 'a_Instance',
231
+ shaderLocation: 12,
244
232
  buffer: {
245
233
  usage: gl.STATIC_DRAW,
246
234
  data: [],
@@ -257,6 +245,7 @@ var Arc3DModel = /*#__PURE__*/function (_BaseModel) {
257
245
  type: AttributeType.Attribute,
258
246
  descriptor: {
259
247
  name: 'a_iconMapUV',
248
+ shaderLocation: 14,
260
249
  buffer: {
261
250
  usage: gl.DYNAMIC_DRAW,
262
251
  data: [],
@@ -266,12 +255,12 @@ var Arc3DModel = /*#__PURE__*/function (_BaseModel) {
266
255
  update: function update(feature) {
267
256
  var iconMap = _this2.iconService.getIconMap();
268
257
  var texture = feature.texture;
269
- var _ref5 = iconMap[texture] || {
258
+ var _ref4 = iconMap[texture] || {
270
259
  x: 0,
271
260
  y: 0
272
261
  },
273
- x = _ref5.x,
274
- y = _ref5.y;
262
+ x = _ref4.x,
263
+ y = _ref4.y;
275
264
  return [x, y];
276
265
  }
277
266
  }
@@ -1,7 +1,13 @@
1
- import { IModel, IModelUniform } from '@antv/l7-core';
1
+ import type { IModel } from '@antv/l7-core';
2
2
  import BaseModel from '../../core/BaseModel';
3
3
  export default class FlowLineModel extends BaseModel {
4
- getUninforms(): IModelUniform;
4
+ protected getCommonUniformsInfo(): {
5
+ uniformsArray: number[];
6
+ uniformsLength: number;
7
+ uniformsOption: {
8
+ [key: string]: any;
9
+ };
10
+ };
5
11
  initModels(): Promise<IModel[]>;
6
12
  buildModels(): Promise<IModel[]>;
7
13
  protected registerBuiltinAttributes(): void;