@antv/l7-layers 2.21.1 → 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 (393) 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/point/index.js +118 -182
  67. package/es/point/models/billboard_point.js +72 -127
  68. package/es/point/models/earthExtrude.js +170 -220
  69. package/es/point/models/earthFill.js +136 -192
  70. package/es/point/models/extrude.js +167 -217
  71. package/es/point/models/fill.js +152 -209
  72. package/es/point/models/fillImage.js +156 -211
  73. package/es/point/models/image.js +127 -180
  74. package/es/point/models/index.js +1 -1
  75. package/es/point/models/normal.js +67 -122
  76. package/es/point/models/radar.js +93 -148
  77. package/es/point/models/text.js +447 -578
  78. package/es/point/shape/extrude.js +19 -25
  79. package/es/polygon/index.js +61 -99
  80. package/es/polygon/models/extrude.js +208 -281
  81. package/es/polygon/models/extrusion.js +95 -142
  82. package/es/polygon/models/fill.js +102 -153
  83. package/es/polygon/models/index.js +1 -1
  84. package/es/polygon/models/ocean.js +139 -198
  85. package/es/polygon/models/water.js +120 -179
  86. package/es/raster/buffers/triangulation.js +13 -11
  87. package/es/raster/index.js +47 -88
  88. package/es/raster/models/index.js +1 -1
  89. package/es/raster/models/raster.js +134 -202
  90. package/es/raster/models/rasterRgb.js +134 -208
  91. package/es/raster/models/rasterTerrainRgb.js +98 -153
  92. package/es/tile/core/BaseLayer.d.ts +1 -0
  93. package/es/tile/core/BaseLayer.js +206 -282
  94. package/es/tile/core/TileDebugLayer.js +12 -46
  95. package/es/tile/interaction/getRasterData.js +24 -30
  96. package/es/tile/interaction/utils.js +15 -33
  97. package/es/tile/service/TileLayerService.js +104 -177
  98. package/es/tile/service/TilePickService.js +99 -156
  99. package/es/tile/service/TileSourceService.js +17 -26
  100. package/es/tile/tile/DebugTile.js +41 -78
  101. package/es/tile/tile/ImageTile.js +33 -66
  102. package/es/tile/tile/MaskTile.js +47 -81
  103. package/es/tile/tile/RasterRGBTile.js +40 -71
  104. package/es/tile/tile/RasterTerrainRGBTile.js +33 -66
  105. package/es/tile/tile/RasterTile.js +69 -104
  106. package/es/tile/tile/Tile.d.ts +1 -1
  107. package/es/tile/tile/Tile.js +151 -232
  108. package/es/tile/tile/VectorTile.js +77 -124
  109. package/es/tile/tile/index.js +4 -2
  110. package/es/tile/utils/constants.js +1 -1
  111. package/es/tile/utils/utils.js +2 -2
  112. package/es/utils/blend.js +52 -46
  113. package/es/utils/collision-index.js +62 -70
  114. package/es/utils/extrude_polyline.js +441 -471
  115. package/es/utils/grid-index.js +97 -123
  116. package/es/utils/identityScale.js +5 -5
  117. package/es/utils/load-image.js +15 -39
  118. package/es/utils/multiPassRender.js +7 -9
  119. package/es/utils/polylineNormal.js +40 -42
  120. package/es/utils/rampcolor_legend.js +5 -3
  121. package/es/utils/simpleLine.js +53 -66
  122. package/es/utils/symbol-layout.js +95 -117
  123. package/es/wind/index.js +28 -70
  124. package/es/wind/models/index.js +1 -1
  125. package/es/wind/models/utils.js +36 -34
  126. package/es/wind/models/wind.js +203 -260
  127. package/es/wind/models/windRender.js +258 -269
  128. package/es/wind/models/windShader.js +145 -6
  129. package/lib/canvas/index.d.ts +18 -0
  130. package/lib/canvas/index.js +64 -113
  131. package/lib/canvas/models/canvas.d.ts +23 -0
  132. package/lib/canvas/models/canvas.js +97 -136
  133. package/lib/canvas/models/constants.d.ts +2 -0
  134. package/lib/canvas/models/constants.js +1 -1
  135. package/lib/canvas/models/index.d.ts +2 -0
  136. package/lib/canvas/models/index.js +2 -2
  137. package/lib/citybuliding/building.d.ts +7 -0
  138. package/lib/citybuliding/building.js +22 -58
  139. package/lib/citybuliding/models/build.d.ts +17 -0
  140. package/lib/citybuliding/models/build.js +144 -199
  141. package/lib/core/BaseLayer.d.ts +247 -0
  142. package/lib/core/BaseLayer.js +1115 -1412
  143. package/lib/core/BaseModel.d.ts +82 -0
  144. package/lib/core/BaseModel.js +263 -315
  145. package/lib/core/CommonStyleAttribute.d.ts +20 -0
  146. package/lib/core/CommonStyleAttribute.js +25 -18
  147. package/lib/core/LayerPickService.d.ts +12 -0
  148. package/lib/core/LayerPickService.js +93 -140
  149. package/lib/core/TextureService.d.ts +15 -0
  150. package/lib/core/TextureService.js +59 -68
  151. package/lib/core/constant.d.ts +6 -0
  152. package/lib/core/constant.js +2 -2
  153. package/lib/core/interface.d.ts +282 -0
  154. package/lib/core/interface.js +5 -5
  155. package/lib/core/line_trangluation.d.ts +19 -0
  156. package/lib/core/line_trangluation.js +38 -43
  157. package/lib/core/schema.d.ts +27 -0
  158. package/lib/core/shape/Path.d.ts +39 -0
  159. package/lib/core/shape/Path.js +21 -13
  160. package/lib/core/shape/arrow.d.ts +25 -0
  161. package/lib/core/shape/arrow.js +50 -62
  162. package/lib/core/shape/extrude.d.ts +17 -0
  163. package/lib/core/shape/extrude.js +54 -62
  164. package/lib/core/triangulation.d.ts +136 -0
  165. package/lib/core/triangulation.js +194 -174
  166. package/lib/core/utils.d.ts +4 -0
  167. package/lib/core/utils.js +5 -5
  168. package/lib/earth/index.d.ts +22 -0
  169. package/lib/earth/index.js +37 -73
  170. package/lib/earth/models/atmosphere.d.ts +15 -0
  171. package/lib/earth/models/atmosphere.js +100 -148
  172. package/lib/earth/models/base.d.ts +22 -0
  173. package/lib/earth/models/base.js +150 -201
  174. package/lib/earth/models/bloomsphere.d.ts +15 -0
  175. package/lib/earth/models/bloomsphere.js +99 -147
  176. package/lib/earth/utils.d.ts +26 -0
  177. package/lib/earth/utils.js +37 -39
  178. package/lib/geometry/index.d.ts +22 -0
  179. package/lib/geometry/index.js +38 -75
  180. package/lib/geometry/models/billboard.d.ts +24 -0
  181. package/lib/geometry/models/billboard.js +149 -204
  182. package/lib/geometry/models/index.d.ts +5 -0
  183. package/lib/geometry/models/index.js +1 -1
  184. package/lib/geometry/models/plane.d.ts +43 -0
  185. package/lib/geometry/models/plane.js +280 -357
  186. package/lib/geometry/models/sprite.d.ts +48 -0
  187. package/lib/geometry/models/sprite.js +184 -240
  188. package/lib/heatmap/index.d.ts +13 -0
  189. package/lib/heatmap/index.js +74 -121
  190. package/lib/heatmap/models/grid.d.ts +15 -0
  191. package/lib/heatmap/models/grid.js +68 -118
  192. package/lib/heatmap/models/grid3d.d.ts +15 -0
  193. package/lib/heatmap/models/grid3d.js +103 -151
  194. package/lib/heatmap/models/heatmap.d.ts +27 -0
  195. package/lib/heatmap/models/heatmap.js +400 -455
  196. package/lib/heatmap/models/hexagon.d.ts +15 -0
  197. package/lib/heatmap/models/hexagon.js +69 -119
  198. package/lib/heatmap/models/index.d.ts +5 -0
  199. package/lib/heatmap/models/index.js +1 -1
  200. package/lib/heatmap/triangulation.d.ts +5 -0
  201. package/lib/heatmap/triangulation.js +20 -20
  202. package/lib/image/index.d.ts +9 -0
  203. package/lib/image/index.js +25 -62
  204. package/lib/image/models/image.d.ts +17 -0
  205. package/lib/image/models/image.js +101 -163
  206. package/lib/image/models/index.d.ts +5 -0
  207. package/lib/image/models/index.js +1 -1
  208. package/lib/index.d.ts +18 -0
  209. package/lib/index.js +17 -17
  210. package/lib/line/index.d.ts +36 -0
  211. package/lib/line/index.js +67 -106
  212. package/lib/line/models/arc.d.ts +22 -0
  213. package/lib/line/models/arc.js +202 -248
  214. package/lib/line/models/arc_3d.d.ts +22 -0
  215. package/lib/line/models/arc_3d.js +193 -241
  216. package/lib/line/models/flow.d.ts +14 -0
  217. package/lib/line/models/flow.js +103 -153
  218. package/lib/line/models/great_circle.d.ts +17 -0
  219. package/lib/line/models/great_circle.js +185 -234
  220. package/lib/line/models/index.d.ts +5 -0
  221. package/lib/line/models/index.js +1 -1
  222. package/lib/line/models/line.d.ts +27 -0
  223. package/lib/line/models/line.js +232 -285
  224. package/lib/line/models/simple_line.d.ts +19 -0
  225. package/lib/line/models/simple_line.js +144 -192
  226. package/lib/line/models/wall.d.ts +17 -0
  227. package/lib/line/models/wall.js +223 -273
  228. package/lib/mask/index.d.ts +16 -0
  229. package/lib/mask/index.js +18 -53
  230. package/lib/mask/models/fill.d.ts +18 -0
  231. package/lib/mask/models/fill.js +53 -108
  232. package/lib/mask/models/index.d.ts +5 -0
  233. package/lib/mask/models/index.js +1 -1
  234. package/lib/plugins/DataMappingPlugin.d.ts +13 -0
  235. package/lib/plugins/DataMappingPlugin.js +206 -248
  236. package/lib/plugins/DataSourcePlugin.d.ts +6 -0
  237. package/lib/plugins/DataSourcePlugin.js +65 -91
  238. package/lib/plugins/FeatureScalePlugin.d.ts +20 -0
  239. package/lib/plugins/FeatureScalePlugin.js +261 -304
  240. package/lib/plugins/LayerAnimateStylePlugin.d.ts +4 -0
  241. package/lib/plugins/LayerAnimateStylePlugin.js +13 -21
  242. package/lib/plugins/LayerMaskPlugin.d.ts +7 -0
  243. package/lib/plugins/LayerMaskPlugin.js +16 -24
  244. package/lib/plugins/LayerModelPlugin.d.ts +10 -0
  245. package/lib/plugins/LayerModelPlugin.js +53 -135
  246. package/lib/plugins/LayerStylePlugin.d.ts +7 -0
  247. package/lib/plugins/LayerStylePlugin.js +15 -23
  248. package/lib/plugins/LightingPlugin.d.ts +35 -0
  249. package/lib/plugins/LightingPlugin.js +27 -36
  250. package/lib/plugins/MultiPassRendererPlugin.d.ts +22 -0
  251. package/lib/plugins/MultiPassRendererPlugin.js +35 -38
  252. package/lib/plugins/PixelPickingPlugin.d.ts +11 -0
  253. package/lib/plugins/PixelPickingPlugin.js +130 -149
  254. package/lib/plugins/RegisterStyleAttributePlugin.d.ts +11 -0
  255. package/lib/plugins/RegisterStyleAttributePlugin.js +81 -96
  256. package/lib/plugins/ShaderUniformPlugin.d.ts +22 -0
  257. package/lib/plugins/ShaderUniformPlugin.js +160 -130
  258. package/lib/plugins/UpdateModelPlugin.d.ts +7 -0
  259. package/lib/plugins/UpdateModelPlugin.js +17 -26
  260. package/lib/plugins/UpdateStyleAttributePlugin.d.ts +9 -0
  261. package/lib/plugins/UpdateStyleAttributePlugin.js +48 -65
  262. package/lib/plugins/index.d.ts +15 -0
  263. package/lib/point/index.d.ts +33 -0
  264. package/lib/point/index.js +120 -182
  265. package/lib/point/models/billboard_point.d.ts +21 -0
  266. package/lib/point/models/billboard_point.js +74 -127
  267. package/lib/point/models/earthExtrude.d.ts +16 -0
  268. package/lib/point/models/earthExtrude.js +172 -220
  269. package/lib/point/models/earthFill.d.ts +15 -0
  270. package/lib/point/models/earthFill.js +138 -192
  271. package/lib/point/models/extrude.d.ts +16 -0
  272. package/lib/point/models/extrude.js +169 -217
  273. package/lib/point/models/fill.d.ts +31 -0
  274. package/lib/point/models/fill.js +154 -209
  275. package/lib/point/models/fillImage.d.ts +26 -0
  276. package/lib/point/models/fillImage.js +159 -211
  277. package/lib/point/models/image.d.ts +18 -0
  278. package/lib/point/models/image.js +129 -180
  279. package/lib/point/models/index.d.ts +5 -0
  280. package/lib/point/models/index.js +1 -1
  281. package/lib/point/models/normal.d.ts +22 -0
  282. package/lib/point/models/normal.js +69 -122
  283. package/lib/point/models/radar.d.ts +22 -0
  284. package/lib/point/models/radar.js +95 -148
  285. package/lib/point/models/text.d.ts +69 -0
  286. package/lib/point/models/text.js +449 -578
  287. package/lib/point/shape/extrude.d.ts +15 -0
  288. package/lib/point/shape/extrude.js +19 -25
  289. package/lib/polygon/index.d.ts +18 -0
  290. package/lib/polygon/index.js +63 -99
  291. package/lib/polygon/models/extrude.d.ts +25 -0
  292. package/lib/polygon/models/extrude.js +210 -281
  293. package/lib/polygon/models/extrusion.d.ts +24 -0
  294. package/lib/polygon/models/extrusion.js +97 -142
  295. package/lib/polygon/models/fill.d.ts +18 -0
  296. package/lib/polygon/models/fill.js +104 -153
  297. package/lib/polygon/models/index.d.ts +5 -0
  298. package/lib/polygon/models/index.js +1 -1
  299. package/lib/polygon/models/ocean.d.ts +23 -0
  300. package/lib/polygon/models/ocean.js +141 -198
  301. package/lib/polygon/models/water.d.ts +21 -0
  302. package/lib/polygon/models/water.js +122 -179
  303. package/lib/raster/buffers/triangulation.d.ts +6 -0
  304. package/lib/raster/buffers/triangulation.js +13 -11
  305. package/lib/raster/index.d.ts +11 -0
  306. package/lib/raster/index.js +49 -88
  307. package/lib/raster/models/index.d.ts +5 -0
  308. package/lib/raster/models/index.js +1 -1
  309. package/lib/raster/models/raster.d.ts +21 -0
  310. package/lib/raster/models/raster.js +136 -202
  311. package/lib/raster/models/rasterRgb.d.ts +21 -0
  312. package/lib/raster/models/rasterRgb.js +136 -208
  313. package/lib/raster/models/rasterTerrainRgb.d.ts +16 -0
  314. package/lib/raster/models/rasterTerrainRgb.js +100 -153
  315. package/lib/tile/core/BaseLayer.d.ts +48 -0
  316. package/lib/tile/core/BaseLayer.js +207 -281
  317. package/lib/tile/core/TileDebugLayer.d.ts +15 -0
  318. package/lib/tile/core/TileDebugLayer.js +14 -46
  319. package/lib/tile/interaction/getFeatureData.d.ts +0 -0
  320. package/lib/tile/interaction/getRasterData.d.ts +4 -0
  321. package/lib/tile/interaction/getRasterData.js +24 -31
  322. package/lib/tile/interaction/utils.d.ts +11 -0
  323. package/lib/tile/interaction/utils.js +15 -34
  324. package/lib/tile/interface.d.ts +29 -0
  325. package/lib/tile/service/TileLayerService.d.ts +33 -0
  326. package/lib/tile/service/TileLayerService.js +105 -177
  327. package/lib/tile/service/TilePickService.d.ts +26 -0
  328. package/lib/tile/service/TilePickService.js +100 -156
  329. package/lib/tile/service/TileSourceService.d.ts +7 -0
  330. package/lib/tile/service/TileSourceService.js +20 -29
  331. package/lib/tile/tile/DebugTile.d.ts +16 -0
  332. package/lib/tile/tile/DebugTile.js +43 -78
  333. package/lib/tile/tile/ImageTile.d.ts +14 -0
  334. package/lib/tile/tile/ImageTile.js +35 -66
  335. package/lib/tile/tile/MaskTile.d.ts +18 -0
  336. package/lib/tile/tile/MaskTile.js +49 -81
  337. package/lib/tile/tile/RasterRGBTile.d.ts +11 -0
  338. package/lib/tile/tile/RasterRGBTile.js +42 -71
  339. package/lib/tile/tile/RasterTerrainRGBTile.d.ts +14 -0
  340. package/lib/tile/tile/RasterTerrainRGBTile.js +35 -66
  341. package/lib/tile/tile/RasterTile.d.ts +18 -0
  342. package/lib/tile/tile/RasterTile.js +71 -104
  343. package/lib/tile/tile/Tile.d.ts +114 -0
  344. package/lib/tile/tile/Tile.js +152 -231
  345. package/lib/tile/tile/VectorTile.d.ts +26 -0
  346. package/lib/tile/tile/VectorTile.js +79 -124
  347. package/lib/tile/tile/index.d.ts +12 -0
  348. package/lib/tile/tile/index.js +6 -4
  349. package/lib/tile/tile/util.d.ts +5 -0
  350. package/lib/tile/utils/constants.d.ts +1 -0
  351. package/lib/tile/utils/constants.js +1 -1
  352. package/lib/tile/utils/utils.d.ts +8 -0
  353. package/lib/tile/utils/utils.js +2 -2
  354. package/lib/utils/blend.d.ts +2 -0
  355. package/lib/utils/blend.js +52 -47
  356. package/lib/utils/collision-index.d.ts +47 -0
  357. package/lib/utils/collision-index.js +64 -69
  358. package/lib/utils/extrude_polyline.d.ts +68 -0
  359. package/lib/utils/extrude_polyline.js +442 -470
  360. package/lib/utils/grid-index.d.ts +28 -0
  361. package/lib/utils/grid-index.js +97 -123
  362. package/lib/utils/identityScale.d.ts +8 -0
  363. package/lib/utils/identityScale.js +5 -5
  364. package/lib/utils/load-image.d.ts +1 -0
  365. package/lib/utils/load-image.js +15 -39
  366. package/lib/utils/multiPassRender.d.ts +16 -0
  367. package/lib/utils/multiPassRender.js +7 -10
  368. package/lib/utils/polylineNormal.d.ts +9 -0
  369. package/lib/utils/polylineNormal.js +40 -43
  370. package/lib/utils/rampcolor_legend.d.ts +6 -0
  371. package/lib/utils/rampcolor_legend.js +5 -4
  372. package/lib/utils/simpleLine.d.ts +23 -0
  373. package/lib/utils/simpleLine.js +54 -65
  374. package/lib/utils/stencil.d.ts +7 -0
  375. package/lib/utils/symbol-layout.d.ts +43 -0
  376. package/lib/utils/symbol-layout.js +95 -117
  377. package/lib/wind/index.d.ts +11 -0
  378. package/lib/wind/index.js +30 -70
  379. package/lib/wind/models/index.d.ts +5 -0
  380. package/lib/wind/models/index.js +1 -1
  381. package/lib/wind/models/utils.d.ts +19 -0
  382. package/lib/wind/models/utils.js +36 -34
  383. package/lib/wind/models/wind.d.ts +24 -0
  384. package/lib/wind/models/wind.js +205 -260
  385. package/lib/wind/models/windRender.d.ts +104 -0
  386. package/lib/wind/models/windRender.js +261 -272
  387. package/lib/wind/models/windShader.d.ts +12 -0
  388. package/lib/wind/models/windShader.js +145 -6
  389. package/package.json +16 -19
  390. package/CHANGELOG.md +0 -492
  391. package/LICENSE.md +0 -21
  392. package/es/glsl.d.ts +0 -5
  393. package/lib/glsl.d.ts +0 -5
