/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import{disposeMaybe as r}from"../../../core/maybe.js";import{subclass as s}from"../../../core/accessorSupport/decorators.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import{equals as i,copy as n}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{N as c}from"../../../chunks/NoiseTextureAtlas.glsl.js";import{NoiseTextureAtlasTechniqueConfiguration as m}from"./NoiseTextureAtlasConfiguration.js";import{atlasSize as a}from"./NoiseTextureAtlasDimensions.js";import{NoiseTextureAtlasTechnique as h}from"./NoiseTextureAtlasTechnique.js";import{FramebufferObject as p}from"../../webgl/FramebufferObject.js";import{TextureDescriptor as u}from"../../webgl/TextureDescriptor.js";let x=class extends t{constructor(e){super(e),this._needsRender=!0,this._passParameters=new c,this._configuration=new m,this._fbo=new p(e.context.renderContext.rctx,new u(a)),e.context.techniques.precompile(h,new m);const t=new m;t.mode=1,e.context.techniques.precompile(h,t)}get textureAtlas(){if(this._texture&&!this._needsRender)return this._texture;this._configuration.mode=this._texture?1:0;const e=this.context.techniques.get(h,this._configuration);return e.compiled&&(this._texture=this._render(e)),this._texture}updateWeatherMap(e){i(this._passParameters.weatherTile,e)||(n(this._passParameters.weatherTile,e),this._needsRender=!0)}destroy(){this._fbo=r(this._fbo)}_render(e){if(!this._fbo)return null;const t=this.context.renderContext.rctx,r=t.getViewport();return t.setViewport(0,0,a,a),t.bindFramebuffer(this._fbo),t.bindTechnique(e,this.context.renderContext.bind,this._passParameters),t.screen.draw(),t.setViewport(r.x,r.y,r.width,r.height),this._needsRender=!1,this._fbo.colorTexture}};e([o({constructOnly:!0})],x.prototype,"context",void 0),x=e([s("esri.views.3d.environment.NoiseTextureAtlas")],x);export{x as NoiseTextureAtlas};
