UNPKG

@arcgis/core

Version:

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

3 lines (2 loc) 2.83 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.19/LICENSE.txt */ import{__decorate as e}from"tslib";import r from"../../../../../core/PooledArray.js";import{property as t,subclass as s}from"../../../../../core/accessorSupport/decorators.js";import{ZEROS as n}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{InternalRenderCategory as i}from"../../../webgl.js";import o from"../../../webgl/RenderNode.js";import{Blit as c}from"../blit/Blit.js";import{DepthStencilAttachment as d}from"../../../../webgl/enums.js";let l=class extends o{constructor(e){super(e),this.consumes={required:[i.OCCLUDED]},this.produces=i.OCCLUDED,this._blit=new c(e.view.stage.renderView.techniques,2)}precompile(){const e=this.view.stage.renderer;e.plugins.plugins.forEach(r=>{e.precompileSlots(r,10,12),r.material&&e.precompileOccludedSlots(r,p)})}render(e){const r=e.find(({name:e})=>e===this.produces);return this._renderOccludedAndTransparentStencil(r),this._renderOccludedComposite(r),r}_renderOccludedAndTransparentStencil(e){const r=this.view.stage.renderer,t=a;this._acquirePlugins(t,8),0!==t.length&&(r.renderSlots(t,11),this._renderAndComposite(e,e.getAttachment(d),.5,()=>r.renderSlots(t,12),!1,!1),t.clear())}_renderOccludedComposite(e){const r=this.view.stage.renderer,t=a,s=this._acquirePlugins(t,u);if(0===t.length)return;const n=this._getDepthStencilAttachment(e);let i=n.clearStencil;for(const o of p)s&o&&(this._renderAndComposite(e,n.depth,16===o?1:.5,()=>r.renderOccludedSlots(t,o),!0,i),i=!1);n.release(),t.clear()}_acquirePlugins(e,r){const t=this.view.stage.renderer;e.clear();let s=0,n=!1;for(const i of t.plugins.plugins){const t=i.renderOccludedFlags&r;s|=t,t&&(e.push(i),n||=0!==i.testsTransparentRenderOrder)}return n&&e.sort((e,r)=>e.testsTransparentRenderOrder-r.testsTransparentRenderOrder),s}_renderAndComposite(e,r,t,s,i,o){const c=this.renderingContext,{width:d,height:l}=e.fbo,a=this.fboCache.acquire(d,l,"tmp color");a.attachDepth(r),c.bindFramebuffer(a.fbo),c.clearFramebuffer(n,i,o),s(),a.detachDepth(),this._blit.blend(c,a,e,this.bindParameters,t),a.release()}_getDepthStencilAttachment(e){const{width:r,height:t}=e.fbo;if(!this.view.stage.renderer.occludedRequiresIntegratedMeshStencil){const e=this.fboCache.acquireDepth(14,r,t,"retained stencil");return{depth:e,release:()=>e.release(),clearStencil:!0}}const s=this.fboCache.acquire(r,t,"retained stencil",14);return this.renderingContext.blitFramebuffer(e.fbo,s.fbo,1024),{depth:s.getAttachment(d),release:()=>s.release(),clearStencil:!1}}};e([t()],l.prototype,"consumes",void 0),e([t()],l.prototype,"produces",void 0),l=e([s("esri.views.3d.webgl-engine.effects.geometry.RenderOccludedRenderNode")],l);const a=new r;function h(){a.prune()}const p=[4,2,16],u=p.reduce((e,r)=>e|r,0);export{l as RenderOccludedRenderNode,h as cleanupRenderOccluded};