@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,3 +1,4 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
1
2
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
3
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
4
  import _createClass from "@babel/runtime/helpers/esm/createClass";
@@ -7,38 +8,28 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConst
7
8
  import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
8
9
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
9
10
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
10
-
11
11
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
12
-
13
12
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
14
-
15
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
16
-
13
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
17
14
  import _regeneratorRuntime from "@babel/runtime/regenerator";
18
-
19
15
  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); }; }
20
-
21
16
  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; } }
22
-
23
17
  import { AttributeType, gl } from '@antv/l7-core';
24
- import { boundsContains, calculateCentroid, padBounds } from '@antv/l7-utils';
25
- import { isEqual, isNumber } from 'lodash';
18
+ import { boundsContains, calculateCentroid, padBounds, rgb2arr } from '@antv/l7-utils';
19
+ import { isEqual } from 'lodash';
26
20
  import BaseModel from "../../core/BaseModel";
27
21
  import CollisionIndex from "../../utils/collision-index";
28
22
  import { getGlyphQuads, shapeText } from "../../utils/symbol-layout";
29
-
30
23
  /* babel-plugin-inline-import '../shaders/text_frag.glsl' */
31
- var textFrag = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 48.0\nuniform sampler2D u_sdf_map;\nuniform float u_gamma_scale : 0.5;\n// uniform float u_font_size : 24.0;\nuniform float u_opacity : 1.0;\nuniform vec4 u_stroke_color : [0, 0, 0, 1];\nuniform float u_stroke_width : 2.0;\nuniform float u_halo_blur : 0.5;\nuniform float u_DevicePixelRatio;\n\nvarying vec4 v_color;\nvarying vec2 v_uv;\nvarying float v_gamma_scale;\nvarying float v_fontScale;\n\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n\n#pragma include \"picking\"\nvoid main() {\n // get style data mapping\n float opacity = styleMappingMat[0][0];\n float strokeWidth = styleMappingMat[0][2];\n vec4 textrueStroke = vec4(\n styleMappingMat[1][0],\n styleMappingMat[1][1],\n styleMappingMat[1][2],\n styleMappingMat[1][3]\n );\n\n // get sdf from atlas\n float dist = texture2D(u_sdf_map, v_uv).a;\n\n // float fontScale = u_font_size / FONT_SIZE;\n\n // lowp float buff = (6.0 - u_stroke_width / v_fontScale) / SDF_PX;\n lowp float buff = (6.0 - strokeWidth / v_fontScale) / SDF_PX;\n highp float gamma = (u_halo_blur * 1.19 / SDF_PX + EDGE_GAMMA) / (v_fontScale * u_gamma_scale) / 1.0;\n\n highp float gamma_scaled = gamma * v_gamma_scale;\n\n highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist);\n // gl_FragColor = mix(vec4(v_color.rgb, v_color.a * u_opacity), vec4(u_stroke_color.rgb, u_stroke_color.a * u_opacity), smoothstep(0., 0.5, 1. - dist));\n gl_FragColor = mix(vec4(v_color.rgb, v_color.a * opacity), vec4(textrueStroke.rgb, textrueStroke.a * opacity), smoothstep(0., 0.5, 1. - dist));\n gl_FragColor.a= gl_FragColor.a * alpha;\n // \u4F5C\u4E3A mask \u6A21\u677F\u65F6\u9700\u8981\u4E22\u5F03\u900F\u660E\u7684\u50CF\u7D20\n if (gl_FragColor.a < 0.01) {\n discard;\n }\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
32
-
24
+ var textFrag = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 48.0\nuniform sampler2D u_sdf_map;\nuniform float u_gamma_scale : 0.5;\nuniform float u_stroke_width : 2.0;\nuniform float u_halo_blur : 0.5;\nuniform float u_DevicePixelRatio;\n\nvarying vec4 v_color;\nvarying vec4 v_stroke_color;\nvarying vec2 v_uv;\nvarying float v_gamma_scale;\nvarying float v_fontScale;\n\n\n#pragma include \"picking\"\nvoid main() {\n // get style data mapping\n\n // get sdf from atlas\n float dist = texture2D(u_sdf_map, v_uv).a;\n\n lowp float buff = (6.0 - u_stroke_width / v_fontScale) / SDF_PX;\n highp float gamma = (u_halo_blur * 1.19 / SDF_PX + EDGE_GAMMA) / (v_fontScale * u_gamma_scale) / 1.0;\n\n highp float gamma_scaled = gamma * v_gamma_scale;\n\n highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist);\n\n gl_FragColor = mix(v_color, v_stroke_color, smoothstep(0., 0.5, 1.- dist));\n\n gl_FragColor.a *= alpha;\n // \u4F5C\u4E3A mask \u6A21\u677F\u65F6\u9700\u8981\u4E22\u5F03\u900F\u660E\u7684\u50CF\u7D20\n if (gl_FragColor.a < 0.01) {\n discard;\n }\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
33
25
  /* babel-plugin-inline-import '../shaders/text_vert.glsl' */
