@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 1.94 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */
import{__decorate as t,__param as o}from"tslib";import{GraphShaderModule as e,FragmentOutput as r,location as i,uniform as n,input as s,VertexInput as p,UniformGroup as a,FragmentInput as l}from"../../GraphShaderModule.js";import{Vec3 as d,Vec4 as c,abs as y,fract as h,min as m,Float as f,Vec2 as g,smoothstep as v,Int as x,round as u,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 p{}t([i(0,g)],G.prototype,"position",void 0);class S extends l{}class M extends a{}t([n(I)],M.prototype,"dvs",void 0);class k extends a{}t([n(f)],k.prototype,"halfWidth",void 0),t([n(f)],k.prototype,"aaWidth",void 0),t([n(f)],k.prototype,"pxPerCell",void 0),t([n(c)],k.prototype,"minorLineColor",void 0),t([n(c)],k.prototype,"majorLineColor",void 0),t([n(x)],k.prototype,"majorLineInterval",void 0);class q 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=y(t.gridPos),e=h(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),p=m(s.x,s.y),a=new f(1).subtract(v(new f(0),this.config.aaWidth,p)),l=new x(u(o.x)),d=new x(u(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)),M=m(c,I),k=j(S,M,G),q=P(this.config.majorLineColor,this.config.minorLineColor,m(k,new f(1))),z=new r;return z.fragColor=q.multiply(a),z}}t([n(M)],q.prototype,"transform",void 0),t([n(k)],q.prototype,"config",void 0),t([o(0,s(G))],q.prototype,"vertex",null),t([o(0,s(S))],q.prototype,"fragment",null);export{q as GridShader};