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