34
- var textVert = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 24.0\nattribute vec3 a_Position;\nattribute vec2 a_tex;\nattribute vec2 a_textOffsets;\nattribute vec4 a_Color;\nattribute float a_Size;\nattribute float a_Rotate;\n\nuniform vec2 u_sdf_map_size;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform float u_raisingHeight: 0.0;\n\nvarying vec2 v_uv;\nvarying float v_gamma_scale;\nvarying vec4 v_color;\nvarying float v_fontScale;\n\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\nuniform float u_opacity : 1;\nuniform float u_stroke_width : 2;\nuniform vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n#pragma include \"styleMappingCalStrokeWidth\"\n\n#pragma include \"projection\"\n#pragma include \"picking\"\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 - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0\n );\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\n vec2 strokeWidthAndOffset = calStrokeWidthAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][2] = strokeWidthAndOffset.r;\n textureOffset = strokeWidthAndOffset.g;\n\n vec4 textrueStroke = vec4(-1.0, -1.0, -1.0, -1.0);\n if(hasStroke()) {\n vec2 valueRPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][0] = pos2value(valueRPos, columnWidth, rowHeight); // R\n textureOffset += 1.0;\n\n vec2 valueGPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][1] = pos2value(valueGPos, columnWidth, rowHeight); // G\n textureOffset += 1.0;\n\n vec2 valueBPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][2] = pos2value(valueBPos, columnWidth, rowHeight); // B\n textureOffset += 1.0;\n\n vec2 valueAPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][3] = pos2value(valueAPos, columnWidth, rowHeight); // A\n textureOffset += 1.0;\n } else {\n if(u_stroke_color == vec4(0.0)) {\n styleMappingMat[1][0] = v_color.r;\n styleMappingMat[1][1] = v_color.g;\n styleMappingMat[1][2] = v_color.b;\n styleMappingMat[1][3] = v_color.a;\n } else {\n styleMappingMat[1][0] = u_stroke_color.r;\n styleMappingMat[1][1] = u_stroke_color.g;\n styleMappingMat[1][2] = u_stroke_color.b;\n styleMappingMat[1][3] = u_stroke_color.a;\n }\n }\n \n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n v_color = a_Color;\n v_uv = a_tex / u_sdf_map_size;\n\n // \u6587\u672C\u7F29\u653E\u6BD4\u4F8B\n float fontScale = a_Size / FONT_SIZE;\n v_fontScale = fontScale;\n\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n // vec4 projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n highp float angle_sin = sin(a_Rotate);\n highp float angle_cos = cos(a_Rotate);\n mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);\n \n // gl_Position = vec4(projected_position.xy / projected_position.w + rotation_matrix * a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);\n\n float raiseHeight = u_raisingHeight;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n raiseHeight = u_raisingHeight * mapboxZoomScale;\n }\n\n vec4 projected_position;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n projected_position = u_Mvp *(vec4(a_Position.xyz + vec3(0.0, 0.0, raiseHeight), 1.0));\n } else { // else\n projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz + vec3(0.0, 0.0, raiseHeight), 1.0));\n }\n\n gl_Position = vec4(\n projected_position.xy / projected_position.w + rotation_matrix * a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);\n v_gamma_scale = gl_Position.w;\n setPickingColor(a_PickingColor);\n\n}\n";
26
+ var textVert = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 24.0\nattribute vec3 a_Position;\nattribute vec2 a_tex;\nattribute vec2 a_textOffsets;\nattribute vec4 a_Color;\nattribute float a_Size;\nattribute float a_Rotate;\n\nuniform vec2 u_sdf_map_size;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform float u_raisingHeight: 0.0;\n\nvarying vec2 v_uv;\nvarying float v_gamma_scale;\nvarying vec4 v_color;\nvarying vec4 v_stroke_color;\nvarying float v_fontScale;\n// uniform float u_opacity : 1;\nuniform float u_stroke_width : 2;\nuniform vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\n\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n \n v_uv = a_tex / u_sdf_map_size;\n\n\n\n v_color = vec4(a_Color.xyz, a_Color.w * opacity);\n v_stroke_color = vec4(u_stroke_color.xyz, u_stroke_color.w * opacity);\n\n // \u6587\u672C\u7F29\u653E\u6BD4\u4F8B\n float fontScale = a_Size / FONT_SIZE;\n v_fontScale = fontScale;\n\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n // vec4 projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n highp float angle_sin = sin(a_Rotate);\n highp float angle_cos = cos(a_Rotate);\n mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);\n \n // gl_Position = vec4(projected_position.xy / projected_position.w + rotation_matrix * a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);\n\n float raiseHeight = u_raisingHeight;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n raiseHeight = u_raisingHeight * mapboxZoomScale;\n }\n\n vec4 projected_position;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n projected_position = u_Mvp *(vec4(a_Position.xyz + vec3(0.0, 0.0, raiseHeight), 1.0));\n } else { // else\n projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz + vec3(0.0, 0.0, raiseHeight), 1.0));\n }\n\n gl_Position = vec4(\n projected_position.xy / projected_position.w + rotation_matrix * a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);\n v_gamma_scale = gl_Position.w;\n setPickingColor(a_PickingColor);\n\n}\n";
35
27
  export function TextTrianglation(feature) {
36
28
  // @ts-ignore
37
29
  var that = this;
38
30
  var id = feature.id;
39
31
  var vertices = [];
40
32
  var indices = [];
41
-
42
33
  if (!that.glyphInfoMap || !that.glyphInfoMap[id]) {
43
34
  return {
44
35
  vertices: [],
@@ -47,9 +38,7 @@ export function TextTrianglation(feature) {
47
38
  size: 7
48
39
  };
49
40
  }
50
-
51
41
  var centroid = that.glyphInfoMap[id].centroid; // 计算中心点
52
-
53
42
  var coord = centroid.length === 2 ? [centroid[0], centroid[1], 0] : centroid;
54
43
  that.glyphInfoMap[id].glyphQuads.forEach(function (quad, index) {
55
44
  vertices.push.apply(vertices, _toConsumableArray(coord).concat([quad.tex.x, quad.tex.y + quad.tex.height, quad.tl.x, quad.tl.y], _toConsumableArray(coord), [quad.tex.x + quad.tex.width, quad.tex.y + quad.tex.height, quad.tr.x, quad.tr.y], _toConsumableArray(coord), [quad.tex.x + quad.tex.width, quad.tex.y, quad.br.x, quad.br.y], _toConsumableArray(coord), [quad.tex.x, quad.tex.y, quad.bl.x, quad.bl.y]));
@@ -62,161 +51,93 @@ export function TextTrianglation(feature) {
62
51
  size: 7
63
52
  };
64
53
  }
65
-
66
54
  var TextModel = /*#__PURE__*/function (_BaseModel) {
67
55
  _inherits(TextModel, _BaseModel);
68
-
69
56
  var _super = _createSuper(TextModel);
70
-
71
57
  function TextModel() {
72
58
  var _this;
73
-
74
59
  _classCallCheck(this, TextModel);
75
-
76
60
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
77
61
  args[_key] = arguments[_key];
78
62
  }
79
-
80
63
  _this = _super.call.apply(_super, [this].concat(args));
81
-
82
64
  _defineProperty(_assertThisInitialized(_this), "glyphInfoMap", {});
83
-
84
65
  _defineProperty(_assertThisInitialized(_this), "currentZoom", -1);
85
-
86
66
  _defineProperty(_assertThisInitialized(_this), "textureHeight", 0);
87
-
88
67
  _defineProperty(_assertThisInitialized(_this), "textCount", 0);
89
-
90
68
  _defineProperty(_assertThisInitialized(_this), "preTextStyle", {});
91
-
92
69
  _defineProperty(_assertThisInitialized(_this), "mapping", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
93
70
  return _regeneratorRuntime.wrap(function _callee$(_context) {
94
- while (1) {
95
- switch (_context.prev = _context.next) {
96
- case 0:
97
- _this.initGlyph(); //
98
-
99
-
100
- _this.updateTexture();
101
-
102
- _context.next = 4;
103
- return _this.reBuildModel();
104
-
105
- case 4:
106
- case "end":
107
- return _context.stop();
108
- }
71
+ while (1) switch (_context.prev = _context.next) {
72
+ case 0:
73
+ _this.initGlyph(); //
74
+ _this.updateTexture();
75
+ _context.next = 4;
76
+ return _this.reBuildModel();
77
+ case 4:
78
+ case "end":
79
+ return _context.stop();
109
80
  }
110
81
  }, _callee);
111
82
  })));
112
-
113
83
  return _this;
114
84
  }
115
-
116
85
  _createClass(TextModel, [{
117
86
  key: "getUninforms",
118
87
  value: function getUninforms() {
119
88
  var _ref2 = this.layer.getLayerConfig(),
120
- _ref2$opacity = _ref2.opacity,
121
- opacity = _ref2$opacity === void 0 ? 1.0 : _ref2$opacity,
122
- _ref2$stroke = _ref2.stroke,
123
- stroke = _ref2$stroke === void 0 ? '#fff' : _ref2$stroke,
124
- _ref2$strokeWidth = _ref2.strokeWidth,
125
- strokeWidth = _ref2$strokeWidth === void 0 ? 0 : _ref2$strokeWidth,
126
- _ref2$halo = _ref2.halo,
127
- halo = _ref2$halo === void 0 ? 0.5 : _ref2$halo,
128
- _ref2$gamma = _ref2.gamma,
129
- gamma = _ref2$gamma === void 0 ? 2.0 : _ref2$gamma,
130
- _ref2$raisingHeight = _ref2.raisingHeight,
131
- raisingHeight = _ref2$raisingHeight === void 0 ? 0 : _ref2$raisingHeight;
132
-
89
+ _ref2$opacity = _ref2.opacity,
90
+ opacity = _ref2$opacity === void 0 ? 1.0 : _ref2$opacity,
91
+ _ref2$stroke = _ref2.stroke,
92
+ stroke = _ref2$stroke === void 0 ? '#fff' : _ref2$stroke,
93
+ _ref2$strokeWidth = _ref2.strokeWidth,
94
+ strokeWidth = _ref2$strokeWidth === void 0 ? 0 : _ref2$strokeWidth,
95
+ _ref2$halo = _ref2.halo,
96
+ halo = _ref2$halo === void 0 ? 0.5 : _ref2$halo,
97
+ _ref2$gamma = _ref2.gamma,
98
+ gamma = _ref2$gamma === void 0 ? 2.0 : _ref2$gamma,
99
+ _ref2$raisingHeight = _ref2.raisingHeight,
100
+ raisingHeight = _ref2$raisingHeight === void 0 ? 0 : _ref2$raisingHeight;
133
101
  var mapping = this.getFontServiceMapping();
134
102
  var canvas = this.getFontServiceCanvas();
135
-
136
103
  if (mapping && Object.keys(mapping).length !== this.textCount && canvas) {
137
104
  this.updateTexture();
138
105
  this.textCount = Object.keys(mapping).length;
139
106
  }
140
-
141
107
  this.preTextStyle = this.getTextStyle();
142
-
143
- if (this.dataTextureTest && this.dataTextureNeedUpdate({
144
- opacity: opacity,
145
- strokeWidth: strokeWidth,
146
- stroke: stroke
147
- })) {
148
- this.judgeStyleAttributes({
149
- opacity: opacity,
150
- strokeWidth: strokeWidth,
151
- stroke: stroke
152
- });
153
- var encodeData = this.layer.getEncodedData();
154
-
155
- var _this$calDataFrame = this.calDataFrame(this.cellLength, encodeData, this.cellProperties),
156
- data = _this$calDataFrame.data,
157
- width = _this$calDataFrame.width,
158
- height = _this$calDataFrame.height;
159
-
160
- this.rowCount = height; // 当前数据纹理有多少行
161
-
162
- this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
163
- flipY: true,
164
- data: data,
165
- format: gl.LUMINANCE,
166
- type: gl.FLOAT,
167
- width: width,
168
- height: height
169
- }) : this.createTexture2D({
170
- flipY: true,
171
- data: [1],
172
- format: gl.LUMINANCE,
173
- type: gl.FLOAT,
174
- width: 1,
175
- height: 1
176
- });
177
- }
178
-
179
- return {
180
- u_dataTexture: this.dataTexture,
181
- // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]
182
- u_cellTypeLayout: this.getCellTypeLayout(),
108
+ return _objectSpread({
183
109
  u_raisingHeight: Number(raisingHeight),
184
- u_opacity: isNumber(opacity) ? opacity : 1.0,
185
- u_stroke_width: isNumber(strokeWidth) ? strokeWidth : 1.0,
186
- u_stroke_color: this.getStrokeColor(stroke),
110
+ // u_opacity: opacity,
111
+ u_stroke_width: strokeWidth,
112
+ u_stroke_color: rgb2arr(stroke),
187
113
  u_sdf_map: this.texture,
188
114
  u_halo_blur: halo,
189
115
  u_gamma_scale: gamma,
190
116
  u_sdf_map_size: [(canvas === null || canvas === void 0 ? void 0 : canvas.width) || 1, (canvas === null || canvas === void 0 ? void 0 : canvas.height) || 1]
191
- };
117
+ }, this.getStyleAttribute());
192
118
  }
193
119
  }, {
194
120
  key: "initModels",
195
121
  value: function () {
196
122
  var _initModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
197
123
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
198
- while (1) {
199
- switch (_context2.prev = _context2.next) {
200
- case 0:
201
- // 绑定事件
202
- this.bindEvent();
203
- this.extent = this.textExtent();
204
- this.rawEncodeData = this.layer.getEncodedData();
205
- this.preTextStyle = this.getTextStyle();
206
- return _context2.abrupt("return", this.buildModels());
207
-
208
- case 5:
209
- case "end":
210
- return _context2.stop();
211
- }
124
+ while (1) switch (_context2.prev = _context2.next) {
125
+ case 0:
126
+ // 绑定事件
127
+ this.bindEvent();
128
+ this.extent = this.textExtent();
129
+ this.rawEncodeData = this.layer.getEncodedData();
130
+ this.preTextStyle = this.getTextStyle();
131
+ return _context2.abrupt("return", this.buildModels());
132
+ case 5:
133
+ case "end":
134
+ return _context2.stop();
212
135
  }
213
136
  }, _callee2, this);
214
137
  }));
