build/SPE.js
function(
        attribute, index, base, radius, radiusSpread, radiusScale, radiusSpreadClamp, distributionClamp
    ) {
        'use strict';

        var depth = 2 * Math.random() - 1,
            t = 6.2832 * Math.random(),
            r = Math.sqrt( 1 - depth * depth ),
            rand = this.randomFloat( radius, radiusSpread ),
            x = 0,
            y = 0,
            z = 0;


        if ( radiusSpreadClamp ) {
            rand = Math.round( rand / radiusSpreadClamp ) * radiusSpreadClamp;
        }



        // Set position on sphere
        x = r * Math.cos( t ) * rand;
        y = r * Math.sin( t ) * rand;
        z = depth * rand;

        // Apply radius scale to this position
        x *= radiusScale.x;
        y *= radiusScale.y;
        z *= radiusScale.z;

        // Translate to the base position.
        x += base.x;
        y += base.y;
        z += base.z;

        // Set the values in the typed array.
        attribute.typedArray.setVec3Components( index, x, y, z );
    }
function(
        attribute, index, base, radius, radiusSpread, radiusScale, radiusSpreadClamp, distributionClamp
    ) {
        'use strict';

        var depth = 2 * Math.random() - 1,
            t = 6.2832 * Math.random(),
            r = Math.sqrt( 1 - depth * depth ),
            rand = this.randomFloat( radius, radiusSpread ),
            x = 0,
            y = 0,
            z = 0;


        if ( radiusSpreadClamp ) {
            rand = Math.round( rand / radiusSpreadClamp ) * radiusSpreadClamp;
        }



        // Set position on sphere
        x = r * Math.cos( t ) * rand;
        y = r * Math.sin( t ) * rand;
        z = depth * rand;

        // Apply radius scale to this position
        x *= radiusScale.x;
        y *= radiusScale.y;
        z *= radiusScale.z;

        // Translate to the base position.
        x += base.x;
        y += base.y;
        z += base.z;

        // Set the values in the typed array.
        attribute.typedArray.setVec3Components( index, x, y, z );
    }
function ( attribute , index , base , radius , radiusSpread , radiusScale , radiusSpreadClamp , distributionClamp ) { 'use strict' ; var depth = 2 * Math . random ( ) - 1 , t = 6.2832 * Math . random ( ) , r = Math . sqrt ( 1 - depth * depth ) , rand = this . randomFloat ( radius , radiusSpread ) , x = 0 , y = 0 , z = 0 ; if ( radiusSpreadClamp ) { rand = Math . round ( rand / radiusSpreadClamp ) * radiusSpreadClamp ; } // Set position on sphere x = r * Math . cos ( t ) * rand ; y = r * Math . sin ( t ) * rand ; z = depth * rand ; // Apply radius scale to this position x *= radiusScale . x ; y *= radiusScale . y ; z *= radiusScale . z ; // Translate to the base position. x += base . x ; y += base . y ; z += base . z ; // Set the values in the typed array. attribute . typedArray . setVec3Components ( index , x , y , z ) ; }
Assigns a random vector 3 value to an SPE.ShaderAttribute instance, projecting the
given values onto a sphere.

@param  {Object} attribute The instance of SPE.ShaderAttribute to save the result to.
@param  {Number} index     The offset in the attribute's TypedArray to save the result from.
@param  {Object} base              THREE.Vector3 instance describing the origin of the transform.
@param  {Number} radius            The radius of the sphere to project onto.
@param  {Number} radiusSpread      The amount of randomness to apply to the projection result
@param  {Object} radiusScale       THREE.Vector3 instance describing the scale of each axis of the sphere.
@param  {Number} radiusSpreadClamp What numeric multiple the projected value should be clamped to.
Assigns a random vector 3 value to an SPE . ShaderAttribute instance projecting the given values onto a sphere .