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