UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 2.04 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import{_ as t,a as o}from"../../../../../../../chunks/tslib.es6.js";import{GraphShaderModule as e,FragmentOutput as r,location as i,uniform as n,input as s,VertexInput as a,UniformGroup as p,FragmentInput as l}from"../../GraphShaderModule.js";import{Vec3 as d,Vec4 as c,abs as h,fract as y,min as m,Float as f,Vec2 as g,smoothstep as u,Int as v,round as x,intMod as w,ifElse as j,lessThan as C,greaterThan as L,multiply as b,step as W,mix as P,Mat3 as I}from"../../graph/glsl.js";class G extends a{}t([i(0,g)],G.prototype,"position",void 0);class S extends l{}class k extends p{}t([n(I)],k.prototype,"dvs",void 0);class M extends p{}t([n(f)],M.prototype,"halfWidth",void 0),t([n(f)],M.prototype,"aaWidth",void 0),t([n(f)],M.prototype,"pxPerCell",void 0),t([n(c)],M.prototype,"minorLineColor",void 0),t([n(c)],M.prototype,"majorLineColor",void 0),t([n(v)],M.prototype,"majorLineInterval",void 0);class _ extends e{constructor(){super(...arguments),this.type="GridShader"}vertex(t){const o=t.position.multiply(2).subtract(1);return{gridPos:this.transform.dvs.multiply(new d(o,1)).xy,glPosition:new c(o,0,1)}}fragment(t){const o=h(t.gridPos),e=y(o),i=m(e.x,new f(1).subtract(e.x)),n=m(e.y,new f(1).subtract(e.y)),s=new g(i,n).multiply(this.config.pxPerCell).subtract(this.config.halfWidth),a=m(s.x,s.y),p=new f(1).subtract(u(new f(0),this.config.aaWidth,a)),l=new v(x(o.x)),d=new v(x(o.y)),c=new f(w(l,this.config.majorLineInterval)),I=new f(w(d,this.config.majorLineInterval)),G=j(C(s.x,s.y),c,I),S=L(b(W(s.x,this.config.aaWidth),W(s.y,this.config.aaWidth)),new f(.5)),k=m(c,I),M=j(S,k,G),_=P(this.config.majorLineColor,this.config.minorLineColor,m(M,new f(1))),q=new r;return q.fragColor=_.multiply(p),q}}t([n(k)],_.prototype,"transform",void 0),t([n(M)],_.prototype,"config",void 0),t([o(0,s(G))],_.prototype,"vertex",null),t([o(0,s(S))],_.prototype,"fragment",null);export{_ as GridShader};