function generateRandomPointOnHemisphere(origin, sphere) {
        var xD, zD, xR, yR, zR, r;
        var yD = new THREE.Vector3().subVectors(origin, sphere.center).normalize();

        xD = (yD.y !== 0 && yD.x === 0 && yD.z === 0) ? (new THREE.Vector3(1, 0, 0)) : (new THREE.Vector3().crossVectors(yD, new THREE.Vector3(0, 1, 0)).normalize());
        zD = new THREE.Vector3().crossVectors(xD, yD).normalize();

        r = sphere.radius;
        xR = mathFun.randomBetween(-1, 1);
        var zmax = Math.sin(Math.acos(xR));
        zR = mathFun.randomBetween(-zmax, zmax);

        xD.multiplyScalar(xR);
        zD.multiplyScalar(zR);

        var pointOnCylinder = new THREE.Vector3().addVectors(xD, zD);
        var len = pointOnCylinder.length();

        yR = Math.sin(Math.acos(len));
        yD.multiplyScalar(yR);

        return (pointOnCylinder.add(yD).normalize()).multiplyScalar(r);
    }
/**
     * This method henerates a random point on the visible hemisphere of a point light with radius
     * @param origin
     * @param sphere
     * @returns {*}
     */
This method henerates a random point on the visible hemisphere of a point light with radius
@param origin
@param sphere
@returns {*}
This method henerates a random point on the visible hemisphere of a point light with radius @param origin @param sphere @returns { * }
function generateRandomPointOnHemisphere(origin, sphere) {
        var xD, zD, xR, yR, zR, r;
        var yD = new THREE.Vector3().subVectors(origin, sphere.center).normalize();
        xD = (yD.y !== 0 && yD.x === 0 && yD.z === 0) ? (new THREE.Vector3(1, 0, 0)) : (new THREE.Vector3().crossVectors(yD, new THREE.Vector3(0, 1, 0)).normalize());
        zD = new THREE.Vector3().crossVectors(xD, yD).normalize();
        r = sphere.radius;
        xR = mathFun.randomBetween(-1, 1);
        var zmax = Math.sin(Math.acos(xR));
        zR = mathFun.randomBetween(-zmax, zmax);
        xD.multiplyScalar(xR);
        zD.multiplyScalar(zR);
        var pointOnCylinder = new THREE.Vector3().addVectors(xD, zD);
        var len = pointOnCylinder.length();
        yR = Math.sin(Math.acos(len));
        yD.multiplyScalar(yR);
        return (pointOnCylinder.add(yD).normalize()).multiplyScalar(r);
    }
function generateRandomPointOnHemisphere ( origin , sphere ) { var xD , zD , xR , yR , zR , r ; var yD = new THREE . Vector3 ( ) . subVectors ( origin , sphere . center ) . normalize ( ) ; xD = ( yD . y !== 0 && yD . x === 0 && yD . z === 0 ) ? ( new THREE . Vector3 ( 1 , 0 , 0 ) ) : ( new THREE . Vector3 ( ) . crossVectors ( yD , new THREE . Vector3 ( 0 , 1 , 0 ) ) . normalize ( ) ) ; zD = new THREE . Vector3 ( ) . crossVectors ( xD , yD ) . normalize ( ) ; r = sphere . radius ; xR = mathFun . randomBetween ( - 1 , 1 ) ; var zmax = Math . sin ( Math . acos ( xR ) ) ; zR = mathFun . randomBetween ( - zmax , zmax ) ; xD . multiplyScalar ( xR ) ; zD . multiplyScalar ( zR ) ; var pointOnCylinder = new THREE . Vector3 ( ) . addVectors ( xD , zD ) ; var len = pointOnCylinder . length ( ) ; yR = Math . sin ( Math . acos ( len ) ) ; yD . multiplyScalar ( yR ) ; return ( pointOnCylinder . add ( yD ) . normalize ( ) ) . multiplyScalar ( r ) ; }
This method henerates a random point on the visible hemisphere of a point light with radius
 @param origin
 @param sphere
 @returns {*}
This method henerates a random point on the visible hemisphere of a point light with radius @param origin @param sphere @returns { * }