Cesium flyTo
// 1. Fly to a position with a top-down view
viewer.camera.flyTo({
destination : Cesium.Cartesian3.fromDegrees(-117.16, 32.71, 15000.0)
});
// 2. Fly to a Rectangle with a top-down view
viewer.camera.flyTo({
destination : Cesium.Rectangle.fromDegrees(west, south, east, north)
});
// 3. Fly to a position with an orientation using unit vectors.
viewer.camera.flyTo({
destination : Cesium.Cartesian3.fromDegrees(-122.19, 46.25, 5000.0),
orientation : {
direction : new Cesium.Cartesian3(-0.04231243104240401, -0.20123236049443421, -0.97862924300734),
up : new Cesium.Cartesian3(-0.47934589305293746, -0.8553216253114552, 0.1966022179118339)
}
});
// 4. Fly to a position with an orientation using heading, pitch and roll.
viewer.camera.flyTo({
destination : Cesium.Cartesian3.fromDegrees(-122.19, 46.25, 5000.0),
orientation : {
heading : Cesium.Math.toRadians(175.0),
pitch : Cesium.Math.toRadians(-35.0),
roll : 0.0
}
});
Cesium viewer.camera.setView用法同上
Cesium 获取当前屏幕范围内的中心点以及相机姿态 //相机姿态
var direction = viewer.camera._direction; var x = Cesium.Math.toDegrees(direction.x); var y = Cesium.Math.toDegrees(direction.y); var z = Cesium.Math.toDegrees(direction.z);
//中心点位置
var rectangle = viewer.camera.computeViewRectangle(); var west =rectangle.west / Math.PI * 180; var north = rectangle.north / Math.PI * 180; var east = rectangle.east / Math.PI * 180; var south = rectangle.south / Math.PI * 180; var centerx=(west+east)/2; var cnetery=(north+south)/2; // 鉴于高德、leaflet获取的边界都是southwest和northeast字段来表示,本例保持一致性 console.log("centerx:"+centerx); console.log("cnetery:"+cnetery);
Rectangle = Cesium.Rectangle.fromCartesianArray(cartesians, ellipsoid, result) BoundingSphere = Cesium.BoundingSphere.fromPoints(positions, result)