diff --git a/packages/dev/core/src/Particles/Node/Blocks/Update/basicPositionUpdateBlock.ts b/packages/dev/core/src/Particles/Node/Blocks/Update/basicPositionUpdateBlock.ts index 64a923d6325..23ded51de48 100644 --- a/packages/dev/core/src/Particles/Node/Blocks/Update/basicPositionUpdateBlock.ts +++ b/packages/dev/core/src/Particles/Node/Blocks/Update/basicPositionUpdateBlock.ts @@ -54,8 +54,8 @@ export class BasicPositionUpdateBlock extends NodeParticleBlock { const processPosition = (particle: Particle) => { state.particleContext = particle; state.systemContext = system; - particle.direction.scaleToRef(system._directionScale, system._scaledDirection); - particle.position.addInPlace(system._scaledDirection); + particle.direction.scaleToRef(particle._directionScale, particle._scaledDirection); + particle.position.addInPlace(particle._scaledDirection); }; const positionProcessing = { diff --git a/packages/dev/core/src/Particles/Node/nodeParticleBuildState.ts b/packages/dev/core/src/Particles/Node/nodeParticleBuildState.ts index 59726179969..cd331c27f46 100644 --- a/packages/dev/core/src/Particles/Node/nodeParticleBuildState.ts +++ b/packages/dev/core/src/Particles/Node/nodeParticleBuildState.ts @@ -115,8 +115,8 @@ export class NodeParticleBuildState { case NodeParticleContextualSources.Direction: return this.particleContext.direction; case NodeParticleContextualSources.ScaledDirection: - this.particleContext.direction.scaleToRef(this.systemContext._directionScale, this.systemContext._scaledDirection); - return this.systemContext._scaledDirection; + this.particleContext.direction.scaleToRef(this.particleContext._directionScale, this.particleContext._scaledDirection); + return this.particleContext._scaledDirection; case NodeParticleContextualSources.Color: return this.particleContext.color; case NodeParticleContextualSources.InitialColor: @@ -149,8 +149,8 @@ export class NodeParticleBuildState { this.particleContext.colorStep.scaleToRef(this.systemContext._scaledUpdateSpeed, this.systemContext._scaledColorStep); return this.systemContext._scaledColorStep; case NodeParticleContextualSources.LocalPositionUpdated: - this.particleContext.direction.scaleToRef(this.systemContext._directionScale, this.systemContext._scaledDirection); - this.particleContext._localPosition!.addInPlace(this.systemContext._scaledDirection); + this.particleContext.direction.scaleToRef(this.particleContext._directionScale, this.particleContext._scaledDirection); + this.particleContext._localPosition!.addInPlace(this.particleContext._scaledDirection); Vector3.TransformCoordinatesToRef(this.particleContext._localPosition!, this.systemContext._emitterWorldMatrix, this.particleContext.position); return this.particleContext.position; } diff --git a/packages/dev/core/src/Particles/particle.ts b/packages/dev/core/src/Particles/particle.ts index f233d601cec..e05bf4fbf05 100644 --- a/packages/dev/core/src/Particles/particle.ts +++ b/packages/dev/core/src/Particles/particle.ts @@ -132,6 +132,12 @@ export class Particle { /** @internal */ public _currentVelocity2 = 0; + /** @internal */ + public _directionScale: number; + + /** @internal */ + public _scaledDirection = Vector3.Zero(); + /** @internal */ public _currentLimitVelocityGradient: Nullable; /** @internal */ diff --git a/packages/dev/core/src/Particles/thinParticleSystem.function.ts b/packages/dev/core/src/Particles/thinParticleSystem.function.ts index 15ff6aa7304..5092ce83e91 100644 --- a/packages/dev/core/src/Particles/thinParticleSystem.function.ts +++ b/packages/dev/core/src/Particles/thinParticleSystem.function.ts @@ -120,7 +120,7 @@ export function _ProcessVelocityGradients(particle: Particle, system: ThinPartic particle._currentVelocity2 = (nextGradient).getFactor(); particle._currentVelocityGradient = currentGradient; } - system._directionScale *= Lerp(particle._currentVelocity1, particle._currentVelocity2, scale); + particle._directionScale *= Lerp(particle._currentVelocity1, particle._currentVelocity2, scale); }); } @@ -143,8 +143,8 @@ export function _ProcessLimitVelocityGradients(particle: Particle, system: ThinP } /** @internal */ -export function _ProcessDirection(particle: Particle, system: ThinParticleSystem) { - particle.direction.scaleToRef(system._directionScale, system._scaledDirection); +export function _ProcessDirection(particle: Particle) { + particle.direction.scaleToRef(particle._directionScale, particle._scaledDirection); } /** Position */ @@ -172,10 +172,10 @@ export function _CreateIsLocalData(particle: Particle, system: ThinParticleSyste /** @internal */ export function _ProcessPosition(particle: Particle, system: ThinParticleSystem) { if (system.isLocal && particle._localPosition) { - particle._localPosition!.addInPlace(system._scaledDirection); + particle._localPosition!.addInPlace(particle._scaledDirection); Vector3.TransformCoordinatesToRef(particle._localPosition!, system._emitterWorldMatrix, particle.position); } else { - particle.position.addInPlace(system._scaledDirection); + particle.position.addInPlace(particle._scaledDirection); } } @@ -204,7 +204,7 @@ export function _ProcessDragGradients(particle: Particle, system: ThinParticleSy const drag = Lerp(particle._currentDrag1, particle._currentDrag2, scale); - system._scaledDirection.scaleInPlace(1.0 - drag); + particle._scaledDirection.scaleInPlace(1.0 - drag); }); } diff --git a/packages/dev/core/src/Particles/thinParticleSystem.ts b/packages/dev/core/src/Particles/thinParticleSystem.ts index 71472393527..4b6f51fa348 100644 --- a/packages/dev/core/src/Particles/thinParticleSystem.ts +++ b/packages/dev/core/src/Particles/thinParticleSystem.ts @@ -197,8 +197,6 @@ export class ThinParticleSystem extends BaseParticleSystem implements IDisposabl /** @internal */ public _colorDiff = new Color4(0, 0, 0, 0); /** @internal */ - public _scaledDirection = Vector3.Zero(); - /** @internal */ public _scaledGravity = Vector3.Zero(); private _currentRenderId = -1; private _alive: boolean; @@ -283,8 +281,6 @@ export class ThinParticleSystem extends BaseParticleSystem implements IDisposabl private _noiseCreation: _IExecutionQueueItem; private _createQueueStart: Nullable<_IExecutionQueueItem> = null; - /** @internal */ - public _directionScale: number; /** @internal */ public _tempScaledUpdateSpeed: number; /** @internal */ @@ -716,7 +712,7 @@ export class ThinParticleSystem extends BaseParticleSystem implements IDisposabl } this._ratio = particle.age / particle.lifeTime; - this._directionScale = this._tempScaledUpdateSpeed; + particle._directionScale = this._tempScaledUpdateSpeed; // Processing queue let currentQueueItem = this._updateQueueStart;