UNPKG

@pixi/core

Version:
78 lines (73 loc) 1.78 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var runner = require('@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.Runner("setRealSize"); this.onUpdate = new runner.Runner("update"); this.onError = new runner.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; } } exports.Resource = Resource; //# sourceMappingURL=Resource.js.map