Saltar la navegación

33 Rotate Photosphere Steps and Speed Controled

//vision spherical picture by x steps

//textBillboard in each step and number of total steps

var camera = Scene.getItem("");

camera.setPosition(0,0,1);

var steps=20;//steps in 360º

var step=3;//current stop

var t_step=3;//time stopped in each step

var x_initial=0;//Circle center coordinates described by the camera

var y_initial=0;//Circle center coordinates described by the camera

var z_initial=0;//Circle center coordinates described by the camera

var radio = 10;//Radius of the circle described by the camera

var rotate_0 =Math.PI*3/2;//Initial viewing angle of the camera

var height_from_the_ground= 1;//Height of the camera to the ground

var dist_cartel=2; //Must be greater than 1

var pos_zc=0; //postion axial Y of the textBillboard

var textBillboard = Scene.createTextBillboard(0, 0, 1);

textBillboard.setTextColor(0,0,0);

textBillboard.setColor(0, 205, 170);

camera.setPositionAngle(0, radio,height_from_the_ground, 0, 0, 1,rotate_0);

Scene.scheduleRepeating(function() {

step=step+1;

if (step >steps){

step=Math.round(step % steps);

}

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

var pos_x= x_initial + radio*Math.sin(rotate);

var pos_y= y_initial + radio*Math.cos(rotate);

var pos_z=z_initial + height_from_the_ground;

var tb=Math.round((rotate-rotate_0)*360/(2*Math.PI))

if (tb >360){

tb=Math.round((rotate*360/(2*Math.PI)) % 360);

}

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

textBillboard.setPositionAngle(pos_x*dist_cartel, pos_y*dist_cartel, pos_zc, 0, 0, 1,rotate);

textBillboard.setText(tb +"º" +"\n"+ +step+ "/"+ steps);

Space.log(textBillboard.text());

}, t_step);