mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 17:56:04 +08:00
[ts][webcomponents] Avoid recreating texture when image is passed through cache.
This commit is contained in:
parent
2e5a099ef4
commit
40685bb6c6
@ -142,13 +142,13 @@ export class AssetManagerBase implements Disposable {
|
|||||||
const loadedStatus = this.cache.assetsLoaded[path];
|
const loadedStatus = this.cache.assetsLoaded[path];
|
||||||
const alreadyExistsOrLoading = loadedStatus !== undefined;
|
const alreadyExistsOrLoading = loadedStatus !== undefined;
|
||||||
if (alreadyExistsOrLoading) {
|
if (alreadyExistsOrLoading) {
|
||||||
loadedStatus
|
this.cache.assetsLoaded[path] = loadedStatus
|
||||||
.then(data => {
|
.then(data => {
|
||||||
if (data instanceof Image) {
|
// necessary when user preloads an image into the cache.
|
||||||
data = this.textureLoader(data);
|
// texture loader is not avaiable in the cache, so we transform in GLTexture at first use
|
||||||
this.cache.assetsLoaded[path] = Promise.resolve(data);
|
data = (data instanceof Image || data instanceof ImageBitmap) ? this.textureLoader(data) : data;
|
||||||
}
|
this.success(success, path, data);
|
||||||
return this.success(success, path, data)
|
return data;
|
||||||
})
|
})
|
||||||
.catch(errorMsg => this.error(error, path, errorMsg));
|
.catch(errorMsg => this.error(error, path, errorMsg));
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user