@galacean/engine-physics-physx 0.9.12 → 0.9.14

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.
@@ -2285,6 +2285,28 @@ var /** @internal */ PromiseState;
2285
2285
  * @remarks The release principle is that it is not referenced by the components, including direct and indirect reference.
2286
2286
  */ _proto.gc = function gc() {
2287
2287
  this._gc(false);
2288
+ var engine = this.engine;
2289
+ engine._renderElementPool.garbageCollection();
2290
+ engine._spriteElementPool.garbageCollection();
2291
+ engine._spriteMaskElementPool.garbageCollection();
2292
+ engine._textElementPool.garbageCollection();
2293
+ var _componentsManager = engine._componentsManager, _lightManager = engine._lightManager;
2294
+ _componentsManager._renderers.garbageCollection();
2295
+ // @ts-ignore
2296
+ _componentsManager._onStartScripts.garbageCollection();
2297
+ // @ts-ignore
2298
+ _componentsManager._onUpdateScripts.garbageCollection();
2299
+ // @ts-ignore
2300
+ _componentsManager._onLateUpdateScripts.garbageCollection();
2301
+ // @ts-ignore
2302
+ _componentsManager._onPhysicsUpdateScripts.garbageCollection();
2303
+ // @ts-ignore
2304
+ _componentsManager._onUpdateAnimations.garbageCollection();
2305
+ // @ts-ignore
2306
+ _componentsManager._onUpdateRenderers.garbageCollection();
2307
+ _lightManager._spotLights.garbageCollection();
2308
+ _lightManager._pointLights.garbageCollection();
2309
+ _lightManager._directLights.garbageCollection();
2288
2310
  };
2289
2311
  /**
2290
2312
  * @internal
@@ -4115,6 +4137,11 @@ var TransformModifyFlags;
4115
4137
  * @returns Cloned entity
4116
4138
  */ _proto.clone = function clone() {
4117
4139
  var cloneEntity = new Entity(this._engine, this.name);
4140
+ var _this = this, hookResource = _this._hookResource;
4141
+ if (hookResource) {
4142
+ cloneEntity._hookResource = hookResource;
4143
+ hookResource._addRefCount(1);
4144
+ }
4118
4145
  cloneEntity._isActive = this._isActive;
4119
4146
  cloneEntity.transform.localMatrix = this.transform.localMatrix;
4120
4147
  var children = this._children;
@@ -4139,6 +4166,10 @@ var TransformModifyFlags;
4139
4166
  return;
4140
4167
  }
4141
4168
  EngineObject.prototype.destroy.call(this);
4169
+ if (this._hookResource) {
4170
+ this._hookResource._addRefCount(-1);
4171
+ this._hookResource = null;
4172
+ }
4142
4173
  var components = this._components;
