UNPKG

playcanvas

Version:

Open-source WebGL/WebGPU 3D engine for the web

38 lines (35 loc) 737 B
import { EventHandler } from '../../core/event-handler.js'; class Bundle extends EventHandler { addFile(url, data) { if (this._index.has(url)) { return; } this._index.set(url, data); this.fire('add', url, data); } has(url) { return this._index.has(url); } get(url) { return this._index.get(url) || null; } destroy() { this._index.clear(); } set loaded(value) { if (!value || this._loaded) { return; } this._loaded = true; this.fire('load'); } get loaded() { return this._loaded; } constructor(...args){ super(...args), this._index = new Map(), this._loaded = false; } } Bundle.EVENT_ADD = 'add'; Bundle.EVENT_LOAD = 'load'; export { Bundle };