From 8420c3e158e2b9526969406d9c2c55cb1c3a6ba8 Mon Sep 17 00:00:00 2001 From: 2912401452 <2912401452@qq.com> Date: Tue, 1 Jun 2021 13:43:11 +0800 Subject: [PATCH] feat: arc tex test --- .../layers/src/line/shaders/line_arc_frag.glsl | 14 ++++++++++++++ .../layers/src/line/shaders/line_arc_vert.glsl | 15 +++++++++++++-- stories/Map/components/amap2demo_arcLineTex.tsx | 14 +------------- 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/packages/layers/src/line/shaders/line_arc_frag.glsl b/packages/layers/src/line/shaders/line_arc_frag.glsl index 6751c2e880..1d1e60b3b9 100644 --- a/packages/layers/src/line/shaders/line_arc_frag.glsl +++ b/packages/layers/src/line/shaders/line_arc_frag.glsl @@ -13,6 +13,9 @@ varying vec4 v_color; uniform float u_time; uniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ]; +varying float v_u; +varying float v_segmentIndex; + #pragma include "picking" void main() { @@ -47,4 +50,15 @@ void main() { // gl_FragColor = filterColor(gl_FragColor); // } gl_FragColor = filterColor(gl_FragColor); + // gl_FragColor.a = v_u; + gl_FragColor = v_color; + + if(v_segmentIndex < 15.0) { + // v_u = (segmentIndex + 1.0)/15.0; + gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); + } else { + // v_u = (segmentIndex + 1.0 - 15.0)/15.0; + // v_u = 0.0; + gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0); + } } diff --git a/packages/layers/src/line/shaders/line_arc_vert.glsl b/packages/layers/src/line/shaders/line_arc_vert.glsl index bce49316d1..078697c97d 100644 --- a/packages/layers/src/line/shaders/line_arc_vert.glsl +++ b/packages/layers/src/line/shaders/line_arc_vert.glsl @@ -21,7 +21,8 @@ varying vec4 v_dash_array; // uniform float u_icon_step: 100; // uniform float u_line_texture; -// varying float v_u; +varying float v_segmentIndex; +varying float v_u; // varying vec2 v_offset; // varying float v_a; // attribute vec2 a_iconMapUV; @@ -80,6 +81,7 @@ vec2 getNormal(vec2 line_clipspace, float offset_direction) { void main() { v_color = a_Color; + v_segmentIndex = a_Position.x + 1.0; vec2 source = a_Instance.rg; vec2 target = a_Instance.ba; @@ -107,7 +109,16 @@ void main() { // if(LineTexture == u_line_texture) { // 开启贴图模式 // v_iconMapUV = a_iconMapUV; - + // float r = (segmentIndex + 1.0)/30.0; + // if(segmentIndex < 15.0) { + // // v_u = (segmentIndex + 1.0)/15.0; + // v_color = vec4(1.0, 0.0, 0.0, 1.0); + // } else { + // // v_u = (segmentIndex + 1.0 - 15.0)/15.0; + // // v_u = 0.0; + // v_color = vec4(1.0, 1.0, 0.0, 1.0); + // } + // v_u = fract(r * 2.0); // float arctotal_Distance = length(source - target); // float pixelLen = project_pixel(u_icon_step); // v_u = fract(segmentRatio * (floor(arctotal_Distance/pixelLen))); diff --git a/stories/Map/components/amap2demo_arcLineTex.tsx b/stories/Map/components/amap2demo_arcLineTex.tsx index 0b90ccbd8f..2c67e7eaef 100644 --- a/stories/Map/components/amap2demo_arcLineTex.tsx +++ b/stories/Map/components/amap2demo_arcLineTex.tsx @@ -30,18 +30,6 @@ export default class Amap2demo_arcLineTex extends React.Component { ); let data = [ - // { - // lng1: 91.111891, - // lat1: 40.662557, - // lng2: 120.342625, - // lat2: 37.373799, - // }, - // { - // lng1: 116.98242187499999, - // lat1: 43.004647127794435, - // lng2: 105.64453124999999, - // lat2: 28.998531814051795, - // }, { lng1: 75.76171875, lat1: 36.31512514748051, @@ -71,7 +59,7 @@ export default class Amap2demo_arcLineTex extends React.Component { // lineTexture: true, // 开启线的贴图功能 // iconStep: 100, // 设置贴图纹理的间距 }) - .animate(true); + // .animate(true); scene.addLayer(layer); }); }