UNPKG

@animech-public/playcanvas

Version:
2 lines (1 loc) 571 B
import{LIGHTTYPE_OMNI as t}from"../constants.js";import{ShadowMap as e}from"./shadow-map.js";class c{constructor(){this.cache=new Map}destroy(){this.clear(),this.cache=null}clear(){this.cache.forEach((t=>{t.forEach((t=>{t.destroy()}))})),this.cache.clear()}getKey(e){return`${e._type===t}-${e._shadowType}-${e._shadowResolution}`}get(t,c){const s=this.getKey(c),h=this.cache.get(s);if(h&&h.length)return h.pop();const a=e.create(t,c);return a.cached=!0,a}add(t,e){const c=this.getKey(t),s=this.cache.get(c);s?s.push(e):this.cache.set(c,[e])}}export{c as ShadowMapCache};