@antv/l7-layers 2.21.0 → 2.21.2

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