@galacean/engine-core 1.0.0-beta.12 → 1.0.0-beta.13

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
@@ -2306,29 +2306,7 @@ var /** @internal */ PromiseState;
2306
2306
  * @remarks The release principle is that it is not referenced by the components, including direct and indirect reference.
2307
2307
  */ _proto.gc = function gc() {
2308
2308
  this._gc(false);
2309
- var engine = this.engine;
2310
- engine._renderElementPool.garbageCollection();
2311
- engine._meshRenderDataPool.garbageCollection();
2312
- engine._spriteRenderDataPool.garbageCollection();
2313
- engine._spriteMaskRenderDataPool.garbageCollection();
2314
- engine._textRenderDataPool.garbageCollection();
2315
- var _componentsManager = engine._componentsManager, _lightManager = engine._lightManager;
2316
- _componentsManager._renderers.garbageCollection();
2317
- // @ts-ignore
2318
- _componentsManager._onStartScripts.garbageCollection();
2319
- // @ts-ignore
2320
- _componentsManager._onUpdateScripts.garbageCollection();
2321
- // @ts-ignore
2322
- _componentsManager._onLateUpdateScripts.garbageCollection();
2323
- // @ts-ignore
2324
- _componentsManager._onPhysicsUpdateScripts.garbageCollection();
2325
- // @ts-ignore
2326
- _componentsManager._onUpdateAnimations.garbageCollection();
2327
- // @ts-ignore
2328
- _componentsManager._onUpdateRenderers.garbageCollection();
2329
- _lightManager._spotLights.garbageCollection();
2330
- _lightManager._pointLights.garbageCollection();
2331
- _lightManager._directLights.garbageCollection();
2309
+ this.engine._pendingGC();
2332
2310
  };
2333
2311
  /**
2334
2312
  * Add content restorer.
@@ -3254,6 +3232,17 @@ exports.GLCapabilityType = void 0;
3254
3232
  componentContainer.length = 0;
3255
3233
  this._componentsContainerPool.push(componentContainer);
3256
3234
  };
3235
+ /**
3236
+ * @internal
3237
+ */ _proto._gc = function _gc() {
3238
+ this._renderers.garbageCollection();
3239
+ this._onStartScripts.garbageCollection();
3240
+ this._onUpdateScripts.garbageCollection();
3241
+ this._onLateUpdateScripts.garbageCollection();
3242
+ this._onPhysicsUpdateScripts.garbageCollection();
3243
+ this._onUpdateAnimations.garbageCollection();
3244
+ this._onUpdateRenderers.garbageCollection();
3245
+ };
3257
3246
  return ComponentsManager;
3258
3247
  }();
3259
3248
 
@@ -5885,6 +5874,11 @@ var Collision = function Collision() {
5885
5874
  elements[i]._onLateUpdate();
5886
5875
  }
5887
5876
  };
5877
+ /**
5878
+ * @internal
5879
+ */ _proto._gc = function _gc() {
5880
+ this._colliders.garbageCollection();
5881
+ };
5888
5882
  _proto._setGravity = function _setGravity() {
5889
5883
  this._nativePhysicsManager.setGravity(this._gravity);
5890
5884
  };
@@ -8462,6 +8456,13 @@ __decorate([
8462
8456
  shaderData.disableMacro("SCENE_SPOT_LIGHT_COUNT");
8463
8457
  }
8464
8458
  };
8459
+ /**
8460
+ * @internal
8461
+ */ _proto._gc = function _gc() {
8462
+ this._spotLights.garbageCollection();
8463
+ this._pointLights.garbageCollection();
8464
+ this._directLights.garbageCollection();
8465
+ };
8465
8466
  return LightManager;
8466
8467
  }();
8467
8468
 
@@ -16911,6 +16912,7 @@ ShaderPool.init();
16911
16912
  _this._frameInProcess = false;
16912
16913
  _this._waitingDestroy = false;
16913
16914
  _this._isDeviceLost = false;
16915
+ _this._waitingGC = false;
16914
16916
  _this._animate = function() {
16915
16917
  if (_this._vSyncCount) {
16916
16918
  _this._requestId = requestAnimationFrame(_this._animate);
@@ -17014,6 +17016,10 @@ ShaderPool.init();
17014
17016
  if (this._waitingDestroy) {
17015
17017
  this._destroy();
17016
17018
  }
17019
+ if (this._waitingGC) {
17020
+ this._gc();
17021
+ this._waitingGC = false;
17022
+ }
17017
17023
  this._frameInProcess = false;
17018
17024
  };
17019
17025
  /**
@@ -17172,6 +17178,15 @@ ShaderPool.init();
17172
17178
  };
17173
17179
  /**
17174
17180
  * @internal
17181
+ */ _proto._pendingGC = function _pendingGC() {
17182
+ if (this._frameInProcess) {
17183
+ this._waitingGC = true;
17184
+ } else {
17185
+ this._gc();
17186
+ }
17187
+ };
17188
+ /**
17189
+ * @internal
17175
17190
  */ _proto._initialize = function _initialize(configuration) {
17176
17191
  var _this = this;
17177
17192
  var physics = configuration.physics;
@@ -17234,6 +17249,16 @@ ShaderPool.init();
17234
17249
  console.error(error);
17235
17250
  });
17236
17251
  };
