cesium.js的地球仪demo

去掉背景色、月亮、星星等,只留下地球自己旋转

 

(function () {
  "use strict";
  Cesium.BingMapsApi.defaultKey = 'SHHFsraTruJW1WlBZo4W~Voo0XWCy1Zt2-2iAVLxvFQ~Ai_3AucRsH-FTKgfBT34iPCl128DNCGslmWLM0Hplg9UgMZoftwZFkKbhHu_RAo8'
  var viewer = new Cesium.Viewer('cesiumContainer' , {
    //关闭地球的2D,就是只用3D
    scene3DOnly: true,
    baseLayerPicker: false,
    sceneModePicker: false,
    navigationHelpButton: false,
    animation: false,
    timeline: false,
    allowDataSourcesToSuspendAnimation: false,
    //关闭月亮、星星等
    skyBox: new Cesium.SkyBox({  
      show: false
    }),
    //关闭地球光环
    skyAtmosphere: false
  });
  viewer.imageryLayers.addImageryProvider(new Cesium.SingleTileImageryProvider({
    url: 'Source/Images/webwxgetmsgimg1.jpg'
  }));
  
  var initialPosition = new Cesium.Cartesian3.fromDegrees(113.42, 34.16, 16000000);
  var homeCameraView = {
      destination : initialPosition,
  };
  viewer.scene.camera.setView(homeCameraView);
  
  var x = 113;
  window.setInterval(function () {
    x = x + 0.3;
    if (x >= 178.5) {
      x = -180
    }
    viewer.scene.camera.setView({
      destination: new Cesium.Cartesian3.fromDegrees(x, 30, 16000000)
    });
  }, 16)
  
  viewer.scene.sun.destroy(); //去掉太阳
  viewer.scene.sun = undefined; //去掉太阳
  viewer.scene.moon.destroy(); //去掉月亮
  viewer.scene.moon = undefined; //去掉月亮
  viewer.scene.backgroundColor = Cesium.Color.TRANSPARENT;

  viewer.entities.add({
    position : Cesium.Cartesian3.fromDegrees(112.42, 34.16),
    ellipse : {
      coordinates: Cesium.Rectangle.fromDegrees(112.42, 34.16, 50.0),
      semiMinorAxis : 55000.0, //半小轴
      semiMajorAxis : 55000.0, //半长轴
      material : Cesium.Color.WHITE
    }
  });
  viewer.entities.add({
    position : Cesium.Cartesian3.fromDegrees(116.42, 40.16),
    ellipse : {
      semiMinorAxis : 25000.0, //半小轴
      semiMajorAxis : 25000.0, //半长轴
      material : Cesium.Color.fromAlpha(Cesium.Color.WHITE, 1)
    }
  });

  //viewer.zoomTo(viewer.entities);
})()

 

posted @ 2018-01-17 18:08  秦孝公嬴渠梁  阅读(2824)  评论(0编辑  收藏  举报