/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../../../chunks/_rollupPluginBabelHelpers","../../../../core/mathUtils","../../../../core/maybe","../../../../chunks/vec3","../../../../chunks/vec3f64","../../../ViewingMode","../core/shaderLibrary/shading/ReadShadowMap.glsl","./glUtil3D","../shaders/ShadowHighlightTechnique","../../../webgl/Util"],(function(e,t,i,a,s,r,n,h,o,c,d){"use strict";const u=.001953125,l=4e4,_=5e4;let p=function(){function e(e,t){this._rctx=e,this._viewingMode=t,this._maxOpacity=1,this._passParameters=new c.ShadowHighlightPassParameters,this._drawParameters=new h.ReadShadowMapBindParameters,this._vao=o.createQuadVAO(this._rctx)}var r=e.prototype;return r.render=function(e,t){if(!e.shadowMap.enabled||!e.linearDepthTexture||!this.isVisible)return;const i=this.technique;this._drawParameters.origin=e.camera.center,this._rctx.bindFramebuffer(t),this._rctx.bindTechnique(i,this._passParameters,e).bindDraw(this._drawParameters,e),this._rctx.bindVAO(this._vao),this._rctx.drawArrays(i.primitiveType,0,d.vertexCount(this._vao,"geometry"))},r.setDefaultOptions=function(e){this._passParameters={...this._passParameters,...e},this._updateMaxOpacity()},r.updateParameters=function(e,t){this._passParameters.opacityElevation=1-i.smoothstep(l,_,e.relativeElevation);const a=this._viewingMode===n.ViewingMode.Global?s.normalize(m,e.center):s.set(m,0,0,1),r=s.dot(a,t);this._passParameters.dayNightTerminator=i.smoothstep(0,1,i.clamp(30*r,0,1))},r.dispose=function(){this._vao=a.disposeMaybe(this._vao),this._technique=a.releaseMaybe(this._technique)},r._updateMaxOpacity=function(){const e=Math.max(this._passParameters.shadowOpacity,this._passParameters.occludedShadowOpacity);this._maxOpacity=e*this._passParameters.shadowColor[3]},t._createClass(e,[{key:"technique",get:function(){return a.isNone(this._technique)&&(this._technique=new c.ShadowHighlightTechnique({rctx:this._rctx,viewingMode:this._viewingMode})),this._technique}},{key:"gpuMemoryUsage",get:function(){var e,t;return null!=(e=null==(t=this._vao)?void 0:t.size)?e:0}},{key:"isVisible",get:function(){const{opacityElevation:e,dayNightTerminator:t}=this._passParameters;return this._maxOpacity*e*t>=u}}]),e}();const m=r.create();e.ShadowHighlight=p,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
