@esotericsoftware/spine-phaser-v3 4.2.92 → 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/esm/spine-phaser-v3.min.mjs +3 -3
- package/dist/esm/spine-phaser-v3.mjs +41 -14
- package/dist/esm/spine-phaser-v3.mjs.map +2 -2
- package/dist/iife/spine-phaser-v3.js +41 -14
- package/dist/iife/spine-phaser-v3.js.map +2 -2
- package/dist/iife/spine-phaser-v3.min.js +2 -2
- package/package.json +4 -4
|
@@ -5874,7 +5874,7 @@ var spine = (() => {
|
|
|
5874
5874
|
return blob ? createImageBitmap(blob, { premultiplyAlpha: "none", colorSpaceConversion: "none" }) : null;
|
|
5875
5875
|
}).then((bitmap) => {
|
|
5876
5876
|
if (bitmap) {
|
|
5877
|
-
const texture = this.
|
|
5877
|
+
const texture = this.createTexture(path, bitmap);
|
|
5878
5878
|
this.success(success, path, texture);
|
|
5879
5879
|
resolve(texture);
|
|
5880
5880
|
}
|
|
@@ -5884,7 +5884,7 @@ var spine = (() => {
|
|
|
5884
5884
|
let image = new Image();
|
|
5885
5885
|
image.crossOrigin = "anonymous";
|
|
5886
5886
|
image.onload = () => {
|
|
5887
|
-
const texture = this.
|
|
5887
|
+
const texture = this.createTexture(path, image);
|
|
5888
5888
|
this.success(success, path, texture);
|
|
5889
5889
|
resolve(texture);
|
|
5890
5890
|
};
|
|
@@ -5908,7 +5908,7 @@ var spine = (() => {
|
|
|
5908
5908
|
this.cache.assetsLoaded[path] = new Promise((resolve, reject) => {
|
|
5909
5909
|
this.downloader.downloadText(path, (atlasText) => {
|
|
5910
5910
|
try {
|
|
5911
|
-
|
|
5911
|
+
const atlas = this.createTextureAtlas(path, atlasText);
|
|
5912
5912
|
let toLoad = atlas.pages.length, abort = false;
|
|
5913
5913
|
for (let page of atlas.pages) {
|
|
5914
5914
|
this.loadTexture(
|
|
@@ -5952,7 +5952,7 @@ var spine = (() => {
|
|
|
5952
5952
|
this.cache.assetsLoaded[path] = new Promise((resolve, reject) => {
|
|
5953
5953
|
this.downloader.downloadText(path, (atlasText) => {
|
|
5954
5954
|
try {
|
|
5955
|
-
const atlas =
|
|
5955
|
+
const atlas = this.createTextureAtlas(path, atlasText);
|
|
5956
5956
|
this.success(success, path, atlas);
|
|
5957
5957
|
resolve(atlas);
|
|
5958
5958
|
} catch (e) {
|
|
@@ -6058,9 +6058,12 @@ var spine = (() => {
|
|
|
6058
6058
|
}
|
|
6059
6059
|
// dispose asset only if it's not used by others
|
|
6060
6060
|
disposeAsset(path) {
|
|
6061
|
-
|
|
6062
|
-
|
|
6061
|
+
const asset = this.cache.assets[path];
|
|
6062
|
+
if (asset instanceof TextureAtlas) {
|
|
6063
|
+
asset.dispose();
|
|
6064
|
+
return;
|
|
6063
6065
|
}
|
|
6066
|
+
this.disposeAssetInternal(path);
|
|
6064
6067
|
}
|
|
6065
6068
|
hasErrors() {
|
|
6066
6069
|
return Object.keys(this.errors).length > 0;
|
|
@@ -6068,6 +6071,30 @@ var spine = (() => {
|
|
|
6068
6071
|
getErrors() {
|
|
6069
6072
|
return this.errors;
|
|
6070
6073
|
}
|
|
6074
|
+
disposeAssetInternal(path) {
|
|
6075
|
+
if (this.cache.assetsRefCount[path] > 0 && --this.cache.assetsRefCount[path] === 0) {
|
|
6076
|
+
return this.remove(path);
|
|
6077
|
+
}
|
|
6078
|
+
}
|
|
6079
|
+
createTextureAtlas(path, atlasText) {
|
|
6080
|
+
const atlas = new TextureAtlas(atlasText);
|
|
6081
|
+
atlas.dispose = () => {
|
|
6082
|
+
if (this.cache.assetsRefCount[path] <= 0) return;
|
|
6083
|
+
this.disposeAssetInternal(path);
|
|
6084
|
+
for (const page of atlas.pages) {
|
|
6085
|
+
page.texture?.dispose();
|
|
6086
|
+
}
|
|
6087
|
+
};
|
|
6088
|
+
return atlas;
|
|
6089
|
+
}
|
|
6090
|
+
createTexture(path, image) {
|
|
6091
|
+
const texture = this.textureLoader(image);
|
|
6092
|
+
const textureDispose = texture.dispose.bind(texture);
|
|
6093
|
+
texture.dispose = () => {
|
|
6094
|
+
if (this.disposeAssetInternal(path)) textureDispose();
|
|
6095
|
+
};
|
|
6096
|
+
return texture;
|
|
6097
|
+
}
|
|
6071
6098
|
};
|
|
6072
6099
|
var AssetCache = class _AssetCache {
|
|
6073
6100
|
assets = {};
|
|
@@ -11760,10 +11787,10 @@ var spine = (() => {
|
|
|
11760
11787
|
var ManagedWebGLRenderingContext = class {
|
|
11761
11788
|
canvas;
|
|
11762
11789
|
gl;
|
|
11763
|
-
restorables =
|
|
11764
|
-
constructor(canvasOrContext, contextConfig = { alpha:
|
|
11790
|
+
restorables = [];
|
|
11791
|
+
constructor(canvasOrContext, contextConfig = { alpha: true }) {
|
|
11765
11792
|
if (!(canvasOrContext instanceof WebGLRenderingContext || typeof WebGL2RenderingContext !== "undefined" && canvasOrContext instanceof WebGL2RenderingContext)) {
|
|
11766
|
-
|
|
11793
|
+
const canvas = canvasOrContext;
|
|
11767
11794
|
this.gl = canvas.getContext("webgl2", contextConfig) || canvas.getContext("webgl", contextConfig);
|
|
11768
11795
|
this.canvas = canvas;
|
|
11769
11796
|
canvas.addEventListener("webglcontextlost", this.contextLostHandler);
|
|
@@ -11773,13 +11800,13 @@ var spine = (() => {
|
|
|
11773
11800
|
this.canvas = this.gl.canvas;
|
|
11774
11801
|
}
|
|
11775
11802
|
}
|
|
11776
|
-
contextLostHandler(e) {
|
|
11803
|
+
contextLostHandler = (e) => {
|
|
11777
11804
|
if (e) e.preventDefault();
|
|
11778
|
-
}
|
|
11779
|
-
contextRestoredHandler(
|
|
11805
|
+
};
|
|
11806
|
+
contextRestoredHandler = () => {
|
|
11780
11807
|
for (let i = 0, n = this.restorables.length; i < n; i++)
|
|
11781
11808
|
this.restorables[i].restore();
|
|
11782
|
-
}
|
|
11809
|
+
};
|
|
11783
11810
|
dispose() {
|
|
11784
11811
|
this.canvas.removeEventListener("webglcontextlost", this.contextLostHandler);
|
|
11785
11812
|
this.canvas.removeEventListener("webglcontextrestored", this.contextRestoredHandler);
|
|
@@ -11788,7 +11815,7 @@ var spine = (() => {
|
|
|
11788
11815
|
this.restorables.push(restorable);
|
|
11789
11816
|
}
|
|
11790
11817
|
removeRestorable(restorable) {
|
|
11791
|
-
|
|
11818
|
+
const index = this.restorables.indexOf(restorable);
|
|
11792
11819
|
if (index > -1) this.restorables.splice(index, 1);
|
|
11793
11820
|
}
|
|
11794
11821
|
};
|