@antv/l7-layers 2.17.2 → 2.17.4

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 (242) 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 +478 -313
  10. package/es/core/BaseModel.js +80 -51
  11. package/es/core/CommonStyleAttribute.js +5 -2
  12. package/es/core/LayerPickService.js +32 -21
  13. package/es/core/TextureService.js +13 -0
  14. package/es/core/interface.js +24 -17
  15. package/es/core/shape/Path.js +20 -13
  16. package/es/core/shape/extrude.js +39 -27
  17. package/es/core/triangulation.js +136 -99
  18. package/es/earth/index.js +33 -9
  19. package/es/earth/models/atmosphere.js +54 -30
  20. package/es/earth/models/base.js +85 -47
  21. package/es/earth/models/bloomsphere.js +54 -30
  22. package/es/earth/utils.js +13 -9
  23. package/es/heatmap/index.js +40 -10
  24. package/es/heatmap/models/grid.js +52 -28
  25. package/es/heatmap/models/grid3d.js +52 -28
  26. package/es/heatmap/models/heatmap.js +149 -92
  27. package/es/heatmap/models/hexagon.js +52 -28
  28. package/es/heatmap/triangulation.js +4 -0
  29. package/es/image/index.js +28 -9
  30. package/es/image/models/image.js +100 -66
  31. package/es/index.js +17 -9
  32. package/es/line/index.js +35 -9
  33. package/es/line/models/arc.js +114 -64
  34. package/es/line/models/arc_3d.js +102 -58
  35. package/es/line/models/earthArc_3d.js +105 -60
  36. package/es/line/models/flow.js +60 -36
  37. package/es/line/models/great_circle.js +94 -53
  38. package/es/line/models/line.js +138 -86
  39. package/es/line/models/linearline.js +76 -43
  40. package/es/line/models/simpleLine.js +69 -39
  41. package/es/line/models/wall.js +92 -52
  42. package/es/mask/index.js +28 -9
  43. package/es/mask/models/fill.js +54 -29
  44. package/es/plugins/DataMappingPlugin.js +114 -78
  45. package/es/plugins/DataSourcePlugin.js +68 -45
  46. package/es/plugins/FeatureScalePlugin.js +122 -67
  47. package/es/plugins/LayerAnimateStylePlugin.js +5 -0
  48. package/es/plugins/LayerMaskPlugin.js +11 -3
  49. package/es/plugins/LayerModelPlugin.js +108 -69
  50. package/es/plugins/LayerStylePlugin.js +9 -3
  51. package/es/plugins/LightingPlugin.js +18 -12
  52. package/es/plugins/MultiPassRendererPlugin.js +16 -11
  53. package/es/plugins/PixelPickingPlugin.js +21 -12
  54. package/es/plugins/RegisterStyleAttributePlugin.js +12 -5
  55. package/es/plugins/ShaderUniformPlugin.js +27 -13
  56. package/es/plugins/UpdateModelPlugin.js +5 -0
  57. package/es/plugins/UpdateStyleAttributePlugin.js +11 -5
  58. package/es/point/index.js +78 -26
  59. package/es/point/models/earthExtrude.js +95 -58
  60. package/es/point/models/earthFill.js +80 -52
  61. package/es/point/models/extrude.js +94 -57
  62. package/es/point/models/fill.js +81 -56
  63. package/es/point/models/fillmage.js +100 -60
  64. package/es/point/models/image.js +83 -47
  65. package/es/point/models/index.js +2 -2
  66. package/es/point/models/normal.js +54 -30
  67. package/es/point/models/radar.js +63 -38
  68. package/es/point/models/simplePoint.js +62 -38
  69. package/es/point/models/text.js +296 -199
  70. package/es/point/shape/extrude.js +13 -4
  71. package/es/polygon/index.js +41 -11
  72. package/es/polygon/models/extrude.js +135 -87
  73. package/es/polygon/models/fill.js +79 -50
  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/extrude_polyline.js +149 -101
  104. package/es/utils/grid-index.js +27 -2
  105. package/es/utils/identityScale.js +8 -0
  106. package/es/utils/layerData.js +44 -30
  107. package/es/utils/multiPassRender.js +13 -11
  108. package/es/utils/polylineNormal.js +37 -31
  109. package/es/utils/simpleLine.js +16 -2
  110. package/es/utils/stencil.js +3 -2
  111. package/es/utils/symbol-layout.js +53 -27
  112. package/es/wind/index.js +29 -9
  113. package/es/wind/models/utils.js +51 -26
  114. package/es/wind/models/wind.js +147 -101
  115. package/es/wind/models/windRender.js +66 -53
  116. package/lib/Geometry/index.js +38 -9
  117. package/lib/Geometry/models/billboard.js +97 -51
  118. package/lib/Geometry/models/index.js +5 -0
  119. package/lib/Geometry/models/plane.js +151 -79
  120. package/lib/Geometry/models/sprite.js +127 -60
  121. package/lib/canvas/index.js +40 -10
  122. package/lib/canvas/models/canvas.js +101 -41
  123. package/lib/canvas/models/index.js +3 -0
  124. package/lib/citybuliding/building.js +35 -8
  125. package/lib/citybuliding/models/build.js +92 -57
  126. package/lib/core/BaseLayer.js +469 -313
  127. package/lib/core/BaseModel.js +90 -51
  128. package/lib/core/CommonStyleAttribute.js +7 -2
  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 +62 -27
  135. package/lib/core/triangulation.js +177 -98
  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 +166 -92
  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 +124 -62
  154. package/lib/line/models/arc_3d.js +113 -56
  155. package/lib/line/models/earthArc_3d.js +115 -58
  156. package/lib/line/models/flow.js +70 -36
  157. package/lib/line/models/great_circle.js +104 -53
  158. package/lib/line/models/index.js +11 -0
  159. package/lib/line/models/line.js +146 -84
  160. package/lib/line/models/linearline.js +88 -43
  161. package/lib/line/models/simpleLine.js +79 -39
  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 +125 -78
  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 +117 -70
  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 +106 -58
  182. package/lib/point/models/earthFill.js +110 -52
  183. package/lib/point/models/extrude.js +103 -57
  184. package/lib/point/models/fill.js +90 -54
  185. package/lib/point/models/fillmage.js +107 -58
  186. package/lib/point/models/image.js +92 -47
  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 +72 -38
  190. package/lib/point/models/simplePoint.js +72 -38
  191. package/lib/point/models/text.js +305 -199
  192. package/lib/point/shape/extrude.js +20 -4
  193. package/lib/polygon/index.js +48 -11
  194. package/lib/polygon/models/extrude.js +146 -87
  195. package/lib/polygon/models/fill.js +89 -50
  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/extrude_polyline.js +181 -101
  228. package/lib/utils/grid-index.js +28 -2
  229. package/lib/utils/identityScale.js +9 -0
  230. package/lib/utils/layerData.js +49 -30
  231. package/lib/utils/multiPassRender.js +16 -11
  232. package/lib/utils/polylineNormal.js +66 -31
  233. package/lib/utils/simpleLine.js +21 -2
  234. package/lib/utils/stencil.js +4 -0
  235. package/lib/utils/symbol-layout.js +55 -27
  236. package/lib/wind/index.js +37 -9
  237. package/lib/wind/models/index.js +3 -0
  238. package/lib/wind/models/utils.js +62 -26
  239. package/lib/wind/models/wind.js +157 -101
  240. package/lib/wind/models/windRender.js +71 -53
  241. package/lib/wind/models/windShader.js +1 -0
  242. package/package.json +7 -7
