@antv/l7-layers 2.17.4 → 2.17.5

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 (250) hide show
  1. package/es/Geometry/index.js +9 -31
  2. package/es/Geometry/models/billboard.js +51 -89
  3. package/es/Geometry/models/plane.js +81 -143
  4. package/es/Geometry/models/sprite.js +60 -118
  5. package/es/canvas/index.js +10 -33
  6. package/es/canvas/models/canvas.js +41 -97
  7. package/es/citybuliding/building.js +8 -27
  8. package/es/citybuliding/models/build.js +57 -82
  9. package/es/core/BaseLayer.js +325 -483
  10. package/es/core/BaseModel.js +51 -80
  11. package/es/core/CommonStyleAttribute.js +2 -5
  12. package/es/core/LayerPickService.js +21 -32
  13. package/es/core/TextureService.js +0 -13
  14. package/es/core/interface.js +17 -24
  15. package/es/core/shape/Path.js +13 -20
  16. package/es/core/shape/extrude.js +27 -39
  17. package/es/core/triangulation.js +99 -136
  18. package/es/earth/index.js +9 -33
  19. package/es/earth/models/atmosphere.js +30 -54
  20. package/es/earth/models/base.js +47 -85
  21. package/es/earth/models/bloomsphere.js +30 -54
  22. package/es/earth/utils.js +9 -13
  23. package/es/heatmap/index.js +10 -40
  24. package/es/heatmap/models/grid.js +28 -52
  25. package/es/heatmap/models/grid3d.js +28 -52
  26. package/es/heatmap/models/heatmap.js +92 -149
  27. package/es/heatmap/models/hexagon.js +28 -52
  28. package/es/heatmap/triangulation.js +0 -4
  29. package/es/image/index.js +9 -28
  30. package/es/image/models/image.js +66 -100
  31. package/es/index.js +9 -17
  32. package/es/line/index.js +9 -35
  33. package/es/line/models/arc.js +63 -112
  34. package/es/line/models/arc_3d.js +58 -102
  35. package/es/line/models/earthArc_3d.js +60 -105
  36. package/es/line/models/flow.js +36 -60
  37. package/es/line/models/great_circle.js +53 -94
  38. package/es/line/models/line.js +92 -144
  39. package/es/line/models/linearline.js +42 -74
  40. package/es/line/models/simpleLine.js +38 -67
  41. package/es/line/models/wall.js +52 -92
  42. package/es/line/shaders/dash/line_dash_vert.glsl +1 -2
  43. package/es/line/shaders/line_frag.glsl +1 -3
  44. package/es/line/shaders/line_vert.glsl +2 -0
  45. package/es/line/shaders/linear/line_linear_frag.glsl +1 -1
  46. package/es/mask/index.js +9 -28
  47. package/es/mask/models/fill.js +29 -54
  48. package/es/plugins/DataMappingPlugin.js +78 -114
  49. package/es/plugins/DataSourcePlugin.js +45 -68
  50. package/es/plugins/FeatureScalePlugin.js +67 -122
  51. package/es/plugins/LayerAnimateStylePlugin.js +0 -5
  52. package/es/plugins/LayerMaskPlugin.js +3 -11
  53. package/es/plugins/LayerModelPlugin.js +69 -118
  54. package/es/plugins/LayerStylePlugin.js +4 -9
  55. package/es/plugins/LightingPlugin.js +12 -18
  56. package/es/plugins/MultiPassRendererPlugin.js +11 -16
  57. package/es/plugins/PixelPickingPlugin.js +12 -21
  58. package/es/plugins/RegisterStyleAttributePlugin.js +5 -12
  59. package/es/plugins/ShaderUniformPlugin.js +13 -27
  60. package/es/plugins/UpdateModelPlugin.js +0 -5
  61. package/es/plugins/UpdateStyleAttributePlugin.js +5 -11
  62. package/es/point/index.js +26 -78
  63. package/es/point/models/earthExtrude.js +58 -95
  64. package/es/point/models/earthFill.js +52 -80
  65. package/es/point/models/extrude.js +57 -94
  66. package/es/point/models/fill.js +56 -81
  67. package/es/point/models/fillmage.js +60 -100
  68. package/es/point/models/image.js +47 -83
  69. package/es/point/models/index.js +2 -2
  70. package/es/point/models/normal.js +30 -54
  71. package/es/point/models/radar.js +38 -63
  72. package/es/point/models/simplePoint.js +38 -62
  73. package/es/point/models/text.js +199 -296
  74. package/es/point/shape/extrude.js +4 -13
  75. package/es/polygon/index.js +11 -41
  76. package/es/polygon/models/extrude.js +87 -135
  77. package/es/polygon/models/fill.js +50 -79
  78. package/es/polygon/models/index.js +3 -2
  79. package/es/polygon/models/ocean.js +42 -76
  80. package/es/polygon/models/water.js +37 -71
  81. package/es/raster/buffers/triangulation.js +2 -4
  82. package/es/raster/index.js +9 -32
  83. package/es/raster/models/raster.js +80 -116
  84. package/es/raster/models/rasterRgb.js +84 -127
  85. package/es/raster/models/rasterTerrainRgb.js +56 -84
  86. package/es/tile/interaction/getRasterData.js +14 -20
  87. package/es/tile/interaction/utils.js +7 -9
  88. package/es/tile/manager/base.js +63 -96
  89. package/es/tile/service/TileLayerService.js +33 -55
  90. package/es/tile/service/TilePickService.js +26 -40
  91. package/es/tile/service/TileSourceService.js +3 -7
  92. package/es/tile/tileFactory/DebugTile.js +29 -46
  93. package/es/tile/tileFactory/ImageTile.js +20 -38
  94. package/es/tile/tileFactory/MaskTile.js +22 -43
  95. package/es/tile/tileFactory/RasterRGBTile.js +22 -42
  96. package/es/tile/tileFactory/RasterTerrainRGBTile.js +20 -38
  97. package/es/tile/tileFactory/RasterTile.js +30 -53
  98. package/es/tile/tileFactory/Tile.js +63 -97
  99. package/es/tile/tileFactory/VectorTile.js +41 -68
  100. package/es/tile/tileFactory/index.js +0 -11
  101. package/es/tile/tileFactory/layers/TileDebugLayer.js +6 -27
  102. package/es/tile/tileFactory/util.js +0 -3
  103. package/es/tile/tileLayer/BaseLayer.js +105 -146
  104. package/es/tile/utils.js +1 -1
  105. package/es/utils/blend.js +0 -2
  106. package/es/utils/collision-index.js +9 -16
  107. package/es/utils/extrude_polyline.js +101 -149
  108. package/es/utils/grid-index.js +2 -27
  109. package/es/utils/identityScale.js +0 -8
  110. package/es/utils/layerData.js +30 -44
  111. package/es/utils/multiPassRender.js +11 -13
  112. package/es/utils/polylineNormal.js +31 -37
  113. package/es/utils/simpleLine.js +2 -16
  114. package/es/utils/stencil.js +2 -3
  115. package/es/utils/symbol-layout.js +27 -53
  116. package/es/wind/index.js +9 -29
  117. package/es/wind/models/utils.js +26 -51
  118. package/es/wind/models/wind.js +101 -147
  119. package/es/wind/models/windRender.js +53 -66
  120. package/lib/Geometry/index.js +9 -38
  121. package/lib/Geometry/models/billboard.js +51 -97
  122. package/lib/Geometry/models/index.js +0 -5
  123. package/lib/Geometry/models/plane.js +79 -151
  124. package/lib/Geometry/models/sprite.js +60 -127
  125. package/lib/canvas/index.js +10 -40
  126. package/lib/canvas/models/canvas.js +41 -101
  127. package/lib/canvas/models/index.js +0 -3
  128. package/lib/citybuliding/building.js +8 -35
  129. package/lib/citybuliding/models/build.js +57 -92
  130. package/lib/core/BaseLayer.js +325 -474
  131. package/lib/core/BaseModel.js +51 -90
  132. package/lib/core/CommonStyleAttribute.js +2 -7
  133. package/lib/core/LayerPickService.js +21 -37
  134. package/lib/core/TextureService.js +0 -16
  135. package/lib/core/interface.js +21 -31
  136. package/lib/core/schema.js +0 -1
  137. package/lib/core/shape/Path.js +14 -31
  138. package/lib/core/shape/extrude.js +27 -62
  139. package/lib/core/triangulation.js +98 -177
  140. package/lib/earth/index.js +9 -43
  141. package/lib/earth/models/atmosphere.js +30 -63
  142. package/lib/earth/models/base.js +47 -90
  143. package/lib/earth/models/bloomsphere.js +30 -63
  144. package/lib/earth/utils.js +7 -31
  145. package/lib/heatmap/index.js +10 -48
  146. package/lib/heatmap/models/grid.js +28 -60
  147. package/lib/heatmap/models/grid3d.js +28 -60
  148. package/lib/heatmap/models/heatmap.js +92 -166
  149. package/lib/heatmap/models/hexagon.js +28 -60
  150. package/lib/heatmap/models/index.js +0 -6
  151. package/lib/heatmap/triangulation.js +0 -5
  152. package/lib/image/index.js +9 -36
  153. package/lib/image/models/image.js +66 -109
  154. package/lib/image/models/index.js +0 -3
  155. package/lib/index.js +7 -61
  156. package/lib/line/index.js +9 -40
  157. package/lib/line/models/arc.js +61 -122
  158. package/lib/line/models/arc_3d.js +56 -113
  159. package/lib/line/models/earthArc_3d.js +58 -115
  160. package/lib/line/models/flow.js +36 -70
  161. package/lib/line/models/great_circle.js +53 -104
  162. package/lib/line/models/index.js +0 -11
  163. package/lib/line/models/line.js +90 -152
  164. package/lib/line/models/linearline.js +42 -86
  165. package/lib/line/models/simpleLine.js +38 -77
  166. package/lib/line/models/wall.js +52 -103
  167. package/lib/line/shaders/dash/line_dash_vert.glsl +1 -2
  168. package/lib/line/shaders/line_frag.glsl +1 -3
  169. package/lib/line/shaders/line_vert.glsl +2 -0
  170. package/lib/line/shaders/linear/line_linear_frag.glsl +1 -1
  171. package/lib/mask/index.js +9 -36
  172. package/lib/mask/models/fill.js +29 -63
  173. package/lib/mask/models/index.js +0 -3
  174. package/lib/plugins/DataMappingPlugin.js +78 -125
  175. package/lib/plugins/DataSourcePlugin.js +45 -76
  176. package/lib/plugins/FeatureScalePlugin.js +67 -138
  177. package/lib/plugins/LayerAnimateStylePlugin.js +0 -10
  178. package/lib/plugins/LayerMaskPlugin.js +4 -17
  179. package/lib/plugins/LayerModelPlugin.js +70 -127
  180. package/lib/plugins/LayerStylePlugin.js +5 -14
  181. package/lib/plugins/LightingPlugin.js +12 -25
  182. package/lib/plugins/MultiPassRendererPlugin.js +11 -22
  183. package/lib/plugins/PixelPickingPlugin.js +12 -27
  184. package/lib/plugins/RegisterStyleAttributePlugin.js +5 -19
  185. package/lib/plugins/ShaderUniformPlugin.js +13 -34
  186. package/lib/plugins/UpdateModelPlugin.js +1 -10
  187. package/lib/plugins/UpdateStyleAttributePlugin.js +5 -16
  188. package/lib/point/index.js +26 -83
  189. package/lib/point/models/earthExtrude.js +58 -106
  190. package/lib/point/models/earthFill.js +52 -110
  191. package/lib/point/models/extrude.js +57 -103
  192. package/lib/point/models/fill.js +54 -90
  193. package/lib/point/models/fillmage.js +58 -107
  194. package/lib/point/models/image.js +47 -92
  195. package/lib/point/models/index.js +1 -12
  196. package/lib/point/models/normal.js +30 -64
  197. package/lib/point/models/radar.js +38 -72
  198. package/lib/point/models/simplePoint.js +38 -72
  199. package/lib/point/models/text.js +199 -305
  200. package/lib/point/shape/extrude.js +4 -20
  201. package/lib/polygon/index.js +11 -48
  202. package/lib/polygon/models/extrude.js +87 -146
  203. package/lib/polygon/models/fill.js +50 -89
  204. package/lib/polygon/models/index.js +2 -14
  205. package/lib/polygon/models/ocean.js +42 -88
  206. package/lib/polygon/models/water.js +37 -82
  207. package/lib/raster/buffers/triangulation.js +3 -7
  208. package/lib/raster/index.js +9 -40
  209. package/lib/raster/models/index.js +0 -5
  210. package/lib/raster/models/raster.js +80 -125
  211. package/lib/raster/models/rasterRgb.js +84 -139
  212. package/lib/raster/models/rasterTerrainRgb.js +56 -93
  213. package/lib/tile/interaction/getRasterData.js +14 -25
  214. package/lib/tile/interaction/utils.js +7 -19
  215. package/lib/tile/manager/base.js +63 -104
  216. package/lib/tile/service/TileLayerService.js +33 -60
  217. package/lib/tile/service/TilePickService.js +26 -48
  218. package/lib/tile/service/TileSourceService.js +2 -16
  219. package/lib/tile/style/utils.js +0 -3
  220. package/lib/tile/tileFactory/DebugTile.js +29 -54
  221. package/lib/tile/tileFactory/ImageTile.js +20 -46
  222. package/lib/tile/tileFactory/MaskTile.js +22 -51
  223. package/lib/tile/tileFactory/RasterRGBTile.js +22 -50
  224. package/lib/tile/tileFactory/RasterTerrainRGBTile.js +20 -46
  225. package/lib/tile/tileFactory/RasterTile.js +30 -63
  226. package/lib/tile/tileFactory/Tile.js +63 -102
  227. package/lib/tile/tileFactory/VectorTile.js +41 -76
  228. package/lib/tile/tileFactory/index.js +0 -25
  229. package/lib/tile/tileFactory/layers/TileDebugLayer.js +6 -32
  230. package/lib/tile/tileFactory/util.js +0 -9
  231. package/lib/tile/tileLayer/BaseLayer.js +105 -153
  232. package/lib/tile/utils.js +1 -5
  233. package/lib/utils/blend.js +0 -5
  234. package/lib/utils/collision-index.js +9 -25
  235. package/lib/utils/extrude_polyline.js +101 -181
  236. package/lib/utils/grid-index.js +2 -28
  237. package/lib/utils/identityScale.js +0 -9
  238. package/lib/utils/layerData.js +30 -49
  239. package/lib/utils/multiPassRender.js +11 -16
  240. package/lib/utils/polylineNormal.js +31 -66
  241. package/lib/utils/simpleLine.js +2 -21
  242. package/lib/utils/stencil.js +0 -4
  243. package/lib/utils/symbol-layout.js +27 -55
  244. package/lib/wind/index.js +9 -37
  245. package/lib/wind/models/index.js +0 -3
  246. package/lib/wind/models/utils.js +26 -62
  247. package/lib/wind/models/wind.js +101 -157
  248. package/lib/wind/models/windRender.js +53 -71
  249. package/lib/wind/models/windShader.js +0 -1
  250. package/package.json +7 -7
