@antv/l7-layers 2.21.1 → 2.21.3

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