@antv/l7-layers 2.21.0 → 2.21.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 (397) hide show
  1. package/es/canvas/index.js +60 -113
  2. package/es/canvas/models/canvas.js +95 -135
  3. package/es/canvas/models/constants.js +1 -1
  4. package/es/citybuliding/building.js +20 -58
  5. package/es/citybuliding/models/build.js +142 -199
  6. package/es/core/BaseLayer.d.ts +2 -1
  7. package/es/core/BaseLayer.js +1113 -1405
  8. package/es/core/BaseModel.js +262 -318
  9. package/es/core/CommonStyleAttribute.js +25 -18
  10. package/es/core/LayerPickService.js +92 -142
  11. package/es/core/TextureService.js +58 -69
  12. package/es/core/constant.js +2 -2
  13. package/es/core/interface.js +5 -5
  14. package/es/core/line_trangluation.js +38 -43
  15. package/es/core/shape/Path.js +21 -13
  16. package/es/core/shape/arrow.js +50 -62
  17. package/es/core/shape/extrude.js +54 -63
  18. package/es/core/triangulation.js +192 -171
  19. package/es/core/utils.js +5 -5
  20. package/es/earth/index.js +35 -73
  21. package/es/earth/models/atmosphere.js +98 -148
  22. package/es/earth/models/base.js +148 -202
  23. package/es/earth/models/bloomsphere.js +97 -147
  24. package/es/earth/utils.js +37 -38
  25. package/es/geometry/index.js +36 -75
  26. package/es/geometry/models/billboard.js +147 -204
  27. package/es/geometry/models/index.js +1 -1
  28. package/es/geometry/models/plane.js +277 -357
  29. package/es/geometry/models/sprite.js +182 -240
  30. package/es/heatmap/index.js +72 -122
  31. package/es/heatmap/models/grid.js +66 -118
  32. package/es/heatmap/models/grid3d.js +101 -151
  33. package/es/heatmap/models/heatmap.js +398 -455
  34. package/es/heatmap/models/hexagon.js +67 -119
  35. package/es/heatmap/models/index.js +1 -1
  36. package/es/heatmap/triangulation.js +20 -20
  37. package/es/image/index.js +23 -62
  38. package/es/image/models/image.js +99 -163
  39. package/es/image/models/index.js +1 -1
  40. package/es/line/index.js +65 -106
  41. package/es/line/models/arc.js +200 -248
  42. package/es/line/models/arc_3d.js +190 -242
  43. package/es/line/models/flow.js +101 -153
  44. package/es/line/models/great_circle.js +183 -234
  45. package/es/line/models/index.js +1 -1
  46. package/es/line/models/line.js +232 -288
  47. package/es/line/models/simple_line.js +142 -192
  48. package/es/line/models/wall.js +221 -273
  49. package/es/line/shaders/line/line_vert.glsl +0 -2
  50. package/es/line/shaders/wall/wall_vert.glsl +15 -0
  51. package/es/mask/index.js +16 -53
  52. package/es/mask/models/fill.js +51 -108
  53. package/es/mask/models/index.js +1 -1
  54. package/es/plugins/DataMappingPlugin.js +205 -251
  55. package/es/plugins/DataSourcePlugin.js +64 -92
  56. package/es/plugins/FeatureScalePlugin.js +258 -302
  57. package/es/plugins/LayerAnimateStylePlugin.js +12 -22
  58. package/es/plugins/LayerMaskPlugin.js +15 -24
  59. package/es/plugins/LayerModelPlugin.js +52 -136
  60. package/es/plugins/LayerStylePlugin.js +14 -23
  61. package/es/plugins/LightingPlugin.js +26 -37
  62. package/es/plugins/MultiPassRendererPlugin.js +34 -39
  63. package/es/plugins/PixelPickingPlugin.js +129 -151
  64. package/es/plugins/RegisterStyleAttributePlugin.js +80 -96
  65. package/es/plugins/ShaderUniformPlugin.js +159 -131
  66. package/es/plugins/UpdateModelPlugin.js +16 -26
  67. package/es/plugins/UpdateStyleAttributePlugin.js +47 -65
  68. package/es/point/index.js +118 -182
  69. package/es/point/models/billboard_point.js +72 -127
  70. package/es/point/models/earthExtrude.js +170 -220
  71. package/es/point/models/earthFill.js +136 -192
  72. package/es/point/models/extrude.js +167 -217
  73. package/es/point/models/fill.js +153 -210
  74. package/es/point/models/fillImage.js +156 -211
  75. package/es/point/models/image.js +127 -180
  76. package/es/point/models/index.js +1 -1
  77. package/es/point/models/normal.js +67 -122
  78. package/es/point/models/radar.js +93 -148
  79. package/es/point/models/text.js +447 -578
  80. package/es/point/shape/extrude.js +19 -25
  81. package/es/polygon/index.js +61 -99
  82. package/es/polygon/models/extrude.js +208 -281
  83. package/es/polygon/models/extrusion.js +95 -142
  84. package/es/polygon/models/fill.js +103 -155
  85. package/es/polygon/models/index.js +1 -2
  86. package/es/polygon/models/ocean.js +139 -198
  87. package/es/polygon/models/water.js +120 -179
  88. package/es/raster/buffers/triangulation.js +13 -11
  89. package/es/raster/index.js +47 -88
  90. package/es/raster/models/index.js +1 -1
  91. package/es/raster/models/raster.js +134 -202
  92. package/es/raster/models/rasterRgb.js +134 -208
  93. package/es/raster/models/rasterTerrainRgb.js +98 -153
  94. package/es/tile/core/BaseLayer.d.ts +1 -0
  95. package/es/tile/core/BaseLayer.js +206 -282
  96. package/es/tile/core/TileDebugLayer.js +12 -46
  97. package/es/tile/interaction/getRasterData.js +24 -31
  98. package/es/tile/interaction/utils.js +15 -33
  99. package/es/tile/service/TileLayerService.js +104 -177
  100. package/es/tile/service/TilePickService.js +99 -156
  101. package/es/tile/service/TileSourceService.js +17 -26
  102. package/es/tile/tile/DebugTile.js +41 -78
  103. package/es/tile/tile/ImageTile.js +33 -66
  104. package/es/tile/tile/MaskTile.js +47 -81
  105. package/es/tile/tile/RasterRGBTile.js +40 -71
  106. package/es/tile/tile/RasterTerrainRGBTile.js +33 -66
  107. package/es/tile/tile/RasterTile.js +69 -104
  108. package/es/tile/tile/Tile.d.ts +1 -1
  109. package/es/tile/tile/Tile.js +151 -232
  110. package/es/tile/tile/VectorTile.js +77 -124
  111. package/es/tile/tile/index.js +4 -2
  112. package/es/tile/utils/constants.js +1 -1
  113. package/es/tile/utils/utils.js +2 -2
  114. package/es/utils/blend.js +52 -47
  115. package/es/utils/collision-index.js +62 -70
  116. package/es/utils/extrude_polyline.js +441 -471
  117. package/es/utils/grid-index.js +97 -123
  118. package/es/utils/identityScale.js +5 -5
  119. package/es/utils/load-image.js +15 -39
  120. package/es/utils/multiPassRender.js +7 -9
  121. package/es/utils/polylineNormal.js +40 -43
  122. package/es/utils/rampcolor_legend.js +5 -4
  123. package/es/utils/simpleLine.js +53 -66
  124. package/es/utils/symbol-layout.js +95 -117
  125. package/es/wind/index.js +28 -71
  126. package/es/wind/models/index.js +1 -1
  127. package/es/wind/models/utils.js +36 -34
  128. package/es/wind/models/wind.js +203 -260
  129. package/es/wind/models/windRender.js +258 -269
  130. package/es/wind/models/windShader.js +145 -6
  131. package/lib/canvas/index.d.ts +18 -0
  132. package/lib/canvas/index.js +64 -113
  133. package/lib/canvas/models/canvas.d.ts +23 -0
  134. package/lib/canvas/models/canvas.js +97 -136
  135. package/lib/canvas/models/constants.d.ts +2 -0
  136. package/lib/canvas/models/constants.js +1 -1
  137. package/lib/canvas/models/index.d.ts +2 -0
  138. package/lib/canvas/models/index.js +2 -2
  139. package/lib/citybuliding/building.d.ts +7 -0
  140. package/lib/citybuliding/building.js +22 -58
  141. package/lib/citybuliding/models/build.d.ts +17 -0
  142. package/lib/citybuliding/models/build.js +144 -199
  143. package/lib/core/BaseLayer.d.ts +247 -0
  144. package/lib/core/BaseLayer.js +1115 -1405
  145. package/lib/core/BaseModel.d.ts +82 -0
  146. package/lib/core/BaseModel.js +262 -316
  147. package/lib/core/CommonStyleAttribute.d.ts +20 -0
  148. package/lib/core/CommonStyleAttribute.js +25 -18
  149. package/lib/core/LayerPickService.d.ts +12 -0
  150. package/lib/core/LayerPickService.js +93 -141
  151. package/lib/core/TextureService.d.ts +15 -0
  152. package/lib/core/TextureService.js +59 -68
  153. package/lib/core/constant.d.ts +6 -0
  154. package/lib/core/constant.js +2 -2
  155. package/lib/core/interface.d.ts +282 -0
  156. package/lib/core/interface.js +5 -5
  157. package/lib/core/line_trangluation.d.ts +19 -0
  158. package/lib/core/line_trangluation.js +38 -43
  159. package/lib/core/schema.d.ts +27 -0
  160. package/lib/core/shape/Path.d.ts +39 -0
  161. package/lib/core/shape/Path.js +21 -14
  162. package/lib/core/shape/arrow.d.ts +25 -0
  163. package/lib/core/shape/arrow.js +50 -62
  164. package/lib/core/shape/extrude.d.ts +17 -0
  165. package/lib/core/shape/extrude.js +54 -63
  166. package/lib/core/triangulation.d.ts +136 -0
  167. package/lib/core/triangulation.js +194 -174
  168. package/lib/core/utils.d.ts +4 -0
  169. package/lib/core/utils.js +5 -5
  170. package/lib/earth/index.d.ts +22 -0
  171. package/lib/earth/index.js +37 -73
  172. package/lib/earth/models/atmosphere.d.ts +15 -0
  173. package/lib/earth/models/atmosphere.js +100 -148
  174. package/lib/earth/models/base.d.ts +22 -0
  175. package/lib/earth/models/base.js +150 -202
  176. package/lib/earth/models/bloomsphere.d.ts +15 -0
  177. package/lib/earth/models/bloomsphere.js +99 -147
  178. package/lib/earth/utils.d.ts +26 -0
  179. package/lib/earth/utils.js +37 -39
  180. package/lib/geometry/index.d.ts +22 -0
  181. package/lib/geometry/index.js +38 -75
  182. package/lib/geometry/models/billboard.d.ts +24 -0
  183. package/lib/geometry/models/billboard.js +149 -204
  184. package/lib/geometry/models/index.d.ts +5 -0
  185. package/lib/geometry/models/index.js +1 -1
  186. package/lib/geometry/models/plane.d.ts +43 -0
  187. package/lib/geometry/models/plane.js +280 -357
  188. package/lib/geometry/models/sprite.d.ts +48 -0
  189. package/lib/geometry/models/sprite.js +184 -240
  190. package/lib/heatmap/index.d.ts +13 -0
  191. package/lib/heatmap/index.js +74 -122
  192. package/lib/heatmap/models/grid.d.ts +15 -0
  193. package/lib/heatmap/models/grid.js +68 -118
  194. package/lib/heatmap/models/grid3d.d.ts +15 -0
  195. package/lib/heatmap/models/grid3d.js +103 -151
  196. package/lib/heatmap/models/heatmap.d.ts +27 -0
  197. package/lib/heatmap/models/heatmap.js +400 -455
  198. package/lib/heatmap/models/hexagon.d.ts +15 -0
  199. package/lib/heatmap/models/hexagon.js +69 -119
  200. package/lib/heatmap/models/index.d.ts +5 -0
  201. package/lib/heatmap/models/index.js +1 -1
  202. package/lib/heatmap/triangulation.d.ts +5 -0
  203. package/lib/heatmap/triangulation.js +20 -20
  204. package/lib/image/index.d.ts +9 -0
  205. package/lib/image/index.js +25 -62
  206. package/lib/image/models/image.d.ts +17 -0
  207. package/lib/image/models/image.js +101 -163
  208. package/lib/image/models/index.d.ts +5 -0
  209. package/lib/image/models/index.js +1 -1
  210. package/lib/index.d.ts +18 -0
  211. package/lib/index.js +17 -17
  212. package/lib/line/index.d.ts +36 -0
  213. package/lib/line/index.js +67 -106
  214. package/lib/line/models/arc.d.ts +22 -0
  215. package/lib/line/models/arc.js +202 -248
  216. package/lib/line/models/arc_3d.d.ts +22 -0
  217. package/lib/line/models/arc_3d.js +193 -242
  218. package/lib/line/models/flow.d.ts +14 -0
  219. package/lib/line/models/flow.js +103 -153
  220. package/lib/line/models/great_circle.d.ts +17 -0
  221. package/lib/line/models/great_circle.js +185 -234
  222. package/lib/line/models/index.d.ts +5 -0
  223. package/lib/line/models/index.js +1 -1
  224. package/lib/line/models/line.d.ts +27 -0
  225. package/lib/line/models/line.js +233 -285
  226. package/lib/line/models/simple_line.d.ts +19 -0
  227. package/lib/line/models/simple_line.js +144 -192
  228. package/lib/line/models/wall.d.ts +17 -0
  229. package/lib/line/models/wall.js +223 -273
  230. package/lib/line/shaders/line/line_vert.glsl +0 -2
  231. package/lib/line/shaders/wall/wall_vert.glsl +15 -0
  232. package/lib/mask/index.d.ts +16 -0
  233. package/lib/mask/index.js +18 -53
  234. package/lib/mask/models/fill.d.ts +18 -0
  235. package/lib/mask/models/fill.js +53 -108
  236. package/lib/mask/models/index.d.ts +5 -0
  237. package/lib/mask/models/index.js +1 -1
  238. package/lib/plugins/DataMappingPlugin.d.ts +13 -0
  239. package/lib/plugins/DataMappingPlugin.js +206 -250
  240. package/lib/plugins/DataSourcePlugin.d.ts +6 -0
  241. package/lib/plugins/DataSourcePlugin.js +65 -91
  242. package/lib/plugins/FeatureScalePlugin.d.ts +20 -0
  243. package/lib/plugins/FeatureScalePlugin.js +261 -304
  244. package/lib/plugins/LayerAnimateStylePlugin.d.ts +4 -0
  245. package/lib/plugins/LayerAnimateStylePlugin.js +13 -21
  246. package/lib/plugins/LayerMaskPlugin.d.ts +7 -0
  247. package/lib/plugins/LayerMaskPlugin.js +16 -24
  248. package/lib/plugins/LayerModelPlugin.d.ts +10 -0
  249. package/lib/plugins/LayerModelPlugin.js +53 -135
  250. package/lib/plugins/LayerStylePlugin.d.ts +7 -0
  251. package/lib/plugins/LayerStylePlugin.js +15 -23
  252. package/lib/plugins/LightingPlugin.d.ts +35 -0
  253. package/lib/plugins/LightingPlugin.js +27 -36
  254. package/lib/plugins/MultiPassRendererPlugin.d.ts +22 -0
  255. package/lib/plugins/MultiPassRendererPlugin.js +35 -38
  256. package/lib/plugins/PixelPickingPlugin.d.ts +11 -0
  257. package/lib/plugins/PixelPickingPlugin.js +130 -150
  258. package/lib/plugins/RegisterStyleAttributePlugin.d.ts +11 -0
  259. package/lib/plugins/RegisterStyleAttributePlugin.js +81 -96
  260. package/lib/plugins/ShaderUniformPlugin.d.ts +22 -0
  261. package/lib/plugins/ShaderUniformPlugin.js +160 -130
  262. package/lib/plugins/UpdateModelPlugin.d.ts +7 -0
  263. package/lib/plugins/UpdateModelPlugin.js +17 -26
  264. package/lib/plugins/UpdateStyleAttributePlugin.d.ts +9 -0
  265. package/lib/plugins/UpdateStyleAttributePlugin.js +48 -65
  266. package/lib/plugins/index.d.ts +15 -0
  267. package/lib/point/index.d.ts +33 -0
  268. package/lib/point/index.js +120 -182
  269. package/lib/point/models/billboard_point.d.ts +21 -0
  270. package/lib/point/models/billboard_point.js +74 -127
  271. package/lib/point/models/earthExtrude.d.ts +16 -0
  272. package/lib/point/models/earthExtrude.js +172 -220
  273. package/lib/point/models/earthFill.d.ts +15 -0
  274. package/lib/point/models/earthFill.js +138 -192
  275. package/lib/point/models/extrude.d.ts +16 -0
  276. package/lib/point/models/extrude.js +169 -217
  277. package/lib/point/models/fill.d.ts +31 -0
  278. package/lib/point/models/fill.js +155 -210
  279. package/lib/point/models/fillImage.d.ts +26 -0
  280. package/lib/point/models/fillImage.js +159 -211
  281. package/lib/point/models/image.d.ts +18 -0
  282. package/lib/point/models/image.js +129 -180
  283. package/lib/point/models/index.d.ts +5 -0
  284. package/lib/point/models/index.js +1 -1
  285. package/lib/point/models/normal.d.ts +22 -0
  286. package/lib/point/models/normal.js +69 -122
  287. package/lib/point/models/radar.d.ts +22 -0
  288. package/lib/point/models/radar.js +95 -148
  289. package/lib/point/models/text.d.ts +69 -0
  290. package/lib/point/models/text.js +449 -578
  291. package/lib/point/shape/extrude.d.ts +15 -0
  292. package/lib/point/shape/extrude.js +19 -25
  293. package/lib/polygon/index.d.ts +18 -0
  294. package/lib/polygon/index.js +63 -99
  295. package/lib/polygon/models/extrude.d.ts +25 -0
  296. package/lib/polygon/models/extrude.js +210 -281
  297. package/lib/polygon/models/extrusion.d.ts +24 -0
  298. package/lib/polygon/models/extrusion.js +97 -142
  299. package/lib/polygon/models/fill.d.ts +18 -0
  300. package/lib/polygon/models/fill.js +104 -154
  301. package/lib/polygon/models/index.d.ts +5 -0
  302. package/lib/polygon/models/index.js +1 -1
  303. package/lib/polygon/models/ocean.d.ts +23 -0
  304. package/lib/polygon/models/ocean.js +141 -198
  305. package/lib/polygon/models/water.d.ts +21 -0
  306. package/lib/polygon/models/water.js +122 -179
  307. package/lib/raster/buffers/triangulation.d.ts +6 -0
  308. package/lib/raster/buffers/triangulation.js +13 -11
  309. package/lib/raster/index.d.ts +11 -0
  310. package/lib/raster/index.js +49 -88
  311. package/lib/raster/models/index.d.ts +5 -0
  312. package/lib/raster/models/index.js +1 -1
  313. package/lib/raster/models/raster.d.ts +21 -0
  314. package/lib/raster/models/raster.js +136 -202
  315. package/lib/raster/models/rasterRgb.d.ts +21 -0
  316. package/lib/raster/models/rasterRgb.js +136 -208
  317. package/lib/raster/models/rasterTerrainRgb.d.ts +16 -0
  318. package/lib/raster/models/rasterTerrainRgb.js +100 -153
  319. package/lib/tile/core/BaseLayer.d.ts +48 -0
  320. package/lib/tile/core/BaseLayer.js +207 -281
  321. package/lib/tile/core/TileDebugLayer.d.ts +15 -0
  322. package/lib/tile/core/TileDebugLayer.js +14 -46
  323. package/lib/tile/interaction/getFeatureData.d.ts +0 -0
  324. package/lib/tile/interaction/getRasterData.d.ts +4 -0
  325. package/lib/tile/interaction/getRasterData.js +24 -32
  326. package/lib/tile/interaction/utils.d.ts +11 -0
  327. package/lib/tile/interaction/utils.js +15 -34
  328. package/lib/tile/interface.d.ts +29 -0
  329. package/lib/tile/service/TileLayerService.d.ts +33 -0
  330. package/lib/tile/service/TileLayerService.js +105 -177
  331. package/lib/tile/service/TilePickService.d.ts +26 -0
  332. package/lib/tile/service/TilePickService.js +100 -156
  333. package/lib/tile/service/TileSourceService.d.ts +7 -0
  334. package/lib/tile/service/TileSourceService.js +20 -29
  335. package/lib/tile/tile/DebugTile.d.ts +16 -0
  336. package/lib/tile/tile/DebugTile.js +43 -78
  337. package/lib/tile/tile/ImageTile.d.ts +14 -0
  338. package/lib/tile/tile/ImageTile.js +35 -66
  339. package/lib/tile/tile/MaskTile.d.ts +18 -0
  340. package/lib/tile/tile/MaskTile.js +49 -81
  341. package/lib/tile/tile/RasterRGBTile.d.ts +11 -0
  342. package/lib/tile/tile/RasterRGBTile.js +42 -71
  343. package/lib/tile/tile/RasterTerrainRGBTile.d.ts +14 -0
  344. package/lib/tile/tile/RasterTerrainRGBTile.js +35 -66
  345. package/lib/tile/tile/RasterTile.d.ts +18 -0
  346. package/lib/tile/tile/RasterTile.js +71 -104
  347. package/lib/tile/tile/Tile.d.ts +114 -0
  348. package/lib/tile/tile/Tile.js +152 -231
  349. package/lib/tile/tile/VectorTile.d.ts +26 -0
  350. package/lib/tile/tile/VectorTile.js +79 -124
  351. package/lib/tile/tile/index.d.ts +12 -0
  352. package/lib/tile/tile/index.js +6 -4
  353. package/lib/tile/tile/util.d.ts +5 -0
  354. package/lib/tile/utils/constants.d.ts +1 -0
  355. package/lib/tile/utils/constants.js +1 -1
  356. package/lib/tile/utils/utils.d.ts +8 -0
  357. package/lib/tile/utils/utils.js +2 -2
  358. package/lib/utils/blend.d.ts +2 -0
  359. package/lib/utils/blend.js +52 -48
  360. package/lib/utils/collision-index.d.ts +47 -0
  361. package/lib/utils/collision-index.js +64 -69
  362. package/lib/utils/extrude_polyline.d.ts +68 -0
  363. package/lib/utils/extrude_polyline.js +442 -470
  364. package/lib/utils/grid-index.d.ts +28 -0
  365. package/lib/utils/grid-index.js +97 -123
  366. package/lib/utils/identityScale.d.ts +8 -0
  367. package/lib/utils/identityScale.js +5 -5
  368. package/lib/utils/load-image.d.ts +1 -0
  369. package/lib/utils/load-image.js +15 -39
  370. package/lib/utils/multiPassRender.d.ts +16 -0
  371. package/lib/utils/multiPassRender.js +7 -10
  372. package/lib/utils/polylineNormal.d.ts +9 -0
  373. package/lib/utils/polylineNormal.js +40 -44
  374. package/lib/utils/rampcolor_legend.d.ts +6 -0
  375. package/lib/utils/rampcolor_legend.js +5 -5
  376. package/lib/utils/simpleLine.d.ts +23 -0
  377. package/lib/utils/simpleLine.js +54 -65
  378. package/lib/utils/stencil.d.ts +7 -0
  379. package/lib/utils/symbol-layout.d.ts +43 -0
  380. package/lib/utils/symbol-layout.js +95 -117
  381. package/lib/wind/index.d.ts +11 -0
  382. package/lib/wind/index.js +30 -71
  383. package/lib/wind/models/index.d.ts +5 -0
  384. package/lib/wind/models/index.js +1 -1
  385. package/lib/wind/models/utils.d.ts +19 -0
  386. package/lib/wind/models/utils.js +36 -34
  387. package/lib/wind/models/wind.d.ts +24 -0
  388. package/lib/wind/models/wind.js +205 -260
  389. package/lib/wind/models/windRender.d.ts +104 -0
  390. package/lib/wind/models/windRender.js +261 -272
  391. package/lib/wind/models/windShader.d.ts +12 -0
  392. package/lib/wind/models/windShader.js +145 -6
  393. package/package.json +16 -19
  394. package/CHANGELOG.md +0 -492
  395. package/LICENSE.md +0 -21
  396. package/es/glsl.d.ts +0 -5
  397. package/lib/glsl.d.ts +0 -5
