@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 5.95 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
*/
import{_ as i}from"../../../../../../../chunks/tslib.es6.js";import{animationDebugFlags as t}from"../../../../../../../symbols/cim/animationDebugFlags.js";import{generateVirtualMachineSource as e}from"../../../animations/instructions.js";import{location as o,uniform as a,option as s}from"../../GraphShaderModule.js";import{Vec2 as r,texture2D as l,block as n,Float as m,step as p,negate as u,cond as d,equal as c,Mat2 as y,cos as f,sin as v,Mat3 as b,Vec3 as S,lessThanEqual as h,ifElse as w,clamp as g,abs as V,Vec4 as x}from"../../graph/glsl.js";import{AnimationUniformInfo as z}from"./AnimationUniformInfo.js";import{AnimationParamIndex as j}from"./enums.js";import{MarkerConstants as P}from"../markers/markerConstants.js";import{AFeatureShader as T,FeatureVertexInput as _,FeatureFragmentInput as I}from"../shaders/AFeatureShader.js";import{c256ToRad as O,softEdgeRatio as C}from"../shaders/constants.js";import{LocalTileOffset as M}from"../shaders/LocalTileOffset.js";import{MosaicInfo as D}from"../shaders/MosaicInfo.js";import{getBit as A,rgba2float as F}from"../shaders/utils.js";import{VisualVariableColor as L}from"../shaders/VisualVariableColor.js";import{VisualVariableOpacity as R}from"../shaders/VisualVariableOpacity.js";import{VisualVariableRotation as k}from"../shaders/VisualVariableRotation.js";import{VisualVariableSizeMinMaxValue as U}from"../shaders/VisualVariableSizeMinMaxValue.js";import{VisualVariableSizeScaleStops as E}from"../shaders/VisualVariableSizeScaleStops.js";import{VisualVariableSizeStops as B}from"../shaders/VisualVariableSizeStops.js";import{VisualVariableSizeUnitValue as G}from"../shaders/VisualVariableSizeUnitValue.js";import{getVisualVariableSize as N,getVisualVariableAngle as W}from"../shaders/vvUtils.js";class q extends _{}i([o(3,r)],q.prototype,"offset",void 0),i([o(4,x)],q.prototype,"sizing",void 0),i([o(5,x)],q.prototype,"value1Position2Value2",void 0),i([o(6,x)],q.prototype,"animationPointerAndBaseSizeAndReferenceSize",void 0),i([o(7,r)],q.prototype,"zoomRange",void 0),i([o(8,m)],q.prototype,"lineLength",void 0);class H extends I{}class J extends T{_vertexPreamble(i,t,e){const{id:o,offset:a,animationPointerAndBaseSizeAndReferenceSize:s,sizing:r}=i,l=s.xy,n=s.z,b=s.w,S=r.xy,h=this._getEvalParams(i,S,e);let w,g;if(i.value1Position2Value2){const t=K(l,j.shift,h).a,e=i.pos,o=i.value1Position2Value2.yz,a=i.value1Position2Value2.x,s=i.value1Position2Value2.w,r=t.subtract(a).divide(s.subtract(a));g=e.add(o.subtract(e).multiply(r)),w=p(new m(1),r).add(p(new m(0),u(r)))}else g=i.pos,w=new m(0);const V=r.z,x=A(i.bitset,P.bitset.isStroke),z=r.w,T=A(i.bitset,P.bitset.scaleSymbolsProportionally),_=K(l,j.transform,h),I=d([c(A(i.bitset,P.bitset.isMapAligned),new m(1)),this.view.rotation.divide(180).multiply(Math.PI)],[!0,new m(0)]),C=new y(f(I),v(I.multiply(-1)),v(I),f(I)).multiply(_.xy),M=_.z.subtract(I).subtract(t.multiply(O)),D=_.w,F=A(i.bitset,P.bitset.isSDF),L=N(this,o,new m(b)).divide(new m(b));return{baseSize:n,animationPointer:l,strokeWidth:V,isOutline:x,unscaledDistanceToPx:z,scaleSymbolsProportionally:T,isSDF:F,position:this._getScreenPosition({id:o,pos:g,offset:a,referenceSize:b,translation:C,rotation:M,scale:D,vvScale:L}),evalParams:h,vvScale:L,scale:D,clip:w}}_getScreenPosition(i){const{pos:t,translation:e,rotation:o,scale:a,offset:s,id:r,vvScale:l}=i,n=W(this,r).multiply(Math.PI/180),p=e.x.multiply(4/3),d=e.y.multiply(-1).multiply(4/3),c=v(n),y=f(n),h=y.multiply(p).add(u(c).multiply(d)),w=c.multiply(p).add(y.multiply(d)),g=v(o.subtract(n)),V=f(o.subtract(n)),x=new m(0),z=new m(1),{pixelRatio:j}=this.animationInfo,P=new b(z,x,x,x,z,x,h.multiply(j),w.multiply(j),z),T=new b(V,g.multiply(-1),x,g,V,x,0,0,z),_=a.multiply(l).multiply(j).multiply(4/3),I=T.multiply(_),O=this.animationInfo.toScreen.multiply(new S(t,1)),C=P.multiply(O).xy,M=I.multiply(new S(s,0)).xy;return C.add(M)}_clip(i,e){let o=super.clip(i,e);const a=h(this._getLocalTimeOrigin(i),new m(0));return t.forceGlobalTimeOrigin||(o=o.add(d([a,()=>new m(2)],[!0,()=>new m(0)]))),o}_getLocalTimeOrigin(i){return this.storage.getLocalTimeOrigin(i)}_toNdc(i){return this.animationInfo.toNdc.multiply(new S(i,1)).xy}_getEvalParams(i,t,e){const{globalTime:o,animationTextureSize:a,animationTexture:s}=this.animationInfo;return{globalTime:o,localTimeOrigin:this._getLocalTimeOrigin(i.id),animationTextureSize:a,animationTexture:s,pixelDimensions:t,lineLength:e}}_getColor(i,t){return w(c(t.isSDF,new m(1)),this._getSDFColor(i,t),this._getSpriteColor(i,t))}_getSpriteColor(i,t){return l(this.mosaicInfo.texture,i).multiply(t.color)}_getSDFColor(i,t){const e=l(this.mosaicInfo.texture,i),o=new m(.5).subtract(F(e)).multiply(t.distanceToPx).multiply(C),a=g(new m(.5).subtract(o),new m(0),new m(1)),s=t.color.multiply(a),r=t.outlineSize.multiply(.5),n=V(o).subtract(r),p=g(new m(.5).subtract(n),new m(0),new m(1)),u=t.outlineColor.multiply(p);return new m(1).subtract(u.a).multiply(s).add(u)}}function K(i,t,o){const a=i.add(new r(t,0)),s=l(o.animationTexture,a.add(.5).divide(o.animationTextureSize)).xy;return i=i.add(s),n({animationPointer:i,...o},x,null,(i=>{const{out:t}=i;if(!t)throw new Error("out is null");return e({...i,out:t})}))}i([a(D)],J.prototype,"mosaicInfo",void 0),i([a(z)],J.prototype,"animationInfo",void 0),i([a(M)],J.prototype,"localTileOffset",void 0),i([s(L)],J.prototype,"visualVariableColor",void 0),i([s(R)],J.prototype,"visualVariableOpacity",void 0),i([s(U)],J.prototype,"visualVariableSizeMinMaxValue",void 0),i([s(E)],J.prototype,"visualVariableSizeScaleStops",void 0),i([s(B)],J.prototype,"visualVariableSizeStops",void 0),i([s(G)],J.prototype,"visualVariableSizeUnitValue",void 0),i([s(k)],J.prototype,"visualVariableRotation",void 0);export{H as AAnimatedFragmentInput,J as AAnimatedShader,q as AAnimatedVertexInput,K as getValue};