@antv/l7-layers 2.20.13 → 2.20.14
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 +0 -1
- package/es/core/BaseLayer.js +8 -5
- package/es/core/LayerPickService.d.ts +1 -1
- package/es/core/LayerPickService.js +28 -10
- package/es/geometry/models/sprite.js +2 -2
- package/es/heatmap/models/grid.js +2 -2
- package/es/heatmap/models/grid3d.js +4 -4
- package/es/heatmap/models/heatmap.js +10 -6
- package/es/heatmap/shaders/grid/grid_frag.glsl +1 -0
- package/es/heatmap/shaders/grid3d/grid_3d_frag.glsl +9 -0
- package/es/heatmap/shaders/grid3d/grid_3d_vert.glsl +4 -8
- package/es/heatmap/shaders/heatmap/heatmap_framebuffer_frag.glsl +2 -1
- package/es/heatmap/shaders/heatmap/heatmap_framebuffer_vert.glsl +3 -1
- package/es/heatmap/shaders/heatmap/heatmap_vert.glsl +3 -0
- package/es/image/models/image.js +6 -8
- package/es/line/models/arc.js +1 -1
- package/es/line/models/line.js +10 -45
- package/es/line/shaders/arc/line_arc_frag.glsl +2 -1
- package/es/line/shaders/line/line_frag.glsl +2 -2
- package/es/line/shaders/line/line_vert.glsl +10 -7
- package/es/plugins/ShaderUniformPlugin.js +3 -2
- package/es/point/models/extrude.js +2 -2
- package/es/point/models/fill.js +1 -1
- package/es/point/models/fillImage.js +3 -5
- package/es/point/models/text.js +2 -2
- package/es/point/shaders/extrude/extrude_frag.glsl +1 -0
- package/es/point/shaders/extrude/extrude_vert.glsl +0 -1
- package/es/point/shaders/fill/fill_frag.glsl +1 -1
- package/es/point/shaders/fillImage/fillImage_frag.glsl +1 -2
- package/es/point/shaders/text/text_frag.glsl +3 -2
- package/es/point/shaders/text/text_vert.glsl +0 -2
- package/es/polygon/models/extrude.js +30 -39
- package/es/polygon/models/extrusion.js +1 -1
- package/es/polygon/models/fill.js +3 -3
- package/es/polygon/models/water.js +6 -4
- package/es/polygon/shaders/extrude/polygon_extrude_frag.glsl +1 -0
- package/es/polygon/shaders/extrude/polygon_extrude_picklight_frag.glsl +1 -0
- package/es/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +2 -3
- package/es/polygon/shaders/extrude/polygon_extrudetex_frag.glsl +7 -9
- package/es/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +1 -2
- package/es/polygon/shaders/extrusion/polygon_extrusion_frag.glsl +1 -0
- package/es/polygon/shaders/fill/fill_frag.glsl +1 -0
- package/es/polygon/shaders/fill/fill_linear_frag.glsl +4 -3
- package/es/polygon/shaders/fill/fill_linear_vert.glsl +5 -8
- package/es/raster/models/rasterTerrainRgb.d.ts +8 -2
- package/es/raster/models/rasterTerrainRgb.js +20 -14
- package/es/raster/shaders/terrain/terrain_rgb_frag.glsl +18 -16
- package/es/raster/shaders/terrain/terrain_rgb_vert.glsl +13 -5
- package/es/tile/service/TilePickService.d.ts +1 -1
- package/es/tile/service/TilePickService.js +36 -13
- package/es/tile/tile/Tile.js +4 -3
- package/es/utils/load-image.d.ts +1 -0
- package/es/utils/load-image.js +46 -0
- package/lib/core/BaseLayer.js +8 -5
- package/lib/core/LayerPickService.js +28 -10
- package/lib/geometry/models/sprite.js +2 -2
- package/lib/heatmap/models/grid.js +2 -2
- package/lib/heatmap/models/grid3d.js +4 -4
- package/lib/heatmap/models/heatmap.js +10 -6
- package/lib/heatmap/shaders/grid/grid_frag.glsl +1 -0
- package/lib/heatmap/shaders/grid3d/grid_3d_frag.glsl +9 -0
- package/lib/heatmap/shaders/grid3d/grid_3d_vert.glsl +4 -8
- package/lib/heatmap/shaders/heatmap/heatmap_framebuffer_frag.glsl +2 -1
- package/lib/heatmap/shaders/heatmap/heatmap_framebuffer_vert.glsl +3 -1
- package/lib/heatmap/shaders/heatmap/heatmap_vert.glsl +3 -0
- package/lib/image/models/image.js +6 -8
- package/lib/line/models/arc.js +1 -1
- package/lib/line/models/line.js +10 -45
- package/lib/line/shaders/arc/line_arc_frag.glsl +2 -1
- package/lib/line/shaders/line/line_frag.glsl +2 -2
- package/lib/line/shaders/line/line_vert.glsl +10 -7
- package/lib/plugins/ShaderUniformPlugin.js +3 -2
- package/lib/point/models/extrude.js +2 -2
- package/lib/point/models/fill.js +1 -1
- package/lib/point/models/fillImage.js +3 -5
- package/lib/point/models/text.js +2 -2
- package/lib/point/shaders/extrude/extrude_frag.glsl +1 -0
- package/lib/point/shaders/extrude/extrude_vert.glsl +0 -1
- package/lib/point/shaders/fill/fill_frag.glsl +1 -1
- package/lib/point/shaders/fillImage/fillImage_frag.glsl +1 -2
- package/lib/point/shaders/text/text_frag.glsl +3 -2
- package/lib/point/shaders/text/text_vert.glsl +0 -2
- package/lib/polygon/models/extrude.js +29 -38
- package/lib/polygon/models/extrusion.js +1 -1
- package/lib/polygon/models/fill.js +3 -3
- package/lib/polygon/models/water.js +6 -4
- package/lib/polygon/shaders/extrude/polygon_extrude_frag.glsl +1 -0
- package/lib/polygon/shaders/extrude/polygon_extrude_picklight_frag.glsl +1 -0
- package/lib/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +2 -3
- package/lib/polygon/shaders/extrude/polygon_extrudetex_frag.glsl +7 -9
- package/lib/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +1 -2
- package/lib/polygon/shaders/extrusion/polygon_extrusion_frag.glsl +1 -0
- package/lib/polygon/shaders/fill/fill_frag.glsl +1 -0
- package/lib/polygon/shaders/fill/fill_linear_frag.glsl +4 -3
- package/lib/polygon/shaders/fill/fill_linear_vert.glsl +5 -8
- package/lib/raster/models/rasterTerrainRgb.js +20 -14
- package/lib/raster/shaders/terrain/terrain_rgb_frag.glsl +18 -16
- package/lib/raster/shaders/terrain/terrain_rgb_vert.glsl +13 -5
- package/lib/tile/service/TilePickService.js +36 -13
- package/lib/tile/tile/Tile.js +4 -3
- package/lib/utils/load-image.js +53 -0
- package/package.json +7 -7
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
in vec4 v_color;
|
|
2
2
|
|
|
3
|
+
layout(std140) uniform commonUniforms {
|
|
4
|
+
vec2 u_radius;
|
|
5
|
+
float u_opacity;
|
|
6
|
+
float u_coverage;
|
|
7
|
+
float u_angle;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
#pragma include "scene_uniforms"
|
|
3
11
|
#pragma include "picking"
|
|
12
|
+
|
|
4
13
|
out vec4 outputColor;
|
|
5
14
|
void main() {
|
|
6
15
|
outputColor = v_color;
|
|
@@ -5,10 +5,10 @@ layout(location = 10) in vec3 a_Pos;
|
|
|
5
5
|
layout(location = 13) in vec3 a_Normal;
|
|
6
6
|
|
|
7
7
|
layout(std140) uniform commonUniforms {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
vec2 u_radius;
|
|
9
|
+
float u_opacity;
|
|
10
|
+
float u_coverage;
|
|
11
|
+
float u_angle;
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
out vec4 v_color;
|
|
@@ -18,12 +18,10 @@ out vec4 v_color;
|
|
|
18
18
|
#pragma include "light"
|
|
19
19
|
#pragma include "picking"
|
|
20
20
|
|
|
21
|
-
|
|
22
21
|
void main() {
|
|
23
22
|
mat2 rotationMatrix = mat2(cos(u_angle), sin(u_angle), -sin(u_angle), cos(u_angle));
|
|
24
23
|
vec2 offset =(vec2(a_Position.xy * u_radius * rotationMatrix * u_coverage));
|
|
25
24
|
|
|
26
|
-
|
|
27
25
|
if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
|
|
28
26
|
|
|
29
27
|
vec2 lnglat = unProjectFlat(a_Pos.xy + offset); // 经纬度
|
|
@@ -44,7 +42,5 @@ void main() {
|
|
|
44
42
|
gl_Position = project_common_position_to_clipspace(project_pos);
|
|
45
43
|
}
|
|
46
44
|
|
|
47
|
-
|
|
48
|
-
|
|
49
45
|
setPickingColor(a_PickingColor);
|
|
50
46
|
}
|
|
@@ -5,10 +5,11 @@ layout(std140) uniform commonUniforms {
|
|
|
5
5
|
float u_common_uniforms_padding2;
|
|
6
6
|
};
|
|
7
7
|
|
|
8
|
-
in float v_weight;
|
|
9
8
|
in vec2 v_extrude;
|
|
9
|
+
in float v_weight;
|
|
10
10
|
out vec4 outputColor;
|
|
11
11
|
#define GAUSS_COEF 0.3989422804014327
|
|
12
|
+
|
|
12
13
|
void main(){
|
|
13
14
|
float d = -0.5 * 3.0 * 3.0 * dot(v_extrude, v_extrude);
|
|
14
15
|
float val = v_weight * u_intensity * GAUSS_COEF * exp(d);
|
|
@@ -13,12 +13,14 @@ layout(std140) uniform commonUniforms {
|
|
|
13
13
|
out vec2 v_extrude;
|
|
14
14
|
out float v_weight;
|
|
15
15
|
|
|
16
|
-
|
|
17
16
|
#define GAUSS_COEF 0.3989422804014327
|
|
18
17
|
|
|
19
18
|
#pragma include "projection"
|
|
19
|
+
#pragma include "picking"
|
|
20
20
|
|
|
21
21
|
void main(){
|
|
22
|
+
vec3 picking_color_placeholder = u_PickingColor;
|
|
23
|
+
|
|
22
24
|
v_weight = a_Size;
|
|
23
25
|
float ZERO = 1.0 / 255.0 / 16.0;
|
|
24
26
|
float extrude_x = a_Dir.x * 2.0 -1.0;
|
|
@@ -13,10 +13,10 @@ 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 _l7Utils = require("@antv/l7-utils");
|
|
16
17
|
var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
|
|
17
|
-
var _triangulation = require("../../core/triangulation");
|
|
18
18
|
var _CommonStyleAttribute = require("../../core/CommonStyleAttribute");
|
|
19
|
-
var
|
|
19
|
+
var _triangulation = require("../../core/triangulation");
|
|
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/image_frag.glsl' */
|
|
@@ -34,14 +34,11 @@ var ImageModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
|
34
34
|
key: "getCommonUniformsInfo",
|
|
35
35
|
value: function getCommonUniformsInfo() {
|
|
36
36
|
var _ref = this.layer.getLayerConfig(),
|
|
37
|
-
_ref$color = _ref.color,
|
|
38
|
-
color = _ref$color === void 0 ? 'rgb(255,255,255)' : _ref$color,
|
|
39
37
|
opacity = _ref.opacity,
|
|
40
38
|
brightness = _ref.brightness,
|
|
41
39
|
contrast = _ref.contrast,
|
|
42
40
|
saturation = _ref.saturation,
|
|
43
41
|
gamma = _ref.gamma;
|
|
44
|
-
var colorArry = (0, _l7Utils.rgb2arr)(color);
|
|
45
42
|
var commonOptions = {
|
|
46
43
|
u_opacity: (0, _l7Utils.defaultValue)(opacity, 1.0),
|
|
47
44
|
u_brightness: (0, _l7Utils.defaultValue)(brightness, 1.0),
|
|
@@ -91,8 +88,8 @@ var ImageModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
|
91
88
|
case 0:
|
|
92
89
|
createTexture2D = this.rendererService.createTexture2D;
|
|
93
90
|
this.texture = createTexture2D({
|
|
94
|
-
height:
|
|
95
|
-
width:
|
|
91
|
+
height: 1,
|
|
92
|
+
width: 1
|
|
96
93
|
});
|
|
97
94
|
source = this.layer.getSource();
|
|
98
95
|
_context2.next = 5;
|
|
@@ -139,7 +136,8 @@ var ImageModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
|
139
136
|
},
|
|
140
137
|
depth: {
|
|
141
138
|
enable: false
|
|
142
|
-
}
|
|
139
|
+
},
|
|
140
|
+
pickingEnabled: false
|
|
143
141
|
});
|
|
144
142
|
case 3:
|
|
145
143
|
model = _context3.sent;
|
package/lib/line/models/arc.js
CHANGED
|
@@ -22,7 +22,7 @@ var _triangulation = require("../../core/triangulation");
|
|
|
22
22
|
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); }; }
|
|
23
23
|
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; } }
|
|
24
24
|
/* babel-plugin-inline-import '../shaders/arc/line_arc_frag.glsl' */
|
|
25
|
-
var arc_line_frag = "\n#define Animate 0.0\n#define LineTexture 1.0\nuniform sampler2D u_texture;\nlayout(std140) uniform commonUniorm {\n vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\n vec4 u_dash_array;\n vec4 u_sourceColor;\n vec4 u_targetColor;\n vec2 u_textSize;\n float segmentNumber;\n float u_lineDir: 1.0;\n float u_icon_step: 100;\n float u_line_texture: 0.0;\n float u_textureBlend;\n float u_blur : 0.9;\n float u_line_type: 0.0;\n float u_time;\n float u_linearColor: 0.0;\n};\nin
|
|
25
|
+
var arc_line_frag = "\n#define Animate 0.0\n#define LineTexture 1.0\nuniform sampler2D u_texture;\nlayout(std140) uniform commonUniorm {\n vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\n vec4 u_dash_array;\n vec4 u_sourceColor;\n vec4 u_targetColor;\n vec2 u_textSize;\n float segmentNumber;\n float u_lineDir: 1.0;\n float u_icon_step: 100;\n float u_line_texture: 0.0;\n float u_textureBlend;\n float u_blur : 0.9;\n float u_line_type: 0.0;\n float u_time;\n float u_linearColor: 0.0;\n};\n\nin vec4 v_color;\nin vec2 v_iconMapUV;\nin vec4 v_lineData;\n//dash\nin vec4 v_dash_array;\nin float v_distance_ratio;\n\nout vec4 outputColor;\n#pragma include \"picking\"\n\nvoid main() {\n if(u_dash_array!=vec4(0.0)){\n float dashLength = mod(v_distance_ratio, v_dash_array.x + v_dash_array.y + v_dash_array.z + v_dash_array.w);\n if(!(dashLength < v_dash_array.x || (dashLength > (v_dash_array.x + v_dash_array.y) && dashLength < v_dash_array.x + v_dash_array.y + v_dash_array.z))) {\n discard;\n };\n }\n float animateSpeed = 0.0; // \u8FD0\u52A8\u901F\u5EA6\n outputColor = v_color;\n if(u_animate.x == Animate && u_line_texture != LineTexture) {\n animateSpeed = u_time / u_animate.y;\n float alpha =1.0 - fract( mod(1.0- v_lineData.b, u_animate.z)* (1.0/ u_animate.z) + u_time / u_animate.y);\n alpha = (alpha + u_animate.w -1.0) / u_animate.w;\n // alpha = smoothstep(0., 1., alpha);\n alpha = clamp(alpha, 0.0, 1.0);\n outputColor.a *= alpha;\n }\n\n // \u5F53\u5B58\u5728\u8D34\u56FE\u65F6\u5728\u5E95\u8272\u4E0A\u8D34\u4E0A\u8D34\u56FE\n if(u_line_texture == LineTexture) { // while load texture\n float arcRadio = smoothstep( 0.0, 1.0, (v_lineData.r / segmentNumber));\n // float arcRadio = smoothstep( 0.0, 1.0, d_distance_ratio);\n\n float count = v_lineData.g; // \u8D34\u56FE\u5728\u5F27\u7EBF\u4E0A\u91CD\u590D\u7684\u6570\u91CF\n\n float time = 0.0;\n if(u_animate.x == Animate) {\n time = u_time / u_animate.y;\n }\n float redioCount = arcRadio * count;\n\n float u = fract(redioCount - time);\n float v = v_lineData.a; // \u6A2A\u5411 v\n vec2 uv= v_iconMapUV / u_textSize + vec2(u, v) / u_textSize * 64.;\n\n vec4 pattern = texture(SAMPLER_2D(u_texture), uv);\n\n if(u_animate.x == Animate) {\n float currentPlane = floor(redioCount - time);\n float textureStep = floor(count * u_animate.z);\n float a = mod(currentPlane, textureStep);\n if(a < textureStep - 1.0) {\n pattern = vec4(0.0);\n }\n }\n\n if(u_textureBlend == 0.0) { // normal\n pattern.a = 0.0;\n outputColor = filterColor(outputColor + pattern);\n } else { // replace\n pattern.a *= v_color.a;\n if(outputColor.a <= 0.0) {\n pattern.a = 0.0;\n }\n outputColor = filterColor(pattern);\n }\n \n } else {\n outputColor = filterColor(outputColor);\n }\n}";
|
|
26
26
|
/* babel-plugin-inline-import '../shaders/arc/line_arc_vert.glsl' */
|
|
27
27
|
var arc_line_vert = "#define Animate 0.0\n#define LineTexture 1.0\nlayout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in float a_Size;\nlayout(location = 12) in vec4 a_Instance;\nlayout(location = 14) in vec2 a_iconMapUV;\n\nlayout(std140) uniform commonUniorm {\n vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\n vec4 u_dash_array;\n vec4 u_sourceColor;\n vec4 u_targetColor;\n vec2 u_textSize;\n float segmentNumber;\n float u_lineDir: 1.0;\n float u_icon_step: 100;\n float u_line_texture: 0.0;\n float u_textureBlend;\n float u_blur : 0.9;\n float u_line_type: 0.0;\n float u_time;\n float u_linearColor: 0.0;\n};\nout vec4 v_color;\nout vec2 v_iconMapUV;\nout vec4 v_lineData;\n//dash\nout vec4 v_dash_array;\nout float v_distance_ratio;\n\n\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"picking\"\n\nfloat bezier3(vec3 arr, float t) {\n float ut = 1. - t;\n return (arr.x * ut + arr.y * t) * ut + (arr.y * ut + arr.z * t) * t;\n}\nvec2 midPoint(vec2 source, vec2 target, float arcThetaOffset) {\n vec2 center = target - source;\n float r = length(center);\n float theta = atan(center.y, center.x);\n float thetaOffset = arcThetaOffset;\n float r2 = r / 2.0 / cos(thetaOffset);\n float theta2 = theta + thetaOffset;\n vec2 mid = vec2(r2*cos(theta2) + source.x, r2*sin(theta2) + source.y);\n if(u_lineDir == 1.0) { // \u6B63\u5411\n return mid;\n } else { // \u9006\u5411\n // (mid + vmin)/2 = (s + t)/2\n vec2 vmid = source + target - mid;\n return vmid;\n }\n // return mid;\n}\nfloat getSegmentRatio(float index) {\n // dash: index / (segmentNumber - 1.);\n // normal: smoothstep(0.0, 1.0, index / (segmentNumber - 1.));\n return smoothstep(0.0, 1.0, index / (segmentNumber - 1.));\n // return index / (segmentNumber - 1.);\n}\nvec2 interpolate (vec2 source, vec2 target, float t, float arcThetaOffset) {\n // if the angularDist is PI, linear interpolation is applied. otherwise, use spherical interpolation\n vec2 mid = midPoint(source, target, arcThetaOffset);\n vec3 x = vec3(source.x, mid.x, target.x);\n vec3 y = vec3(source.y, mid.y, target.y);\n return vec2(bezier3(x ,t), bezier3(y,t));\n}\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n vec2 offset = dir_screenspace * offset_direction * setPickingSize(a_Size) / 2.0;\n return offset;\n}\nvec2 getNormal(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n return reverse_offset_normal(vec3(dir_screenspace,1.0)).xy * sign(offset_direction);\n}\n\nvoid main() {\n //vs\u4E2D\u8BA1\u7B97\u6E10\u53D8\u8272\n if(u_linearColor==1.0){\n float d_segmentIndex = a_Position.x + 1.0; // \u5F53\u524D\u9876\u70B9\u5728\u5F27\u7EBF\u4E2D\u6240\u5904\u7684\u5206\u6BB5\u4F4D\u7F6E\n v_color = mix(u_sourceColor, u_targetColor, d_segmentIndex/segmentNumber);\n }\n else{\n v_color = a_Color;\n }\n v_color.a = v_color.a * opacity;\n\n vec2 source = a_Instance.rg; // \u8D77\u59CB\u70B9\n vec2 target = a_Instance.ba; // \u7EC8\u70B9\n\n\n\n float segmentIndex = a_Position.x;\n float segmentRatio = getSegmentRatio(segmentIndex);\n\n //\u8BA1\u7B97dashArray\u548CdistanceRatio \u8F93\u51FA\u5230\u7247\u5143\n vec2 s = source;\n vec2 t = target;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n s = unProjCustomCoord(source);\n t = unProjCustomCoord(target);\n }\n float total_Distance = pixelDistance(s, t) / 2.0 * PI;\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / total_Distance;\n v_distance_ratio = segmentIndex / segmentNumber;\n\n float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n float d_distance_ratio;\n \n if(u_animate.x == Animate) {\n d_distance_ratio = segmentIndex / segmentNumber;\n if(u_lineDir != 1.0) {\n d_distance_ratio = 1.0 - d_distance_ratio;\n }\n }\n\n v_lineData.b = d_distance_ratio;\n\n vec4 curr = project_position(vec4(interpolate(source, target, segmentRatio, thetaOffset), 0.0, 1.0));\n vec4 next = project_position(vec4(interpolate(source, target, nextSegmentRatio, thetaOffset), 0.0, 1.0));\n\n \n vec2 offset = project_pixel(getExtrusionOffset((next.xy - curr.xy) * indexDir, a_Position.y));\n\n\n float d_segmentIndex = a_Position.x + 1.0; // \u5F53\u524D\u9876\u70B9\u5728\u5F27\u7EBF\u4E2D\u6240\u5904\u7684\u5206\u6BB5\u4F4D\u7F6E\n v_lineData.r = d_segmentIndex;\n\n if(LineTexture == u_line_texture) { // \u5F00\u542F\u8D34\u56FE\u6A21\u5F0F\n\n float arcDistrance = length(source - target); // \u8D77\u59CB\u70B9\u548C\u7EC8\u70B9\u7684\u8DDD\u79BB\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20) { // amap\n arcDistrance *= 1000000.0;\n }\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) { // mapbox\n // arcDistrance *= 8.0;\n arcDistrance = project_pixel_allmap(arcDistrance);\n }\n v_iconMapUV = a_iconMapUV;\n\n float pixelLen = project_pixel_texture(u_icon_step); // \u8D34\u56FE\u6CBF\u5F27\u7EBF\u65B9\u5411\u7684\u957F\u5EA6 - \u968F\u5730\u56FE\u7F29\u653E\u6539\u53D8\n float texCount = floor(arcDistrance/pixelLen); // \u8D34\u56FE\u5728\u5F27\u7EBF\u4E0A\u91CD\u590D\u7684\u6570\u91CF\n v_lineData.g = texCount;\n\n float lineOffsetWidth = length(offset + offset * sign(a_Position.y)); // \u7EBF\u6A2A\u5411\u504F\u79FB\u7684\u8DDD\u79BB\n float linePixelSize = project_pixel(a_Size); // \u5B9A\u70B9\u4F4D\u7F6E\u504F\u79FB\n v_lineData.a = lineOffsetWidth/linePixelSize; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n }\n\n gl_Position = project_common_position_to_clipspace_v2(vec4(curr.xy + offset, 0, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
28
28
|
var lineStyleObj = {
|
package/lib/line/models/line.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
10
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
11
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
12
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
@@ -22,9 +23,9 @@ var _CommonStyleAttribute = require("../../core/CommonStyleAttribute");
|
|
|
22
23
|
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); }; }
|
|
23
24
|
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; } } // import { LineTriangulation } from '../../core/triangulation';
|
|
24
25
|
/* babel-plugin-inline-import '../shaders/line/line_frag.glsl' */
|
|
25
|
-
var line_frag = "// #extension GL_OES_standard_derivatives : enable\n#define Animate 0.0\n#define LineTexture 1.0\n\nuniform sampler2D u_texture;\nlayout(std140) uniform commonUniorm {\n vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\n vec4 u_dash_array;\n vec4 u_blur;\n vec4 u_sourceColor;\n vec4 u_targetColor;\n vec2 u_textSize;\n float u_icon_step: 100;\n float u_heightfixed: 0.0;\n float u_vertexScale: 1.0;\n float u_raisingHeight: 0.0;\n float u_strokeWidth: 0.0;\n float u_textureBlend;\n float u_line_texture;\n float u_linearDir: 1.0;\n float u_linearColor: 0;\n float u_time;\n};\n\nin vec4 v_color;\nin vec4 v_stroke;\
|
|
26
|
+
var line_frag = "// #extension GL_OES_standard_derivatives : enable\n#define Animate 0.0\n#define LineTexture 1.0\n\nuniform sampler2D u_texture;\nlayout(std140) uniform commonUniorm {\n vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\n vec4 u_dash_array;\n vec4 u_blur;\n vec4 u_sourceColor;\n vec4 u_targetColor;\n vec2 u_textSize;\n float u_icon_step: 100;\n float u_heightfixed: 0.0;\n float u_vertexScale: 1.0;\n float u_raisingHeight: 0.0;\n float u_strokeWidth: 0.0;\n float u_textureBlend;\n float u_line_texture;\n float u_linearDir: 1.0;\n float u_linearColor: 0;\n float u_time;\n};\n\nin vec4 v_color;\nin vec4 v_stroke;\n// dash\nin vec4 v_dash_array;\nin float v_d_distance_ratio;\nin vec2 v_iconMapUV;\nin vec4 v_texture_data;\n\nout vec4 outputColor;\n#pragma include \"picking\"\n\n// [animate, duration, interval, trailLength],\nvoid main() {\n if(u_dash_array!=vec4(0.0)){\n float dashLength = mod(v_d_distance_ratio, v_dash_array.x + v_dash_array.y + v_dash_array.z + v_dash_array.w);\n if(!(dashLength < v_dash_array.x || (dashLength > (v_dash_array.x + v_dash_array.y) && dashLength < v_dash_array.x + v_dash_array.y + v_dash_array.z))) {\n // \u865A\u7EBF\u90E8\u5206\n discard;\n };\n }\n float animateSpeed = 0.0; // \u8FD0\u52A8\u901F\u5EA6\n float d_distance_ratio = v_texture_data.r; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n if(u_linearDir < 1.0) {\n d_distance_ratio = v_texture_data.a;\n }\n if(u_linearColor == 1.0) { // \u4F7F\u7528\u6E10\u53D8\u989C\u8272\n outputColor = mix(u_sourceColor, u_targetColor, d_distance_ratio);\n outputColor.a *= v_color.a;\n } else { // \u4F7F\u7528 color \u65B9\u6CD5\u4F20\u5165\u7684\u989C\u8272\n outputColor = v_color;\n }\n // anti-alias\n // float blur = 1.0 - smoothstep(u_blur, 1., length(v_normal.xy));\n if(u_animate.x == Animate) {\n animateSpeed = u_time / u_animate.y;\n float alpha =1.0 - fract( mod(1.0- d_distance_ratio, u_animate.z)* (1.0/ u_animate.z) + animateSpeed);\n alpha = (alpha + u_animate.w -1.0) / u_animate.w;\n alpha = smoothstep(0., 1., alpha);\n outputColor.a *= alpha;\n }\n\n if(u_line_texture == LineTexture) { // while load texture\n float aDistance = v_texture_data.g; // \u5F53\u524D\u9876\u70B9\u7684\u8DDD\u79BB\n float d_texPixelLen = v_texture_data.b; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n float u = fract(mod(aDistance, d_texPixelLen)/d_texPixelLen - animateSpeed);\n float v = v_texture_data.a; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n // v = max(smoothstep(0.95, 1.0, v), v);\n vec2 uv= v_iconMapUV / u_textSize + vec2(u, v) / u_textSize * 64.;\n vec4 pattern = texture(SAMPLER_2D(u_texture), uv);\n\n if(u_textureBlend == 0.0) { // normal\n pattern.a = 0.0;\n outputColor += pattern;\n } else { // replace\n pattern.a *= v_color.a;\n if(outputColor.a <= 0.0) {\n pattern.a = 0.0;\n }\n outputColor = pattern;\n }\n } \n\n float v = v_texture_data.a;\n float strokeWidth = min(0.5, u_strokeWidth);\n // \u7ED8\u5236 border\n if(strokeWidth > 0.01) {\n float borderOuterWidth = strokeWidth / 2.0;\n\n\n if(v >= 1.0 - strokeWidth || v <= strokeWidth) {\n if(v > strokeWidth) { // \u5916\u4FA7\n float linear = smoothstep(0.0, 1.0, (v - (1.0 - strokeWidth))/strokeWidth);\n // float linear = step(0.0, (v - (1.0 - borderWidth))/borderWidth);\n outputColor.rgb = mix(outputColor.rgb, v_stroke.rgb, linear);\n } else if(v <= strokeWidth) {\n float linear = smoothstep(0.0, 1.0, v/strokeWidth);\n outputColor.rgb = mix(v_stroke.rgb, outputColor.rgb, linear);\n }\n }\n\n if(v < borderOuterWidth) {\n outputColor.a = mix(0.0, outputColor.a, v/borderOuterWidth);\n } else if(v > 1.0 - borderOuterWidth) {\n outputColor.a = mix(outputColor.a, 0.0, (v - (1.0 - borderOuterWidth))/borderOuterWidth);\n }\n }\n\n // blur\n float blurV = v_texture_data.a;\n if(blurV < 0.5) {\n outputColor.a *= mix(u_blur.r, u_blur.g, blurV/0.5);\n } else {\n outputColor.a *= mix(u_blur.g, u_blur.b, (blurV - 0.5)/0.5);\n }\n \n outputColor = filterColor(outputColor);\n}\n";
|
|
26
27
|
/* babel-plugin-inline-import '../shaders/line/line_vert.glsl' */
|
|
27
|
-
var line_vert = "\n#define Animate 0.0\n\nlayout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location =
|
|
28
|
+
var line_vert = "\n#define Animate 0.0\n\nlayout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in vec2 a_Size;\nlayout(location = 10) in vec3 a_DistanceAndIndexAndMiter;\nlayout(location = 13) in vec4 a_Normal_Total_Distance;\nlayout(location = 14) in vec2 a_iconMapUV;\n\nlayout(std140) uniform commonUniorm {\n vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\n vec4 u_dash_array;\n vec4 u_blur;\n vec4 u_sourceColor;\n vec4 u_targetColor;\n vec2 u_textSize;\n float u_icon_step: 100;\n float u_heightfixed: 0.0;\n float u_vertexScale: 1.0;\n float u_raisingHeight: 0.0;\n float u_strokeWidth: 0.0;\n float u_textureBlend;\n float u_line_texture;\n float u_linearDir: 1.0;\n float u_linearColor: 0;\n float u_time;\n};\n\n\nout vec4 v_color;\nout vec4 v_stroke;\n//dash\nout vec4 v_dash_array;\nout float v_d_distance_ratio;\n// texV \u7EBF\u56FE\u5C42 - \u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\uFF08\u7EBF\u7684\u5BBD\u5EA6\u65B9\u5411\uFF09\nout vec2 v_iconMapUV;\nout vec4 v_texture_data;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n vec2 a_DistanceAndIndex = a_DistanceAndIndexAndMiter.xy;\n float a_Miter = a_DistanceAndIndexAndMiter.z;\n vec3 a_Normal = a_Normal_Total_Distance.xyz;\n float a_Total_Distance = a_Normal_Total_Distance.w;\n //dash\u8F93\u51FA\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / a_Total_Distance;\n v_d_distance_ratio = a_DistanceAndIndex.x / a_Total_Distance;\n\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n float d_texPixelLen; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n v_iconMapUV = a_iconMapUV;\n d_texPixelLen = project_float_pixel(u_icon_step);\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n d_texPixelLen *= 10.0;\n }\n\n v_color = a_Color;\n v_color.a *= opacity;\n v_stroke = stroke;\n\n vec3 size = a_Miter * setPickingSize(a_Size.x) * reverse_offset_normal(a_Normal);\n \n vec2 offset = project_pixel(size.xy);\n\n float lineDistance = a_DistanceAndIndex.x;\n float currentLinePointRatio = lineDistance / a_Total_Distance;\n \n\n float lineOffsetWidth = length(offset + offset * sign(a_Miter)); // \u7EBF\u6A2A\u5411\u504F\u79FB\u7684\u8DDD\u79BB\uFF08\u5411\u4E24\u4FA7\u504F\u79FB\u7684\u548C\uFF09\n float linePixelSize = project_pixel(a_Size.x) * 2.0; // \u5B9A\u70B9\u4F4D\u7F6E\u504F\u79FB\uFF0C\u6309\u5730\u56FE\u7B49\u7EA7\u7F29\u653E\u540E\u7684\u8DDD\u79BB \u5355\u4FA7 * 2\n float texV = lineOffsetWidth/linePixelSize; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n \n v_texture_data = vec4(currentLinePointRatio, lineDistance, d_texPixelLen, texV);\n // \u8BBE\u7F6E\u6570\u636E\u96C6\u7684\u53C2\u6570\n\n vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));\n\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, a_Size.y, 1.0));\n\n float h = float(a_Position.z) * u_vertexScale; // \u7EBF\u9876\u70B9\u7684\u9AD8\u5EA6 - \u517C\u5BB9\u4E0D\u5B58\u5728\u7B2C\u4E09\u4E2A\u6570\u503C\u7684\u60C5\u51B5 vertex height\n float lineHeight = a_Size.y; // size \u7B2C\u4E8C\u4E2A\u53C2\u6570\u4EE3\u8868\u7684\u9AD8\u5EA6 [linewidth, lineheight]\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n lineHeight *= 0.2; // \u4FDD\u6301\u548C amap/mapbox \u4E00\u81F4\u7684\u6548\u679C\n h *= 0.2;\n if(u_heightfixed < 1.0) {\n lineHeight = project_pixel(a_Size.y);\n }\n gl_Position = u_Mvp * (vec4(project_pos.xy + offset, lineHeight + h + u_raisingHeight, 1.0));\n } else {\n // mapbox - amap\n \n // \u517C\u5BB9 mapbox \u5728\u7EBF\u9AD8\u5EA6\u4E0A\u7684\u6548\u679C\u8868\u73B0\u57FA\u672C\u4E00\u81F4\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // mapbox\n // \u4FDD\u6301\u9AD8\u5EA6\u76F8\u5BF9\u4E0D\u53D8\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n h *= mapboxZoomScale;\n h += u_raisingHeight * mapboxZoomScale;\n if(u_heightfixed > 0.0) {\n lineHeight *= mapboxZoomScale;\n }\n \n } else {\n // amap\n h += u_raisingHeight;\n // lineHeight \u9876\u70B9\u504F\u79FB\u9AD8\u5EA6\n if(u_heightfixed < 1.0) {\n lineHeight *= pow(2.0, 20.0 - u_Zoom);\n }\n }\n\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, lineHeight + h, 1.0));\n }\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
28
29
|
var lineStyleObj = {
|
|
29
30
|
solid: 0.0,
|
|
30
31
|
dash: 1.0
|
|
@@ -240,7 +241,7 @@ var LineModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
|
240
241
|
name: 'distanceAndIndex',
|
|
241
242
|
type: _l7Core.AttributeType.Attribute,
|
|
242
243
|
descriptor: {
|
|
243
|
-
name: '
|
|
244
|
+
name: 'a_DistanceAndIndexAndMiter',
|
|
244
245
|
shaderLocation: 10,
|
|
245
246
|
buffer: {
|
|
246
247
|
// give the WebGL driver a hint that this buffer may change
|
|
@@ -248,27 +249,9 @@ var LineModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
|
248
249
|
data: [],
|
|
249
250
|
type: _l7Core.gl.FLOAT
|
|
250
251
|
},
|
|
251
|
-
size:
|
|
252
|
+
size: 3,
|
|
252
253
|
update: function update(feature, featureIdx, vertex, attributeIdx, normal, vertexIndex) {
|
|
253
|
-
return vertexIndex === undefined ? [vertex[3], 10] : [vertex[3], vertexIndex];
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
});
|
|
257
|
-
this.styleAttributeService.registerStyleAttribute({
|
|
258
|
-
name: 'total_distance',
|
|
259
|
-
type: _l7Core.AttributeType.Attribute,
|
|
260
|
-
descriptor: {
|
|
261
|
-
name: 'a_Total_Distance',
|
|
262
|
-
shaderLocation: 11,
|
|
263
|
-
buffer: {
|
|
264
|
-
// give the WebGL driver a hint that this buffer may change
|
|
265
|
-
usage: _l7Core.gl.STATIC_DRAW,
|
|
266
|
-
data: [],
|
|
267
|
-
type: _l7Core.gl.FLOAT
|
|
268
|
-
},
|
|
269
|
-
size: 1,
|
|
270
|
-
update: function update(feature, featureIdx, vertex) {
|
|
271
|
-
return [vertex[5]];
|
|
254
|
+
return vertexIndex === undefined ? [vertex[3], 10, vertex[4]] : [vertex[3], vertexIndex, vertex[4]];
|
|
272
255
|
}
|
|
273
256
|
}
|
|
274
257
|
});
|
|
@@ -295,10 +278,10 @@ var LineModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
|
295
278
|
|
|
296
279
|
// point layer size;
|
|
297
280
|
this.styleAttributeService.registerStyleAttribute({
|
|
298
|
-
name: '
|
|
281
|
+
name: 'normal_total_distance',
|
|
299
282
|
type: _l7Core.AttributeType.Attribute,
|
|
300
283
|
descriptor: {
|
|
301
|
-
name: '
|
|
284
|
+
name: 'a_Normal_Total_Distance',
|
|
302
285
|
shaderLocation: _CommonStyleAttribute.ShaderLocation.NORMAL,
|
|
303
286
|
buffer: {
|
|
304
287
|
// give the WebGL driver a hint that this buffer may change
|
|
@@ -306,27 +289,9 @@ var LineModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
|
306
289
|
data: [],
|
|
307
290
|
type: _l7Core.gl.FLOAT
|
|
308
291
|
},
|
|
309
|
-
size:
|
|
292
|
+
size: 4,
|
|
310
293
|
update: function update(feature, featureIdx, vertex, attributeIdx, normal) {
|
|
311
|
-
return normal;
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
});
|
|
315
|
-
this.styleAttributeService.registerStyleAttribute({
|
|
316
|
-
name: 'miter',
|
|
317
|
-
type: _l7Core.AttributeType.Attribute,
|
|
318
|
-
descriptor: {
|
|
319
|
-
shaderLocation: 15,
|
|
320
|
-
name: 'a_Miter',
|
|
321
|
-
buffer: {
|
|
322
|
-
// give the WebGL driver a hint that this buffer may change
|
|
323
|
-
usage: _l7Core.gl.STATIC_DRAW,
|
|
324
|
-
data: [],
|
|
325
|
-
type: _l7Core.gl.FLOAT
|
|
326
|
-
},
|
|
327
|
-
size: 1,
|
|
328
|
-
update: function update(feature, featureIdx, vertex) {
|
|
329
|
-
return [vertex[4]];
|
|
294
|
+
return [].concat((0, _toConsumableArray2.default)(normal), [vertex[5]]);
|
|
330
295
|
}
|
|
331
296
|
}
|
|
332
297
|
});
|
|
@@ -24,11 +24,11 @@ layout(std140) uniform commonUniorm {
|
|
|
24
24
|
|
|
25
25
|
in vec4 v_color;
|
|
26
26
|
in vec4 v_stroke;
|
|
27
|
-
in vec2 v_iconMapUV;
|
|
28
|
-
in vec4 v_texture_data;
|
|
29
27
|
// dash
|
|
30
28
|
in vec4 v_dash_array;
|
|
31
29
|
in float v_d_distance_ratio;
|
|
30
|
+
in vec2 v_iconMapUV;
|
|
31
|
+
in vec4 v_texture_data;
|
|
32
32
|
|
|
33
33
|
out vec4 outputColor;
|
|
34
34
|
#pragma include "picking"
|
|
@@ -3,11 +3,9 @@
|
|
|
3
3
|
|
|
4
4
|
layout(location = 0) in vec3 a_Position;
|
|
5
5
|
layout(location = 1) in vec4 a_Color;
|
|
6
|
-
layout(location = 10) in vec2 a_DistanceAndIndex;
|
|
7
6
|
layout(location = 9) in vec2 a_Size;
|
|
8
|
-
layout(location =
|
|
9
|
-
layout(location = 13) in
|
|
10
|
-
layout(location = 15) in float a_Miter;
|
|
7
|
+
layout(location = 10) in vec3 a_DistanceAndIndexAndMiter;
|
|
8
|
+
layout(location = 13) in vec4 a_Normal_Total_Distance;
|
|
11
9
|
layout(location = 14) in vec2 a_iconMapUV;
|
|
12
10
|
|
|
13
11
|
layout(std140) uniform commonUniorm {
|
|
@@ -28,20 +26,25 @@ layout(std140) uniform commonUniorm {
|
|
|
28
26
|
float u_linearColor: 0;
|
|
29
27
|
float u_time;
|
|
30
28
|
};
|
|
31
|
-
|
|
32
|
-
#pragma include "picking"
|
|
29
|
+
|
|
33
30
|
|
|
34
31
|
out vec4 v_color;
|
|
35
32
|
out vec4 v_stroke;
|
|
36
33
|
//dash
|
|
37
34
|
out vec4 v_dash_array;
|
|
38
35
|
out float v_d_distance_ratio;
|
|
39
|
-
|
|
40
36
|
// texV 线图层 - 贴图部分的 v 坐标(线的宽度方向)
|
|
41
37
|
out vec2 v_iconMapUV;
|
|
42
38
|
out vec4 v_texture_data;
|
|
43
39
|
|
|
40
|
+
#pragma include "projection"
|
|
41
|
+
#pragma include "picking"
|
|
42
|
+
|
|
44
43
|
void main() {
|
|
44
|
+
vec2 a_DistanceAndIndex = a_DistanceAndIndexAndMiter.xy;
|
|
45
|
+
float a_Miter = a_DistanceAndIndexAndMiter.z;
|
|
46
|
+
vec3 a_Normal = a_Normal_Total_Distance.xyz;
|
|
47
|
+
float a_Total_Distance = a_Normal_Total_Distance.w;
|
|
45
48
|
//dash输出
|
|
46
49
|
v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / a_Total_Distance;
|
|
47
50
|
v_d_distance_ratio = a_DistanceAndIndex.x / a_Total_Distance;
|
|
@@ -73,9 +73,10 @@ var ShaderUniformPlugin = exports.default = (_dec = (0, _inversify.injectable)()
|
|
|
73
73
|
var _this$generateUBO = _this.generateUBO(mvp, sceneCenterMercator, width, height),
|
|
74
74
|
data = _this$generateUBO.data,
|
|
75
75
|
uniforms = _this$generateUBO.uniforms;
|
|
76
|
-
if (_this.layerService.alreadyInRendering &&
|
|
76
|
+
if (_this.layerService.alreadyInRendering && _this.rendererService.uniformBuffers[0]) {
|
|
77
|
+
var renderUniformBuffer = _this.rendererService.uniformBuffers[0];
|
|
77
78
|
// Update only once since all models can share one UBO.
|
|
78
|
-
|
|
79
|
+
renderUniformBuffer.subData({
|
|
79
80
|
offset: 0,
|
|
80
81
|
data: data
|
|
81
82
|
});
|
|
@@ -22,9 +22,9 @@ var _triangulation = require("../../core/triangulation");
|
|
|
22
22
|
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); }; }
|
|
23
23
|
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; } }
|
|
24
24
|
/* babel-plugin-inline-import '../shaders/extrude/extrude_frag.glsl' */
|
|
25
|
-
var pointExtrudeFrag = "\nin vec4 v_color;\nin float v_lightWeight;\nout vec4 outputColor;\n\nlayout(std140) uniform commonUniforms {\n float u_pickLight;\n float u_heightfixed;\n float u_r;\n float u_linearColor;\n vec4 u_sourceColor;\n vec4 u_targetColor;\n float u_opacitylinear;\n float u_opacitylinear_dir;\n float u_lightEnable;\n};\n\n#pragma include \"picking\"\n\nvoid main() {\n\n outputColor = v_color;\n // \u5F00\u542F\u900F\u660E\u5EA6\u6E10\u53D8\n // picking\n if(u_pickLight > 0.0) {\n outputColor = filterColorAlpha(outputColor, v_lightWeight);\n } else {\n outputColor = filterColor(outputColor);\n }\n}\n";
|
|
25
|
+
var pointExtrudeFrag = "\nin vec4 v_color;\nin float v_lightWeight;\nout vec4 outputColor;\n\nlayout(std140) uniform commonUniforms {\n float u_pickLight;\n float u_heightfixed;\n float u_r;\n float u_linearColor;\n vec4 u_sourceColor;\n vec4 u_targetColor;\n float u_opacitylinear;\n float u_opacitylinear_dir;\n float u_lightEnable;\n};\n\n#pragma include \"scene_uniforms\"\n#pragma include \"picking\"\n\nvoid main() {\n\n outputColor = v_color;\n // \u5F00\u542F\u900F\u660E\u5EA6\u6E10\u53D8\n // picking\n if(u_pickLight > 0.0) {\n outputColor = filterColorAlpha(outputColor, v_lightWeight);\n } else {\n outputColor = filterColor(outputColor);\n }\n}\n";
|
|
26
26
|
/* babel-plugin-inline-import '../shaders/extrude/extrude_vert.glsl' */
|
|
27
|
-
var pointExtrudeVert = "#define pi 3.1415926535\n\nlayout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in vec3 a_Size;\nlayout(location = 11) in vec3 a_Extrude;\nlayout(location = 13) in vec3 a_Normal;\n\nlayout(std140) uniform commonUniforms {\n float u_pickLight;\n float u_heightfixed;\n float u_r;\n float u_linearColor;\n vec4 u_sourceColor;\n vec4 u_targetColor;\n float u_opacitylinear;\n float u_opacitylinear_dir;\n float u_lightEnable;\n};\nout vec4 v_color;\nout float v_lightWeight;\
|
|
27
|
+
var pointExtrudeVert = "#define pi 3.1415926535\n\nlayout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in vec3 a_Size;\nlayout(location = 11) in vec3 a_Extrude;\nlayout(location = 13) in vec3 a_Normal;\n\nlayout(std140) uniform commonUniforms {\n float u_pickLight;\n float u_heightfixed;\n float u_r;\n float u_linearColor;\n vec4 u_sourceColor;\n vec4 u_targetColor;\n float u_opacitylinear;\n float u_opacitylinear_dir;\n float u_lightEnable;\n};\nout vec4 v_color;\nout float v_lightWeight;\n\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\nfloat getYRadian(float x, float z) {\n if(x > 0.0 && z > 0.0) {\n return atan(x/z);\n } else if(x > 0.0 && z <= 0.0){\n return atan(-z/x) + pi/2.0;\n } else if(x <= 0.0 && z <= 0.0) {\n return pi + atan(x/z); //atan(x/z) + \n } else {\n return atan(z/-x) + pi*3.0/2.0;\n }\n}\n\nfloat getXRadian(float y, float r) {\n return atan(y/r);\n}\n\nvoid main() {\n\n\n vec3 size = a_Size * a_Position;\n\n vec3 offset = size; // \u63A7\u5236\u5706\u67F1\u4F53\u7684\u5927\u5C0F - \u4ECE\u6807\u51C6\u5355\u4F4D\u5706\u67F1\u4F53\u8FDB\u884C\u504F\u79FB\n\n if(u_heightfixed < 1.0) { // \u5706\u67F1\u4F53\u4E0D\u56FA\u5B9A\u9AD8\u5EA6\n \n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20 || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n // P20 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF1\n offset = offset * pow(2.0, (19.0 - u_Zoom));\n }\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n // P20_2 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF3\n offset = offset * pow(2.0, (19.0 - 3.0 - u_Zoom));\n }\n } else {// \u5706\u67F1\u4F53\u56FA\u5B9A\u9AD8\u5EA6 \uFF08 \u5904\u7406 mapbox \uFF09\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n offset *= 4.0/pow(2.0, 21.0 - u_Zoom);\n }\n }\n\n\n vec4 project_pos = project_position(vec4(a_Extrude.xy, 0., 1.0));\n\n // u_r \u63A7\u5236\u5706\u67F1\u7684\u751F\u957F\n vec4 pos = vec4(project_pos.xy + offset.xy, offset.z * u_r, 1.0);\n\n // // \u5706\u67F1\u5149\u7167\u6548\u679C\n float lightWeight = 1.0;\n\n if(u_lightEnable > 0.0) { // \u53D6\u6D88\u4E09\u5143\u8868\u8FBE\u5F0F\uFF0C\u589E\u5F3A\u5065\u58EE\u6027\n lightWeight = calc_lighting(pos);\n }\n\n v_lightWeight = lightWeight;\n\n v_color = a_Color;\n\n // \u8BBE\u7F6E\u5706\u67F1\u7684\u5E95\u8272\n if(u_linearColor == 1.0) { // \u4F7F\u7528\u6E10\u53D8\u989C\u8272\n v_color = mix(u_sourceColor, u_targetColor, a_Position.z);\n v_color.a = v_color.a * opacity;\n } else {\n v_color = vec4(a_Color.rgb * lightWeight, a_Color.w * opacity);\n }\n\n if(u_opacitylinear > 0.0) {\n v_color.a *= u_opacitylinear_dir > 0.0 ? (1.0 - a_Position.z): a_Position.z;\n }\n\n\n gl_Position = project_common_position_to_clipspace_v2(pos);\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
28
28
|
var ExtrudeModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
29
29
|
(0, _inherits2.default)(ExtrudeModel, _BaseModel);
|
|
30
30
|
var _super = _createSuper(ExtrudeModel);
|
package/lib/point/models/fill.js
CHANGED
|
@@ -20,7 +20,7 @@ var _interface = require("../../core/interface");
|
|
|
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/fill/fill_frag.glsl' */
|
|
23
|
-
var pointFillFrag = "
|
|
23
|
+
var pointFillFrag = "\nlayout(std140) uniform commonUniforms {\n vec3 u_blur_height_fixed;\n float u_stroke_width;\n float u_additive;\n float u_stroke_opacity;\n float u_size_unit;\n float u_time;\n vec4 u_animate;\n};\n\nin vec4 v_color;\nin vec4 v_stroke;\nin vec4 v_data;\nin float v_radius;\n\n#pragma include \"scene_uniforms\"\n#pragma include \"sdf_2d\"\n#pragma include \"picking\"\n\nout vec4 outputColor;\n\nvoid main() {\n int shape = int(floor(v_data.w + 0.5));\n lowp float antialiasblur = v_data.z;\n float r = v_radius / (v_radius + u_stroke_width);\n\n float outer_df;\n float inner_df;\n // 'circle', 'triangle', 'square', 'pentagon', 'hexagon', 'octogon', 'hexagram', 'rhombus', 'vesica'\n if (shape == 0) {\n outer_df = sdCircle(v_data.xy, 1.0);\n inner_df = sdCircle(v_data.xy, r);\n } else if (shape == 1) {\n outer_df = sdEquilateralTriangle(1.1 * v_data.xy);\n inner_df = sdEquilateralTriangle(1.1 / r * v_data.xy);\n } else if (shape == 2) {\n outer_df = sdBox(v_data.xy, vec2(1.));\n inner_df = sdBox(v_data.xy, vec2(r));\n } else if (shape == 3) {\n outer_df = sdPentagon(v_data.xy, 0.8);\n inner_df = sdPentagon(v_data.xy, r * 0.8);\n } else if (shape == 4) {\n outer_df = sdHexagon(v_data.xy, 0.8);\n inner_df = sdHexagon(v_data.xy, r * 0.8);\n } else if (shape == 5) {\n outer_df = sdOctogon(v_data.xy, 1.0);\n inner_df = sdOctogon(v_data.xy, r);\n } else if (shape == 6) {\n outer_df = sdHexagram(v_data.xy, 0.52);\n inner_df = sdHexagram(v_data.xy, r * 0.52);\n } else if (shape == 7) {\n outer_df = sdRhombus(v_data.xy, vec2(1.0));\n inner_df = sdRhombus(v_data.xy, vec2(r));\n } else if (shape == 8) {\n outer_df = sdVesica(v_data.xy, 1.1, 0.8);\n inner_df = sdVesica(v_data.xy, r * 1.1, r * 0.8);\n }\n\n float opacity_t = smoothstep(0.0, antialiasblur, outer_df);\n\n float color_t = u_stroke_width < 0.01 ? 0.0 : smoothstep(\n antialiasblur,\n 0.0,\n inner_df\n );\n\n float PI = 3.14159;\n float N_RINGS = 3.0;\n float FREQ = 1.0;\n\n if(u_stroke_width < 0.01) {\n outputColor = v_color;\n } else {\n outputColor = mix(v_color, v_stroke * u_stroke_opacity, color_t);\n }\n float intensity = 1.0;\n if(u_time!=-1.0){\n //wave\u76F8\u5173\u903B\u8F91\n float d = length(v_data.xy);\n if(d > 0.5) {\n discard;\n }\n intensity = clamp(cos(d * PI), 0.0, 1.0) * clamp(cos(2.0 * PI * (d * 2.0 * u_animate.z - u_animate.y * u_time)), 0.0, 1.0);\n }\n\n if(u_additive > 0.0) {\n outputColor *= opacity_t;\n outputColor *= intensity;//wave\n outputColor = filterColorAlpha(outputColor, outputColor.a);\n } else {\n outputColor.a *= opacity_t;\n outputColor.a *= intensity;//wave \n outputColor = filterColor(outputColor);\n }\n // \u4F5C\u4E3A mask \u6A21\u677F\u65F6\u9700\u8981\u4E22\u5F03\u900F\u660E\u7684\u50CF\u7D20\n if(outputColor.a < 0.01) {\n discard;\n } \n}\n";
|
|
24
24
|
/* babel-plugin-inline-import '../shaders/fill/fill_vert.glsl' */
|
|
25
25
|
var pointFillVert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in float a_Size;\nlayout(location = 10) in float a_Shape;\nlayout(location = 11) in vec3 a_Extrude;\n\nlayout(std140) uniform commonUniforms {\n vec3 u_blur_height_fixed;\n float u_stroke_width;\n float u_additive;\n float u_stroke_opacity;\n float u_size_unit;\n float u_time;\n vec4 u_animate; \n};\n\nout vec4 v_color;\nout vec4 v_stroke;\nout vec4 v_data;\nout float v_radius;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n#pragma include \"rotation_2d\"\n\nvoid main() {\n // \u900F\u660E\u5EA6\u8BA1\u7B97\n v_stroke = stroke; \n vec3 extrude = a_Extrude;\n float shape_type = a_Shape;\n /*\n * setPickingSize \u8BBE\u7F6E\u62FE\u53D6\u5927\u5C0F\n * u_meter2coord \u5728\u7B49\u9762\u79EF\u5927\u5C0F\u7684\u65F6\u5019\u8BBE\u7F6E\u5355\u4F4D\n */\n float newSize = setPickingSize(a_Size);\n // float newSize = setPickingSize(a_Size) * 0.00001038445708445579;\n\n\n\n // unpack color(vec2)\n v_color = vec4(a_Color.xyz, a_Color.w * opacity);\n\n if(u_size_unit == 1.0) {\n newSize = newSize * u_PixelsPerMeter.z;\n }\n\n v_radius = newSize;\n\n // anti-alias\n // float antialiased_blur = -max(u_blur, antialiasblur);\n float antialiasblur = -max(2.0 / u_DevicePixelRatio / newSize, u_blur_height_fixed.x);\n\n vec2 offset = (extrude.xy * (newSize + u_stroke_width) + u_offsets);\n vec3 aPosition = a_Position;\n\n offset = project_pixel(offset);\n offset = rotate_matrix(offset,rotation);\n \n // TODP: /abs(extrude.x) \u662F\u4E3A\u4E86\u517C\u5BB9\u5730\u7403\u6A21\u5F0F\n v_data = vec4(extrude.x/abs(extrude.x), extrude.y/abs(extrude.y), antialiasblur,shape_type);\n\n\n // vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0));\n vec4 project_pos = project_position(vec4(aPosition.xy, 0.0, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, project_pixel(setPickingOrder(0.0)), 1.0));\n\n float raisingHeight = u_blur_height_fixed.y;\n\n if(u_blur_height_fixed.z < 1.0) { // false\n raisingHeight = project_pixel(u_blur_height_fixed.y);\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_blur_height_fixed.y * mapboxZoomScale;\n }\n }\n \n gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xy + offset, raisingHeight, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
26
26
|
var FillModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
@@ -23,7 +23,7 @@ var _CommonStyleAttribute = require("../../core/CommonStyleAttribute");
|
|
|
23
23
|
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); }; }
|
|
24
24
|
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; } } // static pointLayer shader - not support animate
|
|
25
25
|
/* babel-plugin-inline-import '../shaders/fillImage/fillImage_frag.glsl' */
|
|
26
|
-
var pointFillFrag = "in
|
|
26
|
+
var pointFillFrag = "in vec2 v_uv;// \u672C\u8EAB\u7684 uv \u5750\u6807\nin vec2 v_Iconuv;\nin float v_opacity;\nout vec4 outputColor;\n\nuniform sampler2D u_texture;\nlayout(std140) uniform commonUniform {\n vec2 u_textSize;\n float u_heightfixed: 0.0;\n float u_raisingHeight: 0.0;\n float u_size_unit;\n};\n\n#pragma include \"scene_uniforms\"\n#pragma include \"sdf_2d\"\n#pragma include \"picking\"\n\nvoid main() {\n vec2 pos = v_Iconuv / u_textSize + v_uv / u_textSize * 64.;\n outputColor = texture(SAMPLER_2D(u_texture), pos);\n outputColor.a *= v_opacity;\n outputColor = filterColor(outputColor);\n}\n";
|
|
27
27
|
/* babel-plugin-inline-import '../shaders/fillImage/fillImage_vert.glsl' */
|
|
28
28
|
var pointFillVert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in float a_Size;\nlayout(location = 11) in vec3 a_Extrude;\nlayout(location = 14) in vec2 a_Uv;\n\nlayout(std140) uniform commonUniform {\n vec2 u_textSize;\n float u_heightfixed: 0.0;\n float u_raisingHeight: 0.0;\n float u_size_unit;\n};\n\nout vec2 v_uv;\nout vec2 v_Iconuv;\nout float v_opacity;\n\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n#pragma include \"rotation_2d\"\n\nvoid main() {\n vec3 extrude = a_Extrude;\n v_uv = (a_Extrude.xy + 1.0)/2.0;\n v_uv.y = 1.0 - v_uv.y;\n v_Iconuv = a_Uv;\n v_opacity = opacity;\n float newSize = a_Size;\n if(u_size_unit == 1.0) {\n newSize = newSize * u_PixelsPerMeter.z;\n }\n \n // vec2 offset = (u_RotateMatrix * extrude.xy * (a_Size) + textrueOffsets);\n vec2 offset = (extrude.xy * (newSize) + offsets);\n\n offset = rotate_matrix(offset,rotation);\n\n vec3 aPosition = a_Position;\n\n offset = project_pixel(offset);\n\n vec4 project_pos = project_position(vec4(aPosition.xy, 0.0, 1.0));\n float raisingHeight = u_raisingHeight;\n if(u_heightfixed < 1.0) { // height fixed\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 gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xy + offset, 0.0, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
29
29
|
var FillImageModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
@@ -92,10 +92,8 @@ var FillImageModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
|
92
92
|
u_textSize: [1024, this.iconService.canvasHeight || 128],
|
|
93
93
|
u_heightfixed: Number(heightfixed),
|
|
94
94
|
u_raisingHeight: Number(raisingHeight),
|
|
95
|
-
u_size_unit: _interface.SizeUnitType[unit]
|
|
96
|
-
|
|
97
|
-
};
|
|
98
|
-
this.textures = [this.texture];
|
|
95
|
+
u_size_unit: _interface.SizeUnitType[unit]
|
|
96
|
+
}; //2+1+1+1
|
|
99
97
|
var commonBufferInfo = this.getUniformsBufferInfo(commonOptions);
|
|
100
98
|
return commonBufferInfo;
|
|
101
99
|
}
|
package/lib/point/models/text.js
CHANGED
|
@@ -29,9 +29,9 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
29
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); }; }
|
|
30
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; } }
|
|
31
31
|
/* babel-plugin-inline-import '../shaders/text/text_frag.glsl' */
|
|
32
|
-
var textFrag = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 48.0\n\nuniform sampler2D u_sdf_map;\nlayout(std140) uniform commonUniforms {\n vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\n vec2 u_sdf_map_size;\n float u_raisingHeight: 0.0;\n float u_stroke_width : 2;\n float u_gamma_scale : 0.5;\n float u_halo_blur : 0.5;\n};\n\nin
|
|
32
|
+
var textFrag = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 48.0\n\nuniform sampler2D u_sdf_map;\nlayout(std140) uniform commonUniforms {\n vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\n vec2 u_sdf_map_size;\n float u_raisingHeight: 0.0;\n float u_stroke_width : 2;\n float u_gamma_scale : 0.5;\n float u_halo_blur : 0.5;\n};\n\nin vec2 v_uv;\nin float v_gamma_scale;\nin vec4 v_color;\nin vec4 v_stroke_color;\nin float v_fontScale;\n\nout vec4 outputColor;\n\n#pragma include \"picking\"\nvoid main() {\n // get style data mapping\n\n // get sdf from atlas\n float dist = texture(SAMPLER_2D(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 outputColor = mix(v_color, v_stroke_color, smoothstep(0., 0.5, 1.- dist));\n\n outputColor.a *= alpha;\n // \u4F5C\u4E3A mask \u6A21\u677F\u65F6\u9700\u8981\u4E22\u5F03\u900F\u660E\u7684\u50CF\u7D20\n if (outputColor.a < 0.01) {\n discard;\n }\n outputColor = filterColor(outputColor);\n}\n";
|
|
33
33
|
/* babel-plugin-inline-import '../shaders/text/text_vert.glsl' */
|
|
34
|
-
var textVert = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 24.0\n\nlayout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in float a_Size;\nlayout(location = 10) in vec2 a_textOffsets;\nlayout(location = 14) in vec2 a_tex;\n\nlayout(std140) uniform commonUniforms {\n vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\n vec2 u_sdf_map_size;\n float u_raisingHeight: 0.0;\n float u_stroke_width : 2;\n float u_gamma_scale : 0.5;\n float u_halo_blur : 0.5;\n};\n\nout vec2 v_uv;\nout float v_gamma_scale;\nout vec4 v_color;\nout vec4 v_stroke_color;\nout float v_fontScale;\n\n
|
|
34
|
+
var textVert = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 24.0\n\nlayout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in float a_Size;\nlayout(location = 10) in vec2 a_textOffsets;\nlayout(location = 14) in vec2 a_tex;\n\nlayout(std140) uniform commonUniforms {\n vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\n vec2 u_sdf_map_size;\n float u_raisingHeight: 0.0;\n float u_stroke_width : 2;\n float u_gamma_scale : 0.5;\n float u_halo_blur : 0.5;\n};\n\nout vec2 v_uv;\nout float v_gamma_scale;\nout vec4 v_color;\nout vec4 v_stroke_color;\nout float v_fontScale;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n#pragma include \"rotation_2d\"\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 vec2 offset = rotate_matrix(a_textOffsets,rotation);\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 = project_common_position_to_clipspace_v2(vec4(project_pos.xyz + vec3(0.0, 0.0, raiseHeight), 1.0));\n\n gl_Position = vec4(\n projected_position.xy / projected_position.w + offset * 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";
|
|
35
35
|
var isEqual = _l7Utils.lodashUtil.isEqual;
|
|
36
36
|
function TextTrianglation(feature) {
|
|
37
37
|
// @ts-ignore
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
in vec4 v_color;
|
|
2
1
|
in vec2 v_uv;// 本身的 uv 坐标
|
|
3
2
|
in vec2 v_Iconuv;
|
|
4
3
|
in float v_opacity;
|
|
@@ -12,10 +11,10 @@ layout(std140) uniform commonUniform {
|
|
|
12
11
|
float u_size_unit;
|
|
13
12
|
};
|
|
14
13
|
|
|
14
|
+
#pragma include "scene_uniforms"
|
|
15
15
|
#pragma include "sdf_2d"
|
|
16
16
|
#pragma include "picking"
|
|
17
17
|
|
|
18
|
-
|
|
19
18
|
void main() {
|
|
20
19
|
vec2 pos = v_Iconuv / u_textSize + v_uv / u_textSize * 64.;
|
|
21
20
|
outputColor = texture(SAMPLER_2D(u_texture), pos);
|
|
@@ -12,11 +12,12 @@ layout(std140) uniform commonUniforms {
|
|
|
12
12
|
float u_halo_blur : 0.5;
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
in vec4 v_color;
|
|
16
|
-
in vec4 v_stroke_color;
|
|
17
15
|
in vec2 v_uv;
|
|
18
16
|
in float v_gamma_scale;
|
|
17
|
+
in vec4 v_color;
|
|
18
|
+
in vec4 v_stroke_color;
|
|
19
19
|
in float v_fontScale;
|
|
20
|
+
|
|
20
21
|
out vec4 outputColor;
|
|
21
22
|
|
|
22
23
|
#pragma include "picking"
|