@pixi/3d
    Preparing search index...

    Interface EmitterShape

    Where a particle starts and which way it heads

    Implement it for a shape of your own. sample runs once per particle, so allocate in the constructor, never in sample.

    class MyRingShape implements EmitterShape {
    public radius = 2;

    public sample(rng: () => number, outPos: Vector3, outDir: Vector3): void {
    const angle = rng() * Math.PI * 2;

    outPos.set(Math.cos(angle) * this.radius, 0, Math.sin(angle) * this.radius);
    outDir.set(0, 1, 0);
    }
    }

    const halo = new ParticleSystem3D({ shape: new MyRingShape(), speed: 1 });
    interface EmitterShape {
        sample(rng: () => number, outPos: Vector3, outDir: Vector3): void;
    }

    Implemented by

    Index
    • Writes one spawn offset into outPos and a unit direction into outDir

      Parameters

      • rng: () => number

        The system's random source; use it, not Math.random, so seeded runs replay.

      • outPos: Vector3

        Receives the spawn offset, relative to the emitter.

      • outDir: Vector3

        Receives a unit direction.

      Returns void

      const preview = new Vector3();
      const heading = new Vector3();

      emitter.shape.sample(seededRandom('preview'), preview, heading);