@@ -6,39 +6,28 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.TextTrianglation = TextTrianglation;
8
8
  exports.default = void 0;
9
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
10
9
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
10
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
12
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
14
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
15
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
16
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
17
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
18
11
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
19
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
20
12
  var _l7Core = require("@antv/l7-core");
21
13
  var _l7Utils = require("@antv/l7-utils");
22
- var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
14
+ var _BaseModel = _interopRequireDefault(require("../../core/BaseModel"));
23
15
  var _collisionIndex = _interopRequireDefault(require("../../utils/collision-index"));
24
16
  var _symbolLayout = require("../../utils/symbol-layout");
25
17
  var _CommonStyleAttribute = require("../../core/CommonStyleAttribute");
26
- 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; } } }; }
27
- 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); }
28
- 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; }
29
- 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); }; }
30
- 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; } }
31
18
  /* babel-plugin-inline-import '../shaders/text/text_frag.glsl' */
32
- var textFrag = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 48.0\n\nuniform sampler2D u_sdf_map;\nlayout(std140) uniform commonUniforms {\n vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\n vec2 u_sdf_map_size;\n float u_raisingHeight: 0.0;\n float u_stroke_width : 2;\n float u_gamma_scale : 0.5;\n float u_halo_blur : 0.5;\n};\n\nin vec2 v_uv;\nin float v_gamma_scale;\nin vec4 v_color;\nin vec4 v_stroke_color;\nin float v_fontScale;\n\nout vec4 outputColor;\n\n#pragma include \"picking\"\nvoid main() {\n // get style data mapping\n\n // get sdf from atlas\n float dist = texture(SAMPLER_2D(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 outputColor = mix(v_color, v_stroke_color, smoothstep(0., 0.5, 1.- dist));\n\n outputColor.a *= alpha;\n // \u4F5C\u4E3A mask \u6A21\u677F\u65F6\u9700\u8981\u4E22\u5F03\u900F\u660E\u7684\u50CF\u7D20\n if (outputColor.a < 0.01) {\n discard;\n }\n outputColor = filterColor(outputColor);\n}\n";
19
+ const textFrag = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 48.0\n\nuniform sampler2D u_sdf_map;\nlayout(std140) uniform commonUniforms {\n vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\n vec2 u_sdf_map_size;\n float u_raisingHeight: 0.0;\n float u_stroke_width : 2;\n float u_gamma_scale : 0.5;\n float u_halo_blur : 0.5;\n};\n\nin vec2 v_uv;\nin float v_gamma_scale;\nin vec4 v_color;\nin vec4 v_stroke_color;\nin float v_fontScale;\n\nout vec4 outputColor;\n\n#pragma include \"picking\"\nvoid main() {\n // get style data mapping\n\n // get sdf from atlas\n float dist = texture(SAMPLER_2D(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 outputColor = mix(v_color, v_stroke_color, smoothstep(0., 0.5, 1.- dist));\n\n outputColor.a *= alpha;\n // \u4F5C\u4E3A mask \u6A21\u677F\u65F6\u9700\u8981\u4E22\u5F03\u900F\u660E\u7684\u50CF\u7D20\n if (outputColor.a < 0.01) {\n discard;\n }\n outputColor = filterColor(outputColor);\n}\n";
33
20
  /* babel-plugin-inline-import '../shaders/text/text_vert.glsl' */
