@antv/l7-layers 2.21.0 → 2.21.2

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