@esotericsoftware/spine-webgl 4.2.93 → 4.2.94
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/iife/spine-webgl.js
CHANGED
|
@@ -5827,7 +5827,7 @@ var spine = (() => {
|
|
|
5827
5827
|
return blob ? createImageBitmap(blob, { premultiplyAlpha: "none", colorSpaceConversion: "none" }) : null;
|
|
5828
5828
|
}).then((bitmap) => {
|
|
5829
5829
|
if (bitmap) {
|
|
5830
|
-
const texture = this.
|
|
5830
|
+
const texture = this.createTexture(path, bitmap);
|
|
5831
5831
|
this.success(success, path, texture);
|
|
5832
5832
|
resolve(texture);
|
|
5833
5833
|
}
|
|
@@ -5837,7 +5837,7 @@ var spine = (() => {
|
|
|
5837
5837
|
let image = new Image();
|
|
5838
5838
|
image.crossOrigin = "anonymous";
|
|
5839
5839
|
image.onload = () => {
|
|
5840
|
-
const texture = this.
|
|
5840
|
+
const texture = this.createTexture(path, image);
|
|
5841
5841
|
this.success(success, path, texture);
|
|
5842
5842
|
resolve(texture);
|
|
5843
5843
|
};
|
|
@@ -5861,7 +5861,7 @@ var spine = (() => {
|
|
|
5861
5861
|
this.cache.assetsLoaded[path] = new Promise((resolve, reject) => {
|
|
5862
5862
|
this.downloader.downloadText(path, (atlasText) => {
|
|
5863
5863
|
try {
|
|
5864
|
-
|
|
5864
|
+
const atlas = this.createTextureAtlas(path, atlasText);
|
|
5865
5865
|
let toLoad = atlas.pages.length, abort = false;
|
|
5866
5866
|
for (let page of atlas.pages) {
|
|
5867
5867
|
this.loadTexture(
|
|
@@ -5905,7 +5905,7 @@ var spine = (() => {
|
|
|
5905
5905
|
this.cache.assetsLoaded[path] = new Promise((resolve, reject) => {
|
|
5906
5906
|
this.downloader.downloadText(path, (atlasText) => {
|
|
5907
5907
|
try {
|
|
5908
|
-
const atlas =
|
|
5908
|
+
const atlas = this.createTextureAtlas(path, atlasText);
|
|
5909
5909
|
this.success(success, path, atlas);
|
|
5910
5910
|
resolve(atlas);
|
|
5911
5911
|
} catch (e) {
|
|
@@ -6011,9 +6011,12 @@ var spine = (() => {
|
|
|
6011
6011
|
}
|
|
6012
6012
|
// dispose asset only if it's not used by others
|
|
6013
6013
|
disposeAsset(path) {
|
|
6014
|
-
|
|
6015
|
-
|
|
6014
|
+
const asset = this.cache.assets[path];
|
|
6015
|
+
if (asset instanceof TextureAtlas) {
|
|
6016
|
+
asset.dispose();
|
|
6017
|
+
return;
|
|
6016
6018
|
}
|
|
6019
|
+
this.disposeAssetInternal(path);
|
|
6017
6020
|
}
|
|
6018
6021
|
hasErrors() {
|
|
6019
6022
|
return Object.keys(this.errors).length > 0;
|
|
@@ -6021,6 +6024,30 @@ var spine = (() => {
|
|
|
6021
6024
|
getErrors() {
|
|
6022
6025
|
return this.errors;
|
|
6023
6026
|
}
|
|
6027
|
+
disposeAssetInternal(path) {
|
|
6028
|
+
if (this.cache.assetsRefCount[path] > 0 && --this.cache.assetsRefCount[path] === 0) {
|
|
6029
|
+
return this.remove(path);
|
|
6030
|
+
}
|
|
6031
|
+
}
|
|
6032
|
+
createTextureAtlas(path, atlasText) {
|
|
6033
|
+
const atlas = new TextureAtlas(atlasText);
|
|
6034
|
+
atlas.dispose = () => {
|
|
6035
|
+
if (this.cache.assetsRefCount[path] <= 0) return;
|
|
6036
|
+
this.disposeAssetInternal(path);
|
|
6037
|
+
for (const page of atlas.pages) {
|
|
6038
|
+
page.texture?.dispose();
|
|
6039
|
+
}
|
|
6040
|
+
};
|
|
6041
|
+
return atlas;
|
|
6042
|
+
}
|
|
6043
|
+
createTexture(path, image) {
|
|
6044
|
+
const texture = this.textureLoader(image);
|
|
6045
|
+
const textureDispose = texture.dispose.bind(texture);
|
|
6046
|
+
texture.dispose = () => {
|
|
6047
|
+
if (this.disposeAssetInternal(path)) textureDispose();
|
|
6048
|
+
};
|
|
6049
|
+
return texture;
|
|
6050
|
+
}
|
|
6024
6051
|
};
|
|
6025
6052
|
var AssetCache = class _AssetCache {
|
|
6026
6053
|
assets = {};
|