CallbackProperty function never gets called

I have an application that allows the user to draw a freehand line on the earth’s surface. I’m using a CallbackProperty for the poistions property of a Entities polyline. At one point I had the polyline updating correctly for the very first time the line was being drawn. I’ve made some changes so that a new polyline is created for each line that is being drawn(instead of trying to reuse the polyline). Now, the polyline isn’t updated until the user releases the mouse button, which is the exact behavior I was seeing prior to using the CallbackProperty.

Here’s the code:

temporaryPoints = ;

var tempLine = cesium.entities.add( {

“parent”: temporaryParent,

“position”: Cesium.Cartesian3.fromDegrees( 0, 0, 0 ),

“name”: TEMP_GRAPHIC_ID_PREFIX + TEMP_GRAPHIC_TYPE_LINE + “-” + id,

“polyline”: {

“positions”: new Cesium.CallbackProperty( function( time, result ) {

console.info( "polyline.positions callback: " + temporaryPoints.length );

return temporaryPoints;

}, false ),

“width”: 5,

“material”: Cesium.Color.RED

}

} );

The temporartPoints array is being updated via a drawing behavior which is receiving events from cesium. Can anyone see anything wrong with the code that I have?

Thanks,

Scott

I created a sample sandcastle drawing application(attached) to try to understand the CallbackProperty a little better, and of course the application works as expected. The way I had written the application, I could only draw one line at a time. I was able to fix that issue by replacing the CallbackProperty with a copy of the current points array. This causes the line to disappear briefly which isn’t a big deal, but I was wondering if anyone could look at the application and make a suggestion on how to make any improvements.

This application is written almost exactly the same way as my drawing code. I’ve created a unminified version of our Cesium build, so that I can try to trace through what all is going on my application. Since this issue is dealing with mouse move debugging can be rather difficult. Are there any suggestions on how to or where to place some console trace info to help out?

Thanks,

Scott

Drawing.html (3.48 KB)

Is there a way to remove a CallbackProperty and have the property value retain the current value? While the mouse is down, I need the line to be updated on mouse move, but as soon as the mouse up occurs the polyline’s positions property will be constant.

Scott

Hello Scott,

I didn’t get a chance to look at your example yet, but I’ll run it tomorrow to see if I can help with a solution.

To remove the callback property, I think you can just set the position to the final array of positions. Like polyline.positions = myPositionsArray.

Best,

Hannah

That’s what I’m currently doing, and that just causes the line to disappear for a couple of frames which is acceptable. I was just wondering if there was a way around visibility issue.