215
-
216
138
  function initModels() {
217
139
  return _initModels.apply(this, arguments);
218
140
  }
219
-
220
141
  return initModels;
221
142
  }()
222
143
  }, {
@@ -224,48 +145,38 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
224
145
  value: function () {
225
146
  var _buildModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
226
147
  var _ref3, _ref3$textAllowOverla, textAllowOverlap, model;
227
-
228
148
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
229
- while (1) {
230
- switch (_context3.prev = _context3.next) {
231
- case 0:
232
- _ref3 = this.layer.getLayerConfig(), _ref3$textAllowOverla = _ref3.textAllowOverlap, textAllowOverlap = _ref3$textAllowOverla === void 0 ? false : _ref3$textAllowOverla; // this.mapping(); 重复调用
233
-
234
- this.initGlyph(); //
235
-
236
- this.updateTexture();
237
-
238
- if (!textAllowOverlap) {
239
- this.filterGlyphs();
149
+ while (1) switch (_context3.prev = _context3.next) {
150
+ case 0:
151
+ _ref3 = this.layer.getLayerConfig(), _ref3$textAllowOverla = _ref3.textAllowOverlap, textAllowOverlap = _ref3$textAllowOverla === void 0 ? false : _ref3$textAllowOverla; // this.mapping(); 重复调用
152
+ this.initGlyph(); //
153
+ this.updateTexture();
154
+ if (!textAllowOverlap) {
155
+ this.filterGlyphs();
156
+ }
157
+ _context3.next = 6;
158
+ return this.layer.buildLayerModel({
159
+ moduleName: 'pointText',
160
+ vertexShader: textVert,
161
+ fragmentShader: textFrag,
162
+ inject: this.getInject(),
163
+ triangulation: TextTrianglation.bind(this),
164
+ depth: {
165
+ enable: false
240
166
  }
241
-
242
- _context3.next = 6;
243
- return this.layer.buildLayerModel({
244
- moduleName: 'pointText',
245
- vertexShader: textVert,
246
- fragmentShader: textFrag,
247
- triangulation: TextTrianglation.bind(this),
248
- depth: {
249
- enable: false
250
- }
251
- });
252
-
253
- case 6:
254
- model = _context3.sent;
255
- return _context3.abrupt("return", [model]);
256
-
257
- case 8:
258
- case "end":
259
- return _context3.stop();
260
- }
167
+ });
168
+ case 6:
169
+ model = _context3.sent;
170
+ return _context3.abrupt("return", [model]);
171
+ case 8:
172
+ case "end":
173
+ return _context3.stop();
261
174
  }
262
175
  }, _callee3, this);
263
176
  }));
