-
-
Notifications
You must be signed in to change notification settings - Fork 136
Open
Description
Reporoduction:
// example setup to cause props to change after 1 second
function useLightingDelay(){
const [lighting, setLighting] = useState(true);
useEffect(() => {
const timer = setTimeout(() => {
setLighting(false);
}, 1000);
return () => clearTimeout(timer);
});
return lighting;
}
// example terrain (same class as default terrain, but obviously a fresh instance)
// createWorldTerrainAsync() also has the same behavior if you want to test with promises.
const terrain = new EllipsoidTerrainProvider();
// after update, globe disappears, leaving only atmospheric effects
function Breaks(){
const lighting = useLightingDelay();
return (
<Viewer>
<Globe enableLighting={lighting}/>
</Viewer>
);
}
// after update, globe disappears, leaving only atmospheric effects
function AlsoBreaks(){
const lighting = useLightingDelay();
return (
<Viewer terrainProvider={terrain}>
<Globe enableLighting={lighting}/>
</Viewer>
);
}
// after update, globe disappears until terrain is recalculated
function Flashes(){
const lighting = useLightingDelay();
return (
<Viewer>
<Globe enableLighting={lighting} terrainProvider={terrain} />
</Viewer>
);
}
// after update nothing happens (other than lighting being disabled).
// this is what I would expect to happen for both examples above
function Workaround(){
const lighting = useLightingDelay();
return (
<Viewer terrainProvider={terrain}>
<Globe enableLighting={lighting} terrainProvider={terrain} />
</Viewer>
);
}I believe this is due to the unconditional assignment at https://github.com/reearth/resium/blob/main/src/Globe/Globe.ts#L119 .
But I don't understand why it doesn't apply on the first render.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels