resium
resium copied to clipboard
Adding a new entity within Viewer/Scene causes the entire scene to re-render.
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>
</>
}
To add to this, I know I can keep a viewerRef and call add on the entity collection, but that defeats the purpose of having a react wrapper around Cesium.
I would expect to have an EntityCollection component inside of which I could add / remote Entity components without causing the entire scene to reload.
I am also looking for the entityCollection component to dynamically add/remove/edit entities avoiding the scene to rerender. @rot1024 any hint? Thank you