@antv/l7-layers 2.17.4 → 2.17.5
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/index.js +9 -31
- package/es/Geometry/models/billboard.js +51 -89
- package/es/Geometry/models/plane.js +81 -143
- package/es/Geometry/models/sprite.js +60 -118
- package/es/canvas/index.js +10 -33
- package/es/canvas/models/canvas.js +41 -97
- package/es/citybuliding/building.js +8 -27
- package/es/citybuliding/models/build.js +57 -82
- package/es/core/BaseLayer.js +325 -483
- package/es/core/BaseModel.js +51 -80
- package/es/core/CommonStyleAttribute.js +2 -5
- package/es/core/LayerPickService.js +21 -32
- package/es/core/TextureService.js +0 -13
- package/es/core/interface.js +17 -24
- package/es/core/shape/Path.js +13 -20
- package/es/core/shape/extrude.js +27 -39
- package/es/core/triangulation.js +99 -136
- package/es/earth/index.js +9 -33
- package/es/earth/models/atmosphere.js +30 -54
- package/es/earth/models/base.js +47 -85
- package/es/earth/models/bloomsphere.js +30 -54
- package/es/earth/utils.js +9 -13
- package/es/heatmap/index.js +10 -40
- package/es/heatmap/models/grid.js +28 -52
- package/es/heatmap/models/grid3d.js +28 -52
- package/es/heatmap/models/heatmap.js +92 -149
- package/es/heatmap/models/hexagon.js +28 -52
- package/es/heatmap/triangulation.js +0 -4
- package/es/image/index.js +9 -28
- package/es/image/models/image.js +66 -100
- package/es/index.js +9 -17
- package/es/line/index.js +9 -35
- package/es/line/models/arc.js +63 -112
- package/es/line/models/arc_3d.js +58 -102
- package/es/line/models/earthArc_3d.js +60 -105
- package/es/line/models/flow.js +36 -60
- package/es/line/models/great_circle.js +53 -94
- package/es/line/models/line.js +92 -144
- package/es/line/models/linearline.js +42 -74
- package/es/line/models/simpleLine.js +38 -67
- package/es/line/models/wall.js +52 -92
- package/es/line/shaders/dash/line_dash_vert.glsl +1 -2
- package/es/line/shaders/line_frag.glsl +1 -3
- package/es/line/shaders/line_vert.glsl +2 -0
- package/es/line/shaders/linear/line_linear_frag.glsl +1 -1
- package/es/mask/index.js +9 -28
- package/es/mask/models/fill.js +29 -54
- package/es/plugins/DataMappingPlugin.js +78 -114
- package/es/plugins/DataSourcePlugin.js +45 -68
- package/es/plugins/FeatureScalePlugin.js +67 -122
- package/es/plugins/LayerAnimateStylePlugin.js +0 -5
- package/es/plugins/LayerMaskPlugin.js +3 -11
- package/es/plugins/LayerModelPlugin.js +69 -118
- package/es/plugins/LayerStylePlugin.js +4 -9
- package/es/plugins/LightingPlugin.js +12 -18
- package/es/plugins/MultiPassRendererPlugin.js +11 -16
- package/es/plugins/PixelPickingPlugin.js +12 -21
- package/es/plugins/RegisterStyleAttributePlugin.js +5 -12
- package/es/plugins/ShaderUniformPlugin.js +13 -27
- package/es/plugins/UpdateModelPlugin.js +0 -5
- package/es/plugins/UpdateStyleAttributePlugin.js +5 -11
- package/es/point/index.js +26 -78
- package/es/point/models/earthExtrude.js +58 -95
- package/es/point/models/earthFill.js +52 -80
- package/es/point/models/extrude.js +57 -94
- package/es/point/models/fill.js +56 -81
- package/es/point/models/fillmage.js +60 -100
- package/es/point/models/image.js +47 -83
- package/es/point/models/index.js +2 -2
- package/es/point/models/normal.js +30 -54
- package/es/point/models/radar.js +38 -63
- package/es/point/models/simplePoint.js +38 -62
- package/es/point/models/text.js +199 -296
- package/es/point/shape/extrude.js +4 -13
- package/es/polygon/index.js +11 -41
- package/es/polygon/models/extrude.js +87 -135
- package/es/polygon/models/fill.js +50 -79
- package/es/polygon/models/index.js +3 -2
- package/es/polygon/models/ocean.js +42 -76
- package/es/polygon/models/water.js +37 -71
- package/es/raster/buffers/triangulation.js +2 -4
- package/es/raster/index.js +9 -32
- package/es/raster/models/raster.js +80 -116
- package/es/raster/models/rasterRgb.js +84 -127
- package/es/raster/models/rasterTerrainRgb.js +56 -84
- package/es/tile/interaction/getRasterData.js +14 -20
- package/es/tile/interaction/utils.js +7 -9
- package/es/tile/manager/base.js +63 -96
- package/es/tile/service/TileLayerService.js +33 -55
- package/es/tile/service/TilePickService.js +26 -40
- package/es/tile/service/TileSourceService.js +3 -7
- package/es/tile/tileFactory/DebugTile.js +29 -46
- package/es/tile/tileFactory/ImageTile.js +20 -38
- package/es/tile/tileFactory/MaskTile.js +22 -43
- package/es/tile/tileFactory/RasterRGBTile.js +22 -42
- package/es/tile/tileFactory/RasterTerrainRGBTile.js +20 -38
- package/es/tile/tileFactory/RasterTile.js +30 -53
- package/es/tile/tileFactory/Tile.js +63 -97
- package/es/tile/tileFactory/VectorTile.js +41 -68
- package/es/tile/tileFactory/index.js +0 -11
- package/es/tile/tileFactory/layers/TileDebugLayer.js +6 -27
- package/es/tile/tileFactory/util.js +0 -3
- package/es/tile/tileLayer/BaseLayer.js +105 -146
- package/es/tile/utils.js +1 -1
- package/es/utils/blend.js +0 -2
- package/es/utils/collision-index.js +9 -16
- package/es/utils/extrude_polyline.js +101 -149
- package/es/utils/grid-index.js +2 -27
- package/es/utils/identityScale.js +0 -8
- package/es/utils/layerData.js +30 -44
- package/es/utils/multiPassRender.js +11 -13
- package/es/utils/polylineNormal.js +31 -37
- package/es/utils/simpleLine.js +2 -16
- package/es/utils/stencil.js +2 -3
- package/es/utils/symbol-layout.js +27 -53
- package/es/wind/index.js +9 -29
- package/es/wind/models/utils.js +26 -51
- package/es/wind/models/wind.js +101 -147
- package/es/wind/models/windRender.js +53 -66
- package/lib/Geometry/index.js +9 -38
- package/lib/Geometry/models/billboard.js +51 -97
- package/lib/Geometry/models/index.js +0 -5
- package/lib/Geometry/models/plane.js +79 -151
- package/lib/Geometry/models/sprite.js +60 -127
- package/lib/canvas/index.js +10 -40
- package/lib/canvas/models/canvas.js +41 -101
- package/lib/canvas/models/index.js +0 -3
- package/lib/citybuliding/building.js +8 -35
- package/lib/citybuliding/models/build.js +57 -92
- package/lib/core/BaseLayer.js +325 -474
- package/lib/core/BaseModel.js +51 -90
- package/lib/core/CommonStyleAttribute.js +2 -7
- package/lib/core/LayerPickService.js +21 -37
- package/lib/core/TextureService.js +0 -16
- package/lib/core/interface.js +21 -31
- package/lib/core/schema.js +0 -1
- package/lib/core/shape/Path.js +14 -31
- package/lib/core/shape/extrude.js +27 -62
- package/lib/core/triangulation.js +98 -177
- package/lib/earth/index.js +9 -43
- package/lib/earth/models/atmosphere.js +30 -63
- package/lib/earth/models/base.js +47 -90
- package/lib/earth/models/bloomsphere.js +30 -63
- package/lib/earth/utils.js +7 -31
- package/lib/heatmap/index.js +10 -48
- package/lib/heatmap/models/grid.js +28 -60
- package/lib/heatmap/models/grid3d.js +28 -60
- package/lib/heatmap/models/heatmap.js +92 -166
- package/lib/heatmap/models/hexagon.js +28 -60
- package/lib/heatmap/models/index.js +0 -6
- package/lib/heatmap/triangulation.js +0 -5
- package/lib/image/index.js +9 -36
- package/lib/image/models/image.js +66 -109
- package/lib/image/models/index.js +0 -3
- package/lib/index.js +7 -61
- package/lib/line/index.js +9 -40
- package/lib/line/models/arc.js +61 -122
- package/lib/line/models/arc_3d.js +56 -113
- package/lib/line/models/earthArc_3d.js +58 -115
- package/lib/line/models/flow.js +36 -70
- package/lib/line/models/great_circle.js +53 -104
- package/lib/line/models/index.js +0 -11
- package/lib/line/models/line.js +90 -152
- package/lib/line/models/linearline.js +42 -86
- package/lib/line/models/simpleLine.js +38 -77
- package/lib/line/models/wall.js +52 -103
- package/lib/line/shaders/dash/line_dash_vert.glsl +1 -2
- package/lib/line/shaders/line_frag.glsl +1 -3
- package/lib/line/shaders/line_vert.glsl +2 -0
- package/lib/line/shaders/linear/line_linear_frag.glsl +1 -1
- package/lib/mask/index.js +9 -36
- package/lib/mask/models/fill.js +29 -63
- package/lib/mask/models/index.js +0 -3
- package/lib/plugins/DataMappingPlugin.js +78 -125
- package/lib/plugins/DataSourcePlugin.js +45 -76
- package/lib/plugins/FeatureScalePlugin.js +67 -138
- package/lib/plugins/LayerAnimateStylePlugin.js +0 -10
- package/lib/plugins/LayerMaskPlugin.js +4 -17
- package/lib/plugins/LayerModelPlugin.js +70 -127
- package/lib/plugins/LayerStylePlugin.js +5 -14
- package/lib/plugins/LightingPlugin.js +12 -25
- package/lib/plugins/MultiPassRendererPlugin.js +11 -22
- package/lib/plugins/PixelPickingPlugin.js +12 -27
- package/lib/plugins/RegisterStyleAttributePlugin.js +5 -19
- package/lib/plugins/ShaderUniformPlugin.js +13 -34
- package/lib/plugins/UpdateModelPlugin.js +1 -10
- package/lib/plugins/UpdateStyleAttributePlugin.js +5 -16
- package/lib/point/index.js +26 -83
- package/lib/point/models/earthExtrude.js +58 -106
- package/lib/point/models/earthFill.js +52 -110
- package/lib/point/models/extrude.js +57 -103
- package/lib/point/models/fill.js +54 -90
- package/lib/point/models/fillmage.js +58 -107
- package/lib/point/models/image.js +47 -92
- package/lib/point/models/index.js +1 -12
- package/lib/point/models/normal.js +30 -64
- package/lib/point/models/radar.js +38 -72
- package/lib/point/models/simplePoint.js +38 -72
- package/lib/point/models/text.js +199 -305
- package/lib/point/shape/extrude.js +4 -20
- package/lib/polygon/index.js +11 -48
- package/lib/polygon/models/extrude.js +87 -146
- package/lib/polygon/models/fill.js +50 -89
- package/lib/polygon/models/index.js +2 -14
- package/lib/polygon/models/ocean.js +42 -88
- package/lib/polygon/models/water.js +37 -82
- package/lib/raster/buffers/triangulation.js +3 -7
- package/lib/raster/index.js +9 -40
- package/lib/raster/models/index.js +0 -5
- package/lib/raster/models/raster.js +80 -125
- package/lib/raster/models/rasterRgb.js +84 -139
- package/lib/raster/models/rasterTerrainRgb.js +56 -93
- package/lib/tile/interaction/getRasterData.js +14 -25
- package/lib/tile/interaction/utils.js +7 -19
- package/lib/tile/manager/base.js +63 -104
- package/lib/tile/service/TileLayerService.js +33 -60
- package/lib/tile/service/TilePickService.js +26 -48
- package/lib/tile/service/TileSourceService.js +2 -16
- package/lib/tile/style/utils.js +0 -3
- package/lib/tile/tileFactory/DebugTile.js +29 -54
- package/lib/tile/tileFactory/ImageTile.js +20 -46
- package/lib/tile/tileFactory/MaskTile.js +22 -51
- package/lib/tile/tileFactory/RasterRGBTile.js +22 -50
- package/lib/tile/tileFactory/RasterTerrainRGBTile.js +20 -46
- package/lib/tile/tileFactory/RasterTile.js +30 -63
- package/lib/tile/tileFactory/Tile.js +63 -102
- package/lib/tile/tileFactory/VectorTile.js +41 -76
- package/lib/tile/tileFactory/index.js +0 -25
- package/lib/tile/tileFactory/layers/TileDebugLayer.js +6 -32
- package/lib/tile/tileFactory/util.js +0 -9
- package/lib/tile/tileLayer/BaseLayer.js +105 -153
- package/lib/tile/utils.js +1 -5
- package/lib/utils/blend.js +0 -5
- package/lib/utils/collision-index.js +9 -25
- package/lib/utils/extrude_polyline.js +101 -181
- package/lib/utils/grid-index.js +2 -28
- package/lib/utils/identityScale.js +0 -9
- package/lib/utils/layerData.js +30 -49
- package/lib/utils/multiPassRender.js +11 -16
- package/lib/utils/polylineNormal.js +31 -66
- package/lib/utils/simpleLine.js +2 -21
- package/lib/utils/stencil.js +0 -4
- package/lib/utils/symbol-layout.js +27 -55
- package/lib/wind/index.js +9 -37
- package/lib/wind/models/index.js +0 -3
- package/lib/wind/models/utils.js +26 -62
- package/lib/wind/models/wind.js +101 -157
- package/lib/wind/models/windRender.js +53 -71
- package/lib/wind/models/windShader.js +0 -1
- package/package.json +7 -7
package/lib/point/models/text.js
CHANGED
|
@@ -1,70 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.TextTrianglation = TextTrianglation;
|
|
9
8
|
exports.default = void 0;
|
|
10
|
-
|
|
11
9
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
12
|
-
|
|
13
10
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
14
|
-
|
|
15
11
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
16
|
-
|
|
17
12
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
18
|
-
|
|
19
13
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
20
|
-
|
|
21
14
|
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
22
|
-
|
|
23
15
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
24
|
-
|
|
25
16
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
26
|
-
|
|
27
17
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
28
|
-
|
|
29
18
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
30
|
-
|
|
31
19
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
32
|
-
|
|
33
20
|
var _l7Core = require("@antv/l7-core");
|
|
34
|
-
|
|
35
21
|
var _l7Utils = require("@antv/l7-utils");
|
|
36
|
-
|
|
37
22
|
var _lodash = require("lodash");
|
|
38
|
-
|
|
39
23
|
var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
|
|
40
|
-
|
|
41
24
|
var _collisionIndex = _interopRequireDefault(require("../../utils/collision-index"));
|
|
42
|
-
|
|
43
25
|
var _symbolLayout = require("../../utils/symbol-layout");
|
|
44
|
-
|
|
45
26
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
46
|
-
|
|
47
27
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
48
|
-
|
|
49
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
50
|
-
|
|
28
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
51
29
|
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); }; }
|
|
52
|
-
|
|
53
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; } }
|
|
54
|
-
|
|
55
31
|
/* babel-plugin-inline-import '../shaders/text_frag.glsl' */
|
|
56
32
|
var textFrag = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 48.0\nuniform sampler2D u_sdf_map;\nuniform float u_gamma_scale : 0.5;\nuniform float u_stroke_width : 2.0;\nuniform float u_halo_blur : 0.5;\nuniform float u_DevicePixelRatio;\n\nvarying vec4 v_color;\nvarying vec4 v_stroke_color;\nvarying vec2 v_uv;\nvarying float v_gamma_scale;\nvarying float v_fontScale;\n\n\n#pragma include \"picking\"\nvoid main() {\n // get style data mapping\n\n // get sdf from atlas\n float dist = texture2D(u_sdf_map, v_uv).a;\n\n lowp float buff = (6.0 - u_stroke_width / v_fontScale) / SDF_PX;\n highp float gamma = (u_halo_blur * 1.19 / SDF_PX + EDGE_GAMMA) / (v_fontScale * u_gamma_scale) / 1.0;\n\n highp float gamma_scaled = gamma * v_gamma_scale;\n\n highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist);\n\n gl_FragColor = mix(v_color, v_stroke_color, smoothstep(0., 0.5, 1.- dist));\n\n gl_FragColor.a *= alpha;\n // \u4F5C\u4E3A mask \u6A21\u677F\u65F6\u9700\u8981\u4E22\u5F03\u900F\u660E\u7684\u50CF\u7D20\n if (gl_FragColor.a < 0.01) {\n discard;\n }\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
|
|
57
|
-
|
|
58
33
|
/* babel-plugin-inline-import '../shaders/text_vert.glsl' */
|
|
59
34
|
var textVert = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 24.0\nattribute vec3 a_Position;\nattribute vec2 a_tex;\nattribute vec2 a_textOffsets;\nattribute vec4 a_Color;\nattribute float a_Size;\nattribute float a_Rotate;\n\nuniform vec2 u_sdf_map_size;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform float u_raisingHeight: 0.0;\n\nvarying vec2 v_uv;\nvarying float v_gamma_scale;\nvarying vec4 v_color;\nvarying vec4 v_stroke_color;\nvarying float v_fontScale;\n// uniform float u_opacity : 1;\nuniform float u_stroke_width : 2;\nuniform vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\n\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\n \n v_uv = a_tex / u_sdf_map_size;\n\n\n\n v_color = vec4(a_Color.xyz, a_Color.w * opacity);\n v_stroke_color = vec4(u_stroke_color.xyz, u_stroke_color.w * opacity);\n\n // \u6587\u672C\u7F29\u653E\u6BD4\u4F8B\n float fontScale = a_Size / FONT_SIZE;\n v_fontScale = fontScale;\n\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n // vec4 projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n highp float angle_sin = sin(a_Rotate);\n highp float angle_cos = cos(a_Rotate);\n mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);\n \n // gl_Position = vec4(projected_position.xy / projected_position.w + rotation_matrix * a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);\n\n float raiseHeight = u_raisingHeight;\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 raiseHeight = u_raisingHeight * mapboxZoomScale;\n }\n\n vec4 projected_position;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n projected_position = u_Mvp *(vec4(a_Position.xyz + vec3(0.0, 0.0, raiseHeight), 1.0));\n } else { // else\n projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz + vec3(0.0, 0.0, raiseHeight), 1.0));\n }\n\n gl_Position = vec4(\n projected_position.xy / projected_position.w + rotation_matrix * a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);\n v_gamma_scale = gl_Position.w;\n setPickingColor(a_PickingColor);\n\n}\n";
|
|
60
|
-
|
|
61
35
|
function TextTrianglation(feature) {
|
|
62
36
|
// @ts-ignore
|
|
63
37
|
var that = this;
|
|
64
38
|
var id = feature.id;
|
|
65
39
|
var vertices = [];
|
|
66
40
|
var indices = [];
|
|
67
|
-
|
|
68
41
|
if (!that.glyphInfoMap || !that.glyphInfoMap[id]) {
|
|
69
42
|
return {
|
|
70
43
|
vertices: [],
|
|
@@ -73,9 +46,7 @@ function TextTrianglation(feature) {
|
|
|
73
46
|
size: 7
|
|
74
47
|
};
|
|
75
48
|
}
|
|
76
|
-
|
|
77
49
|
var centroid = that.glyphInfoMap[id].centroid; // 计算中心点
|
|
78
|
-
|
|
79
50
|
var coord = centroid.length === 2 ? [centroid[0], centroid[1], 0] : centroid;
|
|
80
51
|
that.glyphInfoMap[id].glyphQuads.forEach(function (quad, index) {
|
|
81
52
|
vertices.push.apply(vertices, (0, _toConsumableArray2.default)(coord).concat([quad.tex.x, quad.tex.y + quad.tex.height, quad.tl.x, quad.tl.y], (0, _toConsumableArray2.default)(coord), [quad.tex.x + quad.tex.width, quad.tex.y + quad.tex.height, quad.tr.x, quad.tr.y], (0, _toConsumableArray2.default)(coord), [quad.tex.x + quad.tex.width, quad.tex.y, quad.br.x, quad.br.y], (0, _toConsumableArray2.default)(coord), [quad.tex.x, quad.tex.y, quad.bl.x, quad.bl.y]));
|
|
@@ -88,21 +59,15 @@ function TextTrianglation(feature) {
|
|
|
88
59
|
size: 7
|
|
89
60
|
};
|
|
90
61
|
}
|
|
91
|
-
|
|
92
62
|
var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
93
63
|
(0, _inherits2.default)(TextModel, _BaseModel);
|
|
94
|
-
|
|
95
64
|
var _super = _createSuper(TextModel);
|
|
96
|
-
|
|
97
65
|
function TextModel() {
|
|
98
66
|
var _this;
|
|
99
|
-
|
|
100
67
|
(0, _classCallCheck2.default)(this, TextModel);
|
|
101
|
-
|
|
102
68
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
103
69
|
args[_key] = arguments[_key];
|
|
104
70
|
}
|
|
105
|
-
|
|
106
71
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
107
72
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "glyphInfoMap", {});
|
|
108
73
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "currentZoom", -1);
|
|
@@ -111,52 +76,42 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
111
76
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "preTextStyle", {});
|
|
112
77
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "mapping", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
113
78
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
114
|
-
while (1) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
return _this.reBuildModel();
|
|
124
|
-
|
|
125
|
-
case 4:
|
|
126
|
-
case "end":
|
|
127
|
-
return _context.stop();
|
|
128
|
-
}
|
|
79
|
+
while (1) switch (_context.prev = _context.next) {
|
|
80
|
+
case 0:
|
|
81
|
+
_this.initGlyph(); //
|
|
82
|
+
_this.updateTexture();
|
|
83
|
+
_context.next = 4;
|
|
84
|
+
return _this.reBuildModel();
|
|
85
|
+
case 4:
|
|
86
|
+
case "end":
|
|
87
|
+
return _context.stop();
|
|
129
88
|
}
|
|
130
89
|
}, _callee);
|
|
131
90
|
})));
|
|
132
91
|
return _this;
|
|
133
92
|
}
|
|
134
|
-
|
|
135
93
|
(0, _createClass2.default)(TextModel, [{
|
|
136
94
|
key: "getUninforms",
|
|
137
95
|
value: function getUninforms() {
|
|
138
96
|
var _ref2 = this.layer.getLayerConfig(),
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
97
|
+
_ref2$opacity = _ref2.opacity,
|
|
98
|
+
opacity = _ref2$opacity === void 0 ? 1.0 : _ref2$opacity,
|
|
99
|
+
_ref2$stroke = _ref2.stroke,
|
|
100
|
+
stroke = _ref2$stroke === void 0 ? '#fff' : _ref2$stroke,
|
|
101
|
+
_ref2$strokeWidth = _ref2.strokeWidth,
|
|
102
|
+
strokeWidth = _ref2$strokeWidth === void 0 ? 0 : _ref2$strokeWidth,
|
|
103
|
+
_ref2$halo = _ref2.halo,
|
|
104
|
+
halo = _ref2$halo === void 0 ? 0.5 : _ref2$halo,
|
|
105
|
+
_ref2$gamma = _ref2.gamma,
|
|
106
|
+
gamma = _ref2$gamma === void 0 ? 2.0 : _ref2$gamma,
|
|
107
|
+
_ref2$raisingHeight = _ref2.raisingHeight,
|
|
108
|
+
raisingHeight = _ref2$raisingHeight === void 0 ? 0 : _ref2$raisingHeight;
|
|
152
109
|
var mapping = this.getFontServiceMapping();
|
|
153
110
|
var canvas = this.getFontServiceCanvas();
|
|
154
|
-
|
|
155
111
|
if (mapping && Object.keys(mapping).length !== this.textCount && canvas) {
|
|
156
112
|
this.updateTexture();
|
|
157
113
|
this.textCount = Object.keys(mapping).length;
|
|
158
114
|
}
|
|
159
|
-
|
|
160
115
|
this.preTextStyle = this.getTextStyle();
|
|
161
116
|
return (0, _objectSpread2.default)({
|
|
162
117
|
u_raisingHeight: Number(raisingHeight),
|
|
@@ -174,28 +129,23 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
174
129
|
value: function () {
|
|
175
130
|
var _initModels = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
176
131
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
177
|
-
while (1) {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
case "end":
|
|
189
|
-
return _context2.stop();
|
|
190
|
-
}
|
|
132
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
133
|
+
case 0:
|
|
134
|
+
// 绑定事件
|
|
135
|
+
this.bindEvent();
|
|
136
|
+
this.extent = this.textExtent();
|
|
137
|
+
this.rawEncodeData = this.layer.getEncodedData();
|
|
138
|
+
this.preTextStyle = this.getTextStyle();
|
|
139
|
+
return _context2.abrupt("return", this.buildModels());
|
|
140
|
+
case 5:
|
|
141
|
+
case "end":
|
|
142
|
+
return _context2.stop();
|
|
191
143
|
}
|
|
192
144
|
}, _callee2, this);
|
|
193
145
|
}));
|
|
194
|
-
|
|
195
146
|
function initModels() {
|
|
196
147
|
return _initModels.apply(this, arguments);
|
|
197
148
|
}
|
|
198
|
-
|
|
199
149
|
return initModels;
|
|
200
150
|
}()
|
|
201
151
|
}, {
|
|
@@ -203,49 +153,38 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
203
153
|
value: function () {
|
|
204
154
|
var _buildModels = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
|
|
205
155
|
var _ref3, _ref3$textAllowOverla, textAllowOverlap, model;
|
|
206
|
-
|
|
207
156
|
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
208
|
-
while (1) {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
157
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
158
|
+
case 0:
|
|
159
|
+
_ref3 = this.layer.getLayerConfig(), _ref3$textAllowOverla = _ref3.textAllowOverlap, textAllowOverlap = _ref3$textAllowOverla === void 0 ? false : _ref3$textAllowOverla; // this.mapping(); 重复调用
|
|
160
|
+
this.initGlyph(); //
|
|
161
|
+
this.updateTexture();
|
|
162
|
+
if (!textAllowOverlap) {
|
|
163
|
+
this.filterGlyphs();
|
|
164
|
+
}
|
|
165
|
+
_context3.next = 6;
|
|
166
|
+
return this.layer.buildLayerModel({
|
|
167
|
+
moduleName: 'pointText',
|
|
168
|
+
vertexShader: textVert,
|
|
169
|
+
fragmentShader: textFrag,
|
|
170
|
+
inject: this.getInject(),
|
|
171
|
+
triangulation: TextTrianglation.bind(this),
|
|
172
|
+
depth: {
|
|
173
|
+
enable: false
|
|
219
174
|
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
triangulation: TextTrianglation.bind(this),
|
|
228
|
-
depth: {
|
|
229
|
-
enable: false
|
|
230
|
-
}
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
case 6:
|
|
234
|
-
model = _context3.sent;
|
|
235
|
-
return _context3.abrupt("return", [model]);
|
|
236
|
-
|
|
237
|
-
case 8:
|
|
238
|
-
case "end":
|
|
239
|
-
return _context3.stop();
|
|
240
|
-
}
|
|
175
|
+
});
|
|
176
|
+
case 6:
|
|
177
|
+
model = _context3.sent;
|
|
178
|
+
return _context3.abrupt("return", [model]);
|
|
179
|
+
case 8:
|
|
180
|
+
case "end":
|
|
181
|
+
return _context3.stop();
|
|
241
182
|
}
|
|
242
183
|
}, _callee3, this);
|
|
243
184
|
}));
|
|
244
|
-
|
|
245
185
|
function buildModels() {
|
|
246
186
|
return _buildModels.apply(this, arguments);
|
|
247
187
|
}
|
|
248
|
-
|
|
249
188
|
return buildModels;
|
|
250
189
|
}() // 需要更新的场景
|
|
251
190
|
// 1. 文本偏移量发生改变
|
|
@@ -253,79 +192,61 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
253
192
|
// 3. 文本允许重叠发生改变
|
|
254
193
|
// 4. 文本字体发生改变
|
|
255
194
|
// 5. 文本字体粗细发生改变
|
|
256
|
-
|
|
257
195
|
}, {
|
|
258
196
|
key: "needUpdate",
|
|
259
197
|
value: function () {
|
|
260
198
|
var _needUpdate = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
|
|
261
199
|
var _ref4, _ref4$textAllowOverla, textAllowOverlap, _ref4$textAnchor, textAnchor, textOffset, padding, fontFamily, fontWeight, zoom, extent, flag;
|
|
262
|
-
|
|
263
200
|
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
264
|
-
while (1) {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
_context4.next = 13;
|
|
300
|
-
return this.reBuildModel();
|
|
301
|
-
|
|
302
|
-
case 13:
|
|
303
|
-
return _context4.abrupt("return", true);
|
|
304
|
-
|
|
305
|
-
case 14:
|
|
306
|
-
return _context4.abrupt("return", false);
|
|
307
|
-
|
|
308
|
-
case 15:
|
|
309
|
-
case "end":
|
|
310
|
-
return _context4.stop();
|
|
311
|
-
}
|
|
201
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
202
|
+
case 0:
|
|
203
|
+
_ref4 = this.getTextStyle(), _ref4$textAllowOverla = _ref4.textAllowOverlap, textAllowOverlap = _ref4$textAllowOverla === void 0 ? false : _ref4$textAllowOverla, _ref4$textAnchor = _ref4.textAnchor, textAnchor = _ref4$textAnchor === void 0 ? 'center' : _ref4$textAnchor, textOffset = _ref4.textOffset, padding = _ref4.padding, fontFamily = _ref4.fontFamily, fontWeight = _ref4.fontWeight;
|
|
204
|
+
if (!(!(0, _lodash.isEqual)(padding, this.preTextStyle.padding) || !(0, _lodash.isEqual)(textOffset, this.preTextStyle.textOffset) || !(0, _lodash.isEqual)(textAnchor, this.preTextStyle.textAnchor) || !(0, _lodash.isEqual)(fontFamily, this.preTextStyle.fontFamily) || !(0, _lodash.isEqual)(fontWeight, this.preTextStyle.fontWeight))) {
|
|
205
|
+
_context4.next = 5;
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
_context4.next = 4;
|
|
209
|
+
return this.mapping();
|
|
210
|
+
case 4:
|
|
211
|
+
return _context4.abrupt("return", true);
|
|
212
|
+
case 5:
|
|
213
|
+
if (!textAllowOverlap) {
|
|
214
|
+
_context4.next = 7;
|
|
215
|
+
break;
|
|
216
|
+
}
|
|
217
|
+
return _context4.abrupt("return", false);
|
|
218
|
+
case 7:
|
|
219
|
+
// textAllowOverlap 发生改变
|
|
220
|
+
zoom = this.mapService.getZoom();
|
|
221
|
+
extent = this.mapService.getBounds();
|
|
222
|
+
flag = (0, _l7Utils.boundsContains)(this.extent, extent); // 文本不能压盖则进行过滤
|
|
223
|
+
if (!(Math.abs(this.currentZoom - zoom) > 0.5 || !flag || textAllowOverlap !== this.preTextStyle.textAllowOverlap)) {
|
|
224
|
+
_context4.next = 14;
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
_context4.next = 13;
|
|
228
|
+
return this.reBuildModel();
|
|
229
|
+
case 13:
|
|
230
|
+
return _context4.abrupt("return", true);
|
|
231
|
+
case 14:
|
|
232
|
+
return _context4.abrupt("return", false);
|
|
233
|
+
case 15:
|
|
234
|
+
case "end":
|
|
235
|
+
return _context4.stop();
|
|
312
236
|
}
|
|
313
237
|
}, _callee4, this);
|
|
314
238
|
}));
|
|
315
|
-
|
|
316
239
|
function needUpdate() {
|
|
317
240
|
return _needUpdate.apply(this, arguments);
|
|
318
241
|
}
|
|
319
|
-
|
|
320
242
|
return needUpdate;
|
|
321
243
|
}()
|
|
322
244
|
}, {
|
|
323
245
|
key: "clearModels",
|
|
324
246
|
value: function clearModels() {
|
|
325
247
|
var _this$texture;
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
248
|
+
(_this$texture = this.texture) === null || _this$texture === void 0 ? void 0 : _this$texture.destroy();
|
|
249
|
+
// TODO this.mapping
|
|
329
250
|
this.layer.off('remapping', this.mapping);
|
|
330
251
|
}
|
|
331
252
|
}, {
|
|
@@ -344,7 +265,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
344
265
|
size: 1,
|
|
345
266
|
update: function update(feature) {
|
|
346
267
|
var _feature$rotate = feature.rotate,
|
|
347
|
-
|
|
268
|
+
rotate = _feature$rotate === void 0 ? 0 : _feature$rotate;
|
|
348
269
|
return Array.isArray(rotate) ? [rotate[0]] : [rotate];
|
|
349
270
|
}
|
|
350
271
|
}
|
|
@@ -366,8 +287,9 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
366
287
|
return [vertex[5], vertex[6]];
|
|
367
288
|
}
|
|
368
289
|
}
|
|
369
|
-
});
|
|
290
|
+
});
|
|
370
291
|
|
|
292
|
+
// point layer size;
|
|
371
293
|
this.styleAttributeService.registerStyleAttribute({
|
|
372
294
|
name: 'size',
|
|
373
295
|
type: _l7Core.AttributeType.Attribute,
|
|
@@ -382,7 +304,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
382
304
|
size: 1,
|
|
383
305
|
update: function update(feature) {
|
|
384
306
|
var _feature$size = feature.size,
|
|
385
|
-
|
|
307
|
+
size = _feature$size === void 0 ? 12 : _feature$size;
|
|
386
308
|
return Array.isArray(size) ? [size[0]] : [size];
|
|
387
309
|
}
|
|
388
310
|
}
|
|
@@ -421,28 +343,23 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
421
343
|
/**
|
|
422
344
|
* 生成文字纹理(生成文字纹理字典)
|
|
423
345
|
*/
|
|
424
|
-
|
|
425
346
|
}, {
|
|
426
347
|
key: "initTextFont",
|
|
427
348
|
value: function initTextFont() {
|
|
428
349
|
var _this$getTextStyle = this.getTextStyle(),
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
350
|
+
fontWeight = _this$getTextStyle.fontWeight,
|
|
351
|
+
fontFamily = _this$getTextStyle.fontFamily;
|
|
432
352
|
var data = this.rawEncodeData;
|
|
433
353
|
var characterSet = [];
|
|
434
354
|
data.forEach(function (item) {
|
|
435
355
|
var _item$shape = item.shape,
|
|
436
|
-
|
|
356
|
+
shape = _item$shape === void 0 ? '' : _item$shape;
|
|
437
357
|
shape = shape.toString();
|
|
438
|
-
|
|
439
358
|
var _iterator = _createForOfIteratorHelper(shape),
|
|
440
|
-
|
|
441
|
-
|
|
359
|
+
_step;
|
|
442
360
|
try {
|
|
443
361
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
444
362
|
var char = _step.value;
|
|
445
|
-
|
|
446
363
|
// 去重
|
|
447
364
|
if (characterSet.indexOf(char) === -1) {
|
|
448
365
|
characterSet.push(char);
|
|
@@ -461,24 +378,22 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
461
378
|
iconfont: false
|
|
462
379
|
});
|
|
463
380
|
}
|
|
381
|
+
|
|
464
382
|
/**
|
|
465
383
|
* 生成 iconfont 纹理字典
|
|
466
384
|
*/
|
|
467
|
-
|
|
468
385
|
}, {
|
|
469
386
|
key: "initIconFontTex",
|
|
470
387
|
value: function initIconFontTex() {
|
|
471
388
|
var _this$getTextStyle2 = this.getTextStyle(),
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
389
|
+
fontWeight = _this$getTextStyle2.fontWeight,
|
|
390
|
+
fontFamily = _this$getTextStyle2.fontFamily;
|
|
475
391
|
var data = this.rawEncodeData;
|
|
476
392
|
var characterSet = [];
|
|
477
393
|
data.forEach(function (item) {
|
|
478
394
|
var _item$shape2 = item.shape,
|
|
479
|
-
|
|
395
|
+
shape = _item$shape2 === void 0 ? '' : _item$shape2;
|
|
480
396
|
shape = "".concat(shape);
|
|
481
|
-
|
|
482
397
|
if (characterSet.indexOf(shape) === -1) {
|
|
483
398
|
characterSet.push(shape);
|
|
484
399
|
}
|
|
@@ -494,27 +409,26 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
494
409
|
key: "getTextStyle",
|
|
495
410
|
value: function getTextStyle() {
|
|
496
411
|
var _ref5 = this.layer.getLayerConfig(),
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
412
|
+
_ref5$fontWeight = _ref5.fontWeight,
|
|
413
|
+
fontWeight = _ref5$fontWeight === void 0 ? '400' : _ref5$fontWeight,
|
|
414
|
+
_ref5$fontFamily = _ref5.fontFamily,
|
|
415
|
+
fontFamily = _ref5$fontFamily === void 0 ? 'sans-serif' : _ref5$fontFamily,
|
|
416
|
+
_ref5$textAllowOverla = _ref5.textAllowOverlap,
|
|
417
|
+
textAllowOverlap = _ref5$textAllowOverla === void 0 ? false : _ref5$textAllowOverla,
|
|
418
|
+
_ref5$padding = _ref5.padding,
|
|
419
|
+
padding = _ref5$padding === void 0 ? [0, 0] : _ref5$padding,
|
|
420
|
+
_ref5$textAnchor = _ref5.textAnchor,
|
|
421
|
+
textAnchor = _ref5$textAnchor === void 0 ? 'center' : _ref5$textAnchor,
|
|
422
|
+
_ref5$textOffset = _ref5.textOffset,
|
|
423
|
+
textOffset = _ref5$textOffset === void 0 ? [0, 0] : _ref5$textOffset,
|
|
424
|
+
_ref5$opacity = _ref5.opacity,
|
|
425
|
+
opacity = _ref5$opacity === void 0 ? 1 : _ref5$opacity,
|
|
426
|
+
_ref5$strokeOpacity = _ref5.strokeOpacity,
|
|
427
|
+
strokeOpacity = _ref5$strokeOpacity === void 0 ? 1 : _ref5$strokeOpacity,
|
|
428
|
+
_ref5$strokeWidth = _ref5.strokeWidth,
|
|
429
|
+
strokeWidth = _ref5$strokeWidth === void 0 ? 0 : _ref5$strokeWidth,
|
|
430
|
+
_ref5$stroke = _ref5.stroke,
|
|
431
|
+
stroke = _ref5$stroke === void 0 ? '#000' : _ref5$stroke;
|
|
518
432
|
return {
|
|
519
433
|
fontWeight: fontWeight,
|
|
520
434
|
fontFamily: fontFamily,
|
|
@@ -528,40 +442,41 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
528
442
|
stroke: stroke
|
|
529
443
|
};
|
|
530
444
|
}
|
|
445
|
+
|
|
531
446
|
/**
|
|
532
447
|
* 生成文字布局(对照文字纹理字典提取对应文字的位置很好信息)
|
|
533
448
|
*/
|
|
534
|
-
|
|
535
449
|
}, {
|
|
536
450
|
key: "generateGlyphLayout",
|
|
537
451
|
value: function generateGlyphLayout(iconfont) {
|
|
538
452
|
var _this2 = this;
|
|
539
|
-
|
|
540
453
|
var mapping = this.getFontServiceMapping();
|
|
541
|
-
|
|
542
454
|
var _ref6 = this.layer.getLayerConfig(),
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
455
|
+
_ref6$spacing = _ref6.spacing,
|
|
456
|
+
spacing = _ref6$spacing === void 0 ? 2 : _ref6$spacing,
|
|
457
|
+
_ref6$textAnchor = _ref6.textAnchor,
|
|
458
|
+
textAnchor = _ref6$textAnchor === void 0 ? 'center' : _ref6$textAnchor,
|
|
459
|
+
textOffset = _ref6.textOffset;
|
|
549
460
|
var data = this.rawEncodeData;
|
|
550
461
|
this.glyphInfo = data.map(function (feature) {
|
|
551
462
|
var _feature$shape = feature.shape,
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
var shaping = (0, _symbolLayout.shapeText)(shape.toString(), mapping,
|
|
557
|
-
|
|
463
|
+
shape = _feature$shape === void 0 ? '' : _feature$shape,
|
|
464
|
+
id = feature.id,
|
|
465
|
+
_feature$size2 = feature.size,
|
|
466
|
+
size = _feature$size2 === void 0 ? 1 : _feature$size2;
|
|
467
|
+
var shaping = (0, _symbolLayout.shapeText)(shape.toString(), mapping,
|
|
468
|
+
// @ts-ignore
|
|
469
|
+
size, textAnchor, 'left', spacing, textOffset,
|
|
470
|
+
// || feature['textOffset'] || [0, 0],// TODO: 文字偏移量 CPU 计算
|
|
558
471
|
iconfont);
|
|
559
472
|
var glyphQuads = (0, _symbolLayout.getGlyphQuads)(shaping, textOffset, false);
|
|
560
473
|
feature.shaping = shaping;
|
|
561
|
-
feature.glyphQuads = glyphQuads;
|
|
474
|
+
feature.glyphQuads = glyphQuads;
|
|
475
|
+
// feature.centroid = calculteCentroid(coordinates);
|
|
562
476
|
|
|
563
|
-
feature.centroid = (0, _l7Utils.calculateCentroid)(feature.coordinates);
|
|
477
|
+
feature.centroid = (0, _l7Utils.calculateCentroid)(feature.coordinates);
|
|
564
478
|
|
|
479
|
+
// 此时地图高德2.0 originCentroid == centroid
|
|
565
480
|
feature.originCentroid = feature.version === 'GAODE2.x' ? (0, _l7Utils.calculateCentroid)(feature.originCoordinates) : feature.originCentroid = feature.centroid;
|
|
566
481
|
_this2.glyphInfoMap[id] = {
|
|
567
482
|
shaping: shaping,
|
|
@@ -575,76 +490,66 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
575
490
|
key: "getFontServiceMapping",
|
|
576
491
|
value: function getFontServiceMapping() {
|
|
577
492
|
var _ref7 = this.layer.getLayerConfig(),
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
493
|
+
_ref7$fontWeight = _ref7.fontWeight,
|
|
494
|
+
fontWeight = _ref7$fontWeight === void 0 ? '400' : _ref7$fontWeight,
|
|
495
|
+
_ref7$fontFamily = _ref7.fontFamily,
|
|
496
|
+
fontFamily = _ref7$fontFamily === void 0 ? 'sans-serif' : _ref7$fontFamily;
|
|
583
497
|
return this.fontService.getMappingByKey("".concat(fontFamily, "_").concat(fontWeight));
|
|
584
498
|
}
|
|
585
499
|
}, {
|
|
586
500
|
key: "getFontServiceCanvas",
|
|
587
501
|
value: function getFontServiceCanvas() {
|
|
588
502
|
var _ref8 = this.layer.getLayerConfig(),
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
503
|
+
_ref8$fontWeight = _ref8.fontWeight,
|
|
504
|
+
fontWeight = _ref8$fontWeight === void 0 ? '400' : _ref8$fontWeight,
|
|
505
|
+
_ref8$fontFamily = _ref8.fontFamily,
|
|
506
|
+
fontFamily = _ref8$fontFamily === void 0 ? 'sans-serif' : _ref8$fontFamily;
|
|
507
|
+
// 更新文字布局
|
|
595
508
|
return this.fontService.getCanvasByKey("".concat(fontFamily, "_").concat(fontWeight));
|
|
596
509
|
}
|
|
510
|
+
|
|
597
511
|
/**
|
|
598
512
|
* 文字避让 depend on originCentorid
|
|
599
513
|
*/
|
|
600
|
-
|
|
601
514
|
}, {
|
|
602
515
|
key: "filterGlyphs",
|
|
603
516
|
value: function filterGlyphs() {
|
|
604
517
|
var _this3 = this;
|
|
605
|
-
|
|
606
518
|
var _ref9 = this.layer.getLayerConfig(),
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
519
|
+
_ref9$padding = _ref9.padding,
|
|
520
|
+
padding = _ref9$padding === void 0 ? [0, 0] : _ref9$padding,
|
|
521
|
+
_ref9$textAllowOverla = _ref9.textAllowOverlap,
|
|
522
|
+
textAllowOverlap = _ref9$textAllowOverla === void 0 ? false : _ref9$textAllowOverla;
|
|
612
523
|
if (textAllowOverlap) {
|
|
613
524
|
// 如果允许文本覆盖
|
|
614
525
|
return;
|
|
615
526
|
}
|
|
616
|
-
|
|
617
527
|
this.glyphInfoMap = {};
|
|
618
528
|
this.currentZoom = this.mapService.getZoom();
|
|
619
529
|
this.extent = this.textExtent();
|
|
620
|
-
|
|
621
530
|
var _this$rendererService = this.rendererService.getViewportSize(),
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
531
|
+
width = _this$rendererService.width,
|
|
532
|
+
height = _this$rendererService.height;
|
|
625
533
|
var collisionIndex = new _collisionIndex.default(width, height);
|
|
626
534
|
var filterData = this.glyphInfo.filter(function (feature) {
|
|
627
535
|
var shaping = feature.shaping,
|
|
628
|
-
|
|
629
|
-
|
|
536
|
+
_feature$id = feature.id,
|
|
537
|
+
id = _feature$id === void 0 ? 0 : _feature$id;
|
|
538
|
+
// const centroid = feature.centroid as [number, number];
|
|
630
539
|
// const centroid = feature.originCentroid as [number, number];
|
|
631
|
-
|
|
632
540
|
var centroid = feature.version === 'GAODE2.x' ? feature.originCentroid : feature.centroid;
|
|
633
541
|
var size = feature.size;
|
|
634
542
|
var fontScale = size / 16;
|
|
635
|
-
|
|
636
543
|
var pixels = _this3.mapService.lngLatToContainer(centroid);
|
|
637
|
-
|
|
638
544
|
var _collisionIndex$place = collisionIndex.placeCollisionBox({
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
545
|
+
x1: shaping.left * fontScale - padding[0],
|
|
546
|
+
x2: shaping.right * fontScale + padding[0],
|
|
547
|
+
y1: shaping.top * fontScale - padding[1],
|
|
548
|
+
y2: shaping.bottom * fontScale + padding[1],
|
|
549
|
+
anchorPointX: pixels.x,
|
|
550
|
+
anchorPointY: pixels.y
|
|
551
|
+
}),
|
|
552
|
+
box = _collisionIndex$place.box;
|
|
648
553
|
if (box && box.length) {
|
|
649
554
|
collisionIndex.insertCollisionBox(box, id);
|
|
650
555
|
return true;
|
|
@@ -655,39 +560,35 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
655
560
|
filterData.forEach(function (item) {
|
|
656
561
|
// @ts-ignore
|
|
657
562
|
_this3.glyphInfoMap[item.id] = item;
|
|
658
|
-
});
|
|
563
|
+
});
|
|
564
|
+
// this.layer.setEncodedData(filterData);
|
|
659
565
|
}
|
|
660
566
|
/**
|
|
661
567
|
* 初始化文字布局
|
|
662
568
|
*/
|
|
663
|
-
|
|
664
569
|
}, {
|
|
665
570
|
key: "initGlyph",
|
|
666
571
|
value: function initGlyph() {
|
|
667
572
|
var _this$layer$getLayerC = this.layer.getLayerConfig(),
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
573
|
+
_this$layer$getLayerC2 = _this$layer$getLayerC.iconfont,
|
|
574
|
+
iconfont = _this$layer$getLayerC2 === void 0 ? false : _this$layer$getLayerC2;
|
|
575
|
+
// 1.生成文字纹理(或是生成 iconfont)
|
|
576
|
+
iconfont ? this.initIconFontTex() : this.initTextFont();
|
|
577
|
+
// 2.生成文字布局
|
|
674
578
|
this.generateGlyphLayout(iconfont);
|
|
675
579
|
}
|
|
676
580
|
/**
|
|
677
581
|
* 更新文字纹理
|
|
678
582
|
*/
|
|
679
|
-
|
|
680
583
|
}, {
|
|
681
584
|
key: "updateTexture",
|
|
682
585
|
value: function updateTexture() {
|
|
683
586
|
var createTexture2D = this.rendererService.createTexture2D;
|
|
684
587
|
var canvas = this.getFontServiceCanvas();
|
|
685
588
|
this.textureHeight = canvas.height;
|
|
686
|
-
|
|
687
589
|
if (this.texture) {
|
|
688
590
|
this.texture.destroy();
|
|
689
591
|
}
|
|
690
|
-
|
|
691
592
|
this.texture = createTexture2D({
|
|
692
593
|
data: canvas,
|
|
693
594
|
mag: _l7Core.gl.LINEAR,
|
|
@@ -702,43 +603,36 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
702
603
|
var _reBuildModel = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
|
|
703
604
|
var model;
|
|
704
605
|
return _regenerator.default.wrap(function _callee5$(_context5) {
|
|
705
|
-
while (1) {
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
case 5:
|
|
727
|
-
case "end":
|
|
728
|
-
return _context5.stop();
|
|
729
|
-
}
|
|
606
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
607
|
+
case 0:
|
|
608
|
+
this.filterGlyphs();
|
|
609
|
+
_context5.next = 3;
|
|
610
|
+
return this.layer.buildLayerModel({
|
|
611
|
+
moduleName: 'pointText',
|
|
612
|
+
vertexShader: textVert,
|
|
613
|
+
fragmentShader: textFrag,
|
|
614
|
+
triangulation: TextTrianglation.bind(this),
|
|
615
|
+
inject: this.getInject(),
|
|
616
|
+
depth: {
|
|
617
|
+
enable: false
|
|
618
|
+
}
|
|
619
|
+
});
|
|
620
|
+
case 3:
|
|
621
|
+
model = _context5.sent;
|
|
622
|
+
// TODO 渲染流程待修改
|
|
623
|
+
this.layer.models = [model];
|
|
624
|
+
case 5:
|
|
625
|
+
case "end":
|
|
626
|
+
return _context5.stop();
|
|
730
627
|
}
|
|
731
628
|
}, _callee5, this);
|
|
732
629
|
}));
|
|
733
|
-
|
|
734
630
|
function reBuildModel() {
|
|
735
631
|
return _reBuildModel.apply(this, arguments);
|
|
736
632
|
}
|
|
737
|
-
|
|
738
633
|
return reBuildModel;
|
|
739
634
|
}()
|
|
740
635
|
}]);
|
|
741
636
|
return TextModel;
|
|
742
637
|
}(_BaseModel2.default);
|
|
743
|
-
|
|
744
638
|
exports.default = TextModel;
|