@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 1.82 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.19/LICENSE.txt */
import{getOrCreateMapValue as e}from"../../../../../core/MapUtils.js";import{DataType as t}from"../../../../webgl/enums.js";class s{constructor(e,t,s=0){this._rctx=e,this._techniques=t,this._sorting=s,this._draws=new Array,this._previouslyBoundDraw=new Map}submitDraw(e,t,s,r,n,a){const o=(s.indexed?s.vao.indexBuffer.indexType:null)??0,h=new i(e,t,s,r,n,o,a);this._draws.push(h)}acquire(t,s){const i=new Map;return this._draws.map(r=>e(i,r.material,()=>r.material.acquireTechnique(this._techniques,t,s,r.geometry.parameters)))}dispatch(e,t,s){const i=this._rctx;this._previouslyBoundDraw.clear();let n=null;const a=this._draws.length,o=t.highlight?.name;for(let h=0;h<a;h++){const a=this._draws[h];if(2===e.identifier){const e=a.highlightName;if(e){if(e!==o)continue}else if(!o||!t.overlay?.hasHighlight(o))continue}const d=s[h];d===n&&0===t.oitPass||(i.bindTechnique(d,t,e),n=d);const{geometryRanges:u,indexType:c,geometry:l,drawParameters:m}=a;i.bindVAO(l.vao),this._previouslyBoundDraw.get(d)!==m&&(d.program.bindDraw(t,e,m),this._previouslyBoundDraw.set(d,m));const g=u.length,{primitiveType:p}=l;for(let e=0;e<g;e+=2){const t=u[e],s=u[e+1];if(0!==c){const e=r.get(c);i.drawElements(p,s,c,t*e)}else i.drawArrays(p,t,s)}}}prepareSubmit(){this._draws.length=0}finishSubmit(){const e=0===this._sorting?1:-1;this._draws.sort((t,s)=>e*(t.depthSquaredHint-s.depthSquaredHint)||t.geometry.vao.usedMemory-s.geometry.vao.usedMemory)}get count(){return this._draws.length}}class i{constructor(e,t,s,i,r,n,a){this.material=e,this.drawParameters=t,this.geometry=s,this.geometryRanges=i,this.depthSquaredHint=r,this.indexType=n,this.highlightName=a}}const r=new Map;r.set(t.UNSIGNED_BYTE,1),r.set(t.UNSIGNED_SHORT,2),r.set(t.UNSIGNED_INT,4);export{s as RenderPass};