@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 3.62 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 e}from"../../../chunks/tslib.es6.js";import{disposeMaybe as t}from"../../../core/maybe.js";import{watch as r,initial as i}from"../../../core/reactiveUtils.js";import"../../../core/Logger.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import"../../../core/Error.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";import{copy as o}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{create as m}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{InternalRenderCategory as n}from"../webgl.js";import{S as a}from"../../../chunks/SimpleAtmosphere.glsl.js";import{SimpleAtmosphereTechnique as p}from"./SimpleAtmosphereTechnique.js";import{SimpleAtmosphereTechniqueConfiguration as c,SimpleAtmosphereGeometry as f}from"./SimpleAtmosphereTechniqueConfiguration.js";import{earthAtmosphereTextureSimple as l}from"./resources/SimpleAtmosphereTexture.js";import{glLayout as h}from"../support/buffer/glUtil.js";import{newLayout as u}from"../support/buffer/InterleavedLayout.js";import{OpaqueEnvironment as b}from"../webgl-engine/effects/OpaqueEnvironment.js";import{RenderRequestType as g}from"../webgl-engine/lib/basicInterfaces.js";import{Default3D as j}from"../webgl-engine/lib/DefaultVertexAttributeLocations.js";import{createPolySphereData as _}from"../webgl-engine/lib/GeometryUtil.js";import{VertexArrayObject as d}from"../webgl-engine/lib/VertexArrayObject.js";import{VertexAttribute as w}from"../webgl-engine/lib/VertexAttribute.js";import{BufferObject as v}from"../../webgl/BufferObject.js";import{TextureWrapMode as x,PrimitiveType as A,Usage as T}from"../../webgl/enums.js";import{Texture as P}from"../../webgl/Texture.js";import{TextureDescriptor as y}from"../../webgl/TextureDescriptor.js";import{vertexCount as C}from"../../webgl/Util.js";let E=class extends b{constructor(){super(...arguments),this._configuration=new c,this._passParameters=new a,this._vao=null,this._vaoCount=0}initialize(){this._configuration.geometry=f.Cylinder,this.addHandles([r((()=>this.view.environment.atmosphereEnabled),(e=>e?this._enable():this._disable()),i)])}destroy(){this._passParameters.texture=t(this._passParameters.texture),this._vao=t(this._vao)}precompile(){this.techniques.precompile(p,this._configuration)}render(e){const t=e.find((({name:e})=>e===n.OPAQUE_ENVIRONMENT)),r=this.techniques.get(p,this._configuration);if(!r.compiled)return this.requestRender(g.UPDATE),t;const i=this.renderingContext;if(this._vao||(this._vao=O(i),this._vaoCount=C(this._vao,"geometry")),!this._passParameters.texture){const e=new y;e.wrapMode=x.CLAMP_TO_EDGE,e.flipped=!0,e.width=1,e.height=512,this._passParameters.texture=new P(i,e,l)}const s=i.bindTechnique(r,this.bindParameters,this._passParameters);return S(L,this.bindParameters.camera.viewMatrix),s.setUniformMatrix4fv("view",L),i.bindVAO(this._vao),s.assertCompatibleVertexAttributeLocations(this._vao),i.drawArrays(A.TRIANGLES,0,this._vaoCount),t}};function O(e){const t=_(1,2,!1),{data:r,indices:i}=t[0][1],s=q.createBuffer(i.length),o=s.position;for(let m=0;m<i.length;++m){const e=3*i[m%3==0?m+2:m%3==2?m-2:m];o.set(m,0,r[e]),o.set(m,1,r[e+1]),o.set(m,2,r[e+2])}return new d(e,j,new Map([["geometry",h(q)]]),new Map([["geometry",v.createVertex(e,T.STATIC_DRAW,s.buffer)]]))}function S(e,t){o(e,t),e[12]=0,e[13]=0,e[14]=0,e[15]=1}E=e([s("esri.views.3d.environment.LocalAtmosphere")],E);const L=m(),q=u().vec3f(w.POSITION);export{E as LocalAtmosphere};