convex-pixel
Version:
The library for creating pseudo 3d interactive scenes based on webgl
37 lines • 1.13 kB
JavaScript
import * as PIXI from "pixi.js";
export class ResourceManager {
constructor(resources) {
if (ResourceManager._instance) {
return;
// throw new Error("The resource manager already created. (singletone)");
}
ResourceManager._instance = this;
ResourceManager._resources = resources;
}
static get resources() {
return this._resources;
}
static getResource(name) {
if (!this._resources)
return null;
const res = this._resources[name];
if (res) {
if (res.diffuseMap) {
res.diffuseMapTexture = PIXI.Texture.from(res.diffuseMap);
}
if (res.depthMap) {
res.depthMapTexture = PIXI.Texture.from(res.depthMap);
}
return res;
}
return null;
}
dispose() {
ResourceManager._resources = undefined;
ResourceManager._instance = undefined;
}
get resources() {
return ResourceManager.resources;
}
}
//# sourceMappingURL=resource-manager.js.map