Setting Pitch

Hello.

When I set pitch for a default view using camera.setView, the map is no longer centered as defined by the destination property.

How do I change the pitch so the map is centered on the destination point?

See this sandcastle example.

https://cesiumjs.org/Cesium/Build/Apps/Sandcastle/#c=XVJNbxoxEP0rIy5ZpK2XZb0hSQkqopdIqYoITS97MfYQpvXayPYSkSj/vV4WUIkv9sy8N28+nGVzSybATNtGwWoPc2fXDOYY0MFUazQpzKxu6hUJ+GVoh85T2MPCrmwg6eFRrBg8SWEMmZc2wVTjH2GUs7B0VkqrCaIJP0RAghlZKZwmZJXZCQc7wtcodA8GX2GGnpqaPR98yZU8mDNrgiCD7iqF98pAPLE0F12x0h2pyL47MaXDqPLbOq2WHSbpV+aj/7UynVwgjR7DpV53Fd+XXTB5h8bpc84HaxbobeMksrWz9dRHzINK8ms+zPtwSN51wbxEg2zrqKYQB+WZUCo5Sh5r+B8oRY1OsBhsO06OzSn0gYwIZM3dRZXChfgSpkg4H+Qjztk15zkvi5ynMByWgzJnPB+Mbm7zfFAOU+DlbcmHA1aM+OiG86Lop52EdYRxqJ3EUbY9Wwpyc248LmzDgl0IFUV98oWX/Q76cR5pL+2NfdhrnHSRb1RvrQvt/BLGsoD1VseF+GzVyL8YmPS+JY6zE2msaAek7qvep2VXPZBaeB8j60brJ3rDqjcZZxF/QdM2lmdefsZvqcW+hWzyyWPnZIyNs2ieWP8A

When setting the pitch, the center of the camera moves slightly to north. I would expect the setting the pitch would result in the same thing as dragging dragging down the mouse.

there a way to programmatically reproduce the click and drag mouse movement?

This is because Cesium move to camera to right above your center point then start to pitch the camera, so the desired destination will move, sometimes out of screen.
I, too, hope Cesium could do something about that.

在 2019年4月2日星期二 UTC+8上午12:40:44,Brian Behling写道:

I’ve run into something similar before, where flyTo would tilt and cause an entity that was supposed to be tracked to go out of view:

https://github.com/AnalyticalGraphicsInc/cesium/issues/7116

Notice that for entity to stay in view when you change the pitch, the camera position needs to change. camera.setView will set the camera’s position and orientation exactly as given. Ideally what we want is something that’ll tell the camera to look at a certain point, with a given orientation. This is what the camera.lookAt is for:

https://cesiumjs.org/Cesium/Build/Documentation/Camera.html?classFilter=Camera#lookAt

Here’s a Sandcastle example where you can change the pitch and it should still be looking at that roof:

Sandcastle example.

I changed the position for the camera to be the actual position on the ground for the camera to focus on (using scene.pickPosition on a mouse click). Let me know if this solves your issue!

The problem with camera.lookAt is that we can’t navigate around the globe any more. The camera is constrained to the position value.

Ah yes, I didn’t realize that. You can unlock the camera again by resetting the transform:

viewer.camera.lookAtTransform(Cesium.Matrix4.IDENTITY);

``

But it will still keep it in the same position. Does that work for you?

Hey yeah, that will work!

Thanks Omar

Well, for this example, lookAt doesn’t work. It moves the camera north.

https://cesiumjs.org/Cesium/Build/Apps/Sandcastle/#c=bVNfb9owEP8qJ16aSJlDSEjpStEQnTSkdkOUbZqUF+Mc1KtjI9uhZVW/+y4EttIteYh9vrvfn3PieGak9jBRpi5huYOZNSsGM/RoYawU6ggmRtXVUnL4quUWrZN+B3OzNF4KBzd8yeBOcK2lXjcNxgp/cl1aAwtrhDBKAm3hlnuUMJFGcKskskJvuYWtxEcCugKNjzBBJ+uKfdvHgjOx306M9lxqtGcRPBca6CFqlkLEdCtLqn5/rBQWCeW7sapctDlBWOiX8LLQzdsAeqnQoT9FbD/p9aI9DJ6htupP16nRc3SmtgLZyppq7ChnWgZJnvWSEPbtWx3MCdTINlZW0pNVjvGyDA6QLYuGw8aQhdLoNyS49bTiOg2Sbr836PbZRZ4mWZqc5xHkSS/PsoylWTro5r2LLIIk62VpmrNskPfPB4PBxSsigldoOVPGPIx9cASMoDXwn+cVjU/IS5rkTHpxP+d6jUE3Op7RDO+ZN3PK4NoF77J+GEG/Gx6kHaFJpGNGCyXFA2lc1Vo06AFuUfvwMMWDEXR+6h3VzA50g/+502vbsKcI2sVuD08dhdHOKCTR60ZxE305JfbKk4UlBStjq+CvNiufMja9/vh5MV38CC87UWfo/E7hqHXtg6w2xvrmbgSMxR6rjaLr5uJlLR7QM+H2mMP4WDQs5RZkeVV03lzlogNCcefoZFUrdSd/YdEZDWPKPylTZj+LL/TTKb5rUu6T0U0bZIwNY9oeq34D

Is should be centered like this:

https://cesiumjs.org/Cesium/Build/Apps/Sandcastle/#c=dVNdb9owFP0rV7w0SJHTkDSlLa2G6B6Q9oFatmlSXoxz6bw6vsh2aFnV/74bAmxUm/MQ+36dc4+vk2RG2gaYGGoqWGxg5mgpYIYBHYyNQRvDhExTL7SEL1av0XkdNnBHCwpaefggFwLulbRW24e2wNjgT2krRzB3pBQZDXyEjzKghokmJZ3RKEq7lg7WGp8Y6BosPsEEvW5q8XVri07U9jghG6S26E5ieCkt8GJqjk3MdK0rzr7cZyqHjPKNnKnmXUzUL+1r/6q07dcCBm3QYzhG7H7Z7bxzRi/QOHOoOiV7h54ap1AsHdVjzzHTKkqLfJD2YVu+60N4hRbFyulaB5bKC1lV0Q6yY9FyWBFLqMm+ISFd4J20WZSeng2Gp2fiosjSPEvPixiKdFDkeS6yPBueFoOLPIY0H+RZVoh8WJydD4fDi7+IKFmjk4JhWzWjnXDtqtAHbWWLf3lgEv/xo63mTlq/JFcfJODLc/o5F9Pb95/m0/n3ffhO2gMot+cFWWW0euTulo1VbfkI12hDf3d/OwnYf6wa58x2fKJ/6TLoyojnGLrNpt/Cc0VF1pNBYegh4sqt9fWY2FYNQ/Q4Dofuov8017/qxb2RDxuDN12j73S9IhfaqYiESALWK8OD5pNFox4xCOW3mKNknzSq9Bp0dV323gxx2QNlpPfsWTbG3OtfWPZuRgnHH6UZkhW/p8/83IzctCE/0psPnVEIMUr4uM/6DQ

This is actually the same issue as before, where the point you’re looking at is not on the ground. I clicked the point on the ground, and replaced the position with it in the first example, and it should look right now:

We can’t change the cartesian position to offset the camera angle. This point is going to be dynamic, and it’s going to be the centroid of various sized polygons.

Isn’t there a way to simply set the camera angle along an arc, like what the behavior of click and mouse drag, so the camera is always pointed at the position, without having to offset the position coordinates?