Files

839 B
Raw Permalink Blame History

radiation_explosion.js — drawSphere() (satır 246)

← radiation_explosion.js · ← Master

function drawSphere(world, cx, cy, cz, radius, density)
{
    var samples = Math.floor(40 + radius * radius * 0.8);
    if (samples > 500) samples = 500;

    for (var i = 0; i < samples; i++)
    {
        var u = Math.random() * 2 - 1;
        var theta = Math.random() * Math.PI * 2;
        var sr = Math.sqrt(1 - u * u);
        var px = cx + 0.5 + radius * sr * Math.cos(theta);
        var py = cy + 0.5 + radius * u;
        var pz = cz + 0.5 + radius * sr * Math.sin(theta);

        world.spawnParticles(PT_RAD, true, px, py, pz, 1, 0, 0, 0, 0);
        if (i % 3 === 0)
            world.spawnParticles(PT_SPELL, true, px, py, pz, 1, 0, 0, 0, 0);
    }
}