@antv/l7-layers 2.14.1 → 2.14.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/es/Geometry/models/billboard.js +3 -6
  2. package/es/Geometry/models/plane.js +3 -6
  3. package/es/core/BaseLayer.d.ts +7 -3
  4. package/es/core/BaseLayer.js +64 -20
  5. package/es/core/BaseModel.d.ts +3 -2
  6. package/es/core/BaseModel.js +39 -3
  7. package/es/core/LayerPickService.js +6 -30
  8. package/es/heatmap/index.d.ts +2 -2
  9. package/es/heatmap/index.js +5 -2
  10. package/es/heatmap/models/grid.js +5 -9
  11. package/es/heatmap/models/grid3d.js +5 -10
  12. package/es/heatmap/models/heatmap.d.ts +2 -2
  13. package/es/heatmap/models/heatmap.js +54 -46
  14. package/es/heatmap/models/hexagon.js +5 -10
  15. package/es/image/models/image.js +13 -16
  16. package/es/image/shaders/image_frag.glsl +2 -0
  17. package/es/index.js +6 -0
  18. package/es/line/models/arc.js +4 -6
  19. package/es/line/models/arc_3d.js +4 -6
  20. package/es/line/models/earthArc_3d.js +4 -6
  21. package/es/line/models/great_circle.js +9 -13
  22. package/es/line/models/half.js +4 -6
  23. package/es/line/models/line.js +3 -5
  24. package/es/line/models/linearline.js +4 -6
  25. package/es/line/models/simpleLine.js +5 -8
  26. package/es/mask/models/fill.js +1 -17
  27. package/es/plugins/LayerMaskPlugin.d.ts +8 -0
  28. package/es/plugins/LayerMaskPlugin.js +42 -0
  29. package/es/plugins/LayerStylePlugin.js +2 -1
  30. package/es/point/models/extrude.js +0 -1
  31. package/es/point/models/fill.js +4 -6
  32. package/es/point/models/fillmage.js +8 -12
  33. package/es/point/models/image.js +9 -14
  34. package/es/point/models/normal.js +4 -9
  35. package/es/point/models/radar.js +5 -10
  36. package/es/point/models/simplePoint.js +5 -10
  37. package/es/point/models/text.js +10 -16
  38. package/es/point/shaders/fill_frag.glsl +4 -0
  39. package/es/point/shaders/image_frag.glsl +4 -0
  40. package/es/point/shaders/text_frag.glsl +4 -0
  41. package/es/polygon/index.js +1 -1
  42. package/es/polygon/models/extrude.js +11 -13
  43. package/es/polygon/models/fill.js +3 -5
  44. package/es/polygon/models/ocean.js +6 -9
  45. package/es/polygon/models/water.js +7 -11
  46. package/es/raster/models/raster.js +9 -11
  47. package/es/raster/models/rasterRgb.js +8 -11
  48. package/es/raster/models/rasterTerrainRgb.js +9 -13
  49. package/es/raster/shaders/raster_2d_frag.glsl +6 -3
  50. package/es/raster/shaders/raster_frag.glsl +2 -0
  51. package/es/raster/shaders/raster_rgb_frag.glsl +2 -0
  52. package/es/raster/shaders/raster_terrain_rgb_frag.glsl +2 -0
  53. package/es/tile/service/TileLayerService.js +5 -4
  54. package/es/tile/style/constants.js +1 -1
  55. package/es/tile/tileFactory/Tile.d.ts +8 -0
  56. package/es/tile/tileFactory/Tile.js +102 -14
  57. package/es/tile/tileFactory/VectorTile.d.ts +0 -1
  58. package/es/tile/tileFactory/VectorTile.js +6 -46
  59. package/es/tile/tileLayer/BaseLayer.d.ts +2 -1
  60. package/es/tile/tileLayer/BaseLayer.js +68 -62
  61. package/es/utils/stencil.d.ts +7 -0
  62. package/es/utils/stencil.js +50 -0
  63. package/es/wind/index.d.ts +2 -1
  64. package/es/wind/index.js +3 -1
  65. package/es/wind/models/wind.d.ts +2 -2
  66. package/es/wind/models/wind.js +12 -10
  67. package/lib/Geometry/models/billboard.js +3 -7
  68. package/lib/Geometry/models/plane.js +2 -6
  69. package/lib/core/BaseLayer.js +64 -20
  70. package/lib/core/BaseModel.js +40 -2
  71. package/lib/core/LayerPickService.js +6 -32
  72. package/lib/heatmap/index.js +5 -2
  73. package/lib/heatmap/models/grid.js +5 -10
  74. package/lib/heatmap/models/grid3d.js +5 -11
  75. package/lib/heatmap/models/heatmap.js +53 -45
  76. package/lib/heatmap/models/hexagon.js +5 -11
  77. package/lib/image/models/image.js +12 -15
  78. package/lib/image/shaders/image_frag.glsl +2 -0
  79. package/lib/index.js +8 -0
  80. package/lib/line/models/arc.js +3 -5
  81. package/lib/line/models/arc_3d.js +3 -5
  82. package/lib/line/models/earthArc_3d.js +3 -5
  83. package/lib/line/models/great_circle.js +8 -12
  84. package/lib/line/models/half.js +3 -5
  85. package/lib/line/models/line.js +2 -4
  86. package/lib/line/models/linearline.js +3 -5
  87. package/lib/line/models/simpleLine.js +4 -7
  88. package/lib/mask/models/fill.js +1 -18
  89. package/lib/plugins/LayerMaskPlugin.js +54 -0
  90. package/lib/plugins/LayerStylePlugin.js +2 -1
  91. package/lib/point/models/extrude.js +0 -1
  92. package/lib/point/models/fill.js +3 -5
  93. package/lib/point/models/fillmage.js +7 -11
  94. package/lib/point/models/image.js +9 -15
  95. package/lib/point/models/normal.js +4 -10
  96. package/lib/point/models/radar.js +5 -11
  97. package/lib/point/models/simplePoint.js +5 -11
  98. package/lib/point/models/text.js +9 -15
  99. package/lib/point/shaders/fill_frag.glsl +4 -0
  100. package/lib/point/shaders/image_frag.glsl +4 -0
  101. package/lib/point/shaders/text_frag.glsl +4 -0
  102. package/lib/polygon/index.js +1 -1
  103. package/lib/polygon/models/extrude.js +10 -12
  104. package/lib/polygon/models/fill.js +2 -4
  105. package/lib/polygon/models/ocean.js +5 -8
  106. package/lib/polygon/models/water.js +7 -12
  107. package/lib/raster/models/raster.js +8 -10
  108. package/lib/raster/models/rasterRgb.js +8 -12
  109. package/lib/raster/models/rasterTerrainRgb.js +8 -12
  110. package/lib/raster/shaders/raster_2d_frag.glsl +6 -3
  111. package/lib/raster/shaders/raster_frag.glsl +2 -0
  112. package/lib/raster/shaders/raster_rgb_frag.glsl +2 -0
  113. package/lib/raster/shaders/raster_terrain_rgb_frag.glsl +2 -0
  114. package/lib/tile/service/TileLayerService.js +5 -4
  115. package/lib/tile/style/constants.js +1 -1
  116. package/lib/tile/tileFactory/Tile.js +102 -14
  117. package/lib/tile/tileFactory/VectorTile.js +6 -47
  118. package/lib/tile/tileLayer/BaseLayer.js +67 -62
  119. package/lib/utils/stencil.js +60 -0
  120. package/lib/wind/index.js +3 -1
  121. package/lib/wind/models/wind.js +11 -9
  122. package/package.json +7 -7
