@antv/l7-layers 2.9.23 → 2.9.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/Geometry/models/plane.d.ts +1 -0
- package/es/citybuliding/building.js +1 -1
- package/es/core/BaseLayer.js +10 -3
- package/es/core/interface.d.ts +26 -48
- package/es/core/interface.js +3 -0
- package/es/core/schema.d.ts +3 -3
- package/es/core/triangulation.d.ts +4 -3
- package/es/core/triangulation.js +54 -39
- package/es/heatmap/models/heatmap.js +1 -1
- package/es/image/models/image.js +7 -1
- package/es/line/index.js +4 -1
- package/es/line/models/arc.js +1 -1
- package/es/line/models/simpleLine.js +1 -1
- package/es/line/shaders/line_arc_vert.glsl +5 -3
- package/es/line/shaders/simple/simpleline_vert.glsl +1 -0
- package/es/plugins/FeatureScalePlugin.js +0 -1
- package/es/point/index.js +3 -1
- package/es/point/models/fill.js +5 -2
- package/es/point/models/fillmage.js +9 -3
- package/es/point/models/image.js +8 -2
- package/es/point/models/radar.js +2 -3
- package/es/point/models/tile.js +1 -1
- package/es/point/shaders/fill_vert.glsl +13 -6
- package/es/point/shaders/image/fillImage_vert.glsl +13 -5
- package/es/point/shaders/image_vert.glsl +17 -8
- package/es/polygon/index.js +4 -1
- package/es/raster/index.js +3 -1
- package/es/tile/manager/tileLayerManager.d.ts +3 -2
- package/es/tile/manager/tileLayerManager.js +5 -2
- package/es/tile/models/tileModel.js +4 -3
- package/es/tile/tileFactory/base.d.ts +1 -1
- package/es/tile/tileFactory/base.js +32 -5
- package/es/tile/tileFactory/vectorLayer.d.ts +3 -1
- package/es/tile/tileFactory/vectorLayer.js +22 -1
- package/es/tile/tileLayer/baseTileLayer.d.ts +1 -1
- package/es/tile/tileLayer/baseTileLayer.js +3 -2
- package/es/tile/utils.d.ts +2 -0
- package/es/tile/utils.js +5 -1
- package/lib/Geometry/index.js +114 -77
- package/lib/Geometry/models/billboard.js +232 -181
- package/lib/Geometry/models/index.js +18 -34
- package/lib/Geometry/models/plane.js +407 -278
- package/lib/Geometry/models/sprite.js +291 -189
- package/lib/canvas/index.js +101 -66
- package/lib/canvas/models/canvas.js +207 -140
- package/lib/canvas/models/index.js +12 -30
- package/lib/citybuliding/building.js +98 -63
- package/lib/citybuliding/models/build.js +192 -146
- package/lib/core/BaseLayer.js +1331 -809
- package/lib/core/BaseModel.js +457 -279
- package/lib/core/interface.js +40 -53
- package/lib/core/schema.js +21 -39
- package/lib/core/shape/Path.js +67 -79
- package/lib/core/shape/extrude.js +132 -91
- package/lib/core/triangulation.js +412 -213
- package/lib/earth/index.js +100 -62
- package/lib/earth/models/atmosphere.js +146 -112
- package/lib/earth/models/base.js +210 -150
- package/lib/earth/models/bloomsphere.js +146 -112
- package/lib/earth/utils.js +111 -91
- package/lib/heatmap/index.js +149 -92
- package/lib/heatmap/models/grid.js +118 -91
- package/lib/heatmap/models/grid3d.js +155 -123
- package/lib/heatmap/models/heatmap.js +475 -338
- package/lib/heatmap/models/hexagon.js +121 -92
- package/lib/heatmap/models/index.js +22 -37
- package/lib/heatmap/triangulation.js +31 -47
- package/lib/image/index.js +111 -74
- package/lib/image/models/dataImage.js +232 -174
- package/lib/image/models/image.js +175 -123
- package/lib/image/models/index.js +15 -32
- package/lib/index.js +263 -97
- package/lib/line/index.js +131 -83
- package/lib/line/models/arc.js +352 -237
- package/lib/line/models/arc_3d.js +334 -228
- package/lib/line/models/earthArc_3d.js +336 -228
- package/lib/line/models/great_circle.js +291 -200
- package/lib/line/models/half.js +286 -201
- package/lib/line/models/index.js +42 -50
- package/lib/line/models/line.js +428 -299
- package/lib/line/models/linearline.js +277 -203
- package/lib/line/models/simpleLine.js +239 -175
- package/lib/line/models/tile.js +348 -237
- package/lib/line/models/wall.js +327 -235
- package/lib/line/shaders/line_arc_vert.glsl +5 -3
- package/lib/line/shaders/simple/simpleline_vert.glsl +1 -0
- package/lib/mask/index.js +92 -59
- package/lib/mask/models/fill.js +134 -82
- package/lib/mask/models/index.js +12 -30
- package/lib/plugins/DataMappingPlugin.js +342 -224
- package/lib/plugins/DataSourcePlugin.js +102 -87
- package/lib/plugins/FeatureScalePlugin.js +330 -241
- package/lib/plugins/LayerAnimateStylePlugin.js +61 -55
- package/lib/plugins/LayerModelPlugin.js +80 -73
- package/lib/plugins/LayerStylePlugin.js +48 -51
- package/lib/plugins/LightingPlugin.js +80 -68
- package/lib/plugins/MultiPassRendererPlugin.js +91 -65
- package/lib/plugins/PixelPickingPlugin.js +150 -109
- package/lib/plugins/RegisterStyleAttributePlugin.js +110 -110
- package/lib/plugins/ShaderUniformPlugin.js +118 -99
- package/lib/plugins/UpdateModelPlugin.js +40 -47
- package/lib/plugins/UpdateStyleAttributePlugin.js +93 -75
- package/lib/point/index.js +226 -148
- package/lib/point/models/earthExtrude.js +279 -201
- package/lib/point/models/earthFill.js +287 -202
- package/lib/point/models/extrude.js +299 -203
- package/lib/point/models/fill.js +406 -273
- package/lib/point/models/fillmage.js +365 -252
- package/lib/point/models/image.js +241 -164
- package/lib/point/models/index.js +46 -52
- package/lib/point/models/normal.js +183 -134
- package/lib/point/models/radar.js +304 -212
- package/lib/point/models/simplePoint.js +194 -142
- package/lib/point/models/text.js +608 -385
- package/lib/point/models/tile.js +314 -223
- package/lib/point/shaders/fill_vert.glsl +13 -6
- package/lib/point/shaders/image/fillImage_vert.glsl +13 -5
- package/lib/point/shaders/image_vert.glsl +17 -8
- package/lib/point/shape/extrude.js +56 -52
- package/lib/polygon/index.js +154 -100
- package/lib/polygon/models/extrude.js +311 -223
- package/lib/polygon/models/fill.js +215 -153
- package/lib/polygon/models/index.js +46 -52
- package/lib/polygon/models/ocean.js +244 -173
- package/lib/polygon/models/tile.js +144 -100
- package/lib/polygon/models/water.js +222 -153
- package/lib/raster/buffers/triangulation.js +27 -40
- package/lib/raster/index.js +115 -74
- package/lib/raster/models/index.js +16 -33
- package/lib/raster/models/raster.js +178 -135
- package/lib/raster/raster.js +187 -132
- package/lib/tile/interface.js +4 -16
- package/lib/tile/manager/tileConfigManager.js +125 -86
- package/lib/tile/manager/tileLayerManager.js +314 -227
- package/lib/tile/manager/tilePickerManager.js +192 -123
- package/lib/tile/models/tileModel.js +71 -51
- package/lib/tile/tileFactory/base.js +433 -292
- package/lib/tile/tileFactory/index.js +51 -49
- package/lib/tile/tileFactory/line.js +65 -50
- package/lib/tile/tileFactory/point.js +65 -50
- package/lib/tile/tileFactory/polygon.js +65 -50
- package/lib/tile/tileFactory/raster.js +66 -54
- package/lib/tile/tileFactory/rasterData.js +88 -76
- package/lib/tile/tileFactory/rasterDataLayer.js +97 -62
- package/lib/tile/tileFactory/vectorLayer.js +169 -95
- package/lib/tile/tileLayer/baseTileLayer.js +420 -220
- package/lib/tile/tmsTileLayer.js +110 -67
- package/lib/tile/utils.js +113 -87
- package/lib/utils/blend.js +59 -79
- package/lib/utils/collision-index.js +107 -64
- package/lib/utils/dataMappingStyle.js +105 -60
- package/lib/utils/extrude_polyline.js +600 -398
- package/lib/utils/grid-index.js +163 -111
- package/lib/utils/layerData.js +130 -99
- package/lib/utils/multiPassRender.js +49 -41
- package/lib/utils/polylineNormal.js +148 -96
- package/lib/utils/simpleLine.js +100 -85
- package/lib/utils/symbol-layout.js +219 -116
- package/lib/utils/updateShape.js +15 -41
- package/lib/wind/index.js +109 -71
- package/lib/wind/models/index.js +12 -30
- package/lib/wind/models/utils.js +144 -105
- package/lib/wind/models/wind.js +333 -224
- package/lib/wind/models/windRender.js +329 -218
- package/lib/wind/models/windShader.js +23 -181
- package/package.json +7 -6
package/lib/line/models/line.js
CHANGED
|
@@ -1,330 +1,459 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
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";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
21
4
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
__export(line_exports, {
|
|
25
|
-
default: () => LineModel
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
26
7
|
});
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
var
|
|
32
|
-
|
|
33
|
-
var
|
|
34
|
-
|
|
35
|
-
var
|
|
36
|
-
|
|
37
|
-
var
|
|
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 _lodash = require("lodash");
|
|
29
|
+
|
|
30
|
+
var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
|
|
31
|
+
|
|
32
|
+
var _interface = require("../../core/interface");
|
|
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/dash/line_dash_frag.glsl' */
|
|
39
|
+
// import { LineTriangulation } from '../../core/triangulation';
|
|
40
|
+
// dash line shader
|
|
41
|
+
var line_dash_frag = "#define LineTypeSolid 0.0\nuniform float u_opacity : 1.0;\n\nvarying vec4 v_color;\n\n// dash\nvarying vec4 v_dash_array;\n\n#pragma include \"picking\"\n\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ]; // \u63A7\u5236\u8FD0\u52A8\n\nvarying mat4 styleMappingMat;\n// [animate, duration, interval, trailLength],\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 gl_FragColor = v_color;\n gl_FragColor.a *= opacity; // \u5168\u5C40\u900F\u660E\u5EA6\n \n float dashLength = mod(d_distance_ratio, v_dash_array.x + v_dash_array.y + v_dash_array.z + v_dash_array.w);\n if(dashLength < v_dash_array.x || (dashLength > (v_dash_array.x + v_dash_array.y) && dashLength < v_dash_array.x + v_dash_array.y + v_dash_array.z)) {\n // \u5B9E\u7EBF\u90E8\u5206\n } else {\n // \u865A\u7EBF\u90E8\u5206\n discard;\n };\n\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
|
|
42
|
+
|
|
43
|
+
/* babel-plugin-inline-import '../shaders/dash/line_dash_vert.glsl' */
|
|
44
|
+
var line_dash_vert = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n\nattribute float a_Miter;\nattribute vec4 a_Color;\nattribute vec2 a_Size;\nattribute vec3 a_Normal;\nattribute vec3 a_Position;\n\nattribute vec2 a_iconMapUV;\n\n// dash line\nattribute float a_Total_Distance;\nattribute vec2 a_DistanceAndIndex;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform vec4 u_dash_array: [10.0, 5., 0, 0];\n\nuniform float u_vertexScale: 1.0;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvarying vec4 v_color;\nvarying vec4 v_dash_array;\n\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\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 v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / a_Total_Distance;\n v_color = a_Color;\n\n vec3 size = a_Miter * setPickingSize(a_Size.x) * reverse_offset_normal(a_Normal);\n vec2 offset = project_pixel(size.xy);\n\n // \u8BBE\u7F6E\u6570\u636E\u96C6\u7684\u53C2\u6570\n styleMappingMat[3][0] = a_DistanceAndIndex.x / a_Total_Distance; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n styleMappingMat[3][1] = a_DistanceAndIndex.x; // \u5F53\u524D\u9876\u70B9\u7684\u8DDD\u79BB\n\n vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));\n\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, a_Size.y, 1.0));\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xy + offset, project_pixel(a_Size.y), 1.0));\n } else {\n float lineHeight = a_Size.y;\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 + offset, lineHeight, 1.0));\n }\n\n setPickingColor(a_PickingColor);\n}\n"; // basic line shader
|
|
45
|
+
|
|
46
|
+
/* babel-plugin-inline-import '../shaders/line_frag.glsl' */
|
|
47
|
+
var line_frag = "#define Animate 0.0\n#define LineTexture 1.0\nuniform float u_opacity : 1.0;\nuniform float u_textureBlend;\n\nuniform float u_borderWidth: 0.0;\n\nuniform vec3 u_blur;\nuniform vec4 u_borderColor;\nvarying vec4 v_color;\n\n// line texture\nuniform float u_line_texture;\nuniform sampler2D u_texture;\nuniform vec2 u_textSize;\n\nvarying vec2 v_iconMapUV;\n\n#pragma include \"picking\"\n\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ]; // \u63A7\u5236\u8FD0\u52A8\n\nvarying mat4 styleMappingMat;\n// [animate, duration, interval, trailLength],\nvoid main() {\n float opacity = styleMappingMat[0][0];\n float animateSpeed = 0.0; // \u8FD0\u52A8\u901F\u5EA6\n float d_distance_ratio = styleMappingMat[3].r; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n gl_FragColor = v_color;\n // anti-alias\n // float blur = 1.0 - smoothstep(u_blur, 1., length(v_normal.xy));\n gl_FragColor.a *= opacity; // \u5168\u5C40\u900F\u660E\u5EA6\n if(u_aimate.x == Animate) {\n animateSpeed = u_time / u_aimate.y;\n float alpha =1.0 - fract( mod(1.0- d_distance_ratio, u_aimate.z)* (1.0/ u_aimate.z) + animateSpeed);\n alpha = (alpha + u_aimate.w -1.0) / u_aimate.w;\n alpha = smoothstep(0., 1., alpha);\n gl_FragColor.a *= alpha;\n }\n\n if(u_line_texture == LineTexture) { // while load texture\n float aDistance = styleMappingMat[3].g; // \u5F53\u524D\u9876\u70B9\u7684\u8DDD\u79BB\n float d_texPixelLen = styleMappingMat[3].b; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n float u = fract(mod(aDistance, d_texPixelLen)/d_texPixelLen - animateSpeed);\n float v = styleMappingMat[3].a; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n // v = max(smoothstep(0.95, 1.0, v), v);\n vec2 uv= v_iconMapUV / u_textSize + vec2(u, v) / u_textSize * 64.;\n \n // gl_FragColor = filterColor(gl_FragColor + texture2D(u_texture, vec2(u, v)));\n // gl_FragColor = filterColor(gl_FragColor + texture2D(u_texture, uv));\n vec4 pattern = texture2D(u_texture, uv);\n\n if(u_textureBlend == 0.0) { // normal\n pattern.a = 0.0;\n gl_FragColor += pattern;\n } else { // replace\n pattern.a *= opacity;\n if(gl_FragColor.a <= 0.0) {\n pattern.a = 0.0;\n }\n gl_FragColor = pattern;\n }\n } \n\n float v = styleMappingMat[3].a;\n float borderWidth = min(0.5, u_borderWidth);\n // \u7ED8\u5236 border\n if(borderWidth > 0.01) {\n float borderOuterWidth = borderWidth/2.0;\n\n if(v >= 1.0 - borderWidth || v <= borderWidth) {\n if(v > borderWidth) {\n float linear = smoothstep(0.0, 1.0, (v - (1.0 - borderWidth))/borderWidth);\n gl_FragColor.rgb = mix(gl_FragColor.rgb, u_borderColor.rgb, linear);\n } else if(v <= borderWidth) {\n float linear = smoothstep(0.0, 1.0, v/borderWidth);\n gl_FragColor.rgb = mix(u_borderColor.rgb, gl_FragColor.rgb, linear);\n }\n }\n\n if(v < borderOuterWidth) {\n gl_FragColor.a = mix(0.0, gl_FragColor.a, v/borderOuterWidth);\n } else if(v > 1.0 - borderOuterWidth) {\n gl_FragColor.a = mix(gl_FragColor.a, 0.0, (v - (1.0 - borderOuterWidth))/borderOuterWidth);\n }\n }\n\n // blur\n float blurV = styleMappingMat[3][3];\n if(blurV < 0.5) {\n gl_FragColor.a *= mix(u_blur.r, u_blur.g, blurV/0.5);\n } else {\n gl_FragColor.a *= mix(u_blur.g, u_blur.b, (blurV - 0.5)/0.5);\n }\n \n\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
|
|
48
|
+
|
|
49
|
+
/* babel-plugin-inline-import '../shaders/line_vert.glsl' */
|
|
50
|
+
var line_vert = "\n#define Animate 0.0\n\nattribute float a_Miter;\nattribute vec4 a_Color;\nattribute vec2 a_Size;\nattribute vec3 a_Normal;\nattribute vec3 a_Position;\n\nattribute vec2 a_iconMapUV;\n\n// dash line\nattribute float a_Total_Distance;\nattribute vec2 a_DistanceAndIndex;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\nuniform float u_icon_step: 100;\n\nuniform float u_heightfixed: 0.0;\nuniform float u_vertexScale: 1.0;\nuniform float u_raisingHeight: 0.0;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvarying vec4 v_color;\n\n// texV \u7EBF\u56FE\u5C42 - \u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\uFF08\u7EBF\u7684\u5BBD\u5EA6\u65B9\u5411\uFF09\nvarying vec2 v_iconMapUV;\n\n\nuniform float u_linearColor: 0;\nuniform float u_arrow: 0.0;\nuniform float u_arrowHeight: 3.0;\nuniform float u_arrowWidth: 2.0;\nuniform float u_tailWidth: 1.0;\n\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\nvec2 calculateArrow(vec2 offset) {\n /*\n * \u5728\u652F\u6301\u7BAD\u5934\u7684\u65F6\u5019\uFF0C\u7B2C\u4E8C\u3001\u7B2C\u4E09\u7EC4\u9876\u70B9\u662F\u989D\u5916\u63D2\u5165\u7528\u4E8E\u6784\u5EFA\u9876\u70B9\u7684\n */\n float arrowFlag = -1.0;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n // \u9AD8\u5FB7 2.0 \u7684\u65CB\u8F6C\u89D2\u5EA6\u4E0D\u540C\n arrowFlag = 1.0;\n }\n float pi = arrowFlag * 3.1415926/2.;\n if(a_Miter < 0.) {\n // \u6839\u636E\u7EBF\u7684\u4E24\u4FA7\u504F\u79FB\u4E0D\u540C\u3001\u65CB\u8F6C\u7684\u65B9\u5411\u76F8\u53CD\n pi = -pi;\n }\n highp float angle_sin = sin(pi);\n highp float angle_cos = cos(pi);\n // \u8BA1\u7B97\u5782\u76F4\u4E0E\u7EBF\u65B9\u5411\u7684\u65CB\u8F6C\u77E9\u9635\n mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);\n float arrowWidth = u_arrowWidth;\n float arrowHeight = u_arrowHeight;\n\n vec2 arrowOffset = vec2(0.0);\n /*\n * a_DistanceAndIndex.y \u7528\u4E8E\u6807\u8BB0\u5F53\u524D\u9876\u70B9\u5C5E\u4E8E\u54EA\u4E00\u7EC4\uFF08\u4E24\u4E2A\u9876\u70B9\u4E00\u7EC4\uFF0C\u6784\u6210\u7EBF\u7684\u5176\u5B9E\u662F\u77E9\u5F62\uFF0C\u6700\u7B80\u9700\u8981\u56DB\u4E2A\u9876\u70B9\u3001\u4E24\u7EC4\u9876\u70B9\u6784\u6210\uFF09\n */\n if(a_DistanceAndIndex.y == 0.0) {\n // \u7BAD\u5934\u5C16\u90E8\n offset = vec2(0.0);\n } else if(a_DistanceAndIndex.y == 1.0) {\n // \u7BAD\u5934\u4E24\u4FA7\n arrowOffset = rotation_matrix*(offset * arrowHeight);\n offset += arrowOffset; // \u6CBF\u7EBF\u504F\u79FB\n offset = offset * arrowWidth; // \u5782\u76F4\u7EBF\u5411\u5916\u504F\u79FB\uFF08\u662F\u6784\u5EFA\u7BAD\u5934\u4E24\u4FA7\u7684\u9876\u70B9\uFF09\n } else if(a_DistanceAndIndex.y == 2.0 || a_DistanceAndIndex.y == 3.0 || a_DistanceAndIndex.y == 4.0) {\n // \u504F\u79FB\u5176\u4F59\u7684\u70B9\u4F4D\uFF08\u5C06\u957F\u5EA6\u8BA9\u4F4D\u7ED9\u7BAD\u5934\uFF09\n arrowOffset = rotation_matrix*(offset * arrowHeight) * arrowWidth;\n offset += arrowOffset;// \u6CBF\u7EBF\u504F\u79FB\n }\n\n return offset;\n}\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 float d_texPixelLen; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n\n v_iconMapUV = a_iconMapUV;\n d_texPixelLen = project_float_pixel(u_icon_step);\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n d_texPixelLen *= 10.0;\n }\n\n v_color = a_Color;\n\n vec3 size = a_Miter * setPickingSize(a_Size.x) * reverse_offset_normal(a_Normal);\n \n vec2 offset = project_pixel(size.xy);\n\n float lineDistance = a_DistanceAndIndex.x;\n float currentLinePointRatio = lineDistance / a_Total_Distance;\n \n if(u_arrow > 0.0) {\n // \u8BA1\u7B97\u7BAD\u5934\n offset = calculateArrow(offset);\n\n if(a_DistanceAndIndex.y > 4.0) {\n offset *= mix(1.0, u_tailWidth, currentLinePointRatio);\n }\n }\n\n float lineOffsetWidth = length(offset + offset * sign(a_Miter)); // \u7EBF\u6A2A\u5411\u504F\u79FB\u7684\u8DDD\u79BB\uFF08\u5411\u4E24\u4FA7\u504F\u79FB\u7684\u548C\uFF09\n float linePixelSize = project_pixel(a_Size.x) * 2.0; // \u5B9A\u70B9\u4F4D\u7F6E\u504F\u79FB\uFF0C\u6309\u5730\u56FE\u7B49\u7EA7\u7F29\u653E\u540E\u7684\u8DDD\u79BB \u5355\u4FA7 * 2\n float texV = lineOffsetWidth/linePixelSize; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n // \u8BBE\u7F6E\u6570\u636E\u96C6\u7684\u53C2\u6570\n styleMappingMat[3][0] = currentLinePointRatio; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n styleMappingMat[3][1] = lineDistance; // \u5F53\u524D\u9876\u70B9\u7684\u8DDD\u79BB\n styleMappingMat[3][2] = d_texPixelLen; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n styleMappingMat[3][3] = texV; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));\n\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, a_Size.y, 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 vertex height\n float lineHeight = a_Size.y; // size \u7B2C\u4E8C\u4E2A\u53C2\u6570\u4EE3\u8868\u7684\u9AD8\u5EA6 [linewidth, lineheight]\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n lineHeight *= 0.2; // \u4FDD\u6301\u548C amap/mapbox \u4E00\u81F4\u7684\u6548\u679C\n h *= 0.2;\n if(u_heightfixed < 1.0) {\n lineHeight = project_pixel(a_Size.y);\n }\n gl_Position = u_Mvp * (vec4(project_pos.xy + offset, lineHeight + h + u_raisingHeight, 1.0));\n } else {\n // mapbox - amap\n \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 // mapbox\n // \u4FDD\u6301\u9AD8\u5EA6\u76F8\u5BF9\u4E0D\u53D8\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n h *= mapboxZoomScale;\n h += u_raisingHeight * mapboxZoomScale;\n if(u_heightfixed > 0.0) {\n lineHeight *= mapboxZoomScale;\n }\n \n } else {\n // amap\n h += u_raisingHeight;\n // lineHeight \u9876\u70B9\u504F\u79FB\u9AD8\u5EA6\n if(u_heightfixed < 1.0) {\n lineHeight *= pow(2.0, 20.0 - u_Zoom);\n }\n }\n\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, lineHeight + h, 1.0));\n }\n\n setPickingColor(a_PickingColor);\n}\n"; // other function shaders
|
|
51
|
+
|
|
52
|
+
/* babel-plugin-inline-import '../shaders/linear/line_linear_frag.glsl' */
|
|
53
|
+
var linear_line_frag = "varying vec4 v_color;\nuniform float u_linearDir: 1.0;\nuniform float u_linearColor: 0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\n\n#pragma include \"picking\"\n\n\nvarying mat4 styleMappingMat;\n\nvoid main() {\n float opacity = styleMappingMat[0][0];\n float linearRadio = styleMappingMat[3][0]; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n if(u_linearDir < 1.0) {\n linearRadio = styleMappingMat[3][3];\n }\n\n if(u_linearColor == 1.0) { // \u4F7F\u7528\u6E10\u53D8\u989C\u8272\n gl_FragColor = mix(u_sourceColor, u_targetColor, linearRadio);\n } else { // \u4F7F\u7528 color \u65B9\u6CD5\u4F20\u5165\u7684\u989C\u8272\n gl_FragColor = v_color;\n }\n\n gl_FragColor.a *= opacity; // \u5168\u5C40\u900F\u660E\u5EA6\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
|
|
38
54
|
var lineStyleObj = {
|
|
39
|
-
solid: 0,
|
|
40
|
-
dash: 1
|
|
55
|
+
solid: 0.0,
|
|
56
|
+
dash: 1.0
|
|
41
57
|
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
58
|
+
|
|
59
|
+
var LineModel = /*#__PURE__*/function (_BaseModel) {
|
|
60
|
+
(0, _inherits2.default)(LineModel, _BaseModel);
|
|
61
|
+
|
|
62
|
+
var _super = _createSuper(LineModel);
|
|
63
|
+
|
|
64
|
+
function LineModel() {
|
|
65
|
+
var _this;
|
|
66
|
+
|
|
67
|
+
(0, _classCallCheck2.default)(this, LineModel);
|
|
68
|
+
|
|
69
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
70
|
+
args[_key] = arguments[_key];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
74
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "updateTexture", function () {
|
|
75
|
+
var createTexture2D = _this.rendererService.createTexture2D;
|
|
76
|
+
|
|
77
|
+
if (_this.texture) {
|
|
78
|
+
_this.texture.update({
|
|
79
|
+
data: _this.iconService.getCanvas()
|
|
50
80
|
});
|
|
51
|
-
|
|
81
|
+
|
|
82
|
+
_this.layer.render();
|
|
83
|
+
|
|
52
84
|
return;
|
|
53
85
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
86
|
+
|
|
87
|
+
_this.texture = createTexture2D({
|
|
88
|
+
data: _this.iconService.getCanvas(),
|
|
89
|
+
mag: _l7Core.gl.NEAREST,
|
|
90
|
+
min: _l7Core.gl.NEAREST,
|
|
58
91
|
premultiplyAlpha: false,
|
|
59
92
|
width: 1024,
|
|
60
|
-
height:
|
|
93
|
+
height: _this.iconService.canvasHeight || 128
|
|
61
94
|
});
|
|
62
|
-
};
|
|
95
|
+
});
|
|
96
|
+
return _this;
|
|
63
97
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
98
|
+
|
|
99
|
+
(0, _createClass2.default)(LineModel, [{
|
|
100
|
+
key: "getUninforms",
|
|
101
|
+
value: function getUninforms() {
|
|
102
|
+
var _ref = this.layer.getLayerConfig(),
|
|
103
|
+
_ref$opacity = _ref.opacity,
|
|
104
|
+
opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
|
|
105
|
+
sourceColor = _ref.sourceColor,
|
|
106
|
+
targetColor = _ref.targetColor,
|
|
107
|
+
_ref$textureBlend = _ref.textureBlend,
|
|
108
|
+
textureBlend = _ref$textureBlend === void 0 ? 'normal' : _ref$textureBlend,
|
|
109
|
+
_ref$lineType = _ref.lineType,
|
|
110
|
+
lineType = _ref$lineType === void 0 ? 'solid' : _ref$lineType,
|
|
111
|
+
_ref$dashArray = _ref.dashArray,
|
|
112
|
+
dashArray = _ref$dashArray === void 0 ? [10, 5, 0, 0] : _ref$dashArray,
|
|
113
|
+
_ref$lineTexture = _ref.lineTexture,
|
|
114
|
+
lineTexture = _ref$lineTexture === void 0 ? false : _ref$lineTexture,
|
|
115
|
+
_ref$iconStep = _ref.iconStep,
|
|
116
|
+
iconStep = _ref$iconStep === void 0 ? 100 : _ref$iconStep,
|
|
117
|
+
_ref$vertexHeightScal = _ref.vertexHeightScale,
|
|
118
|
+
vertexHeightScale = _ref$vertexHeightScal === void 0 ? 20.0 : _ref$vertexHeightScal,
|
|
119
|
+
_ref$borderWidth = _ref.borderWidth,
|
|
120
|
+
borderWidth = _ref$borderWidth === void 0 ? 0.0 : _ref$borderWidth,
|
|
121
|
+
_ref$borderColor = _ref.borderColor,
|
|
122
|
+
borderColor = _ref$borderColor === void 0 ? '#ccc' : _ref$borderColor,
|
|
123
|
+
_ref$raisingHeight = _ref.raisingHeight,
|
|
124
|
+
raisingHeight = _ref$raisingHeight === void 0 ? 0 : _ref$raisingHeight,
|
|
125
|
+
_ref$heightfixed = _ref.heightfixed,
|
|
126
|
+
heightfixed = _ref$heightfixed === void 0 ? false : _ref$heightfixed,
|
|
127
|
+
_ref$linearDir = _ref.linearDir,
|
|
128
|
+
linearDir = _ref$linearDir === void 0 ? _interface.LinearDir.VERTICAL : _ref$linearDir,
|
|
129
|
+
_ref$blur = _ref.blur,
|
|
130
|
+
blur = _ref$blur === void 0 ? [1, 1, 1] : _ref$blur,
|
|
131
|
+
_ref$arrow = _ref.arrow,
|
|
132
|
+
arrow = _ref$arrow === void 0 ? {
|
|
82
133
|
enable: false,
|
|
83
134
|
arrowWidth: 2,
|
|
84
135
|
arrowHeight: 3,
|
|
85
136
|
tailWidth: 1
|
|
137
|
+
} : _ref$arrow;
|
|
138
|
+
|
|
139
|
+
if (dashArray.length === 2) {
|
|
140
|
+
dashArray.push(0, 0);
|
|
86
141
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
if (this.dataTextureTest && this.dataTextureNeedUpdate({ opacity })) {
|
|
103
|
-
this.judgeStyleAttributes({ opacity });
|
|
104
|
-
const encodeData = this.layer.getEncodedData();
|
|
105
|
-
const { data, width, height } = this.calDataFrame(this.cellLength, encodeData, this.cellProperties);
|
|
106
|
-
this.rowCount = height;
|
|
107
|
-
this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
|
|
108
|
-
flipY: true,
|
|
109
|
-
data,
|
|
110
|
-
format: import_l7_core.gl.LUMINANCE,
|
|
111
|
-
type: import_l7_core.gl.FLOAT,
|
|
112
|
-
width,
|
|
113
|
-
height
|
|
114
|
-
}) : this.createTexture2D({
|
|
115
|
-
flipY: true,
|
|
116
|
-
data: [1],
|
|
117
|
-
format: import_l7_core.gl.LUMINANCE,
|
|
118
|
-
type: import_l7_core.gl.FLOAT,
|
|
119
|
-
width: 1,
|
|
120
|
-
height: 1
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
return {
|
|
124
|
-
u_dataTexture: this.dataTexture,
|
|
125
|
-
u_cellTypeLayout: this.getCellTypeLayout(),
|
|
126
|
-
u_opacity: (0, import_lodash.isNumber)(opacity) ? opacity : 1,
|
|
127
|
-
u_textureBlend: textureBlend === import_interface.TextureBlend.NORMAL ? 0 : 1,
|
|
128
|
-
u_line_type: lineStyleObj[lineType],
|
|
129
|
-
u_dash_array: dashArray,
|
|
130
|
-
u_blur: blur,
|
|
131
|
-
u_texture: this.texture,
|
|
132
|
-
u_line_texture: lineTexture ? 1 : 0,
|
|
133
|
-
u_icon_step: iconStep,
|
|
134
|
-
u_textSize: [1024, this.iconService.canvasHeight || 128],
|
|
135
|
-
u_borderWidth: borderWidth,
|
|
136
|
-
u_borderColor: (0, import_l7_utils.rgb2arr)(borderColor),
|
|
137
|
-
u_linearDir: linearDir === import_interface.LinearDir.VERTICAL ? 1 : 0,
|
|
138
|
-
u_linearColor: useLinearColor,
|
|
139
|
-
u_sourceColor: sourceColorArr,
|
|
140
|
-
u_targetColor: targetColorArr,
|
|
141
|
-
u_heightfixed: Number(heightfixed),
|
|
142
|
-
u_vertexScale: vertexHeightScale,
|
|
143
|
-
u_raisingHeight: Number(raisingHeight),
|
|
144
|
-
u_arrow: Number(arrow.enable),
|
|
145
|
-
u_arrowHeight: arrow.arrowHeight || 3,
|
|
146
|
-
u_arrowWidth: arrow.arrowWidth || 2,
|
|
147
|
-
u_tailWidth: arrow.tailWidth === void 0 ? 1 : arrow.tailWidth
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
getAnimateUniforms() {
|
|
151
|
-
const { animateOption } = this.layer.getLayerConfig();
|
|
152
|
-
return {
|
|
153
|
-
u_aimate: this.animateOption2Array(animateOption),
|
|
154
|
-
u_time: this.layer.getLayerAnimateTime()
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
initModels(callbackModel) {
|
|
158
|
-
this.updateTexture();
|
|
159
|
-
this.iconService.on("imageUpdate", this.updateTexture);
|
|
160
|
-
this.buildModels(callbackModel);
|
|
161
|
-
}
|
|
162
|
-
clearModels() {
|
|
163
|
-
var _a, _b;
|
|
164
|
-
(_a = this.texture) == null ? void 0 : _a.destroy();
|
|
165
|
-
(_b = this.dataTexture) == null ? void 0 : _b.destroy();
|
|
166
|
-
this.iconService.off("imageUpdate", this.updateTexture);
|
|
167
|
-
}
|
|
168
|
-
buildModels(callbackModel) {
|
|
169
|
-
const {
|
|
170
|
-
mask = false,
|
|
171
|
-
maskInside = true,
|
|
172
|
-
depth = false,
|
|
173
|
-
workerEnabled = false,
|
|
174
|
-
enablePicking
|
|
175
|
-
} = this.layer.getLayerConfig();
|
|
176
|
-
const { frag, vert, type } = this.getShaders();
|
|
177
|
-
this.layer.triangulation = import_l7_utils.LineTriangulation;
|
|
178
|
-
this.layer.buildLayerModel({
|
|
179
|
-
moduleName: "line" + type,
|
|
180
|
-
vertexShader: vert,
|
|
181
|
-
fragmentShader: frag,
|
|
182
|
-
triangulation: import_l7_utils.LineTriangulation,
|
|
183
|
-
depth: { enable: depth },
|
|
184
|
-
blend: this.getBlend(),
|
|
185
|
-
stencil: (0, import_l7_utils.getMask)(mask, maskInside),
|
|
186
|
-
workerEnabled,
|
|
187
|
-
workerOptions: {
|
|
188
|
-
modelType: "line" + type,
|
|
189
|
-
enablePicking,
|
|
190
|
-
iconMap: this.iconService.getIconMap()
|
|
142
|
+
|
|
143
|
+
if (this.rendererService.getDirty()) {
|
|
144
|
+
this.texture.bind();
|
|
145
|
+
} // 转化渐变色
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
var useLinearColor = 0; // 默认不生效
|
|
149
|
+
|
|
150
|
+
var sourceColorArr = [0, 0, 0, 0];
|
|
151
|
+
var targetColorArr = [0, 0, 0, 0];
|
|
152
|
+
|
|
153
|
+
if (sourceColor && targetColor) {
|
|
154
|
+
sourceColorArr = (0, _l7Utils.rgb2arr)(sourceColor);
|
|
155
|
+
targetColorArr = (0, _l7Utils.rgb2arr)(targetColor);
|
|
156
|
+
useLinearColor = 1;
|
|
191
157
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
158
|
+
|
|
159
|
+
if (this.dataTextureTest && this.dataTextureNeedUpdate({
|
|
160
|
+
opacity: opacity
|
|
161
|
+
})) {
|
|
162
|
+
this.judgeStyleAttributes({
|
|
163
|
+
opacity: opacity
|
|
164
|
+
});
|
|
165
|
+
var encodeData = this.layer.getEncodedData();
|
|
166
|
+
|
|
167
|
+
var _this$calDataFrame = this.calDataFrame(this.cellLength, encodeData, this.cellProperties),
|
|
168
|
+
data = _this$calDataFrame.data,
|
|
169
|
+
width = _this$calDataFrame.width,
|
|
170
|
+
height = _this$calDataFrame.height;
|
|
171
|
+
|
|
172
|
+
this.rowCount = height; // 当前数据纹理有多少行
|
|
173
|
+
|
|
174
|
+
this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
|
|
175
|
+
flipY: true,
|
|
176
|
+
data: data,
|
|
177
|
+
format: _l7Core.gl.LUMINANCE,
|
|
178
|
+
type: _l7Core.gl.FLOAT,
|
|
179
|
+
width: width,
|
|
180
|
+
height: height
|
|
181
|
+
}) : this.createTexture2D({
|
|
182
|
+
flipY: true,
|
|
183
|
+
data: [1],
|
|
184
|
+
format: _l7Core.gl.LUMINANCE,
|
|
185
|
+
type: _l7Core.gl.FLOAT,
|
|
186
|
+
width: 1,
|
|
187
|
+
height: 1
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
|
|
206
191
|
return {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
192
|
+
u_dataTexture: this.dataTexture,
|
|
193
|
+
// 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]
|
|
194
|
+
u_cellTypeLayout: this.getCellTypeLayout(),
|
|
195
|
+
u_opacity: (0, _lodash.isNumber)(opacity) ? opacity : 1.0,
|
|
196
|
+
u_textureBlend: textureBlend === _interface.TextureBlend.NORMAL ? 0.0 : 1.0,
|
|
197
|
+
u_line_type: lineStyleObj[lineType],
|
|
198
|
+
u_dash_array: dashArray,
|
|
199
|
+
u_blur: blur,
|
|
200
|
+
// 纹理支持参数
|
|
201
|
+
u_texture: this.texture,
|
|
202
|
+
// 贴图
|
|
203
|
+
u_line_texture: lineTexture ? 1.0 : 0.0,
|
|
204
|
+
// 传入线的标识
|
|
205
|
+
u_icon_step: iconStep,
|
|
206
|
+
u_textSize: [1024, this.iconService.canvasHeight || 128],
|
|
207
|
+
// line border 参数
|
|
208
|
+
u_borderWidth: borderWidth,
|
|
209
|
+
u_borderColor: (0, _l7Utils.rgb2arr)(borderColor),
|
|
210
|
+
// 渐变色支持参数
|
|
211
|
+
u_linearDir: linearDir === _interface.LinearDir.VERTICAL ? 1.0 : 0.0,
|
|
212
|
+
u_linearColor: useLinearColor,
|
|
213
|
+
u_sourceColor: sourceColorArr,
|
|
214
|
+
u_targetColor: targetColorArr,
|
|
215
|
+
// 是否固定高度
|
|
216
|
+
u_heightfixed: Number(heightfixed),
|
|
217
|
+
// 顶点高度 scale
|
|
218
|
+
u_vertexScale: vertexHeightScale,
|
|
219
|
+
u_raisingHeight: Number(raisingHeight),
|
|
220
|
+
// arrow
|
|
221
|
+
u_arrow: Number(arrow.enable),
|
|
222
|
+
u_arrowHeight: arrow.arrowHeight || 3,
|
|
223
|
+
u_arrowWidth: arrow.arrowWidth || 2,
|
|
224
|
+
u_tailWidth: arrow.tailWidth === undefined ? 1 : arrow.tailWidth
|
|
210
225
|
};
|
|
211
226
|
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
} else {
|
|
227
|
+
}, {
|
|
228
|
+
key: "getAnimateUniforms",
|
|
229
|
+
value: function getAnimateUniforms() {
|
|
230
|
+
var _ref2 = this.layer.getLayerConfig(),
|
|
231
|
+
animateOption = _ref2.animateOption;
|
|
232
|
+
|
|
219
233
|
return {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
type: ""
|
|
234
|
+
u_aimate: this.animateOption2Array(animateOption),
|
|
235
|
+
u_time: this.layer.getLayerAnimateTime()
|
|
223
236
|
};
|
|
224
237
|
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
238
|
+
}, {
|
|
239
|
+
key: "initModels",
|
|
240
|
+
value: function initModels(callbackModel) {
|
|
241
|
+
this.updateTexture();
|
|
242
|
+
this.iconService.on('imageUpdate', this.updateTexture);
|
|
243
|
+
this.buildModels(callbackModel);
|
|
244
|
+
}
|
|
245
|
+
}, {
|
|
246
|
+
key: "clearModels",
|
|
247
|
+
value: function clearModels() {
|
|
248
|
+
var _this$texture, _this$dataTexture;
|
|
249
|
+
|
|
250
|
+
(_this$texture = this.texture) === null || _this$texture === void 0 ? void 0 : _this$texture.destroy();
|
|
251
|
+
(_this$dataTexture = this.dataTexture) === null || _this$dataTexture === void 0 ? void 0 : _this$dataTexture.destroy();
|
|
252
|
+
this.iconService.off('imageUpdate', this.updateTexture);
|
|
253
|
+
}
|
|
254
|
+
}, {
|
|
255
|
+
key: "buildModels",
|
|
256
|
+
value: function buildModels(callbackModel) {
|
|
257
|
+
var _ref3 = this.layer.getLayerConfig(),
|
|
258
|
+
_ref3$mask = _ref3.mask,
|
|
259
|
+
mask = _ref3$mask === void 0 ? false : _ref3$mask,
|
|
260
|
+
_ref3$maskInside = _ref3.maskInside,
|
|
261
|
+
maskInside = _ref3$maskInside === void 0 ? true : _ref3$maskInside,
|
|
262
|
+
_ref3$depth = _ref3.depth,
|
|
263
|
+
depth = _ref3$depth === void 0 ? false : _ref3$depth,
|
|
264
|
+
_ref3$workerEnabled = _ref3.workerEnabled,
|
|
265
|
+
workerEnabled = _ref3$workerEnabled === void 0 ? false : _ref3$workerEnabled,
|
|
266
|
+
enablePicking = _ref3.enablePicking;
|
|
267
|
+
|
|
268
|
+
var _this$getShaders = this.getShaders(),
|
|
269
|
+
frag = _this$getShaders.frag,
|
|
270
|
+
vert = _this$getShaders.vert,
|
|
271
|
+
type = _this$getShaders.type;
|
|
272
|
+
|
|
273
|
+
this.layer.triangulation = _l7Utils.LineTriangulation;
|
|
274
|
+
this.layer.buildLayerModel({
|
|
275
|
+
moduleName: 'line' + type,
|
|
276
|
+
vertexShader: vert,
|
|
277
|
+
fragmentShader: frag,
|
|
278
|
+
triangulation: _l7Utils.LineTriangulation,
|
|
279
|
+
depth: {
|
|
280
|
+
enable: depth
|
|
236
281
|
},
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
282
|
+
blend: this.getBlend(),
|
|
283
|
+
stencil: (0, _l7Utils.getMask)(mask, maskInside),
|
|
284
|
+
workerEnabled: workerEnabled,
|
|
285
|
+
workerOptions: {
|
|
286
|
+
modelType: 'line' + type,
|
|
287
|
+
enablePicking: enablePicking,
|
|
288
|
+
iconMap: this.iconService.getIconMap()
|
|
240
289
|
}
|
|
290
|
+
}).then(function (model) {
|
|
291
|
+
callbackModel([model]);
|
|
292
|
+
}).catch(function (err) {
|
|
293
|
+
console.warn(err);
|
|
294
|
+
callbackModel([]);
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* 根据参数获取不同的 shader 代码
|
|
299
|
+
* @returns
|
|
300
|
+
*/
|
|
301
|
+
|
|
302
|
+
}, {
|
|
303
|
+
key: "getShaders",
|
|
304
|
+
value: function getShaders() {
|
|
305
|
+
var _ref4 = this.layer.getLayerConfig(),
|
|
306
|
+
sourceColor = _ref4.sourceColor,
|
|
307
|
+
targetColor = _ref4.targetColor,
|
|
308
|
+
lineType = _ref4.lineType;
|
|
309
|
+
|
|
310
|
+
if (lineType === 'dash') {
|
|
311
|
+
return {
|
|
312
|
+
frag: line_dash_frag,
|
|
313
|
+
vert: line_dash_vert,
|
|
314
|
+
type: 'Dash'
|
|
315
|
+
};
|
|
241
316
|
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
}
|
|
317
|
+
|
|
318
|
+
if (sourceColor && targetColor) {
|
|
319
|
+
// 分离 linear 功能
|
|
320
|
+
return {
|
|
321
|
+
frag: linear_line_frag,
|
|
322
|
+
vert: line_vert,
|
|
323
|
+
type: 'Linear'
|
|
324
|
+
};
|
|
325
|
+
} else {
|
|
326
|
+
return {
|
|
327
|
+
frag: line_frag,
|
|
328
|
+
vert: line_vert,
|
|
329
|
+
type: ''
|
|
330
|
+
};
|
|
257
331
|
}
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
332
|
+
}
|
|
333
|
+
}, {
|
|
334
|
+
key: "registerBuiltinAttributes",
|
|
335
|
+
value: function registerBuiltinAttributes() {
|
|
336
|
+
var _this2 = this;
|
|
337
|
+
|
|
338
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
339
|
+
name: 'distanceAndIndex',
|
|
340
|
+
type: _l7Core.AttributeType.Attribute,
|
|
341
|
+
descriptor: {
|
|
342
|
+
name: 'a_DistanceAndIndex',
|
|
343
|
+
buffer: {
|
|
344
|
+
// give the WebGL driver a hint that this buffer may change
|
|
345
|
+
usage: _l7Core.gl.STATIC_DRAW,
|
|
346
|
+
data: [],
|
|
347
|
+
type: _l7Core.gl.FLOAT
|
|
348
|
+
},
|
|
349
|
+
size: 2,
|
|
350
|
+
update: function update(feature, featureIdx, vertex, attributeIdx, normal, vertexIndex) {
|
|
351
|
+
return vertexIndex === undefined ? [vertex[3], 10] : [vertex[3], vertexIndex];
|
|
352
|
+
}
|
|
273
353
|
}
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
354
|
+
});
|
|
355
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
356
|
+
name: 'total_distance',
|
|
357
|
+
type: _l7Core.AttributeType.Attribute,
|
|
358
|
+
descriptor: {
|
|
359
|
+
name: 'a_Total_Distance',
|
|
360
|
+
buffer: {
|
|
361
|
+
// give the WebGL driver a hint that this buffer may change
|
|
362
|
+
usage: _l7Core.gl.STATIC_DRAW,
|
|
363
|
+
data: [],
|
|
364
|
+
type: _l7Core.gl.FLOAT
|
|
365
|
+
},
|
|
366
|
+
size: 1,
|
|
367
|
+
update: function update(feature, featureIdx, vertex, attributeIdx) {
|
|
368
|
+
return [vertex[5]];
|
|
369
|
+
}
|
|
289
370
|
}
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
371
|
+
});
|
|
372
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
373
|
+
name: 'size',
|
|
374
|
+
type: _l7Core.AttributeType.Attribute,
|
|
375
|
+
descriptor: {
|
|
376
|
+
name: 'a_Size',
|
|
377
|
+
buffer: {
|
|
378
|
+
// give the WebGL driver a hint that this buffer may change
|
|
379
|
+
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
380
|
+
data: [],
|
|
381
|
+
type: _l7Core.gl.FLOAT
|
|
382
|
+
},
|
|
383
|
+
size: 2,
|
|
384
|
+
update: function update(feature, featureIdx, vertex, attributeIdx) {
|
|
385
|
+
var _feature$size = feature.size,
|
|
386
|
+
size = _feature$size === void 0 ? 1 : _feature$size;
|
|
387
|
+
return Array.isArray(size) ? [size[0], size[1]] : [size, 0];
|
|
388
|
+
}
|
|
305
389
|
}
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
return [x, y];
|
|
390
|
+
}); // point layer size;
|
|
391
|
+
|
|
392
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
393
|
+
name: 'normal',
|
|
394
|
+
type: _l7Core.AttributeType.Attribute,
|
|
395
|
+
descriptor: {
|
|
396
|
+
name: 'a_Normal',
|
|
397
|
+
buffer: {
|
|
398
|
+
// give the WebGL driver a hint that this buffer may change
|
|
399
|
+
usage: _l7Core.gl.STATIC_DRAW,
|
|
400
|
+
data: [],
|
|
401
|
+
type: _l7Core.gl.FLOAT
|
|
402
|
+
},
|
|
403
|
+
size: 3,
|
|
404
|
+
update: function update(feature, featureIdx, vertex, attributeIdx, normal) {
|
|
405
|
+
return normal;
|
|
406
|
+
}
|
|
324
407
|
}
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
408
|
+
});
|
|
409
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
410
|
+
name: 'miter',
|
|
411
|
+
type: _l7Core.AttributeType.Attribute,
|
|
412
|
+
descriptor: {
|
|
413
|
+
name: 'a_Miter',
|
|
414
|
+
buffer: {
|
|
415
|
+
// give the WebGL driver a hint that this buffer may change
|
|
416
|
+
usage: _l7Core.gl.STATIC_DRAW,
|
|
417
|
+
data: [],
|
|
418
|
+
type: _l7Core.gl.FLOAT
|
|
419
|
+
},
|
|
420
|
+
size: 1,
|
|
421
|
+
update: function update(feature, featureIdx, vertex, attributeIdx) {
|
|
422
|
+
return [vertex[4]];
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
});
|
|
426
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
427
|
+
name: 'uv',
|
|
428
|
+
type: _l7Core.AttributeType.Attribute,
|
|
429
|
+
descriptor: {
|
|
430
|
+
name: 'a_iconMapUV',
|
|
431
|
+
buffer: {
|
|
432
|
+
// give the WebGL driver a hint that this buffer may change
|
|
433
|
+
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
434
|
+
data: [],
|
|
435
|
+
type: _l7Core.gl.FLOAT
|
|
436
|
+
},
|
|
437
|
+
size: 2,
|
|
438
|
+
update: function update(feature, featureIdx, vertex, attributeIdx) {
|
|
439
|
+
var iconMap = _this2.iconService.getIconMap();
|
|
440
|
+
|
|
441
|
+
var texture = feature.texture;
|
|
442
|
+
|
|
443
|
+
var _ref5 = iconMap[texture] || {
|
|
444
|
+
x: 0,
|
|
445
|
+
y: 0
|
|
446
|
+
},
|
|
447
|
+
x = _ref5.x,
|
|
448
|
+
y = _ref5.y;
|
|
449
|
+
|
|
450
|
+
return [x, y];
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
}]);
|
|
456
|
+
return LineModel;
|
|
457
|
+
}(_BaseModel2.default);
|
|
458
|
+
|
|
459
|
+
exports.default = LineModel;
|