Cesium 相机的三种放置方式

Cesium 相机的三种放置方式

Cesium 提供了三种方式对相机的位置进行摆放

第一种:setView 计算视角

1. Cartesian3 方式

viewer.value.camera.setView({
    
    
  destination: Cesium.Cartesian3.fromDegrees(116.435314, 39.960521, 15000.0), // 设置位置
  orientation: {
    
    
    heading: Cesium.Math.toRadians(20.0), // 方向
    pitch: Cesium.Math.toRadians(-90.0), // 倾斜角度
    roll: 0,
  },
});

2. Rectangle 方式

viewer.value.camera.setView({
    
    
  destination: Cesium.Rectangle.fromDegrees(0.0, 20.0, 10.0, 30.0),//west, south, east, north
  orientation: {
    
    
    heading: Cesium.Math.toRadians(20.0), // 方向
    pitch: Cesium.Math.toRadians(-90.0), // 倾斜角度
    roll: 0,
  },
});

第二种:flyTo

viewer.value.camera.flyTo({
    
    
  destination :Cesium.Cartesian3.fromDegrees(116.435314,39.960521, 15000.0), // 设置位置
  orientation: {
    
    
    heading :Cesium.Math.toRadians(20.0), // 方向
    pitch :Cesium.Math.toRadians(-90.0),// 倾斜角度
    roll :0
  },
  duration:5, // 设置飞行持续时间,默认会根据距离来计算
  complete:function () {
    
    
  // 到达位置后执行的回调函数
  },
  cancle:function () {
    
    
  // 如果取消飞行则会调用此函数
  },
  pitchAdjustHeight:-90, // 如果摄像机飞越高于该值,则调整俯仰俯仰的俯仰角度,并将地球保持在视口中。
  maximumHeight:5000, // 相机最大飞行高度
  flyOverLongitude:100, // 如果到达目的地有2种方式,设置具体值后会强制选择方向飞过这个经度(这个,很好用)
});

第三种:lookAt

var center = Cesium.Cartesian3.fromDegrees(114.44455, 22.0444);//camera视野的中心点坐标
var heading = Cesium.Math.toRadians(50.0);
var pitch = Cesium.Math.toRadians(-20.0);
var range = 5000.0;
viewer.value.camera.lookAt(center, new Cesium.HeadingPitchRange(heading, pitch, range));

猜你喜欢

转载自blog.csdn.net/qq_53810245/article/details/132431815