34
- var textVert = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 24.0\n\nlayout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in float a_Size;\nlayout(location = 10) in vec2 a_textOffsets;\nlayout(location = 14) in vec2 a_tex;\n\nlayout(std140) uniform commonUniforms {\n vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\n vec2 u_sdf_map_size;\n float u_raisingHeight: 0.0;\n float u_stroke_width : 2;\n float u_gamma_scale : 0.5;\n float u_halo_blur : 0.5;\n};\n\nout vec2 v_uv;\nout float v_gamma_scale;\nout vec4 v_color;\nout vec4 v_stroke_color;\nout float v_fontScale;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n#pragma include \"rotation_2d\"\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 vec2 offset = rotate_matrix(a_textOffsets,rotation);\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 = project_common_position_to_clipspace_v2(vec4(project_pos.xyz + vec3(0.0, 0.0, raiseHeight), 1.0));\n\n gl_Position = vec4(\n projected_position.xy / projected_position.w + offset * 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
- var isEqual = _l7Utils.lodashUtil.isEqual;
21
+ const textVert = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 24.0\n\nlayout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in float a_Size;\nlayout(location = 10) in vec2 a_textOffsets;\nlayout(location = 14) in vec2 a_tex;\n\nlayout(std140) uniform commonUniforms {\n vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\n vec2 u_sdf_map_size;\n float u_raisingHeight: 0.0;\n float u_stroke_width : 2;\n float u_gamma_scale : 0.5;\n float u_halo_blur : 0.5;\n};\n\nout vec2 v_uv;\nout float v_gamma_scale;\nout vec4 v_color;\nout vec4 v_stroke_color;\nout float v_fontScale;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n#pragma include \"rotation_2d\"\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 vec2 offset = rotate_matrix(a_textOffsets,rotation);\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 = project_common_position_to_clipspace_v2(vec4(project_pos.xyz + vec3(0.0, 0.0, raiseHeight), 1.0));\n\n gl_Position = vec4(\n projected_position.xy / projected_position.w + offset * 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";
22
+ const {
23
+ isEqual
24
+ } = _l7Utils.lodashUtil;
36
25
  function TextTrianglation(feature) {
37
26
  // @ts-ignore
38
- var that = this;
39
- var id = feature.id;
40
- var vertices = [];
41
- var indices = [];
27
+ const that = this;
28
+ const id = feature.id;
29
+ const vertices = [];
30
+ const indices = [];
42
31
  if (!that.glyphInfoMap || !that.glyphInfoMap[id]) {
43
32
  return {
44
33
  vertices: [],
@@ -47,588 +36,470 @@ function TextTrianglation(feature) {
47
36
  size: 7
48
37
  };
49
38
  }
50
- var centroid = that.glyphInfoMap[id].centroid; // 计算中心点
51
- var coord = centroid.length === 2 ? [centroid[0], centroid[1], 0] : centroid;
52
- that.glyphInfoMap[id].glyphQuads.forEach(function (quad, index) {
53
- vertices.push.apply(vertices, (0, _toConsumableArray2.default)(coord).concat([quad.tex.x, quad.tex.y + quad.tex.height, quad.tl.x, quad.tl.y], (0, _toConsumableArray2.default)(coord), [quad.tex.x + quad.tex.width, quad.tex.y + quad.tex.height, quad.tr.x, quad.tr.y], (0, _toConsumableArray2.default)(coord), [quad.tex.x + quad.tex.width, quad.tex.y, quad.br.x, quad.br.y], (0, _toConsumableArray2.default)(coord), [quad.tex.x, quad.tex.y, quad.bl.x, quad.bl.y]));
39
+ const centroid = that.glyphInfoMap[id].centroid; // 计算中心点
40
+ const coord = centroid.length === 2 ? [centroid[0], centroid[1], 0] : centroid;
41
+ that.glyphInfoMap[id].glyphQuads.forEach((quad, index) => {
42
+ vertices.push(...coord, quad.tex.x, quad.tex.y + quad.tex.height, quad.tl.x, quad.tl.y, ...coord, quad.tex.x + quad.tex.width, quad.tex.y + quad.tex.height, quad.tr.x, quad.tr.y, ...coord, quad.tex.x + quad.tex.width, quad.tex.y, quad.br.x, quad.br.y, ...coord, quad.tex.x, quad.tex.y, quad.bl.x, quad.bl.y);
54
43
  indices.push(0 + index * 4, 1 + index * 4, 2 + index * 4, 2 + index * 4, 3 + index * 4, 0 + index * 4);
55
44
  });
56
45
  return {
57
- vertices: vertices,
46
+ vertices,
58
47
  // [ x, y, z, tex.x,tex.y, offset.x. offset.y]
59
- indices: indices,
48
+ indices,
60
49
  size: 7
61
50
  };
62
51
  }
63
- var TextModel = exports.default = /*#__PURE__*/function (_BaseModel) {
64
- (0, _inherits2.default)(TextModel, _BaseModel);
65
- var _super = _createSuper(TextModel);
66
- function TextModel() {
52
+ class TextModel extends _BaseModel.default {
53
+ constructor(...args) {
67
54
  var _this;
68
- (0, _classCallCheck2.default)(this, TextModel);
69
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
70
- args[_key] = arguments[_key];
71
- }
72
- _this = _super.call.apply(_super, [this].concat(args));
73
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "glyphInfoMap", {});
74
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "currentZoom", -1);
75
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "textureHeight", 0);
76
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "textCount", 0);
77
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "preTextStyle", {});
78
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "mapping", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
79
- return _regenerator.default.wrap(function _callee$(_context) {
80
- while (1) switch (_context.prev = _context.next) {
81
- case 0:
82
- _this.initGlyph(); //
83
- _this.updateTexture();
84
- _context.next = 4;
85
- return _this.reBuildModel();
86
- case 4:
87
- case "end":
88
- return _context.stop();
89
- }
90
- }, _callee);
91
- })));
92
- return _this;
55
+ super(...args);
56
+ _this = this;
57
+ (0, _defineProperty2.default)(this, "glyphInfo", void 0);
58
+ (0, _defineProperty2.default)(this, "glyphInfoMap", {});
59
+ (0, _defineProperty2.default)(this, "rawEncodeData", void 0);
60
+ (0, _defineProperty2.default)(this, "texture", void 0);
61
+ (0, _defineProperty2.default)(this, "currentZoom", -1);
62
+ (0, _defineProperty2.default)(this, "extent", void 0);
63
+ (0, _defineProperty2.default)(this, "textureHeight", 0);
64
+ (0, _defineProperty2.default)(this, "textCount", 0);
65
+ (0, _defineProperty2.default)(this, "preTextStyle", {});
66
+ (0, _defineProperty2.default)(this, "mapping", /*#__PURE__*/(0, _asyncToGenerator2.default)(function* () {
67
+ _this.initGlyph(); //
68
+ _this.updateTexture();
69
+ yield _this.reBuildModel();
70
+ }));
93
71
  }
