@antv/l7-layers 2.19.6 → 2.19.8
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 +1 -1
- package/es/core/BaseLayer.js +3 -1
- package/es/line/models/line.js +1 -1
- package/es/line/shaders/dash/line_dash_vert.glsl +30 -11
- package/es/wind/models/utils.js +1 -0
- package/lib/core/BaseLayer.js +3 -1
- package/lib/line/models/line.js +1 -1
- package/lib/line/shaders/dash/line_dash_vert.glsl +30 -11
- package/lib/wind/models/utils.js +1 -0
- package/package.json +7 -7
package/es/core/BaseLayer.d.ts
CHANGED
|
@@ -231,7 +231,7 @@ export default class BaseLayer<ChildLayerStyleOptions = {}> extends EventEmitter
|
|
|
231
231
|
protected sourceEvent: () => void;
|
|
232
232
|
protected initLayerModels(): Promise<void>;
|
|
233
233
|
protected reRender(): void;
|
|
234
|
-
protected splitValuesAndCallbackInAttribute(valuesOrCallback?: unknown[]
|
|
234
|
+
protected splitValuesAndCallbackInAttribute(valuesOrCallback?: unknown[]): {
|
|
235
235
|
values: unknown[] | undefined;
|
|
236
236
|
callback: (unknown[] & ((...args: any[]) => any)) | undefined;
|
|
237
237
|
};
|
package/es/core/BaseLayer.js
CHANGED
|
@@ -1474,7 +1474,9 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
|
|
|
1474
1474
|
}
|
|
1475
1475
|
}, {
|
|
1476
1476
|
key: "splitValuesAndCallbackInAttribute",
|
|
1477
|
-
value: function splitValuesAndCallbackInAttribute(valuesOrCallback
|
|
1477
|
+
value: function splitValuesAndCallbackInAttribute(valuesOrCallback
|
|
1478
|
+
// defaultValues?: unknown[],
|
|
1479
|
+
) {
|
|
1478
1480
|
return {
|
|
1479
1481
|
values: isFunction(valuesOrCallback) ? undefined : valuesOrCallback,
|
|
1480
1482
|
callback: isFunction(valuesOrCallback) ? valuesOrCallback : undefined
|
package/es/line/models/line.js
CHANGED
|
@@ -19,7 +19,7 @@ import { LinearDir, TextureBlend } from "../../core/interface";
|
|
|
19
19
|
/* babel-plugin-inline-import '../shaders/dash/line_dash_frag.glsl' */
|
|
20
20
|
var line_dash_frag = "#define LineTypeSolid 0.0\nvarying vec4 v_color;\n\n// dash\nvarying vec4 v_dash_array;\nvarying float v_d_distance_ratio;\n\n#pragma include \"picking\"\n\nuniform float u_time;\nuniform vec4 u_animate: [ 1., 2., 1.0, 0.2 ]; // \u63A7\u5236\u8FD0\u52A8\n\n// [animate, duration, interval, trailLength],\nvoid main() {\n\n gl_FragColor = v_color;\n\n \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 // \u5B9E\u7EBF\u90E8\u5206\n } else {\n // \u865A\u7EBF\u90E8\u5206\n discard;\n };\n\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
|
|
21
21
|
/* babel-plugin-inline-import '../shaders/dash/line_dash_vert.glsl' */
|
|
22
|
-
var line_dash_vert = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n\nattribute float a_Miter;\nattribute vec4 a_Color;\nattribute vec2 a_Size;\nattribute vec3 a_Normal;\nattribute vec3 a_Position;\n\nattribute vec2 a_iconMapUV;\n\n// dash line\nattribute float a_Total_Distance;\nattribute vec2 a_DistanceAndIndex;\nuniform float u_raisingHeight: 0.0;\n\nuniform mat4 u_ModelMatrix;\n\nuniform vec4 u_dash_array: [10.0, 5., 0, 0];\n\nuniform float u_vertexScale: 1.0;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvarying vec4 v_color;\nvarying vec4 v_dash_array;\nvarying float v_d_distance_ratio;\n\n\nvoid main() {\n\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / a_Total_Distance;\n v_color = vec4(a_Color.xyz, a_Color.w * opacity);\n\n vec3 size = a_Miter * setPickingSize(a_Size.x) * reverse_offset_normal(a_Normal);\n vec2 offset = project_pixel(size.xy);\n v_d_distance_ratio = a_DistanceAndIndex.x / a_Total_Distance;\n\n\n vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));\n\n
|
|
22
|
+
var line_dash_vert = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n\nattribute float a_Miter;\nattribute vec4 a_Color;\nattribute vec2 a_Size;\nattribute vec3 a_Normal;\nattribute vec3 a_Position;\n\nattribute vec2 a_iconMapUV;\n\n// dash line\nattribute float a_Total_Distance;\nattribute vec2 a_DistanceAndIndex;\nuniform float u_raisingHeight: 0.0;\nuniform float u_heightfixed: 0.0;\n\nuniform mat4 u_ModelMatrix;\n\nuniform vec4 u_dash_array: [10.0, 5., 0, 0];\n\nuniform float u_vertexScale: 1.0;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvarying vec4 v_color;\nvarying vec4 v_dash_array;\nvarying float v_d_distance_ratio;\n\n\nvoid main() {\n\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / a_Total_Distance;\n v_color = vec4(a_Color.xyz, a_Color.w * opacity);\n\n vec3 size = a_Miter * setPickingSize(a_Size.x) * reverse_offset_normal(a_Normal);\n vec2 offset = project_pixel(size.xy);\n v_d_distance_ratio = a_DistanceAndIndex.x / a_Total_Distance;\n\n\n vec4 project_pos = project_position(vec4(a_Position.xy, 0, 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"; // basic line shader
|
|
23
23
|
/* babel-plugin-inline-import '../shaders/line_frag.glsl' */
|
|
24
24
|
var line_frag = "#extension GL_OES_standard_derivatives : enable\n#define Animate 0.0\n#define LineTexture 1.0\nuniform float u_textureBlend;\n\nuniform float u_borderWidth: 0.0;\n\nuniform vec3 u_blur;\nuniform vec4 u_borderColor;\nvarying vec4 v_color;\n\n// line texture\nuniform float u_line_texture;\nuniform sampler2D u_texture;\nuniform vec2 u_textSize;\nvarying vec2 v_iconMapUV;\nvarying vec4 v_texture_data;\n\n\n#pragma include \"picking\"\n\nuniform float u_time;\nuniform vec4 u_animate: [ 1, 2., 1.0, 0.2 ]; // \u63A7\u5236\u8FD0\u52A8\n// [animate, duration, interval, trailLength],\nvoid main() {\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 gl_FragColor = v_color;\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 gl_FragColor.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 = texture2D(u_texture, uv);\n\n if(u_textureBlend == 0.0) { // normal\n pattern.a = 0.0;\n gl_FragColor += pattern;\n } else { // replace\n pattern.a *= v_color.a;\n if(gl_FragColor.a <= 0.0) {\n pattern.a = 0.0;\n }\n gl_FragColor = pattern;\n }\n } \n\n float v = v_texture_data.a;\n float borderWidth = min(0.5, u_borderWidth);\n // \u7ED8\u5236 border\n if(borderWidth > 0.01) {\n float borderOuterWidth = borderWidth / 2.0;\n\n\n if(v >= 1.0 - borderWidth || v <= borderWidth) {\n if(v > borderWidth) { // \u5916\u4FA7\n float linear = smoothstep(0.0, 1.0, (v - (1.0 - borderWidth))/borderWidth);\n // float linear = step(0.0, (v - (1.0 - borderWidth))/borderWidth);\n gl_FragColor.rgb = mix(gl_FragColor.rgb, u_borderColor.rgb, linear);\n } else if(v <= borderWidth) {\n float linear = smoothstep(0.0, 1.0, v/borderWidth);\n gl_FragColor.rgb = mix(u_borderColor.rgb, gl_FragColor.rgb, linear);\n }\n }\n\n if(v < borderOuterWidth) {\n gl_FragColor.a = mix(0.0, gl_FragColor.a, v/borderOuterWidth);\n } else if(v > 1.0 - borderOuterWidth) {\n gl_FragColor.a = mix(gl_FragColor.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 gl_FragColor.a *= mix(u_blur.r, u_blur.g, blurV/0.5);\n } else {\n gl_FragColor.a *= mix(u_blur.g, u_blur.b, (blurV - 0.5)/0.5);\n }\n \n gl_FragColor = filterColor(gl_FragColor);\n}\n";
|
|
25
25
|
/* babel-plugin-inline-import '../shaders/line_vert.glsl' */
|
|
@@ -14,6 +14,7 @@ attribute vec2 a_iconMapUV;
|
|
|
14
14
|
attribute float a_Total_Distance;
|
|
15
15
|
attribute vec2 a_DistanceAndIndex;
|
|
16
16
|
uniform float u_raisingHeight: 0.0;
|
|
17
|
+
uniform float u_heightfixed: 0.0;
|
|
17
18
|
|
|
18
19
|
uniform mat4 u_ModelMatrix;
|
|
19
20
|
|
|
@@ -40,23 +41,41 @@ void main() {
|
|
|
40
41
|
|
|
41
42
|
|
|
42
43
|
vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
|
|
45
|
+
float h = float(a_Position.z) * u_vertexScale; // 线顶点的高度 - 兼容不存在第三个数值的情况 vertex height
|
|
46
|
+
float lineHeight = a_Size.y; // size 第二个参数代表的高度 [linewidth, lineheight]
|
|
45
47
|
|
|
46
48
|
if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
|
|
47
|
-
|
|
49
|
+
lineHeight *= 0.2; // 保持和 amap/mapbox 一致的效果
|
|
50
|
+
h *= 0.2;
|
|
51
|
+
if(u_heightfixed < 1.0) {
|
|
52
|
+
lineHeight = project_pixel(a_Size.y);
|
|
53
|
+
}
|
|
54
|
+
gl_Position = u_Mvp * (vec4(project_pos.xy + offset, lineHeight + h + u_raisingHeight, 1.0));
|
|
48
55
|
} else {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
//
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if(u_CoordinateSystem == COORDINATE_SYSTEM_P20 || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {
|
|
56
|
+
// mapbox - amap
|
|
57
|
+
|
|
58
|
+
// 兼容 mapbox 在线高度上的效果表现基本一致
|
|
59
|
+
if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {
|
|
60
|
+
// mapbox
|
|
55
61
|
// 保持高度相对不变
|
|
56
|
-
|
|
62
|
+
float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);
|
|
63
|
+
h *= mapboxZoomScale;
|
|
64
|
+
h += u_raisingHeight * mapboxZoomScale;
|
|
65
|
+
if(u_heightfixed > 0.0) {
|
|
66
|
+
lineHeight *= mapboxZoomScale;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
} else {
|
|
70
|
+
// amap
|
|
71
|
+
h += u_raisingHeight;
|
|
72
|
+
// lineHeight 顶点偏移高度
|
|
73
|
+
if(u_heightfixed < 1.0) {
|
|
74
|
+
lineHeight *= pow(2.0, 20.0 - u_Zoom);
|
|
75
|
+
}
|
|
57
76
|
}
|
|
58
77
|
|
|
59
|
-
gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, lineHeight, 1.0));
|
|
78
|
+
gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, lineHeight + h, 1.0));
|
|
60
79
|
}
|
|
61
80
|
|
|
62
81
|
setPickingColor(a_PickingColor);
|
package/es/wind/models/utils.js
CHANGED
|
@@ -135,6 +135,7 @@ export function bindAttriIndicesBuffer(gl, indices) {
|
|
|
135
135
|
}
|
|
136
136
|
export function bindUnifrom(gl, unifromName, data, program, vec) {
|
|
137
137
|
var uniform = gl.getUniformLocation(program, unifromName);
|
|
138
|
+
// @ts-ignore
|
|
138
139
|
if (uniform === null || uniform < 0) {
|
|
139
140
|
console.warn('无法获取 uniform 变量的存储位置');
|
|
140
141
|
} else {
|
package/lib/core/BaseLayer.js
CHANGED
|
@@ -1480,7 +1480,9 @@ var BaseLayer = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.IGlobalConfigServi
|
|
|
1480
1480
|
}
|
|
1481
1481
|
}, {
|
|
1482
1482
|
key: "splitValuesAndCallbackInAttribute",
|
|
1483
|
-
value: function splitValuesAndCallbackInAttribute(valuesOrCallback
|
|
1483
|
+
value: function splitValuesAndCallbackInAttribute(valuesOrCallback
|
|
1484
|
+
// defaultValues?: unknown[],
|
|
1485
|
+
) {
|
|
1484
1486
|
return {
|
|
1485
1487
|
values: isFunction(valuesOrCallback) ? undefined : valuesOrCallback,
|
|
1486
1488
|
callback: isFunction(valuesOrCallback) ? valuesOrCallback : undefined
|
package/lib/line/models/line.js
CHANGED
|
@@ -26,7 +26,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
26
26
|
// dash line shader
|
|
27
27
|
var line_dash_frag = "#define LineTypeSolid 0.0\nvarying vec4 v_color;\n\n// dash\nvarying vec4 v_dash_array;\nvarying float v_d_distance_ratio;\n\n#pragma include \"picking\"\n\nuniform float u_time;\nuniform vec4 u_animate: [ 1., 2., 1.0, 0.2 ]; // \u63A7\u5236\u8FD0\u52A8\n\n// [animate, duration, interval, trailLength],\nvoid main() {\n\n gl_FragColor = v_color;\n\n \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 // \u5B9E\u7EBF\u90E8\u5206\n } else {\n // \u865A\u7EBF\u90E8\u5206\n discard;\n };\n\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
|
|
28
28
|
/* babel-plugin-inline-import '../shaders/dash/line_dash_vert.glsl' */
|
|
29
|
-
var line_dash_vert = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n\nattribute float a_Miter;\nattribute vec4 a_Color;\nattribute vec2 a_Size;\nattribute vec3 a_Normal;\nattribute vec3 a_Position;\n\nattribute vec2 a_iconMapUV;\n\n// dash line\nattribute float a_Total_Distance;\nattribute vec2 a_DistanceAndIndex;\nuniform float u_raisingHeight: 0.0;\n\nuniform mat4 u_ModelMatrix;\n\nuniform vec4 u_dash_array: [10.0, 5., 0, 0];\n\nuniform float u_vertexScale: 1.0;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvarying vec4 v_color;\nvarying vec4 v_dash_array;\nvarying float v_d_distance_ratio;\n\n\nvoid main() {\n\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / a_Total_Distance;\n v_color = vec4(a_Color.xyz, a_Color.w * opacity);\n\n vec3 size = a_Miter * setPickingSize(a_Size.x) * reverse_offset_normal(a_Normal);\n vec2 offset = project_pixel(size.xy);\n v_d_distance_ratio = a_DistanceAndIndex.x / a_Total_Distance;\n\n\n vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));\n\n
|
|
29
|
+
var line_dash_vert = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n\nattribute float a_Miter;\nattribute vec4 a_Color;\nattribute vec2 a_Size;\nattribute vec3 a_Normal;\nattribute vec3 a_Position;\n\nattribute vec2 a_iconMapUV;\n\n// dash line\nattribute float a_Total_Distance;\nattribute vec2 a_DistanceAndIndex;\nuniform float u_raisingHeight: 0.0;\nuniform float u_heightfixed: 0.0;\n\nuniform mat4 u_ModelMatrix;\n\nuniform vec4 u_dash_array: [10.0, 5., 0, 0];\n\nuniform float u_vertexScale: 1.0;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvarying vec4 v_color;\nvarying vec4 v_dash_array;\nvarying float v_d_distance_ratio;\n\n\nvoid main() {\n\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / a_Total_Distance;\n v_color = vec4(a_Color.xyz, a_Color.w * opacity);\n\n vec3 size = a_Miter * setPickingSize(a_Size.x) * reverse_offset_normal(a_Normal);\n vec2 offset = project_pixel(size.xy);\n v_d_distance_ratio = a_DistanceAndIndex.x / a_Total_Distance;\n\n\n vec4 project_pos = project_position(vec4(a_Position.xy, 0, 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"; // basic line shader
|
|
30
30
|
/* babel-plugin-inline-import '../shaders/line_frag.glsl' */
|
|
31
31
|
var line_frag = "#extension GL_OES_standard_derivatives : enable\n#define Animate 0.0\n#define LineTexture 1.0\nuniform float u_textureBlend;\n\nuniform float u_borderWidth: 0.0;\n\nuniform vec3 u_blur;\nuniform vec4 u_borderColor;\nvarying vec4 v_color;\n\n// line texture\nuniform float u_line_texture;\nuniform sampler2D u_texture;\nuniform vec2 u_textSize;\nvarying vec2 v_iconMapUV;\nvarying vec4 v_texture_data;\n\n\n#pragma include \"picking\"\n\nuniform float u_time;\nuniform vec4 u_animate: [ 1, 2., 1.0, 0.2 ]; // \u63A7\u5236\u8FD0\u52A8\n// [animate, duration, interval, trailLength],\nvoid main() {\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 gl_FragColor = v_color;\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 gl_FragColor.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 = texture2D(u_texture, uv);\n\n if(u_textureBlend == 0.0) { // normal\n pattern.a = 0.0;\n gl_FragColor += pattern;\n } else { // replace\n pattern.a *= v_color.a;\n if(gl_FragColor.a <= 0.0) {\n pattern.a = 0.0;\n }\n gl_FragColor = pattern;\n }\n } \n\n float v = v_texture_data.a;\n float borderWidth = min(0.5, u_borderWidth);\n // \u7ED8\u5236 border\n if(borderWidth > 0.01) {\n float borderOuterWidth = borderWidth / 2.0;\n\n\n if(v >= 1.0 - borderWidth || v <= borderWidth) {\n if(v > borderWidth) { // \u5916\u4FA7\n float linear = smoothstep(0.0, 1.0, (v - (1.0 - borderWidth))/borderWidth);\n // float linear = step(0.0, (v - (1.0 - borderWidth))/borderWidth);\n gl_FragColor.rgb = mix(gl_FragColor.rgb, u_borderColor.rgb, linear);\n } else if(v <= borderWidth) {\n float linear = smoothstep(0.0, 1.0, v/borderWidth);\n gl_FragColor.rgb = mix(u_borderColor.rgb, gl_FragColor.rgb, linear);\n }\n }\n\n if(v < borderOuterWidth) {\n gl_FragColor.a = mix(0.0, gl_FragColor.a, v/borderOuterWidth);\n } else if(v > 1.0 - borderOuterWidth) {\n gl_FragColor.a = mix(gl_FragColor.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 gl_FragColor.a *= mix(u_blur.r, u_blur.g, blurV/0.5);\n } else {\n gl_FragColor.a *= mix(u_blur.g, u_blur.b, (blurV - 0.5)/0.5);\n }\n \n gl_FragColor = filterColor(gl_FragColor);\n}\n";
|
|
32
32
|
/* babel-plugin-inline-import '../shaders/line_vert.glsl' */
|
|
@@ -14,6 +14,7 @@ attribute vec2 a_iconMapUV;
|
|
|
14
14
|
attribute float a_Total_Distance;
|
|
15
15
|
attribute vec2 a_DistanceAndIndex;
|
|
16
16
|
uniform float u_raisingHeight: 0.0;
|
|
17
|
+
uniform float u_heightfixed: 0.0;
|
|
17
18
|
|
|
18
19
|
uniform mat4 u_ModelMatrix;
|
|
19
20
|
|
|
@@ -40,23 +41,41 @@ void main() {
|
|
|
40
41
|
|
|
41
42
|
|
|
42
43
|
vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
|
|
45
|
+
float h = float(a_Position.z) * u_vertexScale; // 线顶点的高度 - 兼容不存在第三个数值的情况 vertex height
|
|
46
|
+
float lineHeight = a_Size.y; // size 第二个参数代表的高度 [linewidth, lineheight]
|
|
45
47
|
|
|
46
48
|
if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
|
|
47
|
-
|
|
49
|
+
lineHeight *= 0.2; // 保持和 amap/mapbox 一致的效果
|
|
50
|
+
h *= 0.2;
|
|
51
|
+
if(u_heightfixed < 1.0) {
|
|
52
|
+
lineHeight = project_pixel(a_Size.y);
|
|
53
|
+
}
|
|
54
|
+
gl_Position = u_Mvp * (vec4(project_pos.xy + offset, lineHeight + h + u_raisingHeight, 1.0));
|
|
48
55
|
} else {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
//
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if(u_CoordinateSystem == COORDINATE_SYSTEM_P20 || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {
|
|
56
|
+
// mapbox - amap
|
|
57
|
+
|
|
58
|
+
// 兼容 mapbox 在线高度上的效果表现基本一致
|
|
59
|
+
if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {
|
|
60
|
+
// mapbox
|
|
55
61
|
// 保持高度相对不变
|
|
56
|
-
|
|
62
|
+
float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);
|
|
63
|
+
h *= mapboxZoomScale;
|
|
64
|
+
h += u_raisingHeight * mapboxZoomScale;
|
|
65
|
+
if(u_heightfixed > 0.0) {
|
|
66
|
+
lineHeight *= mapboxZoomScale;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
} else {
|
|
70
|
+
// amap
|
|
71
|
+
h += u_raisingHeight;
|
|
72
|
+
// lineHeight 顶点偏移高度
|
|
73
|
+
if(u_heightfixed < 1.0) {
|
|
74
|
+
lineHeight *= pow(2.0, 20.0 - u_Zoom);
|
|
75
|
+
}
|
|
57
76
|
}
|
|
58
77
|
|
|
59
|
-
gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, lineHeight, 1.0));
|
|
78
|
+
gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, lineHeight + h, 1.0));
|
|
60
79
|
}
|
|
61
80
|
|
|
62
81
|
setPickingColor(a_PickingColor);
|
package/lib/wind/models/utils.js
CHANGED
|
@@ -151,6 +151,7 @@ function bindAttriIndicesBuffer(gl, indices) {
|
|
|
151
151
|
}
|
|
152
152
|
function bindUnifrom(gl, unifromName, data, program, vec) {
|
|
153
153
|
var uniform = gl.getUniformLocation(program, unifromName);
|
|
154
|
+
// @ts-ignore
|
|
154
155
|
if (uniform === null || uniform < 0) {
|
|
155
156
|
console.warn('无法获取 uniform 变量的存储位置');
|
|
156
157
|
} else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/l7-layers",
|
|
3
|
-
"version": "2.19.
|
|
3
|
+
"version": "2.19.8",
|
|
4
4
|
"description": "L7's collection of built-in layers",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
"license": "ISC",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@antv/async-hook": "^2.2.9",
|
|
30
|
-
"@antv/l7-core": "2.19.
|
|
31
|
-
"@antv/l7-maps": "2.19.
|
|
32
|
-
"@antv/l7-source": "2.19.
|
|
33
|
-
"@antv/l7-utils": "2.19.
|
|
30
|
+
"@antv/l7-core": "2.19.8",
|
|
31
|
+
"@antv/l7-maps": "2.19.8",
|
|
32
|
+
"@antv/l7-source": "2.19.8",
|
|
33
|
+
"@antv/l7-utils": "2.19.8",
|
|
34
34
|
"@babel/runtime": "^7.7.7",
|
|
35
35
|
"@mapbox/martini": "^0.2.0",
|
|
36
36
|
"@turf/clone": "^6.5.0",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"reflect-metadata": "^0.1.13"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@antv/l7-test-utils": "2.19.
|
|
55
|
+
"@antv/l7-test-utils": "2.19.8",
|
|
56
56
|
"@types/d3-array": "^2.0.0",
|
|
57
57
|
"@types/d3-color": "^1.2.2",
|
|
58
58
|
"@types/d3-interpolate": "1.1.6",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"@types/gl-matrix": "^2.4.5",
|
|
62
62
|
"@types/lodash": "^4.14.138"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "9111d4c9dcbeca5df641a994215c062e5b209311",
|
|
65
65
|
"publishConfig": {
|
|
66
66
|
"access": "public"
|
|
67
67
|
}
|