@@ -1,35 +1,26 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.getTileLayer = getTileLayer;
9
8
  exports.isNeedMask = isNeedMask;
10
-
11
9
  var _line = _interopRequireDefault(require("../../line"));
12
-
13
10
  var _index = _interopRequireDefault(require("../../point/index"));
14
-
15
11
  var _polygon = _interopRequireDefault(require("../../polygon"));
16
-
17
12
  function getTileLayer(type) {
18
13
  if (type === 'PolygonLayer') {
19
14
  return _polygon.default;
20
15
  }
21
-
22
16
  if (type === 'LineLayer') {
23
17
  return _line.default;
24
18
  }
25
-
26
19
  if (type === 'PointLayer') {
27
20
  return _index.default;
28
21
  }
29
-
30
22
  return _index.default;
31
23
  }
32
-
33
24
  function isNeedMask(type) {
34
25
  return ['PolygonLayer', 'LineLayer'].indexOf(type) !== -1;
35
26
  }
@@ -1,71 +1,51 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = void 0;
9
-
10
8
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
-
12
9
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
-
14
10
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
15
-
16
11
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
17
-
18
12
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
19
-
20
13
  var _l7Core = require("@antv/l7-core");
21
-
22
14
  var _lodash = require("lodash");
23
-
24
15
  var _TileLayerService = require("../service/TileLayerService");