4143
4174
  for(var i = components.length - 1; i >= 0; i--){
4144
4175
  components[i].destroy();
@@ -9685,9 +9716,9 @@ __decorate$1([
9685
9716
  var Material = function Material(engine, shader) {
9686
9717
  var _this;
9687
9718
  _this = RefObject.call(this, engine) || this;
9688
- /** Shader data. */ _this.shaderData = new ShaderData(ShaderDataGroup.Material);
9689
9719
  /** @internal */ _this._renderStates = [] // todo: later will as a part of shaderData when shader effect frame is OK, that is more powerful and flexible.
9690
9720
  ;
9721
+ _this._shaderData = new ShaderData(ShaderDataGroup.Material);
9691
9722
  _this.shader = shader;
9692
9723
  return _this;
9693
9724
  };
@@ -9720,8 +9751,21 @@ __decorate$1([
9720
9751
  */ _proto._preRender = function _preRender(renderElement) {};
9721
9752
  /**
9722
9753
  * @override
9723
- */ _proto._onDestroy = function _onDestroy() {};
9754
+ */ _proto._onDestroy = function _onDestroy() {
9755
+ this._shader = null;
9756
+ this._shaderData = null;
9757
+ this._renderStates.length = 0;
9758
+ this._renderStates = null;
9759
+ };
9724
9760
  _create_class$2(Material, [
9761
+ {
9762
+ key: "shaderData",
9763
+ get: /**
9764
+ * Shader data.
9765
+ */ function get() {
9766
+ return this._shaderData;
9767
+ }
9768
+ },
9725
9769
  {
9726
9770
  key: "shader",
9727
9771
  get: /**
@@ -9789,6 +9833,12 @@ __decorate$1([
9789
9833
  */ _proto.resetPool = function resetPool() {
9790
9834
  this._elementPoolIndex = 0;
9791
9835
  };
9836
+ _proto.garbageCollection = function garbageCollection() {
9837
+ var _this = this, pool = _this._elementPool;
9838
+ for(var i = pool.length - 1; i >= 0; i--){
9839
+ pool[i].dispose && pool[i].dispose();
9840
+ }
9841
+ };
9792
9842
  return ClassPool;
9793
9843
  }();
9794
9844
  var RenderElement = function RenderElement() {};
@@ -9808,6 +9858,9 @@ var RenderElement = function RenderElement() {};
9808
9858
  this.renderState = renderState;
9809
9859
  this.shaderPass = shaderPass;
9810
9860
  };
9861
+ _proto.dispose = function dispose() {
9862
+ this.component = this.mesh = this.subMesh = this.material = this.renderState = this.shaderPass = null;
9863
+ };
9811
9864
  return MeshRenderElement;
9812
9865
  }(RenderElement);
9813
9866
  /**
@@ -9851,6 +9904,9 @@ var SpriteElement = /*#__PURE__*/ function(RenderElement) {
9851
9904
  this.renderState = renderState;
9852
9905
  this.shaderPass = shaderPass;
9853
9906
  };
9907
+ _proto.dispose = function dispose() {
9908
+ this.component = this.renderData = this.material = this.texture = this.renderState = this.shaderPass = null;
9909
+ };
9854
9910
  return SpriteElement;
9855
9911
  }(RenderElement);
9856
9912
  var SpriteMaskElement = /*#__PURE__*/ function(RenderElement) {
@@ -9868,6 +9924,9 @@ var SpriteMaskElement = /*#__PURE__*/ function(RenderElement) {
9868
9924
  this.renderData = renderData;
9869
9925
  this.material = material;
9870
9926
  };
9927
+ _proto.dispose = function dispose() {
9928
+ this.component = this.renderData = this.material = null;
9929
+ };
9871
9930
  return SpriteMaskElement;
9872
9931
  }(RenderElement);
9873
9932
  /**
@@ -9883,7 +9942,6 @@ exports.Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
9883
9942
  var Renderer1 = function Renderer1(entity) {
9884
9943
  var _this;
9885
9944
  _this = Component.call(this, entity) || this;
9886
- /** ShaderData related to renderer. */ _this.shaderData = new ShaderData(ShaderDataGroup.Renderer);
9887
9945
  /** @internal */ _this._onUpdateIndex = -1;
9888
9946
  /** @internal */ _this._rendererIndex = -1;
9889
9947
  /** @internal */ _this._globalShaderMacro = new ShaderMacroCollection();
@@ -9891,6 +9949,7 @@ exports.Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
9891
9949
  _this._overrideUpdate = false;
9892
9950
  _this._materials = [];
9893
9951
  _this._dirtyUpdateFlag = 0;
9952
+ _this._shaderData = new ShaderData(ShaderDataGroup.Renderer);
9894
9953
  _this._mvMatrix = new miniprogram$7.Matrix();
9895
9954
  _this._mvpMatrix = new miniprogram$7.Matrix();
9896
9955
  _this._mvInvMatrix = new miniprogram$7.Matrix();
@@ -10038,6 +10097,17 @@ exports.Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
10038
10097
  var _materials_i;
10039
10098
  (_materials_i = materials[i]) == null ? void 0 : _materials_i._addRefCount(-1);
10040
10099
  }
10100
+ this._entity = null;
10101
+ this._globalShaderMacro = null;
10102
+ this._bounds = null;
10103
+ this._materials = null;
10104
+ this._shaderData = null;
10105
+ this._mvMatrix = null;
10106
+ this._mvpMatrix = null;
10107
+ this._mvInvMatrix = null;
10108
+ this._normalMatrix = null;
10109
+ this._materialsInstanced = null;
10110
+ this._rendererLayer = null;
10041
10111
  };
10042
10112
  _proto._updateShaderData = function _updateShaderData(context) {
10043
10113
  var entity = this.entity;
@@ -10099,6 +10169,14 @@ exports.Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
10099
10169
  this._dirtyUpdateFlag |= 0x1;
10100
10170
  };
10101
10171
  _create_class$2(Renderer1, [
10172
+ {
10173
+ key: "shaderData",
10174
+ get: /**
10175
+ * ShaderData related to renderer.
10176
+ */ function get() {
10177
+ return this._shaderData;
10178
+ }
10179
+ },
10102
10180
  {
10103
10181
  key: "isCulled",
10104
10182
  get: /**
@@ -10183,9 +10261,6 @@ exports.Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
10183
10261
  }(), function() {
10184
10262
  _Renderer._rendererLayerProperty = Shader.getPropertyByName("oasis_RendererLayer");
10185
10263
  }(), _Renderer);
10186
- __decorate$1([
10187
- deepClone
10188
- ], exports.Renderer.prototype, "shaderData", void 0);
10189
10264
  __decorate$1([
10190
10265
  ignoreClone
10191
10266
  ], exports.Renderer.prototype, "_distanceForSort", void 0);
@@ -10213,6 +10288,9 @@ __decorate$1([
10213
10288
  __decorate$1([
10214
10289
  ignoreClone
10215
10290
  ], exports.Renderer.prototype, "_dirtyUpdateFlag", void 0);
10291
+ __decorate$1([
10292
+ deepClone
10293
+ ], exports.Renderer.prototype, "_shaderData", void 0);
10216
10294
  __decorate$1([
10217
10295
  ignoreClone
10218
10296
  ], exports.Renderer.prototype, "_mvMatrix", void 0);
@@ -10460,6 +10538,7 @@ SimpleSpriteAssembler = __decorate$1([
10460
10538
  sprite._addRefCount(-1);
10461
10539
  sprite._updateFlagManager.removeListener(this._onSpriteChange);
10462
10540
  }
10541
+ this._entity = null;
10463
10542
  this._sprite = null;
10464
10543
  this._renderData = null;
10465
10544
  };
@@ -11054,14 +11133,19 @@ var BufferUtil = /*#__PURE__*/ function() {
11054
11133
  }();
11055
11134
  /**
11056
11135
  * Sub-mesh, mainly contains drawing information.
11057
- */ var SubMesh = function SubMesh(start, count, topology) {
11058
- if (start === void 0) start = 0;
11059
- if (count === void 0) count = 0;
11060
- if (topology === void 0) topology = exports.MeshTopology.Triangles;
11061
- this.start = start;
11062
- this.count = count;
11063
- this.topology = topology;
11064
- };
11136
+ */ var SubMesh = /*#__PURE__*/ function() {
11137
+ var SubMesh = function SubMesh(start, count, topology) {
11138
+ if (start === void 0) start = 0;
11139
+ if (count === void 0) count = 0;
11140
+ if (topology === void 0) topology = exports.MeshTopology.Triangles;
11141
+ this.start = start;
11142
+ this.count = count;
11143
+ this.topology = topology;
11144
+ };
11145
+ var _proto = SubMesh.prototype;
11146
+ _proto.dispose = function dispose() {};
11147
+ return SubMesh;
11148
+ }();
11065
11149
  /**
11066
11150
  * Mesh.
11067
11151
  */ var Mesh = /*#__PURE__*/ function(RefObject) {
@@ -11176,6 +11260,7 @@ var BufferUtil = /*#__PURE__*/ function() {
11176
11260
  this._indexBufferBinding = null;
11177
11261
  this._vertexElements = null;
11178
11262
  this._vertexElementMap = null;
11263
+ this._updateFlagManager = null;
11179
11264
  this._platformPrimitive.destroy();
11180
11265
  };
11181
11266
  _proto._setVertexElements = function _setVertexElements(elements) {
@@ -12855,8 +12940,8 @@ var VertexChangedFlags;
12855
12940
  */ _proto._onDestroy = function _onDestroy() {
12856
12941
  Renderer.prototype._onDestroy.call(this);
12857
12942
  var mesh = this._mesh;
12858
- if (mesh && !mesh.destroyed) {
12859
- mesh._addRefCount(-1);
12943
+ if (mesh) {
12944
+ mesh.destroyed || mesh._addRefCount(-1);
12860
12945
  mesh._updateFlagManager.removeListener(this._onMeshChanged);
12861
12946
  this._mesh = null;
12862
12947
  }
@@ -13190,10 +13275,21 @@ var rePropName = RegExp("[^.[\\]]+" + "|" + // Or match property names within br
13190
13275
  * @internal
13191
13276
  * @override
13192
13277
  */ _proto._onDestroy = function _onDestroy() {
13193
- var _this_rootBone, _this__jointTexture;
13278
+ var _this__rootBone, _this__jointTexture;
13194
13279
  MeshRenderer.prototype._onDestroy.call(this);
13195
- (_this_rootBone = this.rootBone) == null ? void 0 : _this_rootBone.transform._updateFlagManager.removeListener(this._onTransformChanged);
13280
+ (_this__rootBone = this._rootBone) == null ? void 0 : _this__rootBone.transform._updateFlagManager.removeListener(this._onTransformChanged);
13281
+ this._rootBone = null;
13282
+ this._jointDataCreateCache = null;
13283
+ this._skin = null;
13284
+ this._blendShapeWeights = null;
13285
+ this._localBounds = null;
13286
+ this._jointMatrices = null;
13196
13287
  (_this__jointTexture = this._jointTexture) == null ? void 0 : _this__jointTexture.destroy();
13288
+ this._jointTexture = null;
13289
+ if (this._jointEntities) {
13290
+ this._jointEntities.length = 0;
13291
+ this._jointEntities = null;
13292
+ }
13197
13293
  };
13198
13294
  /**
13199
13295
  * @internal
@@ -14568,6 +14664,11 @@ var TextRenderElement = /*#__PURE__*/ function(RenderElement) {
14568
14664
  return _this;
14569
14665
  };
14570
14666
  _inherits$2(TextRenderElement, RenderElement);
14667
+ var _proto = TextRenderElement.prototype;
14668
+ _proto.dispose = function dispose() {
14669
+ this.component = this.material = this.renderState = this.shaderPass = null;
14670
+ this.charElements.length = 0;
14671
+ };
14571
14672
  return TextRenderElement;
14572
14673
  }(RenderElement);
14573
14674
  /**
@@ -14711,7 +14812,6 @@ var TextRenderElement = /*#__PURE__*/ function(RenderElement) {
14711
14812
  this.texture = null;
14712
14813
  this.solidColor = null;
14713
14814
  this.sky.destroy();
14714
- this._engine = null;
14715
14815
  };
14716
14816
  /**
14717
14817
  * @internal
@@ -15092,8 +15192,6 @@ var TextRenderElement = /*#__PURE__*/ function(RenderElement) {
15092
15192
  function Scene(engine, name) {
15093
15193
  var _this;
15094
15194
  _this = EngineObject.call(this, engine) || this;
15095
- /** The background of the scene. */ _this.background = new Background(_this._engine);
15096
- /** Scene-related shader data. */ _this.shaderData = new ShaderData(ShaderDataGroup.Scene);
15097
15195
  /** If cast shadows. */ _this.castShadows = true;
15098
15196
  /** The resolution of the shadow maps. */ _this.shadowResolution = exports.ShadowResolution.Medium;
15099
15197
  /** The splits of two cascade distribution. */ _this.shadowTwoCascadeSplits = 1.0 / 3.0;
@@ -15103,6 +15201,8 @@ var TextRenderElement = /*#__PURE__*/ function(RenderElement) {
15103
15201
  /** @internal */ _this._isActiveInEngine = false;
15104
15202
  /** @internal */ _this._globalShaderMacro = new ShaderMacroCollection();
15105
15203
  /** @internal */ _this._rootEntities = [];
15204
+ _this._background = new Background(_this._engine);
15205
+ _this._shaderData = new ShaderData(ShaderDataGroup.Scene);
15106
15206
  _this._shadowCascades = exports.ShadowCascadesMode.NoCascades;
15107
15207
  _this._fogMode = exports.FogMode.None;
15108
15208
  _this._fogColor = new miniprogram$7.Color(0.5, 0.5, 0.5, 1.0);
@@ -15264,6 +15364,8 @@ var TextRenderElement = /*#__PURE__*/ function(RenderElement) {
15264
15364
  var sunLightIndex = lightManager._getSunLightIndex();
15265
15365
  if (sunLightIndex !== -1) {
15266
15366
  this._sunLight = lightManager._directLights.get(sunLightIndex);
15367
+ } else {
15368
+ this._sunLight = null;
15267
15369
  }
15268
15370
  if (this.castShadows && this._sunLight && this._sunLight.shadowType !== exports.ShadowType.None) {
15269
15371
  shaderData.enableMacro("SHADOW_TYPE", this._sunLight.shadowType.toString());
@@ -15323,6 +15425,22 @@ var TextRenderElement = /*#__PURE__*/ function(RenderElement) {
15323
15425
  this._fogParams.w = density / Math.sqrt(Math.LN2);
15324
15426
  };
15325
15427
  _create_class$2(Scene, [
15428
+ {
15429
+ key: "shaderData",
15430
+ get: /**
15431
+ * Scene-related shader data.
15432
+ */ function get() {
15433
+ return this._shaderData;
15434
+ }
15435
+ },
15436
+ {
15437
+ key: "background",
15438
+ get: /**
15439
+ * The background of the scene.
15440
+ */ function get() {
15441
+ return this._background;
15442
+ }
15443
+ },
15326
15444
  {
15327
15445
  key: "shadowCascades",
15328
15446
  get: /**
@@ -17579,7 +17697,6 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component) {
17579
17697
  var Camera1 = function Camera1(entity) {
17580
17698
  var _this;
17581
17699
  _this = Component.call(this, entity) || this;
17582
- /** Shader data. */ _this.shaderData = new ShaderData(ShaderDataGroup.Camera);
17583
17700
  /** Rendering priority - A Camera with higher priority will be rendered on top of a camera with lower priority. */ _this.priority = 0;
17584
17701
  /** Whether to enable frustum culling, it is enabled by default. */ _this.enableFrustumCulling = true;
17585
17702
  /**
@@ -17593,6 +17710,7 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component) {
17593
17710
  /** @internal */ _this._globalShaderMacro = new ShaderMacroCollection();
17594
17711
  /** @internal */ _this._frustum = new miniprogram$7.BoundingFrustum();
17595
17712
  /** @internal */ _this._virtualCamera = new VirtualCamera();
17713
+ _this._shaderData = new ShaderData(ShaderDataGroup.Camera);
17596
17714
  _this._isProjMatSetting = false;
17597
17715
  _this._nearClipPlane = 0.1;
17598
17716
  _this._farClipPlane = 100;
@@ -17792,6 +17910,20 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component) {
17792
17910
  this._isInvViewProjDirty.destroy();
17793
17911
  this._isViewMatrixDirty.destroy();
17794
17912
  this.shaderData._addRefCount(-1);
17913
+ this._entity = null;
17914
+ this._globalShaderMacro = null;
17915
+ this._frustum = null;
17916
+ this._renderPipeline = null;
17917
+ this._virtualCamera = null;
17918
+ this._shaderData = null;
17919
+ this._frustumViewChangeFlag = null;
17920
+ this._transform = null;
17921
+ this._isViewMatrixDirty = null;
17922
+ this._isInvViewProjDirty = null;
17923
+ this._viewport = null;
17924
+ this._inverseProjectionMatrix = null;
17925
+ this._lastAspectSize = null;
17926
+ this._invViewProjMat = null;
17795
17927
  };
17796
17928
  _proto._projMatChange = function _projMatChange() {
17797
17929
  this._isFrustumProjectDirty = true;
@@ -17831,6 +17963,14 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component) {
17831
17963
  return this._inverseProjectionMatrix;
17832
17964
  };
17833
17965
  _create_class$2(Camera1, [
17966
+ {
17967
+ key: "shaderData",
17968
+ get: /**
17969
+ * Shader data.
17970
+ */ function get() {
17971
+ return this._shaderData;
17972
+ }
17973
+ },
17834
17974
  {
17835
17975
  key: "nearClipPlane",
17836
17976
  get: /**
@@ -19879,6 +20019,7 @@ SlicedSpriteAssembler = __decorate$1([
19879
20019
  sprite._addRefCount(-1);
19880
20020
  sprite._updateFlagManager.removeListener(this._onSpriteChange);
19881
20021
  }
20022
+ this._entity = null;
19882
20023
  this._color = null;
19883
20024
  this._sprite = null;
19884
20025
  this._assembler = null;
@@ -21112,8 +21253,6 @@ var DirtyFlag;
21112
21253
  * @internal
21113
21254
  */ var AnimationCurveOwner = /*#__PURE__*/ function() {
21114
21255
  function AnimationCurveOwner(target, type, property, cureType) {
21115
- this.crossCurveMark = 0;
21116
- this.hasSavedDefaultValue = false;
21117
21256
  this.baseEvaluateData = {
21118
21257
  curKeyframeIndex: 0,
21119
21258
  value: null
@@ -21126,7 +21265,7 @@ var DirtyFlag;
21126
21265
  this.type = type;
21127
21266
  this.property = property;
21128
21267
  this.component = target.getComponent(type);
21129
- this._cureType = cureType;
21268
+ this.cureType = cureType;
21130
21269
  var assemblerType = AnimationCurveOwner.getAssemblerType(type, property);
21131
21270
  this._assembler = new assemblerType();
21132
21271
  this._assembler.initialize(this);
@@ -21135,89 +21274,80 @@ var DirtyFlag;
21135
21274
  }
21136
21275
  }
21137
21276
  var _proto = AnimationCurveOwner.prototype;
21138
- _proto.evaluateAndApplyValue = function evaluateAndApplyValue(curve, time, layerWeight, additive) {
21139
- if (curve.keys.length) {
21140
- if (additive) {
21141
- var value = curve._evaluateAdditive(time, this.baseEvaluateData);
21142
- var cureType = this._cureType;
21143
- if (cureType._isReferenceType) {
21144
- cureType._additiveValue(value, layerWeight, this.referenceTargetValue);
21145
- } else {
21146
- var assembler = this._assembler;
21147
- var originValue = assembler.getTargetValue();
21148
- var additiveValue = cureType._additiveValue(value, layerWeight, originValue);
21149
- assembler.setTargetValue(additiveValue);
21150
- }
21151
- } else {
21152
- var value1 = curve._evaluate(time, this.baseEvaluateData);
21153
- this._applyValue(value1, layerWeight);
21154
- }
21155
- }
21277
+ _proto.evaluateValue = function evaluateValue(curve, time, additive) {
21278
+ return additive ? curve._evaluateAdditive(time, this.baseEvaluateData) : curve._evaluate(time, this.baseEvaluateData);
21156
21279
  };
21157
- _proto.crossFadeAndApplyValue = function crossFadeAndApplyValue(srcCurve, destCurve, srcTime, destTime, crossWeight, layerWeight, additive) {
21158
- 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;
21159
- 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;
21160
- this._applyCrossValue(srcValue, destValue, crossWeight, layerWeight, additive);
21280
+ _proto.evaluateCrossFadeValue = function evaluateCrossFadeValue(srcCurve, destCurve, srcTime, destTime, crossWeight, additive) {
21281
+ 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;
21282
+ 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;
21283
+ return this._lerpValue(srcValue, destValue, crossWeight);
21161
21284
  };
21162
- _proto.crossFadeFromPoseAndApplyValue = function crossFadeFromPoseAndApplyValue(destCurve, destTime, crossWeight, layerWeight, additive) {
21163
- var srcValue = additive ? this._cureType._subtractValue(this.fixedPoseValue, this.defaultValue, this.baseEvaluateData.value) : this.fixedPoseValue;
21164
- 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;
21165
- this._applyCrossValue(srcValue, destValue, crossWeight, layerWeight, additive);
21285
+ _proto.crossFadeFromPoseAndApplyValue = function crossFadeFromPoseAndApplyValue(destCurve, destTime, crossWeight, additive) {
21286
+ var srcValue = additive ? this.cureType._subtractValue(this.fixedPoseValue, this.defaultValue, this.baseEvaluateData.value) : this.fixedPoseValue;
21287
+ 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;
21288
+ return this._lerpValue(srcValue, destValue, crossWeight);
21166
21289
  };
21167
21290
  _proto.revertDefaultValue = function revertDefaultValue() {
21168
21291
  this._assembler.setTargetValue(this.defaultValue);
21169
21292
  };
21293
+ _proto.getEvaluateValue = function getEvaluateValue(out) {
21294
+ if (this.cureType._isReferenceType) {
21295
+ this.cureType._copyValue(this.baseEvaluateData.value, out);
21296
+ return out;
21297
+ } else {
21298
+ return this.baseEvaluateData.value;
21299
+ }
21300
+ };
21170
21301
  _proto.saveDefaultValue = function saveDefaultValue() {
21171
- if (this._cureType._isReferenceType) {
21172
- this._cureType._copyValue(this.referenceTargetValue, this.defaultValue);
21302
+ if (this.cureType._isReferenceType) {
21303
+ this.cureType._copyValue(this.referenceTargetValue, this.defaultValue);
21173
21304
  } else {
21174
21305
  this.defaultValue = this._assembler.getTargetValue();
21175
21306
  }
21176
- this.hasSavedDefaultValue = true;
21177
21307
  };
21178
21308
  _proto.saveFixedPoseValue = function saveFixedPoseValue() {
21179
- if (this._cureType._isReferenceType) {
21180
- this._cureType._copyValue(this.referenceTargetValue, this.fixedPoseValue);
21309
+ if (this.cureType._isReferenceType) {
21310
+ this.cureType._copyValue(this.referenceTargetValue, this.fixedPoseValue);
21181
21311
  } else {
21182
21312
  this.fixedPoseValue = this._assembler.getTargetValue();
21183
21313
  }
21184
21314
  };
21185
- _proto._applyValue = function _applyValue(value, weight) {
21186
- if (weight === 1.0) {
21187
- if (this._cureType._isReferenceType) {
21188
- this._cureType._copyValue(value, this.referenceTargetValue);
21315
+ _proto.applyValue = function applyValue(value, weight, additive) {
21316
+ var cureType = this.cureType;
21317
+ if (additive) {
21318
+ if (cureType._isReferenceType) {
21319
+ cureType._additiveValue(value, weight, this.referenceTargetValue);
21189
21320
  } else {
21190
- this._assembler.setTargetValue(value);
21321
+ var assembler = this._assembler;
21322
+ var originValue = assembler.getTargetValue();
21323
+ var additiveValue = cureType._additiveValue(value, weight, originValue);
21324
+ assembler.setTargetValue(additiveValue);
21191
21325
  }
21192
21326
  } else {
21193
- if (this._cureType._isReferenceType) {
21194
- var targetValue = this.referenceTargetValue;
21195
- this._cureType._lerpValue(targetValue, value, weight, targetValue);
21327
+ if (weight === 1.0) {
21328
+ if (cureType._isReferenceType) {
21329
+ cureType._copyValue(value, this.referenceTargetValue);
21330
+ } else {
21331
+ this._assembler.setTargetValue(value);
21332
+ }
21196
21333
  } else {
21197
- var originValue = this._assembler.getTargetValue();
21198
- var lerpValue = this._cureType._lerpValue(originValue, value, weight);
21199
- this._assembler.setTargetValue(lerpValue);
21334
+ if (cureType._isReferenceType) {
21335
+ var targetValue = this.referenceTargetValue;
21336
+ cureType._lerpValue(targetValue, value, weight, targetValue);
21337
+ } else {
21338
+ var originValue1 = this._assembler.getTargetValue();
21339
+ var lerpValue = cureType._lerpValue(originValue1, value, weight);
21340
+ this._assembler.setTargetValue(lerpValue);
21341
+ }
21200
21342
  }
21201
21343
  }
21202
21344
  };
21203
- _proto._applyCrossValue = function _applyCrossValue(srcValue, destValue, crossWeight, layerWeight, additive) {
21204
- var out;
21205
- if (this._cureType._isReferenceType) {
21206
- out = this.baseEvaluateData.value;
21207
- this._cureType._lerpValue(srcValue, destValue, crossWeight, out);
21208
- } else {
21209
- out = this._cureType._lerpValue(srcValue, destValue, crossWeight);
21210
- }
21211
- if (additive) {
21212
- if (this._cureType._isReferenceType) {
21213
- this._cureType._additiveValue(out, layerWeight, this.referenceTargetValue);
21214
- } else {
21215
- var originValue = this._assembler.getTargetValue();
21216
- var lerpValue = this._cureType._additiveValue(out, layerWeight, originValue);
21217
- this._assembler.setTargetValue(lerpValue);
21218
- }
21345
+ _proto._lerpValue = function _lerpValue(srcValue, destValue, crossWeight) {
21346
+ if (this.cureType._isReferenceType) {
21347
+ return this.cureType._lerpValue(srcValue, destValue, crossWeight, this.baseEvaluateData.value);
21219
21348
  } else {
21220
- this._applyValue(out, layerWeight);
21349
+ this.baseEvaluateData.value = this.cureType._lerpValue(srcValue, destValue, crossWeight);
21350
+ return this.baseEvaluateData.value;
21221
21351
  }
21222
21352
  };
21223
21353
  AnimationCurveOwner.registerAssembler = function registerAssembler(componentType, property, assemblerType) {
@@ -21306,6 +21436,26 @@ AnimationCurveOwner.registerAssembler(Transform, "scale", ScaleAnimationCurveOwn
21306
21436
  return BlendShapeWeightsAnimationCurveOwnerAssembler;
21307
21437
  }();
21308
21438
  AnimationCurveOwner.registerAssembler(SkinnedMeshRenderer, "blendShapeWeights", BlendShapeWeightsAnimationCurveOwnerAssembler);
21439
+ /**
21440
+ * @internal
21441
+ */ var AnimationCurveLayerOwner = /*#__PURE__*/ function() {
21442
+ var AnimationCurveLayerOwner = function AnimationCurveLayerOwner() {
21443
+ this.crossCurveMark = 0;
21444
+ };
21445
+ var _proto = AnimationCurveLayerOwner.prototype;
21446
+ _proto.initFinalValue = function initFinalValue() {
21447
+ var _this_curveOwner = this.curveOwner, cureType = _this_curveOwner.cureType, defaultValue = _this_curveOwner.defaultValue;
21448
+ if (cureType._isReferenceType) {
21449
+ cureType._copyValue(defaultValue, this.finalValue);
21450
+ } else {
21451
+ this.finalValue = defaultValue;
21452
+ }
21453
+ };
21454
+ _proto.saveFinalValue = function saveFinalValue() {
21455
+ this.finalValue = this.curveOwner.getEvaluateValue(this.finalValue);
21456
+ };
21457
+ return AnimationCurveLayerOwner;
21458
+ }();
21309
21459
  /**
21310
21460
  * Associate AnimationCurve and the Entity
21311
21461
  */ var AnimationClipCurveBinding = /*#__PURE__*/ function() {
@@ -21319,10 +21469,22 @@ AnimationCurveOwner.registerAssembler(SkinnedMeshRenderer, "blendShapeWeights",
21319
21469
  var curveType = this.curve.constructor;
21320
21470
  var owner = new AnimationCurveOwner(entity, this.type, this.property, curveType);
21321
21471
  curveType._initializeOwner(owner);
21472
+ owner.saveDefaultValue();
21322
21473
  return owner;
21323
21474
  };
21324
21475
  /**
21325
21476
  * @internal
21477
+ */ _proto._createCurveLayerOwner = function _createCurveLayerOwner(owner) {
21478
+ var curveType = this.curve.constructor;
21479
+ var layerOwner = new AnimationCurveLayerOwner();
21480
+ curveType._initializeLayerOwner(layerOwner);
21481
+ layerOwner.curveOwner = owner;
21482
+ // If curve.keys.length is 0, updateFinishedState will assign 0 to the target, causing an error, so initialize by assigning defaultValue to finalValue.
21483
+ layerOwner.initFinalValue();
21484
+ return layerOwner;
21485
+ };
21486
+ /**
21487
+ * @internal
21326
21488
  */ _proto._getTempCurveOwner = function _getTempCurveOwner(entity) {
21327
21489
  var instanceId = entity.instanceId;
21328
21490
  if (!this._tempCurveOwner[instanceId]) {
@@ -21399,7 +21561,8 @@ AnimationCurveOwner.registerAssembler(SkinnedMeshRenderer, "blendShapeWeights",
21399
21561
  var targetEntity = entity.findByPath(curveData.relativePath);
21400
21562
  if (targetEntity) {
21401
21563
  var curveOwner = curveData._getTempCurveOwner(targetEntity);
21402
- curveOwner.evaluateAndApplyValue(curveData.curve, time, 1, false);
21564
+ var value = curveOwner.evaluateValue(curveData.curve, time, false);
21565
+ curveOwner.applyValue(value, 1, false);
21403
21566
  }
21404
21567
  }
21405
21568
  };
@@ -21541,6 +21704,7 @@ AnimationCurveOwner.registerAssembler(SkinnedMeshRenderer, "blendShapeWeights",
21541
21704
  break;
21542
21705
  }
21543
21706
  }
21707
+ evaluateData.value = value;
21544
21708
  return value;
21545
21709
  };
21546
21710
  /**
@@ -21596,6 +21760,11 @@ exports.AnimationArrayCurve = (_AnimationArrayCurve = /*#__PURE__*/ function(Ani
21596
21760
  };
21597
21761
  /**
21598
21762
  * @internal
21763
+ */ AnimationArrayCurve._initializeLayerOwner = function _initializeLayerOwner(owner) {
21764
+ owner.finalValue = [];
21765
+ };
21766
+ /**
21767
+ * @internal
21599
21768
  */ AnimationArrayCurve._lerpValue = function _lerpValue(srcValue, destValue, weight, out) {
21600
21769
  for(var i = 0, n = out.length; i < n; ++i){
21601
21770
  var src = srcValue[i];
@@ -21685,6 +21854,11 @@ exports.AnimationBoolCurve = (_AnimationBoolCurve = /*#__PURE__*/ function(Anima
21685
21854
  };
21686
21855
  /**
21687
21856
  * @internal
21857
+ */ AnimationBoolCurve._initializeLayerOwner = function _initializeLayerOwner(owner) {
21858
+ owner.finalValue = false;
21859
+ };
21860
+ /**
21861
+ * @internal
21688
21862
  */ AnimationBoolCurve._lerpValue = function _lerpValue(srcValue, destValue) {
21689
21863
  return destValue;
21690
21864
  };
@@ -21741,6 +21915,11 @@ exports.AnimationColorCurve = (_AnimationColorCurve = /*#__PURE__*/ function(Ani
21741
21915
  };
21742
21916
  /**
21743
21917
  * @internal
21918
+ */ AnimationColorCurve._initializeLayerOwner = function _initializeLayerOwner(owner) {
21919
+ owner.finalValue = new miniprogram$7.Color();
21920
+ };
21921
+ /**
21922
+ * @internal
21744
21923
  */ AnimationColorCurve._lerpValue = function _lerpValue(srcValue, destValue, weight, out) {
21745
21924
  miniprogram$7.Color.lerp(srcValue, destValue, weight, out);
21746
21925
  return out;
@@ -21847,6 +22026,12 @@ exports.AnimationFloatArrayCurve = (_AnimationFloatArrayCurve = /*#__PURE__*/ fu
21847
22026
  };
21848
22027
  /**
21849
22028
  * @internal
22029
+ */ AnimationFloatArrayCurve._initializeLayerOwner = function _initializeLayerOwner(owner) {
22030
+ var size = owner.curveOwner.referenceTargetValue.length;
22031
+ owner.finalValue = new Float32Array(size);
22032
+ };
22033
+ /**
22034
+ * @internal
21850
22035
  */ AnimationFloatArrayCurve._lerpValue = function _lerpValue(srcValue, destValue, weight, out) {
21851
22036
  for(var i = 0, n = out.length; i < n; ++i){
21852
22037
  var src = srcValue[i];
@@ -21936,6 +22121,11 @@ exports.AnimationFloatCurve = (_AnimationFloatCurve = /*#__PURE__*/ function(Ani
21936
22121
  };
21937
22122
  /**
21938
22123
  * @internal
22124
+ */ AnimationFloatCurve._initializeLayerOwner = function _initializeLayerOwner(owner) {
22125
+ owner.finalValue = 0;
22126
+ };
22127
+ /**
22128
+ * @internal
21939
22129
  */ AnimationFloatCurve._lerpValue = function _lerpValue(srcValue, destValue, crossWeight) {
21940
22130
  return srcValue + (destValue - srcValue) * crossWeight;
21941
22131
  };
@@ -22004,6 +22194,11 @@ exports.AnimationQuaternionCurve = (_AnimationQuaternionCurve = /*#__PURE__*/ fu
22004
22194
  };
22005
22195
  /**
22006
22196
  * @internal
22197
+ */ AnimationQuaternionCurve1._initializeLayerOwner = function _initializeLayerOwner(owner) {
22198
+ owner.finalValue = new miniprogram$7.Quaternion();
22199
+ };
22200
+ /**
22201
+ * @internal
22007
22202
  */ AnimationQuaternionCurve1._lerpValue = function _lerpValue(src, dest, weight, out) {
22008
22203
  miniprogram$7.Quaternion.slerp(src, dest, weight, out);
22009
22204
  return out;
@@ -22107,6 +22302,11 @@ exports.AnimationVector2Curve = (_AnimationVector2Curve = /*#__PURE__*/ function
22107
22302
  };
22108
22303
  /**
22109
22304
  * @internal
22305
+ */ AnimationVector2Curve._initializeLayerOwner = function _initializeLayerOwner(owner) {
22306
+ owner.finalValue = new miniprogram$7.Vector2();
22307
+ };
22308
+ /**
22309
+ * @internal
22110
22310
  */ AnimationVector2Curve._lerpValue = function _lerpValue(srcValue, destValue, weight, out) {
22111
22311
  miniprogram$7.Vector2.lerp(srcValue, destValue, weight, out);
22112
22312
  return out;
@@ -22191,6 +22391,11 @@ exports.AnimationVector3Curve = (_AnimationVector3Curve = /*#__PURE__*/ function
22191
22391
  };
22192
22392
  /**
22193
22393
  * @internal
22394
+ */ AnimationVector3Curve._initializeLayerOwner = function _initializeLayerOwner(owner) {
22395
+ owner.finalValue = new miniprogram$7.Vector3();
22396
+ };
22397
+ /**
22398
+ * @internal
22194
22399
  */ AnimationVector3Curve._lerpValue = function _lerpValue(srcValue, destValue, weight, out) {
22195
22400
  miniprogram$7.Vector3.lerp(srcValue, destValue, weight, out);
22196
22401
  return out;
@@ -22287,6 +22492,11 @@ exports.AnimationVector4Curve = (_AnimationVector4Curve = /*#__PURE__*/ function
22287
22492
  };
22288
22493
  /**
22289
22494
  * @internal
22495
+ */ AnimationVector4Curve._initializeLayerOwner = function _initializeLayerOwner(owner) {
22496
+ owner.finalValue = new miniprogram$7.Vector4();
22497
+ };
22498
+ /**
22499
+ * @internal
22290
22500
  */ AnimationVector4Curve._lerpValue = function _lerpValue(srcValue, destValue, weight, out) {
22291
22501
  miniprogram$7.Vector4.lerp(srcValue, destValue, weight, out);
22292
22502
  return out;
@@ -22392,12 +22602,20 @@ exports.AnimatorLayerBlendingMode = void 0;
22392
22602
  LayerState[LayerState[/** Playing state. */ "Playing"] = 1] = "Playing";
22393
22603
  LayerState[LayerState[/** CrossFading state. */ "CrossFading"] = 2] = "CrossFading";
22394
22604
  LayerState[LayerState[/** FixedCrossFading state. */ "FixedCrossFading"] = 3] = "FixedCrossFading";
22605
+ LayerState[LayerState[/** Finished state. */ "Finished"] = 4] = "Finished";
22395
22606
  })(LayerState || (LayerState = {}));
22396
22607
  /**
22397
22608
  * @internal
22398
- */ var AnimationEventHandler = function AnimationEventHandler() {
22399
- this.handlers = [];
22400
- };
22609
+ */ var AnimationEventHandler = /*#__PURE__*/ function() {
22610
+ var AnimationEventHandler = function AnimationEventHandler() {
22611
+ this.handlers = [];
22612
+ };
22613
+ var _proto = AnimationEventHandler.prototype;
22614
+ _proto.dispose = function dispose() {
22615
+ this.handlers.length = 0;
22616
+ };
22617
+ return AnimationEventHandler;
22618
+ }();
22401
22619
  /**
22402
22620
  * Transitions define when and how the state machine switch from on state to another. AnimatorTransition always originate from a StateMachine or a StateMachine entry.
22403
22621
  */ var AnimatorStateTransition = function AnimatorStateTransition() {
@@ -22451,12 +22669,14 @@ exports.AnimatorLayerBlendingMode = void 0;
22451
22669
  * @internal
22452
22670
  */ var AnimatorLayerData = /*#__PURE__*/ function() {
22453
22671
  var AnimatorLayerData = function AnimatorLayerData() {
22672
+ this.curveOwnerPool = Object.create(null);
22454
22673
  this.animatorStateDataMap = {};
22455
22674
  this.srcPlayData = new AnimatorStatePlayData();
22456
22675
  this.destPlayData = new AnimatorStatePlayData();
22457
22676
  this.layerState = LayerState.Standby;
22458
22677
  this.crossCurveMark = 0;
22459
22678
  this.manuallyTransition = new AnimatorStateTransition();
22679
+ this.crossLayerOwnerCollection = [];
22460
22680
  };
22461
22681
  var _proto = AnimatorLayerData.prototype;
22462
22682
  _proto.switchPlayData = function switchPlayData() {
@@ -22470,7 +22690,7 @@ exports.AnimatorLayerBlendingMode = void 0;
22470
22690
  /**
22471
22691
  * @internal
22472
22692
  */ var AnimatorStateData = function AnimatorStateData() {
22473
- this.curveOwners = [];
22693
+ this.curveLayerOwner = [];
22474
22694
  this.eventHandlers = [];
22475
22695
  };
22476
22696
  /**
@@ -22482,8 +22702,8 @@ exports.AnimatorLayerBlendingMode = void 0;
22482
22702
  /** Culling mode of this Animator. */ _this.cullingMode = exports.AnimatorCullingMode.None;
22483
22703
  /** The playback speed of the Animator, 1.0 is normal playback speed. */ _this.speed = 1.0;
22484
22704
  _this._animatorLayersData = [];
22485
- _this._crossOwnerCollection = [];
22486
- _this._animationCurveOwners = [];
22705
+ _this._curveOwnerPool = Object.create(null);
22706
+ _this._needRevertCurveOwners = [];
22487
22707
  _this._animationEventHandlerPool = new ClassPool(AnimationEventHandler);
22488
22708
  _this._tempAnimatorStateInfo = {
22489
22709
  layerIndex: -1,
@@ -22507,7 +22727,7 @@ exports.AnimatorLayerBlendingMode = void 0;
22507
22727
  this._reset();
22508
22728
  }
22509
22729
  var stateInfo = this._getAnimatorStateInfo(stateName, layerIndex);
22510
- var state = stateInfo.state;
22730
+ var state = stateInfo.state, playLayerIndex = stateInfo.layerIndex;
22511
22731
  if (!state) {
22512
22732
  return;
22513
22733
  }
@@ -22516,9 +22736,8 @@ exports.AnimatorLayerBlendingMode = void 0;
22516
22736
  return;
22517
22737
  }
22518
22738
  var animatorLayerData = this._getAnimatorLayerData(stateInfo.layerIndex);
22519
- //TODO CM: Not consider same stateName, but different animation
22520
- var animatorStateData = this._getAnimatorStateData(stateName, state, animatorLayerData);
22521
- this._preparePlay(animatorLayerData, state, animatorStateData);
22739
+ var animatorStateData = this._getAnimatorStateData(stateName, state, animatorLayerData, playLayerIndex);
22740
+ this._preparePlay(animatorLayerData, state);
22522
22741
  animatorLayerData.layerState = LayerState.Playing;
22523
22742
  animatorLayerData.srcPlayData.reset(state, animatorStateData, state._getDuration() * normalizedTimeOffset);
22524
22743
  };
@@ -22569,6 +22788,7 @@ exports.AnimatorLayerBlendingMode = void 0;
22569
22788
  return;
22570
22789
  }
22571
22790
  deltaTime *= this.speed;
22791
+ this._revertCurveOwners();
22572
22792
  for(var i1 = 0, n1 = animatorController.layers.length; i1 < n1; i1++){
22573
22793
  var animatorLayerData = this._getAnimatorLayerData(i1);
22574
22794
  if (animatorLayerData.layerState === LayerState.Standby) {
@@ -22609,17 +22829,17 @@ exports.AnimatorLayerBlendingMode = void 0;
22609
22829
  /**
22610
22830
  * @internal
22611
22831
  */ _proto._reset = function _reset() {
22612
- var _this = this, animationCurveOwners = _this._animationCurveOwners;
22832
+ var _this = this, animationCurveOwners = _this._curveOwnerPool;
22613
22833
  for(var instanceId in animationCurveOwners){
22614
22834
  var propertyOwners = animationCurveOwners[instanceId];
22615
22835
  for(var property in propertyOwners){
22616
22836
  var owner = propertyOwners[property];
22617
- owner.hasSavedDefaultValue && owner.revertDefaultValue();
22837
+ owner.revertDefaultValue();
22618
22838
  }
22619
22839
  }
22620
22840
  this._animatorLayersData.length = 0;
22621
- this._crossOwnerCollection.length = 0;
22622
- this._animationCurveOwners.length = 0;
22841
+ this._needRevertCurveOwners.length = 0;
22842
+ this._curveOwnerPool = {};
22623
22843
  this._animationEventHandlerPool.resetPool();
22624
22844
  if (this._controllerUpdateFlag) {
22625
22845
  this._controllerUpdateFlag.flag = false;
@@ -22646,38 +22866,51 @@ exports.AnimatorLayerBlendingMode = void 0;
22646
22866
  stateInfo.state = state;
22647
22867
  return stateInfo;
22648
22868
  };
22649
- _proto._saveDefaultValues = function _saveDefaultValues(stateData) {
22650
- var curveOwners = stateData.curveOwners;
22651
- for(var i = curveOwners.length - 1; i >= 0; i--){
22652
- var _curveOwners_i;
22653
- (_curveOwners_i = curveOwners[i]) == null ? void 0 : _curveOwners_i.saveDefaultValue();
22654
- }
22655
- };
22656
- _proto._getAnimatorStateData = function _getAnimatorStateData(stateName, animatorState, animatorLayerData) {
22869
+ _proto._getAnimatorStateData = function _getAnimatorStateData(stateName, animatorState, animatorLayerData, layerIndex) {
22657
22870
  var animatorStateDataMap = animatorLayerData.animatorStateDataMap;
22658
22871
  var animatorStateData = animatorStateDataMap[stateName];
22659
22872
  if (!animatorStateData) {
22660
22873
  animatorStateData = new AnimatorStateData();
22661
22874
  animatorStateDataMap[stateName] = animatorStateData;
22662
- this._saveAnimatorStateData(animatorState, animatorStateData);
22875
+ this._saveAnimatorStateData(animatorState, animatorStateData, animatorLayerData, layerIndex);
22663
22876
  this._saveAnimatorEventHandlers(animatorState, animatorStateData);
22664
22877
  }
22665
22878
  return animatorStateData;
22666
22879
  };
22667
- _proto._saveAnimatorStateData = function _saveAnimatorStateData(animatorState, animatorStateData) {
22668
- var _this = this, entity = _this.entity, animationCureOwners = _this._animationCurveOwners;
22669
- var curveOwners = animatorStateData.curveOwners;
22880
+ _proto._saveAnimatorStateData = function _saveAnimatorStateData(animatorState, animatorStateData, animatorLayerData, layerIndex) {
22881
+ var _this = this, entity = _this.entity, curveOwnerPool = _this._curveOwnerPool;
22882
+ var curveLayerOwner = animatorStateData.curveLayerOwner;
22883
+ var layerCurveOwnerPool = animatorLayerData.curveOwnerPool;
22670
22884
  var _animatorState_clip = animatorState.clip, curves = _animatorState_clip._curveBindings;
22671
22885
  for(var i = curves.length - 1; i >= 0; i--){
22672
22886
  var curve = curves[i];
22673
22887
  var targetEntity = curve.relativePath === "" ? entity : entity.findByPath(curve.relativePath);
22674
22888
  if (targetEntity) {
22889
+ var _curveOwnerPool, _instanceId, _propertyOwners, _property, _layerCurveOwnerPool, _instanceId1, _layerPropertyOwners, _property1;
22675
22890
  var property = curve.property;
22676
22891
  var instanceId = targetEntity.instanceId;
22677
- var propertyOwners = animationCureOwners[instanceId] || (animationCureOwners[instanceId] = {});
22678
- curveOwners[i] = propertyOwners[property] || (propertyOwners[property] = curve._createCurveOwner(targetEntity));
22892
+ var needRevert = false;
22893
+ var baseAnimatorLayerData = this._animatorLayersData[0];
22894
+ var baseLayerCurveOwnerPool = baseAnimatorLayerData.curveOwnerPool;
22895
+ if (this.animatorController.layers[layerIndex].blendingMode === exports.AnimatorLayerBlendingMode.Additive && layerIndex > 0 && !(baseLayerCurveOwnerPool[instanceId] && baseLayerCurveOwnerPool[instanceId][property])) {
22896
+ needRevert = true;
22897
+ }
22898
+ // Get owner
22899
+ var propertyOwners = (_curveOwnerPool = curveOwnerPool)[_instanceId = instanceId] || (_curveOwnerPool[_instanceId] = Object.create(null));
22900
+ var owner = (_propertyOwners = propertyOwners)[_property = property] || (_propertyOwners[_property] = curve._createCurveOwner(targetEntity));
22901
+ //@todo: There is performance waste here, which will be handled together with organizing AnimatorStateData later. The logic is changing from runtime to initialization.
22902
+ if (needRevert) {
22903
+ this._needRevertCurveOwners.push(owner);
22904
+ } else {
22905
+ var index = this._needRevertCurveOwners.indexOf(owner);
22906
+ index > -1 && this._needRevertCurveOwners.splice(index, 1);
22907
+ }
22908
+ // Get layer owner
22909
+ var layerPropertyOwners = (_layerCurveOwnerPool = layerCurveOwnerPool)[_instanceId1 = instanceId] || (_layerCurveOwnerPool[_instanceId1] = Object.create(null));
22910
+ var layerOwner = (_layerPropertyOwners = layerPropertyOwners)[_property1 = property] || (_layerPropertyOwners[_property1] = curve._createCurveLayerOwner(owner));
22911
+ curveLayerOwner[i] = layerOwner;
22679
22912
  } else {
22680
- curveOwners[i] = null;
22913
+ curveLayerOwner[i] = null;
22681
22914
  console.warn("The entity don't have the child entity which path is " + curve.relativePath + ".");
22682
22915
  }
22683
22916
  }
@@ -22705,65 +22938,60 @@ exports.AnimatorLayerBlendingMode = void 0;
22705
22938
  };
22706
22939
  _proto._clearCrossData = function _clearCrossData(animatorLayerData) {
22707
22940
  animatorLayerData.crossCurveMark++;
22708
- this._crossOwnerCollection.length = 0;
22941
+ animatorLayerData.crossLayerOwnerCollection.length = 0;
22709
22942
  };
22710
- _proto._addCrossCurveData = function _addCrossCurveData(crossCurveData, owner, curCurveIndex, nextCurveIndex) {
22711
- owner.crossSrcCurveIndex = curCurveIndex;
22712
- owner.crossDestCurveIndex = nextCurveIndex;
22713
- crossCurveData.push(owner);
22943
+ _proto._addCrossOwner = function _addCrossOwner(animatorLayerData, layerOwner, curCurveIndex, nextCurveIndex) {
22944
+ layerOwner.crossSrcCurveIndex = curCurveIndex;
22945
+ layerOwner.crossDestCurveIndex = nextCurveIndex;
22946
+ animatorLayerData.crossLayerOwnerCollection.push(layerOwner);
22714
22947
  };
22715
22948
  _proto._prepareCrossFading = function _prepareCrossFading(animatorLayerData) {
22716
- var crossCurveData = this._crossOwnerCollection;
22717
- var crossCurveMark = animatorLayerData.crossCurveMark;
22718
22949
  // Add src cross curve data.
22719
- this._prepareSrcCrossData(crossCurveData, animatorLayerData.srcPlayData, crossCurveMark, false);
22950
+ this._prepareSrcCrossData(animatorLayerData, false);
22720
22951
  // Add dest cross curve data.
22721
- this._prepareDestCrossData(crossCurveData, animatorLayerData.destPlayData, crossCurveMark, false);
22952
+ this._prepareDestCrossData(animatorLayerData, false);
22722
22953
  };
22723
22954
  _proto._prepareStandbyCrossFading = function _prepareStandbyCrossFading(animatorLayerData) {
22724
- var crossOwnerCollection = this._crossOwnerCollection;
22725
- var srcPlayData = animatorLayerData.srcPlayData, crossCurveMark = animatorLayerData.crossCurveMark;
22726
22955
  // Standby have two sub state, one is never play, one is finished, never play srcPlayData.state is null.
22727
- srcPlayData.state && this._prepareSrcCrossData(crossOwnerCollection, srcPlayData, crossCurveMark, true);
22956
+ animatorLayerData.srcPlayData.state && this._prepareSrcCrossData(animatorLayerData, true);
22728
22957
  // Add dest cross curve data.
22729
- this._prepareDestCrossData(crossOwnerCollection, animatorLayerData.destPlayData, crossCurveMark, true);
22958
+ this._prepareDestCrossData(animatorLayerData, true);
22730
22959
  };
22731
22960
  _proto._prepareFixedPoseCrossFading = function _prepareFixedPoseCrossFading(animatorLayerData) {
22732
- var crossOwnerCollection = this._crossOwnerCollection;
22961
+ var crossLayerOwnerCollection = animatorLayerData.crossLayerOwnerCollection;
22733
22962
  // Save current cross curve data owner fixed pose.
22734
- for(var i = crossOwnerCollection.length - 1; i >= 0; i--){
22735
- var item = crossOwnerCollection[i];
22736
- item.saveFixedPoseValue();
22963
+ for(var i = crossLayerOwnerCollection.length - 1; i >= 0; i--){
22964
+ var layerOwner = crossLayerOwnerCollection[i];
22965
+ if (!layerOwner) continue;
22966
+ layerOwner.curveOwner.saveFixedPoseValue();
22737
22967
  // Reset destCurveIndex When fixed pose crossFading again.
22738
- item.crossDestCurveIndex = -1;
22968
+ layerOwner.crossDestCurveIndex = -1;
22739
22969
  }
22740
22970
  // prepare dest AnimatorState cross data.
22741
- this._prepareDestCrossData(crossOwnerCollection, animatorLayerData.destPlayData, animatorLayerData.crossCurveMark, true);
22742
- };
22743
- _proto._prepareSrcCrossData = function _prepareSrcCrossData(crossCurveData, srcPlayData, crossCurveMark, saveFixed) {
22744
- var curveOwners = srcPlayData.stateData.curveOwners;
22745
- for(var i = curveOwners.length - 1; i >= 0; i--){
22746
- var owner = curveOwners[i];
22747
- if (!owner) continue;
22748
- owner.crossCurveMark = crossCurveMark;
22749
- owner.crossCurveDataIndex = crossCurveData.length;
22750
- saveFixed && owner.saveFixedPoseValue();
22751
- this._addCrossCurveData(crossCurveData, owner, i, -1);
22752
- }
22753
- };
22754
- _proto._prepareDestCrossData = function _prepareDestCrossData(crossCurveData, destPlayData, crossCurveMark, saveFixed) {
22755
- var curveOwners = destPlayData.stateData.curveOwners;
22756
- for(var i = curveOwners.length - 1; i >= 0; i--){
22757
- var owner = curveOwners[i];
22758
- if (!owner) continue;
22759
- if (owner.crossCurveMark === crossCurveMark) {
22760
- crossCurveData[owner.crossCurveDataIndex].crossDestCurveIndex = i;
22971
+ this._prepareDestCrossData(animatorLayerData, true);
22972
+ };
22973
+ _proto._prepareSrcCrossData = function _prepareSrcCrossData(animatorLayerData, saveFixed) {
22974
+ var curveLayerOwner = animatorLayerData.srcPlayData.stateData.curveLayerOwner;
22975
+ for(var i = curveLayerOwner.length - 1; i >= 0; i--){
22976
+ var layerOwner = curveLayerOwner[i];
22977
+ if (!layerOwner) continue;
22978
+ layerOwner.crossCurveMark = animatorLayerData.crossCurveMark;
22979
+ saveFixed && layerOwner.curveOwner.saveFixedPoseValue();
22980
+ this._addCrossOwner(animatorLayerData, layerOwner, i, -1);
22981
+ }
22982
+ };
22983
+ _proto._prepareDestCrossData = function _prepareDestCrossData(animatorLayerData, saveFixed) {
22984
+ var curveLayerOwner = animatorLayerData.destPlayData.stateData.curveLayerOwner;
22985
+ for(var i = curveLayerOwner.length - 1; i >= 0; i--){
22986
+ var layerOwner = curveLayerOwner[i];
22987
+ if (!layerOwner) continue;
22988
+ if (layerOwner.crossCurveMark === animatorLayerData.crossCurveMark) {
22989
+ layerOwner.crossDestCurveIndex = i;
22761
22990
  } else {
22762
- owner.saveDefaultValue();
22991
+ var owner = layerOwner.curveOwner;
22763
22992
  saveFixed && owner.saveFixedPoseValue();
22764
- owner.crossCurveMark = crossCurveMark;
22765
- owner.crossCurveDataIndex = crossCurveData.length;
22766
- this._addCrossCurveData(crossCurveData, owner, -1, i);
22993
+ layerOwner.crossCurveMark = animatorLayerData.crossCurveMark;
22994
+ this._addCrossOwner(animatorLayerData, layerOwner, -1, i);
22767
22995
  }
22768
22996
  }
22769
22997
  };
@@ -22778,7 +23006,7 @@ exports.AnimatorLayerBlendingMode = void 0;
22778
23006
  var srcPlayData = layerData.srcPlayData, destPlayData = layerData.destPlayData, crossFadeTransitionInfo = layerData.crossFadeTransition;
22779
23007
  var additive = blendingMode === exports.AnimatorLayerBlendingMode.Additive;
22780
23008
  firstLayer && (weight = 1.0);
22781
- //TODO: 任意情况都应该检查,后面要优化
23009
+ //@todo: All situations should be checked, optimizations will follow later.
22782
23010
  layerData.layerState !== LayerState.FixedCrossFading && this._checkTransition(srcPlayData, crossFadeTransitionInfo, layerIndex);
22783
23011
  switch(layerData.layerState){
22784
23012
  case LayerState.Playing:
@@ -22790,26 +23018,36 @@ exports.AnimatorLayerBlendingMode = void 0;
22790
23018
  case LayerState.CrossFading:
22791
23019
  this._updateCrossFade(srcPlayData, destPlayData, layerData, layerIndex, weight, deltaTime, additive, aniUpdate);
22792
23020
  break;
23021
+ case LayerState.Finished:
23022
+ this._updateFinishedState(srcPlayData, weight, additive, aniUpdate);
23023
+ break;
22793
23024
  }
22794
23025
  };
22795
23026
  _proto._updatePlayingState = function _updatePlayingState(playData, layerData, layerIndex, weight, delta, additive, aniUpdate) {
22796
- var _playData_stateData = playData.stateData, curveOwners = _playData_stateData.curveOwners, eventHandlers = _playData_stateData.eventHandlers;
23027
+ var _playData_stateData = playData.stateData, curveLayerOwner = _playData_stateData.curveLayerOwner, eventHandlers = _playData_stateData.eventHandlers;
22797
23028
  var state = playData.state, lastPlayState = playData.playState, lastClipTime = playData.clipTime;
22798
23029
  var _state_clip = state.clip, curveBindings = _state_clip._curveBindings;
22799
23030
  playData.update(this.speed < 0);
22800
- if (!aniUpdate) {
22801
- return;
22802
- }
22803
23031
  var clipTime = playData.clipTime, playState = playData.playState;
22804
- eventHandlers.length && this._fireAnimationEvents(playData, eventHandlers, lastClipTime, clipTime);
22805
- for(var i = curveBindings.length - 1; i >= 0; i--){
22806
- var owner = curveOwners[i];
22807
- owner == null ? void 0 : owner.evaluateAndApplyValue(curveBindings[i].curve, clipTime, weight, additive);
23032
+ var finished = playState === AnimatorStatePlayState.Finished;
23033
+ if (aniUpdate || finished) {
23034
+ for(var i = curveBindings.length - 1; i >= 0; i--){
23035
+ var layerOwner = curveLayerOwner[i];
23036
+ var owner = layerOwner == null ? void 0 : layerOwner.curveOwner;
23037
+ if (!owner) continue;
23038
+ var curve = curveBindings[i].curve;
23039
+ if (curve.keys.length) {
23040
+ var value = owner.evaluateValue(curve, clipTime, additive);
23041
+ aniUpdate && owner.applyValue(value, weight, additive);
23042
+ finished && layerOwner.saveFinalValue();
23043
+ }
23044
+ }
22808
23045
  }
22809
23046
  playData.frameTime += state.speed * delta;
22810
23047
  if (playState === AnimatorStatePlayState.Finished) {
22811
- layerData.layerState = LayerState.Standby;
23048
+ layerData.layerState = LayerState.Finished;
22812
23049
  }
23050
+ eventHandlers.length && this._fireAnimationEvents(playData, eventHandlers, lastClipTime, clipTime);
22813
23051
  if (lastPlayState === AnimatorStatePlayState.UnStarted) {
22814
23052
  this._callAnimatorScriptOnEnter(state, layerIndex);
22815
23053
  }
@@ -22820,7 +23058,7 @@ exports.AnimatorLayerBlendingMode = void 0;
22820
23058
  }
22821
23059
  };
22822
23060
  _proto._updateCrossFade = function _updateCrossFade(srcPlayData, destPlayData, layerData, layerIndex, weight, delta, additive, aniUpdate) {
22823
- var _this = this, crossCurveDataCollection = _this._crossOwnerCollection;
23061
+ var crossLayerOwnerCollection = layerData.crossLayerOwnerCollection;
22824
23062
  var _srcPlayData_state_clip = srcPlayData.state.clip, srcCurves = _srcPlayData_state_clip._curveBindings;
22825
23063
  var srcState = srcPlayData.state, srcStateData = srcPlayData.stateData, lastSrcPlayState = srcPlayData.playState;
22826
23064
  var srcEventHandlers = srcStateData.eventHandlers;
@@ -22829,18 +23067,27 @@ exports.AnimatorLayerBlendingMode = void 0;
22829
23067
  var _destState_clip = destState.clip, destCurves = _destState_clip._curveBindings;
22830
23068
  var lastSrcClipTime = srcPlayData.clipTime;
22831
23069
  var lastDestClipTime = destPlayData.clipTime;
22832
- var crossWeight = Math.abs(destPlayData.frameTime) / (destState._getDuration() * layerData.crossFadeTransition.duration);
22833
- crossWeight >= 1.0 && (crossWeight = 1.0);
23070
+ var duration = destState._getDuration() * layerData.crossFadeTransition.duration;
23071
+ var crossWeight = Math.abs(destPlayData.frameTime) / duration;
23072
+ (crossWeight >= 1.0 || duration === 0) && (crossWeight = 1.0);
22834
23073
  srcPlayData.update(this.speed < 0);
22835
23074
  destPlayData.update(this.speed < 0);
22836
- var srcPlayState = srcPlayData.playState;
22837
- var destPlayState = destPlayData.playState;
22838
- this._updateCrossFadeData(layerData, crossWeight, delta, false);
22839
- if (!aniUpdate) {
22840
- return;
23075
+ var srcClipTime = srcPlayData.clipTime, srcPlayState = srcPlayData.playState;
23076
+ var destClipTime = destPlayData.clipTime, destPlayState = destPlayData.playState;
23077
+ var finished = destPlayData.playState === AnimatorStatePlayState.Finished;
23078
+ if (aniUpdate || finished) {
23079
+ for(var i = crossLayerOwnerCollection.length - 1; i >= 0; i--){
23080
+ var layerOwner = crossLayerOwnerCollection[i];
23081
+ var owner = layerOwner == null ? void 0 : layerOwner.curveOwner;
23082
+ if (!owner) continue;
23083
+ var srcCurveIndex = layerOwner.crossSrcCurveIndex;
23084
+ var destCurveIndex = layerOwner.crossDestCurveIndex;
23085
+ var value = owner.evaluateCrossFadeValue(srcCurveIndex >= 0 ? srcCurves[srcCurveIndex].curve : null, destCurveIndex >= 0 ? destCurves[destCurveIndex].curve : null, srcClipTime, destClipTime, crossWeight, additive);
23086
+ aniUpdate && owner.applyValue(value, weight, additive);
23087
+ finished && layerOwner.saveFinalValue();
23088
+ }
22841
23089
  }
22842
- var srcClipTime = srcPlayData.clipTime;
22843
- var destClipTime = destPlayData.clipTime;
23090
+ this._updateCrossFadeData(layerData, crossWeight, delta, false);
22844
23091
  srcEventHandlers.length && this._fireAnimationEvents(srcPlayData, srcEventHandlers, lastSrcClipTime, srcClipTime);
22845
23092
  destEventHandlers.length && this._fireAnimationEvents(destPlayData, destEventHandlers, lastDestClipTime, destClipTime);
22846
23093
  if (lastSrcPlayState === AnimatorStatePlayState.UnStarted) {
@@ -22859,28 +23106,34 @@ exports.AnimatorLayerBlendingMode = void 0;
22859
23106
  } else {
22860
23107
  this._callAnimatorScriptOnUpdate(destState, layerIndex);
22861
23108
  }
22862
- for(var i = crossCurveDataCollection.length - 1; i >= 0; i--){
22863
- var crossCurveData = crossCurveDataCollection[i];
22864
- var crossSrcCurveIndex = crossCurveData.crossSrcCurveIndex, crossDestCurveIndex = crossCurveData.crossDestCurveIndex;
22865
- crossCurveData.crossFadeAndApplyValue(crossSrcCurveIndex >= 0 ? srcCurves[crossSrcCurveIndex].curve : null, crossDestCurveIndex >= 0 ? destCurves[crossDestCurveIndex].curve : null, srcClipTime, destClipTime, crossWeight, weight, additive);
22866
- }
22867
23109
  };
22868
- _proto._updateCrossFadeFromPose = function _updateCrossFadeFromPose(destPlayData, layerData, layerIndex, layerWeight, delta, additive, aniUpdate) {
22869
- var crossCurveDataCollection = this._crossOwnerCollection;
23110
+ _proto._updateCrossFadeFromPose = function _updateCrossFadeFromPose(destPlayData, layerData, layerIndex, weight, delta, additive, aniUpdate) {
23111
+ var crossLayerOwnerCollection = layerData.crossLayerOwnerCollection;
22870
23112
  var state = destPlayData.state, stateData = destPlayData.stateData, lastPlayState = destPlayData.playState;
22871
23113
  var eventHandlers = stateData.eventHandlers;
22872
23114
  var _state_clip = state.clip, curveBindings = _state_clip._curveBindings;
22873
23115
  var lastDestClipTime = destPlayData.clipTime;
22874
- var crossWeight = Math.abs(destPlayData.frameTime) / (state._getDuration() * layerData.crossFadeTransition.duration);
22875
- crossWeight >= 1.0 && (crossWeight = 1.0);
23116
+ var duration = state._getDuration() * layerData.crossFadeTransition.duration;
23117
+ var crossWeight = Math.abs(destPlayData.frameTime) / duration;
23118
+ (crossWeight >= 1.0 || duration === 0) && (crossWeight = 1.0);
22876
23119
  destPlayData.update(this.speed < 0);
22877
23120
  var playState = destPlayData.playState;
22878
23121
  this._updateCrossFadeData(layerData, crossWeight, delta, true);
22879
- if (!aniUpdate) {
22880
- return;
22881
- }
22882
23122
  var destClipTime = destPlayData.clipTime;
22883
- //TODO: srcState 少了最新一段时间的判断
23123
+ var finished = playState === AnimatorStatePlayState.Finished;
23124
+ // 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.
23125
+ if (aniUpdate || finished) {
23126
+ for(var i = crossLayerOwnerCollection.length - 1; i >= 0; i--){
23127
+ var layerOwner = crossLayerOwnerCollection[i];
23128
+ var owner = layerOwner == null ? void 0 : layerOwner.curveOwner;
23129
+ if (!owner) continue;
23130
+ var curveIndex = layerOwner.crossDestCurveIndex;
23131
+ var value = layerOwner.curveOwner.crossFadeFromPoseAndApplyValue(curveIndex >= 0 ? curveBindings[curveIndex].curve : null, destClipTime, crossWeight, additive);
23132
+ aniUpdate && owner.applyValue(value, weight, additive);
23133
+ finished && layerOwner.saveFinalValue();
23134
+ }
23135
+ }
23136
+ //@todo: srcState is missing the judgment of the most recent period."
22884
23137
  eventHandlers.length && this._fireAnimationEvents(destPlayData, eventHandlers, lastDestClipTime, destClipTime);
22885
23138
  if (lastPlayState === AnimatorStatePlayState.UnStarted) {
22886
23139
  this._callAnimatorScriptOnEnter(state, layerIndex);
@@ -22890,10 +23143,18 @@ exports.AnimatorLayerBlendingMode = void 0;
22890
23143
  } else {
22891
23144
  this._callAnimatorScriptOnUpdate(state, layerIndex);
22892
23145
  }
22893
- for(var i = crossCurveDataCollection.length - 1; i >= 0; i--){
22894
- var crossCurveData = crossCurveDataCollection[i];
22895
- var crossDestCurveIndex = crossCurveData.crossDestCurveIndex;
22896
- crossCurveData.crossFadeFromPoseAndApplyValue(crossDestCurveIndex >= 0 ? curveBindings[crossDestCurveIndex].curve : null, destClipTime, crossWeight, layerWeight, additive);
23146
+ };
23147
+ _proto._updateFinishedState = function _updateFinishedState(playData, weight, additive, aniUpdate) {
23148
+ if (!aniUpdate) {
23149
+ return;
23150
+ }
23151
+ var curveLayerOwner = playData.stateData.curveLayerOwner;
23152
+ var _playData_state_clip = playData.state.clip, curveBindings = _playData_state_clip._curveBindings;
23153
+ for(var i = curveBindings.length - 1; i >= 0; i--){
23154
+ var layerOwner = curveLayerOwner[i];
23155
+ var owner = layerOwner == null ? void 0 : layerOwner.curveOwner;
23156
+ if (!owner) continue;
23157
+ owner.applyValue(layerOwner.finalValue, weight, additive);
22897
23158
  }
22898
23159
  };
22899
23160
  _proto._updateCrossFadeData = function _updateCrossFadeData(layerData, crossWeight, delta, fixed) {
@@ -22901,7 +23162,7 @@ exports.AnimatorLayerBlendingMode = void 0;
22901
23162
  destPlayData.frameTime += destPlayData.state.speed * delta;
22902
23163
  if (crossWeight === 1.0) {
22903
23164
  if (destPlayData.playState === AnimatorStatePlayState.Finished) {
22904
- layerData.layerState = LayerState.Standby;
23165
+ layerData.layerState = LayerState.Finished;
22905
23166
  } else {
22906
23167
  layerData.layerState = LayerState.Playing;
22907
23168
  }
@@ -22911,25 +23172,24 @@ exports.AnimatorLayerBlendingMode = void 0;
22911
23172
  fixed || (layerData.srcPlayData.frameTime += layerData.srcPlayData.state.speed * delta);
22912
23173
  }
22913
23174
  };
22914
- _proto._preparePlay = function _preparePlay(layerData, playState, playStateData) {
23175
+ _proto._preparePlay = function _preparePlay(layerData, playState) {
22915
23176
  if (layerData.layerState === LayerState.Playing) {
22916
23177
  var srcPlayData = layerData.srcPlayData;
22917
23178
  if (srcPlayData.state !== playState) {
22918
- var curveOwners = srcPlayData.stateData.curveOwners;
22919
- for(var i = curveOwners.length - 1; i >= 0; i--){
22920
- var owner = curveOwners[i];
22921
- (owner == null ? void 0 : owner.hasSavedDefaultValue) && owner.revertDefaultValue();
23179
+ var curveLayerOwner = srcPlayData.stateData.curveLayerOwner;
23180
+ for(var i = curveLayerOwner.length - 1; i >= 0; i--){
23181
+ var _curveLayerOwner_i;
23182
+ var owner = (_curveLayerOwner_i = curveLayerOwner[i]) == null ? void 0 : _curveLayerOwner_i.curveOwner;
23183
+ owner.revertDefaultValue();
22922
23184
  }
22923
- this._saveDefaultValues(playStateData);
22924
23185
  }
22925
23186
  } else {
22926
- // layerState is CrossFading, FixedCrossFading, Standby
22927
- var crossCurveDataCollection = this._crossOwnerCollection;
22928
- for(var i1 = crossCurveDataCollection.length - 1; i1 >= 0; i1--){
22929
- var owner1 = crossCurveDataCollection[i1];
22930
- owner1.hasSavedDefaultValue && owner1.revertDefaultValue();
23187
+ // layerState is CrossFading, FixedCrossFading, Standby, Finished
23188
+ var crossLayerOwnerCollection = layerData.crossLayerOwnerCollection;
23189
+ for(var i1 = crossLayerOwnerCollection.length - 1; i1 >= 0; i1--){
23190
+ var owner1 = crossLayerOwnerCollection[i1].curveOwner;
23191
+ owner1.revertDefaultValue();
22931
23192
  }
22932
- this._saveDefaultValues(playStateData);
22933
23193
  }
22934
23194
  };
22935
23195
  _proto._checkTransition = function _checkTransition(stateData, crossFadeTransition, layerIndex) {
@@ -22946,7 +23206,7 @@ exports.AnimatorLayerBlendingMode = void 0;
22946
23206
  _proto._crossFadeByTransition = function _crossFadeByTransition(transition, layerIndex) {
22947
23207
  var name = transition.destinationState.name;
22948
23208
  var stateInfo = this._getAnimatorStateInfo(name, layerIndex);
22949
- var crossState = stateInfo.state;
23209
+ var crossState = stateInfo.state, playLayerIndex = stateInfo.layerIndex;
22950
23210
  if (!crossState) {
22951
23211
  return;
22952
23212
  }
@@ -22954,21 +23214,21 @@ exports.AnimatorLayerBlendingMode = void 0;
22954
23214
  console.warn("The state named " + name + " has no AnimationClip data.");
22955
23215
  return;
22956
23216
  }
22957
- var animatorLayerData = this._getAnimatorLayerData(stateInfo.layerIndex);
23217
+ var animatorLayerData = this._getAnimatorLayerData(playLayerIndex);
22958
23218
  var layerState = animatorLayerData.layerState;
22959
23219
  var destPlayData = animatorLayerData.destPlayData;
22960
- var animatorStateData = this._getAnimatorStateData(name, crossState, animatorLayerData);
23220
+ var animatorStateData = this._getAnimatorStateData(name, crossState, animatorLayerData, playLayerIndex);
22961
23221
  var duration = crossState._getDuration();
22962
23222
  var offset = duration * transition.offset;
22963
23223
  destPlayData.reset(crossState, animatorStateData, offset);
22964
23224
  switch(layerState){
22965
- // Maybe not play, maybe end.
22966
23225
  case LayerState.Standby:
22967
23226
  animatorLayerData.layerState = LayerState.FixedCrossFading;
22968
23227
  this._clearCrossData(animatorLayerData);
22969
23228
  this._prepareStandbyCrossFading(animatorLayerData);
22970
23229
  break;
22971
23230
  case LayerState.Playing:
23231
+ case LayerState.Finished:
22972
23232
  animatorLayerData.layerState = LayerState.CrossFading;
22973
23233
  this._clearCrossData(animatorLayerData);
22974
23234
  this._prepareCrossFading(animatorLayerData);
@@ -23065,6 +23325,12 @@ exports.AnimatorLayerBlendingMode = void 0;
23065
23325
  }
23066
23326
  }
23067
23327
  };
23328
+ _proto._revertCurveOwners = function _revertCurveOwners() {
23329
+ var curveOwners = this._needRevertCurveOwners;
23330
+ for(var i = 0, n = curveOwners.length; i < n; ++i){
23331
+ curveOwners[i].revertDefaultValue();
23332
+ }
23333
+ };
23068
23334
  _create_class$2(Animator, [
23069
23335
  {
23070
23336
  key: "animatorController",
@@ -23096,10 +23362,10 @@ __decorate$1([
23096
23362
  ], Animator.prototype, "_animatorLayersData", void 0);
23097
23363
  __decorate$1([
23098
23364
  ignoreClone
23099
- ], Animator.prototype, "_crossOwnerCollection", void 0);
23365
+ ], Animator.prototype, "_curveOwnerPool", void 0);
23100
23366
  __decorate$1([
23101
23367
  ignoreClone
23102
- ], Animator.prototype, "_animationCurveOwners", void 0);
23368
+ ], Animator.prototype, "_needRevertCurveOwners", void 0);
23103
23369
  __decorate$1([
23104
23370
  ignoreClone
23105
23371
  ], Animator.prototype, "_animationEventHandlerPool", void 0);
@@ -26472,6 +26738,10 @@ var EntityParser = /*#__PURE__*/ function(Parser) {
26472
26738
  }
26473
26739
  glTFResource.sceneRoots = sceneRoots;
26474
26740
  glTFResource.defaultSceneRoot = sceneRoots[sceneID];
26741
+ // @ts-ignore
26742
+ glTFResource.defaultSceneRoot._hookResource = glTFResource;
26743
+ // @ts-ignore
26744
+ glTFResource._addRefCount(1);
26475
26745
  };
26476
26746
  return EntityParser;
26477
26747
  }(Parser);
@@ -27203,36 +27473,20 @@ var GLTFParser = /*#__PURE__*/ function() {
27203
27473
  })();
27204
27474
  /**
27205
27475
  * Product after GLTF parser, usually, `defaultSceneRoot` is only needed to use.
27206
- */ var GLTFResource = /*#__PURE__*/ function(EngineObject) {
27476
+ */ var GLTFResource = /*#__PURE__*/ function(RefObject) {
27207
27477
  var GLTFResource = function GLTFResource(engine, url) {
27208
27478
  var _this;
27209
- _this = EngineObject.call(this, engine) || this;
27479
+ _this = RefObject.call(this, engine) || this;
27210
27480
  _this.url = url;
27211
27481
  return _this;
27212
27482
  };
27213
- _inherits$1(GLTFResource, EngineObject);
27483
+ _inherits$1(GLTFResource, RefObject);
27214
27484
  var _proto = GLTFResource.prototype;
27215
27485
  /**
27216
- * @override
27217
- */ _proto.destroy = function destroy() {
27218
- if (this._destroyed) {
27219
- return;
27220
- }
27221
- EngineObject.prototype.destroy.call(this);
27222
- this.defaultSceneRoot.destroy();
27223
- this.textures = null;
27224
- this.materials = null;
27225
- this.meshes = null;
27226
- this.skins = null;
27227
- this.animations = null;
27228
- this.entities = null;
27229
- this.cameras = null;
27230
- this.lights = null;
27231
- this.sceneRoots = null;
27232
- this.variants = null;
27233
- };
27486
+ * @internal
27487
+ */ _proto._onDestroy = function _onDestroy() {};
27234
27488
  return GLTFResource;
27235
- }(miniprogram$5.EngineObject);
27489
+ }(miniprogram$5.RefObject);
27236
27490
  var GLTFLoader = /*#__PURE__*/ function(Loader) {
27237
27491
  var GLTFLoader = function GLTFLoader() {
27238
27492
  return Loader.apply(this, arguments);
@@ -36006,7 +36260,7 @@ function _interopNamespace(e) {
36006
36260
  }
36007
36261
  var CoreObjects__namespace = /*#__PURE__*/ _interopNamespace(CoreObjects);
36008
36262
  //@ts-ignore
36009
- var version = "0.9.12";
36263
+ var version = "0.9.14";
36010
36264
  console.log("Galacean engine version: " + version);
36011
36265
  for(var key in CoreObjects__namespace){
36012
36266
  CoreObjects.Loader.registerClass(key, CoreObjects__namespace[key]);