@galacean/engine-core 0.0.0-experimental-2.0-game.14 → 0.0.0-experimental-2.0-game.16

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
@@ -353,10 +353,14 @@ function _instanceof(left, right) {
353
353
  if (_instanceof(sourceProperty, Map) || _instanceof(sourceProperty, Set)) return CloneMode.Deep;
354
354
  // Value types with copyFrom (math types like Vector3, Color, etc.)
355
355
  if (sourceProperty.copyFrom) return CloneMode.Deep;
356
- // Plain objects - deep clone (may contain Entity/Component refs)
357
- if (sourceProperty.constructor === Object) return CloneMode.Deep;
358
- // Other class instances (engine resources like Material, Texture) - shared reference
359
- return CloneMode.Assignment;
356
+ // Engine resources (Material, Texture, Mesh, Shader, ...) refCount-managed,
357
+ // shared by reference. Anything outside this contract is treated as a value-like
358
+ // user class and gets a deep clone (so nested Entity/Component refs are remapped).
359
+ if (_instanceof(sourceProperty, ReferResource)) return CloneMode.Assignment;
360
+ // Default: deep clone. Covers plain objects {...} and user-defined value classes
361
+ // (EventHandler, business data containers). Internal Entity/Component refs reach
362
+ // line 109's _remap branch and are correctly rebound to the target tree.
363
+ return CloneMode.Deep;
360
364
  };