25
-
26
16
  var _TilePickService = require("../service/TilePickService");
27
-
28
17
  var _constants = require("../style/constants");
29
-
30
18
  var _tileFactory = require("../tileFactory");
31
-
32
19
  var BaseTileLayer = /*#__PURE__*/function () {
33
20
  // 瓦片数据管理器
21
+
34
22
  function BaseTileLayer(parent) {
35
23
  var _this = this;
36
-
37
24
  (0, _classCallCheck2.default)(this, BaseTileLayer);
38
25
  (0, _defineProperty2.default)(this, "initedTileset", false);
39
26
  (0, _defineProperty2.default)(this, "mapchange", function () {
40
27
  var _this$tilesetManager;
41
-
42
28
  var _this$getCurrentView = _this.getCurrentView(),
43
- latLonBounds = _this$getCurrentView.latLonBounds,
44
- zoom = _this$getCurrentView.zoom;
45
-
29
+ latLonBounds = _this$getCurrentView.latLonBounds,
30
+ zoom = _this$getCurrentView.zoom;
46
31
  if (_this.mapService.version === 'GAODE1.x') {
47
32
  var _this$parent$getLayer = _this.parent.getLayerConfig(),
48
- visible = _this$parent$getLayer.visible;
49
-
33
+ visible = _this$parent$getLayer.visible;
50
34
  if (zoom < 2 && visible) {
51
35
  _this.parent.updateLayerConfig({
52
36
  visible: false
53
37
  });
54
-
55
38
  _this.layerService.reRender();
56
39
  } else if (zoom >= 2 && !visible) {
57
40
  _this.parent.updateLayerConfig({
58
41
  visible: true
59
42
  });
60
-
61
43
  _this.layerService.reRender();
62
44
  }
63
45
  }
64
-
65
46
  if (_this.lastViewStates && _this.lastViewStates.zoom === zoom && _this.lastViewStates.latLonBounds.toString() === latLonBounds.toString()) {
66
47
  return;
67
48
  }
68
-
69
49
  _this.lastViewStates = {
70
50
  zoom: zoom,
71
51
  latLonBounds: latLonBounds
@@ -78,42 +58,39 @@ var BaseTileLayer = /*#__PURE__*/function () {
78
58
  this.rendererService = container.get(_l7Core.TYPES.IRendererService);
79
59
  this.layerService = container.get(_l7Core.TYPES.ILayerService);
80
60
  this.mapService = container.get(_l7Core.TYPES.IMapService);
81
- this.pickingService = container.get(_l7Core.TYPES.IPickingService); // 初始化瓦片管理服务
61
+ this.pickingService = container.get(_l7Core.TYPES.IPickingService);
82
62
 
63
+ // 初始化瓦片管理服务
83
64
  this.tileLayerService = new _TileLayerService.TileLayerService({
84
65
  rendererService: this.rendererService,
85
66
  layerService: this.layerService,
86
67
  parent: parent
87
- }); // 初始化拾取服务
88
-
68
+ });
69
+ // 初始化拾取服务
89
70
  this.tilePickService = new _TilePickService.TilePickService({
90
71
  tileLayerService: this.tileLayerService,
91
72
  layerService: this.layerService,
92
73
  parent: parent
93
- }); // 重置
74
+ });
94
75
 
76
+ // 重置
95
77
  this.parent.setLayerPickService(this.tilePickService);
96
78
  this.proxy(parent);
97
79
  this.initTileSetManager();
98
80
  }
99
-
100
81
  (0, _createClass2.default)(BaseTileLayer, [{
101
82
  key: "initTileSetManager",
102
83
  value: function initTileSetManager() {
103
84
  var _this$tilesetManager2;
104
-
105
85
  var source = this.parent.getSource();
106
86
  this.tilesetManager = source.tileset;
107
-
108
87
  if (!this.initedTileset) {
109
88
  this.bindTilesetEvent();
110
89
  this.initedTileset = true;
111
90
  }
112
-
113
91
  var _this$getCurrentView2 = this.getCurrentView(),
114
- latLonBounds = _this$getCurrentView2.latLonBounds,
115
- zoom = _this$getCurrentView2.zoom;
116
-
92
+ latLonBounds = _this$getCurrentView2.latLonBounds,
93
+ zoom = _this$getCurrentView2.zoom;
117
94
  (_this$tilesetManager2 = this.tilesetManager) === null || _this$tilesetManager2 === void 0 ? void 0 : _this$tilesetManager2.update(zoom, latLonBounds);
118
95
  }
119
96
  }, {
@@ -131,27 +108,31 @@ var BaseTileLayer = /*#__PURE__*/function () {
131
108
  key: "bindTilesetEvent",
132
109
  value: function bindTilesetEvent() {
133
110
  var _this2 = this;
134
-
135
111
  // 瓦片数据加载成功
136
112
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
137
- this.tilesetManager.on('tile-loaded', function (tile) {// 将事件抛出,图层上可以监听使用
138
- }); // 瓦片数据从缓存删除或被执行重新加载
113
+ this.tilesetManager.on('tile-loaded', function (tile) {
114
+ // 将事件抛出,图层上可以监听使用
115
+ });
139
116
 
117
+ // 瓦片数据从缓存删除或被执行重新加载
140
118
  this.tilesetManager.on('tile-unload', function (tile) {
141
119
  // 将事件抛出,图层上可以监听使用
142
120
  _this2.tileUnLoad(tile);
143
- }); // 瓦片数据加载失败
144
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
121
+ });
145
122
 
123
+ // 瓦片数据加载失败
124
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
146
125
  this.tilesetManager.on('tile-error', function (error, tile) {
147
126
  // 将事件抛出,图层上可以监听使用
148
127
  _this2.tileError(error);
149
- }); // 瓦片显隐状态更新
128
+ });
150
129
 
130
+ // 瓦片显隐状态更新
151
131
  this.tilesetManager.on('tile-update', function () {
152
132
  _this2.tileUpdate();
153
- }); // 地图视野发生改变
133
+ });
154
134
 
