@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.
- package/es/Geometry/index.js +31 -9
- package/es/Geometry/models/billboard.js +89 -51
- package/es/Geometry/models/plane.js +143 -81
- package/es/Geometry/models/sprite.js +118 -60
- package/es/canvas/index.js +33 -10
- package/es/canvas/models/canvas.js +97 -41
- package/es/citybuliding/building.js +27 -8
- package/es/citybuliding/models/build.js +82 -57
- package/es/core/BaseLayer.js +478 -313
- package/es/core/BaseModel.js +80 -51
- package/es/core/CommonStyleAttribute.js +5 -2
- package/es/core/LayerPickService.js +32 -21
- package/es/core/TextureService.js +13 -0
- package/es/core/interface.js +24 -17
- package/es/core/shape/Path.js +20 -13
- package/es/core/shape/extrude.js +39 -27
- package/es/core/triangulation.js +136 -99
- package/es/earth/index.js +33 -9
- package/es/earth/models/atmosphere.js +54 -30
- package/es/earth/models/base.js +85 -47
- package/es/earth/models/bloomsphere.js +54 -30
- package/es/earth/utils.js +13 -9
- package/es/heatmap/index.js +40 -10
- package/es/heatmap/models/grid.js +52 -28
- package/es/heatmap/models/grid3d.js +52 -28
- package/es/heatmap/models/heatmap.js +149 -92
- package/es/heatmap/models/hexagon.js +52 -28
- package/es/heatmap/triangulation.js +4 -0
- package/es/image/index.js +28 -9
- package/es/image/models/image.js +100 -66
- package/es/index.js +17 -9
- package/es/line/index.js +35 -9
- package/es/line/models/arc.js +114 -64
- package/es/line/models/arc_3d.js +102 -58
- package/es/line/models/earthArc_3d.js +105 -60
- package/es/line/models/flow.js +60 -36
- package/es/line/models/great_circle.js +94 -53
- package/es/line/models/line.js +138 -86
- package/es/line/models/linearline.js +76 -43
- package/es/line/models/simpleLine.js +69 -39
- package/es/line/models/wall.js +92 -52
- package/es/mask/index.js +28 -9
- package/es/mask/models/fill.js +54 -29
- package/es/plugins/DataMappingPlugin.js +114 -78
- package/es/plugins/DataSourcePlugin.js +68 -45
- package/es/plugins/FeatureScalePlugin.js +122 -67
- package/es/plugins/LayerAnimateStylePlugin.js +5 -0
- package/es/plugins/LayerMaskPlugin.js +11 -3
- package/es/plugins/LayerModelPlugin.js +108 -69
- package/es/plugins/LayerStylePlugin.js +9 -3
- package/es/plugins/LightingPlugin.js +18 -12
- package/es/plugins/MultiPassRendererPlugin.js +16 -11
- package/es/plugins/PixelPickingPlugin.js +21 -12
- package/es/plugins/RegisterStyleAttributePlugin.js +12 -5
- package/es/plugins/ShaderUniformPlugin.js +27 -13
- package/es/plugins/UpdateModelPlugin.js +5 -0
- package/es/plugins/UpdateStyleAttributePlugin.js +11 -5
- package/es/point/index.js +78 -26
- package/es/point/models/earthExtrude.js +95 -58
- package/es/point/models/earthFill.js +80 -52
- package/es/point/models/extrude.js +94 -57
- package/es/point/models/fill.js +81 -56
- package/es/point/models/fillmage.js +100 -60
- package/es/point/models/image.js +83 -47
- package/es/point/models/index.js +2 -2
- package/es/point/models/normal.js +54 -30
- package/es/point/models/radar.js +63 -38
- package/es/point/models/simplePoint.js +62 -38
- package/es/point/models/text.js +296 -199
- package/es/point/shape/extrude.js +13 -4
- package/es/polygon/index.js +41 -11
- package/es/polygon/models/extrude.js +135 -87
- package/es/polygon/models/fill.js +79 -50
- package/es/polygon/models/index.js +2 -3
- package/es/polygon/models/ocean.js +76 -42
- package/es/polygon/models/water.js +71 -37
- package/es/raster/buffers/triangulation.js +4 -2
- package/es/raster/index.js +32 -9
- package/es/raster/models/raster.js +116 -80
- package/es/raster/models/rasterRgb.js +127 -84
- package/es/raster/models/rasterTerrainRgb.js +84 -56
- package/es/tile/interaction/getRasterData.js +20 -14
- package/es/tile/interaction/utils.js +9 -7
- package/es/tile/manager/base.js +96 -63
- package/es/tile/service/TileLayerService.js +55 -33
- package/es/tile/service/TilePickService.js +40 -26
- package/es/tile/service/TileSourceService.js +7 -3
- package/es/tile/tileFactory/DebugTile.js +46 -29
- package/es/tile/tileFactory/ImageTile.js +38 -20
- package/es/tile/tileFactory/MaskTile.js +43 -22
- package/es/tile/tileFactory/RasterRGBTile.js +42 -22
- package/es/tile/tileFactory/RasterTerrainRGBTile.js +38 -20
- package/es/tile/tileFactory/RasterTile.js +53 -30
- package/es/tile/tileFactory/Tile.js +97 -63
- package/es/tile/tileFactory/VectorTile.js +68 -41
- package/es/tile/tileFactory/index.js +11 -0
- package/es/tile/tileFactory/layers/TileDebugLayer.js +27 -6
- package/es/tile/tileFactory/util.js +3 -0
- package/es/tile/tileLayer/BaseLayer.js +146 -105
- package/es/tile/utils.js +1 -1
- package/es/utils/blend.js +2 -0
- package/es/utils/collision-index.js +16 -9
- package/es/utils/extrude_polyline.js +149 -101
- package/es/utils/grid-index.js +27 -2
- package/es/utils/identityScale.js +8 -0
- package/es/utils/layerData.js +44 -30
- package/es/utils/multiPassRender.js +13 -11
- package/es/utils/polylineNormal.js +37 -31
- package/es/utils/simpleLine.js +16 -2
- package/es/utils/stencil.js +3 -2
- package/es/utils/symbol-layout.js +53 -27
- package/es/wind/index.js +29 -9
- package/es/wind/models/utils.js +51 -26
- package/es/wind/models/wind.js +147 -101
- package/es/wind/models/windRender.js +66 -53
- package/lib/Geometry/index.js +38 -9
- package/lib/Geometry/models/billboard.js +97 -51
- package/lib/Geometry/models/index.js +5 -0
- package/lib/Geometry/models/plane.js +151 -79
- package/lib/Geometry/models/sprite.js +127 -60
- package/lib/canvas/index.js +40 -10
- package/lib/canvas/models/canvas.js +101 -41
- package/lib/canvas/models/index.js +3 -0
- package/lib/citybuliding/building.js +35 -8
- package/lib/citybuliding/models/build.js +92 -57
- package/lib/core/BaseLayer.js +469 -313
- package/lib/core/BaseModel.js +90 -51
- package/lib/core/CommonStyleAttribute.js +7 -2
- package/lib/core/LayerPickService.js +37 -21
- package/lib/core/TextureService.js +16 -0
- package/lib/core/interface.js +31 -21
- package/lib/core/schema.js +1 -0
- package/lib/core/shape/Path.js +31 -14
- package/lib/core/shape/extrude.js +62 -27
- package/lib/core/triangulation.js +177 -98
- package/lib/earth/index.js +43 -9
- package/lib/earth/models/atmosphere.js +63 -30
- package/lib/earth/models/base.js +90 -47
- package/lib/earth/models/bloomsphere.js +63 -30
- package/lib/earth/utils.js +31 -7
- package/lib/heatmap/index.js +48 -10
- package/lib/heatmap/models/grid.js +60 -28
- package/lib/heatmap/models/grid3d.js +60 -28
- package/lib/heatmap/models/heatmap.js +166 -92
- package/lib/heatmap/models/hexagon.js +60 -28
- package/lib/heatmap/models/index.js +6 -0
- package/lib/heatmap/triangulation.js +5 -0
- package/lib/image/index.js +36 -9
- package/lib/image/models/image.js +109 -66
- package/lib/image/models/index.js +3 -0
- package/lib/index.js +61 -7
- package/lib/line/index.js +40 -9
- package/lib/line/models/arc.js +124 -62
- package/lib/line/models/arc_3d.js +113 -56
- package/lib/line/models/earthArc_3d.js +115 -58
- package/lib/line/models/flow.js +70 -36
- package/lib/line/models/great_circle.js +104 -53
- package/lib/line/models/index.js +11 -0
- package/lib/line/models/line.js +146 -84
- package/lib/line/models/linearline.js +88 -43
- package/lib/line/models/simpleLine.js +79 -39
- package/lib/line/models/wall.js +103 -52
- package/lib/mask/index.js +36 -9
- package/lib/mask/models/fill.js +63 -29
- package/lib/mask/models/index.js +3 -0
- package/lib/plugins/DataMappingPlugin.js +125 -78
- package/lib/plugins/DataSourcePlugin.js +76 -45
- package/lib/plugins/FeatureScalePlugin.js +138 -67
- package/lib/plugins/LayerAnimateStylePlugin.js +10 -0
- package/lib/plugins/LayerMaskPlugin.js +17 -4
- package/lib/plugins/LayerModelPlugin.js +117 -70
- package/lib/plugins/LayerStylePlugin.js +14 -4
- package/lib/plugins/LightingPlugin.js +25 -12
- package/lib/plugins/MultiPassRendererPlugin.js +22 -11
- package/lib/plugins/PixelPickingPlugin.js +27 -12
- package/lib/plugins/RegisterStyleAttributePlugin.js +19 -5
- package/lib/plugins/ShaderUniformPlugin.js +34 -13
- package/lib/plugins/UpdateModelPlugin.js +10 -1
- package/lib/plugins/UpdateStyleAttributePlugin.js +16 -5
- package/lib/point/index.js +83 -26
- package/lib/point/models/earthExtrude.js +106 -58
- package/lib/point/models/earthFill.js +110 -52
- package/lib/point/models/extrude.js +103 -57
- package/lib/point/models/fill.js +90 -54
- package/lib/point/models/fillmage.js +107 -58
- package/lib/point/models/image.js +92 -47
- package/lib/point/models/index.js +12 -1
- package/lib/point/models/normal.js +64 -30
- package/lib/point/models/radar.js +72 -38
- package/lib/point/models/simplePoint.js +72 -38
- package/lib/point/models/text.js +305 -199
- package/lib/point/shape/extrude.js +20 -4
- package/lib/polygon/index.js +48 -11
- package/lib/polygon/models/extrude.js +146 -87
- package/lib/polygon/models/fill.js +89 -50
- package/lib/polygon/models/index.js +14 -2
- package/lib/polygon/models/ocean.js +88 -42
- package/lib/polygon/models/water.js +82 -37
- package/lib/raster/buffers/triangulation.js +7 -3
- package/lib/raster/index.js +40 -9
- package/lib/raster/models/index.js +5 -0
- package/lib/raster/models/raster.js +125 -80
- package/lib/raster/models/rasterRgb.js +139 -84
- package/lib/raster/models/rasterTerrainRgb.js +93 -56
- package/lib/tile/interaction/getRasterData.js +25 -14
- package/lib/tile/interaction/utils.js +19 -7
- package/lib/tile/manager/base.js +104 -63
- package/lib/tile/service/TileLayerService.js +60 -33
- package/lib/tile/service/TilePickService.js +48 -26
- package/lib/tile/service/TileSourceService.js +16 -2
- package/lib/tile/style/utils.js +3 -0
- package/lib/tile/tileFactory/DebugTile.js +54 -29
- package/lib/tile/tileFactory/ImageTile.js +46 -20
- package/lib/tile/tileFactory/MaskTile.js +51 -22
- package/lib/tile/tileFactory/RasterRGBTile.js +50 -22
- package/lib/tile/tileFactory/RasterTerrainRGBTile.js +46 -20
- package/lib/tile/tileFactory/RasterTile.js +63 -30
- package/lib/tile/tileFactory/Tile.js +102 -63
- package/lib/tile/tileFactory/VectorTile.js +76 -41
- package/lib/tile/tileFactory/index.js +25 -0
- package/lib/tile/tileFactory/layers/TileDebugLayer.js +32 -6
- package/lib/tile/tileFactory/util.js +9 -0
- package/lib/tile/tileLayer/BaseLayer.js +153 -105
- package/lib/tile/utils.js +5 -1
- package/lib/utils/blend.js +5 -0
- package/lib/utils/collision-index.js +25 -9
- package/lib/utils/extrude_polyline.js +181 -101
- package/lib/utils/grid-index.js +28 -2
- package/lib/utils/identityScale.js +9 -0
- package/lib/utils/layerData.js +49 -30
- package/lib/utils/multiPassRender.js +16 -11
- package/lib/utils/polylineNormal.js +66 -31
- package/lib/utils/simpleLine.js +21 -2
- package/lib/utils/stencil.js +4 -0
- package/lib/utils/symbol-layout.js +55 -27
- package/lib/wind/index.js +37 -9
- package/lib/wind/models/index.js +3 -0
- package/lib/wind/models/utils.js +62 -26
- package/lib/wind/models/wind.js +157 -101
- package/lib/wind/models/windRender.js +71 -53
- package/lib/wind/models/windShader.js +1 -0
- 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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
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.
|
|
31
|
-
"@antv/l7-maps": "2.17.
|
|
32
|
-
"@antv/l7-source": "2.17.
|
|
33
|
-
"@antv/l7-utils": "2.17.
|
|
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.
|
|
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": "
|
|
65
|
+
"gitHead": "f6a09dc02ed0fc7a7f5dc44b231105f43b26f67b",
|
|
66
66
|
"publishConfig": {
|
|
67
67
|
"access": "public"
|
|
68
68
|
}
|