@antv/l7-layers 2.21.11-beta.6 → 2.22.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/line/models/arc_3d.js +1 -1
- package/es/line/models/great_circle.js +1 -1
- package/es/line/models/wall.js +2 -2
- package/es/line/shaders/arc3d/line_arc_3d_frag.glsl +3 -4
- package/es/line/shaders/greatCircle/line_arc_great_circle_frag.glsl +7 -7
- package/es/line/shaders/wall/wall_frag.glsl +5 -3
- package/es/line/shaders/wall/wall_vert.glsl +4 -5
- package/lib/line/models/arc_3d.js +1 -1
- package/lib/line/models/great_circle.js +1 -1
- package/lib/line/models/wall.js +2 -2
- package/lib/line/shaders/arc3d/line_arc_3d_frag.glsl +3 -4
- package/lib/line/shaders/greatCircle/line_arc_great_circle_frag.glsl +7 -7
- package/lib/line/shaders/wall/wall_frag.glsl +5 -3
- package/lib/line/shaders/wall/wall_vert.glsl +4 -5
- package/package.json +6 -6
package/es/line/models/arc_3d.js
CHANGED
|
@@ -7,7 +7,7 @@ import { LineArcTriangulation } from "../../core/triangulation";
|
|
|
7
7
|
import { EARTH_RADIUS } from "../../earth/utils";
|
|
8
8
|
// arc3d line layer
|
|
9
9
|
/* babel-plugin-inline-import '../shaders/arc3d/line_arc_3d_frag.glsl' */
|
|
10
|
-
const arc3d_line_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;\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 u_globel;\n float u_globel_radius;\n float u_global_height: 10;\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.0;\n};\n\
|
|
10
|
+
const arc3d_line_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;\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 u_globel;\n float u_globel_radius;\n float u_global_height: 10;\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.0;\n};\n\nin vec4 v_color;\nin vec4 v_dash_array;\nin float v_segmentIndex;\nin vec2 v_iconMapUV;\nin vec4 v_line_data;\n\nout vec4 outputColor;\n\n#pragma include \"picking\"\n\nvoid main() {\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 outputColor = v_color;\n\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 outputColor.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 outputColor.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 = texture(SAMPLER_2D(u_texture), uv);\n\n if(u_animate.x == Animate) {\n float currentPlane = floor(redioCount - time);\n float textureStep = floor(count * u_animate.z);\n float a = mod(currentPlane, textureStep);\n if(a < textureStep - 1.0) {\n pattern = vec4(0.0);\n }\n }\n\n if(u_textureBlend == 0.0) { // normal\n pattern.a = 0.0;\n outputColor = filterColor(outputColor + pattern);\n } else { // replace\n pattern.a *= v_color.a;\n if(outputColor.a <= 0.0) {\n pattern.a = 0.0;\n discard;\n } else {\n outputColor = filterColor(pattern);\n }\n }\n\n } else {\n outputColor = filterColor(outputColor);\n }\n}\n";
|
|
11
11
|
/* babel-plugin-inline-import '../shaders/arc3d/line_arc_3d_vert.glsl' */
|
|
12
12
|
const arc3d_line_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\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 u_globel;\n float u_globel_radius;\n float u_global_height: 10;\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.0;\n};\nout vec4 v_color;\nout vec4 v_dash_array;\nout float v_segmentIndex;\nout vec2 v_iconMapUV;\nout 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 dir_screenspace.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 //vs\u4E2D\u8BA1\u7B97\u6E10\u53D8\u8272\n if(u_linearColor==1.0){\n float d_segmentIndex = a_Position.x + 1.0; // \u5F53\u524D\u9876\u70B9\u5728\u5F27\u7EBF\u4E2D\u6240\u5904\u7684\u5206\u6BB5\u4F4D\u7F6E\n v_color = mix(u_sourceColor, u_targetColor, d_segmentIndex/segmentNumber);\n }\n else{\n v_color = a_Color;\n }\n v_color.a = v_color.a * opacity;\n vec2 source = project_position(vec4(a_Instance.rg, 0, 0), a_Instance64Low.xy).xy;\n vec2 target = project_position(vec4(a_Instance.ba, 0, 0), a_Instance64Low.zw).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(source, target) / 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(vec4(curr.xy + project_pixel(offset), curr.z * thetaOffset, 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";
|
|
13
13
|
const lineStyleObj = {
|
|
@@ -5,7 +5,7 @@ import { fp64LowPart, rgb2arr } from '@antv/l7-utils';
|
|
|
5
5
|
import BaseModel from "../../core/BaseModel";
|
|
6
6
|
import { LineArcTriangulation } from "../../core/triangulation";
|
|
7
7
|
/* babel-plugin-inline-import '../shaders/greatCircle/line_arc_great_circle_frag.glsl' */
|
|
8
|
-
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
|
|
8
|
+
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_dash_array;\nin vec4 v_color;\nin vec2 v_iconMapUV;\nin vec4 v_line_data;\nin float v_distance_ratio;\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}\n";
|
|
9
9
|
/* babel-plugin-inline-import '../shaders/greatCircle/line_arc_great_circle_vert.glsl' */
|
|
10
10
|
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 d_arcDistrance = project_pixel(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";
|
|
11
11
|
const lineStyleObj = {
|
package/es/line/models/wall.js
CHANGED
|
@@ -5,9 +5,9 @@ import { rgb2arr } from '@antv/l7-utils';
|
|
|
5
5
|
import BaseModel from "../../core/BaseModel";
|
|
6
6
|
import { LineTriangulation } from "../../core/triangulation";
|
|
7
7
|
/* babel-plugin-inline-import '../shaders/wall/wall_frag.glsl' */
|
|
8
|
-
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
|
|
8
|
+
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};\n\n\nin vec2 v_iconMapUV;\nin vec4 v_color;\nin float v_blur;\nin vec4 v_dataset;\n\nout vec4 outputColor;\n\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";
|
|
9
9
|
/* babel-plugin-inline-import '../shaders/wall/wall_vert.glsl' */
|
|
10
|
-
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
|
|
10
|
+
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// 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 vec4 v_dataset;\n\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\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";
|
|
11
11
|
export default class LineWallModel extends BaseModel {
|
|
12
12
|
constructor(...args) {
|
|
13
13
|
super(...args);
|
|
@@ -23,12 +23,11 @@ layout(std140) uniform commonUniorm {
|
|
|
23
23
|
float u_linearColor: 0.0;
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
// varying vec2 v_normal;
|
|
27
|
-
in vec4 v_dash_array;
|
|
28
26
|
in vec4 v_color;
|
|
29
|
-
in vec4
|
|
27
|
+
in vec4 v_dash_array;
|
|
30
28
|
in float v_segmentIndex;
|
|
31
29
|
in vec2 v_iconMapUV;
|
|
30
|
+
in vec4 v_line_data;
|
|
32
31
|
|
|
33
32
|
out vec4 outputColor;
|
|
34
33
|
|
|
@@ -57,7 +56,7 @@ void main() {
|
|
|
57
56
|
alpha = clamp(alpha, 0.0, 1.0);
|
|
58
57
|
outputColor.a *= alpha;
|
|
59
58
|
|
|
60
|
-
// u_animate
|
|
59
|
+
// u_animate
|
|
61
60
|
// x enable
|
|
62
61
|
// y duration
|
|
63
62
|
// z interval
|
|
@@ -19,11 +19,11 @@ layout(std140) uniform commonUniorm {
|
|
|
19
19
|
float u_linearColor: 0;
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
in vec4 v_line_data;
|
|
23
|
-
in vec2 v_iconMapUV;
|
|
24
22
|
in vec4 v_dash_array;
|
|
25
|
-
in float v_distance_ratio;
|
|
26
23
|
in vec4 v_color;
|
|
24
|
+
in vec2 v_iconMapUV;
|
|
25
|
+
in vec4 v_line_data;
|
|
26
|
+
in float v_distance_ratio;
|
|
27
27
|
|
|
28
28
|
out vec4 outputColor;
|
|
29
29
|
#pragma include "picking"
|
|
@@ -34,7 +34,7 @@ void main() {
|
|
|
34
34
|
|
|
35
35
|
float animateSpeed = 0.0;
|
|
36
36
|
float d_segmentIndex = v_line_data.g;
|
|
37
|
-
|
|
37
|
+
|
|
38
38
|
// 设置弧线的底色
|
|
39
39
|
if(u_linearColor == 1.0) { // 使用渐变颜色
|
|
40
40
|
outputColor = mix(u_sourceColor, u_targetColor, d_segmentIndex/segmentNumber);
|
|
@@ -65,7 +65,7 @@ void main() {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
// 设置弧线的贴图
|
|
68
|
-
if(LineTexture == u_line_texture && u_line_type != LineTypeDash) {
|
|
68
|
+
if(LineTexture == u_line_texture && u_line_type != LineTypeDash) {
|
|
69
69
|
float arcRadio = smoothstep( 0.0, 1.0, (d_segmentIndex / (segmentNumber - 1.0)));
|
|
70
70
|
// float arcRadio = d_segmentIndex / (segmentNumber - 1.0);
|
|
71
71
|
float count = v_line_data.b; // 贴图在弧线上重复的数量
|
|
@@ -79,7 +79,7 @@ void main() {
|
|
|
79
79
|
|
|
80
80
|
vec2 uv= v_iconMapUV / u_textSize + vec2(u, v) / u_textSize * 64.;
|
|
81
81
|
vec4 pattern = texture(SAMPLER_2D(u_texture), uv);
|
|
82
|
-
|
|
82
|
+
|
|
83
83
|
// 设置贴图和底色的叠加模式
|
|
84
84
|
if(u_textureBlend == 0.0) { // normal
|
|
85
85
|
pattern.a = 0.0;
|
|
@@ -96,4 +96,4 @@ void main() {
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
// gl_FragColor = filterColor(gl_FragColor);
|
|
99
|
-
}
|
|
99
|
+
}
|
|
@@ -17,13 +17,15 @@ layout(std140) uniform commonUniorm {
|
|
|
17
17
|
float u_iconStepCount;
|
|
18
18
|
float u_time;
|
|
19
19
|
};
|
|
20
|
+
|
|
21
|
+
|
|
20
22
|
in vec2 v_iconMapUV;
|
|
21
|
-
in float v_blur;
|
|
22
|
-
in float v_radio;
|
|
23
23
|
in vec4 v_color;
|
|
24
|
+
in float v_blur;
|
|
24
25
|
in vec4 v_dataset;
|
|
25
26
|
|
|
26
27
|
out vec4 outputColor;
|
|
28
|
+
|
|
27
29
|
#pragma include "picking"
|
|
28
30
|
|
|
29
31
|
void main() {
|
|
@@ -79,7 +81,7 @@ void main() {
|
|
|
79
81
|
outputColor = filterColor(pattern);
|
|
80
82
|
}
|
|
81
83
|
}
|
|
82
|
-
|
|
84
|
+
|
|
83
85
|
|
|
84
86
|
// blur - AA
|
|
85
87
|
if(v < v_blur) {
|
|
@@ -21,17 +21,16 @@ layout(std140) uniform commonUniorm {
|
|
|
21
21
|
float u_time;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
#pragma include "projection"
|
|
25
|
-
#pragma include "light"
|
|
26
|
-
#pragma include "picking"
|
|
27
|
-
|
|
28
24
|
// texV 线图层 - 贴图部分的 v 坐标(线的宽度方向)
|
|
29
25
|
out vec2 v_iconMapUV;
|
|
30
26
|
out vec4 v_color;
|
|
31
27
|
out float v_blur;
|
|
32
|
-
out float v_radio;
|
|
33
28
|
out vec4 v_dataset;
|
|
34
29
|
|
|
30
|
+
#pragma include "projection"
|
|
31
|
+
#pragma include "light"
|
|
32
|
+
#pragma include "picking"
|
|
33
|
+
|
|
35
34
|
void main() {
|
|
36
35
|
float a_Distance = a_Distance_Total_Miter.x;
|
|
37
36
|
float a_Miter = a_Distance_Total_Miter.y;
|
|
@@ -14,7 +14,7 @@ var _triangulation = require("../../core/triangulation");
|
|
|
14
14
|
var _utils = require("../../earth/utils");
|
|
15
15
|
/* babel-plugin-inline-import '../shaders/arc3d/line_arc_3d_frag.glsl' */
|
|
16
16
|
// arc3d line layer
|
|
17
|
-
const arc3d_line_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;\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 u_globel;\n float u_globel_radius;\n float u_global_height: 10;\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.0;\n};\n\
|
|
17
|
+
const arc3d_line_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;\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 u_globel;\n float u_globel_radius;\n float u_global_height: 10;\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.0;\n};\n\nin vec4 v_color;\nin vec4 v_dash_array;\nin float v_segmentIndex;\nin vec2 v_iconMapUV;\nin vec4 v_line_data;\n\nout vec4 outputColor;\n\n#pragma include \"picking\"\n\nvoid main() {\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 outputColor = v_color;\n\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 outputColor.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 outputColor.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 = texture(SAMPLER_2D(u_texture), uv);\n\n if(u_animate.x == Animate) {\n float currentPlane = floor(redioCount - time);\n float textureStep = floor(count * u_animate.z);\n float a = mod(currentPlane, textureStep);\n if(a < textureStep - 1.0) {\n pattern = vec4(0.0);\n }\n }\n\n if(u_textureBlend == 0.0) { // normal\n pattern.a = 0.0;\n outputColor = filterColor(outputColor + pattern);\n } else { // replace\n pattern.a *= v_color.a;\n if(outputColor.a <= 0.0) {\n pattern.a = 0.0;\n discard;\n } else {\n outputColor = filterColor(pattern);\n }\n }\n\n } else {\n outputColor = filterColor(outputColor);\n }\n}\n";
|
|
18
18
|
/* babel-plugin-inline-import '../shaders/arc3d/line_arc_3d_vert.glsl' */
|
|
19
19
|
const arc3d_line_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\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 u_globel;\n float u_globel_radius;\n float u_global_height: 10;\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.0;\n};\nout vec4 v_color;\nout vec4 v_dash_array;\nout float v_segmentIndex;\nout vec2 v_iconMapUV;\nout 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 dir_screenspace.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 //vs\u4E2D\u8BA1\u7B97\u6E10\u53D8\u8272\n if(u_linearColor==1.0){\n float d_segmentIndex = a_Position.x + 1.0; // \u5F53\u524D\u9876\u70B9\u5728\u5F27\u7EBF\u4E2D\u6240\u5904\u7684\u5206\u6BB5\u4F4D\u7F6E\n v_color = mix(u_sourceColor, u_targetColor, d_segmentIndex/segmentNumber);\n }\n else{\n v_color = a_Color;\n }\n v_color.a = v_color.a * opacity;\n vec2 source = project_position(vec4(a_Instance.rg, 0, 0), a_Instance64Low.xy).xy;\n vec2 target = project_position(vec4(a_Instance.ba, 0, 0), a_Instance64Low.zw).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(source, target) / 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(vec4(curr.xy + project_pixel(offset), curr.z * thetaOffset, 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";
|
|
20
20
|
const lineStyleObj = {
|
|
@@ -12,7 +12,7 @@ var _l7Utils = require("@antv/l7-utils");
|
|
|
12
12
|
var _BaseModel = _interopRequireDefault(require("../../core/BaseModel"));
|
|
13
13
|
var _triangulation = require("../../core/triangulation");
|
|
14
14
|
/* babel-plugin-inline-import '../shaders/greatCircle/line_arc_great_circle_frag.glsl' */
|
|
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
|
|
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_dash_array;\nin vec4 v_color;\nin vec2 v_iconMapUV;\nin vec4 v_line_data;\nin float v_distance_ratio;\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}\n";
|
|
16
16
|
/* babel-plugin-inline-import '../shaders/greatCircle/line_arc_great_circle_vert.glsl' */
|
|
17
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 d_arcDistrance = project_pixel(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";
|
|
18
18
|
const lineStyleObj = {
|
package/lib/line/models/wall.js
CHANGED
|
@@ -12,9 +12,9 @@ var _l7Utils = require("@antv/l7-utils");
|
|
|
12
12
|
var _BaseModel = _interopRequireDefault(require("../../core/BaseModel"));
|
|
13
13
|
var _triangulation = require("../../core/triangulation");
|
|
14
14
|
/* babel-plugin-inline-import '../shaders/wall/wall_frag.glsl' */
|
|
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
|
|
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};\n\n\nin vec2 v_iconMapUV;\nin vec4 v_color;\nin float v_blur;\nin vec4 v_dataset;\n\nout vec4 outputColor;\n\n#pragma include \"picking\"\n\nvoid main() {\n float animateSpeed = 0.0; // \u8FD0\u52A8\u901F\u5EA6\n float d_distance_ratio = v_dataset.r; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n float v = v_dataset.a;\n\n if(u_linearColor == 1.0) { // \u4F7F\u7528\u6E10\u53D8\u989C\u8272\n outputColor = mix(u_sourceColor, u_targetColor, v);\n } else { // \u4F7F\u7528 color \u65B9\u6CD5\u4F20\u5165\u7684\u989C\u8272\n outputColor = v_color;\n }\n\n outputColor.a *= v_color.a; // \u5168\u5C40\u900F\u660E\u5EA6\n if(u_animate.x == Animate) {\n animateSpeed = u_time / u_animate.y;\n float alpha =1.0 - fract( mod(1.0- d_distance_ratio, u_animate.z)* (1.0/ u_animate.z) + animateSpeed);\n alpha = (alpha + u_animate.w -1.0) / u_animate.w;\n alpha = smoothstep(0., 1., alpha);\n outputColor.a *= alpha;\n }\n\n if(u_line_texture == LineTexture) { // while load texture\n float aDistance = v_dataset.g; // \u5F53\u524D\u9876\u70B9\u7684\u8DDD\u79BB\n float d_texPixelLen = v_dataset.b; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n float u = fract(mod(aDistance, d_texPixelLen)/d_texPixelLen - animateSpeed);\n float v = v_dataset.a; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n // \u8BA1\u7B97\u7EB9\u7406\u95F4\u9694 start\n float flag = 0.0;\n if(u > 1.0/u_iconStepCount) {\n flag = 1.0;\n }\n u = fract(u*u_iconStepCount);\n // \u8BA1\u7B97\u7EB9\u7406\u95F4\u9694 end\n\n vec2 uv= v_iconMapUV / u_textSize + vec2(u, v) / u_textSize * 64.;\n vec4 pattern = texture(SAMPLER_2D(u_texture), uv);\n\n // Tip: \u5224\u65AD\u7EB9\u7406\u95F4\u9694\n if(flag > 0.0) {\n pattern = vec4(0.0);\n }\n\n if(u_textureBlend == 0.0) { // normal\n pattern.a = 0.0;\n outputColor = filterColor(outputColor + pattern);\n } else { // replace\n pattern.a *= v_color.a;\n if(outputColor.a <= 0.0) {\n pattern.a = 0.0;\n }\n outputColor = filterColor(pattern);\n }\n }\n\n\n // blur - AA\n if(v < v_blur) {\n outputColor.a = mix(0.0, outputColor.a, v/v_blur);\n } else if(v > 1.0 - v_blur) {\n outputColor.a = mix(outputColor.a, 0.0, (v - (1.0 - v_blur))/v_blur);\n }\n\n outputColor = filterColor(outputColor);\n}\n";
|
|
16
16
|
/* babel-plugin-inline-import '../shaders/wall/wall_vert.glsl' */
|
|
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
|
|
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// 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 vec4 v_dataset;\n\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\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";
|
|
18
18
|
class LineWallModel extends _BaseModel.default {
|
|
19
19
|
constructor(...args) {
|
|
20
20
|
super(...args);
|
|
@@ -23,12 +23,11 @@ layout(std140) uniform commonUniorm {
|
|
|
23
23
|
float u_linearColor: 0.0;
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
// varying vec2 v_normal;
|
|
27
|
-
in vec4 v_dash_array;
|
|
28
26
|
in vec4 v_color;
|
|
29
|
-
in vec4
|
|
27
|
+
in vec4 v_dash_array;
|
|
30
28
|
in float v_segmentIndex;
|
|
31
29
|
in vec2 v_iconMapUV;
|
|
30
|
+
in vec4 v_line_data;
|
|
32
31
|
|
|
33
32
|
out vec4 outputColor;
|
|
34
33
|
|
|
@@ -57,7 +56,7 @@ void main() {
|
|
|
57
56
|
alpha = clamp(alpha, 0.0, 1.0);
|
|
58
57
|
outputColor.a *= alpha;
|
|
59
58
|
|
|
60
|
-
// u_animate
|
|
59
|
+
// u_animate
|
|
61
60
|
// x enable
|
|
62
61
|
// y duration
|
|
63
62
|
// z interval
|
|
@@ -19,11 +19,11 @@ layout(std140) uniform commonUniorm {
|
|
|
19
19
|
float u_linearColor: 0;
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
in vec4 v_line_data;
|
|
23
|
-
in vec2 v_iconMapUV;
|
|
24
22
|
in vec4 v_dash_array;
|
|
25
|
-
in float v_distance_ratio;
|
|
26
23
|
in vec4 v_color;
|
|
24
|
+
in vec2 v_iconMapUV;
|
|
25
|
+
in vec4 v_line_data;
|
|
26
|
+
in float v_distance_ratio;
|
|
27
27
|
|
|
28
28
|
out vec4 outputColor;
|
|
29
29
|
#pragma include "picking"
|
|
@@ -34,7 +34,7 @@ void main() {
|
|
|
34
34
|
|
|
35
35
|
float animateSpeed = 0.0;
|
|
36
36
|
float d_segmentIndex = v_line_data.g;
|
|
37
|
-
|
|
37
|
+
|
|
38
38
|
// 设置弧线的底色
|
|
39
39
|
if(u_linearColor == 1.0) { // 使用渐变颜色
|
|
40
40
|
outputColor = mix(u_sourceColor, u_targetColor, d_segmentIndex/segmentNumber);
|
|
@@ -65,7 +65,7 @@ void main() {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
// 设置弧线的贴图
|
|
68
|
-
if(LineTexture == u_line_texture && u_line_type != LineTypeDash) {
|
|
68
|
+
if(LineTexture == u_line_texture && u_line_type != LineTypeDash) {
|
|
69
69
|
float arcRadio = smoothstep( 0.0, 1.0, (d_segmentIndex / (segmentNumber - 1.0)));
|
|
70
70
|
// float arcRadio = d_segmentIndex / (segmentNumber - 1.0);
|
|
71
71
|
float count = v_line_data.b; // 贴图在弧线上重复的数量
|
|
@@ -79,7 +79,7 @@ void main() {
|
|
|
79
79
|
|
|
80
80
|
vec2 uv= v_iconMapUV / u_textSize + vec2(u, v) / u_textSize * 64.;
|
|
81
81
|
vec4 pattern = texture(SAMPLER_2D(u_texture), uv);
|
|
82
|
-
|
|
82
|
+
|
|
83
83
|
// 设置贴图和底色的叠加模式
|
|
84
84
|
if(u_textureBlend == 0.0) { // normal
|
|
85
85
|
pattern.a = 0.0;
|
|
@@ -96,4 +96,4 @@ void main() {
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
// gl_FragColor = filterColor(gl_FragColor);
|
|
99
|
-
}
|
|
99
|
+
}
|
|
@@ -17,13 +17,15 @@ layout(std140) uniform commonUniorm {
|
|
|
17
17
|
float u_iconStepCount;
|
|
18
18
|
float u_time;
|
|
19
19
|
};
|
|
20
|
+
|
|
21
|
+
|
|
20
22
|
in vec2 v_iconMapUV;
|
|
21
|
-
in float v_blur;
|
|
22
|
-
in float v_radio;
|
|
23
23
|
in vec4 v_color;
|
|
24
|
+
in float v_blur;
|
|
24
25
|
in vec4 v_dataset;
|
|
25
26
|
|
|
26
27
|
out vec4 outputColor;
|
|
28
|
+
|
|
27
29
|
#pragma include "picking"
|
|
28
30
|
|
|
29
31
|
void main() {
|
|
@@ -79,7 +81,7 @@ void main() {
|
|
|
79
81
|
outputColor = filterColor(pattern);
|
|
80
82
|
}
|
|
81
83
|
}
|
|
82
|
-
|
|
84
|
+
|
|
83
85
|
|
|
84
86
|
// blur - AA
|
|
85
87
|
if(v < v_blur) {
|
|
@@ -21,17 +21,16 @@ layout(std140) uniform commonUniorm {
|
|
|
21
21
|
float u_time;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
#pragma include "projection"
|
|
25
|
-
#pragma include "light"
|
|
26
|
-
#pragma include "picking"
|
|
27
|
-
|
|
28
24
|
// texV 线图层 - 贴图部分的 v 坐标(线的宽度方向)
|
|
29
25
|
out vec2 v_iconMapUV;
|
|
30
26
|
out vec4 v_color;
|
|
31
27
|
out float v_blur;
|
|
32
|
-
out float v_radio;
|
|
33
28
|
out vec4 v_dataset;
|
|
34
29
|
|
|
30
|
+
#pragma include "projection"
|
|
31
|
+
#pragma include "light"
|
|
32
|
+
#pragma include "picking"
|
|
33
|
+
|
|
35
34
|
void main() {
|
|
36
35
|
float a_Distance = a_Distance_Total_Miter.x;
|
|
37
36
|
float a_Miter = a_Distance_Total_Miter.y;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/l7-layers",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.22.0",
|
|
4
4
|
"description": "L7's collection of built-in layers",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "https://github.com/orgs/antvis/people",
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"gl-matrix": "^3.1.0",
|
|
34
34
|
"gl-vec2": "^1.3.0",
|
|
35
35
|
"polyline-miter-util": "^1.0.1",
|
|
36
|
-
"@antv/l7-core": "2.
|
|
37
|
-
"@antv/l7-maps": "2.
|
|
38
|
-
"@antv/l7-source": "2.
|
|
39
|
-
"@antv/l7-utils": "2.
|
|
36
|
+
"@antv/l7-core": "2.22.0",
|
|
37
|
+
"@antv/l7-maps": "2.22.0",
|
|
38
|
+
"@antv/l7-source": "2.22.0",
|
|
39
|
+
"@antv/l7-utils": "2.22.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/d3-array": "^2",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@types/d3-scale": "^2.1.1",
|
|
46
46
|
"@types/earcut": "^2.1.0",
|
|
47
47
|
"@types/gl-matrix": "^2.4.5",
|
|
48
|
-
"@antv/l7-test-utils": "^2.
|
|
48
|
+
"@antv/l7-test-utils": "^2.22.0"
|
|
49
49
|
},
|
|
50
50
|
"publishConfig": {
|
|
51
51
|
"access": "public",
|