Step 8. Paint the cube

The cube is "painted" with a solid color. It would be nice to paint it with a JPEG or PNG image.

Insert the following code inside "AB.world.newRun". (Remember the program structure.)

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

You will now get something like the following: