29 Movement 360
Moviment cercle d’un item
//Scene 1
//item rotates in circle
var radio = 10;//Circle radio
var x_initial=0;//Circle center coordinates
var y_initial=0;
var z_initial=0;
var rotate_0 = Math.PI/2;//rotate initial item
var Height_from_the_ground= 0;
var item = Scene.createItem('LP_Horse', 0, 0, 0);
var steps=30;//number steps circle
item.setPositionAngle(0, radio,Height_from_the_ground, 0, 0, 1,rotate_0);
var step=0;
Scene.scheduleRepeating(function() {
step=step+1;
var pos_x= x_initial + radio*Math.sin(Math.PI*2*step/steps);
var pos_y= y_initial + radio*Math.cos(Math.PI*2*step/steps);
var pos_z=z_initial + Height_from_the_ground;
var rotate= rotate_0 + (Math.PI*2*step/steps);
item.setPositionAngle(pos_x, pos_y, pos_z, 0, 0, 1,rotate);
item.say(step + 1);
}, 0.2);
…………………………………………………………………………………………………..
//scene 2
//two items rotate in circle,
var radio_1 = 12;//Circle radio 1
var radio_2 = 8;//Circle radio 2
var x_initial_1=0;//Circle center coordinates item 1
var y_initial_1=0;
var z_initial_1=0;
var x_initial_2=0;//Circle center coordinates item 2
var y_initial_2=0;
var z_initial_2=0;
1……………………..//posar un 2
var rotate_0_1 = Math.PI/2;//rotate initial item 1
var rotate_0_2 = - Math.PI/2;//rotate initial item 2
5……………………………………………………….canviar
var rotate_0_2 = 0;//rotate initial item 2
var Height_from_the_ground_1= 0;//level z item 1
var Height_from_the_ground_2= 0;//level z item 2
var item_1 = Scene.createItem('LP_Horse', 0, 0, 0);
var item_2 = Scene.createItem('LP_Horse', 0, 0, 0);
2……………………...posar una imatge
var item_2 = Scene.getItem('');
……………………...cambiar radi del principi a 4
var steps_1=20;//number steps circle
var steps_2=40;//number steps circle
……………………………………………..opcions de modificar
3……………….80
var speed=10;// speed rotate
4……………………………………..posar un 4
item_1.setPositionAngle(0, radio_1,Height_from_the_ground_1, 0, 0, 1,rotate_0_1);
item_2.setPositionAngle(0, radio_2,Height_from_the_ground_2, 0, 0, 1,rotate_0_2);
var step=0;//number step
Scene.scheduleRepeating(function() {
step=step+1;//go to next step
//clockwise
var pos_x_1= x_initial_1 + radio_1*Math.sin(Math.PI*2*step/steps_1);
var pos_y_1= y_initial_1 + radio_1*Math.cos(Math.PI*2*step/steps_1);
var pos_z_1=z_initial_1 + Height_from_the_ground_1;
var rotate_1= rotate_0_1 + (Math.PI*2*step/steps_1);
//counterclockwise
var pos_x_2= x_initial_2 + radio_2*Math.sin(-Math.PI*2*step/steps_2);
var pos_y_2= y_initial_2 + radio_2*Math.cos(-Math.PI*2*step/steps_2);
var pos_z_2=z_initial_2 + Height_from_the_ground_2;
var rotate_2= rotate_0_2 - (Math.PI*2*step/steps_2);
item_1.setPositionAngle(pos_x_1, pos_y_1, pos_z_1, 0, 0, 1,rotate_1);
item_2.setPositionAngle(pos_x_2, pos_y_2, pos_z_2, 0, 0, 1,rotate_2);
item_1.say(step + 1);
item_2.say(step+1);
}, 1/speed);
……………………………………………………………………………………...
Obra publicada con Licencia Creative Commons Reconocimiento 4.0