94
- (0, _createClass2.default)(TextModel, [{
95
- key: "getUninforms",
96
- value: function getUninforms() {
97
- var commoninfo = this.getCommonUniformsInfo();
98
- var attributeInfo = this.getUniformsBufferInfo(this.getStyleAttribute());
99
- this.updateStyleUnifoms();
100
- return (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, commoninfo.uniformsOption), attributeInfo.uniformsOption), {
101
- u_sdf_map: this.textures[0]
102
- });
72
+ getUninforms() {
73
+ const commoninfo = this.getCommonUniformsInfo();
74
+ const attributeInfo = this.getUniformsBufferInfo(this.getStyleAttribute());
75
+ this.updateStyleUnifoms();
76
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, commoninfo.uniformsOption), attributeInfo.uniformsOption), {
77
+ u_sdf_map: this.textures[0]
78
+ });
79
+ }
80
+ getCommonUniformsInfo() {
81
+ const {
82
+ stroke = '#fff',
83
+ strokeWidth = 0,
84
+ halo = 0.5,
85
+ gamma = 2.0,
86
+ raisingHeight = 0
87
+ } = this.layer.getLayerConfig();
88
+ const mapping = this.getFontServiceMapping();
89
+ const canvas = this.getFontServiceCanvas();
90
+ if (mapping && Object.keys(mapping).length !== this.textCount && canvas) {
91
+ this.updateTexture();
92
+ this.textCount = Object.keys(mapping).length;
103
93
  }
104
- }, {
105
- key: "getCommonUniformsInfo",
106
- value: function getCommonUniformsInfo() {
107
- var _ref2 = this.layer.getLayerConfig(),
108
- _ref2$stroke = _ref2.stroke,
109
- stroke = _ref2$stroke === void 0 ? '#fff' : _ref2$stroke,
110
- _ref2$strokeWidth = _ref2.strokeWidth,
111
- strokeWidth = _ref2$strokeWidth === void 0 ? 0 : _ref2$strokeWidth,
112
- _ref2$halo = _ref2.halo,
113
- halo = _ref2$halo === void 0 ? 0.5 : _ref2$halo,
114
- _ref2$gamma = _ref2.gamma,
115
- gamma = _ref2$gamma === void 0 ? 2.0 : _ref2$gamma,
116
- _ref2$raisingHeight = _ref2.raisingHeight,
117
- raisingHeight = _ref2$raisingHeight === void 0 ? 0 : _ref2$raisingHeight;
118
- var mapping = this.getFontServiceMapping();
119
- var canvas = this.getFontServiceCanvas();
120
- if (mapping && Object.keys(mapping).length !== this.textCount && canvas) {
121
- this.updateTexture();
122
- this.textCount = Object.keys(mapping).length;
94
+ this.preTextStyle = this.getTextStyle();
95
+ const commonOptions = {
96
+ u_stroke_color: (0, _l7Utils.rgb2arr)(stroke),
97
+ u_sdf_map_size: [(canvas === null || canvas === void 0 ? void 0 : canvas.width) || 1, (canvas === null || canvas === void 0 ? void 0 : canvas.height) || 1],
98
+ u_raisingHeight: Number(raisingHeight),
99
+ u_stroke_width: strokeWidth,
100
+ u_gamma_scale: gamma,
101
+ u_halo_blur: halo
102
+ };
103
+ const commonBufferInfo = this.getUniformsBufferInfo(commonOptions);
104
+ return commonBufferInfo;
105
+ }
106
+ initModels() {
107
+ var _this2 = this;
108
+ return (0, _asyncToGenerator2.default)(function* () {
109
+ // 绑定事件
110
+ _this2.bindEvent();
111
+ _this2.extent = _this2.textExtent();
112
+ _this2.rawEncodeData = _this2.layer.getEncodedData();
113
+ _this2.preTextStyle = _this2.getTextStyle();
114
+ _this2.initUniformsBuffer();
115
+ return _this2.buildModels();
116
+ })();
117
+ }
118
+ buildModels() {
119
+ var _this3 = this;
120
+ return (0, _asyncToGenerator2.default)(function* () {
121
+ const {
122
+ textAllowOverlap = false
123
+ } = _this3.layer.getLayerConfig();
124
+
125
+ // this.mapping(); 重复调用
126
+ _this3.initGlyph(); //
127
+ _this3.updateTexture();
128
+ if (!textAllowOverlap) {
129
+ _this3.filterGlyphs();
123
130
  }
124
- this.preTextStyle = this.getTextStyle();
125
- var commonOptions = {
126
- u_stroke_color: (0, _l7Utils.rgb2arr)(stroke),
127
- u_sdf_map_size: [(canvas === null || canvas === void 0 ? void 0 : canvas.width) || 1, (canvas === null || canvas === void 0 ? void 0 : canvas.height) || 1],
128
- u_raisingHeight: Number(raisingHeight),
129
- u_stroke_width: strokeWidth,
130
- u_gamma_scale: gamma,
131
- u_halo_blur: halo
132
- };
133
- var commonBufferInfo = this.getUniformsBufferInfo(commonOptions);
134
- return commonBufferInfo;
135
- }
136
- }, {
137
- key: "initModels",
138
- value: function () {
139
- var _initModels = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
140
- return _regenerator.default.wrap(function _callee2$(_context2) {
141
- while (1) switch (_context2.prev = _context2.next) {
142
- case 0:
143
- // 绑定事件
144
- this.bindEvent();
145
- this.extent = this.textExtent();
146
- this.rawEncodeData = this.layer.getEncodedData();
147
- this.preTextStyle = this.getTextStyle();
148
- this.initUniformsBuffer();
149
- return _context2.abrupt("return", this.buildModels());
150
- case 6:
151
- case "end":
152
- return _context2.stop();
153
- }
154
- }, _callee2, this);
155
- }));
156
- function initModels() {
157
- return _initModels.apply(this, arguments);
131
+ const model = yield _this3.layer.buildLayerModel({
132
+ moduleName: 'pointText',
133
+ vertexShader: textVert,
134
+ fragmentShader: textFrag,
135
+ inject: _this3.getInject(),
136
+ triangulation: TextTrianglation.bind(_this3),
137
+ depth: {
138
+ enable: false
139
+ }
140
+ });
141
+ return [model];
142
+ })();
143
+ }
144
+ // 需要更新的场景
145
+ // 1. 文本偏移量发生改变
146
+ // 2. 文本锚点发生改变
147
+ // 3. 文本允许重叠发生改变
148
+ // 4. 文本字体发生改变
149
+ // 5. 文本字体粗细发生改变
150
+ needUpdate() {
151
+ var _this4 = this;
152
+ return (0, _asyncToGenerator2.default)(function* () {
153
+ const {
154
+ textAllowOverlap = false,
155
+ textAnchor = 'center',
156
+ textOffset,
157
+ padding,
158
+ fontFamily,
159
+ fontWeight
160
+ } = _this4.getTextStyle();
161
+ if (!isEqual(padding, _this4.preTextStyle.padding) || !isEqual(textOffset, _this4.preTextStyle.textOffset) || !isEqual(textAnchor, _this4.preTextStyle.textAnchor) || !isEqual(fontFamily, _this4.preTextStyle.fontFamily) || !isEqual(fontWeight, _this4.preTextStyle.fontWeight)) {
162
+ yield _this4.mapping();
163
+ return true;
158
164
  }
159
- return initModels;
160
- }()
161
- }, {
162
- key: "buildModels",
163
- value: function () {
164
- var _buildModels = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
165
- var _ref3, _ref3$textAllowOverla, textAllowOverlap, model;
166
- return _regenerator.default.wrap(function _callee3$(_context3) {
167
- while (1) switch (_context3.prev = _context3.next) {
168
- case 0:
169
- _ref3 = this.layer.getLayerConfig(), _ref3$textAllowOverla = _ref3.textAllowOverlap, textAllowOverlap = _ref3$textAllowOverla === void 0 ? false : _ref3$textAllowOverla; // this.mapping(); 重复调用
170
- this.initGlyph(); //
171
- this.updateTexture();
172
- if (!textAllowOverlap) {
173
- this.filterGlyphs();
174
- }
175
- _context3.next = 6;
176
- return this.layer.buildLayerModel({
177
- moduleName: 'pointText',
178
- vertexShader: textVert,
179
- fragmentShader: textFrag,
180
- inject: this.getInject(),
181
- triangulation: TextTrianglation.bind(this),
182
- depth: {
183
- enable: false
184
- }
185
- });
186
- case 6:
187
- model = _context3.sent;
188
- return _context3.abrupt("return", [model]);
189
- case 8:
190
- case "end":
191
- return _context3.stop();
192
- }
193
- }, _callee3, this);
194
- }));
195
- function buildModels() {
196
- return _buildModels.apply(this, arguments);
165
+ if (textAllowOverlap) {
166
+ // 小于不做避让
167
+ return false;
197
168
  }
198
- return buildModels;
199
- }() // 需要更新的场景
200
- // 1. 文本偏移量发生改变
201
- // 2. 文本锚点发生改变
202
- // 3. 文本允许重叠发生改变
203
- // 4. 文本字体发生改变
204
- // 5. 文本字体粗细发生改变
205
- }, {
206
- key: "needUpdate",
207
- value: function () {
208
- var _needUpdate = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
209
- var _ref4, _ref4$textAllowOverla, textAllowOverlap, _ref4$textAnchor, textAnchor, textOffset, padding, fontFamily, fontWeight, zoom, extent, flag;
210
- return _regenerator.default.wrap(function _callee4$(_context4) {
211
- while (1) switch (_context4.prev = _context4.next) {
212
- case 0:
213
- _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;
214
- 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))) {
215
- _context4.next = 5;
216
- break;
217
- }
218
- _context4.next = 4;
219
- return this.mapping();
220
- case 4:
221
- return _context4.abrupt("return", true);
222
- case 5:
223
- if (!textAllowOverlap) {
224
- _context4.next = 7;
225
- break;
226
- }
227
- return _context4.abrupt("return", false);
228
- case 7:
229
- // textAllowOverlap 发生改变
230
- zoom = this.mapService.getZoom();
231
- extent = this.mapService.getBounds();
232
- flag = (0, _l7Utils.boundsContains)(this.extent, extent); // 文本不能压盖则进行过滤
233
- if (!(Math.abs(this.currentZoom - zoom) > 0.5 || !flag || textAllowOverlap !== this.preTextStyle.textAllowOverlap)) {
234
- _context4.next = 14;
235
- break;
236
- }
237
- _context4.next = 13;
238
- return this.reBuildModel();
239
- case 13:
240
- return _context4.abrupt("return", true);
241
- case 14:
242
- return _context4.abrupt("return", false);
243
- case 15:
244
- case "end":
245
- return _context4.stop();
246
- }
247
- }, _callee4, this);
248
- }));
249
- function needUpdate() {
250
- return _needUpdate.apply(this, arguments);
169
+
170
+ // textAllowOverlap 发生改变
171
+ const zoom = _this4.mapService.getZoom();
172
+ const extent = _this4.mapService.getBounds();
173
+ const flag = (0, _l7Utils.boundsContains)(_this4.extent, extent);
174
+ // 文本不能压盖则进行过滤
175
+ if (Math.abs(_this4.currentZoom - zoom) > 0.5 || !flag || textAllowOverlap !== _this4.preTextStyle.textAllowOverlap) {
176
+ // TODO this.mapping 数据未变化,避让
177
+ yield _this4.reBuildModel();
178
+ return true;
251
179
  }
252
- return needUpdate;
253
- }()
254
- }, {
255
- key: "clearModels",
256
- value: function clearModels() {
257
- var _this$texture;
258
- (_this$texture = this.texture) === null || _this$texture === void 0 || _this$texture.destroy();
259
- // TODO this.mapping
260
- this.layer.off('remapping', this.mapping);
261
- }
262
- }, {
263
- key: "registerBuiltinAttributes",
264
- value: function registerBuiltinAttributes() {
265
- this.styleAttributeService.registerStyleAttribute({
266
- name: 'textOffsets',
267
- type: _l7Core.AttributeType.Attribute,
268
- descriptor: {
269
- shaderLocation: 10,
270
- name: 'a_textOffsets',
271
- // 文字偏移量
272
- buffer: {
273
- // give the WebGL driver a hint that this buffer may change
274
- usage: _l7Core.gl.STATIC_DRAW,
275
- data: [],
276
- type: _l7Core.gl.FLOAT
277
- },
278
- size: 2,
279
- update: function update(feature, featureIdx, vertex) {
280
- return [vertex[5], vertex[6]];
281
- }
180
+ return false;
181
+ })();
182
+ }
183
+ clearModels() {
184
+ var _this$texture;
185
+ (_this$texture = this.texture) === null || _this$texture === void 0 || _this$texture.destroy();
186
+ // TODO this.mapping
187
+ this.layer.off('remapping', this.mapping);
188
+ }
189
+ registerBuiltinAttributes() {
190
+ this.styleAttributeService.registerStyleAttribute({
191
+ name: 'textOffsets',
192
+ type: _l7Core.AttributeType.Attribute,
193
+ descriptor: {
194
+ shaderLocation: 10,
195
+ name: 'a_textOffsets',
196
+ // 文字偏移量
197
+ buffer: {
198
+ // give the WebGL driver a hint that this buffer may change
199
+ usage: _l7Core.gl.STATIC_DRAW,
200
+ data: [],
201
+ type: _l7Core.gl.FLOAT
202
+ },
203
+ size: 2,
204
+ update: (feature, featureIdx, vertex) => {
205
+ return [vertex[5], vertex[6]];
282
206
  }
283
- });
284
- this.styleAttributeService.registerStyleAttribute({
285
- name: 'textUv',
286
- type: _l7Core.AttributeType.Attribute,
287
- descriptor: {
288
- name: 'a_tex',
289
- shaderLocation: _CommonStyleAttribute.ShaderLocation.UV,
290
- buffer: {
291
- usage: _l7Core.gl.DYNAMIC_DRAW,
292
- data: [],
293
- type: _l7Core.gl.FLOAT
294
- },
295
- size: 2,
296
- update: function update(feature, featureIdx, vertex) {
297
- return [vertex[3], vertex[4]];
298
- }
207
+ }
208
+ });
209
+ this.styleAttributeService.registerStyleAttribute({
210
+ name: 'textUv',
211
+ type: _l7Core.AttributeType.Attribute,
212
+ descriptor: {
213
+ name: 'a_tex',
214
+ shaderLocation: _CommonStyleAttribute.ShaderLocation.UV,
215
+ buffer: {
216
+ usage: _l7Core.gl.DYNAMIC_DRAW,
217
+ data: [],
218
+ type: _l7Core.gl.FLOAT
219
+ },
220
+ size: 2,
221
+ update: (feature, featureIdx, vertex) => {
222
+ return [vertex[3], vertex[4]];
299
223
  }
300
- });
301
- // point layer size;
302
- this.styleAttributeService.registerStyleAttribute({
303
- name: 'size',
304
- type: _l7Core.AttributeType.Attribute,
305
- descriptor: {
306
- name: 'a_Size',
307
- shaderLocation: _CommonStyleAttribute.ShaderLocation.SIZE,
308
- buffer: {
309
- // give the WebGL driver a hint that this buffer may change
310
- usage: _l7Core.gl.DYNAMIC_DRAW,
311
- data: [],
312
- type: _l7Core.gl.FLOAT
313
- },
314
- size: 1,
315
- update: function update(feature) {
316
- var _feature$size = feature.size,
317
- size = _feature$size === void 0 ? 12 : _feature$size;
318
- return Array.isArray(size) ? [size[0]] : [size];
319
- }
224
+ }
225
+ });
226
+ // point layer size;
227
+ this.styleAttributeService.registerStyleAttribute({
228
+ name: 'size',
229
+ type: _l7Core.AttributeType.Attribute,
230
+ descriptor: {
231
+ name: 'a_Size',
232
+ shaderLocation: _CommonStyleAttribute.ShaderLocation.SIZE,
233
+ buffer: {
234
+ // give the WebGL driver a hint that this buffer may change
235
+ usage: _l7Core.gl.DYNAMIC_DRAW,
236
+ data: [],
237
+ type: _l7Core.gl.FLOAT
238
+ },
239
+ size: 1,
240
+ update: feature => {
241
+ const {
242
+ size = 12
243
+ } = feature;
244
+ return Array.isArray(size) ? [size[0]] : [size];
320
245
  }
321
- });
322
- }
323
- }, {
324
- key: "bindEvent",
325
- value: function bindEvent() {
326
- if (!this.layer.isTileLayer) {
327
- // 重新绑定
328
- this.layer.on('remapping', this.mapping);
329
246
  }
247
+ });
248
+ }
249
+ bindEvent() {
250
+ if (!this.layer.isTileLayer) {
251
+ // 重新绑定
252
+ this.layer.on('remapping', this.mapping);
330
253
  }
331
- }, {
332
- key: "textExtent",
333
- value: function textExtent() {
334
- var bounds = this.mapService.getBounds();
335
- return (0, _l7Utils.padBounds)(bounds, 0.5);
336
- }
337
- /**
338
- * 生成文字纹理(生成文字纹理字典)
339
- */
340
- }, {
341
- key: "initTextFont",
342
- value: function initTextFont() {
343
- var _this$getTextStyle = this.getTextStyle(),
344
- fontWeight = _this$getTextStyle.fontWeight,
345
- fontFamily = _this$getTextStyle.fontFamily;
346
- var data = this.rawEncodeData;
347
- var characterSet = [];
348
- data.forEach(function (item) {
349
- var _item$shape = item.shape,
350
- shape = _item$shape === void 0 ? '' : _item$shape;
351
- shape = shape.toString();
352
- var _iterator = _createForOfIteratorHelper(shape),
353
- _step;
354
- try {
355
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
356
- var char = _step.value;
357
- // 去重
358
- if (characterSet.indexOf(char) === -1) {
359
- characterSet.push(char);
360
- }
361
- }
362
- } catch (err) {
363
- _iterator.e(err);
364
- } finally {
365
- _iterator.f();
254
+ }
255
+ textExtent() {
256
+ const bounds = this.mapService.getBounds();
257
+ return (0, _l7Utils.padBounds)(bounds, 0.5);
258
+ }
259
+ /**
260
+ * 生成文字纹理(生成文字纹理字典)
261
+ */
262
+ initTextFont() {
263
+ const {
264
+ fontWeight,
265
+ fontFamily
266
+ } = this.getTextStyle();
267
+ const data = this.rawEncodeData;
268
+ const characterSet = [];
269
+ data.forEach(item => {
270
+ let {
271
+ shape = ''
272
+ } = item;
273
+ shape = shape.toString();
274
+ for (const char of shape) {
275
+ // 去重
276
+ if (characterSet.indexOf(char) === -1) {
277
+ characterSet.push(char);
366
278
  }
367
- });
368
- this.fontService.setFontOptions({
369
- characterSet: characterSet,
370
- fontWeight: fontWeight,
371
- fontFamily: fontFamily,
372
- iconfont: false
373
- });
374
- }
279
+ }
280
+ });
281
+ this.fontService.setFontOptions({
282
+ characterSet,
283
+ fontWeight,
284
+ fontFamily,
285
+ iconfont: false
286
+ });
287
+ }
375
288
 
376
- /**
377
- * 生成 iconfont 纹理字典
378
- */
379
- }, {
380
- key: "initIconFontTex",
381
- value: function initIconFontTex() {
382
- var _this$getTextStyle2 = this.getTextStyle(),
383
- fontWeight = _this$getTextStyle2.fontWeight,
384
- fontFamily = _this$getTextStyle2.fontFamily;
385
- var data = this.rawEncodeData;
386
- var characterSet = [];
387
- data.forEach(function (item) {
388
- var _item$shape2 = item.shape,
389
- shape = _item$shape2 === void 0 ? '' : _item$shape2;
390
- shape = "".concat(shape);
391
- if (characterSet.indexOf(shape) === -1) {
392
- characterSet.push(shape);
393
- }
394
- });
395
- this.fontService.setFontOptions({
396
- characterSet: characterSet,
397
- fontWeight: fontWeight,
398
- fontFamily: fontFamily,
399
- iconfont: true
400
- });
401
- }
402
- }, {
403
- key: "getTextStyle",
404
- value: function getTextStyle() {
405
- var _ref5 = this.layer.getLayerConfig(),
406
- _ref5$fontWeight = _ref5.fontWeight,
407
- fontWeight = _ref5$fontWeight === void 0 ? '400' : _ref5$fontWeight,
408
- _ref5$fontFamily = _ref5.fontFamily,
409
- fontFamily = _ref5$fontFamily === void 0 ? 'sans-serif' : _ref5$fontFamily,
410
- _ref5$textAllowOverla = _ref5.textAllowOverlap,
411
- textAllowOverlap = _ref5$textAllowOverla === void 0 ? false : _ref5$textAllowOverla,
412
- _ref5$padding = _ref5.padding,
413
- padding = _ref5$padding === void 0 ? [0, 0] : _ref5$padding,
414
- _ref5$textAnchor = _ref5.textAnchor,
415
- textAnchor = _ref5$textAnchor === void 0 ? 'center' : _ref5$textAnchor,
416
- _ref5$textOffset = _ref5.textOffset,
417
- textOffset = _ref5$textOffset === void 0 ? [0, 0] : _ref5$textOffset,
418
- _ref5$opacity = _ref5.opacity,
419
- opacity = _ref5$opacity === void 0 ? 1 : _ref5$opacity,
420
- _ref5$strokeOpacity = _ref5.strokeOpacity,
421
- strokeOpacity = _ref5$strokeOpacity === void 0 ? 1 : _ref5$strokeOpacity,
422
- _ref5$strokeWidth = _ref5.strokeWidth,
423
- strokeWidth = _ref5$strokeWidth === void 0 ? 0 : _ref5$strokeWidth,
424
- _ref5$stroke = _ref5.stroke,
425
- stroke = _ref5$stroke === void 0 ? '#000' : _ref5$stroke;
426
- return {
427
- fontWeight: fontWeight,
428
- fontFamily: fontFamily,
429
- textAllowOverlap: textAllowOverlap,
430
- padding: padding,
431
- textAnchor: textAnchor,
432
- textOffset: textOffset,
433
- opacity: opacity,
434
- strokeOpacity: strokeOpacity,
435
- strokeWidth: strokeWidth,
436
- stroke: stroke
437
- };
438
- }
289
+ /**
290
+ * 生成 iconfont 纹理字典
291
+ */
292
+ initIconFontTex() {
293
+ const {
294
+ fontWeight,
295
+ fontFamily
296
+ } = this.getTextStyle();
297
+ const data = this.rawEncodeData;
298
+ const characterSet = [];
299
+ data.forEach(item => {
300
+ let {
301
+ shape = ''
302
+ } = item;
303
+ shape = `${shape}`;
304
+ if (characterSet.indexOf(shape) === -1) {
305
+ characterSet.push(shape);
306
+ }
307
+ });
308
+ this.fontService.setFontOptions({
309
+ characterSet,
310
+ fontWeight,
311
+ fontFamily,
312
+ iconfont: true
313
+ });
314
+ }
315
+ getTextStyle() {
316
+ const {
317
+ fontWeight = '400',
318
+ fontFamily = 'sans-serif',
319
+ textAllowOverlap = false,
320
+ padding = [0, 0],
321
+ textAnchor = 'center',
322
+ textOffset = [0, 0],
323
+ opacity = 1,
324
+ strokeOpacity = 1,
325
+ strokeWidth = 0,
326
+ stroke = '#000'
327
+ } = this.layer.getLayerConfig();
328
+ return {
329
+ fontWeight,
330
+ fontFamily,
331
+ textAllowOverlap,
332
+ padding,
333
+ textAnchor,
334
+ textOffset,
335
+ opacity,
336
+ strokeOpacity,
337
+ strokeWidth,
338
+ stroke
339
+ };
340
+ }
439
341
 
440
- /**
441
- * 生成文字布局(对照文字纹理字典提取对应文字的位置很好信息)
442
- */
443
- }, {
444
- key: "generateGlyphLayout",
445
- value: function generateGlyphLayout(iconfont) {
446
- var _this2 = this;
447
- var mapping = this.getFontServiceMapping();
448
- var _ref6 = this.layer.getLayerConfig(),
449
- _ref6$spacing = _ref6.spacing,
450
- spacing = _ref6$spacing === void 0 ? 2 : _ref6$spacing,
451
- _ref6$textAnchor = _ref6.textAnchor,
452
- textAnchor = _ref6$textAnchor === void 0 ? 'center' : _ref6$textAnchor,
453
- textOffset = _ref6.textOffset;
454
- var data = this.rawEncodeData;
455
- this.glyphInfo = data.map(function (feature) {
456
- var _feature$shape = feature.shape,
457
- shape = _feature$shape === void 0 ? '' : _feature$shape,
458
- id = feature.id,
459
- _feature$size2 = feature.size,
460
- size = _feature$size2 === void 0 ? 1 : _feature$size2;
461
- var offset = feature.textOffset ? feature.textOffset : textOffset || [0, 0];
462
- var anchor = feature.textAnchor ? feature.textAnchor : textAnchor || 'center';
463
- var shaping = (0, _symbolLayout.shapeText)(shape.toString(), mapping,
464
- // @ts-ignore
465
- size, anchor, 'left', spacing, offset,
466
- //
467
- iconfont);
468
- var glyphQuads = (0, _symbolLayout.getGlyphQuads)(shaping, offset, false);
469
- feature.shaping = shaping;
470
- feature.glyphQuads = glyphQuads;
471
- // feature.centroid = calculteCentroid(coordinates);
342
+ /**
343
+ * 生成文字布局(对照文字纹理字典提取对应文字的位置很好信息)
344
+ */
345
+ generateGlyphLayout(iconfont) {
346
+ const mapping = this.getFontServiceMapping();
347
+ const {
348
+ spacing = 2,
349
+ textAnchor = 'center',
350
+ textOffset
351
+ } = this.layer.getLayerConfig();
352
+ const data = this.rawEncodeData;
353
+ this.glyphInfo = data.map(feature => {
354
+ const {
355
+ shape = '',
356
+ id,
357
+ size = 1
358
+ } = feature;
359
+ const offset = feature.textOffset ? feature.textOffset : textOffset || [0, 0];
360
+ const anchor = feature.textAnchor ? feature.textAnchor : textAnchor || 'center';
361
+ const shaping = (0, _symbolLayout.shapeText)(shape.toString(), mapping,
362
+ // @ts-ignore
363
+ size, anchor, 'left', spacing, offset,
364
+ //
365
+ iconfont);
366
+ const glyphQuads = (0, _symbolLayout.getGlyphQuads)(shaping, offset, false);
367
+ feature.shaping = shaping;
368
+ feature.glyphQuads = glyphQuads;
369
+ // feature.centroid = calculteCentroid(coordinates);
472
370
 
473
- feature.centroid = (0, _l7Utils.calculateCentroid)(feature.coordinates);
371
+ feature.centroid = (0, _l7Utils.calculateCentroid)(feature.coordinates);
474
372
 
475
- // 此时地图高德2.0 originCentroid == centroid
476
- feature.originCentroid = feature.version === 'GAODE2.x' ? (0, _l7Utils.calculateCentroid)(feature.originCoordinates) : feature.originCentroid = feature.centroid;
477
- _this2.glyphInfoMap[id] = {
478
- shaping: shaping,
479
- glyphQuads: glyphQuads,
480
- centroid: (0, _l7Utils.calculateCentroid)(feature.coordinates)
481
- };
482
- return feature;
483
- });
484
- }
485
- }, {
486
- key: "getFontServiceMapping",
487
- value: function getFontServiceMapping() {
488
- var _ref7 = this.layer.getLayerConfig(),
489
- _ref7$fontWeight = _ref7.fontWeight,
490
- fontWeight = _ref7$fontWeight === void 0 ? '400' : _ref7$fontWeight,
491
- _ref7$fontFamily = _ref7.fontFamily,
492
- fontFamily = _ref7$fontFamily === void 0 ? 'sans-serif' : _ref7$fontFamily;
493
- return this.fontService.getMappingByKey("".concat(fontFamily, "_").concat(fontWeight));
494
- }
495
- }, {
496
- key: "getFontServiceCanvas",
497
- value: function getFontServiceCanvas() {
498
- var _ref8 = this.layer.getLayerConfig(),
499
- _ref8$fontWeight = _ref8.fontWeight,
500
- fontWeight = _ref8$fontWeight === void 0 ? '400' : _ref8$fontWeight,
501
- _ref8$fontFamily = _ref8.fontFamily,
502
- fontFamily = _ref8$fontFamily === void 0 ? 'sans-serif' : _ref8$fontFamily;
503
- // 更新文字布局
504
- return this.fontService.getCanvasByKey("".concat(fontFamily, "_").concat(fontWeight));
505
- }
373
+ // 此时地图高德2.0 originCentroid == centroid
374
+ feature.originCentroid = feature.version === 'GAODE2.x' ? (0, _l7Utils.calculateCentroid)(feature.originCoordinates) : feature.originCentroid = feature.centroid;
375
+ this.glyphInfoMap[id] = {
376
+ shaping,
377
+ glyphQuads,
378
+ centroid: (0, _l7Utils.calculateCentroid)(feature.coordinates)
379
+ };
380
+ return feature;
381
+ });
382
+ }
383
+ getFontServiceMapping() {
384
+ const {
385
+ fontWeight = '400',
386
+ fontFamily = 'sans-serif'
387
+ } = this.layer.getLayerConfig();
388
+ return this.fontService.getMappingByKey(`${fontFamily}_${fontWeight}`);
389
+ }
390
+ getFontServiceCanvas() {
391
+ const {
392
+ fontWeight = '400',
393
+ fontFamily = 'sans-serif'
394
+ } = this.layer.getLayerConfig();
395
+ // 更新文字布局
396
+ return this.fontService.getCanvasByKey(`${fontFamily}_${fontWeight}`);
397
+ }
506
398
 
507
- /**
508
- * 文字避让 depend on originCentorid
509
- */
510
- }, {
511
- key: "filterGlyphs",
512
- value: function filterGlyphs() {
513
- var _this3 = this;
514
- var _ref9 = this.layer.getLayerConfig(),
515
- _ref9$padding = _ref9.padding,
516
- padding = _ref9$padding === void 0 ? [0, 0] : _ref9$padding,
517
- _ref9$textAllowOverla = _ref9.textAllowOverlap,
518
- textAllowOverlap = _ref9$textAllowOverla === void 0 ? false : _ref9$textAllowOverla;
519
- if (textAllowOverlap) {
520
- // 如果允许文本覆盖
521
- return;
522
- }
523
- this.glyphInfoMap = {};
524
- this.currentZoom = this.mapService.getZoom();
525
- this.extent = this.textExtent();
526
- var _this$rendererService = this.rendererService.getViewportSize(),
527
- width = _this$rendererService.width,
528
- height = _this$rendererService.height;
529
- var collisionIndex = new _collisionIndex.default(width, height);
530
- var filterData = this.glyphInfo.filter(function (feature) {
531
- var shaping = feature.shaping,
532
- _feature$id = feature.id,
533
- id = _feature$id === void 0 ? 0 : _feature$id;
534
- // const centroid = feature.centroid as [number, number];
535
- // const centroid = feature.originCentroid as [number, number];
536
- var centroid = feature.version === 'GAODE2.x' ? feature.originCentroid : feature.centroid;
537
- var size = feature.size;
538
- var fontScale = size / 16;
539
- var pixels = _this3.mapService.lngLatToContainer(centroid);
540
- var _collisionIndex$place = collisionIndex.placeCollisionBox({
541
- x1: shaping.left * fontScale - padding[0],
542
- x2: shaping.right * fontScale + padding[0],
543
- y1: shaping.top * fontScale - padding[1],
544
- y2: shaping.bottom * fontScale + padding[1],
545
- anchorPointX: pixels.x,
546
- anchorPointY: pixels.y
547
- }),
548
- box = _collisionIndex$place.box;
549
- if (box && box.length) {
550
- collisionIndex.insertCollisionBox(box, id);
551
- return true;
552
- } else {
553
- return false;
554
- }
555
- });
556
- filterData.forEach(function (item) {
557
- // @ts-ignore
558
- _this3.glyphInfoMap[item.id] = item;
559
- });
560
- // this.layer.setEncodedData(filterData);
561
- }
562
- /**
563
- * 初始化文字布局
564
- */
565
- }, {
566
- key: "initGlyph",
567
- value: function initGlyph() {
568
- var _this$layer$getLayerC = this.layer.getLayerConfig(),
569
- _this$layer$getLayerC2 = _this$layer$getLayerC.iconfont,
570
- iconfont = _this$layer$getLayerC2 === void 0 ? false : _this$layer$getLayerC2;
571
- // 1.生成文字纹理(或是生成 iconfont)
572
- iconfont ? this.initIconFontTex() : this.initTextFont();
573
- // 2.生成文字布局
574
- this.generateGlyphLayout(iconfont);
399
+ /**
400
+ * 文字避让 depend on originCentorid
401
+ */
402
+ filterGlyphs() {
403
+ const {
404
+ padding = [0, 0],
405
+ textAllowOverlap = false
406
+ } = this.layer.getLayerConfig();
407
+ if (textAllowOverlap) {
408
+ // 如果允许文本覆盖
409
+ return;
575
410
  }
576
- /**
577
- * 更新文字纹理
578
- */
579
- }, {
580
- key: "updateTexture",
581
- value: function updateTexture() {
582
- var createTexture2D = this.rendererService.createTexture2D;
583
- var canvas = this.getFontServiceCanvas();
584
- this.textureHeight = canvas.height;
585
- if (this.texture) {
586
- this.texture.destroy();
587
- }
588
- this.texture = createTexture2D({
589
- data: canvas,
590
- mag: _l7Core.gl.LINEAR,
591
- min: _l7Core.gl.LINEAR,
592
- width: canvas.width,
593
- height: canvas.height
411
+ this.glyphInfoMap = {};
412
+ this.currentZoom = this.mapService.getZoom();
413
+ this.extent = this.textExtent();
414
+ const {
415
+ width,
416
+ height
417
+ } = this.rendererService.getViewportSize();
418
+ const collisionIndex = new _collisionIndex.default(width, height);
419
+ const filterData = this.glyphInfo.filter(feature => {
420
+ const {
421
+ shaping,
422
+ id = 0
423
+ } = feature;
424
+ // const centroid = feature.centroid as [number, number];
425
+ // const centroid = feature.originCentroid as [number, number];
426
+ const centroid = feature.version === 'GAODE2.x' ? feature.originCentroid : feature.centroid;
427
+ const size = feature.size;
428
+ const fontScale = size / 16;
429
+ const pixels = this.mapService.lngLatToContainer(centroid);
430
+ const {
431
+ box
432
+ } = collisionIndex.placeCollisionBox({
433
+ x1: shaping.left * fontScale - padding[0],
434
+ x2: shaping.right * fontScale + padding[0],
435
+ y1: shaping.top * fontScale - padding[1],
436
+ y2: shaping.bottom * fontScale + padding[1],
437
+ anchorPointX: pixels.x,
438
+ anchorPointY: pixels.y
594
439
  });
595
- this.textures = [this.texture];
596
- }
597
- }, {
598
- key: "reBuildModel",
599
- value: function () {
600
- var _reBuildModel = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
601
- var model;
602
- return _regenerator.default.wrap(function _callee5$(_context5) {
603
- while (1) switch (_context5.prev = _context5.next) {
604
- case 0:
605
- this.filterGlyphs();
606
- _context5.next = 3;
607
- return this.layer.buildLayerModel({
608
- moduleName: 'pointText',
609
- vertexShader: textVert,
610
- fragmentShader: textFrag,
611
- triangulation: TextTrianglation.bind(this),
612
- inject: this.getInject(),
613
- depth: {
614
- enable: false
615
- }
616
- });
617
- case 3:
618
- model = _context5.sent;
619
- // TODO 渲染流程待修改
620
- this.layer.models = [model];
621
- case 5:
622
- case "end":
623
- return _context5.stop();
624
- }
625
- }, _callee5, this);
626
- }));
627
- function reBuildModel() {
628
- return _reBuildModel.apply(this, arguments);
440
+ if (box && box.length) {
441
+ collisionIndex.insertCollisionBox(box, id);
442
+ return true;
443
+ } else {
444
+ return false;
629
445
  }
630
- return reBuildModel;
631
- }()
632
- }]);
633
- return TextModel;
634
- }(_BaseModel2.default);
446
+ });
447
+ filterData.forEach(item => {
448
+ // @ts-ignore
449
+ this.glyphInfoMap[item.id] = item;
450
+ });
451
+ // this.layer.setEncodedData(filterData);
452
+ }
453
+ /**
454
+ * 初始化文字布局
455
+ */
456
+ initGlyph() {
457
+ const {
458
+ iconfont = false
459
+ } = this.layer.getLayerConfig();
460
+ // 1.生成文字纹理(或是生成 iconfont)
461
+ iconfont ? this.initIconFontTex() : this.initTextFont();
462
+ // 2.生成文字布局
463
+ this.generateGlyphLayout(iconfont);
464
+ }
465
+ /**
466
+ * 更新文字纹理
467
+ */
468
+ updateTexture() {
469
+ const {
470
+ createTexture2D
471
+ } = this.rendererService;
472
+ const canvas = this.getFontServiceCanvas();
473
+ this.textureHeight = canvas.height;
474
+ if (this.texture) {
475
+ this.texture.destroy();
476
+ }
477
+ this.texture = createTexture2D({
478
+ data: canvas,
479
+ mag: _l7Core.gl.LINEAR,
480
+ min: _l7Core.gl.LINEAR,
481
+ width: canvas.width,
482
+ height: canvas.height
483
+ });
484
+ this.textures = [this.texture];
485
+ }
486
+ reBuildModel() {
487
+ var _this5 = this;
488
+ return (0, _asyncToGenerator2.default)(function* () {
489
+ _this5.filterGlyphs();
490
+ const model = yield _this5.layer.buildLayerModel({
491
+ moduleName: 'pointText',
492
+ vertexShader: textVert,
493
+ fragmentShader: textFrag,
494
+ triangulation: TextTrianglation.bind(_this5),
495
+ inject: _this5.getInject(),
496
+ depth: {
497
+ enable: false
498
+ }
499
+ });
500
+ // TODO 渲染流程待修改
501
+ _this5.layer.models = [model];
502
+ })();
503
+ }
504
+ }
505
+ exports.default = TextModel;