@esotericsoftware/spine-core 4.2.93 → 4.2.95
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AssetManagerBase.d.ts +5 -2
- package/dist/AssetManagerBase.js +36 -7
- package/dist/SkeletonBinary.d.ts +1 -1
- package/dist/Utils.d.ts +1 -1
- package/dist/esm/spine-core.min.mjs +2 -2
- package/dist/esm/spine-core.mjs +33 -6
- package/dist/esm/spine-core.mjs.map +2 -2
- package/dist/iife/spine-core.js +33 -6
- package/dist/iife/spine-core.js.map +2 -2
- package/dist/iife/spine-core.min.js +2 -2
- package/package.json +1 -1
package/dist/iife/spine-core.js
CHANGED
|
@@ -5784,7 +5784,7 @@ var spine = (() => {
|
|
|
5784
5784
|
return blob ? createImageBitmap(blob, { premultiplyAlpha: "none", colorSpaceConversion: "none" }) : null;
|
|
5785
5785
|
}).then((bitmap) => {
|
|
5786
5786
|
if (bitmap) {
|
|
5787
|
-
const texture = this.
|
|
5787
|
+
const texture = this.createTexture(path, bitmap);
|
|
5788
5788
|
this.success(success, path, texture);
|
|
5789
5789
|
resolve(texture);
|
|
5790
5790
|
}
|
|
@@ -5794,7 +5794,7 @@ var spine = (() => {
|
|
|
5794
5794
|
let image = new Image();
|
|
5795
5795
|
image.crossOrigin = "anonymous";
|
|
5796
5796
|
image.onload = () => {
|
|
5797
|
-
const texture = this.
|
|
5797
|
+
const texture = this.createTexture(path, image);
|
|
5798
5798
|
this.success(success, path, texture);
|
|
5799
5799
|
resolve(texture);
|
|
5800
5800
|
};
|
|
@@ -5818,7 +5818,7 @@ var spine = (() => {
|
|
|
5818
5818
|
this.cache.assetsLoaded[path] = new Promise((resolve, reject) => {
|
|
5819
5819
|
this.downloader.downloadText(path, (atlasText) => {
|
|
5820
5820
|
try {
|
|
5821
|
-
|
|
5821
|
+
const atlas = this.createTextureAtlas(path, atlasText);
|
|
5822
5822
|
let toLoad = atlas.pages.length, abort = false;
|
|
5823
5823
|
for (let page of atlas.pages) {
|
|
5824
5824
|
this.loadTexture(
|
|
@@ -5862,7 +5862,7 @@ var spine = (() => {
|
|
|
5862
5862
|
this.cache.assetsLoaded[path] = new Promise((resolve, reject) => {
|
|
5863
5863
|
this.downloader.downloadText(path, (atlasText) => {
|
|
5864
5864
|
try {
|
|
5865
|
-
const atlas =
|
|
5865
|
+
const atlas = this.createTextureAtlas(path, atlasText);
|
|
5866
5866
|
this.success(success, path, atlas);
|
|
5867
5867
|
resolve(atlas);
|
|
5868
5868
|
} catch (e) {
|
|
@@ -5968,9 +5968,12 @@ var spine = (() => {
|
|
|
5968
5968
|
}
|
|
5969
5969
|
// dispose asset only if it's not used by others
|
|
5970
5970
|
disposeAsset(path) {
|
|
5971
|
-
|
|
5972
|
-
|
|
5971
|
+
const asset = this.cache.assets[path];
|
|
5972
|
+
if (asset instanceof TextureAtlas) {
|
|
5973
|
+
asset.dispose();
|
|
5974
|
+
return;
|
|
5973
5975
|
}
|
|
5976
|
+
this.disposeAssetInternal(path);
|
|
5974
5977
|
}
|
|
5975
5978
|
hasErrors() {
|
|
5976
5979
|
return Object.keys(this.errors).length > 0;
|
|
@@ -5978,6 +5981,30 @@ var spine = (() => {
|
|
|
5978
5981
|
getErrors() {
|
|
5979
5982
|
return this.errors;
|
|
5980
5983
|
}
|
|
5984
|
+
disposeAssetInternal(path) {
|
|
5985
|
+
if (this.cache.assetsRefCount[path] > 0 && --this.cache.assetsRefCount[path] === 0) {
|
|
5986
|
+
return this.remove(path);
|
|
5987
|
+
}
|
|
5988
|
+
}
|
|
5989
|
+
createTextureAtlas(path, atlasText) {
|
|
5990
|
+
const atlas = new TextureAtlas(atlasText);
|
|
5991
|
+
atlas.dispose = () => {
|
|
5992
|
+
if (this.cache.assetsRefCount[path] <= 0) return;
|
|
5993
|
+
this.disposeAssetInternal(path);
|
|
5994
|
+
for (const page of atlas.pages) {
|
|
5995
|
+
page.texture?.dispose();
|
|
5996
|
+
}
|
|
5997
|
+
};
|
|
5998
|
+
return atlas;
|
|
5999
|
+
}
|
|
6000
|
+
createTexture(path, image) {
|
|
6001
|
+
const texture = this.textureLoader(image);
|
|
6002
|
+
const textureDispose = texture.dispose.bind(texture);
|
|
6003
|
+
texture.dispose = () => {
|
|
6004
|
+
if (this.disposeAssetInternal(path)) textureDispose();
|
|
6005
|
+
};
|
|
6006
|
+
return texture;
|
|
6007
|
+
}
|
|
5981
6008
|
};
|
|
5982
6009
|
var AssetCache = class _AssetCache {
|
|
5983
6010
|
assets = {};
|