@galacean/effects-core 1.2.0 → 1.2.1
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/asset-manager.d.ts +5 -0
- package/dist/index.js +29 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +29 -6
- package/dist/index.mjs.map +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/asset-manager.d.ts
CHANGED
|
@@ -98,6 +98,10 @@ export declare class AssetManager implements Disposable {
|
|
|
98
98
|
* @default 10
|
|
99
99
|
*/
|
|
100
100
|
private timeout;
|
|
101
|
+
/**
|
|
102
|
+
* 场景加载的超时定时器
|
|
103
|
+
*/
|
|
104
|
+
private timers;
|
|
101
105
|
/**
|
|
102
106
|
* 构造函数
|
|
103
107
|
* @param options - 场景加载参数
|
|
@@ -123,6 +127,7 @@ export declare class AssetManager implements Disposable {
|
|
|
123
127
|
private processTextures;
|
|
124
128
|
private loadJSON;
|
|
125
129
|
private loadBins;
|
|
130
|
+
private removeTimer;
|
|
126
131
|
/**
|
|
127
132
|
* 销毁方法
|
|
128
133
|
*/
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Description: Galacean Effects runtime core for the web
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
|
|
6
|
-
* Version: v1.2.
|
|
6
|
+
* Version: v1.2.1
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -23454,6 +23454,10 @@ var AssetManager = /** @class */ (function () {
|
|
|
23454
23454
|
*/
|
|
23455
23455
|
this.assets = {};
|
|
23456
23456
|
this.id = seed$1++;
|
|
23457
|
+
/**
|
|
23458
|
+
* 场景加载的超时定时器
|
|
23459
|
+
*/
|
|
23460
|
+
this.timers = [];
|
|
23457
23461
|
this.updateOptions(options);
|
|
23458
23462
|
}
|
|
23459
23463
|
AssetManager.prototype.updateOptions = function (options) {
|
|
@@ -23486,25 +23490,33 @@ var AssetManager = /** @class */ (function () {
|
|
|
23486
23490
|
compressedTexture = (_c = gpuInstance === null || gpuInstance === void 0 ? void 0 : gpuInstance.detail.compressedTexture) !== null && _c !== void 0 ? _c : 0;
|
|
23487
23491
|
cancelLoading = false;
|
|
23488
23492
|
waitPromise = new Promise(function (resolve, reject) {
|
|
23489
|
-
|
|
23493
|
+
loadTimer = window.setTimeout(function () {
|
|
23490
23494
|
cancelLoading = true;
|
|
23495
|
+
_this.removeTimer(loadTimer);
|
|
23491
23496
|
var totalTime = performance.now() - startTime;
|
|
23492
23497
|
reject("Load time out: totalTime: ".concat(totalTime.toFixed(4), "ms ").concat(timeInfos.join(' '), ", url: ").concat(assetUrl));
|
|
23493
23498
|
}, _this.timeout * 1000);
|
|
23499
|
+
_this.timers.push(loadTimer);
|
|
23494
23500
|
});
|
|
23495
23501
|
hookTimeInfo = function (label, func) { return __awaiter(_this, void 0, void 0, function () {
|
|
23496
|
-
var st, result;
|
|
23502
|
+
var st, result, e_1;
|
|
23497
23503
|
return __generator(this, function (_a) {
|
|
23498
23504
|
switch (_a.label) {
|
|
23499
23505
|
case 0:
|
|
23500
|
-
if (!!cancelLoading) return [3 /*break*/,
|
|
23506
|
+
if (!!cancelLoading) return [3 /*break*/, 4];
|
|
23501
23507
|
st = performance.now();
|
|
23502
|
-
|
|
23508
|
+
_a.label = 1;
|
|
23503
23509
|
case 1:
|
|
23510
|
+
_a.trys.push([1, 3, , 4]);
|
|
23511
|
+
return [4 /*yield*/, func()];
|
|
23512
|
+
case 2:
|
|
23504
23513
|
result = _a.sent();
|
|
23505
23514
|
timeInfos.push("[".concat(label, ": ").concat((performance.now() - st).toFixed(2), "]"));
|
|
23506
23515
|
return [2 /*return*/, result];
|
|
23507
|
-
case
|
|
23516
|
+
case 3:
|
|
23517
|
+
e_1 = _a.sent();
|
|
23518
|
+
throw new Error("load error in ".concat(label, ", ").concat(e_1));
|
|
23519
|
+
case 4: throw new Error('load canceled.');
|
|
23508
23520
|
}
|
|
23509
23521
|
});
|
|
23510
23522
|
}); };
|
|
@@ -23588,6 +23600,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
23588
23600
|
totalTime = performance.now() - startTime;
|
|
23589
23601
|
logger.info("Load asset: totalTime: ".concat(totalTime.toFixed(4), "ms ").concat(timeInfos.join(' '), ", url: ").concat(assetUrl));
|
|
23590
23602
|
window.clearTimeout(loadTimer);
|
|
23603
|
+
this.removeTimer(loadTimer);
|
|
23591
23604
|
scene.totalTime = totalTime;
|
|
23592
23605
|
scene.startTime = startTime;
|
|
23593
23606
|
return [2 /*return*/, scene];
|
|
@@ -23896,16 +23909,26 @@ var AssetManager = /** @class */ (function () {
|
|
|
23896
23909
|
});
|
|
23897
23910
|
});
|
|
23898
23911
|
};
|
|
23912
|
+
AssetManager.prototype.removeTimer = function (id) {
|
|
23913
|
+
var index = this.timers.indexOf(id);
|
|
23914
|
+
if (index !== -1) {
|
|
23915
|
+
this.timers.splice(index, 1);
|
|
23916
|
+
}
|
|
23917
|
+
};
|
|
23899
23918
|
/**
|
|
23900
23919
|
* 销毁方法
|
|
23901
23920
|
*/
|
|
23902
23921
|
AssetManager.prototype.dispose = function () {
|
|
23903
23922
|
var _a;
|
|
23923
|
+
if (this.timers.length) {
|
|
23924
|
+
this.timers.map(function (id) { return window.clearTimeout(id); });
|
|
23925
|
+
}
|
|
23904
23926
|
for (var key in this.assets) {
|
|
23905
23927
|
var asset = this.assets[key];
|
|
23906
23928
|
(_a = asset === null || asset === void 0 ? void 0 : asset.dispose) === null || _a === void 0 ? void 0 : _a.call(asset);
|
|
23907
23929
|
}
|
|
23908
23930
|
this.assets = {};
|
|
23931
|
+
this.timers = [];
|
|
23909
23932
|
};
|
|
23910
23933
|
/**
|
|
23911
23934
|
* 自定义文本缓存,随页面销毁而销毁
|