/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{__decorate as t}from"tslib";import{disposeMaybe as e}from"../../../../core/maybe.js";import{watch as s}from"../../../../core/reactiveUtils.js";import{property as r,subclass as i}from"../../../../core/accessorSupport/decorators.js";import{createQuadVAO as a}from"./glUtil3D.js";import{SortedRenderGeometryRenderer as o}from"./SortedRenderGeometryRenderer.js";import{HeatmapPassParameters as n,HeatmapTechnique as p}from"../shaders/HeatmapTechnique.js";import{HeatmapTechniqueConfiguration as h}from"../shaders/HeatmapTechniqueConfiguration.js";import{PixelType as m}from"../../../webgl/enums.js";import{DisposableFramebufferObject as l}from"../../../webgl/FramebufferObject.js";import c from"../../../webgl/Texture.js";import{TextureDescriptor as d}from"../../../webgl/TextureDescriptor.js";let u=class extends o{constructor(t){super(t),this.pixelRatio=1,this._colorRampData=new Uint8ClampedArray(4),this.type="draped-heatmap",this._passParameters=new n,this._configuration=new h;const e=new d;e.pixelFormat=t.pixelFormat,e.internalFormat=t.internalFormat,e.dataType=t.dataType,e.samplingMode=t.samplingMode,e.wrapMode=33071;const s=t.rendererContext.rctx;this._densityMap=new l(s,e),this._vao=a(s),this._configuration.usesHalfFloat=t.dataType!==m.FLOAT,t.rendererContext.pluginContext.techniques.precompile(p,this._configuration)}initialize(){const t=this._colorRampData,e=new d(t.length/4,1);e.wrapMode=33071,this._colorRamp=new c(this.rctx,e,t),this._passParameters.densityMap=this._densityMap.colorTexture,this.addHandles(s(()=>[this.colorRampData,this.minDensity,this.maxDensity,this.fieldTotal,this.pixelRatio,this.searchRadius],()=>this.rendererContext.notifyContentChanged()))}destroy(){this._densityMap=e(this._densityMap),this._vao=e(this._vao),this._colorRamp=e(this._colorRamp)}get searchRadius(){return this._passParameters.searchRadius}set searchRadius(t){t!==this._passParameters.searchRadius&&(this._passParameters.searchRadius=t,this.notifyChange("searchRadius"))}get minDensity(){return this._passParameters.minDensity}set minDensity(t){t!==this._passParameters.minDensity&&(this._passParameters.minDensity=t,this.notifyChange("minDensity"))}get maxDensity(){return this._passParameters.maxDensity}set maxDensity(t){t!==this._passParameters.maxDensity&&(this._passParameters.maxDensity=t,this.notifyChange("maxDensity"))}get fieldTotal(){return this._passParameters.fieldTotal}set fieldTotal(t){this._passParameters.fieldTotal=t,this.notifyChange("fieldTotal")}get colorRampData(){return this._colorRampData}set colorRampData(t){const{colorRamp:e}=this._passParameters;if(null!=e&&t!==this._colorRampData){const s=e.descriptor.width,r=t.length/4;r!==s&&e.resize(r,1),e.setData(t)}this._colorRampData=t}get _colorRamp(){return this._passParameters.colorRamp}set _colorRamp(t){this._passParameters.colorRamp=t}get hasHighlights(){return!1}get hasWater(){return!1}render(t){const e=this.sortedRenderers;if(0===e.length)return;const s=this.rctx.boundFramebuffer,r=this.rctx.getViewport(),{pixelRatio:i}=this,a=Math.ceil(r.width*i),o=Math.ceil(r.height*i);this._densityMap.resize(a,o),this.rctx.bindFramebuffer(this._densityMap),this.rctx.setViewport(0,0,a,o),this.rctx.clear(16384);let n=!1;if(e.forAll(e=>{const s=e.acquireTechniques(t);s&&(e.render(t,s),n=!0)}),this.rctx.bindFramebuffer(s),this.rctx.setViewport(r.x,r.y,r.width,r.height),!n)return;this.rctx.bindVAO(this._vao);const h=this.rendererContext.pluginContext.techniques.get(p,this._configuration);this.rctx.bindTechnique(h,t.bind,this._passParameters),this.rctx.drawArrays(h.primitiveType,0,this._vao.vertexCount("geometry"))}};t([r()],u.prototype,"searchRadius",null),t([r()],u.prototype,"minDensity",null),t([r()],u.prototype,"maxDensity",null),t([r()],u.prototype,"fieldTotal",null),t([r()],u.prototype,"pixelRatio",void 0),t([r()],u.prototype,"colorRampData",null),t([r({constructOnly:!0})],u.prototype,"dataType",void 0),t([r({constructOnly:!0})],u.prototype,"samplingMode",void 0),t([r({constructOnly:!0})],u.prototype,"pixelFormat",void 0),t([r({constructOnly:!0})],u.prototype,"internalFormat",void 0),t([r()],u.prototype,"_colorRampData",void 0),u=t([i("esri.views.3d.webgl-engine.lib.DrapedHeatmapRenderer")],u);export{u as DrapedHeatmapRenderer};