135
+ // 地图视野发生改变
155
136
  this.mapService.on('zoomend', this.mapchange);
156
137
  this.mapService.on('moveend', this.viewchange);
157
138
  }
@@ -174,12 +155,15 @@ var BaseTileLayer = /*#__PURE__*/function () {
174
155
  key: "getTile",
175
156
  value: function getTile(key) {
176
157
  return this.tileLayerService.getTile(key);
177
- } // 防抖操作
158
+ }
178
159
 
160
+ // 防抖操作
179
161
  }, {
180
162
  key: "tileLoaded",
181
- value: // eslint-disable-next-line @typescript-eslint/no-unused-vars
182
- function tileLoaded(tile) {//
163
+ value:
164
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
165
+ function tileLoaded(tile) {
166
+ //
183
167
  }
184
168
  }, {
185
169
  key: "tileError",
@@ -190,25 +174,21 @@ var BaseTileLayer = /*#__PURE__*/function () {
190
174
  key: "destroy",
191
175
  value: function destroy() {
192
176
  var _this$tilesetManager3;
193
-
194
177
  this.mapService.off('zoomend', this.mapchange);
195
178
  this.mapService.off('moveend', this.viewchange);
196
179
  (_this$tilesetManager3 = this.tilesetManager) === null || _this$tilesetManager3 === void 0 ? void 0 : _this$tilesetManager3.destroy();
197
180
  this.tileLayerService.destroy();
198
- } // 重新加载
199
-
181
+ }
182
+ // 重新加载
200
183
  }, {
201
184
  key: "reload",
202
185
  value: function reload() {
203
186
  var _this$tilesetManager4;
204
-
205
187
  // 瓦片重新加载
206
188
  this.tilesetManager.clear();
207
-
208
189
  var _this$getCurrentView3 = this.getCurrentView(),
209
- latLonBounds = _this$getCurrentView3.latLonBounds,
210
- zoom = _this$getCurrentView3.zoom;
211
-
190
+ latLonBounds = _this$getCurrentView3.latLonBounds,
191
+ zoom = _this$getCurrentView3.zoom;
212
192
  (_this$tilesetManager4 = this.tilesetManager) === null || _this$tilesetManager4 === void 0 ? void 0 : _this$tilesetManager4.update(zoom, latLonBounds);
213
193
  }
214
194
  }, {
@@ -221,106 +201,84 @@ var BaseTileLayer = /*#__PURE__*/function () {
221
201
  value: function () {
222
202
  var _tileUpdate = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
223
203
  var _this3 = this;
224
-
225
204
  var minZoom, maxZoom;
226
205
  return _regenerator.default.wrap(function _callee2$(_context2) {
227
- while (1) {
228
- switch (_context2.prev = _context2.next) {
229
- case 0:
230
- if (this.tilesetManager) {
231
- _context2.next = 2;
232
- break;
233
- }
234
-
235
- return _context2.abrupt("return");
236
-
237
- case 2:
238
- minZoom = this.parent.getMinZoom();
239
- maxZoom = this.parent.getMaxZoom();
240
- _context2.next = 6;
241
- return Promise.all(this.tilesetManager.tiles.filter(function (tile) {
242
- return tile.isLoaded;
243
- }) // 过滤未加载完成的
244
- .filter(function (tile) {
245
- return tile.isVisibleChange;
246
- }) // 过滤未发生变化的
247
- .filter(function (tile) {
248
- return tile.data;
249
- }).filter(function (tile) {
250
- return tile.z >= minZoom && tile.z < maxZoom;
251
- }).map( /*#__PURE__*/function () {
252
- var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(tile) {
253
- var tileInstance, tileLayer;
254
- return _regenerator.default.wrap(function _callee$(_context) {
255
- while (1) {
256
- switch (_context.prev = _context.next) {
257
- case 0:
258
- if (_this3.tileLayerService.hasTile(tile.key)) {
259
- _context.next = 9;
260
- break;
261
- }
262
-
263
- tileInstance = (0, _tileFactory.getTileFactory)(_this3.parent);
264
- tileLayer = new tileInstance(tile, _this3.parent);
265
- _context.next = 5;
266
- return tileLayer.initTileLayer();
267
-
268
- case 5:
269
- _this3.tilePickService.setPickState();
270
-
271
- if (tileLayer.getLayers().length !== 0) {
272
- _this3.tileLayerService.addTile(tileLayer);
273
-
274
- _this3.tileLayerService.updateTileVisible(tile);
275
-
276
- _this3.layerService.reRender();
277
- }
278
-
279
- _context.next = 12;
280
- break;
281
-
282
- case 9:
283
- // 已加载瓦片
284
- _this3.tileLayerService.updateTileVisible(tile);
285
-
286
- _this3.tilePickService.setPickState();
287
-
288
- _this3.layerService.reRender();
289
-
290
- case 12:
291
- case "end":
292
- return _context.stop();
206
+ while (1) switch (_context2.prev = _context2.next) {
207
+ case 0:
208
+ if (this.tilesetManager) {
209
+ _context2.next = 2;
210
+ break;
211
+ }
212
+ return _context2.abrupt("return");
213
+ case 2:
214
+ minZoom = this.parent.getMinZoom();
215
+ maxZoom = this.parent.getMaxZoom();
216
+ _context2.next = 6;
217
+ return Promise.all(this.tilesetManager.tiles.filter(function (tile) {
218
+ return tile.isLoaded;
219
+ }) // 过滤未加载完成的
220
+ .filter(function (tile) {
221
+ return tile.isVisibleChange;
222
+ }) // 过滤未发生变化的
223
+ .filter(function (tile) {
224
+ return tile.data;
225
+ }).filter(function (tile) {
226
+ return tile.z >= minZoom && tile.z < maxZoom;
227
+ }).map( /*#__PURE__*/function () {
228
+ var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(tile) {
229
+ var tileInstance, tileLayer;
230
+ return _regenerator.default.wrap(function _callee$(_context) {
231
+ while (1) switch (_context.prev = _context.next) {
232
+ case 0:
233
+ if (_this3.tileLayerService.hasTile(tile.key)) {
234
+ _context.next = 9;
235
+ break;
293
236
  }
294
- }
295
- }, _callee);
296
- }));
297
-
298
- return function (_x) {
299
- return _ref.apply(this, arguments);
300
- };
301
- }()));
302
-
303
- case 6:
304
- if (this.tilesetManager.isLoaded) {
305
- // 将事件抛出,图层上可以使用瓦片
306
- this.parent.emit('tiles-loaded', this.tilesetManager.currentTiles);
307
- }
308
-
309
- case 7:
310
- case "end":
311
- return _context2.stop();
312
- }
237
+ tileInstance = (0, _tileFactory.getTileFactory)(_this3.parent);
238
+ tileLayer = new tileInstance(tile, _this3.parent);
239
+ _context.next = 5;
240
+ return tileLayer.initTileLayer();
241
+ case 5:
242
+ _this3.tilePickService.setPickState();
243
+ if (tileLayer.getLayers().length !== 0) {
244
+ _this3.tileLayerService.addTile(tileLayer);
245
+ _this3.tileLayerService.updateTileVisible(tile);
246
+ _this3.layerService.reRender();
247
+ }
248
+ _context.next = 12;
249
+ break;
250
+ case 9:
251
+ // 已加载瓦片
252
+
253
+ _this3.tileLayerService.updateTileVisible(tile);
254
+ _this3.tilePickService.setPickState();
255
+ _this3.layerService.reRender();
256
+ case 12:
257
+ case "end":
258
+ return _context.stop();
259
+ }
260
+ }, _callee);
261
+ }));
262
+ return function (_x) {
263
+ return _ref.apply(this, arguments);
264
+ };
265
+ }()));
266
+ case 6:
267
+ if (this.tilesetManager.isLoaded) {
268
+ // 将事件抛出,图层上可以使用瓦片
269
+ this.parent.emit('tiles-loaded', this.tilesetManager.currentTiles);
270
+ }
271
+ case 7:
272
+ case "end":
273
+ return _context2.stop();
313
274
  }
314
275
  }, _callee2, this);
315
276
  }));
