You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
13 lines
5.4 KiB
13 lines
5.4 KiB
// All material copyright Esri, All Rights Reserved, unless otherwise specified. |
|
// See https://js.arcgis.com/4.30/esri/copyright.txt for details. |
|
//>>built |
|
define("../../../core/mathUtils ../../../core/maybe ../../../core/reactiveUtils ../../../core/libs/gl-matrix-2/math/mat4 ../../../core/libs/gl-matrix-2/factories/mat4f64 ../../../core/libs/gl-matrix-2/math/vec2 ../../../chunks/vec32 ../../../core/libs/gl-matrix-2/factories/vec3f64 ../../../geometry/ellipsoidUtils ../../../geometry/support/FloatArray ./AtmosphereType ./atmosphereUtils ../../../chunks/SimpleAtmosphere.glsl ./SimpleAtmosphereTechnique ./SimpleAtmosphereTechniqueConfiguration ./resources/MarsAtmosphereTexture ../support/mathUtils ../support/buffer/glUtil ../support/buffer/InterleavedLayout ../webgl-engine/lib/DefaultVertexAttributeLocations ../webgl-engine/lib/glUtil3D ../webgl-engine/lib/Util ../webgl-engine/lib/VertexArrayObject ../webgl-engine/lib/VertexAttribute ../../webgl/BufferObject ../../webgl/enums ../../webgl/Texture ../../webgl/TextureDescriptor ../../webgl/Util".split(" "), |
|
function(u,D,v,E,F,G,h,q,H,I,J,w,K,x,r,L,M,N,O,P,Q,y,R,S,T,m,U,V,z){function A(a,b,c,f,e){const g=h.length(a),d=f*Math.sqrt(g*g-f*f)/g,k=e.v1,n=e.v2;h.scale(e.center,a,Math.sqrt(f*f-d*d)/g);h.cross(k,a,b);1>h.squaredLength(k)&&h.cross(k,a,c);h.scale(k,k,d/h.length(k));h.cross(n,k,a);h.scale(n,n,d/h.length(n));return d}const B=-w.innerAtmosphereDepth,W=M.makePiecewiseLinearFunction([[50,.1015625],[500,.21875],[5E3,.51171875],[5E4,.4140625]]);class X{constructor(a,b){this.view=a;this.type=J.AtmosphereType.Mars; |
|
this._passParameters=new K.SimpleAtmospherePassParameters;this._vaoCount=0;this._texV1=1;a=H.getReferenceEllipsoid(a.spatialReference);this._planetRadius=a.radius;this._outerRimWidth=a.outerAtmosphereRimWidth;this._innerRimFactor=(this._planetRadius+B)/this._planetRadius;this._middleRimFactor=(this._planetRadius+0)/this._planetRadius;this._outerRimFactor=(this._planetRadius+this._outerRimWidth)/this._planetRadius;this._texV0=0/this._outerRimWidth;this._texVScale=this._texV1-this._texV0;this._techniques= |
|
b.techniques;a=b.renderContext.rctx;this._cameraChangeHandle=v.watch(()=>this.view.state?.camera,()=>b.requestRender(),v.syncAndInitial);this._vao=this._createRibbon(a);this._vaoCount=z.vertexCount(this._vao,"geometry");this._fadeVao=Q.createQuadVAO(a);this._fadeVaoCount=z.vertexCount(this._fadeVao,"geometry");const c=new V.TextureDescriptor;c.wrapMode=m.TextureWrapMode.CLAMP_TO_EDGE;c.flipped=!0;c.width=1;c.height=512;this._passParameters.texture=new U.Texture(a,c,L.marsAtmosphereTextureSimple); |
|
a=new r.SimpleAtmosphereTechniqueConfiguration;a.geometry=r.SimpleAtmosphereGeometry.Cone;this._coneTechnique=this._techniques.acquire(x.SimpleAtmosphereTechnique,a);a.geometry=r.SimpleAtmosphereGeometry.Underground;this._undergroundTechnique=this._techniques.acquire(x.SimpleAtmosphereTechnique,a)}destroy(){this._coneTechnique.release();this._undergroundTechnique.release();this._cameraChangeHandle.remove();this._passParameters.texture=D.disposeMaybe(this._passParameters.texture);this._fadeVao.dispose(); |
|
this._vao.dispose()}render(a){this._update(a.bindParameters.camera);const b=a.rctx;1>this._passParameters.undergroundFadeAlpha&&(b.bindTechnique(this._coneTechnique,a.bindParameters,this._passParameters),b.bindVAO(this._vao),b.drawArrays(m.PrimitiveType.TRIANGLES,0,this._vaoCount));0<this._passParameters.undergroundFadeAlpha&&(b.bindTechnique(this._undergroundTechnique,a.bindParameters,this._passParameters),b.bindVAO(this._fadeVao),b.drawArrays(m.PrimitiveType.TRIANGLE_STRIP,0,this._fadeVaoCount))}renderHaze(){}_update(a){var b= |
|
q.create();const c=this._planetRadius;var f=h.length(a.eye);const e=f-c;this._passParameters.undergroundFadeAlpha=0>e?Math.min(-e/5E3,1):0;var g=c+B,d=c+Math.max(50,e);this._passParameters.innerScale=d*d/(Math.sqrt(d*d-c*c)*Math.sqrt(d*d-g*g)+c*g)-1;this._passParameters.altitudeFade=w.computeInnerAltitudeFade(e);h.scale(b,a.eye,(c+50)/f);A(b,a.center,a.up,c,this._passParameters.silhouette);b=this._computeScreenRimWidth(a,b,a.up,this._passParameters.silhouette);f=W(e);g=this._texV0+.001953125*this._texVScale; |
|
d=this._texV0+b*f*this._texVScale;50<e&&(A(a.eye,a.center,a.up,c,this._passParameters.silhouette),a=this._computeScreenRimWidth(a,a.eye,a.up,this._passParameters.silhouette),a=u.clamp((a-1.5)/(b-1.5),0,1),g=this._texV0+.001953125*a*this._texVScale,d=this._texV0+u.lerp(this._texV1,b*f,a)*this._texVScale);G.set(this._passParameters.texV,g,d)}_createRibbon(a){const b=I.newFloatArray(1155),c=new Uint32Array(1920);b[0]=0;b[1]=0;b[2]=-1;for(var f=0;128>f;f++){var e=9*f+3;b[e]=f;b[e+1]=this._innerRimFactor; |
|
b[e+2]=-1;b[e+3]=f;b[e+4]=this._middleRimFactor;b[e+5]=0;b[e+6]=f;b[e+7]=this._outerRimFactor;b[e+8]=1;e=3*f+1;var g=127===f?1:e+3,d=15*f;c[d]=e;c[d+1]=e+1;c[d+2]=g+1;c[d+3]=g+1;c[d+4]=g;c[d+5]=e;c[d+6]=e+1;c[d+7]=e+2;c[d+8]=g+2;c[d+9]=g+2;c[d+10]=g+1;c[d+11]=e+1;c[d+12]=e;c[d+13]=g;c[d+14]=0}f=C.createBuffer(c.length);e=f.position;for(g=0;g<c.length;++g)d=3*c[g],e.set(g,0,b[d]),e.set(g,1,b[d+1]),e.set(g,2,b[d+2]);return new R.VertexArrayObject(a,P.Default3D,{geometry:N.glLayout(C)},{geometry:T.BufferObject.createVertex(a, |
|
m.Usage.STATIC_DRAW,f.buffer)})}_computeScreenRimWidth(a,b,c,f){h.add(l,f.center,f.v2);h.scale(p,l,this._outerRimFactor);E.lookAt(t,b,l,c);y.project(l,t,a.projectionMatrix,a.viewport,l);y.project(p,t,a.projectionMatrix,a.viewport,p);return h.distance(l,p)/a.height}}const t=F.create(),l=q.create(),p=q.create(),C=O.newLayout().vec3f(S.VertexAttribute.POSITION);return X}); |