@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,184 +1,248 @@
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);
21
-
22
- // src/line/models/simpleLine.ts
23
- var simpleLine_exports = {};
24
- __export(simpleLine_exports, {
25
- default: () => SimpleLineModel
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
26
7
  });
27
- module.exports = __toCommonJS(simpleLine_exports);
28
- var import_l7_core = require("@antv/l7-core");
29
- var import_l7_utils = require("@antv/l7-utils");
30
- var import_lodash = require("lodash");
31
- var import_BaseModel = __toESM(require("../../core/BaseModel"));
32
- var import_triangulation = require("../../core/triangulation");
33
- var import_simpleline_frag = __toESM(require("../shaders/simple/simpleline_frag.glsl"));
34
- var import_simpleline_linear_frag = __toESM(require("../shaders/simple/simpleline_linear_frag.glsl"));
35
- var import_simpleline_vert = __toESM(require("../shaders/simple/simpleline_vert.glsl"));
36
- var SimpleLineModel = class extends import_BaseModel.default {
37
- getUninforms() {
38
- const {
39
- opacity = 1,
40
- sourceColor,
41
- targetColor,
42
- vertexHeightScale = 20
43
- } = this.layer.getLayerConfig();
44
- let useLinearColor = 0;
45
- let sourceColorArr = [0, 0, 0, 0];
46
- let targetColorArr = [0, 0, 0, 0];
47
- if (sourceColor && targetColor) {
48
- sourceColorArr = (0, import_l7_utils.rgb2arr)(sourceColor);
49
- targetColorArr = (0, import_l7_utils.rgb2arr)(targetColor);
50
- useLinearColor = 1;
51
- }
52
- if (this.dataTextureTest && this.dataTextureNeedUpdate({ opacity })) {
53
- this.judgeStyleAttributes({ opacity });
54
- const encodeData = this.layer.getEncodedData();
55
- const { data, width, height } = this.calDataFrame(this.cellLength, encodeData, this.cellProperties);
56
- this.rowCount = height;
57
- this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
58
- flipY: true,
59
- data,
60
- format: import_l7_core.gl.LUMINANCE,
61
- type: import_l7_core.gl.FLOAT,
62
- width,
63
- height
64
- }) : this.createTexture2D({
65
- flipY: true,
66
- data: [1],
67
- format: import_l7_core.gl.LUMINANCE,
68
- type: import_l7_core.gl.FLOAT,
69
- width: 1,
70
- height: 1
71
- });
72
- }
73
- return {
74
- u_dataTexture: this.dataTexture,
75
- u_cellTypeLayout: this.getCellTypeLayout(),
76
- u_opacity: (0, import_lodash.isNumber)(opacity) ? opacity : 1,
77
- u_linearColor: useLinearColor,
78
- u_sourceColor: sourceColorArr,
79
- u_targetColor: targetColorArr,
80
- u_vertexScale: vertexHeightScale
81
- };
82
- }
83
- initModels(callbackModel) {
84
- this.buildModels(callbackModel);
85
- }
86
- clearModels() {
87
- var _a;
88
- (_a = this.dataTexture) == null ? void 0 : _a.destroy();
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 _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
15
+
16
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
17
+
18
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
19
+
20
+ var _l7Core = require("@antv/l7-core");
21
+
22
+ var _l7Utils = require("@antv/l7-utils");
23
+
24
+ var _lodash = require("lodash");
25
+
26
+ var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
27
+
28
+ var _triangulation = require("../../core/triangulation");
29
+
30
+ 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); }; }
31
+
32
+ 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; } }
33
+
34
+ /* babel-plugin-inline-import '../shaders/simple/simpleline_frag.glsl' */
35
+ var simple_line_frag = "\nvarying vec4 v_color;\nvarying mat4 styleMappingMat;\nvoid main() {\n float opacity = styleMappingMat[0][0];\n float d_distance_ratio = styleMappingMat[3].r; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n\n gl_FragColor = v_color;\n gl_FragColor.a *= opacity; // \u5168\u5C40\u900F\u660E\u5EA6\n}\n"; // linear simple line shader
36
+
37
+ /* babel-plugin-inline-import '../shaders/simple/simpleline_linear_frag.glsl' */
38
+ var simle_linear_frag = "uniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\n\nvarying mat4 styleMappingMat;\nvoid main() {\n float opacity = styleMappingMat[0][0];\n\n // styleMappingMat[3][0] \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n gl_FragColor = mix(u_sourceColor, u_targetColor, styleMappingMat[3][0]);\n gl_FragColor.a *= opacity; // \u5168\u5C40\u900F\u660E\u5EA6\n}\n";
39
+
40
+ /* babel-plugin-inline-import '../shaders/simple/simpleline_vert.glsl' */
41
+ var simple_line_vert = "attribute vec4 a_Color;\nattribute vec2 a_Size;\nattribute vec3 a_Position;\n\nattribute float a_Total_Distance;\nattribute float a_Distance;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\nuniform float u_opacity: 1.0;\nuniform float u_vertexScale: 1.0;\n\n#pragma include \"projection\"\n\nvarying vec4 v_color;\n\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0 // distance_ratio/distance/pixelLen/texV\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n \n v_color = a_Color; \n styleMappingMat[3][0] = a_Distance / a_Total_Distance;\n\n vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));\n\n float h = float(a_Position.z) * u_vertexScale; // \u7EBF\u9876\u70B9\u7684\u9AD8\u5EA6 - \u517C\u5BB9\u4E0D\u5B58\u5728\u7B2C\u4E09\u4E2A\u6570\u503C\u7684\u60C5\u51B5\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xy, project_pixel(a_Size.y) + h * 0.2, 1.0));\n } else {\n float lineHeight = a_Size.y;\n // \u517C\u5BB9 mapbox \u5728\u7EBF\u9AD8\u5EA6\u4E0A\u7684\u6548\u679C\u8868\u73B0\u57FA\u672C\u4E00\u81F4\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // \u4FDD\u6301\u9AD8\u5EA6\u76F8\u5BF9\u4E0D\u53D8\n h *= 2.0/pow(2.0, 20.0 - u_Zoom);\n }\n\n // #define COORDINATE_SYSTEM_P20 5.0\n // #define COORDINATE_SYSTEM_P20_OFFSET 6.0\n // amap1.x\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20 || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n // \u4FDD\u6301\u9AD8\u5EA6\u76F8\u5BF9\u4E0D\u53D8\n lineHeight *= pow(2.0, 20.0 - u_Zoom);\n }\n\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy, lineHeight + h, 1.0));\n gl_PointSize = 10.0;\n }\n}\n";
42
+
43
+ var SimpleLineModel = /*#__PURE__*/function (_BaseModel) {
44
+ (0, _inherits2.default)(SimpleLineModel, _BaseModel);
45
+
46
+ var _super = _createSuper(SimpleLineModel);
47
+
48
+ function SimpleLineModel() {
49
+ (0, _classCallCheck2.default)(this, SimpleLineModel);
50
+ return _super.apply(this, arguments);
89
51
  }
90
- getShaders() {
91
- const {
92
- sourceColor,
93
- targetColor
94
- } = this.layer.getLayerConfig();
95
- if (sourceColor && targetColor) {
96
- return {
97
- frag: import_simpleline_linear_frag.default,
98
- vert: import_simpleline_vert.default,
99
- type: "lineSimpleLinear"
100
- };
101
- } else {
52
+
53
+ (0, _createClass2.default)(SimpleLineModel, [{
54
+ key: "getUninforms",
55
+ value: function getUninforms() {
56
+ var _ref = this.layer.getLayerConfig(),
57
+ _ref$opacity = _ref.opacity,
58
+ opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
59
+ sourceColor = _ref.sourceColor,
60
+ targetColor = _ref.targetColor,
61
+ _ref$vertexHeightScal = _ref.vertexHeightScale,
62
+ vertexHeightScale = _ref$vertexHeightScal === void 0 ? 20.0 : _ref$vertexHeightScal; // 转化渐变色
63
+
64
+
65
+ var useLinearColor = 0; // 默认不生效
66
+
67
+ var sourceColorArr = [0, 0, 0, 0];
68
+ var targetColorArr = [0, 0, 0, 0];
69
+
70
+ if (sourceColor && targetColor) {
71
+ sourceColorArr = (0, _l7Utils.rgb2arr)(sourceColor);
72
+ targetColorArr = (0, _l7Utils.rgb2arr)(targetColor);
73
+ useLinearColor = 1;
74
+ }
75
+
76
+ if (this.dataTextureTest && this.dataTextureNeedUpdate({
77
+ opacity: opacity
78
+ })) {
79
+ this.judgeStyleAttributes({
80
+ opacity: opacity
81
+ });
82
+ var encodeData = this.layer.getEncodedData();
83
+
84
+ var _this$calDataFrame = this.calDataFrame(this.cellLength, encodeData, this.cellProperties),
85
+ data = _this$calDataFrame.data,
86
+ width = _this$calDataFrame.width,
87
+ height = _this$calDataFrame.height;
88
+
89
+ this.rowCount = height; // 当前数据纹理有多少行
90
+
91
+ this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
92
+ flipY: true,
93
+ data: data,
94
+ format: _l7Core.gl.LUMINANCE,
95
+ type: _l7Core.gl.FLOAT,
96
+ width: width,
97
+ height: height
98
+ }) : this.createTexture2D({
99
+ flipY: true,
100
+ data: [1],
101
+ format: _l7Core.gl.LUMINANCE,
102
+ type: _l7Core.gl.FLOAT,
103
+ width: 1,
104
+ height: 1
105
+ });
106
+ }
107
+
102
108
  return {
103
- frag: import_simpleline_frag.default,
104
- vert: import_simpleline_vert.default,
105
- type: "lineSimpleNormal"
109
+ u_dataTexture: this.dataTexture,
110
+ // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]
111
+ u_cellTypeLayout: this.getCellTypeLayout(),
112
+ u_opacity: (0, _lodash.isNumber)(opacity) ? opacity : 1.0,
113
+ // 渐变色支持参数
114
+ u_linearColor: useLinearColor,
115
+ u_sourceColor: sourceColorArr,
116
+ u_targetColor: targetColorArr,
117
+ // 顶点高度 scale
118
+ u_vertexScale: vertexHeightScale
106
119
  };
107
120
  }
108
- }
109
- buildModels(callbackModel) {
110
- const {
111
- mask = false,
112
- maskInside = true
113
- } = this.layer.getLayerConfig();
114
- const { frag, vert, type } = this.getShaders();
115
- this.layer.buildLayerModel({
116
- moduleName: type,
117
- vertexShader: vert,
118
- fragmentShader: frag,
119
- triangulation: import_triangulation.SimpleLineTriangulation,
120
- primitive: import_l7_core.gl.LINES,
121
- depth: { enable: false },
122
- blend: this.getBlend(),
123
- stencil: (0, import_l7_utils.getMask)(mask, maskInside)
124
- }).then((model) => {
125
- callbackModel([model]);
126
- }).catch((err) => {
127
- console.warn(err);
128
- callbackModel([]);
129
- });
130
- }
131
- registerBuiltinAttributes() {
132
- this.styleAttributeService.registerStyleAttribute({
133
- name: "distance",
134
- type: import_l7_core.AttributeType.Attribute,
135
- descriptor: {
136
- name: "a_Distance",
137
- buffer: {
138
- usage: import_l7_core.gl.STATIC_DRAW,
139
- data: [],
140
- type: import_l7_core.gl.FLOAT
141
- },
142
- size: 1,
143
- update: (feature, featureIdx, vertex, attributeIdx) => {
144
- return [vertex[3]];
145
- }
121
+ }, {
122
+ key: "initModels",
123
+ value: function initModels(callbackModel) {
124
+ this.buildModels(callbackModel);
125
+ }
126
+ }, {
127
+ key: "clearModels",
128
+ value: function clearModels() {
129
+ var _this$dataTexture;
130
+
131
+ (_this$dataTexture = this.dataTexture) === null || _this$dataTexture === void 0 ? void 0 : _this$dataTexture.destroy();
132
+ }
133
+ }, {
134
+ key: "getShaders",
135
+ value: function getShaders() {
136
+ var _ref2 = this.layer.getLayerConfig(),
137
+ sourceColor = _ref2.sourceColor,
138
+ targetColor = _ref2.targetColor;
139
+
140
+ if (sourceColor && targetColor) {
141
+ // 分离 linear 功能
142
+ return {
143
+ frag: simle_linear_frag,
144
+ vert: simple_line_vert,
145
+ type: 'lineSimpleLinear'
146
+ };
147
+ } else {
148
+ return {
149
+ frag: simple_line_frag,
150
+ vert: simple_line_vert,
151
+ type: 'lineSimpleNormal'
152
+ };
146
153
  }
147
- });
148
- this.styleAttributeService.registerStyleAttribute({
149
- name: "total_distance",
150
- type: import_l7_core.AttributeType.Attribute,
151
- descriptor: {
152
- name: "a_Total_Distance",
153
- buffer: {
154
- usage: import_l7_core.gl.STATIC_DRAW,
155
- data: [],
156
- type: import_l7_core.gl.FLOAT
154
+ }
155
+ }, {
156
+ key: "buildModels",
157
+ value: function buildModels(callbackModel) {
158
+ var _ref3 = this.layer.getLayerConfig(),
159
+ _ref3$mask = _ref3.mask,
160
+ mask = _ref3$mask === void 0 ? false : _ref3$mask,
161
+ _ref3$maskInside = _ref3.maskInside,
162
+ maskInside = _ref3$maskInside === void 0 ? true : _ref3$maskInside;
163
+
164
+ var _this$getShaders = this.getShaders(),
165
+ frag = _this$getShaders.frag,
166
+ vert = _this$getShaders.vert,
167
+ type = _this$getShaders.type;
168
+
169
+ this.layer.buildLayerModel({
170
+ moduleName: type,
171
+ vertexShader: vert,
172
+ fragmentShader: frag,
173
+ triangulation: _triangulation.SimpleLineTriangulation,
174
+ primitive: _l7Core.gl.LINES,
175
+ depth: {
176
+ enable: false
157
177
  },
158
- size: 1,
159
- update: (feature, featureIdx, vertex, attributeIdx) => {
160
- return [vertex[5]];
178
+ blend: this.getBlend(),
179
+ stencil: (0, _l7Utils.getMask)(mask, maskInside)
180
+ }).then(function (model) {
181
+ callbackModel([model]);
182
+ }).catch(function (err) {
183
+ console.warn(err);
184
+ callbackModel([]);
185
+ });
186
+ }
187
+ }, {
188
+ key: "registerBuiltinAttributes",
189
+ value: function registerBuiltinAttributes() {
190
+ this.styleAttributeService.registerStyleAttribute({
191
+ name: 'distance',
192
+ type: _l7Core.AttributeType.Attribute,
193
+ descriptor: {
194
+ name: 'a_Distance',
195
+ buffer: {
196
+ // give the WebGL driver a hint that this buffer may change
197
+ usage: _l7Core.gl.STATIC_DRAW,
198
+ data: [],
199
+ type: _l7Core.gl.FLOAT
200
+ },
201
+ size: 1,
202
+ update: function update(feature, featureIdx, vertex, attributeIdx) {
203
+ return [vertex[3]];
204
+ }
161
205
  }
162
- }
163
- });
164
- this.styleAttributeService.registerStyleAttribute({
165
- name: "size",
166
- type: import_l7_core.AttributeType.Attribute,
167
- descriptor: {
168
- name: "a_Size",
169
- buffer: {
170
- usage: import_l7_core.gl.DYNAMIC_DRAW,
171
- data: [],
172
- type: import_l7_core.gl.FLOAT
173
- },
174
- size: 2,
175
- update: (feature, featureIdx, vertex, attributeIdx) => {
176
- const { size = 1 } = feature;
177
- return Array.isArray(size) ? [size[0], size[1]] : [size, 0];
206
+ });
207
+ this.styleAttributeService.registerStyleAttribute({
208
+ name: 'total_distance',
209
+ type: _l7Core.AttributeType.Attribute,
210
+ descriptor: {
211
+ name: 'a_Total_Distance',
212
+ buffer: {
213
+ // give the WebGL driver a hint that this buffer may change
214
+ usage: _l7Core.gl.STATIC_DRAW,
215
+ data: [],
216
+ type: _l7Core.gl.FLOAT
217
+ },
218
+ size: 1,
219
+ update: function update(feature, featureIdx, vertex, attributeIdx) {
220
+ return [vertex[5]];
221
+ }
178
222
  }
179
- }
180
- });
181
- }
182
- };
183
- // Annotate the CommonJS export names for ESM import in node:
184
- 0 && (module.exports = {});
223
+ });
224
+ this.styleAttributeService.registerStyleAttribute({
225
+ name: 'size',
226
+ type: _l7Core.AttributeType.Attribute,
227
+ descriptor: {
228
+ name: 'a_Size',
229
+ buffer: {
230
+ // give the WebGL driver a hint that this buffer may change
231
+ usage: _l7Core.gl.DYNAMIC_DRAW,
232
+ data: [],
233
+ type: _l7Core.gl.FLOAT
234
+ },
235
+ size: 2,
236
+ update: function update(feature, featureIdx, vertex, attributeIdx) {
237
+ var _feature$size = feature.size,
238
+ size = _feature$size === void 0 ? 1 : _feature$size;
239
+ return Array.isArray(size) ? [size[0], size[1]] : [size, 0];
240
+ }
241
+ }
242
+ });
243
+ }
244
+ }]);
245
+ return SimpleLineModel;
246
+ }(_BaseModel2.default);
247
+
248
+ exports.default = SimpleLineModel;