@galacean/engine-core 2.0.0-alpha.36 → 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/main.js +1312 -246
- package/dist/main.js.map +1 -1
- package/dist/module.js +1309 -247
- package/dist/module.js.map +1 -1
- package/package.json +3 -3
- package/types/Engine.d.ts +1 -0
- package/types/Entity.d.ts +2 -1
- package/types/Signal.d.ts +6 -2
- package/types/animation/AnimationClip.d.ts +7 -1
- package/types/animation/Animator.d.ts +2 -0
- package/types/animation/AnimatorController.d.ts +1 -0
- package/types/animation/AnimatorControllerLayer.d.ts +8 -2
- package/types/animation/AnimatorStateMachine.d.ts +1 -0
- package/types/asset/ResourceManager.d.ts +1 -1
- package/types/audio/AudioManager.d.ts +4 -0
- package/types/audio/AudioSource.d.ts +1 -0
- package/types/particle/ParticleGenerator.d.ts +24 -1
- package/types/particle/enums/ParticleSubEmitterInheritProperty.d.ts +17 -0
- package/types/particle/enums/ParticleSubEmitterType.d.ts +9 -0
- package/types/particle/index.d.ts +4 -0
- package/types/particle/modules/ParticleCompositeCurve.d.ts +2 -2
- package/types/particle/modules/ParticleCompositeGradient.d.ts +1 -0
- package/types/particle/modules/ParticleGeneratorModule.d.ts +0 -2
- package/types/particle/modules/SubEmitter.d.ts +27 -0
- package/types/particle/modules/SubEmittersModule.d.ts +36 -0
- package/types/particle/modules/VelocityOverLifetimeModule.d.ts +62 -0
- package/types/physics/DynamicCollider.d.ts +6 -0
package/dist/main.js
CHANGED
|
@@ -3852,7 +3852,7 @@ exports.TiledSpriteAssembler = __decorate([
|
|
|
3852
3852
|
sprite.name === name && outSprites.push(sprite);
|
|
3853
3853
|
}
|
|
3854
3854
|
} else {
|
|
3855
|
-
console.warn("
|
|
3855
|
+
console.warn("There is no sprite named " + name + " in the atlas.");
|
|
3856
3856
|
}
|
|
3857
3857
|
return outSprites;
|
|
3858
3858
|
};
|
|
@@ -6063,6 +6063,9 @@ __decorate([
|
|
|
6063
6063
|
__decorate([
|
|
6064
6064
|
ignoreClone
|
|
6065
6065
|
], Transform.prototype, "_isParentDirty", void 0);
|
|
6066
|
+
__decorate([
|
|
6067
|
+
ignoreClone
|
|
6068
|
+
], Transform.prototype, "_parentTransformCache", void 0);
|
|
6066
6069
|
__decorate([
|
|
6067
6070
|
ignoreClone
|
|
6068
6071
|
], Transform.prototype, "_dirtyFlag", void 0);
|
|
@@ -17075,9 +17078,10 @@ var ComponentCloner = /*#__PURE__*/ function() {
|
|
|
17075
17078
|
};
|
|
17076
17079
|
/**
|
|
17077
17080
|
* Get the components which match the type of the entity and it's children.
|
|
17081
|
+
* @remarks The components are returned in depth-first pre-order: the entity itself first, then each child's subtree in sibling order.
|
|
17078
17082
|
* @param type - The component type
|
|
17079
17083
|
* @param results - The components collection
|
|
17080
|
-
* @returns
|
|
17084
|
+
* @returns The components collection which match the type
|
|
17081
17085
|
*/ _proto.getComponentsIncludeChildren = function getComponentsIncludeChildren(type, results) {
|
|
17082
17086
|
results.length = 0;
|
|
17083
17087
|
this._getComponentsInChildren(type, results);
|
|
@@ -17382,14 +17386,16 @@ var ComponentCloner = /*#__PURE__*/ function() {
|
|
|
17382
17386
|
}
|
|
17383
17387
|
};
|
|
17384
17388
|
_proto._getComponentsInChildren = function _getComponentsInChildren(type, results) {
|
|
17385
|
-
|
|
17386
|
-
|
|
17389
|
+
var components = this._components;
|
|
17390
|
+
for(var i = 0, n = components.length; i < n; i++){
|
|
17391
|
+
var component = components[i];
|
|
17387
17392
|
if (_instanceof(component, type)) {
|
|
17388
17393
|
results.push(component);
|
|
17389
17394
|
}
|
|
17390
17395
|
}
|
|
17391
|
-
|
|
17392
|
-
|
|
17396
|
+
var children = this._children;
|
|
17397
|
+
for(var i1 = 0, n1 = children.length; i1 < n1; i1++){
|
|
17398
|
+
children[i1]._getComponentsInChildren(type, results);
|
|
17393
17399
|
}
|
|
17394
17400
|
};
|
|
17395
17401
|
_proto._setActiveComponents = function _setActiveComponents(isActive, activeChangeFlag) {
|
|
@@ -18821,37 +18827,39 @@ var MultiExecutor = /*#__PURE__*/ function() {
|
|
|
18821
18827
|
this._contentRestorerPool = null;
|
|
18822
18828
|
this._loadingPromises = null;
|
|
18823
18829
|
};
|
|
18824
|
-
_proto.
|
|
18825
|
-
var
|
|
18826
|
-
|
|
18830
|
+
_proto._resolveLoadItemOptions = function _resolveLoadItemOptions(assetInfo, virtualResourceEntry) {
|
|
18831
|
+
var _assetInfo;
|
|
18832
|
+
var _virtualResourceEntry_type, _ref;
|
|
18833
|
+
assetInfo.type = (_ref = (_virtualResourceEntry_type = virtualResourceEntry == null ? void 0 : virtualResourceEntry.type) != null ? _virtualResourceEntry_type : assetInfo.type) != null ? _ref : ResourceManager._getTypeByUrl(assetInfo.url);
|
|
18827
18834
|
if (assetInfo.type === undefined) {
|
|
18828
18835
|
throw "asset type should be specified: " + assetInfo.url;
|
|
18829
18836
|
}
|
|
18837
|
+
var _params;
|
|
18838
|
+
(_params = (_assetInfo = assetInfo).params) != null ? _params : _assetInfo.params = virtualResourceEntry == null ? void 0 : virtualResourceEntry.params;
|
|
18830
18839
|
var _assetInfo_retryCount;
|
|
18831
18840
|
assetInfo.retryCount = (_assetInfo_retryCount = assetInfo.retryCount) != null ? _assetInfo_retryCount : this.retryCount;
|
|
18832
18841
|
var _assetInfo_timeout;
|
|
18833
18842
|
assetInfo.timeout = (_assetInfo_timeout = assetInfo.timeout) != null ? _assetInfo_timeout : this.timeout;
|
|
18834
18843
|
var _assetInfo_retryInterval;
|
|
18835
18844
|
assetInfo.retryInterval = (_assetInfo_retryInterval = assetInfo.retryInterval) != null ? _assetInfo_retryInterval : this.retryInterval;
|
|
18836
|
-
var _assetInfo_url;
|
|
18837
|
-
assetInfo.url = (_assetInfo_url = assetInfo.url) != null ? _assetInfo_url : assetInfo.urls.join(",");
|
|
18838
|
-
return assetInfo;
|
|
18839
18845
|
};
|
|
18840
18846
|
_proto._loadSingleItem = function _loadSingleItem(itemOrURL) {
|
|
18841
18847
|
var _this = this;
|
|
18842
|
-
var item =
|
|
18848
|
+
var item = typeof itemOrURL === "string" ? {
|
|
18843
18849
|
url: itemOrURL
|
|
18844
|
-
} : itemOrURL
|
|
18845
|
-
var
|
|
18846
|
-
|
|
18847
|
-
if (!Utils.isAbsoluteUrl(url) && this.baseUrl) url = Utils.resolveAbsoluteUrl(this.baseUrl, url);
|
|
18850
|
+
} : itemOrURL;
|
|
18851
|
+
var _item_url;
|
|
18852
|
+
item.url = (_item_url = item.url) != null ? _item_url : item.urls.join(",");
|
|
18848
18853
|
// Parse url
|
|
18849
|
-
var _this__parseURL = this._parseURL(url), assetBaseURL = _this__parseURL.assetBaseURL, queryPath = _this__parseURL.queryPath;
|
|
18854
|
+
var _this__parseURL = this._parseURL(item.url), assetBaseURL = _this__parseURL.assetBaseURL, queryPath = _this__parseURL.queryPath;
|
|
18850
18855
|
var paths = queryPath ? this._parseQueryPath(queryPath) : [];
|
|
18851
18856
|
// Get remote asset base url
|
|
18852
|
-
var
|
|
18853
|
-
|
|
18854
|
-
|
|
18857
|
+
var virtualResourceEntry = this._virtualPathResourceMap[assetBaseURL];
|
|
18858
|
+
this._resolveLoadItemOptions(item, virtualResourceEntry);
|
|
18859
|
+
// Not absolute and base url is set
|
|
18860
|
+
item.url = !Utils.isAbsoluteUrl(assetBaseURL) && this.baseUrl ? Utils.resolveAbsoluteUrl(this.baseUrl, assetBaseURL) : assetBaseURL;
|
|
18861
|
+
var _virtualResourceEntry_path;
|
|
18862
|
+
var remoteAssetBaseURL = (_virtualResourceEntry_path = virtualResourceEntry == null ? void 0 : virtualResourceEntry.path) != null ? _virtualResourceEntry_path : item.url;
|
|
18855
18863
|
// Check cache
|
|
18856
18864
|
var cacheObject = this._assetUrlPool[remoteAssetBaseURL];
|
|
18857
18865
|
if (cacheObject) {
|
|
@@ -18885,25 +18893,24 @@ var MultiExecutor = /*#__PURE__*/ function() {
|
|
|
18885
18893
|
if (!loader) {
|
|
18886
18894
|
throw "loader not found: " + item.type;
|
|
18887
18895
|
}
|
|
18888
|
-
var subpackageName =
|
|
18896
|
+
var subpackageName = virtualResourceEntry == null ? void 0 : virtualResourceEntry.subpackageName;
|
|
18889
18897
|
// Check sub asset
|
|
18890
18898
|
if (queryPath) {
|
|
18891
18899
|
// Check whether load main asset
|
|
18892
|
-
var mainPromise = loadingPromises[remoteAssetBaseURL] || this._loadSubpackageAndMainAsset(loader, item, remoteAssetBaseURL,
|
|
18900
|
+
var mainPromise = loadingPromises[remoteAssetBaseURL] || this._loadSubpackageAndMainAsset(loader, item, remoteAssetBaseURL, subpackageName);
|
|
18893
18901
|
mainPromise.catch(function(e) {
|
|
18894
18902
|
_this._onSubAssetFail(remoteAssetBaseURL, queryPath, e);
|
|
18895
18903
|
});
|
|
18896
18904
|
return this._createSubAssetPromiseCallback(remoteAssetBaseURL, remoteAssetURL, queryPath);
|
|
18897
18905
|
}
|
|
18898
|
-
return this._loadSubpackageAndMainAsset(loader, item, remoteAssetBaseURL,
|
|
18906
|
+
return this._loadSubpackageAndMainAsset(loader, item, remoteAssetBaseURL, subpackageName);
|
|
18899
18907
|
};
|
|
18900
18908
|
// For adapter mini-game platform
|
|
18901
|
-
_proto._loadSubpackageAndMainAsset = function _loadSubpackageAndMainAsset(loader, item, remoteAssetBaseURL,
|
|
18902
|
-
return this._loadMainAsset(loader, item, remoteAssetBaseURL
|
|
18909
|
+
_proto._loadSubpackageAndMainAsset = function _loadSubpackageAndMainAsset(loader, item, remoteAssetBaseURL, subpackageName) {
|
|
18910
|
+
return this._loadMainAsset(loader, item, remoteAssetBaseURL);
|
|
18903
18911
|
};
|
|
18904
|
-
_proto._loadMainAsset = function _loadMainAsset(loader, item, remoteAssetBaseURL
|
|
18912
|
+
_proto._loadMainAsset = function _loadMainAsset(loader, item, remoteAssetBaseURL) {
|
|
18905
18913
|
var _this = this;
|
|
18906
|
-
item.url = assetBaseURL;
|
|
18907
18914
|
var loadingPromises = this._loadingPromises;
|
|
18908
18915
|
var promise = loader.load(item, this);
|
|
18909
18916
|
loadingPromises[remoteAssetBaseURL] = promise;
|
|
@@ -19030,10 +19037,9 @@ var MultiExecutor = /*#__PURE__*/ function() {
|
|
|
19030
19037
|
return AssetPromise.resolve(null);
|
|
19031
19038
|
}
|
|
19032
19039
|
var loadUrl = key ? url + "?q=" + key : url;
|
|
19040
|
+
// type and params omitted: resolved from the virtualPath map, the single source of truth
|
|
19033
19041
|
var promise = this.load({
|
|
19034
|
-
url: loadUrl
|
|
19035
|
-
type: mapped.type,
|
|
19036
|
-
params: mapped.params
|
|
19042
|
+
url: loadUrl
|
|
19037
19043
|
});
|
|
19038
19044
|
return isClone ? promise.then(function(item) {
|
|
19039
19045
|
return item.clone();
|
|
@@ -20440,6 +20446,13 @@ __decorate([
|
|
|
20440
20446
|
this._phasedActiveInScene && this._nativeCollider.addForce(force);
|
|
20441
20447
|
};
|
|
20442
20448
|
/**
|
|
20449
|
+
* Apply a force to the DynamicCollider at a given position in world space.
|
|
20450
|
+
* @param force - The force to apply, in world space
|
|
20451
|
+
* @param position - The position where the force is applied, in world space
|
|
20452
|
+
*/ _proto.applyForceAtPosition = function applyForceAtPosition(force, position) {
|
|
20453
|
+
this._phasedActiveInScene && this._nativeCollider.addForceAtPosition(force, position);
|
|
20454
|
+
};
|
|
20455
|
+
/**
|
|
20443
20456
|
* Apply a torque to the DynamicCollider.
|
|
20444
20457
|
* @param torque - The force make the collider rotate
|
|
20445
20458
|
*/ _proto.applyTorque = function applyTorque(torque) {
|
|
@@ -26792,6 +26805,7 @@ CascadedShadowCasterPass._tempMatrix0 = new engineMath.Matrix();
|
|
|
26792
26805
|
depthOnlyPass.release();
|
|
26793
26806
|
camera.shaderData.setTexture(exports.Camera._cameraDepthTextureProperty, engine._basicResources.whiteTexture2D);
|
|
26794
26807
|
}
|
|
26808
|
+
var pool = engine._renderTargetPool;
|
|
26795
26809
|
// Check if need to create internal color texture or grab texture
|
|
26796
26810
|
if (independentCanvasEnabled) {
|
|
26797
26811
|
var depthFormat;
|
|
@@ -26807,26 +26821,12 @@ CascadedShadowCasterPass._tempMatrix0 = new engineMath.Matrix();
|
|
|
26807
26821
|
depthFormat = null;
|
|
26808
26822
|
}
|
|
26809
26823
|
var viewport = camera.pixelViewport;
|
|
26810
|
-
|
|
26824
|
+
this._internalColorTarget = pool.allocateRenderTarget(viewport.width, viewport.height, camera._getInternalColorTextureFormat(), depthFormat, false, false, !camera.enableHDR, msaaSamples, TextureWrapMode.Clamp, TextureFilterMode.Bilinear);
|
|
26811
26825
|
if (this._shouldCopyBackgroundColor) {
|
|
26812
26826
|
var _camera_renderTarget;
|
|
26813
26827
|
var colorTexture = (_camera_renderTarget = camera.renderTarget) == null ? void 0 : _camera_renderTarget.getColorTexture(0);
|
|
26814
26828
|
var _colorTexture_format, _colorTexture_isSRGBColorSpace;
|
|
26815
|
-
|
|
26816
|
-
this._copyBackgroundTexture = copyBackgroundTexture;
|
|
26817
|
-
}
|
|
26818
|
-
this._internalColorTarget = internalColorTarget;
|
|
26819
|
-
} else {
|
|
26820
|
-
var internalColorTarget1 = this._internalColorTarget;
|
|
26821
|
-
var copyBackgroundTexture1 = this._copyBackgroundTexture;
|
|
26822
|
-
var pool = engine._renderTargetPool;
|
|
26823
|
-
if (internalColorTarget1) {
|
|
26824
|
-
pool.freeRenderTarget(internalColorTarget1);
|
|
26825
|
-
this._internalColorTarget = null;
|
|
26826
|
-
}
|
|
26827
|
-
if (copyBackgroundTexture1) {
|
|
26828
|
-
pool.freeTexture(copyBackgroundTexture1);
|
|
26829
|
-
this._copyBackgroundTexture = null;
|
|
26829
|
+
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);
|
|
26830
26830
|
}
|
|
26831
26831
|
}
|
|
26832
26832
|
// Scalable ambient obscurance pass
|
|
@@ -26839,6 +26839,15 @@ CascadedShadowCasterPass._tempMatrix0 = new engineMath.Matrix();
|
|
|
26839
26839
|
this._saoPass.release();
|
|
26840
26840
|
}
|
|
26841
26841
|
this._drawRenderPass(context, camera, finalClearFlags, cubeFace, mipLevel);
|
|
26842
|
+
// Return the per-frame leases so the next camera with matching shape can reuse them
|
|
26843
|
+
if (this._internalColorTarget) {
|
|
26844
|
+
pool.freeRenderTarget(this._internalColorTarget);
|
|
26845
|
+
this._internalColorTarget = null;
|
|
26846
|
+
}
|
|
26847
|
+
if (this._copyBackgroundTexture) {
|
|
26848
|
+
pool.freeTexture(this._copyBackgroundTexture);
|
|
26849
|
+
this._copyBackgroundTexture = null;
|
|
26850
|
+
}
|
|
26842
26851
|
};
|
|
26843
26852
|
_proto._drawRenderPass = function _drawRenderPass(context, camera, finalClearFlags, cubeFace, mipLevel) {
|
|
26844
26853
|
var cullingResults = this._cullingResults;
|
|
@@ -27172,7 +27181,9 @@ var OverlayCamera = function OverlayCamera() {
|
|
|
27172
27181
|
_inherits(Engine, EventDispatcher);
|
|
27173
27182
|
function Engine(canvas, hardwareRenderer, configuration) {
|
|
27174
27183
|
var _this;
|
|
27175
|
-
_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.
|
|
27184
|
+
_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() {
|
|
27185
|
+
return _this._renderTargetPool.gc();
|
|
27186
|
+
}, _this._animate = function() {
|
|
27176
27187
|
if (_this._vSyncCount) {
|
|
27177
27188
|
var _this_xrManager;
|
|
27178
27189
|
var raf = ((_this_xrManager = _this.xrManager) == null ? void 0 : _this_xrManager._getRequestAnimationFrame()) || requestAnimationFrame;
|
|
@@ -27193,6 +27204,7 @@ var OverlayCamera = function OverlayCamera() {
|
|
|
27193
27204
|
_this._textDefaultFont.isGCIgnored = true;
|
|
27194
27205
|
_this._batcherManager = new BatcherManager(_this);
|
|
27195
27206
|
_this._renderTargetPool = new RenderTargetPool(_this);
|
|
27207
|
+
canvas._sizeUpdateFlagManager.addListener(_this._onCanvasResize);
|
|
27196
27208
|
_this.inputManager = new InputManager(_this, configuration.input);
|
|
27197
27209
|
var xrDevice = configuration.xrDevice;
|
|
27198
27210
|
if (xrDevice) {
|
|
@@ -27396,6 +27408,7 @@ var OverlayCamera = function OverlayCamera() {
|
|
|
27396
27408
|
var _this_xrManager;
|
|
27397
27409
|
this._destroyed = true;
|
|
27398
27410
|
this._waitingDestroy = false;
|
|
27411
|
+
this._canvas._sizeUpdateFlagManager.removeListener(this._onCanvasResize);
|
|
27399
27412
|
this._sceneManager._destroyAllScene();
|
|
27400
27413
|
this._resourceManager._destroy();
|
|
27401
27414
|
this.inputManager._destroy();
|
|
@@ -29730,7 +29743,7 @@ var PointerMethods = /*#__PURE__*/ function(PointerMethods) {
|
|
|
29730
29743
|
for(var _len = arguments.length, signalArgs = new Array(_len), _key = 0; _key < _len; _key++){
|
|
29731
29744
|
signalArgs[_key] = arguments[_key];
|
|
29732
29745
|
}
|
|
29733
|
-
return (_target = target)[methodName].apply(_target, [].concat(
|
|
29746
|
+
return (_target = target)[methodName].apply(_target, [].concat(signalArgs, args));
|
|
29734
29747
|
} : function() {
|
|
29735
29748
|
for(var _len = arguments.length, signalArgs = new Array(_len), _key = 0; _key < _len; _key++){
|
|
29736
29749
|
signalArgs[_key] = arguments[_key];
|
|
@@ -30164,7 +30177,7 @@ AnimationCurveOwner.registerAssembler(SkinnedMeshRenderer, "blendShapeWeights",
|
|
|
30164
30177
|
*/ var AnimationClipCurveBinding = /*#__PURE__*/ function() {
|
|
30165
30178
|
function AnimationClipCurveBinding() {
|
|
30166
30179
|
/** The index of the component that is animated. */ this.typeIndex = 0;
|
|
30167
|
-
this._tempCurveOwner =
|
|
30180
|
+
this._tempCurveOwner = new WeakMap();
|
|
30168
30181
|
}
|
|
30169
30182
|
var _proto = AnimationClipCurveBinding.prototype;
|
|
30170
30183
|
/**
|
|
@@ -30190,11 +30203,12 @@ AnimationCurveOwner.registerAssembler(SkinnedMeshRenderer, "blendShapeWeights",
|
|
|
30190
30203
|
/**
|
|
30191
30204
|
* @internal
|
|
30192
30205
|
*/ _proto._getTempCurveOwner = function _getTempCurveOwner(entity, component) {
|
|
30193
|
-
var
|
|
30194
|
-
if (!
|
|
30195
|
-
|
|
30206
|
+
var owner = this._tempCurveOwner.get(entity);
|
|
30207
|
+
if (!owner) {
|
|
30208
|
+
owner = this._createCurveOwner(entity, component);
|
|
30209
|
+
this._tempCurveOwner.set(entity, owner);
|
|
30196
30210
|
}
|
|
30197
|
-
return
|
|
30211
|
+
return owner;
|
|
30198
30212
|
};
|
|
30199
30213
|
return AnimationClipCurveBinding;
|
|
30200
30214
|
}();
|
|
@@ -30276,11 +30290,10 @@ AnimationCurveOwner.registerAssembler(SkinnedMeshRenderer, "blendShapeWeights",
|
|
|
30276
30290
|
this._length = 0;
|
|
30277
30291
|
};
|
|
30278
30292
|
/**
|
|
30279
|
-
* @internal
|
|
30280
30293
|
* Samples an animation at a given time.
|
|
30281
30294
|
* @param entity - The animated entity
|
|
30282
30295
|
* @param time - The time to sample an animation
|
|
30283
|
-
*/ _proto.
|
|
30296
|
+
*/ _proto.sampleAnimation = function sampleAnimation(entity, time) {
|
|
30284
30297
|
var _this = this, curveBindings = _this._curveBindings;
|
|
30285
30298
|
var components = AnimationCurveOwner._components;
|
|
30286
30299
|
for(var i = curveBindings.length - 1; i >= 0; i--){
|
|
@@ -31455,12 +31468,6 @@ var AnimatorLayerBlendingMode = /*#__PURE__*/ function(AnimatorLayerBlendingMode
|
|
|
31455
31468
|
return LayerState;
|
|
31456
31469
|
}({});
|
|
31457
31470
|
|
|
31458
|
-
/**
|
|
31459
|
-
* @internal
|
|
31460
|
-
*/ var AnimationEventHandler = function AnimationEventHandler() {
|
|
31461
|
-
this.handlers = [];
|
|
31462
|
-
};
|
|
31463
|
-
|
|
31464
31471
|
/**
|
|
31465
31472
|
* Animation wrap mode.
|
|
31466
31473
|
*/ var WrapMode = /*#__PURE__*/ function(WrapMode) {
|
|
@@ -31469,6 +31476,12 @@ var AnimatorLayerBlendingMode = /*#__PURE__*/ function(AnimatorLayerBlendingMode
|
|
|
31469
31476
|
return WrapMode;
|
|
31470
31477
|
}({});
|
|
31471
31478
|
|
|
31479
|
+
/**
|
|
31480
|
+
* @internal
|
|
31481
|
+
*/ var AnimationEventHandler = function AnimationEventHandler() {
|
|
31482
|
+
this.handlers = [];
|
|
31483
|
+
};
|
|
31484
|
+
|
|
31472
31485
|
/**
|
|
31473
31486
|
* @internal
|
|
31474
31487
|
*/ var AnimatorStatePlayData = /*#__PURE__*/ function() {
|
|
@@ -31509,19 +31522,21 @@ var AnimatorLayerBlendingMode = /*#__PURE__*/ function(AnimatorLayerBlendingMode
|
|
|
31509
31522
|
this.playedTime += deltaTime;
|
|
31510
31523
|
var instance = this.instance;
|
|
31511
31524
|
var state = instance._state;
|
|
31525
|
+
var clipLength = state.clip.length;
|
|
31526
|
+
var clipStartTime = state.clipStartTime;
|
|
31512
31527
|
var time = this.playedTime + this.offsetFrameTime;
|
|
31513
|
-
var duration = state.
|
|
31528
|
+
var duration = (state.clipEndTime - clipStartTime) * clipLength;
|
|
31514
31529
|
this.playState = AnimatorStatePlayState.Playing;
|
|
31515
31530
|
if (instance.wrapMode === WrapMode.Loop) {
|
|
31516
31531
|
time = duration ? time % duration : 0;
|
|
31517
|
-
} else {
|
|
31518
|
-
|
|
31519
|
-
|
|
31520
|
-
|
|
31521
|
-
|
|
31532
|
+
} else if (time >= duration || time <= -duration) {
|
|
31533
|
+
time = time < 0 ? -duration : duration;
|
|
31534
|
+
this.playState = AnimatorStatePlayState.Finished;
|
|
31535
|
+
}
|
|
31536
|
+
if (time < 0) {
|
|
31537
|
+
time += duration;
|
|
31522
31538
|
}
|
|
31523
|
-
|
|
31524
|
-
this.clipTime = time + state.clipStartTime * state.clip.length;
|
|
31539
|
+
this.clipTime = time + clipStartTime * clipLength;
|
|
31525
31540
|
if (this._changedOrientation) {
|
|
31526
31541
|
!this.isForward && this._correctTime();
|
|
31527
31542
|
this._changedOrientation = false;
|
|
@@ -31534,6 +31549,26 @@ var AnimatorLayerBlendingMode = /*#__PURE__*/ function(AnimatorLayerBlendingMode
|
|
|
31534
31549
|
this.clipTime = state.clipEndTime * state.clip.length;
|
|
31535
31550
|
}
|
|
31536
31551
|
};
|
|
31552
|
+
_create_class(AnimatorStatePlayData, [
|
|
31553
|
+
{
|
|
31554
|
+
key: "state",
|
|
31555
|
+
get: function get() {
|
|
31556
|
+
return this.instance._state;
|
|
31557
|
+
}
|
|
31558
|
+
},
|
|
31559
|
+
{
|
|
31560
|
+
key: "speed",
|
|
31561
|
+
get: function get() {
|
|
31562
|
+
return this.instance.speed;
|
|
31563
|
+
}
|
|
31564
|
+
},
|
|
31565
|
+
{
|
|
31566
|
+
key: "wrapMode",
|
|
31567
|
+
get: function get() {
|
|
31568
|
+
return this.instance.wrapMode;
|
|
31569
|
+
}
|
|
31570
|
+
}
|
|
31571
|
+
]);
|
|
31537
31572
|
return AnimatorStatePlayData;
|
|
31538
31573
|
}();
|
|
31539
31574
|
|
|
@@ -31712,8 +31747,8 @@ function _type_of(obj) {
|
|
|
31712
31747
|
* @internal
|
|
31713
31748
|
*/ var AnimatorLayerData = /*#__PURE__*/ function() {
|
|
31714
31749
|
function AnimatorLayerData() {
|
|
31715
|
-
this.curveOwnerPool =
|
|
31716
|
-
this.animatorStateDataMap = new
|
|
31750
|
+
this.curveOwnerPool = new WeakMap();
|
|
31751
|
+
this.animatorStateDataMap = new Map();
|
|
31717
31752
|
this.instanceMap = new WeakMap();
|
|
31718
31753
|
this.srcPlayData = null;
|
|
31719
31754
|
this.destPlayData = null;
|
|
@@ -31732,15 +31767,6 @@ function _type_of(obj) {
|
|
|
31732
31767
|
}
|
|
31733
31768
|
return instance;
|
|
31734
31769
|
};
|
|
31735
|
-
_proto.completeCrossFade = function completeCrossFade() {
|
|
31736
|
-
this.srcPlayData = this.destPlayData;
|
|
31737
|
-
this.destPlayData = null;
|
|
31738
|
-
this.crossFadeTransition = null;
|
|
31739
|
-
};
|
|
31740
|
-
_proto.clearCrossFadeSlot = function clearCrossFadeSlot() {
|
|
31741
|
-
this.destPlayData = null;
|
|
31742
|
-
this.crossFadeTransition = null;
|
|
31743
|
-
};
|
|
31744
31770
|
_proto.resetCurrentCheckIndex = function resetCurrentCheckIndex() {
|
|
31745
31771
|
this.layer.stateMachine._entryTransitionCollection.needResetCurrentCheckIndex = true;
|
|
31746
31772
|
this.layer.stateMachine._anyStateTransitionCollection.needResetCurrentCheckIndex = true;
|
|
@@ -31764,7 +31790,7 @@ function _type_of(obj) {
|
|
|
31764
31790
|
_inherits(Animator, Component);
|
|
31765
31791
|
function Animator(entity) {
|
|
31766
31792
|
var _this;
|
|
31767
|
-
_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 =
|
|
31793
|
+
_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 = {
|
|
31768
31794
|
layerIndex: -1,
|
|
31769
31795
|
state: null
|
|
31770
31796
|
}, _this._controlledRenderers = new Array();
|
|
@@ -31947,16 +31973,21 @@ function _type_of(obj) {
|
|
|
31947
31973
|
/**
|
|
31948
31974
|
* @internal
|
|
31949
31975
|
*/ _proto._reset = function _reset() {
|
|
31950
|
-
var
|
|
31951
|
-
for(var
|
|
31952
|
-
var
|
|
31953
|
-
|
|
31954
|
-
|
|
31955
|
-
|
|
31976
|
+
var layersData = this._animatorLayersData;
|
|
31977
|
+
for(var i = 0, n = layersData.length; i < n; i++){
|
|
31978
|
+
var layerData = layersData[i];
|
|
31979
|
+
if (!layerData) continue;
|
|
31980
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(layerData.animatorStateDataMap.values()), _step; !(_step = _iterator()).done;){
|
|
31981
|
+
var stateData = _step.value;
|
|
31982
|
+
var layerOwners = stateData.curveLayerOwner;
|
|
31983
|
+
for(var k = 0, l = layerOwners.length; k < l; k++){
|
|
31984
|
+
var _layerOwners_k_curveOwner, _layerOwners_k;
|
|
31985
|
+
(_layerOwners_k = layerOwners[k]) == null ? void 0 : (_layerOwners_k_curveOwner = _layerOwners_k.curveOwner) == null ? void 0 : _layerOwners_k_curveOwner.revertDefaultValue();
|
|
31986
|
+
}
|
|
31956
31987
|
}
|
|
31957
31988
|
}
|
|
31958
31989
|
this._animatorLayersData.length = 0;
|
|
31959
|
-
this._curveOwnerPool =
|
|
31990
|
+
this._curveOwnerPool = new WeakMap();
|
|
31960
31991
|
this._parametersValueMap = Object.create(null);
|
|
31961
31992
|
if (this._controllerUpdateFlag) {
|
|
31962
31993
|
this._controllerUpdateFlag.flag = false;
|
|
@@ -31979,6 +32010,7 @@ function _type_of(obj) {
|
|
|
31979
32010
|
};
|
|
31980
32011
|
_proto._onDestroy = function _onDestroy() {
|
|
31981
32012
|
Component.prototype._onDestroy.call(this);
|
|
32013
|
+
this._reset();
|
|
31982
32014
|
var controller = this._animatorController;
|
|
31983
32015
|
if (controller) {
|
|
31984
32016
|
var _this__controllerUpdateFlag;
|
|
@@ -31992,7 +32024,8 @@ function _type_of(obj) {
|
|
|
31992
32024
|
if (!state) {
|
|
31993
32025
|
return;
|
|
31994
32026
|
}
|
|
31995
|
-
var
|
|
32027
|
+
var animatorLayerData = this._getAnimatorLayerData(playLayerIndex);
|
|
32028
|
+
var manuallyTransition = animatorLayerData.manuallyTransition;
|
|
31996
32029
|
manuallyTransition.duration = duration;
|
|
31997
32030
|
manuallyTransition.offset = normalizedTimeOffset;
|
|
31998
32031
|
manuallyTransition.isFixedDuration = isFixedDuration;
|
|
@@ -32047,20 +32080,30 @@ function _type_of(obj) {
|
|
|
32047
32080
|
var relativePath = curve.relativePath;
|
|
32048
32081
|
var targetEntity = curve.relativePath === "" ? entity : entity.findByPath(curve.relativePath);
|
|
32049
32082
|
if (targetEntity) {
|
|
32050
|
-
var
|
|
32083
|
+
var _layerPropertyOwners, _property;
|
|
32051
32084
|
var component = curve.typeIndex > 0 ? targetEntity.getComponents(curve.type, components)[curve.typeIndex] : targetEntity.getComponent(curve.type);
|
|
32052
32085
|
components.length = 0;
|
|
32053
32086
|
if (!component) {
|
|
32054
32087
|
continue;
|
|
32055
32088
|
}
|
|
32056
32089
|
var property = curve.property;
|
|
32057
|
-
|
|
32058
|
-
|
|
32059
|
-
|
|
32060
|
-
|
|
32061
|
-
|
|
32062
|
-
|
|
32063
|
-
var
|
|
32090
|
+
// Key owner lookup by Component identity instead of instanceId.
|
|
32091
|
+
var propertyOwners = curveOwnerPool.get(component);
|
|
32092
|
+
if (!propertyOwners) {
|
|
32093
|
+
propertyOwners = Object.create(null);
|
|
32094
|
+
curveOwnerPool.set(component, propertyOwners);
|
|
32095
|
+
}
|
|
32096
|
+
var owner = propertyOwners[property];
|
|
32097
|
+
if (!owner) {
|
|
32098
|
+
owner = curve._createCurveOwner(targetEntity, component);
|
|
32099
|
+
propertyOwners[property] = owner;
|
|
32100
|
+
}
|
|
32101
|
+
var layerPropertyOwners = layerCurveOwnerPool.get(component);
|
|
32102
|
+
if (!layerPropertyOwners) {
|
|
32103
|
+
layerPropertyOwners = Object.create(null);
|
|
32104
|
+
layerCurveOwnerPool.set(component, layerPropertyOwners);
|
|
32105
|
+
}
|
|
32106
|
+
var layerOwner = (_layerPropertyOwners = layerPropertyOwners)[_property = property] || (_layerPropertyOwners[_property] = curve._createCurveLayerOwner(owner));
|
|
32064
32107
|
if (mask && mask.pathMasks.length) {
|
|
32065
32108
|
var _mask_getPathMask;
|
|
32066
32109
|
var _mask_getPathMask_active;
|
|
@@ -32074,8 +32117,6 @@ function _type_of(obj) {
|
|
|
32074
32117
|
}
|
|
32075
32118
|
};
|
|
32076
32119
|
_proto._ensureEventHandlers = function _ensureEventHandlers(state, animatorStateData) {
|
|
32077
|
-
// state._updateFlagManager dispatches on both clip-swap and clip-events-mutation,
|
|
32078
|
-
// so its version covers every input that affects eventHandlers binding
|
|
32079
32120
|
var stateVersion = state._updateFlagManager.version;
|
|
32080
32121
|
var scriptsVersion = this._entity._scriptsVersion;
|
|
32081
32122
|
if (animatorStateData.eventsBuiltVersion === stateVersion && animatorStateData.eventsBuiltScriptsVersion === scriptsVersion) {
|
|
@@ -32199,8 +32240,8 @@ function _type_of(obj) {
|
|
|
32199
32240
|
};
|
|
32200
32241
|
_proto._updatePlayingState = function _updatePlayingState(layerData, weight, additive, deltaTime, aniUpdate) {
|
|
32201
32242
|
var srcPlayData = layerData.srcPlayData;
|
|
32202
|
-
var state = srcPlayData.
|
|
32203
|
-
var playSpeed = srcPlayData.
|
|
32243
|
+
var state = srcPlayData.state;
|
|
32244
|
+
var playSpeed = srcPlayData.speed * this.speed;
|
|
32204
32245
|
var playDeltaTime = playSpeed * deltaTime;
|
|
32205
32246
|
srcPlayData.updateOrientation(playDeltaTime);
|
|
32206
32247
|
var lastClipTime = srcPlayData.clipTime, lastPlayState = srcPlayData.playState;
|
|
@@ -32244,14 +32285,13 @@ function _type_of(obj) {
|
|
|
32244
32285
|
this._evaluatePlayingState(srcPlayData, weight, additive, aniUpdate);
|
|
32245
32286
|
this._fireAnimationEventsAndCallScripts(layerData.layerIndex, srcPlayData, state, lastClipTime, lastPlayState, playCostTime);
|
|
32246
32287
|
if (transition) {
|
|
32247
|
-
// Remove speed factor, use actual cost time
|
|
32248
|
-
// state is paused, so it consumes no time — pass deltaTime through to the destination.
|
|
32288
|
+
// Remove speed factor, use actual cost time
|
|
32249
32289
|
var remainDeltaTime = playSpeed === 0 ? deltaTime : deltaTime - playCostTime / playSpeed;
|
|
32250
32290
|
remainDeltaTime > 0 && this._updateState(layerData, remainDeltaTime, aniUpdate);
|
|
32251
32291
|
}
|
|
32252
32292
|
};
|
|
32253
32293
|
_proto._evaluatePlayingState = function _evaluatePlayingState(playData, weight, additive, aniUpdate) {
|
|
32254
|
-
var curveBindings = playData.
|
|
32294
|
+
var curveBindings = playData.state.clip._curveBindings;
|
|
32255
32295
|
var finished = playData.playState === AnimatorStatePlayState.Finished;
|
|
32256
32296
|
if (aniUpdate || finished) {
|
|
32257
32297
|
var curveLayerOwner = playData.stateData.curveLayerOwner;
|
|
@@ -32274,14 +32314,14 @@ function _type_of(obj) {
|
|
|
32274
32314
|
_proto._updateCrossFadeState = function _updateCrossFadeState(layerData, weight, additive, deltaTime, aniUpdate) {
|
|
32275
32315
|
var srcPlayData = layerData.srcPlayData, destPlayData = layerData.destPlayData, layerIndex = layerData.layerIndex;
|
|
32276
32316
|
var speed = this.speed;
|
|
32277
|
-
var srcState = srcPlayData.
|
|
32278
|
-
var destState = destPlayData.
|
|
32317
|
+
var srcState = srcPlayData.state;
|
|
32318
|
+
var destState = destPlayData.state;
|
|
32279
32319
|
var transitionDuration = layerData.crossFadeTransition._getFixedDuration();
|
|
32280
32320
|
if (this._tryCrossFadeInterrupt(layerData, transitionDuration, destState, deltaTime, aniUpdate)) {
|
|
32281
32321
|
return;
|
|
32282
32322
|
}
|
|
32283
|
-
var srcPlaySpeed = srcPlayData.
|
|
32284
|
-
var dstPlaySpeed = destPlayData.
|
|
32323
|
+
var srcPlaySpeed = srcPlayData.speed * speed;
|
|
32324
|
+
var dstPlaySpeed = destPlayData.speed * speed;
|
|
32285
32325
|
var dstPlayDeltaTime = dstPlaySpeed * deltaTime;
|
|
32286
32326
|
srcPlayData.updateOrientation(srcPlaySpeed * deltaTime);
|
|
32287
32327
|
destPlayData.updateOrientation(dstPlayDeltaTime);
|
|
@@ -32324,8 +32364,8 @@ function _type_of(obj) {
|
|
|
32324
32364
|
};
|
|
32325
32365
|
_proto._evaluateCrossFadeState = function _evaluateCrossFadeState(layerData, srcPlayData, destPlayData, weight, crossWeight, additive, aniUpdate) {
|
|
32326
32366
|
var crossLayerOwnerCollection = layerData.crossLayerOwnerCollection;
|
|
32327
|
-
var
|
|
32328
|
-
var destState = destPlayData.
|
|
32367
|
+
var _srcPlayData_state_clip = srcPlayData.state.clip, srcCurves = _srcPlayData_state_clip._curveBindings;
|
|
32368
|
+
var destState = destPlayData.state;
|
|
32329
32369
|
var _destState_clip = destState.clip, destCurves = _destState_clip._curveBindings;
|
|
32330
32370
|
var finished = destPlayData.playState === AnimatorStatePlayState.Finished;
|
|
32331
32371
|
if (aniUpdate || finished) {
|
|
@@ -32344,12 +32384,12 @@ function _type_of(obj) {
|
|
|
32344
32384
|
};
|
|
32345
32385
|
_proto._updateCrossFadeFromPoseState = function _updateCrossFadeFromPoseState(layerData, weight, additive, deltaTime, aniUpdate) {
|
|
32346
32386
|
var destPlayData = layerData.destPlayData;
|
|
32347
|
-
var state = destPlayData.
|
|
32387
|
+
var state = destPlayData.state;
|
|
32348
32388
|
var transitionDuration = layerData.crossFadeTransition._getFixedDuration();
|
|
32349
32389
|
if (this._tryCrossFadeInterrupt(layerData, transitionDuration, state, deltaTime, aniUpdate)) {
|
|
32350
32390
|
return;
|
|
32351
32391
|
}
|
|
32352
|
-
var playSpeed = destPlayData.
|
|
32392
|
+
var playSpeed = destPlayData.speed * this.speed;
|
|
32353
32393
|
var playDeltaTime = playSpeed * deltaTime;
|
|
32354
32394
|
destPlayData.updateOrientation(playDeltaTime);
|
|
32355
32395
|
var lastDestClipTime = destPlayData.clipTime, lastPlayState = destPlayData.playState;
|
|
@@ -32386,7 +32426,7 @@ function _type_of(obj) {
|
|
|
32386
32426
|
};
|
|
32387
32427
|
_proto._evaluateCrossFadeFromPoseState = function _evaluateCrossFadeFromPoseState(layerData, destPlayData, weight, crossWeight, additive, aniUpdate) {
|
|
32388
32428
|
var crossLayerOwnerCollection = layerData.crossLayerOwnerCollection;
|
|
32389
|
-
var state = destPlayData.
|
|
32429
|
+
var state = destPlayData.state;
|
|
32390
32430
|
var _state_clip = state.clip, curveBindings = _state_clip._curveBindings;
|
|
32391
32431
|
var destClipTime = destPlayData.clipTime, playState = destPlayData.playState;
|
|
32392
32432
|
var finished = playState === AnimatorStatePlayState.Finished;
|
|
@@ -32398,7 +32438,7 @@ function _type_of(obj) {
|
|
|
32398
32438
|
if (!owner) continue;
|
|
32399
32439
|
var curveIndex = layerOwner.crossDestCurveIndex;
|
|
32400
32440
|
this._checkRevertOwner(owner, additive);
|
|
32401
|
-
var value =
|
|
32441
|
+
var value = owner.crossFadeFromPoseAndApplyValue(curveIndex >= 0 ? curveBindings[curveIndex].curve : null, destClipTime, crossWeight, additive);
|
|
32402
32442
|
aniUpdate && owner.applyValue(value, weight, additive);
|
|
32403
32443
|
finished && layerOwner.saveFinalValue();
|
|
32404
32444
|
}
|
|
@@ -32406,8 +32446,8 @@ function _type_of(obj) {
|
|
|
32406
32446
|
};
|
|
32407
32447
|
_proto._updateFinishedState = function _updateFinishedState(layerData, weight, additive, deltaTime, aniUpdate) {
|
|
32408
32448
|
var playData = layerData.srcPlayData;
|
|
32409
|
-
var state = playData.
|
|
32410
|
-
var actualSpeed = playData.
|
|
32449
|
+
var state = playData.state;
|
|
32450
|
+
var actualSpeed = playData.speed * this.speed;
|
|
32411
32451
|
var actualDeltaTime = actualSpeed * deltaTime;
|
|
32412
32452
|
playData.updateOrientation(actualDeltaTime);
|
|
32413
32453
|
var clipTime = playData.clipTime, isForward = playData.isForward;
|
|
@@ -32425,7 +32465,7 @@ function _type_of(obj) {
|
|
|
32425
32465
|
return;
|
|
32426
32466
|
}
|
|
32427
32467
|
var curveLayerOwner = playData.stateData.curveLayerOwner;
|
|
32428
|
-
var
|
|
32468
|
+
var _playData_state_clip = playData.state.clip, curveBindings = _playData_state_clip._curveBindings;
|
|
32429
32469
|
for(var i = curveBindings.length - 1; i >= 0; i--){
|
|
32430
32470
|
var layerOwner = curveLayerOwner[i];
|
|
32431
32471
|
var owner = layerOwner == null ? void 0 : layerOwner.curveOwner;
|
|
@@ -32441,12 +32481,14 @@ function _type_of(obj) {
|
|
|
32441
32481
|
} else {
|
|
32442
32482
|
layerData.layerState = LayerState.Playing;
|
|
32443
32483
|
}
|
|
32444
|
-
layerData.
|
|
32484
|
+
layerData.srcPlayData = destPlayData;
|
|
32485
|
+
layerData.destPlayData = null;
|
|
32486
|
+
layerData.crossFadeTransition = null;
|
|
32445
32487
|
};
|
|
32446
32488
|
_proto._preparePlayOwner = function _preparePlayOwner(layerData, playState) {
|
|
32447
32489
|
if (layerData.layerState === LayerState.Playing) {
|
|
32448
32490
|
var srcPlayData = layerData.srcPlayData;
|
|
32449
|
-
if (srcPlayData.
|
|
32491
|
+
if (srcPlayData.state !== playState) {
|
|
32450
32492
|
var curveLayerOwner = srcPlayData.stateData.curveLayerOwner;
|
|
32451
32493
|
for(var i = curveLayerOwner.length - 1; i >= 0; i--){
|
|
32452
32494
|
var _curveLayerOwner_i;
|
|
@@ -32461,17 +32503,17 @@ function _type_of(obj) {
|
|
|
32461
32503
|
}
|
|
32462
32504
|
};
|
|
32463
32505
|
_proto._applyStateTransitions = function _applyStateTransitions(layerData, isForward, playData, transitionCollection, lastClipTime, clipTime, deltaTime, aniUpdate) {
|
|
32464
|
-
var state = playData.
|
|
32465
|
-
var clipDuration = state.clip.length;
|
|
32506
|
+
var state = playData.state;
|
|
32466
32507
|
var targetTransition = null;
|
|
32467
|
-
var startTime = state.clipStartTime * clipDuration;
|
|
32468
|
-
var endTime = state.clipEndTime * clipDuration;
|
|
32469
32508
|
if (transitionCollection.noExitTimeCount) {
|
|
32470
32509
|
targetTransition = this._checkNoExitTimeTransitions(layerData, transitionCollection, aniUpdate);
|
|
32471
32510
|
if (targetTransition) {
|
|
32472
32511
|
return targetTransition;
|
|
32473
32512
|
}
|
|
32474
32513
|
}
|
|
32514
|
+
var clipDuration = state.clip.length;
|
|
32515
|
+
var startTime = state.clipStartTime * clipDuration;
|
|
32516
|
+
var endTime = state.clipEndTime * clipDuration;
|
|
32475
32517
|
if (isForward) {
|
|
32476
32518
|
if (lastClipTime + deltaTime >= endTime) {
|
|
32477
32519
|
targetTransition = this._checkSubTransition(layerData, state, transitionCollection, lastClipTime, endTime, aniUpdate);
|
|
@@ -32578,9 +32620,8 @@ function _type_of(obj) {
|
|
|
32578
32620
|
var playData = animatorLayerData.getOrCreateInstance(state)._playData;
|
|
32579
32621
|
playData.reset(animatorStateData, state._getClipActualEndTime() * normalizedTimeOffset);
|
|
32580
32622
|
animatorLayerData.srcPlayData = playData;
|
|
32581
|
-
|
|
32582
|
-
|
|
32583
|
-
animatorLayerData.clearCrossFadeSlot();
|
|
32623
|
+
animatorLayerData.destPlayData = null;
|
|
32624
|
+
animatorLayerData.crossFadeTransition = null;
|
|
32584
32625
|
animatorLayerData.resetCurrentCheckIndex();
|
|
32585
32626
|
return true;
|
|
32586
32627
|
};
|
|
@@ -32664,9 +32705,7 @@ function _type_of(obj) {
|
|
|
32664
32705
|
return false;
|
|
32665
32706
|
}
|
|
32666
32707
|
var animatorLayerData = this._getAnimatorLayerData(layerIndex);
|
|
32667
|
-
|
|
32668
|
-
// instance per layer, so a second concurrent fade has nowhere to live.
|
|
32669
|
-
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) {
|
|
32708
|
+
if (((_animatorLayerData_srcPlayData = animatorLayerData.srcPlayData) == null ? void 0 : _animatorLayerData_srcPlayData.state) === crossState || ((_animatorLayerData_destPlayData = animatorLayerData.destPlayData) == null ? void 0 : _animatorLayerData_destPlayData.state) === crossState) {
|
|
32670
32709
|
return false;
|
|
32671
32710
|
}
|
|
32672
32711
|
var animatorStateData = this._getAnimatorStateData(crossState, animatorLayerData, layerIndex);
|
|
@@ -32698,23 +32737,27 @@ function _type_of(obj) {
|
|
|
32698
32737
|
return true;
|
|
32699
32738
|
};
|
|
32700
32739
|
_proto._fireAnimationEvents = function _fireAnimationEvents(playData, eventHandlers, lastClipTime, deltaTime) {
|
|
32701
|
-
var isForward = playData.isForward, clipTime = playData.clipTime;
|
|
32702
|
-
var state = playData.instance._state;
|
|
32740
|
+
var state = playData.state, isForward = playData.isForward, clipTime = playData.clipTime, wrapMode = playData.wrapMode;
|
|
32703
32741
|
var startTime = state._getClipActualStartTime();
|
|
32704
32742
|
var endTime = state._getClipActualEndTime();
|
|
32743
|
+
var canWrap = wrapMode === WrapMode.Loop;
|
|
32705
32744
|
if (isForward) {
|
|
32706
32745
|
if (lastClipTime + deltaTime >= endTime) {
|
|
32707
32746
|
this._fireSubAnimationEvents(playData, eventHandlers, lastClipTime, endTime);
|
|
32708
|
-
|
|
32709
|
-
|
|
32747
|
+
if (canWrap) {
|
|
32748
|
+
playData.currentEventIndex = 0;
|
|
32749
|
+
this._fireSubAnimationEvents(playData, eventHandlers, startTime, clipTime);
|
|
32750
|
+
}
|
|
32710
32751
|
} else {
|
|
32711
32752
|
this._fireSubAnimationEvents(playData, eventHandlers, lastClipTime, clipTime);
|
|
32712
32753
|
}
|
|
32713
32754
|
} else {
|
|
32714
32755
|
if (lastClipTime + deltaTime <= startTime) {
|
|
32715
32756
|
this._fireBackwardSubAnimationEvents(playData, eventHandlers, lastClipTime, startTime);
|
|
32716
|
-
|
|
32717
|
-
|
|
32757
|
+
if (canWrap) {
|
|
32758
|
+
playData.currentEventIndex = eventHandlers.length - 1;
|
|
32759
|
+
this._fireBackwardSubAnimationEvents(playData, eventHandlers, endTime, clipTime);
|
|
32760
|
+
}
|
|
32718
32761
|
} else {
|
|
32719
32762
|
this._fireBackwardSubAnimationEvents(playData, eventHandlers, lastClipTime, clipTime);
|
|
32720
32763
|
}
|
|
@@ -32730,8 +32773,10 @@ function _type_of(obj) {
|
|
|
32730
32773
|
}
|
|
32731
32774
|
var handlers = eventHandler.handlers;
|
|
32732
32775
|
if (time >= lastClipTime) {
|
|
32733
|
-
|
|
32734
|
-
handlers
|
|
32776
|
+
if (this.fireEvents) {
|
|
32777
|
+
for(var j = handlers.length - 1; j >= 0; j--){
|
|
32778
|
+
handlers[j](parameter);
|
|
32779
|
+
}
|
|
32735
32780
|
}
|
|
32736
32781
|
playState.currentEventIndex = Math.min(eventIndex + 1, n - 1);
|
|
32737
32782
|
}
|
|
@@ -32747,8 +32792,10 @@ function _type_of(obj) {
|
|
|
32747
32792
|
}
|
|
32748
32793
|
if (time <= lastClipTime) {
|
|
32749
32794
|
var handlers = eventHandler.handlers;
|
|
32750
|
-
|
|
32751
|
-
handlers
|
|
32795
|
+
if (this.fireEvents) {
|
|
32796
|
+
for(var j = handlers.length - 1; j >= 0; j--){
|
|
32797
|
+
handlers[j](parameter);
|
|
32798
|
+
}
|
|
32752
32799
|
}
|
|
32753
32800
|
playState.currentEventIndex = Math.max(eventIndex - 1, 0);
|
|
32754
32801
|
}
|
|
@@ -32779,9 +32826,6 @@ function _type_of(obj) {
|
|
|
32779
32826
|
owner.updateMark = this._updateMark;
|
|
32780
32827
|
};
|
|
32781
32828
|
_proto._fireAnimationEventsAndCallScripts = function _fireAnimationEventsAndCallScripts(layerIndex, playData, state, lastClipTime, lastPlayState, deltaTime) {
|
|
32782
|
-
// Re-check whether the clip events/scripts changed since the last build —
|
|
32783
|
-
// play()/crossFade() entry points already ensure on enter, but addEvent()
|
|
32784
|
-
// or addComponent(Script) after play() must also flow through.
|
|
32785
32829
|
this._ensureEventHandlers(state, playData.stateData);
|
|
32786
32830
|
var eventHandlers = playData.stateData.eventHandlers;
|
|
32787
32831
|
eventHandlers.length && this._fireAnimationEvents(playData, eventHandlers, lastClipTime, deltaTime);
|
|
@@ -32849,6 +32893,9 @@ Animator._tempScripts = [];
|
|
|
32849
32893
|
__decorate([
|
|
32850
32894
|
assignmentClone
|
|
32851
32895
|
], Animator.prototype, "speed", void 0);
|
|
32896
|
+
__decorate([
|
|
32897
|
+
assignmentClone
|
|
32898
|
+
], Animator.prototype, "fireEvents", void 0);
|
|
32852
32899
|
__decorate([
|
|
32853
32900
|
assignmentClone
|
|
32854
32901
|
], Animator.prototype, "_animatorController", void 0);
|
|
@@ -32920,7 +32967,10 @@ function _assert_this_initialized(self) {
|
|
|
32920
32967
|
/** @internal */ _this._parametersMap = {},
|
|
32921
32968
|
/** @internal */ _this._layers = [],
|
|
32922
32969
|
/** @internal */ _this._layersMap = {},
|
|
32923
|
-
_this._updateFlagManager = new UpdateFlagManager()
|
|
32970
|
+
_this._updateFlagManager = new UpdateFlagManager(),
|
|
32971
|
+
_this._onStatesInvalidate = function() {
|
|
32972
|
+
return _this._updateFlagManager.dispatch();
|
|
32973
|
+
}
|
|
32924
32974
|
][0];
|
|
32925
32975
|
return _assert_this_initialized(_this);
|
|
32926
32976
|
}
|
|
@@ -32975,6 +33025,7 @@ function _assert_this_initialized(self) {
|
|
|
32975
33025
|
*/ _proto.addLayer = function addLayer(layer) {
|
|
32976
33026
|
this._layers.push(layer);
|
|
32977
33027
|
this._layersMap[layer.name] = layer;
|
|
33028
|
+
layer._setStatesInvalidateCallback(this._onStatesInvalidate);
|
|
32978
33029
|
layer._setEngine(this._engine);
|
|
32979
33030
|
this._updateFlagManager.dispatch();
|
|
32980
33031
|
};
|
|
@@ -32984,13 +33035,18 @@ function _assert_this_initialized(self) {
|
|
|
32984
33035
|
*/ _proto.removeLayer = function removeLayer(layerIndex) {
|
|
32985
33036
|
var theLayer = this.layers[layerIndex];
|
|
32986
33037
|
this._layers.splice(layerIndex, 1);
|
|
33038
|
+
theLayer._setStatesInvalidateCallback(null);
|
|
32987
33039
|
delete this._layersMap[theLayer.name];
|
|
32988
33040
|
this._updateFlagManager.dispatch();
|
|
32989
33041
|
};
|
|
32990
33042
|
/**
|
|
32991
33043
|
* Clear layers.
|
|
32992
33044
|
*/ _proto.clearLayers = function clearLayers() {
|
|
32993
|
-
this
|
|
33045
|
+
var _this = this, layers = _this._layers;
|
|
33046
|
+
for(var i = 0, n = layers.length; i < n; i++){
|
|
33047
|
+
layers[i]._setStatesInvalidateCallback(null);
|
|
33048
|
+
}
|
|
33049
|
+
layers.length = 0;
|
|
32994
33050
|
for(var name in this._layersMap){
|
|
32995
33051
|
delete this._layersMap[name];
|
|
32996
33052
|
}
|
|
@@ -33006,7 +33062,9 @@ function _assert_this_initialized(self) {
|
|
|
33006
33062
|
*/ _proto._setEngine = function _setEngine(engine) {
|
|
33007
33063
|
var _this = this, layers = _this._layers;
|
|
33008
33064
|
for(var i = 0, n = layers.length; i < n; i++){
|
|
33009
|
-
layers[i]
|
|
33065
|
+
var layer = layers[i];
|
|
33066
|
+
layer._setStatesInvalidateCallback(this._onStatesInvalidate);
|
|
33067
|
+
layer._setEngine(engine);
|
|
33010
33068
|
}
|
|
33011
33069
|
};
|
|
33012
33070
|
_proto._addParameter = function _addParameter(name, defaultValue, isTrigger) {
|
|
@@ -33393,6 +33451,7 @@ function _assert_this_initialized(self) {
|
|
|
33393
33451
|
*/ var AnimatorStateMachine = /*#__PURE__*/ function() {
|
|
33394
33452
|
function AnimatorStateMachine() {
|
|
33395
33453
|
/** The list of states. */ this.states = [];
|
|
33454
|
+
this._onStatesInvalidate = null;
|
|
33396
33455
|
/**
|
|
33397
33456
|
* The state will be played automatically.
|
|
33398
33457
|
* @remarks When the Animator's AnimatorController changed or the Animator's onEnable be triggered. Cleared to `null` if the state is removed via `removeState`.
|
|
@@ -33429,6 +33488,7 @@ function _assert_this_initialized(self) {
|
|
|
33429
33488
|
if (this.defaultState === state) {
|
|
33430
33489
|
this.defaultState = null;
|
|
33431
33490
|
}
|
|
33491
|
+
this._onStatesInvalidate == null ? void 0 : this._onStatesInvalidate.call(this);
|
|
33432
33492
|
}
|
|
33433
33493
|
};
|
|
33434
33494
|
/**
|
|
@@ -33488,6 +33548,11 @@ function _assert_this_initialized(self) {
|
|
|
33488
33548
|
states[i]._setEngine(engine);
|
|
33489
33549
|
}
|
|
33490
33550
|
};
|
|
33551
|
+
/**
|
|
33552
|
+
* @internal
|
|
33553
|
+
*/ _proto._setStatesInvalidateCallback = function _setStatesInvalidateCallback(onStatesInvalidate) {
|
|
33554
|
+
this._onStatesInvalidate = onStatesInvalidate;
|
|
33555
|
+
};
|
|
33491
33556
|
_create_class(AnimatorStateMachine, [
|
|
33492
33557
|
{
|
|
33493
33558
|
key: "entryTransitions",
|
|
@@ -33516,14 +33581,43 @@ function _assert_this_initialized(self) {
|
|
|
33516
33581
|
this.name = name;
|
|
33517
33582
|
this./** The blending weight that the layers has. It is not taken into account for the first layer. */ weight = 1.0;
|
|
33518
33583
|
this./** The blending mode used by the layer. It is not taken into account for the first layer. */ blendingMode = AnimatorLayerBlendingMode.Override;
|
|
33519
|
-
this.
|
|
33584
|
+
this._onStatesInvalidate = null;
|
|
33585
|
+
this._stateMachine = new AnimatorStateMachine();
|
|
33520
33586
|
}
|
|
33521
33587
|
var _proto = AnimatorControllerLayer.prototype;
|
|
33522
33588
|
/**
|
|
33523
33589
|
* @internal
|
|
33524
33590
|
*/ _proto._setEngine = function _setEngine(engine) {
|
|
33525
|
-
this.
|
|
33591
|
+
this._engine = engine;
|
|
33592
|
+
this._stateMachine._setEngine(engine);
|
|
33526
33593
|
};
|
|
33594
|
+
/**
|
|
33595
|
+
* @internal
|
|
33596
|
+
*/ _proto._setStatesInvalidateCallback = function _setStatesInvalidateCallback(onStatesInvalidate) {
|
|
33597
|
+
this._onStatesInvalidate = onStatesInvalidate;
|
|
33598
|
+
this._stateMachine._setStatesInvalidateCallback(onStatesInvalidate);
|
|
33599
|
+
};
|
|
33600
|
+
_create_class(AnimatorControllerLayer, [
|
|
33601
|
+
{
|
|
33602
|
+
key: "stateMachine",
|
|
33603
|
+
get: /**
|
|
33604
|
+
* The state machine for the layer.
|
|
33605
|
+
*/ function get() {
|
|
33606
|
+
return this._stateMachine;
|
|
33607
|
+
},
|
|
33608
|
+
set: function set(value) {
|
|
33609
|
+
var lastStateMachine = this._stateMachine;
|
|
33610
|
+
if (lastStateMachine === value) {
|
|
33611
|
+
return;
|
|
33612
|
+
}
|
|
33613
|
+
lastStateMachine._setStatesInvalidateCallback(null);
|
|
33614
|
+
this._stateMachine = value;
|
|
33615
|
+
value._setStatesInvalidateCallback(this._onStatesInvalidate);
|
|
33616
|
+
this._engine && value._setEngine(this._engine);
|
|
33617
|
+
this._onStatesInvalidate == null ? void 0 : this._onStatesInvalidate.call(this);
|
|
33618
|
+
}
|
|
33619
|
+
}
|
|
33620
|
+
]);
|
|
33527
33621
|
return AnimatorControllerLayer;
|
|
33528
33622
|
}();
|
|
33529
33623
|
|
|
@@ -33892,8 +33986,10 @@ var ParticleStopMode = /*#__PURE__*/ function(ParticleStopMode) {
|
|
|
33892
33986
|
/**
|
|
33893
33987
|
* @internal
|
|
33894
33988
|
*/ _proto._onEnable = function _onEnable() {
|
|
33895
|
-
|
|
33896
|
-
|
|
33989
|
+
var generator = this.generator;
|
|
33990
|
+
generator._setTransformFeedback();
|
|
33991
|
+
if (generator.main.playOnEnabled) {
|
|
33992
|
+
generator.play(false);
|
|
33897
33993
|
}
|
|
33898
33994
|
};
|
|
33899
33995
|
/**
|
|
@@ -34488,6 +34584,14 @@ ParticleTransformFeedbackSimulator._deltaTimeProperty = ShaderProperty.getByName
|
|
|
34488
34584
|
return ParticleGradientMode;
|
|
34489
34585
|
}({});
|
|
34490
34586
|
|
|
34587
|
+
/**
|
|
34588
|
+
* Particle sub emitter trigger type.
|
|
34589
|
+
*/ var ParticleSubEmitterType = /*#__PURE__*/ function(ParticleSubEmitterType) {
|
|
34590
|
+
/** Triggered when a parent particle is born. */ ParticleSubEmitterType[ParticleSubEmitterType["Birth"] = 0] = "Birth";
|
|
34591
|
+
/** Triggered when a parent particle dies (lifetime expired). */ ParticleSubEmitterType[ParticleSubEmitterType["Death"] = 1] = "Death";
|
|
34592
|
+
return ParticleSubEmitterType;
|
|
34593
|
+
}({});
|
|
34594
|
+
|
|
34491
34595
|
/**
|
|
34492
34596
|
* @internal
|
|
34493
34597
|
*/ var ParticleRandomSubSeeds = /*#__PURE__*/ function(ParticleRandomSubSeeds) {
|
|
@@ -34509,6 +34613,7 @@ ParticleTransformFeedbackSimulator._deltaTimeProperty = ShaderProperty.getByName
|
|
|
34509
34613
|
ParticleRandomSubSeeds[ParticleRandomSubSeeds["ForceOverLifetime"] = 3875246972] = "ForceOverLifetime";
|
|
34510
34614
|
ParticleRandomSubSeeds[ParticleRandomSubSeeds["LimitVelocityOverLifetime"] = 3047300990] = "LimitVelocityOverLifetime";
|
|
34511
34615
|
ParticleRandomSubSeeds[ParticleRandomSubSeeds["Noise"] = 4105357473] = "Noise";
|
|
34616
|
+
ParticleRandomSubSeeds[ParticleRandomSubSeeds["SubEmitter"] = 2622110509] = "SubEmitter";
|
|
34512
34617
|
ParticleRandomSubSeeds[ParticleRandomSubSeeds["EmissionRate"] = 2625893077] = "EmissionRate";
|
|
34513
34618
|
return ParticleRandomSubSeeds;
|
|
34514
34619
|
}({});
|
|
@@ -34578,6 +34683,12 @@ ParticleTransformFeedbackSimulator._deltaTimeProperty = ShaderProperty.getByName
|
|
|
34578
34683
|
* @param colorKeys - The color keys
|
|
34579
34684
|
* @param alphaKeys - The alpha keys
|
|
34580
34685
|
*/ _proto.setKeys = function setKeys(colorKeys, alphaKeys) {
|
|
34686
|
+
if (colorKeys.length > 4) {
|
|
34687
|
+
throw new Error("Gradient can only have 4 color keys");
|
|
34688
|
+
}
|
|
34689
|
+
if (alphaKeys.length > 4) {
|
|
34690
|
+
throw new Error("Gradient can only have 4 alpha keys");
|
|
34691
|
+
}
|
|
34581
34692
|
var currentColorKeys = this._colorKeys;
|
|
34582
34693
|
var currentAlphaKeys = this._alphaKeys;
|
|
34583
34694
|
for(var i = 0, n = currentColorKeys.length; i < n; i++){
|
|
@@ -34632,6 +34743,60 @@ ParticleTransformFeedbackSimulator._deltaTimeProperty = ShaderProperty.getByName
|
|
|
34632
34743
|
}
|
|
34633
34744
|
return typeArray;
|
|
34634
34745
|
};
|
|
34746
|
+
/**
|
|
34747
|
+
* @internal
|
|
34748
|
+
*/ _proto._evaluate = function _evaluate(time, out) {
|
|
34749
|
+
var alphaKeys = this._alphaKeys;
|
|
34750
|
+
var alphaCount = alphaKeys.length;
|
|
34751
|
+
if (alphaCount === 0) {
|
|
34752
|
+
out.a = 0;
|
|
34753
|
+
} else {
|
|
34754
|
+
var alphaMaxTime = alphaKeys[alphaCount - 1].time;
|
|
34755
|
+
var alphaT = Math.min(time, alphaMaxTime);
|
|
34756
|
+
for(var i = 0; i < alphaCount; i++){
|
|
34757
|
+
var key = alphaKeys[i];
|
|
34758
|
+
if (alphaT <= key.time) {
|
|
34759
|
+
if (i === 0) {
|
|
34760
|
+
out.a = key.alpha;
|
|
34761
|
+
} else {
|
|
34762
|
+
var lastKey = alphaKeys[i - 1];
|
|
34763
|
+
var age = (alphaT - lastKey.time) / (key.time - lastKey.time);
|
|
34764
|
+
out.a = lastKey.alpha + (key.alpha - lastKey.alpha) * age;
|
|
34765
|
+
}
|
|
34766
|
+
break;
|
|
34767
|
+
}
|
|
34768
|
+
}
|
|
34769
|
+
}
|
|
34770
|
+
var colorKeys = this._colorKeys;
|
|
34771
|
+
var colorCount = colorKeys.length;
|
|
34772
|
+
if (colorCount === 0) {
|
|
34773
|
+
out.r = 0;
|
|
34774
|
+
out.g = 0;
|
|
34775
|
+
out.b = 0;
|
|
34776
|
+
} else {
|
|
34777
|
+
var colorMaxTime = colorKeys[colorCount - 1].time;
|
|
34778
|
+
var colorT = Math.min(time, colorMaxTime);
|
|
34779
|
+
for(var i1 = 0; i1 < colorCount; i1++){
|
|
34780
|
+
var key1 = colorKeys[i1];
|
|
34781
|
+
if (colorT <= key1.time) {
|
|
34782
|
+
var c = key1.color;
|
|
34783
|
+
if (i1 === 0) {
|
|
34784
|
+
out.r = c.r;
|
|
34785
|
+
out.g = c.g;
|
|
34786
|
+
out.b = c.b;
|
|
34787
|
+
} else {
|
|
34788
|
+
var lastKey1 = colorKeys[i1 - 1];
|
|
34789
|
+
var last = lastKey1.color;
|
|
34790
|
+
var age1 = (colorT - lastKey1.time) / (key1.time - lastKey1.time);
|
|
34791
|
+
out.r = last.r + (c.r - last.r) * age1;
|
|
34792
|
+
out.g = last.g + (c.g - last.g) * age1;
|
|
34793
|
+
out.b = last.b + (c.b - last.b) * age1;
|
|
34794
|
+
}
|
|
34795
|
+
break;
|
|
34796
|
+
}
|
|
34797
|
+
}
|
|
34798
|
+
}
|
|
34799
|
+
};
|
|
34635
34800
|
_proto._addKey = function _addKey(keys, key) {
|
|
34636
34801
|
var time = key.time;
|
|
34637
34802
|
var count = keys.length;
|
|
@@ -34811,6 +34976,17 @@ __decorate([
|
|
|
34811
34976
|
case ParticleGradientMode.TwoConstants:
|
|
34812
34977
|
engineMath.Color.lerp(this.constantMin, this.constantMax, lerpFactor, out);
|
|
34813
34978
|
break;
|
|
34979
|
+
case ParticleGradientMode.Gradient:
|
|
34980
|
+
this.gradientMax._evaluate(time, out);
|
|
34981
|
+
break;
|
|
34982
|
+
case ParticleGradientMode.TwoGradients:
|
|
34983
|
+
{
|
|
34984
|
+
var tmp = ParticleCompositeGradient._tempColor;
|
|
34985
|
+
this.gradientMin._evaluate(time, tmp);
|
|
34986
|
+
this.gradientMax._evaluate(time, out);
|
|
34987
|
+
engineMath.Color.lerp(tmp, out, lerpFactor, out);
|
|
34988
|
+
break;
|
|
34989
|
+
}
|
|
34814
34990
|
}
|
|
34815
34991
|
};
|
|
34816
34992
|
_create_class(ParticleCompositeGradient, [
|
|
@@ -34839,6 +35015,7 @@ __decorate([
|
|
|
34839
35015
|
]);
|
|
34840
35016
|
return ParticleCompositeGradient;
|
|
34841
35017
|
}();
|
|
35018
|
+
ParticleCompositeGradient._tempColor = new engineMath.Color();
|
|
34842
35019
|
__decorate([
|
|
34843
35020
|
deepClone
|
|
34844
35021
|
], ParticleCompositeGradient.prototype, "constantMin", void 0);
|
|
@@ -35016,7 +35193,33 @@ __decorate([
|
|
|
35016
35193
|
};
|
|
35017
35194
|
/**
|
|
35018
35195
|
* @internal
|
|
35196
|
+
*/ _proto._evaluateCumulative = function _evaluateCumulative(normalizedAge, lerpFactor) {
|
|
35197
|
+
switch(this.mode){
|
|
35198
|
+
case ParticleCurveMode.Constant:
|
|
35199
|
+
return this.constantMax * normalizedAge;
|
|
35200
|
+
case ParticleCurveMode.TwoConstants:
|
|
35201
|
+
return (this.constantMin + (this.constantMax - this.constantMin) * lerpFactor) * normalizedAge;
|
|
35202
|
+
case ParticleCurveMode.Curve:
|
|
35203
|
+
var _this_curveMax;
|
|
35204
|
+
var _this_curveMax__evaluateCumulative;
|
|
35205
|
+
return (_this_curveMax__evaluateCumulative = (_this_curveMax = this.curveMax) == null ? void 0 : _this_curveMax._evaluateCumulative(normalizedAge)) != null ? _this_curveMax__evaluateCumulative : 0;
|
|
35206
|
+
case ParticleCurveMode.TwoCurves:
|
|
35207
|
+
{
|
|
35208
|
+
var _this_curveMin, _this_curveMax1;
|
|
35209
|
+
var _this_curveMin__evaluateCumulative;
|
|
35210
|
+
var min = (_this_curveMin__evaluateCumulative = (_this_curveMin = this.curveMin) == null ? void 0 : _this_curveMin._evaluateCumulative(normalizedAge)) != null ? _this_curveMin__evaluateCumulative : 0;
|
|
35211
|
+
var _this_curveMax__evaluateCumulative1;
|
|
35212
|
+
var max = (_this_curveMax__evaluateCumulative1 = (_this_curveMax1 = this.curveMax) == null ? void 0 : _this_curveMax1._evaluateCumulative(normalizedAge)) != null ? _this_curveMax__evaluateCumulative1 : 0;
|
|
35213
|
+
return min + (max - min) * lerpFactor;
|
|
35214
|
+
}
|
|
35215
|
+
default:
|
|
35216
|
+
return 0;
|
|
35217
|
+
}
|
|
35218
|
+
};
|
|
35219
|
+
/**
|
|
35220
|
+
* @internal
|
|
35019
35221
|
*/ _proto._getMax = function _getMax() {
|
|
35222
|
+
var minMaxRange = ParticleCompositeCurve._minMaxRange;
|
|
35020
35223
|
switch(this.mode){
|
|
35021
35224
|
case ParticleCurveMode.Constant:
|
|
35022
35225
|
return this.constantMax;
|
|
@@ -35024,17 +35227,18 @@ __decorate([
|
|
|
35024
35227
|
return Math.max(this.constantMin, this.constantMax);
|
|
35025
35228
|
case ParticleCurveMode.Curve:
|
|
35026
35229
|
var _this_curveMax;
|
|
35027
|
-
|
|
35230
|
+
this._getKeyMinMax((_this_curveMax = this.curveMax) == null ? void 0 : _this_curveMax.keys, minMaxRange);
|
|
35231
|
+
return minMaxRange.y;
|
|
35028
35232
|
case ParticleCurveMode.TwoCurves:
|
|
35029
35233
|
var _this_curveMin, _this_curveMax1;
|
|
35030
|
-
|
|
35031
|
-
var
|
|
35032
|
-
|
|
35234
|
+
this._getKeyMinMax((_this_curveMin = this.curveMin) == null ? void 0 : _this_curveMin.keys, minMaxRange);
|
|
35235
|
+
var maxCurveMin = minMaxRange.y;
|
|
35236
|
+
this._getKeyMinMax((_this_curveMax1 = this.curveMax) == null ? void 0 : _this_curveMax1.keys, minMaxRange);
|
|
35237
|
+
return maxCurveMin > minMaxRange.y ? maxCurveMin : minMaxRange.y;
|
|
35033
35238
|
}
|
|
35034
35239
|
};
|
|
35035
35240
|
/**
|
|
35036
35241
|
* @internal
|
|
35037
|
-
|
|
35038
35242
|
*/ _proto._getMinMax = function _getMinMax(out) {
|
|
35039
35243
|
switch(this.mode){
|
|
35040
35244
|
case ParticleCurveMode.Constant:
|
|
@@ -35044,23 +35248,40 @@ __decorate([
|
|
|
35044
35248
|
out.set(Math.min(this.constantMin, this.constantMax), Math.max(this.constantMin, this.constantMax));
|
|
35045
35249
|
break;
|
|
35046
35250
|
case ParticleCurveMode.Curve:
|
|
35047
|
-
var _this_curveMax
|
|
35048
|
-
|
|
35251
|
+
var _this_curveMax;
|
|
35252
|
+
this._getKeyMinMax((_this_curveMax = this.curveMax) == null ? void 0 : _this_curveMax.keys, out);
|
|
35049
35253
|
break;
|
|
35050
35254
|
case ParticleCurveMode.TwoCurves:
|
|
35051
|
-
var
|
|
35052
|
-
|
|
35053
|
-
var minCurveMin =
|
|
35054
|
-
var
|
|
35055
|
-
|
|
35056
|
-
var
|
|
35057
|
-
var
|
|
35058
|
-
out.set(
|
|
35255
|
+
var _this_curveMin, _this_curveMax1;
|
|
35256
|
+
this._getKeyMinMax((_this_curveMin = this.curveMin) == null ? void 0 : _this_curveMin.keys, out);
|
|
35257
|
+
var minCurveMin = out.x;
|
|
35258
|
+
var maxCurveMin = out.y;
|
|
35259
|
+
this._getKeyMinMax((_this_curveMax1 = this.curveMax) == null ? void 0 : _this_curveMax1.keys, out);
|
|
35260
|
+
var minCurveMax = out.x;
|
|
35261
|
+
var maxCurveMax = out.y;
|
|
35262
|
+
out.set(minCurveMax < minCurveMin ? minCurveMax : minCurveMin, maxCurveMax > maxCurveMin ? maxCurveMax : maxCurveMin);
|
|
35059
35263
|
break;
|
|
35060
35264
|
}
|
|
35061
35265
|
};
|
|
35062
35266
|
/**
|
|
35063
35267
|
* @internal
|
|
35268
|
+
*/ _proto._isZero = function _isZero() {
|
|
35269
|
+
var minMax = ParticleCompositeCurve._minMaxRange;
|
|
35270
|
+
this._getMinMax(minMax);
|
|
35271
|
+
return minMax.x === 0 && minMax.y === 0;
|
|
35272
|
+
};
|
|
35273
|
+
/**
|
|
35274
|
+
* @internal
|
|
35275
|
+
*/ _proto._isCurveMode = function _isCurveMode() {
|
|
35276
|
+
return this._mode === ParticleCurveMode.Curve || this._mode === ParticleCurveMode.TwoCurves;
|
|
35277
|
+
};
|
|
35278
|
+
/**
|
|
35279
|
+
* @internal
|
|
35280
|
+
*/ _proto._isRandomMode = function _isRandomMode() {
|
|
35281
|
+
return this._mode === ParticleCurveMode.TwoConstants || this._mode === ParticleCurveMode.TwoCurves;
|
|
35282
|
+
};
|
|
35283
|
+
/**
|
|
35284
|
+
* @internal
|
|
35064
35285
|
*/ _proto._registerOnValueChanged = function _registerOnValueChanged(listener) {
|
|
35065
35286
|
this._updateManager.addListener(listener);
|
|
35066
35287
|
};
|
|
@@ -35069,31 +35290,20 @@ __decorate([
|
|
|
35069
35290
|
*/ _proto._unRegisterOnValueChanged = function _unRegisterOnValueChanged(listener) {
|
|
35070
35291
|
this._updateManager.removeListener(listener);
|
|
35071
35292
|
};
|
|
35072
|
-
_proto.
|
|
35073
|
-
var max = undefined;
|
|
35074
|
-
var _keys_length;
|
|
35075
|
-
var count = (_keys_length = keys == null ? void 0 : keys.length) != null ? _keys_length : 0;
|
|
35076
|
-
if (count > 0) {
|
|
35077
|
-
max = keys[0].value;
|
|
35078
|
-
for(var i = 1; i < count; i++){
|
|
35079
|
-
var value = keys[i].value;
|
|
35080
|
-
max = Math.max(max, value);
|
|
35081
|
-
}
|
|
35082
|
-
}
|
|
35083
|
-
return max;
|
|
35084
|
-
};
|
|
35085
|
-
_proto._getMinKeyValue = function _getMinKeyValue(keys) {
|
|
35293
|
+
_proto._getKeyMinMax = function _getKeyMinMax(keys, out) {
|
|
35086
35294
|
var min = undefined;
|
|
35295
|
+
var max = undefined;
|
|
35087
35296
|
var _keys_length;
|
|
35088
35297
|
var count = (_keys_length = keys == null ? void 0 : keys.length) != null ? _keys_length : 0;
|
|
35089
35298
|
if (count > 0) {
|
|
35090
|
-
min = keys[0].value;
|
|
35299
|
+
min = max = keys[0].value;
|
|
35091
35300
|
for(var i = 1; i < count; i++){
|
|
35092
35301
|
var value = keys[i].value;
|
|
35093
35302
|
min = Math.min(min, value);
|
|
35303
|
+
max = Math.max(max, value);
|
|
35094
35304
|
}
|
|
35095
35305
|
}
|
|
35096
|
-
|
|
35306
|
+
out.set(min != null ? min : 0, max != null ? max : 0);
|
|
35097
35307
|
};
|
|
35098
35308
|
_proto._onCurveChange = function _onCurveChange(lastValue, value) {
|
|
35099
35309
|
var dispatch = this._updateDispatch;
|
|
@@ -35199,6 +35409,7 @@ __decorate([
|
|
|
35199
35409
|
]);
|
|
35200
35410
|
return ParticleCompositeCurve;
|
|
35201
35411
|
}();
|
|
35412
|
+
ParticleCompositeCurve._minMaxRange = new engineMath.Vector2();
|
|
35202
35413
|
__decorate([
|
|
35203
35414
|
ignoreClone
|
|
35204
35415
|
], ParticleCompositeCurve.prototype, "_updateManager", void 0);
|
|
@@ -36860,6 +37071,34 @@ __decorate([
|
|
|
36860
37071
|
};
|
|
36861
37072
|
/**
|
|
36862
37073
|
* @internal
|
|
37074
|
+
*/ _proto._evaluateCumulative = function _evaluateCumulative(normalizedAge) {
|
|
37075
|
+
var keys = this.keys;
|
|
37076
|
+
var length = keys.length;
|
|
37077
|
+
if (length === 0) return 0;
|
|
37078
|
+
// Single key is a constant curve (matches `_evaluate`); its integral is value × age.
|
|
37079
|
+
if (length === 1) return keys[0].value * normalizedAge;
|
|
37080
|
+
var firstKey = keys[0];
|
|
37081
|
+
if (normalizedAge <= firstKey.time) return firstKey.value * normalizedAge;
|
|
37082
|
+
var cumulative = firstKey.value * firstKey.time;
|
|
37083
|
+
for(var i = 1; i < length; i++){
|
|
37084
|
+
var key = keys[i];
|
|
37085
|
+
var lastKey = keys[i - 1];
|
|
37086
|
+
var segmentTime = key.time - lastKey.time;
|
|
37087
|
+
if (segmentTime <= 0) continue;
|
|
37088
|
+
if (key.time >= normalizedAge) {
|
|
37089
|
+
var offsetTime = normalizedAge - lastKey.time;
|
|
37090
|
+
var t = offsetTime / segmentTime;
|
|
37091
|
+
var currentValue = lastKey.value + (key.value - lastKey.value) * t;
|
|
37092
|
+
cumulative += (lastKey.value + currentValue) * 0.5 * offsetTime;
|
|
37093
|
+
return cumulative;
|
|
37094
|
+
}
|
|
37095
|
+
cumulative += (lastKey.value + key.value) * 0.5 * segmentTime;
|
|
37096
|
+
}
|
|
37097
|
+
var lastKey1 = keys[length - 1];
|
|
37098
|
+
return cumulative + lastKey1.value * (normalizedAge - lastKey1.time);
|
|
37099
|
+
};
|
|
37100
|
+
/**
|
|
37101
|
+
* @internal
|
|
36863
37102
|
*/ _proto._getTypeArray = function _getTypeArray() {
|
|
36864
37103
|
var typeArray = this._typeArray || (this._typeArray = new Float32Array(4 * 2));
|
|
36865
37104
|
if (this._typeArrayDirty) {
|
|
@@ -37508,10 +37747,20 @@ __decorate([
|
|
|
37508
37747
|
_inherits(VelocityOverLifetimeModule, ParticleGeneratorModule);
|
|
37509
37748
|
function VelocityOverLifetimeModule(generator) {
|
|
37510
37749
|
var _this;
|
|
37511
|
-
_this = ParticleGeneratorModule.call(this, generator) || this, /** @internal */ _this._velocityRand = new engineMath.Rand(0, ParticleRandomSubSeeds.VelocityOverLifetime), _this._velocityMinConstant = new engineMath.Vector3(), _this._velocityMaxConstant = new engineMath.Vector3(), _this._space = ParticleSimulationSpace.Local
|
|
37750
|
+
_this = ParticleGeneratorModule.call(this, generator) || this, /** @internal */ _this._velocityRand = new engineMath.Rand(0, ParticleRandomSubSeeds.VelocityOverLifetime), _this._velocityMinConstant = new engineMath.Vector3(), _this._velocityMaxConstant = new engineMath.Vector3(), _this._orbitalMinConstant = new engineMath.Vector3(), _this._orbitalConstant = new engineMath.Vector3(), _this._offset = new engineMath.Vector3(), _this._space = ParticleSimulationSpace.Local, _this._onTransformFeedbackDirty = function() {
|
|
37751
|
+
return _this._generator._setTransformFeedback();
|
|
37752
|
+
};
|
|
37512
37753
|
_this.velocityX = new ParticleCompositeCurve(0);
|
|
37513
37754
|
_this.velocityY = new ParticleCompositeCurve(0);
|
|
37514
37755
|
_this.velocityZ = new ParticleCompositeCurve(0);
|
|
37756
|
+
_this.orbitalX = new ParticleCompositeCurve(0);
|
|
37757
|
+
_this.orbitalY = new ParticleCompositeCurve(0);
|
|
37758
|
+
_this.orbitalZ = new ParticleCompositeCurve(0);
|
|
37759
|
+
_this.radial = new ParticleCompositeCurve(0);
|
|
37760
|
+
// @ts-ignore
|
|
37761
|
+
_this._offset._onValueChanged = function() {
|
|
37762
|
+
return _this._generator._renderer._onGeneratorParamsChanged();
|
|
37763
|
+
};
|
|
37515
37764
|
return _this;
|
|
37516
37765
|
}
|
|
37517
37766
|
var _proto = VelocityOverLifetimeModule.prototype;
|
|
@@ -37520,6 +37769,10 @@ __decorate([
|
|
|
37520
37769
|
*/ _proto._updateShaderData = function _updateShaderData(shaderData) {
|
|
37521
37770
|
var velocityMacro = null;
|
|
37522
37771
|
var isRandomModeMacro = null;
|
|
37772
|
+
var orbitalMacro = null;
|
|
37773
|
+
var orbitalRandomModeMacro = null;
|
|
37774
|
+
var radialMacro = null;
|
|
37775
|
+
var radialRandomModeMacro = null;
|
|
37523
37776
|
if (this.enabled) {
|
|
37524
37777
|
var velocityX = this.velocityX;
|
|
37525
37778
|
var velocityY = this.velocityY;
|
|
@@ -37549,15 +37802,111 @@ __decorate([
|
|
|
37549
37802
|
}
|
|
37550
37803
|
}
|
|
37551
37804
|
shaderData.setInt(VelocityOverLifetimeModule._spaceProperty, this.space);
|
|
37805
|
+
var needTransformFeedback = this._needTransformFeedback();
|
|
37806
|
+
var orbitalActive = needTransformFeedback && this._isOrbitalActive();
|
|
37807
|
+
var radialActive = needTransformFeedback && this._isRadialActive();
|
|
37808
|
+
if (orbitalActive) {
|
|
37809
|
+
var orbitalX = this._orbitalX;
|
|
37810
|
+
var orbitalY = this._orbitalY;
|
|
37811
|
+
var orbitalZ = this._orbitalZ;
|
|
37812
|
+
var isOrbitalRandomCurveMode = orbitalX.mode === ParticleCurveMode.TwoCurves && orbitalY.mode === ParticleCurveMode.TwoCurves && orbitalZ.mode === ParticleCurveMode.TwoCurves;
|
|
37813
|
+
if (isOrbitalRandomCurveMode || orbitalX.mode === ParticleCurveMode.Curve && orbitalY.mode === ParticleCurveMode.Curve && orbitalZ.mode === ParticleCurveMode.Curve) {
|
|
37814
|
+
shaderData.setFloatArray(VelocityOverLifetimeModule._orbitalMaxCurveXProperty, orbitalX.curveMax._getTypeArray());
|
|
37815
|
+
shaderData.setFloatArray(VelocityOverLifetimeModule._orbitalMaxCurveYProperty, orbitalY.curveMax._getTypeArray());
|
|
37816
|
+
shaderData.setFloatArray(VelocityOverLifetimeModule._orbitalMaxCurveZProperty, orbitalZ.curveMax._getTypeArray());
|
|
37817
|
+
orbitalMacro = VelocityOverLifetimeModule._orbitalCurveModeMacro;
|
|
37818
|
+
if (isOrbitalRandomCurveMode) {
|
|
37819
|
+
shaderData.setFloatArray(VelocityOverLifetimeModule._orbitalMinCurveXProperty, orbitalX.curveMin._getTypeArray());
|
|
37820
|
+
shaderData.setFloatArray(VelocityOverLifetimeModule._orbitalMinCurveYProperty, orbitalY.curveMin._getTypeArray());
|
|
37821
|
+
shaderData.setFloatArray(VelocityOverLifetimeModule._orbitalMinCurveZProperty, orbitalZ.curveMin._getTypeArray());
|
|
37822
|
+
orbitalRandomModeMacro = VelocityOverLifetimeModule._orbitalRandomModeMacro;
|
|
37823
|
+
}
|
|
37824
|
+
} else {
|
|
37825
|
+
this._orbitalConstant.set(orbitalX.constantMax, orbitalY.constantMax, orbitalZ.constantMax);
|
|
37826
|
+
shaderData.setVector3(VelocityOverLifetimeModule._orbitalMaxConstantProperty, this._orbitalConstant);
|
|
37827
|
+
orbitalMacro = VelocityOverLifetimeModule._orbitalConstantModeMacro;
|
|
37828
|
+
if (orbitalX.mode === ParticleCurveMode.TwoConstants && orbitalY.mode === ParticleCurveMode.TwoConstants && orbitalZ.mode === ParticleCurveMode.TwoConstants) {
|
|
37829
|
+
this._orbitalMinConstant.set(orbitalX.constantMin, orbitalY.constantMin, orbitalZ.constantMin);
|
|
37830
|
+
shaderData.setVector3(VelocityOverLifetimeModule._orbitalMinConstantProperty, this._orbitalMinConstant);
|
|
37831
|
+
orbitalRandomModeMacro = VelocityOverLifetimeModule._orbitalRandomModeMacro;
|
|
37832
|
+
}
|
|
37833
|
+
}
|
|
37834
|
+
}
|
|
37835
|
+
if (radialActive) {
|
|
37836
|
+
var radial = this._radial;
|
|
37837
|
+
var isRadialRandomMode = radial._isRandomMode();
|
|
37838
|
+
if (radial._isCurveMode()) {
|
|
37839
|
+
shaderData.setFloatArray(VelocityOverLifetimeModule._radialMaxCurveProperty, radial.curveMax._getTypeArray());
|
|
37840
|
+
radialMacro = VelocityOverLifetimeModule._radialCurveModeMacro;
|
|
37841
|
+
if (isRadialRandomMode) {
|
|
37842
|
+
shaderData.setFloatArray(VelocityOverLifetimeModule._radialMinCurveProperty, radial.curveMin._getTypeArray());
|
|
37843
|
+
radialRandomModeMacro = VelocityOverLifetimeModule._radialRandomModeMacro;
|
|
37844
|
+
}
|
|
37845
|
+
} else {
|
|
37846
|
+
shaderData.setFloat(VelocityOverLifetimeModule._radialMaxConstantProperty, radial.constantMax);
|
|
37847
|
+
radialMacro = VelocityOverLifetimeModule._radialConstantModeMacro;
|
|
37848
|
+
if (isRadialRandomMode) {
|
|
37849
|
+
shaderData.setFloat(VelocityOverLifetimeModule._radialMinConstantProperty, radial.constantMin);
|
|
37850
|
+
radialRandomModeMacro = VelocityOverLifetimeModule._radialRandomModeMacro;
|
|
37851
|
+
}
|
|
37852
|
+
}
|
|
37853
|
+
}
|
|
37854
|
+
if (orbitalActive || radialActive) {
|
|
37855
|
+
shaderData.setVector3(VelocityOverLifetimeModule._offsetProperty, this._offset);
|
|
37856
|
+
}
|
|
37552
37857
|
}
|
|
37553
37858
|
this._velocityMacro = this._enableMacro(shaderData, this._velocityMacro, velocityMacro);
|
|
37554
37859
|
this._randomModeMacro = this._enableMacro(shaderData, this._randomModeMacro, isRandomModeMacro);
|
|
37860
|
+
this._orbitalMacro = this._enableMacro(shaderData, this._orbitalMacro, orbitalMacro);
|
|
37861
|
+
this._orbitalRandomModeMacro = this._enableMacro(shaderData, this._orbitalRandomModeMacro, orbitalRandomModeMacro);
|
|
37862
|
+
this._radialMacro = this._enableMacro(shaderData, this._radialMacro, radialMacro);
|
|
37863
|
+
this._radialRandomModeMacro = this._enableMacro(shaderData, this._radialRandomModeMacro, radialRandomModeMacro);
|
|
37555
37864
|
};
|
|
37556
37865
|
/**
|
|
37557
37866
|
* @internal
|
|
37558
37867
|
*/ _proto._resetRandomSeed = function _resetRandomSeed(seed) {
|
|
37559
37868
|
this._velocityRand.reset(seed, ParticleRandomSubSeeds.VelocityOverLifetime);
|
|
37560
37869
|
};
|
|
37870
|
+
/**
|
|
37871
|
+
* @internal
|
|
37872
|
+
*/ _proto._needTransformFeedback = function _needTransformFeedback() {
|
|
37873
|
+
if (!this._enabled || !this._generator._renderer.engine._hardwareRenderer.isWebGL2) {
|
|
37874
|
+
return false;
|
|
37875
|
+
}
|
|
37876
|
+
return this._isOrbitalActive() || this._isRadialActive();
|
|
37877
|
+
};
|
|
37878
|
+
/**
|
|
37879
|
+
* @internal
|
|
37880
|
+
*/ _proto._isOrbitalActive = function _isOrbitalActive() {
|
|
37881
|
+
return !(this._orbitalX._isZero() && this._orbitalY._isZero() && this._orbitalZ._isZero());
|
|
37882
|
+
};
|
|
37883
|
+
/**
|
|
37884
|
+
* @internal
|
|
37885
|
+
*/ _proto._isRadialActive = function _isRadialActive() {
|
|
37886
|
+
return !this._radial._isZero();
|
|
37887
|
+
};
|
|
37888
|
+
/**
|
|
37889
|
+
* @internal
|
|
37890
|
+
*/ _proto._isRandomMode = function _isRandomMode() {
|
|
37891
|
+
var velocityX = this.velocityX;
|
|
37892
|
+
var velocityY = this.velocityY;
|
|
37893
|
+
var velocityZ = this.velocityZ;
|
|
37894
|
+
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;
|
|
37895
|
+
if (!this._needTransformFeedback()) {
|
|
37896
|
+
return isLinearRandomMode;
|
|
37897
|
+
}
|
|
37898
|
+
var orbitalX = this._orbitalX;
|
|
37899
|
+
var orbitalY = this._orbitalY;
|
|
37900
|
+
var orbitalZ = this._orbitalZ;
|
|
37901
|
+
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;
|
|
37902
|
+
return isLinearRandomMode || isOrbitalRandomMode || this._radial._isRandomMode();
|
|
37903
|
+
};
|
|
37904
|
+
_proto._onOrbitalRadialChange = function _onOrbitalRadialChange(lastValue, value) {
|
|
37905
|
+
this._onCompositeCurveChange(lastValue, value);
|
|
37906
|
+
lastValue == null ? void 0 : lastValue._unRegisterOnValueChanged(this._onTransformFeedbackDirty);
|
|
37907
|
+
value == null ? void 0 : value._registerOnValueChanged(this._onTransformFeedbackDirty);
|
|
37908
|
+
this._generator._setTransformFeedback();
|
|
37909
|
+
};
|
|
37561
37910
|
_create_class(VelocityOverLifetimeModule, [
|
|
37562
37911
|
{
|
|
37563
37912
|
key: "velocityX",
|
|
@@ -37604,6 +37953,84 @@ __decorate([
|
|
|
37604
37953
|
}
|
|
37605
37954
|
}
|
|
37606
37955
|
},
|
|
37956
|
+
{
|
|
37957
|
+
key: "orbitalX",
|
|
37958
|
+
get: /**
|
|
37959
|
+
* Orbital velocity (radians/second) around the x axis of the system.
|
|
37960
|
+
* @remarks Requires WebGL2.
|
|
37961
|
+
*/ function get() {
|
|
37962
|
+
return this._orbitalX;
|
|
37963
|
+
},
|
|
37964
|
+
set: function set(value) {
|
|
37965
|
+
var lastValue = this._orbitalX;
|
|
37966
|
+
if (value !== lastValue) {
|
|
37967
|
+
this._orbitalX = value;
|
|
37968
|
+
this._onOrbitalRadialChange(lastValue, value);
|
|
37969
|
+
}
|
|
37970
|
+
}
|
|
37971
|
+
},
|
|
37972
|
+
{
|
|
37973
|
+
key: "orbitalY",
|
|
37974
|
+
get: /**
|
|
37975
|
+
* Orbital velocity (radians/second) around the y axis of the system.
|
|
37976
|
+
* @remarks Requires WebGL2.
|
|
37977
|
+
*/ function get() {
|
|
37978
|
+
return this._orbitalY;
|
|
37979
|
+
},
|
|
37980
|
+
set: function set(value) {
|
|
37981
|
+
var lastValue = this._orbitalY;
|
|
37982
|
+
if (value !== lastValue) {
|
|
37983
|
+
this._orbitalY = value;
|
|
37984
|
+
this._onOrbitalRadialChange(lastValue, value);
|
|
37985
|
+
}
|
|
37986
|
+
}
|
|
37987
|
+
},
|
|
37988
|
+
{
|
|
37989
|
+
key: "orbitalZ",
|
|
37990
|
+
get: /**
|
|
37991
|
+
* Orbital velocity (radians/second) around the z axis of the system.
|
|
37992
|
+
* @remarks Requires WebGL2.
|
|
37993
|
+
*/ function get() {
|
|
37994
|
+
return this._orbitalZ;
|
|
37995
|
+
},
|
|
37996
|
+
set: function set(value) {
|
|
37997
|
+
var lastValue = this._orbitalZ;
|
|
37998
|
+
if (value !== lastValue) {
|
|
37999
|
+
this._orbitalZ = value;
|
|
38000
|
+
this._onOrbitalRadialChange(lastValue, value);
|
|
38001
|
+
}
|
|
38002
|
+
}
|
|
38003
|
+
},
|
|
38004
|
+
{
|
|
38005
|
+
key: "radial",
|
|
38006
|
+
get: /**
|
|
38007
|
+
* Radial velocity moving particles away from (or towards) the center.
|
|
38008
|
+
* @remarks Requires WebGL2.
|
|
38009
|
+
*/ function get() {
|
|
38010
|
+
return this._radial;
|
|
38011
|
+
},
|
|
38012
|
+
set: function set(value) {
|
|
38013
|
+
var lastValue = this._radial;
|
|
38014
|
+
if (value !== lastValue) {
|
|
38015
|
+
this._radial = value;
|
|
38016
|
+
this._onOrbitalRadialChange(lastValue, value);
|
|
38017
|
+
}
|
|
38018
|
+
}
|
|
38019
|
+
},
|
|
38020
|
+
{
|
|
38021
|
+
key: "centerOffset",
|
|
38022
|
+
get: /**
|
|
38023
|
+
* The center offset of orbital/radial motion from the particle system origin.
|
|
38024
|
+
*/ function get() {
|
|
38025
|
+
return this._offset;
|
|
38026
|
+
},
|
|
38027
|
+
set: function set(value) {
|
|
38028
|
+
var offset = this._offset;
|
|
38029
|
+
if (value !== offset) {
|
|
38030
|
+
offset.copyFrom(value);
|
|
38031
|
+
}
|
|
38032
|
+
}
|
|
38033
|
+
},
|
|
37607
38034
|
{
|
|
37608
38035
|
key: "space",
|
|
37609
38036
|
get: /**
|
|
@@ -37626,6 +38053,7 @@ __decorate([
|
|
|
37626
38053
|
set: function set(value) {
|
|
37627
38054
|
if (value !== this._enabled) {
|
|
37628
38055
|
this._enabled = value;
|
|
38056
|
+
this._generator._setTransformFeedback();
|
|
37629
38057
|
this._generator._renderer._onGeneratorParamsChanged();
|
|
37630
38058
|
}
|
|
37631
38059
|
}
|
|
@@ -37645,6 +38073,25 @@ VelocityOverLifetimeModule._maxGradientXProperty = ShaderProperty.getByName("ren
|
|
|
37645
38073
|
VelocityOverLifetimeModule._maxGradientYProperty = ShaderProperty.getByName("renderer_VOLMaxGradientY");
|
|
37646
38074
|
VelocityOverLifetimeModule._maxGradientZProperty = ShaderProperty.getByName("renderer_VOLMaxGradientZ");
|
|
37647
38075
|
VelocityOverLifetimeModule._spaceProperty = ShaderProperty.getByName("renderer_VOLSpace");
|
|
38076
|
+
VelocityOverLifetimeModule._orbitalConstantModeMacro = ShaderMacro.getByName("RENDERER_VOL_ORBITAL_CONSTANT_MODE");
|
|
38077
|
+
VelocityOverLifetimeModule._orbitalCurveModeMacro = ShaderMacro.getByName("RENDERER_VOL_ORBITAL_CURVE_MODE");
|
|
38078
|
+
VelocityOverLifetimeModule._orbitalRandomModeMacro = ShaderMacro.getByName("RENDERER_VOL_ORBITAL_IS_RANDOM_TWO");
|
|
38079
|
+
VelocityOverLifetimeModule._radialConstantModeMacro = ShaderMacro.getByName("RENDERER_VOL_RADIAL_CONSTANT_MODE");
|
|
38080
|
+
VelocityOverLifetimeModule._radialCurveModeMacro = ShaderMacro.getByName("RENDERER_VOL_RADIAL_CURVE_MODE");
|
|
38081
|
+
VelocityOverLifetimeModule._radialRandomModeMacro = ShaderMacro.getByName("RENDERER_VOL_RADIAL_IS_RANDOM_TWO");
|
|
38082
|
+
VelocityOverLifetimeModule._orbitalMinConstantProperty = ShaderProperty.getByName("renderer_VOLOrbitalMinConst");
|
|
38083
|
+
VelocityOverLifetimeModule._orbitalMaxConstantProperty = ShaderProperty.getByName("renderer_VOLOrbitalMaxConst");
|
|
38084
|
+
VelocityOverLifetimeModule._orbitalMinCurveXProperty = ShaderProperty.getByName("renderer_VOLOrbitalMinCurveX");
|
|
38085
|
+
VelocityOverLifetimeModule._orbitalMinCurveYProperty = ShaderProperty.getByName("renderer_VOLOrbitalMinCurveY");
|
|
38086
|
+
VelocityOverLifetimeModule._orbitalMinCurveZProperty = ShaderProperty.getByName("renderer_VOLOrbitalMinCurveZ");
|
|
38087
|
+
VelocityOverLifetimeModule._orbitalMaxCurveXProperty = ShaderProperty.getByName("renderer_VOLOrbitalMaxCurveX");
|
|
38088
|
+
VelocityOverLifetimeModule._orbitalMaxCurveYProperty = ShaderProperty.getByName("renderer_VOLOrbitalMaxCurveY");
|
|
38089
|
+
VelocityOverLifetimeModule._orbitalMaxCurveZProperty = ShaderProperty.getByName("renderer_VOLOrbitalMaxCurveZ");
|
|
38090
|
+
VelocityOverLifetimeModule._radialMinConstantProperty = ShaderProperty.getByName("renderer_VOLRadialMinConst");
|
|
38091
|
+
VelocityOverLifetimeModule._radialMaxConstantProperty = ShaderProperty.getByName("renderer_VOLRadialMaxConst");
|
|
38092
|
+
VelocityOverLifetimeModule._radialMinCurveProperty = ShaderProperty.getByName("renderer_VOLRadialMinCurve");
|
|
38093
|
+
VelocityOverLifetimeModule._radialMaxCurveProperty = ShaderProperty.getByName("renderer_VOLRadialMaxCurve");
|
|
38094
|
+
VelocityOverLifetimeModule._offsetProperty = ShaderProperty.getByName("renderer_VOLOffset");
|
|
37648
38095
|
__decorate([
|
|
37649
38096
|
ignoreClone
|
|
37650
38097
|
], VelocityOverLifetimeModule.prototype, "_velocityRand", void 0);
|
|
@@ -37660,6 +38107,24 @@ __decorate([
|
|
|
37660
38107
|
__decorate([
|
|
37661
38108
|
ignoreClone
|
|
37662
38109
|
], VelocityOverLifetimeModule.prototype, "_randomModeMacro", void 0);
|
|
38110
|
+
__decorate([
|
|
38111
|
+
ignoreClone
|
|
38112
|
+
], VelocityOverLifetimeModule.prototype, "_orbitalMinConstant", void 0);
|
|
38113
|
+
__decorate([
|
|
38114
|
+
ignoreClone
|
|
38115
|
+
], VelocityOverLifetimeModule.prototype, "_orbitalConstant", void 0);
|
|
38116
|
+
__decorate([
|
|
38117
|
+
ignoreClone
|
|
38118
|
+
], VelocityOverLifetimeModule.prototype, "_orbitalMacro", void 0);
|
|
38119
|
+
__decorate([
|
|
38120
|
+
ignoreClone
|
|
38121
|
+
], VelocityOverLifetimeModule.prototype, "_orbitalRandomModeMacro", void 0);
|
|
38122
|
+
__decorate([
|
|
38123
|
+
ignoreClone
|
|
38124
|
+
], VelocityOverLifetimeModule.prototype, "_radialMacro", void 0);
|
|
38125
|
+
__decorate([
|
|
38126
|
+
ignoreClone
|
|
38127
|
+
], VelocityOverLifetimeModule.prototype, "_radialRandomModeMacro", void 0);
|
|
37663
38128
|
__decorate([
|
|
37664
38129
|
deepClone
|
|
37665
38130
|
], VelocityOverLifetimeModule.prototype, "_velocityX", void 0);
|
|
@@ -37669,6 +38134,239 @@ __decorate([
|
|
|
37669
38134
|
__decorate([
|
|
37670
38135
|
deepClone
|
|
37671
38136
|
], VelocityOverLifetimeModule.prototype, "_velocityZ", void 0);
|
|
38137
|
+
__decorate([
|
|
38138
|
+
deepClone
|
|
38139
|
+
], VelocityOverLifetimeModule.prototype, "_orbitalX", void 0);
|
|
38140
|
+
__decorate([
|
|
38141
|
+
deepClone
|
|
38142
|
+
], VelocityOverLifetimeModule.prototype, "_orbitalY", void 0);
|
|
38143
|
+
__decorate([
|
|
38144
|
+
deepClone
|
|
38145
|
+
], VelocityOverLifetimeModule.prototype, "_orbitalZ", void 0);
|
|
38146
|
+
__decorate([
|
|
38147
|
+
deepClone
|
|
38148
|
+
], VelocityOverLifetimeModule.prototype, "_radial", void 0);
|
|
38149
|
+
__decorate([
|
|
38150
|
+
deepClone
|
|
38151
|
+
], VelocityOverLifetimeModule.prototype, "_offset", void 0);
|
|
38152
|
+
__decorate([
|
|
38153
|
+
ignoreClone
|
|
38154
|
+
], VelocityOverLifetimeModule.prototype, "_onTransformFeedbackDirty", void 0);
|
|
38155
|
+
|
|
38156
|
+
/**
|
|
38157
|
+
* Optional parent properties a sub-emitter inherits
|
|
38158
|
+
* Sub particles are always emitted at the parent particle's position; these flags only select
|
|
38159
|
+
* which additional properties are inherited on top of that.
|
|
38160
|
+
*/ var ParticleSubEmitterInheritProperty = /*#__PURE__*/ function(ParticleSubEmitterInheritProperty) {
|
|
38161
|
+
/** Inherit no additional properties; sub particles are still emitted at the parent's position. */ ParticleSubEmitterInheritProperty[ParticleSubEmitterInheritProperty["None"] = 0] = "None";
|
|
38162
|
+
/** Multiply parent's current color into the sub particle's start color. */ ParticleSubEmitterInheritProperty[ParticleSubEmitterInheritProperty["Color"] = 1] = "Color";
|
|
38163
|
+
/** Multiply parent's current size into the sub particle's start size. */ ParticleSubEmitterInheritProperty[ParticleSubEmitterInheritProperty["Size"] = 2] = "Size";
|
|
38164
|
+
/** Add parent's current rotation onto the sub particle's start rotation. */ ParticleSubEmitterInheritProperty[ParticleSubEmitterInheritProperty["Rotation"] = 4] = "Rotation";
|
|
38165
|
+
/** Emit the sub particle along the parent's velocity direction. */ ParticleSubEmitterInheritProperty[ParticleSubEmitterInheritProperty["Velocity"] = 8] = "Velocity";
|
|
38166
|
+
return ParticleSubEmitterInheritProperty;
|
|
38167
|
+
}({});
|
|
38168
|
+
|
|
38169
|
+
/**
|
|
38170
|
+
* One slot in `SubEmittersModule.subEmitters`. Configures which sub-emitter
|
|
38171
|
+
* fires, on which parent event, with what inheritance, probability, and count.
|
|
38172
|
+
*/ var SubEmitter = /*#__PURE__*/ function() {
|
|
38173
|
+
function SubEmitter() {
|
|
38174
|
+
/** Bitmask of properties inherited from the parent particle. */ this.inheritProperties = ParticleSubEmitterInheritProperty.None;
|
|
38175
|
+
/** Probability (0..1) the sub-emitter fires for any given event. */ this.emitProbability = 1;
|
|
38176
|
+
/** Number of sub particles emitted per parent event. */ this.emitCount = 1;
|
|
38177
|
+
/** @internal */ this._module = null;
|
|
38178
|
+
this._emitter = null;
|
|
38179
|
+
this._type = ParticleSubEmitterType.Birth;
|
|
38180
|
+
}
|
|
38181
|
+
_create_class(SubEmitter, [
|
|
38182
|
+
{
|
|
38183
|
+
key: "emitter",
|
|
38184
|
+
get: /**
|
|
38185
|
+
* Target particle renderer the sub particles emit into.
|
|
38186
|
+
*/ function get() {
|
|
38187
|
+
return this._emitter;
|
|
38188
|
+
},
|
|
38189
|
+
set: function set(value) {
|
|
38190
|
+
var _this__module;
|
|
38191
|
+
if (value === this._emitter) return;
|
|
38192
|
+
(_this__module = this._module) == null ? void 0 : _this__module._validateEmitter(value);
|
|
38193
|
+
this._emitter = value;
|
|
38194
|
+
}
|
|
38195
|
+
},
|
|
38196
|
+
{
|
|
38197
|
+
key: "type",
|
|
38198
|
+
get: /**
|
|
38199
|
+
* Which parent-particle event drives this slot.
|
|
38200
|
+
*/ function get() {
|
|
38201
|
+
return this._type;
|
|
38202
|
+
},
|
|
38203
|
+
set: function set(value) {
|
|
38204
|
+
var _this__module;
|
|
38205
|
+
if (value === this._type) return;
|
|
38206
|
+
this._type = value;
|
|
38207
|
+
(_this__module = this._module) == null ? void 0 : _this__module._generator._setTransformFeedback();
|
|
38208
|
+
}
|
|
38209
|
+
}
|
|
38210
|
+
]);
|
|
38211
|
+
return SubEmitter;
|
|
38212
|
+
}();
|
|
38213
|
+
__decorate([
|
|
38214
|
+
ignoreClone
|
|
38215
|
+
], SubEmitter.prototype, "_module", void 0);
|
|
38216
|
+
|
|
38217
|
+
/**
|
|
38218
|
+
* Fires sub-emitters on parent particle lifecycle events (Birth / Death).
|
|
38219
|
+
* @remarks Requires WebGL2; the module stays inactive on WebGL1.
|
|
38220
|
+
*/ var SubEmittersModule = /*#__PURE__*/ function(ParticleGeneratorModule) {
|
|
38221
|
+
_inherits(SubEmittersModule, ParticleGeneratorModule);
|
|
38222
|
+
function SubEmittersModule() {
|
|
38223
|
+
var _this;
|
|
38224
|
+
_this = ParticleGeneratorModule.apply(this, arguments) || this, _this._subEmitters = [], _this._probabilityRand = new engineMath.Rand(0, ParticleRandomSubSeeds.SubEmitter);
|
|
38225
|
+
return _this;
|
|
38226
|
+
}
|
|
38227
|
+
var _proto = SubEmittersModule.prototype;
|
|
38228
|
+
/**
|
|
38229
|
+
* Add a sub-emitter slot.
|
|
38230
|
+
* @param emitter - Target particle renderer
|
|
38231
|
+
* @param type - Trigger event (`Birth` / `Death`)
|
|
38232
|
+
* @param inheritProperties - Bitmask of properties inherited from the parent particle
|
|
38233
|
+
* @param emitProbability - Per-event fire probability [0, 1]
|
|
38234
|
+
* @param emitCount - Number of sub particles emitted per parent event
|
|
38235
|
+
*/ _proto.addSubEmitter = function addSubEmitter(emitter, type, inheritProperties, emitProbability, emitCount) {
|
|
38236
|
+
if (inheritProperties === void 0) inheritProperties = ParticleSubEmitterInheritProperty.None;
|
|
38237
|
+
if (emitProbability === void 0) emitProbability = 1;
|
|
38238
|
+
if (emitCount === void 0) emitCount = 1;
|
|
38239
|
+
if (SubEmittersModule._wouldCreateCycle(emitter, this._generator)) {
|
|
38240
|
+
throw new Error("Sub-emitter would create a cycle");
|
|
38241
|
+
}
|
|
38242
|
+
var sub = new SubEmitter();
|
|
38243
|
+
sub.emitter = emitter;
|
|
38244
|
+
sub.type = type;
|
|
38245
|
+
sub.inheritProperties = inheritProperties;
|
|
38246
|
+
sub.emitProbability = emitProbability;
|
|
38247
|
+
sub.emitCount = emitCount;
|
|
38248
|
+
sub._module = this;
|
|
38249
|
+
this._subEmitters.push(sub);
|
|
38250
|
+
this._generator._setTransformFeedback();
|
|
38251
|
+
};
|
|
38252
|
+
/**
|
|
38253
|
+
* Remove the sub-emitter at the given index.
|
|
38254
|
+
* @param index - Index of the sub-emitter to remove
|
|
38255
|
+
*/ _proto.removeSubEmitterByIndex = function removeSubEmitterByIndex(index) {
|
|
38256
|
+
this._subEmitters.splice(index, 1);
|
|
38257
|
+
this._generator._setTransformFeedback();
|
|
38258
|
+
};
|
|
38259
|
+
/**
|
|
38260
|
+
* @internal
|
|
38261
|
+
*/ _proto._dispatchEvent = function _dispatchEvent(type, worldPosition, parentColor, parentSize, parentRotation, worldDirection) {
|
|
38262
|
+
var subEmitters = this.subEmitters;
|
|
38263
|
+
for(var i = 0, n = subEmitters.length; i < n; i++){
|
|
38264
|
+
var sub = subEmitters[i];
|
|
38265
|
+
if (sub.type !== type) continue;
|
|
38266
|
+
var target = sub.emitter;
|
|
38267
|
+
if (target === null || target.destroyed) continue;
|
|
38268
|
+
var count = sub.emitCount;
|
|
38269
|
+
if (count <= 0) continue;
|
|
38270
|
+
if (sub.emitProbability < 1.0 && this._probabilityRand.random() >= sub.emitProbability) {
|
|
38271
|
+
continue;
|
|
38272
|
+
}
|
|
38273
|
+
var inherit = sub.inheritProperties;
|
|
38274
|
+
var colorOverride = (inherit & ParticleSubEmitterInheritProperty.Color) !== 0 ? parentColor : null;
|
|
38275
|
+
var sizeOverride = (inherit & ParticleSubEmitterInheritProperty.Size) !== 0 ? parentSize : null;
|
|
38276
|
+
var rotationOverride = (inherit & ParticleSubEmitterInheritProperty.Rotation) !== 0 ? parentRotation : null;
|
|
38277
|
+
var directionOverride = (inherit & ParticleSubEmitterInheritProperty.Velocity) !== 0 ? worldDirection : null;
|
|
38278
|
+
target.generator._emitFromSubEmitter(count, worldPosition, colorOverride, sizeOverride, rotationOverride, directionOverride);
|
|
38279
|
+
}
|
|
38280
|
+
};
|
|
38281
|
+
/**
|
|
38282
|
+
* @internal
|
|
38283
|
+
*/ _proto._resetRandomSeed = function _resetRandomSeed(seed) {
|
|
38284
|
+
this._probabilityRand.reset(seed, ParticleRandomSubSeeds.SubEmitter);
|
|
38285
|
+
};
|
|
38286
|
+
/**
|
|
38287
|
+
* @internal
|
|
38288
|
+
*/ _proto._hasSubEmitterOfType = function _hasSubEmitterOfType(type) {
|
|
38289
|
+
if (!this.enabled) return false;
|
|
38290
|
+
var subEmitters = this.subEmitters;
|
|
38291
|
+
for(var i = 0, n = subEmitters.length; i < n; i++){
|
|
38292
|
+
if (subEmitters[i].type === type) return true;
|
|
38293
|
+
}
|
|
38294
|
+
return false;
|
|
38295
|
+
};
|
|
38296
|
+
/**
|
|
38297
|
+
* @internal
|
|
38298
|
+
*/ _proto._cloneTo = function _cloneTo(target) {
|
|
38299
|
+
// _module is @ignoreClone, so re-link each cloned slot back to its new module
|
|
38300
|
+
var subEmitters = target._subEmitters;
|
|
38301
|
+
for(var i = 0, n = subEmitters.length; i < n; i++){
|
|
38302
|
+
subEmitters[i]._module = target;
|
|
38303
|
+
}
|
|
38304
|
+
};
|
|
38305
|
+
/**
|
|
38306
|
+
* @internal
|
|
38307
|
+
*/ _proto._validateEmitter = function _validateEmitter(emitter) {
|
|
38308
|
+
if (emitter && SubEmittersModule._wouldCreateCycle(emitter, this._generator)) {
|
|
38309
|
+
throw new Error("Sub-emitter would create a cycle");
|
|
38310
|
+
}
|
|
38311
|
+
};
|
|
38312
|
+
SubEmittersModule._wouldCreateCycle = function _wouldCreateCycle(target, root) {
|
|
38313
|
+
var visited = SubEmittersModule._cycleVisited;
|
|
38314
|
+
var stack = SubEmittersModule._cycleStack;
|
|
38315
|
+
visited.clear();
|
|
38316
|
+
stack.length = 0;
|
|
38317
|
+
stack.push(target.generator);
|
|
38318
|
+
var found = false;
|
|
38319
|
+
while(stack.length > 0){
|
|
38320
|
+
var cur = stack.pop();
|
|
38321
|
+
if (cur === root) {
|
|
38322
|
+
found = true;
|
|
38323
|
+
break;
|
|
38324
|
+
}
|
|
38325
|
+
if (visited.has(cur)) continue;
|
|
38326
|
+
visited.add(cur);
|
|
38327
|
+
var slots = cur.subEmitters.subEmitters;
|
|
38328
|
+
for(var i = 0, n = slots.length; i < n; i++){
|
|
38329
|
+
var _slots_i_emitter;
|
|
38330
|
+
var child = (_slots_i_emitter = slots[i].emitter) == null ? void 0 : _slots_i_emitter.generator;
|
|
38331
|
+
if (child && !visited.has(child)) stack.push(child);
|
|
38332
|
+
}
|
|
38333
|
+
}
|
|
38334
|
+
visited.clear();
|
|
38335
|
+
stack.length = 0;
|
|
38336
|
+
return found;
|
|
38337
|
+
};
|
|
38338
|
+
_create_class(SubEmittersModule, [
|
|
38339
|
+
{
|
|
38340
|
+
key: "subEmitters",
|
|
38341
|
+
get: /**
|
|
38342
|
+
* The configured sub-emitters.
|
|
38343
|
+
*/ function get() {
|
|
38344
|
+
return this._subEmitters;
|
|
38345
|
+
}
|
|
38346
|
+
},
|
|
38347
|
+
{
|
|
38348
|
+
key: "enabled",
|
|
38349
|
+
get: function get() {
|
|
38350
|
+
return this._enabled && this._generator._renderer.engine._hardwareRenderer.isWebGL2;
|
|
38351
|
+
},
|
|
38352
|
+
set: function set(value) {
|
|
38353
|
+
if (value !== this._enabled) {
|
|
38354
|
+
this._enabled = value;
|
|
38355
|
+
this._generator._setTransformFeedback();
|
|
38356
|
+
}
|
|
38357
|
+
}
|
|
38358
|
+
}
|
|
38359
|
+
]);
|
|
38360
|
+
return SubEmittersModule;
|
|
38361
|
+
}(ParticleGeneratorModule);
|
|
38362
|
+
SubEmittersModule._cycleVisited = new Set();
|
|
38363
|
+
SubEmittersModule._cycleStack = [];
|
|
38364
|
+
__decorate([
|
|
38365
|
+
deepClone
|
|
38366
|
+
], SubEmittersModule.prototype, "_subEmitters", void 0);
|
|
38367
|
+
__decorate([
|
|
38368
|
+
ignoreClone
|
|
38369
|
+
], SubEmittersModule.prototype, "_probabilityRand", void 0);
|
|
37672
38370
|
|
|
37673
38371
|
/**
|
|
37674
38372
|
* Particle Generator.
|
|
@@ -37689,6 +38387,7 @@ __decorate([
|
|
|
37689
38387
|
/** @internal */ this._subPrimitive = new SubMesh(0, 0, MeshTopology.Triangles);
|
|
37690
38388
|
/** @internal */ this._useTransformFeedback = false;
|
|
37691
38389
|
/** @internal */ this._feedbackBindingIndex = -1;
|
|
38390
|
+
this._feedbackReadback = null;
|
|
37692
38391
|
this._isPlaying = false;
|
|
37693
38392
|
this._instanceBufferResized = false;
|
|
37694
38393
|
this._waitProcessRetiredElementCount = 0;
|
|
@@ -37697,6 +38396,13 @@ __decorate([
|
|
|
37697
38396
|
this._firstActiveTransformedBoundingBox = 0;
|
|
37698
38397
|
this._firstFreeTransformedBoundingBox = 0;
|
|
37699
38398
|
this._playStartDelay = 0;
|
|
38399
|
+
this._eventPos = new engineMath.Vector3();
|
|
38400
|
+
this._eventColor = new engineMath.Color();
|
|
38401
|
+
this._eventSize = new engineMath.Vector3();
|
|
38402
|
+
this._eventRotation = new engineMath.Vector3();
|
|
38403
|
+
this._eventDir = new engineMath.Vector3();
|
|
38404
|
+
this._emitLocalPos = new engineMath.Vector3();
|
|
38405
|
+
this._emitDirection = new engineMath.Vector3();
|
|
37700
38406
|
this._renderer = renderer;
|
|
37701
38407
|
var subPrimitive = new SubPrimitive();
|
|
37702
38408
|
subPrimitive.start = 0;
|
|
@@ -37709,6 +38415,7 @@ __decorate([
|
|
|
37709
38415
|
this.sizeOverLifetime = new SizeOverLifetimeModule(this);
|
|
37710
38416
|
this.limitVelocityOverLifetime = new LimitVelocityOverLifetimeModule(this);
|
|
37711
38417
|
this.noise = new NoiseModule(this);
|
|
38418
|
+
this.subEmitters = new SubEmittersModule(this);
|
|
37712
38419
|
this.customData = new CustomDataModule(this);
|
|
37713
38420
|
this.emission.enabled = true;
|
|
37714
38421
|
}
|
|
@@ -38040,16 +38747,15 @@ __decorate([
|
|
|
38040
38747
|
this.rotationOverLifetime._resetRandomSeed(seed);
|
|
38041
38748
|
this.colorOverLifetime._resetRandomSeed(seed);
|
|
38042
38749
|
this.noise._resetRandomSeed(seed);
|
|
38750
|
+
this.subEmitters._resetRandomSeed(seed);
|
|
38043
38751
|
};
|
|
38044
38752
|
/**
|
|
38045
38753
|
* @internal
|
|
38046
38754
|
*/ _proto._setTransformFeedback = function _setTransformFeedback() {
|
|
38047
|
-
var
|
|
38755
|
+
var _this_limitVelocityOverLifetime, _this_noise, _this_velocityOverLifetime, _this_subEmitters;
|
|
38756
|
+
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))));
|
|
38048
38757
|
if (needed === this._useTransformFeedback) return;
|
|
38049
38758
|
this._useTransformFeedback = needed;
|
|
38050
|
-
// Switching TF mode invalidates all active particle state: feedback buffers and instance
|
|
38051
|
-
// buffer layout are incompatible between the two paths. Clear rather than show a one-frame
|
|
38052
|
-
// jump; new particles will fill in naturally from the next emit cycle.
|
|
38053
38759
|
this._clearActiveParticles();
|
|
38054
38760
|
if (needed) {
|
|
38055
38761
|
if (!this._feedbackSimulator) {
|
|
@@ -38127,7 +38833,12 @@ __decorate([
|
|
|
38127
38833
|
this._calculateTransformedBounds(maxLifetime, generatorBounds, transformedBounds);
|
|
38128
38834
|
renderer._setDirtyFlagFalse(ParticleUpdateFlags.TransformVolume);
|
|
38129
38835
|
}
|
|
38130
|
-
this.
|
|
38836
|
+
if (this._useOrbitalBounds()) {
|
|
38837
|
+
bounds.min.copyFrom(transformedBounds.min);
|
|
38838
|
+
bounds.max.copyFrom(transformedBounds.max);
|
|
38839
|
+
} else {
|
|
38840
|
+
this._addGravityToBounds(maxLifetime, transformedBounds, bounds);
|
|
38841
|
+
}
|
|
38131
38842
|
};
|
|
38132
38843
|
/**
|
|
38133
38844
|
* @internal
|
|
@@ -38153,7 +38864,9 @@ __decorate([
|
|
|
38153
38864
|
}
|
|
38154
38865
|
}
|
|
38155
38866
|
var maxLifetime = this.main.startLifetime._getMax();
|
|
38156
|
-
this.
|
|
38867
|
+
if (!this._useOrbitalBounds()) {
|
|
38868
|
+
this._addGravityToBounds(maxLifetime, bounds, bounds);
|
|
38869
|
+
}
|
|
38157
38870
|
};
|
|
38158
38871
|
/**
|
|
38159
38872
|
* @internal
|
|
@@ -38205,7 +38918,7 @@ __decorate([
|
|
|
38205
38918
|
this._transformedBoundsArray[previousFreeElement * ParticleBufferUtils.boundsFloatStride + boundsTimeOffset] = this._playTime;
|
|
38206
38919
|
}
|
|
38207
38920
|
};
|
|
38208
|
-
_proto._addNewParticle = function _addNewParticle(position, direction, transform, playTime, emitWorldPositionOverride) {
|
|
38921
|
+
_proto._addNewParticle = function _addNewParticle(position, direction, transform, playTime, emitWorldPositionOverride, inheritColor, inheritSize, inheritRotation) {
|
|
38209
38922
|
var firstFreeElement = this._firstFreeElement;
|
|
38210
38923
|
var nextFreeElement = firstFreeElement + 1;
|
|
38211
38924
|
if (nextFreeElement >= this._currentParticleCount) {
|
|
@@ -38243,7 +38956,7 @@ __decorate([
|
|
|
38243
38956
|
// Time
|
|
38244
38957
|
instanceVertices[offset + ParticleBufferUtils.timeOffset] = playTime;
|
|
38245
38958
|
// Color
|
|
38246
|
-
var startColor = ParticleGenerator.
|
|
38959
|
+
var startColor = ParticleGenerator._tempColor;
|
|
38247
38960
|
main.startColor.evaluate(undefined, main._startColorRand.random(), startColor);
|
|
38248
38961
|
startColor.copyToArray(instanceVertices, offset + 8);
|
|
38249
38962
|
var duration = this.main.duration;
|
|
@@ -38302,7 +39015,7 @@ __decorate([
|
|
|
38302
39015
|
}
|
|
38303
39016
|
// Velocity random
|
|
38304
39017
|
var velocityOverLifetime = this.velocityOverLifetime;
|
|
38305
|
-
if (velocityOverLifetime.enabled && velocityOverLifetime.
|
|
39018
|
+
if (velocityOverLifetime.enabled && velocityOverLifetime._isRandomMode()) {
|
|
38306
39019
|
var rand = velocityOverLifetime._velocityRand;
|
|
38307
39020
|
instanceVertices[offset + 24] = rand.random();
|
|
38308
39021
|
instanceVertices[offset + 25] = rand.random();
|
|
@@ -38344,11 +39057,79 @@ __decorate([
|
|
|
38344
39057
|
if (limitVelocityOverLifetime.enabled && (limitVelocityOverLifetime._isSpeedRandomMode() || limitVelocityOverLifetime._isDragRandomMode())) {
|
|
38345
39058
|
instanceVertices[offset + 41] = limitVelocityOverLifetime._speedRand.random();
|
|
38346
39059
|
}
|
|
39060
|
+
// Apply sub-emit inherit: multiply color/size, add rotation
|
|
39061
|
+
if (inheritColor) {
|
|
39062
|
+
instanceVertices[offset + 8] *= inheritColor.r;
|
|
39063
|
+
instanceVertices[offset + 9] *= inheritColor.g;
|
|
39064
|
+
instanceVertices[offset + 10] *= inheritColor.b;
|
|
39065
|
+
instanceVertices[offset + 11] *= inheritColor.a;
|
|
39066
|
+
}
|
|
39067
|
+
if (inheritSize) {
|
|
39068
|
+
instanceVertices[offset + 12] *= inheritSize.x;
|
|
39069
|
+
instanceVertices[offset + 13] *= inheritSize.y;
|
|
39070
|
+
instanceVertices[offset + 14] *= inheritSize.z;
|
|
39071
|
+
}
|
|
39072
|
+
if (inheritRotation) {
|
|
39073
|
+
instanceVertices[offset + 15] += inheritRotation.x;
|
|
39074
|
+
instanceVertices[offset + 16] += inheritRotation.y;
|
|
39075
|
+
instanceVertices[offset + 17] += inheritRotation.z;
|
|
39076
|
+
}
|
|
38347
39077
|
// Initialize feedback buffer for this particle
|
|
38348
39078
|
if (this._useTransformFeedback) {
|
|
38349
39079
|
this._addFeedbackParticle(firstFreeElement, position, direction, startSpeed, transform, pos);
|
|
38350
39080
|
}
|
|
38351
39081
|
this._firstFreeElement = nextFreeElement;
|
|
39082
|
+
if (this.subEmitters._hasSubEmitterOfType(ParticleSubEmitterType.Birth)) {
|
|
39083
|
+
this._onParticleBirth(offset, position, direction, transform);
|
|
39084
|
+
}
|
|
39085
|
+
};
|
|
39086
|
+
_proto._onParticleBirth = function _onParticleBirth(offset, position, direction, transform) {
|
|
39087
|
+
var worldRotation = transform.worldRotationQuaternion;
|
|
39088
|
+
var birthPos = this._eventPos;
|
|
39089
|
+
engineMath.Vector3.transformByQuat(position, worldRotation, birthPos);
|
|
39090
|
+
birthPos.add(transform.worldPosition);
|
|
39091
|
+
// Birth emission direction is known directly; Death reads it back from the feedback buffer
|
|
39092
|
+
var worldDirection = this._eventDir;
|
|
39093
|
+
engineMath.Vector3.transformByQuat(direction, worldRotation, worldDirection);
|
|
39094
|
+
var parentColor = this._eventColor;
|
|
39095
|
+
var parentSize = this._eventSize;
|
|
39096
|
+
var parentRotation = this._eventRotation;
|
|
39097
|
+
this._evaluateOverLifetime(offset, 0, parentColor, parentSize, parentRotation);
|
|
39098
|
+
this.subEmitters._dispatchEvent(ParticleSubEmitterType.Birth, birthPos, parentColor, parentSize, parentRotation, worldDirection);
|
|
39099
|
+
};
|
|
39100
|
+
/**
|
|
39101
|
+
* @internal
|
|
39102
|
+
*/ _proto._emitFromSubEmitter = function _emitFromSubEmitter(count, worldPosition, inheritColor, inheritSize, inheritRotation, worldDirection) {
|
|
39103
|
+
if (count <= 0) return;
|
|
39104
|
+
var main = this.main;
|
|
39105
|
+
var notRetired = this._getNotRetiredParticleCount();
|
|
39106
|
+
var available = main.maxParticles - notRetired;
|
|
39107
|
+
if (available <= 0) return;
|
|
39108
|
+
if (count > available) count = available;
|
|
39109
|
+
var transform = this._renderer.entity.transform;
|
|
39110
|
+
var emitterWorldPosition = transform.worldPosition, emitterWorldRotation = transform.worldRotationQuaternion;
|
|
39111
|
+
// Convert event world position into local emission space for a_ShapePos
|
|
39112
|
+
var localPos = this._emitLocalPos;
|
|
39113
|
+
engineMath.Vector3.subtract(worldPosition, emitterWorldPosition, localPos);
|
|
39114
|
+
var invRot = ParticleGenerator._tempQuat0;
|
|
39115
|
+
engineMath.Quaternion.invert(emitterWorldRotation, invRot);
|
|
39116
|
+
engineMath.Vector3.transformByQuat(localPos, invRot, localPos);
|
|
39117
|
+
var direction = this._emitDirection;
|
|
39118
|
+
if (worldDirection) {
|
|
39119
|
+
engineMath.Vector3.transformByQuat(worldDirection, invRot, direction);
|
|
39120
|
+
var len = Math.sqrt(direction.x * direction.x + direction.y * direction.y + direction.z * direction.z);
|
|
39121
|
+
if (len > engineMath.MathUtil.zeroTolerance) {
|
|
39122
|
+
direction.set(direction.x / len, direction.y / len, direction.z / len);
|
|
39123
|
+
} else {
|
|
39124
|
+
direction.set(0, 0, -1);
|
|
39125
|
+
}
|
|
39126
|
+
} else {
|
|
39127
|
+
direction.set(0, 0, -1);
|
|
39128
|
+
}
|
|
39129
|
+
var playTime = this._playTime;
|
|
39130
|
+
for(var i = 0; i < count; i++){
|
|
39131
|
+
this._addNewParticle(localPos, direction, transform, playTime, undefined, inheritColor, inheritSize, inheritRotation);
|
|
39132
|
+
}
|
|
38352
39133
|
};
|
|
38353
39134
|
_proto._addFeedbackParticle = function _addFeedbackParticle(index, shapePosition, direction, startSpeed, transform, emitWorldPosition) {
|
|
38354
39135
|
var position;
|
|
@@ -38372,7 +39153,10 @@ __decorate([
|
|
|
38372
39153
|
var engine = this._renderer.engine;
|
|
38373
39154
|
var frameCount = engine.time.frameCount;
|
|
38374
39155
|
var instanceVertices = this._instanceVertices;
|
|
38375
|
-
|
|
39156
|
+
var hasDeathSlot = this.subEmitters._hasSubEmitterOfType(ParticleSubEmitterType.Death);
|
|
39157
|
+
var firstNewElement = this._firstNewElement;
|
|
39158
|
+
var feedbackLoaded = false;
|
|
39159
|
+
while(this._firstActiveElement !== firstNewElement){
|
|
38376
39160
|
var activeParticleOffset = this._firstActiveElement * ParticleBufferUtils.instanceVertexFloatStride;
|
|
38377
39161
|
var activeParticleTimeOffset = activeParticleOffset + ParticleBufferUtils.timeOffset;
|
|
38378
39162
|
var particleAge = this._playTime - instanceVertices[activeParticleTimeOffset];
|
|
@@ -38380,6 +39164,13 @@ __decorate([
|
|
|
38380
39164
|
if (Math.fround(particleAge) < instanceVertices[activeParticleOffset + ParticleBufferUtils.startLifeTimeOffset]) {
|
|
38381
39165
|
break;
|
|
38382
39166
|
}
|
|
39167
|
+
if (hasDeathSlot) {
|
|
39168
|
+
if (this._feedbackSimulator && !feedbackLoaded) {
|
|
39169
|
+
this._readbackFeedback(this._firstActiveElement, firstNewElement);
|
|
39170
|
+
feedbackLoaded = true;
|
|
39171
|
+
}
|
|
39172
|
+
this._onParticleDeath(activeParticleOffset);
|
|
39173
|
+
}
|
|
38383
39174
|
// Store frame count in time offset to free retired particle
|
|
38384
39175
|
instanceVertices[activeParticleTimeOffset] = frameCount;
|
|
38385
39176
|
if (++this._firstActiveElement >= this._currentParticleCount) {
|
|
@@ -38389,6 +39180,110 @@ __decorate([
|
|
|
38389
39180
|
this._waitProcessRetiredElementCount++;
|
|
38390
39181
|
}
|
|
38391
39182
|
};
|
|
39183
|
+
_proto._readbackFeedback = function _readbackFeedback(firstActiveElement, firstNewElement) {
|
|
39184
|
+
var stride = ParticleBufferUtils.feedbackVertexStride;
|
|
39185
|
+
var floatStride = stride / 4;
|
|
39186
|
+
var totalFloatCount = this._currentParticleCount * floatStride;
|
|
39187
|
+
var readback = this._feedbackReadback;
|
|
39188
|
+
if (!readback || readback.length < totalFloatCount) {
|
|
39189
|
+
readback = this._feedbackReadback = new Float32Array(totalFloatCount);
|
|
39190
|
+
}
|
|
39191
|
+
var buffer = this._feedbackSimulator.readBinding.buffer;
|
|
39192
|
+
var wrapped = firstActiveElement >= firstNewElement;
|
|
39193
|
+
var firstSegmentEnd = wrapped ? this._currentParticleCount : firstNewElement;
|
|
39194
|
+
buffer.getData(readback, firstActiveElement * stride, firstActiveElement * floatStride, (firstSegmentEnd - firstActiveElement) * floatStride);
|
|
39195
|
+
if (wrapped && firstNewElement > 0) {
|
|
39196
|
+
buffer.getData(readback, 0, 0, firstNewElement * floatStride);
|
|
39197
|
+
}
|
|
39198
|
+
};
|
|
39199
|
+
_proto._onParticleDeath = function _onParticleDeath(particleOffset) {
|
|
39200
|
+
var instanceVertices = this._instanceVertices;
|
|
39201
|
+
var transform = this._renderer.entity.transform;
|
|
39202
|
+
var simSpaceLocal = this.main.simulationSpace === ParticleSimulationSpace.Local;
|
|
39203
|
+
var worldRotation = transform.worldRotationQuaternion;
|
|
39204
|
+
var ringIndex = particleOffset / ParticleBufferUtils.instanceVertexFloatStride;
|
|
39205
|
+
var feedbackData = this._feedbackReadback;
|
|
39206
|
+
var feedbackOffset = ringIndex * ParticleBufferUtils.feedbackVertexStride / 4;
|
|
39207
|
+
var local = this._eventPos;
|
|
39208
|
+
local.set(feedbackData[feedbackOffset], feedbackData[feedbackOffset + 1], feedbackData[feedbackOffset + 2]);
|
|
39209
|
+
if (simSpaceLocal) {
|
|
39210
|
+
engineMath.Vector3.transformByQuat(local, worldRotation, local);
|
|
39211
|
+
local.add(transform.worldPosition);
|
|
39212
|
+
}
|
|
39213
|
+
var worldDirection = this._eventDir;
|
|
39214
|
+
worldDirection.set(feedbackData[feedbackOffset + 3], feedbackData[feedbackOffset + 4], feedbackData[feedbackOffset + 5]);
|
|
39215
|
+
if (simSpaceLocal) {
|
|
39216
|
+
engineMath.Vector3.transformByQuat(worldDirection, worldRotation, worldDirection);
|
|
39217
|
+
} else {
|
|
39218
|
+
var spawnRotation = ParticleGenerator._tempQuat0;
|
|
39219
|
+
spawnRotation.set(instanceVertices[particleOffset + 30], instanceVertices[particleOffset + 31], instanceVertices[particleOffset + 32], instanceVertices[particleOffset + 33]);
|
|
39220
|
+
engineMath.Vector3.transformByQuat(worldDirection, spawnRotation, worldDirection);
|
|
39221
|
+
}
|
|
39222
|
+
// Evaluate at the parent's normalizedAge so children inherit its visible appearance at death.
|
|
39223
|
+
var lifetime = instanceVertices[particleOffset + 3];
|
|
39224
|
+
var bornTime = instanceVertices[particleOffset + 7];
|
|
39225
|
+
var parentColor = this._eventColor;
|
|
39226
|
+
var parentSize = this._eventSize;
|
|
39227
|
+
var parentRotation = this._eventRotation;
|
|
39228
|
+
var normalizedAge = Math.min(Math.max((this._playTime - bornTime) / lifetime, 0), 1);
|
|
39229
|
+
this._evaluateOverLifetime(particleOffset, normalizedAge, parentColor, parentSize, parentRotation);
|
|
39230
|
+
this.subEmitters._dispatchEvent(ParticleSubEmitterType.Death, local, parentColor, parentSize, parentRotation, worldDirection);
|
|
39231
|
+
};
|
|
39232
|
+
_proto._evaluateOverLifetime = function _evaluateOverLifetime(particleOffset, normalizedAge, parentColor, parentSize, parentRotation) {
|
|
39233
|
+
var instanceVertices = this._instanceVertices;
|
|
39234
|
+
var r = instanceVertices[particleOffset + 8];
|
|
39235
|
+
var g = instanceVertices[particleOffset + 9];
|
|
39236
|
+
var b = instanceVertices[particleOffset + 10];
|
|
39237
|
+
var a = instanceVertices[particleOffset + 11];
|
|
39238
|
+
var col = this.colorOverLifetime;
|
|
39239
|
+
if (col.enabled) {
|
|
39240
|
+
var colorFactor = ParticleGenerator._tempColor;
|
|
39241
|
+
col.color.evaluate(normalizedAge, instanceVertices[particleOffset + 20], colorFactor);
|
|
39242
|
+
r *= colorFactor.r;
|
|
39243
|
+
g *= colorFactor.g;
|
|
39244
|
+
b *= colorFactor.b;
|
|
39245
|
+
a *= colorFactor.a;
|
|
39246
|
+
}
|
|
39247
|
+
parentColor.set(r, g, b, a);
|
|
39248
|
+
var sx = instanceVertices[particleOffset + 12];
|
|
39249
|
+
var sy = instanceVertices[particleOffset + 13];
|
|
39250
|
+
var sz = instanceVertices[particleOffset + 14];
|
|
39251
|
+
var sol = this.sizeOverLifetime;
|
|
39252
|
+
// SOL only contributes in Curve / TwoCurves modes (shader gates on RENDERER_SOL_CURVE_MODE)
|
|
39253
|
+
if (sol.enabled && (sol.sizeX.mode === ParticleCurveMode.Curve || sol.sizeX.mode === ParticleCurveMode.TwoCurves)) {
|
|
39254
|
+
var sizeRand = instanceVertices[particleOffset + 21];
|
|
39255
|
+
if (sol.separateAxes) {
|
|
39256
|
+
sx *= sol.sizeX.evaluate(normalizedAge, sizeRand);
|
|
39257
|
+
sy *= sol.sizeY.evaluate(normalizedAge, sizeRand);
|
|
39258
|
+
sz *= sol.sizeZ.evaluate(normalizedAge, sizeRand);
|
|
39259
|
+
} else {
|
|
39260
|
+
var factor = sol.sizeX.evaluate(normalizedAge, sizeRand);
|
|
39261
|
+
sx *= factor;
|
|
39262
|
+
sy *= factor;
|
|
39263
|
+
sz *= factor;
|
|
39264
|
+
}
|
|
39265
|
+
}
|
|
39266
|
+
parentSize.set(sx, sy, sz);
|
|
39267
|
+
var rx = instanceVertices[particleOffset + 15];
|
|
39268
|
+
var ry = instanceVertices[particleOffset + 16];
|
|
39269
|
+
var rz = instanceVertices[particleOffset + 17];
|
|
39270
|
+
var rol = this.rotationOverLifetime;
|
|
39271
|
+
if (rol.enabled) {
|
|
39272
|
+
var rotRand = instanceVertices[particleOffset + 22];
|
|
39273
|
+
var lifetime = instanceVertices[particleOffset + 3];
|
|
39274
|
+
var rolZ = rol.rotationZ._evaluateCumulative(normalizedAge, rotRand) * lifetime;
|
|
39275
|
+
if (rol.separateAxes) {
|
|
39276
|
+
rx += rol.rotationX._evaluateCumulative(normalizedAge, rotRand) * lifetime;
|
|
39277
|
+
ry += rol.rotationY._evaluateCumulative(normalizedAge, rotRand) * lifetime;
|
|
39278
|
+
rz += rolZ;
|
|
39279
|
+
} else if (this.main.startRotation3D) {
|
|
39280
|
+
rz += rolZ;
|
|
39281
|
+
} else {
|
|
39282
|
+
rx += rolZ; // 2D rotation: shader stores the Z angle in a_StartRotation0.x
|
|
39283
|
+
}
|
|
39284
|
+
}
|
|
39285
|
+
parentRotation.set(rx, ry, rz);
|
|
39286
|
+
};
|
|
38392
39287
|
_proto._freeRetiredParticles = function _freeRetiredParticles() {
|
|
38393
39288
|
var frameCount = this._renderer.engine.time.frameCount;
|
|
38394
39289
|
while(this._firstRetiredElement !== this._firstActiveElement){
|
|
@@ -38532,7 +39427,7 @@ __decorate([
|
|
|
38532
39427
|
max.set(Math.max(max.x, boundsArray[offset + 3]), Math.max(max.y, boundsArray[offset + 4]), Math.max(max.z, boundsArray[offset + 5]));
|
|
38533
39428
|
};
|
|
38534
39429
|
_proto._calculateTransformedBounds = function _calculateTransformedBounds(maxLifetime, origin, out) {
|
|
38535
|
-
var velMinMaxX = ParticleGenerator._tempVector20, velMinMaxY = ParticleGenerator._tempVector21, velMinMaxZ = ParticleGenerator._tempVector22, worldOffsetMin = ParticleGenerator._tempVector30, worldOffsetMax = ParticleGenerator._tempVector31, rotateMat = ParticleGenerator._tempMat;
|
|
39430
|
+
var velMinMaxX = ParticleGenerator._tempVector20, velMinMaxY = ParticleGenerator._tempVector21, velMinMaxZ = ParticleGenerator._tempVector22, worldOffsetMin = ParticleGenerator._tempVector30, worldOffsetMax = ParticleGenerator._tempVector31, noiseBoundsExtents = ParticleGenerator._tempVector32, rotateMat = ParticleGenerator._tempMat;
|
|
38536
39431
|
worldOffsetMin.set(0, 0, 0);
|
|
38537
39432
|
worldOffsetMax.set(0, 0, 0);
|
|
38538
39433
|
var transform = this._renderer.entity.transform;
|
|
@@ -38575,27 +39470,89 @@ __decorate([
|
|
|
38575
39470
|
worldOffsetMax.set(worldOffsetMax.x + forceMinMaxX.y, worldOffsetMax.y + forceMinMaxY.y, worldOffsetMax.z + forceMinMaxZ.y);
|
|
38576
39471
|
}
|
|
38577
39472
|
}
|
|
38578
|
-
out.transform(rotateMat);
|
|
38579
|
-
min.add(worldOffsetMin);
|
|
38580
|
-
max.add(worldOffsetMax);
|
|
38581
|
-
// Noise module impact: noise output is normalized to [-1, 1],
|
|
38582
|
-
// max displacement = |strength_max|
|
|
38583
39473
|
var noise = this.noise;
|
|
38584
|
-
|
|
38585
|
-
|
|
38586
|
-
|
|
38587
|
-
|
|
38588
|
-
|
|
38589
|
-
|
|
38590
|
-
|
|
38591
|
-
|
|
39474
|
+
this._getNoiseBoundsExtents(maxLifetime, noiseBoundsExtents);
|
|
39475
|
+
var needTransformFeedback = velocityOverLifetime._needTransformFeedback();
|
|
39476
|
+
var orbitalActive = needTransformFeedback && velocityOverLifetime._isOrbitalActive();
|
|
39477
|
+
if (needTransformFeedback) {
|
|
39478
|
+
var centerOffset = velocityOverLifetime.centerOffset;
|
|
39479
|
+
var radialReach = 0;
|
|
39480
|
+
if (velocityOverLifetime._isRadialActive()) {
|
|
39481
|
+
this._getExtremeValueFromZero(velocityOverLifetime.radial, velMinMaxX);
|
|
39482
|
+
radialReach = Math.max(Math.abs(velMinMaxX.x), Math.abs(velMinMaxX.y)) * maxLifetime;
|
|
39483
|
+
}
|
|
39484
|
+
if (orbitalActive) {
|
|
39485
|
+
var dx = Math.max(Math.abs(min.x - centerOffset.x), Math.abs(max.x - centerOffset.x));
|
|
39486
|
+
var dy = Math.max(Math.abs(min.y - centerOffset.y), Math.abs(max.y - centerOffset.y));
|
|
39487
|
+
var dz = Math.max(Math.abs(min.z - centerOffset.z), Math.abs(max.z - centerOffset.z));
|
|
39488
|
+
var worldReach = this._getRangeReach(worldOffsetMin, worldOffsetMax);
|
|
39489
|
+
var noiseReach = this._getVectorReach(noiseBoundsExtents);
|
|
39490
|
+
var gravityReach = this._getGravityBoundsReach(maxLifetime);
|
|
39491
|
+
var reach = Math.sqrt(dx * dx + dy * dy + dz * dz) + worldReach + noiseReach + gravityReach + radialReach;
|
|
39492
|
+
min.set(Math.min(min.x, centerOffset.x - reach), Math.min(min.y, centerOffset.y - reach), Math.min(min.z, centerOffset.z - reach));
|
|
39493
|
+
max.set(Math.max(max.x, centerOffset.x + reach), Math.max(max.y, centerOffset.y + reach), Math.max(max.z, centerOffset.z + reach));
|
|
39494
|
+
} else if (radialReach > 0) {
|
|
39495
|
+
min.set(min.x - radialReach, min.y - radialReach, min.z - radialReach);
|
|
39496
|
+
max.set(max.x + radialReach, max.y + radialReach, max.z + radialReach);
|
|
39497
|
+
}
|
|
39498
|
+
}
|
|
39499
|
+
out.transform(rotateMat);
|
|
39500
|
+
if (!orbitalActive) {
|
|
39501
|
+
min.add(worldOffsetMin);
|
|
39502
|
+
max.add(worldOffsetMax);
|
|
39503
|
+
if (noise.enabled) {
|
|
39504
|
+
min.set(min.x - noiseBoundsExtents.x, min.y - noiseBoundsExtents.y, min.z - noiseBoundsExtents.z);
|
|
39505
|
+
max.set(max.x + noiseBoundsExtents.x, max.y + noiseBoundsExtents.y, max.z + noiseBoundsExtents.z);
|
|
38592
39506
|
}
|
|
38593
|
-
min.set(min.x - noiseMaxX, min.y - noiseMaxY, min.z - noiseMaxZ);
|
|
38594
|
-
max.set(max.x + noiseMaxX, max.y + noiseMaxY, max.z + noiseMaxZ);
|
|
38595
39507
|
}
|
|
38596
39508
|
min.add(worldPosition);
|
|
38597
39509
|
max.add(worldPosition);
|
|
38598
39510
|
};
|
|
39511
|
+
_proto._useOrbitalBounds = function _useOrbitalBounds() {
|
|
39512
|
+
var velocityOverLifetime = this.velocityOverLifetime;
|
|
39513
|
+
return velocityOverLifetime._needTransformFeedback() && velocityOverLifetime._isOrbitalActive();
|
|
39514
|
+
};
|
|
39515
|
+
_proto._getNoiseBoundsExtents = function _getNoiseBoundsExtents(maxLifetime, out) {
|
|
39516
|
+
var noise = this.noise;
|
|
39517
|
+
if (!noise.enabled) {
|
|
39518
|
+
out.set(0, 0, 0);
|
|
39519
|
+
return;
|
|
39520
|
+
}
|
|
39521
|
+
var noiseMaxX, noiseMaxY, noiseMaxZ;
|
|
39522
|
+
if (noise.separateAxes) {
|
|
39523
|
+
noiseMaxX = this._getCurveMagnitudeFromZero(noise.strengthX);
|
|
39524
|
+
noiseMaxY = this._getCurveMagnitudeFromZero(noise.strengthY);
|
|
39525
|
+
noiseMaxZ = this._getCurveMagnitudeFromZero(noise.strengthZ);
|
|
39526
|
+
} else {
|
|
39527
|
+
noiseMaxX = noiseMaxY = noiseMaxZ = this._getCurveMagnitudeFromZero(noise.strengthX);
|
|
39528
|
+
}
|
|
39529
|
+
out.set(noiseMaxX * maxLifetime, noiseMaxY * maxLifetime, noiseMaxZ * maxLifetime);
|
|
39530
|
+
};
|
|
39531
|
+
_proto._getGravityBoundsReach = function _getGravityBoundsReach(maxLifetime) {
|
|
39532
|
+
var modifierMinMax = ParticleGenerator._tempVector20;
|
|
39533
|
+
this._getExtremeValueFromZero(this.main.gravityModifier, modifierMinMax);
|
|
39534
|
+
var coefficient = 0.5 * maxLifetime * maxLifetime;
|
|
39535
|
+
var minGravityEffect = modifierMinMax.x * coefficient;
|
|
39536
|
+
var maxGravityEffect = modifierMinMax.y * coefficient;
|
|
39537
|
+
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;
|
|
39538
|
+
var gravityBoundsExtents = ParticleGenerator._tempVector33;
|
|
39539
|
+
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)));
|
|
39540
|
+
return this._getVectorReach(gravityBoundsExtents);
|
|
39541
|
+
};
|
|
39542
|
+
_proto._getRangeReach = function _getRangeReach(min, max) {
|
|
39543
|
+
var x = Math.max(Math.abs(min.x), Math.abs(max.x));
|
|
39544
|
+
var y = Math.max(Math.abs(min.y), Math.abs(max.y));
|
|
39545
|
+
var z = Math.max(Math.abs(min.z), Math.abs(max.z));
|
|
39546
|
+
return Math.sqrt(x * x + y * y + z * z);
|
|
39547
|
+
};
|
|
39548
|
+
_proto._getVectorReach = function _getVectorReach(value) {
|
|
39549
|
+
return Math.sqrt(value.x * value.x + value.y * value.y + value.z * value.z);
|
|
39550
|
+
};
|
|
39551
|
+
_proto._getCurveMagnitudeFromZero = function _getCurveMagnitudeFromZero(curve) {
|
|
39552
|
+
var minMax = ParticleGenerator._tempVector20;
|
|
39553
|
+
this._getExtremeValueFromZero(curve, minMax);
|
|
39554
|
+
return Math.max(Math.abs(minMax.x), Math.abs(minMax.y));
|
|
39555
|
+
};
|
|
38599
39556
|
_proto._addGravityToBounds = function _addGravityToBounds(maxLifetime, origin, out) {
|
|
38600
39557
|
var originMin = origin.min, originMax = origin.max;
|
|
38601
39558
|
var modifierMinMax = ParticleGenerator._tempVector20;
|
|
@@ -38657,8 +39614,10 @@ ParticleGenerator._tempVector22 = new engineMath.Vector2();
|
|
|
38657
39614
|
ParticleGenerator._tempVector30 = new engineMath.Vector3();
|
|
38658
39615
|
ParticleGenerator._tempVector31 = new engineMath.Vector3();
|
|
38659
39616
|
ParticleGenerator._tempVector32 = new engineMath.Vector3();
|
|
39617
|
+
ParticleGenerator._tempVector33 = new engineMath.Vector3();
|
|
38660
39618
|
ParticleGenerator._tempMat = new engineMath.Matrix();
|
|
38661
|
-
ParticleGenerator.
|
|
39619
|
+
ParticleGenerator._tempColor = new engineMath.Color();
|
|
39620
|
+
ParticleGenerator._tempQuat0 = new engineMath.Quaternion();
|
|
38662
39621
|
ParticleGenerator._tempParticleRenderers = new Array();
|
|
38663
39622
|
ParticleGenerator._particleIncreaseCount = 128;
|
|
38664
39623
|
ParticleGenerator._transformedBoundsIncreaseCount = 16;
|
|
@@ -38693,6 +39652,9 @@ __decorate([
|
|
|
38693
39652
|
__decorate([
|
|
38694
39653
|
deepClone
|
|
38695
39654
|
], ParticleGenerator.prototype, "noise", void 0);
|
|
39655
|
+
__decorate([
|
|
39656
|
+
deepClone
|
|
39657
|
+
], ParticleGenerator.prototype, "subEmitters", void 0);
|
|
38696
39658
|
__decorate([
|
|
38697
39659
|
deepClone
|
|
38698
39660
|
], ParticleGenerator.prototype, "customData", void 0);
|
|
@@ -38732,6 +39694,9 @@ __decorate([
|
|
|
38732
39694
|
__decorate([
|
|
38733
39695
|
ignoreClone
|
|
38734
39696
|
], ParticleGenerator.prototype, "_feedbackBindingIndex", void 0);
|
|
39697
|
+
__decorate([
|
|
39698
|
+
ignoreClone
|
|
39699
|
+
], ParticleGenerator.prototype, "_feedbackReadback", void 0);
|
|
38735
39700
|
__decorate([
|
|
38736
39701
|
ignoreClone
|
|
38737
39702
|
], ParticleGenerator.prototype, "_isPlaying", void 0);
|
|
@@ -38762,6 +39727,27 @@ __decorate([
|
|
|
38762
39727
|
__decorate([
|
|
38763
39728
|
ignoreClone
|
|
38764
39729
|
], ParticleGenerator.prototype, "_playStartDelay", void 0);
|
|
39730
|
+
__decorate([
|
|
39731
|
+
ignoreClone
|
|
39732
|
+
], ParticleGenerator.prototype, "_eventPos", void 0);
|
|
39733
|
+
__decorate([
|
|
39734
|
+
ignoreClone
|
|
39735
|
+
], ParticleGenerator.prototype, "_eventColor", void 0);
|
|
39736
|
+
__decorate([
|
|
39737
|
+
ignoreClone
|
|
39738
|
+
], ParticleGenerator.prototype, "_eventSize", void 0);
|
|
39739
|
+
__decorate([
|
|
39740
|
+
ignoreClone
|
|
39741
|
+
], ParticleGenerator.prototype, "_eventRotation", void 0);
|
|
39742
|
+
__decorate([
|
|
39743
|
+
ignoreClone
|
|
39744
|
+
], ParticleGenerator.prototype, "_eventDir", void 0);
|
|
39745
|
+
__decorate([
|
|
39746
|
+
ignoreClone
|
|
39747
|
+
], ParticleGenerator.prototype, "_emitLocalPos", void 0);
|
|
39748
|
+
__decorate([
|
|
39749
|
+
ignoreClone
|
|
39750
|
+
], ParticleGenerator.prototype, "_emitDirection", void 0);
|
|
38765
39751
|
|
|
38766
39752
|
/**
|
|
38767
39753
|
* Base material for visual effects like particles and trails.
|
|
@@ -40466,7 +41452,14 @@ var cacheDir = new engineMath.Vector3();
|
|
|
40466
41452
|
* Suspend the audio context.
|
|
40467
41453
|
* @returns A promise that resolves when the audio context is suspended
|
|
40468
41454
|
*/ AudioManager.suspend = function suspend() {
|
|
40469
|
-
|
|
41455
|
+
// No context means nothing is playing: suspending is a no-op and must NOT flag a caller-suspend
|
|
41456
|
+
// (a ghost flag would later block foreground recovery), and don't create a cold context just to suspend
|
|
41457
|
+
var context = AudioManager._context;
|
|
41458
|
+
if (!context) {
|
|
41459
|
+
return Promise.resolve();
|
|
41460
|
+
}
|
|
41461
|
+
AudioManager._suspendedByCaller = true;
|
|
41462
|
+
return context.suspend();
|
|
40470
41463
|
};
|
|
40471
41464
|
/**
|
|
40472
41465
|
* Resume the audio context.
|
|
@@ -40474,6 +41467,7 @@ var cacheDir = new engineMath.Vector3();
|
|
|
40474
41467
|
* @returns A promise that resolves when the audio context is resumed
|
|
40475
41468
|
*/ AudioManager.resume = function resume() {
|
|
40476
41469
|
var _AudioManager;
|
|
41470
|
+
AudioManager._suspendedByCaller = false;
|
|
40477
41471
|
var __resumePromise;
|
|
40478
41472
|
return (__resumePromise = (_AudioManager = AudioManager)._resumePromise) != null ? __resumePromise : _AudioManager._resumePromise = AudioManager.getContext().resume().then(function() {
|
|
40479
41473
|
AudioManager._needsUserGestureResume = false;
|
|
@@ -40488,7 +41482,9 @@ var cacheDir = new engineMath.Vector3();
|
|
|
40488
41482
|
if (!context) {
|
|
40489
41483
|
AudioManager._context = context = new window.AudioContext();
|
|
40490
41484
|
document.addEventListener("visibilitychange", AudioManager._onVisibilityChange);
|
|
40491
|
-
// iOS Safari
|
|
41485
|
+
// iOS Safari bfcache restore fires pageshow (persisted) but NOT visibilitychange, so recover here too
|
|
41486
|
+
window.addEventListener("pageshow", AudioManager._onPageShow);
|
|
41487
|
+
// iOS Safari requires a user gesture to resume the AudioContext
|
|
40492
41488
|
document.addEventListener("touchstart", AudioManager._resumeAfterInterruption, {
|
|
40493
41489
|
passive: true
|
|
40494
41490
|
});
|
|
@@ -40516,27 +41512,62 @@ var cacheDir = new engineMath.Vector3();
|
|
|
40516
41512
|
return AudioManager.getContext().state === "running";
|
|
40517
41513
|
};
|
|
40518
41514
|
AudioManager._onVisibilityChange = function _onVisibilityChange() {
|
|
40519
|
-
if (
|
|
40520
|
-
//
|
|
40521
|
-
//
|
|
40522
|
-
|
|
40523
|
-
|
|
40524
|
-
|
|
40525
|
-
AudioManager.
|
|
41515
|
+
if (document.hidden) {
|
|
41516
|
+
var // Desktop/Android don't auto-suspend a running WebAudio context when backgrounded (only iOS does),
|
|
41517
|
+
// so suspend here to stop audio in the background; only if a context already exists (don't create one)
|
|
41518
|
+
_AudioManager__context;
|
|
41519
|
+
(_AudioManager__context = AudioManager._context) == null ? void 0 : _AudioManager__context.suspend().catch(function() {});
|
|
41520
|
+
} else {
|
|
41521
|
+
AudioManager._recoverPlaybackContext();
|
|
41522
|
+
}
|
|
41523
|
+
};
|
|
41524
|
+
AudioManager._recoverPlaybackContext = function _recoverPlaybackContext() {
|
|
41525
|
+
// Returning to foreground with a non-running context (and not a deliberate pause): iOS leaves it
|
|
41526
|
+
// "interrupted", which cannot be resumed directly; suspend() first transitions it to "suspended",
|
|
41527
|
+
// then resume() restarts the pipeline https://bugs.webkit.org/show_bug.cgi?id=263627
|
|
41528
|
+
// _recovering guards re-entry: a bfcache restore fires both visibilitychange and pageshow
|
|
41529
|
+
if (AudioManager._recovering || document.hidden || AudioManager._suspendedByCaller || AudioManager._playingCount <= 0 || AudioManager.isAudioContextRunning()) {
|
|
41530
|
+
return;
|
|
41531
|
+
}
|
|
41532
|
+
AudioManager._recovering = true;
|
|
41533
|
+
AudioManager._needsUserGestureResume = true; // fallback if the auto-resume below is rejected
|
|
41534
|
+
var context = AudioManager.getContext();
|
|
41535
|
+
context.suspend().catch(function() {});
|
|
41536
|
+
// 100ms empirical delay (resume too soon after suspend is unreliable on iOS); _recovering is cleared
|
|
41537
|
+
// on the timer rather than off a promise because iOS may never settle suspend/resume in interrupted
|
|
41538
|
+
setTimeout(function() {
|
|
41539
|
+
AudioManager._recovering = false;
|
|
41540
|
+
if (document.hidden || AudioManager._suspendedByCaller) {
|
|
41541
|
+
return;
|
|
41542
|
+
}
|
|
41543
|
+
// Go through AudioManager.resume() so _resumePromise coalesces any gesture-resume racing us during
|
|
41544
|
+
// the slow iOS interrupted->running transition; a bare context.resume() here wouldn't dedupe
|
|
41545
|
+
AudioManager.resume().catch(function() {});
|
|
41546
|
+
}, 100);
|
|
41547
|
+
};
|
|
41548
|
+
AudioManager._onPageShow = function _onPageShow(event) {
|
|
41549
|
+
// iOS Safari bfcache restore (persisted) needs recovery; a normal load has no suspended context
|
|
41550
|
+
if (event.persisted) {
|
|
41551
|
+
AudioManager._recoverPlaybackContext();
|
|
40526
41552
|
}
|
|
40527
41553
|
};
|
|
40528
41554
|
AudioManager._resumeAfterInterruption = function _resumeAfterInterruption() {
|
|
40529
|
-
|
|
40530
|
-
|
|
40531
|
-
|
|
40532
|
-
|
|
41555
|
+
// iOS Safari gesture fallback for when auto-resume is blocked.
|
|
41556
|
+
// _recovering: don't bypass the 100ms delay (would resume on a still-interrupted context)
|
|
41557
|
+
if (AudioManager._recovering || AudioManager._suspendedByCaller || !AudioManager._needsUserGestureResume) {
|
|
41558
|
+
return;
|
|
40533
41559
|
}
|
|
41560
|
+
AudioManager.resume().catch(function(e) {
|
|
41561
|
+
console.warn("Failed to resume AudioContext:", e);
|
|
41562
|
+
});
|
|
40534
41563
|
};
|
|
40535
41564
|
return AudioManager;
|
|
40536
41565
|
}();
|
|
40537
41566
|
/** @internal */ AudioManager._playingCount = 0;
|
|
40538
41567
|
AudioManager._resumePromise = null;
|
|
40539
41568
|
AudioManager._needsUserGestureResume = false;
|
|
41569
|
+
AudioManager._suspendedByCaller = false;
|
|
41570
|
+
AudioManager._recovering = false;
|
|
40540
41571
|
|
|
40541
41572
|
/**
|
|
40542
41573
|
* Audio Source Component.
|
|
@@ -40546,8 +41577,6 @@ AudioManager._needsUserGestureResume = false;
|
|
|
40546
41577
|
var _this;
|
|
40547
41578
|
_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;
|
|
40548
41579
|
_this._onPlayEnd = _this._onPlayEnd.bind(_this);
|
|
40549
|
-
_this._gainNode = AudioManager.getContext().createGain();
|
|
40550
|
-
_this._gainNode.connect(AudioManager.getGainNode());
|
|
40551
41580
|
return _this;
|
|
40552
41581
|
}
|
|
40553
41582
|
var _proto = AudioSource.prototype;
|
|
@@ -40559,6 +41588,10 @@ AudioManager._needsUserGestureResume = false;
|
|
|
40559
41588
|
if (!((_this__clip = this._clip) == null ? void 0 : _this__clip._getAudioSource()) || this._isPlaying || this._pendingPlay) {
|
|
40560
41589
|
return;
|
|
40561
41590
|
}
|
|
41591
|
+
// Hidden page: don't start (would leak a sound) and don't pend (would replay out of sync) -> drop
|
|
41592
|
+
if (document.hidden) {
|
|
41593
|
+
return;
|
|
41594
|
+
}
|
|
40562
41595
|
if (AudioManager.isAudioContextRunning()) {
|
|
40563
41596
|
this._startPlayback();
|
|
40564
41597
|
} else {
|
|
@@ -40571,8 +41604,8 @@ AudioManager._needsUserGestureResume = false;
|
|
|
40571
41604
|
return;
|
|
40572
41605
|
}
|
|
40573
41606
|
_this._pendingPlay = false;
|
|
40574
|
-
// Check if still valid to play after async resume
|
|
40575
|
-
if (_this._destroyed || !_this.enabled || !_this._clip) {
|
|
41607
|
+
// Check if still valid to play after async resume (page may have been hidden meanwhile)
|
|
41608
|
+
if (_this._destroyed || !_this.enabled || !_this._clip || document.hidden) {
|
|
40576
41609
|
return;
|
|
40577
41610
|
}
|
|
40578
41611
|
_this._startPlayback();
|
|
@@ -40589,10 +41622,11 @@ AudioManager._needsUserGestureResume = false;
|
|
|
40589
41622
|
if (this._isPlaying) {
|
|
40590
41623
|
this._clearSourceNode();
|
|
40591
41624
|
this._isPlaying = false;
|
|
40592
|
-
this._pausedTime = -1;
|
|
40593
|
-
this._playTime = -1;
|
|
40594
41625
|
AudioManager._playingCount--;
|
|
40595
41626
|
}
|
|
41627
|
+
// stop() always resets to the start, including from a paused state (where _isPlaying is already false)
|
|
41628
|
+
this._pausedTime = -1;
|
|
41629
|
+
this._playTime = -1;
|
|
40596
41630
|
};
|
|
40597
41631
|
/**
|
|
40598
41632
|
* Pauses playing the clip.
|
|
@@ -40610,7 +41644,7 @@ AudioManager._needsUserGestureResume = false;
|
|
|
40610
41644
|
*/ _proto._cloneTo = function _cloneTo(target) {
|
|
40611
41645
|
var _target__clip;
|
|
40612
41646
|
(_target__clip = target._clip) == null ? void 0 : _target__clip._addReferCount(1);
|
|
40613
|
-
|
|
41647
|
+
// _volume is field-cloned; its gain node is applied lazily on first play
|
|
40614
41648
|
};
|
|
40615
41649
|
/**
|
|
40616
41650
|
* @internal
|
|
@@ -40632,6 +41666,15 @@ AudioManager._needsUserGestureResume = false;
|
|
|
40632
41666
|
_proto._onPlayEnd = function _onPlayEnd() {
|
|
40633
41667
|
this.stop();
|
|
40634
41668
|
};
|
|
41669
|
+
_proto._ensureGainNode = function _ensureGainNode() {
|
|
41670
|
+
var gainNode = this._gainNode;
|
|
41671
|
+
if (!gainNode) {
|
|
41672
|
+
this._gainNode = gainNode = AudioManager.getContext().createGain();
|
|
41673
|
+
gainNode.connect(AudioManager.getGainNode());
|
|
41674
|
+
gainNode.gain.setValueAtTime(this._volume, AudioManager.getContext().currentTime);
|
|
41675
|
+
}
|
|
41676
|
+
return gainNode;
|
|
41677
|
+
};
|
|
40635
41678
|
_proto._startPlayback = function _startPlayback() {
|
|
40636
41679
|
var startTime = this._pausedTime > 0 ? this._pausedTime - this._playTime : 0;
|
|
40637
41680
|
this._initSourceNode(startTime);
|
|
@@ -40643,13 +41686,17 @@ AudioManager._needsUserGestureResume = false;
|
|
|
40643
41686
|
_proto._initSourceNode = function _initSourceNode(startTime) {
|
|
40644
41687
|
var context = AudioManager.getContext();
|
|
40645
41688
|
var sourceNode = context.createBufferSource();
|
|
40646
|
-
|
|
41689
|
+
var buffer = this._clip._getAudioSource();
|
|
41690
|
+
sourceNode.buffer = buffer;
|
|
40647
41691
|
sourceNode.playbackRate.value = this._playbackRate;
|
|
40648
41692
|
sourceNode.loop = this._loop;
|
|
40649
41693
|
sourceNode.onended = this._onPlayEnd;
|
|
40650
41694
|
this._sourceNode = sourceNode;
|
|
40651
|
-
sourceNode.connect(this.
|
|
40652
|
-
|
|
41695
|
+
sourceNode.connect(this._ensureGainNode());
|
|
41696
|
+
// startTime is total elapsed time; for a looping clip wrap it into the buffer to keep the loop phase
|
|
41697
|
+
// (start()'s offset clamps past the end, it does not wrap)
|
|
41698
|
+
var offset = this._loop && buffer.duration > 0 ? startTime % buffer.duration : startTime;
|
|
41699
|
+
sourceNode.start(0, offset);
|
|
40653
41700
|
};
|
|
40654
41701
|
_proto._clearSourceNode = function _clearSourceNode() {
|
|
40655
41702
|
this._sourceNode.stop();
|
|
@@ -40692,9 +41739,11 @@ AudioManager._needsUserGestureResume = false;
|
|
|
40692
41739
|
return this._volume;
|
|
40693
41740
|
},
|
|
40694
41741
|
set: function set(value) {
|
|
41742
|
+
var // No node yet -> _ensureGainNode() applies _volume on first play
|
|
41743
|
+
_this__gainNode;
|
|
40695
41744
|
value = Math.min(Math.max(0, value), 1.0);
|
|
40696
41745
|
this._volume = value;
|
|
40697
|
-
this._gainNode.gain.setValueAtTime(value, AudioManager.getContext().currentTime);
|
|
41746
|
+
(_this__gainNode = this._gainNode) == null ? void 0 : _this__gainNode.gain.setValueAtTime(value, AudioManager.getContext().currentTime);
|
|
40698
41747
|
}
|
|
40699
41748
|
},
|
|
40700
41749
|
{
|
|
@@ -40806,6 +41855,7 @@ __decorate([
|
|
|
40806
41855
|
Polyfill.registerPolyfill = function registerPolyfill() {
|
|
40807
41856
|
Polyfill._registerMatchAll();
|
|
40808
41857
|
Polyfill._registerAudioContext();
|
|
41858
|
+
Polyfill._registerOfflineAudioContext();
|
|
40809
41859
|
Polyfill._registerTextMetrics();
|
|
40810
41860
|
Polyfill._registerPromiseFinally();
|
|
40811
41861
|
};
|
|
@@ -40870,20 +41920,32 @@ __decorate([
|
|
|
40870
41920
|
if (!window.AudioContext && window.webkitAudioContext) {
|
|
40871
41921
|
Logger.info("Polyfill window.AudioContext");
|
|
40872
41922
|
window.AudioContext = window.webkitAudioContext;
|
|
40873
|
-
|
|
40874
|
-
|
|
40875
|
-
|
|
40876
|
-
|
|
40877
|
-
|
|
40878
|
-
|
|
40879
|
-
|
|
40880
|
-
|
|
40881
|
-
|
|
40882
|
-
|
|
40883
|
-
|
|
41923
|
+
Polyfill._promisifyDecodeAudioData(AudioContext.prototype);
|
|
41924
|
+
}
|
|
41925
|
+
};
|
|
41926
|
+
Polyfill._registerOfflineAudioContext = function _registerOfflineAudioContext() {
|
|
41927
|
+
// iOS 14.0 and earlier expose only webkitOfflineAudioContext, with callback-form decodeAudioData
|
|
41928
|
+
if (!window.OfflineAudioContext && window.webkitOfflineAudioContext) {
|
|
41929
|
+
Logger.info("Polyfill window.OfflineAudioContext");
|
|
41930
|
+
window.OfflineAudioContext = window.webkitOfflineAudioContext;
|
|
41931
|
+
Polyfill._promisifyDecodeAudioData(OfflineAudioContext.prototype);
|
|
41932
|
+
}
|
|
41933
|
+
};
|
|
41934
|
+
// Wrap the old callback-form decodeAudioData (on prefixed iOS contexts) into the modern Promise form
|
|
41935
|
+
Polyfill._promisifyDecodeAudioData = function _promisifyDecodeAudioData(proto) {
|
|
41936
|
+
var originalDecodeAudioData = proto.decodeAudioData;
|
|
41937
|
+
proto.decodeAudioData = function(arrayBuffer, successCallback, errorCallback) {
|
|
41938
|
+
var _this = this;
|
|
41939
|
+
return new Promise(function(resolve, reject) {
|
|
41940
|
+
originalDecodeAudioData.call(_this, arrayBuffer, function(buffer) {
|
|
41941
|
+
successCallback == null ? void 0 : successCallback(buffer);
|
|
41942
|
+
resolve(buffer);
|
|
41943
|
+
}, function(error) {
|
|
41944
|
+
errorCallback == null ? void 0 : errorCallback(error);
|
|
41945
|
+
reject(error);
|
|
40884
41946
|
});
|
|
40885
|
-
};
|
|
40886
|
-
}
|
|
41947
|
+
});
|
|
41948
|
+
};
|
|
40887
41949
|
};
|
|
40888
41950
|
Polyfill._registerTextMetrics = function _registerTextMetrics() {
|
|
40889
41951
|
// 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.
|
|
@@ -41075,6 +42137,8 @@ exports.ParticleShapeArcMode = ParticleShapeArcMode;
|
|
|
41075
42137
|
exports.ParticleShapeType = ParticleShapeType;
|
|
41076
42138
|
exports.ParticleSimulationSpace = ParticleSimulationSpace;
|
|
41077
42139
|
exports.ParticleStopMode = ParticleStopMode;
|
|
42140
|
+
exports.ParticleSubEmitterInheritProperty = ParticleSubEmitterInheritProperty;
|
|
42141
|
+
exports.ParticleSubEmitterType = ParticleSubEmitterType;
|
|
41078
42142
|
exports.PhysicsMaterial = PhysicsMaterial;
|
|
41079
42143
|
exports.PhysicsMaterialCombineMode = PhysicsMaterialCombineMode;
|
|
41080
42144
|
exports.PhysicsScene = PhysicsScene;
|
|
@@ -41164,6 +42228,8 @@ exports.SpriteTileMode = SpriteTileMode;
|
|
|
41164
42228
|
exports.StateMachineScript = StateMachineScript;
|
|
41165
42229
|
exports.StaticCollider = StaticCollider;
|
|
41166
42230
|
exports.StencilOperation = StencilOperation;
|
|
42231
|
+
exports.SubEmitter = SubEmitter;
|
|
42232
|
+
exports.SubEmittersModule = SubEmittersModule;
|
|
41167
42233
|
exports.SubFont = SubFont;
|
|
41168
42234
|
exports.SubMesh = SubMesh;
|
|
41169
42235
|
exports.SubPrimitive = SubPrimitive;
|