@antv/l7-layers 2.20.11 → 2.20.12
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/line/models/line.js +66 -12
- package/es/line/shaders/line/line_vert.glsl +14 -11
- package/es/point/models/extrude.js +1 -1
- package/es/point/models/fill.js +25 -6
- package/es/point/models/radar.js +25 -6
- package/es/point/models/text.js +23 -6
- package/es/point/shaders/extrude/extrude_frag.glsl +1 -1
- package/es/point/shaders/fill/fill_vert.glsl +4 -3
- package/es/point/shaders/radar/radar_vert.glsl +7 -7
- package/es/point/shaders/text/text_vert.glsl +4 -3
- package/es/raster/index.js +1 -1
- package/lib/line/models/line.js +66 -12
- package/lib/line/shaders/line/line_vert.glsl +14 -11
- package/lib/point/models/extrude.js +1 -1
- package/lib/point/models/fill.js +25 -6
- package/lib/point/models/radar.js +25 -6
- package/lib/point/models/text.js +23 -6
- package/lib/point/shaders/extrude/extrude_frag.glsl +1 -1
- package/lib/point/shaders/fill/fill_vert.glsl +4 -3
- package/lib/point/shaders/radar/radar_vert.glsl +7 -7
- package/lib/point/shaders/text/text_vert.glsl +4 -3
- package/lib/raster/index.js +1 -1
- package/package.json +7 -7
package/es/line/models/line.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
1
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
2
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
4
3
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
@@ -20,7 +19,7 @@ import { ShaderLocation } from "../../core/CommonStyleAttribute";
|
|
|
20
19
|
/* babel-plugin-inline-import '../shaders/line/line_frag.glsl' */
|
|
21
20
|
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;\nin vec2 v_iconMapUV;\nin vec4 v_texture_data;\n// dash\nin vec4 v_dash_array;\nin float v_d_distance_ratio;\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";
|
|
22
21
|
/* babel-plugin-inline-import '../shaders/line/line_vert.glsl' */
|
|
23
|
-
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
|
|
22
|
+
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 = 10) in vec2 a_DistanceAndIndex;\nlayout(location = 9) in vec2 a_Size;\nlayout(location = 11) in float a_Total_Distance;\nlayout(location = 13) in vec3 a_Normal;\nlayout(location = 15) in float a_Miter;\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#pragma include \"projection\"\n#pragma include \"picking\"\n\nout vec4 v_color;\nout vec4 v_stroke;\n//dash\nout vec4 v_dash_array;\nout float v_d_distance_ratio;\n\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\nvoid main() {\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";
|
|
24
23
|
var lineStyleObj = {
|
|
25
24
|
solid: 0.0,
|
|
26
25
|
dash: 1.0
|
|
@@ -233,41 +232,96 @@ var LineModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
233
232
|
value: function registerBuiltinAttributes() {
|
|
234
233
|
var _this2 = this;
|
|
235
234
|
this.styleAttributeService.registerStyleAttribute({
|
|
236
|
-
name: '
|
|
235
|
+
name: 'distanceAndIndex',
|
|
237
236
|
type: AttributeType.Attribute,
|
|
238
237
|
descriptor: {
|
|
239
|
-
name: '
|
|
240
|
-
shaderLocation:
|
|
238
|
+
name: 'a_DistanceAndIndex',
|
|
239
|
+
shaderLocation: 10,
|
|
240
|
+
buffer: {
|
|
241
|
+
// give the WebGL driver a hint that this buffer may change
|
|
242
|
+
usage: gl.STATIC_DRAW,
|
|
243
|
+
data: [],
|
|
244
|
+
type: gl.FLOAT
|
|
245
|
+
},
|
|
246
|
+
size: 2,
|
|
247
|
+
update: function update(feature, featureIdx, vertex, attributeIdx, normal, vertexIndex) {
|
|
248
|
+
return vertexIndex === undefined ? [vertex[3], 10] : [vertex[3], vertexIndex];
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
253
|
+
name: 'total_distance',
|
|
254
|
+
type: AttributeType.Attribute,
|
|
255
|
+
descriptor: {
|
|
256
|
+
name: 'a_Total_Distance',
|
|
257
|
+
shaderLocation: 11,
|
|
241
258
|
buffer: {
|
|
259
|
+
// give the WebGL driver a hint that this buffer may change
|
|
242
260
|
usage: gl.STATIC_DRAW,
|
|
243
261
|
data: [],
|
|
244
262
|
type: gl.FLOAT
|
|
245
263
|
},
|
|
246
|
-
size:
|
|
264
|
+
size: 1,
|
|
247
265
|
update: function update(feature, featureIdx, vertex) {
|
|
266
|
+
return [vertex[5]];
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
271
|
+
name: 'size',
|
|
272
|
+
type: AttributeType.Attribute,
|
|
273
|
+
descriptor: {
|
|
274
|
+
name: 'a_Size',
|
|
275
|
+
shaderLocation: ShaderLocation.SIZE,
|
|
276
|
+
buffer: {
|
|
277
|
+
// give the WebGL driver a hint that this buffer may change
|
|
278
|
+
usage: gl.DYNAMIC_DRAW,
|
|
279
|
+
data: [],
|
|
280
|
+
type: gl.FLOAT
|
|
281
|
+
},
|
|
282
|
+
size: 2,
|
|
283
|
+
update: function update(feature) {
|
|
248
284
|
var _feature$size = feature.size,
|
|
249
285
|
size = _feature$size === void 0 ? 1 : _feature$size;
|
|
250
|
-
|
|
251
|
-
return [a_Size[0], a_Size[1], vertex[3], vertex[5]];
|
|
286
|
+
return Array.isArray(size) ? [size[0], size[1]] : [size, 0];
|
|
252
287
|
}
|
|
253
288
|
}
|
|
254
289
|
});
|
|
255
290
|
|
|
256
291
|
// point layer size;
|
|
257
292
|
this.styleAttributeService.registerStyleAttribute({
|
|
258
|
-
name: '
|
|
293
|
+
name: 'normal',
|
|
259
294
|
type: AttributeType.Attribute,
|
|
260
295
|
descriptor: {
|
|
261
|
-
name: '
|
|
296
|
+
name: 'a_Normal',
|
|
262
297
|
shaderLocation: ShaderLocation.NORMAL,
|
|
263
298
|
buffer: {
|
|
299
|
+
// give the WebGL driver a hint that this buffer may change
|
|
264
300
|
usage: gl.STATIC_DRAW,
|
|
265
301
|
data: [],
|
|
266
302
|
type: gl.FLOAT
|
|
267
303
|
},
|
|
268
|
-
size:
|
|
304
|
+
size: 3,
|
|
269
305
|
update: function update(feature, featureIdx, vertex, attributeIdx, normal) {
|
|
270
|
-
return
|
|
306
|
+
return normal;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
311
|
+
name: 'miter',
|
|
312
|
+
type: AttributeType.Attribute,
|
|
313
|
+
descriptor: {
|
|
314
|
+
shaderLocation: 15,
|
|
315
|
+
name: 'a_Miter',
|
|
316
|
+
buffer: {
|
|
317
|
+
// give the WebGL driver a hint that this buffer may change
|
|
318
|
+
usage: gl.STATIC_DRAW,
|
|
319
|
+
data: [],
|
|
320
|
+
type: gl.FLOAT
|
|
321
|
+
},
|
|
322
|
+
size: 1,
|
|
323
|
+
update: function update(feature, featureIdx, vertex) {
|
|
324
|
+
return [vertex[4]];
|
|
271
325
|
}
|
|
272
326
|
}
|
|
273
327
|
});
|
|
@@ -3,8 +3,11 @@
|
|
|
3
3
|
|
|
4
4
|
layout(location = 0) in vec3 a_Position;
|
|
5
5
|
layout(location = 1) in vec4 a_Color;
|
|
6
|
-
layout(location =
|
|
7
|
-
layout(location =
|
|
6
|
+
layout(location = 10) in vec2 a_DistanceAndIndex;
|
|
7
|
+
layout(location = 9) in vec2 a_Size;
|
|
8
|
+
layout(location = 11) in float a_Total_Distance;
|
|
9
|
+
layout(location = 13) in vec3 a_Normal;
|
|
10
|
+
layout(location = 15) in float a_Miter;
|
|
8
11
|
layout(location = 14) in vec2 a_iconMapUV;
|
|
9
12
|
|
|
10
13
|
layout(std140) uniform commonUniorm {
|
|
@@ -40,8 +43,8 @@ out vec4 v_texture_data;
|
|
|
40
43
|
|
|
41
44
|
void main() {
|
|
42
45
|
//dash输出
|
|
43
|
-
v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array /
|
|
44
|
-
v_d_distance_ratio =
|
|
46
|
+
v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / a_Total_Distance;
|
|
47
|
+
v_d_distance_ratio = a_DistanceAndIndex.x / a_Total_Distance;
|
|
45
48
|
|
|
46
49
|
// cal style mapping - 数据纹理映射部分的计算
|
|
47
50
|
float d_texPixelLen; // 贴图的像素长度,根据地图层级缩放
|
|
@@ -55,16 +58,16 @@ void main() {
|
|
|
55
58
|
v_color.a *= opacity;
|
|
56
59
|
v_stroke = stroke;
|
|
57
60
|
|
|
58
|
-
vec3 size =
|
|
61
|
+
vec3 size = a_Miter * setPickingSize(a_Size.x) * reverse_offset_normal(a_Normal);
|
|
59
62
|
|
|
60
63
|
vec2 offset = project_pixel(size.xy);
|
|
61
64
|
|
|
62
|
-
float lineDistance =
|
|
63
|
-
float currentLinePointRatio = lineDistance /
|
|
65
|
+
float lineDistance = a_DistanceAndIndex.x;
|
|
66
|
+
float currentLinePointRatio = lineDistance / a_Total_Distance;
|
|
64
67
|
|
|
65
68
|
|
|
66
|
-
float lineOffsetWidth = length(offset + offset * sign(
|
|
67
|
-
float linePixelSize = project_pixel(
|
|
69
|
+
float lineOffsetWidth = length(offset + offset * sign(a_Miter)); // 线横向偏移的距离(向两侧偏移的和)
|
|
70
|
+
float linePixelSize = project_pixel(a_Size.x) * 2.0; // 定点位置偏移,按地图等级缩放后的距离 单侧 * 2
|
|
68
71
|
float texV = lineOffsetWidth/linePixelSize; // 线图层贴图部分的 v 坐标值
|
|
69
72
|
|
|
70
73
|
v_texture_data = vec4(currentLinePointRatio, lineDistance, d_texPixelLen, texV);
|
|
@@ -75,13 +78,13 @@ void main() {
|
|
|
75
78
|
// gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, a_Size.y, 1.0));
|
|
76
79
|
|
|
77
80
|
float h = float(a_Position.z) * u_vertexScale; // 线顶点的高度 - 兼容不存在第三个数值的情况 vertex height
|
|
78
|
-
float lineHeight =
|
|
81
|
+
float lineHeight = a_Size.y; // size 第二个参数代表的高度 [linewidth, lineheight]
|
|
79
82
|
|
|
80
83
|
if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
|
|
81
84
|
lineHeight *= 0.2; // 保持和 amap/mapbox 一致的效果
|
|
82
85
|
h *= 0.2;
|
|
83
86
|
if(u_heightfixed < 1.0) {
|
|
84
|
-
lineHeight = project_pixel(
|
|
87
|
+
lineHeight = project_pixel(a_Size.y);
|
|
85
88
|
}
|
|
86
89
|
gl_Position = u_Mvp * (vec4(project_pos.xy + offset, lineHeight + h + u_raisingHeight, 1.0));
|
|
87
90
|
} else {
|
|
@@ -15,7 +15,7 @@ import BaseModel from "../../core/BaseModel";
|
|
|
15
15
|
import { ShaderLocation } from "../../core/CommonStyleAttribute";
|
|
16
16
|
import { PointExtrudeTriangulation } from "../../core/triangulation";
|
|
17
17
|
/* babel-plugin-inline-import '../shaders/extrude/extrude_frag.glsl' */
|
|
18
|
-
var pointExtrudeFrag = "
|
|
18
|
+
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";
|
|
19
19
|
/* babel-plugin-inline-import '../shaders/extrude/extrude_vert.glsl' */
|
|
20
20
|
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;\nout float v_barLinearZ;\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";
|
|
21
21
|
var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
package/es/point/models/fill.js
CHANGED
|
@@ -14,7 +14,7 @@ import { ShaderLocation } from "../../core/CommonStyleAttribute";
|
|
|
14
14
|
/* babel-plugin-inline-import '../shaders/fill/fill_frag.glsl' */
|
|
15
15
|
var pointFillFrag = "layout(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\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";
|
|
16
16
|
/* babel-plugin-inline-import '../shaders/fill/fill_vert.glsl' */
|
|
17
|
-
var pointFillVert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in
|
|
17
|
+
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";
|
|
18
18
|
import { SizeUnitType } from "../../core/interface";
|
|
19
19
|
var FillModel = /*#__PURE__*/function (_BaseModel) {
|
|
20
20
|
_inherits(FillModel, _BaseModel);
|
|
@@ -180,10 +180,10 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
180
180
|
|
|
181
181
|
// point layer size;
|
|
182
182
|
this.styleAttributeService.registerStyleAttribute({
|
|
183
|
-
name: '
|
|
183
|
+
name: 'size',
|
|
184
184
|
type: AttributeType.Attribute,
|
|
185
185
|
descriptor: {
|
|
186
|
-
name: '
|
|
186
|
+
name: 'a_Size',
|
|
187
187
|
shaderLocation: ShaderLocation.SIZE,
|
|
188
188
|
buffer: {
|
|
189
189
|
// give the WebGL driver a hint that this buffer may change
|
|
@@ -191,15 +191,34 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
191
191
|
data: [],
|
|
192
192
|
type: gl.FLOAT
|
|
193
193
|
},
|
|
194
|
-
size:
|
|
194
|
+
size: 1,
|
|
195
195
|
update: function update(feature) {
|
|
196
196
|
var _feature$size = feature.size,
|
|
197
197
|
size = _feature$size === void 0 ? 5 : _feature$size;
|
|
198
|
+
return Array.isArray(size) ? [size[0]] : [size];
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
// point layer shape;
|
|
204
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
205
|
+
name: 'shape',
|
|
206
|
+
type: AttributeType.Attribute,
|
|
207
|
+
descriptor: {
|
|
208
|
+
name: 'a_Shape',
|
|
209
|
+
shaderLocation: ShaderLocation.SHAPE,
|
|
210
|
+
buffer: {
|
|
211
|
+
// give the WebGL driver a hint that this buffer may change
|
|
212
|
+
usage: gl.DYNAMIC_DRAW,
|
|
213
|
+
data: [],
|
|
214
|
+
type: gl.FLOAT
|
|
215
|
+
},
|
|
216
|
+
size: 1,
|
|
217
|
+
update: function update(feature) {
|
|
198
218
|
var _feature$shape = feature.shape,
|
|
199
219
|
shape = _feature$shape === void 0 ? 2 : _feature$shape;
|
|
200
220
|
var shapeIndex = shape2d.indexOf(shape);
|
|
201
|
-
|
|
202
|
-
return [a_Size, shapeIndex];
|
|
221
|
+
return [shapeIndex];
|
|
203
222
|
}
|
|
204
223
|
}
|
|
205
224
|
});
|
package/es/point/models/radar.js
CHANGED
|
@@ -14,7 +14,7 @@ import { PointFillTriangulation } from "../../core/triangulation";
|
|
|
14
14
|
/* babel-plugin-inline-import '../shaders/radar/radar_frag.glsl' */
|
|
15
15
|
var pointFillFrag = "\nlayout(std140) uniform commonUniorm{\n float u_additive;\n float u_size_unit;\n float u_speed: 1.0;\n float u_time;\n};\nin vec4 v_data;\nin vec4 v_color;\nin float v_radius;\nin vec2 v_extrude;\n#pragma include \"sdf_2d\"\n#pragma include \"picking\"\n\nout vec4 outputColor;\n\nvoid main() {\n\n lowp float antialiasblur = v_data.z;\n float r = v_radius / (v_radius);\n\n float outer_df = sdCircle(v_data.xy, 1.0);\n float inner_df = sdCircle(v_data.xy, r);\n\n float opacity_t = smoothstep(0.0, antialiasblur, outer_df);\n\n outputColor = vec4(v_color.rgb, v_color.a);\n\n if(u_additive > 0.0) {\n outputColor *= opacity_t;\n } else {\n outputColor.a *= opacity_t;\n }\n\n if(outputColor.a > 0.0) {\n outputColor = filterColor(outputColor);\n }\n\n vec2 extrude = v_extrude;\n vec2 dir = normalize(extrude);\n vec2 baseDir = vec2(1.0, 0.0);\n float pi = 3.14159265359;\n float flag = sign(dir.y);\n float rades = dot(dir, baseDir);\n float radar_v = (flag - 1.0) * -0.5 * acos(rades)/pi;\n // simple AA\n if(radar_v > 0.99) {\n radar_v = 1.0 - (radar_v - 0.99)/0.01;\n }\n\n outputColor.a *= radar_v;\n}\n";
|
|
16
16
|
/* babel-plugin-inline-import '../shaders/radar/radar_vert.glsl' */
|
|
17
|
-
var pointFillVert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 11) in
|
|
17
|
+
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;\n\nlayout(std140) uniform commonUniorm {\n float u_additive;\n float u_size_unit;\n float u_speed: 1.0;\n float u_time;\n};\n\nout vec4 v_data;\nout vec4 v_color;\nout float v_radius;\nout vec2 v_extrude;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n float newSize = setPickingSize(a_Size);\n\n float time = u_time * u_speed;\n mat2 rotateMatrix = mat2( \n cos(time), sin(time), \n -sin(time), cos(time)\n );\n v_extrude = rotateMatrix * a_Extrude.xy;\n\n v_color = a_Color;\n v_color.a *= opacity;\n\n float blur = 0.0;\n float antialiasblur = -max(2.0 / u_DevicePixelRatio / a_Size, blur);\n\n if(u_size_unit == 1.) {\n newSize = newSize * u_PixelsPerMeter.z;\n }\n v_radius = newSize;\n\n vec2 offset = (a_Extrude.xy * (newSize));\n vec3 aPosition = a_Position;\n \n offset = project_pixel(offset);\n \n v_data = vec4(a_Extrude.x, a_Extrude.y, antialiasblur, -1.0);\n\n vec4 project_pos = project_position(vec4(aPosition.xy, 0.0, 1.0));\n gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xy + offset, project_pixel(setPickingOrder(0.0)), 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
18
18
|
import { ShaderLocation } from "../../core/CommonStyleAttribute";
|
|
19
19
|
var RadarModel = /*#__PURE__*/function (_BaseModel) {
|
|
20
20
|
_inherits(RadarModel, _BaseModel);
|
|
@@ -113,10 +113,10 @@ var RadarModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
113
113
|
key: "registerBuiltinAttributes",
|
|
114
114
|
value: function registerBuiltinAttributes() {
|
|
115
115
|
this.styleAttributeService.registerStyleAttribute({
|
|
116
|
-
name: '
|
|
116
|
+
name: 'extrude',
|
|
117
117
|
type: AttributeType.Attribute,
|
|
118
118
|
descriptor: {
|
|
119
|
-
name: '
|
|
119
|
+
name: 'a_Extrude',
|
|
120
120
|
shaderLocation: ShaderLocation.EXTRUDE,
|
|
121
121
|
buffer: {
|
|
122
122
|
// give the WebGL driver a hint that this buffer may change
|
|
@@ -124,14 +124,33 @@ var RadarModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
124
124
|
data: [],
|
|
125
125
|
type: gl.FLOAT
|
|
126
126
|
},
|
|
127
|
-
size:
|
|
127
|
+
size: 3,
|
|
128
128
|
update: function update(feature, featureIdx, vertex, attributeIdx) {
|
|
129
129
|
var extrude = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0];
|
|
130
130
|
var extrudeIndex = attributeIdx % 4 * 3;
|
|
131
|
+
return [extrude[extrudeIndex], extrude[extrudeIndex + 1], extrude[extrudeIndex + 2]];
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
// point layer size;
|
|
137
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
138
|
+
name: 'size',
|
|
139
|
+
type: AttributeType.Attribute,
|
|
140
|
+
descriptor: {
|
|
141
|
+
shaderLocation: ShaderLocation.SIZE,
|
|
142
|
+
name: 'a_Size',
|
|
143
|
+
buffer: {
|
|
144
|
+
// give the WebGL driver a hint that this buffer may change
|
|
145
|
+
usage: gl.DYNAMIC_DRAW,
|
|
146
|
+
data: [],
|
|
147
|
+
type: gl.FLOAT
|
|
148
|
+
},
|
|
149
|
+
size: 1,
|
|
150
|
+
update: function update(feature) {
|
|
131
151
|
var _feature$size = feature.size,
|
|
132
152
|
size = _feature$size === void 0 ? 5 : _feature$size;
|
|
133
|
-
|
|
134
|
-
return [extrude[extrudeIndex], extrude[extrudeIndex + 1], extrude[extrudeIndex + 2], a_Size];
|
|
153
|
+
return Array.isArray(size) ? [size[0]] : [size];
|
|
135
154
|
}
|
|
136
155
|
}
|
|
137
156
|
});
|
package/es/point/models/text.js
CHANGED
|
@@ -22,7 +22,7 @@ import { getGlyphQuads, shapeText } from "../../utils/symbol-layout";
|
|
|
22
22
|
/* babel-plugin-inline-import '../shaders/text/text_frag.glsl' */
|
|
23
23
|
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 vec4 v_color;\nin vec4 v_stroke_color;\nin vec2 v_uv;\nin float v_gamma_scale;\nin float v_fontScale;\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";
|
|
24
24
|
/* babel-plugin-inline-import '../shaders/text/text_vert.glsl' */
|
|
25
|
-
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 = 14) in
|
|
25
|
+
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\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";
|
|
26
26
|
import { ShaderLocation } from "../../core/CommonStyleAttribute";
|
|
27
27
|
var isEqual = lodashUtil.isEqual;
|
|
28
28
|
export function TextTrianglation(feature) {
|
|
@@ -255,21 +255,38 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
255
255
|
key: "registerBuiltinAttributes",
|
|
256
256
|
value: function registerBuiltinAttributes() {
|
|
257
257
|
this.styleAttributeService.registerStyleAttribute({
|
|
258
|
-
name: '
|
|
258
|
+
name: 'textOffsets',
|
|
259
259
|
type: AttributeType.Attribute,
|
|
260
260
|
descriptor: {
|
|
261
|
-
|
|
261
|
+
shaderLocation: 10,
|
|
262
|
+
name: 'a_textOffsets',
|
|
262
263
|
// 文字偏移量
|
|
263
|
-
shaderLocation: ShaderLocation.UV,
|
|
264
264
|
buffer: {
|
|
265
265
|
// give the WebGL driver a hint that this buffer may change
|
|
266
266
|
usage: gl.STATIC_DRAW,
|
|
267
267
|
data: [],
|
|
268
268
|
type: gl.FLOAT
|
|
269
269
|
},
|
|
270
|
-
size:
|
|
270
|
+
size: 2,
|
|
271
|
+
update: function update(feature, featureIdx, vertex) {
|
|
272
|
+
return [vertex[5], vertex[6]];
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
277
|
+
name: 'textUv',
|
|
278
|
+
type: AttributeType.Attribute,
|
|
279
|
+
descriptor: {
|
|
280
|
+
name: 'a_tex',
|
|
281
|
+
shaderLocation: ShaderLocation.UV,
|
|
282
|
+
buffer: {
|
|
283
|
+
usage: gl.DYNAMIC_DRAW,
|
|
284
|
+
data: [],
|
|
285
|
+
type: gl.FLOAT
|
|
286
|
+
},
|
|
287
|
+
size: 2,
|
|
271
288
|
update: function update(feature, featureIdx, vertex) {
|
|
272
|
-
return [vertex[3], vertex[4]
|
|
289
|
+
return [vertex[3], vertex[4]];
|
|
273
290
|
}
|
|
274
291
|
}
|
|
275
292
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
layout(location = 0) in vec3 a_Position;
|
|
2
2
|
layout(location = 1) in vec4 a_Color;
|
|
3
|
-
layout(location = 9) in
|
|
3
|
+
layout(location = 9) in float a_Size;
|
|
4
|
+
layout(location = 10) in float a_Shape;
|
|
4
5
|
layout(location = 11) in vec3 a_Extrude;
|
|
5
6
|
|
|
6
7
|
layout(std140) uniform commonUniforms {
|
|
@@ -26,12 +27,12 @@ void main() {
|
|
|
26
27
|
// 透明度计算
|
|
27
28
|
v_stroke = stroke;
|
|
28
29
|
vec3 extrude = a_Extrude;
|
|
29
|
-
float shape_type =
|
|
30
|
+
float shape_type = a_Shape;
|
|
30
31
|
/*
|
|
31
32
|
* setPickingSize 设置拾取大小
|
|
32
33
|
* u_meter2coord 在等面积大小的时候设置单位
|
|
33
34
|
*/
|
|
34
|
-
float newSize = setPickingSize(
|
|
35
|
+
float newSize = setPickingSize(a_Size);
|
|
35
36
|
// float newSize = setPickingSize(a_Size) * 0.00001038445708445579;
|
|
36
37
|
|
|
37
38
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
layout(location = 0) in vec3 a_Position;
|
|
2
2
|
layout(location = 1) in vec4 a_Color;
|
|
3
|
-
layout(location =
|
|
3
|
+
layout(location = 9) in float a_Size;
|
|
4
|
+
layout(location = 11) in vec3 a_Extrude;
|
|
4
5
|
|
|
5
6
|
layout(std140) uniform commonUniorm {
|
|
6
7
|
float u_additive;
|
|
@@ -18,33 +19,32 @@ out vec2 v_extrude;
|
|
|
18
19
|
#pragma include "picking"
|
|
19
20
|
|
|
20
21
|
void main() {
|
|
21
|
-
|
|
22
|
-
float newSize = setPickingSize(a_ExtrudeAndSize.w);
|
|
22
|
+
float newSize = setPickingSize(a_Size);
|
|
23
23
|
|
|
24
24
|
float time = u_time * u_speed;
|
|
25
25
|
mat2 rotateMatrix = mat2(
|
|
26
26
|
cos(time), sin(time),
|
|
27
27
|
-sin(time), cos(time)
|
|
28
28
|
);
|
|
29
|
-
v_extrude = rotateMatrix *
|
|
29
|
+
v_extrude = rotateMatrix * a_Extrude.xy;
|
|
30
30
|
|
|
31
31
|
v_color = a_Color;
|
|
32
32
|
v_color.a *= opacity;
|
|
33
33
|
|
|
34
34
|
float blur = 0.0;
|
|
35
|
-
float antialiasblur = -max(2.0 / u_DevicePixelRatio /
|
|
35
|
+
float antialiasblur = -max(2.0 / u_DevicePixelRatio / a_Size, blur);
|
|
36
36
|
|
|
37
37
|
if(u_size_unit == 1.) {
|
|
38
38
|
newSize = newSize * u_PixelsPerMeter.z;
|
|
39
39
|
}
|
|
40
40
|
v_radius = newSize;
|
|
41
41
|
|
|
42
|
-
vec2 offset = (
|
|
42
|
+
vec2 offset = (a_Extrude.xy * (newSize));
|
|
43
43
|
vec3 aPosition = a_Position;
|
|
44
44
|
|
|
45
45
|
offset = project_pixel(offset);
|
|
46
46
|
|
|
47
|
-
v_data = vec4(
|
|
47
|
+
v_data = vec4(a_Extrude.x, a_Extrude.y, antialiasblur, -1.0);
|
|
48
48
|
|
|
49
49
|
vec4 project_pos = project_position(vec4(aPosition.xy, 0.0, 1.0));
|
|
50
50
|
gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xy + offset, project_pixel(setPickingOrder(0.0)), 1.0));
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
layout(location = 0) in vec3 a_Position;
|
|
6
6
|
layout(location = 1) in vec4 a_Color;
|
|
7
7
|
layout(location = 9) in float a_Size;
|
|
8
|
-
layout(location =
|
|
8
|
+
layout(location = 10) in vec2 a_textOffsets;
|
|
9
|
+
layout(location = 14) in vec2 a_tex;
|
|
9
10
|
|
|
10
11
|
layout(std140) uniform commonUniforms {
|
|
11
12
|
vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];
|
|
@@ -31,7 +32,7 @@ out float v_fontScale;
|
|
|
31
32
|
void main() {
|
|
32
33
|
// cal style mapping - 数据纹理映射部分的计算
|
|
33
34
|
|
|
34
|
-
v_uv =
|
|
35
|
+
v_uv = a_tex / u_sdf_map_size;
|
|
35
36
|
|
|
36
37
|
|
|
37
38
|
|
|
@@ -45,7 +46,7 @@ void main() {
|
|
|
45
46
|
vec4 project_pos = project_position(vec4(a_Position, 1.0));
|
|
46
47
|
// vec4 projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));
|
|
47
48
|
|
|
48
|
-
vec2 offset = rotate_matrix(
|
|
49
|
+
vec2 offset = rotate_matrix(a_textOffsets,rotation);
|
|
49
50
|
|
|
50
51
|
// gl_Position = vec4(projected_position.xy / projected_position.w + rotation_matrix * a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);
|
|
51
52
|
|
package/es/raster/index.js
CHANGED
|
@@ -65,7 +65,7 @@ var RaterLayer = /*#__PURE__*/function (_BaseLayer) {
|
|
|
65
65
|
// 根据 source 的类型判断 model type
|
|
66
66
|
var parserType = this.layerSource.getParserType();
|
|
67
67
|
switch (parserType) {
|
|
68
|
-
case 'raster':
|
|
68
|
+
case 'raster' || 'ndi':
|
|
69
69
|
return 'raster';
|
|
70
70
|
case 'rasterRgb':
|
|
71
71
|
return 'rasterRgb';
|
package/lib/line/models/line.js
CHANGED
|
@@ -6,7 +6,6 @@ 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"));
|
|
10
9
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
11
10
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
12
11
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
@@ -25,7 +24,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
25
24
|
/* babel-plugin-inline-import '../shaders/line/line_frag.glsl' */
|
|
26
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;\nin vec2 v_iconMapUV;\nin vec4 v_texture_data;\n// dash\nin vec4 v_dash_array;\nin float v_d_distance_ratio;\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";
|
|
27
26
|
/* babel-plugin-inline-import '../shaders/line/line_vert.glsl' */
|
|
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
|
|
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 = 10) in vec2 a_DistanceAndIndex;\nlayout(location = 9) in vec2 a_Size;\nlayout(location = 11) in float a_Total_Distance;\nlayout(location = 13) in vec3 a_Normal;\nlayout(location = 15) in float a_Miter;\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#pragma include \"projection\"\n#pragma include \"picking\"\n\nout vec4 v_color;\nout vec4 v_stroke;\n//dash\nout vec4 v_dash_array;\nout float v_d_distance_ratio;\n\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\nvoid main() {\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";
|
|
29
28
|
var lineStyleObj = {
|
|
30
29
|
solid: 0.0,
|
|
31
30
|
dash: 1.0
|
|
@@ -238,41 +237,96 @@ var LineModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
|
238
237
|
value: function registerBuiltinAttributes() {
|
|
239
238
|
var _this2 = this;
|
|
240
239
|
this.styleAttributeService.registerStyleAttribute({
|
|
241
|
-
name: '
|
|
240
|
+
name: 'distanceAndIndex',
|
|
242
241
|
type: _l7Core.AttributeType.Attribute,
|
|
243
242
|
descriptor: {
|
|
244
|
-
name: '
|
|
245
|
-
shaderLocation:
|
|
243
|
+
name: 'a_DistanceAndIndex',
|
|
244
|
+
shaderLocation: 10,
|
|
245
|
+
buffer: {
|
|
246
|
+
// give the WebGL driver a hint that this buffer may change
|
|
247
|
+
usage: _l7Core.gl.STATIC_DRAW,
|
|
248
|
+
data: [],
|
|
249
|
+
type: _l7Core.gl.FLOAT
|
|
250
|
+
},
|
|
251
|
+
size: 2,
|
|
252
|
+
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,
|
|
246
263
|
buffer: {
|
|
264
|
+
// give the WebGL driver a hint that this buffer may change
|
|
247
265
|
usage: _l7Core.gl.STATIC_DRAW,
|
|
248
266
|
data: [],
|
|
249
267
|
type: _l7Core.gl.FLOAT
|
|
250
268
|
},
|
|
251
|
-
size:
|
|
269
|
+
size: 1,
|
|
252
270
|
update: function update(feature, featureIdx, vertex) {
|
|
271
|
+
return [vertex[5]];
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
276
|
+
name: 'size',
|
|
277
|
+
type: _l7Core.AttributeType.Attribute,
|
|
278
|
+
descriptor: {
|
|
279
|
+
name: 'a_Size',
|
|
280
|
+
shaderLocation: _CommonStyleAttribute.ShaderLocation.SIZE,
|
|
281
|
+
buffer: {
|
|
282
|
+
// give the WebGL driver a hint that this buffer may change
|
|
283
|
+
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
284
|
+
data: [],
|
|
285
|
+
type: _l7Core.gl.FLOAT
|
|
286
|
+
},
|
|
287
|
+
size: 2,
|
|
288
|
+
update: function update(feature) {
|
|
253
289
|
var _feature$size = feature.size,
|
|
254
290
|
size = _feature$size === void 0 ? 1 : _feature$size;
|
|
255
|
-
|
|
256
|
-
return [a_Size[0], a_Size[1], vertex[3], vertex[5]];
|
|
291
|
+
return Array.isArray(size) ? [size[0], size[1]] : [size, 0];
|
|
257
292
|
}
|
|
258
293
|
}
|
|
259
294
|
});
|
|
260
295
|
|
|
261
296
|
// point layer size;
|
|
262
297
|
this.styleAttributeService.registerStyleAttribute({
|
|
263
|
-
name: '
|
|
298
|
+
name: 'normal',
|
|
264
299
|
type: _l7Core.AttributeType.Attribute,
|
|
265
300
|
descriptor: {
|
|
266
|
-
name: '
|
|
301
|
+
name: 'a_Normal',
|
|
267
302
|
shaderLocation: _CommonStyleAttribute.ShaderLocation.NORMAL,
|
|
268
303
|
buffer: {
|
|
304
|
+
// give the WebGL driver a hint that this buffer may change
|
|
269
305
|
usage: _l7Core.gl.STATIC_DRAW,
|
|
270
306
|
data: [],
|
|
271
307
|
type: _l7Core.gl.FLOAT
|
|
272
308
|
},
|
|
273
|
-
size:
|
|
309
|
+
size: 3,
|
|
274
310
|
update: function update(feature, featureIdx, vertex, attributeIdx, normal) {
|
|
275
|
-
return
|
|
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]];
|
|
276
330
|
}
|
|
277
331
|
}
|
|
278
332
|
});
|
|
@@ -3,8 +3,11 @@
|
|
|
3
3
|
|
|
4
4
|
layout(location = 0) in vec3 a_Position;
|
|
5
5
|
layout(location = 1) in vec4 a_Color;
|
|
6
|
-
layout(location =
|
|
7
|
-
layout(location =
|
|
6
|
+
layout(location = 10) in vec2 a_DistanceAndIndex;
|
|
7
|
+
layout(location = 9) in vec2 a_Size;
|
|
8
|
+
layout(location = 11) in float a_Total_Distance;
|
|
9
|
+
layout(location = 13) in vec3 a_Normal;
|
|
10
|
+
layout(location = 15) in float a_Miter;
|
|
8
11
|
layout(location = 14) in vec2 a_iconMapUV;
|
|
9
12
|
|
|
10
13
|
layout(std140) uniform commonUniorm {
|
|
@@ -40,8 +43,8 @@ out vec4 v_texture_data;
|
|
|
40
43
|
|
|
41
44
|
void main() {
|
|
42
45
|
//dash输出
|
|
43
|
-
v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array /
|
|
44
|
-
v_d_distance_ratio =
|
|
46
|
+
v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / a_Total_Distance;
|
|
47
|
+
v_d_distance_ratio = a_DistanceAndIndex.x / a_Total_Distance;
|
|
45
48
|
|
|
46
49
|
// cal style mapping - 数据纹理映射部分的计算
|
|
47
50
|
float d_texPixelLen; // 贴图的像素长度,根据地图层级缩放
|
|
@@ -55,16 +58,16 @@ void main() {
|
|
|
55
58
|
v_color.a *= opacity;
|
|
56
59
|
v_stroke = stroke;
|
|
57
60
|
|
|
58
|
-
vec3 size =
|
|
61
|
+
vec3 size = a_Miter * setPickingSize(a_Size.x) * reverse_offset_normal(a_Normal);
|
|
59
62
|
|
|
60
63
|
vec2 offset = project_pixel(size.xy);
|
|
61
64
|
|
|
62
|
-
float lineDistance =
|
|
63
|
-
float currentLinePointRatio = lineDistance /
|
|
65
|
+
float lineDistance = a_DistanceAndIndex.x;
|
|
66
|
+
float currentLinePointRatio = lineDistance / a_Total_Distance;
|
|
64
67
|
|
|
65
68
|
|
|
66
|
-
float lineOffsetWidth = length(offset + offset * sign(
|
|
67
|
-
float linePixelSize = project_pixel(
|
|
69
|
+
float lineOffsetWidth = length(offset + offset * sign(a_Miter)); // 线横向偏移的距离(向两侧偏移的和)
|
|
70
|
+
float linePixelSize = project_pixel(a_Size.x) * 2.0; // 定点位置偏移,按地图等级缩放后的距离 单侧 * 2
|
|
68
71
|
float texV = lineOffsetWidth/linePixelSize; // 线图层贴图部分的 v 坐标值
|
|
69
72
|
|
|
70
73
|
v_texture_data = vec4(currentLinePointRatio, lineDistance, d_texPixelLen, texV);
|
|
@@ -75,13 +78,13 @@ void main() {
|
|
|
75
78
|
// gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, a_Size.y, 1.0));
|
|
76
79
|
|
|
77
80
|
float h = float(a_Position.z) * u_vertexScale; // 线顶点的高度 - 兼容不存在第三个数值的情况 vertex height
|
|
78
|
-
float lineHeight =
|
|
81
|
+
float lineHeight = a_Size.y; // size 第二个参数代表的高度 [linewidth, lineheight]
|
|
79
82
|
|
|
80
83
|
if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
|
|
81
84
|
lineHeight *= 0.2; // 保持和 amap/mapbox 一致的效果
|
|
82
85
|
h *= 0.2;
|
|
83
86
|
if(u_heightfixed < 1.0) {
|
|
84
|
-
lineHeight = project_pixel(
|
|
87
|
+
lineHeight = project_pixel(a_Size.y);
|
|
85
88
|
}
|
|
86
89
|
gl_Position = u_Mvp * (vec4(project_pos.xy + offset, lineHeight + h + u_raisingHeight, 1.0));
|
|
87
90
|
} else {
|
|
@@ -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/extrude/extrude_frag.glsl' */
|
|
25
|
-
var pointExtrudeFrag = "
|
|
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";
|
|
26
26
|
/* babel-plugin-inline-import '../shaders/extrude/extrude_vert.glsl' */
|
|
27
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;\nout float v_barLinearZ;\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) {
|
package/lib/point/models/fill.js
CHANGED
|
@@ -22,7 +22,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
22
22
|
/* babel-plugin-inline-import '../shaders/fill/fill_frag.glsl' */
|
|
23
23
|
var pointFillFrag = "layout(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\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
|
-
var pointFillVert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in
|
|
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) {
|
|
27
27
|
(0, _inherits2.default)(FillModel, _BaseModel);
|
|
28
28
|
var _super = _createSuper(FillModel);
|
|
@@ -187,10 +187,10 @@ var FillModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
|
187
187
|
|
|
188
188
|
// point layer size;
|
|
189
189
|
this.styleAttributeService.registerStyleAttribute({
|
|
190
|
-
name: '
|
|
190
|
+
name: 'size',
|
|
191
191
|
type: _l7Core.AttributeType.Attribute,
|
|
192
192
|
descriptor: {
|
|
193
|
-
name: '
|
|
193
|
+
name: 'a_Size',
|
|
194
194
|
shaderLocation: _CommonStyleAttribute.ShaderLocation.SIZE,
|
|
195
195
|
buffer: {
|
|
196
196
|
// give the WebGL driver a hint that this buffer may change
|
|
@@ -198,15 +198,34 @@ var FillModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
|
198
198
|
data: [],
|
|
199
199
|
type: _l7Core.gl.FLOAT
|
|
200
200
|
},
|
|
201
|
-
size:
|
|
201
|
+
size: 1,
|
|
202
202
|
update: function update(feature) {
|
|
203
203
|
var _feature$size = feature.size,
|
|
204
204
|
size = _feature$size === void 0 ? 5 : _feature$size;
|
|
205
|
+
return Array.isArray(size) ? [size[0]] : [size];
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
// point layer shape;
|
|
211
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
212
|
+
name: 'shape',
|
|
213
|
+
type: _l7Core.AttributeType.Attribute,
|
|
214
|
+
descriptor: {
|
|
215
|
+
name: 'a_Shape',
|
|
216
|
+
shaderLocation: _CommonStyleAttribute.ShaderLocation.SHAPE,
|
|
217
|
+
buffer: {
|
|
218
|
+
// give the WebGL driver a hint that this buffer may change
|
|
219
|
+
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
220
|
+
data: [],
|
|
221
|
+
type: _l7Core.gl.FLOAT
|
|
222
|
+
},
|
|
223
|
+
size: 1,
|
|
224
|
+
update: function update(feature) {
|
|
205
225
|
var _feature$shape = feature.shape,
|
|
206
226
|
shape = _feature$shape === void 0 ? 2 : _feature$shape;
|
|
207
227
|
var shapeIndex = shape2d.indexOf(shape);
|
|
208
|
-
|
|
209
|
-
return [a_Size, shapeIndex];
|
|
228
|
+
return [shapeIndex];
|
|
210
229
|
}
|
|
211
230
|
}
|
|
212
231
|
});
|
|
@@ -22,7 +22,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
22
22
|
/* babel-plugin-inline-import '../shaders/radar/radar_frag.glsl' */
|
|
23
23
|
var pointFillFrag = "\nlayout(std140) uniform commonUniorm{\n float u_additive;\n float u_size_unit;\n float u_speed: 1.0;\n float u_time;\n};\nin vec4 v_data;\nin vec4 v_color;\nin float v_radius;\nin vec2 v_extrude;\n#pragma include \"sdf_2d\"\n#pragma include \"picking\"\n\nout vec4 outputColor;\n\nvoid main() {\n\n lowp float antialiasblur = v_data.z;\n float r = v_radius / (v_radius);\n\n float outer_df = sdCircle(v_data.xy, 1.0);\n float inner_df = sdCircle(v_data.xy, r);\n\n float opacity_t = smoothstep(0.0, antialiasblur, outer_df);\n\n outputColor = vec4(v_color.rgb, v_color.a);\n\n if(u_additive > 0.0) {\n outputColor *= opacity_t;\n } else {\n outputColor.a *= opacity_t;\n }\n\n if(outputColor.a > 0.0) {\n outputColor = filterColor(outputColor);\n }\n\n vec2 extrude = v_extrude;\n vec2 dir = normalize(extrude);\n vec2 baseDir = vec2(1.0, 0.0);\n float pi = 3.14159265359;\n float flag = sign(dir.y);\n float rades = dot(dir, baseDir);\n float radar_v = (flag - 1.0) * -0.5 * acos(rades)/pi;\n // simple AA\n if(radar_v > 0.99) {\n radar_v = 1.0 - (radar_v - 0.99)/0.01;\n }\n\n outputColor.a *= radar_v;\n}\n";
|
|
24
24
|
/* babel-plugin-inline-import '../shaders/radar/radar_vert.glsl' */
|
|
25
|
-
var pointFillVert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 11) in
|
|
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 = 11) in vec3 a_Extrude;\n\nlayout(std140) uniform commonUniorm {\n float u_additive;\n float u_size_unit;\n float u_speed: 1.0;\n float u_time;\n};\n\nout vec4 v_data;\nout vec4 v_color;\nout float v_radius;\nout vec2 v_extrude;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n float newSize = setPickingSize(a_Size);\n\n float time = u_time * u_speed;\n mat2 rotateMatrix = mat2( \n cos(time), sin(time), \n -sin(time), cos(time)\n );\n v_extrude = rotateMatrix * a_Extrude.xy;\n\n v_color = a_Color;\n v_color.a *= opacity;\n\n float blur = 0.0;\n float antialiasblur = -max(2.0 / u_DevicePixelRatio / a_Size, blur);\n\n if(u_size_unit == 1.) {\n newSize = newSize * u_PixelsPerMeter.z;\n }\n v_radius = newSize;\n\n vec2 offset = (a_Extrude.xy * (newSize));\n vec3 aPosition = a_Position;\n \n offset = project_pixel(offset);\n \n v_data = vec4(a_Extrude.x, a_Extrude.y, antialiasblur, -1.0);\n\n vec4 project_pos = project_position(vec4(aPosition.xy, 0.0, 1.0));\n gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xy + offset, project_pixel(setPickingOrder(0.0)), 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
26
26
|
var RadarModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
27
27
|
(0, _inherits2.default)(RadarModel, _BaseModel);
|
|
28
28
|
var _super = _createSuper(RadarModel);
|
|
@@ -120,10 +120,10 @@ var RadarModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
|
120
120
|
key: "registerBuiltinAttributes",
|
|
121
121
|
value: function registerBuiltinAttributes() {
|
|
122
122
|
this.styleAttributeService.registerStyleAttribute({
|
|
123
|
-
name: '
|
|
123
|
+
name: 'extrude',
|
|
124
124
|
type: _l7Core.AttributeType.Attribute,
|
|
125
125
|
descriptor: {
|
|
126
|
-
name: '
|
|
126
|
+
name: 'a_Extrude',
|
|
127
127
|
shaderLocation: _CommonStyleAttribute.ShaderLocation.EXTRUDE,
|
|
128
128
|
buffer: {
|
|
129
129
|
// give the WebGL driver a hint that this buffer may change
|
|
@@ -131,14 +131,33 @@ var RadarModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
|
131
131
|
data: [],
|
|
132
132
|
type: _l7Core.gl.FLOAT
|
|
133
133
|
},
|
|
134
|
-
size:
|
|
134
|
+
size: 3,
|
|
135
135
|
update: function update(feature, featureIdx, vertex, attributeIdx) {
|
|
136
136
|
var extrude = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0];
|
|
137
137
|
var extrudeIndex = attributeIdx % 4 * 3;
|
|
138
|
+
return [extrude[extrudeIndex], extrude[extrudeIndex + 1], extrude[extrudeIndex + 2]];
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
// point layer size;
|
|
144
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
145
|
+
name: 'size',
|
|
146
|
+
type: _l7Core.AttributeType.Attribute,
|
|
147
|
+
descriptor: {
|
|
148
|
+
shaderLocation: _CommonStyleAttribute.ShaderLocation.SIZE,
|
|
149
|
+
name: 'a_Size',
|
|
150
|
+
buffer: {
|
|
151
|
+
// give the WebGL driver a hint that this buffer may change
|
|
152
|
+
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
153
|
+
data: [],
|
|
154
|
+
type: _l7Core.gl.FLOAT
|
|
155
|
+
},
|
|
156
|
+
size: 1,
|
|
157
|
+
update: function update(feature) {
|
|
138
158
|
var _feature$size = feature.size,
|
|
139
159
|
size = _feature$size === void 0 ? 5 : _feature$size;
|
|
140
|
-
|
|
141
|
-
return [extrude[extrudeIndex], extrude[extrudeIndex + 1], extrude[extrudeIndex + 2], a_Size];
|
|
160
|
+
return Array.isArray(size) ? [size[0]] : [size];
|
|
142
161
|
}
|
|
143
162
|
}
|
|
144
163
|
});
|
package/lib/point/models/text.js
CHANGED
|
@@ -31,7 +31,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
31
31
|
/* babel-plugin-inline-import '../shaders/text/text_frag.glsl' */
|
|
32
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 vec4 v_color;\nin vec4 v_stroke_color;\nin vec2 v_uv;\nin float v_gamma_scale;\nin float v_fontScale;\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 = 14) in
|
|
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\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
|
|
@@ -263,21 +263,38 @@ var TextModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
|
263
263
|
key: "registerBuiltinAttributes",
|
|
264
264
|
value: function registerBuiltinAttributes() {
|
|
265
265
|
this.styleAttributeService.registerStyleAttribute({
|
|
266
|
-
name: '
|
|
266
|
+
name: 'textOffsets',
|
|
267
267
|
type: _l7Core.AttributeType.Attribute,
|
|
268
268
|
descriptor: {
|
|
269
|
-
|
|
269
|
+
shaderLocation: 10,
|
|
270
|
+
name: 'a_textOffsets',
|
|
270
271
|
// 文字偏移量
|
|
271
|
-
shaderLocation: _CommonStyleAttribute.ShaderLocation.UV,
|
|
272
272
|
buffer: {
|
|
273
273
|
// give the WebGL driver a hint that this buffer may change
|
|
274
274
|
usage: _l7Core.gl.STATIC_DRAW,
|
|
275
275
|
data: [],
|
|
276
276
|
type: _l7Core.gl.FLOAT
|
|
277
277
|
},
|
|
278
|
-
size:
|
|
278
|
+
size: 2,
|
|
279
|
+
update: function update(feature, featureIdx, vertex) {
|
|
280
|
+
return [vertex[5], vertex[6]];
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
285
|
+
name: 'textUv',
|
|
286
|
+
type: _l7Core.AttributeType.Attribute,
|
|
287
|
+
descriptor: {
|
|
288
|
+
name: 'a_tex',
|
|
289
|
+
shaderLocation: _CommonStyleAttribute.ShaderLocation.UV,
|
|
290
|
+
buffer: {
|
|
291
|
+
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
292
|
+
data: [],
|
|
293
|
+
type: _l7Core.gl.FLOAT
|
|
294
|
+
},
|
|
295
|
+
size: 2,
|
|
279
296
|
update: function update(feature, featureIdx, vertex) {
|
|
280
|
-
return [vertex[3], vertex[4]
|
|
297
|
+
return [vertex[3], vertex[4]];
|
|
281
298
|
}
|
|
282
299
|
}
|
|
283
300
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
layout(location = 0) in vec3 a_Position;
|
|
2
2
|
layout(location = 1) in vec4 a_Color;
|
|
3
|
-
layout(location = 9) in
|
|
3
|
+
layout(location = 9) in float a_Size;
|
|
4
|
+
layout(location = 10) in float a_Shape;
|
|
4
5
|
layout(location = 11) in vec3 a_Extrude;
|
|
5
6
|
|
|
6
7
|
layout(std140) uniform commonUniforms {
|
|
@@ -26,12 +27,12 @@ void main() {
|
|
|
26
27
|
// 透明度计算
|
|
27
28
|
v_stroke = stroke;
|
|
28
29
|
vec3 extrude = a_Extrude;
|
|
29
|
-
float shape_type =
|
|
30
|
+
float shape_type = a_Shape;
|
|
30
31
|
/*
|
|
31
32
|
* setPickingSize 设置拾取大小
|
|
32
33
|
* u_meter2coord 在等面积大小的时候设置单位
|
|
33
34
|
*/
|
|
34
|
-
float newSize = setPickingSize(
|
|
35
|
+
float newSize = setPickingSize(a_Size);
|
|
35
36
|
// float newSize = setPickingSize(a_Size) * 0.00001038445708445579;
|
|
36
37
|
|
|
37
38
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
layout(location = 0) in vec3 a_Position;
|
|
2
2
|
layout(location = 1) in vec4 a_Color;
|
|
3
|
-
layout(location =
|
|
3
|
+
layout(location = 9) in float a_Size;
|
|
4
|
+
layout(location = 11) in vec3 a_Extrude;
|
|
4
5
|
|
|
5
6
|
layout(std140) uniform commonUniorm {
|
|
6
7
|
float u_additive;
|
|
@@ -18,33 +19,32 @@ out vec2 v_extrude;
|
|
|
18
19
|
#pragma include "picking"
|
|
19
20
|
|
|
20
21
|
void main() {
|
|
21
|
-
|
|
22
|
-
float newSize = setPickingSize(a_ExtrudeAndSize.w);
|
|
22
|
+
float newSize = setPickingSize(a_Size);
|
|
23
23
|
|
|
24
24
|
float time = u_time * u_speed;
|
|
25
25
|
mat2 rotateMatrix = mat2(
|
|
26
26
|
cos(time), sin(time),
|
|
27
27
|
-sin(time), cos(time)
|
|
28
28
|
);
|
|
29
|
-
v_extrude = rotateMatrix *
|
|
29
|
+
v_extrude = rotateMatrix * a_Extrude.xy;
|
|
30
30
|
|
|
31
31
|
v_color = a_Color;
|
|
32
32
|
v_color.a *= opacity;
|
|
33
33
|
|
|
34
34
|
float blur = 0.0;
|
|
35
|
-
float antialiasblur = -max(2.0 / u_DevicePixelRatio /
|
|
35
|
+
float antialiasblur = -max(2.0 / u_DevicePixelRatio / a_Size, blur);
|
|
36
36
|
|
|
37
37
|
if(u_size_unit == 1.) {
|
|
38
38
|
newSize = newSize * u_PixelsPerMeter.z;
|
|
39
39
|
}
|
|
40
40
|
v_radius = newSize;
|
|
41
41
|
|
|
42
|
-
vec2 offset = (
|
|
42
|
+
vec2 offset = (a_Extrude.xy * (newSize));
|
|
43
43
|
vec3 aPosition = a_Position;
|
|
44
44
|
|
|
45
45
|
offset = project_pixel(offset);
|
|
46
46
|
|
|
47
|
-
v_data = vec4(
|
|
47
|
+
v_data = vec4(a_Extrude.x, a_Extrude.y, antialiasblur, -1.0);
|
|
48
48
|
|
|
49
49
|
vec4 project_pos = project_position(vec4(aPosition.xy, 0.0, 1.0));
|
|
50
50
|
gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xy + offset, project_pixel(setPickingOrder(0.0)), 1.0));
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
layout(location = 0) in vec3 a_Position;
|
|
6
6
|
layout(location = 1) in vec4 a_Color;
|
|
7
7
|
layout(location = 9) in float a_Size;
|
|
8
|
-
layout(location =
|
|
8
|
+
layout(location = 10) in vec2 a_textOffsets;
|
|
9
|
+
layout(location = 14) in vec2 a_tex;
|
|
9
10
|
|
|
10
11
|
layout(std140) uniform commonUniforms {
|
|
11
12
|
vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];
|
|
@@ -31,7 +32,7 @@ out float v_fontScale;
|
|
|
31
32
|
void main() {
|
|
32
33
|
// cal style mapping - 数据纹理映射部分的计算
|
|
33
34
|
|
|
34
|
-
v_uv =
|
|
35
|
+
v_uv = a_tex / u_sdf_map_size;
|
|
35
36
|
|
|
36
37
|
|
|
37
38
|
|
|
@@ -45,7 +46,7 @@ void main() {
|
|
|
45
46
|
vec4 project_pos = project_position(vec4(a_Position, 1.0));
|
|
46
47
|
// vec4 projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));
|
|
47
48
|
|
|
48
|
-
vec2 offset = rotate_matrix(
|
|
49
|
+
vec2 offset = rotate_matrix(a_textOffsets,rotation);
|
|
49
50
|
|
|
50
51
|
// gl_Position = vec4(projected_position.xy / projected_position.w + rotation_matrix * a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);
|
|
51
52
|
|
package/lib/raster/index.js
CHANGED
|
@@ -72,7 +72,7 @@ var RaterLayer = exports.default = /*#__PURE__*/function (_BaseLayer) {
|
|
|
72
72
|
// 根据 source 的类型判断 model type
|
|
73
73
|
var parserType = this.layerSource.getParserType();
|
|
74
74
|
switch (parserType) {
|
|
75
|
-
case 'raster':
|
|
75
|
+
case 'raster' || 'ndi':
|
|
76
76
|
return 'raster';
|
|
77
77
|
case 'rasterRgb':
|
|
78
78
|
return 'rasterRgb';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/l7-layers",
|
|
3
|
-
"version": "2.20.
|
|
3
|
+
"version": "2.20.12",
|
|
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.20.
|
|
31
|
-
"@antv/l7-maps": "2.20.
|
|
32
|
-
"@antv/l7-source": "2.20.
|
|
33
|
-
"@antv/l7-utils": "2.20.
|
|
30
|
+
"@antv/l7-core": "2.20.12",
|
|
31
|
+
"@antv/l7-maps": "2.20.12",
|
|
32
|
+
"@antv/l7-source": "2.20.12",
|
|
33
|
+
"@antv/l7-utils": "2.20.12",
|
|
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.20.
|
|
55
|
+
"@antv/l7-test-utils": "2.20.12",
|
|
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": "82fdda60dd4255ce14405f0a780f235a71d7e0b1",
|
|
65
65
|
"publishConfig": {
|
|
66
66
|
"access": "public"
|
|
67
67
|
}
|