@newkrok/three-particles - v2.4.0
    Preparing search index...

    Function createParticleSystem

    • 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.

      Parameters

      • config: ParticleSystemConfig = DEFAULT_PARTICLE_SYSTEM_CONFIG

        Configuration object for the particle system. If not provided, uses default settings. See ParticleSystemConfig for all available options.

      • OptionalexternalNow: number

        Optional custom timestamp in milliseconds. If not provided, uses Date.now(). Useful for synchronized particle systems or testing.

      Returns ParticleSystem

      A ParticleSystem object containing:

      • instance: The THREE.Object3D that should be added to your scene
      • resumeEmitter(): Function to resume particle emission
      • pauseEmitter(): Function to pause particle emission
      • dispose(): Function to clean up resources and remove the particle system
      import { 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();