Update state management for time-related properties in App.tsx

This commit is contained in:
2026-04-13 15:00:03 +02:00
parent 4f40ba1635
commit 184e07f8ef

View File

@@ -1902,34 +1902,36 @@ export function App({ store, initialStatusMessage }: AppProps) {
const [projectTimeDuskDurationHoursDraft, setProjectTimeDuskDurationHoursDraft] = const [projectTimeDuskDurationHoursDraft, setProjectTimeDuskDurationHoursDraft] =
useState(String(editorState.projectDocument.time.duskDurationHours)); useState(String(editorState.projectDocument.time.duskDurationHours));
const [ const [
projectTimeDawnAmbientIntensityFactorDraft, worldDawnAmbientIntensityFactorDraft,
setProjectTimeDawnAmbientIntensityFactorDraft setWorldDawnAmbientIntensityFactorDraft
] = useState(String(editorState.projectDocument.time.dawn.ambientIntensityFactor)); ] = useState(String(editorState.document.world.timeOfDay.dawn.ambientIntensityFactor));
const [ const [
projectTimeDawnLightIntensityFactorDraft, worldDawnLightIntensityFactorDraft,
setProjectTimeDawnLightIntensityFactorDraft setWorldDawnLightIntensityFactorDraft
] = useState(String(editorState.projectDocument.time.dawn.lightIntensityFactor)); ] = useState(String(editorState.document.world.timeOfDay.dawn.lightIntensityFactor));
const [ const [
projectTimeDuskAmbientIntensityFactorDraft, worldDuskAmbientIntensityFactorDraft,
setProjectTimeDuskAmbientIntensityFactorDraft setWorldDuskAmbientIntensityFactorDraft
] = useState(String(editorState.projectDocument.time.dusk.ambientIntensityFactor)); ] = useState(String(editorState.document.world.timeOfDay.dusk.ambientIntensityFactor));
const [ const [
projectTimeDuskLightIntensityFactorDraft, worldDuskLightIntensityFactorDraft,
setProjectTimeDuskLightIntensityFactorDraft setWorldDuskLightIntensityFactorDraft
] = useState(String(editorState.projectDocument.time.dusk.lightIntensityFactor)); ] = useState(String(editorState.document.world.timeOfDay.dusk.lightIntensityFactor));
const [ const [
projectTimeNightAmbientIntensityFactorDraft, worldNightAmbientIntensityFactorDraft,
setProjectTimeNightAmbientIntensityFactorDraft setWorldNightAmbientIntensityFactorDraft
] = useState(String(editorState.projectDocument.time.night.ambientIntensityFactor)); ] = useState(String(editorState.document.world.timeOfDay.night.ambientIntensityFactor));
const [ const [
projectTimeNightLightIntensityFactorDraft, worldNightLightIntensityFactorDraft,
setProjectTimeNightLightIntensityFactorDraft setWorldNightLightIntensityFactorDraft
] = useState(String(editorState.projectDocument.time.night.lightIntensityFactor)); ] = useState(String(editorState.document.world.timeOfDay.night.lightIntensityFactor));
const [ const [
projectTimeNightBackgroundEnvironmentIntensityDraft, worldNightBackgroundEnvironmentIntensityDraft,
setProjectTimeNightBackgroundEnvironmentIntensityDraft setWorldNightBackgroundEnvironmentIntensityDraft
] = useState( ] = useState(
String(editorState.projectDocument.time.nightBackground.environmentIntensity) editorState.document.world.timeOfDay.night.background.mode === "image"
? String(editorState.document.world.timeOfDay.night.background.environmentIntensity)
: "0.5"
); );
const [ const [
backgroundEnvironmentIntensityDraft, backgroundEnvironmentIntensityDraft,
@@ -2469,29 +2471,36 @@ export function App({ store, initialStatusMessage }: AppProps) {
); );
setProjectTimeDawnDurationHoursDraft(String(projectTime.dawnDurationHours)); setProjectTimeDawnDurationHoursDraft(String(projectTime.dawnDurationHours));
setProjectTimeDuskDurationHoursDraft(String(projectTime.duskDurationHours)); setProjectTimeDuskDurationHoursDraft(String(projectTime.duskDurationHours));
setProjectTimeDawnAmbientIntensityFactorDraft(
String(projectTime.dawn.ambientIntensityFactor)
);
setProjectTimeDawnLightIntensityFactorDraft(
String(projectTime.dawn.lightIntensityFactor)
);
setProjectTimeDuskAmbientIntensityFactorDraft(
String(projectTime.dusk.ambientIntensityFactor)
);
setProjectTimeDuskLightIntensityFactorDraft(
String(projectTime.dusk.lightIntensityFactor)
);
setProjectTimeNightAmbientIntensityFactorDraft(
String(projectTime.night.ambientIntensityFactor)
);
setProjectTimeNightLightIntensityFactorDraft(
String(projectTime.night.lightIntensityFactor)
);
setProjectTimeNightBackgroundEnvironmentIntensityDraft(
String(projectTime.nightBackground.environmentIntensity)
);
}, [editorState.projectDocument.time]); }, [editorState.projectDocument.time]);
useEffect(() => {
const worldTimeOfDay = editorState.document.world.timeOfDay;
setWorldDawnAmbientIntensityFactorDraft(
String(worldTimeOfDay.dawn.ambientIntensityFactor)
);
setWorldDawnLightIntensityFactorDraft(
String(worldTimeOfDay.dawn.lightIntensityFactor)
);
setWorldDuskAmbientIntensityFactorDraft(
String(worldTimeOfDay.dusk.ambientIntensityFactor)
);
setWorldDuskLightIntensityFactorDraft(
String(worldTimeOfDay.dusk.lightIntensityFactor)
);
setWorldNightAmbientIntensityFactorDraft(
String(worldTimeOfDay.night.ambientIntensityFactor)
);
setWorldNightLightIntensityFactorDraft(
String(worldTimeOfDay.night.lightIntensityFactor)
);
setWorldNightBackgroundEnvironmentIntensityDraft(
worldTimeOfDay.night.background.mode === "image"
? String(worldTimeOfDay.night.background.environmentIntensity)
: "0.5"
);
}, [editorState.document.world.timeOfDay]);
useEffect(() => { useEffect(() => {
setAmbientLightIntensityDraft( setAmbientLightIntensityDraft(
String(editorState.document.world.ambientLight.intensity) String(editorState.document.world.ambientLight.intensity)