2017-02-16 37 views
0

有城市100k人大。我想从任意高度(z值)显示我的地形(地图层+ 3栋建筑物)。使用内建机制可以做到吗?是否可以为旋转和位置分配约束?

+0

你是不是想从下面得到一个特定的高度限制的相机? – emackey

+0

下面应该很好,因为我特别需要降低地面面积。 – RobertW

回答

0

您可以挂上时钟,每次打勾确保相机处于“允许区域”。

每打勾一次,检查相机是否处于不正确的位置。如果不是,请更正它。

以下是限制相机高度的示例,但是也可以使用相同的图案来限制位置的其他方面。

沙堡:http://cesiumjs.org/Cesium/Apps/Sandcastle/?src=Hello%20World.html&label=Showcases&gist=c943ebc6b2d06b9a555584cd1e3f6a97

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; 
    } 
});