sample method
Writes the spawn position and unit emission direction for particle
index into storage.
Implementation
@override
void sample(ParticleStorage storage, int index) {
// Area-uniform disc position in the XZ plane.
final rr = radius * math.sqrt(storage.randomFor(index, _saltA));
final theta = 2.0 * math.pi * storage.randomFor(index, _saltB);
storage.posX[index] = rr * math.cos(theta);
storage.posY[index] = 0.0;
storage.posZ[index] = rr * math.sin(theta);
// Solid-angle-uniform direction within the cone about +Y.
final cosT =
1.0 - storage.randomFor(index, _saltC) * (1.0 - math.cos(angle));
final sinT = math.sqrt(math.max(0.0, 1.0 - cosT * cosT));
final phi = 2.0 * math.pi * storage.randomFor(index, _saltD);
storage.velX[index] = sinT * math.cos(phi);
storage.velY[index] = cosT;
storage.velZ[index] = sinT * math.sin(phi);
}