Closed keiya01 closed 3 months ago
Seeing a similar issue to @Primajin where when we change the value of the terrainProvider
passed to Viewer
when switching between various terrain tilesets, Cesium does not update to reflect that change.
Should "terrainProvider"
be included in the cesiumProps
category in https://github.com/reearth/resium/blob/9c95c87859593ca76d8af981720034249aa37815/src/Viewer/Viewer.ts#L41 instead of in otherProps
?
@Primajin Thank you. I investigated the issue, but I couldn't see it. Is this story your issue? This story toggles EllipsoidTerrainProvider and CesiumTerrainProvider. But this is still working in 1.18.1. Could you give me a more specific code if possible?
For us, we're swapping a TerrainRgbProvider
with a new TerrainRgbProvider
. Our TerrainRgbProvider
extends the MartiniTerrainProvider
from cesium-martini
.
We've resolved the issue in our code by forcing a terrain provider update when we toggle between providers:
// We load this hook in our `Viewer` component wrapper
export function useUpdateTerrainProvider(
viewerRef: MutableRefObject<CesiumComponentRef<Viewer> | null>,
terrainProvider: TerrainProvider,
) {
useEffect(() => {
if (!viewerRef.current?.cesiumElement) {
return;
}
viewerRef.current.cesiumElement.terrainProvider = terrainProvider;
}, [terrainProvider, viewerRef.current?.cesiumElement]);
}
@MatthewHerbst Thanks for your help. I fixed it in v1.18.2. Could you try it?
Sorry for not responding earlier @keiya01, I can confirm that 1.18.2
works as expected again for me.
Thanks a lot for the fix 🙏🏻
Hi,
Sorry to reopen that subject, but I have the exact same problem in 1.18.2. I've been using the terrainProviderViewModels and selectedTerrainProviderViewModel and it was working fine. Since I updated from 1.17.2 to 1.18.2, the terrain doesn't seem to load correctly. If I remove the default selectedTerrainProviderViewModel, then I can manually select my terrain and it will load, but it doesn't do that on app startup. So it looks exactly like Primajin described "It is only loaded when manually selecting the terrain after everything has been loaded - but it doesn't load by default as it did before.". I tried manually fixing the terrain by adding a terrainProvider to the viewer, but the issue persist.
There is also an odd quirk when using a VPN (which is obviously beyond control of this project) the terrain doesn't load for me - when I deactivate it it works fine.
Apologies for the delayed response. 1.18.2 has not resolved the issue for us.
From a React perspective, I would expect the changing the terrainProvider
prop provided to Viewer
to completely re-render the component. At it's most simple this could simply be destroy the Cesium instance and re-create it. More complex would be manually changing the cesiumElement.terrainProvider
as I do in the hook I made to resolve this. I realize Cesium is a bit more nuanced about what a re-render actually means, but I don't think anything fancy needs to happen here. Happy to share anything that would be useful.
Hey there @keiya01 - I seem to have the opposite problem: Since this change in
1.18.1
my terrain isn't loaded anymore - with1.18.0
it still works.https://github.com/Primajin/satellite-tracker/pull/104
It is only loaded when manually selecting the terrain after everything has been loaded - but it doesn't load by default as it did before.