@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 1.96 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.19/LICENSE.txt */
import{__decorate as t,__param as o}from"tslib";import{GraphShaderModule as e,FragmentOutput as r,location as n,uniform as i,input as s,VertexInput as a,UniformGroup as p,FragmentInput as d}from"../../GraphShaderModule.js";import{Vec2 as l,Vec4 as c,texture2D as u,Float as y,ifElse as m,equal as w,atan as x,pow as f,length as g,cos as v,sin as b,Sampler2D as h}from"../../graph/glsl.js";import{magnifierBarrelFactor as k}from"./constants.js";class T extends a{}t([n(0,l)],T.prototype,"position",void 0);class C extends d{}class E extends p{}t([i(h)],E.prototype,"readbackTexture",void 0),t([i(h)],E.prototype,"maskTexture",void 0),t([i(h)],E.prototype,"overlayTexture",void 0),t([i(c)],E.prototype,"background",void 0),t([i(c)],E.prototype,"drawPos",void 0),t([i(y)],E.prototype,"maskEnabled",void 0),t([i(y)],E.prototype,"overlayEnabled",void 0);class P extends e{constructor(){super(...arguments),this.type="MagnifierShader"}vertex(t){const o=t.position,e=t.position.subtract(new l(.5)).multiply(this.config.drawPos.zw),r=this.config.drawPos.xy.add(e);return{glPosition:new c(r,0,1),texCoord:o}}fragment(t){let o=u(this.config.readbackTexture,j(t.texCoord));o=o.add(new y(1).subtract(o.a)).multiply(this.config.background);const e=m(w(this.config.maskEnabled,new y(1)),u(this.config.maskTexture,t.texCoord).a,new y(1));o=o.multiply(e);const n=m(w(this.config.overlayEnabled,new y(1)),u(this.config.overlayTexture,t.texCoord),new c(0)),i=new r;return i.fragColor=n.add(new y(1).subtract(n.a).multiply(o)),i}}function j(t){const o=t.multiply(new l(2)).subtract(1);return m(w(o.x,new y(0)).and(w(o.y,new y(0))),new l(.5),()=>{const t=x(o.y,o.x),e=f(g(o),new y(k)),r=new l(v(t),b(t));return e.multiply(r).multiply(new l(.5)).add(new y(.5))})}t([i(E)],P.prototype,"config",void 0),t([o(0,s(T))],P.prototype,"vertex",null),t([o(0,s(C))],P.prototype,"fragment",null);export{P as MagnifierShader};