@@ -5,17 +5,9 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
8
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
10
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
9
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
12
10
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
13
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
14
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
15
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
16
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
17
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
18
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
19
11
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
20
12
  var _asyncHook = require("@antv/async-hook");
21
13
  var _l7Core = require("@antv/l7-core");
@@ -26,43 +18,82 @@ var _blend = require("../utils/blend");
26
18
  var _multiPassRender = require("../utils/multiPassRender");
27
19
  var _LayerPickService = _interopRequireDefault(require("./LayerPickService"));
28
20
  var _TextureService = _interopRequireDefault(require("./TextureService"));
29
- var _excluded = ["passes"],
30
- _excluded2 = ["moduleName", "vertexShader", "fragmentShader", "inject", "triangulation", "styleOption", "pickingEnabled"];
31
- 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; } } }; }
32
- 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); }
33
- 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; }
34
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
35
- 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; } } // @ts-ignore
36
- var isEqual = _l7Utils.lodashUtil.isEqual,
37
- isFunction = _l7Utils.lodashUtil.isFunction,
38
- isNumber = _l7Utils.lodashUtil.isNumber,
39
- isObject = _l7Utils.lodashUtil.isObject,
40
- isPlainObject = _l7Utils.lodashUtil.isPlainObject,
41
- isUndefined = _l7Utils.lodashUtil.isUndefined;
21
+ const _excluded = ["passes"],
22
+ _excluded2 = ["moduleName", "vertexShader", "fragmentShader", "inject", "triangulation", "styleOption", "pickingEnabled"]; // @ts-ignore
23
+ const {
24
+ isEqual,
25
+ isFunction,
26
+ isNumber,
27
+ isObject,
28
+ isPlainObject,
29
+ isUndefined
30
+ } = _l7Utils.lodashUtil;
42
31
  /**
43
32
  * 分配 layer id
44
33
  */
45
- var layerIdCounter = 0;
46
- var BaseLayer = exports.default = /*#__PURE__*/function (_ref) {
47
- (0, _inherits2.default)(BaseLayer, _ref);
48
- var _super = _createSuper(BaseLayer);
49
- function BaseLayer() {
50
- var _this;
51
- var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
52
- (0, _classCallCheck2.default)(this, BaseLayer);
53
- _this = _super.call(this);
54
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "id", "".concat(layerIdCounter++));
55
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "name", "".concat(layerIdCounter));
56
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "visible", true);
57
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "zIndex", 0);
58
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "inited", false);
59
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "layerModelNeedUpdate", false);
60
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "pickedFeatureID", null);
61
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "selectedFeatureID", null);
62
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "styleNeedUpdate", false);
63
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "forceRender", false);
64
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "clusterZoom", 0);
65
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "defaultSourceConfig", {
34
+ let layerIdCounter = 0;
35
+ class BaseLayer extends _eventemitter.EventEmitter {
36
+ get shaderModuleService() {
37
+ return this.container.shaderModuleService;
38
+ }
39
+ get cameraService() {
40
+ return this.container.cameraService;
41
+ }
42
+ get coordinateService() {
43
+ return this.container.coordinateSystemService;
44
+ }
45
+ get iconService() {
46
+ return this.container.iconService;
47
+ }
48
+ get fontService() {
49
+ return this.container.fontService;
50
+ }
51
+ get pickingService() {
52
+ return this.container.pickingService;
53
+ }
54
+ get rendererService() {
55
+ return this.container.rendererService;
56
+ }
57
+ get layerService() {
58
+ return this.container.layerService;
59
+ }
60
+ get debugService() {
61
+ return this.container.debugService;
62
+ }
63
+ get interactionService() {
64
+ return this.container.interactionService;
65
+ }
66
+ get mapService() {
67
+ return this.container.mapService;
68
+ }
69
+ get normalPassFactory() {
70
+ return this.container.normalPassFactory;
71
+ }
72
+ constructor(config = {}) {
73
+ super();
74
+ (0, _defineProperty2.default)(this, "id", `${layerIdCounter++}`);
75
+ (0, _defineProperty2.default)(this, "name", `${layerIdCounter}`);
76
+ (0, _defineProperty2.default)(this, "parent", void 0);
77
+ (0, _defineProperty2.default)(this, "coordCenter", void 0);
78
+ (0, _defineProperty2.default)(this, "type", void 0);
79
+ (0, _defineProperty2.default)(this, "visible", true);
80
+ (0, _defineProperty2.default)(this, "zIndex", 0);
81
+ (0, _defineProperty2.default)(this, "minZoom", void 0);
82
+ (0, _defineProperty2.default)(this, "maxZoom", void 0);
83
+ (0, _defineProperty2.default)(this, "inited", false);
84
+ (0, _defineProperty2.default)(this, "layerModelNeedUpdate", false);
85
+ (0, _defineProperty2.default)(this, "pickedFeatureID", null);
86
+ (0, _defineProperty2.default)(this, "selectedFeatureID", null);
87
+ (0, _defineProperty2.default)(this, "styleNeedUpdate", false);
88
+ (0, _defineProperty2.default)(this, "rendering", void 0);
89
+ (0, _defineProperty2.default)(this, "forceRender", false);
90
+ (0, _defineProperty2.default)(this, "clusterZoom", 0);
91
+ // 聚合等级标记
92
+ (0, _defineProperty2.default)(this, "layerType", void 0);
93
+ (0, _defineProperty2.default)(this, "triangulation", void 0);
94
+ (0, _defineProperty2.default)(this, "layerPickService", void 0);
95
+ (0, _defineProperty2.default)(this, "textureService", void 0);
96
+ (0, _defineProperty2.default)(this, "defaultSourceConfig", {
66
97
  data: [],
67
98
  options: {
68
99
  parser: {
@@ -70,7 +101,7 @@ var BaseLayer = exports.default = /*#__PURE__*/function (_ref) {
70
101
  }
71
102
  }
72
103
  });
73
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "dataState", {
104
+ (0, _defineProperty2.default)(this, "dataState", {
74
105
  dataSourceNeedUpdate: false,
75
106
  dataMappingNeedUpdate: false,
76
107
  filterNeedUpdate: false,
@@ -78,7 +109,7 @@ var BaseLayer = exports.default = /*#__PURE__*/function (_ref) {
78
109
  StyleAttrNeedUpdate: false
79
110
  });
80
111
  // 生命周期钩子
81
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "hooks", {
112
+ (0, _defineProperty2.default)(this, "hooks", {
82
113
  init: new _asyncHook.AsyncSeriesBailHook(),
83
114
  afterInit: new _asyncHook.SyncBailHook(),
84
115
  beforeRender: new _asyncHook.SyncBailHook(),
@@ -94,1478 +125,1150 @@ var BaseLayer = exports.default = /*#__PURE__*/function (_ref) {
94
125
  afterDestroy: new _asyncHook.SyncHook()
95
126
  });
96
127
  // 待渲染 model 列表
97
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "models", []);
98
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "startInit", false);
128
+ (0, _defineProperty2.default)(this, "models", []);
129
+ // 每个 Layer 都有一个
130
+ (0, _defineProperty2.default)(this, "multiPassRenderer", void 0);
131
+ // 注入插件
132
+ (0, _defineProperty2.default)(this, "plugins", void 0);
133
+ (0, _defineProperty2.default)(this, "startInit", false);
134
+ (0, _defineProperty2.default)(this, "sourceOption", void 0);
135
+ (0, _defineProperty2.default)(this, "layerModel", void 0);
136
+ (0, _defineProperty2.default)(this, "shapeOption", void 0);
137
+ (0, _defineProperty2.default)(this, "tileLayer", void 0);
99
138
  // 用于保存子图层对象
100
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "layerChildren", []);
101
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "masks", []);
102
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "configService", _l7Core.globalConfigService);
103
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "animateOptions", {
139
+ (0, _defineProperty2.default)(this, "layerChildren", []);
140
+ (0, _defineProperty2.default)(this, "masks", []);
141
+ (0, _defineProperty2.default)(this, "configService", _l7Core.globalConfigService);
142
+ (0, _defineProperty2.default)(this, "styleAttributeService", void 0);
143
+ (0, _defineProperty2.default)(this, "layerSource", void 0);
144
+ (0, _defineProperty2.default)(this, "postProcessingPassFactory", void 0);
145
+ (0, _defineProperty2.default)(this, "animateOptions", {
104
146
  enable: false
105
147
  });
106
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "currentPickId", null);
107
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "encodeStyleAttribute", {});
148
+ /**
149
+ * 图层容器
150
+ */
151
+ (0, _defineProperty2.default)(this, "container", void 0);
152
+ (0, _defineProperty2.default)(this, "encodedData", void 0);
153
+ (0, _defineProperty2.default)(this, "currentPickId", null);
154
+ (0, _defineProperty2.default)(this, "rawConfig", void 0);
155
+ (0, _defineProperty2.default)(this, "needUpdateConfig", void 0);
156
+ (0, _defineProperty2.default)(this, "encodeStyleAttribute", {});
108
157
  // Shader 的数据映射
109
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "enableShaderEncodeStyles", []);
158
+ (0, _defineProperty2.default)(this, "enableShaderEncodeStyles", []);
110
159
  // 数据层数据映射
111
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "enableDataEncodeStyles", []);
160
+ (0, _defineProperty2.default)(this, "enableDataEncodeStyles", []);
112
161
  /**
113
162
  * 待更新样式属性,在初始化阶段完成注册
114
163
  */
115
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "pendingStyleAttributes", []);
116
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "scaleOptions", {});
117
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "animateStatus", false);
118
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isDestroyed", false);
164
+ (0, _defineProperty2.default)(this, "pendingStyleAttributes", []);
165
+ (0, _defineProperty2.default)(this, "scaleOptions", {});
166
+ (0, _defineProperty2.default)(this, "animateStartTime", void 0);
167
+ (0, _defineProperty2.default)(this, "animateStatus", false);
168
+ (0, _defineProperty2.default)(this, "isDestroyed", false);
119
169
  // private pickingPassRender: IPass<'pixelPicking'>;
