UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 918 B
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import{MemCachePool as e}from"../../../../../core/MemCachePool.js";import{VertexArrayObject as t}from"../../lib/VertexArrayObject.js";import{BufferObject as r}from"../../../../webgl/BufferObject.js";import{Usage as o}from"../../../../webgl/enums.js";class s{constructor(t,r,o){this._rctx=t,this._locations=r,this._layout=o,this._cache=new e(t.newCache,"VAOCache")}dispose(){this._cache.destroy()}newVao(e){const s=e.toString();let c=this._cache.pop(s);return c||(c=new t(this._rctx,this._locations,new Map([["geometry",this._layout]]),new Map([["geometry",r.createVertex(this._rctx,o.STATIC_DRAW)]])),c.vertexBuffers.get("geometry")?.setSize(e),c)}deleteVao(e){if(null==e)return;const t=e.getByteLength("geometry").toString();this._cache.put(t,e)}}export{s as VaoCache};