@antv/l7-layers 2.21.9-beta.0 → 2.21.9
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 +0 -16
- package/es/citybuliding/models/build.js +20 -18
- package/es/citybuliding/shaders/build_frag.glsl +6 -6
- package/es/citybuliding/shaders/build_vert.glsl +14 -8
- package/es/core/BaseLayer.js +8 -12
- package/es/core/BaseModel.d.ts +2 -15
- package/es/core/BaseModel.js +62 -94
- package/es/core/CommonStyleAttribute.d.ts +18 -14
- package/es/core/CommonStyleAttribute.js +67 -23
- package/es/core/triangulation.js +39 -13
- package/es/earth/models/atmosphere.d.ts +0 -15
- package/es/earth/models/atmosphere.js +24 -30
- package/es/earth/models/base.d.ts +0 -15
- package/es/earth/models/base.js +24 -30
- package/es/earth/models/bloomsphere.d.ts +0 -15
- package/es/earth/models/bloomsphere.js +24 -30
- package/es/earth/shaders/atmosphere/atmosphere_vert.glsl +5 -7
- package/es/earth/shaders/base/base_vert.glsl +3 -3
- package/es/earth/shaders/bloomshpere/bloomsphere_vert.glsl +4 -5
- package/es/geometry/models/billboard.d.ts +0 -15
- package/es/geometry/models/billboard.js +8 -14
- package/es/geometry/models/plane.d.ts +0 -14
- package/es/geometry/models/plane.js +10 -10
- package/es/geometry/models/sprite.js +9 -3
- package/es/geometry/shaders/billboard_vert.glsl +25 -28
- package/es/geometry/shaders/plane_vert.glsl +6 -6
- package/es/geometry/shaders/sprite_vert.glsl +9 -7
- package/es/heatmap/models/grid.d.ts +0 -14
- package/es/heatmap/models/grid.js +3 -10
- package/es/heatmap/models/grid3d.d.ts +0 -16
- package/es/heatmap/models/grid3d.js +6 -14
- package/es/heatmap/models/heatmap.d.ts +1 -20
- package/es/heatmap/models/heatmap.js +83 -96
- package/es/heatmap/models/hexagon.d.ts +0 -14
- package/es/heatmap/models/hexagon.js +3 -9
- package/es/heatmap/shaders/grid/grid_vert.glsl +42 -30
- package/es/heatmap/shaders/grid3d/grid_3d_vert.glsl +26 -14
- package/es/heatmap/shaders/heatmap/heatmap_3d_vert.glsl +16 -19
- package/es/heatmap/shaders/heatmap/heatmap_framebuffer_vert.glsl +22 -16
- package/es/heatmap/shaders/heatmap/heatmap_vert.glsl +4 -3
- package/es/heatmap/shaders/hexagon/hexagon_vert.glsl +23 -13
- package/es/image/models/image.d.ts +0 -14
- package/es/image/models/image.js +3 -11
- package/es/image/shaders/image_vert.glsl +6 -7
- package/es/line/models/arc.d.ts +0 -18
- package/es/line/models/arc.js +8 -57
- package/es/line/models/arc_3d.d.ts +0 -18
- package/es/line/models/arc_3d.js +7 -55
- package/es/line/models/flow.d.ts +0 -17
- package/es/line/models/flow.js +7 -35
- package/es/line/models/great_circle.d.ts +0 -17
- package/es/line/models/great_circle.js +6 -34
- package/es/line/models/line.d.ts +0 -17
- package/es/line/models/line.js +8 -17
- package/es/line/models/simple_line.d.ts +0 -14
- package/es/line/models/simple_line.js +47 -12
- package/es/line/models/wall.d.ts +0 -17
- package/es/line/models/wall.js +48 -22
- package/es/line/shaders/arc/line_arc_vert.glsl +48 -42
- package/es/line/shaders/arc3d/line_arc_3d_vert.glsl +20 -15
- package/es/line/shaders/flow/flow_line_vert.glsl +48 -30
- package/es/line/shaders/greatCircle/line_arc_great_circle_vert.glsl +72 -56
- package/es/line/shaders/line/line_vert.glsl +48 -31
- package/es/line/shaders/simple/simpleline_vert.glsl +23 -18
- package/es/line/shaders/wall/wall_vert.glsl +45 -36
- package/es/mask/models/fill.js +1 -2
- package/es/mask/shaders/mask_vert.glsl +7 -2
- package/es/plugins/DataMappingPlugin.d.ts +1 -0
- package/es/plugins/DataMappingPlugin.js +24 -1
- package/es/plugins/PixelPickingPlugin.js +2 -2
- package/es/plugins/RegisterStyleAttributePlugin.d.ts +1 -0
- package/es/plugins/RegisterStyleAttributePlugin.js +25 -3
- package/es/plugins/ShaderUniformPlugin.d.ts +5 -0
- package/es/plugins/ShaderUniformPlugin.js +34 -2
- package/es/point/models/billboard_point.d.ts +0 -14
- package/es/point/models/billboard_point.js +3 -11
- package/es/point/models/earthExtrude.d.ts +0 -16
- package/es/point/models/earthExtrude.js +8 -15
- package/es/point/models/earthFill.d.ts +0 -16
- package/es/point/models/earthFill.js +5 -13
- package/es/point/models/extrude.d.ts +0 -16
- package/es/point/models/extrude.js +12 -19
- package/es/point/models/fill.d.ts +0 -16
- package/es/point/models/fill.js +5 -16
- package/es/point/models/fillImage.d.ts +0 -16
- package/es/point/models/fillImage.js +16 -16
- package/es/point/models/image.d.ts +0 -15
- package/es/point/models/image.js +4 -14
- package/es/point/models/normal.d.ts +0 -14
- package/es/point/models/normal.js +3 -11
- package/es/point/models/radar.d.ts +0 -15
- package/es/point/models/radar.js +4 -13
- package/es/point/models/text.d.ts +0 -16
- package/es/point/models/text.js +11 -18
- package/es/point/shaders/billboard/billboard_point_vert.glsl +13 -10
- package/es/point/shaders/earthExtrude/earthExtrude_vert.glsl +25 -15
- package/es/point/shaders/earthFill/earthFill_vert.glsl +6 -6
- package/es/point/shaders/extrude/extrude_vert.glsl +39 -35
- package/es/point/shaders/fill/fill_vert.glsl +14 -12
- package/es/point/shaders/fillImage/fillImage_vert.glsl +28 -16
- package/es/point/shaders/image/image_vert.glsl +12 -15
- package/es/point/shaders/normal/normal_vert.glsl +10 -7
- package/es/point/shaders/radar/radar_vert.glsl +11 -11
- package/es/point/shaders/text/text_vert.glsl +9 -10
- package/es/polygon/models/extrude.d.ts +0 -16
- package/es/polygon/models/extrude.js +26 -26
- package/es/polygon/models/extrusion.d.ts +0 -16
- package/es/polygon/models/extrusion.js +4 -34
- package/es/polygon/models/fill.d.ts +0 -14
- package/es/polygon/models/fill.js +4 -12
- package/es/polygon/models/ocean.d.ts +0 -14
- package/es/polygon/models/ocean.js +6 -11
- package/es/polygon/models/water.d.ts +0 -14
- package/es/polygon/models/water.js +6 -11
- package/es/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +15 -17
- package/es/polygon/shaders/extrude/polygon_extrude_vert.glsl +20 -22
- 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 +6 -7
- package/es/polygon/shaders/fill/fill_vert.glsl +12 -10
- package/es/polygon/shaders/ocean/ocean_vert.glsl +4 -3
- 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 +0 -14
- package/es/raster/models/raster.js +3 -12
- package/es/raster/models/rasterRgb.d.ts +0 -14
- package/es/raster/models/rasterRgb.js +3 -12
- package/es/raster/models/rasterTerrainRgb.d.ts +0 -14
- package/es/raster/models/rasterTerrainRgb.js +3 -11
- 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 +16 -0
- package/es/tile/tile/Tile.d.ts +0 -2
- package/es/utils/extrude_polyline.d.ts +15 -0
- package/es/utils/extrude_polyline.js +217 -0
- package/es/utils/multiPassRender.js +2 -10
- package/es/wind/models/wind.d.ts +0 -14
- package/es/wind/models/wind.js +1 -9
- package/es/wind/shaders/wind_vert.glsl +5 -6
- package/lib/citybuliding/models/build.d.ts +0 -16
- package/lib/citybuliding/models/build.js +20 -18
- package/lib/citybuliding/shaders/build_frag.glsl +6 -6
- package/lib/citybuliding/shaders/build_vert.glsl +14 -8
- package/lib/core/BaseLayer.js +8 -12
- package/lib/core/BaseModel.d.ts +2 -15
- package/lib/core/BaseModel.js +60 -92
- package/lib/core/CommonStyleAttribute.d.ts +18 -14
- package/lib/core/CommonStyleAttribute.js +68 -23
- package/lib/core/triangulation.js +39 -13
- package/lib/earth/models/atmosphere.d.ts +0 -15
- package/lib/earth/models/atmosphere.js +24 -30
- package/lib/earth/models/base.d.ts +0 -15
- package/lib/earth/models/base.js +24 -30
- package/lib/earth/models/bloomsphere.d.ts +0 -15
- package/lib/earth/models/bloomsphere.js +24 -30
- package/lib/earth/shaders/atmosphere/atmosphere_vert.glsl +5 -7
- package/lib/earth/shaders/base/base_vert.glsl +3 -3
- package/lib/earth/shaders/bloomshpere/bloomsphere_vert.glsl +4 -5
- package/lib/geometry/models/billboard.d.ts +0 -15
- package/lib/geometry/models/billboard.js +8 -14
- package/lib/geometry/models/plane.d.ts +0 -14
- package/lib/geometry/models/plane.js +10 -10
- package/lib/geometry/models/sprite.js +9 -3
- package/lib/geometry/shaders/billboard_vert.glsl +25 -28
- package/lib/geometry/shaders/plane_vert.glsl +6 -6
- package/lib/geometry/shaders/sprite_vert.glsl +9 -7
- package/lib/heatmap/models/grid.d.ts +0 -14
- package/lib/heatmap/models/grid.js +3 -10
- package/lib/heatmap/models/grid3d.d.ts +0 -16
- package/lib/heatmap/models/grid3d.js +6 -14
- package/lib/heatmap/models/heatmap.d.ts +1 -20
- package/lib/heatmap/models/heatmap.js +82 -95
- package/lib/heatmap/models/hexagon.d.ts +0 -14
- package/lib/heatmap/models/hexagon.js +3 -9
- package/lib/heatmap/shaders/grid/grid_vert.glsl +42 -30
- package/lib/heatmap/shaders/grid3d/grid_3d_vert.glsl +26 -14
- package/lib/heatmap/shaders/heatmap/heatmap_3d_vert.glsl +16 -19
- package/lib/heatmap/shaders/heatmap/heatmap_framebuffer_vert.glsl +22 -16
- package/lib/heatmap/shaders/heatmap/heatmap_vert.glsl +4 -3
- package/lib/heatmap/shaders/hexagon/hexagon_vert.glsl +23 -13
- package/lib/image/models/image.d.ts +0 -14
- package/lib/image/models/image.js +3 -11
- package/lib/image/shaders/image_vert.glsl +6 -7
- package/lib/line/models/arc.d.ts +0 -18
- package/lib/line/models/arc.js +7 -56
- package/lib/line/models/arc_3d.d.ts +0 -18
- package/lib/line/models/arc_3d.js +7 -55
- package/lib/line/models/flow.d.ts +0 -17
- package/lib/line/models/flow.js +7 -35
- package/lib/line/models/great_circle.d.ts +0 -17
- package/lib/line/models/great_circle.js +5 -33
- package/lib/line/models/line.d.ts +0 -17
- package/lib/line/models/line.js +8 -17
- package/lib/line/models/simple_line.d.ts +0 -14
- package/lib/line/models/simple_line.js +47 -12
- package/lib/line/models/wall.d.ts +0 -17
- package/lib/line/models/wall.js +48 -22
- package/lib/line/shaders/arc/line_arc_vert.glsl +48 -42
- package/lib/line/shaders/arc3d/line_arc_3d_vert.glsl +20 -15
- package/lib/line/shaders/flow/flow_line_vert.glsl +48 -30
- package/lib/line/shaders/greatCircle/line_arc_great_circle_vert.glsl +72 -56
- package/lib/line/shaders/line/line_vert.glsl +48 -31
- package/lib/line/shaders/simple/simpleline_vert.glsl +23 -18
- package/lib/line/shaders/wall/wall_vert.glsl +45 -36
- package/lib/mask/models/fill.js +1 -2
- package/lib/mask/shaders/mask_vert.glsl +7 -2
- package/lib/plugins/DataMappingPlugin.d.ts +1 -0
- package/lib/plugins/DataMappingPlugin.js +23 -0
- package/lib/plugins/PixelPickingPlugin.js +1 -1
- package/lib/plugins/RegisterStyleAttributePlugin.d.ts +1 -0
- package/lib/plugins/RegisterStyleAttributePlugin.js +24 -2
- package/lib/plugins/ShaderUniformPlugin.d.ts +5 -0
- package/lib/plugins/ShaderUniformPlugin.js +34 -2
- package/lib/point/models/billboard_point.d.ts +0 -14
- package/lib/point/models/billboard_point.js +3 -11
- package/lib/point/models/earthExtrude.d.ts +0 -16
- package/lib/point/models/earthExtrude.js +7 -14
- package/lib/point/models/earthFill.d.ts +0 -16
- package/lib/point/models/earthFill.js +5 -13
- package/lib/point/models/extrude.d.ts +0 -16
- package/lib/point/models/extrude.js +11 -18
- package/lib/point/models/fill.d.ts +0 -16
- package/lib/point/models/fill.js +5 -16
- package/lib/point/models/fillImage.d.ts +0 -16
- package/lib/point/models/fillImage.js +16 -16
- package/lib/point/models/image.d.ts +0 -15
- package/lib/point/models/image.js +4 -14
- package/lib/point/models/normal.d.ts +0 -14
- package/lib/point/models/normal.js +3 -11
- package/lib/point/models/radar.d.ts +0 -15
- package/lib/point/models/radar.js +4 -13
- package/lib/point/models/text.d.ts +0 -16
- package/lib/point/models/text.js +11 -18
- package/lib/point/shaders/billboard/billboard_point_vert.glsl +13 -10
- package/lib/point/shaders/earthExtrude/earthExtrude_vert.glsl +25 -15
- package/lib/point/shaders/earthFill/earthFill_vert.glsl +6 -6
- package/lib/point/shaders/extrude/extrude_vert.glsl +39 -35
- package/lib/point/shaders/fill/fill_vert.glsl +14 -12
- package/lib/point/shaders/fillImage/fillImage_vert.glsl +28 -16
- package/lib/point/shaders/image/image_vert.glsl +12 -15
- package/lib/point/shaders/normal/normal_vert.glsl +10 -7
- package/lib/point/shaders/radar/radar_vert.glsl +11 -11
- package/lib/point/shaders/text/text_vert.glsl +9 -10
- package/lib/polygon/models/extrude.d.ts +0 -16
- package/lib/polygon/models/extrude.js +25 -25
- package/lib/polygon/models/extrusion.d.ts +0 -16
- package/lib/polygon/models/extrusion.js +4 -34
- package/lib/polygon/models/fill.d.ts +0 -14
- package/lib/polygon/models/fill.js +4 -12
- package/lib/polygon/models/ocean.d.ts +0 -14
- package/lib/polygon/models/ocean.js +6 -11
- package/lib/polygon/models/water.d.ts +0 -14
- package/lib/polygon/models/water.js +6 -11
- package/lib/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +15 -17
- package/lib/polygon/shaders/extrude/polygon_extrude_vert.glsl +20 -22
- 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 +6 -7
- package/lib/polygon/shaders/fill/fill_vert.glsl +12 -10
- package/lib/polygon/shaders/ocean/ocean_vert.glsl +4 -3
- 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 +0 -14
- package/lib/raster/models/raster.js +3 -12
- package/lib/raster/models/rasterRgb.d.ts +0 -14
- package/lib/raster/models/rasterRgb.js +3 -12
- package/lib/raster/models/rasterTerrainRgb.d.ts +0 -14
- package/lib/raster/models/rasterTerrainRgb.js +3 -11
- 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 +16 -0
- package/lib/tile/tile/Tile.d.ts +0 -2
- package/lib/utils/extrude_polyline.d.ts +15 -0
- package/lib/utils/extrude_polyline.js +217 -0
- package/lib/utils/multiPassRender.js +2 -10
- package/lib/wind/models/wind.d.ts +0 -14
- package/lib/wind/models/wind.js +1 -9
- package/lib/wind/shaders/wind_vert.glsl +5 -6
- package/package.json +6 -6
|
@@ -10,11 +10,12 @@ 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");
|
|
13
14
|
var _triangulation = require("../../core/triangulation");
|
|
14
15
|
/* babel-plugin-inline-import '../shaders/greatCircle/line_arc_great_circle_frag.glsl' */
|
|
15
16
|
const line_arc_frag = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n#define LineTexture 1.0\n\nuniform sampler2D u_texture;\nlayout(std140) uniform commonUniorm {\n vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\n vec4 u_dash_array: [10.0, 5., 0, 0];\n vec4 u_sourceColor;\n vec4 u_targetColor;\n vec2 u_textSize;\n float segmentNumber;\n float u_line_type: 0.0;\n float u_icon_step: 100;\n float u_line_texture: 0.0;\n float u_textureBlend;\n float u_time;\n float u_linearColor: 0;\n};\n\nin vec4 v_line_data;\nin vec2 v_iconMapUV;\nin vec4 v_dash_array;\nin float v_distance_ratio;\nin vec4 v_color;\n\nout vec4 outputColor;\n#pragma include \"picking\"\n#pragma include \"project\"\n#pragma include \"projection\"\n\nvoid main() {\n\n float animateSpeed = 0.0;\n float d_segmentIndex = v_line_data.g;\n \n // \u8BBE\u7F6E\u5F27\u7EBF\u7684\u5E95\u8272\n if(u_linearColor == 1.0) { // \u4F7F\u7528\u6E10\u53D8\u989C\u8272\n outputColor = mix(u_sourceColor, u_targetColor, d_segmentIndex/segmentNumber);\n outputColor.a *= v_color.a;\n } else { // \u4F7F\u7528 color \u65B9\u6CD5\u4F20\u5165\u7684\u989C\u8272\n outputColor = v_color;\n }\n\n // float blur = 1.- smoothstep(u_blur, 1., length(v_normal.xy));\n // float blur = smoothstep(1.0, u_blur, length(v_normal.xy));\n if(u_line_type == LineTypeDash) {\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 // \u5B9E\u7EBF\u90E8\u5206\n } else {\n // \u865A\u7EBF\u90E8\u5206\n discard;\n };\n }\n\n // \u8BBE\u7F6E\u5F27\u7EBF\u7684\u52A8\u753B\u6A21\u5F0F\n if(u_animate.x == Animate) {\n animateSpeed = u_time / u_animate.y;\n float alpha =1.0 - fract( mod(1.0- v_distance_ratio, 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 outputColor.a *= alpha;\n }\n\n // \u8BBE\u7F6E\u5F27\u7EBF\u7684\u8D34\u56FE\n if(LineTexture == u_line_texture && u_line_type != LineTypeDash) { \n float arcRadio = smoothstep( 0.0, 1.0, (d_segmentIndex / (segmentNumber - 1.0)));\n // float arcRadio = d_segmentIndex / (segmentNumber - 1.0);\n float count = v_line_data.b; // \u8D34\u56FE\u5728\u5F27\u7EBF\u4E0A\u91CD\u590D\u7684\u6570\u91CF\n float u = fract(arcRadio * count - animateSpeed * count);\n // float u = fract(arcRadio * count - animateSpeed);\n if(u_animate.x == Animate) {\n u = outputColor.a/v_color.a;\n }\n\n float v = v_line_data.a; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n vec2 uv= v_iconMapUV / u_textSize + vec2(u, v) / u_textSize * 64.;\n vec4 pattern = texture(SAMPLER_2D(u_texture), uv);\n \n // \u8BBE\u7F6E\u8D34\u56FE\u548C\u5E95\u8272\u7684\u53E0\u52A0\u6A21\u5F0F\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 } else {\n outputColor = filterColor(outputColor);\n }\n\n // gl_FragColor = filterColor(gl_FragColor);\n}";
|
|
16
17
|
/* babel-plugin-inline-import '../shaders/greatCircle/line_arc_great_circle_vert.glsl' */
|
|
17
|
-
const line_arc2d_vert = "#define LineTypeSolid
|
|
18
|
+
const line_arc2d_vert = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n#define LineTexture 1.0\n\nlayout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in float a_Size;\nlayout(location = 12) in vec4 a_Instance;\nlayout(location = 14) in vec2 a_iconMapUV;\n\nlayout(std140) uniform commonUniorm {\n vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\n vec4 u_dash_array: [10.0, 5., 0, 0];\n vec4 u_sourceColor;\n vec4 u_targetColor;\n vec2 u_textSize;\n float segmentNumber;\n float u_line_type: 0.0;\n float u_icon_step: 100;\n float u_line_texture: 0.0;\n float u_textureBlend;\n float u_time;\n float u_linearColor: 0;\n};\n\nout vec4 v_dash_array;\nout vec4 v_color;\nout vec2 v_iconMapUV;\nout vec4 v_line_data;\nout float v_distance_ratio;\n\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"picking\"\n\nfloat maps (float value, float start1, float stop1, float start2, float stop2) {\n return start2 + (stop2 - start2) * ((value - start1) / (stop1 - start1));\n}\n\nfloat getSegmentRatio(float index) {\n return index / (segmentNumber - 1.);\n}\n\nfloat paraboloid(vec2 source, vec2 target, float ratio) {\n vec2 x = mix(source, target, ratio);\n vec2 center = mix(source, target, 0.5);\n float dSourceCenter = distance(source, center);\n float dXCenter = distance(x, center);\n return (dSourceCenter + dXCenter) * (dSourceCenter - dXCenter);\n}\n\nvec3 getPos(vec2 source, vec2 target, float segmentRatio) {\n float vertex_height = paraboloid(source, target, segmentRatio);\n\n return vec3(\n mix(source, target, segmentRatio),\n sqrt(max(0.0, vertex_height))\n );\n}\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n vec2 offset = dir_screenspace * offset_direction * setPickingSize(a_Size)/ 2.0;\n return offset;\n}\nvec2 getNormal(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n return reverse_offset_normal(vec3(dir_screenspace,1.0)).xy * sign(offset_direction);\n}\nfloat getAngularDist (vec2 source, vec2 target) {\n vec2 delta = source - target;\n vec2 sin_half_delta = sin(delta / 2.0);\n float a =\n sin_half_delta.y * sin_half_delta.y +\n cos(source.y) * cos(target.y) *\n sin_half_delta.x * sin_half_delta.x;\n return 2.0 * atan(sqrt(a), sqrt(1.0 - a));\n}\n\nvec2 midPoint(vec2 source, vec2 target) {\n vec2 center = target - source;\n float r = length(center);\n float theta = atan(center.y, center.x);\n float thetaOffset = 0.314;\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 return mid;\n}\nfloat bezier3(vec3 arr, float t) {\n float ut = 1. - t;\n return (arr.x * ut + arr.y * t) * ut + (arr.y * ut + arr.z * t) * t;\n}\n\nvec2 interpolate (vec2 source, vec2 target, float angularDist, float t) {\n // if the angularDist is PI, linear interpolation is applied. otherwise, use spherical interpolation\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n vec2 mid = midPoint(source, target);\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 }\n else {\n if(abs(angularDist - PI) < 0.001) {\n return (1.0 - t) * source + t * target;\n }\n float a = sin((1.0 - t) * angularDist) / sin(angularDist);\n float b = sin(t * angularDist) / sin(angularDist);\n vec2 sin_source = sin(source);\n vec2 cos_source = cos(source);\n vec2 sin_target = sin(target);\n vec2 cos_target = cos(target);\n float x = a * cos_source.y * cos_source.x + b * cos_target.y * cos_target.x;\n float y = a * cos_source.y * sin_source.x + b * cos_target.y * sin_target.x;\n float z = a * sin_source.y + b * sin_target.y;\n return vec2(atan(y, x), atan(z, sqrt(x * x + y * y)));\n }\n}\n\nvoid main() {\n v_color = a_Color;\n v_color.a = v_color.a * opacity;\n vec2 source = radians(a_Instance.rg);\n vec2 target = radians(a_Instance.ba);\n float angularDist = getAngularDist(source, target);\n float segmentIndex = a_Position.x;\n float segmentRatio = getSegmentRatio(segmentIndex);\n float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\n\n if(u_line_type == LineTypeDash) {\n v_distance_ratio = segmentIndex / segmentNumber;\n vec2 s = source;\n vec2 t = target;\n \n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n s = unProjCustomCoord(source);\n t = unProjCustomCoord(target);\n }\n float total_Distance = pixelDistance(s, t) / 2.0 * PI;\n total_Distance = total_Distance*16.0; // total_Distance*16.0 \u8C03\u6574\u9ED8\u8BA4\u7684\u6548\u679C\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / total_Distance;\n }\n\n if(u_animate.x == Animate) {\n v_distance_ratio = segmentIndex / segmentNumber;\n }\n\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n v_distance_ratio = segmentIndex / segmentNumber;\n vec4 curr = project_position(vec4(degrees(interpolate(source, target, angularDist, segmentRatio)), 0.0, 1.0));\n vec4 next = project_position(vec4(degrees(interpolate(source, target, angularDist, nextSegmentRatio)), 0.0, 1.0));\n // v_normal = getNormal((next.xy - curr.xy) * indexDir, a_Position.y);\n vec2 offset = project_pixel(getExtrusionOffset((next.xy - curr.xy) * indexDir, a_Position.y));\n // vec4 project_pos = project_position(vec4(curr.xy, 0, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(curr.xy + offset, curr.z, 1.0));\n\n v_line_data.g = a_Position.x; // \u8BE5\u9876\u70B9\u5728\u5F27\u7EBF\u4E0A\u7684\u5206\u6BB5\u6392\u5E8F\n if(LineTexture == u_line_texture) { // \u5F00\u542F\u8D34\u56FE\u6A21\u5F0F \n // float mapZoomScale = u_CoordinateSystem !== COORDINATE_SYSTEM_P20_2?10000000.0:1.0;\n float d_arcDistrance = length(source - target);\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20) { // amap\n d_arcDistrance = d_arcDistrance * 1000000.0;\n }\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) { // mapbox\n d_arcDistrance = project_pixel_allmap(d_arcDistrance);\n }\n float d_pixelLen = project_pixel(u_icon_step)/8.0;\n v_line_data.b = floor(d_arcDistrance/d_pixelLen); // \u8D34\u56FE\u5728\u5F27\u7EBF\u4E0A\u91CD\u590D\u7684\u6570\u91CF\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\uFF0C\u6309\u5730\u56FE\u7B49\u7EA7\u7F29\u653E\u540E\u7684\u8DDD\u79BB\n v_line_data.a = lineOffsetWidth/linePixelSize; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n v_iconMapUV = a_iconMapUV;\n }\n\n gl_Position = project_common_position_to_clipspace_v2(vec4(curr.xy + offset, 0, 1.0));\n setPickingColor(a_PickingColor);\n}\n\n";
|
|
18
19
|
const lineStyleObj = {
|
|
19
20
|
solid: 0.0,
|
|
20
21
|
dash: 1.0
|
|
@@ -45,15 +46,6 @@ class GreatCircleModel extends _BaseModel.default {
|
|
|
45
46
|
this.textures = [this.texture];
|
|
46
47
|
});
|
|
47
48
|
}
|
|
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
|
-
});
|
|
56
|
-
}
|
|
57
49
|
getCommonUniformsInfo() {
|
|
58
50
|
const {
|
|
59
51
|
sourceColor,
|
|
@@ -146,7 +138,6 @@ class GreatCircleModel extends _BaseModel.default {
|
|
|
146
138
|
styleOption: {
|
|
147
139
|
segmentNumber
|
|
148
140
|
},
|
|
149
|
-
defines: _this2.getDefines(),
|
|
150
141
|
inject: _this2.getInject(),
|
|
151
142
|
depth: {
|
|
152
143
|
enable: false
|
|
@@ -161,7 +152,7 @@ class GreatCircleModel extends _BaseModel.default {
|
|
|
161
152
|
type: _l7Core.AttributeType.Attribute,
|
|
162
153
|
descriptor: {
|
|
163
154
|
name: 'a_Size',
|
|
164
|
-
shaderLocation:
|
|
155
|
+
shaderLocation: _CommonStyleAttribute.ShaderLocation.SIZE,
|
|
165
156
|
buffer: {
|
|
166
157
|
// give the WebGL driver a hint that this buffer may change
|
|
167
158
|
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
@@ -183,7 +174,7 @@ class GreatCircleModel extends _BaseModel.default {
|
|
|
183
174
|
type: _l7Core.AttributeType.Attribute,
|
|
184
175
|
descriptor: {
|
|
185
176
|
name: 'a_Instance',
|
|
186
|
-
shaderLocation:
|
|
177
|
+
shaderLocation: 12,
|
|
187
178
|
buffer: {
|
|
188
179
|
usage: _l7Core.gl.STATIC_DRAW,
|
|
189
180
|
data: [],
|
|
@@ -195,31 +186,12 @@ class GreatCircleModel extends _BaseModel.default {
|
|
|
195
186
|
}
|
|
196
187
|
}
|
|
197
188
|
});
|
|
198
|
-
|
|
199
|
-
// save low part for enabled double precision INSTANCE attribute
|
|
200
|
-
this.styleAttributeService.registerStyleAttribute({
|
|
201
|
-
name: 'instance64Low',
|
|
202
|
-
type: _l7Core.AttributeType.Attribute,
|
|
203
|
-
descriptor: {
|
|
204
|
-
name: 'a_Instance64Low',
|
|
205
|
-
shaderLocation: this.attributeLocation.INSTANCE_64LOW,
|
|
206
|
-
buffer: {
|
|
207
|
-
usage: _l7Core.gl.STATIC_DRAW,
|
|
208
|
-
data: [],
|
|
209
|
-
type: _l7Core.gl.FLOAT
|
|
210
|
-
},
|
|
211
|
-
size: 4,
|
|
212
|
-
update: (feature, featureIdx, vertex) => {
|
|
213
|
-
return [(0, _l7Utils.fp64LowPart)(vertex[3]), (0, _l7Utils.fp64LowPart)(vertex[4]), (0, _l7Utils.fp64LowPart)(vertex[5]), (0, _l7Utils.fp64LowPart)(vertex[6])];
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
});
|
|
217
189
|
this.styleAttributeService.registerStyleAttribute({
|
|
218
190
|
name: 'uv',
|
|
219
191
|
type: _l7Core.AttributeType.Attribute,
|
|
220
192
|
descriptor: {
|
|
221
193
|
name: 'a_iconMapUV',
|
|
222
|
-
shaderLocation:
|
|
194
|
+
shaderLocation: 14,
|
|
223
195
|
buffer: {
|
|
224
196
|
// give the WebGL driver a hint that this buffer may change
|
|
225
197
|
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
@@ -1,23 +1,6 @@
|
|
|
1
1
|
import type { IModel, ITexture2D } from '@antv/l7-core';
|
|
2
2
|
import BaseModel from '../../core/BaseModel';
|
|
3
3
|
export default class LineModel 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
|
-
DISTANCE_INDEX: number;
|
|
18
|
-
NORMAL: number;
|
|
19
|
-
UV: number;
|
|
20
|
-
};
|
|
21
4
|
private textureEventFlag;
|
|
22
5
|
protected texture: ITexture2D;
|
|
23
6
|
protected getCommonUniformsInfo(): {
|
package/lib/line/models/line.js
CHANGED
|
@@ -12,10 +12,11 @@ var _l7Utils = require("@antv/l7-utils");
|
|
|
12
12
|
var _BaseModel = _interopRequireDefault(require("../../core/BaseModel"));
|
|
13
13
|
var _interface = require("../../core/interface");
|
|
14
14
|
var _triangulation = require("../../core/triangulation");
|
|
15
|
+
var _CommonStyleAttribute = require("../../core/CommonStyleAttribute");
|
|
15
16
|
/* babel-plugin-inline-import '../shaders/line/line_frag.glsl' */
|
|
16
17
|
const line_frag = "// #extension GL_OES_standard_derivatives : enable\n#define Animate 0.0\n#define LineTexture 1.0\n\nuniform sampler2D u_texture;\nlayout(std140) uniform commonUniorm {\n vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\n vec4 u_dash_array;\n vec4 u_blur;\n vec4 u_sourceColor;\n vec4 u_targetColor;\n vec2 u_textSize;\n float u_icon_step: 100;\n float u_heightfixed: 0.0;\n float u_vertexScale: 1.0;\n float u_raisingHeight: 0.0;\n float u_strokeWidth: 0.0;\n float u_textureBlend;\n float u_line_texture;\n float u_linearDir: 1.0;\n float u_linearColor: 0;\n float u_time;\n};\n\nin vec4 v_color;\nin vec4 v_stroke;\n// dash\nin vec4 v_dash_array;\nin float v_d_distance_ratio;\nin vec2 v_iconMapUV;\nin vec4 v_texture_data;\n\nout vec4 outputColor;\n#pragma include \"picking\"\n\n// [animate, duration, interval, trailLength],\nvoid main() {\n if(u_dash_array!=vec4(0.0)){\n float dashLength = mod(v_d_distance_ratio, v_dash_array.x + v_dash_array.y + v_dash_array.z + v_dash_array.w);\n if(!(dashLength < v_dash_array.x || (dashLength > (v_dash_array.x + v_dash_array.y) && dashLength < v_dash_array.x + v_dash_array.y + v_dash_array.z))) {\n // \u865A\u7EBF\u90E8\u5206\n discard;\n };\n }\n float animateSpeed = 0.0; // \u8FD0\u52A8\u901F\u5EA6\n float d_distance_ratio = v_texture_data.r; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n if(u_linearDir < 1.0) {\n d_distance_ratio = v_texture_data.a;\n }\n if(u_linearColor == 1.0) { // \u4F7F\u7528\u6E10\u53D8\u989C\u8272\n outputColor = mix(u_sourceColor, u_targetColor, d_distance_ratio);\n outputColor.a *= v_color.a;\n } else { // \u4F7F\u7528 color \u65B9\u6CD5\u4F20\u5165\u7684\u989C\u8272\n outputColor = v_color;\n }\n // anti-alias\n // float blur = 1.0 - smoothstep(u_blur, 1., length(v_normal.xy));\n if(u_animate.x == Animate) {\n animateSpeed = u_time / u_animate.y;\n float alpha =1.0 - fract( mod(1.0- d_distance_ratio, u_animate.z)* (1.0/ u_animate.z) + animateSpeed);\n alpha = (alpha + u_animate.w -1.0) / u_animate.w;\n alpha = smoothstep(0., 1., alpha);\n outputColor.a *= alpha;\n }\n\n if(u_line_texture == LineTexture) { // while load texture\n float aDistance = v_texture_data.g; // \u5F53\u524D\u9876\u70B9\u7684\u8DDD\u79BB\n float d_texPixelLen = v_texture_data.b; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n float u = fract(mod(aDistance, d_texPixelLen)/d_texPixelLen - animateSpeed);\n float v = v_texture_data.a; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n // v = max(smoothstep(0.95, 1.0, v), v);\n vec2 uv= v_iconMapUV / u_textSize + vec2(u, v) / u_textSize * 64.;\n vec4 pattern = texture(SAMPLER_2D(u_texture), uv);\n\n if(u_textureBlend == 0.0) { // normal\n pattern.a = 0.0;\n outputColor += pattern;\n } else { // replace\n pattern.a *= v_color.a;\n if(outputColor.a <= 0.0) {\n pattern.a = 0.0;\n }\n outputColor = pattern;\n }\n } \n\n float v = v_texture_data.a;\n float strokeWidth = min(0.5, u_strokeWidth);\n // \u7ED8\u5236 border\n if(strokeWidth > 0.01) {\n float borderOuterWidth = strokeWidth / 2.0;\n\n\n if(v >= 1.0 - strokeWidth || v <= strokeWidth) {\n if(v > strokeWidth) { // \u5916\u4FA7\n float linear = smoothstep(0.0, 1.0, (v - (1.0 - strokeWidth))/strokeWidth);\n // float linear = step(0.0, (v - (1.0 - borderWidth))/borderWidth);\n outputColor.rgb = mix(outputColor.rgb, v_stroke.rgb, linear);\n } else if(v <= strokeWidth) {\n float linear = smoothstep(0.0, 1.0, v/strokeWidth);\n outputColor.rgb = mix(v_stroke.rgb, outputColor.rgb, linear);\n }\n }\n\n if(v < borderOuterWidth) {\n outputColor.a = mix(0.0, outputColor.a, v/borderOuterWidth);\n } else if(v > 1.0 - borderOuterWidth) {\n outputColor.a = mix(outputColor.a, 0.0, (v - (1.0 - borderOuterWidth))/borderOuterWidth);\n }\n }\n\n // blur\n float blurV = v_texture_data.a;\n if(blurV < 0.5) {\n outputColor.a *= mix(u_blur.r, u_blur.g, blurV/0.5);\n } else {\n outputColor.a *= mix(u_blur.g, u_blur.b, (blurV - 0.5)/0.5);\n }\n \n outputColor = filterColor(outputColor);\n}\n";
|
|
17
18
|
/* babel-plugin-inline-import '../shaders/line/line_vert.glsl' */
|
|
18
|
-
const line_vert = "#define Animate
|
|
19
|
+
const line_vert = "\n#define Animate 0.0\n\nlayout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in vec2 a_Size;\nlayout(location = 10) in vec3 a_DistanceAndIndexAndMiter;\nlayout(location = 13) in vec4 a_Normal_Total_Distance;\nlayout(location = 14) in vec2 a_iconMapUV;\n\nlayout(std140) uniform commonUniorm {\n vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\n vec4 u_dash_array;\n vec4 u_blur;\n vec4 u_sourceColor;\n vec4 u_targetColor;\n vec2 u_textSize;\n float u_icon_step: 100;\n float u_heightfixed: 0.0;\n float u_vertexScale: 1.0;\n float u_raisingHeight: 0.0;\n float u_strokeWidth: 0.0;\n float u_textureBlend;\n float u_line_texture;\n float u_linearDir: 1.0;\n float u_linearColor: 0;\n float u_time;\n};\n\n\nout vec4 v_color;\nout vec4 v_stroke;\n//dash\nout vec4 v_dash_array;\nout float v_d_distance_ratio;\n// texV \u7EBF\u56FE\u5C42 - \u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\uFF08\u7EBF\u7684\u5BBD\u5EA6\u65B9\u5411\uFF09\nout vec2 v_iconMapUV;\nout vec4 v_texture_data;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n vec2 a_DistanceAndIndex = a_DistanceAndIndexAndMiter.xy;\n float a_Miter = a_DistanceAndIndexAndMiter.z;\n vec3 a_Normal = a_Normal_Total_Distance.xyz;\n float a_Total_Distance = a_Normal_Total_Distance.w;\n //dash\u8F93\u51FA\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / a_Total_Distance;\n v_d_distance_ratio = a_DistanceAndIndex.x / a_Total_Distance;\n\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n float d_texPixelLen; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n v_iconMapUV = a_iconMapUV;\n d_texPixelLen = project_float_pixel(u_icon_step);\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n d_texPixelLen *= 10.0;\n }\n\n v_color = a_Color;\n v_color.a *= opacity;\n v_stroke = stroke;\n\n vec3 size = a_Miter * setPickingSize(a_Size.x) * reverse_offset_normal(a_Normal);\n \n vec2 offset = project_pixel(size.xy);\n\n float lineDistance = a_DistanceAndIndex.x;\n float currentLinePointRatio = lineDistance / a_Total_Distance;\n \n\n float lineOffsetWidth = length(offset + offset * sign(a_Miter)); // \u7EBF\u6A2A\u5411\u504F\u79FB\u7684\u8DDD\u79BB\uFF08\u5411\u4E24\u4FA7\u504F\u79FB\u7684\u548C\uFF09\n float linePixelSize = project_pixel(a_Size.x) * 2.0; // \u5B9A\u70B9\u4F4D\u7F6E\u504F\u79FB\uFF0C\u6309\u5730\u56FE\u7B49\u7EA7\u7F29\u653E\u540E\u7684\u8DDD\u79BB \u5355\u4FA7 * 2\n float texV = lineOffsetWidth/linePixelSize; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n \n v_texture_data = vec4(currentLinePointRatio, lineDistance, d_texPixelLen, texV);\n // \u8BBE\u7F6E\u6570\u636E\u96C6\u7684\u53C2\u6570\n\n vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));\n\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, a_Size.y, 1.0));\n\n float h = float(a_Position.z) * u_vertexScale; // \u7EBF\u9876\u70B9\u7684\u9AD8\u5EA6 - \u517C\u5BB9\u4E0D\u5B58\u5728\u7B2C\u4E09\u4E2A\u6570\u503C\u7684\u60C5\u51B5 vertex height\n float lineHeight = a_Size.y; // size \u7B2C\u4E8C\u4E2A\u53C2\u6570\u4EE3\u8868\u7684\u9AD8\u5EA6 [linewidth, lineheight]\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n lineHeight *= 0.2; // \u4FDD\u6301\u548C amap/mapbox \u4E00\u81F4\u7684\u6548\u679C\n h *= 0.2;\n if(u_heightfixed < 1.0) {\n lineHeight = project_pixel(a_Size.y);\n }\n gl_Position = u_Mvp * (vec4(project_pos.xy + offset, lineHeight + h + u_raisingHeight, 1.0));\n } else {\n // \u517C\u5BB9 mapbox \u5728\u7EBF\u9AD8\u5EA6\u4E0A\u7684\u6548\u679C\u8868\u73B0\u57FA\u672C\u4E00\u81F4\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // mapbox\n // \u4FDD\u6301\u9AD8\u5EA6\u76F8\u5BF9\u4E0D\u53D8\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n h *= mapboxZoomScale;\n h += u_raisingHeight * mapboxZoomScale;\n if(u_heightfixed > 0.0) {\n lineHeight *= mapboxZoomScale;\n }\n \n } else {\n // amap\n h += u_raisingHeight;\n // lineHeight \u9876\u70B9\u504F\u79FB\u9AD8\u5EA6\n if(u_heightfixed < 1.0) {\n lineHeight *= pow(2.0, 20.0 - u_Zoom);\n }\n }\n\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, lineHeight + h, 1.0));\n }\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
19
20
|
class LineModel extends _BaseModel.default {
|
|
20
21
|
constructor(...args) {
|
|
21
22
|
super(...args);
|
|
@@ -49,15 +50,6 @@ class LineModel extends _BaseModel.default {
|
|
|
49
50
|
});
|
|
50
51
|
});
|
|
51
52
|
}
|
|
52
|
-
get attributeLocation() {
|
|
53
|
-
return Object.assign(super.attributeLocation, {
|
|
54
|
-
MAX: super.attributeLocation.MAX,
|
|
55
|
-
SIZE: 9,
|
|
56
|
-
DISTANCE_INDEX: 10,
|
|
57
|
-
NORMAL: 11,
|
|
58
|
-
UV: 12
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
53
|
getCommonUniformsInfo() {
|
|
62
54
|
const {
|
|
63
55
|
sourceColor,
|
|
@@ -166,7 +158,6 @@ class LineModel extends _BaseModel.default {
|
|
|
166
158
|
vertexShader: vert,
|
|
167
159
|
fragmentShader: frag,
|
|
168
160
|
triangulation: _triangulation.LineTriangulation,
|
|
169
|
-
defines: _this2.getDefines(),
|
|
170
161
|
inject: _this2.getInject(),
|
|
171
162
|
depth: {
|
|
172
163
|
enable: depth
|
|
@@ -188,14 +179,12 @@ class LineModel extends _BaseModel.default {
|
|
|
188
179
|
};
|
|
189
180
|
}
|
|
190
181
|
registerBuiltinAttributes() {
|
|
191
|
-
// 注册 Position 属性 64 位地位部分,经纬度数据开启双精度,避免大于 20层级以上出现数据偏移
|
|
192
|
-
this.registerPosition64LowAttribute();
|
|
193
182
|
this.styleAttributeService.registerStyleAttribute({
|
|
194
183
|
name: 'distanceAndIndex',
|
|
195
184
|
type: _l7Core.AttributeType.Attribute,
|
|
196
185
|
descriptor: {
|
|
197
186
|
name: 'a_DistanceAndIndexAndMiter',
|
|
198
|
-
shaderLocation:
|
|
187
|
+
shaderLocation: 10,
|
|
199
188
|
buffer: {
|
|
200
189
|
// give the WebGL driver a hint that this buffer may change
|
|
201
190
|
usage: _l7Core.gl.STATIC_DRAW,
|
|
@@ -213,7 +202,7 @@ class LineModel extends _BaseModel.default {
|
|
|
213
202
|
type: _l7Core.AttributeType.Attribute,
|
|
214
203
|
descriptor: {
|
|
215
204
|
name: 'a_Size',
|
|
216
|
-
shaderLocation:
|
|
205
|
+
shaderLocation: _CommonStyleAttribute.ShaderLocation.SIZE,
|
|
217
206
|
buffer: {
|
|
218
207
|
// give the WebGL driver a hint that this buffer may change
|
|
219
208
|
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
@@ -229,12 +218,14 @@ class LineModel extends _BaseModel.default {
|
|
|
229
218
|
}
|
|
230
219
|
}
|
|
231
220
|
});
|
|
221
|
+
|
|
222
|
+
// point layer size;
|
|
232
223
|
this.styleAttributeService.registerStyleAttribute({
|
|
233
224
|
name: 'normal_total_distance',
|
|
234
225
|
type: _l7Core.AttributeType.Attribute,
|
|
235
226
|
descriptor: {
|
|
236
227
|
name: 'a_Normal_Total_Distance',
|
|
237
|
-
shaderLocation:
|
|
228
|
+
shaderLocation: _CommonStyleAttribute.ShaderLocation.NORMAL,
|
|
238
229
|
buffer: {
|
|
239
230
|
// give the WebGL driver a hint that this buffer may change
|
|
240
231
|
usage: _l7Core.gl.STATIC_DRAW,
|
|
@@ -252,7 +243,7 @@ class LineModel extends _BaseModel.default {
|
|
|
252
243
|
type: _l7Core.AttributeType.Attribute,
|
|
253
244
|
descriptor: {
|
|
254
245
|
name: 'a_iconMapUV',
|
|
255
|
-
shaderLocation:
|
|
246
|
+
shaderLocation: _CommonStyleAttribute.ShaderLocation.UV,
|
|
256
247
|
buffer: {
|
|
257
248
|
// give the WebGL driver a hint that this buffer may change
|
|
258
249
|
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
@@ -1,20 +1,6 @@
|
|
|
1
1
|
import type { IModel } from '@antv/l7-core';
|
|
2
2
|
import BaseModel from '../../core/BaseModel';
|
|
3
3
|
export default class SimpleLineModel 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
|
-
};
|
|
18
4
|
protected getCommonUniformsInfo(): {
|
|
19
5
|
uniformsArray: number[];
|
|
20
6
|
uniformsLength: number;
|
|
@@ -9,18 +9,13 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
|
|
|
9
9
|
var _l7Core = require("@antv/l7-core");
|
|
10
10
|
var _l7Utils = require("@antv/l7-utils");
|
|
11
11
|
var _BaseModel = _interopRequireDefault(require("../../core/BaseModel"));
|
|
12
|
+
var _CommonStyleAttribute = require("../../core/CommonStyleAttribute");
|
|
12
13
|
var _triangulation = require("../../core/triangulation");
|
|
13
14
|
/* babel-plugin-inline-import '../shaders/simple/simpleline_frag.glsl' */
|
|
14
15
|
const simple_line_frag = "\nlayout(std140) uniform commonUniorm {\n vec4 u_sourceColor;\n vec4 u_targetColor;\n vec4 u_dash_array;\n float u_vertexScale: 1.0;\n float u_linearColor: 0;\n};\nin float v_distanceScale;\nin vec4 v_color;\n//dash\nin vec4 v_dash_array;\n\nout vec4 outputColor;\nvoid main() {\n if(u_dash_array!=vec4(0.0)){\n float dashLength = mod(v_distanceScale, v_dash_array.x + v_dash_array.y + v_dash_array.z + v_dash_array.w);\n if(!(dashLength < v_dash_array.x || (dashLength > (v_dash_array.x + v_dash_array.y) && dashLength < v_dash_array.x + v_dash_array.y + v_dash_array.z))) {\n // \u865A\u7EBF\u90E8\u5206\n discard;\n };\n }\n if(u_linearColor==1.0){\n outputColor = mix(u_sourceColor, u_targetColor, v_distanceScale);\n outputColor.a *= v_color.a; // \u5168\u5C40\u900F\u660E\u5EA6\n }\n else{\n outputColor = v_color;\n }\n}\n";
|
|
15
16
|
/* babel-plugin-inline-import '../shaders/simple/simpleline_vert.glsl' */
|
|
16
|
-
const simple_line_vert = "layout(location =
|
|
17
|
+
const simple_line_vert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in vec4 a_SizeDistanceAndTotalDistance;\n\nlayout(std140) uniform commonUniorm {\n vec4 u_sourceColor;\n vec4 u_targetColor;\n vec4 u_dash_array;\n float u_vertexScale: 1.0;\n float u_linearColor: 0;\n};\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nout vec4 v_color;\nout float v_distanceScale;\nout vec4 v_dash_array;\n\nvoid main() {\n //dash\u8F93\u51FA\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / a_SizeDistanceAndTotalDistance.a;\n\n v_color = a_Color; \n v_distanceScale = a_SizeDistanceAndTotalDistance.b / a_SizeDistanceAndTotalDistance.a;\n v_color.a = v_color.a * opacity;\n vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));\n\n float h = float(a_Position.z) * u_vertexScale; // \u7EBF\u9876\u70B9\u7684\u9AD8\u5EA6 - \u517C\u5BB9\u4E0D\u5B58\u5728\u7B2C\u4E09\u4E2A\u6570\u503C\u7684\u60C5\u51B5\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xy, project_pixel(a_SizeDistanceAndTotalDistance.y) + h * 0.2, 1.0));\n } else {\n float lineHeight = a_SizeDistanceAndTotalDistance.y;\n // \u517C\u5BB9 mapbox \u5728\u7EBF\u9AD8\u5EA6\u4E0A\u7684\u6548\u679C\u8868\u73B0\u57FA\u672C\u4E00\u81F4\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // \u4FDD\u6301\u9AD8\u5EA6\u76F8\u5BF9\u4E0D\u53D8\n h *= 2.0/pow(2.0, 20.0 - u_Zoom);\n }\n\n // amap1.x\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20 || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n // \u4FDD\u6301\u9AD8\u5EA6\u76F8\u5BF9\u4E0D\u53D8\n lineHeight *= pow(2.0, 20.0 - u_Zoom);\n }\n\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy, lineHeight + h, 1.0));\n gl_PointSize = 10.0;\n }\n}\n";
|
|
17
18
|
class SimpleLineModel extends _BaseModel.default {
|
|
18
|
-
get attributeLocation() {
|
|
19
|
-
return Object.assign(super.attributeLocation, {
|
|
20
|
-
MAX: super.attributeLocation.MAX,
|
|
21
|
-
SIZE: 9
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
19
|
getCommonUniformsInfo() {
|
|
25
20
|
const {
|
|
26
21
|
sourceColor,
|
|
@@ -84,7 +79,6 @@ class SimpleLineModel extends _BaseModel.default {
|
|
|
84
79
|
vertexShader: vert,
|
|
85
80
|
fragmentShader: frag,
|
|
86
81
|
triangulation: _triangulation.SimpleLineTriangulation,
|
|
87
|
-
defines: _this2.getDefines(),
|
|
88
82
|
inject: _this2.getInject(),
|
|
89
83
|
primitive: _l7Core.gl.LINES,
|
|
90
84
|
depth: {
|
|
@@ -96,16 +90,57 @@ class SimpleLineModel extends _BaseModel.default {
|
|
|
96
90
|
})();
|
|
97
91
|
}
|
|
98
92
|
registerBuiltinAttributes() {
|
|
99
|
-
//
|
|
100
|
-
|
|
101
|
-
|
|
93
|
+
// this.styleAttributeService.registerStyleAttribute({
|
|
94
|
+
// name: 'distance',
|
|
95
|
+
// type: AttributeType.Attribute,
|
|
96
|
+
// descriptor: {
|
|
97
|
+
// name: 'a_Distance',
|
|
98
|
+
// shaderLocation: 14,
|
|
99
|
+
// buffer: {
|
|
100
|
+
// // give the WebGL driver a hint that this buffer may change
|
|
101
|
+
// usage: gl.STATIC_DRAW,
|
|
102
|
+
// data: [],
|
|
103
|
+
// type: gl.FLOAT,
|
|
104
|
+
// },
|
|
105
|
+
// size: 1,
|
|
106
|
+
// update: (
|
|
107
|
+
// feature: IEncodeFeature,
|
|
108
|
+
// featureIdx: number,
|
|
109
|
+
// vertex: number[],
|
|
110
|
+
// ) => {
|
|
111
|
+
// return [vertex[3]];
|
|
112
|
+
// },
|
|
113
|
+
// },
|
|
114
|
+
// });
|
|
115
|
+
// this.styleAttributeService.registerStyleAttribute({
|
|
116
|
+
// name: 'total_distance',
|
|
117
|
+
// type: AttributeType.Attribute,
|
|
118
|
+
// descriptor: {
|
|
119
|
+
// name: 'a_Total_Distance',
|
|
120
|
+
// shaderLocation: 13,//枚举不够了,先固定写值吧,在shader中location也成一致的并且不与其他的重复就行了
|
|
121
|
+
// buffer: {
|
|
122
|
+
// // give the WebGL driver a hint that this buffer may change
|
|
123
|
+
// usage: gl.STATIC_DRAW,
|
|
124
|
+
// data: [],
|
|
125
|
+
// type: gl.FLOAT,
|
|
126
|
+
// },
|
|
127
|
+
// size: 1,
|
|
128
|
+
// update: (
|
|
129
|
+
// feature: IEncodeFeature,
|
|
130
|
+
// featureIdx: number,
|
|
131
|
+
// vertex: number[],
|
|
132
|
+
// ) => {
|
|
133
|
+
// return [vertex[5]];
|
|
134
|
+
// },
|
|
135
|
+
// },
|
|
136
|
+
// });
|
|
102
137
|
//size.x,size,y,distance,totalDistance
|
|
103
138
|
this.styleAttributeService.registerStyleAttribute({
|
|
104
139
|
name: 'sizeDistanceAndTotalDistance',
|
|
105
140
|
type: _l7Core.AttributeType.Attribute,
|
|
106
141
|
descriptor: {
|
|
107
142
|
name: 'a_SizeDistanceAndTotalDistance',
|
|
108
|
-
shaderLocation:
|
|
143
|
+
shaderLocation: _CommonStyleAttribute.ShaderLocation.SIZE,
|
|
109
144
|
buffer: {
|
|
110
145
|
usage: _l7Core.gl.STATIC_DRAW,
|
|
111
146
|
data: [],
|
|
@@ -1,23 +1,6 @@
|
|
|
1
1
|
import type { IModel, ITexture2D } from '@antv/l7-core';
|
|
2
2
|
import BaseModel from '../../core/BaseModel';
|
|
3
3
|
export default class LineWallModel 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
|
-
NORMAL: number;
|
|
18
|
-
UV: number;
|
|
19
|
-
DISTANCE_MITER_TOTAL: number;
|
|
20
|
-
};
|
|
21
4
|
protected texture: ITexture2D;
|
|
22
5
|
protected getCommonUniformsInfo(): {
|
|
23
6
|
uniformsArray: number[];
|
package/lib/line/models/wall.js
CHANGED
|
@@ -10,11 +10,12 @@ 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");
|
|
13
14
|
var _triangulation = require("../../core/triangulation");
|
|
14
15
|
/* babel-plugin-inline-import '../shaders/wall/wall_frag.glsl' */
|
|
15
16
|
const line_frag = "#define Animate 0.0\n#define LineTexture 1.0\n\n// line texture\n\nuniform sampler2D u_texture;\nlayout(std140) uniform commonUniorm {\n vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\n vec4 u_sourceColor;\n vec4 u_targetColor;\n vec2 u_textSize;\n float u_icon_step: 100;\n float u_heightfixed;\n float u_linearColor: 0;\n float u_line_texture;\n float u_textureBlend;\n float u_iconStepCount;\n float u_time;\n};\nin vec2 v_iconMapUV;\nin float v_blur;\nin float v_radio;\nin vec4 v_color;\nin vec4 v_dataset;\n\nout vec4 outputColor;\n#pragma include \"picking\"\n\nvoid main() {\n float animateSpeed = 0.0; // \u8FD0\u52A8\u901F\u5EA6\n float d_distance_ratio = v_dataset.r; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n float v = v_dataset.a;\n\n if(u_linearColor == 1.0) { // \u4F7F\u7528\u6E10\u53D8\u989C\u8272\n outputColor = mix(u_sourceColor, u_targetColor, v);\n } else { // \u4F7F\u7528 color \u65B9\u6CD5\u4F20\u5165\u7684\u989C\u8272\n outputColor = v_color;\n }\n\n outputColor.a *= v_color.a; // \u5168\u5C40\u900F\u660E\u5EA6\n if(u_animate.x == Animate) {\n animateSpeed = u_time / u_animate.y;\n float alpha =1.0 - fract( mod(1.0- d_distance_ratio, u_animate.z)* (1.0/ u_animate.z) + animateSpeed);\n alpha = (alpha + u_animate.w -1.0) / u_animate.w;\n alpha = smoothstep(0., 1., alpha);\n outputColor.a *= alpha;\n }\n\n if(u_line_texture == LineTexture) { // while load texture\n float aDistance = v_dataset.g; // \u5F53\u524D\u9876\u70B9\u7684\u8DDD\u79BB\n float d_texPixelLen = v_dataset.b; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n float u = fract(mod(aDistance, d_texPixelLen)/d_texPixelLen - animateSpeed);\n float v = v_dataset.a; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n // \u8BA1\u7B97\u7EB9\u7406\u95F4\u9694 start\n float flag = 0.0;\n if(u > 1.0/u_iconStepCount) {\n flag = 1.0;\n }\n u = fract(u*u_iconStepCount);\n // \u8BA1\u7B97\u7EB9\u7406\u95F4\u9694 end\n\n vec2 uv= v_iconMapUV / u_textSize + vec2(u, v) / u_textSize * 64.;\n vec4 pattern = texture(SAMPLER_2D(u_texture), uv);\n\n // Tip: \u5224\u65AD\u7EB9\u7406\u95F4\u9694\n if(flag > 0.0) {\n pattern = vec4(0.0);\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 \n\n // blur - AA\n if(v < v_blur) {\n outputColor.a = mix(0.0, outputColor.a, v/v_blur);\n } else if(v > 1.0 - v_blur) {\n outputColor.a = mix(outputColor.a, 0.0, (v - (1.0 - v_blur))/v_blur);\n }\n\n outputColor = filterColor(outputColor);\n}\n";
|
|
16
17
|
/* babel-plugin-inline-import '../shaders/wall/wall_vert.glsl' */
|
|
17
|
-
const line_vert = "#define Animate 0.0\nlayout(location =
|
|
18
|
+
const line_vert = "#define Animate 0.0\nlayout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in vec2 a_Size;\nlayout(location = 10) in float a_Miter;\nlayout(location = 11) in float a_Total_Distance;\nlayout(location = 12) in vec4 a_Instance;\nlayout(location = 13) in vec3 a_Normal;\nlayout(location = 14) in vec2 a_iconMapUV;\nlayout(location = 15) in float a_Distance;\n\n\nlayout(std140) uniform commonUniorm {\n vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\n vec4 u_sourceColor;\n vec4 u_targetColor;\n vec2 u_textSize;\n float u_icon_step: 100;\n float u_heightfixed;\n float u_linearColor: 0;\n float u_line_texture;\n float u_textureBlend;\n float u_iconStepCount;\n float u_time;\n};\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\n// texV \u7EBF\u56FE\u5C42 - \u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\uFF08\u7EBF\u7684\u5BBD\u5EA6\u65B9\u5411\uFF09\nout vec2 v_iconMapUV;\nout vec4 v_color;\nout float v_blur;\nout float v_radio;\nout vec4 v_dataset;\n\nvoid main() {\n\n\n float d_distance_ratio; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n float d_texPixelLen; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n\n v_iconMapUV = a_iconMapUV;\n if(u_heightfixed < 1.0) { // \u9AD8\u5EA6\u968F zoom \u8C03\u6574\n d_texPixelLen = project_pixel(u_icon_step);\n } else {\n d_texPixelLen = u_icon_step;\n }\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n d_texPixelLen *= 10.0;\n }\n\n if(u_animate.x == Animate || u_linearColor == 1.0) {\n d_distance_ratio = a_Distance / a_Total_Distance;\n }\n\n float miter = (a_Miter + 1.0)/2.0;\n // \u8BBE\u7F6E\u6570\u636E\u96C6\u7684\u53C2\u6570\n v_dataset[0] = d_distance_ratio; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n v_dataset[1] = a_Distance; // \u5F53\u524D\u9876\u70B9\u7684\u8DDD\u79BB\n v_dataset[2] = d_texPixelLen; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n v_dataset[3] = miter; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C 0 - 1\n\n vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));\n\n float originSize = a_Size.x; // \u56FA\u5B9A\u9AD8\u5EA6\n if(u_heightfixed < 1.0) { \n originSize = project_float_meter(a_Size.x); // \u9AD8\u5EA6\u968F zoom \u8C03\u6574\n }\n\n\n float wallHeight = originSize * miter;\n float lightWeight = calc_lighting(vec4(project_pos.xy, wallHeight, 1.0));\n\n v_blur = min(project_float_pixel(2.0) / originSize, 0.05);\n v_color = vec4(a_Color.rgb * lightWeight, a_Color.w * opacity);\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xy, wallHeight, 1.0));\n } else {\n// \u517C\u5BB9 mapbox \u5728\u7EBF\u9AD8\u5EA6\u4E0A\u7684\u6548\u679C\u8868\u73B0\u57FA\u672C\u4E00\u81F4\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // mapbox\n // \u4FDD\u6301\u9AD8\u5EA6\u76F8\u5BF9\u4E0D\u53D8\n float mapboxZoomScale = 4.0 / pow(2.0, 21.0 - u_Zoom);\n if(u_heightfixed > 0.0) {\n wallHeight *= mapboxZoomScale;\n }\n \n } else {\n // lineHeight \u9876\u70B9\u504F\u79FB\u9AD8\u5EA6\n if(u_heightfixed < 1.0) {\n wallHeight *= pow(2.0, 20.0 - u_Zoom);\n }\n }\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy, wallHeight, 1.0));\n }\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
18
19
|
class LineWallModel extends _BaseModel.default {
|
|
19
20
|
constructor(...args) {
|
|
20
21
|
super(...args);
|
|
@@ -41,15 +42,6 @@ class LineWallModel extends _BaseModel.default {
|
|
|
41
42
|
this.textures = [this.texture];
|
|
42
43
|
});
|
|
43
44
|
}
|
|
44
|
-
get attributeLocation() {
|
|
45
|
-
return Object.assign(super.attributeLocation, {
|
|
46
|
-
MAX: super.attributeLocation.MAX,
|
|
47
|
-
SIZE: 9,
|
|
48
|
-
NORMAL: 12,
|
|
49
|
-
UV: 13,
|
|
50
|
-
DISTANCE_MITER_TOTAL: 15
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
45
|
getCommonUniformsInfo() {
|
|
54
46
|
const {
|
|
55
47
|
sourceColor,
|
|
@@ -125,7 +117,6 @@ class LineWallModel extends _BaseModel.default {
|
|
|
125
117
|
vertexShader: line_vert,
|
|
126
118
|
fragmentShader: line_frag,
|
|
127
119
|
triangulation: _triangulation.LineTriangulation,
|
|
128
|
-
defines: _this2.getDefines(),
|
|
129
120
|
inject: _this2.getInject(),
|
|
130
121
|
depth: {
|
|
131
122
|
enable: false
|
|
@@ -136,14 +127,48 @@ class LineWallModel extends _BaseModel.default {
|
|
|
136
127
|
})();
|
|
137
128
|
}
|
|
138
129
|
registerBuiltinAttributes() {
|
|
139
|
-
|
|
140
|
-
|
|
130
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
131
|
+
name: 'distance',
|
|
132
|
+
type: _l7Core.AttributeType.Attribute,
|
|
133
|
+
descriptor: {
|
|
134
|
+
name: 'a_Distance',
|
|
135
|
+
shaderLocation: 15,
|
|
136
|
+
buffer: {
|
|
137
|
+
// give the WebGL driver a hint that this buffer may change
|
|
138
|
+
usage: _l7Core.gl.STATIC_DRAW,
|
|
139
|
+
data: [],
|
|
140
|
+
type: _l7Core.gl.FLOAT
|
|
141
|
+
},
|
|
142
|
+
size: 1,
|
|
143
|
+
update: (feature, featureIdx, vertex) => {
|
|
144
|
+
return [vertex[3]];
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
149
|
+
name: 'total_distance',
|
|
150
|
+
type: _l7Core.AttributeType.Attribute,
|
|
151
|
+
descriptor: {
|
|
152
|
+
name: 'a_Total_Distance',
|
|
153
|
+
shaderLocation: 11,
|
|
154
|
+
buffer: {
|
|
155
|
+
// give the WebGL driver a hint that this buffer may change
|
|
156
|
+
usage: _l7Core.gl.STATIC_DRAW,
|
|
157
|
+
data: [],
|
|
158
|
+
type: _l7Core.gl.FLOAT
|
|
159
|
+
},
|
|
160
|
+
size: 1,
|
|
161
|
+
update: (feature, featureIdx, vertex) => {
|
|
162
|
+
return [vertex[5]];
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
});
|
|
141
166
|
this.styleAttributeService.registerStyleAttribute({
|
|
142
167
|
name: 'size',
|
|
143
168
|
type: _l7Core.AttributeType.Attribute,
|
|
144
169
|
descriptor: {
|
|
145
170
|
name: 'a_Size',
|
|
146
|
-
shaderLocation:
|
|
171
|
+
shaderLocation: _CommonStyleAttribute.ShaderLocation.SIZE,
|
|
147
172
|
buffer: {
|
|
148
173
|
// give the WebGL driver a hint that this buffer may change
|
|
149
174
|
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
@@ -159,12 +184,14 @@ class LineWallModel extends _BaseModel.default {
|
|
|
159
184
|
}
|
|
160
185
|
}
|
|
161
186
|
});
|
|
187
|
+
|
|
188
|
+
// point layer size;
|
|
162
189
|
this.styleAttributeService.registerStyleAttribute({
|
|
163
190
|
name: 'normal',
|
|
164
191
|
type: _l7Core.AttributeType.Attribute,
|
|
165
192
|
descriptor: {
|
|
166
193
|
name: 'a_Normal',
|
|
167
|
-
shaderLocation:
|
|
194
|
+
shaderLocation: _CommonStyleAttribute.ShaderLocation.NORMAL,
|
|
168
195
|
buffer: {
|
|
169
196
|
// give the WebGL driver a hint that this buffer may change
|
|
170
197
|
usage: _l7Core.gl.STATIC_DRAW,
|
|
@@ -179,21 +206,20 @@ class LineWallModel extends _BaseModel.default {
|
|
|
179
206
|
}
|
|
180
207
|
});
|
|
181
208
|
this.styleAttributeService.registerStyleAttribute({
|
|
182
|
-
name: '
|
|
209
|
+
name: 'miter',
|
|
183
210
|
type: _l7Core.AttributeType.Attribute,
|
|
184
211
|
descriptor: {
|
|
185
|
-
name: '
|
|
186
|
-
shaderLocation:
|
|
212
|
+
name: 'a_Miter',
|
|
213
|
+
shaderLocation: 10,
|
|
187
214
|
buffer: {
|
|
188
215
|
// give the WebGL driver a hint that this buffer may change
|
|
189
216
|
usage: _l7Core.gl.STATIC_DRAW,
|
|
190
217
|
data: [],
|
|
191
218
|
type: _l7Core.gl.FLOAT
|
|
192
219
|
},
|
|
193
|
-
size:
|
|
220
|
+
size: 1,
|
|
194
221
|
update: (feature, featureIdx, vertex) => {
|
|
195
|
-
|
|
196
|
-
return [vertex[3], vertex[4], vertex[5]];
|
|
222
|
+
return [vertex[4]];
|
|
197
223
|
}
|
|
198
224
|
}
|
|
199
225
|
});
|
|
@@ -202,7 +228,7 @@ class LineWallModel extends _BaseModel.default {
|
|
|
202
228
|
type: _l7Core.AttributeType.Attribute,
|
|
203
229
|
descriptor: {
|
|
204
230
|
name: 'a_iconMapUV',
|
|
205
|
-
shaderLocation:
|
|
231
|
+
shaderLocation: 14,
|
|
206
232
|
buffer: {
|
|
207
233
|
// give the WebGL driver a hint that this buffer may change
|
|
208
234
|
usage: _l7Core.gl.DYNAMIC_DRAW,
|