@antv/l7-layers 2.15.1 → 2.15.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 (243) 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 +320 -484
  10. package/es/core/BaseModel.js +97 -126
  11. package/es/core/LayerPickService.js +21 -32
  12. package/es/core/TextureService.js +0 -13
  13. package/es/core/interface.js +17 -24
  14. package/es/core/shape/Path.js +13 -20
  15. package/es/core/shape/extrude.js +10 -31
  16. package/es/core/triangulation.js +54 -114
  17. package/es/earth/index.js +9 -33
  18. package/es/earth/models/atmosphere.js +30 -54
  19. package/es/earth/models/base.js +47 -85
  20. package/es/earth/models/bloomsphere.js +30 -54
  21. package/es/earth/utils.js +9 -13
  22. package/es/heatmap/index.js +10 -40
  23. package/es/heatmap/models/grid.js +28 -52
  24. package/es/heatmap/models/grid3d.js +28 -52
  25. package/es/heatmap/models/heatmap.js +91 -146
  26. package/es/heatmap/models/hexagon.js +28 -52
  27. package/es/heatmap/triangulation.js +0 -4
  28. package/es/image/index.js +9 -28
  29. package/es/image/models/image.js +66 -100
  30. package/es/index.js +9 -17
  31. package/es/line/index.js +9 -34
  32. package/es/line/models/arc.js +66 -118
  33. package/es/line/models/arc_3d.js +60 -108
  34. package/es/line/models/earthArc_3d.js +63 -111
  35. package/es/line/models/great_circle.js +56 -100
  36. package/es/line/models/half.js +46 -77
  37. package/es/line/models/line.js +94 -148
  38. package/es/line/models/linearline.js +45 -80
  39. package/es/line/models/simpleLine.js +41 -74
  40. package/es/line/models/wall.js +52 -92
  41. package/es/mask/index.js +9 -28
  42. package/es/mask/models/fill.js +29 -54
  43. package/es/plugins/DataMappingPlugin.js +80 -117
  44. package/es/plugins/DataSourcePlugin.js +45 -68
  45. package/es/plugins/FeatureScalePlugin.js +67 -122
  46. package/es/plugins/LayerAnimateStylePlugin.js +0 -5
  47. package/es/plugins/LayerMaskPlugin.js +3 -11
  48. package/es/plugins/LayerModelPlugin.js +67 -104
  49. package/es/plugins/LayerStylePlugin.js +3 -9
  50. package/es/plugins/LightingPlugin.js +12 -18
  51. package/es/plugins/MultiPassRendererPlugin.js +11 -16
  52. package/es/plugins/PixelPickingPlugin.js +12 -21
  53. package/es/plugins/RegisterStyleAttributePlugin.js +5 -12
  54. package/es/plugins/ShaderUniformPlugin.js +13 -27
  55. package/es/plugins/UpdateModelPlugin.js +0 -5
  56. package/es/plugins/UpdateStyleAttributePlugin.js +5 -11
  57. package/es/point/index.js +26 -77
  58. package/es/point/models/earthExtrude.js +61 -102
  59. package/es/point/models/earthFill.js +57 -87
  60. package/es/point/models/extrude.js +60 -101
  61. package/es/point/models/fill.js +70 -100
  62. package/es/point/models/fillmage.js +63 -107
  63. package/es/point/models/image.js +48 -88
  64. package/es/point/models/index.js +2 -2
  65. package/es/point/models/normal.js +30 -54
  66. package/es/point/models/radar.js +40 -64
  67. package/es/point/models/simplePoint.js +41 -69
  68. package/es/point/models/text.d.ts +2 -0
  69. package/es/point/models/text.js +214 -295
  70. package/es/point/shape/extrude.js +4 -13
  71. package/es/polygon/index.js +11 -40
  72. package/es/polygon/models/extrude.js +48 -92
  73. package/es/polygon/models/fill.js +54 -88
  74. package/es/polygon/models/index.js +3 -2
  75. package/es/polygon/models/ocean.js +42 -76
  76. package/es/polygon/models/water.js +37 -71
  77. package/es/raster/buffers/triangulation.js +2 -4
  78. package/es/raster/index.js +9 -32
  79. package/es/raster/models/raster.js +80 -116
  80. package/es/raster/models/rasterRgb.js +84 -127
  81. package/es/raster/models/rasterTerrainRgb.js +56 -84
  82. package/es/tile/interaction/getRasterData.js +14 -20
  83. package/es/tile/interaction/utils.js +7 -9
  84. package/es/tile/manager/base.js +63 -96
  85. package/es/tile/service/TileLayerService.js +30 -52
  86. package/es/tile/service/TilePickService.js +26 -40
  87. package/es/tile/service/TileSourceService.js +3 -7
  88. package/es/tile/tileFactory/DebugTile.js +28 -45
  89. package/es/tile/tileFactory/ImageTile.js +20 -38
  90. package/es/tile/tileFactory/MaskTile.js +22 -43
  91. package/es/tile/tileFactory/RasterRGBTile.js +22 -42
  92. package/es/tile/tileFactory/RasterTerrainRGBTile.js +20 -38
  93. package/es/tile/tileFactory/RasterTile.js +30 -53
  94. package/es/tile/tileFactory/Tile.js +63 -97
  95. package/es/tile/tileFactory/VectorTile.js +41 -68
  96. package/es/tile/tileFactory/index.js +0 -11
  97. package/es/tile/tileFactory/layers/TileDebugLayer.js +6 -27
  98. package/es/tile/tileFactory/util.js +0 -3
  99. package/es/tile/tileLayer/BaseLayer.js +105 -146
  100. package/es/tile/utils.js +1 -1
  101. package/es/utils/blend.js +0 -2
  102. package/es/utils/collision-index.js +9 -16
  103. package/es/utils/dataMappingStyle.js +8 -18
  104. package/es/utils/extrude_polyline.js +101 -149
  105. package/es/utils/grid-index.js +2 -27
  106. package/es/utils/identityScale.js +0 -8
  107. package/es/utils/layerData.js +30 -44
  108. package/es/utils/multiPassRender.js +11 -13
  109. package/es/utils/polylineNormal.js +31 -37
  110. package/es/utils/simpleLine.js +2 -16
  111. package/es/utils/stencil.js +2 -3
  112. package/es/utils/symbol-layout.js +27 -53
  113. package/es/wind/index.js +9 -29
  114. package/es/wind/models/utils.js +26 -51
  115. package/es/wind/models/wind.js +101 -147
  116. package/es/wind/models/windRender.js +53 -66
  117. package/lib/Geometry/index.js +9 -38
  118. package/lib/Geometry/models/billboard.js +51 -97
  119. package/lib/Geometry/models/index.js +0 -5
  120. package/lib/Geometry/models/plane.js +79 -151
  121. package/lib/Geometry/models/sprite.js +60 -127
  122. package/lib/canvas/index.js +10 -40
  123. package/lib/canvas/models/canvas.js +41 -101
  124. package/lib/canvas/models/index.js +0 -3
  125. package/lib/citybuliding/building.js +8 -35
  126. package/lib/citybuliding/models/build.js +57 -92
  127. package/lib/core/BaseLayer.js +320 -478
  128. package/lib/core/BaseModel.js +97 -139
  129. package/lib/core/LayerPickService.js +21 -37
  130. package/lib/core/TextureService.js +0 -16
  131. package/lib/core/interface.js +21 -31
  132. package/lib/core/schema.js +0 -1
  133. package/lib/core/shape/Path.js +14 -31
  134. package/lib/core/shape/extrude.js +10 -54
  135. package/lib/core/triangulation.js +53 -153
  136. package/lib/earth/index.js +9 -43
  137. package/lib/earth/models/atmosphere.js +30 -63
  138. package/lib/earth/models/base.js +47 -90
  139. package/lib/earth/models/bloomsphere.js +30 -63
  140. package/lib/earth/utils.js +7 -31
  141. package/lib/heatmap/index.js +10 -48
  142. package/lib/heatmap/models/grid.js +28 -60
  143. package/lib/heatmap/models/grid3d.js +28 -60
  144. package/lib/heatmap/models/heatmap.js +91 -162
  145. package/lib/heatmap/models/hexagon.js +28 -60
  146. package/lib/heatmap/models/index.js +0 -6
  147. package/lib/heatmap/triangulation.js +0 -5
  148. package/lib/image/index.js +9 -36
  149. package/lib/image/models/image.js +66 -109
  150. package/lib/image/models/index.js +0 -3
  151. package/lib/index.js +7 -61
  152. package/lib/line/index.js +9 -40
  153. package/lib/line/models/arc.js +64 -128
  154. package/lib/line/models/arc_3d.js +58 -119
  155. package/lib/line/models/earthArc_3d.js +61 -122
  156. package/lib/line/models/great_circle.js +56 -111
  157. package/lib/line/models/half.js +46 -87
  158. package/lib/line/models/index.js +0 -11
  159. package/lib/line/models/line.js +92 -156
  160. package/lib/line/models/linearline.js +45 -92
  161. package/lib/line/models/simpleLine.js +41 -84
  162. package/lib/line/models/wall.js +52 -103
  163. package/lib/mask/index.js +9 -36
  164. package/lib/mask/models/fill.js +29 -63
  165. package/lib/mask/models/index.js +0 -3
  166. package/lib/plugins/DataMappingPlugin.js +80 -128
  167. package/lib/plugins/DataSourcePlugin.js +45 -76
  168. package/lib/plugins/FeatureScalePlugin.js +67 -138
  169. package/lib/plugins/LayerAnimateStylePlugin.js +0 -10
  170. package/lib/plugins/LayerMaskPlugin.js +4 -17
  171. package/lib/plugins/LayerModelPlugin.js +68 -113
  172. package/lib/plugins/LayerStylePlugin.js +4 -14
  173. package/lib/plugins/LightingPlugin.js +12 -25
  174. package/lib/plugins/MultiPassRendererPlugin.js +11 -22
  175. package/lib/plugins/PixelPickingPlugin.js +12 -27
  176. package/lib/plugins/RegisterStyleAttributePlugin.js +5 -19
  177. package/lib/plugins/ShaderUniformPlugin.js +13 -34
  178. package/lib/plugins/UpdateModelPlugin.js +1 -10
  179. package/lib/plugins/UpdateStyleAttributePlugin.js +5 -16
  180. package/lib/point/index.js +26 -83
  181. package/lib/point/models/earthExtrude.js +61 -113
  182. package/lib/point/models/earthFill.js +57 -117
  183. package/lib/point/models/extrude.js +60 -111
  184. package/lib/point/models/fill.js +68 -109
  185. package/lib/point/models/fillmage.js +61 -115
  186. package/lib/point/models/image.js +48 -98
  187. package/lib/point/models/index.js +1 -12
  188. package/lib/point/models/normal.js +30 -64
  189. package/lib/point/models/radar.js +40 -74
  190. package/lib/point/models/simplePoint.js +41 -79
  191. package/lib/point/models/text.js +214 -303
  192. package/lib/point/shape/extrude.js +4 -20
  193. package/lib/polygon/index.js +11 -48
  194. package/lib/polygon/models/extrude.js +48 -103
  195. package/lib/polygon/models/fill.js +54 -98
  196. package/lib/polygon/models/index.js +2 -14
  197. package/lib/polygon/models/ocean.js +42 -88
  198. package/lib/polygon/models/water.js +37 -82
  199. package/lib/raster/buffers/triangulation.js +3 -7
  200. package/lib/raster/index.js +9 -40
  201. package/lib/raster/models/index.js +0 -5
  202. package/lib/raster/models/raster.js +80 -125
  203. package/lib/raster/models/rasterRgb.js +84 -139
  204. package/lib/raster/models/rasterTerrainRgb.js +56 -93
  205. package/lib/tile/interaction/getRasterData.js +14 -25
  206. package/lib/tile/interaction/utils.js +7 -19
  207. package/lib/tile/manager/base.js +63 -104
  208. package/lib/tile/service/TileLayerService.js +30 -57
  209. package/lib/tile/service/TilePickService.js +26 -48
  210. package/lib/tile/service/TileSourceService.js +2 -16
  211. package/lib/tile/style/utils.js +0 -3
  212. package/lib/tile/tileFactory/DebugTile.js +28 -53
  213. package/lib/tile/tileFactory/ImageTile.js +20 -46
  214. package/lib/tile/tileFactory/MaskTile.js +22 -51
  215. package/lib/tile/tileFactory/RasterRGBTile.js +22 -50
  216. package/lib/tile/tileFactory/RasterTerrainRGBTile.js +20 -46
  217. package/lib/tile/tileFactory/RasterTile.js +30 -63
  218. package/lib/tile/tileFactory/Tile.js +63 -102
  219. package/lib/tile/tileFactory/VectorTile.js +41 -76
  220. package/lib/tile/tileFactory/index.js +0 -25
  221. package/lib/tile/tileFactory/layers/TileDebugLayer.js +6 -32
  222. package/lib/tile/tileFactory/util.js +0 -9
  223. package/lib/tile/tileLayer/BaseLayer.js +105 -153
  224. package/lib/tile/utils.js +1 -5
  225. package/lib/utils/blend.js +0 -5
  226. package/lib/utils/collision-index.js +9 -25
  227. package/lib/utils/dataMappingStyle.js +8 -19
  228. package/lib/utils/extrude_polyline.js +101 -181
  229. package/lib/utils/grid-index.js +2 -28
  230. package/lib/utils/identityScale.js +0 -9
  231. package/lib/utils/layerData.js +30 -49
  232. package/lib/utils/multiPassRender.js +11 -16
  233. package/lib/utils/polylineNormal.js +31 -66
  234. package/lib/utils/simpleLine.js +2 -21
  235. package/lib/utils/stencil.js +0 -4
  236. package/lib/utils/symbol-layout.js +27 -55
  237. package/lib/wind/index.js +9 -37
  238. package/lib/wind/models/index.js +0 -3
  239. package/lib/wind/models/utils.js +26 -62
  240. package/lib/wind/models/wind.js +101 -157
  241. package/lib/wind/models/windRender.js +53 -71
  242. package/lib/wind/models/windShader.js +0 -1
  243. package/package.json +7 -7
