diff --git a/packages/quarks.core/src/IParticleSystem.ts b/packages/quarks.core/src/IParticleSystem.ts index ca93f33..174242c 100644 --- a/packages/quarks.core/src/IParticleSystem.ts +++ b/packages/quarks.core/src/IParticleSystem.ts @@ -135,6 +135,7 @@ export interface IParticleSystem { paused: boolean; pause(): void; + stop(): void; play(): void; restart(): void; diff --git a/packages/quarks.nodes/src/nodes/NodeVFX.ts b/packages/quarks.nodes/src/nodes/NodeVFX.ts index 848de8d..463caca 100644 --- a/packages/quarks.nodes/src/nodes/NodeVFX.ts +++ b/packages/quarks.nodes/src/nodes/NodeVFX.ts @@ -298,6 +298,11 @@ export class NodeVFX implements IParticleSystem { this.prewarmed = false; } + stop(): void { + this.restart(); + this.pause(); + } + pause() { this.paused = true; } diff --git a/packages/three.quarks/src/ParticleSystem.ts b/packages/three.quarks/src/ParticleSystem.ts index 18c0754..43a619b 100644 --- a/packages/three.quarks/src/ParticleSystem.ts +++ b/packages/three.quarks/src/ParticleSystem.ts @@ -778,14 +778,29 @@ export class ParticleSystem implements IParticleSystem { this.prewarmed = false; } + /** + * Pause the simulation of the particle system + */ pause() { this.paused = true; } + /** + * Unpause the simulation of the particle system + */ play() { this.paused = false; } + /** + * remove all existing particles, reset the particle system + * and pause at the beginning + */ + stop() { + this.restart(); + this.pause(); + } + private spawn(count: number, emissionState: EmissionState, matrix: Matrix4) { tempQ.setFromRotationMatrix(matrix as unknown as Matrix4); const translation = tempV; @@ -910,6 +925,10 @@ export class ParticleSystem implements IParticleSystem { if (this.emitter.parent) this.emitter.parent.remove(this.emitter); } + /** + * remove all existing particles, reset the particle system + * and restart the particle system + */ restart() { this.memory.length = 0; this.paused = false;