Saltar la navegación

40 c Items rotating cylinders

var steps=10;//steps in a tour

//tp diferents options

var tp1=0.5; //Time it takes in a step in seconds firts cylinder

var tp2=0.5;//Time it takes in a step in seconds second cylinder

var tp3=0.5;//Time it takes in a step in seconds thirdcylinder

var tp4=0.5;//Time it takes in a step in seconds fourth cylinder

var tp5=0.5;//Time it takes in a step in seconds fifth cylinder

var tp6=0.5;//Time it takes in a step in seconds sixth cylinder

//variables cylinders

var cx=2;//radius x cylinder

var cy=2;//radius y cylinder

var chi=4;//z base cylinder

var ch=1;//height del cilindro

var cxplus=1;//changing the radius x

var cyplus=1;// changing the radius y

var chiplus=1;//changing z base cylinder

//create cylinders

//1

var cylinder1 = Scene.createItem('EllipticCylinder', 0, 0, chi);

cylinder1.setRadiusX(cx);

cylinder1.setRadiusY(cy);

cylinder1.setHeight(ch);

cylinder1.setColor(219,186,240);

//2

var cylinder2 = Scene.createItem('EllipticCylinder', 0, 0, chi-chiplus);

cylinder2.setRadiusX(cx+cxplus);

cylinder2.setRadiusY(cy+cyplus);

cylinder2.setHeight(ch);

cylinder2.setColor(175,121,211);

//3

var cylinder3 = Scene.createItem('EllipticCylinder', 0, 0, chi-2*chiplus);

cylinder3.setRadiusX(cx+2*cxplus);

cylinder3.setRadiusY(cy+2*cyplus);

cylinder3.setHeight(ch);

cylinder3.setColor(162,98,204);

//4

var cylinder4 = Scene.createItem('EllipticCylinder', 0, 0, chi-3*chiplus);

cylinder4.setRadiusX(cx+3*cxplus);

cylinder4.setRadiusY(cy+3*cyplus);

cylinder4.setHeight(ch);

cylinder4.setColor(82,40,110);

//5

var cylinder5 = Scene.createItem('EllipticCylinder', 0, 0, chi-4*chiplus);

cylinder5.setRadiusX(cx+4*cxplus);

cylinder5.setRadiusY(cy+4*cyplus);

cylinder5.setHeight(ch);

cylinder5.setColor(41,16,57);

var i=0;

//items in the "cake""

var item1 = Scene.getItem("")

item1.setPosition (0, -(cx-(cxplus/2)), chi+chiplus);

var item2 = Scene.getItem("")

item2.setPosition (0, -(cy+(cyplus/2)), chi);

var item3 = Scene.getItem("")

item3.setPosition (0,-(cy+(cyplus*3/2)), chi-chiplus);

var item4 = Scene.getItem("")

item4.setPosition (0,-(cy+(cyplus*5/2)), chi-2*chiplus);

var item5 = Scene.getItem("")

item5.setPosition (0,-(cy+ (cyplus*7/2)), chi-3*chiplus);

var item6 = Scene.getItem("")

item6.setPosition (0,- (cy+(cyplus*9/2)), chi-4*chiplus);

//rotate top item on the “cake” (on top cylinder)

Scene.scheduleRepeating(function() {

i++;

var pos_x= (cx-cxplus/2)*Math.sin(Math.PI*2*i/steps);

var pos_y= (cy-cyplus/2)*Math.cos(Math.PI*2*i/steps);

var pos_z=chi+chiplus;

var rotate=(Math.PI/2) +(Math.PI*2*i/steps);

item1.setPositionAngle(pos_x, pos_y, pos_z, 0, 0, 1, rotate);

}, tp1);

//cuarta escena

//rotate second item

Scene.scheduleRepeating(function() {

var pos_x= (cx+(cxplus/2))*Math.sin(-(Math.PI*2*i/steps));

var pos_y= (cy+(cyplus/2))*Math.cos(-(Math.PI*2*i/steps));

var pos_z=chi;

var rotate= -(Math.PI/2)-(Math.PI*2*i/steps);

item2.setPositionAngle(pos_x, pos_y, pos_z, 0, 0, 1, rotate);

}, tp2);

//quinta escena tots items

Scene.scheduleRepeating(function() {

var pos_x= (cx+(cxplus*3/2))*Math.sin((Math.PI*2*i/steps));

var pos_y= (cy+(cyplus*3/2))*Math.cos((Math.PI*2*i/steps));

var pos_z=chi-chiplus;

var rotate= (Math.PI/2)+(Math.PI*2*i/steps);

item3.setPositionAngle(pos_x, pos_y, pos_z, 0, 0, 1, rotate);

}, tp3);

Scene.scheduleRepeating(function() {

var pos_x= (cx+(cxplus*5/2))*Math.sin(-(Math.PI*2*i/steps));

var pos_y= (cy+(cyplus*5/2))*Math.cos(-(Math.PI*2*i/steps));

var pos_z=chi-2*chiplus;

var rotate= -(Math.PI/2)-(Math.PI*2*i/steps);

item4.setPositionAngle(pos_x, pos_y, pos_z, 0, 0, 1, rotate);

}, tp4);

Scene.scheduleRepeating(function() {

var pos_x= (cx+(cxplus*7/2))*Math.sin((Math.PI*2*i/steps));

var pos_y= (cy+(cyplus*7/2))*Math.cos((Math.PI*2*i/steps));

var pos_z=chi-3*chiplus;

var rotate= (Math.PI/2)+(Math.PI*2*i/steps);

item5.setPositionAngle(pos_x, pos_y, pos_z, 0, 0, 1, rotate);

}, tp5);

Scene.scheduleRepeating(function() {

var pos_x= (cx+(cxplus*9/2))*Math.sin(-(Math.PI*2*i/steps));

var pos_y= (cy+(cyplus*9/2))*Math.cos(-(Math.PI*2*i/steps));

var pos_z=chi-4*chiplus;

var rotate= -(Math.PI/2)-(Math.PI*2*i/steps);

item6.setPositionAngle(pos_x, pos_y, pos_z, 0, 0, 1, rotate);

}, tp6);