@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 2.06 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 n,VertexInput as s,UniformGroup as i,FragmentOutput as a,input 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 h,Sampler2D as b}from"../../graph/glsl.js";import{magnifierBarrelFactor as k}from"./constants.js";class T extends s{}t([e(0,l)],T.prototype,"position",void 0);class C extends d{}class j extends i{}t([r(b)],j.prototype,"readbackTexture",void 0),t([r(b)],j.prototype,"maskTexture",void 0),t([r(b)],j.prototype,"overlayTexture",void 0),t([r(c)],j.prototype,"background",void 0),t([r(c)],j.prototype,"drawPos",void 0),t([r(y)],j.prototype,"maskEnabled",void 0),t([r(y)],j.prototype,"overlayEnabled",void 0);class E extends n{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,P(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 r=m(w(this.config.overlayEnabled,new y(1)),u(this.config.overlayTexture,t.texCoord),new c(0)),n=new a;return n.fragColor=r.add(new y(1).subtract(r.a).multiply(o)),n}}function P(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),h(t));return e.multiply(r).multiply(new l(.5)).add(new y(.5))}))}t([r(j)],E.prototype,"config",void 0),t([o(0,p(T))],E.prototype,"vertex",null),t([o(0,p(C))],E.prototype,"fragment",null);export{E as MagnifierShader};