316
-
317
277
  function tileUpdate() {
318
278
  return _tileUpdate.apply(this, arguments);
319
279
  }
320
-
321
280
  return tileUpdate;
322
281
  }() // eslint-disable-next-line @typescript-eslint/no-unused-vars
323
-
324
282
  }, {
325
283
  key: "setPickState",
326
284
  value: function setPickState(layers) {
@@ -341,39 +299,34 @@ var BaseTileLayer = /*#__PURE__*/function () {
341
299
  value: function highlightPickedFeature(pickedColors) {
342
300
  this.tilePickService.highlightPickedFeature(pickedColors);
343
301
  }
302
+
344
303
  /**
345
304
  * 实现 TileLayer 对子图层方法的代理
346
305
  * @param parent
347
306
  */
348
-
349
307
  }, {
350
308
  key: "proxy",
351
309
  value: function proxy(parent) {
352
310
  var _this4 = this;
353
-
354
311
  _constants.ProxyFuncs.forEach(function (func) {
355
312
  // @ts-ignore
356
- var oldStyleFunc = parent[func].bind(parent); // @ts-ignore
357
-
313
+ var oldStyleFunc = parent[func].bind(parent);
314
+ // @ts-ignore
358
315
  parent[func] = function () {
359
316
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
360
317
  args[_key] = arguments[_key];
361
318
  }
362
-
363
319
  oldStyleFunc.apply(void 0, args);
364
-
365
320
  _this4.getLayers().map(function (child) {
366
321
  // @ts-ignore
367
322
  child[func].apply(child, args);
368
- }); // Tip: 目前在更新 RasterData 的 colorTexture 的时候需要额外优化
369
-
370
-
323
+ });
324
+ // Tip: 目前在更新 RasterData 的 colorTexture 的时候需要额外优化
371
325
  if (func === 'style') {
372
326
  _this4.getTiles().forEach(function (tile) {
373
327
  return tile.styleUpdate.apply(tile, args);
374
328
  });
375
329
  }
376
-
377
330
  return parent;
378
331
  };
379
332
  });
@@ -381,5 +334,4 @@ var BaseTileLayer = /*#__PURE__*/function () {
381
334
  }]);
