UNPKG

2.45 kBTypeScriptView Raw
1import { BaseTexture } from '../BaseTexture';
2import { Resource } from './Resource';
3import type { ISize } from '@pixi/math';
4import type { IAutoDetectOptions } from './autoDetectResource';
5/**
6 * Resource that can manage several resource (items) inside.
7 * All resources need to have the same pixel size.
8 * Parent class for CubeResource and ArrayResource
9 * @memberof PIXI
10 */
11export declare abstract class AbstractMultiResource extends Resource {
12 /** Number of elements in array. */
13 readonly length: number;
14 /**
15 * Collection of partial baseTextures that correspond to resources.
16 * @readonly
17 */
18 items: Array<BaseTexture>;
19 /**
20 * Dirty IDs for each part.
21 * @readonly
22 */
23 itemDirtyIds: Array<number>;
24 /**
25 * Promise when loading.
26 * @default null
27 */
28 private _load;
29 /** Bound baseTexture, there can only be one. */
30 baseTexture: BaseTexture;
31 /**
32 * @param length
33 * @param options - Options to for Resource constructor
34 * @param {number} [options.width] - Width of the resource
35 * @param {number} [options.height] - Height of the resource
36 */
37 constructor(length: number, options?: ISize);
38 /**
39 * Used from ArrayResource and CubeResource constructors.
40 * @param resources - Can be resources, image elements, canvas, etc. ,
41 * length should be same as constructor length
42 * @param options - Detect options for resources
43 */
44 protected initFromArray(resources: Array<any>, options?: IAutoDetectOptions): void;
45 /** Destroy this BaseImageResource. */
46 dispose(): void;
47 /**
48 * Set a baseTexture by ID
49 * @param baseTexture
50 * @param index - Zero-based index of resource to set
51 * @returns - Instance for chaining
52 */
53 abstract addBaseTextureAt(baseTexture: BaseTexture, index: number): this;
54 /**
55 * Set a resource by ID
56 * @param resource
57 * @param index - Zero-based index of resource to set
58 * @returns - Instance for chaining
59 */
60 addResourceAt(resource: Resource, index: number): this;
61 /**
62 * Set the parent base texture.
63 * @param baseTexture
64 */
65 bind(baseTexture: BaseTexture): void;
66 /**
67 * Unset the parent base texture.
68 * @param baseTexture
69 */
70 unbind(baseTexture: BaseTexture): void;
71 /**
72 * Load all the resources simultaneously
73 * @returns - When load is resolved
74 */
75 load(): Promise<this>;
76}