1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, '__esModule', { value: true });
|
4 |
|
5 | var runner = require('@pixi/runner');
|
6 |
|
7 | class Resource {
|
8 | constructor(width = 0, height = 0) {
|
9 | this._width = width;
|
10 | this._height = height;
|
11 | this.destroyed = false;
|
12 | this.internal = false;
|
13 | this.onResize = new runner.Runner("setRealSize");
|
14 | this.onUpdate = new runner.Runner("update");
|
15 | this.onError = new runner.Runner("onError");
|
16 | }
|
17 | bind(baseTexture) {
|
18 | this.onResize.add(baseTexture);
|
19 | this.onUpdate.add(baseTexture);
|
20 | this.onError.add(baseTexture);
|
21 | if (this._width || this._height) {
|
22 | this.onResize.emit(this._width, this._height);
|
23 | }
|
24 | }
|
25 | unbind(baseTexture) {
|
26 | this.onResize.remove(baseTexture);
|
27 | this.onUpdate.remove(baseTexture);
|
28 | this.onError.remove(baseTexture);
|
29 | }
|
30 | resize(width, height) {
|
31 | if (width !== this._width || height !== this._height) {
|
32 | this._width = width;
|
33 | this._height = height;
|
34 | this.onResize.emit(width, height);
|
35 | }
|
36 | }
|
37 | get valid() {
|
38 | return !!this._width && !!this._height;
|
39 | }
|
40 | update() {
|
41 | if (!this.destroyed) {
|
42 | this.onUpdate.emit();
|
43 | }
|
44 | }
|
45 | load() {
|
46 | return Promise.resolve(this);
|
47 | }
|
48 | get width() {
|
49 | return this._width;
|
50 | }
|
51 | get height() {
|
52 | return this._height;
|
53 | }
|
54 | style(_renderer, _baseTexture, _glTexture) {
|
55 | return false;
|
56 | }
|
57 | dispose() {
|
58 | }
|
59 | destroy() {
|
60 | if (!this.destroyed) {
|
61 | this.destroyed = true;
|
62 | this.dispose();
|
63 | this.onError.removeAll();
|
64 | this.onError = null;
|
65 | this.onResize.removeAll();
|
66 | this.onResize = null;
|
67 | this.onUpdate.removeAll();
|
68 | this.onUpdate = null;
|
69 | }
|
70 | }
|
71 | static test(_source, _extension) {
|
72 | return false;
|
73 | }
|
74 | }
|
75 |
|
76 | exports.Resource = Resource;
|
77 |
|