264
-
265
177
  function buildModels() {
266
178
  return _buildModels.apply(this, arguments);
267
179
  }
268
-
269
180
  return buildModels;
270
181
  }() // 需要更新的场景
271
182
  // 1. 文本偏移量发生改变
@@ -273,80 +184,61 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
273
184
  // 3. 文本允许重叠发生改变
274
185
  // 4. 文本字体发生改变
275
186
  // 5. 文本字体粗细发生改变
276
-
277
187
  }, {
278
188
  key: "needUpdate",
279
189
  value: function () {
280
190
  var _needUpdate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
281
191
  var _ref4, _ref4$textAllowOverla, textAllowOverlap, _ref4$textAnchor, textAnchor, textOffset, padding, fontFamily, fontWeight, zoom, extent, flag;
282
-
283
192
  return _regeneratorRuntime.wrap(function _callee4$(_context4) {
284
- while (1) {
285
- switch (_context4.prev = _context4.next) {
286
- case 0:
287
- _ref4 = this.getTextStyle(), _ref4$textAllowOverla = _ref4.textAllowOverlap, textAllowOverlap = _ref4$textAllowOverla === void 0 ? false : _ref4$textAllowOverla, _ref4$textAnchor = _ref4.textAnchor, textAnchor = _ref4$textAnchor === void 0 ? 'center' : _ref4$textAnchor, textOffset = _ref4.textOffset, padding = _ref4.padding, fontFamily = _ref4.fontFamily, fontWeight = _ref4.fontWeight;
288
-
289
- if (!(!isEqual(padding, this.preTextStyle.padding) || !isEqual(textOffset, this.preTextStyle.textOffset) || !isEqual(textAnchor, this.preTextStyle.textAnchor) || !isEqual(fontFamily, this.preTextStyle.fontFamily) || !isEqual(fontWeight, this.preTextStyle.fontWeight))) {
290
- _context4.next = 5;
291
- break;
292
- }
293
-
294
- _context4.next = 4;
295
- return this.mapping();
296
-
297
- case 4:
298
- return _context4.abrupt("return", true);
299
-
300
- case 5:
301
- if (!textAllowOverlap) {
302
- _context4.next = 7;
303
- break;
304
- }
305
-
306
- return _context4.abrupt("return", false);
307
-
308
- case 7:
309
- // textAllowOverlap 发生改变
310
- zoom = this.mapService.getZoom();
311
- extent = this.mapService.getBounds();
312
- flag = boundsContains(this.extent, extent); // 文本不能压盖则进行过滤
313
-
314
- if (!(Math.abs(this.currentZoom - zoom) > 0.5 || !flag || textAllowOverlap !== this.preTextStyle.textAllowOverlap)) {
315
- _context4.next = 14;
316
- break;
317
- }
318
-
319
- _context4.next = 13;
320
- return this.reBuildModel();
321
-
322
- case 13:
323
- return _context4.abrupt("return", true);
324
-
325
- case 14:
326
- return _context4.abrupt("return", false);
327
-
328
- case 15:
329
- case "end":
330
- return _context4.stop();
331
- }
193
+ while (1) switch (_context4.prev = _context4.next) {
194
+ case 0:
195
+ _ref4 = this.getTextStyle(), _ref4$textAllowOverla = _ref4.textAllowOverlap, textAllowOverlap = _ref4$textAllowOverla === void 0 ? false : _ref4$textAllowOverla, _ref4$textAnchor = _ref4.textAnchor, textAnchor = _ref4$textAnchor === void 0 ? 'center' : _ref4$textAnchor, textOffset = _ref4.textOffset, padding = _ref4.padding, fontFamily = _ref4.fontFamily, fontWeight = _ref4.fontWeight;
196
+ if (!(!isEqual(padding, this.preTextStyle.padding) || !isEqual(textOffset, this.preTextStyle.textOffset) || !isEqual(textAnchor, this.preTextStyle.textAnchor) || !isEqual(fontFamily, this.preTextStyle.fontFamily) || !isEqual(fontWeight, this.preTextStyle.fontWeight))) {
197
+ _context4.next = 5;
198
+ break;
199
+ }
200
+ _context4.next = 4;
201
+ return this.mapping();
202
+ case 4:
203
+ return _context4.abrupt("return", true);
204
+ case 5:
205
+ if (!textAllowOverlap) {
206
+ _context4.next = 7;
207
+ break;
208
+ }
209
+ return _context4.abrupt("return", false);
210
+ case 7:
211
+ // textAllowOverlap 发生改变
212
+ zoom = this.mapService.getZoom();
213
+ extent = this.mapService.getBounds();
214
+ flag = boundsContains(this.extent, extent); // 文本不能压盖则进行过滤
215
+ if (!(Math.abs(this.currentZoom - zoom) > 0.5 || !flag || textAllowOverlap !== this.preTextStyle.textAllowOverlap)) {
216
+ _context4.next = 14;
217
+ break;
218
+ }
219
+ _context4.next = 13;
220
+ return this.reBuildModel();
221
+ case 13:
222
+ return _context4.abrupt("return", true);
223
+ case 14:
224
+ return _context4.abrupt("return", false);
225
+ case 15:
226
+ case "end":
227
+ return _context4.stop();
332
228
  }
333
229
  }, _callee4, this);
334
230
  }));
