@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
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
*/
import{_ as t,a as o}from"../../../../../../../chunks/tslib.es6.js";import{location as e,uniform as r,GraphShaderModule as i,VertexInput as n,UniformGroup as s,FragmentOutput as a,input 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 n{}t([e(0,g)],G.prototype,"position",void 0);class S extends l{}class k extends s{}t([r(I)],k.prototype,"dvs",void 0);class M extends s{}t([r(f)],M.prototype,"halfWidth",void 0),t([r(f)],M.prototype,"aaWidth",void 0),t([r(f)],M.prototype,"pxPerCell",void 0),t([r(c)],M.prototype,"minorLineColor",void 0),t([r(c)],M.prototype,"majorLineColor",void 0),t([r(v)],M.prototype,"majorLineInterval",void 0);class _ extends i{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),r=m(e.x,new f(1).subtract(e.x)),i=m(e.y,new f(1).subtract(e.y)),n=new g(r,i).multiply(this.config.pxPerCell).subtract(this.config.halfWidth),s=m(n.x,n.y),p=new f(1).subtract(u(new f(0),this.config.aaWidth,s)),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(n.x,n.y),c,I),S=L(b(W(n.x,this.config.aaWidth),W(n.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 a;return q.fragColor=_.multiply(p),q}}t([r(k)],_.prototype,"transform",void 0),t([r(M)],_.prototype,"config",void 0),t([o(0,p(G))],_.prototype,"vertex",null),t([o(0,p(S))],_.prototype,"fragment",null);export{_ as GridShader};