@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.
Files changed (166) hide show
  1. package/es/Geometry/models/plane.d.ts +1 -0
  2. package/es/citybuliding/building.js +1 -1
  3. package/es/core/BaseLayer.js +10 -3
  4. package/es/core/interface.d.ts +26 -48
  5. package/es/core/interface.js +3 -0
  6. package/es/core/schema.d.ts +3 -3
  7. package/es/core/triangulation.d.ts +4 -3
  8. package/es/core/triangulation.js +54 -39
  9. package/es/heatmap/models/heatmap.js +1 -1
  10. package/es/image/models/image.js +7 -1
  11. package/es/line/index.js +4 -1
  12. package/es/line/models/arc.js +1 -1
  13. package/es/line/models/simpleLine.js +1 -1
  14. package/es/line/shaders/line_arc_vert.glsl +5 -3
  15. package/es/line/shaders/simple/simpleline_vert.glsl +1 -0
  16. package/es/plugins/FeatureScalePlugin.js +0 -1
  17. package/es/point/index.js +3 -1
  18. package/es/point/models/fill.js +5 -2
  19. package/es/point/models/fillmage.js +9 -3
  20. package/es/point/models/image.js +8 -2
  21. package/es/point/models/radar.js +2 -3
  22. package/es/point/models/tile.js +1 -1
  23. package/es/point/shaders/fill_vert.glsl +13 -6
  24. package/es/point/shaders/image/fillImage_vert.glsl +13 -5
  25. package/es/point/shaders/image_vert.glsl +17 -8
  26. package/es/polygon/index.js +4 -1
  27. package/es/raster/index.js +3 -1
  28. package/es/tile/manager/tileLayerManager.d.ts +3 -2
  29. package/es/tile/manager/tileLayerManager.js +5 -2
  30. package/es/tile/models/tileModel.js +4 -3
  31. package/es/tile/tileFactory/base.d.ts +1 -1
  32. package/es/tile/tileFactory/base.js +32 -5
  33. package/es/tile/tileFactory/vectorLayer.d.ts +3 -1
  34. package/es/tile/tileFactory/vectorLayer.js +22 -1
  35. package/es/tile/tileLayer/baseTileLayer.d.ts +1 -1
  36. package/es/tile/tileLayer/baseTileLayer.js +3 -2
  37. package/es/tile/utils.d.ts +2 -0
  38. package/es/tile/utils.js +5 -1
  39. package/lib/Geometry/index.js +114 -77
  40. package/lib/Geometry/models/billboard.js +232 -181
  41. package/lib/Geometry/models/index.js +18 -34
  42. package/lib/Geometry/models/plane.js +407 -278
  43. package/lib/Geometry/models/sprite.js +291 -189
  44. package/lib/canvas/index.js +101 -66
  45. package/lib/canvas/models/canvas.js +207 -140
  46. package/lib/canvas/models/index.js +12 -30
  47. package/lib/citybuliding/building.js +98 -63
  48. package/lib/citybuliding/models/build.js +192 -146
  49. package/lib/core/BaseLayer.js +1331 -809
  50. package/lib/core/BaseModel.js +457 -279
  51. package/lib/core/interface.js +40 -53
  52. package/lib/core/schema.js +21 -39
  53. package/lib/core/shape/Path.js +67 -79
  54. package/lib/core/shape/extrude.js +132 -91
  55. package/lib/core/triangulation.js +412 -213
  56. package/lib/earth/index.js +100 -62
  57. package/lib/earth/models/atmosphere.js +146 -112
  58. package/lib/earth/models/base.js +210 -150
  59. package/lib/earth/models/bloomsphere.js +146 -112
  60. package/lib/earth/utils.js +111 -91
  61. package/lib/heatmap/index.js +149 -92
  62. package/lib/heatmap/models/grid.js +118 -91
  63. package/lib/heatmap/models/grid3d.js +155 -123
  64. package/lib/heatmap/models/heatmap.js +475 -338
  65. package/lib/heatmap/models/hexagon.js +121 -92
  66. package/lib/heatmap/models/index.js +22 -37
  67. package/lib/heatmap/triangulation.js +31 -47
  68. package/lib/image/index.js +111 -74
  69. package/lib/image/models/dataImage.js +232 -174
  70. package/lib/image/models/image.js +175 -123
  71. package/lib/image/models/index.js +15 -32
  72. package/lib/index.js +263 -97
  73. package/lib/line/index.js +131 -83
  74. package/lib/line/models/arc.js +352 -237
  75. package/lib/line/models/arc_3d.js +334 -228
  76. package/lib/line/models/earthArc_3d.js +336 -228
  77. package/lib/line/models/great_circle.js +291 -200
  78. package/lib/line/models/half.js +286 -201
  79. package/lib/line/models/index.js +42 -50
  80. package/lib/line/models/line.js +428 -299
  81. package/lib/line/models/linearline.js +277 -203
  82. package/lib/line/models/simpleLine.js +239 -175
  83. package/lib/line/models/tile.js +348 -237
  84. package/lib/line/models/wall.js +327 -235
  85. package/lib/line/shaders/line_arc_vert.glsl +5 -3
  86. package/lib/line/shaders/simple/simpleline_vert.glsl +1 -0
  87. package/lib/mask/index.js +92 -59
  88. package/lib/mask/models/fill.js +134 -82
  89. package/lib/mask/models/index.js +12 -30
  90. package/lib/plugins/DataMappingPlugin.js +342 -224
  91. package/lib/plugins/DataSourcePlugin.js +102 -87
  92. package/lib/plugins/FeatureScalePlugin.js +330 -241
  93. package/lib/plugins/LayerAnimateStylePlugin.js +61 -55
  94. package/lib/plugins/LayerModelPlugin.js +80 -73
  95. package/lib/plugins/LayerStylePlugin.js +48 -51
  96. package/lib/plugins/LightingPlugin.js +80 -68
  97. package/lib/plugins/MultiPassRendererPlugin.js +91 -65
  98. package/lib/plugins/PixelPickingPlugin.js +150 -109
  99. package/lib/plugins/RegisterStyleAttributePlugin.js +110 -110
  100. package/lib/plugins/ShaderUniformPlugin.js +118 -99
  101. package/lib/plugins/UpdateModelPlugin.js +40 -47
  102. package/lib/plugins/UpdateStyleAttributePlugin.js +93 -75
  103. package/lib/point/index.js +226 -148
  104. package/lib/point/models/earthExtrude.js +279 -201
  105. package/lib/point/models/earthFill.js +287 -202
  106. package/lib/point/models/extrude.js +299 -203
  107. package/lib/point/models/fill.js +406 -273
  108. package/lib/point/models/fillmage.js +365 -252
  109. package/lib/point/models/image.js +241 -164
  110. package/lib/point/models/index.js +46 -52
  111. package/lib/point/models/normal.js +183 -134
  112. package/lib/point/models/radar.js +304 -212
  113. package/lib/point/models/simplePoint.js +194 -142
  114. package/lib/point/models/text.js +608 -385
  115. package/lib/point/models/tile.js +314 -223
  116. package/lib/point/shaders/fill_vert.glsl +13 -6
  117. package/lib/point/shaders/image/fillImage_vert.glsl +13 -5
  118. package/lib/point/shaders/image_vert.glsl +17 -8
  119. package/lib/point/shape/extrude.js +56 -52
  120. package/lib/polygon/index.js +154 -100
  121. package/lib/polygon/models/extrude.js +311 -223
  122. package/lib/polygon/models/fill.js +215 -153
  123. package/lib/polygon/models/index.js +46 -52
  124. package/lib/polygon/models/ocean.js +244 -173
  125. package/lib/polygon/models/tile.js +144 -100
  126. package/lib/polygon/models/water.js +222 -153
  127. package/lib/raster/buffers/triangulation.js +27 -40
  128. package/lib/raster/index.js +115 -74
  129. package/lib/raster/models/index.js +16 -33
  130. package/lib/raster/models/raster.js +178 -135
  131. package/lib/raster/raster.js +187 -132
  132. package/lib/tile/interface.js +4 -16
  133. package/lib/tile/manager/tileConfigManager.js +125 -86
  134. package/lib/tile/manager/tileLayerManager.js +314 -227
  135. package/lib/tile/manager/tilePickerManager.js +192 -123
  136. package/lib/tile/models/tileModel.js +71 -51
  137. package/lib/tile/tileFactory/base.js +433 -292
  138. package/lib/tile/tileFactory/index.js +51 -49
  139. package/lib/tile/tileFactory/line.js +65 -50
  140. package/lib/tile/tileFactory/point.js +65 -50
  141. package/lib/tile/tileFactory/polygon.js +65 -50
  142. package/lib/tile/tileFactory/raster.js +66 -54
  143. package/lib/tile/tileFactory/rasterData.js +88 -76
  144. package/lib/tile/tileFactory/rasterDataLayer.js +97 -62
  145. package/lib/tile/tileFactory/vectorLayer.js +169 -95
  146. package/lib/tile/tileLayer/baseTileLayer.js +420 -220
  147. package/lib/tile/tmsTileLayer.js +110 -67
  148. package/lib/tile/utils.js +113 -87
  149. package/lib/utils/blend.js +59 -79
  150. package/lib/utils/collision-index.js +107 -64
  151. package/lib/utils/dataMappingStyle.js +105 -60
  152. package/lib/utils/extrude_polyline.js +600 -398
  153. package/lib/utils/grid-index.js +163 -111
  154. package/lib/utils/layerData.js +130 -99
  155. package/lib/utils/multiPassRender.js +49 -41
  156. package/lib/utils/polylineNormal.js +148 -96
  157. package/lib/utils/simpleLine.js +100 -85
  158. package/lib/utils/symbol-layout.js +219 -116
  159. package/lib/utils/updateShape.js +15 -41
  160. package/lib/wind/index.js +109 -71
  161. package/lib/wind/models/index.js +12 -30
  162. package/lib/wind/models/utils.js +144 -105
  163. package/lib/wind/models/wind.js +333 -224
  164. package/lib/wind/models/windRender.js +329 -218
  165. package/lib/wind/models/windShader.js +23 -181
  166. package/package.json +7 -6
