@antv/l7-layers 2.12.2 → 2.13.1
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 +18 -7
- package/es/core/TextureService.d.ts +4 -3
- package/es/core/TextureService.js +32 -10
- package/es/core/interface.d.ts +5 -6
- package/es/core/interface.js +7 -0
- package/es/line/index.d.ts +1 -1
- package/es/line/models/index.d.ts +1 -1
- package/es/line/models/index.js +0 -2
- package/es/line/models/line.d.ts +0 -1
- package/es/line/models/line.js +0 -9
- package/es/plugins/DataMappingPlugin.js +10 -7
- package/es/point/index.d.ts +1 -1
- package/es/point/models/fill.d.ts +0 -14
- package/es/point/models/fill.js +9 -100
- package/es/point/models/fillmage.d.ts +0 -5
- package/es/point/models/fillmage.js +15 -65
- package/es/point/models/index.d.ts +1 -1
- package/es/point/models/index.js +0 -4
- package/es/point/models/radar.d.ts +0 -7
- package/es/point/models/radar.js +13 -79
- package/es/point/models/text.js +1 -1
- package/es/point/shaders/fill_vert.glsl +9 -26
- package/es/point/shaders/image/fillImage_vert.glsl +8 -14
- package/es/point/shaders/radar/radar_vert.glsl +12 -19
- package/es/point/shaders/text_vert.glsl +1 -1
- package/es/polygon/index.js +0 -2
- package/es/polygon/models/index.d.ts +1 -1
- package/es/polygon/models/index.js +2 -4
- package/es/raster/models/raster.d.ts +0 -2
- package/es/raster/models/raster.js +6 -22
- package/es/raster/models/rasterTerrainRgb.js +6 -6
- package/es/raster/shaders/raster_2d_frag.glsl +1 -0
- package/es/tile/tileFactory/RasterRGBTile.js +0 -1
- package/es/tile/tileFactory/RasterTile.js +13 -8
- package/lib/core/BaseLayer.js +17 -6
- package/lib/core/TextureService.js +31 -9
- package/lib/core/interface.js +9 -1
- package/lib/line/models/index.js +0 -3
- package/lib/line/models/line.js +0 -8
- package/lib/plugins/DataMappingPlugin.js +10 -7
- package/lib/point/models/fill.js +8 -98
- package/lib/point/models/fillmage.js +16 -67
- package/lib/point/models/index.js +0 -6
- package/lib/point/models/radar.js +13 -80
- package/lib/point/models/text.js +1 -1
- package/lib/point/shaders/fill_vert.glsl +9 -26
- package/lib/point/shaders/image/fillImage_vert.glsl +8 -14
- package/lib/point/shaders/radar/radar_vert.glsl +12 -19
- package/lib/point/shaders/text_vert.glsl +1 -1
- package/lib/polygon/index.js +0 -2
- package/lib/polygon/models/index.js +2 -5
- package/lib/raster/models/raster.js +5 -21
- package/lib/raster/models/rasterTerrainRgb.js +5 -5
- package/lib/raster/shaders/raster_2d_frag.glsl +1 -0
- package/lib/tile/tileFactory/RasterTile.js +14 -8
- package/package.json +6 -6
- package/es/line/models/tile.d.ts +0 -8
- package/es/line/models/tile.js +0 -201
- package/es/line/shaders/tile/line_tile_map_vert.glsl +0 -25
- package/es/line/shaders/tile/line_tile_vert.glsl +0 -52
- package/es/line/shaders/tile/simpleline_map_vert.glsl +0 -15
- package/es/line/shaders/tile/simpleline_vert.glsl +0 -21
- package/es/point/models/tile.d.ts +0 -15
- package/es/point/models/tile.js +0 -217
- package/es/point/models/tileText.d.ts +0 -52
- package/es/point/models/tileText.js +0 -544
- package/es/point/shaders/tile/fill_tile_frag.glsl +0 -76
- package/es/point/shaders/tile/fill_tile_vert.glsl +0 -78
- package/es/point/shaders/tile/text_frag.glsl +0 -33
- package/es/point/shaders/tile/text_map_frag.glsl +0 -31
- package/es/point/shaders/tile/text_map_vert.glsl +0 -38
- package/es/point/shaders/tile/text_vert.glsl +0 -48
- package/es/polygon/models/tile.d.ts +0 -12
- package/es/polygon/models/tile.js +0 -141
- package/es/polygon/shaders/tile/polygon_tile_map_vert.glsl +0 -16
- package/es/polygon/shaders/tile/polygon_tile_vert.glsl +0 -42
- package/es/raster/models/rasterTile.d.ts +0 -18
- package/es/raster/models/rasterTile.js +0 -180
- package/es/tile/tileFactory/layers/RasterDataLayer.d.ts +0 -11
- package/es/tile/tileFactory/layers/RasterDataLayer.js +0 -89
- package/lib/line/models/tile.js +0 -217
- package/lib/line/shaders/tile/line_tile_map_vert.glsl +0 -25
- package/lib/line/shaders/tile/line_tile_vert.glsl +0 -52
- package/lib/line/shaders/tile/simpleline_map_vert.glsl +0 -15
- package/lib/line/shaders/tile/simpleline_vert.glsl +0 -21
- package/lib/point/models/tile.js +0 -233
- package/lib/point/models/tileText.js +0 -560
- package/lib/point/shaders/tile/fill_tile_frag.glsl +0 -76
- package/lib/point/shaders/tile/fill_tile_vert.glsl +0 -78
- package/lib/point/shaders/tile/text_frag.glsl +0 -33
- package/lib/point/shaders/tile/text_map_frag.glsl +0 -31
- package/lib/point/shaders/tile/text_map_vert.glsl +0 -38
- package/lib/point/shaders/tile/text_vert.glsl +0 -48
- package/lib/polygon/models/tile.js +0 -156
- package/lib/polygon/shaders/tile/polygon_tile_map_vert.glsl +0 -16
- package/lib/polygon/shaders/tile/polygon_tile_vert.glsl +0 -42
- package/lib/raster/models/rasterTile.js +0 -196
- package/lib/tile/tileFactory/layers/RasterDataLayer.js +0 -105
package/lib/point/models/text.js
CHANGED
|
@@ -54,7 +54,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
54
54
|
var textFrag = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 48.0\nuniform sampler2D u_sdf_map;\nuniform float u_gamma_scale : 0.5;\n// uniform float u_font_size : 24.0;\nuniform float u_opacity : 1.0;\nuniform vec4 u_stroke_color : [0, 0, 0, 1];\nuniform float u_stroke_width : 2.0;\nuniform float u_halo_blur : 0.5;\nuniform float u_DevicePixelRatio;\n\nvarying vec4 v_color;\nvarying vec2 v_uv;\nvarying float v_gamma_scale;\nvarying float v_fontScale;\n\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n\n#pragma include \"picking\"\nvoid main() {\n // get style data mapping\n float opacity = styleMappingMat[0][0];\n float strokeWidth = styleMappingMat[0][2];\n vec4 textrueStroke = vec4(\n styleMappingMat[1][0],\n styleMappingMat[1][1],\n styleMappingMat[1][2],\n styleMappingMat[1][3]\n );\n\n // get sdf from atlas\n float dist = texture2D(u_sdf_map, v_uv).a;\n\n // float fontScale = u_font_size / FONT_SIZE;\n\n // lowp float buff = (6.0 - u_stroke_width / v_fontScale) / SDF_PX;\n lowp float buff = (6.0 - strokeWidth / 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 // gl_FragColor = mix(vec4(v_color.rgb, v_color.a * u_opacity), vec4(u_stroke_color.rgb, u_stroke_color.a * u_opacity), smoothstep(0., 0.5, 1. - dist));\n gl_FragColor = mix(vec4(v_color.rgb, v_color.a * opacity), vec4(textrueStroke.rgb, textrueStroke.a * opacity), smoothstep(0., 0.5, 1. - dist));\n gl_FragColor.a= gl_FragColor.a * alpha;\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
|
|
55
55
|
|
|
56
56
|
/* babel-plugin-inline-import '../shaders/text_vert.glsl' */
|
|
57
|
-
var textVert = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 24.0\nattribute vec3 a_Position;\nattribute vec2 a_tex;\nattribute vec2 a_textOffsets;\nattribute vec4 a_Color;\nattribute float a_Size;\nattribute float a_Rotate;\n\nuniform vec2 u_sdf_map_size;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform float u_raisingHeight: 0.0;\n\nvarying vec2 v_uv;\nvarying float v_gamma_scale;\nvarying vec4 v_color;\nvarying float v_fontScale;\n\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\nuniform float u_opacity : 1;\nuniform float u_stroke_width : 2;\nuniform vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n#pragma include \"styleMappingCalStrokeWidth\"\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n\n vec2 strokeWidthAndOffset = calStrokeWidthAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][2] = strokeWidthAndOffset.r;\n textureOffset = strokeWidthAndOffset.g;\n\n vec4 textrueStroke = vec4(-1.0, -1.0, -1.0, -1.0);\n if(hasStroke()) {\n vec2 valueRPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][0] = pos2value(valueRPos, columnWidth, rowHeight); // R\n textureOffset += 1.0;\n\n vec2 valueGPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][1] = pos2value(valueGPos, columnWidth, rowHeight); // G\n textureOffset += 1.0;\n\n vec2 valueBPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][2] = pos2value(valueBPos, columnWidth, rowHeight); // B\n textureOffset += 1.0;\n\n vec2 valueAPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][3] = pos2value(valueAPos, columnWidth, rowHeight); // A\n textureOffset += 1.0;\n } else {\n if(u_stroke_color == vec4(0.0)) {\n styleMappingMat[1][0] = v_color.r;\n styleMappingMat[1][1] = v_color.g;\n styleMappingMat[1][2] = v_color.b;\n styleMappingMat[1][3] = v_color.a;\n } else {\n styleMappingMat[1][0] = u_stroke_color.r;\n styleMappingMat[1][1] = u_stroke_color.g;\n styleMappingMat[1][2] = u_stroke_color.b;\n styleMappingMat[1][3] = u_stroke_color.a;\n }\n }\n \n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n v_color = a_Color;\n v_uv = a_tex / u_sdf_map_size;\n\n // \u6587\u672C\u7F29\u653E\u6BD4\u4F8B\n float fontScale = a_Size / FONT_SIZE;\n v_fontScale = fontScale;\n\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n // vec4 projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n highp float angle_sin = sin(a_Rotate);\n highp float angle_cos = cos(a_Rotate);\n mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);\n \n // gl_Position = vec4(projected_position.xy / projected_position.w + rotation_matrix * a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);\n\n float raiseHeight = u_raisingHeight;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n raiseHeight = u_raisingHeight * mapboxZoomScale;\n }\n\n vec4 projected_position;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n projected_position = u_Mvp *
|
|
57
|
+
var textVert = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 24.0\nattribute vec3 a_Position;\nattribute vec2 a_tex;\nattribute vec2 a_textOffsets;\nattribute vec4 a_Color;\nattribute float a_Size;\nattribute float a_Rotate;\n\nuniform vec2 u_sdf_map_size;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform float u_raisingHeight: 0.0;\n\nvarying vec2 v_uv;\nvarying float v_gamma_scale;\nvarying vec4 v_color;\nvarying float v_fontScale;\n\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\nuniform float u_opacity : 1;\nuniform float u_stroke_width : 2;\nuniform vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n#pragma include \"styleMappingCalStrokeWidth\"\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n\n vec2 strokeWidthAndOffset = calStrokeWidthAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][2] = strokeWidthAndOffset.r;\n textureOffset = strokeWidthAndOffset.g;\n\n vec4 textrueStroke = vec4(-1.0, -1.0, -1.0, -1.0);\n if(hasStroke()) {\n vec2 valueRPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][0] = pos2value(valueRPos, columnWidth, rowHeight); // R\n textureOffset += 1.0;\n\n vec2 valueGPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][1] = pos2value(valueGPos, columnWidth, rowHeight); // G\n textureOffset += 1.0;\n\n vec2 valueBPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][2] = pos2value(valueBPos, columnWidth, rowHeight); // B\n textureOffset += 1.0;\n\n vec2 valueAPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][3] = pos2value(valueAPos, columnWidth, rowHeight); // A\n textureOffset += 1.0;\n } else {\n if(u_stroke_color == vec4(0.0)) {\n styleMappingMat[1][0] = v_color.r;\n styleMappingMat[1][1] = v_color.g;\n styleMappingMat[1][2] = v_color.b;\n styleMappingMat[1][3] = v_color.a;\n } else {\n styleMappingMat[1][0] = u_stroke_color.r;\n styleMappingMat[1][1] = u_stroke_color.g;\n styleMappingMat[1][2] = u_stroke_color.b;\n styleMappingMat[1][3] = u_stroke_color.a;\n }\n }\n \n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n v_color = a_Color;\n v_uv = a_tex / u_sdf_map_size;\n\n // \u6587\u672C\u7F29\u653E\u6BD4\u4F8B\n float fontScale = a_Size / FONT_SIZE;\n v_fontScale = fontScale;\n\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n // vec4 projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n highp float angle_sin = sin(a_Rotate);\n highp float angle_cos = cos(a_Rotate);\n mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);\n \n // gl_Position = vec4(projected_position.xy / projected_position.w + rotation_matrix * a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);\n\n float raiseHeight = u_raisingHeight;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n raiseHeight = u_raisingHeight * mapboxZoomScale;\n }\n\n vec4 projected_position;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n projected_position = u_Mvp *(vec4(a_Position.xyz + vec3(0.0, 0.0, raiseHeight), 1.0));\n } else { // else\n projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz + vec3(0.0, 0.0, raiseHeight), 1.0));\n }\n\n gl_Position = vec4(\n projected_position.xy / projected_position.w + rotation_matrix * a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);\n v_gamma_scale = gl_Position.w;\n setPickingColor(a_PickingColor);\n\n}\n";
|
|
58
58
|
|
|
59
59
|
function TextTriangulation(feature) {
|
|
60
60
|
// @ts-ignore
|
|
@@ -8,9 +8,7 @@ varying mat4 styleMappingMat; // 用于将在顶点着色器中计算好的样
|
|
|
8
8
|
|
|
9
9
|
uniform mat4 u_ModelMatrix;
|
|
10
10
|
uniform mat4 u_Mvp;
|
|
11
|
-
uniform
|
|
12
|
-
uniform float u_meteryScale;
|
|
13
|
-
uniform float u_isMeter;
|
|
11
|
+
uniform int u_Size_Unit;
|
|
14
12
|
|
|
15
13
|
varying vec4 v_data;
|
|
16
14
|
varying vec4 v_color;
|
|
@@ -42,7 +40,7 @@ void main() {
|
|
|
42
40
|
* setPickingSize 设置拾取大小
|
|
43
41
|
* u_meter2coord 在等面积大小的时候设置单位
|
|
44
42
|
*/
|
|
45
|
-
float newSize = setPickingSize(a_Size)
|
|
43
|
+
float newSize = setPickingSize(a_Size);
|
|
46
44
|
// float newSize = setPickingSize(a_Size) * 0.00001038445708445579;
|
|
47
45
|
|
|
48
46
|
// cal style mapping - 数据纹理映射部分的计算
|
|
@@ -126,9 +124,11 @@ void main() {
|
|
|
126
124
|
|
|
127
125
|
// unpack color(vec2)
|
|
128
126
|
v_color = a_Color;
|
|
127
|
+
if(u_Size_Unit == 1) {
|
|
128
|
+
newSize = newSize * u_PixelsPerMeter.z;
|
|
129
|
+
}
|
|
129
130
|
|
|
130
|
-
|
|
131
|
-
v_radius = newSize;
|
|
131
|
+
v_radius = newSize;
|
|
132
132
|
|
|
133
133
|
// anti-alias
|
|
134
134
|
// float antialiased_blur = -max(u_blur, antialiasblur);
|
|
@@ -136,26 +136,9 @@ void main() {
|
|
|
136
136
|
|
|
137
137
|
vec2 offset = (extrude.xy * (newSize + u_stroke_width) + textrueOffsets);
|
|
138
138
|
vec3 aPosition = a_Position;
|
|
139
|
-
if(u_isMeter < 1.0) {
|
|
140
|
-
// 不以米为实际单位
|
|
141
|
-
offset = project_pixel(offset);
|
|
142
|
-
} else {
|
|
143
|
-
// 以米为实际单位
|
|
144
|
-
if(newSize * pow(2.0, u_Zoom) < 48.0) {
|
|
145
|
-
antialiasblur = max(antialiasblur, -0.05);
|
|
146
|
-
} else if(newSize * pow(2.0, u_Zoom) < 128.0) {
|
|
147
|
-
antialiasblur = max(antialiasblur, -0.6/pow(u_Zoom, 2.0));
|
|
148
|
-
} else {
|
|
149
|
-
antialiasblur = max(antialiasblur, -0.8/pow(u_Zoom, 2.0));
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {
|
|
153
|
-
aPosition.x += offset.x / u_meteryScale;
|
|
154
|
-
aPosition.y += offset.y;
|
|
155
|
-
offset = vec2(0.0);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
139
|
|
|
140
|
+
offset = project_pixel(offset);
|
|
141
|
+
|
|
159
142
|
// TODP: /abs(extrude.x) 是为了兼容地球模式
|
|
160
143
|
v_data = vec4(extrude.x/abs(extrude.x), extrude.y/abs(extrude.y), antialiasblur,shape_type);
|
|
161
144
|
|
|
@@ -177,7 +160,7 @@ void main() {
|
|
|
177
160
|
|
|
178
161
|
|
|
179
162
|
if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
|
|
180
|
-
gl_Position =
|
|
163
|
+
gl_Position = u_Mvp * vec4(project_pos.xy + offset, raisingHeight, 1.0);
|
|
181
164
|
} else {
|
|
182
165
|
gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, raisingHeight, 1.0));
|
|
183
166
|
}
|
|
@@ -10,7 +10,7 @@ varying mat4 styleMappingMat; // 用于将在顶点着色器中计算好的样
|
|
|
10
10
|
uniform mat4 u_ModelMatrix;
|
|
11
11
|
uniform mat4 u_Mvp;
|
|
12
12
|
uniform mat2 u_RotateMatrix;
|
|
13
|
-
uniform
|
|
13
|
+
uniform int u_Size_Unit;
|
|
14
14
|
|
|
15
15
|
varying vec2 v_uv; // 本身的 uv 坐标
|
|
16
16
|
varying vec2 v_Iconuv; // icon 贴图的 uv 坐标
|
|
@@ -76,22 +76,16 @@ void main() {
|
|
|
76
76
|
highp float angle_sin = sin(a_Rotate);
|
|
77
77
|
highp float angle_cos = cos(a_Rotate);
|
|
78
78
|
mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);
|
|
79
|
+
float newSize = a_Size;
|
|
80
|
+
if(u_Size_Unit == 1) {
|
|
81
|
+
newSize = newSize * u_PixelsPerMeter.z;
|
|
82
|
+
}
|
|
79
83
|
|
|
80
84
|
// vec2 offset = (u_RotateMatrix * extrude.xy * (a_Size) + textrueOffsets);
|
|
81
|
-
vec2 offset = (rotation_matrix * u_RotateMatrix * extrude.xy * (
|
|
85
|
+
vec2 offset = (rotation_matrix * u_RotateMatrix * extrude.xy * (newSize) + textrueOffsets);
|
|
82
86
|
vec3 aPosition = a_Position;
|
|
83
|
-
if(u_isMeter < 1.0) {
|
|
84
|
-
// 不以米为实际单位
|
|
85
|
-
offset = project_pixel(offset);
|
|
86
|
-
} else {
|
|
87
|
-
// 以米为实际单位
|
|
88
87
|
|
|
89
|
-
|
|
90
|
-
aPosition.xy += offset;
|
|
91
|
-
offset.x = 0.0;
|
|
92
|
-
offset.y = 0.0;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
88
|
+
offset = project_pixel(offset);
|
|
95
89
|
|
|
96
90
|
vec4 project_pos = project_position(vec4(aPosition.xy, 0.0, 1.0));
|
|
97
91
|
float raisingHeight = u_raisingHeight;
|
|
@@ -105,7 +99,7 @@ void main() {
|
|
|
105
99
|
}
|
|
106
100
|
|
|
107
101
|
if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
|
|
108
|
-
gl_Position = u_Mvp *
|
|
102
|
+
gl_Position = u_Mvp *vec4(project_pos.xy + offset, raisingHeight, 1.0);
|
|
109
103
|
} else {
|
|
110
104
|
gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, raisingHeight, 1.0));
|
|
111
105
|
}
|
|
@@ -7,7 +7,7 @@ uniform float u_time;
|
|
|
7
7
|
|
|
8
8
|
uniform mat4 u_ModelMatrix;
|
|
9
9
|
uniform mat4 u_Mvp;
|
|
10
|
-
uniform
|
|
10
|
+
uniform int u_Size_Unit;
|
|
11
11
|
|
|
12
12
|
varying vec4 v_data;
|
|
13
13
|
varying vec4 v_color;
|
|
@@ -31,37 +31,30 @@ void main() {
|
|
|
31
31
|
// unpack color(vec2)
|
|
32
32
|
v_color = a_Color;
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
v_radius = newSize;
|
|
34
|
+
|
|
36
35
|
|
|
37
36
|
// anti-alias
|
|
38
37
|
float blur = 0.0;
|
|
39
38
|
float antialiasblur = -max(2.0 / u_DevicePixelRatio / a_Size, blur);
|
|
40
39
|
|
|
40
|
+
if(u_Size_Unit == 1) {
|
|
41
|
+
newSize = newSize * u_PixelsPerMeter.z;
|
|
42
|
+
}
|
|
43
|
+
// radius(16-bit)
|
|
44
|
+
v_radius = newSize;
|
|
45
|
+
|
|
41
46
|
vec2 offset = (extrude.xy * (newSize));
|
|
42
47
|
vec3 aPosition = a_Position;
|
|
43
|
-
|
|
48
|
+
|
|
44
49
|
// 不以米为实际单位
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
// 以米为实际单位
|
|
48
|
-
antialiasblur *= pow(19.0 - u_Zoom, 2.0);
|
|
49
|
-
antialiasblur = max(antialiasblur, -0.01);
|
|
50
|
-
// offset *= 0.5;
|
|
51
|
-
|
|
52
|
-
if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {
|
|
53
|
-
aPosition.xy += offset;
|
|
54
|
-
offset.x = 0.0;
|
|
55
|
-
offset.y = 0.0;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
50
|
+
offset = project_pixel(offset);
|
|
51
|
+
|
|
59
52
|
v_data = vec4(extrude.x, extrude.y, antialiasblur, -1.0);
|
|
60
53
|
|
|
61
54
|
vec4 project_pos = project_position(vec4(aPosition.xy, 0.0, 1.0));
|
|
62
55
|
|
|
63
56
|
if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
|
|
64
|
-
gl_Position = u_Mvp *
|
|
57
|
+
gl_Position = u_Mvp *vec4(project_pos.xy + offset, 0.0, 1.0);
|
|
65
58
|
} else {
|
|
66
59
|
gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, project_pixel(setPickingOrder(0.0)), 1.0));
|
|
67
60
|
}
|
|
@@ -118,7 +118,7 @@ void main() {
|
|
|
118
118
|
|
|
119
119
|
vec4 projected_position;
|
|
120
120
|
if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
|
|
121
|
-
projected_position = u_Mvp *
|
|
121
|
+
projected_position = u_Mvp *(vec4(a_Position.xyz + vec3(0.0, 0.0, raiseHeight), 1.0));
|
|
122
122
|
} else { // else
|
|
123
123
|
projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz + vec3(0.0, 0.0, raiseHeight), 1.0));
|
|
124
124
|
}
|
package/lib/polygon/index.js
CHANGED
|
@@ -25,8 +25,6 @@ var _fill2 = _interopRequireDefault(require("./fill"));
|
|
|
25
25
|
|
|
26
26
|
var _ocean = _interopRequireDefault(require("./ocean"));
|
|
27
27
|
|
|
28
|
-
var _tile = _interopRequireDefault(require("./tile"));
|
|
29
|
-
|
|
30
28
|
var _water = _interopRequireDefault(require("./water"));
|
|
31
29
|
|
|
32
30
|
var PolygonModels = {
|
|
@@ -39,9 +37,8 @@ var PolygonModels = {
|
|
|
39
37
|
point_normal: _normal.default,
|
|
40
38
|
point_extrude: _extrude.default,
|
|
41
39
|
water: _water.default,
|
|
42
|
-
ocean: _ocean.default,
|
|
43
|
-
|
|
44
|
-
tile: _tile.default
|
|
40
|
+
ocean: _ocean.default // point_fill: PointModels.fill,
|
|
41
|
+
|
|
45
42
|
};
|
|
46
43
|
var _default = PolygonModels;
|
|
47
44
|
exports.default = _default;
|
|
@@ -34,7 +34,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
34
34
|
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; } }
|
|
35
35
|
|
|
36
36
|
/* babel-plugin-inline-import '../shaders/raster_2d_frag.glsl' */
|
|
37
|
-
var rasterFrag = "precision mediump float;\nuniform float u_opacity: 1.0;\nuniform sampler2D u_texture;\nuniform sampler2D u_colorTexture;\nuniform float u_min;\nuniform float u_max;\nuniform vec2 u_domain;\nuniform float u_noDataValue;\nuniform bool u_clampLow: true;\nuniform bool u_clampHigh: true;\nvarying vec2 v_texCoord;\nbool isnan_emu(float x) { return (x > 0.0 || x < 0.0) ? x != x : x != 0.0; }\n\n\nvoid main() {\n\n float value = texture2D(u_texture,vec2(v_texCoord.x,v_texCoord.y)).r;\n if (value == u_noDataValue || isnan_emu(value))\n gl_FragColor = vec4(0.0, 0, 0, 0.0);\n else if ((!u_clampLow && value < u_domain[0]) || (!u_clampHigh && value > u_domain[1]))\n gl_FragColor = vec4(0, 0, 0, 0);\n else {\n float normalisedValue =(value - u_domain[0]) / (u_domain[1] -u_domain[0]);\n vec4 color = texture2D(u_colorTexture,vec2(normalisedValue, 0));\n gl_FragColor = color;\n gl_FragColor.a = gl_FragColor.a * u_opacity ;\n }\n}\n";
|
|
37
|
+
var rasterFrag = "precision mediump float;\nuniform float u_opacity: 1.0;\nuniform sampler2D u_texture;\nuniform sampler2D u_colorTexture;\nuniform float u_min;\nuniform float u_max;\nuniform vec2 u_domain;\nuniform float u_noDataValue;\nuniform bool u_clampLow: true;\nuniform bool u_clampHigh: true;\nvarying vec2 v_texCoord;\nbool isnan_emu(float x) { return (x > 0.0 || x < 0.0) ? x != x : x != 0.0; }\n\n\nvoid main() {\n\n float value = texture2D(u_texture,vec2(v_texCoord.x,v_texCoord.y)).r;\n if (value == u_noDataValue || isnan_emu(value))\n gl_FragColor = vec4(0.0, 0, 0, 0.0);\n else if ((!u_clampLow && value < u_domain[0]) || (!u_clampHigh && value > u_domain[1]))\n gl_FragColor = vec4(0, 0, 0, 0);\n else {\n \n float normalisedValue =(value - u_domain[0]) / (u_domain[1] -u_domain[0]);\n vec4 color = texture2D(u_colorTexture,vec2(normalisedValue, 0));\n gl_FragColor = color;\n gl_FragColor.a = gl_FragColor.a * u_opacity ;\n }\n}\n";
|
|
38
38
|
|
|
39
39
|
/* babel-plugin-inline-import '../shaders/raster_2d_vert.glsl' */
|
|
40
40
|
var rasterVert = "precision highp float;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nattribute vec3 a_Position;\nattribute vec2 a_Uv;\nvarying vec2 v_texCoord;\n#pragma include \"projection\"\nvoid main() {\n v_texCoord = a_Uv;\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xy,0., 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy,0., 1.0));\n }\n}\n";
|
|
@@ -61,15 +61,15 @@ var RasterModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
61
61
|
clampHigh = _ref$clampHigh === void 0 ? true : _ref$clampHigh,
|
|
62
62
|
_ref$noDataValue = _ref.noDataValue,
|
|
63
63
|
noDataValue = _ref$noDataValue === void 0 ? -9999999 : _ref$noDataValue,
|
|
64
|
-
|
|
65
|
-
domain = _ref$domain === void 0 ? [0, 1] : _ref$domain,
|
|
64
|
+
domain = _ref.domain,
|
|
66
65
|
rampColors = _ref.rampColors;
|
|
67
66
|
|
|
68
|
-
|
|
67
|
+
var newdomain = domain || (0, _l7Utils.getDefaultDomain)(rampColors);
|
|
68
|
+
this.colorTexture = this.layer.textureService.getColorTexture(rampColors, newdomain);
|
|
69
69
|
return {
|
|
70
70
|
u_opacity: opacity || 1,
|
|
71
71
|
u_texture: this.texture,
|
|
72
|
-
u_domain:
|
|
72
|
+
u_domain: newdomain,
|
|
73
73
|
u_clampLow: clampLow,
|
|
74
74
|
u_clampHigh: typeof clampHigh !== 'undefined' ? clampHigh : clampLow,
|
|
75
75
|
u_noDataValue: noDataValue,
|
|
@@ -245,22 +245,6 @@ var RasterModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
245
245
|
}
|
|
246
246
|
});
|
|
247
247
|
}
|
|
248
|
-
}, {
|
|
249
|
-
key: "updateColorTexture",
|
|
250
|
-
value: function updateColorTexture() {
|
|
251
|
-
var createTexture2D = this.rendererService.createTexture2D;
|
|
252
|
-
|
|
253
|
-
var _ref3 = this.layer.getLayerConfig(),
|
|
254
|
-
rampColors = _ref3.rampColors;
|
|
255
|
-
|
|
256
|
-
var imageData = (0, _l7Utils.generateColorRamp)(rampColors);
|
|
257
|
-
this.colorTexture = createTexture2D({
|
|
258
|
-
data: imageData.data,
|
|
259
|
-
width: imageData.width,
|
|
260
|
-
height: imageData.height,
|
|
261
|
-
flipY: false
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
248
|
}]);
|
|
265
249
|
return RasterModel;
|
|
266
250
|
}(_BaseModel2.default);
|
|
@@ -60,23 +60,23 @@ var RasterTerrainRGB = /*#__PURE__*/function (_BaseModel) {
|
|
|
60
60
|
clampHigh = _ref$clampHigh === void 0 ? true : _ref$clampHigh,
|
|
61
61
|
_ref$noDataValue = _ref.noDataValue,
|
|
62
62
|
noDataValue = _ref$noDataValue === void 0 ? -9999999 : _ref$noDataValue,
|
|
63
|
-
|
|
64
|
-
domain = _ref$domain === void 0 ? [0, 1] : _ref$domain,
|
|
63
|
+
domain = _ref.domain,
|
|
65
64
|
rampColors = _ref.rampColors,
|
|
66
65
|
colorTexture = _ref.colorTexture;
|
|
67
66
|
|
|
67
|
+
var newdomain = domain || (0, _l7Utils.getDefaultDomain)(rampColors);
|
|
68
68
|
var texture = colorTexture;
|
|
69
69
|
|
|
70
70
|
if (!colorTexture) {
|
|
71
|
-
texture = this.layer.textureService.getColorTexture(rampColors);
|
|
71
|
+
texture = this.layer.textureService.getColorTexture(rampColors, newdomain);
|
|
72
72
|
} else {
|
|
73
|
-
this.layer.textureService.setColorTexture(colorTexture, rampColors);
|
|
73
|
+
this.layer.textureService.setColorTexture(colorTexture, rampColors, newdomain);
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
return {
|
|
77
77
|
u_opacity: opacity || 1,
|
|
78
78
|
u_texture: this.texture,
|
|
79
|
-
u_domain:
|
|
79
|
+
u_domain: newdomain,
|
|
80
80
|
u_clampLow: clampLow,
|
|
81
81
|
u_clampHigh: typeof clampHigh !== 'undefined' ? clampHigh : clampLow,
|
|
82
82
|
u_noDataValue: noDataValue,
|
|
@@ -20,6 +20,7 @@ void main() {
|
|
|
20
20
|
else if ((!u_clampLow && value < u_domain[0]) || (!u_clampHigh && value > u_domain[1]))
|
|
21
21
|
gl_FragColor = vec4(0, 0, 0, 0);
|
|
22
22
|
else {
|
|
23
|
+
|
|
23
24
|
float normalisedValue =(value - u_domain[0]) / (u_domain[1] -u_domain[0]);
|
|
24
25
|
vec4 color = texture2D(u_colorTexture,vec2(normalisedValue, 0));
|
|
25
26
|
gl_FragColor = color;
|
|
@@ -29,6 +29,8 @@ var _raster = _interopRequireDefault(require("../../raster"));
|
|
|
29
29
|
|
|
30
30
|
var _Tile2 = _interopRequireDefault(require("./Tile"));
|
|
31
31
|
|
|
32
|
+
var _l7Utils = require("@antv/l7-utils");
|
|
33
|
+
|
|
32
34
|
var _excluded = ["rasterData"];
|
|
33
35
|
|
|
34
36
|
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); }; }
|
|
@@ -54,7 +56,8 @@ var RasterTile = /*#__PURE__*/function (_Tile) {
|
|
|
54
56
|
key: "initTileLayer",
|
|
55
57
|
value: function () {
|
|
56
58
|
var _initTileLayer = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
57
|
-
var attributes, layerOptions, sourceOptions, layer;
|
|
59
|
+
var attributes, layerOptions, sourceOptions, _ref, rampColors, domain, layer;
|
|
60
|
+
|
|
58
61
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
59
62
|
while (1) {
|
|
60
63
|
switch (_context.prev = _context.next) {
|
|
@@ -62,7 +65,8 @@ var RasterTile = /*#__PURE__*/function (_Tile) {
|
|
|
62
65
|
attributes = this.parent.getLayerAttributeConfig();
|
|
63
66
|
layerOptions = this.getLayerOptions();
|
|
64
67
|
sourceOptions = this.getSourceOption();
|
|
65
|
-
|
|
68
|
+
_ref = this.getLayerOptions(), rampColors = _ref.rampColors, domain = _ref.domain;
|
|
69
|
+
this.colorTexture = this.parent.textureService.getColorTexture(rampColors, domain);
|
|
66
70
|
layer = new _raster.default((0, _objectSpread2.default)((0, _objectSpread2.default)({}, layerOptions), {}, {
|
|
67
71
|
colorTexture: this.colorTexture
|
|
68
72
|
})).source(sourceOptions.data, sourceOptions.options); // 初始化数据映射
|
|
@@ -74,13 +78,13 @@ var RasterTile = /*#__PURE__*/function (_Tile) {
|
|
|
74
78
|
|
|
75
79
|
layer[attr]((_attributes$attr = attributes[attr]) === null || _attributes$attr === void 0 ? void 0 : _attributes$attr.field, (_attributes$attr2 = attributes[attr]) === null || _attributes$attr2 === void 0 ? void 0 : _attributes$attr2.values);
|
|
76
80
|
});
|
|
77
|
-
_context.next =
|
|
81
|
+
_context.next = 9;
|
|
78
82
|
return this.addLayer(layer);
|
|
79
83
|
|
|
80
|
-
case
|
|
84
|
+
case 9:
|
|
81
85
|
this.isLoaded = true;
|
|
82
86
|
|
|
83
|
-
case
|
|
87
|
+
case 10:
|
|
84
88
|
case "end":
|
|
85
89
|
return _context.stop();
|
|
86
90
|
}
|
|
@@ -126,9 +130,11 @@ var RasterTile = /*#__PURE__*/function (_Tile) {
|
|
|
126
130
|
arg[_key] = arguments[_key];
|
|
127
131
|
}
|
|
128
132
|
|
|
129
|
-
var
|
|
130
|
-
rampColors =
|
|
131
|
-
|
|
133
|
+
var _ref2 = arg,
|
|
134
|
+
_ref2$rampColors = _ref2.rampColors,
|
|
135
|
+
rampColors = _ref2$rampColors === void 0 ? DEFAULT_COLOR_TEXTURE_OPTION : _ref2$rampColors,
|
|
136
|
+
domain = _ref2.domain;
|
|
137
|
+
this.colorTexture = this.parent.textureService.getColorTexture(rampColors, domain || (0, _l7Utils.getDefaultDomain)(rampColors));
|
|
132
138
|
this.layers.forEach(function (layer) {
|
|
133
139
|
return layer.style({
|
|
134
140
|
colorTexture: _this.colorTexture
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/l7-layers",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.13.1",
|
|
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.
|
|
31
|
-
"@antv/l7-maps": "2.
|
|
32
|
-
"@antv/l7-source": "2.
|
|
33
|
-
"@antv/l7-utils": "2.
|
|
30
|
+
"@antv/l7-core": "2.13.1",
|
|
31
|
+
"@antv/l7-maps": "2.13.1",
|
|
32
|
+
"@antv/l7-source": "2.13.1",
|
|
33
|
+
"@antv/l7-utils": "2.13.1",
|
|
34
34
|
"@babel/runtime": "^7.7.7",
|
|
35
35
|
"@mapbox/martini": "^0.2.0",
|
|
36
36
|
"@turf/clone": "^6.5.0",
|
|
@@ -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": "6a7cbf5974ee1b3f38f926b3eaac97a144013ef2",
|
|
65
65
|
"publishConfig": {
|
|
66
66
|
"access": "public"
|
|
67
67
|
}
|
package/es/line/models/tile.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { IModel, IModelUniform } from '@antv/l7-core';
|
|
2
|
-
import BaseModel from '../../core/BaseModel';
|
|
3
|
-
export default class LineModel extends BaseModel {
|
|
4
|
-
getUninforms(): IModelUniform;
|
|
5
|
-
initModels(): Promise<IModel[]>;
|
|
6
|
-
buildModels(): Promise<IModel[]>;
|
|
7
|
-
protected registerBuiltinAttributes(): void;
|
|
8
|
-
}
|
package/es/line/models/tile.js
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
5
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
|
6
|
-
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
7
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
8
|
-
|
|
9
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
10
|
-
|
|
11
|
-
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; } }
|
|
12
|
-
|
|
13
|
-
import { AttributeType, gl } from '@antv/l7-core';
|
|
14
|
-
import { getMask, rgb2arr } from '@antv/l7-utils';
|
|
15
|
-
import BaseModel from "../../core/BaseModel";
|
|
16
|
-
import { LineTriangulation } from "../../core/triangulation";
|
|
17
|
-
|
|
18
|
-
/* babel-plugin-inline-import '../../shader/minify_picking_frag.glsl' */
|
|
19
|
-
var line_tile_frag = "uniform float u_opacity : 1.0;\nvarying vec4 v_color;\n\n#pragma include \"picking\"\n\nvoid main() {\n gl_FragColor = v_color;\n gl_FragColor.a *= u_opacity;\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
|
|
20
|
-
|
|
21
|
-
/* babel-plugin-inline-import '../shaders/tile/line_tile_vert.glsl' */
|
|
22
|
-
var line_tile_vert = "attribute float a_Miter;\nattribute vec4 a_Color;\nattribute vec2 a_Size;\nattribute vec3 a_Normal;\nattribute vec3 a_Position;\n\n// uniform vec2 u_tileOrigin;\n// uniform float u_coord;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvarying vec4 v_color;\n\nvoid main() {\n v_color = a_Color;\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 vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));\n\n // if(u_coord > 0.0) { // \u4F7F\u7528\u7ECF\u7EAC\u5EA6\u5750\u6807\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xy + offset, 0.0, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));\n }\n // } else { // \u4F7F\u7528\u504F\u79FB\u5750\u6807\n // vec2 pointPos = a_Position.xy;\n // vec4 tileWorld = vec4(project_mvt_offset_position(vec4(u_tileOrigin, 0.0, 1.0)).xyz, 1.0); // \u74E6\u7247\u8D77\u59CB\u70B9\u7684\u4E16\u754C\u5750\u6807\n\n // vec2 pointOffset = pointPos * pow(2.0, u_Zoom); // \u74E6\u7247\u5185\u7684\u70B9\u7684\u504F\u79FB\u5750\u6807\n \n // tileWorld.xy += pointOffset;\n\n // tileWorld.xy += offset;\n\n // if (u_CoordinateSystem == COORDINATE_SYSTEM_METER_OFFSET || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // // Needs to be divided with project_uCommonUnitsPerMeter\n // tileWorld.w *= u_PixelsPerMeter.z;\n // }\n // gl_Position = u_ViewProjectionMatrix * tileWorld + u_ViewportCenterProjection;\n // }\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
23
|
-
|
|
24
|
-
/* babel-plugin-inline-import '../../shader/minify_frag.glsl' */
|
|
25
|
-
var line_tile_map_frag = "uniform float u_opacity : 1.0;\nuniform vec4 u_color;\n\nvoid main() {\n gl_FragColor = u_color;\n gl_FragColor.a *= u_opacity;\n}\n";
|
|
26
|
-
|
|
27
|
-
/* babel-plugin-inline-import '../shaders/tile/line_tile_map_vert.glsl' */
|
|
28
|
-
var line_tile_map_vert = "attribute float a_Miter;\nattribute vec4 a_Color;\nattribute vec3 a_Normal;\nattribute vec3 a_Position;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform float u_size;\n\n#pragma include \"projection\"\n\nvoid main() {\n\n vec3 size = a_Miter * u_size * reverse_offset_normal(a_Normal);\n \n vec2 offset = project_pixel(size.xy);\n\n vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xy + offset, 0.0, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));\n }\n}\n";
|
|
29
|
-
|
|
30
|
-
var LineModel = /*#__PURE__*/function (_BaseModel) {
|
|
31
|
-
_inherits(LineModel, _BaseModel);
|
|
32
|
-
|
|
33
|
-
var _super = _createSuper(LineModel);
|
|
34
|
-
|
|
35
|
-
function LineModel() {
|
|
36
|
-
_classCallCheck(this, LineModel);
|
|
37
|
-
|
|
38
|
-
return _super.apply(this, arguments);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
_createClass(LineModel, [{
|
|
42
|
-
key: "getUninforms",
|
|
43
|
-
value: function getUninforms() {
|
|
44
|
-
var _ref = this.layer.getLayerConfig(),
|
|
45
|
-
_ref$opacity = _ref.opacity,
|
|
46
|
-
opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
|
|
47
|
-
usage = _ref.usage,
|
|
48
|
-
_ref$color = _ref.color,
|
|
49
|
-
color = _ref$color === void 0 ? '#fff' : _ref$color,
|
|
50
|
-
_ref$size = _ref.size,
|
|
51
|
-
size = _ref$size === void 0 ? 1 : _ref$size;
|
|
52
|
-
|
|
53
|
-
return {
|
|
54
|
-
// u_tileOrigin: tileOrigin || [0, 0],
|
|
55
|
-
// u_coord: coord === 'lnglat' ? 1.0 : 0.0,
|
|
56
|
-
u_opacity: Number(opacity),
|
|
57
|
-
u_color: usage === 'basemap' ? rgb2arr(color) : [0, 0, 0, 0],
|
|
58
|
-
u_size: usage === 'basemap' ? size : 1
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
}, {
|
|
62
|
-
key: "initModels",
|
|
63
|
-
value: function () {
|
|
64
|
-
var _initModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
65
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
66
|
-
while (1) {
|
|
67
|
-
switch (_context.prev = _context.next) {
|
|
68
|
-
case 0:
|
|
69
|
-
_context.next = 2;
|
|
70
|
-
return this.buildModels();
|
|
71
|
-
|
|
72
|
-
case 2:
|
|
73
|
-
return _context.abrupt("return", _context.sent);
|
|
74
|
-
|
|
75
|
-
case 3:
|
|
76
|
-
case "end":
|
|
77
|
-
return _context.stop();
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}, _callee, this);
|
|
81
|
-
}));
|
|
82
|
-
|
|
83
|
-
function initModels() {
|
|
84
|
-
return _initModels.apply(this, arguments);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return initModels;
|
|
88
|
-
}()
|
|
89
|
-
}, {
|
|
90
|
-
key: "buildModels",
|
|
91
|
-
value: function () {
|
|
92
|
-
var _buildModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
93
|
-
var _ref2, _ref2$mask, mask, _ref2$maskInside, maskInside, _ref2$depth, depth, usage, model;
|
|
94
|
-
|
|
95
|
-
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
96
|
-
while (1) {
|
|
97
|
-
switch (_context2.prev = _context2.next) {
|
|
98
|
-
case 0:
|
|
99
|
-
_ref2 = this.layer.getLayerConfig(), _ref2$mask = _ref2.mask, mask = _ref2$mask === void 0 ? false : _ref2$mask, _ref2$maskInside = _ref2.maskInside, maskInside = _ref2$maskInside === void 0 ? true : _ref2$maskInside, _ref2$depth = _ref2.depth, depth = _ref2$depth === void 0 ? false : _ref2$depth, usage = _ref2.usage;
|
|
100
|
-
this.layer.triangulation = LineTriangulation;
|
|
101
|
-
_context2.next = 4;
|
|
102
|
-
return this.layer.buildLayerModel({
|
|
103
|
-
moduleName: 'lineTile_' + usage,
|
|
104
|
-
vertexShader: usage === 'basemap' ? line_tile_map_vert : line_tile_vert,
|
|
105
|
-
fragmentShader: usage === 'basemap' ? line_tile_map_frag : line_tile_frag,
|
|
106
|
-
triangulation: LineTriangulation,
|
|
107
|
-
blend: this.getBlend(),
|
|
108
|
-
depth: {
|
|
109
|
-
enable: depth
|
|
110
|
-
},
|
|
111
|
-
stencil: getMask(mask, maskInside),
|
|
112
|
-
pick: usage !== 'basemap'
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
case 4:
|
|
116
|
-
model = _context2.sent;
|
|
117
|
-
return _context2.abrupt("return", [model]);
|
|
118
|
-
|
|
119
|
-
case 6:
|
|
120
|
-
case "end":
|
|
121
|
-
return _context2.stop();
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}, _callee2, this);
|
|
125
|
-
}));
|
|
126
|
-
|
|
127
|
-
function buildModels() {
|
|
128
|
-
return _buildModels.apply(this, arguments);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
return buildModels;
|
|
132
|
-
}()
|
|
133
|
-
}, {
|
|
134
|
-
key: "registerBuiltinAttributes",
|
|
135
|
-
value: function registerBuiltinAttributes() {
|
|
136
|
-
var _this$layer$getLayerC = this.layer.getLayerConfig(),
|
|
137
|
-
usage = _this$layer$getLayerC.usage;
|
|
138
|
-
|
|
139
|
-
if (usage !== 'basemap') {
|
|
140
|
-
this.styleAttributeService.registerStyleAttribute({
|
|
141
|
-
name: 'size',
|
|
142
|
-
type: AttributeType.Attribute,
|
|
143
|
-
descriptor: {
|
|
144
|
-
name: 'a_Size',
|
|
145
|
-
buffer: {
|
|
146
|
-
// give the WebGL driver a hint that this buffer may change
|
|
147
|
-
usage: gl.DYNAMIC_DRAW,
|
|
148
|
-
data: [],
|
|
149
|
-
type: gl.FLOAT
|
|
150
|
-
},
|
|
151
|
-
size: 2,
|
|
152
|
-
update: function update(feature) {
|
|
153
|
-
var _feature$size = feature.size,
|
|
154
|
-
size = _feature$size === void 0 ? 1 : _feature$size;
|
|
155
|
-
return Array.isArray(size) ? [size[0], size[1]] : [size, 0];
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
this.styleAttributeService.registerStyleAttribute({
|
|
162
|
-
name: 'normal',
|
|
163
|
-
type: AttributeType.Attribute,
|
|
164
|
-
descriptor: {
|
|
165
|
-
name: 'a_Normal',
|
|
166
|
-
buffer: {
|
|
167
|
-
// give the WebGL driver a hint that this buffer may change
|
|
168
|
-
usage: gl.STATIC_DRAW,
|
|
169
|
-
data: [],
|
|
170
|
-
type: gl.FLOAT
|
|
171
|
-
},
|
|
172
|
-
size: 3,
|
|
173
|
-
update: function update(feature, featureIdx, vertex, attributeIdx, normal) {
|
|
174
|
-
return normal;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
this.styleAttributeService.registerStyleAttribute({
|
|
179
|
-
name: 'miter',
|
|
180
|
-
type: AttributeType.Attribute,
|
|
181
|
-
descriptor: {
|
|
182
|
-
name: 'a_Miter',
|
|
183
|
-
buffer: {
|
|
184
|
-
// give the WebGL driver a hint that this buffer may change
|
|
185
|
-
usage: gl.STATIC_DRAW,
|
|
186
|
-
data: [],
|
|
187
|
-
type: gl.FLOAT
|
|
188
|
-
},
|
|
189
|
-
size: 1,
|
|
190
|
-
update: function update(feature, featureIdx, vertex) {
|
|
191
|
-
return [vertex[4]];
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
}]);
|
|
197
|
-
|
|
198
|
-
return LineModel;
|
|
199
|
-
}(BaseModel);
|
|
200
|
-
|
|
201
|
-
export { LineModel as default };
|