举个例子:
// camera fly
var forward = 0;
var path_length = [1320, 200, 200, 200, 300]
var path_angle = [0.39269908125, 0.78539816339744830961566084581988, 0.78539816339744830961566084581988, 1.5707963267948966192313216916398]
var path_dir = ['u', 'r', 'r', 'r'];
var path_speed = [10, 5, 4, 2, 2];
var path_i = 0;
var fly_handler = null;
function freeFly(){
viewer.camera.moveForward(path_speed[path_i]);
forward += path_speed[path_i];
if (forward >= path_length[path_i]) {
if (path_i + 1 >= path_length.length) {
path_i = 0;
viewer.zoomTo(tileset, default_HeadingPitchRange);
return;
}
forward = 0;
if (path_dir[path_i] == 'u')
viewer.camera.lookUp(path_angle[path_i]);
if (path_dir[path_i] == 'r')
viewer.camera.lookRight(path_angle[path_i]);
path_i++;
}
}
function startToFly() {
require(["Cesium"],function(Cesium){
fly_handler = setInterval(freeFly, 100);
});
}