// All material copyright Esri, All Rights Reserved, unless otherwise specified.
// See https://js.arcgis.com/4.30/esri/copyright.txt for details.
//>>built
define("exports ../../../core/mathUtils ../../../core/libs/gl-matrix-2/math/mat4 ../../../core/libs/gl-matrix-2/factories/mat4f64 ../../../chunks/vec32 ../../../core/libs/gl-matrix-2/factories/vec3f64 ../../../geometry/support/axisAngleDegrees ../../../geometry/support/Ellipsoid ./CloudsData ./weather ../../support/RenderState".split(" "),function(b,u,q,n,d,l,m,p,g,h,v){class w{constructor(){this.readChannels=g.CloudsTextureChannels.RG;this.renderingStage=g.CloudsRenderingStages.FINISHED;this.startTimeHeightFade=
this.startTime=0;this.cameraPositionLastFrame=l.create();this.parallax=new r;this.parallaxNew=new r;this.pointOnGround=l.create();this.fadeMode=b.FadeMode.HIDE;this.opacity=this.fadeFactor=0}updateParallax(a){var c=this.parallax;a=d.length(a.eye);c.radiusCurvatureCorrectionFactor=.84*Math.sqrt(Math.max(a*a-p.earth.radius*p.earth.radius,0))/a;m.fromPoints(t,c.anchorPointClouds,k);q.rotate(c.transform,n.IDENTITY,k[3],m.axis(k));this.fadeMode===b.FadeMode.CROSS_FADE&&(c=this.parallaxNew,m.fromPoints(t,
c.anchorPointClouds,k),q.rotate(c.transform,n.IDENTITY,k[3],m.axis(k)))}updateFading(a,c,f,e){this.isFading&&this._advanceFading(f,e);this._evaluateFading(a,c,f)}_evaluateFading(a,c,f){const e=a.relativeElevation;a=this._calculateDistanceToAnchorPoint(a);(e>1.7*h.weatherHeightLimit||e<-h.weatherHeightLimit||2E5h.weatherHeightLimit||e<-.35*h.weatherHeightLimit||64E3=-.35*h.weatherHeightLimit&&c===v.RenderState.IDLE&&g.ensureClouds(this.data)&&(0===this.opacity?this._setFade(b.FadeMode.FADE_IN,f):(34E3this.fadeFactor?(this.fadeFactor=c?u.clamp((a-this.startTime)/(1.25*c),0,1):1,this.fadeMode===b.FadeMode.FADE_OUT&&
(this.opacity=1-this.fadeFactor),this.fadeMode===b.FadeMode.FADE_IN&&(this.opacity=this.fadeFactor),this.fadeMode===b.FadeMode.CROSS_FADE&&(this.opacity=1)):(this.fadeFactor=0,this.fadeMode===b.FadeMode.FADE_OUT&&(this.opacity=0),this.fadeMode===b.FadeMode.FADE_IN&&(this.opacity=1),this.fadeMode===b.FadeMode.CROSS_FADE&&(this.opacity=1),this.fadeMode=b.FadeMode.NONE)}_switchReadChannels(){const a=this.fadeMode===b.FadeMode.CROSS_FADE&&1===this.fadeFactor,c=this.fadeMode===b.FadeMode.FADE_IN&&0===
this.fadeFactor;this.renderingStage===g.CloudsRenderingStages.FADING&&(a||c)&&(this.readChannels=1-this.readChannels,this.renderingStage=g.CloudsRenderingStages.FINISHED)}_calculateDistanceToAnchorPoint(a){d.normalize(this.pointOnGround,a.eye);d.scale(this.pointOnGround,this.pointOnGround,p.earth.radius);return d.length(d.subtract(x,this.parallax.anchorPointClouds,this.pointOnGround))}_updateAnchorPoint(){this.fadeMode===b.FadeMode.CROSS_FADE&&(0===this.fadeFactor&&d.copy(this.parallaxNew.anchorPointClouds,
this.pointOnGround),1===this.fadeFactor&&d.copy(this.parallax.anchorPointClouds,this.parallaxNew.anchorPointClouds));this.fadeMode===b.FadeMode.FADE_IN&&0===this.fadeFactor&&d.copy(this.parallax.anchorPointClouds,this.pointOnGround)}_setFade(a,c){switch(a){case b.FadeMode.HIDE:this.opacity=0;break;case b.FadeMode.FADE_OUT:this.opacity=1;break;case b.FadeMode.FADE_IN:this.opacity=0;break;case b.FadeMode.CROSS_FADE:this.opacity=1}this.fadeMode=a;this.fadeFactor=0;this.startTime=c}get isFading(){return this.fadeMode===
b.FadeMode.FADE_OUT||this.fadeMode===b.FadeMode.FADE_IN||this.fadeMode===b.FadeMode.CROSS_FADE}}b.FadeMode=void 0;(function(a){a[a.NONE=0]="NONE";a[a.HIDE=1]="HIDE";a[a.FADE_OUT=2]="FADE_OUT";a[a.FADE_IN=3]="FADE_IN";a[a.CROSS_FADE=4]="CROSS_FADE"})(b.FadeMode||(b.FadeMode={}));class r{constructor(){this.anchorPointClouds=l.create();this.radiusCurvatureCorrectionFactor=0;this.transform=n.create()}}const t=l.fromValues(0,0,1),k=m.create(),x=l.create();b.CloudsParameters=w;b.crossFadeDistanceThreshold=
34E3;b.fadeOutDistanceThreshold=64E3;b.hideDistanceThreshold=2E5;Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})});