pixi.js 7.0.3 → 7.1.0-alpha
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/pixi.js +248 -223
- package/dist/pixi.js.map +1 -1
- package/dist/pixi.min.js +35 -35
- package/dist/pixi.min.js.map +1 -1
- package/dist/pixi.min.mjs +35 -35
- package/dist/pixi.min.mjs.map +1 -1
- package/dist/pixi.mjs +248 -224
- package/dist/pixi.mjs.map +1 -1
- package/package.json +31 -31
package/dist/pixi.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* pixi.js - v7.0
|
|
3
|
-
* Compiled
|
|
2
|
+
* pixi.js - v7.1.0-alpha
|
|
3
|
+
* Compiled Thu, 10 Nov 2022 16:24:03 UTC
|
|
4
4
|
*
|
|
5
5
|
* pixi.js is licensed under the MIT License.
|
|
6
6
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -7026,7 +7026,7 @@ Deprecated since v${version}`);
|
|
|
7026
7026
|
RenderTexturePool.SCREEN_KEY = -1;
|
|
7027
7027
|
|
|
7028
7028
|
class Attribute {
|
|
7029
|
-
constructor(buffer, size = 0, normalized = false, type = TYPES.FLOAT, stride, start, instance) {
|
|
7029
|
+
constructor(buffer, size = 0, normalized = false, type = TYPES.FLOAT, stride, start, instance, divisor = 1) {
|
|
7030
7030
|
this.buffer = buffer;
|
|
7031
7031
|
this.size = size;
|
|
7032
7032
|
this.normalized = normalized;
|
|
@@ -7034,6 +7034,7 @@ Deprecated since v${version}`);
|
|
|
7034
7034
|
this.stride = stride;
|
|
7035
7035
|
this.start = start;
|
|
7036
7036
|
this.instance = instance;
|
|
7037
|
+
this.divisor = divisor;
|
|
7037
7038
|
}
|
|
7038
7039
|
destroy() {
|
|
7039
7040
|
this.buffer = null;
|
|
@@ -8541,7 +8542,7 @@ Deprecated since v${version}`);
|
|
|
8541
8542
|
gl.vertexAttribPointer(location, attribute.size, attribute.type || gl.FLOAT, attribute.normalized, attribute.stride, attribute.start);
|
|
8542
8543
|
if (attribute.instance) {
|
|
8543
8544
|
if (this.hasInstance) {
|
|
8544
|
-
gl.vertexAttribDivisor(location,
|
|
8545
|
+
gl.vertexAttribDivisor(location, attribute.divisor);
|
|
8545
8546
|
} else {
|
|
8546
8547
|
throw new Error("geometry error, GPU Instancing is not supported on this device");
|
|
8547
8548
|
}
|
|
@@ -11367,7 +11368,7 @@ ${this.fragmentSrc}`;
|
|
|
11367
11368
|
const renderer = this.renderer;
|
|
11368
11369
|
renderer.emitWithCustomOptions(renderer.runners.init, options);
|
|
11369
11370
|
if (options.hello) {
|
|
11370
|
-
console.log(`PixiJS ${"7.0
|
|
11371
|
+
console.log(`PixiJS ${"7.1.0-alpha"} - ${renderer.rendererLogId} - https://pixijs.com`);
|
|
11371
11372
|
}
|
|
11372
11373
|
renderer.resize(this.renderer.screen.width, this.renderer.screen.height);
|
|
11373
11374
|
}
|
|
@@ -11493,7 +11494,17 @@ ${this.fragmentSrc}`;
|
|
|
11493
11494
|
projectionMatrix: new Matrix()
|
|
11494
11495
|
}, true);
|
|
11495
11496
|
const systemConfig = {
|
|
11496
|
-
runners: [
|
|
11497
|
+
runners: [
|
|
11498
|
+
"init",
|
|
11499
|
+
"destroy",
|
|
11500
|
+
"contextChange",
|
|
11501
|
+
"resolutionChange",
|
|
11502
|
+
"reset",
|
|
11503
|
+
"update",
|
|
11504
|
+
"postrender",
|
|
11505
|
+
"prerender",
|
|
11506
|
+
"resize"
|
|
11507
|
+
],
|
|
11497
11508
|
systems: _Renderer.__systems,
|
|
11498
11509
|
priority: [
|
|
11499
11510
|
"_view",
|
|
@@ -11588,6 +11599,10 @@ ${this.fragmentSrc}`;
|
|
|
11588
11599
|
get resolution() {
|
|
11589
11600
|
return this._view.resolution;
|
|
11590
11601
|
}
|
|
11602
|
+
set resolution(value) {
|
|
11603
|
+
this._view.resolution = value;
|
|
11604
|
+
this.runners.resolutionChange.emit(value);
|
|
11605
|
+
}
|
|
11591
11606
|
get autoDensity() {
|
|
11592
11607
|
return this._view.autoDensity;
|
|
11593
11608
|
}
|
|
@@ -12336,7 +12351,7 @@ ${this.fragmentSrc}`;
|
|
|
12336
12351
|
};
|
|
12337
12352
|
extensions$1.add(ObjectRendererSystem);
|
|
12338
12353
|
|
|
12339
|
-
const VERSION = "7.0
|
|
12354
|
+
const VERSION = "7.1.0-alpha";
|
|
12340
12355
|
|
|
12341
12356
|
var fragment$6 = "varying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform float uAlpha;\n\nvoid main(void)\n{\n gl_FragColor = texture2D(uSampler, vTextureCoord) * uAlpha;\n}\n";
|
|
12342
12357
|
|
|
@@ -15392,6 +15407,9 @@ ${this.fragmentSrc}`;
|
|
|
15392
15407
|
this.setTargetElement(view);
|
|
15393
15408
|
this.resolution = resolution;
|
|
15394
15409
|
}
|
|
15410
|
+
resolutionChange(resolution) {
|
|
15411
|
+
this.resolution = resolution;
|
|
15412
|
+
}
|
|
15395
15413
|
destroy() {
|
|
15396
15414
|
this.setTargetElement(null);
|
|
15397
15415
|
this.renderer = null;
|
|
@@ -16576,222 +16594,6 @@ ${e}`);
|
|
|
16576
16594
|
}
|
|
16577
16595
|
}
|
|
16578
16596
|
|
|
16579
|
-
class AssetsClass {
|
|
16580
|
-
constructor() {
|
|
16581
|
-
this._detections = [];
|
|
16582
|
-
this._initialized = false;
|
|
16583
|
-
this.resolver = new Resolver();
|
|
16584
|
-
this.loader = new Loader();
|
|
16585
|
-
this.cache = Cache;
|
|
16586
|
-
this._backgroundLoader = new BackgroundLoader(this.loader);
|
|
16587
|
-
this._backgroundLoader.active = true;
|
|
16588
|
-
this.reset();
|
|
16589
|
-
}
|
|
16590
|
-
async init(options = {}) {
|
|
16591
|
-
if (this._initialized) {
|
|
16592
|
-
return;
|
|
16593
|
-
}
|
|
16594
|
-
this._initialized = true;
|
|
16595
|
-
if (options.basePath) {
|
|
16596
|
-
this.resolver.basePath = options.basePath;
|
|
16597
|
-
}
|
|
16598
|
-
if (options.manifest) {
|
|
16599
|
-
let manifest = options.manifest;
|
|
16600
|
-
if (typeof manifest === "string") {
|
|
16601
|
-
manifest = await this.load(manifest);
|
|
16602
|
-
}
|
|
16603
|
-
this.resolver.addManifest(manifest);
|
|
16604
|
-
}
|
|
16605
|
-
const resolutionPref = options.texturePreference?.resolution ?? 1;
|
|
16606
|
-
const resolution = typeof resolutionPref === "number" ? [resolutionPref] : resolutionPref;
|
|
16607
|
-
let formats = [];
|
|
16608
|
-
if (options.texturePreference?.format) {
|
|
16609
|
-
const formatPref = options.texturePreference?.format;
|
|
16610
|
-
formats = typeof formatPref === "string" ? [formatPref] : formatPref;
|
|
16611
|
-
for (const detection of this._detections) {
|
|
16612
|
-
if (!await detection.test()) {
|
|
16613
|
-
formats = await detection.remove(formats);
|
|
16614
|
-
}
|
|
16615
|
-
}
|
|
16616
|
-
} else {
|
|
16617
|
-
for (const detection of this._detections) {
|
|
16618
|
-
if (await detection.test()) {
|
|
16619
|
-
formats = await detection.add(formats);
|
|
16620
|
-
}
|
|
16621
|
-
}
|
|
16622
|
-
}
|
|
16623
|
-
this.resolver.prefer({
|
|
16624
|
-
params: {
|
|
16625
|
-
format: formats,
|
|
16626
|
-
resolution
|
|
16627
|
-
}
|
|
16628
|
-
});
|
|
16629
|
-
}
|
|
16630
|
-
add(keysIn, assetsIn, data) {
|
|
16631
|
-
this.resolver.add(keysIn, assetsIn, data);
|
|
16632
|
-
}
|
|
16633
|
-
async load(urls, onProgress) {
|
|
16634
|
-
if (!this._initialized) {
|
|
16635
|
-
await this.init();
|
|
16636
|
-
}
|
|
16637
|
-
const singleAsset = isSingleItem(urls);
|
|
16638
|
-
const urlArray = convertToList(urls).map((url) => {
|
|
16639
|
-
if (typeof url !== "string") {
|
|
16640
|
-
this.resolver.add(url.src, url);
|
|
16641
|
-
return url.src;
|
|
16642
|
-
}
|
|
16643
|
-
return url;
|
|
16644
|
-
});
|
|
16645
|
-
const resolveResults = this.resolver.resolve(urlArray);
|
|
16646
|
-
const out = await this._mapLoadToResolve(resolveResults, onProgress);
|
|
16647
|
-
return singleAsset ? out[urlArray[0]] : out;
|
|
16648
|
-
}
|
|
16649
|
-
addBundle(bundleId, assets) {
|
|
16650
|
-
this.resolver.addBundle(bundleId, assets);
|
|
16651
|
-
}
|
|
16652
|
-
async loadBundle(bundleIds, onProgress) {
|
|
16653
|
-
if (!this._initialized) {
|
|
16654
|
-
await this.init();
|
|
16655
|
-
}
|
|
16656
|
-
let singleAsset = false;
|
|
16657
|
-
if (typeof bundleIds === "string") {
|
|
16658
|
-
singleAsset = true;
|
|
16659
|
-
bundleIds = [bundleIds];
|
|
16660
|
-
}
|
|
16661
|
-
const resolveResults = this.resolver.resolveBundle(bundleIds);
|
|
16662
|
-
const out = {};
|
|
16663
|
-
const keys = Object.keys(resolveResults);
|
|
16664
|
-
let count = 0;
|
|
16665
|
-
let total = 0;
|
|
16666
|
-
const _onProgress = () => {
|
|
16667
|
-
onProgress?.(++count / total);
|
|
16668
|
-
};
|
|
16669
|
-
const promises = keys.map((bundleId) => {
|
|
16670
|
-
const resolveResult = resolveResults[bundleId];
|
|
16671
|
-
total += Object.keys(resolveResult).length;
|
|
16672
|
-
return this._mapLoadToResolve(resolveResult, _onProgress).then((resolveResult2) => {
|
|
16673
|
-
out[bundleId] = resolveResult2;
|
|
16674
|
-
});
|
|
16675
|
-
});
|
|
16676
|
-
await Promise.all(promises);
|
|
16677
|
-
return singleAsset ? out[bundleIds[0]] : out;
|
|
16678
|
-
}
|
|
16679
|
-
async backgroundLoad(urls) {
|
|
16680
|
-
if (!this._initialized) {
|
|
16681
|
-
await this.init();
|
|
16682
|
-
}
|
|
16683
|
-
if (typeof urls === "string") {
|
|
16684
|
-
urls = [urls];
|
|
16685
|
-
}
|
|
16686
|
-
const resolveResults = this.resolver.resolve(urls);
|
|
16687
|
-
this._backgroundLoader.add(Object.values(resolveResults));
|
|
16688
|
-
}
|
|
16689
|
-
async backgroundLoadBundle(bundleIds) {
|
|
16690
|
-
if (!this._initialized) {
|
|
16691
|
-
await this.init();
|
|
16692
|
-
}
|
|
16693
|
-
if (typeof bundleIds === "string") {
|
|
16694
|
-
bundleIds = [bundleIds];
|
|
16695
|
-
}
|
|
16696
|
-
const resolveResults = this.resolver.resolveBundle(bundleIds);
|
|
16697
|
-
Object.values(resolveResults).forEach((resolveResult) => {
|
|
16698
|
-
this._backgroundLoader.add(Object.values(resolveResult));
|
|
16699
|
-
});
|
|
16700
|
-
}
|
|
16701
|
-
reset() {
|
|
16702
|
-
this.resolver.reset();
|
|
16703
|
-
this.loader.reset();
|
|
16704
|
-
this.cache.reset();
|
|
16705
|
-
this._initialized = false;
|
|
16706
|
-
}
|
|
16707
|
-
get(keys) {
|
|
16708
|
-
if (typeof keys === "string") {
|
|
16709
|
-
return Cache.get(keys);
|
|
16710
|
-
}
|
|
16711
|
-
const assets = {};
|
|
16712
|
-
for (let i = 0; i < keys.length; i++) {
|
|
16713
|
-
assets[i] = Cache.get(keys[i]);
|
|
16714
|
-
}
|
|
16715
|
-
return assets;
|
|
16716
|
-
}
|
|
16717
|
-
async _mapLoadToResolve(resolveResults, onProgress) {
|
|
16718
|
-
const resolveArray = Object.values(resolveResults);
|
|
16719
|
-
const resolveKeys = Object.keys(resolveResults);
|
|
16720
|
-
this._backgroundLoader.active = false;
|
|
16721
|
-
const loadedAssets = await this.loader.load(resolveArray, onProgress);
|
|
16722
|
-
this._backgroundLoader.active = true;
|
|
16723
|
-
const out = {};
|
|
16724
|
-
resolveArray.forEach((resolveResult, i) => {
|
|
16725
|
-
const asset = loadedAssets[resolveResult.src];
|
|
16726
|
-
const keys = [resolveResult.src];
|
|
16727
|
-
if (resolveResult.alias) {
|
|
16728
|
-
keys.push(...resolveResult.alias);
|
|
16729
|
-
}
|
|
16730
|
-
out[resolveKeys[i]] = asset;
|
|
16731
|
-
Cache.set(keys, asset);
|
|
16732
|
-
});
|
|
16733
|
-
return out;
|
|
16734
|
-
}
|
|
16735
|
-
async unload(urls) {
|
|
16736
|
-
if (!this._initialized) {
|
|
16737
|
-
await this.init();
|
|
16738
|
-
}
|
|
16739
|
-
const urlArray = convertToList(urls).map((url) => typeof url !== "string" ? url.src : url);
|
|
16740
|
-
const resolveResults = this.resolver.resolve(urlArray);
|
|
16741
|
-
await this._unloadFromResolved(resolveResults);
|
|
16742
|
-
}
|
|
16743
|
-
async unloadBundle(bundleIds) {
|
|
16744
|
-
if (!this._initialized) {
|
|
16745
|
-
await this.init();
|
|
16746
|
-
}
|
|
16747
|
-
bundleIds = convertToList(bundleIds);
|
|
16748
|
-
const resolveResults = this.resolver.resolveBundle(bundleIds);
|
|
16749
|
-
const promises = Object.keys(resolveResults).map((bundleId) => this._unloadFromResolved(resolveResults[bundleId]));
|
|
16750
|
-
await Promise.all(promises);
|
|
16751
|
-
}
|
|
16752
|
-
async _unloadFromResolved(resolveResult) {
|
|
16753
|
-
const resolveArray = Object.values(resolveResult);
|
|
16754
|
-
resolveArray.forEach((resolveResult2) => {
|
|
16755
|
-
Cache.remove(resolveResult2.src);
|
|
16756
|
-
});
|
|
16757
|
-
await this.loader.unload(resolveArray);
|
|
16758
|
-
}
|
|
16759
|
-
get detections() {
|
|
16760
|
-
return this._detections;
|
|
16761
|
-
}
|
|
16762
|
-
}
|
|
16763
|
-
const Assets = new AssetsClass();
|
|
16764
|
-
extensions$1.handleByList(ExtensionType.LoadParser, Assets.loader.parsers).handleByList(ExtensionType.ResolveParser, Assets.resolver.parsers).handleByList(ExtensionType.CacheParser, Assets.cache.parsers).handleByList(ExtensionType.DetectionParser, Assets.detections);
|
|
16765
|
-
|
|
16766
|
-
const assetKeyMap = {
|
|
16767
|
-
loader: ExtensionType.LoadParser,
|
|
16768
|
-
resolver: ExtensionType.ResolveParser,
|
|
16769
|
-
cache: ExtensionType.CacheParser,
|
|
16770
|
-
detection: ExtensionType.DetectionParser
|
|
16771
|
-
};
|
|
16772
|
-
extensions$1.handle(ExtensionType.Asset, (extension) => {
|
|
16773
|
-
const ref = extension.ref;
|
|
16774
|
-
Object.entries(assetKeyMap).filter(([key]) => !!ref[key]).forEach(([key, type]) => extensions$1.add(Object.assign(ref[key], { extension: ref[key].extension ?? type })));
|
|
16775
|
-
}, (extension) => {
|
|
16776
|
-
const ref = extension.ref;
|
|
16777
|
-
Object.keys(assetKeyMap).filter((key) => !!ref[key]).forEach((key) => extensions$1.remove(ref[key]));
|
|
16778
|
-
});
|
|
16779
|
-
|
|
16780
|
-
const cacheTextureArray = {
|
|
16781
|
-
extension: ExtensionType.CacheParser,
|
|
16782
|
-
test: (asset) => Array.isArray(asset) && asset.every((t) => t instanceof Texture),
|
|
16783
|
-
getCacheableAssets: (keys, asset) => {
|
|
16784
|
-
const out = {};
|
|
16785
|
-
keys.forEach((key) => {
|
|
16786
|
-
asset.forEach((item, i) => {
|
|
16787
|
-
out[key + (i === 0 ? "" : i + 1)] = item;
|
|
16788
|
-
});
|
|
16789
|
-
});
|
|
16790
|
-
return out;
|
|
16791
|
-
}
|
|
16792
|
-
};
|
|
16793
|
-
extensions$1.add(cacheTextureArray);
|
|
16794
|
-
|
|
16795
16597
|
var LoaderParserPriority = /* @__PURE__ */ ((LoaderParserPriority2) => {
|
|
16796
16598
|
LoaderParserPriority2[LoaderParserPriority2["Low"] = 0] = "Low";
|
|
16797
16599
|
LoaderParserPriority2[LoaderParserPriority2["Normal"] = 1] = "Normal";
|
|
@@ -17157,6 +16959,228 @@ ${e}`);
|
|
|
17157
16959
|
unload: loadTextures.unload
|
|
17158
16960
|
};
|
|
17159
16961
|
|
|
16962
|
+
class AssetsClass {
|
|
16963
|
+
constructor() {
|
|
16964
|
+
this._detections = [];
|
|
16965
|
+
this._initialized = false;
|
|
16966
|
+
this.resolver = new Resolver();
|
|
16967
|
+
this.loader = new Loader();
|
|
16968
|
+
this.cache = Cache;
|
|
16969
|
+
this._backgroundLoader = new BackgroundLoader(this.loader);
|
|
16970
|
+
this._backgroundLoader.active = true;
|
|
16971
|
+
this.reset();
|
|
16972
|
+
}
|
|
16973
|
+
async init(options = {}) {
|
|
16974
|
+
if (this._initialized) {
|
|
16975
|
+
return;
|
|
16976
|
+
}
|
|
16977
|
+
this._initialized = true;
|
|
16978
|
+
if (options.basePath) {
|
|
16979
|
+
this.resolver.basePath = options.basePath;
|
|
16980
|
+
}
|
|
16981
|
+
if (options.manifest) {
|
|
16982
|
+
let manifest = options.manifest;
|
|
16983
|
+
if (typeof manifest === "string") {
|
|
16984
|
+
manifest = await this.load(manifest);
|
|
16985
|
+
}
|
|
16986
|
+
this.resolver.addManifest(manifest);
|
|
16987
|
+
}
|
|
16988
|
+
const resolutionPref = options.texturePreference?.resolution ?? 1;
|
|
16989
|
+
const resolution = typeof resolutionPref === "number" ? [resolutionPref] : resolutionPref;
|
|
16990
|
+
let formats = [];
|
|
16991
|
+
if (options.texturePreference?.format) {
|
|
16992
|
+
const formatPref = options.texturePreference?.format;
|
|
16993
|
+
formats = typeof formatPref === "string" ? [formatPref] : formatPref;
|
|
16994
|
+
for (const detection of this._detections) {
|
|
16995
|
+
if (!await detection.test()) {
|
|
16996
|
+
formats = await detection.remove(formats);
|
|
16997
|
+
}
|
|
16998
|
+
}
|
|
16999
|
+
} else {
|
|
17000
|
+
for (const detection of this._detections) {
|
|
17001
|
+
if (await detection.test()) {
|
|
17002
|
+
formats = await detection.add(formats);
|
|
17003
|
+
}
|
|
17004
|
+
}
|
|
17005
|
+
}
|
|
17006
|
+
this.resolver.prefer({
|
|
17007
|
+
params: {
|
|
17008
|
+
format: formats,
|
|
17009
|
+
resolution
|
|
17010
|
+
}
|
|
17011
|
+
});
|
|
17012
|
+
}
|
|
17013
|
+
add(keysIn, assetsIn, data) {
|
|
17014
|
+
this.resolver.add(keysIn, assetsIn, data);
|
|
17015
|
+
}
|
|
17016
|
+
async load(urls, onProgress) {
|
|
17017
|
+
if (!this._initialized) {
|
|
17018
|
+
await this.init();
|
|
17019
|
+
}
|
|
17020
|
+
const singleAsset = isSingleItem(urls);
|
|
17021
|
+
const urlArray = convertToList(urls).map((url) => {
|
|
17022
|
+
if (typeof url !== "string") {
|
|
17023
|
+
this.resolver.add(url.src, url);
|
|
17024
|
+
return url.src;
|
|
17025
|
+
}
|
|
17026
|
+
return url;
|
|
17027
|
+
});
|
|
17028
|
+
const resolveResults = this.resolver.resolve(urlArray);
|
|
17029
|
+
const out = await this._mapLoadToResolve(resolveResults, onProgress);
|
|
17030
|
+
return singleAsset ? out[urlArray[0]] : out;
|
|
17031
|
+
}
|
|
17032
|
+
addBundle(bundleId, assets) {
|
|
17033
|
+
this.resolver.addBundle(bundleId, assets);
|
|
17034
|
+
}
|
|
17035
|
+
async loadBundle(bundleIds, onProgress) {
|
|
17036
|
+
if (!this._initialized) {
|
|
17037
|
+
await this.init();
|
|
17038
|
+
}
|
|
17039
|
+
let singleAsset = false;
|
|
17040
|
+
if (typeof bundleIds === "string") {
|
|
17041
|
+
singleAsset = true;
|
|
17042
|
+
bundleIds = [bundleIds];
|
|
17043
|
+
}
|
|
17044
|
+
const resolveResults = this.resolver.resolveBundle(bundleIds);
|
|
17045
|
+
const out = {};
|
|
17046
|
+
const keys = Object.keys(resolveResults);
|
|
17047
|
+
let count = 0;
|
|
17048
|
+
let total = 0;
|
|
17049
|
+
const _onProgress = () => {
|
|
17050
|
+
onProgress?.(++count / total);
|
|
17051
|
+
};
|
|
17052
|
+
const promises = keys.map((bundleId) => {
|
|
17053
|
+
const resolveResult = resolveResults[bundleId];
|
|
17054
|
+
total += Object.keys(resolveResult).length;
|
|
17055
|
+
return this._mapLoadToResolve(resolveResult, _onProgress).then((resolveResult2) => {
|
|
17056
|
+
out[bundleId] = resolveResult2;
|
|
17057
|
+
});
|
|
17058
|
+
});
|
|
17059
|
+
await Promise.all(promises);
|
|
17060
|
+
return singleAsset ? out[bundleIds[0]] : out;
|
|
17061
|
+
}
|
|
17062
|
+
async backgroundLoad(urls) {
|
|
17063
|
+
if (!this._initialized) {
|
|
17064
|
+
await this.init();
|
|
17065
|
+
}
|
|
17066
|
+
if (typeof urls === "string") {
|
|
17067
|
+
urls = [urls];
|
|
17068
|
+
}
|
|
17069
|
+
const resolveResults = this.resolver.resolve(urls);
|
|
17070
|
+
this._backgroundLoader.add(Object.values(resolveResults));
|
|
17071
|
+
}
|
|
17072
|
+
async backgroundLoadBundle(bundleIds) {
|
|
17073
|
+
if (!this._initialized) {
|
|
17074
|
+
await this.init();
|
|
17075
|
+
}
|
|
17076
|
+
if (typeof bundleIds === "string") {
|
|
17077
|
+
bundleIds = [bundleIds];
|
|
17078
|
+
}
|
|
17079
|
+
const resolveResults = this.resolver.resolveBundle(bundleIds);
|
|
17080
|
+
Object.values(resolveResults).forEach((resolveResult) => {
|
|
17081
|
+
this._backgroundLoader.add(Object.values(resolveResult));
|
|
17082
|
+
});
|
|
17083
|
+
}
|
|
17084
|
+
reset() {
|
|
17085
|
+
this.resolver.reset();
|
|
17086
|
+
this.loader.reset();
|
|
17087
|
+
this.cache.reset();
|
|
17088
|
+
this._initialized = false;
|
|
17089
|
+
}
|
|
17090
|
+
get(keys) {
|
|
17091
|
+
if (typeof keys === "string") {
|
|
17092
|
+
return Cache.get(keys);
|
|
17093
|
+
}
|
|
17094
|
+
const assets = {};
|
|
17095
|
+
for (let i = 0; i < keys.length; i++) {
|
|
17096
|
+
assets[i] = Cache.get(keys[i]);
|
|
17097
|
+
}
|
|
17098
|
+
return assets;
|
|
17099
|
+
}
|
|
17100
|
+
async _mapLoadToResolve(resolveResults, onProgress) {
|
|
17101
|
+
const resolveArray = Object.values(resolveResults);
|
|
17102
|
+
const resolveKeys = Object.keys(resolveResults);
|
|
17103
|
+
this._backgroundLoader.active = false;
|
|
17104
|
+
const loadedAssets = await this.loader.load(resolveArray, onProgress);
|
|
17105
|
+
this._backgroundLoader.active = true;
|
|
17106
|
+
const out = {};
|
|
17107
|
+
resolveArray.forEach((resolveResult, i) => {
|
|
17108
|
+
const asset = loadedAssets[resolveResult.src];
|
|
17109
|
+
const keys = [resolveResult.src];
|
|
17110
|
+
if (resolveResult.alias) {
|
|
17111
|
+
keys.push(...resolveResult.alias);
|
|
17112
|
+
}
|
|
17113
|
+
out[resolveKeys[i]] = asset;
|
|
17114
|
+
Cache.set(keys, asset);
|
|
17115
|
+
});
|
|
17116
|
+
return out;
|
|
17117
|
+
}
|
|
17118
|
+
async unload(urls) {
|
|
17119
|
+
if (!this._initialized) {
|
|
17120
|
+
await this.init();
|
|
17121
|
+
}
|
|
17122
|
+
const urlArray = convertToList(urls).map((url) => typeof url !== "string" ? url.src : url);
|
|
17123
|
+
const resolveResults = this.resolver.resolve(urlArray);
|
|
17124
|
+
await this._unloadFromResolved(resolveResults);
|
|
17125
|
+
}
|
|
17126
|
+
async unloadBundle(bundleIds) {
|
|
17127
|
+
if (!this._initialized) {
|
|
17128
|
+
await this.init();
|
|
17129
|
+
}
|
|
17130
|
+
bundleIds = convertToList(bundleIds);
|
|
17131
|
+
const resolveResults = this.resolver.resolveBundle(bundleIds);
|
|
17132
|
+
const promises = Object.keys(resolveResults).map((bundleId) => this._unloadFromResolved(resolveResults[bundleId]));
|
|
17133
|
+
await Promise.all(promises);
|
|
17134
|
+
}
|
|
17135
|
+
async _unloadFromResolved(resolveResult) {
|
|
17136
|
+
const resolveArray = Object.values(resolveResult);
|
|
17137
|
+
resolveArray.forEach((resolveResult2) => {
|
|
17138
|
+
Cache.remove(resolveResult2.src);
|
|
17139
|
+
});
|
|
17140
|
+
await this.loader.unload(resolveArray);
|
|
17141
|
+
}
|
|
17142
|
+
get detections() {
|
|
17143
|
+
return this._detections;
|
|
17144
|
+
}
|
|
17145
|
+
get preferWorker() {
|
|
17146
|
+
return loadTextures.config.preferWorker;
|
|
17147
|
+
}
|
|
17148
|
+
set preferWorker(value) {
|
|
17149
|
+
loadTextures.config.preferWorker = value;
|
|
17150
|
+
}
|
|
17151
|
+
}
|
|
17152
|
+
const Assets = new AssetsClass();
|
|
17153
|
+
extensions$1.handleByList(ExtensionType.LoadParser, Assets.loader.parsers).handleByList(ExtensionType.ResolveParser, Assets.resolver.parsers).handleByList(ExtensionType.CacheParser, Assets.cache.parsers).handleByList(ExtensionType.DetectionParser, Assets.detections);
|
|
17154
|
+
|
|
17155
|
+
const assetKeyMap = {
|
|
17156
|
+
loader: ExtensionType.LoadParser,
|
|
17157
|
+
resolver: ExtensionType.ResolveParser,
|
|
17158
|
+
cache: ExtensionType.CacheParser,
|
|
17159
|
+
detection: ExtensionType.DetectionParser
|
|
17160
|
+
};
|
|
17161
|
+
extensions$1.handle(ExtensionType.Asset, (extension) => {
|
|
17162
|
+
const ref = extension.ref;
|
|
17163
|
+
Object.entries(assetKeyMap).filter(([key]) => !!ref[key]).forEach(([key, type]) => extensions$1.add(Object.assign(ref[key], { extension: ref[key].extension ?? type })));
|
|
17164
|
+
}, (extension) => {
|
|
17165
|
+
const ref = extension.ref;
|
|
17166
|
+
Object.keys(assetKeyMap).filter((key) => !!ref[key]).forEach((key) => extensions$1.remove(ref[key]));
|
|
17167
|
+
});
|
|
17168
|
+
|
|
17169
|
+
const cacheTextureArray = {
|
|
17170
|
+
extension: ExtensionType.CacheParser,
|
|
17171
|
+
test: (asset) => Array.isArray(asset) && asset.every((t) => t instanceof Texture),
|
|
17172
|
+
getCacheableAssets: (keys, asset) => {
|
|
17173
|
+
const out = {};
|
|
17174
|
+
keys.forEach((key) => {
|
|
17175
|
+
asset.forEach((item, i) => {
|
|
17176
|
+
out[key + (i === 0 ? "" : i + 1)] = item;
|
|
17177
|
+
});
|
|
17178
|
+
});
|
|
17179
|
+
return out;
|
|
17180
|
+
}
|
|
17181
|
+
};
|
|
17182
|
+
extensions$1.add(cacheTextureArray);
|
|
17183
|
+
|
|
17160
17184
|
const resolveTextureUrl = {
|
|
17161
17185
|
extension: ExtensionType.ResolveParser,
|
|
17162
17186
|
test: loadTextures.test,
|
|
@@ -24176,6 +24200,7 @@ ${e}`);
|
|
|
24176
24200
|
exports.settings = settings;
|
|
24177
24201
|
exports.spritesheetAsset = spritesheetAsset;
|
|
24178
24202
|
exports.uniformParsers = uniformParsers;
|
|
24203
|
+
exports.unsafeEvalSupported = unsafeEvalSupported;
|
|
24179
24204
|
exports.utils = index;
|
|
24180
24205
|
|
|
24181
24206
|
Object.defineProperty(exports, '__esModule', { value: true });
|