17252
+ _proto._gc = function _gc() {
17253
+ this._renderElementPool.garbageCollection();
17254
+ this._meshRenderDataPool.garbageCollection();
17255
+ this._spriteRenderDataPool.garbageCollection();
17256
+ this._spriteMaskRenderDataPool.garbageCollection();
17257
+ this._textRenderDataPool.garbageCollection();
17258
+ this._componentsManager._gc();
17259
+ this._lightManager._gc();
17260
+ this.physicsManager._gc();
17261
+ };
17237
17262
  _create_class(Engine, [
17238
17263
  {
17239
17264
  key: "settings",
@@ -22649,7 +22674,6 @@ var DirtyFlag;
22649
22674
  * @internal
22650
22675
  */ var AnimationCurveOwner = /*#__PURE__*/ function() {
22651
22676
  function AnimationCurveOwner(target, type, property, cureType) {
22652
- this.hasSavedDefaultValue = false;
22653
22677
  this.baseEvaluateData = {
22654
22678
  curKeyframeIndex: 0,
22655
22679
  value: null
@@ -22662,7 +22686,7 @@ var DirtyFlag;
22662
22686
  this.type = type;
22663
22687
  this.property = property;
22664
22688
  this.component = target.getComponent(type);
22665
- this._cureType = cureType;
22689
+ this.cureType = cureType;
22666
22690
  var assemblerType = AnimationCurveOwner.getAssemblerType(type, property);
22667
22691
  this._assembler = new assemblerType();
22668
22692
  this._assembler.initialize(this);
@@ -22671,89 +22695,80 @@ var DirtyFlag;
22671
22695
  }
22672
22696
  }
22673
22697
  var _proto = AnimationCurveOwner.prototype;
22674
- _proto.evaluateAndApplyValue = function evaluateAndApplyValue(curve, time, layerWeight, additive) {
22675
- if (curve.keys.length) {
22676
- if (additive) {
22677
- var value = curve._evaluateAdditive(time, this.baseEvaluateData);
22678
- var cureType = this._cureType;
22679
- if (cureType._isReferenceType) {
22680
- cureType._additiveValue(value, layerWeight, this.referenceTargetValue);
22681
- } else {
22682
- var assembler = this._assembler;
22683
- var originValue = assembler.getTargetValue();
22684
- var additiveValue = cureType._additiveValue(value, layerWeight, originValue);
22685
- assembler.setTargetValue(additiveValue);
22686
- }
22687
- } else {
22688
- var value1 = curve._evaluate(time, this.baseEvaluateData);
22689
- this._applyValue(value1, layerWeight);
22690
- }
22691
- }
22698
+ _proto.evaluateValue = function evaluateValue(curve, time, additive) {
22699
+ return additive ? curve._evaluateAdditive(time, this.baseEvaluateData) : curve._evaluate(time, this.baseEvaluateData);
22692
22700
  };
22693
- _proto.crossFadeAndApplyValue = function crossFadeAndApplyValue(srcCurve, destCurve, srcTime, destTime, crossWeight, layerWeight, additive) {
22694
- var srcValue = srcCurve && srcCurve.keys.length ? additive ? srcCurve._evaluateAdditive(srcTime, this.baseEvaluateData) : srcCurve._evaluate(srcTime, this.baseEvaluateData) : additive ? this._cureType._getZeroValue(this.baseEvaluateData.value) : this.defaultValue;
22695
- var destValue = destCurve && destCurve.keys.length ? additive ? destCurve._evaluateAdditive(destTime, this.crossEvaluateData) : destCurve._evaluate(destTime, this.crossEvaluateData) : additive ? this._cureType._getZeroValue(this.crossEvaluateData.value) : this.defaultValue;
22696
- this._applyCrossValue(srcValue, destValue, crossWeight, layerWeight, additive);
22701
+ _proto.evaluateCrossFadeValue = function evaluateCrossFadeValue(srcCurve, destCurve, srcTime, destTime, crossWeight, additive) {
22702
+ var srcValue = srcCurve && srcCurve.keys.length ? additive ? srcCurve._evaluateAdditive(srcTime, this.baseEvaluateData) : srcCurve._evaluate(srcTime, this.baseEvaluateData) : additive ? this.cureType._getZeroValue(this.baseEvaluateData.value) : this.defaultValue;
22703
+ var destValue = destCurve && destCurve.keys.length ? additive ? destCurve._evaluateAdditive(destTime, this.crossEvaluateData) : destCurve._evaluate(destTime, this.crossEvaluateData) : additive ? this.cureType._getZeroValue(this.crossEvaluateData.value) : this.defaultValue;
22704
+ return this._lerpValue(srcValue, destValue, crossWeight);
22697
22705
  };
22698
- _proto.crossFadeFromPoseAndApplyValue = function crossFadeFromPoseAndApplyValue(destCurve, destTime, crossWeight, layerWeight, additive) {
22699
- var srcValue = additive ? this._cureType._subtractValue(this.fixedPoseValue, this.defaultValue, this.baseEvaluateData.value) : this.fixedPoseValue;
22700
- var destValue = destCurve && destCurve.keys.length ? additive ? destCurve._evaluateAdditive(destTime, this.crossEvaluateData) : destCurve._evaluate(destTime, this.crossEvaluateData) : additive ? this._cureType._getZeroValue(this.crossEvaluateData.value) : this.defaultValue;
22701
- this._applyCrossValue(srcValue, destValue, crossWeight, layerWeight, additive);
22706
+ _proto.crossFadeFromPoseAndApplyValue = function crossFadeFromPoseAndApplyValue(destCurve, destTime, crossWeight, additive) {
22707
+ var srcValue = additive ? this.cureType._subtractValue(this.fixedPoseValue, this.defaultValue, this.baseEvaluateData.value) : this.fixedPoseValue;
22708
+ var destValue = destCurve && destCurve.keys.length ? additive ? destCurve._evaluateAdditive(destTime, this.crossEvaluateData) : destCurve._evaluate(destTime, this.crossEvaluateData) : additive ? this.cureType._getZeroValue(this.crossEvaluateData.value) : this.defaultValue;
22709
+ return this._lerpValue(srcValue, destValue, crossWeight);
22702
22710
  };
22703
22711
  _proto.revertDefaultValue = function revertDefaultValue() {
22704
22712
  this._assembler.setTargetValue(this.defaultValue);
22705
22713
  };
22714
+ _proto.getEvaluateValue = function getEvaluateValue(out) {
22715
+ if (this.cureType._isReferenceType) {
22716
+ this.cureType._copyValue(this.baseEvaluateData.value, out);
22717
+ return out;
22718
+ } else {
22719
+ return this.baseEvaluateData.value;
22720
+ }
22721
+ };
22706
22722
  _proto.saveDefaultValue = function saveDefaultValue() {
22707
- if (this._cureType._isReferenceType) {
22708
- this._cureType._copyValue(this.referenceTargetValue, this.defaultValue);
22723
+ if (this.cureType._isReferenceType) {
22724
+ this.cureType._copyValue(this.referenceTargetValue, this.defaultValue);
22709
22725
  } else {
22710
22726
  this.defaultValue = this._assembler.getTargetValue();
22711
22727
  }
22712
- this.hasSavedDefaultValue = true;
22713
22728
  };
22714
22729
  _proto.saveFixedPoseValue = function saveFixedPoseValue() {
22715
- if (this._cureType._isReferenceType) {
22716
- this._cureType._copyValue(this.referenceTargetValue, this.fixedPoseValue);
22730
+ if (this.cureType._isReferenceType) {
22731
+ this.cureType._copyValue(this.referenceTargetValue, this.fixedPoseValue);
22717
22732
  } else {
22718
22733
  this.fixedPoseValue = this._assembler.getTargetValue();
22719
22734
  }
22720
22735
  };
22721
- _proto._applyValue = function _applyValue(value, weight) {
22722
- if (weight === 1.0) {
22723
- if (this._cureType._isReferenceType) {
22724
- this._cureType._copyValue(value, this.referenceTargetValue);
22736
+ _proto.applyValue = function applyValue(value, weight, additive) {
22737
+ var cureType = this.cureType;
22738
+ if (additive) {
22739
+ if (cureType._isReferenceType) {
22740
+ cureType._additiveValue(value, weight, this.referenceTargetValue);
22725
22741
  } else {
22726
- this._assembler.setTargetValue(value);
22742
+ var assembler = this._assembler;
22743
+ var originValue = assembler.getTargetValue();
22744
+ var additiveValue = cureType._additiveValue(value, weight, originValue);
22745
+ assembler.setTargetValue(additiveValue);
22727
22746
  }
22728
22747
  } else {
22729
- if (this._cureType._isReferenceType) {
22730
- var targetValue = this.referenceTargetValue;
22731
- this._cureType._lerpValue(targetValue, value, weight, targetValue);
22748
+ if (weight === 1.0) {
22749
+ if (cureType._isReferenceType) {
22750
+ cureType._copyValue(value, this.referenceTargetValue);
22751
+ } else {
22752
+ this._assembler.setTargetValue(value);
22753
+ }
22732
22754
  } else {
22733
- var originValue = this._assembler.getTargetValue();
22734
- var lerpValue = this._cureType._lerpValue(originValue, value, weight);
22735
- this._assembler.setTargetValue(lerpValue);
22755
+ if (cureType._isReferenceType) {
22756
+ var targetValue = this.referenceTargetValue;
22757
+ cureType._lerpValue(targetValue, value, weight, targetValue);
22758
+ } else {
22759
+ var originValue1 = this._assembler.getTargetValue();
22760
+ var lerpValue = cureType._lerpValue(originValue1, value, weight);
22761
+ this._assembler.setTargetValue(lerpValue);
22762
+ }
22736
22763
  }
22737
22764
  }
22738
22765
  };
22739
- _proto._applyCrossValue = function _applyCrossValue(srcValue, destValue, crossWeight, layerWeight, additive) {
22740
- var out;
22741
- if (this._cureType._isReferenceType) {
22742
- out = this.baseEvaluateData.value;
22743
- this._cureType._lerpValue(srcValue, destValue, crossWeight, out);
22744
- } else {
22745
- out = this._cureType._lerpValue(srcValue, destValue, crossWeight);
22746
- }
22747
- if (additive) {
22748
- if (this._cureType._isReferenceType) {
22749
- this._cureType._additiveValue(out, layerWeight, this.referenceTargetValue);
22750
- } else {
22751
- var originValue = this._assembler.getTargetValue();
22752
- var lerpValue = this._cureType._additiveValue(out, layerWeight, originValue);
22753
- this._assembler.setTargetValue(lerpValue);
22754
- }
22766
+ _proto._lerpValue = function _lerpValue(srcValue, destValue, crossWeight) {
22767
+ if (this.cureType._isReferenceType) {
22768
+ return this.cureType._lerpValue(srcValue, destValue, crossWeight, this.baseEvaluateData.value);
22755
22769
  } else {
22756
- this._applyValue(out, layerWeight);
22770
+ this.baseEvaluateData.value = this.cureType._lerpValue(srcValue, destValue, crossWeight);
22771
+ return this.baseEvaluateData.value;
22757
22772
  }
22758
22773
  };
22759
22774
  AnimationCurveOwner.registerAssembler = function registerAssembler(componentType, property, assemblerType) {
@@ -22849,9 +22864,24 @@ AnimationCurveOwner.registerAssembler(SkinnedMeshRenderer, "blendShapeWeights",
22849
22864
 
22850
22865
  /**
22851
22866
  * @internal
22852
- */ var AnimationCurveLayerOwner = function AnimationCurveLayerOwner() {
22853
- this.crossCurveMark = 0;
22854
- };
22867
+ */ var AnimationCurveLayerOwner = /*#__PURE__*/ function() {
22868
+ function AnimationCurveLayerOwner() {
22869
+ this.crossCurveMark = 0;
22870
+ }
22871
+ var _proto = AnimationCurveLayerOwner.prototype;
22872
+ _proto.initFinalValue = function initFinalValue() {
22873
+ var _this_curveOwner = this.curveOwner, cureType = _this_curveOwner.cureType, defaultValue = _this_curveOwner.defaultValue;
22874
+ if (cureType._isReferenceType) {
22875
+ cureType._copyValue(defaultValue, this.finalValue);
22876
+ } else {
22877
+ this.finalValue = defaultValue;
22878
+ }
22879
+ };
22880
+ _proto.saveFinalValue = function saveFinalValue() {
22881
+ this.finalValue = this.curveOwner.getEvaluateValue(this.finalValue);
22882
+ };
22883
+ return AnimationCurveLayerOwner;
22884
+ }();
22855
22885
 
22856
22886
  /**
22857
22887
  * Associate AnimationCurve and the Entity
@@ -22866,13 +22896,18 @@ AnimationCurveOwner.registerAssembler(SkinnedMeshRenderer, "blendShapeWeights",
22866
22896
  var curveType = this.curve.constructor;
22867
22897
  var owner = new AnimationCurveOwner(entity, this.type, this.property, curveType);
22868
22898
  curveType._initializeOwner(owner);
22899
+ owner.saveDefaultValue();
22869
22900
  return owner;
22870
22901
  };
22871
22902
  /**
22872
22903
  * @internal
22873
22904
  */ _proto._createCurveLayerOwner = function _createCurveLayerOwner(owner) {
22905
+ var curveType = this.curve.constructor;
22874
22906
  var layerOwner = new AnimationCurveLayerOwner();
22875
22907
  layerOwner.curveOwner = owner;
22908
+ curveType._initializeLayerOwner(layerOwner);
22909
+ // If curve.keys.length is 0, updateFinishedState will assign 0 to the target, causing an error, so initialize by assigning defaultValue to finalValue.
22910
+ layerOwner.initFinalValue();
22876
22911
  return layerOwner;
22877
22912
  };
22878
22913
  /**
@@ -22960,7 +22995,8 @@ AnimationCurveOwner.registerAssembler(SkinnedMeshRenderer, "blendShapeWeights",
22960
22995
  var targetEntity = entity.findByPath(curveData.relativePath);
22961
22996
  if (targetEntity) {
22962
22997
  var curveOwner = curveData._getTempCurveOwner(targetEntity);
22963
- curveOwner.evaluateAndApplyValue(curveData.curve, time, 1, false);
22998
+ var value = curveOwner.evaluateValue(curveData.curve, time, false);
22999
+ curveOwner.applyValue(value, 1, false);
22964
23000
  }
22965
23001
  }
22966
23002
  };
@@ -23104,6 +23140,7 @@ AnimationCurveOwner.registerAssembler(SkinnedMeshRenderer, "blendShapeWeights",
23104
23140
  break;
23105
23141
  }
23106
23142
  }
23143
+ evaluateData.value = value;
23107
23144
  return value;
23108
23145
  };
23109
23146
  /**
@@ -23160,6 +23197,11 @@ exports.AnimationArrayCurve = (_AnimationArrayCurve = /*#__PURE__*/ function(Ani
23160
23197
  };
23161
23198
  /**
23162
23199
  * @internal
23200
+ */ AnimationArrayCurve._initializeLayerOwner = function _initializeLayerOwner(owner) {
23201
+ owner.finalValue = [];
23202
+ };
23203
+ /**
23204
+ * @internal
23163
23205
  */ AnimationArrayCurve._lerpValue = function _lerpValue(srcValue, destValue, weight, out) {
23164
23206
  for(var i = 0, n = out.length; i < n; ++i){
23165
23207
  var src = srcValue[i];
@@ -23250,6 +23292,11 @@ exports.AnimationBoolCurve = (_AnimationBoolCurve = /*#__PURE__*/ function(Anima
23250
23292
  };
23251
23293
  /**
23252
23294
  * @internal
23295
+ */ AnimationBoolCurve._initializeLayerOwner = function _initializeLayerOwner(owner) {
23296
+ owner.finalValue = false;
23297
+ };
23298
+ /**
23299
+ * @internal
23253
23300
  */ AnimationBoolCurve._lerpValue = function _lerpValue(srcValue, destValue) {
23254
23301
  return destValue;
23255
23302
  };
@@ -23307,6 +23354,11 @@ exports.AnimationColorCurve = (_AnimationColorCurve = /*#__PURE__*/ function(Ani
23307
23354
  };
23308
23355
  /**
23309
23356
  * @internal
23357
+ */ AnimationColorCurve._initializeLayerOwner = function _initializeLayerOwner(owner) {
23358
+ owner.finalValue = new engineMath.Color();
23359
+ };
23360
+ /**
23361
+ * @internal
23310
23362
  */ AnimationColorCurve._lerpValue = function _lerpValue(srcValue, destValue, weight, out) {
23311
23363
  engineMath.Color.lerp(srcValue, destValue, weight, out);
23312
23364
  return out;
@@ -23413,6 +23465,12 @@ exports.AnimationFloatArrayCurve = (_AnimationFloatArrayCurve = /*#__PURE__*/ fu
23413
23465
  };
23414
23466
  /**
23415
23467
  * @internal
23468
+ */ AnimationFloatArrayCurve._initializeLayerOwner = function _initializeLayerOwner(owner) {
23469
+ var size = owner.curveOwner.referenceTargetValue.length;
23470
+ owner.finalValue = new Float32Array(size);
23471
+ };
23472
+ /**
23473
+ * @internal
23416
23474
  */ AnimationFloatArrayCurve._lerpValue = function _lerpValue(srcValue, destValue, weight, out) {
23417
23475
  for(var i = 0, n = out.length; i < n; ++i){
23418
23476
  var src = srcValue[i];
@@ -23503,6 +23561,11 @@ exports.AnimationFloatCurve = (_AnimationFloatCurve = /*#__PURE__*/ function(Ani
23503
23561
  };
23504
23562
  /**
23505
23563
  * @internal
23564
+ */ AnimationFloatCurve._initializeLayerOwner = function _initializeLayerOwner(owner) {
23565
+ owner.finalValue = 0;
23566
+ };
23567
+ /**
23568
+ * @internal
23506
23569
  */ AnimationFloatCurve._lerpValue = function _lerpValue(srcValue, destValue, crossWeight) {
23507
23570
  return srcValue + (destValue - srcValue) * crossWeight;
23508
23571
  };
@@ -23572,6 +23635,11 @@ exports.AnimationQuaternionCurve = (_AnimationQuaternionCurve = /*#__PURE__*/ fu
23572
23635
  };
23573
23636
  /**
23574
23637
  * @internal
23638
+ */ AnimationQuaternionCurve1._initializeLayerOwner = function _initializeLayerOwner(owner) {
23639
+ owner.finalValue = new engineMath.Quaternion();
23640
+ };
23641
+ /**
23642
+ * @internal
23575
23643
  */ AnimationQuaternionCurve1._lerpValue = function _lerpValue(src, dest, weight, out) {
23576
23644
  engineMath.Quaternion.slerp(src, dest, weight, out);
23577
23645
  return out;
@@ -23676,6 +23744,11 @@ exports.AnimationVector2Curve = (_AnimationVector2Curve = /*#__PURE__*/ function
23676
23744
  };
23677
23745
  /**
23678
23746
  * @internal
23747
+ */ AnimationVector2Curve._initializeLayerOwner = function _initializeLayerOwner(owner) {
23748
+ owner.finalValue = new engineMath.Vector2();
23749
+ };
23750
+ /**
23751
+ * @internal
23679
23752
  */ AnimationVector2Curve._lerpValue = function _lerpValue(srcValue, destValue, weight, out) {
23680
23753
  engineMath.Vector2.lerp(srcValue, destValue, weight, out);
23681
23754
  return out;
@@ -23761,6 +23834,11 @@ exports.AnimationVector3Curve = (_AnimationVector3Curve = /*#__PURE__*/ function
23761
23834
  };
23762
23835
  /**
23763
23836
  * @internal
23837
+ */ AnimationVector3Curve._initializeLayerOwner = function _initializeLayerOwner(owner) {
23838
+ owner.finalValue = new engineMath.Vector3();
23839
+ };
23840
+ /**
23841
+ * @internal
23764
23842
  */ AnimationVector3Curve._lerpValue = function _lerpValue(srcValue, destValue, weight, out) {
23765
23843
  engineMath.Vector3.lerp(srcValue, destValue, weight, out);
23766
23844
  return out;
@@ -23858,6 +23936,11 @@ exports.AnimationVector4Curve = (_AnimationVector4Curve = /*#__PURE__*/ function
23858
23936
  };
23859
23937
  /**
23860
23938
  * @internal
23939
+ */ AnimationVector4Curve._initializeLayerOwner = function _initializeLayerOwner(owner) {
23940
+ owner.finalValue = new engineMath.Vector4();
23941
+ };
23942
+ /**
23943
+ * @internal
23861
23944
  */ AnimationVector4Curve._lerpValue = function _lerpValue(srcValue, destValue, weight, out) {
23862
23945
  engineMath.Vector4.lerp(srcValue, destValue, weight, out);
23863
23946
  return out;
@@ -23967,6 +24050,7 @@ exports.AnimatorLayerBlendingMode = void 0;
23967
24050
  LayerState[LayerState[/** Playing state. */ "Playing"] = 1] = "Playing";
23968
24051
  LayerState[LayerState[/** CrossFading state. */ "CrossFading"] = 2] = "CrossFading";
23969
24052
  LayerState[LayerState[/** FixedCrossFading state. */ "FixedCrossFading"] = 3] = "FixedCrossFading";
24053
+ LayerState[LayerState[/** Finished state. */ "Finished"] = 4] = "Finished";
23970
24054
  })(LayerState || (LayerState = {}));
23971
24055
 
23972
24056
  /**
@@ -24043,7 +24127,7 @@ exports.AnimatorLayerBlendingMode = void 0;
24043
24127
  this.layerState = LayerState.Standby;
24044
24128
  this.crossCurveMark = 0;
24045
24129
  this.manuallyTransition = new AnimatorStateTransition();
24046
- this.crossOwnerLayerDataCollection = [];
24130
+ this.crossLayerOwnerCollection = [];
24047
24131
  }
24048
24132
  var _proto = AnimatorLayerData.prototype;
24049
24133
  _proto.switchPlayData = function switchPlayData() {
@@ -24073,6 +24157,7 @@ exports.AnimatorLayerBlendingMode = void 0;
24073
24157
  /** The playback speed of the Animator, 1.0 is normal playback speed. */ _this.speed = 1.0;
24074
24158
  _this._animatorLayersData = [];
24075
24159
  _this._curveOwnerPool = Object.create(null);
24160
+ _this._needRevertCurveOwners = [];
24076
24161
  _this._animationEventHandlerPool = new ClassPool(AnimationEventHandler);
24077
24162
  _this._tempAnimatorStateInfo = {
24078
24163
  layerIndex: -1,
@@ -24095,7 +24180,7 @@ exports.AnimatorLayerBlendingMode = void 0;
24095
24180
  this._reset();
24096
24181
  }
24097
24182
  var stateInfo = this._getAnimatorStateInfo(stateName, layerIndex);
24098
- var state = stateInfo.state;
24183
+ var state = stateInfo.state, playLayerIndex = stateInfo.layerIndex;
24099
24184
  if (!state) {
24100
24185
  return;
24101
24186
  }
@@ -24104,8 +24189,8 @@ exports.AnimatorLayerBlendingMode = void 0;
24104
24189
  return;
24105
24190
  }
24106
24191
  var animatorLayerData = this._getAnimatorLayerData(stateInfo.layerIndex);
24107
- var animatorStateData = this._getAnimatorStateData(stateName, state, animatorLayerData);
24108
- this._preparePlay(animatorLayerData, state, animatorStateData);
24192
+ var animatorStateData = this._getAnimatorStateData(stateName, state, animatorLayerData, playLayerIndex);
24193
+ this._preparePlay(animatorLayerData, state);
24109
24194
  animatorLayerData.layerState = LayerState.Playing;
24110
24195
  animatorLayerData.srcPlayData.reset(state, animatorStateData, state._getDuration() * normalizedTimeOffset);
24111
24196
  };
@@ -24156,6 +24241,7 @@ exports.AnimatorLayerBlendingMode = void 0;
24156
24241
  return;
24157
24242
  }
24158
24243
  deltaTime *= this.speed;
24244
+ this._revertCurveOwners();
24159
24245
  for(var i1 = 0, n1 = animatorController.layers.length; i1 < n1; i1++){
24160
24246
  var animatorLayerData = this._getAnimatorLayerData(i1);
24161
24247
  if (animatorLayerData.layerState === LayerState.Standby) {
@@ -24199,10 +24285,11 @@ exports.AnimatorLayerBlendingMode = void 0;
24199
24285
  var propertyOwners = animationCurveOwners[instanceId];
24200
24286
  for(var property in propertyOwners){
24201
24287
  var owner = propertyOwners[property];
24202
- owner.hasSavedDefaultValue && owner.revertDefaultValue();
24288
+ owner.revertDefaultValue();
24203
24289
  }
24204
24290
  }
24205
24291
  this._animatorLayersData.length = 0;
24292
+ this._needRevertCurveOwners.length = 0;
24206
24293
  this._curveOwnerPool = {};
24207
24294
  this._animationEventHandlerPool.resetPool();
24208
24295
  if (this._controllerUpdateFlag) {
@@ -24230,25 +24317,18 @@ exports.AnimatorLayerBlendingMode = void 0;
24230
24317
  stateInfo.state = state;
24231
24318
  return stateInfo;
24232
24319
  };
24233
- _proto._saveDefaultValues = function _saveDefaultValues(stateData) {
24234
- var curveLayerOwner = stateData.curveLayerOwner;
24235
- for(var i = curveLayerOwner.length - 1; i >= 0; i--){
24236
- var _curveLayerOwner_i;
24237
- (_curveLayerOwner_i = curveLayerOwner[i]) == null ? void 0 : _curveLayerOwner_i.curveOwner.saveDefaultValue();
24238
- }
24239
- };
24240
- _proto._getAnimatorStateData = function _getAnimatorStateData(stateName, animatorState, animatorLayerData) {
24320
+ _proto._getAnimatorStateData = function _getAnimatorStateData(stateName, animatorState, animatorLayerData, layerIndex) {
24241
24321
  var animatorStateDataMap = animatorLayerData.animatorStateDataMap;
24242
24322
  var animatorStateData = animatorStateDataMap[stateName];
24243
24323
  if (!animatorStateData) {
24244
24324
  animatorStateData = new AnimatorStateData();
24245
24325
  animatorStateDataMap[stateName] = animatorStateData;
24246
- this._saveAnimatorStateData(animatorState, animatorStateData, animatorLayerData);
24326
+ this._saveAnimatorStateData(animatorState, animatorStateData, animatorLayerData, layerIndex);
24247
24327
  this._saveAnimatorEventHandlers(animatorState, animatorStateData);
24248
24328
  }
24249
24329
  return animatorStateData;
24250
24330
  };
24251
- _proto._saveAnimatorStateData = function _saveAnimatorStateData(animatorState, animatorStateData, animatorLayerData) {
24331
+ _proto._saveAnimatorStateData = function _saveAnimatorStateData(animatorState, animatorStateData, animatorLayerData, layerIndex) {
24252
24332
  var _this = this, entity = _this.entity, curveOwnerPool = _this._curveOwnerPool;
24253
24333
  var curveLayerOwner = animatorStateData.curveLayerOwner;
24254
24334
  var layerCurveOwnerPool = animatorLayerData.curveOwnerPool;
@@ -24260,9 +24340,22 @@ exports.AnimatorLayerBlendingMode = void 0;
24260
24340
  var _curveOwnerPool, _instanceId, _propertyOwners, _property, _layerCurveOwnerPool, _instanceId1, _layerPropertyOwners, _property1;
24261
24341
  var property = curve.property;
24262
24342
  var instanceId = targetEntity.instanceId;
24343
+ var needRevert = false;
24344
+ var baseAnimatorLayerData = this._animatorLayersData[0];
24345
+ var baseLayerCurveOwnerPool = baseAnimatorLayerData.curveOwnerPool;
24346
+ if (this.animatorController.layers[layerIndex].blendingMode === exports.AnimatorLayerBlendingMode.Additive && layerIndex > 0 && !(baseLayerCurveOwnerPool[instanceId] && baseLayerCurveOwnerPool[instanceId][property])) {
24347
+ needRevert = true;
24348
+ }
24263
24349
  // Get owner
24264
24350
  var propertyOwners = (_curveOwnerPool = curveOwnerPool)[_instanceId = instanceId] || (_curveOwnerPool[_instanceId] = Object.create(null));
24265
24351
  var owner = (_propertyOwners = propertyOwners)[_property = property] || (_propertyOwners[_property] = curve._createCurveOwner(targetEntity));
24352
+ //@todo: There is performance waste here, which will be handled together with organizing AnimatorStateData later. The logic is changing from runtime to initialization.
24353
+ if (needRevert) {
24354
+ this._needRevertCurveOwners.push(owner);
24355
+ } else {
24356
+ var index = this._needRevertCurveOwners.indexOf(owner);
24357
+ index > -1 && this._needRevertCurveOwners.splice(index, 1);
24358
+ }
24266
24359
  // Get layer owner
24267
24360
  var layerPropertyOwners = (_layerCurveOwnerPool = layerCurveOwnerPool)[_instanceId1 = instanceId] || (_layerCurveOwnerPool[_instanceId1] = Object.create(null));
24268
24361
  var layerOwner = (_layerPropertyOwners = layerPropertyOwners)[_property1 = property] || (_layerPropertyOwners[_property1] = curve._createCurveLayerOwner(owner));
@@ -24296,12 +24389,12 @@ exports.AnimatorLayerBlendingMode = void 0;
24296
24389
  };
24297
24390
  _proto._clearCrossData = function _clearCrossData(animatorLayerData) {
24298
24391
  animatorLayerData.crossCurveMark++;
24299
- animatorLayerData.crossOwnerLayerDataCollection.length = 0;
24392
+ animatorLayerData.crossLayerOwnerCollection.length = 0;
24300
24393
  };
24301
24394
  _proto._addCrossOwner = function _addCrossOwner(animatorLayerData, layerOwner, curCurveIndex, nextCurveIndex) {
24302
24395
  layerOwner.crossSrcCurveIndex = curCurveIndex;
24303
24396
  layerOwner.crossDestCurveIndex = nextCurveIndex;
24304
- animatorLayerData.crossOwnerLayerDataCollection.push(layerOwner);
24397
+ animatorLayerData.crossLayerOwnerCollection.push(layerOwner);
24305
24398
  };
24306
24399
  _proto._prepareCrossFading = function _prepareCrossFading(animatorLayerData) {
24307
24400
  // Add src cross curve data.
@@ -24316,10 +24409,10 @@ exports.AnimatorLayerBlendingMode = void 0;
24316
24409
  this._prepareDestCrossData(animatorLayerData, true);
24317
24410
  };
24318
24411
  _proto._prepareFixedPoseCrossFading = function _prepareFixedPoseCrossFading(animatorLayerData) {
24319
- var crossOwnerLayerDataCollection = animatorLayerData.crossOwnerLayerDataCollection;
24412
+ var crossLayerOwnerCollection = animatorLayerData.crossLayerOwnerCollection;
24320
24413
  // Save current cross curve data owner fixed pose.
24321
- for(var i = crossOwnerLayerDataCollection.length - 1; i >= 0; i--){
24322
- var layerOwner = crossOwnerLayerDataCollection[i];
24414
+ for(var i = crossLayerOwnerCollection.length - 1; i >= 0; i--){
24415
+ var layerOwner = crossLayerOwnerCollection[i];
24323
24416
  if (!layerOwner) continue;
24324
24417
  layerOwner.curveOwner.saveFixedPoseValue();
24325
24418
  // Reset destCurveIndex When fixed pose crossFading again.
@@ -24347,7 +24440,6 @@ exports.AnimatorLayerBlendingMode = void 0;
24347
24440
  layerOwner.crossDestCurveIndex = i;
24348
24441
  } else {
24349
24442
  var owner = layerOwner.curveOwner;
24350
- owner.saveDefaultValue();
24351
24443
  saveFixed && owner.saveFixedPoseValue();
24352
24444
  layerOwner.crossCurveMark = animatorLayerData.crossCurveMark;
24353
24445
  this._addCrossOwner(animatorLayerData, layerOwner, -1, i);
@@ -24365,7 +24457,7 @@ exports.AnimatorLayerBlendingMode = void 0;
24365
24457
  var srcPlayData = layerData.srcPlayData, destPlayData = layerData.destPlayData, crossFadeTransitionInfo = layerData.crossFadeTransition;
24366
24458
  var additive = blendingMode === exports.AnimatorLayerBlendingMode.Additive;
24367
24459
  firstLayer && (weight = 1.0);
24368
- //TODO: 任意情况都应该检查,后面要优化
24460
+ //@todo: All situations should be checked, optimizations will follow later.
24369
24461
  layerData.layerState !== LayerState.FixedCrossFading && this._checkTransition(srcPlayData, crossFadeTransitionInfo, layerIndex);
24370
24462
  switch(layerData.layerState){
24371
24463
  case LayerState.Playing:
@@ -24377,6 +24469,9 @@ exports.AnimatorLayerBlendingMode = void 0;
24377
24469
  case LayerState.CrossFading:
24378
24470
  this._updateCrossFade(srcPlayData, destPlayData, layerData, layerIndex, weight, deltaTime, additive, aniUpdate);
24379
24471
  break;
24472
+ case LayerState.Finished:
24473
+ this._updateFinishedState(srcPlayData, weight, additive, aniUpdate);
24474
+ break;
24380
24475
  }
24381
24476
  };
24382
24477
  _proto._updatePlayingState = function _updatePlayingState(playData, layerData, layerIndex, weight, delta, additive, aniUpdate) {
@@ -24384,19 +24479,26 @@ exports.AnimatorLayerBlendingMode = void 0;
24384
24479
  var state = playData.state, lastPlayState = playData.playState, lastClipTime = playData.clipTime;
24385
24480
  var _state_clip = state.clip, curveBindings = _state_clip._curveBindings;
24386
24481
  playData.update(this.speed < 0);
24387
- if (!aniUpdate) {
24388
- return;
24389
- }
24390
24482
  var clipTime = playData.clipTime, playState = playData.playState;
24391
- eventHandlers.length && this._fireAnimationEvents(playData, eventHandlers, lastClipTime, clipTime);
24392
- for(var i = curveBindings.length - 1; i >= 0; i--){
24393
- var _curveLayerOwner_i;
24394
- (_curveLayerOwner_i = curveLayerOwner[i]) == null ? void 0 : _curveLayerOwner_i.curveOwner.evaluateAndApplyValue(curveBindings[i].curve, clipTime, weight, additive);
24483
+ var finished = playState === AnimatorStatePlayState.Finished;
24484
+ if (aniUpdate || finished) {
24485
+ for(var i = curveBindings.length - 1; i >= 0; i--){
24486
+ var layerOwner = curveLayerOwner[i];
24487
+ var owner = layerOwner == null ? void 0 : layerOwner.curveOwner;
24488
+ if (!owner) continue;
24489
+ var curve = curveBindings[i].curve;
24490
+ if (curve.keys.length) {
24491
+ var value = owner.evaluateValue(curve, clipTime, additive);
24492
+ aniUpdate && owner.applyValue(value, weight, additive);
24493
+ finished && layerOwner.saveFinalValue();
24494
+ }
24495
+ }
24395
24496
  }
24396
24497
  playData.frameTime += state.speed * delta;
24397
24498
  if (playState === AnimatorStatePlayState.Finished) {
24398
- layerData.layerState = LayerState.Standby;
24499
+ layerData.layerState = LayerState.Finished;
24399
24500
  }
24501
+ eventHandlers.length && this._fireAnimationEvents(playData, eventHandlers, lastClipTime, clipTime);
24400
24502
  if (lastPlayState === AnimatorStatePlayState.UnStarted) {
24401
24503
  this._callAnimatorScriptOnEnter(state, layerIndex);
24402
24504
  }
@@ -24407,7 +24509,7 @@ exports.AnimatorLayerBlendingMode = void 0;
24407
24509
  }
24408
24510
  };
24409
24511
  _proto._updateCrossFade = function _updateCrossFade(srcPlayData, destPlayData, layerData, layerIndex, weight, delta, additive, aniUpdate) {
24410
- var crossOwnerLayerDataCollection = layerData.crossOwnerLayerDataCollection;
24512
+ var crossLayerOwnerCollection = layerData.crossLayerOwnerCollection;
24411
24513
  var _srcPlayData_state_clip = srcPlayData.state.clip, srcCurves = _srcPlayData_state_clip._curveBindings;
24412
24514
  var srcState = srcPlayData.state, srcStateData = srcPlayData.stateData, lastSrcPlayState = srcPlayData.playState;
24413
24515
  var srcEventHandlers = srcStateData.eventHandlers;
@@ -24416,18 +24518,27 @@ exports.AnimatorLayerBlendingMode = void 0;
24416
24518
  var _destState_clip = destState.clip, destCurves = _destState_clip._curveBindings;
24417
24519
  var lastSrcClipTime = srcPlayData.clipTime;
24418
24520
  var lastDestClipTime = destPlayData.clipTime;
24419
- var crossWeight = Math.abs(destPlayData.frameTime) / (destState._getDuration() * layerData.crossFadeTransition.duration);
24420
- crossWeight >= 1.0 && (crossWeight = 1.0);
24521
+ var duration = destState._getDuration() * layerData.crossFadeTransition.duration;
24522
+ var crossWeight = Math.abs(destPlayData.frameTime) / duration;
24523
+ (crossWeight >= 1.0 || duration === 0) && (crossWeight = 1.0);
24421
24524
  srcPlayData.update(this.speed < 0);
24422
24525
  destPlayData.update(this.speed < 0);
24423
- var srcPlayState = srcPlayData.playState;
24424
- var destPlayState = destPlayData.playState;
24425
- this._updateCrossFadeData(layerData, crossWeight, delta, false);
24426
- if (!aniUpdate) {
24427
- return;
24526
+ var srcClipTime = srcPlayData.clipTime, srcPlayState = srcPlayData.playState;
24527
+ var destClipTime = destPlayData.clipTime, destPlayState = destPlayData.playState;
24528
+ var finished = destPlayData.playState === AnimatorStatePlayState.Finished;
24529
+ if (aniUpdate || finished) {
24530
+ for(var i = crossLayerOwnerCollection.length - 1; i >= 0; i--){
24531
+ var layerOwner = crossLayerOwnerCollection[i];
24532
+ var owner = layerOwner == null ? void 0 : layerOwner.curveOwner;
24533
+ if (!owner) continue;
24534
+ var srcCurveIndex = layerOwner.crossSrcCurveIndex;
24535
+ var destCurveIndex = layerOwner.crossDestCurveIndex;
24536
+ var value = owner.evaluateCrossFadeValue(srcCurveIndex >= 0 ? srcCurves[srcCurveIndex].curve : null, destCurveIndex >= 0 ? destCurves[destCurveIndex].curve : null, srcClipTime, destClipTime, crossWeight, additive);
24537
+ aniUpdate && owner.applyValue(value, weight, additive);
24538
+ finished && layerOwner.saveFinalValue();
24539
+ }
24428
24540
  }
24429
- var srcClipTime = srcPlayData.clipTime;
24430
- var destClipTime = destPlayData.clipTime;
24541
+ this._updateCrossFadeData(layerData, crossWeight, delta, false);
24431
24542
  srcEventHandlers.length && this._fireAnimationEvents(srcPlayData, srcEventHandlers, lastSrcClipTime, srcClipTime);
24432
24543
  destEventHandlers.length && this._fireAnimationEvents(destPlayData, destEventHandlers, lastDestClipTime, destClipTime);
24433
24544
  if (lastSrcPlayState === AnimatorStatePlayState.UnStarted) {
@@ -24446,30 +24557,34 @@ exports.AnimatorLayerBlendingMode = void 0;
24446
24557
  } else {
24447
24558
  this._callAnimatorScriptOnUpdate(destState, layerIndex);
24448
24559
  }
24449
- for(var i = crossOwnerLayerDataCollection.length - 1; i >= 0; i--){
24450
- var layerOwner = crossOwnerLayerDataCollection[i];
24451
- if (!layerOwner) continue;
24452
- var srcCurveIndex = layerOwner.crossSrcCurveIndex;
24453
- var destCurveIndex = layerOwner.crossDestCurveIndex;
24454
- layerOwner.curveOwner.crossFadeAndApplyValue(srcCurveIndex >= 0 ? srcCurves[srcCurveIndex].curve : null, destCurveIndex >= 0 ? destCurves[destCurveIndex].curve : null, srcClipTime, destClipTime, crossWeight, weight, additive);
24455
- }
24456
24560
  };
24457
- _proto._updateCrossFadeFromPose = function _updateCrossFadeFromPose(destPlayData, layerData, layerIndex, layerWeight, delta, additive, aniUpdate) {
24458
- var crossOwnerLayerDataCollection = layerData.crossOwnerLayerDataCollection;
24561
+ _proto._updateCrossFadeFromPose = function _updateCrossFadeFromPose(destPlayData, layerData, layerIndex, weight, delta, additive, aniUpdate) {
24562
+ var crossLayerOwnerCollection = layerData.crossLayerOwnerCollection;
24459
24563
  var state = destPlayData.state, stateData = destPlayData.stateData, lastPlayState = destPlayData.playState;
24460
24564
  var eventHandlers = stateData.eventHandlers;
24461
24565
  var _state_clip = state.clip, curveBindings = _state_clip._curveBindings;
24462
24566
  var lastDestClipTime = destPlayData.clipTime;
24463
- var crossWeight = Math.abs(destPlayData.frameTime) / (state._getDuration() * layerData.crossFadeTransition.duration);
24464
- crossWeight >= 1.0 && (crossWeight = 1.0);
24567
+ var duration = state._getDuration() * layerData.crossFadeTransition.duration;
24568
+ var crossWeight = Math.abs(destPlayData.frameTime) / duration;
24569
+ (crossWeight >= 1.0 || duration === 0) && (crossWeight = 1.0);
24465
24570
  destPlayData.update(this.speed < 0);
24466
24571
  var playState = destPlayData.playState;
24467
24572
  this._updateCrossFadeData(layerData, crossWeight, delta, true);
24468
- if (!aniUpdate) {
24469
- return;
24470
- }
24471
24573
  var destClipTime = destPlayData.clipTime;
24472
- //TODO: srcState 少了最新一段时间的判断
24574
+ var finished = playState === AnimatorStatePlayState.Finished;
24575
+ // When the animator is culled (aniUpdate=false), if the play state has finished, the final value needs to be calculated and saved to be applied directly.
24576
+ if (aniUpdate || finished) {
24577
+ for(var i = crossLayerOwnerCollection.length - 1; i >= 0; i--){
24578
+ var layerOwner = crossLayerOwnerCollection[i];
24579
+ var owner = layerOwner == null ? void 0 : layerOwner.curveOwner;
24580
+ if (!owner) continue;
24581
+ var curveIndex = layerOwner.crossDestCurveIndex;
24582
+ var value = layerOwner.curveOwner.crossFadeFromPoseAndApplyValue(curveIndex >= 0 ? curveBindings[curveIndex].curve : null, destClipTime, crossWeight, additive);
24583
+ aniUpdate && owner.applyValue(value, weight, additive);
24584
+ finished && layerOwner.saveFinalValue();
24585
+ }
24586
+ }
24587
+ //@todo: srcState is missing the judgment of the most recent period."
24473
24588
  eventHandlers.length && this._fireAnimationEvents(destPlayData, eventHandlers, lastDestClipTime, destClipTime);
24474
24589
  if (lastPlayState === AnimatorStatePlayState.UnStarted) {
24475
24590
  this._callAnimatorScriptOnEnter(state, layerIndex);
@@ -24479,11 +24594,18 @@ exports.AnimatorLayerBlendingMode = void 0;
24479
24594
  } else {
24480
24595
  this._callAnimatorScriptOnUpdate(state, layerIndex);
24481
24596
  }
24482
- for(var i = crossOwnerLayerDataCollection.length - 1; i >= 0; i--){
24483
- var layerOwner = crossOwnerLayerDataCollection[i];
24484
- if (!layerOwner) continue;
24485
- var curveIndex = layerOwner.crossDestCurveIndex;
24486
- layerOwner.curveOwner.crossFadeFromPoseAndApplyValue(curveIndex >= 0 ? curveBindings[curveIndex].curve : null, destClipTime, crossWeight, layerWeight, additive);
24597
+ };
24598
+ _proto._updateFinishedState = function _updateFinishedState(playData, weight, additive, aniUpdate) {
24599
+ if (!aniUpdate) {
24600
+ return;
24601
+ }
24602
+ var curveLayerOwner = playData.stateData.curveLayerOwner;
24603
+ var _playData_state_clip = playData.state.clip, curveBindings = _playData_state_clip._curveBindings;
24604
+ for(var i = curveBindings.length - 1; i >= 0; i--){
24605
+ var layerOwner = curveLayerOwner[i];
24606
+ var owner = layerOwner == null ? void 0 : layerOwner.curveOwner;
24607
+ if (!owner) continue;
24608
+ owner.applyValue(layerOwner.finalValue, weight, additive);
24487
24609
  }
24488
24610
  };
24489
24611
  _proto._updateCrossFadeData = function _updateCrossFadeData(layerData, crossWeight, delta, fixed) {
@@ -24491,7 +24613,7 @@ exports.AnimatorLayerBlendingMode = void 0;
24491
24613
  destPlayData.frameTime += destPlayData.state.speed * delta;
24492
24614
  if (crossWeight === 1.0) {
24493
24615
  if (destPlayData.playState === AnimatorStatePlayState.Finished) {
24494
- layerData.layerState = LayerState.Standby;
24616
+ layerData.layerState = LayerState.Finished;
24495
24617
  } else {
24496
24618
  layerData.layerState = LayerState.Playing;
24497
24619
  }
@@ -24501,7 +24623,7 @@ exports.AnimatorLayerBlendingMode = void 0;
24501
24623
  fixed || (layerData.srcPlayData.frameTime += layerData.srcPlayData.state.speed * delta);
24502
24624
  }
24503
24625
  };
24504
- _proto._preparePlay = function _preparePlay(layerData, playState, playStateData) {
24626
+ _proto._preparePlay = function _preparePlay(layerData, playState) {
24505
24627
  if (layerData.layerState === LayerState.Playing) {
24506
24628
  var srcPlayData = layerData.srcPlayData;
24507
24629
  if (srcPlayData.state !== playState) {
@@ -24509,18 +24631,16 @@ exports.AnimatorLayerBlendingMode = void 0;
24509
24631
  for(var i = curveLayerOwner.length - 1; i >= 0; i--){
24510
24632
  var _curveLayerOwner_i;
24511
24633
  var owner = (_curveLayerOwner_i = curveLayerOwner[i]) == null ? void 0 : _curveLayerOwner_i.curveOwner;
24512
- (owner == null ? void 0 : owner.hasSavedDefaultValue) && owner.revertDefaultValue();
24634
+ owner.revertDefaultValue();
24513
24635
  }
24514
- this._saveDefaultValues(playStateData);
24515
24636
  }
24516
24637
  } else {
24517
- // layerState is CrossFading, FixedCrossFading, Standby
24518
- var crossOwnerLayerDataCollection = layerData.crossOwnerLayerDataCollection;
24519
- for(var i1 = crossOwnerLayerDataCollection.length - 1; i1 >= 0; i1--){
24520
- var owner1 = crossOwnerLayerDataCollection[i1].curveOwner;
24521
- owner1.hasSavedDefaultValue && owner1.revertDefaultValue();
24638
+ // layerState is CrossFading, FixedCrossFading, Standby, Finished
24639
+ var crossLayerOwnerCollection = layerData.crossLayerOwnerCollection;
24640
+ for(var i1 = crossLayerOwnerCollection.length - 1; i1 >= 0; i1--){
24641
+ var owner1 = crossLayerOwnerCollection[i1].curveOwner;
24642
+ owner1.revertDefaultValue();
24522
24643
  }
24523
- this._saveDefaultValues(playStateData);
24524
24644
  }
24525
24645
  };
24526
24646
  _proto._checkTransition = function _checkTransition(stateData, crossFadeTransition, layerIndex) {
@@ -24537,7 +24657,7 @@ exports.AnimatorLayerBlendingMode = void 0;
24537
24657
  _proto._crossFadeByTransition = function _crossFadeByTransition(transition, layerIndex) {
24538
24658
  var name = transition.destinationState.name;
24539
24659
  var stateInfo = this._getAnimatorStateInfo(name, layerIndex);
24540
- var crossState = stateInfo.state;
24660
+ var crossState = stateInfo.state, playLayerIndex = stateInfo.layerIndex;
24541
24661
  if (!crossState) {
24542
24662
  return;
24543
24663
  }
@@ -24545,21 +24665,21 @@ exports.AnimatorLayerBlendingMode = void 0;
24545
24665
  console.warn("The state named " + name + " has no AnimationClip data.");
24546
24666
  return;
24547
24667
  }
24548
- var animatorLayerData = this._getAnimatorLayerData(stateInfo.layerIndex);
24668
+ var animatorLayerData = this._getAnimatorLayerData(playLayerIndex);
24549
24669
  var layerState = animatorLayerData.layerState;
24550
24670
  var destPlayData = animatorLayerData.destPlayData;
24551
- var animatorStateData = this._getAnimatorStateData(name, crossState, animatorLayerData);
24671
+ var animatorStateData = this._getAnimatorStateData(name, crossState, animatorLayerData, playLayerIndex);
24552
24672
  var duration = crossState._getDuration();
24553
24673
  var offset = duration * transition.offset;
24554
24674
  destPlayData.reset(crossState, animatorStateData, offset);
24555
24675
  switch(layerState){
24556
- // Maybe not play, maybe end.
24557
24676
  case LayerState.Standby:
24558
24677
  animatorLayerData.layerState = LayerState.FixedCrossFading;
24559
24678
  this._clearCrossData(animatorLayerData);
24560
24679
  this._prepareStandbyCrossFading(animatorLayerData);
24561
24680
  break;
24562
24681
  case LayerState.Playing:
24682
+ case LayerState.Finished:
24563
24683
  animatorLayerData.layerState = LayerState.CrossFading;
24564
24684
  this._clearCrossData(animatorLayerData);
24565
24685
  this._prepareCrossFading(animatorLayerData);
@@ -24656,6 +24776,12 @@ exports.AnimatorLayerBlendingMode = void 0;
24656
24776
  }
24657
24777
  }
24658
24778
  };
24779
+ _proto._revertCurveOwners = function _revertCurveOwners() {
24780
+ var curveOwners = this._needRevertCurveOwners;
24781
+ for(var i = 0, n = curveOwners.length; i < n; ++i){
24782
+ curveOwners[i].revertDefaultValue();
24783
+ }
24784
+ };
24659
24785
  _create_class(Animator, [
24660
24786
  {
24661
24787
  key: "animatorController",
@@ -24688,6 +24814,9 @@ __decorate([
24688
24814
  __decorate([
24689
24815
  ignoreClone
24690
24816
  ], Animator.prototype, "_curveOwnerPool", void 0);
24817
+ __decorate([
24818
+ ignoreClone
24819
+ ], Animator.prototype, "_needRevertCurveOwners", void 0);
24691
24820
  __decorate([
24692
24821
  ignoreClone
24693
24822
  ], Animator.prototype, "_animationEventHandlerPool", void 0);