@@ -6,6 +6,7 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
6
6
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
7
7
  import _regeneratorRuntime from "@babel/runtime/regenerator";
8
8
  import { createLayerContainer } from '@antv/l7-core';
9
+ import PolygonLayer from "../../polygon";
9
10
  import { isNeedMask } from "./util";
10
11
 
11
12
  var Tile = /*#__PURE__*/function () {
@@ -18,6 +19,8 @@ var Tile = /*#__PURE__*/function () {
18
19
 
19
20
  _defineProperty(this, "isLoaded", false);
20
21
 
22
+ _defineProperty(this, "tileMaskLayers", []);
23
+
21
24
  this.parent = parent;
22
25
  this.sourceTile = sourceTile;
23
26
  this.x = sourceTile.x;
@@ -53,30 +56,80 @@ var Tile = /*#__PURE__*/function () {
53
56
  }, {
54
57
  key: "getLayerOptions",
55
58
  value: function getLayerOptions() {
59
+ var _options$maskLayers;
60
+
56
61
  var options = this.parent.getLayerConfig();
57
62
  return _objectSpread(_objectSpread({}, options), {}, {
58
63
  autoFit: false,
59
- mask: isNeedMask(this.parent.type) || options.mask
64
+ maskLayers: this.getMaskLayer(),
65
+ tileMask: isNeedMask(this.parent.type),
66
+ mask: options.mask || ((_options$maskLayers = options.maskLayers) === null || _options$maskLayers === void 0 ? void 0 : _options$maskLayers.length) !== 0 && options.enableMask
67
+ });
68
+ } // 获取Mask 图层
69
+
70
+ }, {
71
+ key: "getMaskLayer",
72
+ value: function getMaskLayer() {
73
+ var _this = this;
74
+
75
+ var _this$parent$getLayer = this.parent.getLayerConfig(),
76
+ maskLayers = _this$parent$getLayer.maskLayers;
77
+
78
+ var layers = [];
79
+ maskLayers === null || maskLayers === void 0 ? void 0 : maskLayers.forEach(function (layer) {
80
+ if (!layer.tileLayer) {
81
+ // 非瓦片图层返回图层本身,瓦片图层返回对应的行列号图层
82
+ layers.push(layer);
83
+ return layer;
84
+ }
85
+
86
+ var tileLayer = layer.tileLayer;
87
+ var tile = tileLayer.getTile(_this.sourceTile.key);
88
+ var l = tile === null || tile === void 0 ? void 0 : tile.getLayers()[0];
89
+
90
+ if (l) {
91
+ layers.push(l);
92
+ }
60
93
  });
94
+ return layers;
61
95
  }
62
96
  }, {
63
- key: "addMask",
97
+ key: "addTileMask",
64
98
  value: function () {
65
- var _addMask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(layer, mask) {
66
- var container;
99
+ var _addTileMask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
100
+ var mask, container, mainLayer;
67
101
  return _regeneratorRuntime.wrap(function _callee$(_context) {
68
102
  while (1) {
69
103
  switch (_context.prev = _context.next) {
70
104
  case 0:
105
+ mask = new PolygonLayer({
106
+ visible: false,
107
+ enablePicking: false
108
+ }).source({
109
+ type: 'FeatureCollection',
110
+ features: [this.sourceTile.bboxPolygon]
111
+ }, {
112
+ parser: {
113
+ type: 'geojson',
114
+ featureId: 'id'
115
+ }
116
+ }).shape('fill');
71
117
  container = createLayerContainer(this.parent.sceneContainer);
72
118
  mask.setContainer(container, this.parent.sceneContainer);
73
- _context.next = 4;
119
+ _context.next = 5;
74
120
  return mask.init();
75
121
 
76
- case 4:
77
- layer.addMaskLayer(mask);
78
-
79
122
  case 5:
123
+ this.tileMask = mask;
124
+ mainLayer = this.getMainLayer();
125
+
126
+ if (mainLayer !== undefined) {
127
+ mainLayer.tileMask = mask;
128
+ }
129
+
130
+ return _context.abrupt("return", mask);
131
+
132
+ case 9:
80
133
  case "end":
81
134
  return _context.stop();
82
135
  }
@@ -84,6 +137,38 @@ var Tile = /*#__PURE__*/function () {
84
137
  }, _callee, this);
85
138
  }));
86
139
 
140
+ function addTileMask() {
141
+ return _addTileMask.apply(this, arguments);
142
+ }
143
+
144
+ return addTileMask;
145
+ }()
146
+ }, {
147
+ key: "addMask",
148
+ value: function () {
149
+ var _addMask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(layer, mask) {
150
+ var container;
151
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
152
+ while (1) {
153
+ switch (_context2.prev = _context2.next) {
154
+ case 0:
155
+ container = createLayerContainer(this.parent.sceneContainer);
156
+ mask.setContainer(container, this.parent.sceneContainer);
157
+ _context2.next = 4;
158
+ return mask.init();
159
+
160
+ case 4:
161
+ layer.addMask(mask);
162
+ this.tileMaskLayers.push(mask);
163
+
164
+ case 6:
165
+ case "end":
166
+ return _context2.stop();
167
+ }
168
+ }
169
+ }, _callee2, this);
170
+ }));
171
+
87
172
  function addMask(_x, _x2) {
88
173
  return _addMask.apply(this, arguments);
89
174
  }
