Actual position in 2D

I’ve integrated cesium with three js using this tutorial:

In 3D mode it works as expected. But in 2D and CV mode it doesn’t: the positions are off.
I found this function for calculating the actual position in Cesium’s source code: cesium/SceneTransforms.js at master · CesiumGS/cesium · GitHub
It works for Columbus view, but not in 2D. The objects seem to be too high above and aren’t correctly positioned when moving/zooming the camera.

P.S. For Columbus view I use this function:

const transformCV = (pos: Cartesian3) => {
    const temp = cartToVec(cesium.scene.mapProjection.project(Ellipsoid.WGS84.cartesianToCartographic(pos)));
    return Cartesian3.fromArray([temp.z, temp.x, temp.y]);
}

According to the source code, it should be like this in 2D:

const transform2D = (pos: Cartesian3) => {
    const temp = cartToVec(cesium.scene.mapProjection.project(Ellipsoid.WGS84.cartesianToCartographic(pos)));
    return Cartesian3.fromArray([0, temp.x, temp.y]);
}

But it doesn’t work

Hi @IvanLudvig,

I apologize for the delayed response. Can you put together a Sandcastle that demonstrates your issue? I would be able to offer more help then.

Best regards,
Janine

I also encountered this problem, did you solve it?

I solved it by making my own switcher for projection modes. When 2D mode is selected, I switch to Columbus view with camera looking directly down with tilt disabled

Can you share the code to me