@antv/l7-layers 2.21.10 → 2.21.11-beta.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/citybuliding/models/build.d.ts +16 -0
- package/es/citybuliding/models/build.js +18 -20
- package/es/citybuliding/shaders/build_frag.glsl +6 -6
- package/es/citybuliding/shaders/build_vert.glsl +8 -14
- package/es/core/BaseLayer.d.ts +0 -1
- package/es/core/BaseLayer.js +9 -19
- package/es/core/BaseModel.d.ts +15 -2
- package/es/core/BaseModel.js +98 -64
- package/es/core/CommonStyleAttribute.d.ts +14 -18
- package/es/core/CommonStyleAttribute.js +23 -67
- package/es/core/shape/extrude.js +6 -3
- package/es/core/triangulation.js +22 -50
- package/es/core/utils.d.ts +4 -0
- package/es/core/utils.js +33 -0
- package/es/earth/models/atmosphere.d.ts +15 -0
- package/es/earth/models/atmosphere.js +30 -24
- package/es/earth/models/base.d.ts +15 -0
- package/es/earth/models/base.js +30 -24
- package/es/earth/models/bloomsphere.d.ts +15 -0
- package/es/earth/models/bloomsphere.js +30 -24
- package/es/earth/shaders/atmosphere/atmosphere_vert.glsl +7 -5
- package/es/earth/shaders/base/base_vert.glsl +3 -3
- package/es/earth/shaders/bloomshpere/bloomsphere_vert.glsl +5 -4
- package/es/geometry/models/billboard.d.ts +15 -0
- package/es/geometry/models/billboard.js +14 -8
- package/es/geometry/models/plane.d.ts +14 -0
- package/es/geometry/models/plane.js +10 -10
- package/es/geometry/models/sprite.js +3 -9
- package/es/geometry/shaders/billboard_vert.glsl +28 -25
- package/es/geometry/shaders/plane_vert.glsl +6 -6
- package/es/geometry/shaders/sprite_vert.glsl +7 -9
- package/es/heatmap/models/grid.d.ts +14 -0
- package/es/heatmap/models/grid.js +10 -3
- package/es/heatmap/models/grid3d.d.ts +16 -0
- package/es/heatmap/models/grid3d.js +14 -6
- package/es/heatmap/models/heatmap.d.ts +20 -1
- package/es/heatmap/models/heatmap.js +96 -83
- package/es/heatmap/models/hexagon.d.ts +14 -0
- package/es/heatmap/models/hexagon.js +9 -3
- package/es/heatmap/shaders/grid/grid_vert.glsl +30 -42
- package/es/heatmap/shaders/grid3d/grid_3d_vert.glsl +14 -26
- package/es/heatmap/shaders/heatmap/heatmap_3d_vert.glsl +19 -16
- package/es/heatmap/shaders/heatmap/heatmap_framebuffer_vert.glsl +16 -22
- package/es/heatmap/shaders/heatmap/heatmap_vert.glsl +3 -4
- package/es/heatmap/shaders/hexagon/hexagon_vert.glsl +13 -23
- package/es/image/models/image.d.ts +14 -0
- package/es/image/models/image.js +11 -7
- package/es/image/shaders/image_vert.glsl +7 -6
- package/es/line/models/arc.d.ts +18 -0
- package/es/line/models/arc.js +57 -8
- package/es/line/models/arc_3d.d.ts +18 -0
- package/es/line/models/arc_3d.js +55 -7
- package/es/line/models/flow.d.ts +17 -0
- package/es/line/models/flow.js +35 -7
- package/es/line/models/great_circle.d.ts +17 -0
- package/es/line/models/great_circle.js +34 -6
- package/es/line/models/line.d.ts +17 -0
- package/es/line/models/line.js +17 -8
- package/es/line/models/simple_line.d.ts +14 -0
- package/es/line/models/simple_line.js +12 -47
- package/es/line/models/wall.d.ts +17 -0
- package/es/line/models/wall.js +22 -48
- package/es/line/shaders/arc/line_arc_vert.glsl +44 -52
- package/es/line/shaders/arc3d/line_arc_3d_vert.glsl +15 -20
- package/es/line/shaders/flow/flow_line_vert.glsl +30 -48
- package/es/line/shaders/greatCircle/line_arc_great_circle_vert.glsl +53 -74
- package/es/line/shaders/line/line_vert.glsl +31 -48
- package/es/line/shaders/simple/simpleline_vert.glsl +18 -23
- package/es/line/shaders/wall/wall_vert.glsl +36 -45
- package/es/mask/models/fill.js +2 -1
- package/es/mask/shaders/mask_vert.glsl +2 -7
- package/es/plugins/DataMappingPlugin.d.ts +0 -1
- package/es/plugins/DataMappingPlugin.js +1 -24
- package/es/plugins/PixelPickingPlugin.js +2 -2
- package/es/plugins/RegisterStyleAttributePlugin.d.ts +0 -1
- package/es/plugins/RegisterStyleAttributePlugin.js +3 -25
- package/es/plugins/ShaderUniformPlugin.d.ts +0 -5
- package/es/plugins/ShaderUniformPlugin.js +4 -35
- package/es/point/models/billboard_point.d.ts +14 -0
- package/es/point/models/billboard_point.js +11 -3
- package/es/point/models/earthExtrude.d.ts +16 -0
- package/es/point/models/earthExtrude.js +15 -8
- package/es/point/models/earthFill.d.ts +16 -0
- package/es/point/models/earthFill.js +13 -5
- package/es/point/models/extrude.d.ts +16 -0
- package/es/point/models/extrude.js +19 -12
- package/es/point/models/fill.d.ts +16 -0
- package/es/point/models/fill.js +16 -5
- package/es/point/models/fillImage.d.ts +16 -0
- package/es/point/models/fillImage.js +16 -16
- package/es/point/models/image.d.ts +15 -0
- package/es/point/models/image.js +14 -4
- package/es/point/models/normal.d.ts +14 -0
- package/es/point/models/normal.js +11 -3
- package/es/point/models/radar.d.ts +15 -0
- package/es/point/models/radar.js +13 -4
- package/es/point/models/text.d.ts +16 -0
- package/es/point/models/text.js +18 -11
- package/es/point/shaders/billboard/billboard_point_vert.glsl +10 -13
- package/es/point/shaders/earthExtrude/earthExtrude_vert.glsl +15 -25
- package/es/point/shaders/earthFill/earthFill_vert.glsl +6 -6
- package/es/point/shaders/extrude/extrude_vert.glsl +35 -39
- package/es/point/shaders/fill/fill_vert.glsl +12 -14
- package/es/point/shaders/fillImage/fillImage_vert.glsl +16 -28
- package/es/point/shaders/image/image_vert.glsl +15 -12
- package/es/point/shaders/normal/normal_vert.glsl +7 -10
- package/es/point/shaders/radar/radar_vert.glsl +11 -11
- package/es/point/shaders/text/text_vert.glsl +10 -9
- package/es/polygon/models/extrude.d.ts +16 -0
- package/es/polygon/models/extrude.js +26 -26
- package/es/polygon/models/extrusion.d.ts +16 -0
- package/es/polygon/models/extrusion.js +34 -4
- package/es/polygon/models/fill.d.ts +14 -0
- package/es/polygon/models/fill.js +12 -4
- package/es/polygon/models/ocean.d.ts +14 -0
- package/es/polygon/models/ocean.js +11 -6
- package/es/polygon/models/water.d.ts +14 -0
- package/es/polygon/models/water.js +11 -6
- package/es/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +17 -15
- package/es/polygon/shaders/extrude/polygon_extrude_vert.glsl +22 -20
- package/es/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +17 -17
- package/es/polygon/shaders/extrusion/polygon_extrusion_vert.glsl +8 -8
- package/es/polygon/shaders/fill/fill_linear_vert.glsl +7 -6
- package/es/polygon/shaders/fill/fill_vert.glsl +10 -12
- package/es/polygon/shaders/ocean/ocean_vert.glsl +3 -4
- package/es/polygon/shaders/water/polygon_water_vert.glsl +5 -5
- package/es/raster/index.d.ts +1 -1
- package/es/raster/index.js +1 -1
- package/es/raster/models/raster.d.ts +14 -0
- package/es/raster/models/raster.js +13 -3
- package/es/raster/models/rasterRgb.d.ts +14 -0
- package/es/raster/models/rasterRgb.js +12 -3
- package/es/raster/models/rasterTerrainRgb.d.ts +14 -0
- package/es/raster/models/rasterTerrainRgb.js +11 -3
- package/es/raster/shaders/raster/raster_2d_vert.glsl +6 -6
- package/es/raster/shaders/rgb/raster_rgb_vert.glsl +11 -11
- package/es/raster/shaders/terrain/terrain_rgb_vert.glsl +11 -11
- package/es/tile/core/BaseLayer.js +0 -16
- package/es/utils/extrude_polyline.d.ts +0 -15
- package/es/utils/extrude_polyline.js +0 -217
- package/es/wind/models/wind.d.ts +14 -0
- package/es/wind/models/wind.js +9 -1
- package/es/wind/shaders/wind_vert.glsl +6 -5
- package/lib/citybuliding/models/build.d.ts +16 -0
- package/lib/citybuliding/models/build.js +18 -20
- package/lib/citybuliding/shaders/build_frag.glsl +6 -6
- package/lib/citybuliding/shaders/build_vert.glsl +8 -14
- package/lib/core/BaseLayer.d.ts +0 -1
- package/lib/core/BaseLayer.js +9 -19
- package/lib/core/BaseModel.d.ts +15 -2
- package/lib/core/BaseModel.js +96 -62
- package/lib/core/CommonStyleAttribute.d.ts +14 -18
- package/lib/core/CommonStyleAttribute.js +23 -68
- package/lib/core/shape/extrude.js +6 -3
- package/lib/core/triangulation.js +22 -50
- package/lib/core/utils.d.ts +4 -0
- package/lib/core/utils.js +35 -0
- package/lib/earth/models/atmosphere.d.ts +15 -0
- package/lib/earth/models/atmosphere.js +30 -24
- package/lib/earth/models/base.d.ts +15 -0
- package/lib/earth/models/base.js +30 -24
- package/lib/earth/models/bloomsphere.d.ts +15 -0
- package/lib/earth/models/bloomsphere.js +30 -24
- package/lib/earth/shaders/atmosphere/atmosphere_vert.glsl +7 -5
- package/lib/earth/shaders/base/base_vert.glsl +3 -3
- package/lib/earth/shaders/bloomshpere/bloomsphere_vert.glsl +5 -4
- package/lib/geometry/models/billboard.d.ts +15 -0
- package/lib/geometry/models/billboard.js +14 -8
- package/lib/geometry/models/plane.d.ts +14 -0
- package/lib/geometry/models/plane.js +10 -10
- package/lib/geometry/models/sprite.js +3 -9
- package/lib/geometry/shaders/billboard_vert.glsl +28 -25
- package/lib/geometry/shaders/plane_vert.glsl +6 -6
- package/lib/geometry/shaders/sprite_vert.glsl +7 -9
- package/lib/heatmap/models/grid.d.ts +14 -0
- package/lib/heatmap/models/grid.js +10 -3
- package/lib/heatmap/models/grid3d.d.ts +16 -0
- package/lib/heatmap/models/grid3d.js +14 -6
- package/lib/heatmap/models/heatmap.d.ts +20 -1
- package/lib/heatmap/models/heatmap.js +95 -82
- package/lib/heatmap/models/hexagon.d.ts +14 -0
- package/lib/heatmap/models/hexagon.js +9 -3
- package/lib/heatmap/shaders/grid/grid_vert.glsl +30 -42
- package/lib/heatmap/shaders/grid3d/grid_3d_vert.glsl +14 -26
- package/lib/heatmap/shaders/heatmap/heatmap_3d_vert.glsl +19 -16
- package/lib/heatmap/shaders/heatmap/heatmap_framebuffer_vert.glsl +16 -22
- package/lib/heatmap/shaders/heatmap/heatmap_vert.glsl +3 -4
- package/lib/heatmap/shaders/hexagon/hexagon_vert.glsl +13 -23
- package/lib/image/models/image.d.ts +14 -0
- package/lib/image/models/image.js +11 -7
- package/lib/image/shaders/image_vert.glsl +7 -6
- package/lib/line/models/arc.d.ts +18 -0
- package/lib/line/models/arc.js +56 -7
- package/lib/line/models/arc_3d.d.ts +18 -0
- package/lib/line/models/arc_3d.js +55 -7
- package/lib/line/models/flow.d.ts +17 -0
- package/lib/line/models/flow.js +35 -7
- package/lib/line/models/great_circle.d.ts +17 -0
- package/lib/line/models/great_circle.js +33 -5
- package/lib/line/models/line.d.ts +17 -0
- package/lib/line/models/line.js +17 -8
- package/lib/line/models/simple_line.d.ts +14 -0
- package/lib/line/models/simple_line.js +12 -47
- package/lib/line/models/wall.d.ts +17 -0
- package/lib/line/models/wall.js +22 -48
- package/lib/line/shaders/arc/line_arc_vert.glsl +44 -52
- package/lib/line/shaders/arc3d/line_arc_3d_vert.glsl +15 -20
- package/lib/line/shaders/flow/flow_line_vert.glsl +30 -48
- package/lib/line/shaders/greatCircle/line_arc_great_circle_vert.glsl +53 -74
- package/lib/line/shaders/line/line_vert.glsl +31 -48
- package/lib/line/shaders/simple/simpleline_vert.glsl +18 -23
- package/lib/line/shaders/wall/wall_vert.glsl +36 -45
- package/lib/mask/models/fill.js +2 -1
- package/lib/mask/shaders/mask_vert.glsl +2 -7
- package/lib/plugins/DataMappingPlugin.d.ts +0 -1
- package/lib/plugins/DataMappingPlugin.js +0 -23
- package/lib/plugins/PixelPickingPlugin.js +1 -1
- package/lib/plugins/RegisterStyleAttributePlugin.d.ts +0 -1
- package/lib/plugins/RegisterStyleAttributePlugin.js +2 -24
- package/lib/plugins/ShaderUniformPlugin.d.ts +0 -5
- package/lib/plugins/ShaderUniformPlugin.js +4 -35
- package/lib/point/models/billboard_point.d.ts +14 -0
- package/lib/point/models/billboard_point.js +11 -3
- package/lib/point/models/earthExtrude.d.ts +16 -0
- package/lib/point/models/earthExtrude.js +14 -7
- package/lib/point/models/earthFill.d.ts +16 -0
- package/lib/point/models/earthFill.js +13 -5
- package/lib/point/models/extrude.d.ts +16 -0
- package/lib/point/models/extrude.js +18 -11
- package/lib/point/models/fill.d.ts +16 -0
- package/lib/point/models/fill.js +16 -5
- package/lib/point/models/fillImage.d.ts +16 -0
- package/lib/point/models/fillImage.js +16 -16
- package/lib/point/models/image.d.ts +15 -0
- package/lib/point/models/image.js +14 -4
- package/lib/point/models/normal.d.ts +14 -0
- package/lib/point/models/normal.js +11 -3
- package/lib/point/models/radar.d.ts +15 -0
- package/lib/point/models/radar.js +13 -4
- package/lib/point/models/text.d.ts +16 -0
- package/lib/point/models/text.js +18 -11
- package/lib/point/shaders/billboard/billboard_point_vert.glsl +10 -13
- package/lib/point/shaders/earthExtrude/earthExtrude_vert.glsl +15 -25
- package/lib/point/shaders/earthFill/earthFill_vert.glsl +6 -6
- package/lib/point/shaders/extrude/extrude_vert.glsl +35 -39
- package/lib/point/shaders/fill/fill_vert.glsl +12 -14
- package/lib/point/shaders/fillImage/fillImage_vert.glsl +16 -28
- package/lib/point/shaders/image/image_vert.glsl +15 -12
- package/lib/point/shaders/normal/normal_vert.glsl +7 -10
- package/lib/point/shaders/radar/radar_vert.glsl +11 -11
- package/lib/point/shaders/text/text_vert.glsl +10 -9
- package/lib/polygon/models/extrude.d.ts +16 -0
- package/lib/polygon/models/extrude.js +25 -25
- package/lib/polygon/models/extrusion.d.ts +16 -0
- package/lib/polygon/models/extrusion.js +34 -4
- package/lib/polygon/models/fill.d.ts +14 -0
- package/lib/polygon/models/fill.js +12 -4
- package/lib/polygon/models/ocean.d.ts +14 -0
- package/lib/polygon/models/ocean.js +11 -6
- package/lib/polygon/models/water.d.ts +14 -0
- package/lib/polygon/models/water.js +11 -6
- package/lib/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +17 -15
- package/lib/polygon/shaders/extrude/polygon_extrude_vert.glsl +22 -20
- package/lib/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +17 -17
- package/lib/polygon/shaders/extrusion/polygon_extrusion_vert.glsl +8 -8
- package/lib/polygon/shaders/fill/fill_linear_vert.glsl +7 -6
- package/lib/polygon/shaders/fill/fill_vert.glsl +10 -12
- package/lib/polygon/shaders/ocean/ocean_vert.glsl +3 -4
- package/lib/polygon/shaders/water/polygon_water_vert.glsl +5 -5
- package/lib/raster/index.d.ts +1 -1
- package/lib/raster/index.js +2 -2
- package/lib/raster/models/raster.d.ts +14 -0
- package/lib/raster/models/raster.js +13 -3
- package/lib/raster/models/rasterRgb.d.ts +14 -0
- package/lib/raster/models/rasterRgb.js +12 -3
- package/lib/raster/models/rasterTerrainRgb.d.ts +14 -0
- package/lib/raster/models/rasterTerrainRgb.js +11 -3
- package/lib/raster/shaders/raster/raster_2d_vert.glsl +6 -6
- package/lib/raster/shaders/rgb/raster_rgb_vert.glsl +11 -11
- package/lib/raster/shaders/terrain/terrain_rgb_vert.glsl +11 -11
- package/lib/tile/core/BaseLayer.js +0 -16
- package/lib/utils/extrude_polyline.d.ts +0 -15
- package/lib/utils/extrude_polyline.js +0 -217
- package/lib/wind/models/wind.d.ts +14 -0
- package/lib/wind/models/wind.js +9 -1
- package/lib/wind/shaders/wind_vert.glsl +6 -5
- package/package.json +6 -6
|
@@ -13,8 +13,14 @@ var _triangulation = require("../../core/triangulation");
|
|
|
13
13
|
/* babel-plugin-inline-import '../shaders/hexagon/hexagon_frag.glsl' */
|
|
14
14
|
const hexagon_frag = "in vec4 v_color;\n\n#pragma include \"picking\"\nout vec4 outputColor;\nvoid main() {\n outputColor = v_color;\n outputColor = filterColor(outputColor);\n}\n";
|
|
15
15
|
/* babel-plugin-inline-import '../shaders/hexagon/hexagon_vert.glsl' */
|
|
16
|
-
const hexagon_vert = "layout(location =
|
|
16
|
+
const hexagon_vert = "layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;\nlayout(location = ATTRIBUTE_LOCATION_POS) in vec3 a_Pos;\n\nlayout(std140) uniform commonUniforms {\n vec2 u_radius;\n float u_opacity;\n float u_coverage;\n float u_angle;\n};\n\nout vec4 v_color;\n\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"picking\"\n\nvoid main() {\n v_color = a_Color;\n v_color.a *= u_opacity;\n\n mat2 rotationMatrix = mat2(cos(u_angle), sin(u_angle), -sin(u_angle), cos(u_angle));\n vec2 offset = vec2(a_Position.xy * u_radius * rotationMatrix * u_coverage);\n vec2 lnglat = unProjectFlat(a_Pos.xy + offset);\n\n vec4 project_pos = project_position(vec4(lnglat, 0, 1.0));\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy, 0.0, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
17
17
|
class HexagonModel extends _BaseModel.default {
|
|
18
|
+
get attributeLocation() {
|
|
19
|
+
return Object.assign(super.attributeLocation, {
|
|
20
|
+
MAX: super.attributeLocation.MAX,
|
|
21
|
+
POS: 9
|
|
22
|
+
});
|
|
23
|
+
}
|
|
18
24
|
getUninforms() {
|
|
19
25
|
const commoninfo = this.getCommonUniformsInfo();
|
|
20
26
|
const attributeInfo = this.getUniformsBufferInfo(this.getStyleAttribute());
|
|
@@ -66,7 +72,7 @@ class HexagonModel extends _BaseModel.default {
|
|
|
66
72
|
type: _l7Core.AttributeType.Attribute,
|
|
67
73
|
descriptor: {
|
|
68
74
|
name: 'a_Pos',
|
|
69
|
-
shaderLocation:
|
|
75
|
+
shaderLocation: this.attributeLocation.POS,
|
|
70
76
|
buffer: {
|
|
71
77
|
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
72
78
|
data: [],
|
|
@@ -74,7 +80,7 @@ class HexagonModel extends _BaseModel.default {
|
|
|
74
80
|
},
|
|
75
81
|
size: 3,
|
|
76
82
|
update: feature => {
|
|
77
|
-
const coordinates = feature.
|
|
83
|
+
const coordinates = feature.coordinates;
|
|
78
84
|
return [coordinates[0], coordinates[1], 0];
|
|
79
85
|
}
|
|
80
86
|
}
|
|
@@ -1,42 +1,30 @@
|
|
|
1
|
-
layout(location =
|
|
2
|
-
layout(location =
|
|
3
|
-
layout(location =
|
|
4
|
-
|
|
5
|
-
layout(std140) uniform commonUniforms {
|
|
6
|
-
vec2 u_radius;
|
|
7
|
-
float u_opacity;
|
|
8
|
-
float u_coverage;
|
|
9
|
-
float u_angle;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
#pragma include "
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
vec2
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
vec2 lnglat = unProjectFlat(a_Pos.xy + offset);
|
|
32
|
-
vec2 customLnglat = customProject(lnglat) - u_sceneCenterMercator; // 将经纬度转换为高德2.0需要的平面坐标
|
|
33
|
-
vec4 project_pos = project_position(vec4(customLnglat, 0, 1.0));
|
|
34
|
-
gl_Position = u_Mvp * (project_pos);
|
|
35
|
-
} else {
|
|
36
|
-
vec2 lnglat = unProjectFlat(a_Pos.xy + offset);
|
|
37
|
-
vec4 project_pos = project_position(vec4(lnglat, 0, 1.0));
|
|
38
|
-
gl_Position = project_common_position_to_clipspace(project_pos);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
setPickingColor(a_PickingColor);
|
|
42
|
-
}
|
|
1
|
+
layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;
|
|
2
|
+
layout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;
|
|
3
|
+
layout(location = ATTRIBUTE_LOCATION_POS) in vec3 a_Pos;
|
|
4
|
+
|
|
5
|
+
layout(std140) uniform commonUniforms {
|
|
6
|
+
vec2 u_radius;
|
|
7
|
+
float u_opacity;
|
|
8
|
+
float u_coverage;
|
|
9
|
+
float u_angle;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
out vec4 v_color;
|
|
13
|
+
|
|
14
|
+
#pragma include "projection"
|
|
15
|
+
#pragma include "project"
|
|
16
|
+
#pragma include "picking"
|
|
17
|
+
|
|
18
|
+
void main() {
|
|
19
|
+
v_color = a_Color;
|
|
20
|
+
v_color.a *= u_opacity;
|
|
21
|
+
|
|
22
|
+
mat2 rotationMatrix = mat2(cos(u_angle), sin(u_angle), -sin(u_angle), cos(u_angle));
|
|
23
|
+
vec2 offset = a_Position.xy * u_radius * rotationMatrix * u_coverage;
|
|
24
|
+
|
|
25
|
+
vec2 lnglat = unProjectFlat(a_Pos.xy + offset);
|
|
26
|
+
vec4 project_pos = project_position(vec4(lnglat, 0, 1.0));
|
|
27
|
+
gl_Position = project_common_position_to_clipspace(project_pos);
|
|
28
|
+
|
|
29
|
+
setPickingColor(a_PickingColor);
|
|
30
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
layout(location =
|
|
2
|
-
layout(location =
|
|
3
|
-
layout(location =
|
|
4
|
-
layout(location =
|
|
5
|
-
layout(location =
|
|
1
|
+
layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;
|
|
2
|
+
layout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;
|
|
3
|
+
layout(location = ATTRIBUTE_LOCATION_SIZE) in float a_Size;
|
|
4
|
+
layout(location = ATTRIBUTE_LOCATION_POS) in vec3 a_Pos;
|
|
5
|
+
layout(location = ATTRIBUTE_LOCATION_NORMAL) in vec3 a_Normal;
|
|
6
6
|
|
|
7
7
|
layout(std140) uniform commonUniforms {
|
|
8
8
|
vec2 u_radius;
|
|
@@ -20,27 +20,15 @@ out vec4 v_color;
|
|
|
20
20
|
|
|
21
21
|
void main() {
|
|
22
22
|
mat2 rotationMatrix = mat2(cos(u_angle), sin(u_angle), -sin(u_angle), cos(u_angle));
|
|
23
|
-
vec2 offset =
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
v_color =vec4(a_Color.rgb*lightWeight, a_Color.w * u_opacity);
|
|
33
|
-
|
|
34
|
-
gl_Position = u_Mvp * vec4(customLnglat , a_Position.z * a_Size, 1.0);
|
|
35
|
-
} else {
|
|
36
|
-
vec2 lnglat = unProjectFlat(a_Pos.xy + offset); // 实际的经纬度
|
|
37
|
-
vec4 project_pos = project_position(vec4(lnglat, a_Position.z * a_Size, 1.0));
|
|
38
|
-
|
|
39
|
-
float lightWeight = calc_lighting(project_pos);
|
|
40
|
-
v_color =vec4(a_Color.rgb*lightWeight, a_Color.w);
|
|
41
|
-
|
|
42
|
-
gl_Position = project_common_position_to_clipspace(project_pos);
|
|
43
|
-
}
|
|
23
|
+
vec2 offset = vec2(a_Position.xy * u_radius * rotationMatrix * u_coverage);
|
|
24
|
+
|
|
25
|
+
vec2 lnglat = unProjectFlat(a_Pos.xy + offset); // 实际的经纬度
|
|
26
|
+
vec4 project_pos = project_position(vec4(lnglat, a_Position.z * a_Size, 1.0));
|
|
27
|
+
|
|
28
|
+
float lightWeight = calc_lighting(project_pos);
|
|
29
|
+
v_color = vec4(a_Color.rgb * lightWeight, a_Color.w);
|
|
30
|
+
|
|
31
|
+
gl_Position = project_common_position_to_clipspace(project_pos);
|
|
44
32
|
|
|
45
33
|
setPickingColor(a_PickingColor);
|
|
46
34
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
layout(location = 0) in vec3 a_Position;
|
|
2
|
-
layout(location =
|
|
2
|
+
layout(location = 10) in vec2 a_Uv;
|
|
3
3
|
|
|
4
4
|
layout(std140) uniform commonUniforms {
|
|
5
5
|
mat4 u_ViewProjectionMatrixUncentered;
|
|
@@ -17,13 +17,16 @@ out vec2 v_texCoord;
|
|
|
17
17
|
out float v_intensity;
|
|
18
18
|
|
|
19
19
|
vec2 toBezier(float t, vec2 P0, vec2 P1, vec2 P2, vec2 P3) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
float t2 = t * t;
|
|
21
|
+
float one_minus_t = 1.0 - t;
|
|
22
|
+
float one_minus_t2 = one_minus_t * one_minus_t;
|
|
23
|
+
return P0 * one_minus_t2 * one_minus_t +
|
|
24
|
+
P1 * 3.0 * t * one_minus_t2 +
|
|
25
|
+
P2 * 3.0 * t2 * one_minus_t +
|
|
26
|
+
P3 * t2 * t;
|
|
24
27
|
}
|
|
25
|
-
vec2 toBezier(float t, vec4 p){
|
|
26
|
-
|
|
28
|
+
vec2 toBezier(float t, vec4 p) {
|
|
29
|
+
return toBezier(t, vec2(0.0, 0.0), vec2(p.x, p.y), vec2(p.z, p.w), vec2(1.0, 1.0));
|
|
27
30
|
}
|
|
28
31
|
|
|
29
32
|
#pragma include "projection"
|
|
@@ -35,22 +38,22 @@ void main() {
|
|
|
35
38
|
vec2 pos = a_Uv * vec2(2.0) - vec2(1.0); // 将原本 0 -> 1 的 uv 转换为 -1 -> 1 的标准坐标空间(NDC)
|
|
36
39
|
|
|
37
40
|
vec4 p1 = vec4(pos, 0.0, 1.0); // x/y 平面上的点(z == 0)可以认为是三维上的点被投影到平面后的点
|
|
38
|
-
|
|
41
|
+
vec4 p2 = vec4(pos, 1.0, 1.0); // 平行于x/y平面、z==1 的平面上的点
|
|
39
42
|
|
|
40
|
-
|
|
41
|
-
|
|
43
|
+
vec4 inverseP1 = u_InverseViewProjectionMatrix * p1; // 根据视图投影矩阵的逆矩阵平面上的反算出三维空间中的点(p1平面上的点)
|
|
44
|
+
vec4 inverseP2 = u_InverseViewProjectionMatrix * p2;
|
|
42
45
|
|
|
43
46
|
inverseP1 = inverseP1 / inverseP1.w; // 归一化操作(归一化后为世界坐标)
|
|
44
|
-
|
|
47
|
+
inverseP2 = inverseP2 / inverseP2.w;
|
|
45
48
|
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
float zPos = (0.0 - inverseP1.z) / (inverseP2.z - inverseP1.z); // ??
|
|
50
|
+
vec4 position = inverseP1 + zPos * (inverseP2 - inverseP1);
|
|
48
51
|
|
|
49
|
-
vec4 b= vec4(0.
|
|
52
|
+
vec4 b = vec4(0.5, 0.0, 1.0, 0.5);
|
|
50
53
|
float fh;
|
|
51
54
|
|
|
52
55
|
v_intensity = texture(SAMPLER_2D(u_texture), v_texCoord).r;
|
|
53
56
|
fh = toBezier(v_intensity, b).y;
|
|
54
|
-
gl_Position = u_ViewProjectionMatrixUncentered * vec4(position.xy, fh * project_pixel(50.), 1.0);
|
|
55
|
-
|
|
57
|
+
gl_Position = u_ViewProjectionMatrixUncentered * vec4(position.xy, fh * project_pixel(50.0), 1.0);
|
|
58
|
+
|
|
56
59
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
layout(location =
|
|
2
|
-
layout(location =
|
|
3
|
-
layout(location =
|
|
4
|
-
|
|
1
|
+
layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;
|
|
2
|
+
layout(location = ATTRIBUTE_LOCATION_SIZE) in float a_Size;
|
|
3
|
+
layout(location = ATTRIBUTE_LOCATION_DIR) in vec2 a_Dir;
|
|
5
4
|
|
|
6
5
|
layout(std140) uniform commonUniforms {
|
|
7
6
|
float u_radius;
|
|
@@ -13,30 +12,25 @@ layout(std140) uniform commonUniforms {
|
|
|
13
12
|
out vec2 v_extrude;
|
|
14
13
|
out float v_weight;
|
|
15
14
|
|
|
16
|
-
#define GAUSS_COEF
|
|
15
|
+
#define GAUSS_COEF (0.3989422804014327)
|
|
17
16
|
|
|
18
17
|
#pragma include "projection"
|
|
19
18
|
#pragma include "picking"
|
|
20
19
|
|
|
21
|
-
void main(){
|
|
22
|
-
|
|
20
|
+
void main() {
|
|
21
|
+
vec3 picking_color_placeholder = u_PickingColor;
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
v_weight = a_Size;
|
|
24
|
+
float ZERO = 1.0 / 255.0 / 16.0;
|
|
25
|
+
float extrude_x = a_Dir.x * 2.0 - 1.0;
|
|
26
|
+
float extrude_y = a_Dir.y * 2.0 - 1.0;
|
|
27
|
+
vec2 extrude_dir = normalize(vec2(extrude_x, extrude_y));
|
|
28
|
+
float S = sqrt(-2.0 * log(ZERO / a_Size / u_intensity / GAUSS_COEF)) / 2.5;
|
|
29
|
+
v_extrude = extrude_dir * S;
|
|
31
30
|
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
vec2 offset = project_pixel(v_extrude * u_radius);
|
|
32
|
+
vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0));
|
|
34
33
|
|
|
35
|
-
|
|
34
|
+
gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));
|
|
36
35
|
|
|
37
|
-
if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
|
|
38
|
-
gl_Position = u_Mvp * (vec4(project_pos.xy + offset, 0.0, 1.0));
|
|
39
|
-
} else {
|
|
40
|
-
gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));
|
|
41
|
-
}
|
|
42
36
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
1
|
layout(location = 0) in vec3 a_Position;
|
|
3
|
-
layout(location =
|
|
2
|
+
layout(location = 10) in vec2 a_Uv;
|
|
4
3
|
|
|
5
4
|
layout(std140) uniform commonUniforms {
|
|
6
5
|
float u_opacity;
|
|
@@ -15,8 +14,8 @@ out vec2 v_texCoord;
|
|
|
15
14
|
void main() {
|
|
16
15
|
v_texCoord = a_Uv;
|
|
17
16
|
#ifdef VIEWPORT_ORIGIN_TL
|
|
18
|
-
|
|
17
|
+
v_texCoord.y = 1.0 - v_texCoord.y;
|
|
19
18
|
#endif
|
|
20
19
|
|
|
21
|
-
gl_Position = vec4(a_Position.xy, 0, 1.);
|
|
20
|
+
gl_Position = vec4(a_Position.xy, 0, 1.0);
|
|
22
21
|
}
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
layout(location =
|
|
2
|
-
layout(location =
|
|
3
|
-
layout(location =
|
|
1
|
+
layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;
|
|
2
|
+
layout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;
|
|
3
|
+
layout(location = ATTRIBUTE_LOCATION_POS) in vec3 a_Pos;
|
|
4
4
|
|
|
5
5
|
layout(std140) uniform commonUniforms {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
vec2 u_radius;
|
|
7
|
+
float u_opacity;
|
|
8
|
+
float u_coverage;
|
|
9
|
+
float u_angle;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
out vec4 v_color;
|
|
13
13
|
|
|
14
|
-
|
|
15
14
|
#pragma include "projection"
|
|
16
15
|
#pragma include "project"
|
|
17
16
|
#pragma include "picking"
|
|
@@ -19,22 +18,13 @@ out vec4 v_color;
|
|
|
19
18
|
void main() {
|
|
20
19
|
v_color = a_Color;
|
|
21
20
|
v_color.a *= u_opacity;
|
|
22
|
-
|
|
21
|
+
|
|
23
22
|
mat2 rotationMatrix = mat2(cos(u_angle), sin(u_angle), -sin(u_angle), cos(u_angle));
|
|
24
|
-
vec2 offset =
|
|
23
|
+
vec2 offset = vec2(a_Position.xy * u_radius * rotationMatrix * u_coverage);
|
|
25
24
|
vec2 lnglat = unProjectFlat(a_Pos.xy + offset);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
// gl_Position = u_Mvp * (vec4(project_pos.xy, 0., 1.0));
|
|
31
|
-
// gl_Position = u_Mvp * (vec4(a_Pos.xy + offset, 0., 1.0));
|
|
32
|
-
vec2 customLnglat = customProject(lnglat) - u_sceneCenterMercator;
|
|
33
|
-
vec4 project_pos = project_position(vec4(customLnglat, 0, 1.0));
|
|
34
|
-
gl_Position = u_Mvp * vec4(project_pos.xy, 0.0, 1.0);
|
|
35
|
-
} else {
|
|
36
|
-
vec4 project_pos = project_position(vec4(lnglat, 0, 1.0));
|
|
37
|
-
gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy, 0., 1.0));
|
|
38
|
-
}
|
|
25
|
+
|
|
26
|
+
vec4 project_pos = project_position(vec4(lnglat, 0, 1.0));
|
|
27
|
+
gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy, 0.0, 1.0));
|
|
28
|
+
|
|
39
29
|
setPickingColor(a_PickingColor);
|
|
40
30
|
}
|
|
@@ -2,6 +2,20 @@ import type { IModel, ITexture2D } from '@antv/l7-core';
|
|
|
2
2
|
import BaseModel from '../../core/BaseModel';
|
|
3
3
|
export default class ImageModel extends BaseModel {
|
|
4
4
|
protected texture: ITexture2D;
|
|
5
|
+
protected get attributeLocation(): {
|
|
6
|
+
readonly POSITION: 0;
|
|
7
|
+
readonly POSITION_64LOW: 1;
|
|
8
|
+
readonly COLOR: 2;
|
|
9
|
+
readonly PICKING_COLOR: 3;
|
|
10
|
+
readonly STROKE: 4;
|
|
11
|
+
readonly OPACITY: 5;
|
|
12
|
+
readonly OFFSETS: 6;
|
|
13
|
+
readonly ROTATION: 7;
|
|
14
|
+
readonly MAX: 8;
|
|
15
|
+
} & Record<string, number> & {
|
|
16
|
+
MAX: 8;
|
|
17
|
+
UV: number;
|
|
18
|
+
};
|
|
5
19
|
protected getCommonUniformsInfo(): {
|
|
6
20
|
uniformsArray: number[];
|
|
7
21
|
uniformsLength: number;
|
|
@@ -10,17 +10,22 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
10
10
|
var _l7Core = require("@antv/l7-core");
|
|
11
11
|
var _l7Utils = require("@antv/l7-utils");
|
|
12
12
|
var _BaseModel = _interopRequireDefault(require("../../core/BaseModel"));
|
|
13
|
-
var _CommonStyleAttribute = require("../../core/CommonStyleAttribute");
|
|
14
13
|
var _triangulation = require("../../core/triangulation");
|
|
15
14
|
/* babel-plugin-inline-import '../shaders/image_frag.glsl' */
|
|
16
15
|
const ImageFrag = "uniform sampler2D u_texture;\nlayout(std140) uniform commonUniforms {\n float u_opacity:1.0;\n float u_brightness:1.0;\n float u_contrast:1.0;\n float u_saturation:1.0;\n float u_gamma:1.0;\n};\n\nin vec2 v_texCoord;\nout vec4 outputColor;\nvec3 setContrast(vec3 rgb, float contrast) {\n vec3 color = mix(vec3(0.5), rgb, contrast);\n color = clamp(color, 0.0, 1.0);\n return color;\n}\nvec3 setSaturation(vec3 rgb, float adjustment) {\n const vec3 grayVector = vec3(0.2125, 0.7154, 0.0721);\n vec3 intensity = vec3(dot(rgb, grayVector));\n vec3 color = mix(intensity, rgb, adjustment);\n color = clamp(color, 0.0, 1.0);\n return color;\n}\nvoid main() {\n vec4 color = texture(SAMPLER_2D(u_texture),vec2(v_texCoord.x,v_texCoord.y));\n //brightness\n color.rgb = mix(vec3(0.0, 0.0, 0.0), color.rgb, u_brightness);\n //contrast\n color.rgb = setContrast(color.rgb, u_contrast);\n // saturation\n color.rgb = setSaturation(color.rgb, u_saturation);\n // gamma\n color.rgb = pow(color.rgb, vec3(u_gamma));\n outputColor = color;\n outputColor.a *= u_opacity;\n if(outputColor.a < 0.01)\n discard;\n}\n";
|
|
17
16
|
/* babel-plugin-inline-import '../shaders/image_vert.glsl' */
|
|
18
|
-
const ImageVert = "layout(location =
|
|
17
|
+
const ImageVert = "layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_POSITION_64LOW) in vec2 a_Position64Low;\nlayout(location = ATTRIBUTE_LOCATION_UV) in vec2 a_Uv;\n\nlayout(std140) uniform commonUniforms {\n float u_opacity:1.0;\n float u_brightness:1.0;\n float u_contrast:1.0;\n float u_saturation:1.0;\n float u_gamma:1.0;\n};\n\nout vec2 v_texCoord;\n#pragma include \"projection\"\n\nvoid main() {\n v_texCoord = a_Uv;\n vec4 project_pos = project_position(vec4(a_Position, 1.0), a_Position64Low);\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy, 0.0, 1.0));\n}\n";
|
|
19
18
|
class ImageModel extends _BaseModel.default {
|
|
20
19
|
constructor(...args) {
|
|
21
20
|
super(...args);
|
|
22
21
|
(0, _defineProperty2.default)(this, "texture", void 0);
|
|
23
22
|
}
|
|
23
|
+
get attributeLocation() {
|
|
24
|
+
return Object.assign(super.attributeLocation, {
|
|
25
|
+
MAX: super.attributeLocation.MAX,
|
|
26
|
+
UV: 9
|
|
27
|
+
});
|
|
28
|
+
}
|
|
24
29
|
getCommonUniformsInfo() {
|
|
25
30
|
const {
|
|
26
31
|
opacity,
|
|
@@ -57,10 +62,6 @@ class ImageModel extends _BaseModel.default {
|
|
|
57
62
|
const {
|
|
58
63
|
createTexture2D
|
|
59
64
|
} = _this2.rendererService;
|
|
60
|
-
_this2.texture = createTexture2D({
|
|
61
|
-
height: 1,
|
|
62
|
-
width: 1
|
|
63
|
-
});
|
|
64
65
|
const source = _this2.layer.getSource();
|
|
65
66
|
const imageData = yield source.data.images;
|
|
66
67
|
_this2.texture = createTexture2D({
|
|
@@ -80,6 +81,7 @@ class ImageModel extends _BaseModel.default {
|
|
|
80
81
|
moduleName: 'rasterImage',
|
|
81
82
|
vertexShader: ImageVert,
|
|
82
83
|
fragmentShader: ImageFrag,
|
|
84
|
+
defines: _this3.getDefines(),
|
|
83
85
|
triangulation: _triangulation.RasterImageTriangulation,
|
|
84
86
|
primitive: _l7Core.gl.TRIANGLES,
|
|
85
87
|
blend: {
|
|
@@ -95,12 +97,14 @@ class ImageModel extends _BaseModel.default {
|
|
|
95
97
|
})();
|
|
96
98
|
}
|
|
97
99
|
registerBuiltinAttributes() {
|
|
100
|
+
// 注册 Position 属性 64 位地位部分,经纬度数据开启双精度,避免大于 22 层级以上出现数据偏移
|
|
101
|
+
this.registerPosition64LowAttribute();
|
|
98
102
|
this.styleAttributeService.registerStyleAttribute({
|
|
99
103
|
name: 'uv',
|
|
100
104
|
type: _l7Core.AttributeType.Attribute,
|
|
101
105
|
descriptor: {
|
|
102
106
|
name: 'a_Uv',
|
|
103
|
-
shaderLocation:
|
|
107
|
+
shaderLocation: this.attributeLocation.UV,
|
|
104
108
|
buffer: {
|
|
105
109
|
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
106
110
|
data: [],
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
layout(location =
|
|
2
|
-
layout(location =
|
|
1
|
+
layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;
|
|
2
|
+
layout(location = ATTRIBUTE_LOCATION_POSITION_64LOW) in vec2 a_Position64Low;
|
|
3
|
+
layout(location = ATTRIBUTE_LOCATION_UV) in vec2 a_Uv;
|
|
3
4
|
|
|
4
5
|
layout(std140) uniform commonUniforms {
|
|
5
6
|
float u_opacity:1.0;
|
|
@@ -11,9 +12,9 @@ layout(std140) uniform commonUniforms {
|
|
|
11
12
|
|
|
12
13
|
out vec2 v_texCoord;
|
|
13
14
|
#pragma include "projection"
|
|
15
|
+
|
|
14
16
|
void main() {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
v_texCoord = a_Uv;
|
|
18
|
+
vec4 project_pos = project_position(vec4(a_Position, 1.0), a_Position64Low);
|
|
19
|
+
gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy, 0.0, 1.0));
|
|
19
20
|
}
|
package/lib/line/models/arc.d.ts
CHANGED
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
import type { IModel, ITexture2D } from '@antv/l7-core';
|
|
2
2
|
import BaseModel from '../../core/BaseModel';
|
|
3
3
|
export default class ArcModel extends BaseModel {
|
|
4
|
+
protected get attributeLocation(): {
|
|
5
|
+
readonly POSITION: 0;
|
|
6
|
+
readonly POSITION_64LOW: 1;
|
|
7
|
+
readonly COLOR: 2;
|
|
8
|
+
readonly PICKING_COLOR: 3;
|
|
9
|
+
readonly STROKE: 4;
|
|
10
|
+
readonly OPACITY: 5;
|
|
11
|
+
readonly OFFSETS: 6;
|
|
12
|
+
readonly ROTATION: 7;
|
|
13
|
+
readonly MAX: 8;
|
|
14
|
+
} & Record<string, number> & {
|
|
15
|
+
MAX: 8;
|
|
16
|
+
SIZE: number;
|
|
17
|
+
INSTANCE: number;
|
|
18
|
+
INSTANCE_64LOW: number;
|
|
19
|
+
UV: number;
|
|
20
|
+
THETA_OFFSET: number;
|
|
21
|
+
};
|
|
4
22
|
protected texture: ITexture2D;
|
|
5
23
|
protected getCommonUniformsInfo(): {
|
|
6
24
|
uniformsArray: number[];
|
package/lib/line/models/arc.js
CHANGED
|
@@ -10,12 +10,11 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
10
10
|
var _l7Core = require("@antv/l7-core");
|
|
11
11
|
var _l7Utils = require("@antv/l7-utils");
|
|
12
12
|
var _BaseModel = _interopRequireDefault(require("../../core/BaseModel"));
|
|
13
|
-
var _CommonStyleAttribute = require("../../core/CommonStyleAttribute");
|
|
14
13
|
var _triangulation = require("../../core/triangulation");
|
|
15
14
|
/* babel-plugin-inline-import '../shaders/arc/line_arc_frag.glsl' */
|
|
16
15
|
const arc_line_frag = "\n#define Animate 0.0\n#define LineTexture 1.0\nuniform sampler2D u_texture;\nlayout(std140) uniform commonUniorm {\n vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\n vec4 u_dash_array;\n vec4 u_sourceColor;\n vec4 u_targetColor;\n vec2 u_textSize;\n float segmentNumber;\n float u_lineDir: 1.0;\n float u_icon_step: 100;\n float u_line_texture: 0.0;\n float u_textureBlend;\n float u_blur : 0.9;\n float u_line_type: 0.0;\n float u_time;\n float u_linearColor: 0.0;\n};\n\nin vec4 v_color;\nin vec2 v_iconMapUV;\nin vec4 v_lineData;\n//dash\nin vec4 v_dash_array;\nin float v_distance_ratio;\n\nout vec4 outputColor;\n#pragma include \"picking\"\n\nvoid main() {\n if(u_dash_array!=vec4(0.0)){\n float dashLength = mod(v_distance_ratio, v_dash_array.x + v_dash_array.y + v_dash_array.z + v_dash_array.w);\n if(!(dashLength < v_dash_array.x || (dashLength > (v_dash_array.x + v_dash_array.y) && dashLength < v_dash_array.x + v_dash_array.y + v_dash_array.z))) {\n discard;\n };\n }\n float animateSpeed = 0.0; // \u8FD0\u52A8\u901F\u5EA6\n outputColor = v_color;\n if(u_animate.x == Animate && u_line_texture != LineTexture) {\n animateSpeed = u_time / u_animate.y;\n float alpha =1.0 - fract( mod(1.0- v_lineData.b, u_animate.z)* (1.0/ u_animate.z) + u_time / u_animate.y);\n alpha = (alpha + u_animate.w -1.0) / u_animate.w;\n // alpha = smoothstep(0., 1., alpha);\n alpha = clamp(alpha, 0.0, 1.0);\n outputColor.a *= alpha;\n }\n\n // \u5F53\u5B58\u5728\u8D34\u56FE\u65F6\u5728\u5E95\u8272\u4E0A\u8D34\u4E0A\u8D34\u56FE\n if(u_line_texture == LineTexture) { // while load texture\n float arcRadio = smoothstep( 0.0, 1.0, (v_lineData.r / segmentNumber));\n // float arcRadio = smoothstep( 0.0, 1.0, d_distance_ratio);\n\n float count = v_lineData.g; // \u8D34\u56FE\u5728\u5F27\u7EBF\u4E0A\u91CD\u590D\u7684\u6570\u91CF\n\n float time = 0.0;\n if(u_animate.x == Animate) {\n time = u_time / u_animate.y;\n }\n float redioCount = arcRadio * count;\n\n float u = fract(redioCount - time);\n float v = v_lineData.a; // \u6A2A\u5411 v\n vec2 uv= v_iconMapUV / u_textSize + vec2(u, v) / u_textSize * 64.;\n\n vec4 pattern = texture(SAMPLER_2D(u_texture), uv);\n\n if(u_animate.x == Animate) {\n float currentPlane = floor(redioCount - time);\n float textureStep = floor(count * u_animate.z);\n float a = mod(currentPlane, textureStep);\n if(a < textureStep - 1.0) {\n pattern = vec4(0.0);\n }\n }\n\n if(u_textureBlend == 0.0) { // normal\n pattern.a = 0.0;\n outputColor = filterColor(outputColor + pattern);\n } else { // replace\n pattern.a *= v_color.a;\n if(outputColor.a <= 0.0) {\n pattern.a = 0.0;\n }\n outputColor = filterColor(pattern);\n }\n \n } else {\n outputColor = filterColor(outputColor);\n }\n}";
|
|
17
16
|
/* babel-plugin-inline-import '../shaders/arc/line_arc_vert.glsl' */
|
|
18
|
-
const arc_line_vert = "#define Animate 0.0\n#define LineTexture 1.0\nlayout(location =
|
|
17
|
+
const arc_line_vert = "#define Animate (0.0)\n#define LineTexture (1.0)\n\nlayout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;\nlayout(location = ATTRIBUTE_LOCATION_SIZE) in float a_Size;\nlayout(location = ATTRIBUTE_LOCATION_INSTANCE) in vec4 a_Instance;\nlayout(location = ATTRIBUTE_LOCATION_INSTANCE_64LOW) in vec4 a_Instance64Low;\nlayout(location = ATTRIBUTE_LOCATION_UV) in vec2 a_iconMapUV;\n\nlayout(std140) uniform commonUniorm {\n vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\n vec4 u_dash_array;\n vec4 u_sourceColor;\n vec4 u_targetColor;\n vec2 u_textSize;\n float segmentNumber;\n float u_lineDir: 1.0;\n float u_icon_step: 100;\n float u_line_texture: 0.0;\n float u_textureBlend;\n float u_blur : 0.9;\n float u_line_type: 0.0;\n float u_time;\n float u_linearColor: 0.0;\n};\n\nout vec4 v_color;\nout vec2 v_iconMapUV;\nout vec4 v_lineData;\n//dash\nout vec4 v_dash_array;\nout float v_distance_ratio;\n\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"picking\"\n\nfloat bezier3(vec3 arr, float t) {\n float ut = 1.0 - t;\n return (arr.x * ut + arr.y * t) * ut + (arr.y * ut + arr.z * t) * t;\n}\nvec2 midPoint(vec2 source, vec2 target, float arcThetaOffset) {\n vec2 center = target - source;\n float r = length(center);\n float theta = atan(center.y, center.x);\n float thetaOffset = arcThetaOffset;\n float r2 = r / 2.0 / cos(thetaOffset);\n float theta2 = theta + thetaOffset;\n vec2 mid = vec2(r2 * cos(theta2) + source.x, r2 * sin(theta2) + source.y);\n if (u_lineDir == 1.0) {\n // \u6B63\u5411\n return mid;\n } else {\n // \u9006\u5411\n // (mid + vmin)/2 = (s + t)/2\n vec2 vmid = source + target - mid;\n return vmid;\n }\n // return mid;\n}\nfloat getSegmentRatio(float index) {\n // dash: index / (segmentNumber - 1.);\n // normal: smoothstep(0.0, 1.0, index / (segmentNumber - 1.));\n return smoothstep(0.0, 1.0, index / (segmentNumber - 1.0));\n // return index / (segmentNumber - 1.);\n}\nvec2 interpolate(vec2 source, vec2 target, float t, float arcThetaOffset) {\n // if the angularDist is PI, linear interpolation is applied. otherwise, use spherical interpolation\n vec2 mid = midPoint(source, target, arcThetaOffset);\n vec3 x = vec3(source.x, mid.x, target.x);\n vec3 y = vec3(source.y, mid.y, target.y);\n return vec2(bezier3(x, t), bezier3(y, t));\n}\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n vec2 offset = dir_screenspace * offset_direction * setPickingSize(a_Size) / 2.0;\n return offset;\n}\nvec2 getNormal(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n return dir_screenspace.xy * sign(offset_direction);\n}\n\nvoid main() {\n //vs\u4E2D\u8BA1\u7B97\u6E10\u53D8\u8272\n if (u_linearColor == 1.0) {\n float d_segmentIndex = a_Position.x + 1.0; // \u5F53\u524D\u9876\u70B9\u5728\u5F27\u7EBF\u4E2D\u6240\u5904\u7684\u5206\u6BB5\u4F4D\u7F6E\n v_color = mix(u_sourceColor, u_targetColor, d_segmentIndex / segmentNumber);\n } else {\n v_color = a_Color;\n }\n v_color.a = v_color.a * opacity;\n\n vec2 source_world = a_Instance.rg; // \u8D77\u59CB\u70B9\n vec2 target_world = a_Instance.ba; // \u7EC8\u70B9\n\n float segmentIndex = a_Position.x;\n float segmentRatio = getSegmentRatio(segmentIndex);\n\n // \u8BA1\u7B97 dashArray \u548C distanceRatio \u8F93\u51FA\u5230\u7247\u5143\n float total_Distance = pixelDistance(source_world, target_world) / 2.0 * PI;\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / total_Distance;\n v_distance_ratio = segmentIndex / segmentNumber;\n\n float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n float d_distance_ratio;\n\n if(u_animate.x == Animate) {\n d_distance_ratio = segmentIndex / segmentNumber;\n if(u_lineDir != 1.0) {\n d_distance_ratio = 1.0 - d_distance_ratio;\n }\n }\n\n v_lineData.b = d_distance_ratio;\n\n vec4 source = project_position(vec4(source_world, 0, 1.), a_Instance64Low.xy);\n vec4 target = project_position(vec4(target_world, 0, 1.), a_Instance64Low.zw);\n\n vec2 currPos = interpolate(source.xy, target.xy, segmentRatio, thetaOffset);\n vec2 nextPos = interpolate(source.xy, target.xy, nextSegmentRatio, thetaOffset);\n\n vec2 offset = project_pixel(\n getExtrusionOffset((nextPos.xy - currPos.xy) * indexDir, a_Position.y)\n );\n\n float d_segmentIndex = a_Position.x + 1.0; // \u5F53\u524D\u9876\u70B9\u5728\u5F27\u7EBF\u4E2D\u6240\u5904\u7684\u5206\u6BB5\u4F4D\u7F6E\n v_lineData.r = d_segmentIndex;\n\n if(LineTexture == u_line_texture) { // \u5F00\u542F\u8D34\u56FE\u6A21\u5F0F\n float arcDistrance = length(source - target); // \u8D77\u59CB\u70B9\u548C\u7EC8\u70B9\u7684\u8DDD\u79BB\n arcDistrance = project_pixel(arcDistrance);\n\n v_iconMapUV = a_iconMapUV;\n\n float pixelLen = project_pixel_texture(u_icon_step); // \u8D34\u56FE\u6CBF\u5F27\u7EBF\u65B9\u5411\u7684\u957F\u5EA6 - \u968F\u5730\u56FE\u7F29\u653E\u6539\u53D8\n float texCount = floor(arcDistrance / pixelLen); // \u8D34\u56FE\u5728\u5F27\u7EBF\u4E0A\u91CD\u590D\u7684\u6570\u91CF\n v_lineData.g = texCount;\n\n float lineOffsetWidth = length(offset + offset * sign(a_Position.y)); // \u7EBF\u6A2A\u5411\u504F\u79FB\u7684\u8DDD\u79BB\n float linePixelSize = project_pixel(a_Size); // \u5B9A\u70B9\u4F4D\u7F6E\u504F\u79FB\n v_lineData.a = lineOffsetWidth / linePixelSize; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n }\n\n gl_Position = project_common_position_to_clipspace(vec4(currPos.xy + offset, 0, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
19
18
|
const lineStyleObj = {
|
|
20
19
|
solid: 0.0,
|
|
21
20
|
dash: 1.0
|
|
@@ -46,6 +45,16 @@ class ArcModel extends _BaseModel.default {
|
|
|
46
45
|
this.textures = [this.texture];
|
|
47
46
|
});
|
|
48
47
|
}
|
|
48
|
+
get attributeLocation() {
|
|
49
|
+
return Object.assign(super.attributeLocation, {
|
|
50
|
+
MAX: super.attributeLocation.MAX,
|
|
51
|
+
SIZE: 9,
|
|
52
|
+
INSTANCE: 10,
|
|
53
|
+
INSTANCE_64LOW: 11,
|
|
54
|
+
UV: 12,
|
|
55
|
+
THETA_OFFSET: 13
|
|
56
|
+
});
|
|
57
|
+
}
|
|
49
58
|
getCommonUniformsInfo() {
|
|
50
59
|
const {
|
|
51
60
|
sourceColor,
|
|
@@ -152,6 +161,7 @@ class ArcModel extends _BaseModel.default {
|
|
|
152
161
|
moduleName: 'lineArc2d' + type,
|
|
153
162
|
vertexShader: vert,
|
|
154
163
|
fragmentShader: frag,
|
|
164
|
+
defines: _this2.getDefines(),
|
|
155
165
|
inject: _this2.getInject(),
|
|
156
166
|
triangulation: _triangulation.LineArcTriangulation,
|
|
157
167
|
depth: {
|
|
@@ -170,7 +180,7 @@ class ArcModel extends _BaseModel.default {
|
|
|
170
180
|
type: _l7Core.AttributeType.Attribute,
|
|
171
181
|
descriptor: {
|
|
172
182
|
name: 'a_Size',
|
|
173
|
-
shaderLocation:
|
|
183
|
+
shaderLocation: this.attributeLocation.SIZE,
|
|
174
184
|
buffer: {
|
|
175
185
|
// give the WebGL driver a hint that this buffer may change
|
|
176
186
|
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
@@ -186,13 +196,14 @@ class ArcModel extends _BaseModel.default {
|
|
|
186
196
|
}
|
|
187
197
|
}
|
|
188
198
|
});
|
|
199
|
+
|
|
200
|
+
// 弧线起始点信息
|
|
189
201
|
this.styleAttributeService.registerStyleAttribute({
|
|
190
202
|
name: 'instance',
|
|
191
|
-
// 弧线起始点信息
|
|
192
203
|
type: _l7Core.AttributeType.Attribute,
|
|
193
204
|
descriptor: {
|
|
194
205
|
name: 'a_Instance',
|
|
195
|
-
shaderLocation:
|
|
206
|
+
shaderLocation: this.attributeLocation.INSTANCE,
|
|
196
207
|
buffer: {
|
|
197
208
|
usage: _l7Core.gl.STATIC_DRAW,
|
|
198
209
|
data: [],
|
|
@@ -204,14 +215,32 @@ class ArcModel extends _BaseModel.default {
|
|
|
204
215
|
}
|
|
205
216
|
}
|
|
206
217
|
});
|
|
218
|
+
|
|
219
|
+
// save low part for enabled double precision INSTANCE attribute
|
|
220
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
221
|
+
name: 'instance64Low',
|
|
222
|
+
type: _l7Core.AttributeType.Attribute,
|
|
223
|
+
descriptor: {
|
|
224
|
+
name: 'a_Instance64Low',
|
|
225
|
+
shaderLocation: this.attributeLocation.INSTANCE_64LOW,
|
|
226
|
+
buffer: {
|
|
227
|
+
usage: _l7Core.gl.STATIC_DRAW,
|
|
228
|
+
data: [],
|
|
229
|
+
type: _l7Core.gl.FLOAT
|
|
230
|
+
},
|
|
231
|
+
size: 4,
|
|
232
|
+
update: (feature, featureIdx, vertex) => {
|
|
233
|
+
return [(0, _l7Utils.fp64LowPart)(vertex[3]), (0, _l7Utils.fp64LowPart)(vertex[4]), (0, _l7Utils.fp64LowPart)(vertex[5]), (0, _l7Utils.fp64LowPart)(vertex[6])];
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
});
|
|
207
237
|
this.styleAttributeService.registerStyleAttribute({
|
|
208
238
|
name: 'uv',
|
|
209
239
|
type: _l7Core.AttributeType.Attribute,
|
|
210
240
|
descriptor: {
|
|
211
241
|
name: 'a_iconMapUV',
|
|
212
|
-
shaderLocation:
|
|
242
|
+
shaderLocation: this.attributeLocation.UV,
|
|
213
243
|
buffer: {
|
|
214
|
-
// give the WebGL driver a hint that this buffer may change
|
|
215
244
|
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
216
245
|
data: [],
|
|
217
246
|
type: _l7Core.gl.FLOAT
|
|
@@ -233,6 +262,26 @@ class ArcModel extends _BaseModel.default {
|
|
|
233
262
|
}
|
|
234
263
|
}
|
|
235
264
|
});
|
|
265
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
266
|
+
name: 'thetaOffset',
|
|
267
|
+
type: _l7Core.AttributeType.Attribute,
|
|
268
|
+
descriptor: {
|
|
269
|
+
name: 'a_ThetaOffset',
|
|
270
|
+
shaderLocation: this.attributeLocation.THETA_OFFSET,
|
|
271
|
+
buffer: {
|
|
272
|
+
usage: _l7Core.gl.STATIC_DRAW,
|
|
273
|
+
data: [],
|
|
274
|
+
type: _l7Core.gl.FLOAT
|
|
275
|
+
},
|
|
276
|
+
size: 1,
|
|
277
|
+
update: feature => {
|
|
278
|
+
const {
|
|
279
|
+
thetaOffset: op = 1
|
|
280
|
+
} = feature;
|
|
281
|
+
return [op];
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
});
|
|
236
285
|
}
|
|
237
286
|
}
|
|
238
287
|
exports.default = ArcModel;
|