UNPKG

@pixi/core

Version:
74 lines (71 loc) 1.68 kB
import { Runner } from '@pixi/runner'; class Resource { constructor(width = 0, height = 0) { this._width = width; this._height = height; this.destroyed = false; this.internal = false; this.onResize = new Runner("setRealSize"); this.onUpdate = new Runner("update"); this.onError = new Runner("onError"); } bind(baseTexture) { this.onResize.add(baseTexture); this.onUpdate.add(baseTexture); this.onError.add(baseTexture); if (this._width || this._height) { this.onResize.emit(this._width, this._height); } } unbind(baseTexture) { this.onResize.remove(baseTexture); this.onUpdate.remove(baseTexture); this.onError.remove(baseTexture); } resize(width, height) { if (width !== this._width || height !== this._height) { this._width = width; this._height = height; this.onResize.emit(width, height); } } get valid() { return !!this._width && !!this._height; } update() { if (!this.destroyed) { this.onUpdate.emit(); } } load() { return Promise.resolve(this); } get width() { return this._width; } get height() { return this._height; } style(_renderer, _baseTexture, _glTexture) { return false; } dispose() { } destroy() { if (!this.destroyed) { this.destroyed = true; this.dispose(); this.onError.removeAll(); this.onError = null; this.onResize.removeAll(); this.onResize = null; this.onUpdate.removeAll(); this.onUpdate = null; } } static test(_source, _extension) { return false; } } export { Resource }; //# sourceMappingURL=Resource.mjs.map