@antv/l7-layers 2.16.0 → 2.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/Geometry/index.js +31 -9
- package/es/Geometry/models/billboard.js +89 -51
- package/es/Geometry/models/plane.js +143 -81
- package/es/Geometry/models/sprite.js +118 -60
- package/es/canvas/index.js +33 -10
- package/es/canvas/models/canvas.js +97 -41
- package/es/citybuliding/building.js +27 -8
- package/es/citybuliding/models/build.js +82 -57
- package/es/core/BaseLayer.js +485 -321
- package/es/core/BaseModel.js +126 -97
- package/es/core/LayerPickService.js +32 -21
- package/es/core/TextureService.js +13 -0
- package/es/core/interface.js +24 -17
- package/es/core/shape/Path.js +20 -13
- package/es/core/shape/extrude.js +31 -10
- package/es/core/triangulation.js +114 -54
- package/es/earth/index.js +33 -9
- package/es/earth/models/atmosphere.js +54 -30
- package/es/earth/models/base.js +85 -47
- package/es/earth/models/bloomsphere.js +54 -30
- package/es/earth/utils.js +13 -9
- package/es/heatmap/index.js +40 -10
- package/es/heatmap/models/grid.js +52 -28
- package/es/heatmap/models/grid3d.js +52 -28
- package/es/heatmap/models/heatmap.js +146 -91
- package/es/heatmap/models/hexagon.js +52 -28
- package/es/heatmap/triangulation.js +4 -0
- package/es/image/index.js +28 -9
- package/es/image/models/image.js +100 -66
- package/es/index.js +17 -9
- package/es/line/index.js +34 -9
- package/es/line/models/arc.js +118 -66
- package/es/line/models/arc_3d.js +108 -60
- package/es/line/models/earthArc_3d.js +111 -63
- package/es/line/models/great_circle.js +100 -56
- package/es/line/models/half.js +77 -46
- package/es/line/models/line.js +148 -94
- package/es/line/models/linearline.js +80 -45
- package/es/line/models/simpleLine.js +74 -41
- package/es/line/models/wall.js +92 -52
- package/es/mask/index.js +28 -9
- package/es/mask/models/fill.js +54 -29
- package/es/plugins/DataMappingPlugin.js +117 -80
- package/es/plugins/DataSourcePlugin.js +68 -45
- package/es/plugins/FeatureScalePlugin.js +122 -67
- package/es/plugins/LayerAnimateStylePlugin.js +5 -0
- package/es/plugins/LayerMaskPlugin.js +11 -3
- package/es/plugins/LayerModelPlugin.js +104 -67
- package/es/plugins/LayerStylePlugin.js +9 -3
- package/es/plugins/LightingPlugin.js +18 -12
- package/es/plugins/MultiPassRendererPlugin.js +16 -11
- package/es/plugins/PixelPickingPlugin.js +21 -12
- package/es/plugins/RegisterStyleAttributePlugin.js +12 -5
- package/es/plugins/ShaderUniformPlugin.js +27 -13
- package/es/plugins/UpdateModelPlugin.js +5 -0
- package/es/plugins/UpdateStyleAttributePlugin.js +11 -5
- package/es/point/index.js +77 -26
- package/es/point/models/earthExtrude.js +102 -61
- package/es/point/models/earthFill.js +87 -57
- package/es/point/models/extrude.js +101 -60
- package/es/point/models/fill.js +100 -70
- package/es/point/models/fillmage.js +107 -63
- package/es/point/models/image.js +88 -48
- package/es/point/models/index.js +2 -2
- package/es/point/models/normal.js +54 -30
- package/es/point/models/radar.js +64 -40
- package/es/point/models/simplePoint.js +69 -41
- package/es/point/models/text.js +301 -198
- package/es/point/shape/extrude.js +13 -4
- package/es/polygon/index.js +40 -11
- package/es/polygon/models/extrude.js +92 -48
- package/es/polygon/models/fill.js +88 -54
- package/es/polygon/models/index.js +2 -3
- package/es/polygon/models/ocean.js +76 -42
- package/es/polygon/models/water.js +71 -37
- package/es/raster/buffers/triangulation.js +4 -2
- package/es/raster/index.js +32 -9
- package/es/raster/models/raster.js +116 -80
- package/es/raster/models/rasterRgb.js +127 -84
- package/es/raster/models/rasterTerrainRgb.js +84 -56
- package/es/tile/interaction/getRasterData.js +20 -14
- package/es/tile/interaction/utils.js +9 -7
- package/es/tile/manager/base.js +96 -63
- package/es/tile/service/TileLayerService.js +55 -33
- package/es/tile/service/TilePickService.js +40 -26
- package/es/tile/service/TileSourceService.js +7 -3
- package/es/tile/tileFactory/DebugTile.js +46 -29
- package/es/tile/tileFactory/ImageTile.js +38 -20
- package/es/tile/tileFactory/MaskTile.js +43 -22
- package/es/tile/tileFactory/RasterRGBTile.js +42 -22
- package/es/tile/tileFactory/RasterTerrainRGBTile.js +38 -20
- package/es/tile/tileFactory/RasterTile.js +53 -30
- package/es/tile/tileFactory/Tile.js +97 -63
- package/es/tile/tileFactory/VectorTile.js +68 -41
- package/es/tile/tileFactory/index.js +11 -0
- package/es/tile/tileFactory/layers/TileDebugLayer.js +27 -6
- package/es/tile/tileFactory/util.js +3 -0
- package/es/tile/tileLayer/BaseLayer.js +146 -105
- package/es/tile/utils.js +1 -1
- package/es/utils/blend.js +2 -0
- package/es/utils/collision-index.js +16 -9
- package/es/utils/dataMappingStyle.js +18 -8
- package/es/utils/extrude_polyline.js +149 -101
- package/es/utils/grid-index.js +27 -2
- package/es/utils/identityScale.js +8 -0
- package/es/utils/layerData.js +44 -30
- package/es/utils/multiPassRender.js +13 -11
- package/es/utils/polylineNormal.js +37 -31
- package/es/utils/simpleLine.js +16 -2
- package/es/utils/stencil.js +3 -2
- package/es/utils/symbol-layout.js +53 -27
- package/es/wind/index.js +29 -9
- package/es/wind/models/utils.js +51 -26
- package/es/wind/models/wind.js +147 -101
- package/es/wind/models/windRender.js +66 -53
- package/lib/Geometry/index.js +38 -9
- package/lib/Geometry/models/billboard.js +97 -51
- package/lib/Geometry/models/index.js +5 -0
- package/lib/Geometry/models/plane.js +151 -79
- package/lib/Geometry/models/sprite.js +127 -60
- package/lib/canvas/index.js +40 -10
- package/lib/canvas/models/canvas.js +101 -41
- package/lib/canvas/models/index.js +3 -0
- package/lib/citybuliding/building.js +35 -8
- package/lib/citybuliding/models/build.js +92 -57
- package/lib/core/BaseLayer.js +479 -321
- package/lib/core/BaseModel.js +139 -97
- package/lib/core/LayerPickService.js +37 -21
- package/lib/core/TextureService.js +16 -0
- package/lib/core/interface.js +31 -21
- package/lib/core/schema.js +1 -0
- package/lib/core/shape/Path.js +31 -14
- package/lib/core/shape/extrude.js +54 -10
- package/lib/core/triangulation.js +153 -53
- package/lib/earth/index.js +43 -9
- package/lib/earth/models/atmosphere.js +63 -30
- package/lib/earth/models/base.js +90 -47
- package/lib/earth/models/bloomsphere.js +63 -30
- package/lib/earth/utils.js +31 -7
- package/lib/heatmap/index.js +48 -10
- package/lib/heatmap/models/grid.js +60 -28
- package/lib/heatmap/models/grid3d.js +60 -28
- package/lib/heatmap/models/heatmap.js +162 -91
- package/lib/heatmap/models/hexagon.js +60 -28
- package/lib/heatmap/models/index.js +6 -0
- package/lib/heatmap/triangulation.js +5 -0
- package/lib/image/index.js +36 -9
- package/lib/image/models/image.js +109 -66
- package/lib/image/models/index.js +3 -0
- package/lib/index.js +61 -7
- package/lib/line/index.js +40 -9
- package/lib/line/models/arc.js +128 -64
- package/lib/line/models/arc_3d.js +119 -58
- package/lib/line/models/earthArc_3d.js +122 -61
- package/lib/line/models/great_circle.js +111 -56
- package/lib/line/models/half.js +87 -46
- package/lib/line/models/index.js +11 -0
- package/lib/line/models/line.js +156 -92
- package/lib/line/models/linearline.js +92 -45
- package/lib/line/models/simpleLine.js +84 -41
- package/lib/line/models/wall.js +103 -52
- package/lib/mask/index.js +36 -9
- package/lib/mask/models/fill.js +63 -29
- package/lib/mask/models/index.js +3 -0
- package/lib/plugins/DataMappingPlugin.js +128 -80
- package/lib/plugins/DataSourcePlugin.js +76 -45
- package/lib/plugins/FeatureScalePlugin.js +138 -67
- package/lib/plugins/LayerAnimateStylePlugin.js +10 -0
- package/lib/plugins/LayerMaskPlugin.js +17 -4
- package/lib/plugins/LayerModelPlugin.js +113 -68
- package/lib/plugins/LayerStylePlugin.js +14 -4
- package/lib/plugins/LightingPlugin.js +25 -12
- package/lib/plugins/MultiPassRendererPlugin.js +22 -11
- package/lib/plugins/PixelPickingPlugin.js +27 -12
- package/lib/plugins/RegisterStyleAttributePlugin.js +19 -5
- package/lib/plugins/ShaderUniformPlugin.js +34 -13
- package/lib/plugins/UpdateModelPlugin.js +10 -1
- package/lib/plugins/UpdateStyleAttributePlugin.js +16 -5
- package/lib/point/index.js +83 -26
- package/lib/point/models/earthExtrude.js +113 -61
- package/lib/point/models/earthFill.js +117 -57
- package/lib/point/models/extrude.js +111 -60
- package/lib/point/models/fill.js +109 -68
- package/lib/point/models/fillmage.js +115 -61
- package/lib/point/models/image.js +98 -48
- package/lib/point/models/index.js +12 -1
- package/lib/point/models/normal.js +64 -30
- package/lib/point/models/radar.js +74 -40
- package/lib/point/models/simplePoint.js +79 -41
- package/lib/point/models/text.js +309 -198
- package/lib/point/shape/extrude.js +20 -4
- package/lib/polygon/index.js +48 -11
- package/lib/polygon/models/extrude.js +103 -48
- package/lib/polygon/models/fill.js +98 -54
- package/lib/polygon/models/index.js +14 -2
- package/lib/polygon/models/ocean.js +88 -42
- package/lib/polygon/models/water.js +82 -37
- package/lib/raster/buffers/triangulation.js +7 -3
- package/lib/raster/index.js +40 -9
- package/lib/raster/models/index.js +5 -0
- package/lib/raster/models/raster.js +125 -80
- package/lib/raster/models/rasterRgb.js +139 -84
- package/lib/raster/models/rasterTerrainRgb.js +93 -56
- package/lib/tile/interaction/getRasterData.js +25 -14
- package/lib/tile/interaction/utils.js +19 -7
- package/lib/tile/manager/base.js +104 -63
- package/lib/tile/service/TileLayerService.js +60 -33
- package/lib/tile/service/TilePickService.js +48 -26
- package/lib/tile/service/TileSourceService.js +16 -2
- package/lib/tile/style/utils.js +3 -0
- package/lib/tile/tileFactory/DebugTile.js +54 -29
- package/lib/tile/tileFactory/ImageTile.js +46 -20
- package/lib/tile/tileFactory/MaskTile.js +51 -22
- package/lib/tile/tileFactory/RasterRGBTile.js +50 -22
- package/lib/tile/tileFactory/RasterTerrainRGBTile.js +46 -20
- package/lib/tile/tileFactory/RasterTile.js +63 -30
- package/lib/tile/tileFactory/Tile.js +102 -63
- package/lib/tile/tileFactory/VectorTile.js +76 -41
- package/lib/tile/tileFactory/index.js +25 -0
- package/lib/tile/tileFactory/layers/TileDebugLayer.js +32 -6
- package/lib/tile/tileFactory/util.js +9 -0
- package/lib/tile/tileLayer/BaseLayer.js +153 -105
- package/lib/tile/utils.js +5 -1
- package/lib/utils/blend.js +5 -0
- package/lib/utils/collision-index.js +25 -9
- package/lib/utils/dataMappingStyle.js +19 -8
- package/lib/utils/extrude_polyline.js +181 -101
- package/lib/utils/grid-index.js +28 -2
- package/lib/utils/identityScale.js +9 -0
- package/lib/utils/layerData.js +49 -30
- package/lib/utils/multiPassRender.js +16 -11
- package/lib/utils/polylineNormal.js +66 -31
- package/lib/utils/simpleLine.js +21 -2
- package/lib/utils/stencil.js +4 -0
- package/lib/utils/symbol-layout.js +55 -27
- package/lib/wind/index.js +37 -9
- package/lib/wind/models/index.js +3 -0
- package/lib/wind/models/utils.js +62 -26
- package/lib/wind/models/wind.js +157 -101
- package/lib/wind/models/windRender.js +71 -53
- package/lib/wind/models/windShader.js +1 -0
- package/package.json +7 -7
package/lib/point/models/text.js
CHANGED
|
@@ -1,42 +1,68 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports.TextTrianglation = TextTrianglation;
|
|
8
9
|
exports.default = void 0;
|
|
10
|
+
|
|
9
11
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
12
|
+
|
|
10
13
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
14
|
+
|
|
11
15
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
16
|
+
|
|
12
17
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
18
|
+
|
|
13
19
|
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
20
|
+
|
|
14
21
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
22
|
+
|
|
15
23
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
24
|
+
|
|
16
25
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
26
|
+
|
|
17
27
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
28
|
+
|
|
18
29
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
30
|
+
|
|
19
31
|
var _l7Core = require("@antv/l7-core");
|
|
32
|
+
|
|
20
33
|
var _l7Utils = require("@antv/l7-utils");
|
|
34
|
+
|
|
21
35
|
var _lodash = require("lodash");
|
|
36
|
+
|
|
22
37
|
var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
|
|
38
|
+
|
|
23
39
|
var _collisionIndex = _interopRequireDefault(require("../../utils/collision-index"));
|
|
40
|
+
|
|
24
41
|
var _symbolLayout = require("../../utils/symbol-layout");
|
|
42
|
+
|
|
25
43
|
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; } } }; }
|
|
44
|
+
|
|
26
45
|
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); }
|
|
27
|
-
|
|
46
|
+
|
|
47
|
+
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; }
|
|
48
|
+
|
|
28
49
|
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); }; }
|
|
50
|
+
|
|
29
51
|
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; } }
|
|
52
|
+
|
|
30
53
|
/* babel-plugin-inline-import '../shaders/text_frag.glsl' */
|
|
31
54
|
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;\n// uniform float u_font_size : 24.0;\nuniform float u_opacity : 1.0;\nuniform vec4 u_stroke_color : [0, 0, 0, 1];\nuniform float u_stroke_width : 2.0;\nuniform float u_halo_blur : 0.5;\nuniform float u_DevicePixelRatio;\n\nvarying vec4 v_color;\nvarying vec2 v_uv;\nvarying float v_gamma_scale;\nvarying float v_fontScale;\n\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n\n#pragma include \"picking\"\nvoid main() {\n // get style data mapping\n float opacity = styleMappingMat[0][0];\n float strokeWidth = styleMappingMat[0][2];\n vec4 textrueStroke = vec4(\n styleMappingMat[1][0],\n styleMappingMat[1][1],\n styleMappingMat[1][2],\n styleMappingMat[1][3]\n );\n\n // get sdf from atlas\n float dist = texture2D(u_sdf_map, v_uv).a;\n\n // float fontScale = u_font_size / FONT_SIZE;\n\n // lowp float buff = (6.0 - u_stroke_width / v_fontScale) / SDF_PX;\n lowp float buff = (6.0 - strokeWidth / 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 // gl_FragColor = mix(vec4(v_color.rgb, v_color.a * u_opacity), vec4(u_stroke_color.rgb, u_stroke_color.a * u_opacity), smoothstep(0., 0.5, 1. - dist));\n gl_FragColor = mix(vec4(v_color.rgb, v_color.a * opacity), vec4(textrueStroke.rgb, textrueStroke.a * opacity), smoothstep(0., 0.5, 1. - dist));\n gl_FragColor.a= 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";
|
|
55
|
+
|
|
32
56
|
/* babel-plugin-inline-import '../shaders/text_vert.glsl' */
|
|
33
57
|
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 float v_fontScale;\n\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\nuniform 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#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n#pragma include \"styleMappingCalStrokeWidth\"\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 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\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\n vec2 strokeWidthAndOffset = calStrokeWidthAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][2] = strokeWidthAndOffset.r;\n textureOffset = strokeWidthAndOffset.g;\n\n vec4 textrueStroke = vec4(-1.0, -1.0, -1.0, -1.0);\n if(hasStroke()) {\n vec2 valueRPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][0] = pos2value(valueRPos, columnWidth, rowHeight); // R\n textureOffset += 1.0;\n\n vec2 valueGPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][1] = pos2value(valueGPos, columnWidth, rowHeight); // G\n textureOffset += 1.0;\n\n vec2 valueBPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][2] = pos2value(valueBPos, columnWidth, rowHeight); // B\n textureOffset += 1.0;\n\n vec2 valueAPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][3] = pos2value(valueAPos, columnWidth, rowHeight); // A\n textureOffset += 1.0;\n } else {\n if(u_stroke_color == vec4(0.0)) {\n styleMappingMat[1][0] = v_color.r;\n styleMappingMat[1][1] = v_color.g;\n styleMappingMat[1][2] = v_color.b;\n styleMappingMat[1][3] = v_color.a;\n } else {\n styleMappingMat[1][0] = u_stroke_color.r;\n styleMappingMat[1][1] = u_stroke_color.g;\n styleMappingMat[1][2] = u_stroke_color.b;\n styleMappingMat[1][3] = u_stroke_color.a;\n }\n }\n \n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n v_color = a_Color;\n v_uv = a_tex / u_sdf_map_size;\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";
|
|
58
|
+
|
|
34
59
|
function TextTrianglation(feature) {
|
|
35
60
|
// @ts-ignore
|
|
36
61
|
var that = this;
|
|
37
62
|
var id = feature.id;
|
|
38
63
|
var vertices = [];
|
|
39
64
|
var indices = [];
|
|
65
|
+
|
|
40
66
|
if (!that.glyphInfoMap || !that.glyphInfoMap[id]) {
|
|
41
67
|
return {
|
|
42
68
|
vertices: [],
|
|
@@ -45,7 +71,9 @@ function TextTrianglation(feature) {
|
|
|
45
71
|
size: 7
|
|
46
72
|
};
|
|
47
73
|
}
|
|
74
|
+
|
|
48
75
|
var centroid = that.glyphInfoMap[id].centroid; // 计算中心点
|
|
76
|
+
|
|
49
77
|
var coord = centroid.length === 2 ? [centroid[0], centroid[1], 0] : centroid;
|
|
50
78
|
that.glyphInfoMap[id].glyphQuads.forEach(function (quad, index) {
|
|
51
79
|
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]));
|
|
@@ -58,15 +86,21 @@ function TextTrianglation(feature) {
|
|
|
58
86
|
size: 7
|
|
59
87
|
};
|
|
60
88
|
}
|
|
89
|
+
|
|
61
90
|
var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
62
91
|
(0, _inherits2.default)(TextModel, _BaseModel);
|
|
92
|
+
|
|
63
93
|
var _super = _createSuper(TextModel);
|
|
94
|
+
|
|
64
95
|
function TextModel() {
|
|
65
96
|
var _this;
|
|
97
|
+
|
|
66
98
|
(0, _classCallCheck2.default)(this, TextModel);
|
|
99
|
+
|
|
67
100
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
68
101
|
args[_key] = arguments[_key];
|
|
69
102
|
}
|
|
103
|
+
|
|
70
104
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
71
105
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "glyphInfoMap", {});
|
|
72
106
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "currentZoom", -1);
|
|
@@ -75,43 +109,54 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
75
109
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "preTextStyle", {});
|
|
76
110
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "mapping", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
77
111
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
78
|
-
while (1)
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
112
|
+
while (1) {
|
|
113
|
+
switch (_context.prev = _context.next) {
|
|
114
|
+
case 0:
|
|
115
|
+
_this.initGlyph(); //
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
_this.updateTexture();
|
|
119
|
+
|
|
120
|
+
_context.next = 4;
|
|
121
|
+
return _this.reBuildModel();
|
|
122
|
+
|
|
123
|
+
case 4:
|
|
124
|
+
case "end":
|
|
125
|
+
return _context.stop();
|
|
126
|
+
}
|
|
87
127
|
}
|
|
88
128
|
}, _callee);
|
|
89
129
|
})));
|
|
90
130
|
return _this;
|
|
91
131
|
}
|
|
132
|
+
|
|
92
133
|
(0, _createClass2.default)(TextModel, [{
|
|
93
134
|
key: "getUninforms",
|
|
94
135
|
value: function getUninforms() {
|
|
95
136
|
var _ref2 = this.layer.getLayerConfig(),
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
137
|
+
_ref2$opacity = _ref2.opacity,
|
|
138
|
+
opacity = _ref2$opacity === void 0 ? 1.0 : _ref2$opacity,
|
|
139
|
+
_ref2$stroke = _ref2.stroke,
|
|
140
|
+
stroke = _ref2$stroke === void 0 ? '#fff' : _ref2$stroke,
|
|
141
|
+
_ref2$strokeWidth = _ref2.strokeWidth,
|
|
142
|
+
strokeWidth = _ref2$strokeWidth === void 0 ? 0 : _ref2$strokeWidth,
|
|
143
|
+
_ref2$halo = _ref2.halo,
|
|
144
|
+
halo = _ref2$halo === void 0 ? 0.5 : _ref2$halo,
|
|
145
|
+
_ref2$gamma = _ref2.gamma,
|
|
146
|
+
gamma = _ref2$gamma === void 0 ? 2.0 : _ref2$gamma,
|
|
147
|
+
_ref2$raisingHeight = _ref2.raisingHeight,
|
|
148
|
+
raisingHeight = _ref2$raisingHeight === void 0 ? 0 : _ref2$raisingHeight;
|
|
149
|
+
|
|
108
150
|
var mapping = this.getFontServiceMapping();
|
|
109
151
|
var canvas = this.getFontServiceCanvas();
|
|
152
|
+
|
|
110
153
|
if (mapping && Object.keys(mapping).length !== this.textCount && canvas) {
|
|
111
154
|
this.updateTexture();
|
|
112
155
|
this.textCount = Object.keys(mapping).length;
|
|
113
156
|
}
|
|
157
|
+
|
|
114
158
|
this.preTextStyle = this.getTextStyle();
|
|
159
|
+
|
|
115
160
|
if (this.dataTextureTest && this.dataTextureNeedUpdate({
|
|
116
161
|
opacity: opacity,
|
|
117
162
|
strokeWidth: strokeWidth,
|
|
@@ -123,11 +168,14 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
123
168
|
stroke: stroke
|
|
124
169
|
});
|
|
125
170
|
var encodeData = this.layer.getEncodedData();
|
|
171
|
+
|
|
126
172
|
var _this$calDataFrame = this.calDataFrame(this.cellLength, encodeData, this.cellProperties),
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
173
|
+
data = _this$calDataFrame.data,
|
|
174
|
+
width = _this$calDataFrame.width,
|
|
175
|
+
height = _this$calDataFrame.height;
|
|
176
|
+
|
|
130
177
|
this.rowCount = height; // 当前数据纹理有多少行
|
|
178
|
+
|
|
131
179
|
this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
|
|
132
180
|
flipY: true,
|
|
133
181
|
data: data,
|
|
@@ -144,6 +192,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
144
192
|
height: 1
|
|
145
193
|
});
|
|
146
194
|
}
|
|
195
|
+
|
|
147
196
|
return {
|
|
148
197
|
u_dataTexture: this.dataTexture,
|
|
149
198
|
// 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]
|
|
@@ -163,23 +212,28 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
163
212
|
value: function () {
|
|
164
213
|
var _initModels = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
165
214
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
166
|
-
while (1)
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
215
|
+
while (1) {
|
|
216
|
+
switch (_context2.prev = _context2.next) {
|
|
217
|
+
case 0:
|
|
218
|
+
// 绑定事件
|
|
219
|
+
this.bindEvent();
|
|
220
|
+
this.extent = this.textExtent();
|
|
221
|
+
this.rawEncodeData = this.layer.getEncodedData();
|
|
222
|
+
this.preTextStyle = this.getTextStyle();
|
|
223
|
+
return _context2.abrupt("return", this.buildModels());
|
|
224
|
+
|
|
225
|
+
case 5:
|
|
226
|
+
case "end":
|
|
227
|
+
return _context2.stop();
|
|
228
|
+
}
|
|
177
229
|
}
|
|
178
230
|
}, _callee2, this);
|
|
179
231
|
}));
|
|
232
|
+
|
|
180
233
|
function initModels() {
|
|
181
234
|
return _initModels.apply(this, arguments);
|
|
182
235
|
}
|
|
236
|
+
|
|
183
237
|
return initModels;
|
|
184
238
|
}()
|
|
185
239
|
}, {
|
|
@@ -187,37 +241,48 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
187
241
|
value: function () {
|
|
188
242
|
var _buildModels = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
|
|
189
243
|
var _ref3, _ref3$textAllowOverla, textAllowOverlap, model;
|
|
244
|
+
|
|
190
245
|
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
191
|
-
while (1)
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
vertexShader: textVert,
|
|
203
|
-
fragmentShader: textFrag,
|
|
204
|
-
triangulation: TextTrianglation.bind(this),
|
|
205
|
-
depth: {
|
|
206
|
-
enable: false
|
|
246
|
+
while (1) {
|
|
247
|
+
switch (_context3.prev = _context3.next) {
|
|
248
|
+
case 0:
|
|
249
|
+
_ref3 = this.layer.getLayerConfig(), _ref3$textAllowOverla = _ref3.textAllowOverlap, textAllowOverlap = _ref3$textAllowOverla === void 0 ? false : _ref3$textAllowOverla; // this.mapping(); 重复调用
|
|
250
|
+
|
|
251
|
+
this.initGlyph(); //
|
|
252
|
+
|
|
253
|
+
this.updateTexture();
|
|
254
|
+
|
|
255
|
+
if (!textAllowOverlap) {
|
|
256
|
+
this.filterGlyphs();
|
|
207
257
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
258
|
+
|
|
259
|
+
_context3.next = 6;
|
|
260
|
+
return this.layer.buildLayerModel({
|
|
261
|
+
moduleName: 'pointText',
|
|
262
|
+
vertexShader: textVert,
|
|
263
|
+
fragmentShader: textFrag,
|
|
264
|
+
triangulation: TextTrianglation.bind(this),
|
|
265
|
+
depth: {
|
|
266
|
+
enable: false
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
case 6:
|
|
271
|
+
model = _context3.sent;
|
|
272
|
+
return _context3.abrupt("return", [model]);
|
|
273
|
+
|
|
274
|
+
case 8:
|
|
275
|
+
case "end":
|
|
276
|
+
return _context3.stop();
|
|
277
|
+
}
|
|
215
278
|
}
|
|
216
279
|
}, _callee3, this);
|
|
217
280
|
}));
|
|
281
|
+
|
|
218
282
|
function buildModels() {
|
|
219
283
|
return _buildModels.apply(this, arguments);
|
|
220
284
|
}
|
|
285
|
+
|
|
221
286
|
return buildModels;
|
|
222
287
|
}() // 需要更新的场景
|
|
223
288
|
// 1. 文本偏移量发生改变
|
|
@@ -225,62 +290,80 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
225
290
|
// 3. 文本允许重叠发生改变
|
|
226
291
|
// 4. 文本字体发生改变
|
|
227
292
|
// 5. 文本字体粗细发生改变
|
|
293
|
+
|
|
228
294
|
}, {
|
|
229
295
|
key: "needUpdate",
|
|
230
296
|
value: function () {
|
|
231
297
|
var _needUpdate = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
|
|
232
298
|
var _ref4, _ref4$textAllowOverla, textAllowOverlap, _ref4$textAnchor, textAnchor, textOffset, padding, fontFamily, fontWeight, zoom, extent, flag;
|
|
299
|
+
|
|
233
300
|
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
234
|
-
while (1)
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
301
|
+
while (1) {
|
|
302
|
+
switch (_context4.prev = _context4.next) {
|
|
303
|
+
case 0:
|
|
304
|
+
_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;
|
|
305
|
+
|
|
306
|
+
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))) {
|
|
307
|
+
_context4.next = 5;
|
|
308
|
+
break;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
_context4.next = 4;
|
|
312
|
+
return this.mapping();
|
|
313
|
+
|
|
314
|
+
case 4:
|
|
315
|
+
return _context4.abrupt("return", true);
|
|
316
|
+
|
|
317
|
+
case 5:
|
|
318
|
+
if (!textAllowOverlap) {
|
|
319
|
+
_context4.next = 7;
|
|
320
|
+
break;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
return _context4.abrupt("return", false);
|
|
324
|
+
|
|
325
|
+
case 7:
|
|
326
|
+
// textAllowOverlap 发生改变
|
|
327
|
+
zoom = this.mapService.getZoom();
|
|
328
|
+
extent = this.mapService.getBounds();
|
|
329
|
+
flag = (0, _l7Utils.boundsContains)(this.extent, extent); // 文本不能压盖则进行过滤
|
|
330
|
+
|
|
331
|
+
if (!(Math.abs(this.currentZoom - zoom) > 0.5 || !flag || textAllowOverlap !== this.preTextStyle.textAllowOverlap)) {
|
|
332
|
+
_context4.next = 14;
|
|
333
|
+
break;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
_context4.next = 13;
|
|
337
|
+
return this.reBuildModel();
|
|
338
|
+
|
|
339
|
+
case 13:
|
|
340
|
+
return _context4.abrupt("return", true);
|
|
341
|
+
|
|
342
|
+
case 14:
|
|
343
|
+
return _context4.abrupt("return", false);
|
|
344
|
+
|
|
345
|
+
case 15:
|
|
346
|
+
case "end":
|
|
347
|
+
return _context4.stop();
|
|
348
|
+
}
|
|
269
349
|
}
|
|
270
350
|
}, _callee4, this);
|
|
271
351
|
}));
|
|
352
|
+
|
|
272
353
|
function needUpdate() {
|
|
273
354
|
return _needUpdate.apply(this, arguments);
|
|
274
355
|
}
|
|
356
|
+
|
|
275
357
|
return needUpdate;
|
|
276
358
|
}()
|
|
277
359
|
}, {
|
|
278
360
|
key: "clearModels",
|
|
279
361
|
value: function clearModels() {
|
|
280
362
|
var _this$texture, _this$dataTexture;
|
|
363
|
+
|
|
281
364
|
(_this$texture = this.texture) === null || _this$texture === void 0 ? void 0 : _this$texture.destroy();
|
|
282
|
-
(_this$dataTexture = this.dataTexture) === null || _this$dataTexture === void 0 ? void 0 : _this$dataTexture.destroy();
|
|
283
|
-
|
|
365
|
+
(_this$dataTexture = this.dataTexture) === null || _this$dataTexture === void 0 ? void 0 : _this$dataTexture.destroy(); // TODO this.mapping
|
|
366
|
+
|
|
284
367
|
this.layer.off('remapping', this.mapping);
|
|
285
368
|
}
|
|
286
369
|
}, {
|
|
@@ -299,7 +382,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
299
382
|
size: 1,
|
|
300
383
|
update: function update(feature) {
|
|
301
384
|
var _feature$rotate = feature.rotate,
|
|
302
|
-
|
|
385
|
+
rotate = _feature$rotate === void 0 ? 0 : _feature$rotate;
|
|
303
386
|
return Array.isArray(rotate) ? [rotate[0]] : [rotate];
|
|
304
387
|
}
|
|
305
388
|
}
|
|
@@ -320,9 +403,8 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
320
403
|
return [vertex[5], vertex[6]];
|
|
321
404
|
}
|
|
322
405
|
}
|
|
323
|
-
});
|
|
406
|
+
}); // point layer size;
|
|
324
407
|
|
|
325
|
-
// point layer size;
|
|
326
408
|
this.styleAttributeService.registerStyleAttribute({
|
|
327
409
|
name: 'size',
|
|
328
410
|
type: _l7Core.AttributeType.Attribute,
|
|
@@ -337,7 +419,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
337
419
|
size: 1,
|
|
338
420
|
update: function update(feature) {
|
|
339
421
|
var _feature$size = feature.size,
|
|
340
|
-
|
|
422
|
+
size = _feature$size === void 0 ? 12 : _feature$size;
|
|
341
423
|
return Array.isArray(size) ? [size[0]] : [size];
|
|
342
424
|
}
|
|
343
425
|
}
|
|
@@ -376,23 +458,28 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
376
458
|
/**
|
|
377
459
|
* 生成文字纹理(生成文字纹理字典)
|
|
378
460
|
*/
|
|
461
|
+
|
|
379
462
|
}, {
|
|
380
463
|
key: "initTextFont",
|
|
381
464
|
value: function initTextFont() {
|
|
382
465
|
var _this$getTextStyle = this.getTextStyle(),
|
|
383
|
-
|
|
384
|
-
|
|
466
|
+
fontWeight = _this$getTextStyle.fontWeight,
|
|
467
|
+
fontFamily = _this$getTextStyle.fontFamily;
|
|
468
|
+
|
|
385
469
|
var data = this.rawEncodeData;
|
|
386
470
|
var characterSet = [];
|
|
387
471
|
data.forEach(function (item) {
|
|
388
472
|
var _item$shape = item.shape,
|
|
389
|
-
|
|
473
|
+
shape = _item$shape === void 0 ? '' : _item$shape;
|
|
390
474
|
shape = shape.toString();
|
|
475
|
+
|
|
391
476
|
var _iterator = _createForOfIteratorHelper(shape),
|
|
392
|
-
|
|
477
|
+
_step;
|
|
478
|
+
|
|
393
479
|
try {
|
|
394
480
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
395
481
|
var char = _step.value;
|
|
482
|
+
|
|
396
483
|
// 去重
|
|
397
484
|
if (characterSet.indexOf(char) === -1) {
|
|
398
485
|
characterSet.push(char);
|
|
@@ -411,22 +498,24 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
411
498
|
iconfont: false
|
|
412
499
|
});
|
|
413
500
|
}
|
|
414
|
-
|
|
415
501
|
/**
|
|
416
502
|
* 生成 iconfont 纹理字典
|
|
417
503
|
*/
|
|
504
|
+
|
|
418
505
|
}, {
|
|
419
506
|
key: "initIconFontTex",
|
|
420
507
|
value: function initIconFontTex() {
|
|
421
508
|
var _this$getTextStyle2 = this.getTextStyle(),
|
|
422
|
-
|
|
423
|
-
|
|
509
|
+
fontWeight = _this$getTextStyle2.fontWeight,
|
|
510
|
+
fontFamily = _this$getTextStyle2.fontFamily;
|
|
511
|
+
|
|
424
512
|
var data = this.rawEncodeData;
|
|
425
513
|
var characterSet = [];
|
|
426
514
|
data.forEach(function (item) {
|
|
427
515
|
var _item$shape2 = item.shape,
|
|
428
|
-
|
|
516
|
+
shape = _item$shape2 === void 0 ? '' : _item$shape2;
|
|
429
517
|
shape = "".concat(shape);
|
|
518
|
+
|
|
430
519
|
if (characterSet.indexOf(shape) === -1) {
|
|
431
520
|
characterSet.push(shape);
|
|
432
521
|
}
|
|
@@ -442,26 +531,27 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
442
531
|
key: "getTextStyle",
|
|
443
532
|
value: function getTextStyle() {
|
|
444
533
|
var _ref5 = this.layer.getLayerConfig(),
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
534
|
+
_ref5$fontWeight = _ref5.fontWeight,
|
|
535
|
+
fontWeight = _ref5$fontWeight === void 0 ? '400' : _ref5$fontWeight,
|
|
536
|
+
_ref5$fontFamily = _ref5.fontFamily,
|
|
537
|
+
fontFamily = _ref5$fontFamily === void 0 ? 'sans-serif' : _ref5$fontFamily,
|
|
538
|
+
_ref5$textAllowOverla = _ref5.textAllowOverlap,
|
|
539
|
+
textAllowOverlap = _ref5$textAllowOverla === void 0 ? false : _ref5$textAllowOverla,
|
|
540
|
+
_ref5$padding = _ref5.padding,
|
|
541
|
+
padding = _ref5$padding === void 0 ? [0, 0] : _ref5$padding,
|
|
542
|
+
_ref5$textAnchor = _ref5.textAnchor,
|
|
543
|
+
textAnchor = _ref5$textAnchor === void 0 ? 'center' : _ref5$textAnchor,
|
|
544
|
+
_ref5$textOffset = _ref5.textOffset,
|
|
545
|
+
textOffset = _ref5$textOffset === void 0 ? [0, 0] : _ref5$textOffset,
|
|
546
|
+
_ref5$opacity = _ref5.opacity,
|
|
547
|
+
opacity = _ref5$opacity === void 0 ? 1 : _ref5$opacity,
|
|
548
|
+
_ref5$strokeOpacity = _ref5.strokeOpacity,
|
|
549
|
+
strokeOpacity = _ref5$strokeOpacity === void 0 ? 1 : _ref5$strokeOpacity,
|
|
550
|
+
_ref5$strokeWidth = _ref5.strokeWidth,
|
|
551
|
+
strokeWidth = _ref5$strokeWidth === void 0 ? 0 : _ref5$strokeWidth,
|
|
552
|
+
_ref5$stroke = _ref5.stroke,
|
|
553
|
+
stroke = _ref5$stroke === void 0 ? '#000' : _ref5$stroke;
|
|
554
|
+
|
|
465
555
|
return {
|
|
466
556
|
fontWeight: fontWeight,
|
|
467
557
|
fontFamily: fontFamily,
|
|
@@ -475,39 +565,39 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
475
565
|
stroke: stroke
|
|
476
566
|
};
|
|
477
567
|
}
|
|
478
|
-
|
|
479
568
|
/**
|
|
480
569
|
* 生成文字布局(对照文字纹理字典提取对应文字的位置很好信息)
|
|
481
570
|
*/
|
|
571
|
+
|
|
482
572
|
}, {
|
|
483
573
|
key: "generateGlyphLayout",
|
|
484
574
|
value: function generateGlyphLayout(iconfont) {
|
|
485
575
|
var _this2 = this;
|
|
576
|
+
|
|
486
577
|
var mapping = this.getFontServiceMapping();
|
|
578
|
+
|
|
487
579
|
var _ref6 = this.layer.getLayerConfig(),
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
580
|
+
_ref6$spacing = _ref6.spacing,
|
|
581
|
+
spacing = _ref6$spacing === void 0 ? 2 : _ref6$spacing,
|
|
582
|
+
_ref6$textAnchor = _ref6.textAnchor,
|
|
583
|
+
textAnchor = _ref6$textAnchor === void 0 ? 'center' : _ref6$textAnchor,
|
|
584
|
+
textOffset = _ref6.textOffset;
|
|
585
|
+
|
|
493
586
|
var data = this.rawEncodeData;
|
|
494
587
|
this.glyphInfo = data.map(function (feature) {
|
|
495
588
|
var _feature$shape = feature.shape,
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
var shaping = (0, _symbolLayout.shapeText)(shape.toString(), mapping,
|
|
501
|
-
// @ts-ignore
|
|
589
|
+
shape = _feature$shape === void 0 ? '' : _feature$shape,
|
|
590
|
+
id = feature.id,
|
|
591
|
+
_feature$size2 = feature.size,
|
|
592
|
+
size = _feature$size2 === void 0 ? 1 : _feature$size2;
|
|
593
|
+
var shaping = (0, _symbolLayout.shapeText)(shape.toString(), mapping, // @ts-ignore
|
|
502
594
|
size, textAnchor, 'left', spacing, textOffset || feature.textOffset || [0, 0], iconfont);
|
|
503
595
|
var glyphQuads = (0, _symbolLayout.getGlyphQuads)(shaping, textOffset, false);
|
|
504
596
|
feature.shaping = shaping;
|
|
505
|
-
feature.glyphQuads = glyphQuads;
|
|
506
|
-
// feature.centroid = calculteCentroid(coordinates);
|
|
597
|
+
feature.glyphQuads = glyphQuads; // feature.centroid = calculteCentroid(coordinates);
|
|
507
598
|
|
|
508
|
-
feature.centroid = (0, _l7Utils.calculateCentroid)(feature.coordinates);
|
|
599
|
+
feature.centroid = (0, _l7Utils.calculateCentroid)(feature.coordinates); // 此时地图高德2.0 originCentroid == centroid
|
|
509
600
|
|
|
510
|
-
// 此时地图高德2.0 originCentroid == centroid
|
|
511
601
|
feature.originCentroid = feature.version === 'GAODE2.x' ? (0, _l7Utils.calculateCentroid)(feature.originCoordinates) : feature.originCentroid = feature.centroid;
|
|
512
602
|
_this2.glyphInfoMap[id] = {
|
|
513
603
|
shaping: shaping,
|
|
@@ -521,66 +611,76 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
521
611
|
key: "getFontServiceMapping",
|
|
522
612
|
value: function getFontServiceMapping() {
|
|
523
613
|
var _ref7 = this.layer.getLayerConfig(),
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
614
|
+
_ref7$fontWeight = _ref7.fontWeight,
|
|
615
|
+
fontWeight = _ref7$fontWeight === void 0 ? '400' : _ref7$fontWeight,
|
|
616
|
+
_ref7$fontFamily = _ref7.fontFamily,
|
|
617
|
+
fontFamily = _ref7$fontFamily === void 0 ? 'sans-serif' : _ref7$fontFamily;
|
|
618
|
+
|
|
528
619
|
return this.fontService.getMappingByKey("".concat(fontFamily, "_").concat(fontWeight));
|
|
529
620
|
}
|
|
530
621
|
}, {
|
|
531
622
|
key: "getFontServiceCanvas",
|
|
532
623
|
value: function getFontServiceCanvas() {
|
|
533
624
|
var _ref8 = this.layer.getLayerConfig(),
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
625
|
+
_ref8$fontWeight = _ref8.fontWeight,
|
|
626
|
+
fontWeight = _ref8$fontWeight === void 0 ? '400' : _ref8$fontWeight,
|
|
627
|
+
_ref8$fontFamily = _ref8.fontFamily,
|
|
628
|
+
fontFamily = _ref8$fontFamily === void 0 ? 'sans-serif' : _ref8$fontFamily; // 更新文字布局
|
|
629
|
+
|
|
630
|
+
|
|
539
631
|
return this.fontService.getCanvasByKey("".concat(fontFamily, "_").concat(fontWeight));
|
|
540
632
|
}
|
|
541
|
-
|
|
542
633
|
/**
|
|
543
634
|
* 文字避让 depend on originCentorid
|
|
544
635
|
*/
|
|
636
|
+
|
|
545
637
|
}, {
|
|
546
638
|
key: "filterGlyphs",
|
|
547
639
|
value: function filterGlyphs() {
|
|
548
640
|
var _this3 = this;
|
|
641
|
+
|
|
549
642
|
var _ref9 = this.layer.getLayerConfig(),
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
643
|
+
_ref9$padding = _ref9.padding,
|
|
644
|
+
padding = _ref9$padding === void 0 ? [0, 0] : _ref9$padding,
|
|
645
|
+
_ref9$textAllowOverla = _ref9.textAllowOverlap,
|
|
646
|
+
textAllowOverlap = _ref9$textAllowOverla === void 0 ? false : _ref9$textAllowOverla;
|
|
647
|
+
|
|
554
648
|
if (textAllowOverlap) {
|
|
555
649
|
// 如果允许文本覆盖
|
|
556
650
|
return;
|
|
557
651
|
}
|
|
652
|
+
|
|
558
653
|
this.glyphInfoMap = {};
|
|
559
654
|
this.currentZoom = this.mapService.getZoom();
|
|
560
655
|
this.extent = this.textExtent();
|
|
656
|
+
|
|
561
657
|
var _this$rendererService = this.rendererService.getViewportSize(),
|
|
562
|
-
|
|
563
|
-
|
|
658
|
+
width = _this$rendererService.width,
|
|
659
|
+
height = _this$rendererService.height;
|
|
660
|
+
|
|
564
661
|
var collisionIndex = new _collisionIndex.default(width, height);
|
|
565
662
|
var filterData = this.glyphInfo.filter(function (feature) {
|
|
566
663
|
var shaping = feature.shaping,
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
// const centroid = feature.centroid as [number, number];
|
|
664
|
+
_feature$id = feature.id,
|
|
665
|
+
id = _feature$id === void 0 ? 0 : _feature$id; // const centroid = feature.centroid as [number, number];
|
|
570
666
|
// const centroid = feature.originCentroid as [number, number];
|
|
667
|
+
|
|
571
668
|
var centroid = feature.version === 'GAODE2.x' ? feature.originCentroid : feature.centroid;
|
|
572
669
|
var size = feature.size;
|
|
573
670
|
var fontScale = size / 16;
|
|
671
|
+
|
|
574
672
|
var pixels = _this3.mapService.lngLatToContainer(centroid);
|
|
673
|
+
|
|
575
674
|
var _collisionIndex$place = collisionIndex.placeCollisionBox({
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
675
|
+
x1: shaping.left * fontScale - padding[0],
|
|
676
|
+
x2: shaping.right * fontScale + padding[0],
|
|
677
|
+
y1: shaping.top * fontScale - padding[1],
|
|
678
|
+
y2: shaping.bottom * fontScale + padding[1],
|
|
679
|
+
anchorPointX: pixels.x,
|
|
680
|
+
anchorPointY: pixels.y
|
|
681
|
+
}),
|
|
682
|
+
box = _collisionIndex$place.box;
|
|
683
|
+
|
|
584
684
|
if (box && box.length) {
|
|
585
685
|
collisionIndex.insertCollisionBox(box, id);
|
|
586
686
|
return true;
|
|
@@ -591,35 +691,39 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
591
691
|
filterData.forEach(function (item) {
|
|
592
692
|
// @ts-ignore
|
|
593
693
|
_this3.glyphInfoMap[item.id] = item;
|
|
594
|
-
});
|
|
595
|
-
// this.layer.setEncodedData(filterData);
|
|
694
|
+
}); // this.layer.setEncodedData(filterData);
|
|
596
695
|
}
|
|
597
696
|
/**
|
|
598
697
|
* 初始化文字布局
|
|
599
698
|
*/
|
|
699
|
+
|
|
600
700
|
}, {
|
|
601
701
|
key: "initGlyph",
|
|
602
702
|
value: function initGlyph() {
|
|
603
703
|
var _this$layer$getLayerC = this.layer.getLayerConfig(),
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
// 2.生成文字布局
|
|
704
|
+
_this$layer$getLayerC2 = _this$layer$getLayerC.iconfont,
|
|
705
|
+
iconfont = _this$layer$getLayerC2 === void 0 ? false : _this$layer$getLayerC2; // 1.生成文字纹理(或是生成 iconfont)
|
|
706
|
+
|
|
707
|
+
|
|
708
|
+
iconfont ? this.initIconFontTex() : this.initTextFont(); // 2.生成文字布局
|
|
709
|
+
|
|
609
710
|
this.generateGlyphLayout(iconfont);
|
|
610
711
|
}
|
|
611
712
|
/**
|
|
612
713
|
* 更新文字纹理
|
|
613
714
|
*/
|
|
715
|
+
|
|
614
716
|
}, {
|
|
615
717
|
key: "updateTexture",
|
|
616
718
|
value: function updateTexture() {
|
|
617
719
|
var createTexture2D = this.rendererService.createTexture2D;
|
|
618
720
|
var canvas = this.getFontServiceCanvas();
|
|
619
721
|
this.textureHeight = canvas.height;
|
|
722
|
+
|
|
620
723
|
if (this.texture) {
|
|
621
724
|
this.texture.destroy();
|
|
622
725
|
}
|
|
726
|
+
|
|
623
727
|
this.texture = createTexture2D({
|
|
624
728
|
data: canvas,
|
|
625
729
|
mag: _l7Core.gl.LINEAR,
|
|
@@ -634,35 +738,42 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
634
738
|
var _reBuildModel = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
|
|
635
739
|
var model;
|
|
636
740
|
return _regenerator.default.wrap(function _callee5$(_context5) {
|
|
637
|
-
while (1)
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
741
|
+
while (1) {
|
|
742
|
+
switch (_context5.prev = _context5.next) {
|
|
743
|
+
case 0:
|
|
744
|
+
this.filterGlyphs();
|
|
745
|
+
_context5.next = 3;
|
|
746
|
+
return this.layer.buildLayerModel({
|
|
747
|
+
moduleName: 'pointText',
|
|
748
|
+
vertexShader: textVert,
|
|
749
|
+
fragmentShader: textFrag,
|
|
750
|
+
triangulation: TextTrianglation.bind(this),
|
|
751
|
+
depth: {
|
|
752
|
+
enable: false
|
|
753
|
+
}
|
|
754
|
+
});
|
|
755
|
+
|
|
756
|
+
case 3:
|
|
757
|
+
model = _context5.sent;
|
|
758
|
+
// TODO 渲染流程待修改
|
|
759
|
+
this.layer.models = [model];
|
|
760
|
+
|
|
761
|
+
case 5:
|
|
762
|
+
case "end":
|
|
763
|
+
return _context5.stop();
|
|
764
|
+
}
|
|
657
765
|
}
|
|
658
766
|
}, _callee5, this);
|
|
659
767
|
}));
|
|
768
|
+
|
|
660
769
|
function reBuildModel() {
|
|
661
770
|
return _reBuildModel.apply(this, arguments);
|
|
662
771
|
}
|
|
772
|
+
|
|
663
773
|
return reBuildModel;
|
|
664
774
|
}()
|
|
665
775
|
}]);
|
|
666
776
|
return TextModel;
|
|
667
777
|
}(_BaseModel2.default);
|
|
778
|
+
|
|
668
779
|
exports.default = TextModel;
|