@galacean/engine-core 2.0.0-alpha.37 → 2.0.0-alpha.38

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/module.js CHANGED
@@ -3848,7 +3848,7 @@ TiledSpriteAssembler = __decorate([
3848
3848
  sprite.name === name && outSprites.push(sprite);
3849
3849
  }
3850
3850
  } else {
3851
- console.warn("The name of the sprite you want to find is not exit in SpriteAtlas.");
3851
+ console.warn("There is no sprite named " + name + " in the atlas.");
3852
3852
  }
3853
3853
  return outSprites;
3854
3854
  };
@@ -6059,6 +6059,9 @@ __decorate([
6059
6059
  __decorate([
6060
6060
  ignoreClone
6061
6061
  ], Transform.prototype, "_isParentDirty", void 0);
6062
+ __decorate([
6063
+ ignoreClone
6064
+ ], Transform.prototype, "_parentTransformCache", void 0);
6062
6065
  __decorate([
6063
6066
  ignoreClone
6064
6067
  ], Transform.prototype, "_dirtyFlag", void 0);
@@ -17071,9 +17074,10 @@ var ComponentCloner = /*#__PURE__*/ function() {
17071
17074
  };
17072
17075
  /**
17073
17076
  * Get the components which match the type of the entity and it's children.
17077
+ * @remarks The components are returned in depth-first pre-order: the entity itself first, then each child's subtree in sibling order.
17074
17078
  * @param type - The component type
17075
17079
  * @param results - The components collection
17076
- * @returns The components collection which match the type
17080
+ * @returns The components collection which match the type
17077
17081
  */ _proto.getComponentsIncludeChildren = function getComponentsIncludeChildren(type, results) {
17078
17082
  results.length = 0;
17079
17083
  this._getComponentsInChildren(type, results);
@@ -17378,14 +17382,16 @@ var ComponentCloner = /*#__PURE__*/ function() {
17378
17382
  }
17379
17383
  };
17380
17384
  _proto._getComponentsInChildren = function _getComponentsInChildren(type, results) {
17381
- for(var i = this._components.length - 1; i >= 0; i--){
17382
- var component = this._components[i];
17385
+ var components = this._components;
17386
+ for(var i = 0, n = components.length; i < n; i++){
17387
+ var component = components[i];
17383
17388
  if (_instanceof(component, type)) {
17384
17389
  results.push(component);
17385
17390
  }
17386
17391
  }
17387
- for(var i1 = this._children.length - 1; i1 >= 0; i1--){
17388
- this._children[i1]._getComponentsInChildren(type, results);
17392
+ var children = this._children;
17393
+ for(var i1 = 0, n1 = children.length; i1 < n1; i1++){
17394
+ children[i1]._getComponentsInChildren(type, results);
17389
17395
  }
17390
17396
  };
17391
17397
  _proto._setActiveComponents = function _setActiveComponents(isActive, activeChangeFlag) {
@@ -18817,37 +18823,39 @@ var MultiExecutor = /*#__PURE__*/ function() {
18817
18823
  this._contentRestorerPool = null;
18818
18824
  this._loadingPromises = null;
18819
18825
  };
18820
- _proto._assignDefaultOptions = function _assignDefaultOptions(assetInfo) {
18821
- var _assetInfo_type;
18822
- assetInfo.type = (_assetInfo_type = assetInfo.type) != null ? _assetInfo_type : ResourceManager._getTypeByUrl(assetInfo.url);
18826
+ _proto._resolveLoadItemOptions = function _resolveLoadItemOptions(assetInfo, virtualResourceEntry) {
18827
+ var _assetInfo;
18828
+ var _virtualResourceEntry_type, _ref;
18829
+ assetInfo.type = (_ref = (_virtualResourceEntry_type = virtualResourceEntry == null ? void 0 : virtualResourceEntry.type) != null ? _virtualResourceEntry_type : assetInfo.type) != null ? _ref : ResourceManager._getTypeByUrl(assetInfo.url);
18823
18830
  if (assetInfo.type === undefined) {
18824
18831
  throw "asset type should be specified: " + assetInfo.url;
18825
18832
  }
18833
+ var _params;
18834
+ (_params = (_assetInfo = assetInfo).params) != null ? _params : _assetInfo.params = virtualResourceEntry == null ? void 0 : virtualResourceEntry.params;
18826
18835
  var _assetInfo_retryCount;
18827
18836
  assetInfo.retryCount = (_assetInfo_retryCount = assetInfo.retryCount) != null ? _assetInfo_retryCount : this.retryCount;
18828
18837
  var _assetInfo_timeout;
18829
18838
  assetInfo.timeout = (_assetInfo_timeout = assetInfo.timeout) != null ? _assetInfo_timeout : this.timeout;
18830
18839
  var _assetInfo_retryInterval;
18831
18840
  assetInfo.retryInterval = (_assetInfo_retryInterval = assetInfo.retryInterval) != null ? _assetInfo_retryInterval : this.retryInterval;
18832
- var _assetInfo_url;
18833
- assetInfo.url = (_assetInfo_url = assetInfo.url) != null ? _assetInfo_url : assetInfo.urls.join(",");
18834
- return assetInfo;
18835
18841
  };
18836
18842
  _proto._loadSingleItem = function _loadSingleItem(itemOrURL) {
18837
18843
  var _this = this;
18838
- var item = this._assignDefaultOptions(typeof itemOrURL === "string" ? {
18844
+ var item = typeof itemOrURL === "string" ? {
18839
18845
  url: itemOrURL
18840
- } : itemOrURL);
18841
- var url = item.url;
18842
- // Not absolute and base url is set
18843
- if (!Utils.isAbsoluteUrl(url) && this.baseUrl) url = Utils.resolveAbsoluteUrl(this.baseUrl, url);
18846
+ } : itemOrURL;
18847
+ var _item_url;
18848
+ item.url = (_item_url = item.url) != null ? _item_url : item.urls.join(",");
18844
18849
  // Parse url
18845
- var _this__parseURL = this._parseURL(url), assetBaseURL = _this__parseURL.assetBaseURL, queryPath = _this__parseURL.queryPath;
18850
+ var _this__parseURL = this._parseURL(item.url), assetBaseURL = _this__parseURL.assetBaseURL, queryPath = _this__parseURL.queryPath;
18846
18851
  var paths = queryPath ? this._parseQueryPath(queryPath) : [];
18847
18852
  // Get remote asset base url
18848
- var remoteConfig = this._virtualPathResourceMap[assetBaseURL];
18849
- var _remoteConfig_path;
18850
- var remoteAssetBaseURL = (_remoteConfig_path = remoteConfig == null ? void 0 : remoteConfig.path) != null ? _remoteConfig_path : assetBaseURL;
18853
+ var virtualResourceEntry = this._virtualPathResourceMap[assetBaseURL];
18854
+ this._resolveLoadItemOptions(item, virtualResourceEntry);
18855
+ // Not absolute and base url is set
18856
+ item.url = !Utils.isAbsoluteUrl(assetBaseURL) && this.baseUrl ? Utils.resolveAbsoluteUrl(this.baseUrl, assetBaseURL) : assetBaseURL;
18857
+ var _virtualResourceEntry_path;
18858
+ var remoteAssetBaseURL = (_virtualResourceEntry_path = virtualResourceEntry == null ? void 0 : virtualResourceEntry.path) != null ? _virtualResourceEntry_path : item.url;
18851
18859
  // Check cache
18852
18860
  var cacheObject = this._assetUrlPool[remoteAssetBaseURL];
18853
18861
  if (cacheObject) {
@@ -18881,25 +18889,24 @@ var MultiExecutor = /*#__PURE__*/ function() {
18881
18889
  if (!loader) {
18882
18890
  throw "loader not found: " + item.type;
18883
18891
  }
18884
- var subpackageName = remoteConfig == null ? void 0 : remoteConfig.subpackageName;
18892
+ var subpackageName = virtualResourceEntry == null ? void 0 : virtualResourceEntry.subpackageName;
18885
18893
  // Check sub asset
18886
18894
  if (queryPath) {
18887
18895
  // Check whether load main asset
18888
- var mainPromise = loadingPromises[remoteAssetBaseURL] || this._loadSubpackageAndMainAsset(loader, item, remoteAssetBaseURL, assetBaseURL, subpackageName);
18896
+ var mainPromise = loadingPromises[remoteAssetBaseURL] || this._loadSubpackageAndMainAsset(loader, item, remoteAssetBaseURL, subpackageName);
18889
18897
  mainPromise.catch(function(e) {
18890
18898
  _this._onSubAssetFail(remoteAssetBaseURL, queryPath, e);
18891
18899
  });
18892
18900
  return this._createSubAssetPromiseCallback(remoteAssetBaseURL, remoteAssetURL, queryPath);
18893
18901
  }
18894
- return this._loadSubpackageAndMainAsset(loader, item, remoteAssetBaseURL, assetBaseURL, subpackageName);
18902
+ return this._loadSubpackageAndMainAsset(loader, item, remoteAssetBaseURL, subpackageName);
18895
18903
  };
18896
18904
  // For adapter mini-game platform
18897
- _proto._loadSubpackageAndMainAsset = function _loadSubpackageAndMainAsset(loader, item, remoteAssetBaseURL, assetBaseURL, subpackageName) {
18898
- return this._loadMainAsset(loader, item, remoteAssetBaseURL, assetBaseURL);
18905
+ _proto._loadSubpackageAndMainAsset = function _loadSubpackageAndMainAsset(loader, item, remoteAssetBaseURL, subpackageName) {
18906
+ return this._loadMainAsset(loader, item, remoteAssetBaseURL);
18899
18907
  };
18900
- _proto._loadMainAsset = function _loadMainAsset(loader, item, remoteAssetBaseURL, assetBaseURL) {
18908
+ _proto._loadMainAsset = function _loadMainAsset(loader, item, remoteAssetBaseURL) {
18901
18909
  var _this = this;
18902
- item.url = assetBaseURL;
18903
18910
  var loadingPromises = this._loadingPromises;
18904
18911
  var promise = loader.load(item, this);
18905
18912
  loadingPromises[remoteAssetBaseURL] = promise;
@@ -19026,10 +19033,9 @@ var MultiExecutor = /*#__PURE__*/ function() {
19026
19033
  return AssetPromise.resolve(null);
19027
19034
  }
19028
19035
  var loadUrl = key ? url + "?q=" + key : url;
19036
+ // type and params omitted: resolved from the virtualPath map, the single source of truth
19029
19037
  var promise = this.load({
19030
- url: loadUrl,
19031
- type: mapped.type,
19032
- params: mapped.params
19038
+ url: loadUrl
19033
19039
  });
19034
19040
  return isClone ? promise.then(function(item) {
19035
19041
  return item.clone();
@@ -20436,6 +20442,13 @@ __decorate([
20436
20442
  this._phasedActiveInScene && this._nativeCollider.addForce(force);
20437
20443
  };
20438
20444
  /**
20445
+ * Apply a force to the DynamicCollider at a given position in world space.
20446
+ * @param force - The force to apply, in world space
20447
+ * @param position - The position where the force is applied, in world space
20448
+ */ _proto.applyForceAtPosition = function applyForceAtPosition(force, position) {
20449
+ this._phasedActiveInScene && this._nativeCollider.addForceAtPosition(force, position);
20450
+ };
20451
+ /**
20439
20452
  * Apply a torque to the DynamicCollider.
20440
20453
  * @param torque - The force make the collider rotate
20441
20454
  */ _proto.applyTorque = function applyTorque(torque) {
@@ -26788,6 +26801,7 @@ CascadedShadowCasterPass._tempMatrix0 = new Matrix();
26788
26801
  depthOnlyPass.release();
26789
26802
  camera.shaderData.setTexture(Camera._cameraDepthTextureProperty, engine._basicResources.whiteTexture2D);
26790
26803
  }
26804
+ var pool = engine._renderTargetPool;
26791
26805
  // Check if need to create internal color texture or grab texture
26792
26806
  if (independentCanvasEnabled) {
26793
26807
  var depthFormat;
@@ -26803,26 +26817,12 @@ CascadedShadowCasterPass._tempMatrix0 = new Matrix();
26803
26817
  depthFormat = null;
26804
26818
  }
26805
26819
  var viewport = camera.pixelViewport;
26806
- var internalColorTarget = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._internalColorTarget, viewport.width, viewport.height, camera._getInternalColorTextureFormat(), depthFormat, false, false, !camera.enableHDR, msaaSamples, TextureWrapMode.Clamp, TextureFilterMode.Bilinear);
26820
+ this._internalColorTarget = pool.allocateRenderTarget(viewport.width, viewport.height, camera._getInternalColorTextureFormat(), depthFormat, false, false, !camera.enableHDR, msaaSamples, TextureWrapMode.Clamp, TextureFilterMode.Bilinear);
26807
26821
  if (this._shouldCopyBackgroundColor) {
26808
26822
  var _camera_renderTarget;
26809
26823
  var colorTexture = (_camera_renderTarget = camera.renderTarget) == null ? void 0 : _camera_renderTarget.getColorTexture(0);
26810
26824
  var _colorTexture_format, _colorTexture_isSRGBColorSpace;
26811
- var copyBackgroundTexture = PipelineUtils.recreateTextureIfNeeded(engine, this._copyBackgroundTexture, viewport.width, viewport.height, (_colorTexture_format = colorTexture == null ? void 0 : colorTexture.format) != null ? _colorTexture_format : TextureFormat.R8G8B8A8, false, (_colorTexture_isSRGBColorSpace = colorTexture == null ? void 0 : colorTexture.isSRGBColorSpace) != null ? _colorTexture_isSRGBColorSpace : false, TextureWrapMode.Clamp, TextureFilterMode.Bilinear);
26812
- this._copyBackgroundTexture = copyBackgroundTexture;
26813
- }
26814
- this._internalColorTarget = internalColorTarget;
26815
- } else {
26816
- var internalColorTarget1 = this._internalColorTarget;
26817
- var copyBackgroundTexture1 = this._copyBackgroundTexture;
26818
- var pool = engine._renderTargetPool;
26819
- if (internalColorTarget1) {
26820
- pool.freeRenderTarget(internalColorTarget1);
26821
- this._internalColorTarget = null;
26822
- }
26823
- if (copyBackgroundTexture1) {
26824
- pool.freeTexture(copyBackgroundTexture1);
26825
- this._copyBackgroundTexture = null;
26825
+ this._copyBackgroundTexture = pool.allocateTexture(viewport.width, viewport.height, (_colorTexture_format = colorTexture == null ? void 0 : colorTexture.format) != null ? _colorTexture_format : TextureFormat.R8G8B8A8, false, (_colorTexture_isSRGBColorSpace = colorTexture == null ? void 0 : colorTexture.isSRGBColorSpace) != null ? _colorTexture_isSRGBColorSpace : false, TextureWrapMode.Clamp, TextureFilterMode.Bilinear);
26826
26826
  }
26827
26827
  }
26828
26828
  // Scalable ambient obscurance pass
@@ -26835,6 +26835,15 @@ CascadedShadowCasterPass._tempMatrix0 = new Matrix();
26835
26835
  this._saoPass.release();
26836
26836
  }
26837
26837
  this._drawRenderPass(context, camera, finalClearFlags, cubeFace, mipLevel);
26838
+ // Return the per-frame leases so the next camera with matching shape can reuse them
26839
+ if (this._internalColorTarget) {
26840
+ pool.freeRenderTarget(this._internalColorTarget);
26841
+ this._internalColorTarget = null;
26842
+ }
26843
+ if (this._copyBackgroundTexture) {
26844
+ pool.freeTexture(this._copyBackgroundTexture);
26845
+ this._copyBackgroundTexture = null;
26846
+ }
26838
26847
  };
26839
26848
  _proto._drawRenderPass = function _drawRenderPass(context, camera, finalClearFlags, cubeFace, mipLevel) {
26840
26849
  var cullingResults = this._cullingResults;
@@ -27168,7 +27177,9 @@ var OverlayCamera = function OverlayCamera() {
27168
27177
  _inherits(Engine, EventDispatcher);
27169
27178
  function Engine(canvas, hardwareRenderer, configuration) {
27170
27179
  var _this;
27171
- _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() {
27180
+ _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._onCanvasResize = function() {
27181
+ return _this._renderTargetPool.gc();
27182
+ }, _this._animate = function() {
27172
27183
  if (_this._vSyncCount) {
27173
27184
  var _this_xrManager;
27174
27185
  var raf = ((_this_xrManager = _this.xrManager) == null ? void 0 : _this_xrManager._getRequestAnimationFrame()) || requestAnimationFrame;
@@ -27189,6 +27200,7 @@ var OverlayCamera = function OverlayCamera() {
27189
27200
  _this._textDefaultFont.isGCIgnored = true;
27190
27201
  _this._batcherManager = new BatcherManager(_this);
27191
27202
  _this._renderTargetPool = new RenderTargetPool(_this);
27203
+ canvas._sizeUpdateFlagManager.addListener(_this._onCanvasResize);
27192
27204
  _this.inputManager = new InputManager(_this, configuration.input);
27193
27205
  var xrDevice = configuration.xrDevice;
27194
27206
  if (xrDevice) {
@@ -27392,6 +27404,7 @@ var OverlayCamera = function OverlayCamera() {
27392
27404
  var _this_xrManager;
27393
27405
  this._destroyed = true;
27394
27406
  this._waitingDestroy = false;
27407
+ this._canvas._sizeUpdateFlagManager.removeListener(this._onCanvasResize);
27395
27408
  this._sceneManager._destroyAllScene();
27396
27409
  this._resourceManager._destroy();
27397
27410
  this.inputManager._destroy();
@@ -29726,7 +29739,7 @@ var PointerMethods = /*#__PURE__*/ function(PointerMethods) {
29726
29739
  for(var _len = arguments.length, signalArgs = new Array(_len), _key = 0; _key < _len; _key++){
29727
29740
  signalArgs[_key] = arguments[_key];
29728
29741
  }
29729
- return (_target = target)[methodName].apply(_target, [].concat(args, signalArgs));
29742
+ return (_target = target)[methodName].apply(_target, [].concat(signalArgs, args));
29730
29743
  } : function() {
29731
29744
  for(var _len = arguments.length, signalArgs = new Array(_len), _key = 0; _key < _len; _key++){
29732
29745
  signalArgs[_key] = arguments[_key];
@@ -30160,7 +30173,7 @@ AnimationCurveOwner.registerAssembler(SkinnedMeshRenderer, "blendShapeWeights",
30160
30173
  */ var AnimationClipCurveBinding = /*#__PURE__*/ function() {
30161
30174
  function AnimationClipCurveBinding() {
30162
30175
  /** The index of the component that is animated. */ this.typeIndex = 0;
30163
- this._tempCurveOwner = {};
30176
+ this._tempCurveOwner = new WeakMap();
30164
30177
  }
30165
30178
  var _proto = AnimationClipCurveBinding.prototype;
30166
30179
  /**
@@ -30186,11 +30199,12 @@ AnimationCurveOwner.registerAssembler(SkinnedMeshRenderer, "blendShapeWeights",
30186
30199
  /**
30187
30200
  * @internal
30188
30201
  */ _proto._getTempCurveOwner = function _getTempCurveOwner(entity, component) {
30189
- var instanceId = entity.instanceId;
30190
- if (!this._tempCurveOwner[instanceId]) {
30191
- this._tempCurveOwner[instanceId] = this._createCurveOwner(entity, component);
30202
+ var owner = this._tempCurveOwner.get(entity);
30203
+ if (!owner) {
30204
+ owner = this._createCurveOwner(entity, component);
30205
+ this._tempCurveOwner.set(entity, owner);
30192
30206
  }
30193
- return this._tempCurveOwner[instanceId];
30207
+ return owner;
30194
30208
  };
30195
30209
  return AnimationClipCurveBinding;
30196
30210
  }();
@@ -30272,11 +30286,10 @@ AnimationCurveOwner.registerAssembler(SkinnedMeshRenderer, "blendShapeWeights",
30272
30286
  this._length = 0;
30273
30287
  };
30274
30288
  /**
30275
- * @internal
30276
30289
  * Samples an animation at a given time.
30277
30290
  * @param entity - The animated entity
30278
30291
  * @param time - The time to sample an animation
30279
- */ _proto._sampleAnimation = function _sampleAnimation(entity, time) {
30292
+ */ _proto.sampleAnimation = function sampleAnimation(entity, time) {
30280
30293
  var _this = this, curveBindings = _this._curveBindings;
30281
30294
  var components = AnimationCurveOwner._components;
30282
30295
  for(var i = curveBindings.length - 1; i >= 0; i--){
@@ -31451,12 +31464,6 @@ var AnimatorLayerBlendingMode = /*#__PURE__*/ function(AnimatorLayerBlendingMode
31451
31464
  return LayerState;
31452
31465
  }({});
31453
31466
 
31454
- /**
31455
- * @internal
31456
- */ var AnimationEventHandler = function AnimationEventHandler() {
31457
- this.handlers = [];
31458
- };
31459
-
31460
31467
  /**
31461
31468
  * Animation wrap mode.
31462
31469
  */ var WrapMode = /*#__PURE__*/ function(WrapMode) {
@@ -31465,6 +31472,12 @@ var AnimatorLayerBlendingMode = /*#__PURE__*/ function(AnimatorLayerBlendingMode
31465
31472
  return WrapMode;
31466
31473
  }({});
31467
31474
 
31475
+ /**
31476
+ * @internal
31477
+ */ var AnimationEventHandler = function AnimationEventHandler() {
31478
+ this.handlers = [];
31479
+ };
31480
+
31468
31481
  /**
31469
31482
  * @internal
31470
31483
  */ var AnimatorStatePlayData = /*#__PURE__*/ function() {
@@ -31505,19 +31518,21 @@ var AnimatorLayerBlendingMode = /*#__PURE__*/ function(AnimatorLayerBlendingMode
31505
31518
  this.playedTime += deltaTime;
31506
31519
  var instance = this.instance;
31507
31520
  var state = instance._state;
31521
+ var clipLength = state.clip.length;
31522
+ var clipStartTime = state.clipStartTime;
31508
31523
  var time = this.playedTime + this.offsetFrameTime;
31509
- var duration = state._getDuration();
31524
+ var duration = (state.clipEndTime - clipStartTime) * clipLength;
31510
31525
  this.playState = AnimatorStatePlayState.Playing;
31511
31526
  if (instance.wrapMode === WrapMode.Loop) {
31512
31527
  time = duration ? time % duration : 0;
31513
- } else {
31514
- if (Math.abs(time) >= duration) {
31515
- time = time < 0 ? -duration : duration;
31516
- this.playState = AnimatorStatePlayState.Finished;
31517
- }
31528
+ } else if (time >= duration || time <= -duration) {
31529
+ time = time < 0 ? -duration : duration;
31530
+ this.playState = AnimatorStatePlayState.Finished;
31518
31531
  }
31519
- time < 0 && (time += duration);
31520
- this.clipTime = time + state.clipStartTime * state.clip.length;
31532
+ if (time < 0) {
31533
+ time += duration;
31534
+ }
31535
+ this.clipTime = time + clipStartTime * clipLength;
31521
31536
  if (this._changedOrientation) {
31522
31537
  !this.isForward && this._correctTime();
31523
31538
  this._changedOrientation = false;
@@ -31530,6 +31545,26 @@ var AnimatorLayerBlendingMode = /*#__PURE__*/ function(AnimatorLayerBlendingMode
31530
31545
  this.clipTime = state.clipEndTime * state.clip.length;
31531
31546
  }
31532
31547
  };
31548
+ _create_class(AnimatorStatePlayData, [
31549
+ {
31550
+ key: "state",
31551
+ get: function get() {
31552
+ return this.instance._state;
31553
+ }
31554
+ },
31555
+ {
31556
+ key: "speed",
31557
+ get: function get() {
31558
+ return this.instance.speed;
31559
+ }
31560
+ },
31561
+ {
31562
+ key: "wrapMode",
31563
+ get: function get() {
31564
+ return this.instance.wrapMode;
31565
+ }
31566
+ }
31567
+ ]);
31533
31568
  return AnimatorStatePlayData;
31534
31569
  }();
31535
31570
 
@@ -31708,8 +31743,8 @@ function _type_of(obj) {
31708
31743
  * @internal
31709
31744
  */ var AnimatorLayerData = /*#__PURE__*/ function() {
31710
31745
  function AnimatorLayerData() {
31711
- this.curveOwnerPool = Object.create(null);
31712
- this.animatorStateDataMap = new WeakMap();
31746
+ this.curveOwnerPool = new WeakMap();
31747
+ this.animatorStateDataMap = new Map();
31713
31748
  this.instanceMap = new WeakMap();
31714
31749
  this.srcPlayData = null;
31715
31750
  this.destPlayData = null;
@@ -31728,15 +31763,6 @@ function _type_of(obj) {
31728
31763
  }
31729
31764
  return instance;
31730
31765
  };
31731
- _proto.completeCrossFade = function completeCrossFade() {
31732
- this.srcPlayData = this.destPlayData;
31733
- this.destPlayData = null;
31734
- this.crossFadeTransition = null;
31735
- };
31736
- _proto.clearCrossFadeSlot = function clearCrossFadeSlot() {
31737
- this.destPlayData = null;
31738
- this.crossFadeTransition = null;
31739
- };
31740
31766
  _proto.resetCurrentCheckIndex = function resetCurrentCheckIndex() {
31741
31767
  this.layer.stateMachine._entryTransitionCollection.needResetCurrentCheckIndex = true;
31742
31768
  this.layer.stateMachine._anyStateTransitionCollection.needResetCurrentCheckIndex = true;
@@ -31760,7 +31786,7 @@ function _type_of(obj) {
31760
31786
  _inherits(Animator, Component);
31761
31787
  function Animator(entity) {
31762
31788
  var _this;
31763
- _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._parametersValueMap = Object.create(null), _this._tempAnimatorStateInfo = {
31789
+ _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._parametersValueMap = Object.create(null), _this._tempAnimatorStateInfo = {
31764
31790
  layerIndex: -1,
31765
31791
  state: null
31766
31792
  }, _this._controlledRenderers = new Array();
@@ -31943,16 +31969,21 @@ function _type_of(obj) {
31943
31969
  /**
31944
31970
  * @internal
31945
31971
  */ _proto._reset = function _reset() {
31946
- var _this = this, animationCurveOwners = _this._curveOwnerPool;
31947
- for(var instanceId in animationCurveOwners){
31948
- var propertyOwners = animationCurveOwners[instanceId];
31949
- for(var property in propertyOwners){
31950
- var owner = propertyOwners[property];
31951
- owner.revertDefaultValue();
31972
+ var layersData = this._animatorLayersData;
31973
+ for(var i = 0, n = layersData.length; i < n; i++){
31974
+ var layerData = layersData[i];
31975
+ if (!layerData) continue;
31976
+ for(var _iterator = _create_for_of_iterator_helper_loose(layerData.animatorStateDataMap.values()), _step; !(_step = _iterator()).done;){
31977
+ var stateData = _step.value;
31978
+ var layerOwners = stateData.curveLayerOwner;
31979
+ for(var k = 0, l = layerOwners.length; k < l; k++){
31980
+ var _layerOwners_k_curveOwner, _layerOwners_k;
31981
+ (_layerOwners_k = layerOwners[k]) == null ? void 0 : (_layerOwners_k_curveOwner = _layerOwners_k.curveOwner) == null ? void 0 : _layerOwners_k_curveOwner.revertDefaultValue();
31982
+ }
31952
31983
  }
31953
31984
  }
31954
31985
  this._animatorLayersData.length = 0;
31955
- this._curveOwnerPool = Object.create(null);
31986
+ this._curveOwnerPool = new WeakMap();
31956
31987
  this._parametersValueMap = Object.create(null);
31957
31988
  if (this._controllerUpdateFlag) {
31958
31989
  this._controllerUpdateFlag.flag = false;
@@ -31975,6 +32006,7 @@ function _type_of(obj) {
31975
32006
  };
31976
32007
  _proto._onDestroy = function _onDestroy() {
31977
32008
  Component.prototype._onDestroy.call(this);
32009
+ this._reset();
31978
32010
  var controller = this._animatorController;
31979
32011
  if (controller) {
31980
32012
  var _this__controllerUpdateFlag;
@@ -31988,7 +32020,8 @@ function _type_of(obj) {
31988
32020
  if (!state) {
31989
32021
  return;
31990
32022
  }
31991
- var manuallyTransition = this._getAnimatorLayerData(playLayerIndex).manuallyTransition;
32023
+ var animatorLayerData = this._getAnimatorLayerData(playLayerIndex);
32024
+ var manuallyTransition = animatorLayerData.manuallyTransition;
31992
32025
  manuallyTransition.duration = duration;
31993
32026
  manuallyTransition.offset = normalizedTimeOffset;
31994
32027
  manuallyTransition.isFixedDuration = isFixedDuration;
@@ -32043,20 +32076,30 @@ function _type_of(obj) {
32043
32076
  var relativePath = curve.relativePath;
32044
32077
  var targetEntity = curve.relativePath === "" ? entity : entity.findByPath(curve.relativePath);
32045
32078
  if (targetEntity) {
32046
- var _curveOwnerPool, _instanceId, _propertyOwners, _property, _layerCurveOwnerPool, _instanceId1, _layerPropertyOwners, _property1;
32079
+ var _layerPropertyOwners, _property;
32047
32080
  var component = curve.typeIndex > 0 ? targetEntity.getComponents(curve.type, components)[curve.typeIndex] : targetEntity.getComponent(curve.type);
32048
32081
  components.length = 0;
32049
32082
  if (!component) {
32050
32083
  continue;
32051
32084
  }
32052
32085
  var property = curve.property;
32053
- var instanceId = component.instanceId;
32054
- // Get owner
32055
- var propertyOwners = (_curveOwnerPool = curveOwnerPool)[_instanceId = instanceId] || (_curveOwnerPool[_instanceId] = Object.create(null));
32056
- var owner = (_propertyOwners = propertyOwners)[_property = property] || (_propertyOwners[_property] = curve._createCurveOwner(targetEntity, component));
32057
- // Get layer owner
32058
- var layerPropertyOwners = (_layerCurveOwnerPool = layerCurveOwnerPool)[_instanceId1 = instanceId] || (_layerCurveOwnerPool[_instanceId1] = Object.create(null));
32059
- var layerOwner = (_layerPropertyOwners = layerPropertyOwners)[_property1 = property] || (_layerPropertyOwners[_property1] = curve._createCurveLayerOwner(owner));
32086
+ // Key owner lookup by Component identity instead of instanceId.
32087
+ var propertyOwners = curveOwnerPool.get(component);
32088
+ if (!propertyOwners) {
32089
+ propertyOwners = Object.create(null);
32090
+ curveOwnerPool.set(component, propertyOwners);
32091
+ }
32092
+ var owner = propertyOwners[property];
32093
+ if (!owner) {
32094
+ owner = curve._createCurveOwner(targetEntity, component);
32095
+ propertyOwners[property] = owner;
32096
+ }
32097
+ var layerPropertyOwners = layerCurveOwnerPool.get(component);
32098
+ if (!layerPropertyOwners) {
32099
+ layerPropertyOwners = Object.create(null);
32100
+ layerCurveOwnerPool.set(component, layerPropertyOwners);
32101
+ }
32102
+ var layerOwner = (_layerPropertyOwners = layerPropertyOwners)[_property = property] || (_layerPropertyOwners[_property] = curve._createCurveLayerOwner(owner));
32060
32103
  if (mask && mask.pathMasks.length) {
32061
32104
  var _mask_getPathMask;
32062
32105
  var _mask_getPathMask_active;
@@ -32070,8 +32113,6 @@ function _type_of(obj) {
32070
32113
  }
32071
32114
  };
32072
32115
  _proto._ensureEventHandlers = function _ensureEventHandlers(state, animatorStateData) {
32073
- // state._updateFlagManager dispatches on both clip-swap and clip-events-mutation,
32074
- // so its version covers every input that affects eventHandlers binding
32075
32116
  var stateVersion = state._updateFlagManager.version;
32076
32117
  var scriptsVersion = this._entity._scriptsVersion;
32077
32118
  if (animatorStateData.eventsBuiltVersion === stateVersion && animatorStateData.eventsBuiltScriptsVersion === scriptsVersion) {
@@ -32195,8 +32236,8 @@ function _type_of(obj) {
32195
32236
  };
32196
32237
  _proto._updatePlayingState = function _updatePlayingState(layerData, weight, additive, deltaTime, aniUpdate) {
32197
32238
  var srcPlayData = layerData.srcPlayData;
32198
- var state = srcPlayData.instance._state;
32199
- var playSpeed = srcPlayData.instance.speed * this.speed;
32239
+ var state = srcPlayData.state;
32240
+ var playSpeed = srcPlayData.speed * this.speed;
32200
32241
  var playDeltaTime = playSpeed * deltaTime;
32201
32242
  srcPlayData.updateOrientation(playDeltaTime);
32202
32243
  var lastClipTime = srcPlayData.clipTime, lastPlayState = srcPlayData.playState;
@@ -32240,14 +32281,13 @@ function _type_of(obj) {
32240
32281
  this._evaluatePlayingState(srcPlayData, weight, additive, aniUpdate);
32241
32282
  this._fireAnimationEventsAndCallScripts(layerData.layerIndex, srcPlayData, state, lastClipTime, lastPlayState, playCostTime);
32242
32283
  if (transition) {
32243
- // Remove speed factor, use actual cost time. Per-instance speed=0 means the source
32244
- // state is paused, so it consumes no time — pass deltaTime through to the destination.
32284
+ // Remove speed factor, use actual cost time
32245
32285
  var remainDeltaTime = playSpeed === 0 ? deltaTime : deltaTime - playCostTime / playSpeed;
32246
32286
  remainDeltaTime > 0 && this._updateState(layerData, remainDeltaTime, aniUpdate);
32247
32287
  }
32248
32288
  };
32249
32289
  _proto._evaluatePlayingState = function _evaluatePlayingState(playData, weight, additive, aniUpdate) {
32250
- var curveBindings = playData.instance.clip._curveBindings;
32290
+ var curveBindings = playData.state.clip._curveBindings;
32251
32291
  var finished = playData.playState === AnimatorStatePlayState.Finished;
32252
32292
  if (aniUpdate || finished) {
32253
32293
  var curveLayerOwner = playData.stateData.curveLayerOwner;
@@ -32270,14 +32310,14 @@ function _type_of(obj) {
32270
32310
  _proto._updateCrossFadeState = function _updateCrossFadeState(layerData, weight, additive, deltaTime, aniUpdate) {
32271
32311
  var srcPlayData = layerData.srcPlayData, destPlayData = layerData.destPlayData, layerIndex = layerData.layerIndex;
32272
32312
  var speed = this.speed;
32273
- var srcState = srcPlayData.instance._state;
32274
- var destState = destPlayData.instance._state;
32313
+ var srcState = srcPlayData.state;
32314
+ var destState = destPlayData.state;
32275
32315
  var transitionDuration = layerData.crossFadeTransition._getFixedDuration();
32276
32316
  if (this._tryCrossFadeInterrupt(layerData, transitionDuration, destState, deltaTime, aniUpdate)) {
32277
32317
  return;
32278
32318
  }
32279
- var srcPlaySpeed = srcPlayData.instance.speed * speed;
32280
- var dstPlaySpeed = destPlayData.instance.speed * speed;
32319
+ var srcPlaySpeed = srcPlayData.speed * speed;
32320
+ var dstPlaySpeed = destPlayData.speed * speed;
32281
32321
  var dstPlayDeltaTime = dstPlaySpeed * deltaTime;
32282
32322
  srcPlayData.updateOrientation(srcPlaySpeed * deltaTime);
32283
32323
  destPlayData.updateOrientation(dstPlayDeltaTime);
@@ -32320,8 +32360,8 @@ function _type_of(obj) {
32320
32360
  };
32321
32361
  _proto._evaluateCrossFadeState = function _evaluateCrossFadeState(layerData, srcPlayData, destPlayData, weight, crossWeight, additive, aniUpdate) {
32322
32362
  var crossLayerOwnerCollection = layerData.crossLayerOwnerCollection;
32323
- var _srcPlayData_instance_clip = srcPlayData.instance.clip, srcCurves = _srcPlayData_instance_clip._curveBindings;
32324
- var destState = destPlayData.instance._state;
32363
+ var _srcPlayData_state_clip = srcPlayData.state.clip, srcCurves = _srcPlayData_state_clip._curveBindings;
32364
+ var destState = destPlayData.state;
32325
32365
  var _destState_clip = destState.clip, destCurves = _destState_clip._curveBindings;
32326
32366
  var finished = destPlayData.playState === AnimatorStatePlayState.Finished;
32327
32367
  if (aniUpdate || finished) {
@@ -32340,12 +32380,12 @@ function _type_of(obj) {
32340
32380
  };
32341
32381
  _proto._updateCrossFadeFromPoseState = function _updateCrossFadeFromPoseState(layerData, weight, additive, deltaTime, aniUpdate) {
32342
32382
  var destPlayData = layerData.destPlayData;
32343
- var state = destPlayData.instance._state;
32383
+ var state = destPlayData.state;
32344
32384
  var transitionDuration = layerData.crossFadeTransition._getFixedDuration();
32345
32385
  if (this._tryCrossFadeInterrupt(layerData, transitionDuration, state, deltaTime, aniUpdate)) {
32346
32386
  return;
32347
32387
  }
32348
- var playSpeed = destPlayData.instance.speed * this.speed;
32388
+ var playSpeed = destPlayData.speed * this.speed;
32349
32389
  var playDeltaTime = playSpeed * deltaTime;
32350
32390
  destPlayData.updateOrientation(playDeltaTime);
32351
32391
  var lastDestClipTime = destPlayData.clipTime, lastPlayState = destPlayData.playState;
@@ -32382,7 +32422,7 @@ function _type_of(obj) {
32382
32422
  };
32383
32423
  _proto._evaluateCrossFadeFromPoseState = function _evaluateCrossFadeFromPoseState(layerData, destPlayData, weight, crossWeight, additive, aniUpdate) {
32384
32424
  var crossLayerOwnerCollection = layerData.crossLayerOwnerCollection;
32385
- var state = destPlayData.instance._state;
32425
+ var state = destPlayData.state;
32386
32426
  var _state_clip = state.clip, curveBindings = _state_clip._curveBindings;
32387
32427
  var destClipTime = destPlayData.clipTime, playState = destPlayData.playState;
32388
32428
  var finished = playState === AnimatorStatePlayState.Finished;
@@ -32394,7 +32434,7 @@ function _type_of(obj) {
32394
32434
  if (!owner) continue;
32395
32435
  var curveIndex = layerOwner.crossDestCurveIndex;
32396
32436
  this._checkRevertOwner(owner, additive);
32397
- var value = layerOwner.curveOwner.crossFadeFromPoseAndApplyValue(curveIndex >= 0 ? curveBindings[curveIndex].curve : null, destClipTime, crossWeight, additive);
32437
+ var value = owner.crossFadeFromPoseAndApplyValue(curveIndex >= 0 ? curveBindings[curveIndex].curve : null, destClipTime, crossWeight, additive);
32398
32438
  aniUpdate && owner.applyValue(value, weight, additive);
32399
32439
  finished && layerOwner.saveFinalValue();
32400
32440
  }
@@ -32402,8 +32442,8 @@ function _type_of(obj) {
32402
32442
  };
32403
32443
  _proto._updateFinishedState = function _updateFinishedState(layerData, weight, additive, deltaTime, aniUpdate) {
32404
32444
  var playData = layerData.srcPlayData;
32405
- var state = playData.instance._state;
32406
- var actualSpeed = playData.instance.speed * this.speed;
32445
+ var state = playData.state;
32446
+ var actualSpeed = playData.speed * this.speed;
32407
32447
  var actualDeltaTime = actualSpeed * deltaTime;
32408
32448
  playData.updateOrientation(actualDeltaTime);
32409
32449
  var clipTime = playData.clipTime, isForward = playData.isForward;
@@ -32421,7 +32461,7 @@ function _type_of(obj) {
32421
32461
  return;
32422
32462
  }
32423
32463
  var curveLayerOwner = playData.stateData.curveLayerOwner;
32424
- var _playData_instance_clip = playData.instance.clip, curveBindings = _playData_instance_clip._curveBindings;
32464
+ var _playData_state_clip = playData.state.clip, curveBindings = _playData_state_clip._curveBindings;
32425
32465
  for(var i = curveBindings.length - 1; i >= 0; i--){
32426
32466
  var layerOwner = curveLayerOwner[i];
32427
32467
  var owner = layerOwner == null ? void 0 : layerOwner.curveOwner;
@@ -32437,12 +32477,14 @@ function _type_of(obj) {
32437
32477
  } else {
32438
32478
  layerData.layerState = LayerState.Playing;
32439
32479
  }
32440
- layerData.completeCrossFade();
32480
+ layerData.srcPlayData = destPlayData;
32481
+ layerData.destPlayData = null;
32482
+ layerData.crossFadeTransition = null;
32441
32483
  };
32442
32484
  _proto._preparePlayOwner = function _preparePlayOwner(layerData, playState) {
32443
32485
  if (layerData.layerState === LayerState.Playing) {
32444
32486
  var srcPlayData = layerData.srcPlayData;
32445
- if (srcPlayData.instance._state !== playState) {
32487
+ if (srcPlayData.state !== playState) {
32446
32488
  var curveLayerOwner = srcPlayData.stateData.curveLayerOwner;
32447
32489
  for(var i = curveLayerOwner.length - 1; i >= 0; i--){
32448
32490
  var _curveLayerOwner_i;
@@ -32457,17 +32499,17 @@ function _type_of(obj) {
32457
32499
  }
32458
32500
  };
32459
32501
  _proto._applyStateTransitions = function _applyStateTransitions(layerData, isForward, playData, transitionCollection, lastClipTime, clipTime, deltaTime, aniUpdate) {
32460
- var state = playData.instance._state;
32461
- var clipDuration = state.clip.length;
32502
+ var state = playData.state;
32462
32503
  var targetTransition = null;
32463
- var startTime = state.clipStartTime * clipDuration;
32464
- var endTime = state.clipEndTime * clipDuration;
32465
32504
  if (transitionCollection.noExitTimeCount) {
32466
32505
  targetTransition = this._checkNoExitTimeTransitions(layerData, transitionCollection, aniUpdate);
32467
32506
  if (targetTransition) {
32468
32507
  return targetTransition;
32469
32508
  }
32470
32509
  }
32510
+ var clipDuration = state.clip.length;
32511
+ var startTime = state.clipStartTime * clipDuration;
32512
+ var endTime = state.clipEndTime * clipDuration;
32471
32513
  if (isForward) {
32472
32514
  if (lastClipTime + deltaTime >= endTime) {
32473
32515
  targetTransition = this._checkSubTransition(layerData, state, transitionCollection, lastClipTime, endTime, aniUpdate);
@@ -32574,9 +32616,8 @@ function _type_of(obj) {
32574
32616
  var playData = animatorLayerData.getOrCreateInstance(state)._playData;
32575
32617
  playData.reset(animatorStateData, state._getClipActualEndTime() * normalizedTimeOffset);
32576
32618
  animatorLayerData.srcPlayData = playData;
32577
- // Drop any dangling cross-fade slot from a previously-interrupted crossFade
32578
- // so a later crossFade(B) isn't wrongly no-op'd by the active-dest guard.
32579
- animatorLayerData.clearCrossFadeSlot();
32619
+ animatorLayerData.destPlayData = null;
32620
+ animatorLayerData.crossFadeTransition = null;
32580
32621
  animatorLayerData.resetCurrentCheckIndex();
32581
32622
  return true;
32582
32623
  };
@@ -32660,9 +32701,7 @@ function _type_of(obj) {
32660
32701
  return false;
32661
32702
  }
32662
32703
  var animatorLayerData = this._getAnimatorLayerData(layerIndex);
32663
- // Self/active-dest cross-fade is a no-op: each state has one persistent
32664
- // instance per layer, so a second concurrent fade has nowhere to live.
32665
- if (((_animatorLayerData_srcPlayData = animatorLayerData.srcPlayData) == null ? void 0 : _animatorLayerData_srcPlayData.instance._state) === crossState || ((_animatorLayerData_destPlayData = animatorLayerData.destPlayData) == null ? void 0 : _animatorLayerData_destPlayData.instance._state) === crossState) {
32704
+ if (((_animatorLayerData_srcPlayData = animatorLayerData.srcPlayData) == null ? void 0 : _animatorLayerData_srcPlayData.state) === crossState || ((_animatorLayerData_destPlayData = animatorLayerData.destPlayData) == null ? void 0 : _animatorLayerData_destPlayData.state) === crossState) {
32666
32705
  return false;
32667
32706
  }
32668
32707
  var animatorStateData = this._getAnimatorStateData(crossState, animatorLayerData, layerIndex);
@@ -32694,23 +32733,27 @@ function _type_of(obj) {
32694
32733
  return true;
32695
32734
  };
32696
32735
  _proto._fireAnimationEvents = function _fireAnimationEvents(playData, eventHandlers, lastClipTime, deltaTime) {
32697
- var isForward = playData.isForward, clipTime = playData.clipTime;
32698
- var state = playData.instance._state;
32736
+ var state = playData.state, isForward = playData.isForward, clipTime = playData.clipTime, wrapMode = playData.wrapMode;
32699
32737
  var startTime = state._getClipActualStartTime();
32700
32738
  var endTime = state._getClipActualEndTime();
32739
+ var canWrap = wrapMode === WrapMode.Loop;
32701
32740
  if (isForward) {
32702
32741
  if (lastClipTime + deltaTime >= endTime) {
32703
32742
  this._fireSubAnimationEvents(playData, eventHandlers, lastClipTime, endTime);
32704
- playData.currentEventIndex = 0;
32705
- this._fireSubAnimationEvents(playData, eventHandlers, startTime, clipTime);
32743
+ if (canWrap) {
32744
+ playData.currentEventIndex = 0;
32745
+ this._fireSubAnimationEvents(playData, eventHandlers, startTime, clipTime);
32746
+ }
32706
32747
  } else {
32707
32748
  this._fireSubAnimationEvents(playData, eventHandlers, lastClipTime, clipTime);
32708
32749
  }
32709
32750
  } else {
32710
32751
  if (lastClipTime + deltaTime <= startTime) {
32711
32752
  this._fireBackwardSubAnimationEvents(playData, eventHandlers, lastClipTime, startTime);
32712
- playData.currentEventIndex = eventHandlers.length - 1;
32713
- this._fireBackwardSubAnimationEvents(playData, eventHandlers, endTime, clipTime);
32753
+ if (canWrap) {
32754
+ playData.currentEventIndex = eventHandlers.length - 1;
32755
+ this._fireBackwardSubAnimationEvents(playData, eventHandlers, endTime, clipTime);
32756
+ }
32714
32757
  } else {
32715
32758
  this._fireBackwardSubAnimationEvents(playData, eventHandlers, lastClipTime, clipTime);
32716
32759
  }
@@ -32726,8 +32769,10 @@ function _type_of(obj) {
32726
32769
  }
32727
32770
  var handlers = eventHandler.handlers;
32728
32771
  if (time >= lastClipTime) {
32729
- for(var j = handlers.length - 1; j >= 0; j--){
32730
- handlers[j](parameter);
32772
+ if (this.fireEvents) {
32773
+ for(var j = handlers.length - 1; j >= 0; j--){
32774
+ handlers[j](parameter);
32775
+ }
32731
32776
  }
32732
32777
  playState.currentEventIndex = Math.min(eventIndex + 1, n - 1);
32733
32778
  }
@@ -32743,8 +32788,10 @@ function _type_of(obj) {
32743
32788
  }
32744
32789
  if (time <= lastClipTime) {
32745
32790
  var handlers = eventHandler.handlers;
32746
- for(var j = handlers.length - 1; j >= 0; j--){
32747
- handlers[j](parameter);
32791
+ if (this.fireEvents) {
32792
+ for(var j = handlers.length - 1; j >= 0; j--){
32793
+ handlers[j](parameter);
32794
+ }
32748
32795
  }
32749
32796
  playState.currentEventIndex = Math.max(eventIndex - 1, 0);
32750
32797
  }
@@ -32775,9 +32822,6 @@ function _type_of(obj) {
32775
32822
  owner.updateMark = this._updateMark;
32776
32823
  };
32777
32824
  _proto._fireAnimationEventsAndCallScripts = function _fireAnimationEventsAndCallScripts(layerIndex, playData, state, lastClipTime, lastPlayState, deltaTime) {
32778
- // Re-check whether the clip events/scripts changed since the last build —
32779
- // play()/crossFade() entry points already ensure on enter, but addEvent()
32780
- // or addComponent(Script) after play() must also flow through.
32781
32825
  this._ensureEventHandlers(state, playData.stateData);
32782
32826
  var eventHandlers = playData.stateData.eventHandlers;
32783
32827
  eventHandlers.length && this._fireAnimationEvents(playData, eventHandlers, lastClipTime, deltaTime);
@@ -32845,6 +32889,9 @@ Animator._tempScripts = [];
32845
32889
  __decorate([
32846
32890
  assignmentClone
32847
32891
  ], Animator.prototype, "speed", void 0);
32892
+ __decorate([
32893
+ assignmentClone
32894
+ ], Animator.prototype, "fireEvents", void 0);
32848
32895
  __decorate([
32849
32896
  assignmentClone
32850
32897
  ], Animator.prototype, "_animatorController", void 0);
@@ -32916,7 +32963,10 @@ function _assert_this_initialized(self) {
32916
32963
  /** @internal */ _this._parametersMap = {},
32917
32964
  /** @internal */ _this._layers = [],
32918
32965
  /** @internal */ _this._layersMap = {},
32919
- _this._updateFlagManager = new UpdateFlagManager()
32966
+ _this._updateFlagManager = new UpdateFlagManager(),
32967
+ _this._onStatesInvalidate = function() {
32968
+ return _this._updateFlagManager.dispatch();
32969
+ }
32920
32970
  ][0];
32921
32971
  return _assert_this_initialized(_this);
32922
32972
  }
@@ -32971,6 +33021,7 @@ function _assert_this_initialized(self) {
32971
33021
  */ _proto.addLayer = function addLayer(layer) {
32972
33022
  this._layers.push(layer);
32973
33023
  this._layersMap[layer.name] = layer;
33024
+ layer._setStatesInvalidateCallback(this._onStatesInvalidate);
32974
33025
  layer._setEngine(this._engine);
32975
33026
  this._updateFlagManager.dispatch();
32976
33027
  };
@@ -32980,13 +33031,18 @@ function _assert_this_initialized(self) {
32980
33031
  */ _proto.removeLayer = function removeLayer(layerIndex) {
32981
33032
  var theLayer = this.layers[layerIndex];
32982
33033
  this._layers.splice(layerIndex, 1);
33034
+ theLayer._setStatesInvalidateCallback(null);
32983
33035
  delete this._layersMap[theLayer.name];
32984
33036
  this._updateFlagManager.dispatch();
32985
33037
  };
32986
33038
  /**
32987
33039
  * Clear layers.
32988
33040
  */ _proto.clearLayers = function clearLayers() {
32989
- this._layers.length = 0;
33041
+ var _this = this, layers = _this._layers;
33042
+ for(var i = 0, n = layers.length; i < n; i++){
33043
+ layers[i]._setStatesInvalidateCallback(null);
33044
+ }
33045
+ layers.length = 0;
32990
33046
  for(var name in this._layersMap){
32991
33047
  delete this._layersMap[name];
32992
33048
  }
@@ -33002,7 +33058,9 @@ function _assert_this_initialized(self) {
33002
33058
  */ _proto._setEngine = function _setEngine(engine) {
33003
33059
  var _this = this, layers = _this._layers;
33004
33060
  for(var i = 0, n = layers.length; i < n; i++){
33005
- layers[i]._setEngine(engine);
33061
+ var layer = layers[i];
33062
+ layer._setStatesInvalidateCallback(this._onStatesInvalidate);
33063
+ layer._setEngine(engine);
33006
33064
  }
33007
33065
  };
33008
33066
  _proto._addParameter = function _addParameter(name, defaultValue, isTrigger) {
@@ -33389,6 +33447,7 @@ function _assert_this_initialized(self) {
33389
33447
  */ var AnimatorStateMachine = /*#__PURE__*/ function() {
33390
33448
  function AnimatorStateMachine() {
33391
33449
  /** The list of states. */ this.states = [];
33450
+ this._onStatesInvalidate = null;
33392
33451
  /**
33393
33452
  * The state will be played automatically.
33394
33453
  * @remarks When the Animator's AnimatorController changed or the Animator's onEnable be triggered. Cleared to `null` if the state is removed via `removeState`.
@@ -33425,6 +33484,7 @@ function _assert_this_initialized(self) {
33425
33484
  if (this.defaultState === state) {
33426
33485
  this.defaultState = null;
33427
33486
  }
33487
+ this._onStatesInvalidate == null ? void 0 : this._onStatesInvalidate.call(this);
33428
33488
  }
33429
33489
  };
33430
33490
  /**
@@ -33484,6 +33544,11 @@ function _assert_this_initialized(self) {
33484
33544
  states[i]._setEngine(engine);
33485
33545
  }
33486
33546
  };
33547
+ /**
33548
+ * @internal
33549
+ */ _proto._setStatesInvalidateCallback = function _setStatesInvalidateCallback(onStatesInvalidate) {
33550
+ this._onStatesInvalidate = onStatesInvalidate;
33551
+ };
33487
33552
  _create_class(AnimatorStateMachine, [
33488
33553
  {
33489
33554
  key: "entryTransitions",
@@ -33512,14 +33577,43 @@ function _assert_this_initialized(self) {
33512
33577
  this.name = name;
33513
33578
  this./** The blending weight that the layers has. It is not taken into account for the first layer. */ weight = 1.0;
33514
33579
  this./** The blending mode used by the layer. It is not taken into account for the first layer. */ blendingMode = AnimatorLayerBlendingMode.Override;
33515
- this.stateMachine = new AnimatorStateMachine();
33580
+ this._onStatesInvalidate = null;
33581
+ this._stateMachine = new AnimatorStateMachine();
33516
33582
  }
33517
33583
  var _proto = AnimatorControllerLayer.prototype;
33518
33584
  /**
33519
33585
  * @internal
33520
33586
  */ _proto._setEngine = function _setEngine(engine) {
33521
- this.stateMachine._setEngine(engine);
33587
+ this._engine = engine;
33588
+ this._stateMachine._setEngine(engine);
33522
33589
  };
33590
+ /**
33591
+ * @internal
33592
+ */ _proto._setStatesInvalidateCallback = function _setStatesInvalidateCallback(onStatesInvalidate) {
33593
+ this._onStatesInvalidate = onStatesInvalidate;
33594
+ this._stateMachine._setStatesInvalidateCallback(onStatesInvalidate);
33595
+ };
33596
+ _create_class(AnimatorControllerLayer, [
33597
+ {
33598
+ key: "stateMachine",
33599
+ get: /**
33600
+ * The state machine for the layer.
33601
+ */ function get() {
33602
+ return this._stateMachine;
33603
+ },
33604
+ set: function set(value) {
33605
+ var lastStateMachine = this._stateMachine;
33606
+ if (lastStateMachine === value) {
33607
+ return;
33608
+ }
33609
+ lastStateMachine._setStatesInvalidateCallback(null);
33610
+ this._stateMachine = value;
33611
+ value._setStatesInvalidateCallback(this._onStatesInvalidate);
33612
+ this._engine && value._setEngine(this._engine);
33613
+ this._onStatesInvalidate == null ? void 0 : this._onStatesInvalidate.call(this);
33614
+ }
33615
+ }
33616
+ ]);
33523
33617
  return AnimatorControllerLayer;
33524
33618
  }();
33525
33619
 
@@ -35121,6 +35215,7 @@ __decorate([
35121
35215
  /**
35122
35216
  * @internal
35123
35217
  */ _proto._getMax = function _getMax() {
35218
+ var minMaxRange = ParticleCompositeCurve._minMaxRange;
35124
35219
  switch(this.mode){
35125
35220
  case ParticleCurveMode.Constant:
35126
35221
  return this.constantMax;
@@ -35128,17 +35223,18 @@ __decorate([
35128
35223
  return Math.max(this.constantMin, this.constantMax);
35129
35224
  case ParticleCurveMode.Curve:
35130
35225
  var _this_curveMax;
35131
- return this._getMaxKeyValue((_this_curveMax = this.curveMax) == null ? void 0 : _this_curveMax.keys);
35226
+ this._getKeyMinMax((_this_curveMax = this.curveMax) == null ? void 0 : _this_curveMax.keys, minMaxRange);
35227
+ return minMaxRange.y;
35132
35228
  case ParticleCurveMode.TwoCurves:
35133
35229
  var _this_curveMin, _this_curveMax1;
35134
- var min = this._getMaxKeyValue((_this_curveMin = this.curveMin) == null ? void 0 : _this_curveMin.keys);
35135
- var max = this._getMaxKeyValue((_this_curveMax1 = this.curveMax) == null ? void 0 : _this_curveMax1.keys);
35136
- return min > max ? min : max;
35230
+ this._getKeyMinMax((_this_curveMin = this.curveMin) == null ? void 0 : _this_curveMin.keys, minMaxRange);
35231
+ var maxCurveMin = minMaxRange.y;
35232
+ this._getKeyMinMax((_this_curveMax1 = this.curveMax) == null ? void 0 : _this_curveMax1.keys, minMaxRange);
35233
+ return maxCurveMin > minMaxRange.y ? maxCurveMin : minMaxRange.y;
35137
35234
  }
35138
35235
  };
35139
35236
  /**
35140
35237
  * @internal
35141
-
35142
35238
  */ _proto._getMinMax = function _getMinMax(out) {
35143
35239
  switch(this.mode){
35144
35240
  case ParticleCurveMode.Constant:
@@ -35148,23 +35244,40 @@ __decorate([
35148
35244
  out.set(Math.min(this.constantMin, this.constantMax), Math.max(this.constantMin, this.constantMax));
35149
35245
  break;
35150
35246
  case ParticleCurveMode.Curve:
35151
- var _this_curveMax, _this_curveMax1;
35152
- out.set(this._getMinKeyValue((_this_curveMax = this.curveMax) == null ? void 0 : _this_curveMax.keys), this._getMaxKeyValue((_this_curveMax1 = this.curveMax) == null ? void 0 : _this_curveMax1.keys));
35247
+ var _this_curveMax;
35248
+ this._getKeyMinMax((_this_curveMax = this.curveMax) == null ? void 0 : _this_curveMax.keys, out);
35153
35249
  break;
35154
35250
  case ParticleCurveMode.TwoCurves:
35155
- var _this_curveMax2, _this_curveMin, _this_curveMax3, _this_curveMin1;
35156
- var minCurveMax = this._getMinKeyValue((_this_curveMax2 = this.curveMax) == null ? void 0 : _this_curveMax2.keys);
35157
- var minCurveMin = this._getMinKeyValue((_this_curveMin = this.curveMin) == null ? void 0 : _this_curveMin.keys);
35158
- var maxCurveMax = this._getMaxKeyValue((_this_curveMax3 = this.curveMax) == null ? void 0 : _this_curveMax3.keys);
35159
- var maxCurveMin = this._getMaxKeyValue((_this_curveMin1 = this.curveMin) == null ? void 0 : _this_curveMin1.keys);
35160
- var min = minCurveMax < minCurveMin ? minCurveMax : minCurveMin;
35161
- var max = maxCurveMax > maxCurveMin ? maxCurveMax : maxCurveMin;
35162
- out.set(min, max);
35251
+ var _this_curveMin, _this_curveMax1;
35252
+ this._getKeyMinMax((_this_curveMin = this.curveMin) == null ? void 0 : _this_curveMin.keys, out);
35253
+ var minCurveMin = out.x;
35254
+ var maxCurveMin = out.y;
35255
+ this._getKeyMinMax((_this_curveMax1 = this.curveMax) == null ? void 0 : _this_curveMax1.keys, out);
35256
+ var minCurveMax = out.x;
35257
+ var maxCurveMax = out.y;
35258
+ out.set(minCurveMax < minCurveMin ? minCurveMax : minCurveMin, maxCurveMax > maxCurveMin ? maxCurveMax : maxCurveMin);
35163
35259
  break;
35164
35260
  }
35165
35261
  };
35166
35262
  /**
35167
35263
  * @internal
35264
+ */ _proto._isZero = function _isZero() {
35265
+ var minMax = ParticleCompositeCurve._minMaxRange;
35266
+ this._getMinMax(minMax);
35267
+ return minMax.x === 0 && minMax.y === 0;
35268
+ };
35269
+ /**
35270
+ * @internal
35271
+ */ _proto._isCurveMode = function _isCurveMode() {
35272
+ return this._mode === ParticleCurveMode.Curve || this._mode === ParticleCurveMode.TwoCurves;
35273
+ };
35274
+ /**
35275
+ * @internal
35276
+ */ _proto._isRandomMode = function _isRandomMode() {
35277
+ return this._mode === ParticleCurveMode.TwoConstants || this._mode === ParticleCurveMode.TwoCurves;
35278
+ };
35279
+ /**
35280
+ * @internal
35168
35281
  */ _proto._registerOnValueChanged = function _registerOnValueChanged(listener) {
35169
35282
  this._updateManager.addListener(listener);
35170
35283
  };
@@ -35173,31 +35286,20 @@ __decorate([
35173
35286
  */ _proto._unRegisterOnValueChanged = function _unRegisterOnValueChanged(listener) {
35174
35287
  this._updateManager.removeListener(listener);
35175
35288
  };
35176
- _proto._getMaxKeyValue = function _getMaxKeyValue(keys) {
35177
- var max = undefined;
35178
- var _keys_length;
35179
- var count = (_keys_length = keys == null ? void 0 : keys.length) != null ? _keys_length : 0;
35180
- if (count > 0) {
35181
- max = keys[0].value;
35182
- for(var i = 1; i < count; i++){
35183
- var value = keys[i].value;
35184
- max = Math.max(max, value);
35185
- }
35186
- }
35187
- return max;
35188
- };
35189
- _proto._getMinKeyValue = function _getMinKeyValue(keys) {
35289
+ _proto._getKeyMinMax = function _getKeyMinMax(keys, out) {
35190
35290
  var min = undefined;
35291
+ var max = undefined;
35191
35292
  var _keys_length;
35192
35293
  var count = (_keys_length = keys == null ? void 0 : keys.length) != null ? _keys_length : 0;
35193
35294
  if (count > 0) {
35194
- min = keys[0].value;
35295
+ min = max = keys[0].value;
35195
35296
  for(var i = 1; i < count; i++){
35196
35297
  var value = keys[i].value;
35197
35298
  min = Math.min(min, value);
35299
+ max = Math.max(max, value);
35198
35300
  }
35199
35301
  }
35200
- return min;
35302
+ out.set(min != null ? min : 0, max != null ? max : 0);
35201
35303
  };
35202
35304
  _proto._onCurveChange = function _onCurveChange(lastValue, value) {
35203
35305
  var dispatch = this._updateDispatch;
@@ -35303,6 +35405,7 @@ __decorate([
35303
35405
  ]);
35304
35406
  return ParticleCompositeCurve;
35305
35407
  }();
35408
+ ParticleCompositeCurve._minMaxRange = new Vector2();
35306
35409
  __decorate([
35307
35410
  ignoreClone
35308
35411
  ], ParticleCompositeCurve.prototype, "_updateManager", void 0);
@@ -37640,10 +37743,20 @@ __decorate([
37640
37743
  _inherits(VelocityOverLifetimeModule, ParticleGeneratorModule);
37641
37744
  function VelocityOverLifetimeModule(generator) {
37642
37745
  var _this;
37643
- _this = ParticleGeneratorModule.call(this, generator) || this, /** @internal */ _this._velocityRand = new Rand(0, ParticleRandomSubSeeds.VelocityOverLifetime), _this._velocityMinConstant = new Vector3(), _this._velocityMaxConstant = new Vector3(), _this._space = ParticleSimulationSpace.Local;
37746
+ _this = ParticleGeneratorModule.call(this, generator) || this, /** @internal */ _this._velocityRand = new Rand(0, ParticleRandomSubSeeds.VelocityOverLifetime), _this._velocityMinConstant = new Vector3(), _this._velocityMaxConstant = new Vector3(), _this._orbitalMinConstant = new Vector3(), _this._orbitalConstant = new Vector3(), _this._offset = new Vector3(), _this._space = ParticleSimulationSpace.Local, _this._onTransformFeedbackDirty = function() {
37747
+ return _this._generator._setTransformFeedback();
37748
+ };
37644
37749
  _this.velocityX = new ParticleCompositeCurve(0);
37645
37750
  _this.velocityY = new ParticleCompositeCurve(0);
37646
37751
  _this.velocityZ = new ParticleCompositeCurve(0);
37752
+ _this.orbitalX = new ParticleCompositeCurve(0);
37753
+ _this.orbitalY = new ParticleCompositeCurve(0);
37754
+ _this.orbitalZ = new ParticleCompositeCurve(0);
37755
+ _this.radial = new ParticleCompositeCurve(0);
37756
+ // @ts-ignore
37757
+ _this._offset._onValueChanged = function() {
37758
+ return _this._generator._renderer._onGeneratorParamsChanged();
37759
+ };
37647
37760
  return _this;
37648
37761
  }
37649
37762
  var _proto = VelocityOverLifetimeModule.prototype;
@@ -37652,6 +37765,10 @@ __decorate([
37652
37765
  */ _proto._updateShaderData = function _updateShaderData(shaderData) {
37653
37766
  var velocityMacro = null;
37654
37767
  var isRandomModeMacro = null;
37768
+ var orbitalMacro = null;
37769
+ var orbitalRandomModeMacro = null;
37770
+ var radialMacro = null;
37771
+ var radialRandomModeMacro = null;
37655
37772
  if (this.enabled) {
37656
37773
  var velocityX = this.velocityX;
37657
37774
  var velocityY = this.velocityY;
@@ -37681,15 +37798,111 @@ __decorate([
37681
37798
  }
37682
37799
  }
37683
37800
  shaderData.setInt(VelocityOverLifetimeModule._spaceProperty, this.space);
37801
+ var needTransformFeedback = this._needTransformFeedback();
37802
+ var orbitalActive = needTransformFeedback && this._isOrbitalActive();
37803
+ var radialActive = needTransformFeedback && this._isRadialActive();
37804
+ if (orbitalActive) {
37805
+ var orbitalX = this._orbitalX;
37806
+ var orbitalY = this._orbitalY;
37807
+ var orbitalZ = this._orbitalZ;
37808
+ var isOrbitalRandomCurveMode = orbitalX.mode === ParticleCurveMode.TwoCurves && orbitalY.mode === ParticleCurveMode.TwoCurves && orbitalZ.mode === ParticleCurveMode.TwoCurves;
37809
+ if (isOrbitalRandomCurveMode || orbitalX.mode === ParticleCurveMode.Curve && orbitalY.mode === ParticleCurveMode.Curve && orbitalZ.mode === ParticleCurveMode.Curve) {
37810
+ shaderData.setFloatArray(VelocityOverLifetimeModule._orbitalMaxCurveXProperty, orbitalX.curveMax._getTypeArray());
37811
+ shaderData.setFloatArray(VelocityOverLifetimeModule._orbitalMaxCurveYProperty, orbitalY.curveMax._getTypeArray());
37812
+ shaderData.setFloatArray(VelocityOverLifetimeModule._orbitalMaxCurveZProperty, orbitalZ.curveMax._getTypeArray());
37813
+ orbitalMacro = VelocityOverLifetimeModule._orbitalCurveModeMacro;
37814
+ if (isOrbitalRandomCurveMode) {
37815
+ shaderData.setFloatArray(VelocityOverLifetimeModule._orbitalMinCurveXProperty, orbitalX.curveMin._getTypeArray());
37816
+ shaderData.setFloatArray(VelocityOverLifetimeModule._orbitalMinCurveYProperty, orbitalY.curveMin._getTypeArray());
37817
+ shaderData.setFloatArray(VelocityOverLifetimeModule._orbitalMinCurveZProperty, orbitalZ.curveMin._getTypeArray());
37818
+ orbitalRandomModeMacro = VelocityOverLifetimeModule._orbitalRandomModeMacro;
37819
+ }
37820
+ } else {
37821
+ this._orbitalConstant.set(orbitalX.constantMax, orbitalY.constantMax, orbitalZ.constantMax);
37822
+ shaderData.setVector3(VelocityOverLifetimeModule._orbitalMaxConstantProperty, this._orbitalConstant);
37823
+ orbitalMacro = VelocityOverLifetimeModule._orbitalConstantModeMacro;
37824
+ if (orbitalX.mode === ParticleCurveMode.TwoConstants && orbitalY.mode === ParticleCurveMode.TwoConstants && orbitalZ.mode === ParticleCurveMode.TwoConstants) {
37825
+ this._orbitalMinConstant.set(orbitalX.constantMin, orbitalY.constantMin, orbitalZ.constantMin);
37826
+ shaderData.setVector3(VelocityOverLifetimeModule._orbitalMinConstantProperty, this._orbitalMinConstant);
37827
+ orbitalRandomModeMacro = VelocityOverLifetimeModule._orbitalRandomModeMacro;
37828
+ }
37829
+ }
37830
+ }
37831
+ if (radialActive) {
37832
+ var radial = this._radial;
37833
+ var isRadialRandomMode = radial._isRandomMode();
37834
+ if (radial._isCurveMode()) {
37835
+ shaderData.setFloatArray(VelocityOverLifetimeModule._radialMaxCurveProperty, radial.curveMax._getTypeArray());
37836
+ radialMacro = VelocityOverLifetimeModule._radialCurveModeMacro;
37837
+ if (isRadialRandomMode) {
37838
+ shaderData.setFloatArray(VelocityOverLifetimeModule._radialMinCurveProperty, radial.curveMin._getTypeArray());
37839
+ radialRandomModeMacro = VelocityOverLifetimeModule._radialRandomModeMacro;
37840
+ }
37841
+ } else {
37842
+ shaderData.setFloat(VelocityOverLifetimeModule._radialMaxConstantProperty, radial.constantMax);
37843
+ radialMacro = VelocityOverLifetimeModule._radialConstantModeMacro;
37844
+ if (isRadialRandomMode) {
37845
+ shaderData.setFloat(VelocityOverLifetimeModule._radialMinConstantProperty, radial.constantMin);
37846
+ radialRandomModeMacro = VelocityOverLifetimeModule._radialRandomModeMacro;
37847
+ }
37848
+ }
37849
+ }
37850
+ if (orbitalActive || radialActive) {
37851
+ shaderData.setVector3(VelocityOverLifetimeModule._offsetProperty, this._offset);
37852
+ }
37684
37853
  }
37685
37854
  this._velocityMacro = this._enableMacro(shaderData, this._velocityMacro, velocityMacro);
37686
37855
  this._randomModeMacro = this._enableMacro(shaderData, this._randomModeMacro, isRandomModeMacro);
37856
+ this._orbitalMacro = this._enableMacro(shaderData, this._orbitalMacro, orbitalMacro);
37857
+ this._orbitalRandomModeMacro = this._enableMacro(shaderData, this._orbitalRandomModeMacro, orbitalRandomModeMacro);
37858
+ this._radialMacro = this._enableMacro(shaderData, this._radialMacro, radialMacro);
37859
+ this._radialRandomModeMacro = this._enableMacro(shaderData, this._radialRandomModeMacro, radialRandomModeMacro);
37687
37860
  };
37688
37861
  /**
37689
37862
  * @internal
37690
37863
  */ _proto._resetRandomSeed = function _resetRandomSeed(seed) {
37691
37864
  this._velocityRand.reset(seed, ParticleRandomSubSeeds.VelocityOverLifetime);
37692
37865
  };
37866
+ /**
37867
+ * @internal
37868
+ */ _proto._needTransformFeedback = function _needTransformFeedback() {
37869
+ if (!this._enabled || !this._generator._renderer.engine._hardwareRenderer.isWebGL2) {
37870
+ return false;
37871
+ }
37872
+ return this._isOrbitalActive() || this._isRadialActive();
37873
+ };
37874
+ /**
37875
+ * @internal
37876
+ */ _proto._isOrbitalActive = function _isOrbitalActive() {
37877
+ return !(this._orbitalX._isZero() && this._orbitalY._isZero() && this._orbitalZ._isZero());
37878
+ };
37879
+ /**
37880
+ * @internal
37881
+ */ _proto._isRadialActive = function _isRadialActive() {
37882
+ return !this._radial._isZero();
37883
+ };
37884
+ /**
37885
+ * @internal
37886
+ */ _proto._isRandomMode = function _isRandomMode() {
37887
+ var velocityX = this.velocityX;
37888
+ var velocityY = this.velocityY;
37889
+ var velocityZ = this.velocityZ;
37890
+ var isLinearRandomMode = velocityX.mode === ParticleCurveMode.TwoConstants && velocityY.mode === ParticleCurveMode.TwoConstants && velocityZ.mode === ParticleCurveMode.TwoConstants || velocityX.mode === ParticleCurveMode.TwoCurves && velocityY.mode === ParticleCurveMode.TwoCurves && velocityZ.mode === ParticleCurveMode.TwoCurves;
37891
+ if (!this._needTransformFeedback()) {
37892
+ return isLinearRandomMode;
37893
+ }
37894
+ var orbitalX = this._orbitalX;
37895
+ var orbitalY = this._orbitalY;
37896
+ var orbitalZ = this._orbitalZ;
37897
+ var isOrbitalRandomMode = orbitalX.mode === ParticleCurveMode.TwoConstants && orbitalY.mode === ParticleCurveMode.TwoConstants && orbitalZ.mode === ParticleCurveMode.TwoConstants || orbitalX.mode === ParticleCurveMode.TwoCurves && orbitalY.mode === ParticleCurveMode.TwoCurves && orbitalZ.mode === ParticleCurveMode.TwoCurves;
37898
+ return isLinearRandomMode || isOrbitalRandomMode || this._radial._isRandomMode();
37899
+ };
37900
+ _proto._onOrbitalRadialChange = function _onOrbitalRadialChange(lastValue, value) {
37901
+ this._onCompositeCurveChange(lastValue, value);
37902
+ lastValue == null ? void 0 : lastValue._unRegisterOnValueChanged(this._onTransformFeedbackDirty);
37903
+ value == null ? void 0 : value._registerOnValueChanged(this._onTransformFeedbackDirty);
37904
+ this._generator._setTransformFeedback();
37905
+ };
37693
37906
  _create_class(VelocityOverLifetimeModule, [
37694
37907
  {
37695
37908
  key: "velocityX",
@@ -37736,6 +37949,84 @@ __decorate([
37736
37949
  }
37737
37950
  }
37738
37951
  },
37952
+ {
37953
+ key: "orbitalX",
37954
+ get: /**
37955
+ * Orbital velocity (radians/second) around the x axis of the system.
37956
+ * @remarks Requires WebGL2.
37957
+ */ function get() {
37958
+ return this._orbitalX;
37959
+ },
37960
+ set: function set(value) {
37961
+ var lastValue = this._orbitalX;
37962
+ if (value !== lastValue) {
37963
+ this._orbitalX = value;
37964
+ this._onOrbitalRadialChange(lastValue, value);
37965
+ }
37966
+ }
37967
+ },
37968
+ {
37969
+ key: "orbitalY",
37970
+ get: /**
37971
+ * Orbital velocity (radians/second) around the y axis of the system.
37972
+ * @remarks Requires WebGL2.
37973
+ */ function get() {
37974
+ return this._orbitalY;
37975
+ },
37976
+ set: function set(value) {
37977
+ var lastValue = this._orbitalY;
37978
+ if (value !== lastValue) {
37979
+ this._orbitalY = value;
37980
+ this._onOrbitalRadialChange(lastValue, value);
37981
+ }
37982
+ }
37983
+ },
37984
+ {
37985
+ key: "orbitalZ",
37986
+ get: /**
37987
+ * Orbital velocity (radians/second) around the z axis of the system.
37988
+ * @remarks Requires WebGL2.
37989
+ */ function get() {
37990
+ return this._orbitalZ;
37991
+ },
37992
+ set: function set(value) {
37993
+ var lastValue = this._orbitalZ;
37994
+ if (value !== lastValue) {
37995
+ this._orbitalZ = value;
37996
+ this._onOrbitalRadialChange(lastValue, value);
37997
+ }
37998
+ }
37999
+ },
38000
+ {
38001
+ key: "radial",
38002
+ get: /**
38003
+ * Radial velocity moving particles away from (or towards) the center.
38004
+ * @remarks Requires WebGL2.
38005
+ */ function get() {
38006
+ return this._radial;
38007
+ },
38008
+ set: function set(value) {
38009
+ var lastValue = this._radial;
38010
+ if (value !== lastValue) {
38011
+ this._radial = value;
38012
+ this._onOrbitalRadialChange(lastValue, value);
38013
+ }
38014
+ }
38015
+ },
38016
+ {
38017
+ key: "centerOffset",
38018
+ get: /**
38019
+ * The center offset of orbital/radial motion from the particle system origin.
38020
+ */ function get() {
38021
+ return this._offset;
38022
+ },
38023
+ set: function set(value) {
38024
+ var offset = this._offset;
38025
+ if (value !== offset) {
38026
+ offset.copyFrom(value);
38027
+ }
38028
+ }
38029
+ },
37739
38030
  {
37740
38031
  key: "space",
37741
38032
  get: /**
@@ -37758,6 +38049,7 @@ __decorate([
37758
38049
  set: function set(value) {
37759
38050
  if (value !== this._enabled) {
37760
38051
  this._enabled = value;
38052
+ this._generator._setTransformFeedback();
37761
38053
  this._generator._renderer._onGeneratorParamsChanged();
37762
38054
  }
37763
38055
  }
@@ -37777,6 +38069,25 @@ VelocityOverLifetimeModule._maxGradientXProperty = ShaderProperty.getByName("ren
37777
38069
  VelocityOverLifetimeModule._maxGradientYProperty = ShaderProperty.getByName("renderer_VOLMaxGradientY");
37778
38070
  VelocityOverLifetimeModule._maxGradientZProperty = ShaderProperty.getByName("renderer_VOLMaxGradientZ");
37779
38071
  VelocityOverLifetimeModule._spaceProperty = ShaderProperty.getByName("renderer_VOLSpace");
38072
+ VelocityOverLifetimeModule._orbitalConstantModeMacro = ShaderMacro.getByName("RENDERER_VOL_ORBITAL_CONSTANT_MODE");
38073
+ VelocityOverLifetimeModule._orbitalCurveModeMacro = ShaderMacro.getByName("RENDERER_VOL_ORBITAL_CURVE_MODE");
38074
+ VelocityOverLifetimeModule._orbitalRandomModeMacro = ShaderMacro.getByName("RENDERER_VOL_ORBITAL_IS_RANDOM_TWO");
38075
+ VelocityOverLifetimeModule._radialConstantModeMacro = ShaderMacro.getByName("RENDERER_VOL_RADIAL_CONSTANT_MODE");
38076
+ VelocityOverLifetimeModule._radialCurveModeMacro = ShaderMacro.getByName("RENDERER_VOL_RADIAL_CURVE_MODE");
38077
+ VelocityOverLifetimeModule._radialRandomModeMacro = ShaderMacro.getByName("RENDERER_VOL_RADIAL_IS_RANDOM_TWO");
38078
+ VelocityOverLifetimeModule._orbitalMinConstantProperty = ShaderProperty.getByName("renderer_VOLOrbitalMinConst");
38079
+ VelocityOverLifetimeModule._orbitalMaxConstantProperty = ShaderProperty.getByName("renderer_VOLOrbitalMaxConst");
38080
+ VelocityOverLifetimeModule._orbitalMinCurveXProperty = ShaderProperty.getByName("renderer_VOLOrbitalMinCurveX");
38081
+ VelocityOverLifetimeModule._orbitalMinCurveYProperty = ShaderProperty.getByName("renderer_VOLOrbitalMinCurveY");
38082
+ VelocityOverLifetimeModule._orbitalMinCurveZProperty = ShaderProperty.getByName("renderer_VOLOrbitalMinCurveZ");
38083
+ VelocityOverLifetimeModule._orbitalMaxCurveXProperty = ShaderProperty.getByName("renderer_VOLOrbitalMaxCurveX");
38084
+ VelocityOverLifetimeModule._orbitalMaxCurveYProperty = ShaderProperty.getByName("renderer_VOLOrbitalMaxCurveY");
38085
+ VelocityOverLifetimeModule._orbitalMaxCurveZProperty = ShaderProperty.getByName("renderer_VOLOrbitalMaxCurveZ");
38086
+ VelocityOverLifetimeModule._radialMinConstantProperty = ShaderProperty.getByName("renderer_VOLRadialMinConst");
38087
+ VelocityOverLifetimeModule._radialMaxConstantProperty = ShaderProperty.getByName("renderer_VOLRadialMaxConst");
38088
+ VelocityOverLifetimeModule._radialMinCurveProperty = ShaderProperty.getByName("renderer_VOLRadialMinCurve");
38089
+ VelocityOverLifetimeModule._radialMaxCurveProperty = ShaderProperty.getByName("renderer_VOLRadialMaxCurve");
38090
+ VelocityOverLifetimeModule._offsetProperty = ShaderProperty.getByName("renderer_VOLOffset");
37780
38091
  __decorate([
37781
38092
  ignoreClone
37782
38093
  ], VelocityOverLifetimeModule.prototype, "_velocityRand", void 0);
@@ -37792,6 +38103,24 @@ __decorate([
37792
38103
  __decorate([
37793
38104
  ignoreClone
37794
38105
  ], VelocityOverLifetimeModule.prototype, "_randomModeMacro", void 0);
38106
+ __decorate([
38107
+ ignoreClone
38108
+ ], VelocityOverLifetimeModule.prototype, "_orbitalMinConstant", void 0);
38109
+ __decorate([
38110
+ ignoreClone
38111
+ ], VelocityOverLifetimeModule.prototype, "_orbitalConstant", void 0);
38112
+ __decorate([
38113
+ ignoreClone
38114
+ ], VelocityOverLifetimeModule.prototype, "_orbitalMacro", void 0);
38115
+ __decorate([
38116
+ ignoreClone
38117
+ ], VelocityOverLifetimeModule.prototype, "_orbitalRandomModeMacro", void 0);
38118
+ __decorate([
38119
+ ignoreClone
38120
+ ], VelocityOverLifetimeModule.prototype, "_radialMacro", void 0);
38121
+ __decorate([
38122
+ ignoreClone
38123
+ ], VelocityOverLifetimeModule.prototype, "_radialRandomModeMacro", void 0);
37795
38124
  __decorate([
37796
38125
  deepClone
37797
38126
  ], VelocityOverLifetimeModule.prototype, "_velocityX", void 0);
@@ -37801,6 +38130,24 @@ __decorate([
37801
38130
  __decorate([
37802
38131
  deepClone
37803
38132
  ], VelocityOverLifetimeModule.prototype, "_velocityZ", void 0);
38133
+ __decorate([
38134
+ deepClone
38135
+ ], VelocityOverLifetimeModule.prototype, "_orbitalX", void 0);
38136
+ __decorate([
38137
+ deepClone
38138
+ ], VelocityOverLifetimeModule.prototype, "_orbitalY", void 0);
38139
+ __decorate([
38140
+ deepClone
38141
+ ], VelocityOverLifetimeModule.prototype, "_orbitalZ", void 0);
38142
+ __decorate([
38143
+ deepClone
38144
+ ], VelocityOverLifetimeModule.prototype, "_radial", void 0);
38145
+ __decorate([
38146
+ deepClone
38147
+ ], VelocityOverLifetimeModule.prototype, "_offset", void 0);
38148
+ __decorate([
38149
+ ignoreClone
38150
+ ], VelocityOverLifetimeModule.prototype, "_onTransformFeedbackDirty", void 0);
37804
38151
 
37805
38152
  /**
37806
38153
  * Optional parent properties a sub-emitter inherits
@@ -38401,12 +38748,10 @@ __decorate([
38401
38748
  /**
38402
38749
  * @internal
38403
38750
  */ _proto._setTransformFeedback = function _setTransformFeedback() {
38404
- var needed = this._renderer.engine._hardwareRenderer.isWebGL2 && (this.limitVelocityOverLifetime.enabled || this.noise.enabled || this.subEmitters._hasSubEmitterOfType(ParticleSubEmitterType.Death));
38751
+ var _this_limitVelocityOverLifetime, _this_noise, _this_velocityOverLifetime, _this_subEmitters;
38752
+ var needed = !!(this._renderer.engine._hardwareRenderer.isWebGL2 && (((_this_limitVelocityOverLifetime = this.limitVelocityOverLifetime) == null ? void 0 : _this_limitVelocityOverLifetime.enabled) || ((_this_noise = this.noise) == null ? void 0 : _this_noise.enabled) || ((_this_velocityOverLifetime = this.velocityOverLifetime) == null ? void 0 : _this_velocityOverLifetime._needTransformFeedback()) || ((_this_subEmitters = this.subEmitters) == null ? void 0 : _this_subEmitters._hasSubEmitterOfType(ParticleSubEmitterType.Death))));
38405
38753
  if (needed === this._useTransformFeedback) return;
38406
38754
  this._useTransformFeedback = needed;
38407
- // Switching TF mode invalidates all active particle state: feedback buffers and instance
38408
- // buffer layout are incompatible between the two paths. Clear rather than show a one-frame
38409
- // jump; new particles will fill in naturally from the next emit cycle.
38410
38755
  this._clearActiveParticles();
38411
38756
  if (needed) {
38412
38757
  if (!this._feedbackSimulator) {
@@ -38484,7 +38829,12 @@ __decorate([
38484
38829
  this._calculateTransformedBounds(maxLifetime, generatorBounds, transformedBounds);
38485
38830
  renderer._setDirtyFlagFalse(ParticleUpdateFlags.TransformVolume);
38486
38831
  }
38487
- this._addGravityToBounds(maxLifetime, transformedBounds, bounds);
38832
+ if (this._useOrbitalBounds()) {
38833
+ bounds.min.copyFrom(transformedBounds.min);
38834
+ bounds.max.copyFrom(transformedBounds.max);
38835
+ } else {
38836
+ this._addGravityToBounds(maxLifetime, transformedBounds, bounds);
38837
+ }
38488
38838
  };
38489
38839
  /**
38490
38840
  * @internal
@@ -38510,7 +38860,9 @@ __decorate([
38510
38860
  }
38511
38861
  }
38512
38862
  var maxLifetime = this.main.startLifetime._getMax();
38513
- this._addGravityToBounds(maxLifetime, bounds, bounds);
38863
+ if (!this._useOrbitalBounds()) {
38864
+ this._addGravityToBounds(maxLifetime, bounds, bounds);
38865
+ }
38514
38866
  };
38515
38867
  /**
38516
38868
  * @internal
@@ -38659,7 +39011,7 @@ __decorate([
38659
39011
  }
38660
39012
  // Velocity random
38661
39013
  var velocityOverLifetime = this.velocityOverLifetime;
38662
- if (velocityOverLifetime.enabled && velocityOverLifetime.velocityX.mode === ParticleCurveMode.TwoConstants && velocityOverLifetime.velocityY.mode === ParticleCurveMode.TwoConstants && velocityOverLifetime.velocityZ.mode === ParticleCurveMode.TwoConstants) {
39014
+ if (velocityOverLifetime.enabled && velocityOverLifetime._isRandomMode()) {
38663
39015
  var rand = velocityOverLifetime._velocityRand;
38664
39016
  instanceVertices[offset + 24] = rand.random();
38665
39017
  instanceVertices[offset + 25] = rand.random();
@@ -39071,7 +39423,7 @@ __decorate([
39071
39423
  max.set(Math.max(max.x, boundsArray[offset + 3]), Math.max(max.y, boundsArray[offset + 4]), Math.max(max.z, boundsArray[offset + 5]));
39072
39424
  };
39073
39425
  _proto._calculateTransformedBounds = function _calculateTransformedBounds(maxLifetime, origin, out) {
39074
- var velMinMaxX = ParticleGenerator._tempVector20, velMinMaxY = ParticleGenerator._tempVector21, velMinMaxZ = ParticleGenerator._tempVector22, worldOffsetMin = ParticleGenerator._tempVector30, worldOffsetMax = ParticleGenerator._tempVector31, rotateMat = ParticleGenerator._tempMat;
39426
+ var velMinMaxX = ParticleGenerator._tempVector20, velMinMaxY = ParticleGenerator._tempVector21, velMinMaxZ = ParticleGenerator._tempVector22, worldOffsetMin = ParticleGenerator._tempVector30, worldOffsetMax = ParticleGenerator._tempVector31, noiseBoundsExtents = ParticleGenerator._tempVector32, rotateMat = ParticleGenerator._tempMat;
39075
39427
  worldOffsetMin.set(0, 0, 0);
39076
39428
  worldOffsetMax.set(0, 0, 0);
39077
39429
  var transform = this._renderer.entity.transform;
@@ -39114,27 +39466,89 @@ __decorate([
39114
39466
  worldOffsetMax.set(worldOffsetMax.x + forceMinMaxX.y, worldOffsetMax.y + forceMinMaxY.y, worldOffsetMax.z + forceMinMaxZ.y);
39115
39467
  }
39116
39468
  }
39117
- out.transform(rotateMat);
39118
- min.add(worldOffsetMin);
39119
- max.add(worldOffsetMax);
39120
- // Noise module impact: noise output is normalized to [-1, 1],
39121
- // max displacement = |strength_max|
39122
39469
  var noise = this.noise;
39123
- if (noise.enabled) {
39124
- var noiseMaxX, noiseMaxY, noiseMaxZ;
39125
- if (noise.separateAxes) {
39126
- noiseMaxX = Math.abs(noise.strengthX._getMax());
39127
- noiseMaxY = Math.abs(noise.strengthY._getMax());
39128
- noiseMaxZ = Math.abs(noise.strengthZ._getMax());
39129
- } else {
39130
- noiseMaxX = noiseMaxY = noiseMaxZ = Math.abs(noise.strengthX._getMax());
39470
+ this._getNoiseBoundsExtents(maxLifetime, noiseBoundsExtents);
39471
+ var needTransformFeedback = velocityOverLifetime._needTransformFeedback();
39472
+ var orbitalActive = needTransformFeedback && velocityOverLifetime._isOrbitalActive();
39473
+ if (needTransformFeedback) {
39474
+ var centerOffset = velocityOverLifetime.centerOffset;
39475
+ var radialReach = 0;
39476
+ if (velocityOverLifetime._isRadialActive()) {
39477
+ this._getExtremeValueFromZero(velocityOverLifetime.radial, velMinMaxX);
39478
+ radialReach = Math.max(Math.abs(velMinMaxX.x), Math.abs(velMinMaxX.y)) * maxLifetime;
39479
+ }
39480
+ if (orbitalActive) {
39481
+ var dx = Math.max(Math.abs(min.x - centerOffset.x), Math.abs(max.x - centerOffset.x));
39482
+ var dy = Math.max(Math.abs(min.y - centerOffset.y), Math.abs(max.y - centerOffset.y));
39483
+ var dz = Math.max(Math.abs(min.z - centerOffset.z), Math.abs(max.z - centerOffset.z));
39484
+ var worldReach = this._getRangeReach(worldOffsetMin, worldOffsetMax);
39485
+ var noiseReach = this._getVectorReach(noiseBoundsExtents);
39486
+ var gravityReach = this._getGravityBoundsReach(maxLifetime);
39487
+ var reach = Math.sqrt(dx * dx + dy * dy + dz * dz) + worldReach + noiseReach + gravityReach + radialReach;
39488
+ min.set(Math.min(min.x, centerOffset.x - reach), Math.min(min.y, centerOffset.y - reach), Math.min(min.z, centerOffset.z - reach));
39489
+ max.set(Math.max(max.x, centerOffset.x + reach), Math.max(max.y, centerOffset.y + reach), Math.max(max.z, centerOffset.z + reach));
39490
+ } else if (radialReach > 0) {
39491
+ min.set(min.x - radialReach, min.y - radialReach, min.z - radialReach);
39492
+ max.set(max.x + radialReach, max.y + radialReach, max.z + radialReach);
39493
+ }
39494
+ }
39495
+ out.transform(rotateMat);
39496
+ if (!orbitalActive) {
39497
+ min.add(worldOffsetMin);
39498
+ max.add(worldOffsetMax);
39499
+ if (noise.enabled) {
39500
+ min.set(min.x - noiseBoundsExtents.x, min.y - noiseBoundsExtents.y, min.z - noiseBoundsExtents.z);
39501
+ max.set(max.x + noiseBoundsExtents.x, max.y + noiseBoundsExtents.y, max.z + noiseBoundsExtents.z);
39131
39502
  }
39132
- min.set(min.x - noiseMaxX, min.y - noiseMaxY, min.z - noiseMaxZ);
39133
- max.set(max.x + noiseMaxX, max.y + noiseMaxY, max.z + noiseMaxZ);
39134
39503
  }
39135
39504
  min.add(worldPosition);
39136
39505
  max.add(worldPosition);
39137
39506
  };
39507
+ _proto._useOrbitalBounds = function _useOrbitalBounds() {
39508
+ var velocityOverLifetime = this.velocityOverLifetime;
39509
+ return velocityOverLifetime._needTransformFeedback() && velocityOverLifetime._isOrbitalActive();
39510
+ };
39511
+ _proto._getNoiseBoundsExtents = function _getNoiseBoundsExtents(maxLifetime, out) {
39512
+ var noise = this.noise;
39513
+ if (!noise.enabled) {
39514
+ out.set(0, 0, 0);
39515
+ return;
39516
+ }
39517
+ var noiseMaxX, noiseMaxY, noiseMaxZ;
39518
+ if (noise.separateAxes) {
39519
+ noiseMaxX = this._getCurveMagnitudeFromZero(noise.strengthX);
39520
+ noiseMaxY = this._getCurveMagnitudeFromZero(noise.strengthY);
39521
+ noiseMaxZ = this._getCurveMagnitudeFromZero(noise.strengthZ);
39522
+ } else {
39523
+ noiseMaxX = noiseMaxY = noiseMaxZ = this._getCurveMagnitudeFromZero(noise.strengthX);
39524
+ }
39525
+ out.set(noiseMaxX * maxLifetime, noiseMaxY * maxLifetime, noiseMaxZ * maxLifetime);
39526
+ };
39527
+ _proto._getGravityBoundsReach = function _getGravityBoundsReach(maxLifetime) {
39528
+ var modifierMinMax = ParticleGenerator._tempVector20;
39529
+ this._getExtremeValueFromZero(this.main.gravityModifier, modifierMinMax);
39530
+ var coefficient = 0.5 * maxLifetime * maxLifetime;
39531
+ var minGravityEffect = modifierMinMax.x * coefficient;
39532
+ var maxGravityEffect = modifierMinMax.y * coefficient;
39533
+ var _this__renderer_scene_physics_gravity = this._renderer.scene.physics.gravity, x = _this__renderer_scene_physics_gravity.x, y = _this__renderer_scene_physics_gravity.y, z = _this__renderer_scene_physics_gravity.z;
39534
+ var gravityBoundsExtents = ParticleGenerator._tempVector33;
39535
+ gravityBoundsExtents.set(Math.max(Math.abs(x * minGravityEffect), Math.abs(x * maxGravityEffect)), Math.max(Math.abs(y * minGravityEffect), Math.abs(y * maxGravityEffect)), Math.max(Math.abs(z * minGravityEffect), Math.abs(z * maxGravityEffect)));
39536
+ return this._getVectorReach(gravityBoundsExtents);
39537
+ };
39538
+ _proto._getRangeReach = function _getRangeReach(min, max) {
39539
+ var x = Math.max(Math.abs(min.x), Math.abs(max.x));
39540
+ var y = Math.max(Math.abs(min.y), Math.abs(max.y));
39541
+ var z = Math.max(Math.abs(min.z), Math.abs(max.z));
39542
+ return Math.sqrt(x * x + y * y + z * z);
39543
+ };
39544
+ _proto._getVectorReach = function _getVectorReach(value) {
39545
+ return Math.sqrt(value.x * value.x + value.y * value.y + value.z * value.z);
39546
+ };
39547
+ _proto._getCurveMagnitudeFromZero = function _getCurveMagnitudeFromZero(curve) {
39548
+ var minMax = ParticleGenerator._tempVector20;
39549
+ this._getExtremeValueFromZero(curve, minMax);
39550
+ return Math.max(Math.abs(minMax.x), Math.abs(minMax.y));
39551
+ };
39138
39552
  _proto._addGravityToBounds = function _addGravityToBounds(maxLifetime, origin, out) {
39139
39553
  var originMin = origin.min, originMax = origin.max;
39140
39554
  var modifierMinMax = ParticleGenerator._tempVector20;
@@ -39196,6 +39610,7 @@ ParticleGenerator._tempVector22 = new Vector2();
39196
39610
  ParticleGenerator._tempVector30 = new Vector3();
39197
39611
  ParticleGenerator._tempVector31 = new Vector3();
39198
39612
  ParticleGenerator._tempVector32 = new Vector3();
39613
+ ParticleGenerator._tempVector33 = new Vector3();
39199
39614
  ParticleGenerator._tempMat = new Matrix();
39200
39615
  ParticleGenerator._tempColor = new Color();
39201
39616
  ParticleGenerator._tempQuat0 = new Quaternion();
@@ -41033,7 +41448,14 @@ var cacheDir = new Vector3();
41033
41448
  * Suspend the audio context.
41034
41449
  * @returns A promise that resolves when the audio context is suspended
41035
41450
  */ AudioManager.suspend = function suspend() {
41036
- return AudioManager.getContext().suspend();
41451
+ // No context means nothing is playing: suspending is a no-op and must NOT flag a caller-suspend
41452
+ // (a ghost flag would later block foreground recovery), and don't create a cold context just to suspend
41453
+ var context = AudioManager._context;
41454
+ if (!context) {
41455
+ return Promise.resolve();
41456
+ }
41457
+ AudioManager._suspendedByCaller = true;
41458
+ return context.suspend();
41037
41459
  };
41038
41460
  /**
41039
41461
  * Resume the audio context.
@@ -41041,6 +41463,7 @@ var cacheDir = new Vector3();
41041
41463
  * @returns A promise that resolves when the audio context is resumed
41042
41464
  */ AudioManager.resume = function resume() {
41043
41465
  var _AudioManager;
41466
+ AudioManager._suspendedByCaller = false;
41044
41467
  var __resumePromise;
41045
41468
  return (__resumePromise = (_AudioManager = AudioManager)._resumePromise) != null ? __resumePromise : _AudioManager._resumePromise = AudioManager.getContext().resume().then(function() {
41046
41469
  AudioManager._needsUserGestureResume = false;
@@ -41055,7 +41478,9 @@ var cacheDir = new Vector3();
41055
41478
  if (!context) {
41056
41479
  AudioManager._context = context = new window.AudioContext();
41057
41480
  document.addEventListener("visibilitychange", AudioManager._onVisibilityChange);
41058
- // iOS Safari requires user gesture to resume AudioContext
41481
+ // iOS Safari bfcache restore fires pageshow (persisted) but NOT visibilitychange, so recover here too
41482
+ window.addEventListener("pageshow", AudioManager._onPageShow);
41483
+ // iOS Safari requires a user gesture to resume the AudioContext
41059
41484
  document.addEventListener("touchstart", AudioManager._resumeAfterInterruption, {
41060
41485
  passive: true
41061
41486
  });
@@ -41083,27 +41508,62 @@ var cacheDir = new Vector3();
41083
41508
  return AudioManager.getContext().state === "running";
41084
41509
  };
41085
41510
  AudioManager._onVisibilityChange = function _onVisibilityChange() {
41086
- if (!document.hidden && AudioManager._playingCount > 0 && !AudioManager.isAudioContextRunning()) {
41087
- // iOS WKWebView WebKit bug(Triggered in LingGuang App): AudioContext may be in a "zombie" state where
41088
- // state reports "suspended" but resume() alone won't restart audio rendering.
41089
- // Calling suspend() first forces a clean internal state reset before user gesture triggers resume.
41090
- // Related: https://bugs.webkit.org/show_bug.cgi?id=263627
41091
- AudioManager.suspend();
41092
- AudioManager._needsUserGestureResume = true;
41511
+ if (document.hidden) {
41512
+ var // Desktop/Android don't auto-suspend a running WebAudio context when backgrounded (only iOS does),
41513
+ // so suspend here to stop audio in the background; only if a context already exists (don't create one)
41514
+ _AudioManager__context;
41515
+ (_AudioManager__context = AudioManager._context) == null ? void 0 : _AudioManager__context.suspend().catch(function() {});
41516
+ } else {
41517
+ AudioManager._recoverPlaybackContext();
41518
+ }
41519
+ };
41520
+ AudioManager._recoverPlaybackContext = function _recoverPlaybackContext() {
41521
+ // Returning to foreground with a non-running context (and not a deliberate pause): iOS leaves it
41522
+ // "interrupted", which cannot be resumed directly; suspend() first transitions it to "suspended",
41523
+ // then resume() restarts the pipeline https://bugs.webkit.org/show_bug.cgi?id=263627
41524
+ // _recovering guards re-entry: a bfcache restore fires both visibilitychange and pageshow
41525
+ if (AudioManager._recovering || document.hidden || AudioManager._suspendedByCaller || AudioManager._playingCount <= 0 || AudioManager.isAudioContextRunning()) {
41526
+ return;
41527
+ }
41528
+ AudioManager._recovering = true;
41529
+ AudioManager._needsUserGestureResume = true; // fallback if the auto-resume below is rejected
41530
+ var context = AudioManager.getContext();
41531
+ context.suspend().catch(function() {});
41532
+ // 100ms empirical delay (resume too soon after suspend is unreliable on iOS); _recovering is cleared
41533
+ // on the timer rather than off a promise because iOS may never settle suspend/resume in interrupted
41534
+ setTimeout(function() {
41535
+ AudioManager._recovering = false;
41536
+ if (document.hidden || AudioManager._suspendedByCaller) {
41537
+ return;
41538
+ }
41539
+ // Go through AudioManager.resume() so _resumePromise coalesces any gesture-resume racing us during
41540
+ // the slow iOS interrupted->running transition; a bare context.resume() here wouldn't dedupe
41541
+ AudioManager.resume().catch(function() {});
41542
+ }, 100);
41543
+ };
41544
+ AudioManager._onPageShow = function _onPageShow(event) {
41545
+ // iOS Safari bfcache restore (persisted) needs recovery; a normal load has no suspended context
41546
+ if (event.persisted) {
41547
+ AudioManager._recoverPlaybackContext();
41093
41548
  }
41094
41549
  };
41095
41550
  AudioManager._resumeAfterInterruption = function _resumeAfterInterruption() {
41096
- if (AudioManager._needsUserGestureResume) {
41097
- AudioManager.resume().catch(function(e) {
41098
- console.warn("Failed to resume AudioContext:", e);
41099
- });
41551
+ // iOS Safari gesture fallback for when auto-resume is blocked.
41552
+ // _recovering: don't bypass the 100ms delay (would resume on a still-interrupted context)
41553
+ if (AudioManager._recovering || AudioManager._suspendedByCaller || !AudioManager._needsUserGestureResume) {
41554
+ return;
41100
41555
  }
41556
+ AudioManager.resume().catch(function(e) {
41557
+ console.warn("Failed to resume AudioContext:", e);
41558
+ });
41101
41559
  };
41102
41560
  return AudioManager;
41103
41561
  }();
41104
41562
  /** @internal */ AudioManager._playingCount = 0;
41105
41563
  AudioManager._resumePromise = null;
41106
41564
  AudioManager._needsUserGestureResume = false;
41565
+ AudioManager._suspendedByCaller = false;
41566
+ AudioManager._recovering = false;
41107
41567
 
41108
41568
  /**
41109
41569
  * Audio Source Component.
@@ -41113,8 +41573,6 @@ AudioManager._needsUserGestureResume = false;
41113
41573
  var _this;
41114
41574
  _this = Component.call(this, entity) || this, /** If set to true, the audio component automatically begins to play on startup. */ _this.playOnEnabled = true, _this._isPlaying = false, _this._pendingPlay = false, _this._sourceNode = null, _this._pausedTime = -1, _this._playTime = -1, _this._volume = 1, _this._lastVolume = 1, _this._playbackRate = 1, _this._loop = false;
41115
41575
  _this._onPlayEnd = _this._onPlayEnd.bind(_this);
41116
- _this._gainNode = AudioManager.getContext().createGain();
41117
- _this._gainNode.connect(AudioManager.getGainNode());
41118
41576
  return _this;
41119
41577
  }
41120
41578
  var _proto = AudioSource.prototype;
@@ -41126,6 +41584,10 @@ AudioManager._needsUserGestureResume = false;
41126
41584
  if (!((_this__clip = this._clip) == null ? void 0 : _this__clip._getAudioSource()) || this._isPlaying || this._pendingPlay) {
41127
41585
  return;
41128
41586
  }
41587
+ // Hidden page: don't start (would leak a sound) and don't pend (would replay out of sync) -> drop
41588
+ if (document.hidden) {
41589
+ return;
41590
+ }
41129
41591
  if (AudioManager.isAudioContextRunning()) {
41130
41592
  this._startPlayback();
41131
41593
  } else {
@@ -41138,8 +41600,8 @@ AudioManager._needsUserGestureResume = false;
41138
41600
  return;
41139
41601
  }
41140
41602
  _this._pendingPlay = false;
41141
- // Check if still valid to play after async resume
41142
- if (_this._destroyed || !_this.enabled || !_this._clip) {
41603
+ // Check if still valid to play after async resume (page may have been hidden meanwhile)
41604
+ if (_this._destroyed || !_this.enabled || !_this._clip || document.hidden) {
41143
41605
  return;
41144
41606
  }
41145
41607
  _this._startPlayback();
@@ -41156,10 +41618,11 @@ AudioManager._needsUserGestureResume = false;
41156
41618
  if (this._isPlaying) {
41157
41619
  this._clearSourceNode();
41158
41620
  this._isPlaying = false;
41159
- this._pausedTime = -1;
41160
- this._playTime = -1;
41161
41621
  AudioManager._playingCount--;
41162
41622
  }
41623
+ // stop() always resets to the start, including from a paused state (where _isPlaying is already false)
41624
+ this._pausedTime = -1;
41625
+ this._playTime = -1;
41163
41626
  };
41164
41627
  /**
41165
41628
  * Pauses playing the clip.
@@ -41177,7 +41640,7 @@ AudioManager._needsUserGestureResume = false;
41177
41640
  */ _proto._cloneTo = function _cloneTo(target) {
41178
41641
  var _target__clip;
41179
41642
  (_target__clip = target._clip) == null ? void 0 : _target__clip._addReferCount(1);
41180
- target._gainNode.gain.setValueAtTime(target._volume, AudioManager.getContext().currentTime);
41643
+ // _volume is field-cloned; its gain node is applied lazily on first play
41181
41644
  };
41182
41645
  /**
41183
41646
  * @internal
@@ -41199,6 +41662,15 @@ AudioManager._needsUserGestureResume = false;
41199
41662
  _proto._onPlayEnd = function _onPlayEnd() {
41200
41663
  this.stop();
41201
41664
  };
41665
+ _proto._ensureGainNode = function _ensureGainNode() {
41666
+ var gainNode = this._gainNode;
41667
+ if (!gainNode) {
41668
+ this._gainNode = gainNode = AudioManager.getContext().createGain();
41669
+ gainNode.connect(AudioManager.getGainNode());
41670
+ gainNode.gain.setValueAtTime(this._volume, AudioManager.getContext().currentTime);
41671
+ }
41672
+ return gainNode;
41673
+ };
41202
41674
  _proto._startPlayback = function _startPlayback() {
41203
41675
  var startTime = this._pausedTime > 0 ? this._pausedTime - this._playTime : 0;
41204
41676
  this._initSourceNode(startTime);
@@ -41210,13 +41682,17 @@ AudioManager._needsUserGestureResume = false;
41210
41682
  _proto._initSourceNode = function _initSourceNode(startTime) {
41211
41683
  var context = AudioManager.getContext();
41212
41684
  var sourceNode = context.createBufferSource();
41213
- sourceNode.buffer = this._clip._getAudioSource();
41685
+ var buffer = this._clip._getAudioSource();
41686
+ sourceNode.buffer = buffer;
41214
41687
  sourceNode.playbackRate.value = this._playbackRate;
41215
41688
  sourceNode.loop = this._loop;
41216
41689
  sourceNode.onended = this._onPlayEnd;
41217
41690
  this._sourceNode = sourceNode;
41218
- sourceNode.connect(this._gainNode);
41219
- sourceNode.start(0, startTime);
41691
+ sourceNode.connect(this._ensureGainNode());
41692
+ // startTime is total elapsed time; for a looping clip wrap it into the buffer to keep the loop phase
41693
+ // (start()'s offset clamps past the end, it does not wrap)
41694
+ var offset = this._loop && buffer.duration > 0 ? startTime % buffer.duration : startTime;
41695
+ sourceNode.start(0, offset);
41220
41696
  };
41221
41697
  _proto._clearSourceNode = function _clearSourceNode() {
41222
41698
  this._sourceNode.stop();
@@ -41259,9 +41735,11 @@ AudioManager._needsUserGestureResume = false;
41259
41735
  return this._volume;
41260
41736
  },
41261
41737
  set: function set(value) {
41738
+ var // No node yet -> _ensureGainNode() applies _volume on first play
41739
+ _this__gainNode;
41262
41740
  value = Math.min(Math.max(0, value), 1.0);
41263
41741
  this._volume = value;
41264
- this._gainNode.gain.setValueAtTime(value, AudioManager.getContext().currentTime);
41742
+ (_this__gainNode = this._gainNode) == null ? void 0 : _this__gainNode.gain.setValueAtTime(value, AudioManager.getContext().currentTime);
41265
41743
  }
41266
41744
  },
41267
41745
  {
@@ -41373,6 +41851,7 @@ __decorate([
41373
41851
  Polyfill.registerPolyfill = function registerPolyfill() {
41374
41852
  Polyfill._registerMatchAll();
41375
41853
  Polyfill._registerAudioContext();
41854
+ Polyfill._registerOfflineAudioContext();
41376
41855
  Polyfill._registerTextMetrics();
41377
41856
  Polyfill._registerPromiseFinally();
41378
41857
  };
@@ -41437,20 +41916,32 @@ __decorate([
41437
41916
  if (!window.AudioContext && window.webkitAudioContext) {
41438
41917
  Logger.info("Polyfill window.AudioContext");
41439
41918
  window.AudioContext = window.webkitAudioContext;
41440
- var originalDecodeAudioData = AudioContext.prototype.decodeAudioData;
41441
- AudioContext.prototype.decodeAudioData = function(arrayBuffer, successCallback, errorCallback) {
41442
- var _this = this;
41443
- return new Promise(function(resolve, reject) {
41444
- originalDecodeAudioData.call(_this, arrayBuffer, function(buffer) {
41445
- successCallback == null ? void 0 : successCallback(buffer);
41446
- resolve(buffer);
41447
- }, function(error) {
41448
- errorCallback == null ? void 0 : errorCallback(error);
41449
- reject(error);
41450
- });
41919
+ Polyfill._promisifyDecodeAudioData(AudioContext.prototype);
41920
+ }
41921
+ };
41922
+ Polyfill._registerOfflineAudioContext = function _registerOfflineAudioContext() {
41923
+ // iOS 14.0 and earlier expose only webkitOfflineAudioContext, with callback-form decodeAudioData
41924
+ if (!window.OfflineAudioContext && window.webkitOfflineAudioContext) {
41925
+ Logger.info("Polyfill window.OfflineAudioContext");
41926
+ window.OfflineAudioContext = window.webkitOfflineAudioContext;
41927
+ Polyfill._promisifyDecodeAudioData(OfflineAudioContext.prototype);
41928
+ }
41929
+ };
41930
+ // Wrap the old callback-form decodeAudioData (on prefixed iOS contexts) into the modern Promise form
41931
+ Polyfill._promisifyDecodeAudioData = function _promisifyDecodeAudioData(proto) {
41932
+ var originalDecodeAudioData = proto.decodeAudioData;
41933
+ proto.decodeAudioData = function(arrayBuffer, successCallback, errorCallback) {
41934
+ var _this = this;
41935
+ return new Promise(function(resolve, reject) {
41936
+ originalDecodeAudioData.call(_this, arrayBuffer, function(buffer) {
41937
+ successCallback == null ? void 0 : successCallback(buffer);
41938
+ resolve(buffer);
41939
+ }, function(error) {
41940
+ errorCallback == null ? void 0 : errorCallback(error);
41941
+ reject(error);
41451
41942
  });
41452
- };
41453
- }
41943
+ });
41944
+ };
41454
41945
  };
41455
41946
  Polyfill._registerTextMetrics = function _registerTextMetrics() {
41456
41947
  // Based on the specific version of the engine implementation, when actualBoundingBoxLeft is not supported, width is used to represent the rendering width, and `textAlign` uses the default value `start` and direction is left to right.