Skybox time settings - Versioning SceneMetada component - #1184
Conversation
Test this pull request
|
Deploying js-sdk-toolchain with
|
| Latest commit: |
5f40711
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://cd6f4b3b.js-sdk-toolchain.pages.dev |
| Branch Preview URL: | https://feat-skybox-time-settings.js-sdk-toolchain.pages.dev |
| onChange={handleSkyboxAutoChange} | ||
| /> | ||
| <RangeHourField | ||
| value={componentValue.skyboxConfig?.fixedTime || MIDDAY_SECONDS} |
There was a problem hiding this comment.
in case fixedTime is 0, this will default to MIDDAY_SECONDS. Is this correct? (maybe replace it with ??)
| skyboxConfig: { | ||
| fixedTime: Number(inputs.skyboxConfig.fixedTime || MIDDAY_SECONDS), | ||
| transitionMode: TransitionMode.TM_FORWARD | ||
| }, |
There was a problem hiding this comment.
same as above for all the previous ones
| rightLabel?: string | ||
| error?: string | boolean | ||
| info?: React.ReactNode | ||
| isValidValue?: (value: any) => boolean |
There was a problem hiding this comment.
I finally removed this prop
| export type Props = React.InputHTMLAttributes<Omit<HTMLElement, 'type'>> & { | ||
| label?: React.ReactNode | ||
| rightLabel?: string | ||
| error?: string | boolean |
There was a problem hiding this comment.
I think this one should be string | undefined
There was a problem hiding this comment.
Also removed the error prop
| info, | ||
| value = 0, | ||
| min = 0, | ||
| max = 86400, |
There was a problem hiding this comment.
the min and the max value are now set in the component itself
| useEffect(() => { | ||
| const numValue = Number(value) | ||
| if (numValue !== inputValue) { | ||
| setInputValue(numValue) | ||
| setTextValue(formatHour(numValue)) | ||
| } | ||
| }, [value]) |
There was a problem hiding this comment.
I think this one is not necessary 🤔
There was a problem hiding this comment.
it updates the state after a value is received by prop, because the value is not being directly used, it's on the useState
| const [inputValue, setInputValue] = useState<number>(Number(value)) | ||
| const [textValue, setTextValue] = useState(formatHour(Number(value))) |
There was a problem hiding this comment.
seems like this two always change together, maybe we can const [value, setValue] = useState<{ timeInSeconds: number; timeInHHMM: string; }> ?
| if (value.length <= 5) { | ||
| setTextValue(value) | ||
|
|
||
| // Si es un formato válido de hora, actualizar el slider | ||
| if (isValidTimeFormat(value)) { | ||
| const seconds = parseTimeInput(value) | ||
| if (seconds >= Number(min) && seconds <= Number(max)) { | ||
| setInputValue(seconds) | ||
| onChange && | ||
| onChange({ | ||
| ...e, | ||
| target: { ...e.target, value: seconds.toString() } | ||
| } as React.ChangeEvent<HTMLInputElement>) | ||
| } | ||
| } | ||
| } | ||
| }, |
There was a problem hiding this comment.
I think we should split the logic for handling changes on the value input and the text input so we end up with something like:
- handleChangeRange => does what
handleChangeis currently doing + callhandleChange - handleChangeTime => does what
handleChangeTextFieldis currently doing + callhandleChange - handleChange => check if whole value ({ timeInSeconds, timeInHHMM }) is valid and calls
props.onChange
There was a problem hiding this comment.
I'll double check this logic because now that I'm using a native time input, the validation is done by the input itself, so I don't think I need most of these validations
| export function migrateSceneMetadata(engine: IEngine) { | ||
| const latestComponent = getCompositeLatestSceneComponent(engine) | ||
|
|
||
| if (!latestComponent) return | ||
|
|
||
| const { component, value } = latestComponent | ||
|
|
||
| const latestComponentVersion = getLatestSceneComponentVersion() | ||
| const isRunningLatestVersion = component.componentName === latestComponentVersion.key | ||
|
|
||
| if (isRunningLatestVersion) return | ||
|
|
||
| const oldComponent = component | ||
| oldComponent.deleteFrom(engine.RootEntity) | ||
| engine.removeComponentDefinition(oldComponent.componentName) | ||
|
|
||
| const SceneMetadata = engine.getComponent(latestComponentVersion.key) as EditorComponents['Scene'] | ||
| SceneMetadata.createOrReplace(engine.RootEntity, value) | ||
| } |
There was a problem hiding this comment.
🚀 🚀 🚀 🚀
(remember to delete all definitions except the latest one)
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1184 +/- ##
==========================================
- Coverage 62.00% 59.53% -2.47%
==========================================
Files 621 631 +10
Lines 20903 23065 +2162
Branches 2536 2585 +49
==========================================
+ Hits 12960 13731 +771
- Misses 7501 8889 +1388
- Partials 442 445 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
To test:
As it includes a migration of the scene metada componente, please test this feature in new scenes and old scenes.
Screen.Recording.2025-08-04.at.16.25.44.mov
Screen.Recording.2025-07-31.at.13.41.57.mov