//////////////////////////
//3D TRANSFORM         //
////////////////////////
function part17() {
    this.vbl = 0 ;
    this.canvaspart;
    this.initdone = 0 ;

    // 3D Objects
    var my3dball;

    var tweenpoint;

    var mycanvas_stars;
    var mystarfield ;

    var col1 = 0xCC73C4 ;
    var col2 = 0xd5b8fc ;

    var myobjball=[ 
            {p1:0, p2:1, p3:4, params:new MeshBasicMaterial({ color: col1, opacity:0.7})},
            {p1:1, p2:2, p3:4, params:new MeshBasicMaterial({ color: col2, opacity:0.7})},
            {p1:2, p2:3, p3:4, params:new MeshBasicMaterial({ color: col1, opacity:0.7})},
            {p1:0, p2:3, p3:4, params:new MeshBasicMaterial({ color: col2, opacity:0.7})},
            {p1:5, p2:6, p3:9, params:new MeshBasicMaterial({ color: col1, opacity:0.7})},
            {p1:6, p2:7, p3:9, params:new MeshBasicMaterial({ color: col2, opacity:0.7})},
            {p1:7, p2:8, p3:9, params:new MeshBasicMaterial({ color: col1, opacity:0.7})},
            {p1:5, p2:8, p3:9, params:new MeshBasicMaterial({ color: col2, opacity:0.7})},
            {p1:0, p2:3, p3:12, params:new MeshBasicMaterial({ color: col1, opacity:0.7})},
            {p1:0, p2:5, p3:12, params:new MeshBasicMaterial({ color: col2, opacity:0.7})},
            {p1:5, p2:8, p3:12, params:new MeshBasicMaterial({ color: col1, opacity:0.7})},
            {p1:3, p2:8, p3:12, params:new MeshBasicMaterial({ color: col2, opacity:0.7})},
            {p1:1, p2:2, p3:13, params:new MeshBasicMaterial({ color: col1, opacity:0.7})},
            {p1:1, p2:6, p3:13, params:new MeshBasicMaterial({ color: col2, opacity:0.7})},
            {p1:6, p2:7, p3:13, params:new MeshBasicMaterial({ color: col1, opacity:0.7})},
            {p1:2, p2:7, p3:13, params:new MeshBasicMaterial({ color: col2, opacity:0.7})},
            {p1:3, p2:8, p3:10, params:new MeshBasicMaterial({ color: col1, opacity:0.7})},
            {p1:7, p2:8, p3:10, params:new MeshBasicMaterial({ color: col2, opacity:0.7})},
            {p1:2, p2:7, p3:10, params:new MeshBasicMaterial({ color: col1, opacity:0.7})},
            {p1:2, p2:3, p3:10, params:new MeshBasicMaterial({ color: col2, opacity:0.7})},
            {p1:0, p2:5, p3:11, params:new MeshBasicMaterial({ color: col1, opacity:0.7})},
            {p1:5, p2:6, p3:11, params:new MeshBasicMaterial({ color: col2, opacity:0.7})},
            {p1:1, p2:6, p3:11, params:new MeshBasicMaterial({ color: col1, opacity:0.7})},
            {p1:0, p2:1, p3:11, params:new MeshBasicMaterial({ color: col2, opacity:0.7})},
           ];
      
    var object_ball = [
        {x:	-10,y: -10,z:-10}, 
        {x:	-10,y:  10,z:-10}, 
        {x:	 10,y:  10,z:-10}, 
        {x:	 10,y: -10,z:-10}, 
        {x:	  0,y:   0,z:-18}, 
        {x:	-10,y: -10,z: 10}, 
        {x:	-10,y:  10,z: 10}, 
        {x:	 10,y:  10,z: 10}, 
        {x:	 10,y: -10,z: 10}, 
        {x:	  0,y:   0,z: 18}, 
        {x:	 18,y:   0,z:  0}, 
        {x:	-18,y:   0,z:  0}, 
        {x:	  0,y: -18,z:  0}, 
        {x:	  0,y:  18,z:  0}, 
    ];

    var object_cube = [
        {x:	-10,y:-10,z:-10},
        {x:	-10,y: 10,z:-10},
        {x:  10,y: 10,z:-10},
        {x:	 10,y:-10,z:-10},
        {x:	  0,y:  0,z:-10},
        {x:	-10,y:-10,z: 10},
        {x:	-10,y: 10,z: 10},
        {x:	 10,y: 10,z: 10},
        {x:	 10,y:-10,z: 10},
        {x:	  0,y:  0,z: 10},
        {x:	 10,y:  0,z:  0},
        {x:	-10,y:  0,z:  0},
        {x:	  0,y:-10,z:  0},
        {x:	  0,y: 10,z:  0},
    ];

    var object_sams = [
      {x:	-10,y:-2,z:-10},
      {x:	-10,y:2,z:-10},
      {x:	10,y:2,z:-10},
      {x:	10,y:-2,z:-10},
      {x:	0,y:0,z:-12},
      {x:	-10,y:-2,z:10},
      {x:	-10,y:2,z:10},
      {x:	10,y:2,z:10},
      {x:	10,y:-2,z:10},
      {x:	0,y:0,z:12},
      {x:	12,y:0,z:0},
      {x:	-12,y:0,z:0},
      {x:	0,y:-2,z:0},
      {x:	0,y:2,z:0},
    ];

    var object_lozange = [
        {x:	-10,y:-4,z:-10},
        {x:	-10,y:4,z:-10},
        {x:	10,y:4,z:-10},
        {x:	10,y:-4,z:-10},
        {x:	0,y:0,z:-10},
        {x:	-10,y:-4,z:10},
        {x:	-10,y:4,z:10},
        {x:	10,y:4,z:10},
        {x:	10,y:-4,z:10},
        {x:	0,y:0,z:10},
        {x:	10,y:0,z:0},
        {x:	-10,y:0,z:0},
        {x:	0,y:-20,z:0},
        {x:	0,y:20,z:0},
    ];

    var object_pyra = [
        {x:	-8,y:-8,z:-8},
        {x:	-16,y:8,z:-16},
        {x:	16,y:8,z:-16},
        {x:	8,y:-8,z:-8},
        {x:	0,y:0,z:-12},
        {x:	-8,y:-8,z:8},
        {x:	-16,y:8,z:16},
        {x:	16,y:8,z:16},
        {x:	8,y:-8,z:8},
        {x:	0,y:0,z:12},
        {x:	12,y:0,z:0},
        {x:-12,y:0,z:0},
        {x:0,y:-24,z:0},
        {x:0,y:8,z:0},
    ];

    var object_obelix = [	
        {x:	-9,y:-16,z:-9},
        {x:	-8,y:8,z:-8},
        {x:	8,y:8,z:-8},
        {x:	9,y:-16,z:-9},
        {x:	0,y:-4,z:-9},
        {x:	-9,y:-16,z:9},
        {x:	-8,y:8,z:8},
        {x:	8,y:8,z:8},
        {x:	9,y:-16,z:9},
        {x:	0,y:-4,z:9},
        {x:	9,y:-4,z:0},
        {x:	-9,y:-4,z:0},
        {x:	0,y:-30,z:0},
        {x:	0,y:8,z:0	},
    ];

    var object_sship = [		
        {x:	-2,y:-16,z:-2},
        {x:	-8,y:8,z:-4},
        {x:	8,y:8,z:-4},
        {x:	2,y:-16,z:-2},
        {x:	0,y:7,z:-4},
        {x:	-2,y:-16,z:2},
        {x:	-8,y:8,z:4},
        {x:	8,y:8,z:4},
        {x:	2,y:-16,z:2},
        {x:	0,y:7,z:4},
        {x:	18,y:6,z:0},
        {x:	-18,y:6,z:0},
        {x:	0,y:-20,z:0},
        {x:	0,y:8,z:0},
    ];

var myobjects = [ object_ball, object_cube, object_sams, object_lozange, object_pyra, object_obelix, object_sship] ;
var tcomplete = 0 ;
var vbl2 = 0 ;
function tweencomplete(){tcomplete=1}function tweenstarting(){tcomplete=0}
function inittween(){tweenpoint=[];for(var a=0;a<myobjects[0].length;a++){tweenpoint[a]=createjs.Tween.get(myobjects[0][a],{loop:!0});for(var b=1;b<myobjects.length;b++)1==b?(tweenpoint[a].wait(5E3),tweenpoint[a].call(tweenstarting)):tweenpoint[a].wait(175),tweenpoint[a].to({x:myobjects[b][a].x,y:myobjects[b][a].y,z:myobjects[b][a].z},5E3,createjs.Ease.elasticOut);tweenpoint[a].wait(175);tweenpoint[a].to({x:myobjects[0][a].x,y:myobjects[0][a].y,z:myobjects[0][a].z},5E3,createjs.Ease.elasticOut);tweenpoint[a].call(tweencomplete)}}
this.init=function(a){mycanvas_glenz=new canvas(a.width,a.height);mycanvas_stars=new canvas(a.width,a.height);inittween();my3dball=new codef3D(mycanvas_glenz,60,45,1,1600);my3dball.faces(object_ball,myobjball,!0,!1);my3dball.camera.position.z=15;mystarfield=new starfield3D(mycanvas_stars,500,4,a.width,a.height,a.width/2,a.height/2,"#999999",200,0,0);this.initdone=1};
this.render=function(a){0==this.initdone&&(this.canvaspart=new canvas(600,400),this.init(this.canvaspart));this.canvaspart.fill("#0");mycanvas_glenz.clear();for(var b=0;14>b;b++)my3dball.group.children[0].geometry.vertices[b]=object_ball[b],200<vbl2&&0==tcomplete&&tweenpoint[b].tick(33);my3dball.group.rotation.x+=0.03;my3dball.group.rotation.y+=0.04;my3dball.group.rotation.z+=0.02;my3dball.draw();mycanvas_stars.clear();mystarfield.draw();mycanvas_stars.draw(this.canvaspart);mycanvas_glenz.draw(this.canvaspart);
200<vbl2&&(createjs.Tween.tick(15),0==tcomplete&&60>my3dball.camera.position.z&&my3dball.camera.position.z++);this.canvaspart.draw(a,60,88);100>this.vbl&&mycanvasblack.draw(a,60,88,1-this.vbl/100);this.vbl>intro_parts[part_running].part_duration-100&&mycanvasblack.draw(a,60,88,1-(intro_parts[part_running].part_duration-this.vbl)/100);1==tcomplete&&(15<my3dball.camera.position.z&&my3dball.camera.position.z--,15==my3dball.camera.position.z&&(tcomplete=vbl2=0));vbl2++;this.vbl++};
    return this ;
}

///////////////
//END PART17//
/////////////
