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