@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 3.71 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */
import{clamp as t}from"../../../core/mathUtils.js";import{signal as a}from"../../../core/signal.js";import{rotate as e}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as s,create as i}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{squaredLength as r,normalize as h,scale as o,copy as n,length as c,subtract as d}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as l,fromValues as _}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as u,fromPoints as f,axis as p}from"../../../geometry/support/axisAngleDegrees.js";import{earth as m}from"../../../geometry/support/Ellipsoid.js";import{ensureClouds as F}from"./Clouds.js";import{heightLimit as P}from"./weather.js";class x{constructor(){this.startTime=0,this._data=a(null),this.coverage=0,this.absorption=0,this._readChannels=0,this.parallax=new v,this.parallaxNew=new v,this._anchorPoint=l(),this._fadeState=a(0),this._fadeFactor=a(1)}get data(){return this._data.value}set data(t){this._data.value=t}get readChannels(){return this._readChannels}get fadeState(){return this._fadeState.value}get fadeFactor(){return this._fadeFactor.value}get opacity(){switch(this.fadeState){case 0:return 0;case 4:return 1-this.fadeFactor;case 1:return this.fadeFactor;case 2:case 3:return 1}}fade(a,e,s){this.isFading&&this.fadeFactor<1&&(this._fadeFactor.value=s?t((e-this.startTime)/(b*s),0,1):1,1===this.fadeFactor&&this._endFade()),this._evaluateState(a,e),this._updateParallax(a)}_evaluateState(t,a){const e=t.relativeElevation,s=this._updateAnchorPoint(t);(Math.abs(e)>1.7*P||s>j)&&this.opacity>0?this._startFade(0,a):this.isFading||(Math.abs(e)>P||s>C*j?this.opacity>0&&this._startFade(4,a):F(this.data)&&(0===this.opacity?this._startFade(1,a):2===this.data.state&&(2===this.fadeState?this._startFade(3,a):this._startFade(2,a))))}_updateParallax(t){const a=r(t.eye);this.parallax.radiusCurvatureCorrection=.84*Math.sqrt(Math.max(a-m.radius*m.radius,0))/Math.sqrt(a),f(g,this.parallax.anchorPoint,w),e(this.parallax.transform,s,w[3],p(w)),f(g,this.parallaxNew.anchorPoint,w),e(this.parallaxNew.transform,s,w[3],p(w))}_updateAnchorPoint(t){return h(this._anchorPoint,t.eye),o(this._anchorPoint,this._anchorPoint,m.radius),0===this.fadeState&&2===this.data?.state?(n(this.parallax.anchorPoint,this._anchorPoint),0):c(d(S,this.parallax.anchorPoint,this._anchorPoint))}requestFade(){this._fadeFactor.value=0}_startFade(t,a){switch(this._fadeState.value=t,this.startTime=a,t){case 3:this.requestFade(),this._switchReadChannels(),n(this.parallaxNew.anchorPoint,this._anchorPoint);break;case 1:this.requestFade(),this._switchReadChannels(),n(this.parallax.anchorPoint,this._anchorPoint),n(this.parallaxNew.anchorPoint,this._anchorPoint);break;case 4:this.requestFade();break;case 2:this._switchReadChannels(),n(this.parallax.anchorPoint,this._anchorPoint),n(this.parallaxNew.anchorPoint,this._anchorPoint),this._endFade();break;case 0:this._endFade()}}_endFade(){switch(this._fadeFactor.value=1,this.data&&2!==this.data.state&&(this.data.state=0),this.fadeState){case 3:n(this.parallax.anchorPoint,this.parallaxNew.anchorPoint),this._fadeState.value=2;break;case 1:this._fadeState.value=2;break;case 4:this._fadeState.value=0;break;case 2:case 0:break;default:this.fadeState}}_switchReadChannels(){2===this.data?.state&&(this._readChannels=1-this._readChannels,this.data.state=3)}get isFading(){return 4===this.fadeState||1===this.fadeState||3===this.fadeState}}class v{constructor(){this.anchorPoint=l(),this.radiusCurvatureCorrection=0,this.transform=i()}}const g=_(0,0,1),w=u(),S=l(),b=1.25,C=.5,j=2e5;export{x as CloudsParameters};