@@ -3,50 +3,40 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
3
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
4
  import * as glUtils from "./utils";
5
5
  import { drawFrag, drawVert, fullScreenFrag, fullScreenVert, updateFrag, updateVert } from "./windShader";
6
-
7
6
  function getColorRamp(colors) {
8
7
  var canvas = document.createElement('canvas');
9
8
  var ctx = canvas.getContext('2d');
10
9
  canvas.width = 256;
11
10
  canvas.height = 1;
12
11
  var gradient = ctx.createLinearGradient(0, 0, 256, 0);
13
-
14
12
  for (var _i = 0, _Object$keys = Object.keys(colors); _i < _Object$keys.length; _i++) {
15
13
  var stop = _Object$keys[_i];
16
14
  gradient.addColorStop(+stop, colors[+stop]);
17
15
  }
18
-
19
16
  ctx.fillStyle = gradient;
20
- ctx.fillRect(0, 0, 256, 1); // @ts-ignore dispose canvas element
17
+ ctx.fillRect(0, 0, 256, 1);
21
18
 
19
+ // @ts-ignore dispose canvas element
22
20
  canvas = null;
23
21
  return new Uint8Array(ctx.getImageData(0, 0, 256, 1).data);
24
22
  }
25
-
26
23
  function bindAttribute(gl, buffer, attribute, numComponents) {
27
24
  gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
28
25
  gl.enableVertexAttribArray(attribute);
29
26
  gl.vertexAttribPointer(attribute, numComponents, gl.FLOAT, false, 0, 0);
30
27
  }