@@ -93,26 +178,26 @@ var Tile = /*#__PURE__*/function () {
93
178
  }, {
94
179
  key: "addLayer",
95
180
  value: function () {
96
- var _addLayer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(layer) {
181
+ var _addLayer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(layer) {
97
182
  var container;
98
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
183
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
99
184
  while (1) {
100
- switch (_context2.prev = _context2.next) {
185
+ switch (_context3.prev = _context3.next) {
101
186
  case 0:
102
187
  // set flag
103
188
  layer.isTileLayer = true;
104
189
  container = createLayerContainer(this.parent.sceneContainer);
105
190
  layer.setContainer(container, this.parent.sceneContainer);
106
191
  this.layers.push(layer);
107
- _context2.next = 6;
192
+ _context3.next = 6;
108
193
  return layer.init();
109
194
 
110
195
  case 6:
111
196
  case "end":
112
- return _context2.stop();
197
+ return _context3.stop();
113
198
  }
114
199
  }
115
- }, _callee2, this);
200
+ }, _callee3, this);
116
201
  }));
117
202
 
118
203
  function addLayer(_x3) {
@@ -162,6 +247,9 @@ var Tile = /*#__PURE__*/function () {
162
247
  }, {
163
248
  key: "destroy",
164
249
  value: function destroy() {
250
+ var _this$tileMask;
251
+
252
+ (_this$tileMask = this.tileMask) === null || _this$tileMask === void 0 ? void 0 : _this$tileMask.destroy();
165
253
  this.layers.forEach(function (layer) {
166
254
  return layer.destroy();
167
255
  });
@@ -2,7 +2,6 @@ import { ILayer } from '@antv/l7-core';
2
2
  import Tile from './Tile';
3
3
  export default class VectorTile extends Tile {
4
4
  initTileLayer(): Promise<void>;
5
- protected addTileMask(layer: ILayer): Promise<void>;
6
5
  protected getSourceOption(): {
7
6
  data: {
8
7
  type: string;
@@ -11,7 +11,6 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
11
11
 
12
12
  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; } }
13
13
 
14
- import MaskLayer from "../../mask";
15
14
  import Tile from "./Tile";
16
15
  import { getTileLayer } from "./util";
17
16
 
@@ -58,18 +57,17 @@ var VectorTile = /*#__PURE__*/function (_Tile) {
58
57
 
59
58
  layer[attr]((_attributes$attr = attributes[attr]) === null || _attributes$attr === void 0 ? void 0 : _attributes$attr.field, (_attributes$attr2 = attributes[attr]) === null || _attributes$attr2 === void 0 ? void 0 : _attributes$attr2.values);
60
59
  });
60
+ _context.next = 11;
61
+ return this.addLayer(layer);
61
62
 
62
- if (!layerOptions.mask) {
63
- _context.next = 12;
63
+ case 11:
64
+ if (!layerOptions.tileMask) {
65
+ _context.next = 14;
64
66
  break;
65
67
  }
66
68
 
67
- _context.next = 12;
68
- return this.addTileMask(layer);
69
-
70
- case 12:
71
69
  _context.next = 14;
72
- return this.addLayer(layer);
70
+ return this.addTileMask();
73
71
 
74
72
  case 14:
75
73
  this.setLayerMinMaxZoom(layer);
@@ -88,44 +86,6 @@ var VectorTile = /*#__PURE__*/function (_Tile) {
88
86
  }
89
87
 
90
88
  return initTileLayer;
91
- }() // Todo 校验数据有效性
92
-
93
- }, {
94
- key: "addTileMask",
95
- value: function () {
96
- var _addTileMask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(layer) {
97
- var mask;
98
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
99
- while (1) {
100
- switch (_context2.prev = _context2.next) {
101
- case 0:
102
- mask = new MaskLayer({
103
- layerType: 'MaskLayer'
104
- }).source({
105
- type: 'FeatureCollection',
106
- features: [this.sourceTile.bboxPolygon]
107
- }, {
108
- parser: {
109
- type: 'geojson',
110
- featureId: 'id'
111
- }
112
- });
113
- _context2.next = 3;
114
- return this.addMask(layer, mask);
115
-
116
- case 3:
117
- case "end":
118
- return _context2.stop();
119
- }
120
- }
121
- }, _callee2, this);
122
- }));
123
-
124
- function addTileMask(_x) {
125
- return _addTileMask.apply(this, arguments);
126
- }
127
-
128
- return addTileMask;
129
89
  }()
