Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

fix(image-editor): source not displaying in input #8188

Merged
merged 7 commits into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/client-core/i18n/en/editor.json
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@
"image": {
"name": "Image",
"description": "Dynamically loads an image.",
"lbl-imgURL": "Image Url",
"lbl-imgURL": "Image URL",
"lbl-transparency": "Transparency Mode",
"lbl-alphaCutoff": "Alpha Cutoff",
"lbl-projection": "Projection",
Expand Down
19 changes: 15 additions & 4 deletions packages/editor/src/components/properties/ImageNodeEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,30 @@ export const ImageNodeEditor: EditorComponentType = (props) => {
const imageComponent = useComponent(entity, ImageComponent)
const errors = getEntityErrors(props.entity, ImageComponent)

const imageSource =
HexaField marked this conversation as resolved.
Show resolved Hide resolved
imageComponent.resource.value?.jpegStaticResource?.url ||
imageComponent.resource.value?.gifStaticResource?.url ||
imageComponent.resource.value?.pngStaticResource?.url ||
imageComponent.resource.value?.ktx2StaticResource?.url ||
imageComponent.resource.value?.source ||
imageComponent.source.value ||
''

return (
<NodeEditor
{...props}
name={t('editor:properties.image.name')}
description={t('editor:properties.image.description')}
>
<InputGroup name="Image Url" label={t('editor:properties.image.lbl-imgURL')}>
<ImageInput value={imageComponent.source?.value ?? ''} onChange={updateProperty(ImageComponent, 'source')} />
<ImageInput value={imageSource} onChange={updateProperty(ImageComponent, 'source')} />
</InputGroup>
{errors ? (
Object.entries(errors).map(([err, message]) => {
return <div style={{ marginTop: 2, color: '#FF8C00' }}>{'Error: ' + err + '--' + message}</div>
})
Object.entries(errors).map(([err, message]) => (
<div key={err} style={{ marginTop: 2, color: '#FF8C00' }}>
{'Error: ' + err + '--' + message}
</div>
))
) : (
<></>
)}
Expand Down
2 changes: 1 addition & 1 deletion packages/engine/src/scene/components/ImageComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export function ImageReactor() {
// TODO: abort load request, pending https://github.com/mrdoob/three.js/pull/23070
}
},
[image.resource]
[entity, source]
HexaField marked this conversation as resolved.
Show resolved Hide resolved
)

useEffect(
Expand Down