Dynamic entity position and custom ellipsoid model

Hello,

I am trying to have an entity to follow the mouse position.
As far as I understand the suggested way to do that is to use the dynamic properties via the CallbackProperty mechanism.

It actually works, but only if I use a WGS84 globe.
When using a different ellipsoid model, the dynamic entity shows as it is still on WGS84. What is happening here?

The following sandcastle snippet shows the issue (try to switch between models A/B at the top):

<pre>

var myRad = 3e6;
var myModel_A = new Cesium.Ellipsoid( myRad, myRad, myRad );
var myModel_B = Cesium.Ellipsoid.WGS84;
var myModel = myModel_A;

var viewer = new Cesium.Viewer('cesiumContainer', {
    selectionIndicator : false,
    infoBox : false,
    globe: new Cesium.Globe( myModel )
});

var a_start = Cesium.Cartesian3.fromDegrees( -80, 42, 0, myModel );
var a_end = Cesium.Cartesian3.fromDegrees( 0, 0, 0, myModel );
// var a_start = Cesium.Cartesian3.fromDegrees( -80, 42 );
// var a_end = Cesium.Cartesian3.fromDegrees( 0, 0 );
viewer.entities.add({
    name : "line A",
    polyline : {
        positions: [ a_start, a_end ],
        width : 3,
        material : Cesium.Color.RED
    }
});

viewer.entities.add({
    name : "line B",
    polyline : {
        positions: new Cesium.CallbackProperty( function () {
            return [ a_start, a_end ];
        }, false ),
        width : 3,
        material : Cesium.Color.GREEN
    }
});

var handler = new Cesium.ScreenSpaceEventHandler( viewer.scene.canvas );
handler.setInputAction( function(mouse_move) {

    var underMouse = viewer.camera.pickEllipsoid( mouse_move.endPosition, myModel );
    if ( underMouse === undefined ) {return;}
    
    a_end = underMouse;
    
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);

</pre>

Thanks,
Andrea

Hello Andrea,

Thanks so much for posting this code sample! It helped me track down the issue very quickly.

It looks like in the entity layer, we’re not sending the correct ellipsoid to the function that computes the polyline positions.

I’m going to submit a fix for that now and it should be included in the next release. I’ll let you know when it has been merged into master.

Best,

Hannah

Hey super thank you!

Andrea

Hannah,

I noticed that there is a similar issue when displaying paths from
CZML data sources:
The paths show correctly except they are positioned as if they were on
a WGS84 ellipsoid.
I thought this might be related to the entities issue.

Thanks in advance,
Andrea

Hi Andrea,

Thanks for the heads up! I’m pretty sure that was fixed by the same thing that fixed the polyline issue, but I’ve made a note to myself to double check and make sure for the next release =)

-Hannah

Hello Andrea,

Are you still seeing this problem with your paths? It looks like if your are using cartographicDegrees or cartographicRadians to define your positions from CZML, it always uses the WGS84 ellipsoid. In order to avoid this error when using a custom ellipsoid, you will have to specify your positions in cartesian coordinates instead.

Best,

Hannah

Hannah,

yes, I confirm the issue is still there on v1.16; and yes, as you guessed I am using cartographicDegrees in CZML. Are there plans to support a generic ellipsoid (e.g. 3 semi-axis values) in CZML?
If not, related to the cartesian coordinates, which convention for the axis is Cesium using for x,y,z? is it using a ECEF frame?

Thanks in advance,
Andrea

I don’t know if we have any plans to support custom ellipsoids from CZML.
And yes, we do use ECEF for the Cartesian coordinate system. For reference, here is the function we use to convert cartographics to cartesians: https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Source/Core/Ellipsoid.js#L383

I suspect we have custom ellipsoid bugs in a handful of other places that we haven’t run into yet because so many of our users have earth-based applications. If you find anything else let me know! =)

Best,

Hannah