import { LoadGLTF } from "../../assets/functions/LoadGLTF"; export default class GLTFCache { cache: Map; constructor() { this.cache = new Map(); } get(url, options) { const absoluteURL = new URL(url, (window as any).location).href; if (this.cache.has(absoluteURL)) { return this.cache.get(absoluteURL); } else { const loadPromise = LoadGLTF(url); this.cache.set(absoluteURL, loadPromise); loadPromise.catch(e => { this.cache.delete(absoluteURL); }); return loadPromise; } } disposeAndClear() { this.cache.clear(); } }