From 67642997f70930eda9fbbdff853bdc7fcfa35611 Mon Sep 17 00:00:00 2001 From: zxx43 Date: Mon, 21 Sep 2026 17:07:35 +0800 Subject: [PATCH] modify emit rate (#352) * modify emit rate * fix eslint * fix eslint * fix eslint * fix --- cocos/particle/particle-system.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/cocos/particle/particle-system.ts b/cocos/particle/particle-system.ts index 7606a35bc7..234aea2b8a 100644 --- a/cocos/particle/particle-system.ts +++ b/cocos/particle/particle-system.ts @@ -42,7 +42,7 @@ import VelocityOvertimeModule from './animator/velocity-overtime'; import Burst from './burst'; import ShapeModule from './emitter/shape-module'; import { ParticleCullingMode, ParticleSpace } from './enum'; -import { particleEmitZAxis } from './particle-general-function'; +import { isCurveTwoValues, particleEmitZAxis } from './particle-general-function'; import ParticleSystemRenderer from './renderer/particle-system-renderer-data'; import TrailModule from './renderer/trail'; import { ParticleSystemRendererBase } from './renderer/particle-system-renderer-base'; @@ -141,7 +141,7 @@ export class ParticleSystem extends ModelRenderer { @range([0, Number.POSITIVE_INFINITY]) @displayOrder(10) @tooltip('i18n:particle_system.startSizeY') - @visible(function (this: ParticleSystem): boolean { return this.startSize3D; }) + @visible(function (this: ParticleSystem): boolean { return this.startSize3D; }) // eslint-disable-line func-names, comma-dangle public startSizeY = new CurveRange(); /** @@ -153,7 +153,7 @@ export class ParticleSystem extends ModelRenderer { @range([0, Number.POSITIVE_INFINITY]) @displayOrder(10) @tooltip('i18n:particle_system.startSizeZ') - @visible(function (this: ParticleSystem): boolean { return this.startSize3D; }) + @visible(function (this: ParticleSystem): boolean { return this.startSize3D; }) // eslint-disable-line func-names, comma-dangle public startSizeZ = new CurveRange(); /** @@ -184,7 +184,7 @@ export class ParticleSystem extends ModelRenderer { @radian @displayOrder(12) @tooltip('i18n:particle_system.startRotationX') - @visible(function (this: ParticleSystem): boolean { return this.startRotation3D; }) + @visible(function (this: ParticleSystem): boolean { return this.startRotation3D; }) // eslint-disable-line func-names, comma-dangle public startRotationX = new CurveRange(); /** @@ -196,7 +196,7 @@ export class ParticleSystem extends ModelRenderer { @radian @displayOrder(12) @tooltip('i18n:particle_system.startRotationY') - @visible(function (this: ParticleSystem): boolean { return this.startRotation3D; }) + @visible(function (this: ParticleSystem): boolean { return this.startRotation3D; }) // eslint-disable-line func-names, comma-dangle public startRotationY = new CurveRange(); /** @@ -1455,16 +1455,18 @@ export class ParticleSystem extends ModelRenderer { if (!self._isEmitting) return; + const randTime = isCurveTwoValues(self.rateOverTime) ? pseudoRandom(randomRangeInt(0, bits.INT_MAX)) : 1; // emit by rateOverTime - self._emitRateTimeCounter += self.rateOverTime.evaluate(self._time / self.duration, 1)! * dt; + self._emitRateTimeCounter += self.rateOverTime.evaluate(self._time / self.duration, randTime)! * dt; if (self._emitRateTimeCounter > 1) { const emitNum = Math.floor(self._emitRateTimeCounter); self._emitRateTimeCounter -= emitNum; self.emit(emitNum, dt); } + const randDist = isCurveTwoValues(self.rateOverDistance) ? pseudoRandom(randomRangeInt(0, bits.INT_MAX)) : 1; // emit by rateOverDistance - const rateOverDistance = self.rateOverDistance.evaluate(self._time / self.duration, 1)!; + const rateOverDistance = self.rateOverDistance.evaluate(self._time / self.duration, randDist)!; if (rateOverDistance > 0) { Vec3.copy(self._oldWPos, self._curWPos); self.node.getWorldPosition(self._curWPos);