-
-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cesium polyline is not rendering, when state variable changes #465
Comments
That question is already answered. |
@rot1024 can you link to where it was answered |
Sorry. I didn't read that page in detail, so I misunderstood. I've read the code, but so far I can't figure out why. I tried the following code: import React, { useState } from "react";
import { Cartesian3, Color } from "cesium";
import { Viewer, Entity, PolylineGraphics } from "resium";
const positions = Cartesian3.fromDegreesArrayHeights([0, 0, 1000, 100, 100, 1000]);
const App = () => {
const [s, ss] = useState(0);
useEffect(() => {
const i = setInterval(() => ss(v => v + 1), 1000);
return () => clearInterval(i);
}, []);
return (
<Viewer full>
<Entity>
<PolylineGraphics
show
width={3}
material={Color.RED}
positions={positions}
/>
</Entity>
<div style={{ position: "absolute", left: "0", top: "0", color: "#fff" }}>{s}</div>
</Viewer>
);
};
export default App; Result (Cesium 1.82.1, Resium v1.13.1): As you can see, the polylines are displayed successfully even though there was a state update, so there seems to be no problem with Cesium or Resium itself. Tip: Unfortunately, the cause is not clear. Perhaps the component itself is not displaying, or perhaps there is a mistake in the polyline data. Or maybe your Cesium or Resium is old and you have stepped on some bug (I recommend upgrading). If you can provide us with the smallest amount of self-contained code that causes the problem, we may be able to clarify the issue further. And in the process, you'll often discover the cause. |
@rot1024 The problem for me was using How do you recommend updating state if you can't use it within the component? Ideally, I'd like to use the |
Here's a minimal non-working example
And here it is when |
Problem description https://stackoverflow.com/questions/65632650/cesium-polyline-is-not-rendering-when-state-variable-changes
The text was updated successfully, but these errors were encountered: