通过goTo实现飞行路径

通过goTo实现飞行路径,用户想在每个点停顿一下
已邀请:

邵明升

赞同来自: st

【解决办法】:
var view = new SceneView({
container: viewDiv,
map: scene,
zoom: 10,
center: [117.371852,36.35927]
});

points=[
{
x:13058023.490428746,
y:4133579.5625787214,
z:192.76964191813022,
h:346.03380525721093,
t:79.8122105218081
},{
x:13057885.379671251,
y:4134165.8410214735,
z:132.4544222317636,
h:344.2610631473669,
t:85.42138814060058
},{
x:13057776.810946576,
y:4134499.5952105694,
z:174.96305826120079,
h:311.2247224011606,
t:59.828916342620865
}
]
view.on(click, function(e){
goToOnline();
});

function goToOnline(){
var i=0;
var timer = setInterval(change, 2000);
function change(){
if (i< points.length){
var cc = getCamera(i);
view.goTo(cc);
i++;
console.log(cc);
}else{
clearInterval(timer);
return;
}
}
}
function getCamera(goToFlag){
var camera = view.camera.clone();
camera.heading = points[goToFlag].h;
camera.tilt = points[goToFlag].t;
camera.position.x=points[goToFlag].x;
camera.position.y=points[goToFlag].y;
camera.position.z=points[goToFlag].z;
return camera;
}
通过setInterval()实现停顿

要回复问题请先登录注册