382
335
  return BaseTileLayer;
383
336
  }();
384
-
385
337
  exports.default = BaseTileLayer;
package/lib/tile/utils.js CHANGED
@@ -6,23 +6,19 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.getContainerSize = getContainerSize;
7
7
  exports.isTileGroup = isTileGroup;
8
8
  exports.tileVectorParser = void 0;
9
-
10
9
  var _l7Utils = require("@antv/l7-utils");
11
-
12
10
  var tileVectorParser = ['mvt', 'geojsonvt', 'testTile'];
11
+
13
12
  /**
14
13
  * 判断当前图层是否是瓦片图层
15
14
  * @param layer
16
15
  * @returns
17
16
  */
18
-
19
17
  exports.tileVectorParser = tileVectorParser;
20
-
21
18
  function isTileGroup(layer) {
22
19
  var source = layer.getSource();
23
20
  return tileVectorParser.includes(source.parser.type);
24
21
  }
25
-
26
22
  function getContainerSize(container) {
27
23
  if (container.getContext) {
28
24
  return {
@@ -1,18 +1,13 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.BlendTypes = void 0;
9
-
10
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
9
  var _l7Core = require("@antv/l7-core");
13
-
14
10
  var _BlendTypes;
15
-
16
11
  var BlendTypes = (_BlendTypes = {}, (0, _defineProperty2.default)(_BlendTypes, _l7Core.BlendType.additive, {
17
12
  enable: true,
18
13
  func: {
@@ -1,26 +1,17 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = void 0;
9
-
10
8
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
-
12
9
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
-
14
10
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
15
-
16
11
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
17
-
18
12
  var _glMatrix = require("gl-matrix");
19
-
20
13
  var _gridIndex = _interopRequireDefault(require("./grid-index"));
21
-
22
14
  // @mapbox/grid-index 并没有类似 hitTest 的单纯获取碰撞检测结果的方法,query 将导致计算大量多余的包围盒结果,因此使用改良版
23
-
24
15
  /**
25
16
  * 基于网格实现文本避让,大幅提升包围盒碰撞检测效率
26
17
  * @see https://zhuanlan.zhihu.com/p/74373214
@@ -31,15 +22,14 @@ var CollisionIndex = /*#__PURE__*/function () {
31
22
  (0, _defineProperty2.default)(this, "viewportPadding", 100);
32
23
  this.width = width;
33
24
  this.height = height;
34
- this.viewportPadding = Math.max(width, height); // 创建网格索引
35
-
25
+ this.viewportPadding = Math.max(width, height);
26
+ // 创建网格索引
36
27
  this.grid = new _gridIndex.default(width + this.viewportPadding, height + this.viewportPadding, 25);
37
28
  this.screenRightBoundary = width + this.viewportPadding;
38
29
  this.screenBottomBoundary = height + this.viewportPadding;
39
30
  this.gridRightBoundary = width + 2 * this.viewportPadding;
40
31
  this.gridBottomBoundary = height + 2 * this.viewportPadding;
41
32
  }
42
-
43
33
  (0, _createClass2.default)(CollisionIndex, [{
44
34
  key: "placeCollisionBox",
45
35
  value: function placeCollisionBox(collisionBox) {
@@ -48,17 +38,16 @@ var CollisionIndex = /*#__PURE__*/function () {
48
38
  // collisionBox.anchorPointX,
49
39
  // collisionBox.anchorPointY,
50
40
  // );
41
+
51
42
  var tlX = collisionBox.x1 + collisionBox.anchorPointX + this.viewportPadding;
52
43
  var tlY = collisionBox.y1 + collisionBox.anchorPointY + this.viewportPadding;
53
44
  var brX = collisionBox.x2 + collisionBox.anchorPointX + this.viewportPadding;
54
45
  var brY = collisionBox.y2 + collisionBox.anchorPointY + this.viewportPadding;
55
-
56
46
  if (!this.isInsideGrid(tlX, tlY, brX, brY) || this.grid.hitTest(tlX, tlY, brX, brY)) {
57
47
  return {
58
48
  box: []
59
49
  };
60
50
  }
61
-
62
51
  return {
63
52
  box: [tlX, tlY, brX, brY]
64
53
  };
@@ -71,6 +60,7 @@ var CollisionIndex = /*#__PURE__*/function () {
71
60
  };
72
61
  this.grid.insert(key, box[0], box[1], box[2], box[3]);
73
62
  }
63
+
74
64
  /**
75
65
  * 后续碰撞检测都需要投影到 viewport 坐标系
76
66
  * @param {THREE.Matrix4} mvpMatrix mvp矩阵
@@ -78,25 +68,21 @@ var CollisionIndex = /*#__PURE__*/function () {
78
68
  * @param {number} y P20 平面坐标Y
79
69
  * @return {Point} projectedPoint
80
70
  */
81
-
82
71
  }, {
83
72
  key: "project",
84
73
  value: function project(mvpMatrix, x, y) {
85
74
  var point = _glMatrix.vec4.fromValues(x, y, 0, 1);
86
-
87
- var out = _glMatrix.vec4.create(); // @ts-ignore
88
-
89
-
75
+ var out = _glMatrix.vec4.create();
76
+ // @ts-ignore
90
77
  var mat = _glMatrix.mat4.fromValues.apply(_glMatrix.mat4, (0, _toConsumableArray2.default)(mvpMatrix));
91
-
92
- _glMatrix.vec4.transformMat4(out, point, mat); // GL 坐标系[-1, 1] -> viewport 坐标系[width, height]
93
-
94
-
78
+ _glMatrix.vec4.transformMat4(out, point, mat);
79
+ // GL 坐标系[-1, 1] -> viewport 坐标系[width, height]
95
80
  return {
96
81
  x: (out[0] / out[3] + 1) / 2 * this.width + this.viewportPadding,
97
82
  y: (-out[1] / out[3] + 1) / 2 * this.height + this.viewportPadding
98
83
  };
99
84
  }
85
+
100
86
  /**
101
87
  * 判断包围盒是否在整个网格内,需要加上 buffer
102
88
  * @param {number} x1 x1
@@ -105,7 +91,6 @@ var CollisionIndex = /*#__PURE__*/function () {
105
91
  * @param {number} y2 y2
106
92
  * @return {Point} isInside
107
93
  */
108
-
109
94
  }, {
110
95
  key: "isInsideGrid",
111
96
  value: function isInsideGrid(x1, y1, x2, y2) {
@@ -114,5 +99,4 @@ var CollisionIndex = /*#__PURE__*/function () {
114
99
  }]);
115
100
  return CollisionIndex;
116
101
  }();
117
-
118
102
  exports.default = CollisionIndex;