361
365
  CloneManager.deepCloneObject = function deepCloneObject(source, target, deepInstanceMap) {
362
366
  for(var k in source){
@@ -4564,6 +4568,18 @@ var RenderElement = /*#__PURE__*/ function() {
4564
4568
  this.subChunk = subChunk;
4565
4569
  this.instancedRenderers.length = 0;
4566
4570
  };
4571
+ /**
4572
+ * @internal
4573
+ * Copy identity fields from `source` and reset per-queue batch state, so the same
4574
+ * logical element can live in multiple queues (e.g. an Opaque + Transparent multi-pass
4575
+ * material) without one queue's batching corrupting another's `instancedRenderers`.
4576
+ */ _proto._cloneFrom = function _cloneFrom(source) {
4577
+ this.set(source.component, source.material, source.primitive, source.subPrimitive, source.texture, source.subChunk);
4578
+ this.priority = source.priority;
4579
+ this.distanceForSort = source.distanceForSort;
4580
+ this.subShader = source.subShader;
4581
+ this.shaderData = source.shaderData;
4582
+ };
4567
4583
  _proto.dispose = function dispose() {
4568
4584
  this.component = null;
4569
4585
  this.material = null;
@@ -5564,7 +5580,7 @@ function dependentComponents(componentOrComponents, dependentMode) {
5564
5580
  _inherits(Transform, Component);
5565
5581
  function Transform(entity) {
5566
5582
  var _this;
5567
- _this = Component.call(this, entity) || this, _this._position = new engineMath.Vector3(), _this._rotation = new engineMath.Vector3(), _this._rotationQuaternion = new engineMath.Quaternion(), _this._scale = new engineMath.Vector3(1, 1, 1), _this._localUniformScaling = true, _this._worldPosition = new engineMath.Vector3(), _this._worldRotation = new engineMath.Vector3(), _this._worldRotationQuaternion = new engineMath.Quaternion(), _this._worldUniformScaling = true, _this._lossyWorldScale = new engineMath.Vector3(1, 1, 1), _this._localMatrix = new engineMath.Matrix(), _this._worldMatrix = new engineMath.Matrix(), _this._worldForward = null, _this._worldRight = null, _this._worldUp = null, _this._isParentDirty = true, _this._parentTransformCache = null, _this._dirtyFlag = 510;
5583
+ _this = Component.call(this, entity) || this, _this._position = new engineMath.Vector3(), _this._rotation = new engineMath.Vector3(), _this._rotationQuaternion = new engineMath.Quaternion(), _this._scale = new engineMath.Vector3(1, 1, 1), _this._localUniformScaling = true, _this._worldPosition = new engineMath.Vector3(), _this._worldRotation = new engineMath.Vector3(), _this._worldRotationQuaternion = new engineMath.Quaternion(), _this._worldUniformScaling = true, _this._lossyWorldScale = new engineMath.Vector3(1, 1, 1), _this._localMatrix = new engineMath.Matrix(), _this._worldMatrix = new engineMath.Matrix(), _this._worldForward = null, _this._worldRight = null, _this._worldUp = null, _this._frontFaceInvert = false, _this._isParentDirty = true, _this._parentTransformCache = null, _this._dirtyFlag = 2558;
5568
5584
  _this._onPositionChanged = _this._onPositionChanged.bind(_this);
5569
5585
  _this._onWorldPositionChanged = _this._onWorldPositionChanged.bind(_this);
5570
5586
  _this._onRotationChanged = _this._onRotationChanged.bind(_this);
@@ -5722,7 +5738,7 @@ function dependentComponents(componentOrComponents, dependentMode) {
5722
5738
  // `_getParentTransform` was ever called while their ancestor chain was
5723
5739
  // partially constructed during clone/instantiate). Force them to
5724
5740
  // re-resolve the parent transform on next access.
5725
- this._propagateReparentDirty(444);
5741
+ this._propagateReparentDirty(2492);
5726
5742
  };
5727
5743
  _proto._propagateReparentDirty = function _propagateReparentDirty(flags) {
5728
5744
  this._worldAssociatedChange(flags);
@@ -5738,11 +5754,16 @@ function dependentComponents(componentOrComponents, dependentMode) {
5738
5754
  /**
5739
5755
  * @internal
5740
5756
  */ _proto._isFrontFaceInvert = function _isFrontFaceInvert() {
5741
- var scale = this.lossyWorldScale;
5742
- var isInvert = scale.x < 0;
5743
- scale.y < 0 && (isInvert = !isInvert);
5744
- scale.z < 0 && (isInvert = !isInvert);
5745
- return isInvert;
5757
+ if (this._isContainDirtyFlag(2048)) {
5758
+ var s = this._scale;
5759
+ var invert = s.x < 0;
5760
+ s.y < 0 && (invert = !invert);
5761
+ s.z < 0 && (invert = !invert);
5762
+ var parent = this._getParentTransform();
5763
+ this._frontFaceInvert = parent ? invert !== parent._isFrontFaceInvert() : invert;
5764
+ this._setDirtyFlagFalse(2048);
5765
+ }
5766
+ return this._frontFaceInvert;
5746
5767
  };
5747
5768
  /**
5748
5769
  * @internal
@@ -5765,7 +5786,7 @@ function dependentComponents(componentOrComponents, dependentMode) {
5765
5786
  // the computed value. After this _cloneTo writes new local values, those world-derived caches are stale,
5766
5787
  // so re-dirty them and notify listeners (Collider._updateFlag etc.) so subsequent reads recompute correctly.
5767
5788
  target._setDirtyFlagTrue(2 | 64);
5768
- target._worldAssociatedChange(444);
5789
+ target._worldAssociatedChange(2492);
5769
5790
  };
5770
5791
  _proto._onLocalMatrixChanging = function _onLocalMatrixChanging() {
5771
5792
  this._setDirtyFlagFalse(64);
@@ -5848,10 +5869,10 @@ function dependentComponents(componentOrComponents, dependentMode) {
5848
5869
  */ _proto._updateWorldRotationFlag = function _updateWorldRotationFlag() {
5849
5870
  var parent = this._getParentTransform();
5850
5871
  var parentWorldUniformScaling = parent ? parent._getWorldUniformScaling() : true;
5851
- var flags = parentWorldUniformScaling ? 152 : 184;
5872
+ var flags = parentWorldUniformScaling ? 152 : 2232;
5852
5873
  if (!this._isContainDirtyFlags(flags)) {
5853
5874
  this._worldAssociatedChange(flags);
5854
- flags = this._getWorldUniformScaling() ? 156 : 188;
5875
+ flags = this._getWorldUniformScaling() ? 156 : 2236;
5855
5876
  var children = this._entity._children;
5856
5877
  for(var i = 0, n = children.length; i < n; i++){
5857
5878
  var _children_i_transform;
@@ -5870,7 +5891,7 @@ function dependentComponents(componentOrComponents, dependentMode) {
5870
5891
  */ _proto._updateWorldPositionAndRotationFlag = function _updateWorldPositionAndRotationFlag(flags) {
5871
5892
  if (!this._isContainDirtyFlags(flags)) {
5872
5893
  this._worldAssociatedChange(flags);
5873
- flags = this._getWorldUniformScaling() ? 156 : 188;
5894
+ flags = this._getWorldUniformScaling() ? 156 : 2236;
5874
5895
  var children = this._entity._children;
5875
5896
  for(var i = 0, n = children.length; i < n; i++){
5876
5897
  var _children_i_transform;
@@ -5992,9 +6013,9 @@ function dependentComponents(componentOrComponents, dependentMode) {
5992
6013
  var localUniformScaling = x == y && y == z;
5993
6014
  if (this._localUniformScaling !== localUniformScaling) {
5994
6015
  this._localUniformScaling = localUniformScaling;
5995
- this._updateWorldScaleFlag(416);
6016
+ this._updateWorldScaleFlag(2464);
5996
6017
  } else {
5997
- this._updateWorldScaleFlag(160);
6018
+ this._updateWorldScaleFlag(2208);
5998
6019
  }
5999
6020
  };
6000
6021
  _proto._getWorldUniformScaling = function _getWorldUniformScaling() {
@@ -6232,9 +6253,9 @@ function dependentComponents(componentOrComponents, dependentMode) {
6232
6253
  var localUniformScaling = scale.x === scale.y && scale.y === scale.z;
6233
6254
  if (this._localUniformScaling !== localUniformScaling) {
6234
6255
  this._localUniformScaling = localUniformScaling;
6235
- this._updateAllWorldFlag(444);
6256
+ this._updateAllWorldFlag(2492);
6236
6257
  } else {
6237
- this._updateAllWorldFlag(188);
6258
+ this._updateAllWorldFlag(2236);
6238
6259
  }
6239
6260
  }
6240
6261
  },
@@ -6360,6 +6381,9 @@ __decorate([
6360
6381
  __decorate([
6361
6382
  ignoreClone
6362
6383
  ], Transform.prototype, "_worldUp", void 0);
6384
+ __decorate([
6385
+ ignoreClone
6386
+ ], Transform.prototype, "_frontFaceInvert", void 0);
6363
6387
  __decorate([
6364
6388
  ignoreClone
6365
6389
  ], Transform.prototype, "_isParentDirty", void 0);
@@ -6401,16 +6425,18 @@ __decorate([
6401
6425
  /** This is an internal flag used to assist in determining the dispatch
6402
6426
  * of world scaling dirty flags in the case of non-uniform scaling.
6403
6427
  */ TransformModifyFlags[TransformModifyFlags["IsWorldUniformScaling"] = 256] = "IsWorldUniformScaling";
6428
+ // Note: 0x200 (UITransformModifyFlags.Size) and 0x400 (Pivot) are reserved by UITransform — do not reuse.
6429
+ TransformModifyFlags[TransformModifyFlags["WorldFrontFaceInvert"] = 2048] = "WorldFrontFaceInvert";
6404
6430
  /** WorldMatrix | WorldPosition */ TransformModifyFlags[TransformModifyFlags["WmWp"] = 132] = "WmWp";
6405
6431
  /** WorldMatrix | WorldEuler | WorldQuat */ TransformModifyFlags[TransformModifyFlags["WmWeWq"] = 152] = "WmWeWq";
6406
- /** WorldMatrix | WorldEuler | WorldQuat | WorldScale*/ TransformModifyFlags[TransformModifyFlags["WmWeWqWs"] = 184] = "WmWeWqWs";
6432
+ /** WorldMatrix | WorldEuler | WorldQuat | WorldScale | WorldFrontFaceInvert */ TransformModifyFlags[TransformModifyFlags["WmWeWqWs"] = 2232] = "WmWeWqWs";
6407
6433
  /** WorldMatrix | WorldPosition | WorldEuler | WorldQuat */ TransformModifyFlags[TransformModifyFlags["WmWpWeWq"] = 156] = "WmWpWeWq";
6408
- /** WorldMatrix | WorldScale */ TransformModifyFlags[TransformModifyFlags["WmWs"] = 160] = "WmWs";
6409
- /** WorldMatrix | WorldScale | WorldUniformScaling */ TransformModifyFlags[TransformModifyFlags["WmWsWus"] = 416] = "WmWsWus";
6410
- /** WorldMatrix | WorldPosition | WorldScale */ TransformModifyFlags[TransformModifyFlags["WmWpWs"] = 164] = "WmWpWs";
6411
- /** WorldMatrix | WorldPosition | WorldEuler | WorldQuat | WorldScale */ TransformModifyFlags[TransformModifyFlags["WmWpWeWqWs"] = 188] = "WmWpWeWqWs";
6412
- /** WorldMatrix | WorldPosition | WorldEuler | WorldQuat | WorldScale | WorldUniformScaling */ TransformModifyFlags[TransformModifyFlags["WmWpWeWqWsWus"] = 444] = "WmWpWeWqWsWus";
6413
- /** LocalQuat | LocalMatrix | WorldMatrix | WorldPosition | WorldEuler | WorldQuat | WorldScale | WorldUniformScaling */ TransformModifyFlags[TransformModifyFlags["LqLmWmWpWeWqWsWus"] = 510] = "LqLmWmWpWeWqWsWus";
6434
+ /** WorldMatrix | WorldScale | WorldFrontFaceInvert */ TransformModifyFlags[TransformModifyFlags["WmWs"] = 2208] = "WmWs";
6435
+ /** WorldMatrix | WorldScale | WorldUniformScaling | WorldFrontFaceInvert */ TransformModifyFlags[TransformModifyFlags["WmWsWus"] = 2464] = "WmWsWus";
6436
+ /** WorldMatrix | WorldPosition | WorldScale | WorldFrontFaceInvert */ TransformModifyFlags[TransformModifyFlags["WmWpWs"] = 2212] = "WmWpWs";
6437
+ /** WorldMatrix | WorldPosition | WorldEuler | WorldQuat | WorldScale | WorldFrontFaceInvert */ TransformModifyFlags[TransformModifyFlags["WmWpWeWqWs"] = 2236] = "WmWpWeWqWs";
6438
+ /** WorldMatrix | WorldPosition | WorldEuler | WorldQuat | WorldScale | WorldUniformScaling | WorldFrontFaceInvert */ TransformModifyFlags[TransformModifyFlags["WmWpWeWqWsWus"] = 2492] = "WmWpWeWqWsWus";
6439
+ /** LocalQuat | LocalMatrix | WorldMatrix | WorldPosition | WorldEuler | WorldQuat | WorldScale | WorldUniformScaling | WorldFrontFaceInvert */ TransformModifyFlags[TransformModifyFlags["LqLmWmWpWeWqWsWus"] = 2558] = "LqLmWmWpWeWqWsWus";
6414
6440
  return TransformModifyFlags;
6415
6441
  }({});
6416
6442
 
@@ -6460,6 +6486,12 @@ __decorate([
6460
6486
  function ShaderData(group) {
6461
6487
  /** @internal */ this._propertyValueMap = Object.create(null);
6462
6488
  /** @internal */ this._macroCollection = new ShaderMacroCollection();
6489
+ /**
6490
+ * @internal
6491
+ * Sorted (ascending) property ids of renderer-group samplers and arrays. These values
6492
+ * can't differ across instances inside an instanced draw call — `_canBatch` uses this
6493
+ * list to refuse batching renderers that would disagree on what to bind
6494
+ */ this._instanceBatchFields = [];
6463
6495
  this._macroMap = Object.create(null);
6464
6496
  this._refCount = 0;
6465
6497
  this._group = group;
@@ -6678,7 +6710,52 @@ __decorate([
6678
6710
  throw "Shader property " + property.name + " has been used as " + ShaderPropertyType[property._type] + " type.";
6679
6711
  }
6680
6712
  }
6681
- this._propertyValueMap[property._uniqueId] = value;
6713
+ var id = property._uniqueId;
6714
+ // Track renderer-group samplers/arrays so `_canBatch` can refuse instanced batches
6715
+ // whose leader and follower would disagree on what to bind
6716
+ if (this._group === ShaderDataGroup.Renderer && (type === ShaderPropertyType.Texture || type === ShaderPropertyType.TextureArray || type === ShaderPropertyType.FloatArray || type === ShaderPropertyType.IntArray)) {
6717
+ var oldHas = this._propertyValueMap[id] != null;
6718
+ var newHas = value != null;
6719
+ if (oldHas !== newHas) {
6720
+ var fields = this._instanceBatchFields;
6721
+ if (newHas) {
6722
+ // Insert keeping ascending order so exact compare is index-by-index
6723
+ var lo = 0;
6724
+ var hi = fields.length;
6725
+ while(lo < hi){
6726
+ var mid = lo + hi >>> 1;
6727
+ if (fields[mid] < id) {
6728
+ lo = mid + 1;
6729
+ } else {
6730
+ hi = mid;
6731
+ }
6732
+ }
6733
+ fields.splice(lo, 0, id);
6734
+ } else {
6735
+ fields.splice(fields.indexOf(id), 1);
6736
+ }
6737
+ }
6738
+ }
6739
+ this._propertyValueMap[id] = value;
6740
+ };
6741
+ /**
6742
+ * @internal
6743
+ */ _proto._matchesRendererInstanceBatch = function _matchesRendererInstanceBatch(other) {
6744
+ var selfFields = this._instanceBatchFields;
6745
+ var otherFields = other._instanceBatchFields;
6746
+ var fieldCount = selfFields.length;
6747
+ if (fieldCount !== otherFields.length) {
6748
+ return false;
6749
+ }
6750
+ var selfMap = this._propertyValueMap;
6751
+ var otherMap = other._propertyValueMap;
6752
+ for(var i = 0; i < fieldCount; i++){
6753
+ var id = selfFields[i];
6754
+ if (id !== otherFields[i] || selfMap[id] !== otherMap[id]) {
6755
+ return false;
6756
+ }
6757
+ }
6758
+ return true;
6682
6759
  };
6683
6760
  /**
6684
6761
  * @internal
@@ -6709,6 +6786,9 @@ __decorate([
6709
6786
  __decorate([
6710
6787
  ignoreClone
6711
6788
  ], ShaderData.prototype, "_macroCollection", void 0);
6789
+ __decorate([
6790
+ ignoreClone
6791
+ ], ShaderData.prototype, "_instanceBatchFields", void 0);
6712
6792
  __decorate([
6713
6793
  ignoreClone
6714
6794
  ], ShaderData.prototype, "_macroMap", void 0);
@@ -14401,7 +14481,9 @@ var BlendShapeFrameDirty = /*#__PURE__*/ function(BlendShapeFrameDirty) {
14401
14481
  * @internal
14402
14482
  */ _proto._canBatch = function _canBatch(preElement, curElement) {
14403
14483
  if (!this._engine._hardwareRenderer.isWebGL2) return false;
14404
- return preElement.primitive === curElement.primitive && preElement.subPrimitive === curElement.subPrimitive && preElement.material === curElement.material && this._isFrontFaceInvert() === curElement.component._isFrontFaceInvert() && this.shaderData._macroCollection.isEqual(curElement.component.shaderData._macroCollection);
14484
+ var curShaderData = curElement.component.shaderData;
14485
+ return preElement.primitive === curElement.primitive && preElement.subPrimitive === curElement.subPrimitive && preElement.material === curElement.material && this._isFrontFaceInvert() === curElement.component._isFrontFaceInvert() && this.shaderData._macroCollection.isEqual(curShaderData._macroCollection) && // Renderer-group samplers/arrays are shared across the whole instanced draw call
14486
+ this.shaderData._matchesRendererInstanceBatch(curShaderData);
14405
14487
  };
14406
14488
  /**
14407
14489
  * @internal
@@ -18975,8 +19057,11 @@ RenderContext._flipYViewProjectionMatrix = new engineMath.Matrix();
18975
19057
  * @internal
18976
19058
  */ var RenderTargetPool = /*#__PURE__*/ function() {
18977
19059
  function RenderTargetPool(engine) {
19060
+ /** Frames an entry may sit idle before `tick()` destroys it. */ this.maxFreeAgeFrames = 60;
18978
19061
  this._freeRenderTargets = [];
19062
+ this._freeRenderTargetFrames = [];
18979
19063
  this._freeTextures = [];
19064
+ this._freeTextureFrames = [];
18980
19065
  this._engine = engine;
18981
19066
  }
18982
19067
  var _proto = RenderTargetPool.prototype;
@@ -18985,8 +19070,7 @@ RenderContext._flipYViewProjectionMatrix = new engineMath.Matrix();
18985
19070
  for(var i = freeRenderTargets.length - 1; i >= 0; i--){
18986
19071
  var renderTarget = freeRenderTargets[i];
18987
19072
  if (RenderTargetPool._matchRenderTarget(renderTarget, width, height, colorFormat, depthFormat, needDepthTexture, mipmap, isSRGBColorSpace, antiAliasing)) {
18988
- freeRenderTargets[i] = freeRenderTargets[freeRenderTargets.length - 1];
18989
- freeRenderTargets.length--;
19073
+ this._removeFreeRenderTargetAt(i);
18990
19074
  var colorTexture = renderTarget.getColorTexture(0);
18991
19075
  if (colorTexture) {
18992
19076
  colorTexture.wrapModeU = colorTexture.wrapModeV = wrapMode;
@@ -19029,8 +19113,7 @@ RenderContext._flipYViewProjectionMatrix = new engineMath.Matrix();
19029
19113
  for(var i = freeTextures.length - 1; i >= 0; i--){
19030
19114
  var texture = freeTextures[i];
19031
19115
  if (texture.width === width && texture.height === height && texture.format === format && texture.mipmapCount > 1 === mipmap && texture.isSRGBColorSpace === isSRGBColorSpace) {
19032
- freeTextures[i] = freeTextures[freeTextures.length - 1];
19033
- freeTextures.length--;
19116
+ this._removeFreeTextureAt(i);
19034
19117
  texture.wrapModeU = texture.wrapModeV = wrapMode;
19035
19118
  texture.filterMode = filterMode;
19036
19119
  return texture;
@@ -19045,29 +19128,98 @@ RenderContext._flipYViewProjectionMatrix = new engineMath.Matrix();
19045
19128
  _proto.freeRenderTarget = function freeRenderTarget(renderTarget) {
19046
19129
  if (!renderTarget || renderTarget.destroyed) return;
19047
19130
  this._freeRenderTargets.push(renderTarget);
19131
+ this._freeRenderTargetFrames.push(this._engine.time.frameCount);
19048
19132
  };
19049
19133
  _proto.freeTexture = function freeTexture(texture) {
19050
19134
  if (!texture || texture.destroyed) return;
19051
19135
  this._freeTextures.push(texture);
19136
+ this._freeTextureFrames.push(this._engine.time.frameCount);
19137
+ };
19138
+ _proto.tick = function tick(currentFrame) {
19139
+ var maxAge = this.maxFreeAgeFrames;
19140
+ var rtFrames = this._freeRenderTargetFrames;
19141
+ for(var i = rtFrames.length - 1; i >= 0; i--){
19142
+ if (currentFrame - rtFrames[i] > maxAge) {
19143
+ this._destroyFreeRenderTargetAt(i);
19144
+ }
19145
+ }
19146
+ var texFrames = this._freeTextureFrames;
19147
+ for(var i1 = texFrames.length - 1; i1 >= 0; i1--){
19148
+ if (currentFrame - texFrames[i1] > maxAge) {
19149
+ this._destroyFreeTextureAt(i1);
19150
+ }
19151
+ }
19152
+ };
19153
+ _proto.evictBySize = function evictBySize(width, height) {
19154
+ var freeRenderTargets = this._freeRenderTargets;
19155
+ for(var i = freeRenderTargets.length - 1; i >= 0; i--){
19156
+ var rt = freeRenderTargets[i];
19157
+ if (rt.width === width && rt.height === height) {
19158
+ this._destroyFreeRenderTargetAt(i);
19159
+ }
19160
+ }
19161
+ var freeTextures = this._freeTextures;
19162
+ for(var i1 = freeTextures.length - 1; i1 >= 0; i1--){
19163
+ var tex = freeTextures[i1];
19164
+ if (tex.width === width && tex.height === height) {
19165
+ this._destroyFreeTextureAt(i1);
19166
+ }
19167
+ }
19052
19168
  };
19053
19169
  _proto.gc = function gc() {
19054
19170
  var freeRenderTargets = this._freeRenderTargets;
19055
19171
  for(var i = 0, n = freeRenderTargets.length; i < n; i++){
19056
- var renderTarget = freeRenderTargets[i];
19057
- var colorTexture = renderTarget.getColorTexture(0);
19058
- var depthTexture = renderTarget.depthTexture;
19059
- renderTarget.destroy(true);
19060
- colorTexture == null ? void 0 : colorTexture.destroy(true);
19061
- if (depthTexture && depthTexture !== colorTexture) {
19062
- depthTexture.destroy(true);
19063
- }
19172
+ RenderTargetPool._destroyRenderTargetResource(freeRenderTargets[i]);
19064
19173
  }
19065
19174
  freeRenderTargets.length = 0;
19175
+ this._freeRenderTargetFrames.length = 0;
19066
19176
  var freeTextures = this._freeTextures;
19067
19177
  for(var i1 = 0, n1 = freeTextures.length; i1 < n1; i1++){
19068
19178
  freeTextures[i1].destroy(true);
19069
19179
  }
19070
19180
  freeTextures.length = 0;
19181
+ this._freeTextureFrames.length = 0;
19182
+ };
19183
+ _proto._removeFreeRenderTargetAt = function _removeFreeRenderTargetAt(index) {
19184
+ var rts = this._freeRenderTargets;
19185
+ var frames = this._freeRenderTargetFrames;
19186
+ var last = rts.length - 1;
19187
+ if (index !== last) {
19188
+ rts[index] = rts[last];
19189
+ frames[index] = frames[last];
19190
+ }
19191
+ rts.length = last;
19192
+ frames.length = last;
19193
+ };
19194
+ _proto._removeFreeTextureAt = function _removeFreeTextureAt(index) {
19195
+ var texs = this._freeTextures;
19196
+ var frames = this._freeTextureFrames;
19197
+ var last = texs.length - 1;
19198
+ if (index !== last) {
19199
+ texs[index] = texs[last];
19200
+ frames[index] = frames[last];
19201
+ }
19202
+ texs.length = last;
19203
+ frames.length = last;
19204
+ };
19205
+ _proto._destroyFreeRenderTargetAt = function _destroyFreeRenderTargetAt(index) {
19206
+ var rt = this._freeRenderTargets[index];
19207
+ this._removeFreeRenderTargetAt(index);
19208
+ RenderTargetPool._destroyRenderTargetResource(rt);
19209
+ };
19210
+ _proto._destroyFreeTextureAt = function _destroyFreeTextureAt(index) {
19211
+ var tex = this._freeTextures[index];
19212
+ this._removeFreeTextureAt(index);
19213
+ tex.destroy(true);
19214
+ };
19215
+ RenderTargetPool._destroyRenderTargetResource = function _destroyRenderTargetResource(rt) {
19216
+ var colorTexture = rt.getColorTexture(0);
19217
+ var depthTexture = rt.depthTexture;
19218
+ rt.destroy(true);
19219
+ colorTexture == null ? void 0 : colorTexture.destroy(true);
19220
+ if (depthTexture && depthTexture !== colorTexture) {
19221
+ depthTexture.destroy(true);
19222
+ }
19071
19223
  };
19072
19224
  RenderTargetPool._matchRenderTarget = function _matchRenderTarget(renderTarget, width, height, colorFormat, depthFormat, needDepthTexture, mipmap, isSRGBColorSpace, antiAliasing) {
19073
19225
  if (renderTarget.width !== width || renderTarget.height !== height || renderTarget.antiAliasing !== antiAliasing) {
@@ -27180,17 +27332,15 @@ Shader.create("FinalAntiAliasing", BlitVS, FinalAntiAliasingFS);
27180
27332
  }
27181
27333
  var switchProgram = program.bind();
27182
27334
  var switchRenderCount = renderCount !== program._uploadRenderCount;
27183
- // Upload uniforms (cache-aware per block)
27335
+ // Upload uniforms (cache-aware per block). Renderer block carries plain samplers/arrays
27336
+ // even on the instanced path (GLSL forbids them in UBOs); `_canBatch` ensures the whole
27337
+ // batch agrees on those, so the leader's values are correct for the draw call
27184
27338
  if (switchRenderCount) {
27185
27339
  program.groupingOtherUniformBlock();
27186
27340
  program.uploadAll(program.sceneUniformBlock, sceneData);
27187
27341
  program.uploadAll(program.cameraUniformBlock, cameraData);
27188
- if (isInstanced) {
27189
- program._uploadRendererId = -1;
27190
- } else {
27191
- program.uploadAll(program.rendererUniformBlock, rendererData);
27192
- program._uploadRendererId = rendererId;
27193
- }
27342
+ program.uploadAll(program.rendererUniformBlock, rendererData);
27343
+ program._uploadRendererId = isInstanced ? -1 : rendererId;
27194
27344
  program.uploadAll(program.materialUniformBlock, materialData);
27195
27345
  renderElementShaderData && program.uploadAll(program.renderElementUniformBlock, renderElementShaderData);
27196
27346
  // UnGroup textures should upload default value, texture uint maybe change by logic of texture bind
@@ -27212,13 +27362,15 @@ Shader.create("FinalAntiAliasing", BlitVS, FinalAntiAliasingFS);
27212
27362
  } else if (switchProgram) {
27213
27363
  program.uploadTextures(program.cameraUniformBlock, cameraData);
27214
27364
  }
27215
- if (!isInstanced) {
27216
- if (program._uploadRendererId !== rendererId) {
27217
- program.uploadAll(program.rendererUniformBlock, rendererData);
27218
- program._uploadRendererId = rendererId;
27219
- } else if (switchProgram) {
27220
- program.uploadTextures(program.rendererUniformBlock, rendererData);
27221
- }
27365
+ if (isInstanced) {
27366
+ // Different batches may have different leaders, re-upload every time
27367
+ program.uploadAll(program.rendererUniformBlock, rendererData);
27368
+ program._uploadRendererId = -1;
27369
+ } else if (program._uploadRendererId !== rendererId) {
27370
+ program.uploadAll(program.rendererUniformBlock, rendererData);
27371
+ program._uploadRendererId = rendererId;
27372
+ } else if (switchProgram) {
27373
+ program.uploadTextures(program.rendererUniformBlock, rendererData);
27222
27374
  }
27223
27375
  if (program._uploadMaterialId !== materialId) {
27224
27376
  program.uploadAll(program.materialUniformBlock, materialData);
@@ -28237,19 +28389,8 @@ CascadedShadowCasterPass._tempMatrix0 = new engineMath.Matrix();
28237
28389
  this._copyBackgroundTexture = copyBackgroundTexture;
28238
28390
  }
28239
28391
  this._internalColorTarget = internalColorTarget;
28240
- } else {
28241
- var internalColorTarget1 = this._internalColorTarget;
28242
- var copyBackgroundTexture1 = this._copyBackgroundTexture;
28243
- var pool = engine._renderTargetPool;
28244
- if (internalColorTarget1) {
28245
- pool.freeRenderTarget(internalColorTarget1);
28246
- this._internalColorTarget = null;
28247
- }
28248
- if (copyBackgroundTexture1) {
28249
- pool.freeTexture(copyBackgroundTexture1);
28250
- this._copyBackgroundTexture = null;
28251
- }
28252
28392
  }
28393
+ // Both fields are released at the end of `_drawRenderPass`, so they're null on every entry here.
28253
28394
  // Scalable ambient obscurance pass
28254
28395
  // Before opaque pass so materials can sample ambient occlusion in BRDF
28255
28396
  var saoPass = this._saoPass;
@@ -28366,6 +28507,16 @@ CascadedShadowCasterPass._tempMatrix0 = new engineMath.Matrix();
28366
28507
  }
28367
28508
  cameraRenderTarget == null ? void 0 : cameraRenderTarget._blitRenderTarget();
28368
28509
  cameraRenderTarget == null ? void 0 : cameraRenderTarget.generateMipmaps();
28510
+ // Release per-frame leases so the next camera with matching shape can reuse them.
28511
+ var pool = engine._renderTargetPool;
28512
+ if (this._internalColorTarget) {
28513
+ pool.freeRenderTarget(this._internalColorTarget);
28514
+ this._internalColorTarget = null;
28515
+ }
28516
+ if (this._copyBackgroundTexture) {
28517
+ pool.freeTexture(this._copyBackgroundTexture);
28518
+ this._copyBackgroundTexture = null;
28519
+ }
28369
28520
  };
28370
28521
  /**
28371
28522
  * Push render data to render queue.
@@ -28401,6 +28552,7 @@ CascadedShadowCasterPass._tempMatrix0 = new engineMath.Matrix();
28401
28552
  _proto._pushRenderElementByType = function _pushRenderElementByType(renderElement, subShader, renderStates) {
28402
28553
  var shaderPasses = subShader.passes;
28403
28554
  var cullingResults = this._cullingResults;
28555
+ renderElement.subShader = subShader;
28404
28556
  var pushedQueueFlags = 0;
28405
28557
  for(var i = 0, n = shaderPasses.length; i < n; i++){
28406
28558
  var renderQueueType = void 0;
@@ -28412,19 +28564,28 @@ CascadedShadowCasterPass._tempMatrix0 = new engineMath.Matrix();
28412
28564
  renderQueueType = renderStates[i].renderQueueType;
28413
28565
  }
28414
28566
  var flag = 1 << renderQueueType;
28415
- renderElement.subShader = subShader;
28416
28567
  if (pushedQueueFlags & flag) {
28417
28568
  continue;
28418
28569
  }
28570
+ // First queue keeps the original element; subsequent queues each get an isolated
28571
+ // clone so per-queue batch state (`_isBatched`, `instancedRenderers`) doesn't
28572
+ // leak across queues for multi-pass materials (e.g. Opaque + Transparent)
28573
+ var elementForQueue = void 0;
28574
+ if (pushedQueueFlags === 0) {
28575
+ elementForQueue = renderElement;
28576
+ } else {
28577
+ elementForQueue = renderElement.component.engine._renderElementPool.get();
28578
+ elementForQueue._cloneFrom(renderElement);
28579
+ }
28419
28580
  switch(renderQueueType){
28420
28581
  case RenderQueueType.Opaque:
28421
- cullingResults.opaqueQueue.pushRenderElement(renderElement);
28582
+ cullingResults.opaqueQueue.pushRenderElement(elementForQueue);
28422
28583
  break;
28423
28584
  case RenderQueueType.AlphaTest:
28424
- cullingResults.alphaTestQueue.pushRenderElement(renderElement);
28585
+ cullingResults.alphaTestQueue.pushRenderElement(elementForQueue);
28425
28586
  break;
28426
28587
  case RenderQueueType.Transparent:
28427
- cullingResults.transparentQueue.pushRenderElement(renderElement);
28588
+ cullingResults.transparentQueue.pushRenderElement(elementForQueue);
28428
28589
  break;
28429
28590
  }
28430
28591
  pushedQueueFlags |= flag;
@@ -28640,7 +28801,18 @@ ShaderPool.init();
28640
28801
  _inherits(Engine, EventDispatcher);
28641
28802
  function Engine(canvas, hardwareRenderer, configuration) {
28642
28803
  var _this;
28643
- _this = EventDispatcher.call(this) || this, /** @internal */ _this._renderingStatistics = new RenderingStatistics(), /** @internal */ _this._isDeviceLost = false, /** @internal */ _this._frameInProcess = false, /** @internal */ _this._pendingDestroyObjects = [], /** @internal */ _this._processingPendingDestroys = false, /** @internal */ _this._physicsInitialized = false, /* @internal */ _this._lastRenderState = new RenderState(), /* @internal */ _this._renderElementPool = new ClearableObjectPool(RenderElement), /* @internal */ _this._textRenderElementPool = new ClearableObjectPool(RenderElement), /* @internal */ _this._charRenderInfoPool = new ReturnableObjectPool(CharRenderInfo, 50), /* @internal */ _this._renderContext = new RenderContext(), /* @internal */ _this._renderCount = 0, /* @internal */ _this._shaderProgramMaps = [], /** @internal */ _this._fontMap = {}, /** @internal */ _this._macroCollection = new ShaderMacroCollection(), /** @internal */ _this._postProcessPassNeedRefresh = false, _this._settings = {}, _this._resourceManager = new ResourceManager(_this), _this._sceneManager = new SceneManager(_this), _this._vSyncCount = 1, _this._targetFrameRate = 60, _this._time = new Time(), _this._isPaused = true, _this._vSyncCounter = 1, _this._targetFrameInterval = 1000 / 60, _this._destroyed = false, _this._waitingDestroy = false, _this._waitingGC = false, _this._postProcessPasses = new Array(), _this._activePostProcessPasses = new Array(), _this._animate = function() {
28804
+ _this = EventDispatcher.call(this) || this, /** @internal */ _this._renderingStatistics = new RenderingStatistics(), /** @internal */ _this._isDeviceLost = false, /** @internal */ _this._frameInProcess = false, /** @internal */ _this._pendingDestroyObjects = [], /** @internal */ _this._processingPendingDestroys = false, /** @internal */ _this._physicsInitialized = false, /* @internal */ _this._lastRenderState = new RenderState(), /* @internal */ _this._renderElementPool = new ClearableObjectPool(RenderElement), /* @internal */ _this._textRenderElementPool = new ClearableObjectPool(RenderElement), /* @internal */ _this._charRenderInfoPool = new ReturnableObjectPool(CharRenderInfo, 50), /* @internal */ _this._renderContext = new RenderContext(), /* @internal */ _this._renderCount = 0, /* @internal */ _this._shaderProgramMaps = [], /** @internal */ _this._fontMap = {}, /** @internal */ _this._macroCollection = new ShaderMacroCollection(), /** @internal */ _this._postProcessPassNeedRefresh = false, _this._settings = {}, _this._resourceManager = new ResourceManager(_this), _this._sceneManager = new SceneManager(_this), _this._vSyncCount = 1, _this._targetFrameRate = 60, _this._time = new Time(), _this._isPaused = true, _this._vSyncCounter = 1, _this._targetFrameInterval = 1000 / 60, _this._destroyed = false, _this._waitingDestroy = false, _this._waitingGC = false, _this._postProcessPasses = new Array(), _this._activePostProcessPasses = new Array(), _this._lastCanvasWidth = -1, _this._lastCanvasHeight = -1, /** Evict pool entries sized to the previous canvas dimensions. */ _this._onCanvasResize = function() {
28805
+ var _$canvas = _this._canvas;
28806
+ var newWidth = _$canvas.width;
28807
+ var newHeight = _$canvas.height;
28808
+ if (_this._lastCanvasWidth !== newWidth || _this._lastCanvasHeight !== newHeight) {
28809
+ if (_this._lastCanvasWidth >= 0) {
28810
+ _this._renderTargetPool.evictBySize(_this._lastCanvasWidth, _this._lastCanvasHeight);
28811
+ }
28812
+ _this._lastCanvasWidth = newWidth;
28813
+ _this._lastCanvasHeight = newHeight;
28814
+ }
28815
+ }, _this._animate = function() {
28644
28816
  if (_this._vSyncCount) {
28645
28817
  var _this_xrManager;
28646
28818
  var raf = ((_this_xrManager = _this.xrManager) == null ? void 0 : _this_xrManager._getRequestAnimationFrame()) || requestAnimationFrame;
@@ -28661,6 +28833,9 @@ ShaderPool.init();
28661
28833
  _this._textDefaultFont.isGCIgnored = true;
28662
28834
  _this._batcherManager = new BatcherManager(_this);
28663
28835
  _this._renderTargetPool = new RenderTargetPool(_this);
28836
+ _this._lastCanvasWidth = canvas.width;
28837
+ _this._lastCanvasHeight = canvas.height;
28838
+ canvas._sizeUpdateFlagManager.addListener(_this._onCanvasResize);
28664
28839
  _this.inputManager = new InputManager(_this, configuration.input);
28665
28840
  var xrDevice = configuration.xrDevice;
28666
28841
  if (xrDevice) {
@@ -28720,6 +28895,7 @@ ShaderPool.init();
28720
28895
  var _this_xrManager;
28721
28896
  var time = this._time;
28722
28897
  time._update();
28898
+ this._renderTargetPool.tick(time.frameCount);
28723
28899
  var deltaTime = time.deltaTime;
28724
28900
  this._frameInProcess = true;
28725
28901
  this._renderElementPool.clear();
@@ -28864,6 +29040,7 @@ ShaderPool.init();
28864
29040
  var _this_xrManager;
28865
29041
  this._destroyed = true;
28866
29042
  this._waitingDestroy = false;
29043
+ this._canvas._sizeUpdateFlagManager.removeListener(this._onCanvasResize);
28867
29044
  this._sceneManager._destroyAllScene();
28868
29045
  this._resourceManager._destroy();
28869
29046
  this.inputManager._destroy();
@@ -31681,7 +31858,7 @@ AnimationCurveOwner.registerAssembler(SkinnedMeshRenderer, "blendShapeWeights",
31681
31858
  */ var AnimationClipCurveBinding = /*#__PURE__*/ function() {
31682
31859
  function AnimationClipCurveBinding() {
31683
31860
  /** The index of the component that is animated. */ this.typeIndex = 0;
31684
- this._tempCurveOwner = {};
31861
+ this._tempCurveOwner = new WeakMap();
31685
31862
  }
31686
31863
  var _proto = AnimationClipCurveBinding.prototype;
31687
31864
  /**
@@ -31707,11 +31884,12 @@ AnimationCurveOwner.registerAssembler(SkinnedMeshRenderer, "blendShapeWeights",
31707
31884
  /**
31708
31885
  * @internal
31709
31886
  */ _proto._getTempCurveOwner = function _getTempCurveOwner(entity, component) {
31710
- var instanceId = entity.instanceId;
31711
- if (!this._tempCurveOwner[instanceId]) {
31712
- this._tempCurveOwner[instanceId] = this._createCurveOwner(entity, component);
31887
+ var owner = this._tempCurveOwner.get(entity);
31888
+ if (!owner) {
31889
+ owner = this._createCurveOwner(entity, component);
31890
+ this._tempCurveOwner.set(entity, owner);
31713
31891
  }
31714
- return this._tempCurveOwner[instanceId];
31892
+ return owner;
31715
31893
  };
31716
31894
  return AnimationClipCurveBinding;
31717
31895
  }();
@@ -31793,6 +31971,13 @@ AnimationCurveOwner.registerAssembler(SkinnedMeshRenderer, "blendShapeWeights",
31793
31971
  this._length = 0;
31794
31972
  };
31795
31973
  /**
31974
+ * Samples an animation at a given time.
31975
+ * @param entity - The animated entity
31976
+ * @param time - The time to sample an animation
31977
+ */ _proto.sampleAnimation = function sampleAnimation(entity, time) {
31978
+ this._sampleAnimation(entity, time);
31979
+ };
31980
+ /**
31796
31981
  * @internal
31797
31982
  * Samples an animation at a given time.
31798
31983
  * @param entity - The animated entity
@@ -33186,7 +33371,7 @@ function _type_of(obj) {
33186
33371
  * @internal
33187
33372
  */ var AnimatorLayerData = /*#__PURE__*/ function() {
33188
33373
  function AnimatorLayerData() {
33189
- this.curveOwnerPool = Object.create(null);
33374
+ this.curveOwnerPool = new WeakMap();
33190
33375
  this.animatorStateDataMap = {};
33191
33376
  this.srcPlayData = new AnimatorStatePlayData();
33192
33377
  this.destPlayData = new AnimatorStatePlayData();
@@ -33214,6 +33399,8 @@ function _type_of(obj) {
33214
33399
  */ var AnimatorStateData = function AnimatorStateData() {
33215
33400
  this.curveLayerOwner = [];
33216
33401
  this.eventHandlers = [];
33402
+ this.state = null;
33403
+ this.clipChangedListener = null;
33217
33404
  };
33218
33405
 
33219
33406
  /**
@@ -33222,7 +33409,7 @@ function _type_of(obj) {
33222
33409
  _inherits(Animator, Component);
33223
33410
  function Animator(entity) {
33224
33411
  var _this;
33225
- _this = Component.call(this, entity) || this, /** Culling mode of this Animator. */ _this.cullingMode = AnimatorCullingMode.None, /** The playback speed of the Animator, 1.0 is normal playback speed. */ _this.speed = 1.0, /** @internal */ _this._playFrameCount = -1, /** @internal */ _this._onUpdateIndex = -1, _this._updateMark = 0, _this._animatorLayersData = new Array(), _this._curveOwnerPool = Object.create(null), _this._animationEventHandlerPool = new ClearableObjectPool(AnimationEventHandler), _this._parametersValueMap = Object.create(null), _this._tempAnimatorStateInfo = {
33412
+ _this = Component.call(this, entity) || this, /** Culling mode of this Animator. */ _this.cullingMode = AnimatorCullingMode.None, /** The playback speed of the Animator, 1.0 is normal playback speed. */ _this.speed = 1.0, /** Whether the Animator sends AnimationEvent callbacks. */ _this.fireEvents = true, /** @internal */ _this._playFrameCount = -1, /** @internal */ _this._onUpdateIndex = -1, _this._updateMark = 0, _this._animatorLayersData = new Array(), _this._curveOwnerPool = new WeakMap(), _this._animationEventHandlerPool = new ClearableObjectPool(AnimationEventHandler), _this._parametersValueMap = Object.create(null), _this._tempAnimatorStateInfo = {
33226
33413
  layerIndex: -1,
33227
33414
  state: null
33228
33415
  }, _this._controlledRenderers = new Array();
@@ -33418,16 +33605,32 @@ function _type_of(obj) {
33418
33605
  /**
33419
33606
  * @internal
33420
33607
  */ _proto._reset = function _reset() {
33421
- var _this = this, animationCurveOwners = _this._curveOwnerPool;
33422
- for(var instanceId in animationCurveOwners){
33423
- var propertyOwners = animationCurveOwners[instanceId];
33424
- for(var property in propertyOwners){
33425
- var owner = propertyOwners[property];
33426
- owner.revertDefaultValue();
33608
+ // revertDefaultValue 可能在死 target 上抛;listener 清理必须始终发生,否则
33609
+ // polyfill clipChangedListener 会留在共享的 AnimatorState 上,捕获 this(Animator)→Entity 整树。
33610
+ // try/catch 隔离 revert,listener 块紧跟其后无条件执行。
33611
+ var layersData = this._animatorLayersData;
33612
+ for(var i = 0, n = layersData.length; i < n; i++){
33613
+ var stateDataMap = layersData[i].animatorStateDataMap;
33614
+ for(var stateName in stateDataMap){
33615
+ var stateData = stateDataMap[stateName];
33616
+ var layerOwners = stateData.curveLayerOwner;
33617
+ for(var j = 0, m = layerOwners.length; j < m; j++){
33618
+ try {
33619
+ var _layerOwners_j_curveOwner, _layerOwners_j;
33620
+ (_layerOwners_j = layerOwners[j]) == null ? void 0 : (_layerOwners_j_curveOwner = _layerOwners_j.curveOwner) == null ? void 0 : _layerOwners_j_curveOwner.revertDefaultValue();
33621
+ } catch (e) {
33622
+ Logger.warn("Animator._reset: revertDefaultValue threw", e);
33623
+ }
33624
+ }
33625
+ if (stateData.clipChangedListener && stateData.state) {
33626
+ stateData.state._updateFlagManager.removeListener(stateData.clipChangedListener);
33627
+ stateData.clipChangedListener = null;
33628
+ stateData.state = null;
33629
+ }
33427
33630
  }
33428
33631
  }
33429
33632
  this._animatorLayersData.length = 0;
33430
- this._curveOwnerPool = Object.create(null);
33633
+ this._curveOwnerPool = new WeakMap();
33431
33634
  this._parametersValueMap = Object.create(null);
33432
33635
  this._animationEventHandlerPool.clear();
33433
33636
  if (this._controllerUpdateFlag) {
@@ -33445,6 +33648,7 @@ function _type_of(obj) {
33445
33648
  };
33446
33649
  _proto._onDestroy = function _onDestroy() {
33447
33650
  Component.prototype._onDestroy.call(this);
33651
+ this._reset();
33448
33652
  var controller = this._animatorController;
33449
33653
  if (controller) {
33450
33654
  var _this__controllerUpdateFlag;
@@ -33511,19 +33715,26 @@ function _type_of(obj) {
33511
33715
  var relativePath = curve.relativePath;
33512
33716
  var targetEntity = curve.relativePath === "" ? entity : entity.findByPath(curve.relativePath);
33513
33717
  if (targetEntity) {
33514
- var _curveOwnerPool, _instanceId, _propertyOwners, _property, _layerCurveOwnerPool, _instanceId1, _layerPropertyOwners, _property1;
33718
+ var _propertyOwners, _property, _layerPropertyOwners, _property1;
33515
33719
  var component = curve.typeIndex > 0 ? targetEntity.getComponents(curve.type, components)[curve.typeIndex] : targetEntity.getComponent(curve.type);
33516
33720
  components.length = 0;
33517
33721
  if (!component) {
33518
33722
  continue;
33519
33723
  }
33520
33724
  var property = curve.property;
33521
- var instanceId = component.instanceId;
33522
- // Get owner
33523
- var propertyOwners = (_curveOwnerPool = curveOwnerPool)[_instanceId = instanceId] || (_curveOwnerPool[_instanceId] = Object.create(null));
33725
+ // Get owner — WeakMap keyed by Component so dead components let entries GC.
33726
+ var propertyOwners = curveOwnerPool.get(component);
33727
+ if (!propertyOwners) {
33728
+ propertyOwners = Object.create(null);
33729
+ curveOwnerPool.set(component, propertyOwners);
33730
+ }
33524
33731
  var owner = (_propertyOwners = propertyOwners)[_property = property] || (_propertyOwners[_property] = curve._createCurveOwner(targetEntity, component));
33525
- // Get layer owner
33526
- var layerPropertyOwners = (_layerCurveOwnerPool = layerCurveOwnerPool)[_instanceId1 = instanceId] || (_layerCurveOwnerPool[_instanceId1] = Object.create(null));
33732
+ // Get layer owner — same WeakMap-by-Component pattern (was Record<instanceId,...> which kept dead components pinned for the Animator's lifetime).
33733
+ var layerPropertyOwners = layerCurveOwnerPool.get(component);
33734
+ if (!layerPropertyOwners) {
33735
+ layerPropertyOwners = Object.create(null);
33736
+ layerCurveOwnerPool.set(component, layerPropertyOwners);
33737
+ }
33527
33738
  var layerOwner = (_layerPropertyOwners = layerPropertyOwners)[_property1 = property] || (_layerPropertyOwners[_property1] = curve._createCurveLayerOwner(owner));
33528
33739
  if (mask && mask.pathMasks.length) {
33529
33740
  var _mask_getPathMask;
@@ -33565,6 +33776,8 @@ function _type_of(obj) {
33565
33776
  };
33566
33777
  clipChangedListener();
33567
33778
  state._updateFlagManager.addListener(clipChangedListener);
33779
+ animatorStateData.state = state;
33780
+ animatorStateData.clipChangedListener = clipChangedListener;
33568
33781
  };
33569
33782
  _proto._clearCrossData = function _clearCrossData(animatorLayerData) {
33570
33783
  animatorLayerData.crossCurveMark++;
@@ -34233,7 +34446,7 @@ function _type_of(obj) {
34233
34446
  };
34234
34447
  _proto._fireAnimationEventsAndCallScripts = function _fireAnimationEventsAndCallScripts(layerIndex, playData, state, lastClipTime, lastPlayState, deltaTime) {
34235
34448
  var eventHandlers = playData.stateData.eventHandlers;
34236
- eventHandlers.length && this._fireAnimationEvents(playData, eventHandlers, lastClipTime, deltaTime);
34449
+ this.fireEvents && eventHandlers.length && this._fireAnimationEvents(playData, eventHandlers, lastClipTime, deltaTime);
34237
34450
  if (lastPlayState === AnimatorStatePlayState.UnStarted) {
34238
34451
  state._callOnEnter(this, layerIndex);
34239
34452
  }
@@ -34297,6 +34510,9 @@ Animator._passedTriggerParameterNames = new Array();
34297
34510
  __decorate([
34298
34511
  assignmentClone
34299
34512
  ], Animator.prototype, "speed", void 0);
34513
+ __decorate([
34514
+ assignmentClone
34515
+ ], Animator.prototype, "fireEvents", void 0);
34300
34516
  __decorate([
34301
34517
  assignmentClone
34302
34518
  ], Animator.prototype, "_animatorController", void 0);