Code viewer for World: One Cube World (Three.js) ...
// Cloned by Yiming Fu on 1 Dec 2022 from World "One Cube World (Three.js)" by Starter user 
// Please leave this clone trail here.

 const MUSICFILE = '/uploads/starter/SuspenseStrings.mp3';
 AB.backgroundMusic ( MUSICFILE );
 
 AB.socketStart();


const skycolor          = 'CadetBlue';           
const boxcolor          = 'BurlyWood';

const objectsize    = 400;                  // size of object   

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

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


// the object is a cube (each dimension equal): 
  
var shape       = new THREE.BoxGeometry ( 200, 100, 400 );
var material    = new THREE.MeshBasicMaterial ( { color: boxcolor.toLowerCase() } );
var theobject   = new THREE.Mesh ( shape, material );

const texturefile  = '/uploads/fuy3/rsz_1rock.jpg';
const texturefile1  = '/uploads/fuy3/town.png';
var   loader       = new THREE.TextureLoader();
 
loader.load (texturefile, function ( texturefile) 
 // this defines a function to be called whenever the file is loaded 
{			 
    texturefile.minFilter  = THREE.LinearFilter;
    theobject.material    = new THREE.MeshBasicMaterial ( { map: texturefile } );
}); 


  
 


// Define what the World does at the start of a run: 

AB.world.newRun = function() // Instructions to be executed once, at start of run
{
    // start a 3D scene: 
    ABWorld.init3d ( startRadius, maxRadius, skycolor ); //camera swtting
    ABWorld.scene.add ( theobject )
    var boxcolor = 'white';
    

    
};

AB.world.nextStep = function() 
{
	// Instructions to be executed every time step
	//theobject.position.x = theobject.position.x + AB.randomIntAtoB ( -30, 30 );
	//theobject.position.y = theobject.position.y + AB.randomIntAtoB ( -30, 30 );
	theobject.position.z = theobject.position.z + AB.randomIntAtoB ( -30, 30 ); 
	//the distance and direction the cube move each time step. theobject.position.z = theobject.position.z + 10 then move straight line
};