2017-04-06 1 views
0

セシウムの3Dビューで地球の残りの半分を見るためにカメラを飛ぶ方法はありますか?セシウム - 3Dビューで地球の他の半分にカメラをフライト

+0

は、あなたがより具体的にすることはできますか?カメラフライ部に問題がありますか?または、飛行する場所を決定しますか? – Zac

+0

このセシウムの砂浜は、flyTo - http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Camera.html&label=Showcasesを使用してカメラの位置を操作する方法を示しています。 – Zac

答えて

1

あなたはこのようなことをしていると思います。
1 - 現在の位置
2ゲット - 先の計算を
3からflyTo()

ライブデモ:http://cesiumjs.org/Cesium/Apps/Sandcastle/?src=Hello%20World.html&label=Showcases&gist=4c6e1b30ae619b8e5cba621f4f12f59d

var viewer = new Cesium.Viewer('cesiumContainer'); 
var scene = viewer.scene; 

var btn = document.getElementById('swap'); 
btn.addEventListener('click', goToOtherSide); 

function goToOtherSide() { 
    // Get the position of the camera 
    var currentPosition = getPosition(); 

    // Get the position on the other side of the earth 
    var nextPosition = getOtherSide(currentPosition); 

    // Use flyTo with the new position, and maintain the height 
    viewer.camera.flyTo({ 
     destination : Cesium.Cartesian3.fromDegrees(+nextPosition.lon, +nextPosition.lat, viewer.camera.positionCartographic.height) 
    }); 
} 

function getPosition() { 
    var center = viewer.camera.pickEllipsoid(
     new Cesium.Cartesian2(viewer.canvas.width/2, viewer.canvas.height/2), Cesium.Ellipsoid.WGS84); 
    var cartographic = scene.globe.ellipsoid.cartesianToCartographic(center); 
    var lat = Cesium.Math.toDegrees(cartographic.latitude).toFixed(2); 
    var lon = Cesium.Math.toDegrees(cartographic.longitude).toFixed(2); 
    return { 
     lat: lat, 
     lon: lon 
    }; 
} 

function getOtherSide(currentPosition) { 
    var ln = +currentPosition.lon + 180; 
    if (ln > 180) { 
     ln -= 360; 
    } 

    var lt = -currentPosition.lat; 

    return { 
     lat: lt, 
     lon: ln 
    }; 
} 
関連する問題