Skip to content

Commit ebd9c96

Browse files
authored
[3d] bug fix and add loading for background image change (#3888)
1 parent e6d649b commit ebd9c96

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

src/components/load3d/Load3DScene.vue

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ const eventConfig = {
5252
showPreviewChange: (value: boolean) => emit('showPreviewChange', value),
5353
backgroundImageChange: (value: string) =>
5454
emit('backgroundImageChange', value),
55+
backgroundImageLoadingStart: () =>
56+
loadingOverlayRef.value?.startLoading(t('load3d.loadingBackgroundImage')),
57+
backgroundImageLoadingEnd: () => loadingOverlayRef.value?.endLoading(),
5558
upDirectionChange: (value: string) => emit('upDirectionChange', value),
5659
edgeThresholdChange: (value: number) => emit('edgeThresholdChange', value),
5760
modelLoadingStart: () =>
@@ -75,7 +78,7 @@ const eventConfig = {
7578
7679
watchEffect(async () => {
7780
if (load3d.value) {
78-
const rawLoad3d = toRaw(load3d.value)
81+
const rawLoad3d = toRaw(load3d.value) as Load3d
7982
8083
rawLoad3d.setBackgroundColor(props.backgroundColor)
8184
rawLoad3d.toggleGrid(props.showGrid)
@@ -84,15 +87,25 @@ watchEffect(async () => {
8487
rawLoad3d.toggleCamera(props.cameraType)
8588
rawLoad3d.togglePreview(props.showPreview)
8689
await rawLoad3d.setBackgroundImage(props.backgroundImage)
87-
rawLoad3d.setUpDirection(props.upDirection)
8890
}
8991
})
9092
93+
watch(
94+
() => props.upDirection,
95+
(newValue) => {
96+
if (load3d.value) {
97+
const rawLoad3d = toRaw(load3d.value) as Load3d
98+
99+
rawLoad3d.setUpDirection(newValue)
100+
}
101+
}
102+
)
103+
91104
watch(
92105
() => props.materialMode,
93106
(newValue) => {
94107
if (load3d.value) {
95-
const rawLoad3d = toRaw(load3d.value)
108+
const rawLoad3d = toRaw(load3d.value) as Load3d
96109
97110
rawLoad3d.setMaterialMode(newValue)
98111
}
@@ -102,10 +115,9 @@ watch(
102115
watch(
103116
() => props.edgeThreshold,
104117
(newValue) => {
105-
if (load3d.value) {
106-
const rawLoad3d = toRaw(load3d.value)
118+
if (load3d.value && newValue) {
119+
const rawLoad3d = toRaw(load3d.value) as Load3d
107120
108-
// @ts-expect-error fixme ts strict error
109121
rawLoad3d.setEdgeThreshold(newValue)
110122
}
111123
}

src/extensions/core/load3d/SceneManager.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ export class SceneManager implements SceneManagerInterface {
8282
}
8383

8484
async setBackgroundImage(uploadPath: string): Promise<void> {
85+
this.eventManager.emitEvent('backgroundImageLoadingStart', null)
86+
8587
if (uploadPath === '') {
8688
this.removeBackgroundImage()
8789
return
@@ -123,7 +125,9 @@ export class SceneManager implements SceneManagerInterface {
123125
)
124126

125127
this.eventManager.emitEvent('backgroundImageChange', uploadPath)
128+
this.eventManager.emitEvent('backgroundImageLoadingEnd', null)
126129
} catch (error) {
130+
this.eventManager.emitEvent('backgroundImageLoadingEnd', null)
127131
console.error('Error loading background image:', error)
128132
}
129133
}
@@ -139,6 +143,7 @@ export class SceneManager implements SceneManagerInterface {
139143
this.backgroundTexture.dispose()
140144
this.backgroundTexture = null
141145
}
146+
this.eventManager.emitEvent('backgroundImageLoadingEnd', null)
142147
}
143148

144149
updateBackgroundSize(

0 commit comments

Comments
 (0)