UNPKG

@arcgis/core

Version:

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

17 lines (16 loc) 1.74 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 r}from"../views/3d/webgl-engine/core/shaderModules/Float4PassUniform.js";import{FloatPassUniform as d}from"../views/3d/webgl-engine/core/shaderModules/FloatPassUniform.js";import{glsl as o}from"../views/3d/webgl-engine/core/shaderModules/glsl.js";import{VertexAttribute as i}from"../views/3d/webgl-engine/lib/VertexAttribute.js";import{ShaderBuilder as a}from"../views/webgl/ShaderBuilder.js";function g(g){const l=new a,{vertex:t,fragment:s,attributes:n,varyings:c}=l;return e(t,g),n.add(i.POSITION,"vec3"),n.add(i.UV0,"vec2"),c.add("vUV","vec2"),t.main.add(o`vUV = uv0; gl_Position = proj * view * vec4(position, 1.0);`),s.uniforms.add(new r("backgroundColor",(e=>e.backgroundColor)),new r("gridColor",(e=>e.gridColor)),new d("gridWidth",(e=>e.gridWidth))).main.add(o`const float LINE_WIDTH = 1.0; vec2 uvScaled = vUV * gridWidth; vec2 gridUV = (fract(uvScaled + 0.5) - 0.5) / (LINE_WIDTH * fwidth(uvScaled)); vec2 grid = (1.0 - step(0.5, gridUV)) * step(-0.5, gridUV); grid.x *= step(0.5, uvScaled.x) * step(uvScaled.x, gridWidth - 0.5); grid.y *= step(0.5, uvScaled.y) * step(uvScaled.y, gridWidth - 0.5); float gridFade = max(grid.x, grid.y); float gridAlpha = gridColor.a * gridFade; fragColor = vec4(backgroundColor.rgb * backgroundColor.a, backgroundColor.a) * (1.0 - gridAlpha) + vec4(gridColor.rgb, 1.0) * gridAlpha;`),l}const l=Object.freeze(Object.defineProperty({__proto__:null,build:g},Symbol.toStringTag,{value:"Module"}));export{l as S,g as b};