UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 2.71 kB
import{disposeMaybe as e}from"../../../core/maybe.js";import{c as t}from"../../../chunks/mat4.js";import{c as r}from"../../../chunks/mat4f64.js";import{AtmosphereType as s}from"./AtmosphereType.js";import{S as i}from"../../../chunks/SimpleAtmosphere.glsl.js";import{SimpleAtmosphereTechnique as o}from"./SimpleAtmosphereTechnique.js";import{SimpleAtmosphereTechniqueConfiguration as a,SimpleAtmosphereGeometry as m}from"./SimpleAtmosphereTechniqueConfiguration.js";import{earthAtmosphereTextureSimple as n}from"./resources/SimpleAtmosphereTexture.js";import{glLayout as p}from"../support/buffer/glUtil.js";import{newLayout as c}from"../support/buffer/InterleavedLayout.js";import{Default3D as u}from"../webgl-engine/lib/DefaultVertexAttributeLocations.js";import{createPolySphereData as f}from"../webgl-engine/lib/GeometryUtil.js";import{VertexArrayObject as h}from"../webgl-engine/lib/VertexArrayObject.js";import{VertexAttribute as l}from"../webgl-engine/lib/VertexAttribute.js";import{BufferObject as b}from"../../webgl/BufferObject.js";import{PixelFormat as g,PixelType as _,TextureWrapMode as j,TextureSamplingMode as x,PrimitiveType as A,Usage as d}from"../../webgl/enums.js";import{Texture as w}from"../../webgl/Texture.js";import{vertexCount as y}from"../../webgl/Util.js";class T{constructor(e,t){this.type=s.Panoramic,this._configuration=new a,this._passParameters=new i,this._configuration.geometry=m.Cylinder,this._technique=t.techniqueRepository.acquire(o,this._configuration);const r=t.renderContext.rctx;this._vao=this._createVertexArrayObject(r),this._vaoCount=y(this._vao,"geometry"),this._passParameters.texture=new w(r,{pixelFormat:g.RGBA,dataType:_.UNSIGNED_BYTE,wrapMode:j.CLAMP_TO_EDGE,samplingMode:x.LINEAR,flipped:!0,width:1,height:512},n)}destroy(){this._passParameters.texture=e(this._passParameters.texture),this._vao.dispose(),this._technique.release()}render(e){const t=e.rctx,r=t.bindTechnique(this._technique,this._passParameters,e.bindParameters);v(P,e.bindParameters.camera.viewMatrix),r.setUniformMatrix4fv("view",P),t.bindVAO(this._vao),r.assertCompatibleVertexAttributeLocations(this._vao),t.drawArrays(A.TRIANGLES,0,this._vaoCount)}renderHaze(){return!1}_createVertexArrayObject(e){const t=f(1,2,!1),r=t.indices[0][1],s=t.vertexAttributes[0][1];for(let m=0;m<r.length;m+=3){const e=r[m];r[m]=r[m+2],r[m+2]=e}const i=s.data,o=S.createBuffer(r.length),a=o.position;for(let m=0;m<r.length;++m){const e=3*r[m];a.set(m,0,i[e]),a.set(m,1,i[e+1]),a.set(m,2,i[e+2])}return new h(e,u,{geometry:p(S)},{geometry:b.createVertex(e,d.STATIC_DRAW,o.buffer)})}}function v(e,r){t(e,r),e[12]=0,e[13]=0,e[14]=0,e[15]=1}const P=r(),S=c().vec3f(l.POSITION);export{T as PanoramicAtmosphere};