@antv/l7-layers 2.15.5 → 2.16.0
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/core/BaseLayer.js
CHANGED
|
@@ -597,7 +597,7 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
|
|
|
597
597
|
key: "renderLayers",
|
|
598
598
|
value: function renderLayers() {
|
|
599
599
|
this.rendering = true;
|
|
600
|
-
this.layerService.
|
|
600
|
+
this.layerService.reRender();
|
|
601
601
|
this.rendering = false;
|
|
602
602
|
}
|
|
603
603
|
}, {
|
|
@@ -1172,6 +1172,7 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
|
|
|
1172
1172
|
return reject(err);
|
|
1173
1173
|
});
|
|
1174
1174
|
} else {
|
|
1175
|
+
// console.log(this.encodedData)
|
|
1175
1176
|
var _this9$styleAttribute = _this9.styleAttributeService.createAttributesAndIndices(_this9.encodedData, triangulation, segmentNumber),
|
|
1176
1177
|
attributes = _this9$styleAttribute.attributes,
|
|
1177
1178
|
elements = _this9$styleAttribute.elements,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IEncodeFeature, IModel, IModelUniform } from '@antv/l7-core';
|
|
2
2
|
import BaseModel from '../../core/BaseModel';
|
|
3
3
|
import { IGlyphQuad } from '../../utils/symbol-layout';
|
|
4
|
-
export declare function
|
|
4
|
+
export declare function TextTrianglation(feature: IEncodeFeature): {
|
|
5
5
|
vertices: number[];
|
|
6
6
|
indices: number[];
|
|
7
7
|
size: number;
|
|
@@ -15,6 +15,7 @@ export default class TextModel extends BaseModel {
|
|
|
15
15
|
centroid: number[];
|
|
16
16
|
};
|
|
17
17
|
};
|
|
18
|
+
private rawEncodeData;
|
|
18
19
|
private texture;
|
|
19
20
|
private currentZoom;
|
|
20
21
|
private extent;
|
package/es/point/models/text.js
CHANGED
|
@@ -23,7 +23,7 @@ import { getGlyphQuads, shapeText } from "../../utils/symbol-layout";
|
|
|
23
23
|
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";
|
|
24
24
|
/* babel-plugin-inline-import '../shaders/text_vert.glsl' */
|
|
25
25
|
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";
|
|
26
|
-
export function
|
|
26
|
+
export function TextTrianglation(feature) {
|
|
27
27
|
// @ts-ignore
|
|
28
28
|
var that = this;
|
|
29
29
|
var id = feature.id;
|
|
@@ -160,9 +160,10 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
160
160
|
// 绑定事件
|
|
161
161
|
this.bindEvent();
|
|
162
162
|
this.extent = this.textExtent();
|
|
163
|
+
this.rawEncodeData = this.layer.getEncodedData();
|
|
163
164
|
this.preTextStyle = this.getTextStyle();
|
|
164
165
|
return _context2.abrupt("return", this.buildModels());
|
|
165
|
-
case
|
|
166
|
+
case 5:
|
|
166
167
|
case "end":
|
|
167
168
|
return _context2.stop();
|
|
168
169
|
}
|
|
@@ -192,7 +193,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
192
193
|
moduleName: 'pointText',
|
|
193
194
|
vertexShader: textVert,
|
|
194
195
|
fragmentShader: textFrag,
|
|
195
|
-
triangulation:
|
|
196
|
+
triangulation: TextTrianglation.bind(this),
|
|
196
197
|
depth: {
|
|
197
198
|
enable: false
|
|
198
199
|
}
|
|
@@ -373,7 +374,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
373
374
|
var _this$getTextStyle = this.getTextStyle(),
|
|
374
375
|
fontWeight = _this$getTextStyle.fontWeight,
|
|
375
376
|
fontFamily = _this$getTextStyle.fontFamily;
|
|
376
|
-
var data = this.
|
|
377
|
+
var data = this.rawEncodeData;
|
|
377
378
|
var characterSet = [];
|
|
378
379
|
data.forEach(function (item) {
|
|
379
380
|
var _item$shape = item.shape,
|
|
@@ -412,7 +413,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
412
413
|
var _this$getTextStyle2 = this.getTextStyle(),
|
|
413
414
|
fontWeight = _this$getTextStyle2.fontWeight,
|
|
414
415
|
fontFamily = _this$getTextStyle2.fontFamily;
|
|
415
|
-
var data = this.
|
|
416
|
+
var data = this.rawEncodeData;
|
|
416
417
|
var characterSet = [];
|
|
417
418
|
data.forEach(function (item) {
|
|
418
419
|
var _item$shape2 = item.shape,
|
|
@@ -481,7 +482,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
481
482
|
_ref6$textAnchor = _ref6.textAnchor,
|
|
482
483
|
textAnchor = _ref6$textAnchor === void 0 ? 'center' : _ref6$textAnchor,
|
|
483
484
|
textOffset = _ref6.textOffset;
|
|
484
|
-
var data = this.
|
|
485
|
+
var data = this.rawEncodeData;
|
|
485
486
|
this.glyphInfo = data.map(function (feature) {
|
|
486
487
|
var _feature$shape = feature.shape,
|
|
487
488
|
shape = _feature$shape === void 0 ? '' : _feature$shape,
|
|
@@ -633,7 +634,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
633
634
|
moduleName: 'pointText',
|
|
634
635
|
vertexShader: textVert,
|
|
635
636
|
fragmentShader: textFrag,
|
|
636
|
-
triangulation:
|
|
637
|
+
triangulation: TextTrianglation.bind(this),
|
|
637
638
|
depth: {
|
|
638
639
|
enable: false
|
|
639
640
|
}
|
package/lib/core/BaseLayer.js
CHANGED
|
@@ -603,7 +603,7 @@ var BaseLayer = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.IGlobalConfigServi
|
|
|
603
603
|
key: "renderLayers",
|
|
604
604
|
value: function renderLayers() {
|
|
605
605
|
this.rendering = true;
|
|
606
|
-
this.layerService.
|
|
606
|
+
this.layerService.reRender();
|
|
607
607
|
this.rendering = false;
|
|
608
608
|
}
|
|
609
609
|
}, {
|
|
@@ -1178,6 +1178,7 @@ var BaseLayer = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.IGlobalConfigServi
|
|
|
1178
1178
|
return reject(err);
|
|
1179
1179
|
});
|
|
1180
1180
|
} else {
|
|
1181
|
+
// console.log(this.encodedData)
|
|
1181
1182
|
var _this9$styleAttribute = _this9.styleAttributeService.createAttributesAndIndices(_this9.encodedData, triangulation, segmentNumber),
|
|
1182
1183
|
attributes = _this9$styleAttribute.attributes,
|
|
1183
1184
|
elements = _this9$styleAttribute.elements,
|
package/lib/point/models/text.js
CHANGED
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.
|
|
7
|
+
exports.TextTrianglation = TextTrianglation;
|
|
8
8
|
exports.default = void 0;
|
|
9
9
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
10
10
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
@@ -31,7 +31,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
31
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";
|
|
32
32
|
/* babel-plugin-inline-import '../shaders/text_vert.glsl' */
|
|
33
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";
|
|
34
|
-
function
|
|
34
|
+
function TextTrianglation(feature) {
|
|
35
35
|
// @ts-ignore
|
|
36
36
|
var that = this;
|
|
37
37
|
var id = feature.id;
|
|
@@ -168,9 +168,10 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
168
168
|
// 绑定事件
|
|
169
169
|
this.bindEvent();
|
|
170
170
|
this.extent = this.textExtent();
|
|
171
|
+
this.rawEncodeData = this.layer.getEncodedData();
|
|
171
172
|
this.preTextStyle = this.getTextStyle();
|
|
172
173
|
return _context2.abrupt("return", this.buildModels());
|
|
173
|
-
case
|
|
174
|
+
case 5:
|
|
174
175
|
case "end":
|
|
175
176
|
return _context2.stop();
|
|
176
177
|
}
|
|
@@ -200,7 +201,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
200
201
|
moduleName: 'pointText',
|
|
201
202
|
vertexShader: textVert,
|
|
202
203
|
fragmentShader: textFrag,
|
|
203
|
-
triangulation:
|
|
204
|
+
triangulation: TextTrianglation.bind(this),
|
|
204
205
|
depth: {
|
|
205
206
|
enable: false
|
|
206
207
|
}
|
|
@@ -381,7 +382,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
381
382
|
var _this$getTextStyle = this.getTextStyle(),
|
|
382
383
|
fontWeight = _this$getTextStyle.fontWeight,
|
|
383
384
|
fontFamily = _this$getTextStyle.fontFamily;
|
|
384
|
-
var data = this.
|
|
385
|
+
var data = this.rawEncodeData;
|
|
385
386
|
var characterSet = [];
|
|
386
387
|
data.forEach(function (item) {
|
|
387
388
|
var _item$shape = item.shape,
|
|
@@ -420,7 +421,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
420
421
|
var _this$getTextStyle2 = this.getTextStyle(),
|
|
421
422
|
fontWeight = _this$getTextStyle2.fontWeight,
|
|
422
423
|
fontFamily = _this$getTextStyle2.fontFamily;
|
|
423
|
-
var data = this.
|
|
424
|
+
var data = this.rawEncodeData;
|
|
424
425
|
var characterSet = [];
|
|
425
426
|
data.forEach(function (item) {
|
|
426
427
|
var _item$shape2 = item.shape,
|
|
@@ -489,7 +490,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
489
490
|
_ref6$textAnchor = _ref6.textAnchor,
|
|
490
491
|
textAnchor = _ref6$textAnchor === void 0 ? 'center' : _ref6$textAnchor,
|
|
491
492
|
textOffset = _ref6.textOffset;
|
|
492
|
-
var data = this.
|
|
493
|
+
var data = this.rawEncodeData;
|
|
493
494
|
this.glyphInfo = data.map(function (feature) {
|
|
494
495
|
var _feature$shape = feature.shape,
|
|
495
496
|
shape = _feature$shape === void 0 ? '' : _feature$shape,
|
|
@@ -641,7 +642,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
641
642
|
moduleName: 'pointText',
|
|
642
643
|
vertexShader: textVert,
|
|
643
644
|
fragmentShader: textFrag,
|
|
644
|
-
triangulation:
|
|
645
|
+
triangulation: TextTrianglation.bind(this),
|
|
645
646
|
depth: {
|
|
646
647
|
enable: false
|
|
647
648
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/l7-layers",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.16.0",
|
|
4
4
|
"description": "L7's collection of built-in layers",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
"license": "ISC",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@antv/async-hook": "^2.2.9",
|
|
30
|
-
"@antv/l7-core": "2.
|
|
31
|
-
"@antv/l7-maps": "2.
|
|
32
|
-
"@antv/l7-source": "2.
|
|
33
|
-
"@antv/l7-utils": "2.
|
|
30
|
+
"@antv/l7-core": "2.16.0",
|
|
31
|
+
"@antv/l7-maps": "2.16.0",
|
|
32
|
+
"@antv/l7-source": "2.16.0",
|
|
33
|
+
"@antv/l7-utils": "2.16.0",
|
|
34
34
|
"@babel/runtime": "^7.7.7",
|
|
35
35
|
"@mapbox/martini": "^0.2.0",
|
|
36
36
|
"@turf/clone": "^6.5.0",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"reflect-metadata": "^0.1.13"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@antv/l7-test-utils": "2.
|
|
56
|
+
"@antv/l7-test-utils": "2.16.0",
|
|
57
57
|
"@types/d3-array": "^2.0.0",
|
|
58
58
|
"@types/d3-color": "^1.2.2",
|
|
59
59
|
"@types/d3-interpolate": "1.1.6",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"@types/gl-matrix": "^2.4.5",
|
|
63
63
|
"@types/lodash": "^4.14.138"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "901d07c0523b128fbc69ca04e6b3b8367ea3572d",
|
|
66
66
|
"publishConfig": {
|
|
67
67
|
"access": "public"
|
|
68
68
|
}
|