pixi.js 7.0.2 → 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 +254 -226
- 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 +254 -227
- 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
|
|
@@ -483,6 +483,9 @@ var PIXI = (function (exports) {
|
|
|
483
483
|
},
|
|
484
484
|
handleByList(type, list) {
|
|
485
485
|
return this.handle(type, (extension) => {
|
|
486
|
+
if (list.includes(extension.ref)) {
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
486
489
|
list.push(extension.ref);
|
|
487
490
|
list.sort((a, b) => (b.priority ?? -1) - (a.priority ?? -1));
|
|
488
491
|
}, (extension) => {
|
|
@@ -5817,7 +5820,7 @@ Deprecated since v${version}`);
|
|
|
5817
5820
|
return false;
|
|
5818
5821
|
}
|
|
5819
5822
|
} else if (typeof HTMLVideoElement !== "undefined" && source instanceof HTMLVideoElement) {
|
|
5820
|
-
if (source.readyState <= 1) {
|
|
5823
|
+
if (source.readyState <= 1 && source.buffered.length === 0) {
|
|
5821
5824
|
return false;
|
|
5822
5825
|
}
|
|
5823
5826
|
}
|
|
@@ -7023,7 +7026,7 @@ Deprecated since v${version}`);
|
|
|
7023
7026
|
RenderTexturePool.SCREEN_KEY = -1;
|
|
7024
7027
|
|
|
7025
7028
|
class Attribute {
|
|
7026
|
-
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) {
|
|
7027
7030
|
this.buffer = buffer;
|
|
7028
7031
|
this.size = size;
|
|
7029
7032
|
this.normalized = normalized;
|
|
@@ -7031,6 +7034,7 @@ Deprecated since v${version}`);
|
|
|
7031
7034
|
this.stride = stride;
|
|
7032
7035
|
this.start = start;
|
|
7033
7036
|
this.instance = instance;
|
|
7037
|
+
this.divisor = divisor;
|
|
7034
7038
|
}
|
|
7035
7039
|
destroy() {
|
|
7036
7040
|
this.buffer = null;
|
|
@@ -8538,7 +8542,7 @@ Deprecated since v${version}`);
|
|
|
8538
8542
|
gl.vertexAttribPointer(location, attribute.size, attribute.type || gl.FLOAT, attribute.normalized, attribute.stride, attribute.start);
|
|
8539
8543
|
if (attribute.instance) {
|
|
8540
8544
|
if (this.hasInstance) {
|
|
8541
|
-
gl.vertexAttribDivisor(location,
|
|
8545
|
+
gl.vertexAttribDivisor(location, attribute.divisor);
|
|
8542
8546
|
} else {
|
|
8543
8547
|
throw new Error("geometry error, GPU Instancing is not supported on this device");
|
|
8544
8548
|
}
|
|
@@ -11364,7 +11368,7 @@ ${this.fragmentSrc}`;
|
|
|
11364
11368
|
const renderer = this.renderer;
|
|
11365
11369
|
renderer.emitWithCustomOptions(renderer.runners.init, options);
|
|
11366
11370
|
if (options.hello) {
|
|
11367
|
-
console.log(`PixiJS ${"7.0
|
|
11371
|
+
console.log(`PixiJS ${"7.1.0-alpha"} - ${renderer.rendererLogId} - https://pixijs.com`);
|
|
11368
11372
|
}
|
|
11369
11373
|
renderer.resize(this.renderer.screen.width, this.renderer.screen.height);
|
|
11370
11374
|
}
|
|
@@ -11490,7 +11494,17 @@ ${this.fragmentSrc}`;
|
|
|
11490
11494
|
projectionMatrix: new Matrix()
|
|
11491
11495
|
}, true);
|
|
11492
11496
|
const systemConfig = {
|
|
11493
|
-
runners: [
|
|
11497
|
+
runners: [
|
|
11498
|
+
"init",
|
|
11499
|
+
"destroy",
|
|
11500
|
+
"contextChange",
|
|
11501
|
+
"resolutionChange",
|
|
11502
|
+
"reset",
|
|
11503
|
+
"update",
|
|
11504
|
+
"postrender",
|
|
11505
|
+
"prerender",
|
|
11506
|
+
"resize"
|
|
11507
|
+
],
|
|
11494
11508
|
systems: _Renderer.__systems,
|
|
11495
11509
|
priority: [
|
|
11496
11510
|
"_view",
|
|
@@ -11585,6 +11599,10 @@ ${this.fragmentSrc}`;
|
|
|
11585
11599
|
get resolution() {
|
|
11586
11600
|
return this._view.resolution;
|
|
11587
11601
|
}
|
|
11602
|
+
set resolution(value) {
|
|
11603
|
+
this._view.resolution = value;
|
|
11604
|
+
this.runners.resolutionChange.emit(value);
|
|
11605
|
+
}
|
|
11588
11606
|
get autoDensity() {
|
|
11589
11607
|
return this._view.autoDensity;
|
|
11590
11608
|
}
|
|
@@ -12333,7 +12351,7 @@ ${this.fragmentSrc}`;
|
|
|
12333
12351
|
};
|
|
12334
12352
|
extensions$1.add(ObjectRendererSystem);
|
|
12335
12353
|
|
|
12336
|
-
const VERSION = "7.0
|
|
12354
|
+
const VERSION = "7.1.0-alpha";
|
|
12337
12355
|
|
|
12338
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";
|
|
12339
12357
|
|
|
@@ -14226,7 +14244,7 @@ ${this.fragmentSrc}`;
|
|
|
14226
14244
|
if (this._roundPixels) {
|
|
14227
14245
|
const resolution = settings.RESOLUTION;
|
|
14228
14246
|
for (let i = 0; i < vertexData.length; ++i) {
|
|
14229
|
-
vertexData[i] = Math.round(
|
|
14247
|
+
vertexData[i] = Math.round(vertexData[i] * resolution) / resolution;
|
|
14230
14248
|
}
|
|
14231
14249
|
}
|
|
14232
14250
|
}
|
|
@@ -15389,6 +15407,9 @@ ${this.fragmentSrc}`;
|
|
|
15389
15407
|
this.setTargetElement(view);
|
|
15390
15408
|
this.resolution = resolution;
|
|
15391
15409
|
}
|
|
15410
|
+
resolutionChange(resolution) {
|
|
15411
|
+
this.resolution = resolution;
|
|
15412
|
+
}
|
|
15392
15413
|
destroy() {
|
|
15393
15414
|
this.setTargetElement(null);
|
|
15394
15415
|
this.renderer = null;
|
|
@@ -16573,222 +16594,6 @@ ${e}`);
|
|
|
16573
16594
|
}
|
|
16574
16595
|
}
|
|
16575
16596
|
|
|
16576
|
-
class AssetsClass {
|
|
16577
|
-
constructor() {
|
|
16578
|
-
this._detections = [];
|
|
16579
|
-
this._initialized = false;
|
|
16580
|
-
this.resolver = new Resolver();
|
|
16581
|
-
this.loader = new Loader();
|
|
16582
|
-
this.cache = Cache;
|
|
16583
|
-
this._backgroundLoader = new BackgroundLoader(this.loader);
|
|
16584
|
-
this._backgroundLoader.active = true;
|
|
16585
|
-
this.reset();
|
|
16586
|
-
}
|
|
16587
|
-
async init(options = {}) {
|
|
16588
|
-
if (this._initialized) {
|
|
16589
|
-
return;
|
|
16590
|
-
}
|
|
16591
|
-
this._initialized = true;
|
|
16592
|
-
if (options.basePath) {
|
|
16593
|
-
this.resolver.basePath = options.basePath;
|
|
16594
|
-
}
|
|
16595
|
-
if (options.manifest) {
|
|
16596
|
-
let manifest = options.manifest;
|
|
16597
|
-
if (typeof manifest === "string") {
|
|
16598
|
-
manifest = await this.load(manifest);
|
|
16599
|
-
}
|
|
16600
|
-
this.resolver.addManifest(manifest);
|
|
16601
|
-
}
|
|
16602
|
-
const resolutionPref = options.texturePreference?.resolution ?? 1;
|
|
16603
|
-
const resolution = typeof resolutionPref === "number" ? [resolutionPref] : resolutionPref;
|
|
16604
|
-
let formats = [];
|
|
16605
|
-
if (options.texturePreference?.format) {
|
|
16606
|
-
const formatPref = options.texturePreference?.format;
|
|
16607
|
-
formats = typeof formatPref === "string" ? [formatPref] : formatPref;
|
|
16608
|
-
for (const detection of this._detections) {
|
|
16609
|
-
if (!await detection.test()) {
|
|
16610
|
-
formats = await detection.remove(formats);
|
|
16611
|
-
}
|
|
16612
|
-
}
|
|
16613
|
-
} else {
|
|
16614
|
-
for (const detection of this._detections) {
|
|
16615
|
-
if (await detection.test()) {
|
|
16616
|
-
formats = await detection.add(formats);
|
|
16617
|
-
}
|
|
16618
|
-
}
|
|
16619
|
-
}
|
|
16620
|
-
this.resolver.prefer({
|
|
16621
|
-
params: {
|
|
16622
|
-
format: formats,
|
|
16623
|
-
resolution
|
|
16624
|
-
}
|
|
16625
|
-
});
|
|
16626
|
-
}
|
|
16627
|
-
add(keysIn, assetsIn, data) {
|
|
16628
|
-
this.resolver.add(keysIn, assetsIn, data);
|
|
16629
|
-
}
|
|
16630
|
-
async load(urls, onProgress) {
|
|
16631
|
-
if (!this._initialized) {
|
|
16632
|
-
await this.init();
|
|
16633
|
-
}
|
|
16634
|
-
const singleAsset = isSingleItem(urls);
|
|
16635
|
-
const urlArray = convertToList(urls).map((url) => {
|
|
16636
|
-
if (typeof url !== "string") {
|
|
16637
|
-
this.resolver.add(url.src, url);
|
|
16638
|
-
return url.src;
|
|
16639
|
-
}
|
|
16640
|
-
return url;
|
|
16641
|
-
});
|
|
16642
|
-
const resolveResults = this.resolver.resolve(urlArray);
|
|
16643
|
-
const out = await this._mapLoadToResolve(resolveResults, onProgress);
|
|
16644
|
-
return singleAsset ? out[urlArray[0]] : out;
|
|
16645
|
-
}
|
|
16646
|
-
addBundle(bundleId, assets) {
|
|
16647
|
-
this.resolver.addBundle(bundleId, assets);
|
|
16648
|
-
}
|
|
16649
|
-
async loadBundle(bundleIds, onProgress) {
|
|
16650
|
-
if (!this._initialized) {
|
|
16651
|
-
await this.init();
|
|
16652
|
-
}
|
|
16653
|
-
let singleAsset = false;
|
|
16654
|
-
if (typeof bundleIds === "string") {
|
|
16655
|
-
singleAsset = true;
|
|
16656
|
-
bundleIds = [bundleIds];
|
|
16657
|
-
}
|
|
16658
|
-
const resolveResults = this.resolver.resolveBundle(bundleIds);
|
|
16659
|
-
const out = {};
|
|
16660
|
-
const keys = Object.keys(resolveResults);
|
|
16661
|
-
let count = 0;
|
|
16662
|
-
let total = 0;
|
|
16663
|
-
const _onProgress = () => {
|
|
16664
|
-
onProgress?.(++count / total);
|
|
16665
|
-
};
|
|
16666
|
-
const promises = keys.map((bundleId) => {
|
|
16667
|
-
const resolveResult = resolveResults[bundleId];
|
|
16668
|
-
total += Object.keys(resolveResult).length;
|
|
16669
|
-
return this._mapLoadToResolve(resolveResult, _onProgress).then((resolveResult2) => {
|
|
16670
|
-
out[bundleId] = resolveResult2;
|
|
16671
|
-
});
|
|
16672
|
-
});
|
|
16673
|
-
await Promise.all(promises);
|
|
16674
|
-
return singleAsset ? out[bundleIds[0]] : out;
|
|
16675
|
-
}
|
|
16676
|
-
async backgroundLoad(urls) {
|
|
16677
|
-
if (!this._initialized) {
|
|
16678
|
-
await this.init();
|
|
16679
|
-
}
|
|
16680
|
-
if (typeof urls === "string") {
|
|
16681
|
-
urls = [urls];
|
|
16682
|
-
}
|
|
16683
|
-
const resolveResults = this.resolver.resolve(urls);
|
|
16684
|
-
this._backgroundLoader.add(Object.values(resolveResults));
|
|
16685
|
-
}
|
|
16686
|
-
async backgroundLoadBundle(bundleIds) {
|
|
16687
|
-
if (!this._initialized) {
|
|
16688
|
-
await this.init();
|
|
16689
|
-
}
|
|
16690
|
-
if (typeof bundleIds === "string") {
|
|
16691
|
-
bundleIds = [bundleIds];
|
|
16692
|
-
}
|
|
16693
|
-
const resolveResults = this.resolver.resolveBundle(bundleIds);
|
|
16694
|
-
Object.values(resolveResults).forEach((resolveResult) => {
|
|
16695
|
-
this._backgroundLoader.add(Object.values(resolveResult));
|
|
16696
|
-
});
|
|
16697
|
-
}
|
|
16698
|
-
reset() {
|
|
16699
|
-
this.resolver.reset();
|
|
16700
|
-
this.loader.reset();
|
|
16701
|
-
this.cache.reset();
|
|
16702
|
-
this._initialized = false;
|
|
16703
|
-
}
|
|
16704
|
-
get(keys) {
|
|
16705
|
-
if (typeof keys === "string") {
|
|
16706
|
-
return Cache.get(keys);
|
|
16707
|
-
}
|
|
16708
|
-
const assets = {};
|
|
16709
|
-
for (let i = 0; i < keys.length; i++) {
|
|
16710
|
-
assets[i] = Cache.get(keys[i]);
|
|
16711
|
-
}
|
|
16712
|
-
return assets;
|
|
16713
|
-
}
|
|
16714
|
-
async _mapLoadToResolve(resolveResults, onProgress) {
|
|
16715
|
-
const resolveArray = Object.values(resolveResults);
|
|
16716
|
-
const resolveKeys = Object.keys(resolveResults);
|
|
16717
|
-
this._backgroundLoader.active = false;
|
|
16718
|
-
const loadedAssets = await this.loader.load(resolveArray, onProgress);
|
|
16719
|
-
this._backgroundLoader.active = true;
|
|
16720
|
-
const out = {};
|
|
16721
|
-
resolveArray.forEach((resolveResult, i) => {
|
|
16722
|
-
const asset = loadedAssets[resolveResult.src];
|
|
16723
|
-
const keys = [resolveResult.src];
|
|
16724
|
-
if (resolveResult.alias) {
|
|
16725
|
-
keys.push(...resolveResult.alias);
|
|
16726
|
-
}
|
|
16727
|
-
out[resolveKeys[i]] = asset;
|
|
16728
|
-
Cache.set(keys, asset);
|
|
16729
|
-
});
|
|
16730
|
-
return out;
|
|
16731
|
-
}
|
|
16732
|
-
async unload(urls) {
|
|
16733
|
-
if (!this._initialized) {
|
|
16734
|
-
await this.init();
|
|
16735
|
-
}
|
|
16736
|
-
const urlArray = convertToList(urls).map((url) => typeof url !== "string" ? url.src : url);
|
|
16737
|
-
const resolveResults = this.resolver.resolve(urlArray);
|
|
16738
|
-
await this._unloadFromResolved(resolveResults);
|
|
16739
|
-
}
|
|
16740
|
-
async unloadBundle(bundleIds) {
|
|
16741
|
-
if (!this._initialized) {
|
|
16742
|
-
await this.init();
|
|
16743
|
-
}
|
|
16744
|
-
bundleIds = convertToList(bundleIds);
|
|
16745
|
-
const resolveResults = this.resolver.resolveBundle(bundleIds);
|
|
16746
|
-
const promises = Object.keys(resolveResults).map((bundleId) => this._unloadFromResolved(resolveResults[bundleId]));
|
|
16747
|
-
await Promise.all(promises);
|
|
16748
|
-
}
|
|
16749
|
-
async _unloadFromResolved(resolveResult) {
|
|
16750
|
-
const resolveArray = Object.values(resolveResult);
|
|
16751
|
-
resolveArray.forEach((resolveResult2) => {
|
|
16752
|
-
Cache.remove(resolveResult2.src);
|
|
16753
|
-
});
|
|
16754
|
-
await this.loader.unload(resolveArray);
|
|
16755
|
-
}
|
|
16756
|
-
get detections() {
|
|
16757
|
-
return this._detections;
|
|
16758
|
-
}
|
|
16759
|
-
}
|
|
16760
|
-
const Assets = new AssetsClass();
|
|
16761
|
-
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);
|
|
16762
|
-
|
|
16763
|
-
const assetKeyMap = {
|
|
16764
|
-
loader: ExtensionType.LoadParser,
|
|
16765
|
-
resolver: ExtensionType.ResolveParser,
|
|
16766
|
-
cache: ExtensionType.CacheParser,
|
|
16767
|
-
detection: ExtensionType.DetectionParser
|
|
16768
|
-
};
|
|
16769
|
-
extensions$1.handle(ExtensionType.Asset, (extension) => {
|
|
16770
|
-
const ref = extension.ref;
|
|
16771
|
-
Object.entries(assetKeyMap).filter(([key]) => !!ref[key]).forEach(([key, type]) => extensions$1.add(Object.assign(ref[key], { extension: ref[key].extension ?? type })));
|
|
16772
|
-
}, (extension) => {
|
|
16773
|
-
const ref = extension.ref;
|
|
16774
|
-
Object.keys(assetKeyMap).filter((key) => !!ref[key]).forEach((key) => extensions$1.remove(ref[key]));
|
|
16775
|
-
});
|
|
16776
|
-
|
|
16777
|
-
const cacheTextureArray = {
|
|
16778
|
-
extension: ExtensionType.CacheParser,
|
|
16779
|
-
test: (asset) => Array.isArray(asset) && asset.every((t) => t instanceof Texture),
|
|
16780
|
-
getCacheableAssets: (keys, asset) => {
|
|
16781
|
-
const out = {};
|
|
16782
|
-
keys.forEach((key) => {
|
|
16783
|
-
asset.forEach((item, i) => {
|
|
16784
|
-
out[key + (i === 0 ? "" : i + 1)] = item;
|
|
16785
|
-
});
|
|
16786
|
-
});
|
|
16787
|
-
return out;
|
|
16788
|
-
}
|
|
16789
|
-
};
|
|
16790
|
-
extensions$1.add(cacheTextureArray);
|
|
16791
|
-
|
|
16792
16597
|
var LoaderParserPriority = /* @__PURE__ */ ((LoaderParserPriority2) => {
|
|
16793
16598
|
LoaderParserPriority2[LoaderParserPriority2["Low"] = 0] = "Low";
|
|
16794
16599
|
LoaderParserPriority2[LoaderParserPriority2["Normal"] = 1] = "Normal";
|
|
@@ -17154,6 +16959,228 @@ ${e}`);
|
|
|
17154
16959
|
unload: loadTextures.unload
|
|
17155
16960
|
};
|
|
17156
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
|
+
|
|
17157
17184
|
const resolveTextureUrl = {
|
|
17158
17185
|
extension: ExtensionType.ResolveParser,
|
|
17159
17186
|
test: loadTextures.test,
|
|
@@ -20100,7 +20127,7 @@ ${e}`);
|
|
|
20100
20127
|
if (this._roundPixels) {
|
|
20101
20128
|
const resolution = settings.RESOLUTION;
|
|
20102
20129
|
for (let i = 0; i < vertexData.length; ++i) {
|
|
20103
|
-
vertexData[i] = Math.round(
|
|
20130
|
+
vertexData[i] = Math.round(vertexData[i] * resolution) / resolution;
|
|
20104
20131
|
}
|
|
20105
20132
|
}
|
|
20106
20133
|
this.vertexDirty = vertexDirtyId;
|
|
@@ -24173,6 +24200,7 @@ ${e}`);
|
|
|
24173
24200
|
exports.settings = settings;
|
|
24174
24201
|
exports.spritesheetAsset = spritesheetAsset;
|
|
24175
24202
|
exports.uniformParsers = uniformParsers;
|
|
24203
|
+
exports.unsafeEvalSupported = unsafeEvalSupported;
|
|
24176
24204
|
exports.utils = index;
|
|
24177
24205
|
|
|
24178
24206
|
Object.defineProperty(exports, '__esModule', { value: true });
|