I have a question about synchronized multiple callback properties.
This is sandcastle link:
I want update position, cylinder length, cylinder bottomRadius at the same time. As you can see in console log: index between position, length and bottomRadius is different.
My question is: How could we synchronized index in 3 callback property?
Thank for you help.
I think the problem is you’re thinking of a CallbackProperty as an update mechanism. A CallbackProperty should not alter state in itself, but it should compute a value based on the given input (in this case, time). This is because this property is not called once per frame - it’s called every time it’s evaluated. In other words, if 2 parts of the code are checking or using the entity’s position, then the callback property is called twice that frame.
I wrote a bit on the ideology behind a CallbackProperty here:
For your case, I think what you might want to do is have an onTick function (see the viewer.onTick event) or just some function that runs every frame update the properties, and all the CallbackProperty does is return that current value. Note that this way, you’re no longer using Cesium’s time dynamic system, so your updates will not match the timeline and won’t be controlled by the timeline, but this will let you update values every frame as you’re attempting to do now.