是否可以将地球转移到中心的左侧或右侧?我想在透明导航侧边栏下方显示星空,并在地球上向右移动一个等于侧边栏宽度的距离。
我找不到任何这方面的例子,我也没有看到Cesium中现有方法的参考。我尝试使Cesium div比它的容器更大,并使用定位使地球看起来向右移动,但这显示了由于放大而导致的星空模糊。
是的,从UI开始,这是通过按住SHIFT键并拖动来完成的,但在代码中可以使用相机上的lookLeft和lookRight方法完成。
例如:
viewer.camera.lookLeft(Cesium.Math.toRadians(20));
这是一个更完整的示例,按下此处底部的“运行代码片段”:
var viewer = new Cesium.Viewer('cesiumContainer', {
// All these construction options are just to avoid Stack Snippet error messages.
navigationInstructionsInitiallyVisible: false, animation: false, timeline: false,
imageryProvider : Cesium.createTileMapServiceImageryProvider({
url : Cesium.buildModuleUrl('Assets/Textures/NaturalEarthII')
}),
baseLayerPicker : false,
geocoder : false,
infoBox : false
});
// This changes where the Earth is seen by the camera.
viewer.camera.lookLeft(Cesium.Math.toRadians(20));
html, body, #cesiumContainer {
width: 100%; height: 100%; margin: 0; padding: 0; overflow: hidden;
font-family: sans-serif;
}
<link href="http://cesiumjs.org/releases/1.55/Build/Cesium/Widgets/widgets.css"
rel="stylesheet"/>
<script src="http://cesiumjs.org/releases/1.55/Build/Cesium/Cesium.js">
</script>
<div id="cesiumContainer"></div>