@@ -1,237 +1,346 @@
1
- var __create = Object.create;
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
- // src/wind/models/wind.ts
23
- var wind_exports = {};
24
- __export(wind_exports, {
25
- default: () => WindModel
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
26
7
  });
27
- module.exports = __toCommonJS(wind_exports);
28
- var import_l7_core = require("@antv/l7-core");
29
- var import_l7_utils = require("@antv/l7-utils");
30
- var import_BaseModel = __toESM(require("../../core/BaseModel"));
31
- var import_triangulation = require("../../core/triangulation");
32
- var import_wind_frag = __toESM(require("../shaders/wind_frag.glsl"));
33
- var import_wind_vert = __toESM(require("../shaders/wind_vert.glsl"));
34
- var import_windRender = require("./windRender");
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: "#3288bd",
37
- 0.1: "#66c2a5",
38
- 0.2: "#abdda4",
39
- 0.3: "#e6f598",
40
- 0.4: "#fee08b",
41
- 0.5: "#fdae61",
42
- 0.6: "#f46d43",
43
- 1: "#d53e4f"
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
- var WindModel = class extends import_BaseModel.default {
46
- constructor() {
47
- super(...arguments);
48
- this.sizeScale = 0.5;
49
- this.frequency = new import_l7_utils.FrequencyController(7.2);
50
- }
51
- render() {
52
- this.frequency.run(() => {
53
- this.drawWind();
54
- });
55
- this.drawColorMode();
56
- }
57
- getUninforms() {
58
- throw new Error("Method not implemented.");
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
- initModels(callbackModel) {
61
- var _a, _b, _c;
62
- const {
63
- uMin = -21.32,
64
- uMax = 26.8,
65
- vMin = -21.57,
66
- vMax = 21.42,
67
- fadeOpacity = 0.996,
68
- speedFactor = 0.25,
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
- (_a2 = this.texture) == null ? void 0 : _a2.destroy();
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
- width: imageWidth,
110
- height: imageHeight
127
+ height: 0,
128
+ width: 0
111
129
  });
112
- this.layerService.updateLayerRenderList();
113
- this.layerService.renderLayers();
114
- });
115
- this.layer.buildLayerModel({
116
- moduleName: "wind",
117
- vertexShader: import_wind_vert.default,
118
- fragmentShader: import_wind_frag.default,
119
- triangulation: import_triangulation.RasterImageTriangulation,
120
- primitive: import_l7_core.gl.TRIANGLES,
121
- depth: { enable: false },
122
- blend: this.getBlend()
123
- }).then((model) => {
124
- this.colorModel = model;
125
- callbackModel([model]);
126
- }).catch((err) => {
127
- console.warn(err);
128
- callbackModel([]);
129
- });
130
- }
131
- getWindSize() {
132
- const p1 = this.mapService.lngLatToPixel(this.imageCoords[0]);
133
- const p2 = this.mapService.lngLatToPixel(this.imageCoords[1]);
134
- const imageWidth = Math.min(Math.floor((p2.x - p1.x) * this.sizeScale), 2048);
135
- const imageHeight = Math.min(Math.floor((p1.y - p2.y) * this.sizeScale), 2048);
136
- return { imageWidth, imageHeight };
137
- }
138
- buildModels(callbackModel) {
139
- this.initModels(callbackModel);
140
- }
141
- clearModels() {
142
- var _a, _b;
143
- (_a = this.texture) == null ? void 0 : _a.destroy();
144
- (_b = this.wind) == null ? void 0 : _b.destroy();
145
- }
146
- getConfigSchema() {
147
- return {
148
- properties: {
149
- opacity: {
150
- type: "number",
151
- minimum: 0,
152
- maximum: 1
153
- }
154
- }
155
- };
156
- }
157
- registerBuiltinAttributes() {
158
- this.styleAttributeService.registerStyleAttribute({
159
- name: "uv",
160
- type: import_l7_core.AttributeType.Attribute,
161
- descriptor: {
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
- size: 2,
169
- update: (feature, featureIdx, vertex, attributeIdx) => {
170
- return [vertex[3], vertex[4]];
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
- drawColorMode() {
220
- var _a;
221
- const { opacity } = this.layer.getLayerConfig();
222
- this.layer.masks.map((m) => {
223
- m.hooks.beforeRenderData.call();
224
- m.hooks.beforeRender.call();
225
- m.render();
226
- m.hooks.afterRender.call();
227
- });
228
- (_a = this.colorModel) == null ? void 0 : _a.draw({
229
- uniforms: {
230
- u_opacity: opacity || 1,
231
- u_texture: this.texture
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
- // Annotate the CommonJS export names for ESM import in node:
237
- 0 && (module.exports = {});
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;