@antv/l7-layers 2.15.5 → 2.16.1

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