@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 3.26 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */
import{removeUnordered as e}from"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{sort as t}from"../../../../core/heapSort.js";import{isPromiseLike as r,createAbortError as s}from"../../../../core/promiseUtils.js";import{signal as n}from"../../../../core/signal.js";import{DepthRange as o}from"../lib/DepthRange.js";class i{constructor(e){this.context=e,this._renderPlugins=new Array,this._slots=new Array,this._version=n(0);for(let t=0;t<23;++t)this._slots[t]=[]}destroy(){this._renderPlugins.forEach(e=>e.destroy()),this._renderPlugins.length=0}get plugins(){return this._renderPlugins}add(e,t){const n=()=>{if(t?.aborted)throw e.uninitializeRenderContext(),s();this._renderPlugins.push(e),e.produces.forEach((t,r)=>this._slots[r].push(e)),this.context.requestRender(),this._version.value++},o=e.initializeRenderContext(this.context,t);if(r(o))return o.then(n);n()}remove(t){e(this._renderPlugins,t),t.uninitializeRenderContext();for(let e=0;e<this._slots.length;++e)this._slots[e]=this._slots[e].filter(e=>e!==t);this.context.requestRender(),this._version.value++}sortTestsTransparentOrderedSlots(e){if("test"!==process.env.NODE_ENV)return;if(this._renderPlugins.some(e=>0!==e.testsTransparentRenderOrder))for(const r of e){const e=this._slots[r];t(e,0,e.length,(e,t)=>(e.testsTransparentRenderOrder??0)-(t.testsTransparentRenderOrder??0))}}prepareRender(){this._renderPlugins.forEach(e=>{e.prepareRender&&e.prepareRender(this.context.renderContext)})}updateAnimation(e){let t=!1;return this._renderPlugins.forEach(r=>t=r.updateAnimation?.(e)||t),t}precompile(...e){++this.context.techniques.precompiling;const t=this.context.renderContext.bind.slot;for(const r of e)this.context.renderContext.bind.slot=r,this._forEachRender(()=>{});this.context.renderContext.bind.slot=t,--this.context.techniques.precompiling}render(...e){for(const t of e)this.context.renderContext.bind.slot=t,this._forEachRender((e,t)=>e.render(this.context.renderContext,t))}_forEachRender(e){const t=this.context.renderContext.bind.slot,r=this.context.renderContext.output;this._slots[t].forEach(s=>{const n=s.produces.get(t);if(!n?.(r)||s.isDecoration&&!this.context.renderContext.bind.decorations)return;const o=s.acquireTechniques(this.context.renderContext);o&&e(s,o)})}queryDepthRange(e){return this._renderPlugins.reduce((t,r)=>t.union(r.queryDepthRange?.(e)),new o)}get updating(){return this._version.value>=0&&this._renderPlugins.some(e=>e.readyToRun)}produces(e,...t){return t.some(t=>this._slots[t].some(r=>{const s=r.produces.get(t);return!!s&&s(e)}))}consumes(e){return this._renderPlugins.some(t=>t.consumes().required.includes(e))}hasHighlight(e){return d.some(t=>this._slots[t].some(t=>t.hasHighlight(e)))}get hasDecorations(){return this._renderPlugins.some(e=>e.isDecoration)}get hasOccludees(){return this._renderPlugins.some(e=>e.hasOccludees)}get hasEmitters(){return this._renderPlugins.some(e=>e.hasEmitters)}get renderOccludedFlags(){return this._renderPlugins.reduce((e,t)=>e|(t.renderOccludedFlags??0),0)}get usedMemory(){return this._renderPlugins.reduce((e,t)=>t.material?e:e+(t.usedMemory??0),0)}get test(){}}const d=[2,4,20,14,15,16];export{i as RenderPluginManager};