@antv/l7-layers 2.9.23 → 2.9.25
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/models/plane.d.ts +1 -0
- package/es/citybuliding/building.js +1 -1
- package/es/core/BaseLayer.js +10 -3
- package/es/core/interface.d.ts +26 -48
- package/es/core/interface.js +3 -0
- package/es/core/schema.d.ts +3 -3
- package/es/core/triangulation.d.ts +4 -3
- package/es/core/triangulation.js +54 -39
- package/es/heatmap/models/heatmap.js +1 -1
- package/es/image/models/image.js +7 -1
- package/es/line/index.js +4 -1
- package/es/line/models/arc.js +1 -1
- package/es/line/models/simpleLine.js +1 -1
- package/es/line/shaders/line_arc_vert.glsl +5 -3
- package/es/line/shaders/simple/simpleline_vert.glsl +1 -0
- package/es/plugins/FeatureScalePlugin.js +0 -1
- package/es/point/index.js +3 -1
- package/es/point/models/fill.js +5 -2
- package/es/point/models/fillmage.js +9 -3
- package/es/point/models/image.js +8 -2
- package/es/point/models/radar.js +2 -3
- package/es/point/models/tile.js +1 -1
- package/es/point/shaders/fill_vert.glsl +13 -6
- package/es/point/shaders/image/fillImage_vert.glsl +13 -5
- package/es/point/shaders/image_vert.glsl +17 -8
- package/es/polygon/index.js +4 -1
- package/es/raster/index.js +3 -1
- package/es/tile/manager/tileLayerManager.d.ts +3 -2
- package/es/tile/manager/tileLayerManager.js +5 -2
- package/es/tile/models/tileModel.js +4 -3
- package/es/tile/tileFactory/base.d.ts +1 -1
- package/es/tile/tileFactory/base.js +32 -5
- package/es/tile/tileFactory/vectorLayer.d.ts +3 -1
- package/es/tile/tileFactory/vectorLayer.js +22 -1
- package/es/tile/tileLayer/baseTileLayer.d.ts +1 -1
- package/es/tile/tileLayer/baseTileLayer.js +3 -2
- package/es/tile/utils.d.ts +2 -0
- package/es/tile/utils.js +5 -1
- package/lib/Geometry/index.js +114 -77
- package/lib/Geometry/models/billboard.js +232 -181
- package/lib/Geometry/models/index.js +18 -34
- package/lib/Geometry/models/plane.js +407 -278
- package/lib/Geometry/models/sprite.js +291 -189
- package/lib/canvas/index.js +101 -66
- package/lib/canvas/models/canvas.js +207 -140
- package/lib/canvas/models/index.js +12 -30
- package/lib/citybuliding/building.js +98 -63
- package/lib/citybuliding/models/build.js +192 -146
- package/lib/core/BaseLayer.js +1331 -809
- package/lib/core/BaseModel.js +457 -279
- package/lib/core/interface.js +40 -53
- package/lib/core/schema.js +21 -39
- package/lib/core/shape/Path.js +67 -79
- package/lib/core/shape/extrude.js +132 -91
- package/lib/core/triangulation.js +412 -213
- package/lib/earth/index.js +100 -62
- package/lib/earth/models/atmosphere.js +146 -112
- package/lib/earth/models/base.js +210 -150
- package/lib/earth/models/bloomsphere.js +146 -112
- package/lib/earth/utils.js +111 -91
- package/lib/heatmap/index.js +149 -92
- package/lib/heatmap/models/grid.js +118 -91
- package/lib/heatmap/models/grid3d.js +155 -123
- package/lib/heatmap/models/heatmap.js +475 -338
- package/lib/heatmap/models/hexagon.js +121 -92
- package/lib/heatmap/models/index.js +22 -37
- package/lib/heatmap/triangulation.js +31 -47
- package/lib/image/index.js +111 -74
- package/lib/image/models/dataImage.js +232 -174
- package/lib/image/models/image.js +175 -123
- package/lib/image/models/index.js +15 -32
- package/lib/index.js +263 -97
- package/lib/line/index.js +131 -83
- package/lib/line/models/arc.js +352 -237
- package/lib/line/models/arc_3d.js +334 -228
- package/lib/line/models/earthArc_3d.js +336 -228
- package/lib/line/models/great_circle.js +291 -200
- package/lib/line/models/half.js +286 -201
- package/lib/line/models/index.js +42 -50
- package/lib/line/models/line.js +428 -299
- package/lib/line/models/linearline.js +277 -203
- package/lib/line/models/simpleLine.js +239 -175
- package/lib/line/models/tile.js +348 -237
- package/lib/line/models/wall.js +327 -235
- package/lib/line/shaders/line_arc_vert.glsl +5 -3
- package/lib/line/shaders/simple/simpleline_vert.glsl +1 -0
- package/lib/mask/index.js +92 -59
- package/lib/mask/models/fill.js +134 -82
- package/lib/mask/models/index.js +12 -30
- package/lib/plugins/DataMappingPlugin.js +342 -224
- package/lib/plugins/DataSourcePlugin.js +102 -87
- package/lib/plugins/FeatureScalePlugin.js +330 -241
- package/lib/plugins/LayerAnimateStylePlugin.js +61 -55
- package/lib/plugins/LayerModelPlugin.js +80 -73
- package/lib/plugins/LayerStylePlugin.js +48 -51
- package/lib/plugins/LightingPlugin.js +80 -68
- package/lib/plugins/MultiPassRendererPlugin.js +91 -65
- package/lib/plugins/PixelPickingPlugin.js +150 -109
- package/lib/plugins/RegisterStyleAttributePlugin.js +110 -110
- package/lib/plugins/ShaderUniformPlugin.js +118 -99
- package/lib/plugins/UpdateModelPlugin.js +40 -47
- package/lib/plugins/UpdateStyleAttributePlugin.js +93 -75
- package/lib/point/index.js +226 -148
- package/lib/point/models/earthExtrude.js +279 -201
- package/lib/point/models/earthFill.js +287 -202
- package/lib/point/models/extrude.js +299 -203
- package/lib/point/models/fill.js +406 -273
- package/lib/point/models/fillmage.js +365 -252
- package/lib/point/models/image.js +241 -164
- package/lib/point/models/index.js +46 -52
- package/lib/point/models/normal.js +183 -134
- package/lib/point/models/radar.js +304 -212
- package/lib/point/models/simplePoint.js +194 -142
- package/lib/point/models/text.js +608 -385
- package/lib/point/models/tile.js +314 -223
- package/lib/point/shaders/fill_vert.glsl +13 -6
- package/lib/point/shaders/image/fillImage_vert.glsl +13 -5
- package/lib/point/shaders/image_vert.glsl +17 -8
- package/lib/point/shape/extrude.js +56 -52
- package/lib/polygon/index.js +154 -100
- package/lib/polygon/models/extrude.js +311 -223
- package/lib/polygon/models/fill.js +215 -153
- package/lib/polygon/models/index.js +46 -52
- package/lib/polygon/models/ocean.js +244 -173
- package/lib/polygon/models/tile.js +144 -100
- package/lib/polygon/models/water.js +222 -153
- package/lib/raster/buffers/triangulation.js +27 -40
- package/lib/raster/index.js +115 -74
- package/lib/raster/models/index.js +16 -33
- package/lib/raster/models/raster.js +178 -135
- package/lib/raster/raster.js +187 -132
- package/lib/tile/interface.js +4 -16
- package/lib/tile/manager/tileConfigManager.js +125 -86
- package/lib/tile/manager/tileLayerManager.js +314 -227
- package/lib/tile/manager/tilePickerManager.js +192 -123
- package/lib/tile/models/tileModel.js +71 -51
- package/lib/tile/tileFactory/base.js +433 -292
- package/lib/tile/tileFactory/index.js +51 -49
- package/lib/tile/tileFactory/line.js +65 -50
- package/lib/tile/tileFactory/point.js +65 -50
- package/lib/tile/tileFactory/polygon.js +65 -50
- package/lib/tile/tileFactory/raster.js +66 -54
- package/lib/tile/tileFactory/rasterData.js +88 -76
- package/lib/tile/tileFactory/rasterDataLayer.js +97 -62
- package/lib/tile/tileFactory/vectorLayer.js +169 -95
- package/lib/tile/tileLayer/baseTileLayer.js +420 -220
- package/lib/tile/tmsTileLayer.js +110 -67
- package/lib/tile/utils.js +113 -87
- package/lib/utils/blend.js +59 -79
- package/lib/utils/collision-index.js +107 -64
- package/lib/utils/dataMappingStyle.js +105 -60
- package/lib/utils/extrude_polyline.js +600 -398
- package/lib/utils/grid-index.js +163 -111
- package/lib/utils/layerData.js +130 -99
- package/lib/utils/multiPassRender.js +49 -41
- package/lib/utils/polylineNormal.js +148 -96
- package/lib/utils/simpleLine.js +100 -85
- package/lib/utils/symbol-layout.js +219 -116
- package/lib/utils/updateShape.js +15 -41
- package/lib/wind/index.js +109 -71
- package/lib/wind/models/index.js +12 -30
- package/lib/wind/models/utils.js +144 -105
- package/lib/wind/models/wind.js +333 -224
- package/lib/wind/models/windRender.js +329 -218
- package/lib/wind/models/windShader.js +23 -181
- package/package.json +7 -6
package/lib/wind/models/wind.js
CHANGED
|
@@ -1,237 +1,346 @@
|
|
|
1
|
-
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
"use strict";
|
|
21
2
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
26
7
|
});
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
var
|
|
32
|
-
|
|
33
|
-
var
|
|
34
|
-
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
+
|
|
12
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
+
|
|
14
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
15
|
+
|
|
16
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
17
|
+
|
|
18
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
19
|
+
|
|
20
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
21
|
+
|
|
22
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
23
|
+
|
|
24
|
+
var _l7Core = require("@antv/l7-core");
|
|
25
|
+
|
|
26
|
+
var _l7Utils = require("@antv/l7-utils");
|
|
27
|
+
|
|
28
|
+
var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
|
|
29
|
+
|
|
30
|
+
var _triangulation = require("../../core/triangulation");
|
|
31
|
+
|
|
32
|
+
var _windRender = require("./windRender");
|
|
33
|
+
|
|
34
|
+
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); }; }
|
|
35
|
+
|
|
36
|
+
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; } }
|
|
37
|
+
|
|
38
|
+
/* babel-plugin-inline-import '../shaders/wind_frag.glsl' */
|
|
39
|
+
var WindFrag = "precision mediump float;\nuniform float u_opacity: 1.0;\nuniform sampler2D u_texture;\nvarying vec2 v_texCoord;\nvoid main() {\n vec4 color = texture2D(u_texture,vec2(v_texCoord.x,v_texCoord.y));\n gl_FragColor = color;\n gl_FragColor.a *= u_opacity;\n}\n";
|
|
40
|
+
|
|
41
|
+
/* babel-plugin-inline-import '../shaders/wind_vert.glsl' */
|
|
42
|
+
var WindVert = "precision highp float;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nattribute vec3 a_Position;\nattribute vec2 a_Uv;\nvarying vec2 v_texCoord;\n#pragma include \"projection\"\nvoid main() {\n v_texCoord = a_Uv;\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy,0., 1.0));\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xy,0., 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy,0., 1.0));\n }\n}\n";
|
|
35
43
|
var defaultRampColors = {
|
|
36
|
-
0:
|
|
37
|
-
0.1:
|
|
38
|
-
0.2:
|
|
39
|
-
0.3:
|
|
40
|
-
0.4:
|
|
41
|
-
0.5:
|
|
42
|
-
0.6:
|
|
43
|
-
1:
|
|
44
|
+
0.0: '#3288bd',
|
|
45
|
+
0.1: '#66c2a5',
|
|
46
|
+
0.2: '#abdda4',
|
|
47
|
+
0.3: '#e6f598',
|
|
48
|
+
0.4: '#fee08b',
|
|
49
|
+
0.5: '#fdae61',
|
|
50
|
+
0.6: '#f46d43',
|
|
51
|
+
1.0: '#d53e4f'
|
|
44
52
|
};
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
53
|
+
|
|
54
|
+
var WindModel = /*#__PURE__*/function (_BaseModel) {
|
|
55
|
+
(0, _inherits2.default)(WindModel, _BaseModel);
|
|
56
|
+
|
|
57
|
+
var _super = _createSuper(WindModel);
|
|
58
|
+
|
|
59
|
+
function WindModel() {
|
|
60
|
+
var _this;
|
|
61
|
+
|
|
62
|
+
(0, _classCallCheck2.default)(this, WindModel);
|
|
63
|
+
|
|
64
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
65
|
+
args[_key] = arguments[_key];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
69
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "sizeScale", 0.5);
|
|
70
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "frequency", new _l7Utils.FrequencyController(7.2));
|
|
71
|
+
return _this;
|
|
59
72
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
dropRate = 3e-3,
|
|
70
|
-
dropRateBump = 0.01,
|
|
71
|
-
rampColors = defaultRampColors,
|
|
72
|
-
sizeScale = 0.5,
|
|
73
|
-
mask = false,
|
|
74
|
-
maskInside = true
|
|
75
|
-
} = this.layer.getLayerConfig();
|
|
76
|
-
const { createTexture2D } = this.rendererService;
|
|
77
|
-
const source = this.layer.getSource();
|
|
78
|
-
this.texture = createTexture2D({
|
|
79
|
-
height: 0,
|
|
80
|
-
width: 0
|
|
81
|
-
});
|
|
82
|
-
this.cacheZoom = Math.floor(this.mapService.getZoom());
|
|
83
|
-
const glContext = this.rendererService.getGLContext();
|
|
84
|
-
this.imageCoords = (_a = source.data) == null ? void 0 : _a.dataArray[0].coordinates;
|
|
85
|
-
(_c = (_b = source.data) == null ? void 0 : _b.images) == null ? void 0 : _c.then((imageData) => {
|
|
86
|
-
var _a2;
|
|
87
|
-
this.sizeScale = sizeScale * this.getZoomScale();
|
|
88
|
-
const { imageWidth, imageHeight } = this.getWindSize();
|
|
89
|
-
const options = {
|
|
90
|
-
glContext,
|
|
91
|
-
imageWidth,
|
|
92
|
-
imageHeight,
|
|
93
|
-
fadeOpacity,
|
|
94
|
-
speedFactor,
|
|
95
|
-
dropRate,
|
|
96
|
-
dropRateBump,
|
|
97
|
-
rampColors
|
|
98
|
-
};
|
|
99
|
-
this.wind = new import_windRender.Wind(options);
|
|
100
|
-
this.wind.setWind({
|
|
101
|
-
uMin,
|
|
102
|
-
uMax,
|
|
103
|
-
vMin,
|
|
104
|
-
vMax,
|
|
105
|
-
image: imageData[0]
|
|
73
|
+
|
|
74
|
+
(0, _createClass2.default)(WindModel, [{
|
|
75
|
+
key: "render",
|
|
76
|
+
value: function render() {
|
|
77
|
+
var _this2 = this;
|
|
78
|
+
|
|
79
|
+
// Tip: 控制风场的平均更新频率
|
|
80
|
+
this.frequency.run(function () {
|
|
81
|
+
_this2.drawWind();
|
|
106
82
|
});
|
|
107
|
-
|
|
83
|
+
this.drawColorMode();
|
|
84
|
+
}
|
|
85
|
+
}, {
|
|
86
|
+
key: "getUninforms",
|
|
87
|
+
value: function getUninforms() {
|
|
88
|
+
throw new Error('Method not implemented.');
|
|
89
|
+
}
|
|
90
|
+
}, {
|
|
91
|
+
key: "initModels",
|
|
92
|
+
value: function initModels(callbackModel) {
|
|
93
|
+
var _source$data,
|
|
94
|
+
_source$data2,
|
|
95
|
+
_source$data2$images,
|
|
96
|
+
_this3 = this;
|
|
97
|
+
|
|
98
|
+
var _ref = this.layer.getLayerConfig(),
|
|
99
|
+
_ref$uMin = _ref.uMin,
|
|
100
|
+
uMin = _ref$uMin === void 0 ? -21.32 : _ref$uMin,
|
|
101
|
+
_ref$uMax = _ref.uMax,
|
|
102
|
+
uMax = _ref$uMax === void 0 ? 26.8 : _ref$uMax,
|
|
103
|
+
_ref$vMin = _ref.vMin,
|
|
104
|
+
vMin = _ref$vMin === void 0 ? -21.57 : _ref$vMin,
|
|
105
|
+
_ref$vMax = _ref.vMax,
|
|
106
|
+
vMax = _ref$vMax === void 0 ? 21.42 : _ref$vMax,
|
|
107
|
+
_ref$fadeOpacity = _ref.fadeOpacity,
|
|
108
|
+
fadeOpacity = _ref$fadeOpacity === void 0 ? 0.996 : _ref$fadeOpacity,
|
|
109
|
+
_ref$speedFactor = _ref.speedFactor,
|
|
110
|
+
speedFactor = _ref$speedFactor === void 0 ? 0.25 : _ref$speedFactor,
|
|
111
|
+
_ref$dropRate = _ref.dropRate,
|
|
112
|
+
dropRate = _ref$dropRate === void 0 ? 0.003 : _ref$dropRate,
|
|
113
|
+
_ref$dropRateBump = _ref.dropRateBump,
|
|
114
|
+
dropRateBump = _ref$dropRateBump === void 0 ? 0.01 : _ref$dropRateBump,
|
|
115
|
+
_ref$rampColors = _ref.rampColors,
|
|
116
|
+
rampColors = _ref$rampColors === void 0 ? defaultRampColors : _ref$rampColors,
|
|
117
|
+
_ref$sizeScale = _ref.sizeScale,
|
|
118
|
+
sizeScale = _ref$sizeScale === void 0 ? 0.5 : _ref$sizeScale,
|
|
119
|
+
_ref$mask = _ref.mask,
|
|
120
|
+
mask = _ref$mask === void 0 ? false : _ref$mask,
|
|
121
|
+
_ref$maskInside = _ref.maskInside,
|
|
122
|
+
maskInside = _ref$maskInside === void 0 ? true : _ref$maskInside;
|
|
123
|
+
|
|
124
|
+
var createTexture2D = this.rendererService.createTexture2D;
|
|
125
|
+
var source = this.layer.getSource();
|
|
108
126
|
this.texture = createTexture2D({
|
|
109
|
-
|
|
110
|
-
|
|
127
|
+
height: 0,
|
|
128
|
+
width: 0
|
|
111
129
|
});
|
|
112
|
-
this.
|
|
113
|
-
this.
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
name: "a_Uv",
|
|
163
|
-
buffer: {
|
|
164
|
-
usage: import_l7_core.gl.DYNAMIC_DRAW,
|
|
165
|
-
data: [],
|
|
166
|
-
type: import_l7_core.gl.FLOAT
|
|
130
|
+
this.cacheZoom = Math.floor(this.mapService.getZoom());
|
|
131
|
+
var glContext = this.rendererService.getGLContext();
|
|
132
|
+
this.imageCoords = (_source$data = source.data) === null || _source$data === void 0 ? void 0 : _source$data.dataArray[0].coordinates;
|
|
133
|
+
(_source$data2 = source.data) === null || _source$data2 === void 0 ? void 0 : (_source$data2$images = _source$data2.images) === null || _source$data2$images === void 0 ? void 0 : _source$data2$images.then(function (imageData) {
|
|
134
|
+
var _this3$texture;
|
|
135
|
+
|
|
136
|
+
_this3.sizeScale = sizeScale * _this3.getZoomScale();
|
|
137
|
+
|
|
138
|
+
var _this3$getWindSize = _this3.getWindSize(),
|
|
139
|
+
imageWidth = _this3$getWindSize.imageWidth,
|
|
140
|
+
imageHeight = _this3$getWindSize.imageHeight;
|
|
141
|
+
|
|
142
|
+
var options = {
|
|
143
|
+
glContext: glContext,
|
|
144
|
+
imageWidth: imageWidth,
|
|
145
|
+
imageHeight: imageHeight,
|
|
146
|
+
fadeOpacity: fadeOpacity,
|
|
147
|
+
speedFactor: speedFactor,
|
|
148
|
+
dropRate: dropRate,
|
|
149
|
+
dropRateBump: dropRateBump,
|
|
150
|
+
rampColors: rampColors
|
|
151
|
+
};
|
|
152
|
+
_this3.wind = new _windRender.Wind(options); // imageData[0] 风场图
|
|
153
|
+
|
|
154
|
+
_this3.wind.setWind({
|
|
155
|
+
uMin: uMin,
|
|
156
|
+
uMax: uMax,
|
|
157
|
+
vMin: vMin,
|
|
158
|
+
vMax: vMax,
|
|
159
|
+
image: imageData[0]
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
(_this3$texture = _this3.texture) === null || _this3$texture === void 0 ? void 0 : _this3$texture.destroy();
|
|
163
|
+
_this3.texture = createTexture2D({
|
|
164
|
+
width: imageWidth,
|
|
165
|
+
height: imageHeight
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
_this3.layerService.updateLayerRenderList();
|
|
169
|
+
|
|
170
|
+
_this3.layerService.renderLayers();
|
|
171
|
+
});
|
|
172
|
+
this.layer.buildLayerModel({
|
|
173
|
+
moduleName: 'wind',
|
|
174
|
+
vertexShader: WindVert,
|
|
175
|
+
fragmentShader: WindFrag,
|
|
176
|
+
triangulation: _triangulation.RasterImageTriangulation,
|
|
177
|
+
primitive: _l7Core.gl.TRIANGLES,
|
|
178
|
+
depth: {
|
|
179
|
+
enable: false
|
|
167
180
|
},
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
181
|
+
blend: this.getBlend()
|
|
182
|
+
}).then(function (model) {
|
|
183
|
+
_this3.colorModel = model;
|
|
184
|
+
callbackModel([model]);
|
|
185
|
+
}).catch(function (err) {
|
|
186
|
+
console.warn(err);
|
|
187
|
+
callbackModel([]);
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
}, {
|
|
191
|
+
key: "getWindSize",
|
|
192
|
+
value: function getWindSize() {
|
|
193
|
+
var p1 = this.mapService.lngLatToPixel(this.imageCoords[0]);
|
|
194
|
+
var p2 = this.mapService.lngLatToPixel(this.imageCoords[1]);
|
|
195
|
+
var imageWidth = Math.min(Math.floor((p2.x - p1.x) * this.sizeScale), 2048);
|
|
196
|
+
var imageHeight = Math.min(Math.floor((p1.y - p2.y) * this.sizeScale), 2048);
|
|
197
|
+
return {
|
|
198
|
+
imageWidth: imageWidth,
|
|
199
|
+
imageHeight: imageHeight
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
}, {
|
|
203
|
+
key: "buildModels",
|
|
204
|
+
value: function buildModels(callbackModel) {
|
|
205
|
+
this.initModels(callbackModel);
|
|
206
|
+
}
|
|
207
|
+
}, {
|
|
208
|
+
key: "clearModels",
|
|
209
|
+
value: function clearModels() {
|
|
210
|
+
var _this$texture, _this$wind;
|
|
211
|
+
|
|
212
|
+
(_this$texture = this.texture) === null || _this$texture === void 0 ? void 0 : _this$texture.destroy();
|
|
213
|
+
(_this$wind = this.wind) === null || _this$wind === void 0 ? void 0 : _this$wind.destroy();
|
|
214
|
+
}
|
|
215
|
+
}, {
|
|
216
|
+
key: "getConfigSchema",
|
|
217
|
+
value: function getConfigSchema() {
|
|
218
|
+
return {
|
|
219
|
+
properties: {
|
|
220
|
+
opacity: {
|
|
221
|
+
type: 'number',
|
|
222
|
+
minimum: 0,
|
|
223
|
+
maximum: 1
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
}, {
|
|
229
|
+
key: "registerBuiltinAttributes",
|
|
230
|
+
value: function registerBuiltinAttributes() {
|
|
231
|
+
// point layer size;
|
|
232
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
233
|
+
name: 'uv',
|
|
234
|
+
type: _l7Core.AttributeType.Attribute,
|
|
235
|
+
descriptor: {
|
|
236
|
+
name: 'a_Uv',
|
|
237
|
+
buffer: {
|
|
238
|
+
// give the WebGL driver a hint that this buffer may change
|
|
239
|
+
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
240
|
+
data: [],
|
|
241
|
+
type: _l7Core.gl.FLOAT
|
|
242
|
+
},
|
|
243
|
+
size: 2,
|
|
244
|
+
update: function update(feature, featureIdx, vertex, attributeIdx) {
|
|
245
|
+
return [vertex[3], vertex[4]];
|
|
246
|
+
}
|
|
171
247
|
}
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
getZoomScale() {
|
|
176
|
-
return Math.min((this.cacheZoom + 4) / 30 * 2, 2);
|
|
177
|
-
}
|
|
178
|
-
drawWind() {
|
|
179
|
-
if (this.wind) {
|
|
180
|
-
const {
|
|
181
|
-
uMin = -21.32,
|
|
182
|
-
uMax = 26.8,
|
|
183
|
-
vMin = -21.57,
|
|
184
|
-
vMax = 21.42,
|
|
185
|
-
numParticles = 65535,
|
|
186
|
-
fadeOpacity = 0.996,
|
|
187
|
-
speedFactor = 0.25,
|
|
188
|
-
dropRate = 3e-3,
|
|
189
|
-
dropRateBump = 0.01,
|
|
190
|
-
rampColors = defaultRampColors,
|
|
191
|
-
sizeScale = 0.5
|
|
192
|
-
} = this.layer.getLayerConfig();
|
|
193
|
-
let newNumParticles = numParticles;
|
|
194
|
-
const currentZoom = Math.floor(this.mapService.getZoom());
|
|
195
|
-
if (typeof sizeScale === "number" && sizeScale !== this.sizeScale || currentZoom !== this.cacheZoom) {
|
|
196
|
-
const zoomScale = this.getZoomScale();
|
|
197
|
-
this.sizeScale = sizeScale;
|
|
198
|
-
newNumParticles *= zoomScale;
|
|
199
|
-
const { imageWidth, imageHeight } = this.getWindSize();
|
|
200
|
-
this.wind.reSize(imageWidth, imageHeight);
|
|
201
|
-
this.cacheZoom = currentZoom;
|
|
202
|
-
}
|
|
203
|
-
this.wind.updateWindDir(uMin, uMax, vMin, vMax);
|
|
204
|
-
this.wind.updateParticelNum(newNumParticles);
|
|
205
|
-
this.wind.updateColorRampTexture(rampColors);
|
|
206
|
-
this.wind.fadeOpacity = fadeOpacity;
|
|
207
|
-
this.wind.speedFactor = speedFactor;
|
|
208
|
-
this.wind.dropRate = dropRate;
|
|
209
|
-
this.wind.dropRateBump = dropRateBump;
|
|
210
|
-
const { d, w, h } = this.wind.draw();
|
|
211
|
-
this.rendererService.setBaseState();
|
|
212
|
-
this.texture.update({
|
|
213
|
-
data: d,
|
|
214
|
-
width: w,
|
|
215
|
-
height: h
|
|
216
248
|
});
|
|
217
249
|
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
250
|
+
}, {
|
|
251
|
+
key: "getZoomScale",
|
|
252
|
+
value: function getZoomScale() {
|
|
253
|
+
return Math.min((this.cacheZoom + 4) / 30 * 2, 2);
|
|
254
|
+
}
|
|
255
|
+
}, {
|
|
256
|
+
key: "drawWind",
|
|
257
|
+
value: function drawWind() {
|
|
258
|
+
if (this.wind) {
|
|
259
|
+
var _ref2 = this.layer.getLayerConfig(),
|
|
260
|
+
_ref2$uMin = _ref2.uMin,
|
|
261
|
+
uMin = _ref2$uMin === void 0 ? -21.32 : _ref2$uMin,
|
|
262
|
+
_ref2$uMax = _ref2.uMax,
|
|
263
|
+
uMax = _ref2$uMax === void 0 ? 26.8 : _ref2$uMax,
|
|
264
|
+
_ref2$vMin = _ref2.vMin,
|
|
265
|
+
vMin = _ref2$vMin === void 0 ? -21.57 : _ref2$vMin,
|
|
266
|
+
_ref2$vMax = _ref2.vMax,
|
|
267
|
+
vMax = _ref2$vMax === void 0 ? 21.42 : _ref2$vMax,
|
|
268
|
+
_ref2$numParticles = _ref2.numParticles,
|
|
269
|
+
numParticles = _ref2$numParticles === void 0 ? 65535 : _ref2$numParticles,
|
|
270
|
+
_ref2$fadeOpacity = _ref2.fadeOpacity,
|
|
271
|
+
fadeOpacity = _ref2$fadeOpacity === void 0 ? 0.996 : _ref2$fadeOpacity,
|
|
272
|
+
_ref2$speedFactor = _ref2.speedFactor,
|
|
273
|
+
speedFactor = _ref2$speedFactor === void 0 ? 0.25 : _ref2$speedFactor,
|
|
274
|
+
_ref2$dropRate = _ref2.dropRate,
|
|
275
|
+
dropRate = _ref2$dropRate === void 0 ? 0.003 : _ref2$dropRate,
|
|
276
|
+
_ref2$dropRateBump = _ref2.dropRateBump,
|
|
277
|
+
dropRateBump = _ref2$dropRateBump === void 0 ? 0.01 : _ref2$dropRateBump,
|
|
278
|
+
_ref2$rampColors = _ref2.rampColors,
|
|
279
|
+
rampColors = _ref2$rampColors === void 0 ? defaultRampColors : _ref2$rampColors,
|
|
280
|
+
_ref2$sizeScale = _ref2.sizeScale,
|
|
281
|
+
sizeScale = _ref2$sizeScale === void 0 ? 0.5 : _ref2$sizeScale;
|
|
282
|
+
|
|
283
|
+
var newNumParticles = numParticles;
|
|
284
|
+
var currentZoom = Math.floor(this.mapService.getZoom());
|
|
285
|
+
|
|
286
|
+
if (typeof sizeScale === 'number' && sizeScale !== this.sizeScale || currentZoom !== this.cacheZoom) {
|
|
287
|
+
var zoomScale = this.getZoomScale();
|
|
288
|
+
this.sizeScale = sizeScale;
|
|
289
|
+
newNumParticles *= zoomScale;
|
|
290
|
+
|
|
291
|
+
var _this$getWindSize = this.getWindSize(),
|
|
292
|
+
imageWidth = _this$getWindSize.imageWidth,
|
|
293
|
+
imageHeight = _this$getWindSize.imageHeight;
|
|
294
|
+
|
|
295
|
+
this.wind.reSize(imageWidth, imageHeight);
|
|
296
|
+
this.cacheZoom = currentZoom;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
this.wind.updateWindDir(uMin, uMax, vMin, vMax);
|
|
300
|
+
this.wind.updateParticelNum(newNumParticles);
|
|
301
|
+
this.wind.updateColorRampTexture(rampColors);
|
|
302
|
+
this.wind.fadeOpacity = fadeOpacity;
|
|
303
|
+
this.wind.speedFactor = speedFactor;
|
|
304
|
+
this.wind.dropRate = dropRate;
|
|
305
|
+
this.wind.dropRateBump = dropRateBump;
|
|
306
|
+
|
|
307
|
+
var _this$wind$draw = this.wind.draw(),
|
|
308
|
+
d = _this$wind$draw.d,
|
|
309
|
+
w = _this$wind$draw.w,
|
|
310
|
+
h = _this$wind$draw.h; // TODO: 恢复 L7 渲染流程中 gl 状态
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
this.rendererService.setBaseState();
|
|
314
|
+
this.texture.update({
|
|
315
|
+
data: d,
|
|
316
|
+
width: w,
|
|
317
|
+
height: h
|
|
318
|
+
});
|
|
232
319
|
}
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
320
|
+
}
|
|
321
|
+
}, {
|
|
322
|
+
key: "drawColorMode",
|
|
323
|
+
value: function drawColorMode() {
|
|
324
|
+
var _this$colorModel;
|
|
325
|
+
|
|
326
|
+
var _ref3 = this.layer.getLayerConfig(),
|
|
327
|
+
opacity = _ref3.opacity;
|
|
328
|
+
|
|
329
|
+
this.layer.masks.map(function (m) {
|
|
330
|
+
m.hooks.beforeRenderData.call();
|
|
331
|
+
m.hooks.beforeRender.call();
|
|
332
|
+
m.render();
|
|
333
|
+
m.hooks.afterRender.call();
|
|
334
|
+
});
|
|
335
|
+
(_this$colorModel = this.colorModel) === null || _this$colorModel === void 0 ? void 0 : _this$colorModel.draw({
|
|
336
|
+
uniforms: {
|
|
337
|
+
u_opacity: opacity || 1.0,
|
|
338
|
+
u_texture: this.texture
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
}]);
|
|
343
|
+
return WindModel;
|
|
344
|
+
}(_BaseModel2.default);
|
|
345
|
+
|
|
346
|
+
exports.default = WindModel;
|