In sceneMode 3D and 2D, relative position between point and line is different

I have a line and a point, their coordinates is as follows:

import * as Cesium from "cesium";



/* eslint-disable no-unused-vars */



const viewer = new Cesium.Viewer("cesiumContainer");



const redLine = viewer.entities.add({

  name: "Red line on terrain",

  polyline: {

    positions: Cesium.Cartesian3.fromDegreesArray([82.747848, 46.527242,82.778759, 46.599381]),

    width: 5,

    material: Cesium.Color.RED,

    clampToGround: true,

},

});



const greenRhumbLine = viewer.entities.add({

  name: "Green rhumb line",

  polyline: {

    positions: Cesium.Cartesian3.fromDegreesArray([82.747848, 46.527242,82.778759, 46.599381]),

    width: 5,

    arcType: Cesium.ArcType.RHUMB,

    material: Cesium.Color.GREEN,

    clampToGround: true,

},

});



const point = viewer.entities.add({

  position: Cesium.Cartesian3.fromDegrees(82.75719, 46.5490441),

  point: {

    pixelSize: 20,

}

})



viewer.zoomTo(viewer.entities);

In 3D scene mode, the point looks like southeast of the line,but in 2D scene mode, it seems like the point is almost on the line.

I have already set clamptoGround = true, also, two arcType I have tried. But the result is the same.

Also, I try to Interpolate the line into 100 piece, but the result looks the same.

Why does this happend? How to fix this?

Hi @ly15927086342,

Welcome to the CesiumJS community! Do you have any pictures of this issue? I just copy-pasted your code into https://sandcastle.cesium.com/ and the line + point looked the same to me in both 3D and 2D modes.

Best,
Matt

Hi @mzschwartz5


both of them are in the Max zoom.
thank you for your apply!

Hmm that’s odd indeed… I’m not totally sure whether this is a bug, or just an artifact of projection. It’s possible that projecting things to 2D can visually squeeze two things closer together. But… it almost looks as though the point has gone past the line in 2D.

I’ll see if anyone else has any thoughts.

Explanation courtesy of @jjhembd:

Basically the default ArcType.NONE is “dumb”: it’s linear in whatever projection you are using. This is why it changes between 3D and 2D. The other 2 ArcTypes should stay the same relative to each other (and relative to a given point) in every projection.

So the red line (ArcType.NONE) is basically just going to “connect the dots”, and that means its position shifts in different scene modes (3D / 2D). The other arctypes (RHUMB and GEODESIC) will be consistent relative to each other and your point of interest regardless of scene mode.

You can see that in this sandcastle demo that @jjhembd made. As before, the red line (NONE arctype) shifts relative to the point in 3D vs. 2D mode. But the yellow and green lines are consistent in their positions relative to each other and the point, in 3D and 2D mode.

I think the arcType of red line is not ArcType.NONE, according to cesium doc, the default value is ArcType.GEODESTIC. Also, I try to add ArcType.GEODESTIC to red line, the result looks the same with sandcastle demo.

The only difference between red line and yellow line, is the param granularity. The red line doesn’t have param granularity, which of yellow one is 1.0. In 3D mode, when arcType is GEODESTIC, whether granularity exists or not, lines look the same. While when arcType is RHUMB, in the same situation, lines look different. Both of them, point is in the east of line.

In 2D/2.5D mode, whatever arcType is, once the granularity is defined, the point looks in the east of the line, otherwise, the point looks on line.

I think the key to solve this problem, is to figure out the granularity effect in different scene mode. Any ideas?

@mzschwartz5