Help flying to a Rectangle using sceneMode: Cesium.SceneMode.SCENE2D

1. A concise explanation of the problem you’re experiencing.

Flying to a destination from a Rectangle when the view sceneMode: Cesium.SceneMode.SCENE2D is not working as expected.


const rectangle = Cesium.Rectangle.fromDegrees(left, bottom, right, top)

const destination = viewer.camera.getRectangleCameraCoordinates(rectangle)

viewer.camera.flyTo({

destination

})

When I use a SCENE3D the flyTo works correctly, but using SCENE2D it goes to unexpected places.

2. A minimal code example. If you’ve found a bug, this helps us reproduce and repair it.

It’s reproducible on sandcastle:

https://sandcastle.cesium.com/#c=ZVHLTsMwEPwVKxdSKTgPJ2lTQoUUuPGQKOKUi3G2xcKxke20Koh/x2mbUMC3nZ3ZnR1vqEYbDlvQ6BJJ2KIKDO9a/LzH/DO2LyslLeUS9FmAPmuJ/jzDQMKdamA+yJcDgpfVzf1Nco2+Jhe1rCVT0likgVkq1wLc0uO8LRg7R+cxnkVpTrJplEVZkU7zABnV2dc5ijDJIxKlJCEkL5KsyLIAAR1VDkyLIk4LMk2Ja0mlB1kcz9J0Nk1IEeczUsuvHyeNW8sltVxJ5+WQBGa0BU3xGuzjYLTaQ5VSuunpYPzxhskwi1HtGpzKxI06BlGNGF5p1Y4l8U82T3o/v3evxO5J+WPWJ+TA+Z94gVcauxOwODCuePvu7kWdFj7GoYX2XfQuw5eOvYHFzJg+/zIcRGXDN4g3l7X354drDzFBjXGdVSfEkn9A7S3K0PF/yYSiLon1wwa0oLue8hovbg8gxrgMXflfZZUSL1SfTPwG

3. Context. Why do you need to do this? We might know a better way to accomplish your goal.

I store a rectangle so when I pick a location I can zoom into the rectangle location with this snippet;

This looks like a bug to me. I opened an issue here: https://github.com/CesiumGS/cesium/issues/8697

You can pass a rectangle to the destination when doing viewer.camera.flyTo, that seems to work correctly in 3D and 2D. Does that work for you?

Yes, it’s working using the rectangle. Thank you so much!

Following up on this, seems like after flying to the rectangle the method camera.computeViewRectangle() is returning undefined.

Do you have a change to give it a check? I modified your sandcastle a little bit here

Well seems more like the rectangle is not available in America

Sandcastle