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