@esotericsoftware/spine-phaser-v3 4.2.83 → 4.2.85
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 +8 -8
- package/dist/esm/spine-phaser-v3.mjs +51 -27
- package/dist/esm/spine-phaser-v3.mjs.map +2 -2
- package/dist/iife/spine-phaser-v3.js +51 -27
- package/dist/iife/spine-phaser-v3.js.map +2 -2
- package/dist/iife/spine-phaser-v3.min.js +8 -8
- package/package.json +4 -4
|
@@ -4802,7 +4802,7 @@ var MeshAttachment = class _MeshAttachment extends VertexAttachment {
|
|
|
4802
4802
|
this.copyTo(copy);
|
|
4803
4803
|
copy.regionUVs = new Array(this.regionUVs.length);
|
|
4804
4804
|
Utils.arrayCopy(this.regionUVs, 0, copy.regionUVs, 0, this.regionUVs.length);
|
|
4805
|
-
copy.uvs = new Array(this.uvs.length);
|
|
4805
|
+
copy.uvs = this.uvs instanceof Float32Array ? Utils.newFloatArray(this.uvs.length) : new Array(this.uvs.length);
|
|
4806
4806
|
Utils.arrayCopy(this.uvs, 0, copy.uvs, 0, this.uvs.length);
|
|
4807
4807
|
copy.triangles = new Array(this.triangles.length);
|
|
4808
4808
|
Utils.arrayCopy(this.triangles, 0, copy.triangles, 0, this.triangles.length);
|
|
@@ -5543,16 +5543,15 @@ var AssetManagerBase = class {
|
|
|
5543
5543
|
pathPrefix = "";
|
|
5544
5544
|
textureLoader;
|
|
5545
5545
|
downloader;
|
|
5546
|
-
|
|
5547
|
-
assetsRefCount = {};
|
|
5548
|
-
assetsLoaded = {};
|
|
5546
|
+
cache;
|
|
5549
5547
|
errors = {};
|
|
5550
5548
|
toLoad = 0;
|
|
5551
5549
|
loaded = 0;
|
|
5552
|
-
constructor(textureLoader, pathPrefix = "", downloader = new Downloader()) {
|
|
5550
|
+
constructor(textureLoader, pathPrefix = "", downloader = new Downloader(), cache = new AssetCache()) {
|
|
5553
5551
|
this.textureLoader = textureLoader;
|
|
5554
5552
|
this.pathPrefix = pathPrefix;
|
|
5555
5553
|
this.downloader = downloader;
|
|
5554
|
+
this.cache = cache;
|
|
5556
5555
|
}
|
|
5557
5556
|
start(path) {
|
|
5558
5557
|
this.toLoad++;
|
|
@@ -5561,8 +5560,8 @@ var AssetManagerBase = class {
|
|
|
5561
5560
|
success(callback, path, asset) {
|
|
5562
5561
|
this.toLoad--;
|
|
5563
5562
|
this.loaded++;
|
|
5564
|
-
this.assets[path] = asset;
|
|
5565
|
-
this.assetsRefCount[path] = (this.assetsRefCount[path] || 0) + 1;
|
|
5563
|
+
this.cache.assets[path] = asset;
|
|
5564
|
+
this.cache.assetsRefCount[path] = (this.cache.assetsRefCount[path] || 0) + 1;
|
|
5566
5565
|
if (callback) callback(path, asset);
|
|
5567
5566
|
}
|
|
5568
5567
|
error(callback, path, message) {
|
|
@@ -5593,7 +5592,7 @@ var AssetManagerBase = class {
|
|
|
5593
5592
|
}) {
|
|
5594
5593
|
path = this.start(path);
|
|
5595
5594
|
if (this.reuseAssets(path, success, error)) return;
|
|
5596
|
-
this.assetsLoaded[path] = new Promise((resolve, reject) => {
|
|
5595
|
+
this.cache.assetsLoaded[path] = new Promise((resolve, reject) => {
|
|
5597
5596
|
this.downloader.downloadBinary(path, (data) => {
|
|
5598
5597
|
this.success(success, path, data);
|
|
5599
5598
|
resolve(data);
|
|
@@ -5619,7 +5618,7 @@ var AssetManagerBase = class {
|
|
|
5619
5618
|
}) {
|
|
5620
5619
|
path = this.start(path);
|
|
5621
5620
|
if (this.reuseAssets(path, success, error)) return;
|
|
5622
|
-
this.assetsLoaded[path] = new Promise((resolve, reject) => {
|
|
5621
|
+
this.cache.assetsLoaded[path] = new Promise((resolve, reject) => {
|
|
5623
5622
|
this.downloader.downloadJson(path, (data) => {
|
|
5624
5623
|
this.success(success, path, data);
|
|
5625
5624
|
resolve(data);
|
|
@@ -5633,10 +5632,14 @@ var AssetManagerBase = class {
|
|
|
5633
5632
|
reuseAssets(path, success = () => {
|
|
5634
5633
|
}, error = () => {
|
|
5635
5634
|
}) {
|
|
5636
|
-
const loadedStatus = this.assetsLoaded[path];
|
|
5635
|
+
const loadedStatus = this.cache.assetsLoaded[path];
|
|
5637
5636
|
const alreadyExistsOrLoading = loadedStatus !== void 0;
|
|
5638
5637
|
if (alreadyExistsOrLoading) {
|
|
5639
|
-
|
|
5638
|
+
this.cache.assetsLoaded[path] = loadedStatus.then((data) => {
|
|
5639
|
+
data = data instanceof Image || data instanceof ImageBitmap ? this.textureLoader(data) : data;
|
|
5640
|
+
this.success(success, path, data);
|
|
5641
|
+
return data;
|
|
5642
|
+
}).catch((errorMsg) => this.error(error, path, errorMsg));
|
|
5640
5643
|
}
|
|
5641
5644
|
return alreadyExistsOrLoading;
|
|
5642
5645
|
}
|
|
@@ -5645,7 +5648,7 @@ var AssetManagerBase = class {
|
|
|
5645
5648
|
}) {
|
|
5646
5649
|
path = this.start(path);
|
|
5647
5650
|
if (this.reuseAssets(path, success, error)) return;
|
|
5648
|
-
this.assetsLoaded[path] = new Promise((resolve, reject) => {
|
|
5651
|
+
this.cache.assetsLoaded[path] = new Promise((resolve, reject) => {
|
|
5649
5652
|
let isBrowser = !!(typeof window !== "undefined" && typeof navigator !== "undefined" && window.document);
|
|
5650
5653
|
let isWebWorker = !isBrowser;
|
|
5651
5654
|
if (isWebWorker) {
|
|
@@ -5689,7 +5692,7 @@ var AssetManagerBase = class {
|
|
|
5689
5692
|
let parent = index >= 0 ? path.substring(0, index + 1) : "";
|
|
5690
5693
|
path = this.start(path);
|
|
5691
5694
|
if (this.reuseAssets(path, success, error)) return;
|
|
5692
|
-
this.assetsLoaded[path] = new Promise((resolve, reject) => {
|
|
5695
|
+
this.cache.assetsLoaded[path] = new Promise((resolve, reject) => {
|
|
5693
5696
|
this.downloader.downloadText(path, (atlasText) => {
|
|
5694
5697
|
try {
|
|
5695
5698
|
let atlas = new TextureAtlas(atlasText);
|
|
@@ -5708,7 +5711,7 @@ var AssetManagerBase = class {
|
|
|
5708
5711
|
},
|
|
5709
5712
|
(imagePath, message) => {
|
|
5710
5713
|
if (!abort) {
|
|
5711
|
-
const errorMsg = `Couldn't load texture
|
|
5714
|
+
const errorMsg = `Couldn't load texture ${path} page image: ${imagePath}`;
|
|
5712
5715
|
this.error(error, path, errorMsg);
|
|
5713
5716
|
reject(errorMsg);
|
|
5714
5717
|
}
|
|
@@ -5733,7 +5736,7 @@ var AssetManagerBase = class {
|
|
|
5733
5736
|
}, fileAlias) {
|
|
5734
5737
|
path = this.start(path);
|
|
5735
5738
|
if (this.reuseAssets(path, success, error)) return;
|
|
5736
|
-
this.assetsLoaded[path] = new Promise((resolve, reject) => {
|
|
5739
|
+
this.cache.assetsLoaded[path] = new Promise((resolve, reject) => {
|
|
5737
5740
|
this.downloader.downloadText(path, (atlasText) => {
|
|
5738
5741
|
try {
|
|
5739
5742
|
const atlas = new TextureAtlas(atlasText);
|
|
@@ -5797,33 +5800,36 @@ var AssetManagerBase = class {
|
|
|
5797
5800
|
);
|
|
5798
5801
|
});
|
|
5799
5802
|
}
|
|
5803
|
+
setCache(cache) {
|
|
5804
|
+
this.cache = cache;
|
|
5805
|
+
}
|
|
5800
5806
|
get(path) {
|
|
5801
|
-
return this.assets[this.pathPrefix + path];
|
|
5807
|
+
return this.cache.assets[this.pathPrefix + path];
|
|
5802
5808
|
}
|
|
5803
5809
|
require(path) {
|
|
5804
5810
|
path = this.pathPrefix + path;
|
|
5805
|
-
let asset = this.assets[path];
|
|
5811
|
+
let asset = this.cache.assets[path];
|
|
5806
5812
|
if (asset) return asset;
|
|
5807
5813
|
let error = this.errors[path];
|
|
5808
5814
|
throw Error("Asset not found: " + path + (error ? "\n" + error : ""));
|
|
5809
5815
|
}
|
|
5810
5816
|
remove(path) {
|
|
5811
5817
|
path = this.pathPrefix + path;
|
|
5812
|
-
let asset = this.assets[path];
|
|
5818
|
+
let asset = this.cache.assets[path];
|
|
5813
5819
|
if (asset.dispose) asset.dispose();
|
|
5814
|
-
delete this.assets[path];
|
|
5815
|
-
delete this.assetsRefCount[path];
|
|
5816
|
-
delete this.assetsLoaded[path];
|
|
5820
|
+
delete this.cache.assets[path];
|
|
5821
|
+
delete this.cache.assetsRefCount[path];
|
|
5822
|
+
delete this.cache.assetsLoaded[path];
|
|
5817
5823
|
return asset;
|
|
5818
5824
|
}
|
|
5819
5825
|
removeAll() {
|
|
5820
|
-
for (let path in this.assets) {
|
|
5821
|
-
let asset = this.assets[path];
|
|
5826
|
+
for (let path in this.cache.assets) {
|
|
5827
|
+
let asset = this.cache.assets[path];
|
|
5822
5828
|
if (asset.dispose) asset.dispose();
|
|
5823
5829
|
}
|
|
5824
|
-
this.assets = {};
|
|
5825
|
-
this.assetsLoaded = {};
|
|
5826
|
-
this.assetsRefCount = {};
|
|
5830
|
+
this.cache.assets = {};
|
|
5831
|
+
this.cache.assetsLoaded = {};
|
|
5832
|
+
this.cache.assetsRefCount = {};
|
|
5827
5833
|
}
|
|
5828
5834
|
isLoadingComplete() {
|
|
5829
5835
|
return this.toLoad == 0;
|
|
@@ -5839,7 +5845,7 @@ var AssetManagerBase = class {
|
|
|
5839
5845
|
}
|
|
5840
5846
|
// dispose asset only if it's not used by others
|
|
5841
5847
|
disposeAsset(path) {
|
|
5842
|
-
if (--this.assetsRefCount[path] === 0) {
|
|
5848
|
+
if (--this.cache.assetsRefCount[path] === 0) {
|
|
5843
5849
|
this.remove(path);
|
|
5844
5850
|
}
|
|
5845
5851
|
}
|
|
@@ -5850,6 +5856,23 @@ var AssetManagerBase = class {
|
|
|
5850
5856
|
return this.errors;
|
|
5851
5857
|
}
|
|
5852
5858
|
};
|
|
5859
|
+
var AssetCache = class _AssetCache {
|
|
5860
|
+
assets = {};
|
|
5861
|
+
assetsRefCount = {};
|
|
5862
|
+
assetsLoaded = {};
|
|
5863
|
+
static AVAILABLE_CACHES = /* @__PURE__ */ new Map();
|
|
5864
|
+
static getCache(id) {
|
|
5865
|
+
const cache = _AssetCache.AVAILABLE_CACHES.get(id);
|
|
5866
|
+
if (cache) return cache;
|
|
5867
|
+
const newCache = new _AssetCache();
|
|
5868
|
+
_AssetCache.AVAILABLE_CACHES.set(id, newCache);
|
|
5869
|
+
return newCache;
|
|
5870
|
+
}
|
|
5871
|
+
async addAsset(path, asset) {
|
|
5872
|
+
this.assetsLoaded[path] = Promise.resolve(asset);
|
|
5873
|
+
this.assets[path] = await asset;
|
|
5874
|
+
}
|
|
5875
|
+
};
|
|
5853
5876
|
var Downloader = class {
|
|
5854
5877
|
callbacks = {};
|
|
5855
5878
|
rawDataUris = {};
|
|
@@ -14747,6 +14770,7 @@ export {
|
|
|
14747
14770
|
AnimationState,
|
|
14748
14771
|
AnimationStateAdapter,
|
|
14749
14772
|
AnimationStateData,
|
|
14773
|
+
AssetCache,
|
|
14750
14774
|
AssetManager,
|
|
14751
14775
|
AssetManagerBase,
|
|
14752
14776
|
AtlasAttachmentLoader,
|