120
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "uniformBuffers", []);
121
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "encodeDataLength", 0);
122
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "sourceEvent", function () {
123
- _this.dataState.dataSourceNeedUpdate = true;
124
- var layerConfig = _this.getLayerConfig();
170
+ (0, _defineProperty2.default)(this, "uniformBuffers", []);
171
+ (0, _defineProperty2.default)(this, "encodeDataLength", 0);
172
+ (0, _defineProperty2.default)(this, "sourceEvent", () => {
173
+ this.dataState.dataSourceNeedUpdate = true;
174
+ const layerConfig = this.getLayerConfig();
125
175
  if (layerConfig && layerConfig.autoFit) {
126
- _this.fitBounds(layerConfig.fitBoundsOptions);
176
+ this.fitBounds(layerConfig.fitBoundsOptions);
127
177
  }
128
- var autoRender = _this.layerSource.getSourceCfg().autoRender;
178
+ const autoRender = this.layerSource.getSourceCfg().autoRender;
129
179
  if (autoRender) {
130
- setTimeout(function () {
131
- _this.reRender();
180
+ setTimeout(() => {
181
+ this.reRender();
132
182
  }, 10);
133
183
  }
134
184
  });
135
- _this.name = config.name || _this.id;
136
- _this.zIndex = config.zIndex || 0;
137
- _this.rawConfig = config;
138
- _this.masks = config.maskLayers || [];
139
- return _this;
140
- }
141
- (0, _createClass2.default)(BaseLayer, [{
142
- key: "shaderModuleService",
143
- get: function get() {
144
- return this.container.shaderModuleService;
145
- }
146
- }, {
147
- key: "cameraService",
148
- get: function get() {
149
- return this.container.cameraService;
150
- }
151
- }, {
152
- key: "coordinateService",
153
- get: function get() {
154
- return this.container.coordinateSystemService;
155
- }
156
- }, {
157
- key: "iconService",
158
- get: function get() {
159
- return this.container.iconService;
160
- }
161
- }, {
162
- key: "fontService",
163
- get: function get() {
164
- return this.container.fontService;
165
- }
166
- }, {
167
- key: "pickingService",
168
- get: function get() {
169
- return this.container.pickingService;
170
- }
171
- }, {
172
- key: "rendererService",
173
- get: function get() {
174
- return this.container.rendererService;
175
- }
176
- }, {
177
- key: "layerService",
178
- get: function get() {
179
- return this.container.layerService;
180
- }
181
- }, {
182
- key: "debugService",
183
- get: function get() {
184
- return this.container.debugService;
185
- }
186
- }, {
187
- key: "interactionService",
188
- get: function get() {
189
- return this.container.interactionService;
190
- }
191
- }, {
192
- key: "mapService",
193
- get: function get() {
194
- return this.container.mapService;
195
- }
196
- }, {
197
- key: "normalPassFactory",
198
- get: function get() {
199
- return this.container.normalPassFactory;
200
- }
201
- }, {
202
- key: "addMask",
203
- value: function addMask(layer) {
204
- this.masks.push(layer);
205
- this.updateLayerConfig({
206
- maskLayers: this.masks
207
- });
208
- this.enableMask();
209
- }
210
- }, {
211
- key: "removeMask",
212
- value: function removeMask(layer) {
213
- var layerIndex = this.masks.indexOf(layer);
214
- if (layerIndex > -1) {
215
- this.masks.splice(layerIndex, 1);
216
- }
217
- this.updateLayerConfig({
218
- maskLayers: this.masks
219
- });
220
- }
221
- }, {
222
- key: "disableMask",
223
- value: function disableMask() {
224
- this.updateLayerConfig({
225
- enableMask: false
226
- });
227
- }
228
- }, {
229
- key: "enableMask",
230
- value: function enableMask() {
231
- this.updateLayerConfig({
232
- enableMask: true
233
- });
185
+ this.name = config.name || this.id;
186
+ this.zIndex = config.zIndex || 0;
187
+ this.rawConfig = config;
188
+ this.masks = config.maskLayers || [];
189
+ }
190
+ addMask(layer) {
191
+ this.masks.push(layer);
192
+ this.updateLayerConfig({
193
+ maskLayers: this.masks
194
+ });
195
+ this.enableMask();
196
+ }
197
+ removeMask(layer) {
198
+ const layerIndex = this.masks.indexOf(layer);
199
+ if (layerIndex > -1) {
200
+ this.masks.splice(layerIndex, 1);
234
201
  }
202
+ this.updateLayerConfig({
203
+ maskLayers: this.masks
204
+ });
205
+ }
206
+ disableMask() {
207
+ this.updateLayerConfig({
208
+ enableMask: false
209
+ });
210
+ }
211
+ enableMask() {
212
+ this.updateLayerConfig({
213
+ enableMask: true
214
+ });
215
+ }
235
216
 
236
- /**
237
- * 将废弃
238
- * @deprecated
239
- */
240
- }, {
241
- key: "addMaskLayer",
242
- value: function addMaskLayer(maskLayer) {
243
- this.masks.push(maskLayer);
244
- }
217
+ /**
218
+ * 将废弃
219
+ * @deprecated
220
+ */
221
+ addMaskLayer(maskLayer) {
222
+ this.masks.push(maskLayer);
223
+ }
245
224
 
246
- /**
247
- * 将废弃
248
- * @deprecated
249
- */
250
- }, {
251
- key: "removeMaskLayer",
252
- value: function removeMaskLayer(maskLayer) {
253
- var layerIndex = this.masks.indexOf(maskLayer);
254
- if (layerIndex > -1) {
255
- this.masks.splice(layerIndex, 1);
256
- }
257
- maskLayer.destroy();
258
- }
259
- }, {
260
- key: "getAttribute",
261
- value: function getAttribute(name) {
262
- return this.styleAttributeService.getLayerStyleAttribute(name);
263
- }
264
- }, {
265
- key: "getLayerConfig",
266
- value: function getLayerConfig() {
267
- return this.configService.getLayerConfig(this.id);
268
- }
269
- }, {
270
- key: "updateLayerConfig",
271
- value: function updateLayerConfig(configToUpdate) {
272
- var _this2 = this;
273
- // 同步 rawConfig
274
- Object.keys(configToUpdate).map(function (key) {
275
- if (key in _this2.rawConfig) {
276
- // @ts-ignore
277
- _this2.rawConfig[key] = configToUpdate[key];
278
- }
279
- });
280
- if (!this.startInit) {
281
- this.needUpdateConfig = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, this.needUpdateConfig), configToUpdate);
282
- } else {
283
- var sceneId = this.container.id;
225
+ /**
226
+ * 将废弃
227
+ * @deprecated
228
+ */
229
+ removeMaskLayer(maskLayer) {
230
+ const layerIndex = this.masks.indexOf(maskLayer);
231
+ if (layerIndex > -1) {
232
+ this.masks.splice(layerIndex, 1);
233
+ }
234
+ maskLayer.destroy();
235
+ }
236
+ getAttribute(name) {
237
+ return this.styleAttributeService.getLayerStyleAttribute(name);
238
+ }
239
+ getLayerConfig() {
240
+ return this.configService.getLayerConfig(this.id);
241
+ }
242
+ updateLayerConfig(configToUpdate) {
243
+ // 同步 rawConfig
244
+ Object.keys(configToUpdate).map(key => {
245
+ if (key in this.rawConfig) {
284
246
  // @ts-ignore
285
- // styleDataMapping(configToUpdate, this); // 处理 style 中进行数据映射的属性字段
286
- this.configService.setLayerConfig(sceneId, this.id, (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, this.configService.getLayerConfig(this.id)), this.needUpdateConfig), configToUpdate));
287
- this.needUpdateConfig = {};
247
+ this.rawConfig[key] = configToUpdate[key];
288
248
  }
249
+ });
250
+ if (!this.startInit) {
251
+ this.needUpdateConfig = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, this.needUpdateConfig), configToUpdate);
252
+ } else {
253
+ const sceneId = this.container.id;
254
+ // @ts-ignore
255
+ // styleDataMapping(configToUpdate, this); // 处理 style 中进行数据映射的属性字段
256
+ this.configService.setLayerConfig(sceneId, this.id, (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, this.configService.getLayerConfig(this.id)), this.needUpdateConfig), configToUpdate));
257
+ this.needUpdateConfig = {};
289
258
  }
259
+ }
290
260
 