31
-
32
28
  function bindFramebuffer(gl, framebuffer, texture) {
33
29
  gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
34
-
35
30
  if (texture) {
36
31
  gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
37
32
  }
38
33
  }
39
-
40
34
  export var Wind = /*#__PURE__*/function () {
41
35
  function Wind(options) {
42
36
  _classCallCheck(this, Wind);
43
-
44
37
  _defineProperty(this, "width", 512);
45
-
46
38
  _defineProperty(this, "height", 512);
47
-
48
39
  _defineProperty(this, "numParticles", 65536);
49
-
50
40
  this.gl = options.glContext;
51
41
  this.width = options.imageWidth;
52
42
  this.height = options.imageHeight;
@@ -57,17 +47,13 @@ export var Wind = /*#__PURE__*/function () {
57
47
  this.rampColors = options.rampColors;
58
48
  this.init();
59
49
  }
60
-
61
50
  _createClass(Wind, [{
62
51
  key: "init",
63
52
  value: function init() {
64
53
  var gl = this.gl;
65
54
  this.fadeOpacity = 0.996; // how fast the particle trails fade on each frame
66
-
67
55
  this.speedFactor = 0.25; // how fast the particles move
68
-
69
56
  this.dropRate = 0.003; // how often the particles move to a random place
70
-
71
57
  this.dropRateBump = 0.01; // drop rate increase relative to individual particle speed
72
58
 
73
59
  this.drawProgram = glUtils.createProgram(gl, drawVert, drawFrag);
@@ -76,29 +62,28 @@ export var Wind = /*#__PURE__*/function () {
76
62
  this.quadBuffer = glUtils.createBuffer(gl, new Float32Array([0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1]));
77
63
  this.framebuffer = gl.createFramebuffer();
78
64
  this.colorRampTexture = glUtils.createTexture(this.gl, this.gl.LINEAR, getColorRamp(this.rampColors), 16, 16);
79
- var emptyPixels = new Uint8Array(this.width * this.height * 4); // screen textures to hold the drawn screen for the previous and the current frame
65
+ var emptyPixels = new Uint8Array(this.width * this.height * 4);
80
66
 
81
- this.backgroundTexture = glUtils.createTexture(gl, gl.NEAREST, emptyPixels, this.width, this.height);
82
- 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
67
+ // screen textures to hold the drawn screen for the previous and the current frame
83
68
 
84
- var particleRes = this.particleStateResolution = Math.ceil(Math.sqrt(this.numParticles)); // particleRes size
69
+ this.backgroundTexture = glUtils.createTexture(gl, gl.NEAREST, emptyPixels, this.width, this.height);
70
+ this.screenTexture = glUtils.createTexture(gl, gl.NEAREST, emptyPixels, this.width, this.height);
85
71
 
72
+ // we create a square texture where each pixel will hold a particle position encoded as RGBA
73
+ var particleRes = this.particleStateResolution = Math.ceil(Math.sqrt(this.numParticles));
74
+ // particleRes size
86
75
  this.numParticlesSize = particleRes * particleRes;
87
76
  var particleState = new Uint8Array(this.numParticlesSize * 4);
88
-
89
77
  for (var i = 0; i < particleState.length; i++) {
90
78
  particleState[i] = Math.floor(Math.random() * 256); // randomize the initial particle positions
91
- } // textures to hold the particle state for the current and the next frame
92
-
93
-
79
+ }
80
+ // textures to hold the particle state for the current and the next frame
94
81
  this.particleStateTexture0 = glUtils.createTexture(gl, gl.NEAREST, particleState, particleRes, particleRes);
95
82
  this.particleStateTexture1 = glUtils.createTexture(gl, gl.NEAREST, particleState, particleRes, particleRes);
96
83
  var particleIndices = new Float32Array(this.numParticlesSize);
97
-
98
84
  for (var i$1 = 0; i$1 < this.numParticlesSize; i$1++) {
99
85
  particleIndices[i$1] = i$1;
100
86
  }
101
-
102
87
  this.particleIndexBuffer = glUtils.createBuffer(gl, particleIndices);
103
88
  }
104
89
  }, {
@@ -107,40 +92,36 @@ export var Wind = /*#__PURE__*/function () {
107
92
  this.windData = windData;
108
93
  this.windTexture = glUtils.createDataTexture(this.gl, this.gl.LINEAR, windData.image);
109
94
  }
95
+
110
96
  /**
111
97
  * 更新风场粒子数量
112
98
  * @param num
113
99
  */
114
-
115
100
  }, {
116
101
  key: "updateParticelNum",
117
102
  value: function updateParticelNum(num) {
118
103
  var gl = this.gl;
119
-
120
104
  if (num !== this.numParticles) {
121
105
  this.numParticles = num; // params number
122
- // we create a square texture where each pixel will hold a particle position encoded as RGBA
123
106
 
107
+ // we create a square texture where each pixel will hold a particle position encoded as RGBA
124
108
  var particleRes = this.particleStateResolution = Math.ceil(Math.sqrt(this.numParticles));
125
109
  this.numParticlesSize = particleRes * particleRes;
126
110
  var particleState = new Uint8Array(this.numParticlesSize * 4);
127
-
128
111
  for (var i = 0; i < particleState.length; i++) {
129
112
  particleState[i] = Math.floor(Math.random() * 256); // randomize the initial particle positions
130
- } // textures to hold the particle state for the current and the next frame
131
-
132
-
113
+ }
114
+ // textures to hold the particle state for the current and the next frame
133
115
  this.particleStateTexture0 = glUtils.createTexture(gl, gl.NEAREST, particleState, particleRes, particleRes);
134
116
  this.particleStateTexture1 = glUtils.createTexture(gl, gl.NEAREST, particleState, particleRes, particleRes);
135
117
  var particleIndices = new Float32Array(this.numParticlesSize);
136
-
137
118
  for (var i$1 = 0; i$1 < this.numParticlesSize; i$1++) {
138
119
  particleIndices[i$1] = i$1;
139
120
  }
140
-
141
121
  this.particleIndexBuffer = glUtils.createBuffer(gl, particleIndices);
142
122
  }
143
123
  }
124
+
144
125
  /**
145
126
  * 更新风场风向风速
146
127
  * @param uMin
@@ -148,7 +129,6 @@ export var Wind = /*#__PURE__*/function () {
148
129
  * @param vMin
149
130
  * @param vMax
150
131
  */
151
-
152
132
  }, {
153
133
  key: "updateWindDir",
154
134
  value: function updateWindDir(uMin, uMax, vMin, vMax) {
@@ -157,11 +137,11 @@ export var Wind = /*#__PURE__*/function () {
157
137
  this.windData.vMin = vMin;
158
138
  this.windData.vMax = vMax;
159
139
  }
140
+
160
141
  /**
161
142
  * update rampColors
162
143
  * @param rampColors
163
144
  */
164
-
165
145
  }, {
166
146
  key: "updateColorRampTexture",
167
147
  value: function updateColorRampTexture(rampColors) {
@@ -176,23 +156,18 @@ export var Wind = /*#__PURE__*/function () {
176
156
  key: "isColorChanged",
177
157
  value: function isColorChanged(rampColors) {
178
158
  var keys = Object.keys(rampColors);
179
-
180
159
  for (var _i2 = 0, _keys = keys; _i2 < _keys.length; _i2++) {
181
160
  var item = _keys[_i2];
182
-
183
- var _key = Number(item); // exist new key -> color need update
184
-
185
-
161
+ var _key = Number(item);
162
+ // exist new key -> color need update
186
163
  if (!this.rampColors[_key]) {
187
164
  return true;
188
- } // value changed -> color need update
189
-
190
-
165
+ }
166
+ // value changed -> color need update
191
167
  if (this.rampColors[_key] && this.rampColors[_key] !== rampColors[_key]) {
192
168
  return true;
193
169
  }
194
170
  }
195
-
196
171
  return false;
197
172
  }
198
173
  }, {
@@ -204,8 +179,8 @@ export var Wind = /*#__PURE__*/function () {
204
179
  gl.deleteTexture(this.screenTexture);
205
180
  this.width = width;
206
181
  this.height = height;
207
- var emptyPixels = new Uint8Array(width * height * 4); // screen textures to hold the drawn screen for the previous and the current frame
208
-
182
+ var emptyPixels = new Uint8Array(width * height * 4);
183
+ // screen textures to hold the drawn screen for the previous and the current frame
209
184
  this.backgroundTexture = glUtils.createTexture(gl, gl.NEAREST, emptyPixels, width, height);
210
185
  this.screenTexture = glUtils.createTexture(gl, gl.NEAREST, emptyPixels, width, height);
211
186
  }
@@ -214,13 +189,11 @@ export var Wind = /*#__PURE__*/function () {
214
189
  key: "draw",
215
190
  value: function draw() {
216
191
  var _this$windData;
217
-
218
192
  if ((_this$windData = this.windData) !== null && _this$windData !== void 0 && _this$windData.image) {
219
193
  var gl = this.gl;
220
194
  glUtils.bindTexture(gl, this.windTexture, 0);
221
195
  glUtils.bindTexture(gl, this.particleStateTexture0, 1);
222
196
  this.drawScreen(); // draw Particles into framebuffer
223
-
224
197
  this.updateParticles();
225
198
  return {
226
199
  d: this.pixels,
@@ -238,8 +211,9 @@ export var Wind = /*#__PURE__*/function () {
238
211
  }, {
239
212
  key: "drawScreen",
240
213
  value: function drawScreen() {
241
- var gl = this.gl; // draw the screen into a temporary framebuffer to retain it as the background on the next frame
214
+ var gl = this.gl;
242
215
 
216
+ // draw the screen into a temporary framebuffer to retain it as the background on the next frame
243
217
  bindFramebuffer(gl, this.framebuffer, this.screenTexture);
244
218
  gl.viewport(0, 0, this.width, this.height);
245
219
  gl.disable(gl.BLEND);
@@ -248,8 +222,9 @@ export var Wind = /*#__PURE__*/function () {
248
222
  this.pixels = new Uint8Array(4 * this.width * this.height);
249
223
  gl.readPixels(0, 0, this.width, this.height, gl.RGBA, gl.UNSIGNED_BYTE, this.pixels);
250
224
  bindFramebuffer(gl, null, null);
251
- gl.viewport(0, 0, this.gl.canvas.width, this.gl.canvas.height); // save the current screen as the background for the next frame
225
+ gl.viewport(0, 0, this.gl.canvas.width, this.gl.canvas.height);
252
226
 
227
+ // save the current screen as the background for the next frame
253
228
  var temp = this.backgroundTexture;
254
229
  this.backgroundTexture = this.screenTexture;
255
230
  this.screenTexture = temp;
@@ -259,7 +234,9 @@ export var Wind = /*#__PURE__*/function () {
259
234
  value: function drawFullTexture(texture, opacity) {
260
235
  var gl = this.gl;
261
236
  var program = this.fullScreenProgram;
262
- gl.useProgram(program); // bindAttribute(gl, this.quadBuffer, program.a_pos, 2);
237
+ gl.useProgram(program);
238
+
239
+ // bindAttribute(gl, this.quadBuffer, program.a_pos, 2);
263
240
 
264
241
  gl.bindBuffer(gl.ARRAY_BUFFER, this.quadBuffer);
265
242
  gl.vertexAttribPointer(program.a_pos, 2, gl.FLOAT, false, 0, 0);
@@ -268,7 +245,8 @@ export var Wind = /*#__PURE__*/function () {
268
245
  glUtils.bindTexture(gl, texture, 2);
269
246
  gl.uniform1i(program.u_screen, 2);
270
247
  gl.uniform1f(program.u_opacity, opacity);
271
- gl.drawArrays(gl.TRIANGLES, 0, 6); // gl.drawArrays(gl.POINTS, 0, 6);
248
+ gl.drawArrays(gl.TRIANGLES, 0, 6);
249
+ // gl.drawArrays(gl.POINTS, 0, 6);
272
250
  }
273
251
  }, {
274
252
  key: "drawParticles",
@@ -304,12 +282,15 @@ export var Wind = /*#__PURE__*/function () {
304
282
  gl.uniform1f(program.u_speed_factor, this.speedFactor);
305
283
  gl.uniform1f(program.u_drop_rate, this.dropRate);
306
284
  gl.uniform1f(program.u_drop_rate_bump, this.dropRateBump);
307
- gl.drawArrays(gl.TRIANGLES, 0, 6); // swap the particle state textures so the new one becomes the current one
285
+ gl.drawArrays(gl.TRIANGLES, 0, 6);
308
286
 
287
+ // swap the particle state textures so the new one becomes the current one
309
288
  var temp = this.particleStateTexture0;
310
289
  this.particleStateTexture0 = this.particleStateTexture1;
311
290
  this.particleStateTexture1 = temp;
312
- bindFramebuffer(gl, null, null); // gl.viewport(0, 0, this.gl.canvas.width, this.gl.canvas.height);
291
+ bindFramebuffer(gl, null, null);
292
+
293
+ // gl.viewport(0, 0, this.gl.canvas.width, this.gl.canvas.height);
313
294
  }
314
295
  }, {
315
296
  key: "destroy",
@@ -317,31 +298,38 @@ export var Wind = /*#__PURE__*/function () {
317
298
  // private drawProgram: WebGLProgram;
318
299
  // private fullScreenProgram: WebGLProgram;
319
300
  // private updateProgram: WebGLProgram;
301
+
320
302
  // private quadBuffer: WebGLBuffer | null;
321
303
  // private particleIndexBuffer: WebGLBuffer | null;
304
+
322
305
  // private framebuffer: WebGLFramebuffer | null;
306
+
323
307
  // private colorRampTexture: WebGLTexture | null;
324
308
  // private backgroundTexture: WebGLTexture | null;
325
309
  // private screenTexture: WebGLTexture | null;
326
310
  // private particleStateTexture0: WebGLTexture | null;
327
311
  // private particleStateTexture1: WebGLTexture | null;
328
312
  // private windTexture: WebGLTexture | null;
313
+
329
314
  this.gl.deleteBuffer(this.quadBuffer);
330
315
  this.gl.deleteBuffer(this.particleIndexBuffer);
331
- this.gl.deleteFramebuffer(this.framebuffer); // @ts-ignore
332
-
333
- this.gl.deleteShader(this.drawProgram.vertexShader); // @ts-ignore
316
+ this.gl.deleteFramebuffer(this.framebuffer);
334
317
 
318
+ // @ts-ignore
319
+ this.gl.deleteShader(this.drawProgram.vertexShader);
320
+ // @ts-ignore
335
321
  this.gl.deleteShader(this.drawProgram.fragmentShader);
336
- this.gl.deleteProgram(this.drawProgram); // @ts-ignore
337
-
338
- this.gl.deleteShader(this.fullScreenProgram.vertexShader); // @ts-ignore
322
+ this.gl.deleteProgram(this.drawProgram);
339
323
 
324
+ // @ts-ignore
325
+ this.gl.deleteShader(this.fullScreenProgram.vertexShader);
326
+ // @ts-ignore
340
327
  this.gl.deleteShader(this.fullScreenProgram.fragmentShader);
341
- this.gl.deleteProgram(this.fullScreenProgram); // @ts-ignore
342
-
343
- this.gl.deleteShader(this.updateProgram.vertexShader); // @ts-ignore
328
+ this.gl.deleteProgram(this.fullScreenProgram);
344
329
 
330
+ // @ts-ignore
331
+ this.gl.deleteShader(this.updateProgram.vertexShader);
332
+ // @ts-ignore
345
333
  this.gl.deleteShader(this.updateProgram.fragmentShader);
346
334
  this.gl.deleteProgram(this.updateProgram);
347
335
  this.gl.deleteTexture(this.colorRampTexture);
@@ -352,6 +340,5 @@ export var Wind = /*#__PURE__*/function () {
352
340
  this.gl.deleteTexture(this.windTexture);
353
341
  }
354
342
  }]);
355
-
356
343
  return Wind;
357
344
  }();
@@ -1,52 +1,32 @@
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 _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
19
-
20
13
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
21
-
22
14
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
23
-
24
15
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
25
-
26
16
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
27
-
28
17
  var _BaseLayer2 = _interopRequireDefault(require("../core/BaseLayer"));
29
-
30
18
  var _models = _interopRequireDefault(require("./models"));
31
-
32
19
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
33
-
34
20
  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; } }
35
-
36
21
  var GeometryLayer = /*#__PURE__*/function (_BaseLayer) {
37
22
  (0, _inherits2.default)(GeometryLayer, _BaseLayer);
38
-
39
23
  var _super = _createSuper(GeometryLayer);
40
-
41
24
  function GeometryLayer() {
42
25
  var _this;
43
-
44
26
  (0, _classCallCheck2.default)(this, GeometryLayer);
45
-
46
27
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
47
28
  args[_key] = arguments[_key];
48
29
  }
49
-
50
30
  _this = _super.call.apply(_super, [this].concat(args));
51
31
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "type", 'GeometryLayer');
52
32
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "defaultSourceConfig", {
@@ -64,33 +44,27 @@ var GeometryLayer = /*#__PURE__*/function (_BaseLayer) {
64
44
  });
65
45
  return _this;
66
46
  }
67
-
68
47
  (0, _createClass2.default)(GeometryLayer, [{
69
48
  key: "buildModels",
70
49
  value: function () {
71
50
  var _buildModels = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
72
51
  var modelType;
73
52
  return _regenerator.default.wrap(function _callee$(_context) {
74
- while (1) {
75
- switch (_context.prev = _context.next) {
76
- case 0:
77
- modelType = this.getModelType();
78
- this.layerModel = new _models.default[modelType](this);
79
- _context.next = 4;
80
- return this.initLayerModels();
81
-
82
- case 4:
83
- case "end":
84
- return _context.stop();
85
- }
53
+ while (1) switch (_context.prev = _context.next) {
54
+ case 0:
55
+ modelType = this.getModelType();
56
+ this.layerModel = new _models.default[modelType](this);
57
+ _context.next = 4;
58
+ return this.initLayerModels();
59
+ case 4:
60
+ case "end":
61
+ return _context.stop();
86
62
  }
87
63
  }, _callee, this);
88
64
  }));
89
-
90
65
  function buildModels() {
91
66
  return _buildModels.apply(this, arguments);
92
67
  }
93
-
94
68
  return buildModels;
95
69
  }()
96
70
  }, {
@@ -108,10 +82,8 @@ var GeometryLayer = /*#__PURE__*/function (_BaseLayer) {
108
82
  key: "getModelType",
109
83
  value: function getModelType() {
110
84
  var _shapeAttribute$scale;
111
-
112
85
  var shapeAttribute = this.styleAttributeService.getLayerStyleAttribute('shape');
113
86
  var shape = shapeAttribute === null || shapeAttribute === void 0 ? void 0 : (_shapeAttribute$scale = shapeAttribute.scale) === null || _shapeAttribute$scale === void 0 ? void 0 : _shapeAttribute$scale.field;
114
-
115
87
  if (shape === 'plane') {
116
88
  return 'plane';
117
89
  } else if (shape === 'sprite') {
@@ -125,5 +97,4 @@ var GeometryLayer = /*#__PURE__*/function (_BaseLayer) {
125
97
  }]);
126
98
  return GeometryLayer;
127
99
  }(_BaseLayer2.default);
128
-
129
100
  exports.default = GeometryLayer;