@antv/l7-layers 2.21.8 → 2.21.9-beta.0
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.js +9 -8
- package/es/core/BaseModel.d.ts +15 -2
- package/es/core/BaseModel.js +94 -62
- package/es/core/CommonStyleAttribute.d.ts +14 -18
- package/es/core/CommonStyleAttribute.js +23 -67
- package/es/core/triangulation.js +13 -39
- 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 -3
- 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 +42 -48
- 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 +56 -72
- 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 +2 -34
- 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 +12 -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.js +9 -8
- package/lib/core/BaseModel.d.ts +15 -2
- package/lib/core/BaseModel.js +92 -60
- package/lib/core/CommonStyleAttribute.d.ts +14 -18
- package/lib/core/CommonStyleAttribute.js +23 -68
- package/lib/core/triangulation.js +13 -39
- 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 -3
- 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 +42 -48
- 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 +56 -72
- 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 +2 -34
- 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 +12 -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
|
@@ -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/greatCircle/line_arc_great_circle_frag.glsl' */
|
|
16
15
|
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}";
|
|
17
16
|
/* babel-plugin-inline-import '../shaders/greatCircle/line_arc_great_circle_vert.glsl' */
|
|
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 =
|
|
17
|
+
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 = 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: [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.0);\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(mix(source, target, segmentRatio), sqrt(max(0.0, vertex_height)));\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}\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) * 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.0 - 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 (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 float total_Distance = pixelDistance(source, target) / 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\n vec4 curr = project_position(vec4(degrees(interpolate(source, target, angularDist, segmentRatio)), 0.0, 1.0), a_Instance64Low.xy);\n vec4 next = project_position(vec4(degrees(interpolate(source, target, angularDist, nextSegmentRatio)), 0.0, 1.0), a_Instance64Low.zw);\n\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) {\n float d_arcDistrance = length(source - target);\n if (\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT ||\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET\n ) {\n // 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(vec4(curr.xy + offset, 0, 1.0));\n setPickingColor(a_PickingColor);\n}\n\n";
|
|
19
18
|
const lineStyleObj = {
|
|
20
19
|
solid: 0.0,
|
|
21
20
|
dash: 1.0
|
|
@@ -46,6 +45,15 @@ class GreatCircleModel 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
|
+
});
|
|
56
|
+
}
|
|
49
57
|
getCommonUniformsInfo() {
|
|
50
58
|
const {
|
|
51
59
|
sourceColor,
|
|
@@ -138,6 +146,7 @@ class GreatCircleModel extends _BaseModel.default {
|
|
|
138
146
|
styleOption: {
|
|
139
147
|
segmentNumber
|
|
140
148
|
},
|
|
149
|
+
defines: _this2.getDefines(),
|
|
141
150
|
inject: _this2.getInject(),
|
|
142
151
|
depth: {
|
|
143
152
|
enable: false
|
|
@@ -152,7 +161,7 @@ class GreatCircleModel extends _BaseModel.default {
|
|
|
152
161
|
type: _l7Core.AttributeType.Attribute,
|
|
153
162
|
descriptor: {
|
|
154
163
|
name: 'a_Size',
|
|
155
|
-
shaderLocation:
|
|
164
|
+
shaderLocation: this.attributeLocation.SIZE,
|
|
156
165
|
buffer: {
|
|
157
166
|
// give the WebGL driver a hint that this buffer may change
|
|
158
167
|
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
@@ -174,7 +183,7 @@ class GreatCircleModel extends _BaseModel.default {
|
|
|
174
183
|
type: _l7Core.AttributeType.Attribute,
|
|
175
184
|
descriptor: {
|
|
176
185
|
name: 'a_Instance',
|
|
177
|
-
shaderLocation:
|
|
186
|
+
shaderLocation: this.attributeLocation.INSTANCE,
|
|
178
187
|
buffer: {
|
|
179
188
|
usage: _l7Core.gl.STATIC_DRAW,
|
|
180
189
|
data: [],
|
|
@@ -186,12 +195,31 @@ class GreatCircleModel extends _BaseModel.default {
|
|
|
186
195
|
}
|
|
187
196
|
}
|
|
188
197
|
});
|
|
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
|
+
});
|
|
189
217
|
this.styleAttributeService.registerStyleAttribute({
|
|
190
218
|
name: 'uv',
|
|
191
219
|
type: _l7Core.AttributeType.Attribute,
|
|
192
220
|
descriptor: {
|
|
193
221
|
name: 'a_iconMapUV',
|
|
194
|
-
shaderLocation:
|
|
222
|
+
shaderLocation: this.attributeLocation.UV,
|
|
195
223
|
buffer: {
|
|
196
224
|
// give the WebGL driver a hint that this buffer may change
|
|
197
225
|
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
@@ -1,6 +1,23 @@
|
|
|
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
|
+
};
|
|
4
21
|
private textureEventFlag;
|
|
5
22
|
protected texture: ITexture2D;
|
|
6
23
|
protected getCommonUniformsInfo(): {
|
package/lib/line/models/line.js
CHANGED
|
@@ -12,11 +12,10 @@ 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");
|
|
16
15
|
/* babel-plugin-inline-import '../shaders/line/line_frag.glsl' */
|
|
17
16
|
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";
|
|
18
17
|
/* babel-plugin-inline-import '../shaders/line/line_vert.glsl' */
|
|
19
|
-
const line_vert = "
|
|
18
|
+
const line_vert = "#define Animate (0.0)\n\nlayout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_POSITION_64LOW) in vec2 a_Position64Low;\nlayout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;\nlayout(location = ATTRIBUTE_LOCATION_SIZE) in vec2 a_Size;\nlayout(location = ATTRIBUTE_LOCATION_DISTANCE_INDEX) in vec3 a_DistanceAndIndexAndMiter;\nlayout(location = ATTRIBUTE_LOCATION_NORMAL) in vec4 a_Normal_Total_Distance;\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_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\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\n v_color = a_Color;\n v_color.a *= opacity;\n v_stroke = stroke;\n\n vec3 size = a_Miter * setPickingSize(a_Size.x) * 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 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), a_Position64Low);\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 // \u517C\u5BB9 mapbox \u5728\u7EBF\u9AD8\u5EA6\u4E0A\u7684\u6548\u679C\u8868\u73B0\u57FA\u672C\u4E00\u81F4\n if (\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT ||\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET\n ) {\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\n gl_Position = project_common_position_to_clipspace(\n vec4(project_pos.xy + offset, lineHeight + h, 1.0)\n );\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
20
19
|
class LineModel extends _BaseModel.default {
|
|
21
20
|
constructor(...args) {
|
|
22
21
|
super(...args);
|
|
@@ -50,6 +49,15 @@ class LineModel extends _BaseModel.default {
|
|
|
50
49
|
});
|
|
51
50
|
});
|
|
52
51
|
}
|
|
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
|
+
}
|
|
53
61
|
getCommonUniformsInfo() {
|
|
54
62
|
const {
|
|
55
63
|
sourceColor,
|
|
@@ -158,6 +166,7 @@ class LineModel extends _BaseModel.default {
|
|
|
158
166
|
vertexShader: vert,
|
|
159
167
|
fragmentShader: frag,
|
|
160
168
|
triangulation: _triangulation.LineTriangulation,
|
|
169
|
+
defines: _this2.getDefines(),
|
|
161
170
|
inject: _this2.getInject(),
|
|
162
171
|
depth: {
|
|
163
172
|
enable: depth
|
|
@@ -179,12 +188,14 @@ class LineModel extends _BaseModel.default {
|
|
|
179
188
|
};
|
|
180
189
|
}
|
|
181
190
|
registerBuiltinAttributes() {
|
|
191
|
+
// 注册 Position 属性 64 位地位部分,经纬度数据开启双精度,避免大于 20层级以上出现数据偏移
|
|
192
|
+
this.registerPosition64LowAttribute();
|
|
182
193
|
this.styleAttributeService.registerStyleAttribute({
|
|
183
194
|
name: 'distanceAndIndex',
|
|
184
195
|
type: _l7Core.AttributeType.Attribute,
|
|
185
196
|
descriptor: {
|
|
186
197
|
name: 'a_DistanceAndIndexAndMiter',
|
|
187
|
-
shaderLocation:
|
|
198
|
+
shaderLocation: this.attributeLocation.DISTANCE_INDEX,
|
|
188
199
|
buffer: {
|
|
189
200
|
// give the WebGL driver a hint that this buffer may change
|
|
190
201
|
usage: _l7Core.gl.STATIC_DRAW,
|
|
@@ -202,7 +213,7 @@ class LineModel extends _BaseModel.default {
|
|
|
202
213
|
type: _l7Core.AttributeType.Attribute,
|
|
203
214
|
descriptor: {
|
|
204
215
|
name: 'a_Size',
|
|
205
|
-
shaderLocation:
|
|
216
|
+
shaderLocation: this.attributeLocation.SIZE,
|
|
206
217
|
buffer: {
|
|
207
218
|
// give the WebGL driver a hint that this buffer may change
|
|
208
219
|
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
@@ -218,14 +229,12 @@ class LineModel extends _BaseModel.default {
|
|
|
218
229
|
}
|
|
219
230
|
}
|
|
220
231
|
});
|
|
221
|
-
|
|
222
|
-
// point layer size;
|
|
223
232
|
this.styleAttributeService.registerStyleAttribute({
|
|
224
233
|
name: 'normal_total_distance',
|
|
225
234
|
type: _l7Core.AttributeType.Attribute,
|
|
226
235
|
descriptor: {
|
|
227
236
|
name: 'a_Normal_Total_Distance',
|
|
228
|
-
shaderLocation:
|
|
237
|
+
shaderLocation: this.attributeLocation.NORMAL,
|
|
229
238
|
buffer: {
|
|
230
239
|
// give the WebGL driver a hint that this buffer may change
|
|
231
240
|
usage: _l7Core.gl.STATIC_DRAW,
|
|
@@ -243,7 +252,7 @@ class LineModel extends _BaseModel.default {
|
|
|
243
252
|
type: _l7Core.AttributeType.Attribute,
|
|
244
253
|
descriptor: {
|
|
245
254
|
name: 'a_iconMapUV',
|
|
246
|
-
shaderLocation:
|
|
255
|
+
shaderLocation: this.attributeLocation.UV,
|
|
247
256
|
buffer: {
|
|
248
257
|
// give the WebGL driver a hint that this buffer may change
|
|
249
258
|
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
@@ -1,6 +1,20 @@
|
|
|
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
|
+
};
|
|
4
18
|
protected getCommonUniformsInfo(): {
|
|
5
19
|
uniformsArray: number[];
|
|
6
20
|
uniformsLength: number;
|
|
@@ -9,13 +9,18 @@ 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");
|
|
13
12
|
var _triangulation = require("../../core/triangulation");
|
|
14
13
|
/* babel-plugin-inline-import '../shaders/simple/simpleline_frag.glsl' */
|
|
15
14
|
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";
|
|
16
15
|
/* babel-plugin-inline-import '../shaders/simple/simpleline_vert.glsl' */
|
|
17
|
-
const simple_line_vert = "layout(location =
|
|
16
|
+
const simple_line_vert = "layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_POSITION_64LOW) in vec2 a_Position64Low;\nlayout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;\nlayout(location = ATTRIBUTE_LOCATION_SIZE) 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), a_Position64Low);\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 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 (\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT ||\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET\n ) {\n // \u4FDD\u6301\u9AD8\u5EA6\u76F8\u5BF9\u4E0D\u53D8\n h *= 2.0 / 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";
|
|
18
17
|
class SimpleLineModel extends _BaseModel.default {
|
|
18
|
+
get attributeLocation() {
|
|
19
|
+
return Object.assign(super.attributeLocation, {
|
|
20
|
+
MAX: super.attributeLocation.MAX,
|
|
21
|
+
SIZE: 9
|
|
22
|
+
});
|
|
23
|
+
}
|
|
19
24
|
getCommonUniformsInfo() {
|
|
20
25
|
const {
|
|
21
26
|
sourceColor,
|
|
@@ -79,6 +84,7 @@ class SimpleLineModel extends _BaseModel.default {
|
|
|
79
84
|
vertexShader: vert,
|
|
80
85
|
fragmentShader: frag,
|
|
81
86
|
triangulation: _triangulation.SimpleLineTriangulation,
|
|
87
|
+
defines: _this2.getDefines(),
|
|
82
88
|
inject: _this2.getInject(),
|
|
83
89
|
primitive: _l7Core.gl.LINES,
|
|
84
90
|
depth: {
|
|
@@ -90,57 +96,16 @@ class SimpleLineModel extends _BaseModel.default {
|
|
|
90
96
|
})();
|
|
91
97
|
}
|
|
92
98
|
registerBuiltinAttributes() {
|
|
93
|
-
//
|
|
94
|
-
|
|
95
|
-
|
|
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
|
-
// });
|
|
99
|
+
// 注册 Position 属性 64 位地位部分,经纬度数据开启双精度,避免大于 20层级以上出现数据偏移
|
|
100
|
+
this.registerPosition64LowAttribute();
|
|
101
|
+
|
|
137
102
|
//size.x,size,y,distance,totalDistance
|
|
138
103
|
this.styleAttributeService.registerStyleAttribute({
|
|
139
104
|
name: 'sizeDistanceAndTotalDistance',
|
|
140
105
|
type: _l7Core.AttributeType.Attribute,
|
|
141
106
|
descriptor: {
|
|
142
107
|
name: 'a_SizeDistanceAndTotalDistance',
|
|
143
|
-
shaderLocation:
|
|
108
|
+
shaderLocation: this.attributeLocation.SIZE,
|
|
144
109
|
buffer: {
|
|
145
110
|
usage: _l7Core.gl.STATIC_DRAW,
|
|
146
111
|
data: [],
|
|
@@ -1,6 +1,23 @@
|
|
|
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
|
+
};
|
|
4
21
|
protected texture: ITexture2D;
|
|
5
22
|
protected getCommonUniformsInfo(): {
|
|
6
23
|
uniformsArray: number[];
|
package/lib/line/models/wall.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/wall/wall_frag.glsl' */
|
|
16
15
|
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";
|
|
17
16
|
/* babel-plugin-inline-import '../shaders/wall/wall_vert.glsl' */
|
|
18
|
-
const line_vert = "#define Animate 0.0\nlayout(location =
|
|
17
|
+
const line_vert = "#define Animate 0.0\nlayout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_POSITION_64LOW) in vec2 a_Position64Low;\nlayout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;\nlayout(location = ATTRIBUTE_LOCATION_SIZE) in vec2 a_Size;\nlayout(location = ATTRIBUTE_LOCATION_NORMAL) in vec3 a_Normal;\nlayout(location = ATTRIBUTE_LOCATION_UV) in vec2 a_iconMapUV;\nlayout(location = ATTRIBUTE_LOCATION_DISTANCE_MITER_TOTAL) in vec3 a_Distance_Total_Miter;\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\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 float a_Distance = a_Distance_Total_Miter.x;\n float a_Miter = a_Distance_Total_Miter.y;\n float a_Total_Distance = a_Distance_Total_Miter.z;\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) {\n // \u9AD8\u5EA6\u968F zoom \u8C03\u6574\n d_texPixelLen = project_pixel(u_icon_step);\n } else {\n d_texPixelLen = u_icon_step;\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), a_Position64Low);\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 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 // \u517C\u5BB9 mapbox \u5728\u7EBF\u9AD8\u5EA6\u4E0A\u7684\u6548\u679C\u8868\u73B0\u57FA\u672C\u4E00\u81F4\n if (\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT ||\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET\n ) {\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\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy, wallHeight, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
19
18
|
class LineWallModel extends _BaseModel.default {
|
|
20
19
|
constructor(...args) {
|
|
21
20
|
super(...args);
|
|
@@ -42,6 +41,15 @@ class LineWallModel extends _BaseModel.default {
|
|
|
42
41
|
this.textures = [this.texture];
|
|
43
42
|
});
|
|
44
43
|
}
|
|
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
|
+
}
|
|
45
53
|
getCommonUniformsInfo() {
|
|
46
54
|
const {
|
|
47
55
|
sourceColor,
|
|
@@ -117,6 +125,7 @@ class LineWallModel extends _BaseModel.default {
|
|
|
117
125
|
vertexShader: line_vert,
|
|
118
126
|
fragmentShader: line_frag,
|
|
119
127
|
triangulation: _triangulation.LineTriangulation,
|
|
128
|
+
defines: _this2.getDefines(),
|
|
120
129
|
inject: _this2.getInject(),
|
|
121
130
|
depth: {
|
|
122
131
|
enable: false
|
|
@@ -127,48 +136,14 @@ class LineWallModel extends _BaseModel.default {
|
|
|
127
136
|
})();
|
|
128
137
|
}
|
|
129
138
|
registerBuiltinAttributes() {
|
|
130
|
-
|
|
131
|
-
|
|
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
|
-
});
|
|
139
|
+
// 注册 Position 属性 64 位地位部分,经纬度数据开启双精度,避免大于 20层级以上出现数据偏移
|
|
140
|
+
this.registerPosition64LowAttribute();
|
|
166
141
|
this.styleAttributeService.registerStyleAttribute({
|
|
167
142
|
name: 'size',
|
|
168
143
|
type: _l7Core.AttributeType.Attribute,
|
|
169
144
|
descriptor: {
|
|
170
145
|
name: 'a_Size',
|
|
171
|
-
shaderLocation:
|
|
146
|
+
shaderLocation: this.attributeLocation.SIZE,
|
|
172
147
|
buffer: {
|
|
173
148
|
// give the WebGL driver a hint that this buffer may change
|
|
174
149
|
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
@@ -184,14 +159,12 @@ class LineWallModel extends _BaseModel.default {
|
|
|
184
159
|
}
|
|
185
160
|
}
|
|
186
161
|
});
|
|
187
|
-
|
|
188
|
-
// point layer size;
|
|
189
162
|
this.styleAttributeService.registerStyleAttribute({
|
|
190
163
|
name: 'normal',
|
|
191
164
|
type: _l7Core.AttributeType.Attribute,
|
|
192
165
|
descriptor: {
|
|
193
166
|
name: 'a_Normal',
|
|
194
|
-
shaderLocation:
|
|
167
|
+
shaderLocation: this.attributeLocation.NORMAL,
|
|
195
168
|
buffer: {
|
|
196
169
|
// give the WebGL driver a hint that this buffer may change
|
|
197
170
|
usage: _l7Core.gl.STATIC_DRAW,
|
|
@@ -206,20 +179,21 @@ class LineWallModel extends _BaseModel.default {
|
|
|
206
179
|
}
|
|
207
180
|
});
|
|
208
181
|
this.styleAttributeService.registerStyleAttribute({
|
|
209
|
-
name: '
|
|
182
|
+
name: 'distanceAndTotalAndMiter',
|
|
210
183
|
type: _l7Core.AttributeType.Attribute,
|
|
211
184
|
descriptor: {
|
|
212
|
-
name: '
|
|
213
|
-
shaderLocation:
|
|
185
|
+
name: 'a_Distance_Total_Miter',
|
|
186
|
+
shaderLocation: this.attributeLocation.DISTANCE_MITER_TOTAL,
|
|
214
187
|
buffer: {
|
|
215
188
|
// give the WebGL driver a hint that this buffer may change
|
|
216
189
|
usage: _l7Core.gl.STATIC_DRAW,
|
|
217
190
|
data: [],
|
|
218
191
|
type: _l7Core.gl.FLOAT
|
|
219
192
|
},
|
|
220
|
-
size:
|
|
193
|
+
size: 3,
|
|
221
194
|
update: (feature, featureIdx, vertex) => {
|
|
222
|
-
|
|
195
|
+
// [distance, miter, total_distance]
|
|
196
|
+
return [vertex[3], vertex[4], vertex[5]];
|
|
223
197
|
}
|
|
224
198
|
}
|
|
225
199
|
});
|
|
@@ -228,7 +202,7 @@ class LineWallModel extends _BaseModel.default {
|
|
|
228
202
|
type: _l7Core.AttributeType.Attribute,
|
|
229
203
|
descriptor: {
|
|
230
204
|
name: 'a_iconMapUV',
|
|
231
|
-
shaderLocation:
|
|
205
|
+
shaderLocation: this.attributeLocation.UV,
|
|
232
206
|
buffer: {
|
|
233
207
|
// give the WebGL driver a hint that this buffer may change
|
|
234
208
|
usage: _l7Core.gl.DYNAMIC_DRAW,
|