I want to dynamically add / remove entities from a scene but doing so causes the entire scene to re-render.
On pure cesium, calling viewer.entities.add does not have the same effect. Is this possible to achieve with Resium as well?
In the notional example below I have added a button that switches an Entity containing a point graphic with an identical one. Upon clicking the button, the whole scene reloads:
export default function Test() {
const [swapped, setSwapped] = React.useState(false);
return (
<>
<div
onClick={() => {
setSwapped(!swapped);
}}
style={{ position: "absolute", top: 25, left: 25, zIndex: 2 }}
>
swap pins
</div>
<Resium.Viewer
full
style={{
zIndex: 1,
}}
>
<Resium.Scene debugShowFramesPerSecond={true}>
{swapped ? (
<Resium.Entity
point={{ pixelSize: 10 }}
position={Cartesian3.fromDegrees(
longitude,
latitude,
altitude
)} />
) : (
<Resium.Entity
point={{ pixelSize: 10 }}
position={Cartesian3.fromDegrees(
longitude,
latitude,
altitude
)} />
)}
</Resium.Scene>
</Resium.Viewer>
</>
}