@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 868 B
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
*/
import{createProgramTemplate as r}from"./shaders/MaterialPrograms.js";class e{constructor(r){this._rctx=r,this._programByKey=new Map}dispose(){this._programByKey.forEach((r=>r.dispose())),this._programByKey.clear()}getProgram(e,t=[]){const a=e.vsPath+"."+e.fsPath+JSON.stringify(t);if(this._programByKey.has(a))return this._programByKey.get(a);const s={...t.map((r=>"string"==typeof r?{name:r,value:!0}:r)).reduce(((r,e)=>({...r,[e.name]:e.value})),{})},{vsPath:o,fsPath:h,attributes:i}=e,g=r(o,h,i,s),m=this._rctx.programCache.acquire(g.shaders.vertexShader,g.shaders.fragmentShader,g.attributes);if(!m)throw new Error("Unable to get program for key: ${key}");return this._programByKey.set(a,m),m}}export{e as default};