@antv/l7-layers 2.15.2 → 2.15.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 +9 -31
- package/es/Geometry/models/billboard.js +51 -89
- package/es/Geometry/models/plane.js +81 -143
- package/es/Geometry/models/sprite.js +60 -118
- package/es/canvas/index.js +10 -33
- package/es/canvas/models/canvas.js +41 -97
- package/es/citybuliding/building.js +8 -27
- package/es/citybuliding/models/build.js +57 -82
- package/es/core/BaseLayer.js +320 -484
- package/es/core/BaseModel.js +97 -126
- package/es/core/LayerPickService.js +21 -32
- package/es/core/TextureService.js +0 -13
- package/es/core/interface.js +17 -24
- package/es/core/shape/Path.js +13 -20
- package/es/core/shape/extrude.js +10 -31
- package/es/core/triangulation.js +54 -114
- package/es/earth/index.js +9 -33
- package/es/earth/models/atmosphere.js +30 -54
- package/es/earth/models/base.js +47 -85
- package/es/earth/models/bloomsphere.js +30 -54
- package/es/earth/utils.js +9 -13
- package/es/heatmap/index.js +10 -40
- package/es/heatmap/models/grid.js +28 -52
- package/es/heatmap/models/grid3d.js +28 -52
- package/es/heatmap/models/heatmap.js +91 -146
- package/es/heatmap/models/hexagon.js +28 -52
- package/es/heatmap/triangulation.js +0 -4
- package/es/image/index.js +9 -28
- package/es/image/models/image.js +66 -100
- package/es/index.js +9 -17
- package/es/line/index.js +9 -34
- package/es/line/models/arc.js +66 -118
- package/es/line/models/arc_3d.js +60 -108
- package/es/line/models/earthArc_3d.js +63 -111
- package/es/line/models/great_circle.js +56 -100
- package/es/line/models/half.js +46 -77
- package/es/line/models/line.js +94 -148
- package/es/line/models/linearline.js +45 -80
- package/es/line/models/simpleLine.js +41 -74
- package/es/line/models/wall.js +52 -92
- package/es/mask/index.js +9 -28
- package/es/mask/models/fill.js +29 -54
- package/es/plugins/DataMappingPlugin.js +80 -117
- package/es/plugins/DataSourcePlugin.js +45 -68
- package/es/plugins/FeatureScalePlugin.js +67 -122
- package/es/plugins/LayerAnimateStylePlugin.js +0 -5
- package/es/plugins/LayerMaskPlugin.js +3 -11
- package/es/plugins/LayerModelPlugin.js +67 -104
- package/es/plugins/LayerStylePlugin.js +3 -9
- package/es/plugins/LightingPlugin.js +12 -18
- package/es/plugins/MultiPassRendererPlugin.js +11 -16
- package/es/plugins/PixelPickingPlugin.js +12 -21
- package/es/plugins/RegisterStyleAttributePlugin.js +5 -12
- package/es/plugins/ShaderUniformPlugin.js +13 -27
- package/es/plugins/UpdateModelPlugin.js +0 -5
- package/es/plugins/UpdateStyleAttributePlugin.js +5 -11
- package/es/point/index.js +26 -77
- package/es/point/models/earthExtrude.js +61 -102
- package/es/point/models/earthFill.js +57 -87
- package/es/point/models/extrude.js +60 -101
- package/es/point/models/fill.js +70 -100
- package/es/point/models/fillmage.js +63 -107
- package/es/point/models/image.js +48 -88
- package/es/point/models/index.js +2 -2
- package/es/point/models/normal.js +30 -54
- package/es/point/models/radar.js +40 -64
- package/es/point/models/simplePoint.js +41 -69
- package/es/point/models/text.js +197 -299
- package/es/point/shape/extrude.js +4 -13
- package/es/polygon/index.js +11 -40
- package/es/polygon/models/extrude.js +48 -92
- package/es/polygon/models/fill.js +54 -88
- package/es/polygon/models/index.js +3 -2
- package/es/polygon/models/ocean.js +42 -76
- package/es/polygon/models/water.js +37 -71
- package/es/raster/buffers/triangulation.js +2 -4
- package/es/raster/index.js +9 -32
- package/es/raster/models/raster.js +80 -116
- package/es/raster/models/rasterRgb.js +84 -127
- package/es/raster/models/rasterTerrainRgb.js +56 -84
- package/es/tile/interaction/getRasterData.js +14 -20
- package/es/tile/interaction/utils.js +7 -9
- package/es/tile/manager/base.js +63 -96
- package/es/tile/service/TileLayerService.js +30 -52
- package/es/tile/service/TilePickService.js +26 -40
- package/es/tile/service/TileSourceService.js +3 -7
- package/es/tile/tileFactory/DebugTile.js +28 -45
- package/es/tile/tileFactory/ImageTile.js +20 -38
- package/es/tile/tileFactory/MaskTile.js +22 -43
- package/es/tile/tileFactory/RasterRGBTile.js +22 -42
- package/es/tile/tileFactory/RasterTerrainRGBTile.js +20 -38
- package/es/tile/tileFactory/RasterTile.js +30 -53
- package/es/tile/tileFactory/Tile.js +63 -97
- package/es/tile/tileFactory/VectorTile.js +41 -68
- package/es/tile/tileFactory/index.js +0 -11
- package/es/tile/tileFactory/layers/TileDebugLayer.js +6 -27
- package/es/tile/tileFactory/util.js +0 -3
- package/es/tile/tileLayer/BaseLayer.js +105 -146
- package/es/tile/utils.js +1 -1
- package/es/utils/blend.js +0 -2
- package/es/utils/collision-index.js +9 -16
- package/es/utils/dataMappingStyle.js +8 -18
- package/es/utils/extrude_polyline.js +101 -149
- package/es/utils/grid-index.js +2 -27
- package/es/utils/identityScale.js +0 -8
- package/es/utils/layerData.js +30 -44
- package/es/utils/multiPassRender.js +11 -13
- package/es/utils/polylineNormal.js +31 -37
- package/es/utils/simpleLine.js +2 -16
- package/es/utils/stencil.js +2 -3
- package/es/utils/symbol-layout.js +27 -53
- package/es/wind/index.js +9 -29
- package/es/wind/models/utils.js +26 -51
- package/es/wind/models/wind.js +101 -147
- package/es/wind/models/windRender.js +53 -66
- package/lib/Geometry/index.js +9 -38
- package/lib/Geometry/models/billboard.js +51 -97
- package/lib/Geometry/models/index.js +0 -5
- package/lib/Geometry/models/plane.js +79 -151
- package/lib/Geometry/models/sprite.js +60 -127
- package/lib/canvas/index.js +10 -40
- package/lib/canvas/models/canvas.js +41 -101
- package/lib/canvas/models/index.js +0 -3
- package/lib/citybuliding/building.js +8 -35
- package/lib/citybuliding/models/build.js +57 -92
- package/lib/core/BaseLayer.js +320 -478
- package/lib/core/BaseModel.js +97 -139
- package/lib/core/LayerPickService.js +21 -37
- package/lib/core/TextureService.js +0 -16
- package/lib/core/interface.js +21 -31
- package/lib/core/schema.js +0 -1
- package/lib/core/shape/Path.js +14 -31
- package/lib/core/shape/extrude.js +10 -54
- package/lib/core/triangulation.js +53 -153
- package/lib/earth/index.js +9 -43
- package/lib/earth/models/atmosphere.js +30 -63
- package/lib/earth/models/base.js +47 -90
- package/lib/earth/models/bloomsphere.js +30 -63
- package/lib/earth/utils.js +7 -31
- package/lib/heatmap/index.js +10 -48
- package/lib/heatmap/models/grid.js +28 -60
- package/lib/heatmap/models/grid3d.js +28 -60
- package/lib/heatmap/models/heatmap.js +91 -162
- package/lib/heatmap/models/hexagon.js +28 -60
- package/lib/heatmap/models/index.js +0 -6
- package/lib/heatmap/triangulation.js +0 -5
- package/lib/image/index.js +9 -36
- package/lib/image/models/image.js +66 -109
- package/lib/image/models/index.js +0 -3
- package/lib/index.js +7 -61
- package/lib/line/index.js +9 -40
- package/lib/line/models/arc.js +64 -128
- package/lib/line/models/arc_3d.js +58 -119
- package/lib/line/models/earthArc_3d.js +61 -122
- package/lib/line/models/great_circle.js +56 -111
- package/lib/line/models/half.js +46 -87
- package/lib/line/models/index.js +0 -11
- package/lib/line/models/line.js +92 -156
- package/lib/line/models/linearline.js +45 -92
- package/lib/line/models/simpleLine.js +41 -84
- package/lib/line/models/wall.js +52 -103
- package/lib/mask/index.js +9 -36
- package/lib/mask/models/fill.js +29 -63
- package/lib/mask/models/index.js +0 -3
- package/lib/plugins/DataMappingPlugin.js +80 -128
- package/lib/plugins/DataSourcePlugin.js +45 -76
- package/lib/plugins/FeatureScalePlugin.js +67 -138
- package/lib/plugins/LayerAnimateStylePlugin.js +0 -10
- package/lib/plugins/LayerMaskPlugin.js +4 -17
- package/lib/plugins/LayerModelPlugin.js +68 -113
- package/lib/plugins/LayerStylePlugin.js +4 -14
- package/lib/plugins/LightingPlugin.js +12 -25
- package/lib/plugins/MultiPassRendererPlugin.js +11 -22
- package/lib/plugins/PixelPickingPlugin.js +12 -27
- package/lib/plugins/RegisterStyleAttributePlugin.js +5 -19
- package/lib/plugins/ShaderUniformPlugin.js +13 -34
- package/lib/plugins/UpdateModelPlugin.js +1 -10
- package/lib/plugins/UpdateStyleAttributePlugin.js +5 -16
- package/lib/point/index.js +26 -83
- package/lib/point/models/earthExtrude.js +61 -113
- package/lib/point/models/earthFill.js +57 -117
- package/lib/point/models/extrude.js +60 -111
- package/lib/point/models/fill.js +68 -109
- package/lib/point/models/fillmage.js +61 -115
- package/lib/point/models/image.js +48 -98
- package/lib/point/models/index.js +1 -12
- package/lib/point/models/normal.js +30 -64
- package/lib/point/models/radar.js +40 -74
- package/lib/point/models/simplePoint.js +41 -79
- package/lib/point/models/text.js +197 -307
- package/lib/point/shape/extrude.js +4 -20
- package/lib/polygon/index.js +11 -48
- package/lib/polygon/models/extrude.js +48 -103
- package/lib/polygon/models/fill.js +54 -98
- package/lib/polygon/models/index.js +2 -14
- package/lib/polygon/models/ocean.js +42 -88
- package/lib/polygon/models/water.js +37 -82
- package/lib/raster/buffers/triangulation.js +3 -7
- package/lib/raster/index.js +9 -40
- package/lib/raster/models/index.js +0 -5
- package/lib/raster/models/raster.js +80 -125
- package/lib/raster/models/rasterRgb.js +84 -139
- package/lib/raster/models/rasterTerrainRgb.js +56 -93
- package/lib/tile/interaction/getRasterData.js +14 -25
- package/lib/tile/interaction/utils.js +7 -19
- package/lib/tile/manager/base.js +63 -104
- package/lib/tile/service/TileLayerService.js +30 -57
- package/lib/tile/service/TilePickService.js +26 -48
- package/lib/tile/service/TileSourceService.js +2 -16
- package/lib/tile/style/utils.js +0 -3
- package/lib/tile/tileFactory/DebugTile.js +28 -53
- package/lib/tile/tileFactory/ImageTile.js +20 -46
- package/lib/tile/tileFactory/MaskTile.js +22 -51
- package/lib/tile/tileFactory/RasterRGBTile.js +22 -50
- package/lib/tile/tileFactory/RasterTerrainRGBTile.js +20 -46
- package/lib/tile/tileFactory/RasterTile.js +30 -63
- package/lib/tile/tileFactory/Tile.js +63 -102
- package/lib/tile/tileFactory/VectorTile.js +41 -76
- package/lib/tile/tileFactory/index.js +0 -25
- package/lib/tile/tileFactory/layers/TileDebugLayer.js +6 -32
- package/lib/tile/tileFactory/util.js +0 -9
- package/lib/tile/tileLayer/BaseLayer.js +105 -153
- package/lib/tile/utils.js +1 -5
- package/lib/utils/blend.js +0 -5
- package/lib/utils/collision-index.js +9 -25
- package/lib/utils/dataMappingStyle.js +8 -19
- package/lib/utils/extrude_polyline.js +101 -181
- package/lib/utils/grid-index.js +2 -28
- package/lib/utils/identityScale.js +0 -9
- package/lib/utils/layerData.js +30 -49
- package/lib/utils/multiPassRender.js +11 -16
- package/lib/utils/polylineNormal.js +31 -66
- package/lib/utils/simpleLine.js +2 -21
- package/lib/utils/stencil.js +0 -4
- package/lib/utils/symbol-layout.js +27 -55
- package/lib/wind/index.js +9 -37
- package/lib/wind/models/index.js +0 -3
- package/lib/wind/models/utils.js +26 -62
- package/lib/wind/models/wind.js +101 -157
- package/lib/wind/models/windRender.js +53 -71
- package/lib/wind/models/windShader.js +0 -1
- 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);
|
|
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);
|
|
65
|
+
var emptyPixels = new Uint8Array(this.width * this.height * 4);
|
|
80
66
|
|
|
81
|
-
|
|
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
|
-
|
|
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
|
-
}
|
|
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
|
-
}
|
|
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
|
-
|
|
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
|
-
}
|
|
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);
|
|
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;
|
|
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);
|
|
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);
|
|
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);
|
|
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);
|
|
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);
|
|
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);
|
|
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);
|
|
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);
|
|
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
|
}();
|
package/lib/Geometry/index.js
CHANGED
|
@@ -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
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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;
|