UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 4.86 kB
import{_ as t}from"../../../../chunks/tslib.es6.js";import{releaseMaybe as e,disposeMaybe as r,isSome as a}from"../../../../core/maybe.js";import{watch as i}from"../../../../core/reactiveUtils.js";import{property as s}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import{subclass as o}from"../../../../core/accessorSupport/decorators/subclass.js";import{ViewingMode as h}from"../../../ViewingMode.js";import{createQuadVAO as n}from"./glUtil3D.js";import{SortedRenderGeometryRenderer as p}from"./SortedRenderGeometryRenderer.js";import{HeatmapPassParameters as m,HeatmapTechniqueConfiguration as l,HeatmapTechnique as c}from"../shaders/HeatmapTechnique.js";import{TargetType as d,DepthStencilTargetType as u,TextureType as y,TextureWrapMode as _,PixelFormat as g,PixelType as R,TextureSamplingMode as x,ClearBufferBit as f}from"../../../webgl/enums.js";import{FramebufferObject as D}from"../../../webgl/FramebufferObject.js";import{Texture as T}from"../../../webgl/Texture.js";import{vertexCount as w}from"../../../webgl/Util.js";let b=class extends p{constructor(t){super(t),this.pixelRatio=1,this._colorRampData=new Uint8ClampedArray(4),this.type="draped-heatmap",this._heatmapParameters=new m}initialize(){const t={colorTarget:d.TEXTURE,depthStencilTarget:u.NONE,width:0,height:0},e={target:y.TEXTURE_2D,pixelFormat:this.pixelFormat,internalFormat:this.internalFormat,dataType:this.dataType,samplingMode:this.samplingMode,wrapMode:_.CLAMP_TO_EDGE,width:0,height:0};this._densityMap=new D(this.rctx,t,e),this._quad=n(this.rctx);const r=this._colorRampData,a={target:y.TEXTURE_2D,pixelFormat:g.RGBA,dataType:R.UNSIGNED_BYTE,samplingMode:x.LINEAR,wrapMode:_.CLAMP_TO_EDGE,width:r.length/4,height:1};this._colorRamp=new T(this.rctx,a,r);const s=new l;s.usesHalfFloat=this.dataType!==R.FLOAT,this._technique=new c({rctx:this.rctx,viewingMode:h.Local},s),this._heatmapParameters.densityMap=this._densityMap.colorTexture,this.addHandles(i((()=>[this.colorRampData,this.minDensity,this.maxDensity,this.fieldTotal,this.pixelRatio,this.searchRadius]),(()=>this.rendererContext.notifyContentChanged())))}destroy(){this._technique=e(this._technique),this._densityMap=r(this._densityMap),this._quad=r(this._quad),this._colorRamp=r(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(a(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 rendersOccluded(){return!1}render(t){const e=this._sortedMaterialRenderers;if(e.length<1)return;const r=this.rctx.getBoundFramebufferObject(),a=this.rctx.getViewport(),i=t.bindParameters,{pixelRatio:s}=this,o=Math.ceil(a.width*s),h=Math.ceil(a.height*s);this._densityMap.resize(o,h),this.rctx.bindFramebuffer(this._densityMap),this.rctx.setViewport(0,0,o,h),this.rctx.clear(f.COLOR_BUFFER_BIT);let n=!1;e.forAll((e=>{e.material.shouldRender(t)&&(n=e.render(t.output,i)||n)})),this.rctx.bindFramebuffer(r),this.rctx.setViewport(a.x,a.y,a.width,a.height),n&&(this.rctx.bindVAO(this._quad),this.rctx.bindTechnique(this._technique,this._heatmapParameters,t.bindParameters),this.rctx.drawArrays(this._technique.primitiveType,0,w(this._quad,"geometry")))}};t([s()],b.prototype,"searchRadius",null),t([s()],b.prototype,"minDensity",null),t([s()],b.prototype,"maxDensity",null),t([s()],b.prototype,"fieldTotal",null),t([s()],b.prototype,"pixelRatio",void 0),t([s()],b.prototype,"colorRampData",null),t([s({constructOnly:!0})],b.prototype,"dataType",void 0),t([s({constructOnly:!0})],b.prototype,"samplingMode",void 0),t([s({constructOnly:!0})],b.prototype,"pixelFormat",void 0),t([s({constructOnly:!0})],b.prototype,"internalFormat",void 0),t([s()],b.prototype,"_colorRampData",void 0),b=t([o("esri.views.3d.webgl-engine.lib.DrapedHeatmapRenderer")],b);export{b as DrapedHeatmapRenderer};