Code viewer for World: Sushi

// Cloned by Mathias Bazin on 29 May 2018 from World "Cube de viande" by Mathias Bazin 
// Please leave this clone trail here.
 


// Cloned by Mathias Bazin on 29 May 2018 from World "One Cube World" by Starter user 
// Please leave this clone trail here.
 

const skycolor          = 'Beige';          // sky color

const objectsize        = 300;                  // size of object   

const startRadius       = 1500;                 // distance from centre we start the camera at

const maxRadius         = startRadius * 10;     // maximum distance from camera we render things 

const skycolorObject    = new THREE.Color ( skycolor.toLowerCase() );     

const texturefileRice = "/uploads/mathias/rice.jpg"
const texturefileSalmon = "/uploads/mathias/salmon.jpg"


function World() 
{ 
  // the object is a cube (each dimension equal): 
  var shapeRice     = new THREE.BoxGeometry ( objectsize + 300, objectsize, objectsize + 50);
  var rice         = new THREE.Mesh ( shapeRice );
  var textureRice = new THREE.ImageUtils.loadTexture ( texturefileRice );
  rice.material = new THREE.MeshBasicMaterial ( { map: textureRice } );  
  textureRice.minFilter = THREE.LinearFilter;
  rice.position.set(0,0,0);
  
  var shapeSalmon     = new THREE.BoxGeometry ( objectsize + 300, objectsize - 100, objectsize + 50);
  var salmon         = new THREE.Mesh ( shapeSalmon );
  var textureSalmon = new THREE.ImageUtils.loadTexture ( texturefileSalmon );
  salmon.material = new THREE.MeshBasicMaterial ( { map: textureSalmon } );  
  textureSalmon.minFilter = THREE.LinearFilter;
  salmon.position.set(0,250,0);
  
  var sushi = new THREE.Group();
  sushi.add(rice);
  sushi.add(salmon);

  //position of the sushi to spawn
  var x,y,z;
  x=y=z=0;
  
  function randomAtoB ( A, B )    // function to return random number from A to B                  
  {
    return ( A + ( Math.random() * (B-A) ) );       // Math.random() gives random real number from 0 to 1 
  }

  this.newRun = function() 
  {
    // start a 3D scene: 
    threeworld.init3d ( startRadius, maxRadius, skycolorObject ); 

    // add the object to the scene:
    sushi.position.set(x,y,z);
    threeworld.scene.add(sushi);
  };
  

}