Extra millisecond in CallbackProperty

I've added a couple console logs into the "Callback Property" sandcastle example that output the time parameter to the "length" and "midpoint" callbacks. The midpoint function (the position of the label) gets called 3 times for each length function (the text of the label). That's fine, but the third time that the midpoint function is called there's an extra millisecond.

This is an example (I'm displaying secondsOfDay of the time parameter):

midpoint
68948.55300000048
length
68948.55300000048
midpoint
68948.55300000048
midpoint
68948.55400000048
midpoint
68948.66700000048
length
68948.66700000048
midpoint
68948.66700000048
midpoint
68948.66800000049

This works fine for the sandcastle example, but in my application the callback references a pair of entities with SampledPositionProperty and the extra millisecond pushes the time past the last sample.

I'm using cesium 1.48.

Is there a recommended way of dealing with that extra millisecond?

In the sandcastle example, the camera is tracking the entity that draws the label:

viewer.trackedEntity = label;

Part of the logic for tracking an object with the camera uses heuristics to select different reference frames depending on the velocity of the object, which it computes using finite differencing. This is the extra call at t + 0.001

In general, though, any property is expected to be able to return a value for any given time. Returning undefined is a valid result if the object does not exist at the requested time. Alternatively, you could look into the extrapolation options for SampledPositionProperty to either extrapolate or hold the last value.

Thanks Scott. Velocities via finite differences is understandable, but the side-effect is a bit surprising.

Thanks for the suggestion of the extrapolation options. I wasn't aware of those. That looks like an ideal solution in my case.