Cesium地球自转的样例代码

Cesium技术心得 · godlike · 于 6年前 发布 · 12439 次阅读
var i = Date.now();

function rotate() {
	var a = .1;
	var t = Date.now();
	var n = (t - i) / 1e3;
	i = t;
	viewer.scene.camera.rotate(Cesium.Cartesian3.UNIT_Z, -a * n);
}

viewer.clock.onTick.addEventListener(rotate);
setTimeout(function() {
	viewer.clock.onTick.removeEventListener(rotate);
}, 5000);

本文由 admin 创作,采用 知识共享署名 3.0 中国大陆许可协议 进行许可。 可自由转载、引用,但需署名作者且注明文章出处。

共收到 1 条回复
devhu#16年前 0 个赞
(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);
})()

https://www.cnblogs.com/yingquliang/p/8304301.html

添加回复 (需要登录)
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册
Your Site Analytics