@antv/l7-layers 2.16.0 → 2.16.2
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.d.ts +3 -0
- package/es/core/BaseLayer.js +76 -80
- package/es/core/BaseModel.d.ts +9 -71
- package/es/core/BaseModel.js +75 -357
- package/es/core/CommonStyleAttribute.d.ts +2 -0
- package/es/core/CommonStyleAttribute.js +66 -0
- package/es/core/interface.d.ts +13 -3
- package/es/core/shape/extrude.js +18 -6
- package/es/core/triangulation.d.ts +12 -0
- package/es/core/triangulation.js +70 -0
- package/es/heatmap/models/grid.js +1 -1
- package/es/heatmap/models/grid3d.js +1 -1
- package/es/heatmap/models/heatmap.d.ts +1 -0
- package/es/heatmap/models/heatmap.js +17 -13
- package/es/heatmap/models/hexagon.js +1 -1
- package/es/heatmap/shaders/grid_vert.glsl +2 -2
- package/es/heatmap/shaders/hexagon_3d_vert.glsl +2 -2
- package/es/heatmap/shaders/hexagon_vert.glsl +2 -2
- package/es/line/index.d.ts +1 -0
- package/es/line/index.js +3 -2
- package/es/line/models/arc.js +9 -45
- package/es/line/models/arc_3d.js +12 -45
- package/es/line/models/earthArc_3d.js +6 -40
- package/es/line/models/{half.d.ts → flow.d.ts} +1 -11
- package/es/line/models/flow.js +167 -0
- package/es/line/models/great_circle.js +4 -38
- package/es/line/models/index.d.ts +1 -1
- package/es/line/models/index.js +3 -3
- package/es/line/models/line.js +7 -41
- package/es/line/models/linearline.js +4 -38
- package/es/line/models/simpleLine.d.ts +0 -1
- package/es/line/models/simpleLine.js +4 -43
- package/es/line/shaders/dash/arc_dash_frag.glsl +3 -6
- package/es/line/shaders/dash/arc_dash_vert.glsl +6 -46
- package/es/line/shaders/dash/line_dash_frag.glsl +4 -7
- package/es/line/shaders/dash/line_dash_vert.glsl +3 -33
- package/es/line/shaders/flow/flow_line_frag.glsl +13 -0
- package/es/line/shaders/flow/flow_line_vert.glsl +83 -0
- package/es/line/shaders/line_arc_3d_frag.glsl +6 -6
- package/es/line/shaders/line_arc_3d_vert.glsl +4 -34
- package/es/line/shaders/line_arc_frag.glsl +7 -11
- package/es/line/shaders/line_arc_great_circle_frag.glsl +5 -6
- package/es/line/shaders/line_arc_great_circle_vert.glsl +4 -32
- package/es/line/shaders/line_arc_vert.glsl +9 -45
- package/es/line/shaders/line_frag.glsl +15 -17
- package/es/line/shaders/line_vert.glsl +3 -34
- package/es/line/shaders/linear/arc3d_linear_frag.glsl +5 -19
- package/es/line/shaders/linear/arc3d_linear_vert.glsl +9 -48
- package/es/line/shaders/linear/arc_linear_frag.glsl +2 -30
- package/es/line/shaders/linear/arc_linear_vert.glsl +9 -45
- package/es/line/shaders/linear/line_linear_frag.glsl +5 -6
- package/es/line/shaders/linearLine/line_linear_frag.glsl +2 -14
- package/es/line/shaders/linearLine/line_linear_vert.glsl +14 -32
- package/es/line/shaders/simple/simpleline_frag.glsl +1 -5
- package/es/line/shaders/simple/simpleline_linear_frag.glsl +2 -6
- package/es/line/shaders/simple/simpleline_vert.glsl +7 -33
- package/es/plugins/DataMappingPlugin.js +20 -34
- package/es/plugins/LayerModelPlugin.js +13 -1
- package/es/plugins/ShaderUniformPlugin.js +3 -3
- package/es/point/index.d.ts +1 -0
- package/es/point/index.js +1 -0
- package/es/point/models/earthExtrude.d.ts +0 -3
- package/es/point/models/earthExtrude.js +2 -40
- package/es/point/models/earthFill.d.ts +0 -1
- package/es/point/models/earthFill.js +9 -60
- package/es/point/models/extrude.d.ts +0 -3
- package/es/point/models/extrude.js +3 -42
- package/es/point/models/fill.d.ts +0 -1
- package/es/point/models/fill.js +15 -76
- package/es/point/models/fillmage.js +6 -43
- package/es/point/models/image.js +7 -41
- package/es/point/models/normal.js +2 -2
- package/es/point/models/radar.d.ts +0 -1
- package/es/point/models/radar.js +4 -13
- package/es/point/models/simplePoint.d.ts +0 -1
- package/es/point/models/simplePoint.js +8 -49
- package/es/point/models/text.js +17 -47
- package/es/point/shaders/animate/wave_frag.glsl +1 -11
- package/es/point/shaders/earth/extrude_frag.glsl +5 -17
- package/es/point/shaders/earth/extrude_vert.glsl +14 -29
- package/es/point/shaders/earth/fill_frag.glsl +5 -14
- package/es/point/shaders/earth/fill_vert.glsl +1 -75
- package/es/point/shaders/extrude/extrude_frag.glsl +3 -29
- package/es/point/shaders/extrude/extrude_vert.glsl +27 -35
- package/es/point/shaders/fill_frag.glsl +9 -20
- package/es/point/shaders/fill_vert.glsl +16 -101
- package/es/point/shaders/image/fillImage_frag.glsl +2 -5
- package/es/point/shaders/image/fillImage_vert.glsl +4 -47
- package/es/point/shaders/image_frag.glsl +1 -5
- package/es/point/shaders/image_vert.glsl +1 -44
- package/es/point/shaders/normal_frag.glsl +0 -2
- package/es/point/shaders/normal_vert.glsl +2 -1
- package/es/point/shaders/radar/radar_vert.glsl +2 -2
- package/es/point/shaders/simplePoint_frag.glsl +0 -7
- package/es/point/shaders/simplePoint_vert.glsl +3 -45
- package/es/point/shaders/text_frag.glsl +6 -19
- package/es/point/shaders/text_vert.glsl +5 -66
- package/es/polygon/index.d.ts +1 -0
- package/es/polygon/index.js +1 -0
- package/es/polygon/models/extrude.d.ts +0 -3
- package/es/polygon/models/extrude.js +86 -82
- package/es/polygon/models/fill.d.ts +0 -4
- package/es/polygon/models/fill.js +8 -47
- package/es/polygon/shaders/extrude/polygon_extrude_frag.glsl +2 -23
- package/es/polygon/shaders/extrude/polygon_extrude_picklight_frag.glsl +7 -5
- package/es/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +7 -32
- package/es/polygon/shaders/extrude/polygon_extrude_vert.glsl +33 -38
- package/es/polygon/shaders/extrude/polygon_extrudetex_frag.glsl +12 -9
- package/es/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +16 -44
- package/es/polygon/shaders/polygon_frag.glsl +0 -5
- package/es/polygon/shaders/polygon_linear_frag.glsl +0 -8
- package/es/polygon/shaders/polygon_linear_vert.glsl +0 -32
- package/es/polygon/shaders/polygon_vert.glsl +1 -27
- package/es/utils/layerData.js +2 -2
- package/lib/core/BaseLayer.js +74 -78
- package/lib/core/BaseModel.js +74 -356
- package/lib/core/CommonStyleAttribute.js +72 -0
- package/lib/core/shape/extrude.js +18 -6
- package/lib/core/triangulation.js +72 -0
- package/lib/heatmap/models/grid.js +1 -1
- package/lib/heatmap/models/grid3d.js +1 -1
- package/lib/heatmap/models/heatmap.js +17 -13
- package/lib/heatmap/models/hexagon.js +1 -1
- package/lib/heatmap/shaders/grid_vert.glsl +2 -2
- package/lib/heatmap/shaders/hexagon_3d_vert.glsl +2 -2
- package/lib/heatmap/shaders/hexagon_vert.glsl +2 -2
- package/lib/line/index.js +3 -2
- package/lib/line/models/arc.js +9 -45
- package/lib/line/models/arc_3d.js +12 -45
- package/lib/line/models/earthArc_3d.js +6 -40
- package/lib/line/models/flow.js +174 -0
- package/lib/line/models/great_circle.js +4 -38
- package/lib/line/models/index.js +3 -3
- package/lib/line/models/line.js +7 -41
- package/lib/line/models/linearline.js +4 -38
- package/lib/line/models/simpleLine.js +4 -43
- package/lib/line/shaders/dash/arc_dash_frag.glsl +3 -6
- package/lib/line/shaders/dash/arc_dash_vert.glsl +6 -46
- package/lib/line/shaders/dash/line_dash_frag.glsl +4 -7
- package/lib/line/shaders/dash/line_dash_vert.glsl +3 -33
- package/lib/line/shaders/flow/flow_line_frag.glsl +13 -0
- package/lib/line/shaders/flow/flow_line_vert.glsl +83 -0
- package/lib/line/shaders/line_arc_3d_frag.glsl +6 -6
- package/lib/line/shaders/line_arc_3d_vert.glsl +4 -34
- package/lib/line/shaders/line_arc_frag.glsl +7 -11
- package/lib/line/shaders/line_arc_great_circle_frag.glsl +5 -6
- package/lib/line/shaders/line_arc_great_circle_vert.glsl +4 -32
- package/lib/line/shaders/line_arc_vert.glsl +9 -45
- package/lib/line/shaders/line_frag.glsl +15 -17
- package/lib/line/shaders/line_vert.glsl +3 -34
- package/lib/line/shaders/linear/arc3d_linear_frag.glsl +5 -19
- package/lib/line/shaders/linear/arc3d_linear_vert.glsl +9 -48
- package/lib/line/shaders/linear/arc_linear_frag.glsl +2 -30
- package/lib/line/shaders/linear/arc_linear_vert.glsl +9 -45
- package/lib/line/shaders/linear/line_linear_frag.glsl +5 -6
- package/lib/line/shaders/linearLine/line_linear_frag.glsl +2 -14
- package/lib/line/shaders/linearLine/line_linear_vert.glsl +14 -32
- package/lib/line/shaders/simple/simpleline_frag.glsl +1 -5
- package/lib/line/shaders/simple/simpleline_linear_frag.glsl +2 -6
- package/lib/line/shaders/simple/simpleline_vert.glsl +7 -33
- package/lib/plugins/DataMappingPlugin.js +20 -34
- package/lib/plugins/LayerModelPlugin.js +13 -1
- package/lib/plugins/ShaderUniformPlugin.js +3 -3
- package/lib/point/index.js +1 -0
- package/lib/point/models/earthExtrude.js +2 -40
- package/lib/point/models/earthFill.js +9 -60
- package/lib/point/models/extrude.js +3 -42
- package/lib/point/models/fill.js +15 -76
- package/lib/point/models/fillmage.js +6 -43
- package/lib/point/models/image.js +7 -41
- package/lib/point/models/normal.js +2 -2
- package/lib/point/models/radar.js +4 -13
- package/lib/point/models/simplePoint.js +8 -49
- package/lib/point/models/text.js +15 -45
- package/lib/point/shaders/animate/wave_frag.glsl +1 -11
- package/lib/point/shaders/earth/extrude_frag.glsl +5 -17
- package/lib/point/shaders/earth/extrude_vert.glsl +14 -29
- package/lib/point/shaders/earth/fill_frag.glsl +5 -14
- package/lib/point/shaders/earth/fill_vert.glsl +1 -75
- package/lib/point/shaders/extrude/extrude_frag.glsl +3 -29
- package/lib/point/shaders/extrude/extrude_vert.glsl +27 -35
- package/lib/point/shaders/fill_frag.glsl +9 -20
- package/lib/point/shaders/fill_vert.glsl +16 -101
- package/lib/point/shaders/image/fillImage_frag.glsl +2 -5
- package/lib/point/shaders/image/fillImage_vert.glsl +4 -47
- package/lib/point/shaders/image_frag.glsl +1 -5
- package/lib/point/shaders/image_vert.glsl +1 -44
- package/lib/point/shaders/normal_frag.glsl +0 -2
- package/lib/point/shaders/normal_vert.glsl +2 -1
- package/lib/point/shaders/radar/radar_vert.glsl +2 -2
- package/lib/point/shaders/simplePoint_frag.glsl +0 -7
- package/lib/point/shaders/simplePoint_vert.glsl +3 -45
- package/lib/point/shaders/text_frag.glsl +6 -19
- package/lib/point/shaders/text_vert.glsl +5 -66
- package/lib/polygon/index.js +1 -0
- package/lib/polygon/models/extrude.js +86 -82
- package/lib/polygon/models/fill.js +8 -47
- package/lib/polygon/shaders/extrude/polygon_extrude_frag.glsl +2 -23
- package/lib/polygon/shaders/extrude/polygon_extrude_picklight_frag.glsl +7 -5
- package/lib/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +7 -32
- package/lib/polygon/shaders/extrude/polygon_extrude_vert.glsl +33 -38
- package/lib/polygon/shaders/extrude/polygon_extrudetex_frag.glsl +12 -9
- package/lib/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +16 -44
- package/lib/polygon/shaders/polygon_frag.glsl +0 -5
- package/lib/polygon/shaders/polygon_linear_frag.glsl +0 -8
- package/lib/polygon/shaders/polygon_linear_vert.glsl +0 -32
- package/lib/polygon/shaders/polygon_vert.glsl +1 -27
- package/lib/utils/layerData.js +2 -2
- package/package.json +7 -7
- package/es/line/models/half.js +0 -267
- package/es/line/shaders/half/line_half_frag.glsl +0 -53
- package/es/line/shaders/half/line_half_vert.glsl +0 -169
- package/es/utils/dataMappingStyle.d.ts +0 -31
- package/es/utils/dataMappingStyle.js +0 -137
- package/lib/line/models/half.js +0 -274
- package/lib/line/shaders/half/line_half_frag.glsl +0 -53
- package/lib/line/shaders/half/line_half_vert.glsl +0 -169
- package/lib/utils/dataMappingStyle.js +0 -140
|
@@ -15,15 +15,14 @@ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime
|
|
|
15
15
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
16
16
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
17
17
|
var _l7Core = require("@antv/l7-core");
|
|
18
|
-
var _lodash = require("lodash");
|
|
19
18
|
var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
|
|
20
19
|
var _triangulation = require("../../core/triangulation");
|
|
21
20
|
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); }; }
|
|
22
21
|
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; } }
|
|
23
22
|
/* babel-plugin-inline-import '../shaders/image_frag.glsl' */
|
|
24
|
-
var pointImageFrag = "\nuniform sampler2D u_texture;\nvarying vec4 v_color;\nvarying vec2 v_uv;\nuniform vec2 u_textSize;\nuniform float u_opacity : 1;\n\
|
|
23
|
+
var pointImageFrag = "\nuniform sampler2D u_texture;\nvarying vec4 v_color;\nvarying vec2 v_uv;\nuniform vec2 u_textSize;\nuniform float u_opacity : 1;\n\n#pragma include \"picking\"\n\nvoid main(){\n vec2 pos = v_uv / u_textSize + gl_PointCoord / u_textSize * 64.;\n vec4 textureColor;\n\n // Y = 0.299R + 0.587G + 0.114B // \u4EAE\u5EA6\u63D0\u53D6\n \n textureColor = texture2D(u_texture, pos);\n\n // Tip: \u53BB\u9664\u8FB9\u7F18\u90E8\u5206 mipmap \u5BFC\u81F4\u7684\u6DF7\u5408\u53D8\u6697\n float fragmengTocenter = distance(vec2(0.5), gl_PointCoord);\n if(fragmengTocenter >= 0.5) {\n float luma = 0.299 * textureColor.r + 0.587 * textureColor.g + 0.114 * textureColor.b;\n textureColor.a *= luma;\n }\n \n \n\n if(all(lessThan(v_color, vec4(1.0+0.00001))) && all(greaterThan(v_color, vec4(1.0-0.00001))) || v_color==vec4(1.0)){\n gl_FragColor= textureColor;\n }else {\n gl_FragColor= step(0.01, textureColor.z) * v_color;\n }\n\n gl_FragColor.a = gl_FragColor.a * u_opacity;\n \n if (gl_FragColor.a < 0.01) {\n discard;\n }\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
|
|
25
24
|
/* babel-plugin-inline-import '../shaders/image_vert.glsl' */
|
|
26
|
-
var pointImageVert = "precision highp float;\nattribute vec3 a_Position;\nattribute vec4 a_Color;\nattribute vec2 a_Uv;\nattribute float a_Size;\nvarying vec4 v_color;\nvarying vec2 v_uv;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform vec2 u_offsets;\n\nuniform float u_opacity : 1;\nuniform float u_raisingHeight: 0.0;\nuniform float u_heightfixed: 0.0;\n\
|
|
25
|
+
var pointImageVert = "precision highp float;\nattribute vec3 a_Position;\nattribute vec4 a_Color;\nattribute vec2 a_Uv;\nattribute float a_Size;\nvarying vec4 v_color;\nvarying vec2 v_uv;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform vec2 u_offsets;\n\nuniform float u_opacity : 1;\nuniform float u_raisingHeight: 0.0;\nuniform float u_heightfixed: 0.0;\n\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n v_color = a_Color;\n v_uv = a_Uv;\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n \n vec2 offset = project_pixel(u_offsets);\n\n float raisingHeight = u_raisingHeight;\n if(u_heightfixed < 1.0) { // false\n raisingHeight = project_pixel(u_raisingHeight);\n } else {\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 raisingHeight = u_raisingHeight * mapboxZoomScale;\n }\n }\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * vec4(project_pos.xy + offset, raisingHeight, 1.0);\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, raisingHeight, 1.0));\n }\n\n gl_PointSize = a_Size * 2.0 * u_DevicePixelRatio;\n setPickingColor(a_PickingColor);\n}\n";
|
|
27
26
|
var ImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
28
27
|
(0, _inherits2.default)(ImageModel, _BaseModel);
|
|
29
28
|
var _super = _createSuper(ImageModel);
|
|
@@ -75,50 +74,18 @@ var ImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
75
74
|
raisingHeight = _ref$raisingHeight === void 0 ? 0 : _ref$raisingHeight,
|
|
76
75
|
_ref$heightfixed = _ref.heightfixed,
|
|
77
76
|
heightfixed = _ref$heightfixed === void 0 ? false : _ref$heightfixed;
|
|
77
|
+
|
|
78
|
+
// ThreeJS 图层兼容
|
|
78
79
|
if (this.rendererService.getDirty()) {
|
|
79
80
|
this.texture.bind();
|
|
80
81
|
}
|
|
81
|
-
if (this.dataTextureTest && this.dataTextureNeedUpdate({
|
|
82
|
-
opacity: opacity,
|
|
83
|
-
offsets: offsets
|
|
84
|
-
})) {
|
|
85
|
-
this.judgeStyleAttributes({
|
|
86
|
-
opacity: opacity,
|
|
87
|
-
offsets: offsets
|
|
88
|
-
});
|
|
89
|
-
var encodeData = this.layer.getEncodedData();
|
|
90
|
-
var _this$calDataFrame = this.calDataFrame(this.cellLength, encodeData, this.cellProperties),
|
|
91
|
-
data = _this$calDataFrame.data,
|
|
92
|
-
width = _this$calDataFrame.width,
|
|
93
|
-
height = _this$calDataFrame.height;
|
|
94
|
-
this.rowCount = height; // 当前数据纹理有多少行
|
|
95
|
-
|
|
96
|
-
this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
|
|
97
|
-
flipY: true,
|
|
98
|
-
data: data,
|
|
99
|
-
format: _l7Core.gl.LUMINANCE,
|
|
100
|
-
type: _l7Core.gl.FLOAT,
|
|
101
|
-
width: width,
|
|
102
|
-
height: height
|
|
103
|
-
}) : this.createTexture2D({
|
|
104
|
-
flipY: true,
|
|
105
|
-
data: [1],
|
|
106
|
-
format: _l7Core.gl.LUMINANCE,
|
|
107
|
-
type: _l7Core.gl.FLOAT,
|
|
108
|
-
width: 1,
|
|
109
|
-
height: 1
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
82
|
return {
|
|
113
83
|
u_raisingHeight: Number(raisingHeight),
|
|
114
84
|
u_heightfixed: Number(heightfixed),
|
|
115
|
-
u_dataTexture: this.dataTexture,
|
|
116
|
-
// 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]
|
|
117
|
-
u_cellTypeLayout: this.getCellTypeLayout(),
|
|
118
85
|
u_texture: this.texture,
|
|
119
86
|
u_textSize: [1024, this.iconService.canvasHeight || 128],
|
|
120
|
-
u_opacity:
|
|
121
|
-
u_offsets:
|
|
87
|
+
u_opacity: opacity,
|
|
88
|
+
u_offsets: offsets
|
|
122
89
|
};
|
|
123
90
|
}
|
|
124
91
|
}, {
|
|
@@ -145,9 +112,8 @@ var ImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
145
112
|
}, {
|
|
146
113
|
key: "clearModels",
|
|
147
114
|
value: function clearModels() {
|
|
148
|
-
var _this$texture
|
|
115
|
+
var _this$texture;
|
|
149
116
|
(_this$texture = this.texture) === null || _this$texture === void 0 ? void 0 : _this$texture.destroy();
|
|
150
|
-
(_this$dataTexture = this.dataTexture) === null || _this$dataTexture === void 0 ? void 0 : _this$dataTexture.destroy();
|
|
151
117
|
this.iconService.off('imageUpdate', this.updateTexture);
|
|
152
118
|
}
|
|
153
119
|
}, {
|
|
@@ -20,9 +20,9 @@ var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
|
|
|
20
20
|
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); }; }
|
|
21
21
|
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; } }
|
|
22
22
|
/* babel-plugin-inline-import '../shaders/normal_frag.glsl' */
|
|
23
|
-
var normalFrag = "
|
|
23
|
+
var normalFrag = "varying vec4 v_color;\nvoid main() {\n gl_FragColor = v_color;\n}\n";
|
|
24
24
|
/* babel-plugin-inline-import '../shaders/normal_vert.glsl' */
|
|
25
|
-
var normalVert = "\nattribute vec3 a_Position;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nattribute float a_Size;\nattribute vec4 a_Color;\n\nvarying vec4 v_color;\n\n#pragma include \"projection\"\n#pragma include \"project\"\n\nvoid main() {\n v_color = a_Color;\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * vec4(a_Position.xy, a_Position.z, 1.0);\n } else {\n vec4 project_pos = project_position(vec4(a_Position, 1.0)) + vec4(a_Size / 2.,-a_Size /2.,0.,0.);\n gl_Position = project_common_position_to_clipspace(vec4(vec2(project_pos.xy),project_pos.z,project_pos.w));\n }\n\n gl_PointSize = a_Size * 2.0 * u_DevicePixelRatio;\n}\n";
|
|
25
|
+
var normalVert = "\nattribute vec3 a_Position;\nuniform mat4 u_ModelMatrix;\nuniform float u_opacity : 1;\nuniform mat4 u_Mvp;\nattribute float a_Size;\nattribute vec4 a_Color;\n\nvarying vec4 v_color;\n\n#pragma include \"projection\"\n#pragma include \"project\"\n\nvoid main() {\n v_color = vec4(a_Color.xyz, a_Color.w * u_opacity);\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * vec4(a_Position.xy, a_Position.z, 1.0);\n } else {\n vec4 project_pos = project_position(vec4(a_Position, 1.0)) + vec4(a_Size / 2.,-a_Size /2.,0.,0.);\n gl_Position = project_common_position_to_clipspace(vec4(vec2(project_pos.xy),project_pos.z,project_pos.w));\n }\n\n gl_PointSize = a_Size * 2.0 * u_DevicePixelRatio;\n}\n";
|
|
26
26
|
function PointTriangulation(feature) {
|
|
27
27
|
var coordinates = feature.coordinates;
|
|
28
28
|
return {
|
|
@@ -13,7 +13,6 @@ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits
|
|
|
13
13
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
14
14
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
15
15
|
var _l7Core = require("@antv/l7-core");
|
|
16
|
-
var _lodash = require("lodash");
|
|
17
16
|
var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
|
|
18
17
|
var _interface = require("../../core/interface");
|
|
19
18
|
var _triangulation = require("../../core/triangulation");
|
|
@@ -22,7 +21,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
22
21
|
/* babel-plugin-inline-import '../shaders/radar/radar_frag.glsl' */
|
|
23
22
|
var pointFillFrag = "\nuniform float u_additive;\nuniform float u_opacity: 1.0;\n\nvarying vec4 v_data;\nvarying vec4 v_color;\nvarying float v_radius;\nvarying vec2 v_exteude;\n#pragma include \"sdf_2d\"\n#pragma include \"picking\"\n\nvoid main() {\n\n lowp float antialiasblur = v_data.z;\n float r = v_radius / (v_radius);\n\n float outer_df = sdCircle(v_data.xy, 1.0);\n float inner_df = sdCircle(v_data.xy, r);\n\n float opacity_t = smoothstep(0.0, antialiasblur, outer_df);\n\n gl_FragColor = vec4(v_color.rgb, v_color.a * u_opacity);\n\n if(u_additive > 0.0) {\n gl_FragColor *= opacity_t;\n } else {\n gl_FragColor.a *= opacity_t;\n }\n\n if(gl_FragColor.a > 0.0) {\n gl_FragColor = filterColor(gl_FragColor);\n }\n\n vec2 extrude = v_exteude;\n vec2 dir = normalize(extrude);\n vec2 baseDir = vec2(1.0, 0.0);\n float pi = 3.14159265359;\n // full circle\n // float rades = dot(dir, baseDir);\n // float flag = sign(dir.y);\n // float radar_v = (flag - 1.0) * -0.5 + flag * acos(rades)/pi/2.0;\n \n // half circle\n float flag = sign(dir.y);\n float rades = dot(dir, baseDir);\n float radar_v = (flag - 1.0) * -0.5 * acos(rades)/pi;\n // simple AA\n if(radar_v > 0.99) {\n radar_v = 1.0 - (radar_v - 0.99)/0.01;\n }\n\n gl_FragColor.a *= radar_v;\n}\n";
|
|
24
23
|
/* babel-plugin-inline-import '../shaders/radar/radar_vert.glsl' */
|
|
25
|
-
var pointFillVert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Extrude;\nattribute float a_Size;\nuniform float u_speed: 1.0;\nuniform float u_time;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform int
|
|
24
|
+
var pointFillVert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Extrude;\nattribute float a_Size;\nuniform float u_speed: 1.0;\nuniform float u_time;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform int u_size_unit;\n\nvarying vec4 v_data;\nvarying vec4 v_color;\nvarying float v_radius;\nvarying vec2 v_exteude;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n vec3 extrude = a_Extrude;\n float newSize = setPickingSize(a_Size);\n\n float time = u_time * u_speed;\n mat2 rotateMatrix = mat2( \n cos(time), sin(time), \n -sin(time), cos(time)\n );\n v_exteude = rotateMatrix * a_Extrude.xy;\n\n // unpack color(vec2)\n v_color = a_Color;\n\n\n\n // anti-alias\n float blur = 0.0;\n float antialiasblur = -max(2.0 / u_DevicePixelRatio / a_Size, blur);\n\n if(u_size_unit == 1) {\n newSize = newSize * u_PixelsPerMeter.z;\n }\n // radius(16-bit)\n v_radius = newSize;\n\n vec2 offset = (extrude.xy * (newSize));\n vec3 aPosition = a_Position;\n \n // \u4E0D\u4EE5\u7C73\u4E3A\u5B9E\u9645\u5355\u4F4D\n offset = project_pixel(offset);\n \n v_data = vec4(extrude.x, extrude.y, antialiasblur, -1.0);\n\n vec4 project_pos = project_position(vec4(aPosition.xy, 0.0, 1.0));\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp *vec4(project_pos.xy + offset, 0.0, 1.0);\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, project_pixel(setPickingOrder(0.0)), 1.0));\n }\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
26
25
|
var RadarModel = /*#__PURE__*/function (_BaseModel) {
|
|
27
26
|
(0, _inherits2.default)(RadarModel, _BaseModel);
|
|
28
27
|
var _super = _createSuper(RadarModel);
|
|
@@ -42,10 +41,10 @@ var RadarModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
42
41
|
_ref$unit = _ref.unit,
|
|
43
42
|
unit = _ref$unit === void 0 ? 'pixel' : _ref$unit;
|
|
44
43
|
return {
|
|
45
|
-
|
|
44
|
+
u_size_unit: _interface.SizeUnitType[unit],
|
|
46
45
|
u_speed: speed,
|
|
47
46
|
u_additive: blend === 'additive' ? 1.0 : 0.0,
|
|
48
|
-
u_opacity:
|
|
47
|
+
u_opacity: opacity
|
|
49
48
|
};
|
|
50
49
|
}
|
|
51
50
|
}, {
|
|
@@ -116,15 +115,7 @@ var RadarModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
116
115
|
return _buildModels.apply(this, arguments);
|
|
117
116
|
}
|
|
118
117
|
return buildModels;
|
|
119
|
-
}()
|
|
120
|
-
}, {
|
|
121
|
-
key: "clearModels",
|
|
122
|
-
value: function clearModels() {
|
|
123
|
-
var _this$dataTexture;
|
|
124
|
-
(_this$dataTexture = this.dataTexture) === null || _this$dataTexture === void 0 ? void 0 : _this$dataTexture.destroy();
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// overwrite baseModel func
|
|
118
|
+
}() // overwrite baseModel func
|
|
128
119
|
}, {
|
|
129
120
|
key: "animateOption2Array",
|
|
130
121
|
value: function animateOption2Array(option) {
|
|
@@ -15,14 +15,14 @@ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime
|
|
|
15
15
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
16
16
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
17
17
|
var _l7Core = require("@antv/l7-core");
|
|
18
|
-
var _lodash = require("lodash");
|
|
19
18
|
var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
|
|
19
|
+
var _l7Utils = require("@antv/l7-utils");
|
|
20
20
|
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); }; }
|
|
21
21
|
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; } }
|
|
22
22
|
/* babel-plugin-inline-import '../shaders/simplePoint_frag.glsl' */
|
|
23
|
-
var simplePointFrag = "\nuniform float
|
|
23
|
+
var simplePointFrag = "\nuniform float u_additive;\nuniform float u_stroke_opacity : 1;\n\nuniform vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\n\nvarying vec4 v_color;\nvarying float v_blur;\nvarying float v_innerRadius;\n\n#pragma include \"picking\"\nvoid main() {\n vec2 center = vec2(0.5);\n\n // Tip: \u7247\u5143\u5230\u4E2D\u5FC3\u70B9\u7684\u8DDD\u79BB 0 - 1\n float fragmengTocenter = distance(center, gl_PointCoord) * 2.0;\n // Tip: \u7247\u5143\u7684\u526A\u5207\u6210\u5706\u5F62\n float circleClipOpacity = 1.0 - smoothstep(v_blur, 1.0, fragmengTocenter);\n\n\n if(v_innerRadius < 0.99) {\n // \u5F53\u5B58\u5728 stroke \u4E14 stroke > 0.01\n float blurWidth = (1.0 - v_blur)/2.0;\n vec4 stroke = vec4(u_stroke_color.rgb, u_stroke_opacity);\n if(fragmengTocenter > v_innerRadius + blurWidth) {\n gl_FragColor = stroke;\n } else if(fragmengTocenter > v_innerRadius - blurWidth){\n float mixR = (fragmengTocenter - (v_innerRadius - blurWidth)) / (blurWidth * 2.0);\n gl_FragColor = mix(v_color, stroke, mixR);\n } else {\n gl_FragColor = v_color;\n }\n } else {\n // \u5F53\u4E0D\u5B58\u5728 stroke \u6216 stroke <= 0.01\n gl_FragColor = v_color;\n }\n\n gl_FragColor = filterColor(gl_FragColor);\n \n if(u_additive > 0.0) {\n gl_FragColor *= circleClipOpacity;\n } else {\n gl_FragColor.a *= circleClipOpacity;\n }\n\n}\n";
|
|
24
24
|
/* babel-plugin-inline-import '../shaders/simplePoint_vert.glsl' */
|
|
25
|
-
var simplePointVert = "\nattribute vec3 a_Position;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nattribute float a_Size;\nattribute vec4 a_Color;\nvarying vec4 v_color;\n\nuniform float u_opacity : 1;\nuniform vec2 u_offsets;\nuniform float u_stroke_width;\n\nvarying
|
|
25
|
+
var simplePointVert = "\nattribute vec3 a_Position;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nattribute float a_Size;\nattribute vec4 a_Color;\nvarying vec4 v_color;\n\nuniform float u_opacity : 1;\nuniform vec2 u_offsets;\nuniform float u_stroke_width;\n\nvarying float v_blur;\nvarying float v_innerRadius;\n\n\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n#pragma include \"project\"\nvoid main() {\n v_color = vec4(a_Color.xyz, a_Color.w * u_opacity);\n v_blur = 1.0 - max(2.0/a_Size, 0.05);\n v_innerRadius = max((a_Size - u_stroke_width) / a_Size, 0.0);\n \n vec2 offset = project_pixel(u_offsets);\n \n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * vec4(a_Position.xy + offset, a_Position.z, 1.0);\n } else { // else\n vec4 project_pos = project_position(vec4(a_Position, 1.0)) + vec4(a_Size / 2.,-a_Size /2.,0.,0.);\n gl_Position = project_common_position_to_clipspace(vec4(vec2(project_pos.xy+offset),project_pos.z,project_pos.w));\n }\n\n gl_PointSize = a_Size * 2.0 * u_DevicePixelRatio;\n setPickingColor(a_PickingColor);\n}\n";
|
|
26
26
|
function PointTriangulation(feature) {
|
|
27
27
|
var coordinates = feature.coordinates;
|
|
28
28
|
return {
|
|
@@ -60,48 +60,13 @@ var SimplePointModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
60
60
|
strokeWidth = _ref$strokeWidth === void 0 ? 0 : _ref$strokeWidth,
|
|
61
61
|
_ref$stroke = _ref.stroke,
|
|
62
62
|
stroke = _ref$stroke === void 0 ? '#fff' : _ref$stroke;
|
|
63
|
-
if (this.dataTextureTest && this.dataTextureNeedUpdate({
|
|
64
|
-
opacity: opacity,
|
|
65
|
-
offsets: offsets
|
|
66
|
-
})) {
|
|
67
|
-
// 判断当前的样式中哪些是需要进行数据映射的,哪些是常量,同时计算用于构建数据纹理的一些中间变量
|
|
68
|
-
this.judgeStyleAttributes({
|
|
69
|
-
opacity: opacity,
|
|
70
|
-
offsets: offsets
|
|
71
|
-
});
|
|
72
|
-
var encodeData = this.layer.getEncodedData();
|
|
73
|
-
var _this$calDataFrame = this.calDataFrame(this.cellLength, encodeData, this.cellProperties),
|
|
74
|
-
data = _this$calDataFrame.data,
|
|
75
|
-
width = _this$calDataFrame.width,
|
|
76
|
-
height = _this$calDataFrame.height;
|
|
77
|
-
this.rowCount = height; // 当前数据纹理有多少行
|
|
78
|
-
|
|
79
|
-
this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
|
|
80
|
-
flipY: true,
|
|
81
|
-
data: data,
|
|
82
|
-
format: _l7Core.gl.LUMINANCE,
|
|
83
|
-
type: _l7Core.gl.FLOAT,
|
|
84
|
-
width: width,
|
|
85
|
-
height: height
|
|
86
|
-
}) : this.createTexture2D({
|
|
87
|
-
flipY: true,
|
|
88
|
-
data: [1],
|
|
89
|
-
format: _l7Core.gl.LUMINANCE,
|
|
90
|
-
type: _l7Core.gl.FLOAT,
|
|
91
|
-
width: 1,
|
|
92
|
-
height: 1
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
63
|
return {
|
|
96
64
|
u_additive: blend === 'additive' ? 1.0 : 0.0,
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
u_stroke_opacity: (0, _lodash.isNumber)(strokeOpacity) ? strokeOpacity : 1.0,
|
|
103
|
-
u_stroke_width: (0, _lodash.isNumber)(strokeWidth) ? strokeWidth : 1.0,
|
|
104
|
-
u_stroke_color: this.getStrokeColor(stroke)
|
|
65
|
+
u_opacity: opacity,
|
|
66
|
+
u_offsets: offsets,
|
|
67
|
+
u_stroke_opacity: strokeOpacity,
|
|
68
|
+
u_stroke_width: strokeWidth,
|
|
69
|
+
u_stroke_color: (0, _l7Utils.rgb2arr)(stroke)
|
|
105
70
|
};
|
|
106
71
|
}
|
|
107
72
|
}, {
|
|
@@ -157,12 +122,6 @@ var SimplePointModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
157
122
|
}
|
|
158
123
|
return buildModels;
|
|
159
124
|
}()
|
|
160
|
-
}, {
|
|
161
|
-
key: "clearModels",
|
|
162
|
-
value: function clearModels() {
|
|
163
|
-
var _this$dataTexture;
|
|
164
|
-
(_this$dataTexture = this.dataTexture) === null || _this$dataTexture === void 0 ? void 0 : _this$dataTexture.destroy();
|
|
165
|
-
}
|
|
166
125
|
}, {
|
|
167
126
|
key: "registerBuiltinAttributes",
|
|
168
127
|
value: function registerBuiltinAttributes() {
|
package/lib/point/models/text.js
CHANGED
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.TextTrianglation = TextTrianglation;
|
|
8
8
|
exports.default = void 0;
|
|
9
9
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
10
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
10
11
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
11
12
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
12
13
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
@@ -28,9 +29,9 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
28
29
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
29
30
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
30
31
|
/* babel-plugin-inline-import '../shaders/text_frag.glsl' */
|
|
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;\
|
|
32
|
+
var textFrag = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 48.0\nuniform sampler2D u_sdf_map;\nuniform float u_gamma_scale : 0.5;\nuniform float u_stroke_width : 2.0;\nuniform float u_halo_blur : 0.5;\nuniform float u_DevicePixelRatio;\n\nvarying vec4 v_color;\nvarying vec4 v_stroke_color;\nvarying vec2 v_uv;\nvarying float v_gamma_scale;\nvarying float v_fontScale;\n\n\n#pragma include \"picking\"\nvoid main() {\n // get style data mapping\n\n // get sdf from atlas\n float dist = texture2D(u_sdf_map, v_uv).a;\n\n lowp float buff = (6.0 - u_stroke_width / v_fontScale) / SDF_PX;\n highp float gamma = (u_halo_blur * 1.19 / SDF_PX + EDGE_GAMMA) / (v_fontScale * u_gamma_scale) / 1.0;\n\n highp float gamma_scaled = gamma * v_gamma_scale;\n\n highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist);\n\n gl_FragColor = mix(v_color, v_stroke_color, smoothstep(0., 0.5, 1.- dist));\n\n gl_FragColor.a *= alpha;\n // \u4F5C\u4E3A mask \u6A21\u677F\u65F6\u9700\u8981\u4E22\u5F03\u900F\u660E\u7684\u50CF\u7D20\n if (gl_FragColor.a < 0.01) {\n discard;\n }\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
|
|
32
33
|
/* babel-plugin-inline-import '../shaders/text_vert.glsl' */
|
|
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
|
|
34
|
+
var textVert = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 24.0\nattribute vec3 a_Position;\nattribute vec2 a_tex;\nattribute vec2 a_textOffsets;\nattribute vec4 a_Color;\nattribute float a_Size;\nattribute float a_Rotate;\n\nuniform vec2 u_sdf_map_size;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform float u_raisingHeight: 0.0;\n\nvarying vec2 v_uv;\nvarying float v_gamma_scale;\nvarying vec4 v_color;\nvarying vec4 v_stroke_color;\nvarying float v_fontScale;\n// uniform float u_opacity : 1;\nuniform float u_stroke_width : 2;\nuniform vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\n\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n \n v_uv = a_tex / u_sdf_map_size;\n\n\n\n v_color = vec4(a_Color.xyz, a_Color.w * opacity);\n v_stroke_color = vec4(u_stroke_color.xyz, u_stroke_color.w * opacity);\n\n // \u6587\u672C\u7F29\u653E\u6BD4\u4F8B\n float fontScale = a_Size / FONT_SIZE;\n v_fontScale = fontScale;\n\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n // vec4 projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n highp float angle_sin = sin(a_Rotate);\n highp float angle_cos = cos(a_Rotate);\n mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);\n \n // gl_Position = vec4(projected_position.xy / projected_position.w + rotation_matrix * a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);\n\n float raiseHeight = u_raisingHeight;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n raiseHeight = u_raisingHeight * mapboxZoomScale;\n }\n\n vec4 projected_position;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n projected_position = u_Mvp *(vec4(a_Position.xyz + vec3(0.0, 0.0, raiseHeight), 1.0));\n } else { // else\n projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz + vec3(0.0, 0.0, raiseHeight), 1.0));\n }\n\n gl_Position = vec4(\n projected_position.xy / projected_position.w + rotation_matrix * a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);\n v_gamma_scale = gl_Position.w;\n setPickingColor(a_PickingColor);\n\n}\n";
|
|
34
35
|
function TextTrianglation(feature) {
|
|
35
36
|
// @ts-ignore
|
|
36
37
|
var that = this;
|
|
@@ -112,51 +113,16 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
112
113
|
this.textCount = Object.keys(mapping).length;
|
|
113
114
|
}
|
|
114
115
|
this.preTextStyle = this.getTextStyle();
|
|
115
|
-
|
|
116
|
-
opacity: opacity,
|
|
117
|
-
strokeWidth: strokeWidth,
|
|
118
|
-
stroke: stroke
|
|
119
|
-
})) {
|
|
120
|
-
this.judgeStyleAttributes({
|
|
121
|
-
opacity: opacity,
|
|
122
|
-
strokeWidth: strokeWidth,
|
|
123
|
-
stroke: stroke
|
|
124
|
-
});
|
|
125
|
-
var encodeData = this.layer.getEncodedData();
|
|
126
|
-
var _this$calDataFrame = this.calDataFrame(this.cellLength, encodeData, this.cellProperties),
|
|
127
|
-
data = _this$calDataFrame.data,
|
|
128
|
-
width = _this$calDataFrame.width,
|
|
129
|
-
height = _this$calDataFrame.height;
|
|
130
|
-
this.rowCount = height; // 当前数据纹理有多少行
|
|
131
|
-
this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
|
|
132
|
-
flipY: true,
|
|
133
|
-
data: data,
|
|
134
|
-
format: _l7Core.gl.LUMINANCE,
|
|
135
|
-
type: _l7Core.gl.FLOAT,
|
|
136
|
-
width: width,
|
|
137
|
-
height: height
|
|
138
|
-
}) : this.createTexture2D({
|
|
139
|
-
flipY: true,
|
|
140
|
-
data: [1],
|
|
141
|
-
format: _l7Core.gl.LUMINANCE,
|
|
142
|
-
type: _l7Core.gl.FLOAT,
|
|
143
|
-
width: 1,
|
|
144
|
-
height: 1
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
return {
|
|
148
|
-
u_dataTexture: this.dataTexture,
|
|
149
|
-
// 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]
|
|
150
|
-
u_cellTypeLayout: this.getCellTypeLayout(),
|
|
116
|
+
return (0, _objectSpread2.default)({
|
|
151
117
|
u_raisingHeight: Number(raisingHeight),
|
|
152
|
-
u_opacity:
|
|
153
|
-
u_stroke_width:
|
|
154
|
-
u_stroke_color:
|
|
118
|
+
// u_opacity: opacity,
|
|
119
|
+
u_stroke_width: strokeWidth,
|
|
120
|
+
u_stroke_color: (0, _l7Utils.rgb2arr)(stroke),
|
|
155
121
|
u_sdf_map: this.texture,
|
|
156
122
|
u_halo_blur: halo,
|
|
157
123
|
u_gamma_scale: gamma,
|
|
158
124
|
u_sdf_map_size: [(canvas === null || canvas === void 0 ? void 0 : canvas.width) || 1, (canvas === null || canvas === void 0 ? void 0 : canvas.height) || 1]
|
|
159
|
-
};
|
|
125
|
+
}, this.getStyleAttribute());
|
|
160
126
|
}
|
|
161
127
|
}, {
|
|
162
128
|
key: "initModels",
|
|
@@ -201,6 +167,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
201
167
|
moduleName: 'pointText',
|
|
202
168
|
vertexShader: textVert,
|
|
203
169
|
fragmentShader: textFrag,
|
|
170
|
+
inject: this.getInject(),
|
|
204
171
|
triangulation: TextTrianglation.bind(this),
|
|
205
172
|
depth: {
|
|
206
173
|
enable: false
|
|
@@ -277,9 +244,8 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
277
244
|
}, {
|
|
278
245
|
key: "clearModels",
|
|
279
246
|
value: function clearModels() {
|
|
280
|
-
var _this$texture
|
|
247
|
+
var _this$texture;
|
|
281
248
|
(_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
249
|
// TODO this.mapping
|
|
284
250
|
this.layer.off('remapping', this.mapping);
|
|
285
251
|
}
|
|
@@ -309,6 +275,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
309
275
|
type: _l7Core.AttributeType.Attribute,
|
|
310
276
|
descriptor: {
|
|
311
277
|
name: 'a_textOffsets',
|
|
278
|
+
// 文字偏移量
|
|
312
279
|
buffer: {
|
|
313
280
|
// give the WebGL driver a hint that this buffer may change
|
|
314
281
|
usage: _l7Core.gl.STATIC_DRAW,
|
|
@@ -499,7 +466,9 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
499
466
|
size = _feature$size2 === void 0 ? 1 : _feature$size2;
|
|
500
467
|
var shaping = (0, _symbolLayout.shapeText)(shape.toString(), mapping,
|
|
501
468
|
// @ts-ignore
|
|
502
|
-
size, textAnchor, 'left', spacing, textOffset
|
|
469
|
+
size, textAnchor, 'left', spacing, textOffset,
|
|
470
|
+
// || feature['textOffset'] || [0, 0],// TODO: 文字偏移量 CPU 计算
|
|
471
|
+
iconfont);
|
|
503
472
|
var glyphQuads = (0, _symbolLayout.getGlyphQuads)(shaping, textOffset, false);
|
|
504
473
|
feature.shaping = shaping;
|
|
505
474
|
feature.glyphQuads = glyphQuads;
|
|
@@ -643,6 +612,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
643
612
|
vertexShader: textVert,
|
|
644
613
|
fragmentShader: textFrag,
|
|
645
614
|
triangulation: TextTrianglation.bind(this),
|
|
615
|
+
inject: this.getInject(),
|
|
646
616
|
depth: {
|
|
647
617
|
enable: false
|
|
648
618
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
uniform float u_additive;
|
|
3
3
|
|
|
4
|
-
varying mat4 styleMappingMat; // 传递从片元中传递的映射数据
|
|
5
4
|
|
|
6
5
|
varying vec4 v_data;
|
|
7
6
|
varying vec4 v_color;
|
|
@@ -14,15 +13,6 @@ uniform vec4 u_animate: [ 1., 2., 1.0, 0.2 ];
|
|
|
14
13
|
|
|
15
14
|
void main() {
|
|
16
15
|
|
|
17
|
-
vec4 textrueStroke = vec4(
|
|
18
|
-
styleMappingMat[1][0],
|
|
19
|
-
styleMappingMat[1][1],
|
|
20
|
-
styleMappingMat[1][2],
|
|
21
|
-
styleMappingMat[1][3]
|
|
22
|
-
);
|
|
23
|
-
|
|
24
|
-
float opacity = styleMappingMat[0][0];
|
|
25
|
-
|
|
26
16
|
lowp float antialiasblur = v_data.z;
|
|
27
17
|
float r = v_radius / (v_radius);
|
|
28
18
|
|
|
@@ -45,7 +35,7 @@ void main() {
|
|
|
45
35
|
float N_RINGS = 3.0;
|
|
46
36
|
float FREQ = 1.0;
|
|
47
37
|
|
|
48
|
-
|
|
38
|
+
gl_FragColor = v_color;
|
|
49
39
|
|
|
50
40
|
float d = length(v_data.xy);
|
|
51
41
|
if(d > 0.5) {
|
|
@@ -5,7 +5,6 @@ uniform float u_pickLight: 0.0;
|
|
|
5
5
|
|
|
6
6
|
#pragma include "picking"
|
|
7
7
|
|
|
8
|
-
varying mat4 styleMappingMat; // 传递从片元中传递的映射数据
|
|
9
8
|
|
|
10
9
|
uniform float u_linearColor: 0;
|
|
11
10
|
uniform vec4 u_sourceColor;
|
|
@@ -13,31 +12,20 @@ uniform vec4 u_targetColor;
|
|
|
13
12
|
|
|
14
13
|
uniform float u_opacitylinear: 0.0;
|
|
15
14
|
uniform float u_opacitylinear_dir: 1.0;
|
|
16
|
-
|
|
15
|
+
varying float v_lightWeight;
|
|
16
|
+
varying float v_barLinearZ;
|
|
17
17
|
void main() {
|
|
18
|
-
float opacity = styleMappingMat[0][0];
|
|
19
|
-
float lightWeight = styleMappingMat[1][3];
|
|
20
|
-
float barLinearZ = styleMappingMat[2][3];
|
|
21
|
-
|
|
22
|
-
// 设置圆柱的底色
|
|
23
|
-
if(u_linearColor == 1.0) { // 使用渐变颜色
|
|
24
|
-
gl_FragColor = mix(u_sourceColor, u_targetColor, barLinearZ);
|
|
25
|
-
gl_FragColor.rgb *= lightWeight;
|
|
26
|
-
} else { // 使用 color 方法传入的颜色
|
|
27
|
-
gl_FragColor = v_color;
|
|
28
|
-
}
|
|
29
18
|
|
|
30
|
-
|
|
31
|
-
gl_FragColor.a *= opacity;
|
|
19
|
+
gl_FragColor = v_color;
|
|
32
20
|
|
|
33
21
|
// 开启透明度渐变
|
|
34
22
|
if(u_opacitylinear > 0.0) {
|
|
35
|
-
gl_FragColor.a *= u_opacitylinear_dir > 0.0 ? (1.0 -
|
|
23
|
+
gl_FragColor.a *= u_opacitylinear_dir > 0.0 ? (1.0 - v_barLinearZ): v_barLinearZ;
|
|
36
24
|
}
|
|
37
25
|
|
|
38
26
|
// picking
|
|
39
27
|
if(u_pickLight > 0.0) {
|
|
40
|
-
gl_FragColor = filterColorAlpha(gl_FragColor,
|
|
28
|
+
gl_FragColor = filterColorAlpha(gl_FragColor, v_lightWeight);
|
|
41
29
|
} else {
|
|
42
30
|
gl_FragColor = filterColor(gl_FragColor);
|
|
43
31
|
}
|
|
@@ -20,11 +20,10 @@ varying vec4 v_color;
|
|
|
20
20
|
|
|
21
21
|
uniform float u_opacity : 1;
|
|
22
22
|
uniform float u_lightEnable: 1;
|
|
23
|
+
varying float v_lightWeight;
|
|
24
|
+
varying float v_barLinearZ;
|
|
25
|
+
// 用于将在顶点着色器中计算好的样式值传递给片元
|
|
23
26
|
|
|
24
|
-
varying mat4 styleMappingMat; // 用于将在顶点着色器中计算好的样式值传递给片元
|
|
25
|
-
|
|
26
|
-
#pragma include "styleMapping"
|
|
27
|
-
#pragma include "styleMappingCalOpacity"
|
|
28
27
|
|
|
29
28
|
#pragma include "projection"
|
|
30
29
|
#pragma include "light"
|
|
@@ -48,35 +47,15 @@ float getXRadian(float y, float r) {
|
|
|
48
47
|
|
|
49
48
|
void main() {
|
|
50
49
|
|
|
51
|
-
// cal style mapping - 数据纹理映射部分的计算
|
|
52
|
-
styleMappingMat = mat4(
|
|
53
|
-
0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty
|
|
54
|
-
0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA - lightWeight
|
|
55
|
-
0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1] - linearZ(垂直方向 0 - 1 的值)
|
|
56
|
-
0.0, 0.0, 0.0, 0.0
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
float rowCount = u_cellTypeLayout[0][0]; // 当前的数据纹理有几行
|
|
60
|
-
float columnCount = u_cellTypeLayout[0][1]; // 当看到数据纹理有几列
|
|
61
|
-
float columnWidth = 1.0/columnCount; // 列宽
|
|
62
|
-
float rowHeight = 1.0/rowCount; // 行高
|
|
63
|
-
float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets
|
|
64
|
-
float id = a_vertexId; // 第n个顶点
|
|
65
|
-
float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // 起始点在第几行
|
|
66
|
-
float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // 起始点在第几列
|
|
67
50
|
|
|
68
|
-
// cell 固定顺序 opacity -> strokeOpacity -> strokeWidth -> stroke ...
|
|
69
|
-
// 按顺序从 cell 中取值、若没有则自动往下取值
|
|
70
51
|
float textureOffset = 0.0; // 在 cell 中取值的偏移量
|
|
71
52
|
|
|
72
|
-
vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);
|
|
73
|
-
styleMappingMat[0][0] = opacityAndOffset.r;
|
|
74
53
|
textureOffset = opacityAndOffset.g;
|
|
75
54
|
// cal style mapping - 数据纹理映射部分的计算
|
|
76
55
|
vec3 size = a_Size * a_Position;
|
|
77
56
|
|
|
78
57
|
// a_Position.z 是在构建网格的时候传入的标准值 0 - 1,在插值器插值可以获取 0~1 线性渐变的值
|
|
79
|
-
|
|
58
|
+
v_barLinearZ = a_Position.z;
|
|
80
59
|
|
|
81
60
|
vec3 offset = size; // 控制圆柱体的大小 - 从标准单位圆柱体进行偏移
|
|
82
61
|
if(u_heightfixed < 1.0) { // 圆柱体不固定高度
|
|
@@ -106,11 +85,17 @@ void main() {
|
|
|
106
85
|
if(u_lightEnable > 0.0) { // 取消三元表达式,增强健壮性
|
|
107
86
|
lightWeight = calc_lighting(pos);
|
|
108
87
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
88
|
+
v_lightWeight = lightWeight;
|
|
89
|
+
// 设置圆柱的底色
|
|
90
|
+
if(u_linearColor == 1.0) { // 使用渐变颜色
|
|
91
|
+
v_color = mix(u_sourceColor, u_targetColor, barLinearZ);
|
|
92
|
+
v_color.rgb *= lightWeight;
|
|
93
|
+
} else { // 使用 color 方法传入的颜色
|
|
94
|
+
v_color = a_Color;
|
|
95
|
+
}
|
|
96
|
+
v_color.a *= u_opacity;
|
|
112
97
|
|
|
113
|
-
|
|
98
|
+
|
|
114
99
|
// 在地球模式下,将原本垂直于 xy 平面的圆柱调整姿态到适应圆的角度
|
|
115
100
|
//旋转矩阵mx,创建绕x轴旋转矩阵
|
|
116
101
|
float r = sqrt(a_Pos.z*a_Pos.z + a_Pos.x*a_Pos.x);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
uniform float u_additive;
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
uniform float u_opacity : 1;
|
|
3
|
+
uniform float u_stroke_opacity : 1;
|
|
4
|
+
uniform float u_stroke_width : 2;
|
|
4
5
|
|
|
5
6
|
varying vec4 v_data;
|
|
6
7
|
varying vec4 v_color;
|
|
@@ -13,16 +14,6 @@ varying float v_radius;
|
|
|
13
14
|
void main() {
|
|
14
15
|
int shape = int(floor(v_data.w + 0.5));
|
|
15
16
|
|
|
16
|
-
vec4 textrueStroke = vec4(
|
|
17
|
-
styleMappingMat[1][0],
|
|
18
|
-
styleMappingMat[1][1],
|
|
19
|
-
styleMappingMat[1][2],
|
|
20
|
-
styleMappingMat[1][3]
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
float opacity = styleMappingMat[0][0];
|
|
24
|
-
float stroke_opacity = styleMappingMat[0][1];
|
|
25
|
-
float strokeWidth = styleMappingMat[0][2];
|
|
26
17
|
vec4 strokeColor = textrueStroke == vec4(0) ? v_color : textrueStroke;
|
|
27
18
|
|
|
28
19
|
lowp float antialiasblur = v_data.z;
|
|
@@ -71,9 +62,9 @@ void main() {
|
|
|
71
62
|
);
|
|
72
63
|
|
|
73
64
|
if(strokeWidth < 0.01) {
|
|
74
|
-
gl_FragColor = vec4(v_color.rgb, v_color.a *
|
|
65
|
+
gl_FragColor = vec4(v_color.rgb, v_color.a * u_opacity);
|
|
75
66
|
} else {
|
|
76
|
-
gl_FragColor = mix(vec4(v_color.rgb, v_color.a *
|
|
67
|
+
gl_FragColor = mix(vec4(v_color.rgb, v_color.a * u_opacity), u_stroke_color * u_stroke_opacity, color_t);
|
|
77
68
|
}
|
|
78
69
|
|
|
79
70
|
if(u_additive > 0.0) {
|