@galacean/engine-core 0.9.18 → 0.9.20

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/main.js CHANGED
@@ -18396,18 +18396,10 @@ var defaultInterval = 500;
18396
18396
  var _config_type;
18397
18397
  config.type = (_config_type = config.type) != null ? _config_type : getMimeTypeFromUrl(url);
18398
18398
  var realRequest = config.type === "image" ? requestImage : requestRes;
18399
- var lastError;
18400
18399
  var executor = new MultiExecutor(function() {
18401
- return realRequest(url, config).onProgress(setProgress).then(function(res) {
18402
- resolve(res);
18403
- executor.stop();
18404
- }).catch(function(err) {
18405
- return lastError = err;
18406
- });
18400
+ return realRequest(url, config).onProgress(setProgress);
18407
18401
  }, retryCount, retryInterval);
18408
- executor.start(function() {
18409
- reject(lastError);
18410
- });
18402
+ executor.start().onError(reject).onComplete(resolve);
18411
18403
  });
18412
18404
  }
18413
18405
  function requestImage(url, config) {
@@ -18494,23 +18486,33 @@ var MultiExecutor = /*#__PURE__*/ function() {
18494
18486
  this.exec = this.exec.bind(this);
18495
18487
  }
18496
18488
  var _proto = MultiExecutor.prototype;
18497
- _proto.start = function start(done) {
18498
- this.done = done;
18489
+ _proto.start = function start() {
18499
18490
  this.exec();
18491
+ return this;
18500
18492
  };
18501
- _proto.stop = function stop() {
18502
- clearTimeout(this._timeoutId);
18493
+ _proto.onComplete = function onComplete(func) {
18494
+ this._onComplete = func;
18495
+ return this;
18496
+ };
18497
+ _proto.onError = function onError(func) {
18498
+ this._onError = func;
18499
+ return this;
18500
+ };
18501
+ _proto.cancel = function cancel() {
18502
+ window.clearTimeout(this._timeoutId);
18503
18503
  };
18504
18504
  _proto.exec = function exec() {
18505
18505
  var _this = this;
18506
18506
  if (this._currentCount >= this.totalCount) {
18507
- this.done && this.done();
18507
+ this._onError && this._onError(this._error);
18508
18508
  return;
18509
18509
  }
18510
18510
  this._currentCount++;
18511
- this.execFunc(this._currentCount).then(function() {
18512
- //@ts-ignore
18513
- _this._timeoutId = setTimeout(_this.exec, _this.interval);
18511
+ this.execFunc(this._currentCount).then(function(result) {
18512
+ return _this._onComplete && _this._onComplete(result);
18513
+ }).catch(function(e) {
18514
+ _this._error = e;
18515
+ _this._timeoutId = window.setTimeout(_this.exec, _this.interval);
18514
18516
  });
18515
18517
  };
18516
18518
  return MultiExecutor;
@@ -21477,6 +21479,7 @@ var DirtyFlag;
21477
21479
  curKeyframeIndex: 0,
21478
21480
  value: null
21479
21481
  };
21482
+ this.updateMark = 0;
21480
21483
  this.target = target;
21481
21484
  this.type = type;
21482
21485
  this.property = property;
@@ -22949,9 +22952,9 @@ exports.AnimatorLayerBlendingMode = void 0;
22949
22952
  _this = Component.call(this, entity) || this;
22950
22953
  /** Culling mode of this Animator. */ _this.cullingMode = exports.AnimatorCullingMode.None;
22951
22954
  /** The playback speed of the Animator, 1.0 is normal playback speed. */ _this.speed = 1.0;
22955
+ _this._updateMark = 0;
22952
22956
  _this._animatorLayersData = [];
22953
22957
  _this._curveOwnerPool = Object.create(null);
22954
- _this._needRevertCurveOwners = [];
22955
22958
  _this._animationEventHandlerPool = new ClassPool(AnimationEventHandler);
22956
22959
  _this._tempAnimatorStateInfo = {
22957
22960
  layerIndex: -1,
@@ -23035,7 +23038,7 @@ exports.AnimatorLayerBlendingMode = void 0;
23035
23038
  return;
23036
23039
  }
23037
23040
  deltaTime *= this.speed;
23038
- this._revertCurveOwners();
23041
+ this._updateMark++;
23039
23042
  for(var i1 = 0, n1 = animatorController.layers.length; i1 < n1; i1++){
23040
23043
  var animatorLayerData = this._getAnimatorLayerData(i1);
23041
23044
  if (animatorLayerData.layerState === LayerState.Standby) {
@@ -23085,7 +23088,6 @@ exports.AnimatorLayerBlendingMode = void 0;
23085
23088
  }
23086
23089
  }
23087
23090
  this._animatorLayersData.length = 0;
23088
- this._needRevertCurveOwners.length = 0;
23089
23091
  this._curveOwnerPool = {};
23090
23092
  this._animationEventHandlerPool.resetPool();
23091
23093
  if (this._controllerUpdateFlag) {
@@ -23136,17 +23138,9 @@ exports.AnimatorLayerBlendingMode = void 0;
23136
23138
  var _curveOwnerPool, _instanceId, _propertyOwners, _property, _layerCurveOwnerPool, _instanceId1, _layerPropertyOwners, _property1;
23137
23139
  var property = curve.property;
23138
23140
  var instanceId = targetEntity.instanceId;
23139
- var needRevert = false;
23140
- if (this.animatorController.layers[layerIndex].blendingMode === exports.AnimatorLayerBlendingMode.Additive && layerIndex > 0) {
23141
- needRevert = true;
23142
- }
23143
23141
  // Get owner
23144
23142
  var propertyOwners = (_curveOwnerPool = curveOwnerPool)[_instanceId = instanceId] || (_curveOwnerPool[_instanceId] = Object.create(null));
23145
23143
  var owner = (_propertyOwners = propertyOwners)[_property = property] || (_propertyOwners[_property] = curve._createCurveOwner(targetEntity));
23146
- //@todo: There is performance waste here, which will be handled together with organizing AnimatorStateData later. The logic is changing from runtime to initialization.
23147
- if (needRevert) {
23148
- this._needRevertCurveOwners.push(owner);
23149
- }
23150
23144
  // Get layer owner
23151
23145
  var layerPropertyOwners = (_layerCurveOwnerPool = layerCurveOwnerPool)[_instanceId1 = instanceId] || (_layerCurveOwnerPool[_instanceId1] = Object.create(null));
23152
23146
  var layerOwner = (_layerPropertyOwners = layerPropertyOwners)[_property1 = property] || (_layerPropertyOwners[_property1] = curve._createCurveLayerOwner(owner));
@@ -23279,6 +23273,7 @@ exports.AnimatorLayerBlendingMode = void 0;
23279
23273
  if (!owner) continue;
23280
23274
  var curve = curveBindings[i].curve;
23281
23275
  if (curve.keys.length) {
23276
+ this._checkRevertOwner(owner, additive);
23282
23277
  var value = owner.evaluateValue(curve, clipTime, additive);
23283
23278
  aniUpdate && owner.applyValue(value, weight, additive);
23284
23279
  finished && layerOwner.saveFinalValue();
@@ -23324,6 +23319,7 @@ exports.AnimatorLayerBlendingMode = void 0;
23324
23319
  if (!owner) continue;
23325
23320
  var srcCurveIndex = layerOwner.crossSrcCurveIndex;
23326
23321
  var destCurveIndex = layerOwner.crossDestCurveIndex;
23322
+ this._checkRevertOwner(owner, additive);
23327
23323
  var value = owner.evaluateCrossFadeValue(srcCurveIndex >= 0 ? srcCurves[srcCurveIndex].curve : null, destCurveIndex >= 0 ? destCurves[destCurveIndex].curve : null, srcClipTime, destClipTime, crossWeight, additive);
23328
23324
  aniUpdate && owner.applyValue(value, weight, additive);
23329
23325
  finished && layerOwner.saveFinalValue();
@@ -23370,6 +23366,7 @@ exports.AnimatorLayerBlendingMode = void 0;
23370
23366
  var owner = layerOwner == null ? void 0 : layerOwner.curveOwner;
23371
23367
  if (!owner) continue;
23372
23368
  var curveIndex = layerOwner.crossDestCurveIndex;
23369
+ this._checkRevertOwner(owner, additive);
23373
23370
  var value = layerOwner.curveOwner.crossFadeFromPoseAndApplyValue(curveIndex >= 0 ? curveBindings[curveIndex].curve : null, destClipTime, crossWeight, additive);
23374
23371
  aniUpdate && owner.applyValue(value, weight, additive);
23375
23372
  finished && layerOwner.saveFinalValue();
@@ -23396,6 +23393,7 @@ exports.AnimatorLayerBlendingMode = void 0;
23396
23393
  var layerOwner = curveLayerOwner[i];
23397
23394
  var owner = layerOwner == null ? void 0 : layerOwner.curveOwner;
23398
23395
  if (!owner) continue;
23396
+ this._checkRevertOwner(owner, additive);
23399
23397
  owner.applyValue(layerOwner.finalValue, weight, additive);
23400
23398
  }
23401
23399
  };
@@ -23565,11 +23563,11 @@ exports.AnimatorLayerBlendingMode = void 0;
23565
23563
  }
23566
23564
  }
23567
23565
  };
23568
- _proto._revertCurveOwners = function _revertCurveOwners() {
23569
- var curveOwners = this._needRevertCurveOwners;
23570
- for(var i = 0, n = curveOwners.length; i < n; ++i){
23571
- curveOwners[i].revertDefaultValue();
23566
+ _proto._checkRevertOwner = function _checkRevertOwner(owner, additive) {
23567
+ if (additive && owner.updateMark !== this._updateMark) {
23568
+ owner.revertDefaultValue();
23572
23569
  }
23570
+ owner.updateMark = this._updateMark;
23573
23571
  };
23574
23572
  _create_class(Animator, [
23575
23573
  {
@@ -23599,13 +23597,13 @@ __decorate([
23599
23597
  ], Animator.prototype, "_controllerUpdateFlag", void 0);
23600
23598
  __decorate([
23601
23599
  ignoreClone
23602
- ], Animator.prototype, "_animatorLayersData", void 0);
23600
+ ], Animator.prototype, "_updateMark", void 0);
23603
23601
  __decorate([
23604
23602
  ignoreClone
23605
- ], Animator.prototype, "_curveOwnerPool", void 0);
23603
+ ], Animator.prototype, "_animatorLayersData", void 0);
23606
23604
  __decorate([
23607
23605
  ignoreClone
23608
- ], Animator.prototype, "_needRevertCurveOwners", void 0);
23606
+ ], Animator.prototype, "_curveOwnerPool", void 0);
23609
23607
  __decorate([
23610
23608
  ignoreClone
23611
23609
  ], Animator.prototype, "_animationEventHandlerPool", void 0);