UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

6 lines (5 loc) 4.81 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import{_ as t}from"../../../../chunks/tslib.es6.js";import{disposeMaybe as e}from"../../../../core/maybe.js";import{watch as r}from"../../../../core/reactiveUtils.js";import{property as a}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as i}from"../../../../core/accessorSupport/decorators/subclass.js";import{createQuadVAO as s}from"./glUtil3D.js";import{SortedRenderGeometryRenderer as o}from"./SortedRenderGeometryRenderer.js";import{HeatmapPassParameters as n,HeatmapTechnique as h}from"../shaders/HeatmapTechnique.js";import{HeatmapTechniqueConfiguration as p}from"../shaders/HeatmapTechniqueConfiguration.js";import{TextureWrapMode as m,PixelType as c,FramebufferBit as l}from"../../../webgl/enums.js";import{FramebufferObject as d}from"../../../webgl/FramebufferObject.js";import{Texture as u}from"../../../webgl/Texture.js";import{TextureDescriptor as y}from"../../../webgl/TextureDescriptor.js";import{vertexCount as _}from"../../../webgl/Util.js";let g=class extends o{constructor(t){super(t),this.pixelRatio=1,this._colorRampData=new Uint8ClampedArray(4),this.type="draped-heatmap",this._heatmapParameters=new n,this._configuration=new p;const e=new y;e.pixelFormat=t.pixelFormat,e.internalFormat=t.internalFormat,e.dataType=t.dataType,e.samplingMode=t.samplingMode,e.wrapMode=m.CLAMP_TO_EDGE;const r=t.rendererContext.rctx;this._densityMap=new d(r,e),this._quad=s(r),this._configuration.usesHalfFloat=t.dataType!==c.FLOAT,t.rendererContext.pluginContext.techniques.precompile(h,this._configuration)}initialize(){const t=this._colorRampData,e=new y(t.length/4,1);e.wrapMode=m.CLAMP_TO_EDGE,this._colorRamp=new u(this.rctx,e,t),this._heatmapParameters.densityMap=this._densityMap.colorTexture,this.addHandles(r((()=>[this.colorRampData,this.minDensity,this.maxDensity,this.fieldTotal,this.pixelRatio,this.searchRadius]),(()=>this.rendererContext.notifyContentChanged())))}destroy(){this._densityMap=e(this._densityMap),this._quad=e(this._quad),this._colorRamp=e(this._colorRamp)}get searchRadius(){return this._heatmapParameters.searchRadius}set searchRadius(t){t!==this._heatmapParameters.searchRadius&&(this._heatmapParameters.searchRadius=t,this.notifyChange("searchRadius"))}get minDensity(){return this._heatmapParameters.minDensity}set minDensity(t){t!==this._heatmapParameters.minDensity&&(this._heatmapParameters.minDensity=t,this.notifyChange("minDensity"))}get maxDensity(){return this._heatmapParameters.maxDensity}set maxDensity(t){t!==this._heatmapParameters.maxDensity&&(this._heatmapParameters.maxDensity=t,this.notifyChange("maxDensity"))}get fieldTotal(){return this._heatmapParameters.fieldTotal}set fieldTotal(t){this._heatmapParameters.fieldTotal=t,this.notifyChange("fieldTotal")}get colorRampData(){return this._colorRampData}set colorRampData(t){const{colorRamp:e}=this._heatmapParameters;if(null!=e&&t!==this._colorRampData){const r=e.descriptor.width,a=t.length/4;a!==r&&e.resize(a,1),e.setData(t)}this._colorRampData=t}get _colorRamp(){return this._heatmapParameters.colorRamp}set _colorRamp(t){this._heatmapParameters.colorRamp=t}get hasHighlights(){return!1}get hasWater(){return!1}get rendersOccludedDraped(){return!1}render(t){const e=this.sortedRenderers;if(0===e.length)return;const r=this.rctx.getBoundFramebufferObject(),a=this.rctx.getViewport(),{pixelRatio:i}=this,s=Math.ceil(a.width*i),o=Math.ceil(a.height*i);this._densityMap.resize(s,o),this.rctx.bindFramebuffer(this._densityMap),this.rctx.setViewport(0,0,s,o),this.rctx.clear(l.COLOR);let n=!1;if(e.forAll((e=>{const r=e.acquireTechniques(t);r&&(e.render(t,r),n=!0)})),this.rctx.bindFramebuffer(r),this.rctx.setViewport(a.x,a.y,a.width,a.height),!n)return;this.rctx.bindVAO(this._quad);const p=this.rendererContext.pluginContext.techniques.get(h,this._configuration);this.rctx.bindTechnique(p,t.bind,this._heatmapParameters),this.rctx.drawArrays(p.primitiveType,0,_(this._quad,"geometry"))}};t([a()],g.prototype,"searchRadius",null),t([a()],g.prototype,"minDensity",null),t([a()],g.prototype,"maxDensity",null),t([a()],g.prototype,"fieldTotal",null),t([a()],g.prototype,"pixelRatio",void 0),t([a()],g.prototype,"colorRampData",null),t([a({constructOnly:!0})],g.prototype,"dataType",void 0),t([a({constructOnly:!0})],g.prototype,"samplingMode",void 0),t([a({constructOnly:!0})],g.prototype,"pixelFormat",void 0),t([a({constructOnly:!0})],g.prototype,"internalFormat",void 0),t([a()],g.prototype,"_colorRampData",void 0),g=t([i("esri.views.3d.webgl-engine.lib.DrapedHeatmapRenderer")],g);export{g as DrapedHeatmapRenderer};