@galacean/effects-threejs 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/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: Galacean Effects runtime threejs plugin for the web
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
6
- * Version: v1.2.0
6
+ * Version: v1.2.1
7
7
  */
8
8
 
9
9
  'use strict';
@@ -23476,6 +23476,10 @@ var AssetManager = /** @class */ (function () {
23476
23476
  */
23477
23477
  this.assets = {};
23478
23478
  this.id = seed$2++;
23479
+ /**
23480
+ * 场景加载的超时定时器
23481
+ */
23482
+ this.timers = [];
23479
23483
  this.updateOptions(options);
23480
23484
  }
23481
23485
  AssetManager.prototype.updateOptions = function (options) {
@@ -23508,25 +23512,33 @@ var AssetManager = /** @class */ (function () {
23508
23512
  compressedTexture = (_c = gpuInstance === null || gpuInstance === void 0 ? void 0 : gpuInstance.detail.compressedTexture) !== null && _c !== void 0 ? _c : 0;
23509
23513
  cancelLoading = false;
23510
23514
  waitPromise = new Promise(function (resolve, reject) {
23511
- return loadTimer = window.setTimeout(function () {
23515
+ loadTimer = window.setTimeout(function () {
23512
23516
  cancelLoading = true;
23517
+ _this.removeTimer(loadTimer);
23513
23518
  var totalTime = performance.now() - startTime;
23514
23519
  reject("Load time out: totalTime: ".concat(totalTime.toFixed(4), "ms ").concat(timeInfos.join(' '), ", url: ").concat(assetUrl));
23515
23520
  }, _this.timeout * 1000);
23521
+ _this.timers.push(loadTimer);
23516
23522
  });
23517
23523
  hookTimeInfo = function (label, func) { return __awaiter(_this, void 0, void 0, function () {
23518
- var st, result;
23524
+ var st, result, e_1;
23519
23525
  return __generator(this, function (_a) {
23520
23526
  switch (_a.label) {
23521
23527
  case 0:
23522
- if (!!cancelLoading) return [3 /*break*/, 2];
23528
+ if (!!cancelLoading) return [3 /*break*/, 4];
23523
23529
  st = performance.now();
23524
- return [4 /*yield*/, func()];
23530
+ _a.label = 1;
23525
23531
  case 1:
23532
+ _a.trys.push([1, 3, , 4]);
23533
+ return [4 /*yield*/, func()];
23534
+ case 2:
23526
23535
  result = _a.sent();
23527
23536
  timeInfos.push("[".concat(label, ": ").concat((performance.now() - st).toFixed(2), "]"));
23528
23537
  return [2 /*return*/, result];
23529
- case 2: throw new Error('load canceled.');
23538
+ case 3:
23539
+ e_1 = _a.sent();
23540
+ throw new Error("load error in ".concat(label, ", ").concat(e_1));
23541
+ case 4: throw new Error('load canceled.');
23530
23542
  }
23531
23543
  });
23532
23544
  }); };
@@ -23610,6 +23622,7 @@ var AssetManager = /** @class */ (function () {
23610
23622
  totalTime = performance.now() - startTime;
23611
23623
  logger.info("Load asset: totalTime: ".concat(totalTime.toFixed(4), "ms ").concat(timeInfos.join(' '), ", url: ").concat(assetUrl));
23612
23624
  window.clearTimeout(loadTimer);
23625
+ this.removeTimer(loadTimer);
23613
23626
  scene.totalTime = totalTime;
23614
23627
  scene.startTime = startTime;
23615
23628
  return [2 /*return*/, scene];
@@ -23918,16 +23931,26 @@ var AssetManager = /** @class */ (function () {
23918
23931
  });
23919
23932
  });
23920
23933
  };
23934
+ AssetManager.prototype.removeTimer = function (id) {
23935
+ var index = this.timers.indexOf(id);
23936
+ if (index !== -1) {
23937
+ this.timers.splice(index, 1);
23938
+ }
23939
+ };
23921
23940
  /**
23922
23941
  * 销毁方法
23923
23942
  */
23924
23943
  AssetManager.prototype.dispose = function () {
23925
23944
  var _a;
23945
+ if (this.timers.length) {
23946
+ this.timers.map(function (id) { return window.clearTimeout(id); });
23947
+ }
23926
23948
  for (var key in this.assets) {
23927
23949
  var asset = this.assets[key];
23928
23950
  (_a = asset === null || asset === void 0 ? void 0 : asset.dispose) === null || _a === void 0 ? void 0 : _a.call(asset);
23929
23951
  }
23930
23952
  this.assets = {};
23953
+ this.timers = [];
23931
23954
  };
23932
23955
  /**
23933
23956
  * 自定义文本缓存,随页面销毁而销毁
@@ -26889,7 +26912,7 @@ Geometry.create = function (engine, options) {
26889
26912
  Mesh.create = function (engine, props) {
26890
26913
  return new ThreeMesh(engine, props);
26891
26914
  };
26892
- var version = "1.2.0";
26915
+ var version = "1.2.1";
26893
26916
  logger.info('THREEJS plugin version: ' + version);
26894
26917
 
26895
26918
  exports.AbstractPlugin = AbstractPlugin;