首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >是否可以将约束分配给旋转和位置?

是否可以将约束分配给旋转和位置?
EN

Stack Overflow用户
提问于 2017-02-17 05:37:41
回答 1查看 374关注 0票数 0

有10万人大的城市。我想要显示我的地形(地图层+3建筑物)从任意高度(z值)。有没有可能使用内置机制呢?

EN

回答 1

Stack Overflow用户

发布于 2017-04-05 23:16:31

你可以挂在时钟上,每个滴答声都能确保相机在“允许的区域”。

每个刻度,检查相机是否在正确的位置。如果不是,请更正它。

这是一个限制相机高度的例子,但相同的图案也可以用来限制位置的其他方面。

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

代码语言:javascript
复制
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;
    }
});
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42285144

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档