示例#1
0
  PlacementFunctions.randomShell = function( length , size ){

    var positions = [];
    var rotations = [];

    for( var i = 0; i < objectList.length; i ++ ){

      var object = objectList[i];

      var theta = 2 * Math.PI * Math.random();
      var phi   = 2 * Math.PI * ( Math.random() - .5 );

      var position = M.toCart( size , theta, phi  );

      positions.push( position );

      var pNorm = positions.clone().normalize();

      var rotation = new THREE.Euler();
      rotation.x = pNorm.x * 2 * Math.PI;
      rotation.y = pNorm.y * 2 * Math.PI;
      rotation.z = pNorm.z * 2 * Math.PI;

      rotations.push( rotation ); 

    }

    return { positions : positions , rotations : rotations }

  }
示例#2
0
  PlacementFunctions.randomCube = function( objectList , size ){

    for( var i = 0; i < objectList.length; i ++ ){

      var object = objectList[i];

      var theta = 2 * Math.PI * Math.random();
      var phi   = 2 * Math.PI * ( Math.random() - .5 );

      object.position = M.toCart( size , theta, phi );

    }

  }