@antv/l7-layers 2.9.25-alpha.0 → 2.9.26-alpha.1

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 (126) hide show
  1. package/es/heatmap/models/heatmap.js +1 -1
  2. package/es/tile/tileFactory/base.d.ts +1 -1
  3. package/es/tile/utils.js +1 -1
  4. package/lib/Geometry/index.js +114 -77
  5. package/lib/Geometry/models/billboard.js +232 -181
  6. package/lib/Geometry/models/index.js +18 -34
  7. package/lib/Geometry/models/plane.js +407 -278
  8. package/lib/Geometry/models/sprite.js +291 -189
  9. package/lib/canvas/index.js +101 -66
  10. package/lib/canvas/models/canvas.js +207 -140
  11. package/lib/canvas/models/index.js +12 -30
  12. package/lib/citybuliding/building.js +98 -63
  13. package/lib/citybuliding/models/build.js +192 -146
  14. package/lib/core/BaseLayer.js +1331 -814
  15. package/lib/core/BaseModel.js +457 -279
  16. package/lib/core/interface.js +40 -53
  17. package/lib/core/schema.js +21 -39
  18. package/lib/core/shape/Path.js +67 -79
  19. package/lib/core/shape/extrude.js +132 -91
  20. package/lib/core/triangulation.js +378 -196
  21. package/lib/earth/index.js +100 -62
  22. package/lib/earth/models/atmosphere.js +146 -112
  23. package/lib/earth/models/base.js +210 -150
  24. package/lib/earth/models/bloomsphere.js +146 -112
  25. package/lib/earth/utils.js +111 -91
  26. package/lib/heatmap/index.js +149 -92
  27. package/lib/heatmap/models/grid.js +118 -91
  28. package/lib/heatmap/models/grid3d.js +155 -123
  29. package/lib/heatmap/models/heatmap.js +475 -338
  30. package/lib/heatmap/models/hexagon.js +121 -92
  31. package/lib/heatmap/models/index.js +22 -37
  32. package/lib/heatmap/triangulation.js +31 -47
  33. package/lib/image/index.js +111 -74
  34. package/lib/image/models/dataImage.js +232 -174
  35. package/lib/image/models/image.js +175 -128
  36. package/lib/image/models/index.js +15 -32
  37. package/lib/index.js +263 -97
  38. package/lib/line/index.js +131 -85
  39. package/lib/line/models/arc.js +352 -237
  40. package/lib/line/models/arc_3d.js +334 -228
  41. package/lib/line/models/earthArc_3d.js +336 -228
  42. package/lib/line/models/great_circle.js +291 -200
  43. package/lib/line/models/half.js +286 -201
  44. package/lib/line/models/index.js +42 -50
  45. package/lib/line/models/line.js +428 -299
  46. package/lib/line/models/linearline.js +277 -203
  47. package/lib/line/models/simpleLine.js +239 -175
  48. package/lib/line/models/tile.js +348 -237
  49. package/lib/line/models/wall.js +327 -235
  50. package/lib/mask/index.js +92 -59
  51. package/lib/mask/models/fill.js +134 -82
  52. package/lib/mask/models/index.js +12 -30
  53. package/lib/plugins/DataMappingPlugin.js +342 -224
  54. package/lib/plugins/DataSourcePlugin.js +102 -87
  55. package/lib/plugins/FeatureScalePlugin.js +330 -240
  56. package/lib/plugins/LayerAnimateStylePlugin.js +61 -55
  57. package/lib/plugins/LayerModelPlugin.js +80 -73
  58. package/lib/plugins/LayerStylePlugin.js +48 -51
  59. package/lib/plugins/LightingPlugin.js +80 -68
  60. package/lib/plugins/MultiPassRendererPlugin.js +91 -65
  61. package/lib/plugins/PixelPickingPlugin.js +150 -109
  62. package/lib/plugins/RegisterStyleAttributePlugin.js +110 -110
  63. package/lib/plugins/ShaderUniformPlugin.js +118 -99
  64. package/lib/plugins/UpdateModelPlugin.js +40 -47
  65. package/lib/plugins/UpdateStyleAttributePlugin.js +93 -75
  66. package/lib/point/index.js +226 -150
  67. package/lib/point/models/earthExtrude.js +279 -201
  68. package/lib/point/models/earthFill.js +287 -202
  69. package/lib/point/models/extrude.js +299 -203
  70. package/lib/point/models/fill.js +406 -275
  71. package/lib/point/models/fillmage.js +365 -256
  72. package/lib/point/models/image.js +241 -168
  73. package/lib/point/models/index.js +46 -52
  74. package/lib/point/models/normal.js +183 -134
  75. package/lib/point/models/radar.js +304 -211
  76. package/lib/point/models/simplePoint.js +194 -142
  77. package/lib/point/models/text.js +608 -385
  78. package/lib/point/models/tile.js +314 -223
  79. package/lib/point/shape/extrude.js +56 -52
  80. package/lib/polygon/index.js +154 -102
  81. package/lib/polygon/models/extrude.js +311 -223
  82. package/lib/polygon/models/fill.js +215 -153
  83. package/lib/polygon/models/index.js +46 -52
  84. package/lib/polygon/models/ocean.js +244 -173
  85. package/lib/polygon/models/tile.js +144 -100
  86. package/lib/polygon/models/water.js +222 -153
  87. package/lib/raster/buffers/triangulation.js +27 -40
  88. package/lib/raster/index.js +115 -75
  89. package/lib/raster/models/index.js +16 -33
  90. package/lib/raster/models/raster.js +178 -135
  91. package/lib/raster/raster.js +187 -132
  92. package/lib/tile/interface.js +4 -16
  93. package/lib/tile/manager/tileConfigManager.js +125 -86
  94. package/lib/tile/manager/tileLayerManager.js +313 -229
  95. package/lib/tile/manager/tilePickerManager.js +192 -123
  96. package/lib/tile/models/tileModel.js +71 -52
  97. package/lib/tile/tileFactory/base.js +432 -309
  98. package/lib/tile/tileFactory/index.js +51 -49
  99. package/lib/tile/tileFactory/line.js +65 -50
  100. package/lib/tile/tileFactory/point.js +65 -50
  101. package/lib/tile/tileFactory/polygon.js +65 -50
  102. package/lib/tile/tileFactory/raster.js +66 -54
  103. package/lib/tile/tileFactory/rasterData.js +88 -76
  104. package/lib/tile/tileFactory/rasterDataLayer.js +97 -62
  105. package/lib/tile/tileFactory/vectorLayer.js +168 -109
  106. package/lib/tile/tileLayer/baseTileLayer.js +420 -221
  107. package/lib/tile/tmsTileLayer.js +110 -67
  108. package/lib/tile/utils.js +110 -92
  109. package/lib/utils/blend.js +59 -79
  110. package/lib/utils/collision-index.js +107 -64
  111. package/lib/utils/dataMappingStyle.js +105 -60
  112. package/lib/utils/extrude_polyline.js +600 -398
  113. package/lib/utils/grid-index.js +163 -111
  114. package/lib/utils/layerData.js +130 -99
  115. package/lib/utils/multiPassRender.js +49 -41
  116. package/lib/utils/polylineNormal.js +148 -96
  117. package/lib/utils/simpleLine.js +100 -85
  118. package/lib/utils/symbol-layout.js +219 -116
  119. package/lib/utils/updateShape.js +15 -41
  120. package/lib/wind/index.js +109 -71
  121. package/lib/wind/models/index.js +12 -30
  122. package/lib/wind/models/utils.js +144 -105
  123. package/lib/wind/models/wind.js +333 -224
  124. package/lib/wind/models/windRender.js +329 -218
  125. package/lib/wind/models/windShader.js +23 -181
  126. package/package.json +6 -6
