Configuration object for the particle system. If not provided, uses default settings. See ParticleSystemConfig for all available options.
OptionalexternalNow: numberOptional custom timestamp in milliseconds. If not provided, uses Date.now().
Useful for synchronized particle systems or testing.
A ParticleSystem object containing:
instance: The THREE.Object3D that should be added to your sceneresumeEmitter(): Function to resume particle emissionpauseEmitter(): Function to pause particle emissiondispose(): Function to clean up resources and remove the particle systemimport { createParticleSystem, updateParticleSystems } from '@newkrok/three-particles';
// Create a basic particle system with default settings
const { instance, dispose } = createParticleSystem();
scene.add(instance);
// Create a custom fire effect
const fireEffect = createParticleSystem({
duration: 2.0,
looping: true,
startLifetime: { min: 0.5, max: 1.5 },
startSpeed: { min: 2, max: 4 },
startSize: { min: 0.5, max: 1.5 },
startColor: {
min: { r: 1.0, g: 0.3, b: 0.0 },
max: { r: 1.0, g: 0.8, b: 0.0 }
},
emission: { rateOverTime: 50 },
shape: {
shape: Shape.CONE,
cone: { angle: 10, radius: 0.2 }
}
});
scene.add(fireEffect.instance);
// In your animation loop
function animate(time) {
updateParticleSystems({ now: time, delta: deltaTime, elapsed: elapsedTime });
renderer.render(scene, camera);
}
// Clean up when done
fireEffect.dispose();
Creates a new particle system with the specified configuration.
This is the primary function for instantiating particle effects. It handles the complete setup of a particle system including geometry creation, material configuration, shader setup, and initialization of all particle properties.