@galacean/effects-threejs 1.2.0 → 1.2.2

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.2
7
7
  */
8
8
 
9
9
  'use strict';
@@ -19994,9 +19994,10 @@ var TextItem = /** @class */ (function (_super) {
19994
19994
  if (this.textStyle.fontSize === value) {
19995
19995
  return;
19996
19996
  }
19997
+ // 保证字号变化后位置正常
19998
+ var diff = this.textStyle.fontSize - value;
19999
+ this.textLayout.lineHeight += diff;
19997
20000
  this.textStyle.fontSize = value;
19998
- // 1.5175 = 31.43 / 20
19999
- this.textLayout.lineHeight = this.textStyle.fontSize * 1.5175;
20000
20001
  this.isDirty = true;
20001
20002
  };
20002
20003
  /**
@@ -23476,6 +23477,10 @@ var AssetManager = /** @class */ (function () {
23476
23477
  */
23477
23478
  this.assets = {};
23478
23479
  this.id = seed$2++;
23480
+ /**
23481
+ * 场景加载的超时定时器
23482
+ */
23483
+ this.timers = [];
23479
23484
  this.updateOptions(options);
23480
23485
  }
23481
23486
  AssetManager.prototype.updateOptions = function (options) {
@@ -23508,25 +23513,33 @@ var AssetManager = /** @class */ (function () {
23508
23513
  compressedTexture = (_c = gpuInstance === null || gpuInstance === void 0 ? void 0 : gpuInstance.detail.compressedTexture) !== null && _c !== void 0 ? _c : 0;
23509
23514
  cancelLoading = false;
23510
23515
  waitPromise = new Promise(function (resolve, reject) {
23511
- return loadTimer = window.setTimeout(function () {
23516
+ loadTimer = window.setTimeout(function () {
23512
23517
  cancelLoading = true;
23518
+ _this.removeTimer(loadTimer);
23513
23519
  var totalTime = performance.now() - startTime;
23514
23520
  reject("Load time out: totalTime: ".concat(totalTime.toFixed(4), "ms ").concat(timeInfos.join(' '), ", url: ").concat(assetUrl));
23515
23521
  }, _this.timeout * 1000);
23522
+ _this.timers.push(loadTimer);
23516
23523
  });
23517
23524
  hookTimeInfo = function (label, func) { return __awaiter(_this, void 0, void 0, function () {
23518
- var st, result;
23525
+ var st, result, e_1;
23519
23526
  return __generator(this, function (_a) {
23520
23527
  switch (_a.label) {
23521
23528
  case 0:
23522
- if (!!cancelLoading) return [3 /*break*/, 2];
23529
+ if (!!cancelLoading) return [3 /*break*/, 4];
23523
23530
  st = performance.now();
23524
- return [4 /*yield*/, func()];
23531
+ _a.label = 1;
23525
23532
  case 1:
23533
+ _a.trys.push([1, 3, , 4]);
23534
+ return [4 /*yield*/, func()];
23535
+ case 2:
23526
23536
  result = _a.sent();
23527
23537
  timeInfos.push("[".concat(label, ": ").concat((performance.now() - st).toFixed(2), "]"));
23528
23538
  return [2 /*return*/, result];
23529
- case 2: throw new Error('load canceled.');
23539
+ case 3:
23540
+ e_1 = _a.sent();
23541
+ throw new Error("load error in ".concat(label, ", ").concat(e_1));
23542
+ case 4: throw new Error('load canceled.');
23530
23543
  }
23531
23544
  });
23532
23545
  }); };
@@ -23610,6 +23623,7 @@ var AssetManager = /** @class */ (function () {
23610
23623
  totalTime = performance.now() - startTime;
23611
23624
  logger.info("Load asset: totalTime: ".concat(totalTime.toFixed(4), "ms ").concat(timeInfos.join(' '), ", url: ").concat(assetUrl));
23612
23625
  window.clearTimeout(loadTimer);
23626
+ this.removeTimer(loadTimer);
23613
23627
  scene.totalTime = totalTime;
23614
23628
  scene.startTime = startTime;
23615
23629
  return [2 /*return*/, scene];
@@ -23918,16 +23932,26 @@ var AssetManager = /** @class */ (function () {
23918
23932
  });
23919
23933
  });
23920
23934
  };
23935
+ AssetManager.prototype.removeTimer = function (id) {
23936
+ var index = this.timers.indexOf(id);
23937
+ if (index !== -1) {
23938
+ this.timers.splice(index, 1);
23939
+ }
23940
+ };
23921
23941
  /**
23922
23942
  * 销毁方法
23923
23943
  */
23924
23944
  AssetManager.prototype.dispose = function () {
23925
23945
  var _a;
23946
+ if (this.timers.length) {
23947
+ this.timers.map(function (id) { return window.clearTimeout(id); });
23948
+ }
23926
23949
  for (var key in this.assets) {
23927
23950
  var asset = this.assets[key];
23928
23951
  (_a = asset === null || asset === void 0 ? void 0 : asset.dispose) === null || _a === void 0 ? void 0 : _a.call(asset);
23929
23952
  }
23930
23953
  this.assets = {};
23954
+ this.timers = [];
23931
23955
  };
23932
23956
  /**
23933
23957
  * 自定义文本缓存,随页面销毁而销毁
@@ -26889,7 +26913,7 @@ Geometry.create = function (engine, options) {
26889
26913
  Mesh.create = function (engine, props) {
26890
26914
  return new ThreeMesh(engine, props);
26891
26915
  };
26892
- var version = "1.2.0";
26916
+ var version = "1.2.2";
26893
26917
  logger.info('THREEJS plugin version: ' + version);
26894
26918
 
26895
26919
  exports.AbstractPlugin = AbstractPlugin;