//旋转
viewer.clock.multiplier = 200;//速度
viewer.clock.shouldAnimate = true;
var previousTime = viewer.clock.currentTime.secondsOfDay;
function onTickCallback() {
var spinRate = 1;
var currentTime = viewer.clock.currentTime.secondsOfDay;
var delta = (currentTime - previousTime) / 1000;
previousTime = currentTime;
viewer.scene.camera.rotate(Cesium.Cartesian3.UNIT_Z, -spinRate * delta);
}
viewer.clock.onTick.addEventListener(onTickCallback);
//监听点击事件,当点击地图时停止旋转
var handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
handler.setInputAction(function(click) {
viewer.clock.onTick.removeEventListener(onTickCallback);
}, Cesium.ScreenSpaceEventType.LEFT_DOWN);
网友评论