UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

32 lines (29 loc) 2.32 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ 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{VertexAttribute as i}from"../views/3d/webgl-engine/lib/VertexAttribute.js";import{ShaderBuilder as n}from"../views/webgl/ShaderBuilder.js";import{alphaCutoff as s}from"../webscene/support/AlphaCutoff.js";function d(d){const a=new n,{vertex:l,fragment:c}=a;e(l,d),l.uniforms.add(new o("width",(e=>e.width))),a.attributes.add(i.POSITION,"vec3"),a.attributes.add(i.NORMAL,"vec3"),a.attributes.add(i.UV0,"vec2"),a.attributes.add(i.LENGTH,"float"),a.varyings.add("vtc","vec2"),a.varyings.add("vlength","float"),a.varyings.add("vradius","float"),l.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;`),c.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 v=1/Math.sqrt(2);return c.code.add(r` const float INV_SQRT2 = ${r.float(v)}; 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; }`),c.main.add(r` vec2 ntc = vec2(vtc.x / vradius, vtc.y); vec4 color = arrowColor(ntc, vlength / vradius); if (color.a < ${r.float(s)}) { discard; } fragColor = color;`),a}const a=Object.freeze(Object.defineProperty({__proto__:null,build:d},Symbol.toStringTag,{value:"Module"}));export{a as M,d as b};