@@ -1,103 +1,147 @@
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/polygon/models/tile.ts
23
- var tile_exports = {};
24
- __export(tile_exports, {
25
- default: () => FillModel
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(tile_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_polygon_tile_frag = __toESM(require("../shaders/tile/polygon_tile_frag.glsl"));
33
- var import_polygon_tile_vert = __toESM(require("../shaders/tile/polygon_tile_vert.glsl"));
34
- var FillModel = class extends import_BaseModel.default {
35
- getUninforms() {
36
- const {
37
- opacity = 1,
38
- tileOrigin,
39
- coord = "lnglat"
40
- } = this.layer.getLayerConfig();
41
- if (this.dataTextureTest && this.dataTextureNeedUpdate({ opacity })) {
42
- this.judgeStyleAttributes({ opacity });
43
- const encodeData = this.layer.getEncodedData();
44
- const { data, width, height } = this.calDataFrame(this.cellLength, encodeData, this.cellProperties);
45
- this.rowCount = height;
46
- this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
47
- flipY: true,
48
- data,
49
- format: import_l7_core.gl.LUMINANCE,
50
- type: import_l7_core.gl.FLOAT,
51
- width,
52
- height
53
- }) : this.createTexture2D({
54
- flipY: true,
55
- data: [1],
56
- format: import_l7_core.gl.LUMINANCE,
57
- type: import_l7_core.gl.FLOAT,
58
- width: 1,
59
- height: 1
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 _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
25
+
26
+ var _triangulation = require("../../core/triangulation");
27
+
28
+ 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); }; }
29
+
30
+ 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; } }
31
+
32
+ /* babel-plugin-inline-import '../shaders/tile/polygon_tile_frag.glsl' */
33
+ var polygon_tile_frag = "uniform float u_opacity: 1.0;\nvarying vec4 v_Color;\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n\n#pragma include \"picking\"\n\nvoid main() {\n float opacity = styleMappingMat[0][0];\n gl_FragColor = v_Color;\n gl_FragColor.a *= opacity;\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
34
+
35
+ /* babel-plugin-inline-import '../shaders/tile/polygon_tile_vert.glsl' */
36
+ var polygon_tile_vert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\nuniform float u_opacity: 1.0;\n\nuniform vec2 u_tileOrigin;\nuniform float u_coord;\n\nvarying vec4 v_Color;\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\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\nstyleMappingMat = 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\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 v_Color = a_Color;\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n project_pos.z *= mapboxZoomScale;\n }\n\nif(u_coord > 0.0) {\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xyz, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n }\n} else {\n vec2 pointPos = a_Position.xy;\n vec4 world = vec4(project_mvt_offset_position(vec4(u_tileOrigin, 0.0, 1.0)).xyz, 1.0); // \u74E6\u7247\u8D77\u59CB\u70B9\u7684\u4E16\u754C\u5750\u6807\n\n vec2 pointOffset = pointPos * pow(2.0, u_Zoom); // \u74E6\u7247\u5185\u7684\u70B9\u7684\u504F\u79FB\u5750\u6807\n \n world.xy += pointOffset;\n\n if (u_CoordinateSystem == COORDINATE_SYSTEM_METER_OFFSET || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // Needs to be divided with project_uCommonUnitsPerMeter\n world.w *= u_PixelsPerMeter.z;\n }\n\n gl_Position = u_ViewProjectionMatrix * world + u_ViewportCenterProjection;\n}\n\n\n setPickingColor(a_PickingColor);\n}\n\n";
37
+
38
+ var FillModel = /*#__PURE__*/function (_BaseModel) {
39
+ (0, _inherits2.default)(FillModel, _BaseModel);
40
+
41
+ var _super = _createSuper(FillModel);
42
+
43
+ function FillModel() {
44
+ (0, _classCallCheck2.default)(this, FillModel);
45
+ return _super.apply(this, arguments);
46
+ }
47
+
48
+ (0, _createClass2.default)(FillModel, [{
49
+ key: "getUninforms",
50
+ value: function getUninforms() {
51
+ var _ref = this.layer.getLayerConfig(),
52
+ _ref$opacity = _ref.opacity,
53
+ opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
54
+ tileOrigin = _ref.tileOrigin,
55
+ _ref$coord = _ref.coord,
56
+ coord = _ref$coord === void 0 ? 'lnglat' : _ref$coord;
57
+
58
+ if (this.dataTextureTest && this.dataTextureNeedUpdate({
59
+ opacity: opacity
60
+ })) {
61
+ this.judgeStyleAttributes({
62
+ opacity: opacity
63
+ });
64
+ var encodeData = this.layer.getEncodedData();
65
+
66
+ var _this$calDataFrame = this.calDataFrame(this.cellLength, encodeData, this.cellProperties),
67
+ data = _this$calDataFrame.data,
68
+ width = _this$calDataFrame.width,
69
+ height = _this$calDataFrame.height;
70
+
71
+ this.rowCount = height; // 当前数据纹理有多少行
72
+
73
+ this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
74
+ flipY: true,
75
+ data: data,
76
+ format: _l7Core.gl.LUMINANCE,
77
+ type: _l7Core.gl.FLOAT,
78
+ width: width,
79
+ height: height
80
+ }) : this.createTexture2D({
81
+ flipY: true,
82
+ data: [1],
83
+ format: _l7Core.gl.LUMINANCE,
84
+ type: _l7Core.gl.FLOAT,
85
+ width: 1,
86
+ height: 1
87
+ });
88
+ }
89
+
90
+ return {
91
+ u_tileOrigin: tileOrigin || [0, 0],
92
+ u_coord: coord === 'lnglat' ? 1.0 : 0.0,
93
+ u_dataTexture: this.dataTexture,
94
+ // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]
95
+ u_cellTypeLayout: this.getCellTypeLayout(),
96
+ u_opacity: opacity
97
+ };
98
+ }
99
+ }, {
100
+ key: "initModels",
101
+ value: function initModels(callbackModel) {
102
+ this.buildModels(callbackModel);
103
+ }
104
+ }, {
105
+ key: "buildModels",
106
+ value: function buildModels(callbackModel) {
107
+ var _ref2 = this.layer.getLayerConfig(),
108
+ _ref2$mask = _ref2.mask,
109
+ mask = _ref2$mask === void 0 ? false : _ref2$mask,
110
+ _ref2$maskInside = _ref2.maskInside,
111
+ maskInside = _ref2$maskInside === void 0 ? true : _ref2$maskInside;
112
+
113
+ this.layer.triangulation = _triangulation.polygonTriangulation;
114
+ this.layer.buildLayerModel({
115
+ moduleName: 'polygonTile',
116
+ vertexShader: polygon_tile_vert,
117
+ fragmentShader: polygon_tile_frag,
118
+ triangulation: _triangulation.polygonTriangulation,
119
+ primitive: _l7Core.gl.TRIANGLES,
120
+ depth: {
121
+ enable: false
122
+ },
123
+ blend: this.getBlend(),
124
+ stencil: (0, _l7Utils.getMask)(mask, maskInside)
125
+ }).then(function (model) {
126
+ callbackModel([model]);
127
+ }).catch(function (err) {
128
+ console.warn(err);
129
+ callbackModel([]);
60
130
  });
61
131
  }
62
- return {
63
- u_tileOrigin: tileOrigin || [0, 0],
64
- u_coord: coord === "lnglat" ? 1 : 0,
65
- u_dataTexture: this.dataTexture,
66
- u_cellTypeLayout: this.getCellTypeLayout(),
67
- u_opacity: opacity
68
- };
69
- }
70
- initModels(callbackModel) {
71
- this.buildModels(callbackModel);
72
- }
73
- buildModels(callbackModel) {
74
- const {
75
- mask = false,
76
- maskInside = true
77
- } = this.layer.getLayerConfig();
78
- this.layer.triangulation = import_triangulation.polygonTriangulation;
79
- this.layer.buildLayerModel({
80
- moduleName: "polygonTile",
81
- vertexShader: import_polygon_tile_vert.default,
82
- fragmentShader: import_polygon_tile_frag.default,
83
- triangulation: import_triangulation.polygonTriangulation,
84
- primitive: import_l7_core.gl.TRIANGLES,
85
- depth: { enable: false },
86
- blend: this.getBlend(),
87
- stencil: (0, import_l7_utils.getMask)(mask, maskInside)
88
- }).then((model) => {
89
- callbackModel([model]);
90
- }).catch((err) => {
91
- console.warn(err);
92
- callbackModel([]);
93
- });
94
- }
95
- clearModels() {
96
- var _a;
97
- (_a = this.dataTexture) == null ? void 0 : _a.destroy();
98
- }
99
- registerBuiltinAttributes() {
100
- }
101
- };
102
- // Annotate the CommonJS export names for ESM import in node:
103
- 0 && (module.exports = {});
132
+ }, {
133
+ key: "clearModels",
134
+ value: function clearModels() {
135
+ var _this$dataTexture;
136
+
137
+ (_this$dataTexture = this.dataTexture) === null || _this$dataTexture === void 0 ? void 0 : _this$dataTexture.destroy();
138
+ }
139
+ }, {
140
+ key: "registerBuiltinAttributes",
141
+ value: function registerBuiltinAttributes() {//
142
+ }
143
+ }]);
144
+ return FillModel;
145
+ }(_BaseModel2.default);
146
+
147
+ exports.default = FillModel;
@@ -1,160 +1,229 @@
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/polygon/models/water.ts
23
- var water_exports = {};
24
- __export(water_exports, {
25
- default: () => WaterModel
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(water_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_polygon_water_frag = __toESM(require("../shaders/water/polygon_water_frag.glsl"));
34
- var import_polygon_water_vert = __toESM(require("../shaders/water/polygon_water_vert.glsl"));
35
- var WaterModel = class extends import_BaseModel.default {
36
- getUninforms() {
37
- const {
38
- opacity = 1,
39
- speed = 0.5
40
- } = this.layer.getLayerConfig();
41
- if (this.dataTextureTest && this.dataTextureNeedUpdate({ opacity })) {
42
- this.judgeStyleAttributes({ opacity });
43
- const encodeData = this.layer.getEncodedData();
44
- const { data, width, height } = this.calDataFrame(this.cellLength, encodeData, this.cellProperties);
45
- this.rowCount = height;
46
- this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
47
- flipY: true,
48
- data,
49
- format: import_l7_core.gl.LUMINANCE,
50
- type: import_l7_core.gl.FLOAT,
51
- width,
52
- height
53
- }) : this.createTexture2D({
54
- flipY: true,
55
- data: [1],
56
- format: import_l7_core.gl.LUMINANCE,
57
- type: import_l7_core.gl.FLOAT,
58
- width: 1,
59
- height: 1
60
- });
61
- }
62
- return {
63
- u_texture: this.texture,
64
- u_dataTexture: this.dataTexture,
65
- u_cellTypeLayout: this.getCellTypeLayout(),
66
- u_speed: speed,
67
- u_opacity: (0, import_lodash.isNumber)(opacity) ? opacity : 1
68
- };
69
- }
70
- getAnimateUniforms() {
71
- return {
72
- u_time: this.layer.getLayerAnimateTime()
73
- };
74
- }
75
- initModels(callbackModel) {
76
- this.loadTexture();
77
- this.buildModels(callbackModel);
78
- }
79
- buildModels(callbackModel) {
80
- const {
81
- mask = false,
82
- maskInside = true
83
- } = this.layer.getLayerConfig();
84
- this.layer.buildLayerModel({
85
- moduleName: "polygonWater",
86
- vertexShader: import_polygon_water_vert.default,
87
- fragmentShader: import_polygon_water_frag.default,
88
- triangulation: import_triangulation.polygonTriangulation,
89
- primitive: import_l7_core.gl.TRIANGLES,
90
- depth: { enable: false },
91
- stencil: (0, import_l7_utils.getMask)(mask, maskInside)
92
- }).then((model) => {
93
- callbackModel([model]);
94
- }).catch((err) => {
95
- console.warn(err);
96
- callbackModel([]);
97
- });
98
- }
99
- clearModels() {
100
- var _a, _b;
101
- (_a = this.texture) == null ? void 0 : _a.destroy();
102
- (_b = this.dataTexture) == null ? void 0 : _b.destroy();
8
+ exports.default = void 0;
9
+
10
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
+
12
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
+
14
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
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 _l7Core = require("@antv/l7-core");
23
+
24
+ var _l7Utils = require("@antv/l7-utils");
25
+
26
+ var _lodash = require("lodash");
27
+
28
+ var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
29
+
30
+ var _triangulation = require("../../core/triangulation");
31
+
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
+
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
+
36
+ /* babel-plugin-inline-import '../shaders/water/polygon_water_frag.glsl' */
37
+ var water_frag = "uniform sampler2D u_texture;\nuniform float u_time: 0.0;\nuniform float u_speed: 1.0;\nuniform float u_opacity: 1.0;\n\nvarying vec4 v_Color;\nvarying vec2 v_uv;\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n\n\nfloat rand(vec2 n) { return 0.5 + 0.5 * fract(sin(dot(n.xy, vec2(12.9898, 78.233)))* 43758.5453); }\n\nfloat water(vec3 p) {\n float t = u_time * u_speed;\n p.z += t * 2.; p.x += t * 2.;\n vec3 c1 = texture2D(u_texture, p.xz / 30.).xyz;\n p.z += t * 3.; p.x += t * 0.52;\n vec3 c2 = texture2D(u_texture, p.xz / 30.).xyz;\n p.z += t * 4.; p.x += t * 0.8;\n vec3 c3 = texture2D(u_texture, p.xz / 30.).xyz;\n c1 += c2 - c3;\n float z = (c1.x + c1.y + c1.z) / 3.;\n return p.y + z / 4.;\n}\n\nfloat map(vec3 p) {\n float d = 100.0;\n d = water(p);\n return d;\n}\n\nfloat intersect(vec3 ro, vec3 rd) {\n float d = 0.0;\n for (int i = 0; i <= 100; i++) {\n float h = map(ro + rd * d);\n if (h < 0.1) return d;\n d += h;\n }\n return 0.0;\n}\n\nvec3 norm(vec3 p) {\n float eps = .1;\n return normalize(vec3(\n map(p + vec3(eps, 0, 0)) - map(p + vec3(-eps, 0, 0)),\n map(p + vec3(0, eps, 0)) - map(p + vec3(0, -eps, 0)),\n map(p + vec3(0, 0, eps)) - map(p + vec3(0, 0, -eps))\n ));\n} \n\nfloat calSpc() {\n vec3 l1 = normalize(vec3(1, 1, 1));\n vec3 ro = vec3(-3, 20, -8);\n vec3 rc = vec3(0, 0, 0);\n vec3 ww = normalize(rc - ro);\n vec3 uu = normalize(cross(vec3(0,1,0), ww));\n vec3 vv = normalize(cross(rc - ro, uu));\n vec3 rd = normalize(uu * v_uv.x + vv * v_uv.y + ww);\n float d = intersect(ro, rd);\n vec3 p = ro + rd * d;\n vec3 n = norm(p);\n float spc = pow(max(0.0, dot(reflect(l1, n), rd)), 30.0);\n return spc;\n}\n\nvoid main() {\n float opacity = styleMappingMat[0][0];\n gl_FragColor = v_Color;\n gl_FragColor.a *= opacity;\n\n float spc = calSpc();\n gl_FragColor += spc * 0.4;\n}\n";
38
+
39
+ /* babel-plugin-inline-import '../shaders/water/polygon_water_vert.glsl' */
40
+ var water_vert = "attribute vec4 a_Color;\nattribute vec2 a_uv;\nattribute vec3 a_Position;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\nvarying vec4 v_Color;\nvarying vec2 v_uv;\nuniform float u_opacity: 1.0;\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\n#pragma include \"projection\"\n\nvoid main() {\n v_uv = a_uv;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\nstyleMappingMat = 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\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 v_Color = a_Color;\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xyz, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n }\n}\n\n";
41
+
42
+ var WaterModel = /*#__PURE__*/function (_BaseModel) {
43
+ (0, _inherits2.default)(WaterModel, _BaseModel);
44
+
45
+ var _super = _createSuper(WaterModel);
46
+
47
+ function WaterModel() {
48
+ (0, _classCallCheck2.default)(this, WaterModel);
49
+ return _super.apply(this, arguments);
103
50
  }
104
- registerBuiltinAttributes() {
105
- const bbox = this.layer.getSource().extent;
106
- const [minLng, minLat, maxLng, maxLat] = bbox;
107
- const lngLen = maxLng - minLng;
108
- const latLen = maxLat - minLat;
109
- this.styleAttributeService.registerStyleAttribute({
110
- name: "waterUv",
111
- type: import_l7_core.AttributeType.Attribute,
112
- descriptor: {
113
- name: "a_uv",
114
- buffer: {
115
- usage: import_l7_core.gl.STATIC_DRAW,
116
- data: [],
117
- type: import_l7_core.gl.FLOAT
51
+
52
+ (0, _createClass2.default)(WaterModel, [{
53
+ key: "getUninforms",
54
+ value: function getUninforms() {
55
+ var _ref = this.layer.getLayerConfig(),
56
+ _ref$opacity = _ref.opacity,
57
+ opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
58
+ _ref$speed = _ref.speed,
59
+ speed = _ref$speed === void 0 ? 0.5 : _ref$speed;
60
+
61
+ if (this.dataTextureTest && this.dataTextureNeedUpdate({
62
+ opacity: opacity
63
+ })) {
64
+ this.judgeStyleAttributes({
65
+ opacity: opacity
66
+ });
67
+ var encodeData = this.layer.getEncodedData();
68
+
69
+ var _this$calDataFrame = this.calDataFrame(this.cellLength, encodeData, this.cellProperties),
70
+ data = _this$calDataFrame.data,
71
+ width = _this$calDataFrame.width,
72
+ height = _this$calDataFrame.height;
73
+
74
+ this.rowCount = height; // 当前数据纹理有多少行
75
+
76
+ this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
77
+ flipY: true,
78
+ data: data,
79
+ format: _l7Core.gl.LUMINANCE,
80
+ type: _l7Core.gl.FLOAT,
81
+ width: width,
82
+ height: height
83
+ }) : this.createTexture2D({
84
+ flipY: true,
85
+ data: [1],
86
+ format: _l7Core.gl.LUMINANCE,
87
+ type: _l7Core.gl.FLOAT,
88
+ width: 1,
89
+ height: 1
90
+ });
91
+ }
92
+
93
+ return {
94
+ u_texture: this.texture,
95
+ u_dataTexture: this.dataTexture,
96
+ // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]
97
+ u_cellTypeLayout: this.getCellTypeLayout(),
98
+ u_speed: speed,
99
+ u_opacity: (0, _lodash.isNumber)(opacity) ? opacity : 1.0
100
+ };
101
+ }
102
+ }, {
103
+ key: "getAnimateUniforms",
104
+ value: function getAnimateUniforms() {
105
+ return {
106
+ u_time: this.layer.getLayerAnimateTime()
107
+ };
108
+ }
109
+ }, {
110
+ key: "initModels",
111
+ value: function initModels(callbackModel) {
112
+ this.loadTexture();
113
+ this.buildModels(callbackModel);
114
+ }
115
+ }, {
116
+ key: "buildModels",
117
+ value: function buildModels(callbackModel) {
118
+ var _ref2 = this.layer.getLayerConfig(),
119
+ _ref2$mask = _ref2.mask,
120
+ mask = _ref2$mask === void 0 ? false : _ref2$mask,
121
+ _ref2$maskInside = _ref2.maskInside,
122
+ maskInside = _ref2$maskInside === void 0 ? true : _ref2$maskInside;
123
+
124
+ this.layer.buildLayerModel({
125
+ moduleName: 'polygonWater',
126
+ vertexShader: water_vert,
127
+ fragmentShader: water_frag,
128
+ triangulation: _triangulation.polygonTriangulation,
129
+ primitive: _l7Core.gl.TRIANGLES,
130
+ depth: {
131
+ enable: false
118
132
  },
119
- size: 2,
120
- update: (feature, featureIdx, vertex, attributeIdx, normal) => {
121
- const [lng, lat] = vertex;
122
- return [(lng - minLng) / lngLen, (lat - minLat) / latLen];
133
+ stencil: (0, _l7Utils.getMask)(mask, maskInside)
134
+ }).then(function (model) {
135
+ callbackModel([model]);
136
+ }).catch(function (err) {
137
+ console.warn(err);
138
+ callbackModel([]);
139
+ });
140
+ }
141
+ }, {
142
+ key: "clearModels",
143
+ value: function clearModels() {
144
+ var _this$texture, _this$dataTexture;
145
+
146
+ (_this$texture = this.texture) === null || _this$texture === void 0 ? void 0 : _this$texture.destroy();
147
+ (_this$dataTexture = this.dataTexture) === null || _this$dataTexture === void 0 ? void 0 : _this$dataTexture.destroy();
148
+ }
149
+ }, {
150
+ key: "registerBuiltinAttributes",
151
+ value: function registerBuiltinAttributes() {
152
+ var bbox = this.layer.getSource().extent;
153
+
154
+ var _bbox = (0, _slicedToArray2.default)(bbox, 4),
155
+ minLng = _bbox[0],
156
+ minLat = _bbox[1],
157
+ maxLng = _bbox[2],
158
+ maxLat = _bbox[3];
159
+
160
+ var lngLen = maxLng - minLng;
161
+ var latLen = maxLat - minLat;
162
+ this.styleAttributeService.registerStyleAttribute({
163
+ name: 'waterUv',
164
+ type: _l7Core.AttributeType.Attribute,
165
+ descriptor: {
166
+ name: 'a_uv',
167
+ buffer: {
168
+ // give the WebGL driver a hint that this buffer may change
169
+ usage: _l7Core.gl.STATIC_DRAW,
170
+ data: [],
171
+ type: _l7Core.gl.FLOAT
172
+ },
173
+ size: 2,
174
+ update: function update(feature, featureIdx, vertex, attributeIdx, normal) {
175
+ var _vertex = (0, _slicedToArray2.default)(vertex, 2),
176
+ lng = _vertex[0],
177
+ lat = _vertex[1];
178
+
179
+ return [(lng - minLng) / lngLen, (lat - minLat) / latLen];
180
+ }
123
181
  }
124
- }
125
- });
126
- }
127
- loadTexture() {
128
- const {
129
- waterTexture
130
- } = this.layer.getLayerConfig();
131
- const { createTexture2D } = this.rendererService;
132
- this.texture = createTexture2D({
133
- height: 0,
134
- width: 0
135
- });
136
- const image = new Image();
137
- image.crossOrigin = "";
138
- if (waterTexture) {
139
- console.warn("L7 recommend\uFF1Ahttps://gw.alipayobjects.com/mdn/rms_816329/afts/img/A*EojwT4VzSiYAAAAAAAAAAAAAARQnAQ");
140
- image.src = waterTexture;
141
- } else {
142
- image.src = "https://gw.alipayobjects.com/mdn/rms_816329/afts/img/A*EojwT4VzSiYAAAAAAAAAAAAAARQnAQ";
182
+ });
143
183
  }
144
- image.onload = () => {
184
+ }, {
185
+ key: "loadTexture",
186
+ value: function loadTexture() {
187
+ var _this = this;
188
+
189
+ var _ref3 = this.layer.getLayerConfig(),
190
+ waterTexture = _ref3.waterTexture;
191
+
192
+ var createTexture2D = this.rendererService.createTexture2D;
145
193
  this.texture = createTexture2D({
146
- data: image,
147
- width: image.width,
148
- height: image.height,
149
- wrapS: import_l7_core.gl.MIRRORED_REPEAT,
150
- wrapT: import_l7_core.gl.MIRRORED_REPEAT,
151
- min: import_l7_core.gl.LINEAR,
152
- mag: import_l7_core.gl.LINEAR
194
+ height: 0,
195
+ width: 0
153
196
  });
154
- this.layerService.updateLayerRenderList();
155
- this.layerService.renderLayers();
156
- };
157
- }
158
- };
159
- // Annotate the CommonJS export names for ESM import in node:
160
- 0 && (module.exports = {});
197
+ var image = new Image();
198
+ image.crossOrigin = '';
199
+
200
+ if (waterTexture) {
201
+ // custom texture
202
+ console.warn('L7 recommend:https://gw.alipayobjects.com/mdn/rms_816329/afts/img/A*EojwT4VzSiYAAAAAAAAAAAAAARQnAQ');
203
+ image.src = waterTexture;
204
+ } else {
205
+ // default texture
206
+ image.src = 'https://gw.alipayobjects.com/mdn/rms_816329/afts/img/A*EojwT4VzSiYAAAAAAAAAAAAAARQnAQ';
207
+ }
208
+
209
+ image.onload = function () {
210
+ _this.texture = createTexture2D({
211
+ data: image,
212
+ width: image.width,
213
+ height: image.height,
214
+ wrapS: _l7Core.gl.MIRRORED_REPEAT,
215
+ wrapT: _l7Core.gl.MIRRORED_REPEAT,
216
+ min: _l7Core.gl.LINEAR,
217
+ mag: _l7Core.gl.LINEAR
218
+ });
219
+
220
+ _this.layerService.updateLayerRenderList();
221
+
222
+ _this.layerService.renderLayers();
223
+ };
224
+ }
225
+ }]);
226
+ return WaterModel;
227
+ }(_BaseModel2.default);
228
+
229
+ exports.default = WaterModel;