forked from Bitcoindefi/OpenAO
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtextureCaches.ts
More file actions
29 lines (25 loc) · 863 Bytes
/
Copy pathtextureCaches.ts
File metadata and controls
29 lines (25 loc) · 863 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import type { Texture } from "pixi.js";
export type SharedTextureCaches = {
baseTextureCache: Map<string, Texture>;
pendingAssetLoads: Map<string, Promise<Texture>>;
textureCache: Map<string, Texture>;
animatedTextureCache: Map<string, Texture[]>;
};
export function destroySharedTextureCaches(caches: SharedTextureCaches): void {
for (const texture of caches.textureCache.values()) {
if (!texture.destroyed) {
texture.destroy(false);
}
}
for (const textures of caches.animatedTextureCache.values()) {
for (const texture of textures) {
if (!texture.destroyed) {
texture.destroy(false);
}
}
}
caches.textureCache.clear();
caches.animatedTextureCache.clear();
caches.baseTextureCache.clear();
caches.pendingAssetLoads.clear();
}