Add project time settings functionality in App.tsx
This commit is contained in:
@@ -35,6 +35,7 @@ import { createDeleteInteractionLinkCommand } from "../commands/delete-interacti
|
|||||||
import { createSetModelInstanceAuthoredStateCommand } from "../commands/set-model-instance-authored-state-command";
|
import { createSetModelInstanceAuthoredStateCommand } from "../commands/set-model-instance-authored-state-command";
|
||||||
import { createSetModelInstanceNameCommand } from "../commands/set-model-instance-name-command";
|
import { createSetModelInstanceNameCommand } from "../commands/set-model-instance-name-command";
|
||||||
import { createSetProjectNameCommand } from "../commands/set-project-name-command";
|
import { createSetProjectNameCommand } from "../commands/set-project-name-command";
|
||||||
|
import { createSetProjectTimeSettingsCommand } from "../commands/set-project-time-settings-command";
|
||||||
import { createSetSceneLoadingScreenCommand } from "../commands/set-scene-loading-screen-command";
|
import { createSetSceneLoadingScreenCommand } from "../commands/set-scene-loading-screen-command";
|
||||||
import { createSetSceneNameCommand } from "../commands/set-scene-name-command";
|
import { createSetSceneNameCommand } from "../commands/set-scene-name-command";
|
||||||
import { createSetWorldSettingsCommand } from "../commands/set-world-settings-command";
|
import { createSetWorldSettingsCommand } from "../commands/set-world-settings-command";
|
||||||
@@ -159,6 +160,11 @@ import {
|
|||||||
DEFAULT_PROJECT_NAME,
|
DEFAULT_PROJECT_NAME,
|
||||||
type SceneLoadingScreenSettings
|
type SceneLoadingScreenSettings
|
||||||
} from "../document/scene-document";
|
} from "../document/scene-document";
|
||||||
|
import {
|
||||||
|
areProjectTimeSettingsEqual,
|
||||||
|
formatTimeOfDayHours,
|
||||||
|
normalizeTimeOfDayHours
|
||||||
|
} from "../document/project-time-settings";
|
||||||
import {
|
import {
|
||||||
formatSceneDiagnosticSummary,
|
formatSceneDiagnosticSummary,
|
||||||
validateProjectDocument,
|
validateProjectDocument,
|
||||||
@@ -271,8 +277,15 @@ import type {
|
|||||||
RuntimeLocomotionState
|
RuntimeLocomotionState
|
||||||
} from "../runtime-three/navigation-controller";
|
} from "../runtime-three/navigation-controller";
|
||||||
import type { RuntimeInteractionPrompt } from "../runtime-three/runtime-interaction-system";
|
import type { RuntimeInteractionPrompt } from "../runtime-three/runtime-interaction-system";
|
||||||
import { createDefaultRuntimeGlobalState, type RuntimeGlobalState } from "../runtime-three/runtime-global-state";
|
import {
|
||||||
|
createDefaultRuntimeGlobalState,
|
||||||
|
type RuntimeGlobalState
|
||||||
|
} from "../runtime-three/runtime-global-state";
|
||||||
import type { RuntimeSceneExitTransitionRequest } from "../runtime-three/runtime-host";
|
import type { RuntimeSceneExitTransitionRequest } from "../runtime-three/runtime-host";
|
||||||
|
import {
|
||||||
|
areRuntimeClockStatesEqual,
|
||||||
|
type RuntimeClockState
|
||||||
|
} from "../runtime-three/runtime-project-time";
|
||||||
import {
|
import {
|
||||||
buildRuntimeSceneFromDocument,
|
buildRuntimeSceneFromDocument,
|
||||||
type RuntimeNavigationMode,
|
type RuntimeNavigationMode,
|
||||||
@@ -1851,6 +1864,10 @@ export function App({ store, initialStatusMessage }: AppProps) {
|
|||||||
const [sunDirectionDraft, setSunDirectionDraft] = useState(
|
const [sunDirectionDraft, setSunDirectionDraft] = useState(
|
||||||
createVec3Draft(editorState.document.world.sunLight.direction)
|
createVec3Draft(editorState.document.world.sunLight.direction)
|
||||||
);
|
);
|
||||||
|
const [projectTimeStartTimeOfDayDraft, setProjectTimeStartTimeOfDayDraft] =
|
||||||
|
useState(String(editorState.projectDocument.time.startTimeOfDayHours));
|
||||||
|
const [projectTimeDayLengthMinutesDraft, setProjectTimeDayLengthMinutesDraft] =
|
||||||
|
useState(String(editorState.projectDocument.time.dayLengthMinutes));
|
||||||
const [
|
const [
|
||||||
backgroundEnvironmentIntensityDraft,
|
backgroundEnvironmentIntensityDraft,
|
||||||
setBackgroundEnvironmentIntensityDraft
|
setBackgroundEnvironmentIntensityDraft
|
||||||
@@ -1971,7 +1988,9 @@ export function App({ store, initialStatusMessage }: AppProps) {
|
|||||||
const [runtimeSceneLoadingScreen, setRuntimeSceneLoadingScreen] =
|
const [runtimeSceneLoadingScreen, setRuntimeSceneLoadingScreen] =
|
||||||
useState<SceneLoadingScreenSettings | null>(null);
|
useState<SceneLoadingScreenSettings | null>(null);
|
||||||
const [runtimeGlobalState, setRuntimeGlobalState] =
|
const [runtimeGlobalState, setRuntimeGlobalState] =
|
||||||
useState<RuntimeGlobalState>(createDefaultRuntimeGlobalState());
|
useState<RuntimeGlobalState>(
|
||||||
|
createDefaultRuntimeGlobalState(editorState.projectDocument.time)
|
||||||
|
);
|
||||||
const [runtimeMessage, setRuntimeMessage] = useState<string | null>(null);
|
const [runtimeMessage, setRuntimeMessage] = useState<string | null>(null);
|
||||||
const [firstPersonTelemetry, setFirstPersonTelemetry] =
|
const [firstPersonTelemetry, setFirstPersonTelemetry] =
|
||||||
useState<FirstPersonTelemetry | null>(null);
|
useState<FirstPersonTelemetry | null>(null);
|
||||||
@@ -2373,6 +2392,18 @@ export function App({ store, initialStatusMessage }: AppProps) {
|
|||||||
setModelScaleDraft(createVec3Draft(selectedModelInstance.scale));
|
setModelScaleDraft(createVec3Draft(selectedModelInstance.scale));
|
||||||
}, [selectedModelInstance]);
|
}, [selectedModelInstance]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setProjectTimeStartTimeOfDayDraft(
|
||||||
|
String(editorState.projectDocument.time.startTimeOfDayHours)
|
||||||
|
);
|
||||||
|
}, [editorState.projectDocument.time.startTimeOfDayHours]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setProjectTimeDayLengthMinutesDraft(
|
||||||
|
String(editorState.projectDocument.time.dayLengthMinutes)
|
||||||
|
);
|
||||||
|
}, [editorState.projectDocument.time.dayLengthMinutes]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setAmbientLightIntensityDraft(
|
setAmbientLightIntensityDraft(
|
||||||
String(editorState.document.world.ambientLight.intensity)
|
String(editorState.document.world.ambientLight.intensity)
|
||||||
|
|||||||
Reference in New Issue
Block a user