130
90
  }, {
131
91
  key: "getSourceOption",
@@ -18,7 +18,7 @@ export default class BaseTileLayer {
18
18
  };
19
19
  constructor(parent: ILayer);
20
20
  protected initTileSetManager(): void;
21
- protected mapchange(): void;
21
+ protected mapchange: () => void;
22
22
  protected getCurrentView(): {
23
23
  latLonBounds: [number, number, number, number];
24
24
  zoom: number;
@@ -27,6 +27,7 @@ export default class BaseTileLayer {
27
27
  render(): void;
28
28
  getLayers(): ILayer[];
29
29
  getTiles(): import("@antv/l7-core").ITile[];
30
+ getTile(key: string): import("@antv/l7-core").ITile | undefined;
30
31
  viewchange: import("lodash").DebouncedFunc<() => void>;
31
32
  tileLoaded(tile: SourceTile): void;
32
33
  tileError(error: Error): void;
@@ -13,10 +13,49 @@ import { getTileFactory } from "../tileFactory";
13
13
  var BaseTileLayer = /*#__PURE__*/function () {
14
14
  // 瓦片数据管理器
15
15
  function BaseTileLayer(parent) {
16
+ var _this = this;
17
+
16
18
  _classCallCheck(this, BaseTileLayer);
17
19
 
18
20
  _defineProperty(this, "initedTileset", false);
19
21
 
22
+ _defineProperty(this, "mapchange", function () {
23
+ var _this$tilesetManager;
24
+
25
+ var _this$getCurrentView = _this.getCurrentView(),
26
+ latLonBounds = _this$getCurrentView.latLonBounds,
27
+ zoom = _this$getCurrentView.zoom;
28
+
29
+ if (_this.mapService.version === 'GAODE1.x') {
30
+ var _this$parent$getLayer = _this.parent.getLayerConfig(),
31
+ visible = _this$parent$getLayer.visible;
32
+
33
+ if (zoom < 2 && visible) {
34
+ _this.parent.updateLayerConfig({
35
+ visible: false
36
+ });
37
+
38
+ _this.layerService.reRender();
39
+ } else if (zoom >= 2 && !visible) {
40
+ _this.parent.updateLayerConfig({
41
+ visible: true
42
+ });
43
+
44
+ _this.layerService.reRender();
45
+ }
46
+ }
47
+
48
+ if (_this.lastViewStates && _this.lastViewStates.zoom === zoom && _this.lastViewStates.latLonBounds.toString() === latLonBounds.toString()) {
49
+ return;
50
+ }
51
+
52
+ _this.lastViewStates = {
53
+ zoom: zoom,
54
+ latLonBounds: latLonBounds
55
+ };
56
+ (_this$tilesetManager = _this.tilesetManager) === null || _this$tilesetManager === void 0 ? void 0 : _this$tilesetManager.throttleUpdate(zoom, latLonBounds);
57
+ });
58
+
20
59
  _defineProperty(this, "viewchange", debounce(this.mapchange, 24));
21
60
 
22
61
  this.parent = parent;
@@ -46,7 +85,7 @@ var BaseTileLayer = /*#__PURE__*/function () {
46
85
  _createClass(BaseTileLayer, [{
47
86
  key: "initTileSetManager",
48
87
  value: function initTileSetManager() {
49
- var _this$tilesetManager;
88
+ var _this$tilesetManager2;
50
89
 
51
90
  var source = this.parent.getSource();
52
91
  this.tilesetManager = source.tileset;
@@ -56,47 +95,11 @@ var BaseTileLayer = /*#__PURE__*/function () {
56
95
  this.initedTileset = true;
57
96
  }
58
97
 
59
- var _this$getCurrentView = this.getCurrentView(),
60
- latLonBounds = _this$getCurrentView.latLonBounds,
61
- zoom = _this$getCurrentView.zoom;
62
-
63
- (_this$tilesetManager = this.tilesetManager) === null || _this$tilesetManager === void 0 ? void 0 : _this$tilesetManager.update(zoom, latLonBounds);
64
- }
65
- }, {
66
- key: "mapchange",
67
- value: function mapchange() {
68
- var _this$tilesetManager2;
69
-
70
98
  var _this$getCurrentView2 = this.getCurrentView(),
71
99
  latLonBounds = _this$getCurrentView2.latLonBounds,
72
100
  zoom = _this$getCurrentView2.zoom;
73
101
 
74
- if (this.mapService.version === 'GAODE1.x') {
75
- var _this$parent$getLayer = this.parent.getLayerConfig(),
76
- visible = _this$parent$getLayer.visible;
77
-
78
- if (zoom < 2 && visible) {
79
- this.parent.updateLayerConfig({
80
- visible: false
81
- });
82
- this.layerService.reRender();
83
- } else if (zoom >= 2 && !visible) {
84
- this.parent.updateLayerConfig({
85
- visible: true
86
- });
87
- this.layerService.reRender();
88
- }
89
- }
90
-
91
- if (this.lastViewStates && this.lastViewStates.zoom === zoom && this.lastViewStates.latLonBounds.toString() === latLonBounds.toString()) {
92
- return;
93
- }
94
-
95
- this.lastViewStates = {
96
- zoom: zoom,
97
- latLonBounds: latLonBounds
98
- };
99
- (_this$tilesetManager2 = this.tilesetManager) === null || _this$tilesetManager2 === void 0 ? void 0 : _this$tilesetManager2.throttleUpdate(zoom, latLonBounds);
102
+ (_this$tilesetManager2 = this.tilesetManager) === null || _this$tilesetManager2 === void 0 ? void 0 : _this$tilesetManager2.update(zoom, latLonBounds);
100
103
  }
101
104
  }, {
102
105
  key: "getCurrentView",
@@ -112,7 +115,7 @@ var BaseTileLayer = /*#__PURE__*/function () {
112
115
  }, {
113
116
  key: "bindTilesetEvent",
114
117
  value: function bindTilesetEvent() {
115
- var _this = this;
118
+ var _this2 = this;
116
119
 
117
120
  // 瓦片数据加载成功
118
121
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -121,25 +124,21 @@ var BaseTileLayer = /*#__PURE__*/function () {
121
124
 
122
125
  this.tilesetManager.on('tile-unload', function (tile) {
123
126
  // 将事件抛出,图层上可以监听使用
124
- _this.tileUnLoad(tile);
127
+ _this2.tileUnLoad(tile);
125
128
  }); // 瓦片数据加载失败
126
129
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
127
130
 
128
131
  this.tilesetManager.on('tile-error', function (error, tile) {
129
132
  // 将事件抛出,图层上可以监听使用
130
- _this.tileError(error);
133
+ _this2.tileError(error);
131
134
  }); // 瓦片显隐状态更新
132
135
 
133
136
  this.tilesetManager.on('tile-update', function () {
134
- _this.tileUpdate();
137
+ _this2.tileUpdate();
135
138
  }); // 地图视野发生改变
136
139
 
137
- this.mapService.on('zoomend', function () {
138
- return _this.mapchange();
139
- });
140
- this.mapService.on('moveend', function () {
141
- return _this.viewchange();
142
- });
140
+ this.mapService.on('zoomend', this.mapchange);
141
+ this.mapService.on('moveend', this.viewchange);
143
142
  }
144
143
  }, {
145
144
  key: "render",
@@ -155,6 +154,11 @@ var BaseTileLayer = /*#__PURE__*/function () {
155
154
  key: "getTiles",
156
155
  value: function getTiles() {
157
156
  return this.tileLayerService.getTiles();
157
+ }
158
+ }, {
159
+ key: "getTile",
160
+ value: function getTile(key) {
161
+ return this.tileLayerService.getTile(key);
158
162
  } // 防抖操作
159
163
 
160
164
  }, {
@@ -172,6 +176,8 @@ var BaseTileLayer = /*#__PURE__*/function () {
172
176
  value: function destroy() {
173
177
  var _this$tilesetManager3;
174
178
 
179
+ this.mapService.off('zoomend', this.mapchange);
180
+ this.mapService.off('moveend', this.viewchange);
175
181
  (_this$tilesetManager3 = this.tilesetManager) === null || _this$tilesetManager3 === void 0 ? void 0 : _this$tilesetManager3.destroy();
176
182
  this.tileLayerService.destroy();
177
183
  }
@@ -184,7 +190,7 @@ var BaseTileLayer = /*#__PURE__*/function () {
184
190
  key: "tileUpdate",
185
191
  value: function () {
186
192
  var _tileUpdate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
187
- var _this2 = this;
193
+ var _this3 = this;
188
194
 
189
195
  var minZoom, maxZoom;
190
196
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
@@ -219,25 +225,25 @@ var BaseTileLayer = /*#__PURE__*/function () {
219
225
  while (1) {
220
226
  switch (_context.prev = _context.next) {
221
227
  case 0:
222
- if (_this2.tileLayerService.hasTile(tile.key)) {
228
+ if (_this3.tileLayerService.hasTile(tile.key)) {
223
229
  _context.next = 9;
224
230
  break;
225
231
  }
226
232
 
227
- tileInstance = getTileFactory(_this2.parent);
228
- tileLayer = new tileInstance(tile, _this2.parent);
233
+ tileInstance = getTileFactory(_this3.parent);
234
+ tileLayer = new tileInstance(tile, _this3.parent);
229
235
  _context.next = 5;
230
236
  return tileLayer.initTileLayer();
231
237
 
232
238
  case 5:
233
- _this2.tilePickService.setPickState();
239
+ _this3.tilePickService.setPickState();
234
240
 
235
241
  if (tileLayer.getLayers().length !== 0) {
236
- _this2.tileLayerService.addTile(tileLayer);
242
+ _this3.tileLayerService.addTile(tileLayer);
237
243
 
238
- _this2.tileLayerService.updateTileVisible(tile);
244
+ _this3.tileLayerService.updateTileVisible(tile);
239
245
 
240
- _this2.layerService.reRender();
246
+ _this3.layerService.reRender();
241
247
  }
242
248
 
243
249
  _context.next = 12;
@@ -245,11 +251,11 @@ var BaseTileLayer = /*#__PURE__*/function () {
245
251
 
246
252
  case 9:
247
253
  // 已加载瓦片
248
- _this2.tileLayerService.updateTileVisible(tile);
254
+ _this3.tileLayerService.updateTileVisible(tile);
249
255
 
250
- _this2.tilePickService.setPickState();
256
+ _this3.tilePickService.setPickState();
251
257
 
252
- _this2.layerService.reRender();
258
+ _this3.layerService.reRender();
253
259
 
254
260
  case 12:
255
261
  case "end":
@@ -313,7 +319,7 @@ var BaseTileLayer = /*#__PURE__*/function () {
313
319
  }, {
314
320
  key: "proxy",
315
321
  value: function proxy(parent) {
316
- var _this3 = this;
322
+ var _this4 = this;
317
323
 
318
324
  ProxyFuncs.forEach(function (func) {
319
325
  // @ts-ignore
@@ -326,14 +332,14 @@ var BaseTileLayer = /*#__PURE__*/function () {
326
332
 
327
333
  oldStyleFunc.apply(void 0, args);
328
334
 
329
- _this3.getLayers().map(function (child) {
335
+ _this4.getLayers().map(function (child) {
330
336
  // @ts-ignore
331
337
  child[func].apply(child, args);
332
338
  }); // Tip: 目前在更新 RasterData 的 colorTexture 的时候需要额外优化
333
339
 
334
340
 
335
341
  if (func === 'style') {
336
- _this3.getTiles().forEach(function (tile) {
342
+ _this4.getTiles().forEach(function (tile) {
337
343
  return tile.styleUpdate.apply(tile, args);
338
344
  });
339
345
  }
@@ -0,0 +1,7 @@
1
+ import { IRenderOptions, IStencilOptions, MaskOperationType } from '@antv/l7-core';
2
+ export declare function getStencil(mask: boolean, maskInside: boolean): Partial<IStencilOptions>;
3
+ interface IStencilMaskOptions extends IRenderOptions {
4
+ maskOperation?: MaskOperationType;
5
+ }
6
+ export declare function getStencilMask(option: Partial<IStencilMaskOptions>): Partial<IStencilOptions>;
7
+ export {};
@@ -0,0 +1,50 @@
1
+ import { gl, MaskOperation, StencilType } from '@antv/l7-core'; // 掩膜配置
2
+
3
+ export function getStencil(mask, maskInside) {
4
+ return {
5
+ enable: mask,
6
+ mask: 0xff,
7
+ func: {
8
+ cmp: gl.EQUAL,
9
+ // gl.EQUAL,
10
+ ref: maskInside ? 1 : 0,
11
+ mask: 1
12
+ }
13
+ };
14
+ }
15
+ // 模版配置
16
+ export function getStencilMask(option) {
17
+ if (option.maskOperation === MaskOperation.OR) {
18
+ return {
19
+ enable: true,
20
+ mask: 0xff,
21
+ func: {
22
+ cmp: gl.ALWAYS,
23
+ ref: 1,
24
+ mask: 0xff
25
+ },
26
+ opFront: {
27
+ fail: gl.KEEP,
28
+ zfail: gl.REPLACE,
29
+ zpass: gl.REPLACE
30
+ }
31
+ };
32
+ }
33
+
34
+ return {
35
+ enable: true,
36
+ mask: 0xff,
37
+ func: {
38
+ cmp: option.stencilType === StencilType.SINGLE // 单层
39
+ ? gl.ALWAYS : option.stencilIndex === 0 // 多层
40
+ ? gl.ALWAYS : gl.LESS,
41
+ ref: option.stencilType === StencilType.SINGLE ? 1 : option.stencilIndex === 0 ? 2 : 1,
42
+ mask: 0xff
43
+ },
44
+ opFront: {
45
+ fail: gl.KEEP,
46
+ zfail: gl.REPLACE,
47
+ zpass: gl.REPLACE
48
+ }
49
+ };
50
+ }
@@ -1,10 +1,11 @@
1
+ import { IRenderOptions } from '@antv/l7-core';
1
2
  import BaseLayer from '../core/BaseLayer';
2
3
  import { IWindLayerStyleOptions } from '../core/interface';
3
4
  import { WindModelType } from './models';
4
5
  export default class WindLayer extends BaseLayer<IWindLayerStyleOptions> {
5
6
  type: string;
6
7
  buildModels(): Promise<void>;
7
- renderModels(): this;
8
+ renderModels(options?: Partial<IRenderOptions>): this;
8
9
  protected getDefaultConfig(): {};
9
10
  getModelType(): WindModelType;
10
11
  }
package/es/wind/index.js CHANGED
@@ -67,8 +67,10 @@ var WindLayer = /*#__PURE__*/function (_BaseLayer) {
67
67
  }, {
68
68
  key: "renderModels",
69
69
  value: function renderModels() {
70
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
71
+
70
72
  if (this.layerModel) {
71
- this.layerModel.render(); // 独立的渲染流程
73
+ this.layerModel.render(options); // 独立的渲染流程
72
74
  }
73
75
 
74
76
  return this;
@@ -1,4 +1,4 @@
1
- import { IModel, IModelUniform, ITexture2D } from '@antv/l7-core';
1
+ import { IModel, IModelUniform, IRenderOptions, ITexture2D } from '@antv/l7-core';
2
2
  import BaseModel from '../../core/BaseModel';
3
3
  export default class WindModel extends BaseModel {
4
4
  protected texture: ITexture2D;
@@ -8,7 +8,7 @@ export default class WindModel extends BaseModel {
8
8
  private sizeScale;
9
9
  private frequency;
10
10
  private cacheZoom;
11
- render(): void;
11
+ render(options: Partial<IRenderOptions>): void;
12
12
  getUninforms(): IModelUniform;
13
13
  initModels(): Promise<IModel[]>;
14
14
  getWindSize(): {