@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
package/es/point/models/text.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
1
2
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
2
3
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
4
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
@@ -14,15 +15,15 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
14
15
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
15
16
|
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; } }
|
|
16
17
|
import { AttributeType, gl } from '@antv/l7-core';
|
|
17
|
-
import { boundsContains, calculateCentroid, padBounds } from '@antv/l7-utils';
|
|
18
|
-
import { isEqual
|
|
18
|
+
import { boundsContains, calculateCentroid, padBounds, rgb2arr } from '@antv/l7-utils';
|
|
19
|
+
import { isEqual } from 'lodash';
|
|
19
20
|
import BaseModel from "../../core/BaseModel";
|
|
20
21
|
import CollisionIndex from "../../utils/collision-index";
|
|
21
22
|
import { getGlyphQuads, shapeText } from "../../utils/symbol-layout";
|
|
22
23
|
/* babel-plugin-inline-import '../shaders/text_frag.glsl' */
|
|
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;\
|
|
24
|
+
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";
|
|
24
25
|
/* babel-plugin-inline-import '../shaders/text_vert.glsl' */
|
|
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
|
|
26
|
+
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";
|
|
26
27
|
export function TextTrianglation(feature) {
|
|
27
28
|
// @ts-ignore
|
|
28
29
|
var that = this;
|
|
@@ -104,51 +105,16 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
104
105
|
this.textCount = Object.keys(mapping).length;
|
|
105
106
|
}
|
|
106
107
|
this.preTextStyle = this.getTextStyle();
|
|
107
|
-
|
|
108
|
-
opacity: opacity,
|
|
109
|
-
strokeWidth: strokeWidth,
|
|
110
|
-
stroke: stroke
|
|
111
|
-
})) {
|
|
112
|
-
this.judgeStyleAttributes({
|
|
113
|
-
opacity: opacity,
|
|
114
|
-
strokeWidth: strokeWidth,
|
|
115
|
-
stroke: stroke
|
|
116
|
-
});
|
|
117
|
-
var encodeData = this.layer.getEncodedData();
|
|
118
|
-
var _this$calDataFrame = this.calDataFrame(this.cellLength, encodeData, this.cellProperties),
|
|
119
|
-
data = _this$calDataFrame.data,
|
|
120
|
-
width = _this$calDataFrame.width,
|
|
121
|
-
height = _this$calDataFrame.height;
|
|
122
|
-
this.rowCount = height; // 当前数据纹理有多少行
|
|
123
|
-
this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
|
|
124
|
-
flipY: true,
|
|
125
|
-
data: data,
|
|
126
|
-
format: gl.LUMINANCE,
|
|
127
|
-
type: gl.FLOAT,
|
|
128
|
-
width: width,
|
|
129
|
-
height: height
|
|
130
|
-
}) : this.createTexture2D({
|
|
131
|
-
flipY: true,
|
|
132
|
-
data: [1],
|
|
133
|
-
format: gl.LUMINANCE,
|
|
134
|
-
type: gl.FLOAT,
|
|
135
|
-
width: 1,
|
|
136
|
-
height: 1
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
return {
|
|
140
|
-
u_dataTexture: this.dataTexture,
|
|
141
|
-
// 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]
|
|
142
|
-
u_cellTypeLayout: this.getCellTypeLayout(),
|
|
108
|
+
return _objectSpread({
|
|
143
109
|
u_raisingHeight: Number(raisingHeight),
|
|
144
|
-
u_opacity:
|
|
145
|
-
u_stroke_width:
|
|
146
|
-
u_stroke_color:
|
|
110
|
+
// u_opacity: opacity,
|
|
111
|
+
u_stroke_width: strokeWidth,
|
|
112
|
+
u_stroke_color: rgb2arr(stroke),
|
|
147
113
|
u_sdf_map: this.texture,
|
|
148
114
|
u_halo_blur: halo,
|
|
149
115
|
u_gamma_scale: gamma,
|
|
150
116
|
u_sdf_map_size: [(canvas === null || canvas === void 0 ? void 0 : canvas.width) || 1, (canvas === null || canvas === void 0 ? void 0 : canvas.height) || 1]
|
|
151
|
-
};
|
|
117
|
+
}, this.getStyleAttribute());
|
|
152
118
|
}
|
|
153
119
|
}, {
|
|
154
120
|
key: "initModels",
|
|
@@ -193,6 +159,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
193
159
|
moduleName: 'pointText',
|
|
194
160
|
vertexShader: textVert,
|
|
195
161
|
fragmentShader: textFrag,
|
|
162
|
+
inject: this.getInject(),
|
|
196
163
|
triangulation: TextTrianglation.bind(this),
|
|
197
164
|
depth: {
|
|
198
165
|
enable: false
|
|
@@ -269,9 +236,8 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
269
236
|
}, {
|
|
270
237
|
key: "clearModels",
|
|
271
238
|
value: function clearModels() {
|
|
272
|
-
var _this$texture
|
|
239
|
+
var _this$texture;
|
|
273
240
|
(_this$texture = this.texture) === null || _this$texture === void 0 ? void 0 : _this$texture.destroy();
|
|
274
|
-
(_this$dataTexture = this.dataTexture) === null || _this$dataTexture === void 0 ? void 0 : _this$dataTexture.destroy();
|
|
275
241
|
// TODO this.mapping
|
|
276
242
|
this.layer.off('remapping', this.mapping);
|
|
277
243
|
}
|
|
@@ -301,6 +267,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
301
267
|
type: AttributeType.Attribute,
|
|
302
268
|
descriptor: {
|
|
303
269
|
name: 'a_textOffsets',
|
|
270
|
+
// 文字偏移量
|
|
304
271
|
buffer: {
|
|
305
272
|
// give the WebGL driver a hint that this buffer may change
|
|
306
273
|
usage: gl.STATIC_DRAW,
|
|
@@ -491,7 +458,9 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
491
458
|
size = _feature$size2 === void 0 ? 1 : _feature$size2;
|
|
492
459
|
var shaping = shapeText(shape.toString(), mapping,
|
|
493
460
|
// @ts-ignore
|
|
494
|
-
size, textAnchor, 'left', spacing, textOffset
|
|
461
|
+
size, textAnchor, 'left', spacing, textOffset,
|
|
462
|
+
// || feature['textOffset'] || [0, 0],// TODO: 文字偏移量 CPU 计算
|
|
463
|
+
iconfont);
|
|
495
464
|
var glyphQuads = getGlyphQuads(shaping, textOffset, false);
|
|
496
465
|
feature.shaping = shaping;
|
|
497
466
|
feature.glyphQuads = glyphQuads;
|
|
@@ -635,6 +604,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
635
604
|
vertexShader: textVert,
|
|
636
605
|
fragmentShader: textFrag,
|
|
637
606
|
triangulation: TextTrianglation.bind(this),
|
|
607
|
+
inject: this.getInject(),
|
|
638
608
|
depth: {
|
|
639
609
|
enable: false
|
|
640
610
|
}
|
|
@@ -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) {
|
|
@@ -3,9 +3,6 @@ attribute vec3 a_Position;
|
|
|
3
3
|
attribute vec3 a_Extrude;
|
|
4
4
|
attribute float a_Size;
|
|
5
5
|
attribute float a_Shape;
|
|
6
|
-
|
|
7
|
-
varying mat4 styleMappingMat; // 用于将在顶点着色器中计算好的样式值传递给片元
|
|
8
|
-
|
|
9
6
|
uniform mat4 u_ModelMatrix;
|
|
10
7
|
uniform mat4 u_Mvp;
|
|
11
8
|
|
|
@@ -21,11 +18,6 @@ uniform vec2 u_offsets;
|
|
|
21
18
|
|
|
22
19
|
uniform float u_blur : 0.0;
|
|
23
20
|
|
|
24
|
-
#pragma include "styleMapping"
|
|
25
|
-
#pragma include "styleMappingCalOpacity"
|
|
26
|
-
#pragma include "styleMappingCalStrokeOpacity"
|
|
27
|
-
#pragma include "styleMappingCalStrokeWidth"
|
|
28
|
-
|
|
29
21
|
#pragma include "projection"
|
|
30
22
|
#pragma include "picking"
|
|
31
23
|
|
|
@@ -39,72 +31,6 @@ void main() {
|
|
|
39
31
|
float newSize = setPickingSize(a_Size);
|
|
40
32
|
// float newSize = setPickingSize(a_Size) * 0.00001038445708445579;
|
|
41
33
|
|
|
42
|
-
// cal style mapping - 数据纹理映射部分的计算
|
|
43
|
-
styleMappingMat = mat4(
|
|
44
|
-
0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty
|
|
45
|
-
0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA
|
|
46
|
-
0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]
|
|
47
|
-
0.0, 0.0, 0.0, 0.0
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
float rowCount = u_cellTypeLayout[0][0]; // 当前的数据纹理有几行
|
|
51
|
-
float columnCount = u_cellTypeLayout[0][1]; // 当看到数据纹理有几列
|
|
52
|
-
float columnWidth = 1.0/columnCount; // 列宽
|
|
53
|
-
float rowHeight = 1.0/rowCount; // 行高
|
|
54
|
-
float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets
|
|
55
|
-
float id = a_vertexId; // 第n个顶点
|
|
56
|
-
float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // 起始点在第几行
|
|
57
|
-
float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // 起始点在第几列
|
|
58
|
-
|
|
59
|
-
// cell 固定顺序 opacity -> strokeOpacity -> strokeWidth -> stroke ...
|
|
60
|
-
// 按顺序从 cell 中取值、若没有则自动往下取值
|
|
61
|
-
float textureOffset = 0.0; // 在 cell 中取值的偏移量
|
|
62
|
-
|
|
63
|
-
vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);
|
|
64
|
-
styleMappingMat[0][0] = opacityAndOffset.r;
|
|
65
|
-
textureOffset = opacityAndOffset.g;
|
|
66
|
-
|
|
67
|
-
vec2 strokeOpacityAndOffset = calStrokeOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);
|
|
68
|
-
styleMappingMat[0][1] = strokeOpacityAndOffset.r;
|
|
69
|
-
textureOffset = strokeOpacityAndOffset.g;
|
|
70
|
-
|
|
71
|
-
vec2 strokeWidthAndOffset = calStrokeWidthAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);
|
|
72
|
-
styleMappingMat[0][2] = strokeWidthAndOffset.r;
|
|
73
|
-
textureOffset = strokeWidthAndOffset.g;
|
|
74
|
-
|
|
75
|
-
vec4 textrueStroke = vec4(-1.0, -1.0, -1.0, -1.0);
|
|
76
|
-
if(hasStroke()) {
|
|
77
|
-
vec2 valueRPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);
|
|
78
|
-
styleMappingMat[1][0] = pos2value(valueRPos, columnWidth, rowHeight); // R
|
|
79
|
-
textureOffset += 1.0;
|
|
80
|
-
|
|
81
|
-
vec2 valueGPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);
|
|
82
|
-
styleMappingMat[1][1] = pos2value(valueGPos, columnWidth, rowHeight); // G
|
|
83
|
-
textureOffset += 1.0;
|
|
84
|
-
|
|
85
|
-
vec2 valueBPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);
|
|
86
|
-
styleMappingMat[1][2] = pos2value(valueBPos, columnWidth, rowHeight); // B
|
|
87
|
-
textureOffset += 1.0;
|
|
88
|
-
|
|
89
|
-
vec2 valueAPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);
|
|
90
|
-
styleMappingMat[1][3] = pos2value(valueAPos, columnWidth, rowHeight); // A
|
|
91
|
-
textureOffset += 1.0;
|
|
92
|
-
} else {
|
|
93
|
-
if(u_stroke_color == vec4(0.0)) {
|
|
94
|
-
styleMappingMat[1][0] = v_color.r;
|
|
95
|
-
styleMappingMat[1][1] = v_color.g;
|
|
96
|
-
styleMappingMat[1][2] = v_color.b;
|
|
97
|
-
styleMappingMat[1][3] = v_color.a;
|
|
98
|
-
} else {
|
|
99
|
-
styleMappingMat[1][0] = u_stroke_color.r;
|
|
100
|
-
styleMappingMat[1][1] = u_stroke_color.g;
|
|
101
|
-
styleMappingMat[1][2] = u_stroke_color.b;
|
|
102
|
-
styleMappingMat[1][3] = u_stroke_color.a;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// cal style mapping
|
|
107
|
-
|
|
108
34
|
// unpack color(vec2)
|
|
109
35
|
v_color = a_Color;
|
|
110
36
|
|
|
@@ -119,7 +45,7 @@ void main() {
|
|
|
119
45
|
v_data = vec4(extrude.x/abs(extrude.x), extrude.y/abs(extrude.y), antialiasblur,shape_type);
|
|
120
46
|
|
|
121
47
|
|
|
122
|
-
gl_Position = u_ViewProjectionMatrix * vec4(a_Position + extrude * newSize * 0.1, 1.0);
|
|
48
|
+
gl_Position = u_ViewProjectionMatrix * vec4(a_Position + extrude * newSize * 0.1 + u_offsets, 1.0);
|
|
123
49
|
|
|
124
50
|
setPickingColor(a_PickingColor);
|
|
125
51
|
}
|
|
@@ -1,43 +1,17 @@
|
|
|
1
1
|
varying vec4 v_color;
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
varying float v_lightWeight;
|
|
4
3
|
uniform float u_pickLight: 0.0;
|
|
5
4
|
|
|
6
5
|
#pragma include "picking"
|
|
7
6
|
|
|
8
|
-
varying mat4 styleMappingMat; // 传递从片元中传递的映射数据
|
|
9
|
-
|
|
10
|
-
uniform float u_linearColor: 0;
|
|
11
|
-
uniform vec4 u_sourceColor;
|
|
12
|
-
uniform vec4 u_targetColor;
|
|
13
|
-
|
|
14
|
-
uniform float u_opacitylinear: 0.0;
|
|
15
|
-
uniform float u_opacitylinear_dir: 1.0;
|
|
16
7
|
|
|
17
8
|
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
|
-
|
|
30
|
-
// 应用透明度
|
|
31
|
-
gl_FragColor.a *= opacity;
|
|
32
9
|
|
|
10
|
+
gl_FragColor = v_color;
|
|
33
11
|
// 开启透明度渐变
|
|
34
|
-
if(u_opacitylinear > 0.0) {
|
|
35
|
-
gl_FragColor.a *= u_opacitylinear_dir > 0.0 ? (1.0 - barLinearZ): barLinearZ;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
12
|
// picking
|
|
39
13
|
if(u_pickLight > 0.0) {
|
|
40
|
-
gl_FragColor = filterColorAlpha(gl_FragColor,
|
|
14
|
+
gl_FragColor = filterColorAlpha(gl_FragColor, v_lightWeight);
|
|
41
15
|
} else {
|
|
42
16
|
gl_FragColor = filterColor(gl_FragColor);
|
|
43
17
|
}
|
|
@@ -16,14 +16,17 @@ uniform float u_r;
|
|
|
16
16
|
uniform mat4 u_ModelMatrix;
|
|
17
17
|
uniform mat4 u_Mvp;
|
|
18
18
|
varying vec4 v_color;
|
|
19
|
+
varying float v_lightWeight;
|
|
20
|
+
varying float v_barLinearZ;
|
|
19
21
|
|
|
20
22
|
uniform float u_opacity : 1;
|
|
21
23
|
uniform float u_lightEnable: 1;
|
|
24
|
+
uniform float u_opacitylinear: 0.0;
|
|
25
|
+
uniform vec4 u_sourceColor;
|
|
26
|
+
uniform vec4 u_targetColor;
|
|
27
|
+
uniform float u_opacitylinear_dir: 1.0;
|
|
28
|
+
uniform float u_linearColor: 0.0;
|
|
22
29
|
|
|
23
|
-
varying mat4 styleMappingMat; // 用于将在顶点着色器中计算好的样式值传递给片元
|
|
24
|
-
|
|
25
|
-
#pragma include "styleMapping"
|
|
26
|
-
#pragma include "styleMappingCalOpacity"
|
|
27
30
|
|
|
28
31
|
#pragma include "projection"
|
|
29
32
|
#pragma include "light"
|
|
@@ -47,37 +50,11 @@ float getXRadian(float y, float r) {
|
|
|
47
50
|
|
|
48
51
|
void main() {
|
|
49
52
|
|
|
50
|
-
// cal style mapping - 数据纹理映射部分的计算
|
|
51
|
-
styleMappingMat = mat4(
|
|
52
|
-
0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty
|
|
53
|
-
0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA - lightWeight
|
|
54
|
-
0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1] - linearZ(垂直方向 0 - 1 的值)
|
|
55
|
-
0.0, 0.0, 0.0, 0.0
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
float rowCount = u_cellTypeLayout[0][0]; // 当前的数据纹理有几行
|
|
59
|
-
float columnCount = u_cellTypeLayout[0][1]; // 当看到数据纹理有几列
|
|
60
|
-
float columnWidth = 1.0/columnCount; // 列宽
|
|
61
|
-
float rowHeight = 1.0/rowCount; // 行高
|
|
62
|
-
float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets
|
|
63
|
-
float id = a_vertexId; // 第n个顶点
|
|
64
|
-
float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // 起始点在第几行
|
|
65
|
-
float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // 起始点在第几列
|
|
66
|
-
|
|
67
|
-
// cell 固定顺序 opacity -> strokeOpacity -> strokeWidth -> stroke ...
|
|
68
|
-
// 按顺序从 cell 中取值、若没有则自动往下取值
|
|
69
|
-
float textureOffset = 0.0; // 在 cell 中取值的偏移量
|
|
70
|
-
|
|
71
|
-
vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);
|
|
72
|
-
styleMappingMat[0][0] = opacityAndOffset.r;
|
|
73
|
-
textureOffset = opacityAndOffset.g;
|
|
74
|
-
// cal style mapping - 数据纹理映射部分的计算
|
|
75
|
-
vec3 size = a_Size * a_Position;
|
|
76
53
|
|
|
77
|
-
|
|
78
|
-
styleMappingMat[2][3] = a_Position.z;
|
|
54
|
+
vec3 size = a_Size * a_Position;
|
|
79
55
|
|
|
80
56
|
vec3 offset = size; // 控制圆柱体的大小 - 从标准单位圆柱体进行偏移
|
|
57
|
+
|
|
81
58
|
if(u_heightfixed < 1.0) { // 圆柱体不固定高度
|
|
82
59
|
|
|
83
60
|
if (u_CoordinateSystem == COORDINATE_SYSTEM_P20 || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {
|
|
@@ -100,14 +77,29 @@ void main() {
|
|
|
100
77
|
// u_r 控制圆柱的生长
|
|
101
78
|
vec4 pos = vec4(project_pos.xy + offset.xy, offset.z * u_r, 1.0);
|
|
102
79
|
|
|
103
|
-
// 圆柱光照效果
|
|
80
|
+
// // 圆柱光照效果
|
|
104
81
|
float lightWeight = 1.0;
|
|
82
|
+
|
|
105
83
|
if(u_lightEnable > 0.0) { // 取消三元表达式,增强健壮性
|
|
106
84
|
lightWeight = calc_lighting(pos);
|
|
107
85
|
}
|
|
108
|
-
styleMappingMat[1][3] = lightWeight;
|
|
109
86
|
|
|
110
|
-
|
|
87
|
+
v_lightWeight = lightWeight;
|
|
88
|
+
|
|
89
|
+
v_color = a_Color;
|
|
90
|
+
|
|
91
|
+
// 设置圆柱的底色
|
|
92
|
+
if(u_linearColor == 1.0) { // 使用渐变颜色
|
|
93
|
+
v_color = mix(u_sourceColor, u_targetColor, a_Position.z);
|
|
94
|
+
v_color.a = v_color.a * u_opacity;
|
|
95
|
+
} else {
|
|
96
|
+
v_color = vec4(a_Color.rgb * lightWeight, a_Color.w * u_opacity);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if(u_opacitylinear > 0.0) {
|
|
100
|
+
v_color.a *= u_opacitylinear_dir > 0.0 ? (1.0 - a_Position.z): a_Position.z;
|
|
101
|
+
}
|
|
102
|
+
|
|
111
103
|
|
|
112
104
|
// gl_Position = project_common_position_to_clipspace(pos);
|
|
113
105
|
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
uniform float u_additive;
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
uniform float u_stroke_opacity : 1;
|
|
3
|
+
uniform float u_stroke_width : 2;
|
|
4
4
|
|
|
5
5
|
varying vec4 v_data;
|
|
6
6
|
varying vec4 v_color;
|
|
7
7
|
varying float v_radius;
|
|
8
|
+
varying vec4 v_stroke;
|
|
9
|
+
|
|
8
10
|
|
|
9
11
|
#pragma include "sdf_2d"
|
|
10
12
|
#pragma include "picking"
|
|
@@ -12,21 +14,8 @@ varying float v_radius;
|
|
|
12
14
|
|
|
13
15
|
void main() {
|
|
14
16
|
int shape = int(floor(v_data.w + 0.5));
|
|
15
|
-
|
|
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
|
-
vec4 strokeColor = textrueStroke == vec4(0) ? v_color : textrueStroke;
|
|
27
|
-
|
|
28
17
|
lowp float antialiasblur = v_data.z;
|
|
29
|
-
float r = v_radius / (v_radius +
|
|
18
|
+
float r = v_radius / (v_radius + u_stroke_width);
|
|
30
19
|
|
|
31
20
|
float outer_df;
|
|
32
21
|
float inner_df;
|
|
@@ -62,16 +51,16 @@ void main() {
|
|
|
62
51
|
|
|
63
52
|
float opacity_t = smoothstep(0.0, antialiasblur, outer_df);
|
|
64
53
|
|
|
65
|
-
float color_t =
|
|
54
|
+
float color_t = u_stroke_width < 0.01 ? 0.0 : smoothstep(
|
|
66
55
|
antialiasblur,
|
|
67
56
|
0.0,
|
|
68
57
|
inner_df
|
|
69
58
|
);
|
|
70
59
|
|
|
71
|
-
if(
|
|
72
|
-
gl_FragColor =
|
|
60
|
+
if(u_stroke_width < 0.01) {
|
|
61
|
+
gl_FragColor = v_color;
|
|
73
62
|
} else {
|
|
74
|
-
gl_FragColor = mix(
|
|
63
|
+
gl_FragColor = mix(v_color, v_stroke * u_stroke_opacity, color_t);
|
|
75
64
|
}
|
|
76
65
|
|
|
77
66
|
if(u_additive > 0.0) {
|