0
有城市100k人大。我想從任意高度(z值)顯示我的地形(地圖層+ 3棟建築物)。使用內建機制可以做到嗎?是否可以爲旋轉和位置分配約束?
有城市100k人大。我想從任意高度(z值)顯示我的地形(地圖層+ 3棟建築物)。使用內建機制可以做到嗎?是否可以爲旋轉和位置分配約束?
您可以掛上時鐘,每次打勾確保相機處於「允許區域」。
每打勾一次,檢查相機是否處於不正確的位置。如果不是,請更正它。
以下是限制相機高度的示例,但是也可以使用相同的圖案來限制位置的其他方面。
var viewer = new Cesium.Viewer('cesiumContainer');
// the max height that should be allowed in meters
var MAX_HEIGHT = 4e6;
// each clock tick ensure the camera is in the right position
viewer.clock.onTick.addEventListener(function() {
var curHeight = viewer.scene.globe.ellipsoid.cartesianToCartographic(viewer.camera.position).height;
var heightFromMax = curHeight - MAX_HEIGHT;
// if the height of the camera is above the max, move the camera forward to ensure it is lower than the max
if (heightFromMax > 0) {
viewer.scene.camera.moveForward(heightFromMax);
return;
}
});
你是不是想從下面得到一個特定的高度限制的相機? – emackey
下面應該很好,因爲我特別需要降低地面面積。 – RobertW