@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,147 +0,0 @@
1
- import { isFunction, isNumber, isString } from 'lodash';
2
- /**
3
- * 该文件中的工具方法主要用于对 style 中的属性进行 数据映射
4
- */
5
-
6
- /**
7
- * 当 style 中使用的 opacity 不是常数的时候根据数据进行映射
8
- * @param field
9
- * @param values
10
- * @param updateOptions
11
- */
12
- function registerStyleAttribute(fieldName, layer, field, values, updateOptions) {
13
- layer.updateStyleAttribute(fieldName, field, values, updateOptions);
14
- }
15
- /**
16
- * 当样式发生变化时判断是否需要进行数据映射
17
- * @param configToUpdate
18
- * @param layer
19
- */
20
-
21
-
22
- function styleDataMapping(configToUpdate, layer) {
23
- // 瓦片图层不需要进行样式数据映射
24
- if (layer.tileLayer || layer.isTileLayer) {
25
- return;
26
- }
27
-
28
- if (configToUpdate.opacity) {
29
- // 处理 style 中 opacity 属性的数据映射
30
- floatStyleMapping('opacity', layer, configToUpdate.opacity);
31
- }
32
-
33
- if (configToUpdate.strokeWidth) {
34
- // 处理 style 中 strokeWidth 属性的数据映射
35
- floatStyleMapping('strokeWidth', layer, configToUpdate.strokeWidth);
36
- }
37
-
38
- if (configToUpdate.strokeOpacity) {
39
- // 处理 style 中 strokeOpacity 属性的数据映射
40
- floatStyleMapping('strokeOpacity', layer, configToUpdate.strokeOpacity);
41
- }
42
-
43
- if (configToUpdate.stroke) {
44
- // 处理 style 中 stroke (strokeColor) 属性的数据映射
45
- colorStyleMapping('stroke', layer, configToUpdate.stroke);
46
- }
47
-
48
- if (configToUpdate.offsets) {
49
- // 处理 style 中 offsets 属性的数据映射
50
- offsetStyleMapping('offsets', layer, configToUpdate.offsets);
51
- }
52
-
53
- if (configToUpdate.textOffset) {
54
- // 处理 style 中 textOffset 属性的数据映射
55
- offsetStyleMapping('textOffset', layer, configToUpdate.textOffset);
56
- }
57
-
58
- if (configToUpdate.thetaOffset) {
59
- // 处理 style 中 thetaOffset 属性的数据映射
60
- floatStyleMapping('thetaOffset', layer, configToUpdate.thetaOffset);
61
- }
62
- }
63
- /**
64
- * 根据传入参数 float 的类型和值做相应的操作
65
- */
66
-
67
-
68
- function floatStyleMapping(fieldName, layer, styleFloat) {
69
- if (isString(styleFloat)) {
70
- // 如果传入的 styleFloat 是 string 类型,那么就认为其对应的是传入数据的字段
71
- registerStyleAttribute(fieldName, layer, styleFloat, function (value) {
72
- return value;
73
- });
74
- } else if (isNumber(styleFloat)) {// 传入 number、默认值处理
75
- // registerStyleAttribute(fieldName, layer, [styleFloat], undefined);
76
- } else if (Array.isArray(styleFloat) && styleFloat.length === 2) {
77
- // 传入的 styleFloat 是长度为 2 的数组
78
- if (isString(styleFloat[0]) && isFunction(styleFloat[1])) {
79
- // 字段回调函数 [string, callback]
80
- registerStyleAttribute(fieldName, layer, styleFloat[0], styleFloat[1]);
81
- } else if (isString(styleFloat[0]) && Array.isArray(styleFloat[1]) && isNumber(styleFloat[1][0]) && isNumber(styleFloat[1][1])) {
82
- // 字段映射 [string, [start: number, end: number]]
83
- registerStyleAttribute(fieldName, layer, styleFloat[0], styleFloat[1]);
84
- } else {
85
- // 兼容
86
- registerStyleAttribute(fieldName, layer, [1.0], undefined);
87
- }
88
- } else {
89
- // 兼容
90
- registerStyleAttribute(fieldName, layer, [1.0], undefined);
91
- }
92
- }
93
- /**
94
- * 根据传入参数 offsets 的类型和值做相应的操作
95
- * @param fieldName
96
- * @param layer
97
- * @param styleOffsets
98
- */
99
-
100
-
101
- function offsetStyleMapping(fieldName, layer, styleOffsets) {
102
- if (isString(styleOffsets)) {
103
- // 如果传入的 styleOffsets 是 string 类型,那么就认为其对应的是传入数据的字段
104
- registerStyleAttribute(fieldName, layer, styleOffsets, function (value) {
105
- return value;
106
- });
107
- } else if (Array.isArray(styleOffsets) && styleOffsets.length === 2 && isString(styleOffsets[0]) && isFunction(styleOffsets[1])) {
108
- // 字段回调函数 [string, callback]
109
- registerStyleAttribute(fieldName, layer, styleOffsets[0], styleOffsets[1]);
110
- } else if (Array.isArray(styleOffsets) && styleOffsets.length === 2 && isNumber(styleOffsets[0]) && isNumber(styleOffsets[1])) {
111
- // 字段映射 [string, [start: number, end: number]]
112
- registerStyleAttribute(fieldName, layer, styleOffsets, undefined);
113
- } else {
114
- // 兼容
115
- registerStyleAttribute(fieldName, layer, [0, 0], undefined);
116
- }
117
- }
118
- /**
119
- * 根据传入参数 stroke / color 的类型和值做相应的操作
120
- * @param fieldName
121
- * @param layer
122
- * @param styleColor
123
- */
124
-
125
-
126
- function colorStyleMapping(fieldName, layer, styleColor) {
127
- if (isString(styleColor)) {// 如果传入的 styleColor 是 string 类型,那么就认为其是颜色值
128
- // registerStyleAttribute(fieldName, layer, styleColor, undefined);
129
- } else if (Array.isArray(styleColor) && styleColor.length === 2) {
130
- // 传入的 styleColor 是长度为 2 的数组
131
- if (isString(styleColor[0]) && isFunction(styleColor[1])) {
132
- // 字段回调函数 [string, callback]
133
- registerStyleAttribute(fieldName, layer, styleColor[0], styleColor[1]);
134
- } else if (isString(styleColor[0]) && Array.isArray(styleColor[1]) && styleColor[1].length > 0) {
135
- // 字段映射 [string, [start: string, end: string]]
136
- registerStyleAttribute(fieldName, layer, styleColor[0], styleColor[1]);
137
- } else {
138
- // 兼容
139
- registerStyleAttribute(fieldName, layer, '#fff', undefined);
140
- }
141
- } else {
142
- // 兼容
143
- registerStyleAttribute(fieldName, layer, '#fff', undefined);
144
- }
145
- }
146
-
147
- export { styleDataMapping, floatStyleMapping, colorStyleMapping };
@@ -1,315 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = void 0;
9
-
10
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
-
12
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
-
14
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
15
-
16
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
17
-
18
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
19
-
20
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
21
-
22
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
23
-
24
- var _l7Core = require("@antv/l7-core");
25
-
26
- var _l7Utils = require("@antv/l7-utils");
27
-
28
- var _lodash = require("lodash");
29
-
30
- var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
31
-
32
- var _triangulation = require("../../core/triangulation");
33
-
34
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
35
-
36
- 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; } }
37
-
38
- /* babel-plugin-inline-import '../shaders/half/line_half_frag.glsl' */
39
- 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";
40
-
41
- /* babel-plugin-inline-import '../shaders/half/line_half_vert.glsl' */
42
- 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";
43
-
44
- var LineModel = /*#__PURE__*/function (_BaseModel) {
45
- (0, _inherits2.default)(LineModel, _BaseModel);
46
-
47
- var _super = _createSuper(LineModel);
48
-
49
- function LineModel() {
50
- (0, _classCallCheck2.default)(this, LineModel);
51
- return _super.apply(this, arguments);
52
- }
53
-
54
- (0, _createClass2.default)(LineModel, [{
55
- key: "getUninforms",
56
- value: function getUninforms() {
57
- var _ref = this.layer.getLayerConfig(),
58
- _ref$opacity = _ref.opacity,
59
- opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
60
- sourceColor = _ref.sourceColor,
61
- targetColor = _ref.targetColor,
62
- _ref$arrow = _ref.arrow,
63
- arrow = _ref$arrow === void 0 ? {
64
- enable: false,
65
- arrowWidth: 2,
66
- arrowHeight: 3,
67
- tailWidth: 1
68
- } : _ref$arrow; // 转化渐变色
69
-
70
-
71
- var useLinearColor = 0; // 默认不生效
72
-
73
- var sourceColorArr = [0, 0, 0, 0];
74
- var targetColorArr = [0, 0, 0, 0];
75
-
76
- if (sourceColor && targetColor) {
77
- sourceColorArr = (0, _l7Utils.rgb2arr)(sourceColor);
78
- targetColorArr = (0, _l7Utils.rgb2arr)(targetColor);
79
- useLinearColor = 1;
80
- }
81
-
82
- if (this.dataTextureTest && this.dataTextureNeedUpdate({
83
- opacity: opacity
84
- })) {
85
- this.judgeStyleAttributes({
86
- opacity: opacity
87
- });
88
- var encodeData = this.layer.getEncodedData();
89
-
90
- var _this$calDataFrame = this.calDataFrame(this.cellLength, encodeData, this.cellProperties),
91
- data = _this$calDataFrame.data,
92
- width = _this$calDataFrame.width,
93
- height = _this$calDataFrame.height;
94
-
95
- this.rowCount = height; // 当前数据纹理有多少行
96
-
97
- this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
98
- flipY: true,
99
- data: data,
100
- format: _l7Core.gl.LUMINANCE,
101
- type: _l7Core.gl.FLOAT,
102
- width: width,
103
- height: height
104
- }) : this.createTexture2D({
105
- flipY: true,
106
- data: [1],
107
- format: _l7Core.gl.LUMINANCE,
108
- type: _l7Core.gl.FLOAT,
109
- width: 1,
110
- height: 1
111
- });
112
- }
113
-
114
- return {
115
- u_dataTexture: this.dataTexture,
116
- // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]
117
- u_cellTypeLayout: this.getCellTypeLayout(),
118
- u_opacity: (0, _lodash.isNumber)(opacity) ? opacity : 1.0,
119
- // 渐变色支持参数
120
- u_linearColor: useLinearColor,
121
- u_sourceColor: sourceColorArr,
122
- u_targetColor: targetColorArr,
123
- // arrow
124
- u_arrow: Number(arrow.enable),
125
- u_arrowHeight: arrow.arrowHeight || 3,
126
- u_arrowWidth: arrow.arrowWidth || 2,
127
- u_tailWidth: arrow.tailWidth === undefined ? 1 : arrow.tailWidth
128
- };
129
- }
130
- }, {
131
- key: "initModels",
132
- value: function () {
133
- var _initModels = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
134
- return _regenerator.default.wrap(function _callee$(_context) {
135
- while (1) {
136
- switch (_context.prev = _context.next) {
137
- case 0:
138
- return _context.abrupt("return", this.buildModels());
139
-
140
- case 1:
141
- case "end":
142
- return _context.stop();
143
- }
144
- }
145
- }, _callee, this);
146
- }));
147
-
148
- function initModels() {
149
- return _initModels.apply(this, arguments);
150
- }
151
-
152
- return initModels;
153
- }()
154
- }, {
155
- key: "clearModels",
156
- value: function clearModels() {
157
- var _this$dataTexture;
158
-
159
- (_this$dataTexture = this.dataTexture) === null || _this$dataTexture === void 0 ? void 0 : _this$dataTexture.destroy();
160
- }
161
- }, {
162
- key: "buildModels",
163
- value: function () {
164
- var _buildModels = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
165
- var _ref2, _ref2$depth, depth, _this$getShaders, frag, vert, model;
166
-
167
- return _regenerator.default.wrap(function _callee2$(_context2) {
168
- while (1) {
169
- switch (_context2.prev = _context2.next) {
170
- case 0:
171
- _ref2 = this.layer.getLayerConfig(), _ref2$depth = _ref2.depth, depth = _ref2$depth === void 0 ? false : _ref2$depth;
172
- _this$getShaders = this.getShaders(), frag = _this$getShaders.frag, vert = _this$getShaders.vert;
173
- this.layer.triangulation = _triangulation.LineTriangulation;
174
- _context2.next = 5;
175
- return this.layer.buildLayerModel({
176
- moduleName: 'lineHalf',
177
- vertexShader: vert,
178
- fragmentShader: frag,
179
- triangulation: _triangulation.LineTriangulation,
180
- depth: {
181
- enable: depth
182
- }
183
- });
184
-
185
- case 5:
186
- model = _context2.sent;
187
- return _context2.abrupt("return", [model]);
188
-
189
- case 7:
190
- case "end":
191
- return _context2.stop();
192
- }
193
- }
194
- }, _callee2, this);
195
- }));
196
-
197
- function buildModels() {
198
- return _buildModels.apply(this, arguments);
199
- }
200
-
201
- return buildModels;
202
- }()
203
- /**
204
- * 根据参数获取不同的 shader 代码
205
- * @returns
206
- */
207
-
208
- }, {
209
- key: "getShaders",
210
- value: function getShaders() {
211
- return {
212
- frag: line_half_frag,
213
- vert: line_half_vert,
214
- type: 'normal'
215
- };
216
- }
217
- }, {
218
- key: "registerBuiltinAttributes",
219
- value: function registerBuiltinAttributes() {
220
- this.styleAttributeService.registerStyleAttribute({
221
- name: 'distanceAndIndex',
222
- type: _l7Core.AttributeType.Attribute,
223
- descriptor: {
224
- name: 'a_DistanceAndIndex',
225
- buffer: {
226
- // give the WebGL driver a hint that this buffer may change
227
- usage: _l7Core.gl.STATIC_DRAW,
228
- data: [],
229
- type: _l7Core.gl.FLOAT
230
- },
231
- size: 3,
232
- update: function update(feature, featureIdx, vertex, attributeIdx, normal, vertexIndex) {
233
- return vertexIndex === undefined ? [vertex[3], 10, vertex[5]] : [vertex[3], vertexIndex, vertex[5]];
234
- }
235
- }
236
- });
237
- this.styleAttributeService.registerStyleAttribute({
238
- name: 'dirPoints',
239
- type: _l7Core.AttributeType.Attribute,
240
- descriptor: {
241
- name: 'a_dirPoints',
242
- buffer: {
243
- // give the WebGL driver a hint that this buffer may change
244
- usage: _l7Core.gl.STATIC_DRAW,
245
- data: [],
246
- type: _l7Core.gl.FLOAT
247
- },
248
- size: 4,
249
- update: function update(feature) {
250
- var startPoint = feature.coordinates[0] || [0, 0];
251
- var endPoint = feature.coordinates[3] || [0, 0];
252
- return [startPoint[0], startPoint[1], endPoint[0], endPoint[1]];
253
- }
254
- }
255
- });
256
- this.styleAttributeService.registerStyleAttribute({
257
- name: 'size',
258
- type: _l7Core.AttributeType.Attribute,
259
- descriptor: {
260
- name: 'a_Size',
261
- buffer: {
262
- // give the WebGL driver a hint that this buffer may change
263
- usage: _l7Core.gl.DYNAMIC_DRAW,
264
- data: [],
265
- type: _l7Core.gl.FLOAT
266
- },
267
- size: 2,
268
- update: function update(feature) {
269
- var _feature$size = feature.size,
270
- size = _feature$size === void 0 ? 1 : _feature$size;
271
- return Array.isArray(size) ? [size[0], size[1]] : [size, 0];
272
- }
273
- }
274
- }); // point layer size;
275
-
276
- this.styleAttributeService.registerStyleAttribute({
277
- name: 'normal',
278
- type: _l7Core.AttributeType.Attribute,
279
- descriptor: {
280
- name: 'a_Normal',
281
- buffer: {
282
- // give the WebGL driver a hint that this buffer may change
283
- usage: _l7Core.gl.STATIC_DRAW,
284
- data: [],
285
- type: _l7Core.gl.FLOAT
286
- },
287
- size: 3,
288
- update: function update(feature, featureIdx, vertex, attributeIdx, normal) {
289
- return normal;
290
- }
291
- }
292
- });
293
- this.styleAttributeService.registerStyleAttribute({
294
- name: 'miter',
295
- type: _l7Core.AttributeType.Attribute,
296
- descriptor: {
297
- name: 'a_Miter',
298
- buffer: {
299
- // give the WebGL driver a hint that this buffer may change
300
- usage: _l7Core.gl.STATIC_DRAW,
301
- data: [],
302
- type: _l7Core.gl.FLOAT
303
- },
304
- size: 1,
305
- update: function update(feature, featureIdx, vertex) {
306
- return [vertex[4]];
307
- }
308
- }
309
- });
310
- }
311
- }]);
312
- return LineModel;
313
- }(_BaseModel2.default);
314
-
315
- exports.default = LineModel;
@@ -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
- }