Hello
I'm trying to change the end of polyline position to current mouse cursor
position on MOUSE_MOVE event (in the same way as in Picking example we change position for a label), but the line changes position very very slowly.
May be I do something wrong?
The code:
var viewer = new Cesium.Viewer('cesiumContainer', {
selectionIndicator : false,
infoBox : false
});
var scene = viewer.scene;
var handler;
Sandcastle.addDefaultToolbarButton('Show Cartographic Position on Mouse Over', function() {
var entity = viewer.entities.add({
label : {
show : false
}
});
var redLine = viewer.entities.add({
name : 'Red line on the surface',
polyline : {
positions : Cesium.Cartesian3.fromDegreesArray([-75, 35,
-125, 35]),
width : 1,
material : Cesium.Color.RED
}
});
// Mouse over the globe to see the cartographic position
handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
handler.setInputAction(function(movement) {
var cartesian = viewer.camera.pickEllipsoid(movement.endPosition, scene.globe.ellipsoid);
if (cartesian) {
var cartographic = Cesium.Cartographic.fromCartesian(cartesian);
var longitudeString = Cesium.Math.toDegrees(cartographic.longitude).toFixed(2);
var latitudeString = Cesium.Math.toDegrees(cartographic.latitude).toFixed(2);
//entity.position = cartesian;
//entity.label.show = true;
//entity.label.text = '(' + longitudeString + ', ' + latitudeString + ')';
redLine.polyline.positions=Cesium.Cartesian3.fromDegreesArray([-75, 35,
longitudeString, latitudeString]);
} else {
entity.label.show = false;
}
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
});