@antv/l7-layers 2.18.3 → 2.19.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.js +1 -1
- package/es/citybuliding/shaders/build_vert.glsl +0 -1
- package/es/core/BaseModel.js +4 -2
- package/es/core/CommonStyleAttribute.js +20 -0
- package/es/core/interface.d.ts +4 -0
- package/es/{Geometry → geometry}/models/billboard.js +1 -1
- package/es/{Geometry → geometry}/models/plane.js +1 -1
- package/es/{Geometry → geometry}/models/sprite.js +1 -1
- package/{lib/Geometry → es/geometry}/shaders/billboard_vert.glsl +1 -8
- package/es/geometry/shaders/plane_vert.glsl +31 -0
- package/es/{Geometry → geometry}/shaders/sprite_vert.glsl +2 -8
- package/es/heatmap/models/grid.js +1 -1
- package/es/heatmap/models/grid3d.js +1 -1
- package/es/heatmap/models/heatmap.js +1 -1
- package/es/heatmap/models/hexagon.js +1 -1
- package/es/heatmap/shaders/grid_vert.glsl +1 -1
- package/es/heatmap/shaders/heatmap_framebuffer_vert.glsl +1 -1
- package/es/heatmap/shaders/hexagon_3d_vert.glsl +1 -1
- package/es/heatmap/shaders/hexagon_vert.glsl +1 -1
- package/es/image/models/image.js +1 -1
- package/es/image/shaders/image_vert.glsl +3 -7
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/line/models/arc.js +3 -3
- package/es/line/models/arc_3d.js +2 -2
- package/es/line/models/earthArc_3d.js +2 -2
- package/es/line/models/flow.js +1 -1
- package/es/line/models/great_circle.js +1 -1
- package/es/line/models/line.js +2 -2
- package/es/line/models/linearline.js +1 -1
- package/es/line/models/simpleLine.js +1 -1
- package/es/line/models/wall.js +1 -1
- package/es/line/shaders/dash/arc_dash_vert.glsl +3 -6
- package/es/line/shaders/dash/line_dash_vert.glsl +2 -1
- package/es/line/shaders/flow/flow_line_vert.glsl +2 -7
- package/es/line/shaders/line_arc2d_vert.glsl +1 -1
- package/es/line/shaders/line_arc_3d_vert.glsl +3 -8
- package/es/line/shaders/line_arc_great_circle_vert.glsl +4 -6
- package/es/line/shaders/line_arc_vert.glsl +3 -9
- package/es/line/shaders/line_bezier_vert.glsl +1 -1
- package/es/line/shaders/line_vert.glsl +1 -1
- package/es/line/shaders/linear/arc3d_linear_vert.glsl +2 -8
- package/es/line/shaders/linear/arc_linear_vert.glsl +3 -6
- package/es/line/shaders/linearLine/line_linear_vert.glsl +1 -1
- package/es/line/shaders/simple/simpleline_vert.glsl +1 -1
- package/es/line/shaders/wall/wall_vert.glsl +1 -1
- package/es/mask/models/fill.js +1 -1
- package/es/mask/shaders/mask_vert.glsl +1 -1
- package/es/point/models/billboard_point.js +1 -1
- package/es/point/models/earthExtrude.js +1 -1
- package/es/point/models/earthFill.js +1 -1
- package/es/point/models/extrude.js +1 -1
- package/es/point/models/fill.js +1 -1
- package/es/point/models/fillmage.js +1 -1
- package/es/point/models/image.js +1 -1
- package/es/point/models/normal.js +1 -1
- package/es/point/models/radar.js +2 -2
- package/es/point/models/text.js +1 -1
- package/es/point/shaders/billboard_point_vert.glsl +2 -2
- package/es/point/shaders/earth/extrude_vert.glsl +1 -1
- package/es/point/shaders/earth/fill_vert.glsl +1 -1
- package/es/point/shaders/extrude/extrude_vert.glsl +2 -6
- package/es/point/shaders/fill_vert.glsl +3 -10
- package/es/point/shaders/image/fillImage_vert.glsl +2 -8
- package/es/point/shaders/image_vert.glsl +3 -6
- package/es/point/shaders/normal_vert.glsl +1 -1
- package/es/point/shaders/radar/radar_frag.glsl +0 -6
- package/es/point/shaders/radar/radar_vert.glsl +2 -9
- package/es/point/shaders/text_vert.glsl +2 -7
- package/es/polygon/index.js +3 -1
- package/es/polygon/models/extrude.js +3 -3
- package/es/polygon/models/extrusion.d.ts +17 -0
- package/es/polygon/models/extrusion.js +137 -0
- package/es/polygon/models/fill.js +2 -2
- package/es/polygon/models/index.d.ts +1 -1
- package/es/polygon/models/index.js +3 -1
- package/es/polygon/models/ocean.js +1 -1
- package/es/polygon/models/water.js +1 -1
- package/es/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +2 -10
- package/es/polygon/shaders/extrude/polygon_extrude_vert.glsl +2 -8
- package/es/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +2 -8
- package/es/polygon/shaders/extrusion/polygon_extrusion_frag.glsl +13 -0
- package/es/polygon/shaders/extrusion/polygon_extrusion_vert.glsl +34 -0
- package/es/polygon/shaders/polygon_linear_vert.glsl +2 -7
- package/es/polygon/shaders/polygon_vert.glsl +3 -6
- package/es/polygon/shaders/water/polygon_ocean_vert.glsl +2 -7
- package/es/polygon/shaders/water/polygon_water_vert.glsl +2 -6
- package/es/raster/models/raster.js +1 -1
- package/es/raster/models/rasterRgb.js +1 -1
- package/es/raster/models/rasterTerrainRgb.js +1 -1
- package/es/raster/shaders/raster_2d_vert.glsl +2 -6
- package/es/raster/shaders/raster_vert.glsl +2 -12
- package/es/raster/shaders/rater_terrain_rgb_vert.glsl +2 -7
- package/es/wind/models/wind.js +1 -1
- package/es/wind/shaders/wind_vert.glsl +3 -7
- package/lib/citybuliding/models/build.js +1 -1
- package/lib/citybuliding/shaders/build_vert.glsl +0 -1
- package/lib/core/BaseModel.js +4 -2
- package/lib/core/CommonStyleAttribute.js +20 -0
- package/lib/{Geometry → geometry}/models/billboard.js +1 -1
- package/lib/{Geometry → geometry}/models/plane.js +1 -1
- package/lib/{Geometry → geometry}/models/sprite.js +1 -1
- package/{es/Geometry → lib/geometry}/shaders/billboard_vert.glsl +1 -8
- package/lib/geometry/shaders/plane_vert.glsl +31 -0
- package/lib/{Geometry → geometry}/shaders/sprite_vert.glsl +2 -8
- package/lib/heatmap/models/grid.js +1 -1
- package/lib/heatmap/models/grid3d.js +1 -1
- package/lib/heatmap/models/heatmap.js +1 -1
- package/lib/heatmap/models/hexagon.js +1 -1
- package/lib/heatmap/shaders/grid_vert.glsl +1 -1
- package/lib/heatmap/shaders/heatmap_framebuffer_vert.glsl +1 -1
- package/lib/heatmap/shaders/hexagon_3d_vert.glsl +1 -1
- package/lib/heatmap/shaders/hexagon_vert.glsl +1 -1
- package/lib/image/models/image.js +1 -1
- package/lib/image/shaders/image_vert.glsl +3 -7
- package/lib/index.js +2 -2
- package/lib/line/models/arc.js +3 -3
- package/lib/line/models/arc_3d.js +2 -2
- package/lib/line/models/earthArc_3d.js +2 -2
- package/lib/line/models/flow.js +1 -1
- package/lib/line/models/great_circle.js +1 -1
- package/lib/line/models/line.js +2 -2
- package/lib/line/models/linearline.js +1 -1
- package/lib/line/models/simpleLine.js +1 -1
- package/lib/line/models/wall.js +1 -1
- package/lib/line/shaders/dash/arc_dash_vert.glsl +3 -6
- package/lib/line/shaders/dash/line_dash_vert.glsl +2 -1
- package/lib/line/shaders/flow/flow_line_vert.glsl +2 -7
- package/lib/line/shaders/line_arc2d_vert.glsl +1 -1
- package/lib/line/shaders/line_arc_3d_vert.glsl +3 -8
- package/lib/line/shaders/line_arc_great_circle_vert.glsl +4 -6
- package/lib/line/shaders/line_arc_vert.glsl +3 -9
- package/lib/line/shaders/line_bezier_vert.glsl +1 -1
- package/lib/line/shaders/line_vert.glsl +1 -1
- package/lib/line/shaders/linear/arc3d_linear_vert.glsl +2 -8
- package/lib/line/shaders/linear/arc_linear_vert.glsl +3 -6
- package/lib/line/shaders/linearLine/line_linear_vert.glsl +1 -1
- package/lib/line/shaders/simple/simpleline_vert.glsl +1 -1
- package/lib/line/shaders/wall/wall_vert.glsl +1 -1
- package/lib/mask/models/fill.js +1 -1
- package/lib/mask/shaders/mask_vert.glsl +1 -1
- package/lib/point/models/billboard_point.js +1 -1
- package/lib/point/models/earthExtrude.js +1 -1
- package/lib/point/models/earthFill.js +1 -1
- package/lib/point/models/extrude.js +1 -1
- package/lib/point/models/fill.js +1 -1
- package/lib/point/models/fillmage.js +1 -1
- package/lib/point/models/image.js +1 -1
- package/lib/point/models/normal.js +1 -1
- package/lib/point/models/radar.js +2 -2
- package/lib/point/models/text.js +1 -1
- package/lib/point/shaders/billboard_point_vert.glsl +2 -2
- package/lib/point/shaders/earth/extrude_vert.glsl +1 -1
- package/lib/point/shaders/earth/fill_vert.glsl +1 -1
- package/lib/point/shaders/extrude/extrude_vert.glsl +2 -6
- package/lib/point/shaders/fill_vert.glsl +3 -10
- package/lib/point/shaders/image/fillImage_vert.glsl +2 -8
- package/lib/point/shaders/image_vert.glsl +3 -6
- package/lib/point/shaders/normal_vert.glsl +1 -1
- package/lib/point/shaders/radar/radar_frag.glsl +0 -6
- package/lib/point/shaders/radar/radar_vert.glsl +2 -9
- package/lib/point/shaders/text_vert.glsl +2 -7
- package/lib/polygon/index.js +3 -1
- package/lib/polygon/models/extrude.js +3 -3
- package/lib/polygon/models/extrusion.js +144 -0
- package/lib/polygon/models/fill.js +2 -2
- package/lib/polygon/models/index.js +3 -1
- package/lib/polygon/models/ocean.js +1 -1
- package/lib/polygon/models/water.js +1 -1
- package/lib/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +2 -10
- package/lib/polygon/shaders/extrude/polygon_extrude_vert.glsl +2 -8
- package/lib/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +2 -8
- package/lib/polygon/shaders/extrusion/polygon_extrusion_frag.glsl +13 -0
- package/lib/polygon/shaders/extrusion/polygon_extrusion_vert.glsl +34 -0
- package/lib/polygon/shaders/polygon_linear_vert.glsl +2 -7
- package/lib/polygon/shaders/polygon_vert.glsl +3 -6
- package/lib/polygon/shaders/water/polygon_ocean_vert.glsl +2 -7
- package/lib/polygon/shaders/water/polygon_water_vert.glsl +2 -6
- package/lib/raster/models/raster.js +1 -1
- package/lib/raster/models/rasterRgb.js +1 -1
- package/lib/raster/models/rasterTerrainRgb.js +1 -1
- package/lib/raster/shaders/raster_2d_vert.glsl +2 -6
- package/lib/raster/shaders/raster_vert.glsl +2 -12
- package/lib/raster/shaders/rater_terrain_rgb_vert.glsl +2 -7
- package/lib/wind/models/wind.js +1 -1
- package/lib/wind/shaders/wind_vert.glsl +3 -7
- package/package.json +7 -7
- package/es/Geometry/shaders/plane_vert.glsl +0 -53
- package/lib/Geometry/shaders/plane_vert.glsl +0 -53
- /package/es/{Geometry → geometry}/index.d.ts +0 -0
- /package/es/{Geometry → geometry}/index.js +0 -0
- /package/es/{Geometry → geometry}/models/billboard.d.ts +0 -0
- /package/es/{Geometry → geometry}/models/index.d.ts +0 -0
- /package/es/{Geometry → geometry}/models/index.js +0 -0
- /package/es/{Geometry → geometry}/models/plane.d.ts +0 -0
- /package/es/{Geometry → geometry}/models/sprite.d.ts +0 -0
- /package/es/{Geometry → geometry}/shaders/billboard_frag.glsl +0 -0
- /package/es/{Geometry → geometry}/shaders/plane_frag.glsl +0 -0
- /package/es/{Geometry → geometry}/shaders/sprite_frag.glsl +0 -0
- /package/lib/{Geometry → geometry}/index.js +0 -0
- /package/lib/{Geometry → geometry}/models/index.js +0 -0
- /package/lib/{Geometry → geometry}/shaders/billboard_frag.glsl +0 -0
- /package/lib/{Geometry → geometry}/shaders/plane_frag.glsl +0 -0
- /package/lib/{Geometry → geometry}/shaders/sprite_frag.glsl +0 -0
|
@@ -18,11 +18,11 @@ import { EARTH_RADIUS } from "../../earth/utils";
|
|
|
18
18
|
/* babel-plugin-inline-import '../shaders/line_arc_3d_frag.glsl' */
|
|
19
19
|
var arc3d_line_frag = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n#define LineTexture 1.0\n\nuniform float u_textureBlend;\nuniform float u_blur : 0.9;\nuniform float u_line_type: 0.0;\n// varying vec2 v_normal;\nvarying vec4 v_dash_array;\nvarying vec4 v_color;\nvarying vec4 v_line_data;\n\nuniform float u_line_texture: 0.0;\nuniform sampler2D u_texture;\nuniform vec2 u_textSize;\nvarying float v_segmentIndex;\nuniform float segmentNumber;\nuniform float u_opacity;\n\nvarying vec2 v_iconMapUV;\n\nuniform float u_time;\nuniform vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\n\n\n#pragma include \"picking\"\n\nvoid main() {\n float opacity = u_opacity;\n float animateSpeed = 0.0; // \u8FD0\u52A8\u901F\u5EA6\n float d_distance_ratio = v_line_data.g; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n gl_FragColor = v_color;\n\n gl_FragColor.a *= opacity;\n if(u_line_type == LineTypeDash) {\n float flag = 0.;\n float dashLength = mod(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 flag = 1.;\n }\n gl_FragColor.a *=flag;\n }\n\n if(u_animate.x == Animate && u_line_texture != LineTexture) {\n animateSpeed = u_time / u_animate.y;\n float alpha =1.0 - fract( mod(1.0- d_distance_ratio, u_animate.z)* (1.0/ u_animate.z) + u_time / u_animate.y);\n\n alpha = (alpha + u_animate.w -1.0) / u_animate.w;\n // alpha = smoothstep(0., 1., alpha);\n alpha = clamp(alpha, 0.0, 1.0);\n gl_FragColor.a *= alpha;\n\n // u_animate \n // x enable\n // y duration\n // z interval\n // w trailLength\n }\n\n if(u_line_texture == LineTexture && u_line_type != LineTypeDash) { // while load texture\n // float arcRadio = smoothstep( 0.0, 1.0, (v_segmentIndex / segmentNumber));\n float arcRadio = v_segmentIndex / (segmentNumber - 1.0);\n float count = v_line_data.b; // // \u8D34\u56FE\u5728\u5F27\u7EBF\u4E0A\u91CD\u590D\u7684\u6570\u91CF\n\n float time = 0.0;\n if(u_animate.x == Animate) {\n time = u_time / u_animate.y;\n }\n float redioCount = arcRadio * count;\n\n float u = fract(redioCount - time);\n\n float v = v_line_data.a; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n vec2 uv= v_iconMapUV / u_textSize + vec2(u, v) / u_textSize * 64.;\n vec4 pattern = texture2D(u_texture, uv);\n\n if(u_animate.x == Animate) {\n float currentPlane = floor(redioCount - time);\n float textureStep = floor(count * u_animate.z);\n float a = mod(currentPlane, textureStep);\n if(a < textureStep - 1.0) {\n pattern = vec4(0.0);\n }\n }\n\n if(u_textureBlend == 0.0) { // normal\n pattern.a = 0.0;\n gl_FragColor = filterColor(gl_FragColor + pattern);\n } else { // replace\n pattern.a *= opacity;\n if(gl_FragColor.a <= 0.0) {\n pattern.a = 0.0;\n discard;\n } else {\n gl_FragColor = filterColor(pattern);\n }\n }\n\n } else {\n gl_FragColor = filterColor(gl_FragColor);\n }\n}\n";
|
|
20
20
|
/* babel-plugin-inline-import '../shaders/line_arc_3d_vert.glsl' */
|
|
21
|
-
var arc3d_line_vert = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n#define LineTexture 1.0\nattribute vec3 a_Position;\nattribute vec4 a_Instance;\nattribute vec4 a_Color;\nattribute float a_Size;\n\nuniform float u_globel;\nuniform float u_globel_radius;\nuniform float u_global_height: 10;\nuniform mat4 u_ModelMatrix;\nuniform
|
|
21
|
+
var arc3d_line_vert = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n#define LineTexture 1.0\nattribute vec3 a_Position;\nattribute vec4 a_Instance;\nattribute vec4 a_Color;\nattribute float a_Size;\n\nuniform float u_globel;\nuniform float u_globel_radius;\nuniform float u_global_height: 10;\nuniform mat4 u_ModelMatrix;\n\nuniform float segmentNumber;\nuniform vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\nvarying vec4 v_color;\n\nuniform float u_line_type: 0.0;\nuniform vec4 u_dash_array: [10.0, 5., 0, 0];\nvarying vec4 v_dash_array;\n\nuniform float u_icon_step: 100;\nuniform float u_line_texture: 0.0;\nvarying float v_segmentIndex;\n\nattribute vec2 a_iconMapUV;\nvarying vec2 v_iconMapUV;\nvarying vec4 v_line_data;\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 smoothstep(0.0, 1.0, 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(\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\n vec2 offset = dir_screenspace * offset_direction * setPickingSize(a_Size) / 2.0;\n\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}\n\nfloat torad(float deg) {\n return (deg / 180.0) * acos(-1.0);\n}\n\nvec3 lglt2xyz(vec2 lnglat) {\n float pi = 3.1415926;\n // + Math.PI/2 \u662F\u4E3A\u4E86\u5BF9\u9F50\u5750\u6807\n float lng = torad(lnglat.x) + pi / 2.0;\n float lat = torad(lnglat.y);\n\n // \u624B\u52A8\u589E\u52A0\u4E00\u4E9B\u504F\u79FB\uFF0C\u51CF\u8F7B\u9762\u7684\u51B2\u7A81\n float radius = u_globel_radius;\n\n float z = radius * cos(lat) * cos(lng);\n float x = radius * cos(lat) * sin(lng);\n float y = radius * sin(lat);\n return vec3(x, y, z);\n}\n\nvoid main() {\n\n v_color = a_Color;\n vec2 source = project_position(vec4(a_Instance.rg, 0, 0)).xy;\n vec2 target = project_position(vec4(a_Instance.ba, 0, 0)).xy;\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 float d_distance_ratio;\n if(u_line_type == LineTypeDash) {\n d_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 v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / (total_Distance / segmentNumber * segmentIndex);\n }\n if(u_animate.x == Animate) {\n d_distance_ratio = segmentIndex / segmentNumber;\n }\n v_line_data.g = d_distance_ratio; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n vec3 curr = getPos(source, target, segmentRatio);\n vec3 next = getPos(source, target, nextSegmentRatio);\n vec2 offset = getExtrusionOffset((next.xy - curr.xy) * indexDir, a_Position.y);\n // v_normal = getNormal((next.xy - curr.xy) * indexDir, a_Position.y);\n\n\n v_segmentIndex = a_Position.x;\n if(LineTexture == u_line_texture && u_line_type != LineTypeDash) { // \u5F00\u542F\u8D34\u56FE\u6A21\u5F0F \n\n float arcDistrance = length(source - target);\n float pixelLen = project_pixel_texture(u_icon_step);\n v_line_data.b = floor(arcDistrance/pixelLen); // \u8D34\u56FE\u5728\u5F27\u7EBF\u4E0A\u91CD\u590D\u7684\u6570\u91CF\n\n vec2 projectOffset = project_pixel(offset);\n float lineOffsetWidth = length(projectOffset + projectOffset * 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\n gl_Position = project_common_position_to_clipspace_v2(vec4(curr.xy + project_pixel(offset), curr.z, 1.0));\n\n // \u5730\u7403\u6A21\u5F0F\n if(u_globel > 0.0) {\n vec3 startLngLat = lglt2xyz(a_Instance.rg);\n vec3 endLngLat = lglt2xyz(a_Instance.ba);\n float globalRadius = length(startLngLat);\n\n vec3 lineDir = normalize(endLngLat - startLngLat);\n vec3 midPointDir = normalize((startLngLat + endLngLat)/2.0);\n\n // \u7EBF\u7684\u504F\u79FB\n vec3 lnglatOffset = cross(lineDir, midPointDir) * a_Position.y;\n // \u8BA1\u7B97\u8D77\u59CB\u70B9\u548C\u7EC8\u6B62\u70B9\u7684\u8DDD\u79BB\n float lnglatLength = length(a_Instance.rg - a_Instance.ba)/50.0;\n // \u8BA1\u7B97\u98DE\u7EBF\u5404\u4E2A\u8282\u70B9\u76F8\u5E94\u7684\u9AD8\u5EA6\n float lineHeight = u_global_height * (-4.0*segmentRatio*segmentRatio + 4.0 * segmentRatio) * lnglatLength;\n // \u5730\u7403\u70B9\u4F4D\n vec3 globalPoint = normalize(mix(startLngLat, endLngLat, segmentRatio)) * (globalRadius + lineHeight) + lnglatOffset * a_Size;\n \n gl_Position = u_ViewProjectionMatrix * vec4(globalPoint, 1.0);\n }\n \n\n setPickingColor(a_PickingColor);\n}\n"; // arc3d linear layer
|
|
22
22
|
/* babel-plugin-inline-import '../shaders/linear/arc3d_linear_frag.glsl' */
|
|
23
23
|
var arc3d_linear_frag = "\n#define Animate 0.0\nuniform float u_time;\nuniform vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\nvarying vec4 v_Color;\n\nvarying float v_distance_ratio;\n#pragma include \"picking\"\n\nvoid main() {\n\n float animateSpeed = 0.0; // \u8FD0\u52A8\u901F\u5EA6\n gl_FragColor = v_Color;\n\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\n alpha = (alpha + u_animate.w -1.0) / u_animate.w;\n // alpha = smoothstep(0., 1., alpha);\n alpha = clamp(alpha, 0.0, 1.0);\n gl_FragColor.a *= alpha;\n\n // u_animate \n // x enable\n // y duration\n // z interval\n // w trailLength\n }\n\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
|
|
24
24
|
/* babel-plugin-inline-import '../shaders/linear/arc3d_linear_vert.glsl' */
|
|
25
|
-
var arc3d_linear_vert = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n#define LineTexture 1.0\nattribute vec3 a_Position;\nattribute vec4 a_Instance;\nattribute vec4 a_Color;\nattribute float a_Size;\nattribute vec2 a_iconMapUV;\n\nuniform float u_globel;\nuniform float u_globel_radius;\nuniform float u_global_height: 10;\nuniform mat4 u_ModelMatrix;\nuniform
|
|
25
|
+
var arc3d_linear_vert = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n#define LineTexture 1.0\nattribute vec3 a_Position;\nattribute vec4 a_Instance;\nattribute vec4 a_Color;\nattribute float a_Size;\nattribute vec2 a_iconMapUV;\n\nuniform float u_globel;\nuniform float u_globel_radius;\nuniform float u_global_height: 10;\nuniform mat4 u_ModelMatrix;\n\nuniform float segmentNumber;\nuniform vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\n\nuniform float u_line_type: 0.0;\nuniform vec4 u_dash_array: [10.0, 5., 0, 0];\nuniform float u_icon_step: 100;\nuniform float u_line_texture: 0.0;\nvarying float v_distance_ratio;\n\nvarying vec4 v_dash_array;\nvarying vec4 v_color;\nvarying vec2 v_iconMapUV;\nvarying vec4 v_Color;\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 smoothstep(0.0, 1.0, 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(\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\n vec2 offset = dir_screenspace * offset_direction * setPickingSize(a_Size) / 2.0;\n\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}\n\nfloat torad(float deg) {\n return (deg / 180.0) * acos(-1.0);\n}\n\nvec3 lglt2xyz(vec2 lnglat) {\n float pi = 3.1415926;\n // + Math.PI/2 \u662F\u4E3A\u4E86\u5BF9\u9F50\u5750\u6807\n float lng = torad(lnglat.x) + pi / 2.0;\n float lat = torad(lnglat.y);\n\n // \u624B\u52A8\u589E\u52A0\u4E00\u4E9B\u504F\u79FB\uFF0C\u51CF\u8F7B\u9762\u7684\u51B2\u7A81\n float radius = u_globel_radius;\n\n float z = radius * cos(lat) * cos(lng);\n float x = radius * cos(lat) * sin(lng);\n float y = radius * sin(lat);\n return vec3(x, y, z);\n}\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n v_color = a_Color;\n vec2 source = project_position(vec4(a_Instance.rg, 0, 0)).xy;\n vec2 target = project_position(vec4(a_Instance.ba, 0, 0)).xy;\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 float d_distance_ratio;\n if(u_line_type == LineTypeDash) {\n d_distance_ratio = segmentIndex / segmentNumber;\n // float total_Distance = pixelDistance(a_Instance.rg, a_Instance.ba) / 2.0 * PI;\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 v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / (total_Distance / segmentNumber * segmentIndex);\n }\n if(u_animate.x == Animate) {\n v_distance_ratio = segmentIndex / segmentNumber;\n }\n\n\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n vec3 curr = getPos(source, target, segmentRatio);\n vec3 next = getPos(source, target, nextSegmentRatio);\n vec2 offset = getExtrusionOffset((next.xy - curr.xy) * indexDir, a_Position.y);\n\n float animateSpeed = 0.0; // \u8FD0\u52A8\u901F\u5EA6\n v_Color = mix(u_sourceColor, u_targetColor, a_Position.x/segmentNumber);\n\n v_Color.a *= opacity;\n\n gl_Position = project_common_position_to_clipspace_v2(vec4(curr.xy + project_pixel(offset), curr.z, 1.0));\n\n // \u5730\u7403\u6A21\u5F0F\n if(u_globel > 0.0) {\n vec3 startLngLat = lglt2xyz(a_Instance.rg);\n vec3 endLngLat = lglt2xyz(a_Instance.ba);\n float globalRadius = length(startLngLat);\n\n vec3 lineDir = normalize(endLngLat - startLngLat);\n vec3 midPointDir = normalize((startLngLat + endLngLat)/2.0);\n\n // \u7EBF\u7684\u504F\u79FB\n vec3 lnglatOffset = cross(lineDir, midPointDir) * a_Position.y;\n // \u8BA1\u7B97\u8D77\u59CB\u70B9\u548C\u7EC8\u6B62\u70B9\u7684\u8DDD\u79BB\n float lnglatLength = length(a_Instance.rg - a_Instance.ba)/50.0;\n // \u8BA1\u7B97\u98DE\u7EBF\u5404\u4E2A\u8282\u70B9\u76F8\u5E94\u7684\u9AD8\u5EA6\n float lineHeight = u_global_height * (-4.0*segmentRatio*segmentRatio + 4.0 * segmentRatio) * lnglatLength;\n // \u5730\u7403\u70B9\u4F4D\n vec3 globalPoint = normalize(mix(startLngLat, endLngLat, segmentRatio)) * (globalRadius + lineHeight) + lnglatOffset * a_Size;\n \n gl_Position = u_ViewProjectionMatrix * vec4(globalPoint, 1.0);\n }\n \n\n setPickingColor(a_PickingColor);\n}\n";
|
|
26
26
|
var lineStyleObj = {
|
|
27
27
|
solid: 0.0,
|
|
28
28
|
dash: 1.0
|
package/es/line/models/flow.js
CHANGED
|
@@ -15,7 +15,7 @@ import { FlowLineFillTriangulation } from "../../core/triangulation";
|
|
|
15
15
|
/* babel-plugin-inline-import '../shaders/flow/flow_line_frag.glsl' */
|
|
16
16
|
var flow_line_frag = "#extension GL_OES_standard_derivatives : enable\n\nvarying vec4 v_color;\n\n\n// line texture\n\n#pragma include \"picking\"\n\nvoid main() {\ngl_FragColor = v_color;\ngl_FragColor = filterColor(gl_FragColor);\n}\n"; // linear simple line shader
|
|
17
17
|
/* babel-plugin-inline-import '../shaders/flow/flow_line_vert.glsl' */
|
|
18
|
-
var flow_line_vert = "attribute vec4 a_Color;\nattribute vec2 a_Size;\nattribute vec4 a_Instance;\nattribute vec3 a_Normal;\nattribute vec3 a_Position;\n\nuniform mat4 u_ModelMatrix;\
|
|
18
|
+
var flow_line_vert = "attribute vec4 a_Color;\nattribute vec2 a_Size;\nattribute vec4 a_Instance;\nattribute vec3 a_Normal;\nattribute vec3 a_Position;\n\nuniform mat4 u_ModelMatrix;\n\n\n#pragma include \"projection\"\n#pragma include \"picking\"\nvarying vec4 v_color;\nuniform float u_gap_width: 1.0;\nuniform float u_stroke_width: 1.0;\nuniform float u_stroke_opacity: 1.0;\n\n\nvoid main() {\n\n// \u900F\u660E\u5EA6\u8BA1\u7B97\n vec2 source = a_Instance.rg; // \u8D77\u59CB\u70B9\n vec2 target = a_Instance.ba; // \u7EC8\u70B9\n vec2 flowlineDir = normalize(target - source);\n vec2 perpendicularDir = vec2(-flowlineDir.y, flowlineDir.x);\n\n\n vec2 position = mix(source, target, a_Position.x);\n \n float lengthCommon = length(project_position(vec4(target,0,1)) - project_position(vec4(source,0,1))); // \n vec2 offsetDistances = a_Size.x * project_pixel(a_Position.yz);\n vec2 limitedOffsetDistances = clamp( \n offsetDistances,\n project_pixel(-lengthCommon*.8), project_pixel(lengthCommon*.8)\n );\n\n\n float startOffsetCommon = project_pixel(offsets[0]);\n float endOffsetCommon = project_pixel(offsets[1]);\n float endpointOffset = mix(\n clamp(startOffsetCommon, 0.0, lengthCommon*.2),\n -clamp(endOffsetCommon, 0.0, lengthCommon*.2),\n a_Position.x\n );\n\n vec2 normalsCommon = u_stroke_width * project_pixel(a_Normal.xy);\n\n float gapCommon = project_pixel(u_gap_width);\n vec3 offsetCommon = vec3(\n flowlineDir * (limitedOffsetDistances[1] + normalsCommon.y + endpointOffset * 1.05) -\n perpendicularDir * (limitedOffsetDistances[0] + gapCommon + normalsCommon.x),\n 0.0\n );\n\n\n vec4 project_pos = project_position(vec4(position.xy, 0, 1.0));\n\n vec4 fillColor = vec4(a_Color.rgb, a_Color.a * opacity);\n v_color = mix(fillColor, vec4(u_stroke.xyz, u_stroke.w * fillColor.w * u_stroke_opacity), a_Normal.z);\n\n gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xy + offsetCommon.xy, 0., 1.0));\n\n\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
19
19
|
var FlowLineModel = /*#__PURE__*/function (_BaseModel) {
|
|
20
20
|
_inherits(FlowLineModel, _BaseModel);
|
|
21
21
|
var _super = _createSuper(FlowLineModel);
|
|
@@ -16,7 +16,7 @@ import { LineArcTriangulation } from "../../core/triangulation";
|
|
|
16
16
|
/* babel-plugin-inline-import '../shaders/line_arc_great_circle_frag.glsl' */
|
|
17
17
|
var line_arc_frag = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n#define LineTexture 1.0\n\nuniform float u_opacity;\nuniform float u_textureBlend;\nuniform float u_blur : 0.9;\nuniform float u_line_type: 0.0;\n// varying vec2 v_normal;\nvarying vec4 v_dash_array;\nvarying float v_distance_ratio;\nvarying vec4 v_color;\n\nuniform float u_time;\nuniform vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\n\nuniform float u_line_texture: 0.0;\nuniform sampler2D u_texture;\nuniform vec2 u_textSize;\nuniform float segmentNumber;\n\nvarying vec2 v_iconMapUV;\n\nuniform float u_linearColor: 0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\nvarying vec4 v_line_data;\n\n#pragma include \"picking\"\n#pragma include \"project\"\n#pragma include \"projection\"\n\nvoid main() {\n float opacity = u_opacity;\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 gl_FragColor = mix(u_sourceColor, u_targetColor, d_segmentIndex/segmentNumber);\n } else { // \u4F7F\u7528 color \u65B9\u6CD5\u4F20\u5165\u7684\u989C\u8272\n gl_FragColor = 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 gl_FragColor.a *= opacity;\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 gl_FragColor.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 = gl_FragColor.a/opacity;\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 = texture2D(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 gl_FragColor = filterColor(gl_FragColor + pattern);\n } else { // replace\n pattern.a *= opacity;\n if(gl_FragColor.a <= 0.0) {\n pattern.a = 0.0;\n }\n gl_FragColor = filterColor(pattern);\n }\n } else {\n gl_FragColor = filterColor(gl_FragColor);\n }\n\n // gl_FragColor = filterColor(gl_FragColor);\n}";
|
|
18
18
|
/* babel-plugin-inline-import '../shaders/line_arc_great_circle_vert.glsl' */
|
|
19
|
-
var line_arc2d_vert = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n#define LineTexture 1.0\n\nattribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec4 a_Instance;\nattribute float a_Size;\nuniform mat4 u_ModelMatrix;\nuniform
|
|
19
|
+
var line_arc2d_vert = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n#define LineTexture 1.0\n\nattribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec4 a_Instance;\nattribute float a_Size;\nuniform mat4 u_ModelMatrix;\n\nuniform float segmentNumber;\nuniform vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\nvarying vec4 v_color;\n\nvarying float v_distance_ratio;\nuniform float u_line_type: 0.0;\nuniform vec4 u_dash_array: [10.0, 5., 0, 0];\nvarying vec4 v_dash_array;\n\nuniform float u_icon_step: 100;\nuniform float u_line_texture: 0.0;\n\nattribute vec2 a_iconMapUV;\nvarying vec2 v_iconMapUV;\nvarying vec4 v_line_data;\n\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 }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 \n\n v_color = a_Color;\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\nv_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;\nv_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\nv_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\n\n gl_Position = project_common_position_to_clipspace_v2(vec4(curr.xy + offset, 0, 1.0));\n setPickingColor(a_PickingColor);\n}\n\n";
|
|
20
20
|
var lineStyleObj = {
|
|
21
21
|
solid: 0.0,
|
|
22
22
|
dash: 1.0
|
package/es/line/models/line.js
CHANGED
|
@@ -19,11 +19,11 @@ import { LinearDir, TextureBlend } from "../../core/interface";
|
|
|
19
19
|
/* babel-plugin-inline-import '../shaders/dash/line_dash_frag.glsl' */
|
|
20
20
|
var line_dash_frag = "#define LineTypeSolid 0.0\nvarying vec4 v_color;\n\n// dash\nvarying vec4 v_dash_array;\nvarying float v_d_distance_ratio;\n\n#pragma include \"picking\"\n\nuniform float u_time;\nuniform vec4 u_animate: [ 1., 2., 1.0, 0.2 ]; // \u63A7\u5236\u8FD0\u52A8\n\n// [animate, duration, interval, trailLength],\nvoid main() {\n\n gl_FragColor = v_color;\n\n \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 // \u5B9E\u7EBF\u90E8\u5206\n } else {\n // \u865A\u7EBF\u90E8\u5206\n discard;\n };\n\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
|
|
21
21
|
/* babel-plugin-inline-import '../shaders/dash/line_dash_vert.glsl' */
|
|
22
|
-
var line_dash_vert = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n\nattribute float a_Miter;\nattribute vec4 a_Color;\nattribute vec2 a_Size;\nattribute vec3 a_Normal;\nattribute vec3 a_Position;\n\nattribute vec2 a_iconMapUV;\n\n// dash line\nattribute float a_Total_Distance;\nattribute vec2 a_DistanceAndIndex;\
|
|
22
|
+
var line_dash_vert = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n\nattribute float a_Miter;\nattribute vec4 a_Color;\nattribute vec2 a_Size;\nattribute vec3 a_Normal;\nattribute vec3 a_Position;\n\nattribute vec2 a_iconMapUV;\n\n// dash line\nattribute float a_Total_Distance;\nattribute vec2 a_DistanceAndIndex;\nuniform float u_raisingHeight: 0.0;\n\nuniform mat4 u_ModelMatrix;\n\nuniform vec4 u_dash_array: [10.0, 5., 0, 0];\n\nuniform float u_vertexScale: 1.0;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvarying vec4 v_color;\nvarying vec4 v_dash_array;\nvarying float v_d_distance_ratio;\n\n\nvoid main() {\n\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / a_Total_Distance;\n v_color = vec4(a_Color.xyz, a_Color.w * opacity);\n\n vec3 size = a_Miter * setPickingSize(a_Size.x) * reverse_offset_normal(a_Normal);\n vec2 offset = project_pixel(size.xy);\n v_d_distance_ratio = a_DistanceAndIndex.x / a_Total_Distance;\n\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 if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xy + offset, project_pixel(a_Size.y), 1.0));\n } else {\n float lineHeight = a_Size.y;\n \n // #define COORDINATE_SYSTEM_P20 5.0\n // #define COORDINATE_SYSTEM_P20_OFFSET 6.0\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 + offset, lineHeight, 1.0));\n }\n\n setPickingColor(a_PickingColor);\n}\n"; // basic line shader
|
|
23
23
|
/* babel-plugin-inline-import '../shaders/line_frag.glsl' */
|
|
24
24
|
var line_frag = "#extension GL_OES_standard_derivatives : enable\n#define Animate 0.0\n#define LineTexture 1.0\nuniform float u_textureBlend;\n\nuniform float u_borderWidth: 0.0;\n\nuniform vec3 u_blur;\nuniform vec4 u_borderColor;\nvarying vec4 v_color;\n\n// line texture\nuniform float u_line_texture;\nuniform sampler2D u_texture;\nuniform vec2 u_textSize;\nvarying vec2 v_iconMapUV;\nvarying vec4 v_texture_data;\n\n\n#pragma include \"picking\"\n\nuniform float u_time;\nuniform vec4 u_animate: [ 1, 2., 1.0, 0.2 ]; // \u63A7\u5236\u8FD0\u52A8\n// [animate, duration, interval, trailLength],\nvoid main() {\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 gl_FragColor = v_color;\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 gl_FragColor.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 = texture2D(u_texture, uv);\n\n if(u_textureBlend == 0.0) { // normal\n pattern.a = 0.0;\n gl_FragColor += pattern;\n } else { // replace\n pattern.a *= v_color.a;\n if(gl_FragColor.a <= 0.0) {\n pattern.a = 0.0;\n }\n gl_FragColor = pattern;\n }\n } \n\n float v = v_texture_data.a;\n float borderWidth = min(0.5, u_borderWidth);\n // \u7ED8\u5236 border\n if(borderWidth > 0.01) {\n float borderOuterWidth = borderWidth / 2.0;\n\n\n if(v >= 1.0 - borderWidth || v <= borderWidth) {\n if(v > borderWidth) { // \u5916\u4FA7\n float linear = smoothstep(0.0, 1.0, (v - (1.0 - borderWidth))/borderWidth);\n // float linear = step(0.0, (v - (1.0 - borderWidth))/borderWidth);\n gl_FragColor.rgb = mix(gl_FragColor.rgb, u_borderColor.rgb, linear);\n } else if(v <= borderWidth) {\n float linear = smoothstep(0.0, 1.0, v/borderWidth);\n gl_FragColor.rgb = mix(u_borderColor.rgb, gl_FragColor.rgb, linear);\n }\n }\n\n if(v < borderOuterWidth) {\n gl_FragColor.a = mix(0.0, gl_FragColor.a, v/borderOuterWidth);\n } else if(v > 1.0 - borderOuterWidth) {\n gl_FragColor.a = mix(gl_FragColor.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 gl_FragColor.a *= mix(u_blur.r, u_blur.g, blurV/0.5);\n } else {\n gl_FragColor.a *= mix(u_blur.g, u_blur.b, (blurV - 0.5)/0.5);\n }\n \n gl_FragColor = filterColor(gl_FragColor);\n}\n";
|
|
25
25
|
/* babel-plugin-inline-import '../shaders/line_vert.glsl' */
|
|
26
|
-
var line_vert = "\n#define Animate 0.0\n\nattribute float a_Miter;\nattribute vec4 a_Color;\nattribute vec2 a_Size;\nattribute vec3 a_Normal;\nattribute vec3 a_Position;\n\nattribute vec2 a_iconMapUV;\n\n// dash line\nattribute float a_Total_Distance;\nattribute vec2 a_DistanceAndIndex;\n\nuniform mat4 u_ModelMatrix;\nuniform
|
|
26
|
+
var line_vert = "\n#define Animate 0.0\n\nattribute float a_Miter;\nattribute vec4 a_Color;\nattribute vec2 a_Size;\nattribute vec3 a_Normal;\nattribute vec3 a_Position;\n\nattribute vec2 a_iconMapUV;\n\n// dash line\nattribute float a_Total_Distance;\nattribute vec2 a_DistanceAndIndex;\n\nuniform mat4 u_ModelMatrix;\n\nuniform vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\nuniform float u_icon_step: 100;\n\nuniform float u_heightfixed: 0.0;\nuniform float u_vertexScale: 1.0;\nuniform float u_raisingHeight: 0.0;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvarying vec4 v_color;\n\n// texV \u7EBF\u56FE\u5C42 - \u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\uFF08\u7EBF\u7684\u5BBD\u5EA6\u65B9\u5411\uFF09\nvarying vec2 v_iconMapUV;\n\n\nuniform float u_linearColor: 0;\nuniform float u_arrow: 0.0;\nuniform float u_arrowHeight: 3.0;\nuniform float u_arrowWidth: 2.0;\nuniform float u_tailWidth: 1.0;\n\nvarying vec4 v_texture_data;\n\nvec2 calculateArrow(vec2 offset) {\n /*\n * \u5728\u652F\u6301\u7BAD\u5934\u7684\u65F6\u5019\uFF0C\u7B2C\u4E8C\u3001\u7B2C\u4E09\u7EC4\u9876\u70B9\u662F\u989D\u5916\u63D2\u5165\u7528\u4E8E\u6784\u5EFA\u9876\u70B9\u7684\n */\n float arrowFlag = -1.0;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n // \u9AD8\u5FB7 2.0 \u7684\u65CB\u8F6C\u89D2\u5EA6\u4E0D\u540C\n arrowFlag = 1.0;\n }\n float pi = arrowFlag * 3.1415926/2.;\n if(a_Miter < 0.) {\n // \u6839\u636E\u7EBF\u7684\u4E24\u4FA7\u504F\u79FB\u4E0D\u540C\u3001\u65CB\u8F6C\u7684\u65B9\u5411\u76F8\u53CD\n pi = -pi;\n }\n highp float angle_sin = sin(pi);\n highp float angle_cos = cos(pi);\n // \u8BA1\u7B97\u5782\u76F4\u4E0E\u7EBF\u65B9\u5411\u7684\u65CB\u8F6C\u77E9\u9635\n mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);\n float arrowWidth = u_arrowWidth;\n float arrowHeight = u_arrowHeight;\n\n vec2 arrowOffset = vec2(0.0);\n /*\n * a_DistanceAndIndex.y \u7528\u4E8E\u6807\u8BB0\u5F53\u524D\u9876\u70B9\u5C5E\u4E8E\u54EA\u4E00\u7EC4\uFF08\u4E24\u4E2A\u9876\u70B9\u4E00\u7EC4\uFF0C\u6784\u6210\u7EBF\u7684\u5176\u5B9E\u662F\u77E9\u5F62\uFF0C\u6700\u7B80\u9700\u8981\u56DB\u4E2A\u9876\u70B9\u3001\u4E24\u7EC4\u9876\u70B9\u6784\u6210\uFF09\n */\n if(a_DistanceAndIndex.y == 0.0) {\n // \u7BAD\u5934\u5C16\u90E8\n offset = vec2(0.0);\n } else if(a_DistanceAndIndex.y == 1.0) {\n // \u7BAD\u5934\u4E24\u4FA7\n arrowOffset = rotation_matrix*(offset * arrowHeight);\n offset += arrowOffset; // \u6CBF\u7EBF\u504F\u79FB\n offset = offset * arrowWidth; // \u5782\u76F4\u7EBF\u5411\u5916\u504F\u79FB\uFF08\u662F\u6784\u5EFA\u7BAD\u5934\u4E24\u4FA7\u7684\u9876\u70B9\uFF09\n } else if(a_DistanceAndIndex.y == 2.0 || a_DistanceAndIndex.y == 3.0 || a_DistanceAndIndex.y == 4.0) {\n // \u504F\u79FB\u5176\u4F59\u7684\u70B9\u4F4D\uFF08\u5C06\u957F\u5EA6\u8BA9\u4F4D\u7ED9\u7BAD\u5934\uFF09\n arrowOffset = rotation_matrix*(offset * arrowHeight) * arrowWidth;\n offset += arrowOffset;// \u6CBF\u7EBF\u504F\u79FB\n }\n\n return offset;\n}\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n \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 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\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 if(u_arrow > 0.0) {\n // \u8BA1\u7B97\u7BAD\u5934\n offset = calculateArrow(offset);\n\n if(a_DistanceAndIndex.y > 4.0) {\n offset *= mix(1.0, u_tailWidth, currentLinePointRatio);\n }\n }\n\n float lineOffsetWidth = length(offset + offset * sign(a_Miter)); // \u7EBF\u6A2A\u5411\u504F\u79FB\u7684\u8DDD\u79BB\uFF08\u5411\u4E24\u4FA7\u504F\u79FB\u7684\u548C\uFF09\n float linePixelSize = project_pixel(a_Size.x) * 2.0; // \u5B9A\u70B9\u4F4D\u7F6E\u504F\u79FB\uFF0C\u6309\u5730\u56FE\u7B49\u7EA7\u7F29\u653E\u540E\u7684\u8DDD\u79BB \u5355\u4FA7 * 2\n float texV = lineOffsetWidth/linePixelSize; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n \n v_texture_data = vec4(currentLinePointRatio, lineDistance, d_texPixelLen, texV);\n // \u8BBE\u7F6E\u6570\u636E\u96C6\u7684\u53C2\u6570\n\n vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));\n\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, a_Size.y, 1.0));\n\n float h = float(a_Position.z) * u_vertexScale; // \u7EBF\u9876\u70B9\u7684\u9AD8\u5EA6 - \u517C\u5BB9\u4E0D\u5B58\u5728\u7B2C\u4E09\u4E2A\u6570\u503C\u7684\u60C5\u51B5 vertex height\n float lineHeight = a_Size.y; // size \u7B2C\u4E8C\u4E2A\u53C2\u6570\u4EE3\u8868\u7684\u9AD8\u5EA6 [linewidth, lineheight]\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n lineHeight *= 0.2; // \u4FDD\u6301\u548C amap/mapbox \u4E00\u81F4\u7684\u6548\u679C\n h *= 0.2;\n if(u_heightfixed < 1.0) {\n lineHeight = project_pixel(a_Size.y);\n }\n gl_Position = u_Mvp * (vec4(project_pos.xy + offset, lineHeight + h + u_raisingHeight, 1.0));\n } else {\n // mapbox - amap\n \n // \u517C\u5BB9 mapbox \u5728\u7EBF\u9AD8\u5EA6\u4E0A\u7684\u6548\u679C\u8868\u73B0\u57FA\u672C\u4E00\u81F4\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // mapbox\n // \u4FDD\u6301\u9AD8\u5EA6\u76F8\u5BF9\u4E0D\u53D8\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n h *= mapboxZoomScale;\n h += u_raisingHeight * mapboxZoomScale;\n if(u_heightfixed > 0.0) {\n lineHeight *= mapboxZoomScale;\n }\n \n } else {\n // amap\n h += u_raisingHeight;\n // lineHeight \u9876\u70B9\u504F\u79FB\u9AD8\u5EA6\n if(u_heightfixed < 1.0) {\n lineHeight *= pow(2.0, 20.0 - u_Zoom);\n }\n }\n\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, lineHeight + h, 1.0));\n }\n\n setPickingColor(a_PickingColor);\n}\n"; // other function shaders
|
|
27
27
|
/* babel-plugin-inline-import '../shaders/linear/line_linear_frag.glsl' */
|
|
28
28
|
var linear_line_frag = "varying vec4 v_color;\nvarying vec4 v_texture_data;\nuniform float u_linearDir: 1.0;\nuniform float u_linearColor: 0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\nuniform float u_opacity: 1.0;\n\n#pragma include \"picking\"\n\n\nvoid main() {\n float linearRadio = v_texture_data.r; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n if(u_linearDir < 1.0) {\n linearRadio = v_texture_data.a;\n }\n\n if(u_linearColor == 1.0) { // \u4F7F\u7528\u6E10\u53D8\u989C\u8272\n gl_FragColor = mix(u_sourceColor, u_targetColor, linearRadio);\n gl_FragColor.a *= v_color.a;\n } else { // \u4F7F\u7528 color \u65B9\u6CD5\u4F20\u5165\u7684\u989C\u8272\n gl_FragColor = v_color;\n }\n\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
|
|
29
29
|
var lineStyleObj = {
|
|
@@ -17,7 +17,7 @@ import { LineTriangulation } from "../../core/triangulation";
|
|
|
17
17
|
/* babel-plugin-inline-import '../shaders/linearLine/line_linear_frag.glsl' */
|
|
18
18
|
var linear_line_frag = "\nvarying vec4 v_Color;\n#pragma include \"picking\"\nvoid main() {\n\n gl_FragColor = v_Color; // \u5168\u5C40\u900F\u660E\u5EA6\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
|
|
19
19
|
/* babel-plugin-inline-import '../shaders/linearLine/line_linear_vert.glsl' */
|
|
20
|
-
var linear_line_vert = "\nattribute float a_Miter;\nattribute vec2 a_Size;\nattribute vec3 a_Normal;\nattribute vec3 a_Position;\n\n// dash line\nattribute float a_Total_Distance;\nattribute vec2 a_DistanceAndIndex;\n\nuniform mat4 u_ModelMatrix;\
|
|
20
|
+
var linear_line_vert = "\nattribute float a_Miter;\nattribute vec2 a_Size;\nattribute vec3 a_Normal;\nattribute vec3 a_Position;\n\n// dash line\nattribute float a_Total_Distance;\nattribute vec2 a_DistanceAndIndex;\n\nuniform mat4 u_ModelMatrix;\n\n\nuniform float u_heightfixed: 0.0;\nuniform float u_vertexScale: 1.0;\nuniform float u_raisingHeight: 0.0;\nuniform float u_opacity : 1.0;\nuniform sampler2D u_texture;\nuniform float u_linearDir: 1.0;\nvarying vec4 v_Color;\n\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\n\nvoid main() {\n\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 float linearRadio =currentLinePointRatio; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n if(u_linearDir < 1.0) {\n linearRadio = texV;\n }\n\n v_Color = texture2D(u_texture, vec2(linearRadio, 0.5));\n\n v_Color.a *= u_opacity; // \u5168\u5C40\u900F\u660E\u5EA6\n\n\n\n vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));\n\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, a_Size.y, 1.0));\n\n float h = float(a_Position.z) * u_vertexScale; // \u7EBF\u9876\u70B9\u7684\u9AD8\u5EA6 - \u517C\u5BB9\u4E0D\u5B58\u5728\u7B2C\u4E09\u4E2A\u6570\u503C\u7684\u60C5\u51B5 vertex height\n float lineHeight = a_Size.y; // size \u7B2C\u4E8C\u4E2A\u53C2\u6570\u4EE3\u8868\u7684\u9AD8\u5EA6 [linewidth, lineheight]\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n lineHeight *= 0.2; // \u4FDD\u6301\u548C amap/mapbox \u4E00\u81F4\u7684\u6548\u679C\n h *= 0.2;\n if(u_heightfixed < 1.0) {\n lineHeight = project_pixel(a_Size.y);\n }\n gl_Position = u_Mvp * (vec4(project_pos.xy + offset, lineHeight + h + u_raisingHeight, 1.0));\n } else {\n // mapbox - amap\n \n // \u517C\u5BB9 mapbox \u5728\u7EBF\u9AD8\u5EA6\u4E0A\u7684\u6548\u679C\u8868\u73B0\u57FA\u672C\u4E00\u81F4\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // mapbox\n // \u4FDD\u6301\u9AD8\u5EA6\u76F8\u5BF9\u4E0D\u53D8\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n h *= mapboxZoomScale;\n h += u_raisingHeight * mapboxZoomScale;\n if(u_heightfixed > 0.0) {\n lineHeight *= mapboxZoomScale;\n }\n \n } else {\n // amap\n h += u_raisingHeight;\n // lineHeight \u9876\u70B9\u504F\u79FB\u9AD8\u5EA6\n if(u_heightfixed < 1.0) {\n lineHeight *= pow(2.0, 20.0 - u_Zoom);\n }\n }\n\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, lineHeight + h, 1.0));\n }\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
21
21
|
var isNumber = lodashUtil.isNumber;
|
|
22
22
|
var LinearLineModel = /*#__PURE__*/function (_BaseModel) {
|
|
23
23
|
_inherits(LinearLineModel, _BaseModel);
|
|
@@ -16,7 +16,7 @@ var simple_line_frag = "\nvarying vec4 v_color;\nvoid main() {\n gl_FragColor =
|
|
|
16
16
|
/* babel-plugin-inline-import '../shaders/simple/simpleline_linear_frag.glsl' */
|
|
17
17
|
var simle_linear_frag = "uniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\nuniform float opacity;\nvoid main() {\n gl_FragColor = mix(u_sourceColor, u_targetColor, v_distanceScale);\n gl_FragColor.a *= opacity; // \u5168\u5C40\u900F\u660E\u5EA6\n}\n";
|
|
18
18
|
/* babel-plugin-inline-import '../shaders/simple/simpleline_vert.glsl' */
|
|
19
|
-
var simple_line_vert = "attribute vec4 a_Color;\nattribute vec2 a_Size;\nattribute vec3 a_Position;\n\nattribute float a_Total_Distance;\nattribute float a_Distance;\n\nuniform mat4 u_ModelMatrix;\
|
|
19
|
+
var simple_line_vert = "attribute vec4 a_Color;\nattribute vec2 a_Size;\nattribute vec3 a_Position;\n\nattribute float a_Total_Distance;\nattribute float a_Distance;\n\nuniform mat4 u_ModelMatrix;\n\n\nuniform float u_opacity: 1.0;\nuniform float u_vertexScale: 1.0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\n\n\n\n#pragma include \"projection\"\n\nvarying vec4 v_color;\nvarying float v_distanceScale;\n\nvoid main() {\n\n v_color = a_Color; \n v_distanceScale = a_Distance / a_Total_Distance;\n v_color = vec4(a_Color.xyz, a_Color.w * u_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_Size.y) + h * 0.2, 1.0));\n } else {\n float lineHeight = a_Size.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 // #define COORDINATE_SYSTEM_P20 5.0\n // #define COORDINATE_SYSTEM_P20_OFFSET 6.0\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";
|
|
20
20
|
var isNumber = lodashUtil.isNumber;
|
|
21
21
|
var SimpleLineModel = /*#__PURE__*/function (_BaseModel) {
|
|
22
22
|
_inherits(SimpleLineModel, _BaseModel);
|
package/es/line/models/wall.js
CHANGED
|
@@ -16,7 +16,7 @@ import { LineTriangulation } from "../../core/triangulation";
|
|
|
16
16
|
/* babel-plugin-inline-import '../shaders/wall/wall_frag.glsl' */
|
|
17
17
|
var line_frag = "#define Animate 0.0\n#define LineTexture 1.0\n\n// line texture\nuniform float u_line_texture;\nuniform sampler2D u_texture;\nuniform vec2 u_textSize;\nuniform float u_linearColor: 0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\nuniform float u_opacity : 1.0;\nuniform float u_textureBlend;\nuniform float u_iconStepCount;\nuniform float u_time;\nuniform vec4 u_animate: [ 1., 2., 1.0, 0.2 ]; // \u63A7\u5236\u8FD0\u52A8\n\nvarying vec2 v_iconMapUV;\nvarying float v_blur;\nvarying float v_radio;\nvarying vec4 v_color;\nvarying vec4 v_dataset;\n\n#pragma include \"picking\"\n\nvoid main() {\n float opacity = u_opacity;\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 gl_FragColor = mix(u_sourceColor, u_targetColor, v);\n } else { // \u4F7F\u7528 color \u65B9\u6CD5\u4F20\u5165\u7684\u989C\u8272\n gl_FragColor = v_color;\n }\n\n gl_FragColor.a *= opacity; // \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 gl_FragColor.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 = texture2D(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 gl_FragColor = filterColor(gl_FragColor + pattern);\n } else { // replace\n pattern.a *= opacity;\n if(gl_FragColor.a <= 0.0) {\n pattern.a = 0.0;\n }\n gl_FragColor = filterColor(pattern);\n }\n }\n \n\n // blur - AA\n if(v < v_blur) {\n gl_FragColor.a = mix(0.0, gl_FragColor.a, v/v_blur);\n } else if(v > 1.0 - v_blur) {\n gl_FragColor.a = mix(gl_FragColor.a, 0.0, (v - (1.0 - v_blur))/v_blur);\n }\n\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
|
|
18
18
|
/* babel-plugin-inline-import '../shaders/wall/wall_vert.glsl' */
|
|
19
|
-
var line_vert = "#define Animate 0.0\n\nattribute float a_Miter;\nattribute vec4 a_Color;\nattribute vec2 a_Size;\nattribute vec3 a_Normal;\nattribute vec3 a_Position;\nattribute vec2 a_iconMapUV;\nattribute float a_Total_Distance;\nattribute float a_Distance;\n\nuniform mat4 u_ModelMatrix;\nuniform
|
|
19
|
+
var line_vert = "#define Animate 0.0\n\nattribute float a_Miter;\nattribute vec4 a_Color;\nattribute vec2 a_Size;\nattribute vec3 a_Normal;\nattribute vec3 a_Position;\nattribute vec2 a_iconMapUV;\nattribute float a_Total_Distance;\nattribute float a_Distance;\n\nuniform mat4 u_ModelMatrix;\n\nuniform vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\nuniform float u_icon_step: 100;\nuniform float u_heightfixed;\nuniform float u_linearColor: 0;\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\nvarying vec2 v_iconMapUV;\nvarying vec4 v_color;\nvarying float v_blur;\nvarying float v_radio;\nvarying 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) { // \u9AD8\u5EA6\u968F zoom \u8C03\u6574\n originSize = project_float_pixel(a_Size.x);\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);\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 gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy, wallHeight, 1.0));\n }\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
20
20
|
var isNumber = lodashUtil.isNumber;
|
|
21
21
|
var LineWallModel = /*#__PURE__*/function (_BaseModel) {
|
|
22
22
|
_inherits(LineWallModel, _BaseModel);
|
|
@@ -4,7 +4,7 @@ attribute vec3 a_Position;
|
|
|
4
4
|
attribute vec4 a_Instance;
|
|
5
5
|
attribute float a_Size;
|
|
6
6
|
uniform mat4 u_ModelMatrix;
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
uniform float segmentNumber;
|
|
9
9
|
varying vec4 v_color;
|
|
10
10
|
|
|
@@ -100,11 +100,8 @@ void main() {
|
|
|
100
100
|
|
|
101
101
|
vec2 offset = project_pixel(getExtrusionOffset((next.xy - curr.xy) * indexDir, a_Position.y));
|
|
102
102
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
} else {
|
|
106
|
-
gl_Position = project_common_position_to_clipspace(vec4(curr.xy + offset, 0, 1.0));
|
|
107
|
-
}
|
|
103
|
+
gl_Position = project_common_position_to_clipspace_v2(vec4(curr.xy + offset, 0, 1.0));
|
|
104
|
+
|
|
108
105
|
gl_PointSize = 5.0;
|
|
109
106
|
setPickingColor(a_PickingColor);
|
|
110
107
|
}
|
|
@@ -13,9 +13,10 @@ attribute vec2 a_iconMapUV;
|
|
|
13
13
|
// dash line
|
|
14
14
|
attribute float a_Total_Distance;
|
|
15
15
|
attribute vec2 a_DistanceAndIndex;
|
|
16
|
+
uniform float u_raisingHeight: 0.0;
|
|
16
17
|
|
|
17
18
|
uniform mat4 u_ModelMatrix;
|
|
18
|
-
|
|
19
|
+
|
|
19
20
|
uniform vec4 u_dash_array: [10.0, 5., 0, 0];
|
|
20
21
|
|
|
21
22
|
uniform float u_vertexScale: 1.0;
|
|
@@ -5,7 +5,7 @@ attribute vec3 a_Normal;
|
|
|
5
5
|
attribute vec3 a_Position;
|
|
6
6
|
|
|
7
7
|
uniform mat4 u_ModelMatrix;
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
|
|
10
10
|
#pragma include "projection"
|
|
11
11
|
#pragma include "picking"
|
|
@@ -57,12 +57,7 @@ void main() {
|
|
|
57
57
|
vec4 fillColor = vec4(a_Color.rgb, a_Color.a * opacity);
|
|
58
58
|
v_color = mix(fillColor, vec4(u_stroke.xyz, u_stroke.w * fillColor.w * u_stroke_opacity), a_Normal.z);
|
|
59
59
|
|
|
60
|
-
|
|
61
|
-
if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
|
|
62
|
-
gl_Position = u_Mvp * vec4(project_pos.xy + offsetCommon.xy, 0., 1.0);
|
|
63
|
-
} else {
|
|
64
|
-
gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offsetCommon.xy, 0., 1.0));
|
|
65
|
-
}
|
|
60
|
+
gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xy + offsetCommon.xy, 0., 1.0));
|
|
66
61
|
|
|
67
62
|
|
|
68
63
|
|
|
@@ -108,7 +108,7 @@ void main() {
|
|
|
108
108
|
v_normal = getNormal((next.xy - curr.xy) * indexDir, a_Position.y);
|
|
109
109
|
vec2 offset = project_pixel(getExtrusionOffset((next.xy - curr.xy) * indexDir, a_Position.y));
|
|
110
110
|
// vec4 project_pos = project_position(vec4(curr.xy, 0, 1.0));
|
|
111
|
-
gl_Position =
|
|
111
|
+
gl_Position = project_common_position_to_clipspace_v2(vec4(curr.xy + offset, curr.z, 1.0));
|
|
112
112
|
setPickingColor(a_PickingColor);
|
|
113
113
|
}
|
|
114
114
|
|
|
@@ -11,7 +11,7 @@ uniform float u_globel;
|
|
|
11
11
|
uniform float u_globel_radius;
|
|
12
12
|
uniform float u_global_height: 10;
|
|
13
13
|
uniform mat4 u_ModelMatrix;
|
|
14
|
-
|
|
14
|
+
|
|
15
15
|
uniform float segmentNumber;
|
|
16
16
|
uniform vec4 u_animate: [ 1., 2., 1.0, 0.2 ];
|
|
17
17
|
varying vec4 v_color;
|
|
@@ -141,14 +141,9 @@ void main() {
|
|
|
141
141
|
|
|
142
142
|
v_iconMapUV = a_iconMapUV;
|
|
143
143
|
}
|
|
144
|
-
|
|
145
144
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
gl_Position = u_Mvp * (vec4(curr.xy + project_pixel(offset), curr.z, 1.0));
|
|
149
|
-
} else {
|
|
150
|
-
gl_Position = project_common_position_to_clipspace(vec4(curr.xy + project_pixel(offset), curr.z, 1.0));
|
|
151
|
-
}
|
|
145
|
+
|
|
146
|
+
gl_Position = project_common_position_to_clipspace_v2(vec4(curr.xy + project_pixel(offset), curr.z, 1.0));
|
|
152
147
|
|
|
153
148
|
// 地球模式
|
|
154
149
|
if(u_globel > 0.0) {
|
|
@@ -8,7 +8,7 @@ attribute vec3 a_Position;
|
|
|
8
8
|
attribute vec4 a_Instance;
|
|
9
9
|
attribute float a_Size;
|
|
10
10
|
uniform mat4 u_ModelMatrix;
|
|
11
|
-
|
|
11
|
+
|
|
12
12
|
uniform float segmentNumber;
|
|
13
13
|
uniform vec4 u_animate: [ 1., 2., 1.0, 0.2 ];
|
|
14
14
|
varying vec4 v_color;
|
|
@@ -176,11 +176,9 @@ v_line_data.a = lineOffsetWidth/linePixelSize; // 线图层贴图部分的 v
|
|
|
176
176
|
v_iconMapUV = a_iconMapUV;
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
gl_Position = project_common_position_to_clipspace(vec4(curr.xy + offset, curr.z, 1.0));
|
|
183
|
-
}
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
gl_Position = project_common_position_to_clipspace_v2(vec4(curr.xy + offset, 0, 1.0));
|
|
184
182
|
setPickingColor(a_PickingColor);
|
|
185
183
|
}
|
|
186
184
|
|
|
@@ -6,7 +6,7 @@ attribute vec3 a_Position;
|
|
|
6
6
|
attribute vec4 a_Instance;
|
|
7
7
|
attribute float a_Size;
|
|
8
8
|
uniform mat4 u_ModelMatrix;
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
uniform float segmentNumber;
|
|
11
11
|
uniform vec4 u_animate: [ 1., 2., 1.0, 0.2 ];
|
|
12
12
|
varying vec4 v_color;
|
|
@@ -129,14 +129,8 @@ void main() {
|
|
|
129
129
|
float linePixelSize = project_pixel(a_Size); // 定点位置偏移
|
|
130
130
|
v_lineData.a = lineOffsetWidth/linePixelSize; // 线图层贴图部分的 v 坐标值
|
|
131
131
|
}
|
|
132
|
-
|
|
133
132
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
// gl_Position = u_Mvp * (vec4(curr.xy + offset, 0, 1.0));
|
|
137
|
-
gl_Position = u_Mvp * (vec4(curr.xy + offset, 0, 1.0));
|
|
138
|
-
} else {
|
|
139
|
-
gl_Position = project_common_position_to_clipspace(vec4(curr.xy + offset, 0, 1.0));
|
|
140
|
-
}
|
|
133
|
+
gl_Position = project_common_position_to_clipspace_v2(vec4(curr.xy + offset, 0, 1.0));
|
|
134
|
+
|
|
141
135
|
setPickingColor(a_PickingColor);
|
|
142
136
|
}
|
|
@@ -80,6 +80,6 @@ void main() {
|
|
|
80
80
|
v_normal = getNormal((next.xy - curr.xy) * indexDir, a_Position.y);
|
|
81
81
|
vec2 offset = project_pixel(getExtrusionOffset((next.xy - curr.xy) * indexDir, a_Position.y));
|
|
82
82
|
|
|
83
|
-
gl_Position =
|
|
83
|
+
gl_Position = project_common_position_to_clipspace_v2(vec4(curr.xy + offset, 0, 1.0));
|
|
84
84
|
setPickingColor(a_PickingColor);
|
|
85
85
|
}
|
|
@@ -12,7 +12,7 @@ uniform float u_globel;
|
|
|
12
12
|
uniform float u_globel_radius;
|
|
13
13
|
uniform float u_global_height: 10;
|
|
14
14
|
uniform mat4 u_ModelMatrix;
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
uniform float segmentNumber;
|
|
17
17
|
uniform vec4 u_animate: [ 1., 2., 1.0, 0.2 ];
|
|
18
18
|
uniform vec4 u_sourceColor;
|
|
@@ -133,13 +133,7 @@ void main() {
|
|
|
133
133
|
|
|
134
134
|
v_Color.a *= opacity;
|
|
135
135
|
|
|
136
|
-
|
|
137
|
-
// gl_Position = project_common_position_to_clipspace(vec4(curr.xy + project_pixel(offset), curr.z, 1.0));
|
|
138
|
-
if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
|
|
139
|
-
gl_Position = u_Mvp * (vec4(curr.xy + project_pixel(offset), curr.z, 1.0));
|
|
140
|
-
} else {
|
|
141
|
-
gl_Position = project_common_position_to_clipspace(vec4(curr.xy + project_pixel(offset), curr.z, 1.0));
|
|
142
|
-
}
|
|
136
|
+
gl_Position = project_common_position_to_clipspace_v2(vec4(curr.xy + project_pixel(offset), curr.z, 1.0));
|
|
143
137
|
|
|
144
138
|
// 地球模式
|
|
145
139
|
if(u_globel > 0.0) {
|
|
@@ -4,7 +4,7 @@ attribute vec3 a_Position;
|
|
|
4
4
|
attribute vec4 a_Instance;
|
|
5
5
|
attribute float a_Size;
|
|
6
6
|
uniform mat4 u_ModelMatrix;
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
uniform float segmentNumber;
|
|
9
9
|
varying vec4 v_color;
|
|
10
10
|
varying float v_segmentIndex;
|
|
@@ -94,10 +94,7 @@ void main() {
|
|
|
94
94
|
v_color = mix(u_sourceColor, u_targetColor, d_segmentIndex/segmentNumber);
|
|
95
95
|
v_color.a *= u_opacity;
|
|
96
96
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
} else {
|
|
100
|
-
gl_Position = project_common_position_to_clipspace(vec4(curr.xy + offset, 0, 1.0));
|
|
101
|
-
}
|
|
97
|
+
gl_Position = project_common_position_to_clipspace_v2(vec4(curr.xy + offset, 0, 1.0));
|
|
98
|
+
|
|
102
99
|
setPickingColor(a_PickingColor);
|
|
103
100
|
}
|
package/es/mask/models/fill.js
CHANGED
|
@@ -13,7 +13,7 @@ import { polygonTriangulation } from "../../core/triangulation";
|
|
|
13
13
|
/* babel-plugin-inline-import '../../shader/minify_frag.glsl' */
|
|
14
14
|
var mask_frag = "uniform float u_opacity : 1.0;\nuniform vec4 u_color;\n\nvoid main() {\n gl_FragColor = u_color;\n gl_FragColor.a *= u_opacity;\n}\n";
|
|
15
15
|
/* babel-plugin-inline-import '../shaders/mask_vert.glsl' */
|
|
16
|
-
var mask_vert = "attribute vec3 a_Position;\nuniform mat4 u_ModelMatrix;\
|
|
16
|
+
var mask_vert = "attribute vec3 a_Position;\nuniform mat4 u_ModelMatrix;\n\n\n#pragma include \"projection\"\n\nvoid main() {\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xyz, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n }\n}\n\n";
|
|
17
17
|
var isNumber = lodashUtil.isNumber;
|
|
18
18
|
var MaskModel = /*#__PURE__*/function (_BaseModel) {
|
|
19
19
|
_inherits(MaskModel, _BaseModel);
|
|
@@ -14,7 +14,7 @@ import { rgb2arr } from '@antv/l7-utils';
|
|
|
14
14
|
/* babel-plugin-inline-import '../shaders/billboard_point_frag.glsl' */
|
|
15
15
|
var simplePointFrag = "\nuniform float u_additive;\nuniform float u_stroke_opacity : 1;\n\nuniform vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\n\nvarying vec4 v_color;\nvarying float v_blur;\nvarying float v_innerRadius;\n\n#pragma include \"picking\"\nvoid main() {\n vec2 center = vec2(0.5);\n\n // Tip: \u7247\u5143\u5230\u4E2D\u5FC3\u70B9\u7684\u8DDD\u79BB 0 - 1\n float fragmengTocenter = distance(center, gl_PointCoord) * 2.0;\n // Tip: \u7247\u5143\u7684\u526A\u5207\u6210\u5706\u5F62\n float circleClipOpacity = 1.0 - smoothstep(v_blur, 1.0, fragmengTocenter);\n\n\n if(v_innerRadius < 0.99) {\n // \u5F53\u5B58\u5728 stroke \u4E14 stroke > 0.01\n float blurWidth = (1.0 - v_blur)/2.0;\n vec4 stroke = vec4(u_stroke_color.rgb, u_stroke_opacity);\n if(fragmengTocenter > v_innerRadius + blurWidth) {\n gl_FragColor = stroke;\n } else if(fragmengTocenter > v_innerRadius - blurWidth){\n float mixR = (fragmengTocenter - (v_innerRadius - blurWidth)) / (blurWidth * 2.0);\n gl_FragColor = mix(v_color, stroke, mixR);\n } else {\n gl_FragColor = v_color;\n }\n } else {\n // \u5F53\u4E0D\u5B58\u5728 stroke \u6216 stroke <= 0.01\n gl_FragColor = v_color;\n }\n\n gl_FragColor = filterColor(gl_FragColor);\n \n if(u_additive > 0.0) {\n gl_FragColor *= circleClipOpacity;\n } else {\n gl_FragColor.a *= circleClipOpacity;\n }\n\n}\n";
|
|
16
16
|
/* babel-plugin-inline-import '../shaders/billboard_point_vert.glsl' */
|
|
17
|
-
var simplePointVert = "\nattribute vec3 a_Position;\nuniform mat4 u_ModelMatrix;\
|
|
17
|
+
var simplePointVert = "\nattribute vec3 a_Position;\nuniform mat4 u_ModelMatrix;\n\nattribute float a_Size;\nattribute vec4 a_Color;\nvarying vec4 v_color;\n\nuniform float u_opacity : 1;\nuniform vec2 u_offsets;\nuniform float u_stroke_width;\n\nvarying float v_blur;\nvarying float v_innerRadius;\n\n\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n#pragma include \"project\"\nvoid main() {\n v_color = vec4(a_Color.xyz, a_Color.w * u_opacity);\n v_blur = 1.0 - max(2.0/a_Size, 0.05);\n v_innerRadius = max((a_Size - u_stroke_width) / a_Size, 0.0);\n \n vec2 offset = project_pixel(u_offsets);\n \n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * vec4(a_Position.xy + offset, a_Position.z, 1.0);\n } else { // else\n vec4 project_pos = project_position(vec4(a_Position, 1.0)) + vec4(a_Size / 2.,-a_Size /2.,0.,0.);\n gl_Position = project_common_position_to_clipspace(vec4(vec2(project_pos.xy+offset),project_pos.z,project_pos.w));\n }\n \n gl_PointSize = a_Size * 2.0 * u_DevicePixelRatio;\n setPickingColor(a_PickingColor);\n}\n";
|
|
18
18
|
export function PointTriangulation(feature) {
|
|
19
19
|
var coordinates = feature.coordinates;
|
|
20
20
|
return {
|