335
-
336
231
  function needUpdate() {
337
232
  return _needUpdate.apply(this, arguments);
338
233
  }
339
-
340
234
  return needUpdate;
341
235
  }()
342
236
  }, {
343
237
  key: "clearModels",
344
238
  value: function clearModels() {
345
- var _this$texture, _this$dataTexture;
346
-
239
+ var _this$texture;
347
240
  (_this$texture = this.texture) === null || _this$texture === void 0 ? void 0 : _this$texture.destroy();
348
- (_this$dataTexture = this.dataTexture) === null || _this$dataTexture === void 0 ? void 0 : _this$dataTexture.destroy(); // TODO this.mapping
349
-
241
+ // TODO this.mapping
350
242
  this.layer.off('remapping', this.mapping);
351
243
  }
352
244
  }, {
@@ -365,7 +257,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
365
257
  size: 1,
366
258
  update: function update(feature) {
367
259
  var _feature$rotate = feature.rotate,
368
- rotate = _feature$rotate === void 0 ? 0 : _feature$rotate;
260
+ rotate = _feature$rotate === void 0 ? 0 : _feature$rotate;
369
261
  return Array.isArray(rotate) ? [rotate[0]] : [rotate];
370
262
  }
371
263
  }
@@ -375,6 +267,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
375
267
  type: AttributeType.Attribute,
376
268
  descriptor: {
377
269
  name: 'a_textOffsets',
270
+ // 文字偏移量
378
271
  buffer: {
379
272
  // give the WebGL driver a hint that this buffer may change
380
273
  usage: gl.STATIC_DRAW,
@@ -386,8 +279,9 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
386
279
  return [vertex[5], vertex[6]];
387
280
  }
388
281
  }
389
- }); // point layer size;
282
+ });
390
283
 