@@ -1,46 +1,61 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
4
5
  var _typeof = require("@babel/runtime/helpers/typeof");
6
+
5
7
  Object.defineProperty(exports, "__esModule", {
6
8
  value: true
7
9
  });
8
10
  exports.Wind = void 0;
11
+
9
12
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
+
10
14
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
15
+
11
16
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
17
+
12
18
  var glUtils = _interopRequireWildcard(require("./utils"));
19
+
13
20
  var _windShader = require("./windShader");
21
+
14
22
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
23
+
15
24
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
25
+
16
26
  function getColorRamp(colors) {
17
27
  var canvas = document.createElement('canvas');
18
28
  var ctx = canvas.getContext('2d');
19
29
  canvas.width = 256;
20
30
  canvas.height = 1;
21
31
  var gradient = ctx.createLinearGradient(0, 0, 256, 0);
32
+
22
33
  for (var _i = 0, _Object$keys = Object.keys(colors); _i < _Object$keys.length; _i++) {
23
34
  var stop = _Object$keys[_i];
24
35
  gradient.addColorStop(+stop, colors[+stop]);
25
36
  }
37
+
26
38
  ctx.fillStyle = gradient;
27
- ctx.fillRect(0, 0, 256, 1);
39
+ ctx.fillRect(0, 0, 256, 1); // @ts-ignore dispose canvas element
28
40
 
29
- // @ts-ignore dispose canvas element
30
41
  canvas = null;
31
42
  return new Uint8Array(ctx.getImageData(0, 0, 256, 1).data);
32
43
  }
