@doegis/core
Version:
DOE GIS API
3 lines (1 loc) • 3.29 kB
JavaScript
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import{isSome as r,releaseMaybe as s,disposeMaybe as i,isNone as h}from"../../../core/maybe.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import{c as n}from"../../../chunks/vec2.js";import{N as c}from"../../../chunks/NoiseTextureAtlas.glsl.js";import{NoiseTextureRenderMode as u,NoiseTextureAtlasTechniqueConfiguration as p}from"./NoiseTextureAtlasConfiguration.js";import{ATLAS_SIZE as l}from"./NoiseTextureAtlasDimensions.js";import{NoiseTextureAtlasTechnique as _}from"./NoiseTextureAtlasTechnique.js";import{createQuadVAO as m}from"../webgl-engine/lib/glUtil3D.js";import{TargetType as f,TextureType as d,PixelFormat as T,PixelType as w,TextureWrapMode as q,TextureSamplingMode as x}from"../../webgl/enums.js";import{FramebufferObject as g}from"../../webgl/FramebufferObject.js";let y=class extends t{constructor(e){super(e),this._needsRender=!0,this._passParameters=new c,this._frameBuffer=new g(e.context.renderContext.rctx,{colorTarget:f.TEXTURE,width:l,height:l},{target:d.TEXTURE_2D,pixelFormat:T.RGBA,dataType:w.UNSIGNED_BYTE,wrapMode:q.CLAMP_TO_EDGE,samplingMode:x.LINEAR,hasMipmap:!1,width:l,height:l}),this._vao=m(e.context.renderContext.rctx)}get _techniqueRepository(){return this.context.techniqueRepository}get textureAtlas(){return r(this._texture)?r(this._weatherMapTechnique)&&this._weatherMapTechnique.compiled&&this._needsRender&&(this._texture=this._render(u.WeatherMap)):r(this._fullTechnique)&&this._fullTechnique.compiled&&(this._texture=this._render(u.Full)),this._texture}_setDirty(){this._needsRender=!0}updateWeatherMap(e){this._passParameters.weatherTile[0]===e[0]&&this._passParameters.weatherTile[1]===e[1]||(n(this._passParameters.weatherTile,e),this._setDirty())}destroy(){this._fullTechniqueCached=s(this._fullTechniqueCached),this._weatherMapTechniqueCached=s(this._weatherMapTechniqueCached),this._frameBuffer=i(this._frameBuffer),this._vao=i(this._vao)}get _fullTechnique(){if(h(this._fullTechniqueCached)){const e=new p;e.mode=u.Full,this._fullTechniqueCached=this._techniqueRepository.acquire(_,e)}return this._fullTechniqueCached}get _weatherMapTechnique(){if(h(this._weatherMapTechniqueCached)){const e=new p;e.mode=u.WeatherMap,this._weatherMapTechniqueCached=this._techniqueRepository.acquire(_,e)}return this._weatherMapTechniqueCached}_render(e){if(h(this._vao)||h(this._frameBuffer))return null;const t=e===u.Full?this._fullTechnique:this._weatherMapTechnique,r=this.context.renderContext.rctx,s=r.getViewport();r.setViewport(0,0,l,l),r.bindFramebuffer(this._frameBuffer);const i=r.bindTechnique(t,this._passParameters,null);return r.bindVAO(this._vao),i.assertCompatibleVertexAttributeLocations(this._vao),r.gl.drawArrays(r.gl.TRIANGLE_STRIP,0,4),r.setViewport(s.x,s.y,s.width,s.height),this._needsRender=!1,this._frameBuffer.colorTexture}};e([o({constructOnly:!0})],y.prototype,"context",void 0),e([o({readOnly:!0})],y.prototype,"_techniqueRepository",null),y=e([a("esri.views.3d.environment.NoiseTextureAtlas")],y);export{y as NoiseTextureAtlas};