284
+ // point layer size;
391
285
  this.styleAttributeService.registerStyleAttribute({
392
286
  name: 'size',
393
287
  type: AttributeType.Attribute,
@@ -402,7 +296,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
402
296
  size: 1,
403
297
  update: function update(feature) {
404
298
  var _feature$size = feature.size,
405
- size = _feature$size === void 0 ? 12 : _feature$size;
299
+ size = _feature$size === void 0 ? 12 : _feature$size;
406
300
  return Array.isArray(size) ? [size[0]] : [size];
407
301
  }
408
302
  }
@@ -441,28 +335,23 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
441
335
  /**
442
336
  * 生成文字纹理(生成文字纹理字典)
443
337
  */
444
-
445
338
  }, {
446
339
  key: "initTextFont",
447
340
  value: function initTextFont() {
448
341
  var _this$getTextStyle = this.getTextStyle(),
449
- fontWeight = _this$getTextStyle.fontWeight,
450
- fontFamily = _this$getTextStyle.fontFamily;
451
-
342
+ fontWeight = _this$getTextStyle.fontWeight,
343
+ fontFamily = _this$getTextStyle.fontFamily;
452
344
  var data = this.rawEncodeData;
453
345
  var characterSet = [];
454
346
  data.forEach(function (item) {
455
347
  var _item$shape = item.shape,
456
- shape = _item$shape === void 0 ? '' : _item$shape;
348
+ shape = _item$shape === void 0 ? '' : _item$shape;
457
349
  shape = shape.toString();
458
-
459
350
  var _iterator = _createForOfIteratorHelper(shape),
460
- _step;
461
-
351
+ _step;
462
352
  try {
463
353
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
464
354
  var char = _step.value;
465
-
466
355
  // 去重
467
356
  if (characterSet.indexOf(char) === -1) {
468
357
  characterSet.push(char);
@@ -481,24 +370,22 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
481
370
  iconfont: false
482
371
  });
483
372
  }
373
+
484
374
  /**
485
375
  * 生成 iconfont 纹理字典
486
376
  */
487
-
488
377
  }, {
489
378
  key: "initIconFontTex",
490
379
  value: function initIconFontTex() {
491
380
  var _this$getTextStyle2 = this.getTextStyle(),
492
- fontWeight = _this$getTextStyle2.fontWeight,
493
- fontFamily = _this$getTextStyle2.fontFamily;
494
-
381
+ fontWeight = _this$getTextStyle2.fontWeight,
382
+ fontFamily = _this$getTextStyle2.fontFamily;
495
383
  var data = this.rawEncodeData;
496
384
  var characterSet = [];
497
385
  data.forEach(function (item) {
498
386
  var _item$shape2 = item.shape,
499
- shape = _item$shape2 === void 0 ? '' : _item$shape2;
387
+ shape = _item$shape2 === void 0 ? '' : _item$shape2;
500
388
  shape = "".concat(shape);
501
-
502
389
  if (characterSet.indexOf(shape) === -1) {
503
390
  characterSet.push(shape);
504
391
  }
@@ -514,27 +401,26 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
514
401
  key: "getTextStyle",
515
402
  value: function getTextStyle() {
516
403
  var _ref5 = this.layer.getLayerConfig(),
517
- _ref5$fontWeight = _ref5.fontWeight,
518
- fontWeight = _ref5$fontWeight === void 0 ? '400' : _ref5$fontWeight,
519
- _ref5$fontFamily = _ref5.fontFamily,
520
- fontFamily = _ref5$fontFamily === void 0 ? 'sans-serif' : _ref5$fontFamily,
521
- _ref5$textAllowOverla = _ref5.textAllowOverlap,
522
- textAllowOverlap = _ref5$textAllowOverla === void 0 ? false : _ref5$textAllowOverla,
523
- _ref5$padding = _ref5.padding,
524
- padding = _ref5$padding === void 0 ? [0, 0] : _ref5$padding,
525
- _ref5$textAnchor = _ref5.textAnchor,
526
- textAnchor = _ref5$textAnchor === void 0 ? 'center' : _ref5$textAnchor,
527
- _ref5$textOffset = _ref5.textOffset,
528
- textOffset = _ref5$textOffset === void 0 ? [0, 0] : _ref5$textOffset,
529
- _ref5$opacity = _ref5.opacity,
530
- opacity = _ref5$opacity === void 0 ? 1 : _ref5$opacity,
531
- _ref5$strokeOpacity = _ref5.strokeOpacity,
532
- strokeOpacity = _ref5$strokeOpacity === void 0 ? 1 : _ref5$strokeOpacity,
533
- _ref5$strokeWidth = _ref5.strokeWidth,
534
- strokeWidth = _ref5$strokeWidth === void 0 ? 0 : _ref5$strokeWidth,
535
- _ref5$stroke = _ref5.stroke,
536
- stroke = _ref5$stroke === void 0 ? '#000' : _ref5$stroke;
537
-
404
+ _ref5$fontWeight = _ref5.fontWeight,
405
+ fontWeight = _ref5$fontWeight === void 0 ? '400' : _ref5$fontWeight,
406
+ _ref5$fontFamily = _ref5.fontFamily,
407
+ fontFamily = _ref5$fontFamily === void 0 ? 'sans-serif' : _ref5$fontFamily,
408
+ _ref5$textAllowOverla = _ref5.textAllowOverlap,
409
+ textAllowOverlap = _ref5$textAllowOverla === void 0 ? false : _ref5$textAllowOverla,
410
+ _ref5$padding = _ref5.padding,
411
+ padding = _ref5$padding === void 0 ? [0, 0] : _ref5$padding,
412
+ _ref5$textAnchor = _ref5.textAnchor,
413
+ textAnchor = _ref5$textAnchor === void 0 ? 'center' : _ref5$textAnchor,
414
+ _ref5$textOffset = _ref5.textOffset,
415
+ textOffset = _ref5$textOffset === void 0 ? [0, 0] : _ref5$textOffset,
416
+ _ref5$opacity = _ref5.opacity,
417
+ opacity = _ref5$opacity === void 0 ? 1 : _ref5$opacity,
418
+ _ref5$strokeOpacity = _ref5.strokeOpacity,
419
+ strokeOpacity = _ref5$strokeOpacity === void 0 ? 1 : _ref5$strokeOpacity,
420
+ _ref5$strokeWidth = _ref5.strokeWidth,
421
+ strokeWidth = _ref5$strokeWidth === void 0 ? 0 : _ref5$strokeWidth,
422
+ _ref5$stroke = _ref5.stroke,
423
+ stroke = _ref5$stroke === void 0 ? '#000' : _ref5$stroke;
538
424
  return {
539
425
  fontWeight: fontWeight,
540
426
  fontFamily: fontFamily,
@@ -548,39 +434,41 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
548
434
  stroke: stroke
549
435
  };
550
436
  }
437
+
551
438
  /**
552
439
  * 生成文字布局(对照文字纹理字典提取对应文字的位置很好信息)
553
440
  */
554
-
555
441
  }, {
556
442
  key: "generateGlyphLayout",
557
443
  value: function generateGlyphLayout(iconfont) {
558
444
  var _this2 = this;
559
-
560
445
  var mapping = this.getFontServiceMapping();
561
-
562
446
  var _ref6 = this.layer.getLayerConfig(),
563
- _ref6$spacing = _ref6.spacing,
564
- spacing = _ref6$spacing === void 0 ? 2 : _ref6$spacing,
565
- _ref6$textAnchor = _ref6.textAnchor,
566
- textAnchor = _ref6$textAnchor === void 0 ? 'center' : _ref6$textAnchor,
567
- textOffset = _ref6.textOffset;
568
-
447
+ _ref6$spacing = _ref6.spacing,
448
+ spacing = _ref6$spacing === void 0 ? 2 : _ref6$spacing,
449
+ _ref6$textAnchor = _ref6.textAnchor,
450
+ textAnchor = _ref6$textAnchor === void 0 ? 'center' : _ref6$textAnchor,
451
+ textOffset = _ref6.textOffset;
569
452
  var data = this.rawEncodeData;
570
453
  this.glyphInfo = data.map(function (feature) {
571
454
  var _feature$shape = feature.shape,
572
- shape = _feature$shape === void 0 ? '' : _feature$shape,
573
- id = feature.id,
574
- _feature$size2 = feature.size,
575
- size = _feature$size2 === void 0 ? 1 : _feature$size2;
576
- var shaping = shapeText(shape.toString(), mapping, // @ts-ignore
577
- size, textAnchor, 'left', spacing, textOffset || feature.textOffset || [0, 0], iconfont);
455
+ shape = _feature$shape === void 0 ? '' : _feature$shape,
456
+ id = feature.id,
457
+ _feature$size2 = feature.size,
458
+ size = _feature$size2 === void 0 ? 1 : _feature$size2;
459
+ var shaping = shapeText(shape.toString(), mapping,
460
+ // @ts-ignore
461
+ size, textAnchor, 'left', spacing, textOffset,
462
+ // || feature['textOffset'] || [0, 0],// TODO: 文字偏移量 CPU 计算
463
+ iconfont);
578
464
  var glyphQuads = getGlyphQuads(shaping, textOffset, false);
579
465
  feature.shaping = shaping;
580
- feature.glyphQuads = glyphQuads; // feature.centroid = calculteCentroid(coordinates);
466
+ feature.glyphQuads = glyphQuads;
467
+ // feature.centroid = calculteCentroid(coordinates);
581
468
 
582
- feature.centroid = calculateCentroid(feature.coordinates); // 此时地图高德2.0 originCentroid == centroid
469
+ feature.centroid = calculateCentroid(feature.coordinates);
583
470
 
471
+ // 此时地图高德2.0 originCentroid == centroid
584
472
  feature.originCentroid = feature.version === 'GAODE2.x' ? calculateCentroid(feature.originCoordinates) : feature.originCentroid = feature.centroid;
585
473
  _this2.glyphInfoMap[id] = {
586
474
  shaping: shaping,
@@ -594,76 +482,66 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
594
482
  key: "getFontServiceMapping",
595
483
  value: function getFontServiceMapping() {
596
484
  var _ref7 = this.layer.getLayerConfig(),
597
- _ref7$fontWeight = _ref7.fontWeight,
598
- fontWeight = _ref7$fontWeight === void 0 ? '400' : _ref7$fontWeight,
599
- _ref7$fontFamily = _ref7.fontFamily,
600
- fontFamily = _ref7$fontFamily === void 0 ? 'sans-serif' : _ref7$fontFamily;
601
-
485
+ _ref7$fontWeight = _ref7.fontWeight,
486
+ fontWeight = _ref7$fontWeight === void 0 ? '400' : _ref7$fontWeight,
487
+ _ref7$fontFamily = _ref7.fontFamily,
488
+ fontFamily = _ref7$fontFamily === void 0 ? 'sans-serif' : _ref7$fontFamily;
602
489
  return this.fontService.getMappingByKey("".concat(fontFamily, "_").concat(fontWeight));
603
490
  }
604
491
  }, {
605
492
  key: "getFontServiceCanvas",
606
493
  value: function getFontServiceCanvas() {
607
494
  var _ref8 = this.layer.getLayerConfig(),
608
- _ref8$fontWeight = _ref8.fontWeight,
609
- fontWeight = _ref8$fontWeight === void 0 ? '400' : _ref8$fontWeight,
610
- _ref8$fontFamily = _ref8.fontFamily,
611
- fontFamily = _ref8$fontFamily === void 0 ? 'sans-serif' : _ref8$fontFamily; // 更新文字布局
612
-
613
-
495
+ _ref8$fontWeight = _ref8.fontWeight,
496
+ fontWeight = _ref8$fontWeight === void 0 ? '400' : _ref8$fontWeight,
497
+ _ref8$fontFamily = _ref8.fontFamily,
498
+ fontFamily = _ref8$fontFamily === void 0 ? 'sans-serif' : _ref8$fontFamily;
499
+ // 更新文字布局
614
500
  return this.fontService.getCanvasByKey("".concat(fontFamily, "_").concat(fontWeight));
615
501
  }
502
+
616
503
  /**
617
504
  * 文字避让 depend on originCentorid
618
505
  */
619
-
620
506
  }, {
621
507
  key: "filterGlyphs",
622
508
  value: function filterGlyphs() {
623
509
  var _this3 = this;
624
-
625
510
  var _ref9 = this.layer.getLayerConfig(),
626
- _ref9$padding = _ref9.padding,
627
- padding = _ref9$padding === void 0 ? [0, 0] : _ref9$padding,
628
- _ref9$textAllowOverla = _ref9.textAllowOverlap,
629
- textAllowOverlap = _ref9$textAllowOverla === void 0 ? false : _ref9$textAllowOverla;
630
-
511
+ _ref9$padding = _ref9.padding,
512
+ padding = _ref9$padding === void 0 ? [0, 0] : _ref9$padding,
513
+ _ref9$textAllowOverla = _ref9.textAllowOverlap,
514
+ textAllowOverlap = _ref9$textAllowOverla === void 0 ? false : _ref9$textAllowOverla;
631
515
  if (textAllowOverlap) {
632
516
  // 如果允许文本覆盖
633
517
  return;
634
518
  }
635
-
636
519
  this.glyphInfoMap = {};
637
520
  this.currentZoom = this.mapService.getZoom();
638
521
  this.extent = this.textExtent();
639
-
640
522
  var _this$rendererService = this.rendererService.getViewportSize(),
641
- width = _this$rendererService.width,
642
- height = _this$rendererService.height;
643
-
523
+ width = _this$rendererService.width,
524
+ height = _this$rendererService.height;
644
525
  var collisionIndex = new CollisionIndex(width, height);
645
526
  var filterData = this.glyphInfo.filter(function (feature) {
646
527
  var shaping = feature.shaping,
647
- _feature$id = feature.id,
648
- id = _feature$id === void 0 ? 0 : _feature$id; // const centroid = feature.centroid as [number, number];
528
+ _feature$id = feature.id,
529
+ id = _feature$id === void 0 ? 0 : _feature$id;
530
+ // const centroid = feature.centroid as [number, number];
649
531
  // const centroid = feature.originCentroid as [number, number];
650
-
651
532
  var centroid = feature.version === 'GAODE2.x' ? feature.originCentroid : feature.centroid;
652
533
  var size = feature.size;
653
534
  var fontScale = size / 16;
654
-
655
535
  var pixels = _this3.mapService.lngLatToContainer(centroid);
656
-
657
536
  var _collisionIndex$place = collisionIndex.placeCollisionBox({
658
- x1: shaping.left * fontScale - padding[0],
659
- x2: shaping.right * fontScale + padding[0],
660
- y1: shaping.top * fontScale - padding[1],
661
- y2: shaping.bottom * fontScale + padding[1],
662
- anchorPointX: pixels.x,
663
- anchorPointY: pixels.y
664
- }),
665
- box = _collisionIndex$place.box;
666
-
537
+ x1: shaping.left * fontScale - padding[0],
538
+ x2: shaping.right * fontScale + padding[0],
539
+ y1: shaping.top * fontScale - padding[1],
540
+ y2: shaping.bottom * fontScale + padding[1],
541
+ anchorPointX: pixels.x,
542
+ anchorPointY: pixels.y
543
+ }),
544
+ box = _collisionIndex$place.box;
667
545
  if (box && box.length) {
668
546
  collisionIndex.insertCollisionBox(box, id);
669
547
  return true;
@@ -674,39 +552,35 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
674
552
  filterData.forEach(function (item) {
675
553
  // @ts-ignore
676
554
  _this3.glyphInfoMap[item.id] = item;
677
- }); // this.layer.setEncodedData(filterData);
555
+ });
556
+ // this.layer.setEncodedData(filterData);
678
557
  }
679
558
  /**
680
559
  * 初始化文字布局
681
560
  */
682
-
683
561
  }, {
684
562
  key: "initGlyph",
685
563
  value: function initGlyph() {
686
564
  var _this$layer$getLayerC = this.layer.getLayerConfig(),
687
- _this$layer$getLayerC2 = _this$layer$getLayerC.iconfont,
688
- iconfont = _this$layer$getLayerC2 === void 0 ? false : _this$layer$getLayerC2; // 1.生成文字纹理(或是生成 iconfont)
689
-
690
-
691
- iconfont ? this.initIconFontTex() : this.initTextFont(); // 2.生成文字布局
692
-
565
+ _this$layer$getLayerC2 = _this$layer$getLayerC.iconfont,
566
+ iconfont = _this$layer$getLayerC2 === void 0 ? false : _this$layer$getLayerC2;
567
+ // 1.生成文字纹理(或是生成 iconfont)
568
+ iconfont ? this.initIconFontTex() : this.initTextFont();
569
+ // 2.生成文字布局
693
570
  this.generateGlyphLayout(iconfont);
694
571
  }
695
572
  /**
696
573
  * 更新文字纹理
697
574
  */
698
-
699
575
  }, {
700
576
  key: "updateTexture",
701
577
  value: function updateTexture() {
702
578
  var createTexture2D = this.rendererService.createTexture2D;
703
579
  var canvas = this.getFontServiceCanvas();
704
580
  this.textureHeight = canvas.height;
705
-
706
581
  if (this.texture) {
707
582
  this.texture.destroy();
708
583
  }
709
-
710
584
  this.texture = createTexture2D({
711
585
  data: canvas,
712
586
  mag: gl.LINEAR,
@@ -721,43 +595,36 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
721
595
  var _reBuildModel = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
722
596
  var model;
723
597
  return _regeneratorRuntime.wrap(function _callee5$(_context5) {
724
- while (1) {
725
- switch (_context5.prev = _context5.next) {
726
- case 0:
727
- this.filterGlyphs();
728
- _context5.next = 3;
729
- return this.layer.buildLayerModel({
730
- moduleName: 'pointText',
731
- vertexShader: textVert,
732
- fragmentShader: textFrag,
733
- triangulation: TextTrianglation.bind(this),
734
- depth: {
735
- enable: false
736
- }
737
- });
738
-
739
- case 3:
740
- model = _context5.sent;
741
- // TODO 渲染流程待修改
742
- this.layer.models = [model];
743
-
744
- case 5:
745
- case "end":
746
- return _context5.stop();
747
- }
598
+ while (1) switch (_context5.prev = _context5.next) {
599
+ case 0:
600
+ this.filterGlyphs();
601
+ _context5.next = 3;
602
+ return this.layer.buildLayerModel({
603
+ moduleName: 'pointText',
604
+ vertexShader: textVert,
605
+ fragmentShader: textFrag,
606
+ triangulation: TextTrianglation.bind(this),
607
+ inject: this.getInject(),
608
+ depth: {
609
+ enable: false
610
+ }
611
+ });
612
+ case 3:
613
+ model = _context5.sent;
614
+ // TODO 渲染流程待修改
615
+ this.layer.models = [model];
616
+ case 5:
617
+ case "end":
618
+ return _context5.stop();
748
619
  }
749
620
  }, _callee5, this);
750
621
  }));
751
-
752
622
  function reBuildModel() {
753
623
  return _reBuildModel.apply(this, arguments);
754
624
  }
755
-
756
625
  return reBuildModel;
757
626
  }()
758
627
  }]);
759
-
760
628
  return TextModel;
761
629
  }(BaseModel);
762
-
763
630
  export { TextModel as default };