Here’s my use case: I have a geojson data source loaded (a polyline) , then I change the color or the thickness.
When I set my renderMode=false
, everything happens as expected. But for performance reasons, I need to be in renderMode=true.
Changing the color is still functional, but changing the thickness is not.
Of course, I’ve added a call to scene.requestRender()
.
I can display my entity.
Then if I change the thickness, the entity is no longer displayed. I have to manually move the camera to display the path with the correct thickness.
I found this PR #11934 and this Sandcastle
In the sandcastle, the requestRender does not work too with 1.127 (which is the version I’m using in my app)
Any idea ?
I’ve check with an old version , 1.110, it is the same.
But found that the number of points in the polyline have an effect. Withfew (approx. 200 points) it is ok, I can change the thickness on demand. My polylines have 2000 or more points and it fails…
I’m trying a solution using postUpdate event but it’s a little bit tricky , due to CPU usage.
Here’s a workaround in React.
We play with some render events in order to keep a low CPU usage. Here we have a high CPU usage during 0.5 second which is largely acceptable.
But I think that there is a bug somewhere in the render part of Cesium where a requestRender
should act as expected, immediatly.
const requestRender = () => {
if (update) {
viewer.scene.requestRender();
setTimeout(() => {
viewer.scene.postUpdate.removeEventListener(requestRender);
setUpdate(true);
}, 0.5*SECOND);
}
};
useEffect(() => {
setUpdate(true);
const handleCameraMove = () => {
viewer.scene.postUpdate.removeEventListener(requestRender);
viewer.scene.camera.changed.removeEventListener(handleCameraMove);
};
viewer.scene.postUpdate.addEventListener(requestRender);
viewer.scene.camera.changed.addEventListener(handleCameraMove);
return () => {
viewer.scene.postUpdate.removeEventListener(requestRender);
viewer.scene.camera.changed.removeEventListener(handleCameraMove);
};
}, [editorSnapshot.track.thickness]);