diff --git a/src/components/load3d/Load3D.vue b/src/components/load3d/Load3D.vue index b4161578c..ce6f83bc2 100644 --- a/src/components/load3d/Load3D.vue +++ b/src/components/load3d/Load3D.vue @@ -9,6 +9,7 @@ :fov="fov" :cameraType="cameraType" :showPreview="showPreview" + :backgroundImage="backgroundImage" @materialModeChange="listenMaterialModeChange" @backgroundColorChange="listenBackgroundColorChange" @lightIntensityChange="listenLightIntensityChange" @@ -16,6 +17,7 @@ @cameraTypeChange="listenCameraTypeChange" @showGridChange="listenShowGridChange" @showPreviewChange="listenShowPreviewChange" + @backgroundImageChange="listenBackgroundImageChange" /> ('perspective') +const hasBackgroundImage = ref(false) +const backgroundImage = ref('') const showPreviewButton = computed(() => { return !props.type.includes('Preview') @@ -89,6 +96,19 @@ const handleUpdateLightIntensity = (value: number) => { node.value.properties['Light Intensity'] = lightIntensity.value } +const handleBackgroundImageUpdate = async (file: File | null) => { + if (!file) { + hasBackgroundImage.value = false + backgroundImage.value = '' + node.value.properties['Background Image'] = '' + return + } + + backgroundImage.value = await Load3dUtils.uploadFile(file) + + node.value.properties['Background Image'] = backgroundImage.value +} + const handleUpdateFOV = (value: number) => { fov.value = value @@ -137,4 +157,12 @@ const listenShowGridChange = (value: boolean) => { const listenShowPreviewChange = (value: boolean) => { showPreview.value = value } + +const listenBackgroundImageChange = (value: string) => { + backgroundImage.value = value + + if (backgroundImage.value && backgroundImage.value !== '') { + hasBackgroundImage.value = true + } +} diff --git a/src/components/load3d/Load3DAnimation.vue b/src/components/load3d/Load3DAnimation.vue index 6fca8de2f..e96ea8508 100644 --- a/src/components/load3d/Load3DAnimation.vue +++ b/src/components/load3d/Load3DAnimation.vue @@ -15,6 +15,7 @@ :playing="playing" :selectedSpeed="selectedSpeed" :selectedAnimation="selectedAnimation" + :backgroundImage="backgroundImage" @materialModeChange="listenMaterialModeChange" @backgroundColorChange="listenBackgroundColorChange" @lightIntensityChange="listenLightIntensityChange" @@ -22,6 +23,7 @@ @cameraTypeChange="listenCameraTypeChange" @showGridChange="listenShowGridChange" @showPreviewChange="listenShowPreviewChange" + @backgroundImageChange="listenBackgroundImageChange" @animationListChange="animationListChange" />
@@ -35,6 +37,8 @@ :showFOVButton="showFOVButton" :showPreviewButton="showPreviewButton" :cameraType="cameraType" + :hasBackgroundImage="hasBackgroundImage" + @updateBackgroundImage="handleBackgroundImageUpdate" @switchCamera="switchCamera" @toggleGrid="toggleGrid" @updateBackgroundColor="handleBackgroundColorChange" @@ -60,6 +64,7 @@ import Load3DAnimationControls from '@/components/load3d/Load3DAnimationControls import Load3DAnimationScene from '@/components/load3d/Load3DAnimationScene.vue' import Load3DControls from '@/components/load3d/Load3DControls.vue' import type { AnimationItem } from '@/extensions/core/load3d/Load3dAnimation' +import Load3dUtils from '@/extensions/core/load3d/Load3dUtils' const props = defineProps<{ node: any @@ -75,11 +80,13 @@ const showLightIntensityButton = ref(true) const fov = ref(75) const showFOVButton = ref(true) const cameraType = ref<'perspective' | 'orthographic'>('perspective') +const hasBackgroundImage = ref(false) const animations = ref([]) const playing = ref(false) const selectedSpeed = ref(1) const selectedAnimation = ref(0) +const backgroundImage = ref('') const showPreviewButton = computed(() => { return !props.type.includes('Preview') @@ -112,6 +119,19 @@ const handleUpdateLightIntensity = (value: number) => { node.value.properties['Light Intensity'] = lightIntensity.value } +const handleBackgroundImageUpdate = async (file: File | null) => { + if (!file) { + hasBackgroundImage.value = false + backgroundImage.value = '' + node.value.properties['Background Image'] = '' + return + } + + backgroundImage.value = await Load3dUtils.uploadFile(file) + + node.value.properties['Background Image'] = backgroundImage.value +} + const handleUpdateFOV = (value: number) => { fov.value = value @@ -177,4 +197,12 @@ const listenShowGridChange = (value: boolean) => { const listenShowPreviewChange = (value: boolean) => { showPreview.value = value } + +const listenBackgroundImageChange = (value: string) => { + backgroundImage.value = value + + if (backgroundImage.value && backgroundImage.value !== '') { + hasBackgroundImage.value = true + } +} diff --git a/src/components/load3d/Load3DAnimationScene.vue b/src/components/load3d/Load3DAnimationScene.vue index fa50235a4..687213d3f 100644 --- a/src/components/load3d/Load3DAnimationScene.vue +++ b/src/components/load3d/Load3DAnimationScene.vue @@ -9,6 +9,7 @@ :cameraType="cameraType" :showPreview="showPreview" :extraListeners="animationListeners" + :backgroundImage="backgroundImage" @materialModeChange="listenMaterialModeChange" @backgroundColorChange="listenBackgroundColorChange" @lightIntensityChange="listenLightIntensityChange" @@ -39,6 +40,7 @@ const props = defineProps<{ playing: boolean selectedSpeed: number selectedAnimation: number + backgroundImage: string }>() const node = ref(props.node) diff --git a/src/components/load3d/Load3DControls.vue b/src/components/load3d/Load3DControls.vue index 407a263d2..c0a59c5ec 100644 --- a/src/components/load3d/Load3DControls.vue +++ b/src/components/load3d/Load3DControls.vue @@ -1,6 +1,6 @@