44
+
33
45
  function bindAttribute(gl, buffer, attribute, numComponents) {
34
46
  gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
35
47
  gl.enableVertexAttribArray(attribute);
36
48
  gl.vertexAttribPointer(attribute, numComponents, gl.FLOAT, false, 0, 0);
37
49
  }
50
+
38
51
  function bindFramebuffer(gl, framebuffer, texture) {
39
52
  gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
53
+
40
54
  if (texture) {
41
55
  gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
42
56
  }
43
57
  }
58
+
44
59
  var Wind = /*#__PURE__*/function () {
45
60
  function Wind(options) {
46
61
  (0, _classCallCheck2.default)(this, Wind);
@@ -57,13 +72,17 @@ var Wind = /*#__PURE__*/function () {
57
72
  this.rampColors = options.rampColors;
58
73
  this.init();
59
74
  }
75
+
60
76
  (0, _createClass2.default)(Wind, [{
61
77
  key: "init",
62
78
  value: function init() {
63
79
  var gl = this.gl;
64
80
  this.fadeOpacity = 0.996; // how fast the particle trails fade on each frame
81
+
65
82
  this.speedFactor = 0.25; // how fast the particles move
83
+
66
84
  this.dropRate = 0.003; // how often the particles move to a random place
85
+
67
86
  this.dropRateBump = 0.01; // drop rate increase relative to individual particle speed
68
87
 
69
88
  this.drawProgram = glUtils.createProgram(gl, _windShader.drawVert, _windShader.drawFrag);
@@ -72,28 +91,29 @@ var Wind = /*#__PURE__*/function () {
72
91
  this.quadBuffer = glUtils.createBuffer(gl, new Float32Array([0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1]));
73
92
  this.framebuffer = gl.createFramebuffer();
74
93
  this.colorRampTexture = glUtils.createTexture(this.gl, this.gl.LINEAR, getColorRamp(this.rampColors), 16, 16);
75
- var emptyPixels = new Uint8Array(this.width * this.height * 4);
76
-
77
- // screen textures to hold the drawn screen for the previous and the current frame
94
+ var emptyPixels = new Uint8Array(this.width * this.height * 4); // screen textures to hold the drawn screen for the previous and the current frame
78
95
 
79
96
  this.backgroundTexture = glUtils.createTexture(gl, gl.NEAREST, emptyPixels, this.width, this.height);
80
- this.screenTexture = glUtils.createTexture(gl, gl.NEAREST, emptyPixels, this.width, this.height);
97
+ this.screenTexture = glUtils.createTexture(gl, gl.NEAREST, emptyPixels, this.width, this.height); // we create a square texture where each pixel will hold a particle position encoded as RGBA
98
+
99
+ var particleRes = this.particleStateResolution = Math.ceil(Math.sqrt(this.numParticles)); // particleRes size
81
100
 
82
- // we create a square texture where each pixel will hold a particle position encoded as RGBA
83
- var particleRes = this.particleStateResolution = Math.ceil(Math.sqrt(this.numParticles));
84
- // particleRes size
85
101
  this.numParticlesSize = particleRes * particleRes;
86
102
  var particleState = new Uint8Array(this.numParticlesSize * 4);
103
+
87
104
  for (var i = 0; i < particleState.length; i++) {
88
105
  particleState[i] = Math.floor(Math.random() * 256); // randomize the initial particle positions
89
- }
90
- // textures to hold the particle state for the current and the next frame
106
+ } // textures to hold the particle state for the current and the next frame
107
+
108
+
91
109
  this.particleStateTexture0 = glUtils.createTexture(gl, gl.NEAREST, particleState, particleRes, particleRes);
92
110
  this.particleStateTexture1 = glUtils.createTexture(gl, gl.NEAREST, particleState, particleRes, particleRes);
93
111
  var particleIndices = new Float32Array(this.numParticlesSize);
112
+
94
113
  for (var i$1 = 0; i$1 < this.numParticlesSize; i$1++) {
95
114
  particleIndices[i$1] = i$1;
96
115
  }
116
+
97
117
  this.particleIndexBuffer = glUtils.createBuffer(gl, particleIndices);
98
118
  }
99
119
  }, {
@@ -102,36 +122,40 @@ var Wind = /*#__PURE__*/function () {
102
122
  this.windData = windData;
103
123
  this.windTexture = glUtils.createDataTexture(this.gl, this.gl.LINEAR, windData.image);
104
124
  }
105
-
106
125
  /**
107
126
  * 更新风场粒子数量
108
127
  * @param num
109
128
  */
129
+
110
130
  }, {
111
131
  key: "updateParticelNum",
112
132
  value: function updateParticelNum(num) {
113
133
  var gl = this.gl;
134
+
114
135
  if (num !== this.numParticles) {
115
136
  this.numParticles = num; // params number
116
-
117
137
  // we create a square texture where each pixel will hold a particle position encoded as RGBA
138
+
118
139
  var particleRes = this.particleStateResolution = Math.ceil(Math.sqrt(this.numParticles));
119
140
  this.numParticlesSize = particleRes * particleRes;
120
141
  var particleState = new Uint8Array(this.numParticlesSize * 4);
142
+
121
143
  for (var i = 0; i < particleState.length; i++) {
122
144
  particleState[i] = Math.floor(Math.random() * 256); // randomize the initial particle positions
123
- }
124
- // textures to hold the particle state for the current and the next frame
145
+ } // textures to hold the particle state for the current and the next frame
146
+
147
+
125
148
  this.particleStateTexture0 = glUtils.createTexture(gl, gl.NEAREST, particleState, particleRes, particleRes);
126
149
  this.particleStateTexture1 = glUtils.createTexture(gl, gl.NEAREST, particleState, particleRes, particleRes);
127
150
  var particleIndices = new Float32Array(this.numParticlesSize);
151
+
128
152
  for (var i$1 = 0; i$1 < this.numParticlesSize; i$1++) {
129
153
  particleIndices[i$1] = i$1;
130
154
  }
155
+
131
156
  this.particleIndexBuffer = glUtils.createBuffer(gl, particleIndices);
132
157
  }
133
158
  }
134
-
135
159
  /**
136
160
  * 更新风场风向风速
137
161
  * @param uMin
@@ -139,6 +163,7 @@ var Wind = /*#__PURE__*/function () {
139
163
  * @param vMin
140
164
  * @param vMax
141
165
  */
166
+
142
167
  }, {
143
168
  key: "updateWindDir",
144
169
  value: function updateWindDir(uMin, uMax, vMin, vMax) {
@@ -147,11 +172,11 @@ var Wind = /*#__PURE__*/function () {
147
172
  this.windData.vMin = vMin;
148
173
  this.windData.vMax = vMax;
149
174
  }
150
-
151
175
  /**
152
176
  * update rampColors
153
177
  * @param rampColors
154
178
  */
179
+
155
180
  }, {
156
181
  key: "updateColorRampTexture",
157
182
  value: function updateColorRampTexture(rampColors) {
@@ -166,18 +191,23 @@ var Wind = /*#__PURE__*/function () {
166
191
  key: "isColorChanged",
167
192
  value: function isColorChanged(rampColors) {
168
193
  var keys = Object.keys(rampColors);
194
+
169
195
  for (var _i2 = 0, _keys = keys; _i2 < _keys.length; _i2++) {
170
196
  var item = _keys[_i2];
171
- var _key = Number(item);
172
- // exist new key -> color need update
197
+
198
+ var _key = Number(item); // exist new key -> color need update
199
+
200
+
173
201
  if (!this.rampColors[_key]) {
174
202
  return true;
175
- }
176
- // value changed -> color need update
203
+ } // value changed -> color need update
204
+
205
+
177
206
  if (this.rampColors[_key] && this.rampColors[_key] !== rampColors[_key]) {
178
207
  return true;
179
208
  }
180
209
  }
210
+
181
211
  return false;
182
212
  }
183
213
  }, {
@@ -189,8 +219,8 @@ var Wind = /*#__PURE__*/function () {
189
219
  gl.deleteTexture(this.screenTexture);
190
220
  this.width = width;
191
221
  this.height = height;
192
- var emptyPixels = new Uint8Array(width * height * 4);
193
- // screen textures to hold the drawn screen for the previous and the current frame
222
+ var emptyPixels = new Uint8Array(width * height * 4); // screen textures to hold the drawn screen for the previous and the current frame
223
+
194
224
  this.backgroundTexture = glUtils.createTexture(gl, gl.NEAREST, emptyPixels, width, height);
195
225
  this.screenTexture = glUtils.createTexture(gl, gl.NEAREST, emptyPixels, width, height);
196
226
  }
@@ -199,11 +229,13 @@ var Wind = /*#__PURE__*/function () {
199
229
  key: "draw",
200
230
  value: function draw() {
201
231
  var _this$windData;
232
+
202
233
  if ((_this$windData = this.windData) !== null && _this$windData !== void 0 && _this$windData.image) {
203
234
  var gl = this.gl;
204
235
  glUtils.bindTexture(gl, this.windTexture, 0);
205
236
  glUtils.bindTexture(gl, this.particleStateTexture0, 1);
206
237
  this.drawScreen(); // draw Particles into framebuffer
238
+
207
239
  this.updateParticles();
208
240
  return {
209
241
  d: this.pixels,
@@ -221,9 +253,8 @@ var Wind = /*#__PURE__*/function () {
221
253
  }, {
222
254
  key: "drawScreen",
223
255
  value: function drawScreen() {
224
- var gl = this.gl;
256
+ var gl = this.gl; // draw the screen into a temporary framebuffer to retain it as the background on the next frame
225
257
 
226
- // draw the screen into a temporary framebuffer to retain it as the background on the next frame
227
258
  bindFramebuffer(gl, this.framebuffer, this.screenTexture);
228
259
  gl.viewport(0, 0, this.width, this.height);
229
260
  gl.disable(gl.BLEND);
@@ -232,9 +263,8 @@ var Wind = /*#__PURE__*/function () {
232
263
  this.pixels = new Uint8Array(4 * this.width * this.height);
233
264
  gl.readPixels(0, 0, this.width, this.height, gl.RGBA, gl.UNSIGNED_BYTE, this.pixels);
234
265
  bindFramebuffer(gl, null, null);
235
- gl.viewport(0, 0, this.gl.canvas.width, this.gl.canvas.height);
266
+ gl.viewport(0, 0, this.gl.canvas.width, this.gl.canvas.height); // save the current screen as the background for the next frame
236
267
 
237
- // save the current screen as the background for the next frame
238
268
  var temp = this.backgroundTexture;
239
269
  this.backgroundTexture = this.screenTexture;
240
270
  this.screenTexture = temp;
@@ -244,9 +274,7 @@ var Wind = /*#__PURE__*/function () {
244
274
  value: function drawFullTexture(texture, opacity) {
245
275
  var gl = this.gl;
246
276
  var program = this.fullScreenProgram;
247
- gl.useProgram(program);
248
-
249
- // bindAttribute(gl, this.quadBuffer, program.a_pos, 2);
277
+ gl.useProgram(program); // bindAttribute(gl, this.quadBuffer, program.a_pos, 2);
250
278
 
251
279
  gl.bindBuffer(gl.ARRAY_BUFFER, this.quadBuffer);
252
280
  gl.vertexAttribPointer(program.a_pos, 2, gl.FLOAT, false, 0, 0);
@@ -255,8 +283,7 @@ var Wind = /*#__PURE__*/function () {
255
283
  glUtils.bindTexture(gl, texture, 2);
256
284
  gl.uniform1i(program.u_screen, 2);
257
285
  gl.uniform1f(program.u_opacity, opacity);
258
- gl.drawArrays(gl.TRIANGLES, 0, 6);
259
- // gl.drawArrays(gl.POINTS, 0, 6);
286
+ gl.drawArrays(gl.TRIANGLES, 0, 6); // gl.drawArrays(gl.POINTS, 0, 6);
260
287
  }
261
288
  }, {
262
289
  key: "drawParticles",
@@ -292,15 +319,12 @@ var Wind = /*#__PURE__*/function () {
292
319
  gl.uniform1f(program.u_speed_factor, this.speedFactor);
293
320
  gl.uniform1f(program.u_drop_rate, this.dropRate);
294
321
  gl.uniform1f(program.u_drop_rate_bump, this.dropRateBump);
295
- gl.drawArrays(gl.TRIANGLES, 0, 6);
322
+ gl.drawArrays(gl.TRIANGLES, 0, 6); // swap the particle state textures so the new one becomes the current one
296
323
 
297
- // swap the particle state textures so the new one becomes the current one
298
324
  var temp = this.particleStateTexture0;
299
325
  this.particleStateTexture0 = this.particleStateTexture1;
300
326
  this.particleStateTexture1 = temp;
301
- bindFramebuffer(gl, null, null);
302
-
303
- // gl.viewport(0, 0, this.gl.canvas.width, this.gl.canvas.height);
327
+ bindFramebuffer(gl, null, null); // gl.viewport(0, 0, this.gl.canvas.width, this.gl.canvas.height);
304
328
  }
305
329
  }, {
306
330
  key: "destroy",
@@ -308,38 +332,31 @@ var Wind = /*#__PURE__*/function () {
308
332
  // private drawProgram: WebGLProgram;
309
333
  // private fullScreenProgram: WebGLProgram;
310
334
  // private updateProgram: WebGLProgram;
311
-
312
335
  // private quadBuffer: WebGLBuffer | null;
313
336
  // private particleIndexBuffer: WebGLBuffer | null;
314
-
315
337
  // private framebuffer: WebGLFramebuffer | null;
316
-
317
338
  // private colorRampTexture: WebGLTexture | null;
318
339
  // private backgroundTexture: WebGLTexture | null;
319
340
  // private screenTexture: WebGLTexture | null;
320
341
  // private particleStateTexture0: WebGLTexture | null;
321
342
  // private particleStateTexture1: WebGLTexture | null;
322
343
  // private windTexture: WebGLTexture | null;
323
-
324
344
  this.gl.deleteBuffer(this.quadBuffer);
325
345
  this.gl.deleteBuffer(this.particleIndexBuffer);
326
- this.gl.deleteFramebuffer(this.framebuffer);
346
+ this.gl.deleteFramebuffer(this.framebuffer); // @ts-ignore
347
+
348
+ this.gl.deleteShader(this.drawProgram.vertexShader); // @ts-ignore
327
349
 
328
- // @ts-ignore
329
- this.gl.deleteShader(this.drawProgram.vertexShader);
330
- // @ts-ignore
331
350
  this.gl.deleteShader(this.drawProgram.fragmentShader);
332
- this.gl.deleteProgram(this.drawProgram);
351
+ this.gl.deleteProgram(this.drawProgram); // @ts-ignore
352
+
353
+ this.gl.deleteShader(this.fullScreenProgram.vertexShader); // @ts-ignore
333
354
 
334
- // @ts-ignore
335
- this.gl.deleteShader(this.fullScreenProgram.vertexShader);
336
- // @ts-ignore
337
355
  this.gl.deleteShader(this.fullScreenProgram.fragmentShader);
338
- this.gl.deleteProgram(this.fullScreenProgram);
356
+ this.gl.deleteProgram(this.fullScreenProgram); // @ts-ignore
357
+
358
+ this.gl.deleteShader(this.updateProgram.vertexShader); // @ts-ignore
339
359
 
340
- // @ts-ignore
341
- this.gl.deleteShader(this.updateProgram.vertexShader);
342
- // @ts-ignore
343
360
  this.gl.deleteShader(this.updateProgram.fragmentShader);
344
361
  this.gl.deleteProgram(this.updateProgram);
345
362
  this.gl.deleteTexture(this.colorRampTexture);
@@ -352,4 +369,5 @@ var Wind = /*#__PURE__*/function () {
352
369
  }]);
353
370
  return Wind;
354
371
  }();
372
+
355
373
  exports.Wind = Wind;
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.updateVert = exports.updateFrag = exports.fullScreenVert = exports.fullScreenFrag = exports.drawVert = exports.drawFrag = void 0;
7
+
7
8
  /**
8
9
  * drawProgram drawVert drawFrag
9
10
  * screenProgram screenVert screenFrag
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/l7-layers",
3
- "version": "2.17.2",
3
+ "version": "2.17.4",
4
4
  "description": "L7's collection of built-in layers",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -27,10 +27,10 @@
27
27
  "license": "ISC",
28
28
  "dependencies": {
29
29
  "@antv/async-hook": "^2.2.9",
30
- "@antv/l7-core": "2.17.2",
31
- "@antv/l7-maps": "2.17.2",
32
- "@antv/l7-source": "2.17.2",
33
- "@antv/l7-utils": "2.17.2",
30
+ "@antv/l7-core": "^2.17.4",
31
+ "@antv/l7-maps": "^2.17.4",
32
+ "@antv/l7-source": "^2.17.4",
33
+ "@antv/l7-utils": "^2.17.4",
34
34
  "@babel/runtime": "^7.7.7",
35
35
  "@mapbox/martini": "^0.2.0",
36
36
  "@turf/clone": "^6.5.0",
@@ -53,7 +53,7 @@
53
53
  "reflect-metadata": "^0.1.13"
54
54
  },
55
55
  "devDependencies": {
56
- "@antv/l7-test-utils": "2.17.2",
56
+ "@antv/l7-test-utils": "^2.17.4",
57
57
  "@types/d3-array": "^2.0.0",
58
58
  "@types/d3-color": "^1.2.2",
59
59
  "@types/d3-interpolate": "1.1.6",
@@ -62,7 +62,7 @@
62
62
  "@types/gl-matrix": "^2.4.5",
63
63
  "@types/lodash": "^4.14.138"
64
64
  },
65
- "gitHead": "20cccf03638dd13ef950a63aa7308edb40941c83",
65
+ "gitHead": "f6a09dc02ed0fc7a7f5dc44b231105f43b26f67b",
66
66
  "publishConfig": {
67
67
  "access": "public"
68
68
  }