cesium模拟地球自转

	viewer.clock.shouldAnimate = true;
	var previousTime = viewer.clock.currentTime.secondsOfDay;
	const 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(click => {
	// 	viewer.clock.onTick.removeEventListener(onTickCallback);
	// }, Cesium.ScreenSpaceEventType.LEFT_CLICK);

切换2d是地球还是会自转

你可能感兴趣的:(前端,javascript,开发语言)