@antv/l7-layers 2.16.1 → 2.16.2

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 (386) hide show
  1. package/es/Geometry/index.js +9 -31
  2. package/es/Geometry/models/billboard.js +51 -89
  3. package/es/Geometry/models/plane.js +81 -143
  4. package/es/Geometry/models/sprite.js +60 -118
  5. package/es/canvas/index.js +10 -33
  6. package/es/canvas/models/canvas.js +41 -97
  7. package/es/citybuliding/building.js +8 -27
  8. package/es/citybuliding/models/build.js +57 -82
  9. package/es/core/BaseLayer.d.ts +3 -0
  10. package/es/core/BaseLayer.js +360 -528
  11. package/es/core/BaseModel.d.ts +9 -71
  12. package/es/core/BaseModel.js +118 -429
  13. package/es/core/CommonStyleAttribute.d.ts +2 -0
  14. package/es/core/CommonStyleAttribute.js +66 -0
  15. package/es/core/LayerPickService.js +21 -32
  16. package/es/core/TextureService.js +0 -13
  17. package/es/core/interface.d.ts +13 -3
  18. package/es/core/interface.js +17 -24
  19. package/es/core/shape/Path.js +13 -20
  20. package/es/core/shape/extrude.js +27 -36
  21. package/es/core/triangulation.d.ts +12 -0
  22. package/es/core/triangulation.js +124 -114
  23. package/es/earth/index.js +9 -33
  24. package/es/earth/models/atmosphere.js +30 -54
  25. package/es/earth/models/base.js +47 -85
  26. package/es/earth/models/bloomsphere.js +30 -54
  27. package/es/earth/utils.js +9 -13
  28. package/es/heatmap/index.js +10 -40
  29. package/es/heatmap/models/grid.js +29 -53
  30. package/es/heatmap/models/grid3d.js +29 -53
  31. package/es/heatmap/models/heatmap.d.ts +1 -0
  32. package/es/heatmap/models/heatmap.js +99 -150
  33. package/es/heatmap/models/hexagon.js +29 -53
  34. package/es/heatmap/shaders/grid_vert.glsl +2 -2
  35. package/es/heatmap/shaders/hexagon_3d_vert.glsl +2 -2
  36. package/es/heatmap/shaders/hexagon_vert.glsl +2 -2
  37. package/es/heatmap/triangulation.js +0 -4
  38. package/es/image/index.js +9 -28
  39. package/es/image/models/image.js +66 -100
  40. package/es/index.js +9 -17
  41. package/es/line/index.d.ts +1 -0
  42. package/es/line/index.js +12 -36
  43. package/es/line/models/arc.js +72 -160
  44. package/es/line/models/arc_3d.js +67 -148
  45. package/es/line/models/earthArc_3d.js +66 -148
  46. package/es/line/models/{half.d.ts → flow.d.ts} +1 -11
  47. package/es/line/models/flow.js +167 -0
  48. package/es/line/models/great_circle.js +57 -135
  49. package/es/line/models/index.d.ts +1 -1
  50. package/es/line/models/index.js +3 -3
  51. package/es/line/models/line.js +98 -186
  52. package/es/line/models/linearline.js +46 -115
  53. package/es/line/models/simpleLine.d.ts +0 -1
  54. package/es/line/models/simpleLine.js +42 -114
  55. package/es/line/models/wall.js +52 -92
  56. package/es/line/shaders/dash/arc_dash_frag.glsl +3 -6
  57. package/es/line/shaders/dash/arc_dash_vert.glsl +6 -46
  58. package/es/line/shaders/dash/line_dash_frag.glsl +4 -7
  59. package/es/line/shaders/dash/line_dash_vert.glsl +3 -33
  60. package/es/line/shaders/flow/flow_line_frag.glsl +13 -0
  61. package/es/line/shaders/flow/flow_line_vert.glsl +83 -0
  62. package/es/line/shaders/line_arc_3d_frag.glsl +6 -6
  63. package/es/line/shaders/line_arc_3d_vert.glsl +4 -34
  64. package/es/line/shaders/line_arc_frag.glsl +7 -11
  65. package/es/line/shaders/line_arc_great_circle_frag.glsl +5 -6
  66. package/es/line/shaders/line_arc_great_circle_vert.glsl +4 -32
  67. package/es/line/shaders/line_arc_vert.glsl +9 -45
  68. package/es/line/shaders/line_frag.glsl +15 -17
  69. package/es/line/shaders/line_vert.glsl +3 -34
  70. package/es/line/shaders/linear/arc3d_linear_frag.glsl +5 -19
  71. package/es/line/shaders/linear/arc3d_linear_vert.glsl +9 -48
  72. package/es/line/shaders/linear/arc_linear_frag.glsl +2 -30
  73. package/es/line/shaders/linear/arc_linear_vert.glsl +9 -45
  74. package/es/line/shaders/linear/line_linear_frag.glsl +5 -6
  75. package/es/line/shaders/linearLine/line_linear_frag.glsl +2 -14
  76. package/es/line/shaders/linearLine/line_linear_vert.glsl +14 -32
  77. package/es/line/shaders/simple/simpleline_frag.glsl +1 -5
  78. package/es/line/shaders/simple/simpleline_linear_frag.glsl +2 -6
  79. package/es/line/shaders/simple/simpleline_vert.glsl +7 -33
  80. package/es/mask/index.js +9 -28
  81. package/es/mask/models/fill.js +29 -54
  82. package/es/plugins/DataMappingPlugin.js +90 -141
  83. package/es/plugins/DataSourcePlugin.js +45 -68
  84. package/es/plugins/FeatureScalePlugin.js +67 -122
  85. package/es/plugins/LayerAnimateStylePlugin.js +0 -5
  86. package/es/plugins/LayerMaskPlugin.js +3 -11
  87. package/es/plugins/LayerModelPlugin.js +79 -104
  88. package/es/plugins/LayerStylePlugin.js +3 -9
  89. package/es/plugins/LightingPlugin.js +12 -18
  90. package/es/plugins/MultiPassRendererPlugin.js +11 -16
  91. package/es/plugins/PixelPickingPlugin.js +12 -21
  92. package/es/plugins/RegisterStyleAttributePlugin.js +5 -12
  93. package/es/plugins/ShaderUniformPlugin.js +15 -29
  94. package/es/plugins/UpdateModelPlugin.js +0 -5
  95. package/es/plugins/UpdateStyleAttributePlugin.js +5 -11
  96. package/es/point/index.d.ts +1 -0
  97. package/es/point/index.js +27 -77
  98. package/es/point/models/earthExtrude.d.ts +0 -3
  99. package/es/point/models/earthExtrude.js +60 -139
  100. package/es/point/models/earthFill.d.ts +0 -1
  101. package/es/point/models/earthFill.js +59 -140
  102. package/es/point/models/extrude.d.ts +0 -3
  103. package/es/point/models/extrude.js +60 -140
  104. package/es/point/models/fill.d.ts +0 -1
  105. package/es/point/models/fill.js +67 -158
  106. package/es/point/models/fillmage.js +66 -147
  107. package/es/point/models/image.js +52 -126
  108. package/es/point/models/index.js +2 -2
  109. package/es/point/models/normal.js +32 -56
  110. package/es/point/models/radar.d.ts +0 -1
  111. package/es/point/models/radar.js +42 -75
  112. package/es/point/models/simplePoint.d.ts +0 -1
  113. package/es/point/models/simplePoint.js +46 -115
  114. package/es/point/models/text.js +211 -344
  115. package/es/point/shaders/animate/wave_frag.glsl +1 -11
  116. package/es/point/shaders/earth/extrude_frag.glsl +5 -17
  117. package/es/point/shaders/earth/extrude_vert.glsl +14 -29
  118. package/es/point/shaders/earth/fill_frag.glsl +5 -14
  119. package/es/point/shaders/earth/fill_vert.glsl +1 -75
  120. package/es/point/shaders/extrude/extrude_frag.glsl +3 -29
  121. package/es/point/shaders/extrude/extrude_vert.glsl +27 -35
  122. package/es/point/shaders/fill_frag.glsl +9 -20
  123. package/es/point/shaders/fill_vert.glsl +16 -101
  124. package/es/point/shaders/image/fillImage_frag.glsl +2 -5
  125. package/es/point/shaders/image/fillImage_vert.glsl +4 -47
  126. package/es/point/shaders/image_frag.glsl +1 -5
  127. package/es/point/shaders/image_vert.glsl +1 -44
  128. package/es/point/shaders/normal_frag.glsl +0 -2
  129. package/es/point/shaders/normal_vert.glsl +2 -1
  130. package/es/point/shaders/radar/radar_vert.glsl +2 -2
  131. package/es/point/shaders/simplePoint_frag.glsl +0 -7
  132. package/es/point/shaders/simplePoint_vert.glsl +3 -45
  133. package/es/point/shaders/text_frag.glsl +6 -19
  134. package/es/point/shaders/text_vert.glsl +5 -66
  135. package/es/point/shape/extrude.js +4 -13
  136. package/es/polygon/index.d.ts +1 -0
  137. package/es/polygon/index.js +12 -40
  138. package/es/polygon/models/extrude.d.ts +0 -3
  139. package/es/polygon/models/extrude.js +122 -162
  140. package/es/polygon/models/fill.d.ts +0 -4
  141. package/es/polygon/models/fill.js +57 -130
  142. package/es/polygon/models/index.js +3 -2
  143. package/es/polygon/models/ocean.js +42 -76
  144. package/es/polygon/models/water.js +37 -71
  145. package/es/polygon/shaders/extrude/polygon_extrude_frag.glsl +2 -23
  146. package/es/polygon/shaders/extrude/polygon_extrude_picklight_frag.glsl +7 -5
  147. package/es/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +7 -32
  148. package/es/polygon/shaders/extrude/polygon_extrude_vert.glsl +33 -38
  149. package/es/polygon/shaders/extrude/polygon_extrudetex_frag.glsl +12 -9
  150. package/es/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +16 -44
  151. package/es/polygon/shaders/polygon_frag.glsl +0 -5
  152. package/es/polygon/shaders/polygon_linear_frag.glsl +0 -8
  153. package/es/polygon/shaders/polygon_linear_vert.glsl +0 -32
  154. package/es/polygon/shaders/polygon_vert.glsl +1 -27
  155. package/es/raster/buffers/triangulation.js +2 -4
  156. package/es/raster/index.js +9 -32
  157. package/es/raster/models/raster.js +80 -116
  158. package/es/raster/models/rasterRgb.js +84 -127
  159. package/es/raster/models/rasterTerrainRgb.js +56 -84
  160. package/es/tile/interaction/getRasterData.js +14 -20
  161. package/es/tile/interaction/utils.js +7 -9
  162. package/es/tile/manager/base.js +63 -96
  163. package/es/tile/service/TileLayerService.js +33 -55
  164. package/es/tile/service/TilePickService.js +26 -40
  165. package/es/tile/service/TileSourceService.js +3 -7
  166. package/es/tile/tileFactory/DebugTile.js +29 -46
  167. package/es/tile/tileFactory/ImageTile.js +20 -38
  168. package/es/tile/tileFactory/MaskTile.js +22 -43
  169. package/es/tile/tileFactory/RasterRGBTile.js +22 -42
  170. package/es/tile/tileFactory/RasterTerrainRGBTile.js +20 -38
  171. package/es/tile/tileFactory/RasterTile.js +30 -53
  172. package/es/tile/tileFactory/Tile.js +63 -97
  173. package/es/tile/tileFactory/VectorTile.js +41 -68
  174. package/es/tile/tileFactory/index.js +0 -11
  175. package/es/tile/tileFactory/layers/TileDebugLayer.js +6 -27
  176. package/es/tile/tileFactory/util.js +0 -3
  177. package/es/tile/tileLayer/BaseLayer.js +105 -146
  178. package/es/tile/utils.js +1 -1
  179. package/es/utils/blend.js +0 -2
  180. package/es/utils/collision-index.js +9 -16
  181. package/es/utils/extrude_polyline.js +101 -149
  182. package/es/utils/grid-index.js +2 -27
  183. package/es/utils/identityScale.js +0 -8
  184. package/es/utils/layerData.js +32 -46
  185. package/es/utils/multiPassRender.js +11 -13
  186. package/es/utils/polylineNormal.js +31 -37
  187. package/es/utils/simpleLine.js +2 -16
  188. package/es/utils/stencil.js +2 -3
  189. package/es/utils/symbol-layout.js +27 -53
  190. package/es/wind/index.js +9 -29
  191. package/es/wind/models/utils.js +26 -51
  192. package/es/wind/models/wind.js +101 -147
  193. package/es/wind/models/windRender.js +53 -66
  194. package/lib/Geometry/index.js +9 -38
  195. package/lib/Geometry/models/billboard.js +51 -97
  196. package/lib/Geometry/models/index.js +0 -5
  197. package/lib/Geometry/models/plane.js +79 -151
  198. package/lib/Geometry/models/sprite.js +60 -127
  199. package/lib/canvas/index.js +10 -40
  200. package/lib/canvas/models/canvas.js +41 -101
  201. package/lib/canvas/models/index.js +0 -3
  202. package/lib/citybuliding/building.js +8 -35
  203. package/lib/citybuliding/models/build.js +57 -92
  204. package/lib/core/BaseLayer.js +358 -520
  205. package/lib/core/BaseModel.js +117 -441
  206. package/lib/core/CommonStyleAttribute.js +72 -0
  207. package/lib/core/LayerPickService.js +21 -37
  208. package/lib/core/TextureService.js +0 -16
  209. package/lib/core/interface.js +21 -31
  210. package/lib/core/schema.js +0 -1
  211. package/lib/core/shape/Path.js +14 -31
  212. package/lib/core/shape/extrude.js +27 -59
  213. package/lib/core/triangulation.js +125 -153
  214. package/lib/earth/index.js +9 -43
  215. package/lib/earth/models/atmosphere.js +30 -63
  216. package/lib/earth/models/base.js +47 -90
  217. package/lib/earth/models/bloomsphere.js +30 -63
  218. package/lib/earth/utils.js +7 -31
  219. package/lib/heatmap/index.js +10 -48
  220. package/lib/heatmap/models/grid.js +29 -61
  221. package/lib/heatmap/models/grid3d.js +29 -61
  222. package/lib/heatmap/models/heatmap.js +99 -166
  223. package/lib/heatmap/models/hexagon.js +29 -61
  224. package/lib/heatmap/models/index.js +0 -6
  225. package/lib/heatmap/shaders/grid_vert.glsl +2 -2
  226. package/lib/heatmap/shaders/hexagon_3d_vert.glsl +2 -2
  227. package/lib/heatmap/shaders/hexagon_vert.glsl +2 -2
  228. package/lib/heatmap/triangulation.js +0 -5
  229. package/lib/image/index.js +9 -36
  230. package/lib/image/models/image.js +66 -109
  231. package/lib/image/models/index.js +0 -3
  232. package/lib/index.js +7 -61
  233. package/lib/line/index.js +12 -42
  234. package/lib/line/models/arc.js +70 -170
  235. package/lib/line/models/arc_3d.js +65 -159
  236. package/lib/line/models/earthArc_3d.js +64 -159
  237. package/lib/line/models/flow.js +174 -0
  238. package/lib/line/models/great_circle.js +57 -146
  239. package/lib/line/models/index.js +3 -14
  240. package/lib/line/models/line.js +96 -194
  241. package/lib/line/models/linearline.js +46 -127
  242. package/lib/line/models/simpleLine.js +42 -124
  243. package/lib/line/models/wall.js +52 -103
  244. package/lib/line/shaders/dash/arc_dash_frag.glsl +3 -6
  245. package/lib/line/shaders/dash/arc_dash_vert.glsl +6 -46
  246. package/lib/line/shaders/dash/line_dash_frag.glsl +4 -7
  247. package/lib/line/shaders/dash/line_dash_vert.glsl +3 -33
  248. package/lib/line/shaders/flow/flow_line_frag.glsl +13 -0
  249. package/lib/line/shaders/flow/flow_line_vert.glsl +83 -0
  250. package/lib/line/shaders/line_arc_3d_frag.glsl +6 -6
  251. package/lib/line/shaders/line_arc_3d_vert.glsl +4 -34
  252. package/lib/line/shaders/line_arc_frag.glsl +7 -11
  253. package/lib/line/shaders/line_arc_great_circle_frag.glsl +5 -6
  254. package/lib/line/shaders/line_arc_great_circle_vert.glsl +4 -32
  255. package/lib/line/shaders/line_arc_vert.glsl +9 -45
  256. package/lib/line/shaders/line_frag.glsl +15 -17
  257. package/lib/line/shaders/line_vert.glsl +3 -34
  258. package/lib/line/shaders/linear/arc3d_linear_frag.glsl +5 -19
  259. package/lib/line/shaders/linear/arc3d_linear_vert.glsl +9 -48
  260. package/lib/line/shaders/linear/arc_linear_frag.glsl +2 -30
  261. package/lib/line/shaders/linear/arc_linear_vert.glsl +9 -45
  262. package/lib/line/shaders/linear/line_linear_frag.glsl +5 -6
  263. package/lib/line/shaders/linearLine/line_linear_frag.glsl +2 -14
  264. package/lib/line/shaders/linearLine/line_linear_vert.glsl +14 -32
  265. package/lib/line/shaders/simple/simpleline_frag.glsl +1 -5
  266. package/lib/line/shaders/simple/simpleline_linear_frag.glsl +2 -6
  267. package/lib/line/shaders/simple/simpleline_vert.glsl +7 -33
  268. package/lib/mask/index.js +9 -36
  269. package/lib/mask/models/fill.js +29 -63
  270. package/lib/mask/models/index.js +0 -3
  271. package/lib/plugins/DataMappingPlugin.js +90 -152
  272. package/lib/plugins/DataSourcePlugin.js +45 -76
  273. package/lib/plugins/FeatureScalePlugin.js +67 -138
  274. package/lib/plugins/LayerAnimateStylePlugin.js +0 -10
  275. package/lib/plugins/LayerMaskPlugin.js +4 -17
  276. package/lib/plugins/LayerModelPlugin.js +80 -113
  277. package/lib/plugins/LayerStylePlugin.js +4 -14
  278. package/lib/plugins/LightingPlugin.js +12 -25
  279. package/lib/plugins/MultiPassRendererPlugin.js +11 -22
  280. package/lib/plugins/PixelPickingPlugin.js +12 -27
  281. package/lib/plugins/RegisterStyleAttributePlugin.js +5 -19
  282. package/lib/plugins/ShaderUniformPlugin.js +15 -36
  283. package/lib/plugins/UpdateModelPlugin.js +1 -10
  284. package/lib/plugins/UpdateStyleAttributePlugin.js +5 -16
  285. package/lib/point/index.js +27 -83
  286. package/lib/point/models/earthExtrude.js +60 -150
  287. package/lib/point/models/earthFill.js +59 -170
  288. package/lib/point/models/extrude.js +60 -150
  289. package/lib/point/models/fill.js +65 -167
  290. package/lib/point/models/fillmage.js +64 -155
  291. package/lib/point/models/image.js +52 -136
  292. package/lib/point/models/index.js +1 -12
  293. package/lib/point/models/normal.js +32 -66
  294. package/lib/point/models/radar.js +42 -85
  295. package/lib/point/models/simplePoint.js +46 -125
  296. package/lib/point/models/text.js +209 -350
  297. package/lib/point/shaders/animate/wave_frag.glsl +1 -11
  298. package/lib/point/shaders/earth/extrude_frag.glsl +5 -17
  299. package/lib/point/shaders/earth/extrude_vert.glsl +14 -29
  300. package/lib/point/shaders/earth/fill_frag.glsl +5 -14
  301. package/lib/point/shaders/earth/fill_vert.glsl +1 -75
  302. package/lib/point/shaders/extrude/extrude_frag.glsl +3 -29
  303. package/lib/point/shaders/extrude/extrude_vert.glsl +27 -35
  304. package/lib/point/shaders/fill_frag.glsl +9 -20
  305. package/lib/point/shaders/fill_vert.glsl +16 -101
  306. package/lib/point/shaders/image/fillImage_frag.glsl +2 -5
  307. package/lib/point/shaders/image/fillImage_vert.glsl +4 -47
  308. package/lib/point/shaders/image_frag.glsl +1 -5
  309. package/lib/point/shaders/image_vert.glsl +1 -44
  310. package/lib/point/shaders/normal_frag.glsl +0 -2
  311. package/lib/point/shaders/normal_vert.glsl +2 -1
  312. package/lib/point/shaders/radar/radar_vert.glsl +2 -2
  313. package/lib/point/shaders/simplePoint_frag.glsl +0 -7
  314. package/lib/point/shaders/simplePoint_vert.glsl +3 -45
  315. package/lib/point/shaders/text_frag.glsl +6 -19
  316. package/lib/point/shaders/text_vert.glsl +5 -66
  317. package/lib/point/shape/extrude.js +4 -20
  318. package/lib/polygon/index.js +12 -48
  319. package/lib/polygon/models/extrude.js +122 -173
  320. package/lib/polygon/models/fill.js +57 -140
  321. package/lib/polygon/models/index.js +2 -14
  322. package/lib/polygon/models/ocean.js +42 -88
  323. package/lib/polygon/models/water.js +37 -82
  324. package/lib/polygon/shaders/extrude/polygon_extrude_frag.glsl +2 -23
  325. package/lib/polygon/shaders/extrude/polygon_extrude_picklight_frag.glsl +7 -5
  326. package/lib/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +7 -32
  327. package/lib/polygon/shaders/extrude/polygon_extrude_vert.glsl +33 -38
  328. package/lib/polygon/shaders/extrude/polygon_extrudetex_frag.glsl +12 -9
  329. package/lib/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +16 -44
  330. package/lib/polygon/shaders/polygon_frag.glsl +0 -5
  331. package/lib/polygon/shaders/polygon_linear_frag.glsl +0 -8
  332. package/lib/polygon/shaders/polygon_linear_vert.glsl +0 -32
  333. package/lib/polygon/shaders/polygon_vert.glsl +1 -27
  334. package/lib/raster/buffers/triangulation.js +3 -7
  335. package/lib/raster/index.js +9 -40
  336. package/lib/raster/models/index.js +0 -5
  337. package/lib/raster/models/raster.js +80 -125
  338. package/lib/raster/models/rasterRgb.js +84 -139
  339. package/lib/raster/models/rasterTerrainRgb.js +56 -93
  340. package/lib/tile/interaction/getRasterData.js +14 -25
  341. package/lib/tile/interaction/utils.js +7 -19
  342. package/lib/tile/manager/base.js +63 -104
  343. package/lib/tile/service/TileLayerService.js +33 -60
  344. package/lib/tile/service/TilePickService.js +26 -48
  345. package/lib/tile/service/TileSourceService.js +2 -16
  346. package/lib/tile/style/utils.js +0 -3
  347. package/lib/tile/tileFactory/DebugTile.js +29 -54
  348. package/lib/tile/tileFactory/ImageTile.js +20 -46
  349. package/lib/tile/tileFactory/MaskTile.js +22 -51
  350. package/lib/tile/tileFactory/RasterRGBTile.js +22 -50
  351. package/lib/tile/tileFactory/RasterTerrainRGBTile.js +20 -46
  352. package/lib/tile/tileFactory/RasterTile.js +30 -63
  353. package/lib/tile/tileFactory/Tile.js +63 -102
  354. package/lib/tile/tileFactory/VectorTile.js +41 -76
  355. package/lib/tile/tileFactory/index.js +0 -25
  356. package/lib/tile/tileFactory/layers/TileDebugLayer.js +6 -32
  357. package/lib/tile/tileFactory/util.js +0 -9
  358. package/lib/tile/tileLayer/BaseLayer.js +105 -153
  359. package/lib/tile/utils.js +1 -5
  360. package/lib/utils/blend.js +0 -5
  361. package/lib/utils/collision-index.js +9 -25
  362. package/lib/utils/extrude_polyline.js +101 -181
  363. package/lib/utils/grid-index.js +2 -28
  364. package/lib/utils/identityScale.js +0 -9
  365. package/lib/utils/layerData.js +32 -51
  366. package/lib/utils/multiPassRender.js +11 -16
  367. package/lib/utils/polylineNormal.js +31 -66
  368. package/lib/utils/simpleLine.js +2 -21
  369. package/lib/utils/stencil.js +0 -4
  370. package/lib/utils/symbol-layout.js +27 -55
  371. package/lib/wind/index.js +9 -37
  372. package/lib/wind/models/index.js +0 -3
  373. package/lib/wind/models/utils.js +26 -62
  374. package/lib/wind/models/wind.js +101 -157
  375. package/lib/wind/models/windRender.js +53 -71
  376. package/lib/wind/models/windShader.js +0 -1
  377. package/package.json +7 -7
  378. package/es/line/models/half.js +0 -298
  379. package/es/line/shaders/half/line_half_frag.glsl +0 -53
  380. package/es/line/shaders/half/line_half_vert.glsl +0 -169
  381. package/es/utils/dataMappingStyle.d.ts +0 -31
  382. package/es/utils/dataMappingStyle.js +0 -147
  383. package/lib/line/models/half.js +0 -315
  384. package/lib/line/shaders/half/line_half_frag.glsl +0 -53
  385. package/lib/line/shaders/half/line_half_vert.glsl +0 -169
  386. package/lib/utils/dataMappingStyle.js +0 -151
