Code viewer for World: CUBE (clone by Clem)

// Cloned by Clem on 26 Sep 2023 from World "CUBE" by Clem  
// Please leave this clone trail here.
 


// Cloned by Clem on 19 Sep 2023 from World "One Cube World (Three.js)" by Starter user 
// Please leave this clone trail here.
 

const skycolor          = 'lightblue';           
const boxcolor          = 'purple';

const objectsize    = 300;                  // size of object   

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

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

const circleTexture = '/uploads/clem1916/old_paper.jpg';    // Texture for the circle

const MUSICFILE = '/uploads/starter/SuspenseStrings.mp3';  // Music file

const boxNum    = 25;   // number of boxes


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


// Box object array
var a = new Array(boxNum);
for( var i=0; i < boxNum; i++ ) 
{
    a[i] = new THREE.MESH( shape, material );
}


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

AB.world.newRun = function() 
{
    // start a 3D scene: 
    ABWorld.init3d ( startRadius, maxRadius, skycolor ); 

    // add the object to the scene:
    ABWorld.scene.add ( theobject );
    
    // for(var i=0; i < boxNum; i++) 
    // {
    //     ABWorld.scene.add ( a[i] );  
    // }
    
};




function keyHandler ( event )		
{
    
	if ( event.keyCode == 37 )  
	{ 
	    theobject.rotation.z += 0.5;
	    theobject.material.color.setHex(0x800080); //purple
	}  
    if ( event.keyCode == 38 )  
    { 
        theobject.rotation.x -= 0.5;
        theobject.material.color.setHex(0x00ff00); // green
    }	 
    if ( event.keyCode == 39 )  
    { 
        theobject.rotation.z -= 0.5; 
        theobject.material.color.setHex(0xFF0000); // red
    } 	 
    if ( event.keyCode == 40 )  
    { 
        theobject.rotation.x += 0.5;
        theobject.material.color.setHex(0x0000FF); // blue
    }   
	event.stopPropagation(); event.preventDefault(); return false;
}


document.onkeydown = keyHandler;

// Every step spin cube
AB.world.nextStep = function()
{
    
    

};