//////////////////////////
//PHENOM CUBE          //
////////////////////////

function part15() {
    this.vbl = 0 ;
    this.canvaspart;
    this.initdone = 0 ;
    
    var mycanvas3D;
    var mycanvas3D2;
    var mycanvas_stars;

    var my3d;
    var my3d2;

	var angle = 0 ;
	
    this.init = function() {
        mycanvas3D=new canvas(400,400);
        mycanvas3D2=new canvas(400,400);

        // Main 3D
        my3d=new codef3D(mycanvas3D, 12, 60, 1,300 );

		var materials = [
        new THREE.MeshBasicMaterial( { map: THREE.ImageUtils.loadTexture(basepath + 'logo1.png'), overdraw: false } ),
		new THREE.MeshBasicMaterial( { map: THREE.ImageUtils.loadTexture(basepath + 'logo1.png'), overdraw: false } ),
		new THREE.MeshBasicMaterial( { map: THREE.ImageUtils.loadTexture(basepath + 'logo2.png'), overdraw: false } ),
		new THREE.MeshBasicMaterial( { map: THREE.ImageUtils.loadTexture(basepath + 'logo2.png'), overdraw: false } ),
		new THREE.MeshBasicMaterial( { map: THREE.ImageUtils.loadTexture(basepath + 'logo3.png'), overdraw: false } ),
		new THREE.MeshBasicMaterial( { map: THREE.ImageUtils.loadTexture(basepath + 'logo3.png'), overdraw: false } ),	
		];
 
		var geometry = new THREE.CubeGeometry( 6, 6, 6, 8, 8, 8, materials );
    	var cube     = new THREE.Mesh( geometry, new THREE.MeshFaceMaterial() );
		
        cube.overdraw = false;
		my3d.scene.add(cube) ;
			
        my3d2=new codef3D(mycanvas3D2, 12, 60, 1,300 );
		cube = new THREE.CubeGeometry( 6.1,6.1,6.1 );
		material = new THREE.MeshLambertMaterial( { color: 0xA8E5E6, wireframe:true, overdraw:true } );
		mesh = new THREE.Mesh( cube, material );
		my3d2.scene.add(mesh) ;

        mycanvas_stars = new canvas(600,400) ;

        // function starfield3D(           dest,    nb, speed, w, h, centx, centy, color, ratio, offsetx, offsety)
        mystarfield=new starfield3D(mycanvas_stars, 500, 4, 600,400, 320, 200,'#999999', 200,0,0);


		this.initdone = 1 ;
    }


    this.render = function(dest) {
        if (this.initdone == 0) { this.canvaspart = new canvas(600,400) ; this.init() ; }

        this.canvaspart.fill("rgba(0,0,0,0.1)");

        my3d.scene.children[2].rotation.x += 0.01 ;
        my3d.scene.children[2].rotation.y += 0.012 ;
        my3d.scene.children[2].rotation.z += 0.015 ;

        my3d2.scene.children[2].rotation.x += 0.01 ;
        my3d2.scene.children[2].rotation.y += 0.012 ;
        my3d2.scene.children[2].rotation.z += 0.015 ;

        mycanvas3D.clear();
        mycanvas3D2.clear();

        my3d.draw() ;
        my3d2.draw() ;

        mycanvas_stars.clear() ;

        mystarfield.draw() ;
        mycanvas_stars.draw(this.canvaspart,0,0) ;

		mycanvas3D.draw(this.canvaspart,this.canvaspart.width/2 - mycanvas3D2.width/2 + 100*Math.sin(angle),this.canvaspart.height/2-mycanvas3D2.height/2) ;
		mycanvas3D2.draw(this.canvaspart,this.canvaspart.width/2 - mycanvas3D2.width/2 + 100*Math.sin(angle),this.canvaspart.height/2-mycanvas3D2.height/2) ;
		angle += 0.05 ;
			
        this.canvaspart.draw(dest,60,88 );

        if (this.vbl<100) mycanvasblack.draw(dest,60,88,1-this.vbl/100);
        if (this.vbl>intro_parts[part_running].part_duration-100) mycanvasblack.draw(dest,60,88,1-(intro_parts[part_running].part_duration-this.vbl)/100);
        this.vbl++ ;
    }
return this;
}
///////////////
//END PART15//
/////////////