@@ -1,298 +0,0 @@
1
- import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
- import _createClass from "@babel/runtime/helpers/esm/createClass";
4
- import _inherits from "@babel/runtime/helpers/esm/inherits";
5
- import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
6
- import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
7
- import _regeneratorRuntime from "@babel/runtime/regenerator";
8
-
9
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
10
-
11
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
12
-
13
- import { AttributeType, gl } from '@antv/l7-core';
14
- import { rgb2arr } from '@antv/l7-utils';
15
- import { isNumber } from 'lodash';
16
- import BaseModel from "../../core/BaseModel";
17
- import { LineTriangulation } from "../../core/triangulation";
18
-
19
- /* babel-plugin-inline-import '../shaders/half/line_half_frag.glsl' */
20
- var line_half_frag = "#define COORDINATE_SYSTEM_LNGLAT 1.0 // mapbox\n#define COORDINATE_SYSTEM_LNGLAT_OFFSET 2.0 // mapbox offset\n#define COORDINATE_SYSTEM_VECTOR_TILE 3.0\n#define COORDINATE_SYSTEM_IDENTITY 4.0\n#define COORDINATE_SYSTEM_P20 5.0 // amap\n#define COORDINATE_SYSTEM_P20_OFFSET 6.0 // amap offset\n#define COORDINATE_SYSTEM_METER_OFFSET 7.0\n\n#define COORDINATE_SYSTEM_P20_2 8.0 // amap2.0\nuniform float u_CoordinateSystem;\nvarying vec4 v_color;\nuniform float u_arrow: 0.0;\nuniform float u_linearColor: 0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\n\n#pragma include \"picking\"\n\nvarying mat4 styleMappingMat;\nvoid main() {\n float distanceAndIndex = styleMappingMat[0][3];\n float miter = styleMappingMat[0][2];\n\n float opacity = styleMappingMat[0][0];\n float d_distance_ratio = styleMappingMat[3].r; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n\n\n if(u_arrow > 0.0 && distanceAndIndex < 2.0) { // arrow\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20 || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) { \n if(cross(vec3(styleMappingMat[1].rg, 0.0), vec3(styleMappingMat[1].ba, 0.0)).z < 0.0) { // amap\n discard;\n }\n } else { // amap2 mapbox map\n if(cross(vec3(styleMappingMat[1].rg, 0.0), vec3(styleMappingMat[1].ba, 0.0)).z > 0.0) { \n discard;\n }\n }\n } else { // line body\n if(miter < 0.0) {\n discard;\n }\n }\n\n\n if(u_linearColor == 1.0) { // \u4F7F\u7528\u6E10\u53D8\u989C\u8272\n gl_FragColor = mix(u_sourceColor, u_targetColor, d_distance_ratio);\n } else { // \u4F7F\u7528 color \u65B9\u6CD5\u4F20\u5165\u7684\u989C\u8272\n gl_FragColor = v_color;\n }\n\n gl_FragColor.a *= opacity; // \u5168\u5C40\u900F\u660E\u5EA6\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
21
-
22
- /* babel-plugin-inline-import '../shaders/half/line_half_vert.glsl' */
23
- var line_half_vert = "attribute float a_Miter;\nattribute vec4 a_Color;\nattribute vec2 a_Size;\nattribute vec3 a_Normal;\nattribute vec3 a_Position;\n\n// dash line\nattribute vec4 a_dirPoints;\nattribute vec3 a_DistanceAndIndex;\n\nuniform vec4 u_lineDir;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvarying vec4 v_color;\n\nuniform float u_linearColor: 0;\nuniform float u_arrow: 0.0;\nuniform float u_arrowHeight: 3.0;\nuniform float u_arrowWidth: 2.0;\nuniform float u_tailWidth: 1.0;\n\nuniform float u_opacity: 1.0;\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n\nvec2 calculateArrow(vec2 offset) {\n /*\n * \u5728\u652F\u6301\u7BAD\u5934\u7684\u65F6\u5019\uFF0C\u7B2C\u4E8C\u3001\u7B2C\u4E09\u7EC4\u9876\u70B9\u662F\u989D\u5916\u63D2\u5165\u7528\u4E8E\u6784\u5EFA\u9876\u70B9\u7684\n */\n float arrowFlag = -1.0;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n // \u9AD8\u5FB7 2.0 \u7684\u65CB\u8F6C\u89D2\u5EA6\u4E0D\u540C\n arrowFlag = 1.0;\n }\n float pi = arrowFlag * 3.1415926/2.;\n if(a_Miter < 0.) {\n // \u6839\u636E\u7EBF\u7684\u4E24\u4FA7\u504F\u79FB\u4E0D\u540C\u3001\u65CB\u8F6C\u7684\u65B9\u5411\u76F8\u53CD\n pi = -pi;\n }\n highp float angle_sin = sin(pi);\n highp float angle_cos = cos(pi);\n // \u8BA1\u7B97\u5782\u76F4\u4E0E\u7EBF\u65B9\u5411\u7684\u65CB\u8F6C\u77E9\u9635\n mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);\n float arrowWidth = u_arrowWidth;\n float arrowHeight = u_arrowHeight;\n\n vec2 arrowOffset = vec2(0.0);\n /*\n * a_DistanceAndIndex.y \u7528\u4E8E\u6807\u8BB0\u5F53\u524D\u9876\u70B9\u5C5E\u4E8E\u54EA\u4E00\u7EC4\uFF08\u4E24\u4E2A\u9876\u70B9\u4E00\u7EC4\uFF0C\u6784\u6210\u7EBF\u7684\u5176\u5B9E\u662F\u77E9\u5F62\uFF0C\u6700\u7B80\u9700\u8981\u56DB\u4E2A\u9876\u70B9\u3001\u4E24\u7EC4\u9876\u70B9\u6784\u6210\uFF09\n */\n if(a_DistanceAndIndex.y == 0.0) {\n // \u7BAD\u5934\u5C16\u90E8\n offset = vec2(0.0);\n } else if(a_DistanceAndIndex.y == 1.0) {\n // \u7BAD\u5934\u4E24\u4FA7\n arrowOffset = rotation_matrix*(offset * arrowHeight);\n offset += arrowOffset; // \u6CBF\u7EBF\u504F\u79FB\n offset = offset * arrowWidth; // \u5782\u76F4\u7EBF\u5411\u5916\u504F\u79FB\uFF08\u662F\u6784\u5EFA\u7BAD\u5934\u4E24\u4FA7\u7684\u9876\u70B9\uFF09\n } else if(a_DistanceAndIndex.y == 2.0 || a_DistanceAndIndex.y == 3.0 || a_DistanceAndIndex.y == 4.0) {\n // \u504F\u79FB\u5176\u4F59\u7684\u70B9\u4F4D\uFF08\u5C06\u957F\u5EA6\u8BA9\u4F4D\u7ED9\u7BAD\u5934\uFF09\n arrowOffset = rotation_matrix*(offset * arrowHeight) * arrowWidth;\n offset += arrowOffset;// \u6CBF\u7EBF\u504F\u79FB\n }\n\n return offset;\n}\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - a_Miter - a_DistanceAndIndex\n 0.0, 0.0, 0.0, 0.0, // originX - originY - vectorX - vectorY\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0 // distance_ratio/distance/pixelLen/texV\n );\n styleMappingMat[0][3] = a_DistanceAndIndex.y;\n styleMappingMat[0][2] = a_Miter;\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n\n v_color = a_Color;\n\n vec3 size = a_Miter * setPickingSize(a_Size.x) * reverse_offset_normal(a_Normal);\n \n vec2 offset = project_pixel(size.xy);\n\n // styleMappingMat[1].rg = a_Position.xy + offset;\n\n vec2 copyOffset = vec2(offset.x, offset.y);\n\n float lineDistance = a_DistanceAndIndex.x;\n float total_Distance = a_DistanceAndIndex.z;\n float currentLinePointRatio = lineDistance / total_Distance;\n \n if(u_arrow > 0.0) {\n // \u8BA1\u7B97\u7BAD\u5934\n offset = calculateArrow(offset);\n\n if(a_DistanceAndIndex.y > 4.0) {\n offset *= mix(1.0, u_tailWidth, currentLinePointRatio);\n }\n }\n\n float lineOffsetWidth = length(offset + offset * sign(a_Miter)); // \u7EBF\u6A2A\u5411\u504F\u79FB\u7684\u8DDD\u79BB\uFF08\u5411\u4E24\u4FA7\u504F\u79FB\u7684\u548C\uFF09\n float linePixelSize = project_pixel(a_Size.x) * 2.0; // \u5B9A\u70B9\u4F4D\u7F6E\u504F\u79FB\uFF0C\u6309\u5730\u56FE\u7B49\u7EA7\u7F29\u653E\u540E\u7684\u8DDD\u79BB \u5355\u4FA7 * 2\n\n // \u8BBE\u7F6E\u6570\u636E\u96C6\u7684\u53C2\u6570\n styleMappingMat[3][0] = currentLinePointRatio; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n styleMappingMat[3][1] = lineDistance; // \u5F53\u524D\u9876\u70B9\u7684\u8DDD\u79BB\n\n vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));\n\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, a_Size.y, 1.0));\n\n float h = float(a_Position.z); // \u7EBF\u9876\u70B9\u7684\u9AD8\u5EA6 - \u517C\u5BB9\u4E0D\u5B58\u5728\u7B2C\u4E09\u4E2A\u6570\u503C\u7684\u60C5\u51B5 vertex height\n float lineHeight = a_Size.y; // size \u7B2C\u4E8C\u4E2A\u53C2\u6570\u4EE3\u8868\u7684\u9AD8\u5EA6 [linewidth, lineheight]\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n lineHeight *= 0.2; // \u4FDD\u6301\u548C amap/mapbox \u4E00\u81F4\u7684\u6548\u679C\n gl_Position = u_Mvp * (vec4(project_pos.xy + offset, lineHeight, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, lineHeight, 1.0));\n }\n \n if(u_arrow > 0.0 && a_DistanceAndIndex.y < 2.0) {\n vec2 startPoint = a_dirPoints.rg;\n vec2 endPoint = a_dirPoints.ba;\n vec4 t1 = project_position(vec4(startPoint, 0, 1.0));\n vec4 t2 = project_position(vec4(endPoint, 0, 1.0));\n // TODO\uFF1A \u540E\u7EED\u4F18\u5316\u53EF\u4EE5\u628A\u4F4D\u7F6E\u8BA1\u7B97\u653E\u5728 cpu \u4E2D\u5B8C\u6210\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n vec2 p1 = (u_Mvp * vec4(t1.xy, 0.0, 1.0)).xy;\n vec2 p2 = (u_Mvp * vec4(t2.xy, 0.0, 1.0)).xy;\n styleMappingMat[1].rg = normalize(p1 - p2);\n styleMappingMat[1].ba = normalize(gl_Position.xy - p2);\n } else {\n vec2 p1 = project_common_position_to_clipspace(vec4(t1.xy, 0.0, 1.0)).xy;\n vec2 p2 = project_common_position_to_clipspace(vec4(t2.xy, 0.0, 1.0)).xy;\n styleMappingMat[1].rg = normalize(p1 - p2);\n styleMappingMat[1].ba = normalize(gl_Position.xy - p2);\n }\n }\n\n setPickingColor(a_PickingColor);\n}\n";
24
-
25
- var LineModel = /*#__PURE__*/function (_BaseModel) {
26
- _inherits(LineModel, _BaseModel);
27
-
28
- var _super = _createSuper(LineModel);
29
-
30
- function LineModel() {
31
- _classCallCheck(this, LineModel);
32
-
33
- return _super.apply(this, arguments);
34
- }
35
-
36
- _createClass(LineModel, [{
37
- key: "getUninforms",
38
- value: function getUninforms() {
39
- var _ref = this.layer.getLayerConfig(),
40
- _ref$opacity = _ref.opacity,
41
- opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
42
- sourceColor = _ref.sourceColor,
43
- targetColor = _ref.targetColor,
44
- _ref$arrow = _ref.arrow,
45
- arrow = _ref$arrow === void 0 ? {
46
- enable: false,
47
- arrowWidth: 2,
48
- arrowHeight: 3,
49
- tailWidth: 1
50
- } : _ref$arrow; // 转化渐变色
51
-
52
-
53
- var useLinearColor = 0; // 默认不生效
54
-
55
- var sourceColorArr = [0, 0, 0, 0];
56
- var targetColorArr = [0, 0, 0, 0];
57
-
58
- if (sourceColor && targetColor) {
59
- sourceColorArr = rgb2arr(sourceColor);
60
- targetColorArr = rgb2arr(targetColor);
61
- useLinearColor = 1;
62
- }
63
-
64
- if (this.dataTextureTest && this.dataTextureNeedUpdate({
65
- opacity: opacity
66
- })) {
67
- this.judgeStyleAttributes({
68
- opacity: opacity
69
- });
70
- var encodeData = this.layer.getEncodedData();
71
-
72
- var _this$calDataFrame = this.calDataFrame(this.cellLength, encodeData, this.cellProperties),
73
- data = _this$calDataFrame.data,
74
- width = _this$calDataFrame.width,
75
- height = _this$calDataFrame.height;
76
-
77
- this.rowCount = height; // 当前数据纹理有多少行
78
-
79
- this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
80
- flipY: true,
81
- data: data,
82
- format: gl.LUMINANCE,
83
- type: gl.FLOAT,
84
- width: width,
85
- height: height
86
- }) : this.createTexture2D({
87
- flipY: true,
88
- data: [1],
89
- format: gl.LUMINANCE,
90
- type: gl.FLOAT,
91
- width: 1,
92
- height: 1
93
- });
94
- }
95
-
96
- return {
97
- u_dataTexture: this.dataTexture,
98
- // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]
99
- u_cellTypeLayout: this.getCellTypeLayout(),
100
- u_opacity: isNumber(opacity) ? opacity : 1.0,
101
- // 渐变色支持参数
102
- u_linearColor: useLinearColor,
103
- u_sourceColor: sourceColorArr,
104
- u_targetColor: targetColorArr,
105
- // arrow
106
- u_arrow: Number(arrow.enable),
107
- u_arrowHeight: arrow.arrowHeight || 3,
108
- u_arrowWidth: arrow.arrowWidth || 2,
109
- u_tailWidth: arrow.tailWidth === undefined ? 1 : arrow.tailWidth
110
- };
111
- }
112
- }, {
113
- key: "initModels",
114
- value: function () {
115
- var _initModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
116
- return _regeneratorRuntime.wrap(function _callee$(_context) {
117
- while (1) {
118
- switch (_context.prev = _context.next) {
119
- case 0:
120
- return _context.abrupt("return", this.buildModels());
121
-
122
- case 1:
123
- case "end":
124
- return _context.stop();
125
- }
126
- }
127
- }, _callee, this);
128
- }));
129
-
130
- function initModels() {
131
- return _initModels.apply(this, arguments);
132
- }
133
-
134
- return initModels;
135
- }()
136
- }, {
137
- key: "clearModels",
138
- value: function clearModels() {
139
- var _this$dataTexture;
140
-
141
- (_this$dataTexture = this.dataTexture) === null || _this$dataTexture === void 0 ? void 0 : _this$dataTexture.destroy();
142
- }
143
- }, {
144
- key: "buildModels",
145
- value: function () {
146
- var _buildModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
147
- var _ref2, _ref2$depth, depth, _this$getShaders, frag, vert, model;
148
-
149
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
150
- while (1) {
151
- switch (_context2.prev = _context2.next) {
152
- case 0:
153
- _ref2 = this.layer.getLayerConfig(), _ref2$depth = _ref2.depth, depth = _ref2$depth === void 0 ? false : _ref2$depth;
154
- _this$getShaders = this.getShaders(), frag = _this$getShaders.frag, vert = _this$getShaders.vert;
155
- this.layer.triangulation = LineTriangulation;
156
- _context2.next = 5;
157
- return this.layer.buildLayerModel({
158
- moduleName: 'lineHalf',
159
- vertexShader: vert,
160
- fragmentShader: frag,
161
- triangulation: LineTriangulation,
162
- depth: {
163
- enable: depth
164
- }
165
- });
166
-
167
- case 5:
168
- model = _context2.sent;
169
- return _context2.abrupt("return", [model]);
170
-
171
- case 7:
172
- case "end":
173
- return _context2.stop();
174
- }
175
- }
176
- }, _callee2, this);
177
- }));
178
-
179
- function buildModels() {
180
- return _buildModels.apply(this, arguments);
181
- }
182
-
183
- return buildModels;
184
- }()
185
- /**
186
- * 根据参数获取不同的 shader 代码
187
- * @returns
188
- */
189
-
190
- }, {
191
- key: "getShaders",
192
- value: function getShaders() {
193
- return {
194
- frag: line_half_frag,
195
- vert: line_half_vert,
196
- type: 'normal'
197
- };
198
- }
199
- }, {
200
- key: "registerBuiltinAttributes",
201
- value: function registerBuiltinAttributes() {
202
- this.styleAttributeService.registerStyleAttribute({
203
- name: 'distanceAndIndex',
204
- type: AttributeType.Attribute,
205
- descriptor: {
206
- name: 'a_DistanceAndIndex',
207
- buffer: {
208
- // give the WebGL driver a hint that this buffer may change
209
- usage: gl.STATIC_DRAW,
210
- data: [],
211
- type: gl.FLOAT
212
- },
213
- size: 3,
214
- update: function update(feature, featureIdx, vertex, attributeIdx, normal, vertexIndex) {
215
- return vertexIndex === undefined ? [vertex[3], 10, vertex[5]] : [vertex[3], vertexIndex, vertex[5]];
216
- }
217
- }
218
- });
219
- this.styleAttributeService.registerStyleAttribute({
220
- name: 'dirPoints',
221
- type: AttributeType.Attribute,
222
- descriptor: {
223
- name: 'a_dirPoints',
224
- buffer: {
225
- // give the WebGL driver a hint that this buffer may change
226
- usage: gl.STATIC_DRAW,
227
- data: [],
228
- type: gl.FLOAT
229
- },
230
- size: 4,
231
- update: function update(feature) {
232
- var startPoint = feature.coordinates[0] || [0, 0];
233
- var endPoint = feature.coordinates[3] || [0, 0];
234
- return [startPoint[0], startPoint[1], endPoint[0], endPoint[1]];
235
- }
236
- }
237
- });
238
- this.styleAttributeService.registerStyleAttribute({
239
- name: 'size',
240
- type: AttributeType.Attribute,
241
- descriptor: {
242
- name: 'a_Size',
243
- buffer: {
244
- // give the WebGL driver a hint that this buffer may change
245
- usage: gl.DYNAMIC_DRAW,
246
- data: [],
247
- type: gl.FLOAT
248
- },
249
- size: 2,
250
- update: function update(feature) {
251
- var _feature$size = feature.size,
252
- size = _feature$size === void 0 ? 1 : _feature$size;
253
- return Array.isArray(size) ? [size[0], size[1]] : [size, 0];
254
- }
255
- }
256
- }); // point layer size;
257
-
258
- this.styleAttributeService.registerStyleAttribute({
259
- name: 'normal',
260
- type: AttributeType.Attribute,
261
- descriptor: {
262
- name: 'a_Normal',
263
- buffer: {
264
- // give the WebGL driver a hint that this buffer may change
265
- usage: gl.STATIC_DRAW,
266
- data: [],
267
- type: gl.FLOAT
268
- },
269
- size: 3,
270
- update: function update(feature, featureIdx, vertex, attributeIdx, normal) {
271
- return normal;
272
- }
273
- }
274
- });
275
- this.styleAttributeService.registerStyleAttribute({
276
- name: 'miter',
277
- type: AttributeType.Attribute,
278
- descriptor: {
279
- name: 'a_Miter',
280
- buffer: {
281
- // give the WebGL driver a hint that this buffer may change
282
- usage: gl.STATIC_DRAW,
283
- data: [],
284
- type: gl.FLOAT
285
- },
286
- size: 1,
287
- update: function update(feature, featureIdx, vertex) {
288
- return [vertex[4]];
289
- }
290
- }
291
- });
292
- }
293
- }]);
294
-
295
- return LineModel;
296
- }(BaseModel);
297
-
298
- export { LineModel as default };
@@ -1,53 +0,0 @@
1
- #define COORDINATE_SYSTEM_LNGLAT 1.0 // mapbox
2
- #define COORDINATE_SYSTEM_LNGLAT_OFFSET 2.0 // mapbox offset
3
- #define COORDINATE_SYSTEM_VECTOR_TILE 3.0
4
- #define COORDINATE_SYSTEM_IDENTITY 4.0
5
- #define COORDINATE_SYSTEM_P20 5.0 // amap
6
- #define COORDINATE_SYSTEM_P20_OFFSET 6.0 // amap offset
7
- #define COORDINATE_SYSTEM_METER_OFFSET 7.0
8
-
9
- #define COORDINATE_SYSTEM_P20_2 8.0 // amap2.0
10
- uniform float u_CoordinateSystem;
11
- varying vec4 v_color;
12
- uniform float u_arrow: 0.0;
13
- uniform float u_linearColor: 0;
14
- uniform vec4 u_sourceColor;
15
- uniform vec4 u_targetColor;
16
-
17
- #pragma include "picking"
18
-
19
- varying mat4 styleMappingMat;
20
- void main() {
21
- float distanceAndIndex = styleMappingMat[0][3];
22
- float miter = styleMappingMat[0][2];
23
-
24
- float opacity = styleMappingMat[0][0];
25
- float d_distance_ratio = styleMappingMat[3].r; // 当前点位距离占线总长的比例
26
-
27
-
28
- if(u_arrow > 0.0 && distanceAndIndex < 2.0) { // arrow
29
- if(u_CoordinateSystem == COORDINATE_SYSTEM_P20 || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {
30
- if(cross(vec3(styleMappingMat[1].rg, 0.0), vec3(styleMappingMat[1].ba, 0.0)).z < 0.0) { // amap
31
- discard;
32
- }
33
- } else { // amap2 mapbox map
34
- if(cross(vec3(styleMappingMat[1].rg, 0.0), vec3(styleMappingMat[1].ba, 0.0)).z > 0.0) {
35
- discard;
36
- }
37
- }
38
- } else { // line body
39
- if(miter < 0.0) {
40
- discard;
41
- }
42
- }
43
-
44
-
45
- if(u_linearColor == 1.0) { // 使用渐变颜色
46
- gl_FragColor = mix(u_sourceColor, u_targetColor, d_distance_ratio);
47
- } else { // 使用 color 方法传入的颜色
48
- gl_FragColor = v_color;
49
- }
50
-
51
- gl_FragColor.a *= opacity; // 全局透明度
52
- gl_FragColor = filterColor(gl_FragColor);
53
- }
@@ -1,169 +0,0 @@
1
- attribute float a_Miter;
2
- attribute vec4 a_Color;
3
- attribute vec2 a_Size;
4
- attribute vec3 a_Normal;
5
- attribute vec3 a_Position;
6
-
7
- // dash line
8
- attribute vec4 a_dirPoints;
9
- attribute vec3 a_DistanceAndIndex;
10
-
11
- uniform vec4 u_lineDir;
12
-
13
- uniform mat4 u_ModelMatrix;
14
- uniform mat4 u_Mvp;
15
-
16
- #pragma include "projection"
17
- #pragma include "picking"
18
-
19
- varying vec4 v_color;
20
-
21
- uniform float u_linearColor: 0;
22
- uniform float u_arrow: 0.0;
23
- uniform float u_arrowHeight: 3.0;
24
- uniform float u_arrowWidth: 2.0;
25
- uniform float u_tailWidth: 1.0;
26
-
27
- uniform float u_opacity: 1.0;
28
- varying mat4 styleMappingMat; // 用于将在顶点着色器中计算好的样式值传递给片元
29
-
30
- #pragma include "styleMapping"
31
- #pragma include "styleMappingCalOpacity"
32
-
33
- vec2 calculateArrow(vec2 offset) {
34
- /*
35
- * 在支持箭头的时候,第二、第三组顶点是额外插入用于构建顶点的
36
- */
37
- float arrowFlag = -1.0;
38
- if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {
39
- // 高德 2.0 的旋转角度不同
40
- arrowFlag = 1.0;
41
- }
42
- float pi = arrowFlag * 3.1415926/2.;
43
- if(a_Miter < 0.) {
44
- // 根据线的两侧偏移不同、旋转的方向相反
45
- pi = -pi;
46
- }
47
- highp float angle_sin = sin(pi);
48
- highp float angle_cos = cos(pi);
49
- // 计算垂直与线方向的旋转矩阵
50
- mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);
51
- float arrowWidth = u_arrowWidth;
52
- float arrowHeight = u_arrowHeight;
53
-
54
- vec2 arrowOffset = vec2(0.0);
55
- /*
56
- * a_DistanceAndIndex.y 用于标记当前顶点属于哪一组(两个顶点一组,构成线的其实是矩形,最简需要四个顶点、两组顶点构成)
57
- */
58
- if(a_DistanceAndIndex.y == 0.0) {
59
- // 箭头尖部
60
- offset = vec2(0.0);
61
- } else if(a_DistanceAndIndex.y == 1.0) {
62
- // 箭头两侧
63
- arrowOffset = rotation_matrix*(offset * arrowHeight);
64
- offset += arrowOffset; // 沿线偏移
65
- offset = offset * arrowWidth; // 垂直线向外偏移(是构建箭头两侧的顶点)
66
- } else if(a_DistanceAndIndex.y == 2.0 || a_DistanceAndIndex.y == 3.0 || a_DistanceAndIndex.y == 4.0) {
67
- // 偏移其余的点位(将长度让位给箭头)
68
- arrowOffset = rotation_matrix*(offset * arrowHeight) * arrowWidth;
69
- offset += arrowOffset;// 沿线偏移
70
- }
71
-
72
- return offset;
73
- }
74
-
75
- void main() {
76
- // cal style mapping - 数据纹理映射部分的计算
77
- styleMappingMat = mat4(
78
- 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - a_Miter - a_DistanceAndIndex
79
- 0.0, 0.0, 0.0, 0.0, // originX - originY - vectorX - vectorY
80
- 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]
81
- 0.0, 0.0, 0.0, 0.0 // distance_ratio/distance/pixelLen/texV
82
- );
83
- styleMappingMat[0][3] = a_DistanceAndIndex.y;
84
- styleMappingMat[0][2] = a_Miter;
85
-
86
- float rowCount = u_cellTypeLayout[0][0]; // 当前的数据纹理有几行
87
- float columnCount = u_cellTypeLayout[0][1]; // 当看到数据纹理有几列
88
- float columnWidth = 1.0/columnCount; // 列宽
89
- float rowHeight = 1.0/rowCount; // 行高
90
- float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets
91
- float id = a_vertexId; // 第n个顶点
92
- float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // 起始点在第几行
93
- float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // 起始点在第几列
94
-
95
- // cell 固定顺序 opacity -> strokeOpacity -> strokeWidth -> stroke ...
96
- // 按顺序从 cell 中取值、若没有则自动往下取值
97
- float textureOffset = 0.0; // 在 cell 中取值的偏移量
98
-
99
- vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);
100
- styleMappingMat[0][0] = opacityAndOffset.r;
101
- textureOffset = opacityAndOffset.g;
102
- // cal style mapping - 数据纹理映射部分的计算
103
-
104
-
105
- v_color = a_Color;
106
-
107
- vec3 size = a_Miter * setPickingSize(a_Size.x) * reverse_offset_normal(a_Normal);
108
-
109
- vec2 offset = project_pixel(size.xy);
110
-
111
- // styleMappingMat[1].rg = a_Position.xy + offset;
112
-
113
- vec2 copyOffset = vec2(offset.x, offset.y);
114
-
115
- float lineDistance = a_DistanceAndIndex.x;
116
- float total_Distance = a_DistanceAndIndex.z;
117
- float currentLinePointRatio = lineDistance / total_Distance;
118
-
119
- if(u_arrow > 0.0) {
120
- // 计算箭头
121
- offset = calculateArrow(offset);
122
-
123
- if(a_DistanceAndIndex.y > 4.0) {
124
- offset *= mix(1.0, u_tailWidth, currentLinePointRatio);
125
- }
126
- }
127
-
128
- float lineOffsetWidth = length(offset + offset * sign(a_Miter)); // 线横向偏移的距离(向两侧偏移的和)
129
- float linePixelSize = project_pixel(a_Size.x) * 2.0; // 定点位置偏移,按地图等级缩放后的距离 单侧 * 2
130
-
131
- // 设置数据集的参数
132
- styleMappingMat[3][0] = currentLinePointRatio; // 当前点位距离占线总长的比例
133
- styleMappingMat[3][1] = lineDistance; // 当前顶点的距离
134
-
135
- vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));
136
-
137
- // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, a_Size.y, 1.0));
138
-
139
- float h = float(a_Position.z); // 线顶点的高度 - 兼容不存在第三个数值的情况 vertex height
140
- float lineHeight = a_Size.y; // size 第二个参数代表的高度 [linewidth, lineheight]
141
-
142
- if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
143
- lineHeight *= 0.2; // 保持和 amap/mapbox 一致的效果
144
- gl_Position = u_Mvp * (vec4(project_pos.xy + offset, lineHeight, 1.0));
145
- } else {
146
- gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, lineHeight, 1.0));
147
- }
148
-
149
- if(u_arrow > 0.0 && a_DistanceAndIndex.y < 2.0) {
150
- vec2 startPoint = a_dirPoints.rg;
151
- vec2 endPoint = a_dirPoints.ba;
152
- vec4 t1 = project_position(vec4(startPoint, 0, 1.0));
153
- vec4 t2 = project_position(vec4(endPoint, 0, 1.0));
154
- // TODO: 后续优化可以把位置计算放在 cpu 中完成
155
- if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
156
- vec2 p1 = (u_Mvp * vec4(t1.xy, 0.0, 1.0)).xy;
157
- vec2 p2 = (u_Mvp * vec4(t2.xy, 0.0, 1.0)).xy;
158
- styleMappingMat[1].rg = normalize(p1 - p2);
159
- styleMappingMat[1].ba = normalize(gl_Position.xy - p2);
160
- } else {
161
- vec2 p1 = project_common_position_to_clipspace(vec4(t1.xy, 0.0, 1.0)).xy;
162
- vec2 p2 = project_common_position_to_clipspace(vec4(t2.xy, 0.0, 1.0)).xy;
163
- styleMappingMat[1].rg = normalize(p1 - p2);
164
- styleMappingMat[1].ba = normalize(gl_Position.xy - p2);
165
- }
166
- }
167
-
168
- setPickingColor(a_PickingColor);
169
- }
@@ -1,31 +0,0 @@
1
- import { ILayer } from '@antv/l7-core';
2
- /**
3
- * 该文件中的工具方法主要用于对 style 中的属性进行 数据映射
4
- */
5
- interface IConfigToUpdate {
6
- thetaOffset?: any;
7
- opacity?: any;
8
- strokeOpacity?: any;
9
- stroke?: any;
10
- strokeWidth?: any;
11
- offsets?: any;
12
- textOffset?: any;
13
- }
14
- /**
15
- * 当样式发生变化时判断是否需要进行数据映射
16
- * @param configToUpdate
17
- * @param layer
18
- */
19
- declare function styleDataMapping(configToUpdate: IConfigToUpdate, layer: any): void;
20
- /**
21
- * 根据传入参数 float 的类型和值做相应的操作
22
- */
23
- declare function floatStyleMapping(fieldName: string, layer: ILayer, styleFloat: any): void;
24
- /**
25
- * 根据传入参数 stroke / color 的类型和值做相应的操作
26
- * @param fieldName
27
- * @param layer
28
- * @param styleColor
29
- */
30
- declare function colorStyleMapping(fieldName: string, layer: ILayer, styleColor: any): void;
31
- export { styleDataMapping, floatStyleMapping, colorStyleMapping };