/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import{addProjViewLocalOrigin as e}from"../views/3d/webgl-engine/core/shaderLibrary/util/View.glsl.js";import{Float4PassUniform as t}from"../views/3d/webgl-engine/core/shaderModules/Float4PassUniform.js";import{FloatPassUniform as o}from"../views/3d/webgl-engine/core/shaderModules/FloatPassUniform.js";import{glsl as r}from"../views/3d/webgl-engine/core/shaderModules/glsl.js";import{ShaderBuilder as i}from"../views/webgl/ShaderBuilder.js";import{alphaCutoff as n}from"../webscene/support/AlphaCutoff.js";function s(s){const a=new i,{vertex:d,fragment:l}=a;e(d,s),d.uniforms.add(new o("width",e=>e.width)),a.attributes.add("position","vec3"),a.attributes.add("normal","vec3"),a.attributes.add("uv0","vec2"),a.attributes.add("length","float"),a.varyings.add("vtc","vec2"),a.varyings.add("vlength","float"),a.varyings.add("vradius","float"),d.main.add(r`vec3 bitangent = normal;
vtc = uv0;
vlength = length;
vradius = 0.5 * width;
vec4 pos = view * vec4(position + vradius * bitangent * uv0.y, 1.0);
gl_Position = proj * pos;`),l.uniforms.add(new o("outlineSize",e=>e.outlineSize),new t("outlineColor",e=>e.outlineColor),new o("stripeLength",e=>e.stripeLength),new t("stripeEvenColor",e=>e.stripeEvenColor),new t("stripeOddColor",e=>e.stripeOddColor));const c=1/Math.sqrt(2);return l.code.add(r`
    const float INV_SQRT2 = ${r.float(c)};

    vec4 arrowColor(vec2 tc, float len) {
      float d = INV_SQRT2 * (tc.x - abs(tc.y));
      d = min(d, INV_SQRT2 * (len - tc.x - abs(tc.y)));
      d = min(d, 1.0 - abs(tc.y));

      if (d < 0.0) {
        return vec4(0.0);
      }
      if (d < outlineSize) {
        return outlineColor;
      }
      return fract(0.5 / stripeLength * tc.x * vradius) >= 0.5 ? stripeOddColor : stripeEvenColor;
    }`),l.main.add(r`
    vec2 ntc = vec2(vtc.x / vradius, vtc.y);
    vec4 color = arrowColor(ntc, vlength / vradius);
    if (color.a < ${r.float(n)}) {
      discard;
    }
    fragColor = color;`),a}const a=Object.freeze(Object.defineProperty({__proto__:null,build:s},Symbol.toStringTag,{value:"Module"}));export{a as M,s as b};
