Code viewer for World: New World


AB.clockTick       = 50;    
AB.maxSteps        = 500; 
ABHandler.GROUNDZERO		= true;						// "ground" exists at altitude zero

ABWorld.drawCameraControls = false; 

"/uploads/dalye54/chess.obj";
const OBJPATH = "/uploads/dalye54/";
const OBJNAME = "legoobj.obj";
//const MTLNAME = "chess.mtl";

const SKYCOLOR 		= "grey" ;	

const MODELLENGTH 			= 1000;							
const MODELWIDTH			= 1000; 

const SCALE_CASTLE			= 0.5;							// scale it by this		 
const SCALEDMODELLENGTH 	= MODELLENGTH * SCALE_CASTLE;	 			 
const SCALEDMODELWIDTH	 	= MODELWIDTH  * SCALE_CASTLE;

const startRadiusConst 		= SCALEDMODELLENGTH * 0.5 ; 
const maxRadiusConst 		= SCALEDMODELLENGTH * 10 ;

var man;

function loadResources()
{
 	// "/uploads/dalye54/legoobj.obj"
 	var first = new THREE.MTLLoader();
	first.setResourcePath ( "/uploads/dalye54/" );
	first.setPath         ( "/uploads/dalye54/" );
	first.load ("chess.mtl", function (materials)
	{
	    materials.preload();
	    var second = new THREE.OBJLoader();
	    second.setPath( "/uploads/dalye54/" )
	    second.setMaterials(materials);
 	    second.load("chess.obj", function (object)
     	    {
     	        man = object;
     	        if ( asynchFinished() ) initScene() ;
     	    });
 	});
}

function asynchFinished()		 
{
	if ( man ) return true;  
	else return false;
}


function initScene()		// file loads have returned 
{
	
 // add castle object to scene  

    console.log("test");
	man.scale.multiplyScalar ( .1 );    	  
    console.log(man['children'])
    man.position.y = 0;				// adjust so cubes (centred on 0) appear exactly above castle floor 
    man.position.x = 0;
    man.position.z = 0;  
 
   	ABWorld.scene.add(man['children'][0]);
   	ABWorld.scene.add(man['children'][5]);
	
	ABWorld.render();
	
	resourcesLoaded = true;
	AB.runReady = true;
	
}
const LIGHTCOLOR 	= 0xffffff ;
AB.world.newRun = function()
{
    ABWorld.init3d ( startRadiusConst, maxRadiusConst, SKYCOLOR  ); 
	// Code for Three.js initial drawing of objects.
	// Should include one of:
 	// ABWorld.init2d ( arguments ); 	
 	// ABWorld.init3d ( arguments ); 
 	
 	loadResources();
 	
 	var thelight = new THREE.DirectionalLight ( LIGHTCOLOR, 3 );
    thelight.position.set ( startRadiusConst, startRadiusConst, startRadiusConst );
    ABWorld.scene.add(thelight);
};

AB.world.nextStep = function()		 
{
	// Code for Three.js re-drawing of objects.  		
};


AB.world.endRun = function()
{
};