@antv/l7-layers 2.21.1 → 2.21.3

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 (394) 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 +1 -1
  7. package/es/core/BaseLayer.js +1113 -1412
  8. package/es/core/BaseModel.js +263 -317
  9. package/es/core/CommonStyleAttribute.js +25 -18
  10. package/es/core/LayerPickService.js +92 -141
  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 -12
  16. package/es/core/shape/arrow.js +50 -62
  17. package/es/core/shape/extrude.js +54 -62
  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 -201
  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 -121
  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 -241
  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 +230 -285
  47. package/es/line/models/simple_line.js +142 -192
  48. package/es/line/models/wall.js +221 -273
  49. package/es/mask/index.js +16 -53
  50. package/es/mask/models/fill.js +51 -108
  51. package/es/mask/models/index.js +1 -1
  52. package/es/plugins/DataMappingPlugin.js +205 -249
  53. package/es/plugins/DataSourcePlugin.js +64 -92
  54. package/es/plugins/FeatureScalePlugin.js +258 -302
  55. package/es/plugins/LayerAnimateStylePlugin.js +12 -22
  56. package/es/plugins/LayerMaskPlugin.js +15 -24
  57. package/es/plugins/LayerModelPlugin.js +52 -136
  58. package/es/plugins/LayerStylePlugin.js +14 -23
  59. package/es/plugins/LightingPlugin.js +26 -37
  60. package/es/plugins/MultiPassRendererPlugin.js +34 -39
  61. package/es/plugins/PixelPickingPlugin.js +129 -150
  62. package/es/plugins/RegisterStyleAttributePlugin.js +80 -96
  63. package/es/plugins/ShaderUniformPlugin.js +159 -131
  64. package/es/plugins/UpdateModelPlugin.js +16 -26
  65. package/es/plugins/UpdateStyleAttributePlugin.js +47 -65
  66. package/es/plugins/index.d.ts +1 -1
  67. package/es/point/index.js +118 -182
  68. package/es/point/models/billboard_point.js +72 -127
  69. package/es/point/models/earthExtrude.js +170 -220
  70. package/es/point/models/earthFill.js +136 -192
  71. package/es/point/models/extrude.js +167 -217
  72. package/es/point/models/fill.js +152 -209
  73. package/es/point/models/fillImage.js +156 -211
  74. package/es/point/models/image.js +127 -180
  75. package/es/point/models/index.js +1 -1
  76. package/es/point/models/normal.js +67 -122
  77. package/es/point/models/radar.js +93 -148
  78. package/es/point/models/text.js +447 -578
  79. package/es/point/shape/extrude.js +19 -25
  80. package/es/polygon/index.js +61 -99
  81. package/es/polygon/models/extrude.js +208 -281
  82. package/es/polygon/models/extrusion.js +95 -142
  83. package/es/polygon/models/fill.js +102 -153
  84. package/es/polygon/models/index.js +1 -1
  85. package/es/polygon/models/ocean.js +139 -198
  86. package/es/polygon/models/water.js +120 -179
  87. package/es/raster/buffers/triangulation.js +13 -11
  88. package/es/raster/index.js +47 -88
  89. package/es/raster/models/index.js +1 -1
  90. package/es/raster/models/raster.js +134 -202
  91. package/es/raster/models/rasterRgb.js +134 -208
  92. package/es/raster/models/rasterTerrainRgb.js +98 -153
  93. package/es/tile/core/BaseLayer.d.ts +1 -0
  94. package/es/tile/core/BaseLayer.js +206 -282
  95. package/es/tile/core/TileDebugLayer.js +12 -46
  96. package/es/tile/interaction/getRasterData.js +24 -30
  97. package/es/tile/interaction/utils.js +15 -33
  98. package/es/tile/service/TileLayerService.js +104 -177
  99. package/es/tile/service/TilePickService.js +99 -156
  100. package/es/tile/service/TileSourceService.js +17 -26
  101. package/es/tile/tile/DebugTile.js +41 -78
  102. package/es/tile/tile/ImageTile.js +33 -66
  103. package/es/tile/tile/MaskTile.js +47 -81
  104. package/es/tile/tile/RasterRGBTile.js +40 -71
  105. package/es/tile/tile/RasterTerrainRGBTile.js +33 -66
  106. package/es/tile/tile/RasterTile.js +69 -104
  107. package/es/tile/tile/Tile.d.ts +1 -1
  108. package/es/tile/tile/Tile.js +151 -232
  109. package/es/tile/tile/VectorTile.js +77 -124
  110. package/es/tile/tile/index.d.ts +1 -1
  111. package/es/tile/tile/index.js +4 -2
  112. package/es/tile/tile/util.d.ts +1 -1
  113. package/es/tile/utils/constants.js +1 -1
  114. package/es/tile/utils/utils.js +2 -2
  115. package/es/utils/blend.js +52 -46
  116. package/es/utils/collision-index.js +62 -70
  117. package/es/utils/extrude_polyline.js +441 -471
  118. package/es/utils/grid-index.js +97 -123
  119. package/es/utils/identityScale.js +5 -5
  120. package/es/utils/load-image.js +15 -39
  121. package/es/utils/multiPassRender.js +7 -9
  122. package/es/utils/polylineNormal.js +40 -42
  123. package/es/utils/rampcolor_legend.js +5 -3
  124. package/es/utils/simpleLine.js +53 -66
  125. package/es/utils/symbol-layout.js +95 -117
  126. package/es/wind/index.js +28 -70
  127. package/es/wind/models/index.js +1 -1
  128. package/es/wind/models/utils.js +36 -34
  129. package/es/wind/models/wind.js +203 -260
  130. package/es/wind/models/windRender.js +258 -269
  131. package/es/wind/models/windShader.js +145 -6
  132. package/lib/canvas/index.d.ts +18 -0
  133. package/lib/canvas/index.js +64 -113
  134. package/lib/canvas/models/canvas.d.ts +23 -0
  135. package/lib/canvas/models/canvas.js +97 -136
  136. package/lib/canvas/models/constants.d.ts +2 -0
  137. package/lib/canvas/models/constants.js +1 -1
  138. package/lib/canvas/models/index.d.ts +2 -0
  139. package/lib/canvas/models/index.js +2 -2
  140. package/lib/citybuliding/building.d.ts +7 -0
  141. package/lib/citybuliding/building.js +22 -58
  142. package/lib/citybuliding/models/build.d.ts +17 -0
  143. package/lib/citybuliding/models/build.js +144 -199
  144. package/lib/core/BaseLayer.d.ts +247 -0
  145. package/lib/core/BaseLayer.js +1115 -1412
  146. package/lib/core/BaseModel.d.ts +82 -0
  147. package/lib/core/BaseModel.js +263 -315
  148. package/lib/core/CommonStyleAttribute.d.ts +20 -0
  149. package/lib/core/CommonStyleAttribute.js +25 -18
  150. package/lib/core/LayerPickService.d.ts +12 -0
  151. package/lib/core/LayerPickService.js +93 -140
  152. package/lib/core/TextureService.d.ts +15 -0
  153. package/lib/core/TextureService.js +59 -68
  154. package/lib/core/constant.d.ts +6 -0
  155. package/lib/core/constant.js +2 -2
  156. package/lib/core/interface.d.ts +282 -0
  157. package/lib/core/interface.js +5 -5
  158. package/lib/core/line_trangluation.d.ts +19 -0
  159. package/lib/core/line_trangluation.js +38 -43
  160. package/lib/core/schema.d.ts +27 -0
  161. package/lib/core/shape/Path.d.ts +39 -0
  162. package/lib/core/shape/Path.js +21 -13
  163. package/lib/core/shape/arrow.d.ts +25 -0
  164. package/lib/core/shape/arrow.js +50 -62
  165. package/lib/core/shape/extrude.d.ts +17 -0
  166. package/lib/core/shape/extrude.js +54 -62
  167. package/lib/core/triangulation.d.ts +136 -0
  168. package/lib/core/triangulation.js +194 -174
  169. package/lib/core/utils.d.ts +4 -0
  170. package/lib/core/utils.js +5 -5
  171. package/lib/earth/index.d.ts +22 -0
  172. package/lib/earth/index.js +37 -73
  173. package/lib/earth/models/atmosphere.d.ts +15 -0
  174. package/lib/earth/models/atmosphere.js +100 -148
  175. package/lib/earth/models/base.d.ts +22 -0
  176. package/lib/earth/models/base.js +150 -201
  177. package/lib/earth/models/bloomsphere.d.ts +15 -0
  178. package/lib/earth/models/bloomsphere.js +99 -147
  179. package/lib/earth/utils.d.ts +26 -0
  180. package/lib/earth/utils.js +37 -39
  181. package/lib/geometry/index.d.ts +22 -0
  182. package/lib/geometry/index.js +38 -75
  183. package/lib/geometry/models/billboard.d.ts +24 -0
  184. package/lib/geometry/models/billboard.js +149 -204
  185. package/lib/geometry/models/index.d.ts +5 -0
  186. package/lib/geometry/models/index.js +1 -1
  187. package/lib/geometry/models/plane.d.ts +43 -0
  188. package/lib/geometry/models/plane.js +280 -357
  189. package/lib/geometry/models/sprite.d.ts +48 -0
  190. package/lib/geometry/models/sprite.js +184 -240
  191. package/lib/heatmap/index.d.ts +13 -0
  192. package/lib/heatmap/index.js +74 -121
  193. package/lib/heatmap/models/grid.d.ts +15 -0
  194. package/lib/heatmap/models/grid.js +68 -118
  195. package/lib/heatmap/models/grid3d.d.ts +15 -0
  196. package/lib/heatmap/models/grid3d.js +103 -151
  197. package/lib/heatmap/models/heatmap.d.ts +27 -0
  198. package/lib/heatmap/models/heatmap.js +400 -455
  199. package/lib/heatmap/models/hexagon.d.ts +15 -0
  200. package/lib/heatmap/models/hexagon.js +69 -119
  201. package/lib/heatmap/models/index.d.ts +5 -0
  202. package/lib/heatmap/models/index.js +1 -1
  203. package/lib/heatmap/triangulation.d.ts +5 -0
  204. package/lib/heatmap/triangulation.js +20 -20
  205. package/lib/image/index.d.ts +9 -0
  206. package/lib/image/index.js +25 -62
  207. package/lib/image/models/image.d.ts +17 -0
  208. package/lib/image/models/image.js +101 -163
  209. package/lib/image/models/index.d.ts +5 -0
  210. package/lib/image/models/index.js +1 -1
  211. package/lib/index.d.ts +18 -0
  212. package/lib/index.js +17 -17
  213. package/lib/line/index.d.ts +36 -0
  214. package/lib/line/index.js +67 -106
  215. package/lib/line/models/arc.d.ts +22 -0
  216. package/lib/line/models/arc.js +202 -248
  217. package/lib/line/models/arc_3d.d.ts +22 -0
  218. package/lib/line/models/arc_3d.js +193 -241
  219. package/lib/line/models/flow.d.ts +14 -0
  220. package/lib/line/models/flow.js +103 -153
  221. package/lib/line/models/great_circle.d.ts +17 -0
  222. package/lib/line/models/great_circle.js +185 -234
  223. package/lib/line/models/index.d.ts +5 -0
  224. package/lib/line/models/index.js +1 -1
  225. package/lib/line/models/line.d.ts +27 -0
  226. package/lib/line/models/line.js +232 -285
  227. package/lib/line/models/simple_line.d.ts +19 -0
  228. package/lib/line/models/simple_line.js +144 -192
  229. package/lib/line/models/wall.d.ts +17 -0
  230. package/lib/line/models/wall.js +223 -273
  231. package/lib/mask/index.d.ts +16 -0
  232. package/lib/mask/index.js +18 -53
  233. package/lib/mask/models/fill.d.ts +18 -0
  234. package/lib/mask/models/fill.js +53 -108
  235. package/lib/mask/models/index.d.ts +5 -0
  236. package/lib/mask/models/index.js +1 -1
  237. package/lib/plugins/DataMappingPlugin.d.ts +13 -0
  238. package/lib/plugins/DataMappingPlugin.js +206 -248
  239. package/lib/plugins/DataSourcePlugin.d.ts +6 -0
  240. package/lib/plugins/DataSourcePlugin.js +65 -91
  241. package/lib/plugins/FeatureScalePlugin.d.ts +20 -0
  242. package/lib/plugins/FeatureScalePlugin.js +261 -304
  243. package/lib/plugins/LayerAnimateStylePlugin.d.ts +4 -0
  244. package/lib/plugins/LayerAnimateStylePlugin.js +13 -21
  245. package/lib/plugins/LayerMaskPlugin.d.ts +7 -0
  246. package/lib/plugins/LayerMaskPlugin.js +16 -24
  247. package/lib/plugins/LayerModelPlugin.d.ts +10 -0
  248. package/lib/plugins/LayerModelPlugin.js +53 -135
  249. package/lib/plugins/LayerStylePlugin.d.ts +7 -0
  250. package/lib/plugins/LayerStylePlugin.js +15 -23
  251. package/lib/plugins/LightingPlugin.d.ts +35 -0
  252. package/lib/plugins/LightingPlugin.js +27 -36
  253. package/lib/plugins/MultiPassRendererPlugin.d.ts +22 -0
  254. package/lib/plugins/MultiPassRendererPlugin.js +35 -38
  255. package/lib/plugins/PixelPickingPlugin.d.ts +11 -0
  256. package/lib/plugins/PixelPickingPlugin.js +130 -149
  257. package/lib/plugins/RegisterStyleAttributePlugin.d.ts +11 -0
  258. package/lib/plugins/RegisterStyleAttributePlugin.js +81 -96
  259. package/lib/plugins/ShaderUniformPlugin.d.ts +22 -0
  260. package/lib/plugins/ShaderUniformPlugin.js +160 -130
  261. package/lib/plugins/UpdateModelPlugin.d.ts +7 -0
  262. package/lib/plugins/UpdateModelPlugin.js +17 -26
  263. package/lib/plugins/UpdateStyleAttributePlugin.d.ts +9 -0
  264. package/lib/plugins/UpdateStyleAttributePlugin.js +48 -65
  265. package/lib/plugins/index.d.ts +15 -0
  266. package/lib/point/index.d.ts +33 -0
  267. package/lib/point/index.js +120 -182
  268. package/lib/point/models/billboard_point.d.ts +21 -0
  269. package/lib/point/models/billboard_point.js +74 -127
  270. package/lib/point/models/earthExtrude.d.ts +16 -0
  271. package/lib/point/models/earthExtrude.js +172 -220
  272. package/lib/point/models/earthFill.d.ts +15 -0
  273. package/lib/point/models/earthFill.js +138 -192
  274. package/lib/point/models/extrude.d.ts +16 -0
  275. package/lib/point/models/extrude.js +169 -217
  276. package/lib/point/models/fill.d.ts +31 -0
  277. package/lib/point/models/fill.js +154 -209
  278. package/lib/point/models/fillImage.d.ts +26 -0
  279. package/lib/point/models/fillImage.js +159 -211
  280. package/lib/point/models/image.d.ts +18 -0
  281. package/lib/point/models/image.js +129 -180
  282. package/lib/point/models/index.d.ts +5 -0
  283. package/lib/point/models/index.js +1 -1
  284. package/lib/point/models/normal.d.ts +22 -0
  285. package/lib/point/models/normal.js +69 -122
  286. package/lib/point/models/radar.d.ts +22 -0
  287. package/lib/point/models/radar.js +95 -148
  288. package/lib/point/models/text.d.ts +69 -0
  289. package/lib/point/models/text.js +449 -578
  290. package/lib/point/shape/extrude.d.ts +15 -0
  291. package/lib/point/shape/extrude.js +19 -25
  292. package/lib/polygon/index.d.ts +18 -0
  293. package/lib/polygon/index.js +63 -99
  294. package/lib/polygon/models/extrude.d.ts +25 -0
  295. package/lib/polygon/models/extrude.js +210 -281
  296. package/lib/polygon/models/extrusion.d.ts +24 -0
  297. package/lib/polygon/models/extrusion.js +97 -142
  298. package/lib/polygon/models/fill.d.ts +18 -0
  299. package/lib/polygon/models/fill.js +104 -153
  300. package/lib/polygon/models/index.d.ts +5 -0
  301. package/lib/polygon/models/index.js +1 -1
  302. package/lib/polygon/models/ocean.d.ts +23 -0
  303. package/lib/polygon/models/ocean.js +141 -198
  304. package/lib/polygon/models/water.d.ts +21 -0
  305. package/lib/polygon/models/water.js +122 -179
  306. package/lib/raster/buffers/triangulation.d.ts +6 -0
  307. package/lib/raster/buffers/triangulation.js +13 -11
  308. package/lib/raster/index.d.ts +11 -0
  309. package/lib/raster/index.js +49 -88
  310. package/lib/raster/models/index.d.ts +5 -0
  311. package/lib/raster/models/index.js +1 -1
  312. package/lib/raster/models/raster.d.ts +21 -0
  313. package/lib/raster/models/raster.js +136 -202
  314. package/lib/raster/models/rasterRgb.d.ts +21 -0
  315. package/lib/raster/models/rasterRgb.js +136 -208
  316. package/lib/raster/models/rasterTerrainRgb.d.ts +16 -0
  317. package/lib/raster/models/rasterTerrainRgb.js +100 -153
  318. package/lib/tile/core/BaseLayer.d.ts +48 -0
  319. package/lib/tile/core/BaseLayer.js +207 -281
  320. package/lib/tile/core/TileDebugLayer.d.ts +15 -0
  321. package/lib/tile/core/TileDebugLayer.js +14 -46
  322. package/lib/tile/interaction/getFeatureData.d.ts +0 -0
  323. package/lib/tile/interaction/getRasterData.d.ts +4 -0
  324. package/lib/tile/interaction/getRasterData.js +24 -31
  325. package/lib/tile/interaction/utils.d.ts +11 -0
  326. package/lib/tile/interaction/utils.js +15 -34
  327. package/lib/tile/interface.d.ts +29 -0
  328. package/lib/tile/service/TileLayerService.d.ts +33 -0
  329. package/lib/tile/service/TileLayerService.js +105 -177
  330. package/lib/tile/service/TilePickService.d.ts +26 -0
  331. package/lib/tile/service/TilePickService.js +100 -156
  332. package/lib/tile/service/TileSourceService.d.ts +7 -0
  333. package/lib/tile/service/TileSourceService.js +20 -29
  334. package/lib/tile/tile/DebugTile.d.ts +16 -0
  335. package/lib/tile/tile/DebugTile.js +43 -78
  336. package/lib/tile/tile/ImageTile.d.ts +14 -0
  337. package/lib/tile/tile/ImageTile.js +35 -66
  338. package/lib/tile/tile/MaskTile.d.ts +18 -0
  339. package/lib/tile/tile/MaskTile.js +49 -81
  340. package/lib/tile/tile/RasterRGBTile.d.ts +11 -0
  341. package/lib/tile/tile/RasterRGBTile.js +42 -71
  342. package/lib/tile/tile/RasterTerrainRGBTile.d.ts +14 -0
  343. package/lib/tile/tile/RasterTerrainRGBTile.js +35 -66
  344. package/lib/tile/tile/RasterTile.d.ts +18 -0
  345. package/lib/tile/tile/RasterTile.js +71 -104
  346. package/lib/tile/tile/Tile.d.ts +114 -0
  347. package/lib/tile/tile/Tile.js +152 -231
  348. package/lib/tile/tile/VectorTile.d.ts +26 -0
  349. package/lib/tile/tile/VectorTile.js +79 -124
  350. package/lib/tile/tile/index.d.ts +12 -0
  351. package/lib/tile/tile/index.js +6 -4
  352. package/lib/tile/tile/util.d.ts +5 -0
  353. package/lib/tile/utils/constants.d.ts +1 -0
  354. package/lib/tile/utils/constants.js +1 -1
  355. package/lib/tile/utils/utils.d.ts +8 -0
  356. package/lib/tile/utils/utils.js +2 -2
  357. package/lib/utils/blend.d.ts +2 -0
  358. package/lib/utils/blend.js +52 -47
  359. package/lib/utils/collision-index.d.ts +47 -0
  360. package/lib/utils/collision-index.js +64 -69
  361. package/lib/utils/extrude_polyline.d.ts +68 -0
  362. package/lib/utils/extrude_polyline.js +442 -470
  363. package/lib/utils/grid-index.d.ts +28 -0
  364. package/lib/utils/grid-index.js +97 -123
  365. package/lib/utils/identityScale.d.ts +8 -0
  366. package/lib/utils/identityScale.js +5 -5
  367. package/lib/utils/load-image.d.ts +1 -0
  368. package/lib/utils/load-image.js +15 -39
  369. package/lib/utils/multiPassRender.d.ts +16 -0
  370. package/lib/utils/multiPassRender.js +7 -10
  371. package/lib/utils/polylineNormal.d.ts +9 -0
  372. package/lib/utils/polylineNormal.js +40 -43
  373. package/lib/utils/rampcolor_legend.d.ts +6 -0
  374. package/lib/utils/rampcolor_legend.js +5 -4
  375. package/lib/utils/simpleLine.d.ts +23 -0
  376. package/lib/utils/simpleLine.js +54 -65
  377. package/lib/utils/stencil.d.ts +7 -0
  378. package/lib/utils/symbol-layout.d.ts +43 -0
  379. package/lib/utils/symbol-layout.js +95 -117
  380. package/lib/wind/index.d.ts +11 -0
  381. package/lib/wind/index.js +30 -70
  382. package/lib/wind/models/index.d.ts +5 -0
  383. package/lib/wind/models/index.js +1 -1
  384. package/lib/wind/models/utils.d.ts +19 -0
  385. package/lib/wind/models/utils.js +36 -34
  386. package/lib/wind/models/wind.d.ts +24 -0
  387. package/lib/wind/models/wind.js +205 -260
  388. package/lib/wind/models/windRender.d.ts +104 -0
  389. package/lib/wind/models/windRender.js +261 -272
  390. package/lib/wind/models/windShader.d.ts +12 -0
  391. package/lib/wind/models/windShader.js +145 -6
  392. package/package.json +16 -19
  393. package/es/glsl.d.ts +0 -5
  394. 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;