emit method

  1. @override
void emit(
  1. ParticleBirth birth
)
override

Places ParticleBirth.particle for a burst at ParticleBirth.origin, in scene space, pointing along ParticleBirth.direction.

The system reuses one ParticleBirth for every particle it emits: read it here and do not keep it.

Implementation

@override
void emit(ParticleBirth birth) {
  final particle = birth.particle;
  final origin = birth.origin;
  final direction = birth.direction;
  final random = birth.random;
  particle.position.setValues(
    origin.x + (random.nextDouble() * 2.0 - 1.0) * _halfExtents.x,
    origin.y + (random.nextDouble() * 2.0 - 1.0) * _halfExtents.y,
    origin.z + (random.nextDouble() * 2.0 - 1.0) * _halfExtents.z,
  );
  final along = _along ?? direction;
  final v = speed.sample(random);
  particle.velocity
    ..setFrom(along)
    ..scale(v);
}