291
- /**
292
- * 注入图层容器,父容器为场景容器
293
- * RootContainer 1
294
- * -> SceneContainer 1.*
295
- * -> LayerContainer 1.*
296
- */
297
- }, {
298
- key: "setContainer",
299
- value: function setContainer(container) {
300
- this.container = container;
301
- }
302
- }, {
303
- key: "getContainer",
304
- value: function getContainer() {
305
- return this.container;
306
- }
307
- }, {
308
- key: "addPlugin",
309
- value: function addPlugin(plugin) {
310
- this.plugins.push(plugin);
311
- return this;
312
- }
313
- }, {
314
- key: "init",
315
- value: function () {
316
- var _init = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
317
- var _this3 = this;
318
- var sceneId, _this$getLayerConfig, enableMultiPassRenderer, passes, _iterator, _step, plugin;
319
- return _regenerator.default.wrap(function _callee$(_context) {
320
- while (1) switch (_context.prev = _context.next) {
321
- case 0:
322
- // 设置配置项
323
- sceneId = this.container.id;
324
- this.startInit = true;
325
- // 初始化图层配置项
326
- // const { enableMultiPassRenderer = false } = this.rawConfig;
327
- // this.configService.setLayerConfig(sceneId, this.id, {
328
- // enableMultiPassRenderer,
329
- // });
330
- this.configService.setLayerConfig(sceneId, this.id, this.rawConfig);
331
- this.layerType = this.rawConfig.layerType;
332
-
333
- // 全局容器服务
334
-
335
- // 场景容器服务
336
- _this$getLayerConfig = this.getLayerConfig(), enableMultiPassRenderer = _this$getLayerConfig.enableMultiPassRenderer, passes = _this$getLayerConfig.passes;
337
- if (enableMultiPassRenderer && passes !== null && passes !== void 0 && passes.length && passes.length > 0) {
338
- // Tip: 兼容 multiPassRender 在 amap1 时存在的图层不同步问题 zoom
339
- this.mapService.on('mapAfterFrameChange', function () {
340
- _this3.renderLayers();
341
- });
342
- }
343
- this.postProcessingPassFactory = this.container.postProcessingPassFactory;
344
-
345
- // 图层容器服务
346
- this.styleAttributeService = this.container.styleAttributeService;
347
- if (enableMultiPassRenderer) {
348
- // 按需初始化 瓦片频繁报错
349
- this.multiPassRenderer = this.container.multiPassRenderer;
350
- this.multiPassRenderer.setLayer(this);
351
- }
352
- // 完成样式服务注册完成前添加的属性
353
- this.pendingStyleAttributes.forEach(function (_ref2) {
354
- var attributeName = _ref2.attributeName,
355
- attributeField = _ref2.attributeField,
356
- attributeValues = _ref2.attributeValues,
357
- updateOptions = _ref2.updateOptions;
358
- _this3.styleAttributeService.updateStyleAttribute(attributeName, {
359
- // @ts-ignore
360
- scale: (0, _objectSpread2.default)({
361
- field: attributeField
362
- }, _this3.splitValuesAndCallbackInAttribute(
363
- // @ts-ignore
364
- attributeValues,
365
- // @ts-ignore
366
- attributeField ? undefined : _this3.getLayerConfig()[attributeName] // 设置了字段不需要设置默认值
367
- ))
368
- },
369
- // @ts-ignore
370
- updateOptions);
371
- });
372
- this.pendingStyleAttributes = [];
373
-
374
- // 获取插件集
375
- this.plugins = (0, _plugins.createPlugins)();
376
- // 完成插件注册,传入场景和图层容器内的服务
377
- _iterator = _createForOfIteratorHelper(this.plugins);
378
- try {
379
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
380
- plugin = _step.value;
381
- plugin.apply(this, this.container);
382
- }
383
- // if (this.getSource().isTile) {
384
- // this.tileLayer = new TileLayer(this);
385
- // }
261
+ /**
262
+ * 注入图层容器,父容器为场景容器
263
+ * RootContainer 1
264
+ * -> SceneContainer 1.*
265
+ * -> LayerContainer 1.*
266
+ */
267
+ setContainer(container) {
268
+ this.container = container;
269
+ }
270
+ getContainer() {
271
+ return this.container;
272
+ }
273
+ addPlugin(plugin) {
274
+ this.plugins.push(plugin);
275
+ return this;
276
+ }
277
+ init() {
278
+ var _this = this;
279
+ return (0, _asyncToGenerator2.default)(function* () {
280
+ // 设置配置项
281
+ const sceneId = _this.container.id;
282
+ _this.startInit = true;
283
+ // 初始化图层配置项
284
+ // const { enableMultiPassRenderer = false } = this.rawConfig;
285
+ // this.configService.setLayerConfig(sceneId, this.id, {
286
+ // enableMultiPassRenderer,
287
+ // });
288
+ _this.configService.setLayerConfig(sceneId, _this.id, _this.rawConfig);
289
+ _this.layerType = _this.rawConfig.layerType;
386
290
 
387
- // 初始化其他服务
388
- } catch (err) {
389
- _iterator.e(err);
390
- } finally {
391
- _iterator.f();
392
- }
393
- this.layerPickService = new _LayerPickService.default(this);
291
+ // 全局容器服务
394
292
 
395
- // 颜色纹理服务
396
- this.textureService = new _TextureService.default(this);
397
- this.log(_l7Core.IDebugLog.LayerInitStart);
398
- // 触发 init 生命周期插件
399
- _context.next = 19;
400
- return this.hooks.init.promise();
401
- case 19:
402
- this.log(_l7Core.IDebugLog.LayerInitEnd);
403
- this.inited = true;
404
- // add mask layer
405
- // 触发初始化完成事件;
406
- this.emit('inited', {
407
- target: this,
408
- type: 'inited'
409
- });
410
- this.emit('add', {
411
- target: this,
412
- type: 'add'
413
- });
414
- this.hooks.afterInit.call();
415
- case 24:
416
- case "end":
417
- return _context.stop();
418
- }
419
- }, _callee, this);
420
- }));
421
- function init() {
422
- return _init.apply(this, arguments);
423
- }
424
- return init;
425
- }()
426
- }, {
427
- key: "log",
428
- value: function log(logType) {
429
- var _this$debugService;
430
- var step = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'init';
431
- // @ts-ignore 瓦片、瓦片图层目前不参与日志
432
- if (this.tileLayer || this.isTileLayer) {
433
- return;
434
- }
435
- var key = "".concat(this.id, ".").concat(step, ".").concat(logType);
436
- var values = {
437
- id: this.id,
438
- type: this.type
439
- };
440
- (_this$debugService = this.debugService) === null || _this$debugService === void 0 || _this$debugService.log(key, values);
441
- }
442
- }, {
443
- key: "updateModelData",
444
- value: function updateModelData(data) {
445
- if (data.attributes && data.elements) {
446
- this.models.map(function (m) {
447
- m.updateAttributesAndElements(data.attributes, data.elements);
293
+ // 场景容器服务
294
+ const {
295
+ enableMultiPassRenderer,
296
+ passes
297
+ } = _this.getLayerConfig();
298
+ if (enableMultiPassRenderer && passes !== null && passes !== void 0 && passes.length && passes.length > 0) {
299
+ // Tip: 兼容 multiPassRender 在 amap1 时存在的图层不同步问题 zoom
300
+ _this.mapService.on('mapAfterFrameChange', () => {
301
+ _this.renderLayers();
448
302
  });
449
- } else {
450
- console.warn('data error');
451
303
  }
452
- }
453
- }, {
454
- key: "setLayerPickService",
455
- value: function setLayerPickService(layerPickService) {
456
- this.layerPickService = layerPickService;
457
- }
458
- /**
459
- * Model初始化前需要更新Model样式
460
- */
461
- }, {
462
- key: "prepareBuildModel",
463
- value: function prepareBuildModel() {
464
- if (Object.keys(this.needUpdateConfig || {}).length !== 0) {
465
- this.updateLayerConfig({});
304
+ _this.postProcessingPassFactory = _this.container.postProcessingPassFactory;
305
+
306
+ // 图层容器服务
307
+ _this.styleAttributeService = _this.container.styleAttributeService;
308
+ if (enableMultiPassRenderer) {
309
+ // 按需初始化 瓦片频繁报错
310
+ _this.multiPassRenderer = _this.container.multiPassRenderer;
311
+ _this.multiPassRenderer.setLayer(_this);
466
312
  }
313
+ // 完成样式服务注册完成前添加的属性
314
+ _this.pendingStyleAttributes.forEach(({
315
+ attributeName,
316
+ attributeField,
317
+ attributeValues,
318
+ updateOptions
319
+ }) => {
320
+ _this.styleAttributeService.updateStyleAttribute(attributeName, {
321
+ // @ts-ignore
322
+ scale: (0, _objectSpread2.default)({
323
+ field: attributeField
324
+ }, _this.splitValuesAndCallbackInAttribute(
325
+ // @ts-ignore
326
+ attributeValues,
327
+ // @ts-ignore
328
+ attributeField ? undefined : _this.getLayerConfig()[attributeName] // 设置了字段不需要设置默认值
329
+ ))
330
+ },
331
+ // @ts-ignore
332
+ updateOptions);
333
+ });
334
+ _this.pendingStyleAttributes = [];
467
335
 
468
- // 启动动画
469
- var _this$getLayerConfig2 = this.getLayerConfig(),
470
- animateOption = _this$getLayerConfig2.animateOption;
471
- if (animateOption !== null && animateOption !== void 0 && animateOption.enable) {
472
- this.layerService.startAnimate();
473
- this.animateStatus = true;
336
+ // 获取插件集
337
+ _this.plugins = (0, _plugins.createPlugins)();
338
+ // 完成插件注册,传入场景和图层容器内的服务
339
+ for (const plugin of _this.plugins) {
340
+ plugin.apply(_this, _this.container);
474
341
  }
475
- }
476
- }, {
477
- key: "color",
478
- value: function color(field, values, updateOptions) {
479
- this.updateStyleAttribute('color', field, values, updateOptions);
480
- return this;
481
- }
342
+ // if (this.getSource().isTile) {
343
+ // this.tileLayer = new TileLayer(this);
344
+ // }
482
345
 
483
- // 为对应的图层传入纹理的编号名称(point/image 在 shape 方法中传入纹理名称的方法并不通用)
484
- }, {
485
- key: "texture",
486
- value: function texture(field, values, updateOptions) {
487
- this.updateStyleAttribute('texture', field, values, updateOptions);
488
- return this;
489
- }
490
- }, {
491
- key: "rotate",
492
- value: function rotate(field, values, updateOptions) {
493
- this.updateStyleAttribute('rotate', field, values, updateOptions);
494
- return this;
495
- }
496
- }, {
497
- key: "size",
498
- value: function size(field, values, updateOptions) {
499
- this.updateStyleAttribute('size', field, values, updateOptions);
500
- return this;
501
- }
502
- // 对mapping后的数据过滤,scale保持不变
503
- }, {
504
- key: "filter",
505
- value: function filter(field, values, updateOptions) {
506
- var flag = this.updateStyleAttribute('filter', field, values, updateOptions);
507
- this.dataState.dataSourceNeedUpdate = flag && this.inited;
508
- return this;
509
- }
510
- }, {
511
- key: "shape",
512
- value: function shape(field, values, updateOptions) {
513
- this.shapeOption = {
514
- field: field,
515
- values: values
516
- };
517
- var flag = this.updateStyleAttribute('shape', field, values, updateOptions);
518
- this.dataState.dataSourceNeedUpdate = flag && this.inited;
519
- return this;
520
- }
521
- }, {
522
- key: "label",
523
- value: function label(field, values, updateOptions) {
524
- this.pendingStyleAttributes.push({
525
- attributeName: 'label',
526
- attributeField: field,
527
- attributeValues: values,
528
- updateOptions: updateOptions
346
+ // 初始化其他服务
347
+ _this.layerPickService = new _LayerPickService.default(_this);
348
+
349
+ // 颜色纹理服务
350
+ _this.textureService = new _TextureService.default(_this);
351
+ _this.log(_l7Core.IDebugLog.LayerInitStart);
352
+ // 触发 init 生命周期插件
353
+ yield _this.hooks.init.promise();
354
+ _this.log(_l7Core.IDebugLog.LayerInitEnd);
355
+ _this.inited = true;
356
+ // add mask layer
357
+ // 触发初始化完成事件;
358
+ _this.emit('inited', {
359
+ target: _this,
360
+ type: 'inited'
529
361
  });
530
- return this;
531
- }
532
- }, {
533
- key: "animate",
534
- value: function animate(options) {
535
- var rawAnimate = {};
536
- if (isObject(options)) {
537
- rawAnimate.enable = true;
538
- rawAnimate = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, rawAnimate), options);
539
- } else {
540
- rawAnimate.enable = options;
541
- }
542
- this.updateLayerConfig({
543
- animateOption: rawAnimate
362
+ _this.emit('add', {
363
+ target: _this,
364
+ type: 'add'
544
365
  });
545
- return this;
366
+ _this.hooks.afterInit.call();
367
+ })();
368
+ }
369
+ log(logType, step = 'init') {
370
+ var _this$debugService;
371
+ // @ts-ignore 瓦片、瓦片图层目前不参与日志
372
+ if (this.tileLayer || this.isTileLayer) {
373
+ return;
374
+ }
375
+ const key = `${this.id}.${step}.${logType}`;
376
+ const values = {
377
+ id: this.id,
378
+ type: this.type
379
+ };
380
+ (_this$debugService = this.debugService) === null || _this$debugService === void 0 || _this$debugService.log(key, values);
381
+ }
382
+ updateModelData(data) {
383
+ if (data.attributes && data.elements) {
384
+ this.models.map(m => {
385
+ m.updateAttributesAndElements(data.attributes, data.elements);
386
+ });
387
+ } else {
388
+ console.warn('data error');
546
389
  }
547
- }, {
548
- key: "source",
549
- value: function source(data, options) {
550
- if ((data === null || data === void 0 ? void 0 : data.type) === 'source') {
551
- // 判断是否为source
552
- this.setSource(data);
553
- return this;
554
- }
555
- // 设置source 配置
556
- this.sourceOption = {
557
- data: data,
558
- options: options
559
- };
560
- this.clusterZoom = 0;
390
+ }
391
+ setLayerPickService(layerPickService) {
392
+ this.layerPickService = layerPickService;
393
+ }
394
+ /**
395
+ * Model初始化前需要更新Model样式
396
+ */
397
+ prepareBuildModel() {
398
+ if (Object.keys(this.needUpdateConfig || {}).length !== 0) {
399
+ this.updateLayerConfig({});
400
+ }
401
+
402
+ // 启动动画
403
+ const {
404
+ animateOption
405
+ } = this.getLayerConfig();
406
+ if (animateOption !== null && animateOption !== void 0 && animateOption.enable) {
407
+ this.layerService.startAnimate();
408
+ this.animateStatus = true;
409
+ }
410
+ }
411
+ color(field, values, updateOptions) {
412
+ this.updateStyleAttribute('color', field, values, updateOptions);
413
+ return this;
414
+ }
415
+
416
+ // 为对应的图层传入纹理的编号名称(point/image 在 shape 方法中传入纹理名称的方法并不通用)
417
+ texture(field, values, updateOptions) {
418
+ this.updateStyleAttribute('texture', field, values, updateOptions);
419
+ return this;
420
+ }
421
+ rotate(field, values, updateOptions) {
422
+ this.updateStyleAttribute('rotate', field, values, updateOptions);
423
+ return this;
424
+ }
425
+ size(field, values, updateOptions) {
426
+ this.updateStyleAttribute('size', field, values, updateOptions);
427
+ return this;
428
+ }
429
+ // 对mapping后的数据过滤,scale保持不变
430
+ filter(field, values, updateOptions) {
431
+ const flag = this.updateStyleAttribute('filter', field, values, updateOptions);
432
+ this.dataState.dataSourceNeedUpdate = flag && this.inited;
433
+ return this;
434
+ }
435
+ shape(field, values, updateOptions) {
436
+ this.shapeOption = {
437
+ field,
438
+ values
439
+ };
440
+ const flag = this.updateStyleAttribute('shape', field, values, updateOptions);
441
+ this.dataState.dataSourceNeedUpdate = flag && this.inited;
442
+ return this;
443
+ }
444
+ label(field, values, updateOptions) {
445
+ this.pendingStyleAttributes.push({
446
+ attributeName: 'label',
447
+ attributeField: field,
448
+ attributeValues: values,
449
+ updateOptions
450
+ });
451
+ return this;
452
+ }
453
+ animate(options) {
454
+ let rawAnimate = {};
455
+ if (isObject(options)) {
456
+ rawAnimate.enable = true;
457
+ rawAnimate = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, rawAnimate), options);
458
+ } else {
459
+ rawAnimate.enable = options;
460
+ }
461
+ this.updateLayerConfig({
462
+ animateOption: rawAnimate
463
+ });
464
+ return this;
465
+ }
466
+ source(data, options) {
467
+ if ((data === null || data === void 0 ? void 0 : data.type) === 'source') {
468
+ // 判断是否为source
469
+ this.setSource(data);
561
470
  return this;
562
471
  }
563
- }, {
564
- key: "setData",
565
- value: function setData(data, options) {
566
- var _this4 = this;
567
- if (this.inited) {
472
+ // 设置source 配置
473
+ this.sourceOption = {
474
+ data,
475
+ options
476
+ };
477
+ this.clusterZoom = 0;
478
+ return this;
479
+ }
480
+ setData(data, options) {
481
+ if (this.inited) {
482
+ this.dataUpdatelog();
483
+ this.layerSource.setData(data, options);
484
+ } else {
485
+ this.on('inited', () => {
568
486
  this.dataUpdatelog();
569
487
  this.layerSource.setData(data, options);
570
- } else {
571
- this.on('inited', function () {
572
- _this4.dataUpdatelog();
573
- _this4.layerSource.setData(data, options);
574
- });
575
- }
576
- return this;
488
+ });
577
489
  }
578
- }, {
579
- key: "dataUpdatelog",
580
- value: function dataUpdatelog() {
581
- var _this5 = this;
582
- this.log(_l7Core.IDebugLog.SourceInitStart, _l7Core.ILayerStage.UPDATE);
583
- this.layerSource.once('update', function () {
584
- _this5.log(_l7Core.IDebugLog.SourceInitEnd, _l7Core.ILayerStage.UPDATE);
490
+ return this;
491
+ }
492
+ dataUpdatelog() {
493
+ this.log(_l7Core.IDebugLog.SourceInitStart, _l7Core.ILayerStage.UPDATE);
494
+ this.layerSource.once('update', () => {
495
+ this.log(_l7Core.IDebugLog.SourceInitEnd, _l7Core.ILayerStage.UPDATE);
496
+ });
497
+ }
498
+ style(options) {
499
+ const {
500
+ passes
501
+ } = options,
502
+ rest = (0, _objectWithoutProperties2.default)(options, _excluded);
503
+ // passes 特殊处理
504
+ if (passes) {
505
+ (0, _multiPassRender.normalizePasses)(passes).forEach(pass => {
506
+ const postProcessingPass = this.multiPassRenderer.getPostProcessor().getPostProcessingPassByName(pass[0]);
507
+ if (postProcessingPass) {
508
+ postProcessingPass.updateOptions(pass[1]);
509
+ }
585
510
  });
586
511
  }
587
- }, {
588
- key: "style",
589
- value: function style(options) {
590
- var _this6 = this;
591
- var passes = options.passes,
592
- rest = (0, _objectWithoutProperties2.default)(options, _excluded);
593
- // passes 特殊处理
594
- if (passes) {
595
- (0, _multiPassRender.normalizePasses)(passes).forEach(function (pass) {
596
- var postProcessingPass = _this6.multiPassRenderer.getPostProcessor().getPostProcessingPassByName(pass[0]);
597
- if (postProcessingPass) {
598
- postProcessingPass.updateOptions(pass[1]);
599
- }
600
- });
601
- }
602
- // 兼容 borderColor borderWidth
512
+ // 兼容 borderColor borderWidth
513
+ // @ts-ignore
514
+ if (rest.borderColor) {
603
515
  // @ts-ignore
604
- if (rest.borderColor) {
605
- // @ts-ignore
606
- rest.stroke = rest.borderColor;
607
- }
516
+ rest.stroke = rest.borderColor;
517
+ }
518
+ // @ts-ignore
519
+ if (rest.borderWidth) {
608
520
  // @ts-ignore
609
- if (rest.borderWidth) {
610
- // @ts-ignore
611
- rest.strokeWidth = rest.borderWidth;
612
- }
613
-
614
- // 兼容老版本的写法 ['field, 'value']
615
- var newOption = rest;
616
- Object.keys(rest).forEach(function (key) {
617
- // @ts-ignore
618
- var values = rest[key];
619
- if (Array.isArray(values) && values.length === 2 && !isNumber(values[0]) && !isNumber(values[1])) {
620
- newOption[key] = {
621
- field: values[0],
622
- value: values[1]
623
- };
624
- }
625
- });
626
- this.encodeStyle(newOption);
627
- this.updateLayerConfig(newOption);
628
- return this;
521
+ rest.strokeWidth = rest.borderWidth;
629
522
  }
630
523
 
631
- // 参与数据映射的字段 encodeing
632
- }, {
633
- key: "encodeStyle",
634
- value: function encodeStyle(options) {
635
- var _this7 = this;
636
- Object.keys(options).forEach(function (key) {
637
- if (
638
- // 需要数据映射
639
- [].concat((0, _toConsumableArray2.default)(_this7.enableShaderEncodeStyles), (0, _toConsumableArray2.default)(_this7.enableDataEncodeStyles)).includes(key) && isPlainObject(options[key]) && (options[key].field || options[key].value) && !isEqual(_this7.encodeStyleAttribute[key], options[key]) // 防止计算属性重复计算
640
- ) {
641
- _this7.encodeStyleAttribute[key] = options[key];
642
- _this7.updateStyleAttribute(key, options[key].field, options[key].value);
643
- if (_this7.inited) {
644
- _this7.dataState.dataMappingNeedUpdate = true;
645
- }
646
- } else {
647
- // 不需要数据映射
648
- if (_this7.encodeStyleAttribute[key]) {
649
- delete _this7.encodeStyleAttribute[key]; // 删除已经存在的属性
650
- _this7.dataState.dataSourceNeedUpdate = true;
651
- }
524
+ // 兼容老版本的写法 ['field, 'value']
525
+ const newOption = rest;
526
+ Object.keys(rest).forEach(key => {
527
+ // @ts-ignore
528
+ const values = rest[key];
529
+ if (Array.isArray(values) && values.length === 2 && !isNumber(values[0]) && !isNumber(values[1])) {
530
+ newOption[key] = {
531
+ field: values[0],
532
+ value: values[1]
533
+ };
534
+ }
535
+ });
536
+ this.encodeStyle(newOption);
537
+ this.updateLayerConfig(newOption);
538
+ return this;
539
+ }
540
+
541
+ // 参与数据映射的字段 encodeing
542
+ encodeStyle(options) {
543
+ Object.keys(options).forEach(key => {
544
+ if (
545
+ // 需要数据映射
546
+ [...this.enableShaderEncodeStyles, ...this.enableDataEncodeStyles].includes(key) && isPlainObject(options[key]) && (options[key].field || options[key].value) && !isEqual(this.encodeStyleAttribute[key], options[key]) // 防止计算属性重复计算
547
+ ) {
548
+ this.encodeStyleAttribute[key] = options[key];
549
+ this.updateStyleAttribute(key, options[key].field, options[key].value);
550
+ if (this.inited) {
551
+ this.dataState.dataMappingNeedUpdate = true;
652
552
  }
653
- });
654
- }
655
- }, {
656
- key: "scale",
657
- value: function scale(field, cfg) {
658
- var preOption = (0, _objectSpread2.default)({}, this.scaleOptions);
659
- if (isObject(field)) {
660
- this.scaleOptions = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, this.scaleOptions), field);
661
553
  } else {
662
- this.scaleOptions[field] = cfg;
663
- }
664
- if (this.styleAttributeService && !isEqual(preOption, this.scaleOptions)) {
665
- var scaleOptions = isObject(field) ? field : (0, _defineProperty2.default)({}, field, cfg);
666
- this.styleAttributeService.updateScaleAttribute(scaleOptions);
554
+ // 不需要数据映射
555
+ if (this.encodeStyleAttribute[key]) {
556
+ delete this.encodeStyleAttribute[key]; // 删除已经存在的属性
557
+ this.dataState.dataSourceNeedUpdate = true;
558
+ }
667
559
  }
668
- return this;
560
+ });
561
+ }
562
+ scale(field, cfg) {
563
+ const preOption = (0, _objectSpread2.default)({}, this.scaleOptions);
564
+ if (isObject(field)) {
565
+ this.scaleOptions = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, this.scaleOptions), field);
566
+ } else {
567
+ this.scaleOptions[field] = cfg;
568
+ }
569
+ if (this.styleAttributeService && !isEqual(preOption, this.scaleOptions)) {
570
+ const scaleOptions = isObject(field) ? field : {
571
+ [field]: cfg
572
+ };
573
+ this.styleAttributeService.updateScaleAttribute(scaleOptions);
669
574
  }
575
+ return this;
576
+ }
670
577
 
671
- /**
672
- * 渲染所有的图层
673
- */
674
- }, {
675
- key: "renderLayers",
676
- value: function renderLayers() {
677
- this.rendering = true;
678
- this.layerService.reRender();
679
- this.rendering = false;
578
+ /**
579
+ * 渲染所有的图层
580
+ */
581
+ renderLayers() {
582
+ this.rendering = true;
583
+ this.layerService.reRender();
584
+ this.rendering = false;
585
+ }
586
+ prerender() {}
587
+ render(options = {}) {
588
+ if (this.tileLayer) {
589
+ // 瓦片图层执行单独的 render 渲染队列
590
+ this.tileLayer.render();
591
+ return this;
680
592
  }
681
- }, {
682
- key: "prerender",
683
- value: function prerender() {}
684
- }, {
685
- key: "render",
686
- value: function render() {
687
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
688
- if (this.tileLayer) {
689
- // 瓦片图层执行单独的 render 渲染队列
690
- this.tileLayer.render();
691
- return this;
692
- }
693
- this.layerService.beforeRenderData(this);
694
- if (this.encodeDataLength <= 0 && !this.forceRender) {
695
- return this;
696
- }
697
- // Tip: this.getEncodedData().length !== 0 这个判断是为了解决在 2.5.x 引入数据纹理后产生的 空数据渲染导致 texture 超出上限问题
698
- this.renderModels(options);
593
+ this.layerService.beforeRenderData(this);
594
+ if (this.encodeDataLength <= 0 && !this.forceRender) {
699
595
  return this;
700
596
  }
597
+ // Tip: this.getEncodedData().length !== 0 这个判断是为了解决在 2.5.x 引入数据纹理后产生的 空数据渲染导致 texture 超出上限问题
598
+ this.renderModels(options);
599
+ return this;
600
+ }
701
601
 
702
- /**
703
- * renderMultiPass 专门用于渲染支持 multipass 的 layer
704
- */
705
- }, {
706
- key: "renderMultiPass",
707
- value: (function () {
708
- var _renderMultiPass = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
709
- return _regenerator.default.wrap(function _callee2$(_context2) {
710
- while (1) switch (_context2.prev = _context2.next) {
711
- case 0:
712
- if (!(this.encodeDataLength <= 0 && !this.forceRender)) {
713
- _context2.next = 2;
714
- break;
715
- }
716
- return _context2.abrupt("return");
717
- case 2:
718
- if (!(this.multiPassRenderer && this.multiPassRenderer.getRenderFlag())) {
719
- _context2.next = 7;
720
- break;
721
- }
722
- _context2.next = 5;
723
- return this.multiPassRenderer.render();
724
- case 5:
725
- _context2.next = 8;
726
- break;
727
- case 7:
728
- if (this.multiPassRenderer) {
729
- // renderPass 触发的渲染
730
- this.renderModels();
731
- } else {
732
- this.renderModels();
733
- }
734
- case 8:
735
- case "end":
736
- return _context2.stop();
737
- }
738
- }, _callee2, this);
739
- }));
740
- function renderMultiPass() {
741
- return _renderMultiPass.apply(this, arguments);
742
- }
743
- return renderMultiPass;
744
- }())
745
- }, {
746
- key: "active",
747
- value: function active(options) {
748
- var activeOption = {};
749
- activeOption.enableHighlight = isObject(options) ? true : options;
750
- if (isObject(options)) {
751
- activeOption.enableHighlight = true;
752
- if (options.color) {
753
- activeOption.highlightColor = options.color;
754
- }
755
- if (options.mix) {
756
- activeOption.activeMix = options.mix;
757
- }
758
- } else {
759
- activeOption.enableHighlight = !!options;
602
+ /**
603
+ * renderMultiPass 专门用于渲染支持 multipass 的 layer
604
+ */
605
+ renderMultiPass() {
606
+ var _this2 = this;
607
+ return (0, _asyncToGenerator2.default)(function* () {
608
+ if (_this2.encodeDataLength <= 0 && !_this2.forceRender) {
609
+ return;
760
610
  }
761
- this.updateLayerConfig(activeOption);
762
- return this;
763
- }
764
- }, {
765
- key: "setActive",
766
- value: function setActive(id, options) {
767
- var _this8 = this;
768
- if (isObject(id)) {
769
- var _id$x = id.x,
770
- x = _id$x === void 0 ? 0 : _id$x,
771
- _id$y = id.y,
772
- y = _id$y === void 0 ? 0 : _id$y;
773
- this.updateLayerConfig({
774
- highlightColor: isObject(options) ? options.color : this.getLayerConfig().highlightColor,
775
- activeMix: isObject(options) ? options.mix : this.getLayerConfig().activeMix
776
- });
777
- this.pick({
778
- x: x,
779
- y: y
780
- });
611
+ if (_this2.multiPassRenderer && _this2.multiPassRenderer.getRenderFlag()) {
612
+ // multi render 开始执行 multiPassRender 的渲染流程
613
+ yield _this2.multiPassRenderer.render();
614
+ } else if (_this2.multiPassRenderer) {
615
+ // renderPass 触发的渲染
616
+ _this2.renderModels();
781
617
  } else {
782
- this.updateLayerConfig({
783
- pickedFeatureID: id,
784
- highlightColor: isObject(options) ? options.color : this.getLayerConfig().highlightColor,
785
- activeMix: isObject(options) ? options.mix : this.getLayerConfig().activeMix
786
- });
787
- this.hooks.beforeHighlight.call((0, _l7Utils.encodePickingColor)(id))
788
- // @ts-ignore
789
- .then(function () {
790
- setTimeout(function () {
791
- _this8.reRender();
792
- }, 1);
793
- });
618
+ _this2.renderModels();
794
619
  }
795
- }
796
- }, {
797
- key: "select",
798
- value: function select(option) {
799
- var activeOption = {};
800
- activeOption.enableSelect = isObject(option) ? true : option;
801
- if (isObject(option)) {
802
- activeOption.enableSelect = true;
803
- if (option.color) {
804
- activeOption.selectColor = option.color;
805
- }
806
- if (option.mix) {
807
- activeOption.selectMix = option.mix;
808
- }
809
- } else {
810
- activeOption.enableSelect = !!option;
620
+ })();
621
+ }
622
+ active(options) {
623
+ const activeOption = {};
624
+ activeOption.enableHighlight = isObject(options) ? true : options;
625
+ if (isObject(options)) {
626
+ activeOption.enableHighlight = true;
627
+ if (options.color) {
628
+ activeOption.highlightColor = options.color;
811
629
  }
812
- this.updateLayerConfig(activeOption);
813
- return this;
814
- }
815
- }, {
816
- key: "setSelect",
817
- value: function setSelect(id, options) {
818
- var _this9 = this;
819
- if (isObject(id)) {
820
- var _id$x2 = id.x,
821
- x = _id$x2 === void 0 ? 0 : _id$x2,
822
- _id$y2 = id.y,
823
- y = _id$y2 === void 0 ? 0 : _id$y2;
824
- this.updateLayerConfig({
825
- selectColor: isObject(options) ? options.color : this.getLayerConfig().selectColor,
826
- selectMix: isObject(options) ? options.mix : this.getLayerConfig().selectMix
827
- });
828
- this.pick({
829
- x: x,
830
- y: y
831
- });
832
- } else {
833
- this.updateLayerConfig({
834
- pickedFeatureID: id,
835
- selectColor: isObject(options) ? options.color : this.getLayerConfig().selectColor,
836
- selectMix: isObject(options) ? options.mix : this.getLayerConfig().selectMix
837
- });
838
- this.hooks.beforeSelect.call((0, _l7Utils.encodePickingColor)(id))
839
- // @ts-ignore
840
- .then(function () {
841
- setTimeout(function () {
842
- _this9.reRender();
843
- }, 1);
844
- });
630
+ if (options.mix) {
631
+ activeOption.activeMix = options.mix;
845
632
  }
633
+ } else {
634
+ activeOption.enableHighlight = !!options;
846
635
  }
847
- }, {
848
- key: "setBlend",
849
- value: function setBlend(type) {
636
+ this.updateLayerConfig(activeOption);
637
+ return this;
638
+ }
639
+ setActive(id, options) {
640
+ if (isObject(id)) {
641
+ const {
642
+ x = 0,
643
+ y = 0
644
+ } = id;
850
645
  this.updateLayerConfig({
851
- blend: type
646
+ highlightColor: isObject(options) ? options.color : this.getLayerConfig().highlightColor,
647
+ activeMix: isObject(options) ? options.mix : this.getLayerConfig().activeMix
852
648
  });
853
- // this.layerModelNeedUpdate = true;
854
- this.reRender();
855
- return this;
856
- }
857
- }, {
858
- key: "show",
859
- value: function show() {
860
- this.updateLayerConfig({
861
- visible: true
649
+ this.pick({
650
+ x,
651
+ y
862
652
  });
863
- this.reRender();
864
- this.emit('show');
865
- return this;
866
- }
867
- }, {
868
- key: "hide",
869
- value: function hide() {
653
+ } else {
870
654
  this.updateLayerConfig({
871
- visible: false
655
+ pickedFeatureID: id,
656
+ highlightColor: isObject(options) ? options.color : this.getLayerConfig().highlightColor,
657
+ activeMix: isObject(options) ? options.mix : this.getLayerConfig().activeMix
872
658
  });
873
- this.reRender();
874
- this.emit('hide');
875
- return this;
876
- }
877
- }, {
878
- key: "setIndex",
879
- value: function setIndex(index) {
880
- this.zIndex = index;
881
- this.layerService.updateLayerRenderList();
882
- this.layerService.renderLayers();
883
- return this;
884
- }
885
- }, {
886
- key: "setCurrentPickId",
887
- value: function setCurrentPickId(id) {
888
- this.currentPickId = id;
889
- }
890
- }, {
891
- key: "getCurrentPickId",
892
- value: function getCurrentPickId() {
893
- return this.currentPickId;
894
- }
895
- }, {
896
- key: "setCurrentSelectedId",
897
- value: function setCurrentSelectedId(id) {
898
- this.selectedFeatureID = id;
899
- }
900
- }, {
901
- key: "getCurrentSelectedId",
902
- value: function getCurrentSelectedId() {
903
- return this.selectedFeatureID;
904
- }
905
- }, {
906
- key: "isVisible",
907
- value: function isVisible() {
908
- var zoom = this.mapService.getZoom();
909
- var _this$getLayerConfig3 = this.getLayerConfig(),
910
- visible = _this$getLayerConfig3.visible,
911
- _this$getLayerConfig4 = _this$getLayerConfig3.minZoom,
912
- minZoom = _this$getLayerConfig4 === void 0 ? -Infinity : _this$getLayerConfig4,
913
- _this$getLayerConfig5 = _this$getLayerConfig3.maxZoom,
914
- maxZoom = _this$getLayerConfig5 === void 0 ? Infinity : _this$getLayerConfig5;
915
- return !!visible && zoom >= minZoom && zoom < maxZoom;
916
- }
917
- }, {
918
- key: "setMultiPass",
919
- value: function setMultiPass(enableMultiPass, currentPasses) {
920
- this.updateLayerConfig({
921
- enableMultiPassRenderer: enableMultiPass
659
+ this.hooks.beforeHighlight.call((0, _l7Utils.encodePickingColor)(id))
660
+ // @ts-ignore
661
+ .then(() => {
662
+ setTimeout(() => {
663
+ this.reRender();
664
+ }, 1);
922
665
  });
923
- if (currentPasses) {
924
- this.updateLayerConfig({
925
- passes: currentPasses
926
- });
666
+ }
667
+ }
668
+ select(option) {
669
+ const activeOption = {};
670
+ activeOption.enableSelect = isObject(option) ? true : option;
671
+ if (isObject(option)) {
672
+ activeOption.enableSelect = true;
673
+ if (option.color) {
674
+ activeOption.selectColor = option.color;
927
675
  }
928
- if (enableMultiPass) {
929
- var _this$getLayerConfig6 = this.getLayerConfig(),
930
- _this$getLayerConfig7 = _this$getLayerConfig6.passes,
931
- passes = _this$getLayerConfig7 === void 0 ? [] : _this$getLayerConfig7;
932
- this.multiPassRenderer = (0, _multiPassRender.createMultiPassRenderer)(this, passes, this.postProcessingPassFactory, this.normalPassFactory);
933
- this.multiPassRenderer.setRenderFlag(true);
934
- var _this$rendererService = this.rendererService.getViewportSize(),
935
- width = _this$rendererService.width,
936
- height = _this$rendererService.height;
937
- this.multiPassRenderer.resize(width, height);
676
+ if (option.mix) {
677
+ activeOption.selectMix = option.mix;
938
678
  }
939
- return this;
679
+ } else {
680
+ activeOption.enableSelect = !!option;
940
681
  }
941
- }, {
942
- key: "setMinZoom",
943
- value: function setMinZoom(minZoom) {
682
+ this.updateLayerConfig(activeOption);
683
+ return this;
684
+ }
685
+ setSelect(id, options) {
686
+ if (isObject(id)) {
687
+ const {
688
+ x = 0,
689
+ y = 0
690
+ } = id;
944
691
  this.updateLayerConfig({
945
- minZoom: minZoom
692
+ selectColor: isObject(options) ? options.color : this.getLayerConfig().selectColor,
693
+ selectMix: isObject(options) ? options.mix : this.getLayerConfig().selectMix
946
694
  });
947
- return this;
948
- }
949
- }, {
950
- key: "getMinZoom",
951
- value: function getMinZoom() {
952
- var _this$getLayerConfig8 = this.getLayerConfig(),
953
- minZoom = _this$getLayerConfig8.minZoom;
954
- return minZoom;
955
- }
956
- }, {
957
- key: "getMaxZoom",
958
- value: function getMaxZoom() {
959
- var _this$getLayerConfig9 = this.getLayerConfig(),
960
- maxZoom = _this$getLayerConfig9.maxZoom;
961
- return maxZoom;
962
- }
963
- }, {
964
- key: "get",
965
- value: function get(name) {
966
- var cfg = this.getLayerConfig();
695
+ this.pick({
696
+ x,
697
+ y
698
+ });
699
+ } else {
700
+ this.updateLayerConfig({
701
+ pickedFeatureID: id,
702
+ selectColor: isObject(options) ? options.color : this.getLayerConfig().selectColor,
703
+ selectMix: isObject(options) ? options.mix : this.getLayerConfig().selectMix
704
+ });
705
+ this.hooks.beforeSelect.call((0, _l7Utils.encodePickingColor)(id))
967
706
  // @ts-ignore
968
- return cfg[name];
707
+ .then(() => {
708
+ setTimeout(() => {
709
+ this.reRender();
710
+ }, 1);
711
+ });
969
712
  }
970
- }, {
971
- key: "setMaxZoom",
972
- value: function setMaxZoom(maxZoom) {
713
+ }
714
+ setBlend(type) {
715
+ this.updateLayerConfig({
716
+ blend: type
717
+ });
718
+ // this.layerModelNeedUpdate = true;
719
+ this.reRender();
720
+ return this;
721
+ }
722
+ show() {
723
+ this.updateLayerConfig({
724
+ visible: true
725
+ });
726
+ this.reRender();
727
+ this.emit('show');
728
+ return this;
729
+ }
730
+ hide() {
731
+ this.updateLayerConfig({
732
+ visible: false
733
+ });
734
+ this.reRender();
735
+ this.emit('hide');
736
+ return this;
737
+ }
738
+ setIndex(index) {
739
+ this.zIndex = index;
740
+ this.layerService.updateLayerRenderList();
741
+ this.layerService.renderLayers();
742
+ return this;
743
+ }
744
+ setCurrentPickId(id) {
745
+ this.currentPickId = id;
746
+ }
747
+ getCurrentPickId() {
748
+ return this.currentPickId;
749
+ }
750
+ setCurrentSelectedId(id) {
751
+ this.selectedFeatureID = id;
752
+ }
753
+ getCurrentSelectedId() {
754
+ return this.selectedFeatureID;
755
+ }
756
+ isVisible() {
757
+ const zoom = this.mapService.getZoom();
758
+ const {
759
+ visible,
760
+ minZoom = -Infinity,
761
+ maxZoom = Infinity
762
+ } = this.getLayerConfig();
763
+ return !!visible && zoom >= minZoom && zoom < maxZoom;
764
+ }
765
+ setMultiPass(enableMultiPass, currentPasses) {
766
+ this.updateLayerConfig({
767
+ enableMultiPassRenderer: enableMultiPass
768
+ });
769
+ if (currentPasses) {
973
770
  this.updateLayerConfig({
974
- maxZoom: maxZoom
771
+ passes: currentPasses
975
772
  });
976
- return this;
977
773
  }
978
- }, {
979
- key: "setAutoFit",
980
- value: function setAutoFit(autoFit) {
774
+ if (enableMultiPass) {
775
+ const {
776
+ passes = []
777
+ } = this.getLayerConfig();
778
+ this.multiPassRenderer = (0, _multiPassRender.createMultiPassRenderer)(this, passes, this.postProcessingPassFactory, this.normalPassFactory);
779
+ this.multiPassRenderer.setRenderFlag(true);
780
+ const {
781
+ width,
782
+ height
783
+ } = this.rendererService.getViewportSize();
784
+ this.multiPassRenderer.resize(width, height);
785
+ }
786
+ return this;
787
+ }
788
+ setMinZoom(minZoom) {
789
+ this.updateLayerConfig({
790
+ minZoom
791
+ });
792
+ return this;
793
+ }
794
+ getMinZoom() {
795
+ const {
796
+ minZoom
797
+ } = this.getLayerConfig();
798
+ return minZoom;
799
+ }
800
+ getMaxZoom() {
801
+ const {
802
+ maxZoom
803
+ } = this.getLayerConfig();
804
+ return maxZoom;
805
+ }
806
+ get(name) {
807
+ const cfg = this.getLayerConfig();
808
+ // @ts-ignore
809
+ return cfg[name];
810
+ }
811
+ setMaxZoom(maxZoom) {
812
+ this.updateLayerConfig({
813
+ maxZoom
814
+ });
815
+ return this;
816
+ }
817
+ setAutoFit(autoFit) {
818
+ this.updateLayerConfig({
819
+ autoFit
820
+ });
821
+ return this;
822
+ }
823
+
824
+ /**
825
+ * zoom to layer Bounds
826
+ */
827
+ fitBounds(fitBoundsOptions) {
828
+ if (!this.inited) {
981
829
  this.updateLayerConfig({
982
- autoFit: autoFit
830
+ autoFit: true
983
831
  });
984
832
  return this;
985
833
  }
986
-
987
- /**
988
- * zoom to layer Bounds
989
- */
990
- }, {
991
- key: "fitBounds",
992
- value: function fitBounds(fitBoundsOptions) {
993
- if (!this.inited) {
994
- this.updateLayerConfig({
995
- autoFit: true
996
- });
997
- return this;
998
- }
999
- var source = this.getSource();
1000
- var extent = source.extent;
1001
- var isValid = extent.some(function (v) {
1002
- return Math.abs(v) === Infinity;
1003
- });
1004
- if (isValid) {
1005
- return this;
1006
- }
1007
- this.mapService.fitBounds([[extent[0], extent[1]], [extent[2], extent[3]]], fitBoundsOptions);
834
+ const source = this.getSource();
835
+ const extent = source.extent;
836
+ const isValid = extent.some(v => Math.abs(v) === Infinity);
837
+ if (isValid) {
1008
838
  return this;
1009
839
  }
1010
- }, {
1011
- key: "destroy",
1012
- value: function destroy() {
1013
- var _this$layerModel, _this$multiPassRender, _this$layerModel2, _this$tileLayer, _this$debugService2;
1014
- var refresh = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
1015
- if (this.isDestroyed) {
1016
- return;
1017
- }
840
+ this.mapService.fitBounds([[extent[0], extent[1]], [extent[2], extent[3]]], fitBoundsOptions);
841
+ return this;
842
+ }
843
+ destroy(refresh = true) {
844
+ var _this$layerModel, _this$multiPassRender, _this$layerModel2, _this$tileLayer, _this$debugService2;
845
+ if (this.isDestroyed) {
846
+ return;
847
+ }
1018
848
 
1019
- // destroy all UBOs
1020
- (_this$layerModel = this.layerModel) === null || _this$layerModel === void 0 || _this$layerModel.uniformBuffers.forEach(function (buffer) {
1021
- buffer.destroy();
1022
- });
849
+ // destroy all UBOs
850
+ (_this$layerModel = this.layerModel) === null || _this$layerModel === void 0 || _this$layerModel.uniformBuffers.forEach(buffer => {
851
+ buffer.destroy();
852
+ });
1023
853
 
1024
- // remove child layer
1025
- this.layerChildren.map(function (child) {
1026
- return child.destroy(false);
1027
- });
1028
- this.layerChildren = [];
854
+ // remove child layer
855
+ this.layerChildren.map(child => child.destroy(false));
856
+ this.layerChildren = [];
1029
857
 
1030
- // remove mask list maskfence 掩膜需要销毁
1031
- var _this$getLayerConfig10 = this.getLayerConfig(),
1032
- maskfence = _this$getLayerConfig10.maskfence;
1033
- if (maskfence) {
1034
- this.masks.map(function (mask) {
1035
- return mask.destroy(false);
1036
- });
1037
- this.masks = [];
1038
- }
1039
- this.hooks.beforeDestroy.call();
1040
- // 清除sources事件
1041
- this.layerSource.off('update', this.sourceEvent);
1042
- (_this$multiPassRender = this.multiPassRenderer) === null || _this$multiPassRender === void 0 || _this$multiPassRender.destroy();
1043
- this.textureService.destroy();
858
+ // remove mask list maskfence 掩膜需要销毁
859
+ const {
860
+ maskfence
861
+ } = this.getLayerConfig();
862
+ if (maskfence) {
863
+ this.masks.map(mask => mask.destroy(false));
864
+ this.masks = [];
865
+ }
866
+ this.hooks.beforeDestroy.call();
867
+ // 清除sources事件
868
+ this.layerSource.off('update', this.sourceEvent);
869
+ (_this$multiPassRender = this.multiPassRenderer) === null || _this$multiPassRender === void 0 || _this$multiPassRender.destroy();
870
+ this.textureService.destroy();
1044
871
 
1045
- // 清除所有属性以及关联的 vao == 销毁所有 => model this.models.forEach((model) => model.destroy());
1046
- this.styleAttributeService.clearAllAttributes();
872
+ // 清除所有属性以及关联的 vao == 销毁所有 => model this.models.forEach((model) => model.destroy());
873
+ this.styleAttributeService.clearAllAttributes();
1047
874
 
1048
- // 执行每个图层单独的 clearModels 方法 (清除一些额外的 texture、program、buffer 等)
875
+ // 执行每个图层单独的 clearModels 方法 (清除一些额外的 texture、program、buffer 等)
1049
876
 
1050
- this.hooks.afterDestroy.call();
1051
- // Tip: 清除各个图层自定义的 models 资源
1052
- (_this$layerModel2 = this.layerModel) === null || _this$layerModel2 === void 0 || _this$layerModel2.clearModels(refresh);
1053
- (_this$tileLayer = this.tileLayer) === null || _this$tileLayer === void 0 || _this$tileLayer.destroy();
1054
- this.models = [];
1055
- // 清除图层日志(如果有的话:非瓦片相关)
1056
- (_this$debugService2 = this.debugService) === null || _this$debugService2 === void 0 || _this$debugService2.removeLog(this.id);
1057
- this.emit('remove', {
1058
- target: this,
1059
- type: 'remove'
1060
- });
1061
- this.emit('destroy', {
1062
- target: this,
1063
- type: 'destroy'
1064
- });
1065
- this.removeAllListeners();
1066
- this.isDestroyed = true;
1067
- }
1068
- }, {
1069
- key: "clear",
1070
- value: function clear() {
1071
- this.styleAttributeService.clearAllAttributes();
1072
- // 销毁所有 model
1073
- }
1074
- }, {
1075
- key: "clearModels",
1076
- value: function clearModels() {
1077
- var _this$layerModel3;
1078
- this.models.forEach(function (model) {
1079
- return model.destroy();
1080
- });
1081
- (_this$layerModel3 = this.layerModel) === null || _this$layerModel3 === void 0 || _this$layerModel3.clearModels();
1082
- this.models = [];
1083
- }
1084
- }, {
1085
- key: "isDirty",
1086
- value: function isDirty() {
1087
- return !!(this.styleAttributeService.getLayerStyleAttributes() || []).filter(function (attribute) {
1088
- return attribute.needRescale || attribute.needRemapping || attribute.needRegenerateVertices;
1089
- }).length;
877
+ this.hooks.afterDestroy.call();
878
+ // Tip: 清除各个图层自定义的 models 资源
879
+ (_this$layerModel2 = this.layerModel) === null || _this$layerModel2 === void 0 || _this$layerModel2.clearModels(refresh);
880
+ (_this$tileLayer = this.tileLayer) === null || _this$tileLayer === void 0 || _this$tileLayer.destroy();
881
+ this.models = [];
882
+ // 清除图层日志(如果有的话:非瓦片相关)
883
+ (_this$debugService2 = this.debugService) === null || _this$debugService2 === void 0 || _this$debugService2.removeLog(this.id);
884
+ this.emit('remove', {
885
+ target: this,
886
+ type: 'remove'
887
+ });
888
+ this.emit('destroy', {
889
+ target: this,
890
+ type: 'destroy'
891
+ });
892
+ this.removeAllListeners();
893
+ this.isDestroyed = true;
894
+ }
895
+ clear() {
896
+ this.styleAttributeService.clearAllAttributes();
897
+ // 销毁所有 model
898
+ }
899
+ clearModels() {
900
+ var _this$layerModel3;
901
+ this.models.forEach(model => model.destroy());
902
+ (_this$layerModel3 = this.layerModel) === null || _this$layerModel3 === void 0 || _this$layerModel3.clearModels();
903
+ this.models = [];
904
+ }
905
+ isDirty() {
906
+ return !!(this.styleAttributeService.getLayerStyleAttributes() || []).filter(attribute => attribute.needRescale || attribute.needRemapping || attribute.needRegenerateVertices).length;
907
+ }
908
+ // 外部初始化Source
909
+ setSource(source) {
910
+ // 解除原 sources 事件
911
+ if (this.layerSource) {
912
+ this.layerSource.off('update', this.sourceEvent);
1090
913
  }
1091
- // 外部初始化Source
1092
- }, {
1093
- key: "setSource",
1094
- value: function setSource(source) {
1095
- var _this10 = this;
1096
- // 解除原 sources 事件
1097
- if (this.layerSource) {
1098
- this.layerSource.off('update', this.sourceEvent);
1099
- }
1100
- this.layerSource = source;
1101
- this.clusterZoom = 0;
914
+ this.layerSource = source;
915
+ this.clusterZoom = 0;
1102
916
 
1103
- // 已 inited 且启用聚合进行更新聚合数据
1104
- if (this.inited && this.layerSource.cluster) {
1105
- var zoom = this.mapService.getZoom();
1106
- this.layerSource.updateClusterData(zoom);
1107
- }
1108
- if (this.layerSource.inited) {
1109
- this.sourceEvent();
1110
- }
1111
- // this.layerSource.inited 为 true update 事件不会再触发
1112
- this.layerSource.on('update', function (_ref4) {
1113
- var type = _ref4.type;
1114
- if (_this10.coordCenter === undefined) {
1115
- var _this10$mapService;
1116
- var layerCenter = _this10.layerSource.center;
1117
- _this10.coordCenter = layerCenter;
1118
- if ((_this10$mapService = _this10.mapService) !== null && _this10$mapService !== void 0 && _this10$mapService.setCoordCenter) {
1119
- _this10.mapService.setCoordCenter(layerCenter);
1120
- }
917
+ // 已 inited 且启用聚合进行更新聚合数据
918
+ if (this.inited && this.layerSource.cluster) {
919
+ const zoom = this.mapService.getZoom();
920
+ this.layerSource.updateClusterData(zoom);
921
+ }
922
+ if (this.layerSource.inited) {
923
+ this.sourceEvent();
924
+ }
925
+ // this.layerSource.inited 为 true update 事件不会再触发
926
+ this.layerSource.on('update', ({
927
+ type
928
+ }) => {
929
+ if (this.coordCenter === undefined) {
930
+ var _this$mapService;
931
+ const layerCenter = this.layerSource.center;
932
+ this.coordCenter = layerCenter;
933
+ if ((_this$mapService = this.mapService) !== null && _this$mapService !== void 0 && _this$mapService.setCoordCenter) {
934
+ this.mapService.setCoordCenter(layerCenter);
1121
935
  }
1122
- if (type === 'update') {
1123
- if (_this10.tileLayer) {
1124
- // 瓦片图层独立更新
1125
- _this10.tileLayer.reload();
1126
- return;
1127
- }
1128
- // source 初始化不需要处理
1129
- _this10.sourceEvent();
1130
- }
1131
- });
1132
- }
1133
- }, {
1134
- key: "getSource",
1135
- value: function getSource() {
1136
- return this.layerSource;
1137
- }
1138
- }, {
1139
- key: "getScaleOptions",
1140
- value: function getScaleOptions() {
1141
- return this.scaleOptions;
1142
- }
1143
- }, {
1144
- key: "setEncodedData",
1145
- value: function setEncodedData(encodedData) {
1146
- this.encodedData = encodedData;
1147
- this.encodeDataLength = encodedData.length;
1148
- }
1149
- }, {
1150
- key: "getEncodedData",
1151
- value: function getEncodedData() {
1152
- return this.encodedData;
1153
- }
1154
- }, {
1155
- key: "getScale",
1156
- value: function getScale(name) {
1157
- return this.styleAttributeService.getLayerAttributeScale(name);
1158
- }
1159
- }, {
1160
- key: "getLegend",
1161
- value: function getLegend(name) {
1162
- var _attribute$scale, _scales$, _attribute$scale2;
1163
- var attribute = this.styleAttributeService.getLayerStyleAttribute(name);
1164
- var scales = (attribute === null || attribute === void 0 || (_attribute$scale = attribute.scale) === null || _attribute$scale === void 0 ? void 0 : _attribute$scale.scalers) || [];
1165
- return {
1166
- type: (_scales$ = scales[0]) === null || _scales$ === void 0 || (_scales$ = _scales$.option) === null || _scales$ === void 0 ? void 0 : _scales$.type,
1167
- field: attribute === null || attribute === void 0 || (_attribute$scale2 = attribute.scale) === null || _attribute$scale2 === void 0 ? void 0 : _attribute$scale2.field,
1168
- items: this.getLegendItems(name)
1169
- };
1170
- }
1171
- }, {
1172
- key: "getLegendItems",
1173
- value: function getLegendItems(name) {
1174
- var scale = this.styleAttributeService.getLayerAttributeScale(name);
1175
- // 函数自定义映射,没有 scale 返回为空数组
1176
- if (!scale) {
1177
- return [];
1178
936
  }
1179
- if (scale.invertExtent) {
1180
- // 分段类型 Quantize、Quantile、Threshold
1181
- var items = scale.range().map(function (item) {
1182
- return (0, _defineProperty2.default)({
1183
- value: scale.invertExtent(item)
1184
- }, name, item);
1185
- });
1186
- return items;
1187
- } else if (scale.ticks) {
1188
- // 连续类型 Continuous (Linear, Power, Log, Identity, Time)
1189
- var _items = scale.ticks().map(function (item) {
1190
- return (0, _defineProperty2.default)({
1191
- value: item
1192
- }, name, scale(item));
1193
- });
1194
- return _items;
1195
- } else if (scale !== null && scale !== void 0 && scale.domain) {
1196
- // 枚举类型 Cat
1197
- var _items2 = scale.domain().filter(function (item) {
1198
- return !isUndefined(item);
1199
- }).map(function (item) {
1200
- return (0, _defineProperty2.default)({
1201
- value: item
1202
- }, name, scale(item));
1203
- });
1204
- return _items2;
937
+ if (type === 'update') {
938
+ if (this.tileLayer) {
939
+ // 瓦片图层独立更新
940
+ this.tileLayer.reload();
941
+ return;
942
+ }
943
+ // source 初始化不需要处理
944
+ this.sourceEvent();
1205
945
  }
946
+ });
947
+ }
948
+ getSource() {
949
+ return this.layerSource;
950
+ }
951
+ getScaleOptions() {
952
+ return this.scaleOptions;
953
+ }
954
+ setEncodedData(encodedData) {
955
+ this.encodedData = encodedData;
956
+ this.encodeDataLength = encodedData.length;
957
+ }
958
+ getEncodedData() {
959
+ return this.encodedData;
960
+ }
961
+ getScale(name) {
962
+ return this.styleAttributeService.getLayerAttributeScale(name);
963
+ }
964
+ getLegend(name) {
965
+ var _attribute$scale, _scales$, _attribute$scale2;
966
+ const attribute = this.styleAttributeService.getLayerStyleAttribute(name);
967
+ const scales = (attribute === null || attribute === void 0 || (_attribute$scale = attribute.scale) === null || _attribute$scale === void 0 ? void 0 : _attribute$scale.scalers) || [];
968
+ return {
969
+ type: (_scales$ = scales[0]) === null || _scales$ === void 0 || (_scales$ = _scales$.option) === null || _scales$ === void 0 ? void 0 : _scales$.type,
970
+ field: attribute === null || attribute === void 0 || (_attribute$scale2 = attribute.scale) === null || _attribute$scale2 === void 0 ? void 0 : _attribute$scale2.field,
971
+ items: this.getLegendItems(name)
972
+ };
973
+ }
974
+ getLegendItems(name) {
975
+ const scale = this.styleAttributeService.getLayerAttributeScale(name);
976
+ // 函数自定义映射,没有 scale 返回为空数组
977
+ if (!scale) {
1206
978
  return [];
1207
979
  }
1208
- }, {
1209
- key: "pick",
1210
- value: function pick(_ref8) {
1211
- var x = _ref8.x,
1212
- y = _ref8.y;
1213
- this.interactionService.triggerHover({
1214
- x: x,
1215
- y: y
980
+ if (scale.invertExtent) {
981
+ // 分段类型 Quantize、Quantile、Threshold
982
+ const items = scale.range().map(item => {
983
+ return {
984
+ value: scale.invertExtent(item),
985
+ [name]: item
986
+ };
1216
987
  });
988
+ return items;
989
+ } else if (scale.ticks) {
990
+ // 连续类型 Continuous (Linear, Power, Log, Identity, Time)
991
+ const items = scale.ticks().map(item => {
992
+ return {
993
+ value: item,
994
+ [name]: scale(item)
995
+ };
996
+ });
997
+ return items;
998
+ } else if (scale !== null && scale !== void 0 && scale.domain) {
999
+ // 枚举类型 Cat
1000
+ const items = scale.domain().filter(item => !isUndefined(item)).map(item => {
1001
+ return {
1002
+ value: item,
1003
+ [name]: scale(item)
1004
+ };
1005
+ });
1006
+ return items;
1217
1007
  }
1218
- }, {
1219
- key: "boxSelect",
1220
- value: function boxSelect(box, cb) {
1221
- this.pickingService.boxPickLayer(this, box, cb);
1222
- }
1223
- }, {
1224
- key: "buildLayerModel",
1225
- value: function () {
1226
- var _buildLayerModel = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(options) {
1227
- var _this11 = this;
1228
- var moduleName, vertexShader, fragmentShader, inject, triangulation, styleOption, _options$pickingEnabl, pickingEnabled, rest, _this$shaderModuleSer, vs, fs, uniforms, createModel;
1229
- return _regenerator.default.wrap(function _callee3$(_context3) {
1230
- while (1) switch (_context3.prev = _context3.next) {
1231
- case 0:
1232
- moduleName = options.moduleName, vertexShader = options.vertexShader, fragmentShader = options.fragmentShader, inject = options.inject, triangulation = options.triangulation, styleOption = options.styleOption, _options$pickingEnabl = options.pickingEnabled, pickingEnabled = _options$pickingEnabl === void 0 ? true : _options$pickingEnabl, rest = (0, _objectWithoutProperties2.default)(options, _excluded2);
1233
- this.shaderModuleService.registerModule(moduleName, {
1234
- vs: vertexShader,
1235
- fs: fragmentShader,
1236
- inject: inject
1237
- });
1238
- _this$shaderModuleSer = this.shaderModuleService.getModule(moduleName), vs = _this$shaderModuleSer.vs, fs = _this$shaderModuleSer.fs, uniforms = _this$shaderModuleSer.uniforms;
1239
- createModel = this.rendererService.createModel;
1240
- return _context3.abrupt("return", new Promise(function (resolve) {
1241
- var _this11$styleAttribut = _this11.styleAttributeService.createAttributesAndIndices(_this11.encodedData, triangulation, styleOption, _this11),
1242
- attributes = _this11$styleAttribut.attributes,
1243
- elements = _this11$styleAttribut.elements,
1244
- count = _this11$styleAttribut.count;
1245
- var uniformBuffers = [].concat((0, _toConsumableArray2.default)(_this11.layerModel.uniformBuffers), (0, _toConsumableArray2.default)(_this11.rendererService.uniformBuffers), [_this11.getLayerUniformBuffer()]);
1246
- if (pickingEnabled) {
1247
- uniformBuffers.push(_this11.getPickingUniformBuffer());
1248
- }
1249
- var modelOptions = (0, _objectSpread2.default)({
1250
- attributes: attributes,
1251
- uniforms: uniforms,
1252
- fs: fs,
1253
- vs: vs,
1254
- elements: elements,
1255
- blend: _blend.BlendTypes[_l7Core.BlendType.normal],
1256
- uniformBuffers: uniformBuffers,
1257
- textures: _this11.layerModel.textures
1258
- }, rest);
1259
- if (count) {
1260
- modelOptions.count = count;
1261
- }
1262
- var m = createModel(modelOptions);
1263
- resolve(m);
1264
- }));
1265
- case 5:
1266
- case "end":
1267
- return _context3.stop();
1268
- }
1269
- }, _callee3, this);
1270
- }));
1271
- function buildLayerModel(_x) {
1272
- return _buildLayerModel.apply(this, arguments);
1273
- }
1274
- return buildLayerModel;
1275
- }()
1276
- }, {
1277
- key: "createAttributes",
1278
- value: function createAttributes(options) {
1279
- var triangulation = options.triangulation;
1280
- // @ts-ignore
1281
- var _this$styleAttributeS = this.styleAttributeService.createAttributes(this.encodedData, triangulation),
1282
- attributes = _this$styleAttributeS.attributes;
1283
- return attributes;
1284
- }
1285
- }, {
1286
- key: "getTime",
1287
- value: function getTime() {
1288
- return this.layerService.clock.getDelta();
1289
- }
1290
- }, {
1291
- key: "setAnimateStartTime",
1292
- value: function setAnimateStartTime() {
1293
- this.animateStartTime = this.layerService.clock.getElapsedTime();
1294
- }
1295
- }, {
1296
- key: "stopAnimate",
1297
- value: function stopAnimate() {
1298
- if (this.animateStatus) {
1299
- this.layerService.stopAnimate();
1300
- this.animateStatus = false;
1301
- this.updateLayerConfig({
1302
- animateOption: {
1303
- enable: false
1304
- }
1305
- });
1306
- }
1008
+ return [];
1009
+ }
1010
+ pick({
1011
+ x,
1012
+ y
1013
+ }) {
1014
+ this.interactionService.triggerHover({
1015
+ x,
1016
+ y
1017
+ });
1018
+ }
1019
+ boxSelect(box, cb) {
1020
+ this.pickingService.boxPickLayer(this, box, cb);
1021
+ }
1022
+ buildLayerModel(options) {
1023
+ var _this3 = this;
1024
+ return (0, _asyncToGenerator2.default)(function* () {
1025
+ const {
1026
+ moduleName,
1027
+ vertexShader,
1028
+ fragmentShader,
1029
+ inject,
1030
+ triangulation,
1031
+ styleOption,
1032
+ pickingEnabled = true
1033
+ } = options,
1034
+ rest = (0, _objectWithoutProperties2.default)(options, _excluded2);
1035
+ _this3.shaderModuleService.registerModule(moduleName, {
1036
+ vs: vertexShader,
1037
+ fs: fragmentShader,
1038
+ inject
1039
+ });
1040
+ const {
1041
+ vs,
1042
+ fs,
1043
+ uniforms
1044
+ } = _this3.shaderModuleService.getModule(moduleName);
1045
+ const {
1046
+ createModel
1047
+ } = _this3.rendererService;
1048
+ return new Promise(resolve => {
1049
+ const {
1050
+ attributes,
1051
+ elements,
1052
+ count
1053
+ } = _this3.styleAttributeService.createAttributesAndIndices(_this3.encodedData, triangulation, styleOption, _this3);
1054
+ const uniformBuffers = [..._this3.layerModel.uniformBuffers, ..._this3.rendererService.uniformBuffers, _this3.getLayerUniformBuffer()];
1055
+ if (pickingEnabled) {
1056
+ uniformBuffers.push(_this3.getPickingUniformBuffer());
1057
+ }
1058
+ const modelOptions = (0, _objectSpread2.default)({
1059
+ attributes,
1060
+ uniforms,
1061
+ fs,
1062
+ vs,
1063
+ elements,
1064
+ blend: _blend.BlendTypes[_l7Core.BlendType.normal],
1065
+ uniformBuffers,
1066
+ textures: _this3.layerModel.textures
1067
+ }, rest);
1068
+ if (count) {
1069
+ modelOptions.count = count;
1070
+ }
1071
+ const m = createModel(modelOptions);
1072
+ resolve(m);
1073
+ });
1074
+ })();
1075
+ }
1076
+ createAttributes(options) {
1077
+ const {
1078
+ triangulation
1079
+ } = options;
1080
+ // @ts-ignore
1081
+ const {
1082
+ attributes
1083
+ } = this.styleAttributeService.createAttributes(this.encodedData, triangulation);
1084
+ return attributes;
1085
+ }
1086
+ getTime() {
1087
+ return this.layerService.clock.getDelta();
1088
+ }
1089
+ setAnimateStartTime() {
1090
+ this.animateStartTime = this.layerService.clock.getElapsedTime();
1091
+ }
1092
+ stopAnimate() {
1093
+ if (this.animateStatus) {
1094
+ this.layerService.stopAnimate();
1095
+ this.animateStatus = false;
1096
+ this.updateLayerConfig({
1097
+ animateOption: {
1098
+ enable: false
1099
+ }
1100
+ });
1307
1101
  }
1308
- }, {
1309
- key: "getLayerAnimateTime",
1310
- value: function getLayerAnimateTime() {
1311
- return this.layerService.clock.getElapsedTime() - this.animateStartTime;
1102
+ }
1103
+ getLayerAnimateTime() {
1104
+ return this.layerService.clock.getElapsedTime() - this.animateStartTime;
1105
+ }
1106
+ needPick(type) {
1107
+ const {
1108
+ enableHighlight = true,
1109
+ enableSelect = true
1110
+ } = this.getLayerConfig();
1111
+ // 判断layer是否监听事件;
1112
+ let isPick = this.eventNames().indexOf(type) !== -1 || this.eventNames().indexOf('un' + type) !== -1;
1113
+ if ((type === 'click' || type === 'dblclick') && enableSelect) {
1114
+ isPick = true;
1115
+ }
1116
+ if (type === 'mousemove' && (enableHighlight || this.eventNames().indexOf('mouseenter') !== -1 || this.eventNames().indexOf('unmousemove') !== -1 || this.eventNames().indexOf('mouseout') !== -1)) {
1117
+ isPick = true;
1118
+ }
1119
+ return this.isVisible() && isPick;
1120
+ }
1121
+ buildModels() {
1122
+ return (0, _asyncToGenerator2.default)(function* () {
1123
+ throw new Error('Method not implemented.');
1124
+ })();
1125
+ }
1126
+ rebuildModels() {
1127
+ var _this4 = this;
1128
+ return (0, _asyncToGenerator2.default)(function* () {
1129
+ yield _this4.buildModels();
1130
+ })();
1131
+ }
1132
+ renderMulPass(multiPassRenderer) {
1133
+ return (0, _asyncToGenerator2.default)(function* () {
1134
+ yield multiPassRenderer.render();
1135
+ })();
1136
+ }
1137
+ renderModels(options = {}) {
1138
+ // TODO: this.getEncodedData().length > 0 这个判断是为了解决在 2.5.x 引入数据纹理后产生的 空数据渲染导致 texture 超出上限问题
1139
+ if (this.encodeDataLength <= 0 && !this.forceRender) {
1140
+ // 数据为空销毁model
1141
+ this.clearModels();
1142
+ return this;
1312
1143
  }
1313
- }, {
1314
- key: "needPick",
1315
- value: function needPick(type) {
1316
- var _this$getLayerConfig11 = this.getLayerConfig(),
1317
- _this$getLayerConfig12 = _this$getLayerConfig11.enableHighlight,
1318
- enableHighlight = _this$getLayerConfig12 === void 0 ? true : _this$getLayerConfig12,
1319
- _this$getLayerConfig13 = _this$getLayerConfig11.enableSelect,
1320
- enableSelect = _this$getLayerConfig13 === void 0 ? true : _this$getLayerConfig13;
1321
- // 判断layer是否监听事件;
1322
- var isPick = this.eventNames().indexOf(type) !== -1 || this.eventNames().indexOf('un' + type) !== -1;
1323
- if ((type === 'click' || type === 'dblclick') && enableSelect) {
1324
- isPick = true;
1325
- }
1326
- if (type === 'mousemove' && (enableHighlight || this.eventNames().indexOf('mouseenter') !== -1 || this.eventNames().indexOf('unmousemove') !== -1 || this.eventNames().indexOf('mouseout') !== -1)) {
1327
- isPick = true;
1328
- }
1329
- return this.isVisible() && isPick;
1144
+ this.hooks.beforeRender.call();
1145
+ this.models.forEach(model => {
1146
+ model.draw({
1147
+ uniforms: this.layerModel.getUninforms(),
1148
+ blend: this.layerModel.getBlend(),
1149
+ stencil: this.layerModel.getStencil(options),
1150
+ textures: this.layerModel.textures
1151
+ }, (options === null || options === void 0 ? void 0 : options.ispick) || false);
1152
+ });
1153
+ this.hooks.afterRender.call();
1154
+ return this;
1155
+ }
1156
+ updateStyleAttribute(type, field, values, updateOptions) {
1157
+ // encode diff
1158
+ const preAttribute = this.configService.getAttributeConfig(this.id) || {};
1159
+ // @ts-ignore
1160
+ if (isEqual(preAttribute[type], {
1161
+ field,
1162
+ values
1163
+ })) {
1164
+ // 检测是否发生更新
1165
+ return false;
1330
1166
  }
1331
- }, {
1332
- key: "buildModels",
1333
- value: function () {
1334
- var _buildModels = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
1335
- return _regenerator.default.wrap(function _callee4$(_context4) {
1336
- while (1) switch (_context4.prev = _context4.next) {
1337
- case 0:
1338
- throw new Error('Method not implemented.');
1339
- case 1:
1340
- case "end":
1341
- return _context4.stop();
1342
- }
1343
- }, _callee4);
1344
- }));
1345
- function buildModels() {
1346
- return _buildModels.apply(this, arguments);
1347
- }
1348
- return buildModels;
1349
- }()
1350
- }, {
1351
- key: "rebuildModels",
1352
- value: function () {
1353
- var _rebuildModels = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
1354
- return _regenerator.default.wrap(function _callee5$(_context5) {
1355
- while (1) switch (_context5.prev = _context5.next) {
1356
- case 0:
1357
- _context5.next = 2;
1358
- return this.buildModels();
1359
- case 2:
1360
- case "end":
1361
- return _context5.stop();
1362
- }
1363
- }, _callee5, this);
1364
- }));
1365
- function rebuildModels() {
1366
- return _rebuildModels.apply(this, arguments);
1367
- }
1368
- return rebuildModels;
1369
- }()
1370
- }, {
1371
- key: "renderMulPass",
1372
- value: function () {
1373
- var _renderMulPass = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(multiPassRenderer) {
1374
- return _regenerator.default.wrap(function _callee6$(_context6) {
1375
- while (1) switch (_context6.prev = _context6.next) {
1376
- case 0:
1377
- _context6.next = 2;
1378
- return multiPassRenderer.render();
1379
- case 2:
1380
- case "end":
1381
- return _context6.stop();
1382
- }
1383
- }, _callee6);
1384
- }));
1385
- function renderMulPass(_x2) {
1386
- return _renderMulPass.apply(this, arguments);
1387
- }
1388
- return renderMulPass;
1389
- }()
1390
- }, {
1391
- key: "renderModels",
1392
- value: function renderModels() {
1393
- var _this12 = this;
1394
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1395
- // TODO: this.getEncodedData().length > 0 这个判断是为了解决在 2.5.x 引入数据纹理后产生的 空数据渲染导致 texture 超出上限问题
1396
- if (this.encodeDataLength <= 0 && !this.forceRender) {
1397
- // 数据为空销毁model
1398
- this.clearModels();
1399
- return this;
1400
- }
1401
- this.hooks.beforeRender.call();
1402
- this.models.forEach(function (model) {
1403
- model.draw({
1404
- uniforms: _this12.layerModel.getUninforms(),
1405
- blend: _this12.layerModel.getBlend(),
1406
- stencil: _this12.layerModel.getStencil(options),
1407
- textures: _this12.layerModel.textures
1408
- }, (options === null || options === void 0 ? void 0 : options.ispick) || false);
1167
+
1168
+ // 存储 Attribute 瓦片图层使用
1169
+ if (['color', 'size', 'texture', 'rotate', 'filter', 'label', 'shape'].indexOf(type) !== -1) {
1170
+ this.configService.setAttributeConfig(this.id, {
1171
+ [type]: {
1172
+ field,
1173
+ values
1174
+ }
1409
1175
  });
1410
- this.hooks.afterRender.call();
1411
- return this;
1412
1176
  }
1413
- }, {
1414
- key: "updateStyleAttribute",
1415
- value: function updateStyleAttribute(type, field, values, updateOptions) {
1416
- // encode diff
1417
- var preAttribute = this.configService.getAttributeConfig(this.id) || {};
1418
- // @ts-ignore
1419
- if (isEqual(preAttribute[type], {
1420
- field: field,
1421
- values: values
1422
- })) {
1423
- // 检测是否发生更新
1424
- return false;
1425
- }
1426
-
1427
- // 存储 Attribute 瓦片图层使用
1428
- if (['color', 'size', 'texture', 'rotate', 'filter', 'label', 'shape'].indexOf(type) !== -1) {
1429
- this.configService.setAttributeConfig(this.id, (0, _defineProperty2.default)({}, type, {
1430
- field: field,
1431
- values: values
1432
- }));
1433
- }
1434
- if (!this.startInit) {
1435
- // 开始初始化执行
1436
- this.pendingStyleAttributes.push({
1437
- attributeName: type,
1438
- attributeField: field,
1439
- attributeValues: values,
1440
- updateOptions: updateOptions
1441
- });
1442
- } else {
1443
- this.styleAttributeService.updateStyleAttribute(type, {
1444
- // @ts-ignore
1445
- scale: (0, _objectSpread2.default)({
1446
- field: field
1447
- }, this.splitValuesAndCallbackInAttribute(
1448
- // @ts-ignore
1449
- values,
1450
- // @ts-ignore
1451
- this.getLayerConfig()[field]))
1452
- },
1177
+ if (!this.startInit) {
1178
+ // 开始初始化执行
1179
+ this.pendingStyleAttributes.push({
1180
+ attributeName: type,
1181
+ attributeField: field,
1182
+ attributeValues: values,
1183
+ updateOptions
1184
+ });
1185
+ } else {
1186
+ this.styleAttributeService.updateStyleAttribute(type, {
1453
1187
  // @ts-ignore
1454
- updateOptions);
1455
- }
1456
- return true;
1457
- }
1458
- }, {
1459
- key: "getLayerAttributeConfig",
1460
- value: function getLayerAttributeConfig() {
1461
- return this.configService.getAttributeConfig(this.id);
1462
- }
1463
- }, {
1464
- key: "getShaderPickStat",
1465
- value: function getShaderPickStat() {
1466
- return this.layerService.getShaderPickStat();
1188
+ scale: (0, _objectSpread2.default)({
1189
+ field
1190
+ }, this.splitValuesAndCallbackInAttribute(
1191
+ // @ts-ignore
1192
+ values,
1193
+ // @ts-ignore
1194
+ this.getLayerConfig()[field]))
1195
+ },
1196
+ // @ts-ignore
1197
+ updateOptions);
1467
1198
  }
1199
+ return true;
1200
+ }
1201
+ getLayerAttributeConfig() {
1202
+ return this.configService.getAttributeConfig(this.id);
1203
+ }
1204
+ getShaderPickStat() {
1205
+ return this.layerService.getShaderPickStat();
1206
+ }
1468
1207
 
1469
- /**
1470
- * 继承空方法
1471
- * @param time
1472
- */
1473
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1474
- }, {
1475
- key: "setEarthTime",
1476
- value: function setEarthTime(time) {
1477
- console.warn('empty fn');
1478
- }
1208
+ /**
1209
+ * 继承空方法
1210
+ * @param time
1211
+ */
1212
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
1213
+ setEarthTime(time) {
1214
+ console.warn('empty fn');
1215
+ }
1479
1216
 
1480
- // 数据处理 在数据进行 mapping 生成 encodeData 之前对数据进行处理
1481
- // 在各个 layer 中继承
1482
- }, {
1483
- key: "processData",
1484
- value: function processData(filterData) {
1485
- return filterData;
1486
- }
1487
- }, {
1488
- key: "getModelType",
1489
- value: function getModelType() {
1490
- throw new Error('Method not implemented.');
1491
- }
1492
- }, {
1493
- key: "getDefaultConfig",
1494
- value: function getDefaultConfig() {
1495
- return {};
1496
- }
1497
- }, {
1498
- key: "initLayerModels",
1499
- value: function () {
1500
- var _initLayerModels = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7() {
1501
- var layerUniforms, pickingUniforms;
1502
- return _regenerator.default.wrap(function _callee7$(_context7) {
1503
- while (1) switch (_context7.prev = _context7.next) {
1504
- case 0:
1505
- this.models.forEach(function (model) {
1506
- return model.destroy();
1507
- });
1508
- this.models = [];
1509
- this.uniformBuffers.forEach(function (buffer) {
1510
- buffer.destroy();
1511
- });
1512
- this.uniformBuffers = [];
1513
- // Layer Uniform
1514
- layerUniforms = this.rendererService.createBuffer({
1515
- data: new Float32Array(16 + 4).fill(0),
1516
- // u_Mvp
1517
- isUBO: true
1518
- });
1519
- this.uniformBuffers.push(layerUniforms);
1217
+ // 数据处理 在数据进行 mapping 生成 encodeData 之前对数据进行处理
1218
+ // 在各个 layer 中继承
1219
+ processData(filterData) {
1220
+ return filterData;
1221
+ }
1222
+ getModelType() {
1223
+ throw new Error('Method not implemented.');
1224
+ }
1225
+ getDefaultConfig() {
1226
+ return {};
1227
+ }
1228
+ initLayerModels() {
1229
+ var _this5 = this;
1230
+ return (0, _asyncToGenerator2.default)(function* () {
1231
+ _this5.models.forEach(model => model.destroy());
1232
+ _this5.models = [];
1233
+ _this5.uniformBuffers.forEach(buffer => {
1234
+ buffer.destroy();
1235
+ });
1236
+ _this5.uniformBuffers = [];
1237
+ // Layer Uniform
1238
+ const layerUniforms = _this5.rendererService.createBuffer({
1239
+ data: new Float32Array(16 + 4).fill(0),
1240
+ // u_Mvp
1241
+ isUBO: true
1242
+ });
1243
+ _this5.uniformBuffers.push(layerUniforms);
1520
1244
 
1521
- // Picking Uniform
1522
- pickingUniforms = this.rendererService.createBuffer({
1523
- data: new Float32Array(20).fill(0),
1524
- isUBO: true
1525
- });
1526
- this.uniformBuffers.push(pickingUniforms);
1527
- _context7.next = 10;
1528
- return this.layerModel.initModels();
1529
- case 10:
1530
- this.models = _context7.sent;
1531
- case 11:
1532
- case "end":
1533
- return _context7.stop();
1534
- }
1535
- }, _callee7, this);
1536
- }));
1537
- function initLayerModels() {
1538
- return _initLayerModels.apply(this, arguments);
1539
- }
1540
- return initLayerModels;
1541
- }()
1542
- }, {
1543
- key: "getLayerUniformBuffer",
1544
- value: function getLayerUniformBuffer() {
1545
- return this.uniformBuffers[0];
1546
- }
1547
- }, {
1548
- key: "getPickingUniformBuffer",
1549
- value: function getPickingUniformBuffer() {
1550
- return this.uniformBuffers[1];
1551
- }
1552
- }, {
1553
- key: "reRender",
1554
- value: function reRender() {
1555
- if (this.inited) {
1556
- this.layerService.reRender();
1557
- }
1558
- }
1559
- }, {
1560
- key: "splitValuesAndCallbackInAttribute",
1561
- value: function splitValuesAndCallbackInAttribute(valuesOrCallback
1562
- // defaultValues?: unknown[],
1563
- ) {
1564
- return {
1565
- values: isFunction(valuesOrCallback) ? undefined : valuesOrCallback,
1566
- callback: isFunction(valuesOrCallback) ? valuesOrCallback : undefined
1567
- };
1245
+ // Picking Uniform
1246
+ const pickingUniforms = _this5.rendererService.createBuffer({
1247
+ data: new Float32Array(20).fill(0),
1248
+ isUBO: true
1249
+ });
1250
+ _this5.uniformBuffers.push(pickingUniforms);
1251
+ _this5.models = yield _this5.layerModel.initModels();
1252
+ })();
1253
+ }
1254
+ getLayerUniformBuffer() {
1255
+ return this.uniformBuffers[0];
1256
+ }
1257
+ getPickingUniformBuffer() {
1258
+ return this.uniformBuffers[1];
1259
+ }
1260
+ reRender() {
1261
+ if (this.inited) {
1262
+ this.layerService.reRender();
1568
1263
  }
1569
- }]);
1570
- return BaseLayer;
1571
- }(_eventemitter.EventEmitter);
1264
+ }
1265
+ splitValuesAndCallbackInAttribute(valuesOrCallback
1266
+ // defaultValues?: unknown[],
1267
+ ) {
1268
+ return {
1269
+ values: isFunction(valuesOrCallback) ? undefined : valuesOrCallback,
1270
+ callback: isFunction(valuesOrCallback) ? valuesOrCallback : undefined
1271
+ };
1272
+ }
1273
+ }
1274
+ exports.default = BaseLayer;