How to set camera orientation in flyto() ?

Like in this attached picture, at far left is my coordinate, shouldn’t it be in center?

And how to set the heading, pitch and roll value to right suitable position?

Thank you

Hi!

The camera does usually zoom to the position where the position is at the center, and the default orientation shouldn’t be so tilted…so that is odd. Do you have a quick code snippet so I could try to replicate this?

Setting the heading, pitch and roll for the camera is another options parameter called orientation. Here’s a bit of code that shows how to do that:

var camera = viewer.scene.camera;
camera.flyTo({
destination: Cartesian3.fromDegrees(longitude, latitude, height), // your own position
orientation: { heading : heading, // your heading in radians
pitch : pitch, // your pitch in radians
roll : roll // your roll in radians
});

``

Hope this helps!

Hello Jane

Here is an example of my code, we set destination in parameter to be read from database, and set orientation to have a better look at our 3d model, or the camera look straight down and we see nothing.

Now the problem is we never find a right direction to watch naturally at our models, we never find the trick of setting
heading, pitch and roll, could you please tell me?

viewer.camera.flyTo({

 destination : Cesium.Cartesian3.fromDegrees(parseFloat(accuracy), parseFloat(latitude), 400),

 orientation : {

  heading : Cesium.Math.toRadians(200.0),

  pitch : Cesium.Math.toRadians(-60.0),

  roll : 1.0

}

});

Jane Xu xuyuan@seas.upenn.edu 于2018年7月19日周四 下午11:41写道:

The camera defaults to looking straight down if you don’t provide an orientation. This would be a good starting point in playing with the heading, pitch and roll. Just so you know, the default values are respectively heading = 0.0 (north), pitch = -90.0 (looking down), and roll = 0.0. Are you saying that this results in you not seeing your desired model on your screen?

Have you ensured that the destination leads you to the correct position on the model? For example, is the variable accuracy corresponding to a longitude, and is 400 a height where your model is nicely visible?

Hello Jane,

I’ve found the problem but there is not a good way to solve it.

Now without heading, pitch and roll, the flyto() dose send me to the right location and my model is in center of screen.

Here is the problem, the camera then start to tilt based on heading, pitch and roll values so the model is moved to edge and sometimes even out of screen.It is NOT tilted center on my model nor the destination coordinates but on camera.

For now we set destination a little below the model so after the camera tilted, my model will be in the center.

Would the Cesium developers provide a new feature to tilt on destination coordinates, please?

在 2018年7月21日星期六 UTC+8上午1:56:28,Jane Xu写道:

Sorry for getting back so late, but have you also checked out the camera’s flyToBoundingSphere option?

There are many ways to create bounding spheres that will ensure your model is viewable by the camera when you zoom. Check them out here! The ones that may interest you may include Cesium.BoundingSphere.fromCornerPoints and Cesium.BoundingSphere.fromRectangle3D.

This sandcastle is a simple way of showing how you could potentially use these functions, but of course you should change the simple bounding sphere I use with something more appropriate for your project.