有10万人大的城市。我想要显示我的地形(地图层+3建筑物)从任意高度(z值)。有没有可能使用内置机制呢?
发布于 2017-04-05 23:16:31
你可以挂在时钟上,每个滴答声都能确保相机在“允许的区域”。
每个刻度,检查相机是否在正确的位置。如果不是,请更正它。
这是一个限制相机高度的例子,但相同的图案也可以用来限制位置的其他方面。
沙堡: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;
}
});https://stackoverflow.com/questions/42285144
复制相似问题