Skip to content

Commit ed1d944

Browse files
authored
[3d] remove unnecessary uploadTexture (#4357)
1 parent 282f9ce commit ed1d944

File tree

8 files changed

+0
-162
lines changed

8 files changed

+0
-162
lines changed

src/components/load3d/Load3D.vue

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
@update-up-direction="handleUpdateUpDirection"
5656
@update-material-mode="handleUpdateMaterialMode"
5757
@update-edge-threshold="handleUpdateEdgeThreshold"
58-
@upload-texture="handleUploadTexture"
5958
@export-model="handleExportModel"
6059
/>
6160
<div
@@ -215,30 +214,6 @@ const handleBackgroundImageUpdate = async (file: File | null) => {
215214
node.properties['Background Image'] = backgroundImage.value
216215
}
217216
218-
const handleUploadTexture = async (file: File) => {
219-
if (!load3DSceneRef.value?.load3d) {
220-
useToastStore().addAlert(t('toastMessages.no3dScene'))
221-
return
222-
}
223-
224-
try {
225-
const resourceFolder = (node.properties['Resource Folder'] as string) || ''
226-
227-
const subfolder = resourceFolder.trim()
228-
? `3d/${resourceFolder.trim()}`
229-
: '3d'
230-
231-
const texturePath = await Load3dUtils.uploadFile(file, subfolder)
232-
233-
await load3DSceneRef.value.load3d.applyTexture(texturePath)
234-
235-
node.properties['Texture'] = texturePath
236-
} catch (error) {
237-
console.error('Error applying texture:', error)
238-
useToastStore().addAlert(t('toastMessages.failedToApplyTexture'))
239-
}
240-
}
241-
242217
const handleUpdateFOV = (value: number) => {
243218
fov.value = value
244219

src/components/load3d/Load3DControls.vue

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
@update-up-direction="handleUpdateUpDirection"
5252
@update-material-mode="handleUpdateMaterialMode"
5353
@update-edge-threshold="handleUpdateEdgeThreshold"
54-
@upload-texture="handleUploadTexture"
5554
/>
5655

5756
<CameraControls
@@ -183,7 +182,6 @@ const emit = defineEmits<{
183182
(e: 'updateMaterialMode', mode: MaterialMode): void
184183
(e: 'updateEdgeThreshold', value: number): void
185184
(e: 'exportModel', format: string): void
186-
(e: 'uploadTexture', file: File): void
187185
}>()
188186
189187
const backgroundColor = ref(props.backgroundColor)
@@ -232,10 +230,6 @@ const handleUpdateEdgeThreshold = (value: number) => {
232230
emit('updateEdgeThreshold', value)
233231
}
234232
235-
const handleUploadTexture = (file: File) => {
236-
emit('uploadTexture', file)
237-
}
238-
239233
const handleUpdateLightIntensity = (value: number) => {
240234
emit('updateLightIntensity', value)
241235
}

src/components/load3d/Load3DScene.vue

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,6 @@ const eventConfig = {
6969
exportLoadingEnd: () => {
7070
loadingOverlayRef.value?.endLoading()
7171
},
72-
textureLoadingStart: () =>
73-
loadingOverlayRef.value?.startLoading(t('load3d.applyingTexture')),
74-
textureLoadingEnd: () => loadingOverlayRef.value?.endLoading(),
7572
recordingStatusChange: (value: boolean) =>
7673
emit('recordingStatusChange', value)
7774
} as const

src/components/load3d/controls/ModelControls.vue

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -59,32 +59,6 @@
5959
</div>
6060
</div>
6161

62-
<div
63-
v-if="
64-
materialMode === 'original' &&
65-
!props.inputSpec.isAnimation &&
66-
!props.inputSpec.isPreview
67-
"
68-
class="relative show-texture-upload"
69-
>
70-
<Button class="p-button-rounded p-button-text" @click="openTextureUpload">
71-
<i
72-
v-tooltip.right="{
73-
value: t('load3d.uploadTexture'),
74-
showDelay: 300
75-
}"
76-
class="pi pi-image text-white text-lg"
77-
/>
78-
<input
79-
ref="texturePickerRef"
80-
type="file"
81-
accept="image/*"
82-
class="absolute opacity-0 w-0 h-0 p-0 m-0 pointer-events-none"
83-
@change="uploadTexture"
84-
/>
85-
</Button>
86-
</div>
87-
8862
<div v-if="materialMode === 'lineart'" class="relative show-edge-threshold">
8963
<Button
9064
class="p-button-rounded p-button-text"
@@ -142,7 +116,6 @@ const emit = defineEmits<{
142116
(e: 'updateUpDirection', direction: UpDirection): void
143117
(e: 'updateMaterialMode', mode: MaterialMode): void
144118
(e: 'updateEdgeThreshold', value: number): void
145-
(e: 'uploadTexture', file: File): void
146119
}>()
147120
148121
const upDirection = ref(props.upDirection || 'original')
@@ -151,7 +124,6 @@ const edgeThreshold = ref(props.edgeThreshold || 85)
151124
const showUpDirection = ref(false)
152125
const showMaterialMode = ref(false)
153126
const showEdgeThreshold = ref(false)
154-
const texturePickerRef = ref<HTMLInputElement | null>(null)
155127
156128
const upDirections: UpDirection[] = [
157129
'original',
@@ -247,18 +219,6 @@ const updateEdgeThreshold = () => {
247219
emit('updateEdgeThreshold', edgeThreshold.value)
248220
}
249221
250-
const openTextureUpload = () => {
251-
texturePickerRef.value?.click()
252-
}
253-
254-
const uploadTexture = (event: Event) => {
255-
const input = event.target as HTMLInputElement
256-
257-
if (input.files && input.files[0]) {
258-
emit('uploadTexture', input.files[0])
259-
}
260-
}
261-
262222
const closeSceneSlider = (e: MouseEvent) => {
263223
const target = e.target as HTMLElement
264224

src/extensions/core/load3d.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ async function handleModelUpload(files: FileList, node: any) {
2121
(w: any) => w.name === 'model_file'
2222
) as IStringWidget
2323

24-
node.properties['Texture'] = undefined
25-
2624
try {
2725
const resourceFolder = (node.properties['Resource Folder'] as string) || ''
2826

@@ -215,8 +213,6 @@ useExtensionService().registerExtension({
215213
const modelWidget = node.widgets?.find((w) => w.name === 'model_file')
216214
if (modelWidget) {
217215
modelWidget.value = ''
218-
219-
node.properties['Texture'] = undefined
220216
}
221217
})
222218

src/extensions/core/load3d/Load3DConfiguration.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,6 @@ class Load3DConfiguration {
160160

161161
this.load3d.setEdgeThreshold(edgeThreshold)
162162

163-
const texturePath = this.load3d.loadNodeProperty('Texture', null)
164-
165-
if (texturePath) {
166-
await this.load3d.applyTexture(texturePath)
167-
}
168-
169163
if (isFirstLoad && cameraState && typeof cameraState === 'object') {
170164
try {
171165
this.load3d.setCameraState(cameraState)

src/extensions/core/load3d/Load3d.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -293,23 +293,6 @@ class Load3d {
293293
}
294294
}
295295

296-
async applyTexture(texturePath: string): Promise<void> {
297-
if (!this.modelManager.currentModel) {
298-
throw new Error('No model to apply texture to')
299-
}
300-
301-
this.eventManager.emitEvent('textureLoadingStart', null)
302-
303-
try {
304-
await this.modelManager.applyTexture(texturePath)
305-
} catch (error) {
306-
console.error('Error applying texture:', error)
307-
throw error
308-
} finally {
309-
this.eventManager.emitEvent('textureLoadingEnd', null)
310-
}
311-
}
312-
313296
setBackgroundColor(color: string): void {
314297
this.sceneManager.setBackgroundColor(color)
315298

src/extensions/core/load3d/ModelManager.ts

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { LineSegmentsGeometry } from 'three/examples/jsm/lines/LineSegmentsGeome
55
import { GLTF } from 'three/examples/jsm/loaders/GLTFLoader'
66
import { mergeVertices } from 'three/examples/jsm/utils/BufferGeometryUtils'
77

8-
import Load3dUtils from './Load3dUtils'
98
import { ColoredShadowMaterial } from './conditional-lines/ColoredShadowMaterial'
109
import { ConditionalEdgesGeometry } from './conditional-lines/ConditionalEdgesGeometry'
1110
import { ConditionalEdgesShader } from './conditional-lines/ConditionalEdgesShader.js'
@@ -135,66 +134,6 @@ export class ModelManager implements ModelManagerInterface {
135134
})
136135
}
137136

138-
async applyTexture(texturePath: string): Promise<void> {
139-
if (!this.currentModel) {
140-
throw new Error('No model available to apply texture to')
141-
}
142-
143-
if (this.appliedTexture) {
144-
this.appliedTexture.dispose()
145-
}
146-
147-
try {
148-
let imageUrl = Load3dUtils.getResourceURL(
149-
...Load3dUtils.splitFilePath(texturePath)
150-
)
151-
152-
if (!imageUrl.startsWith('/api')) {
153-
imageUrl = '/api' + imageUrl
154-
}
155-
156-
this.appliedTexture = await new Promise<THREE.Texture>(
157-
(resolve, reject) => {
158-
this.textureLoader.load(
159-
imageUrl,
160-
(texture) => {
161-
texture.colorSpace = THREE.SRGBColorSpace
162-
texture.wrapS = THREE.RepeatWrapping
163-
texture.wrapT = THREE.RepeatWrapping
164-
resolve(texture)
165-
},
166-
undefined,
167-
(error) => reject(error)
168-
)
169-
}
170-
)
171-
172-
if (this.materialMode === 'original') {
173-
this.currentModel.traverse((child) => {
174-
if (child instanceof THREE.Mesh) {
175-
const material = new THREE.MeshStandardMaterial({
176-
map: this.appliedTexture,
177-
metalness: 0.1,
178-
roughness: 0.8,
179-
side: THREE.DoubleSide
180-
})
181-
182-
if (!this.originalMaterials.has(child)) {
183-
this.originalMaterials.set(child, child.material)
184-
}
185-
186-
child.material = material
187-
}
188-
})
189-
}
190-
191-
return Promise.resolve()
192-
} catch (error) {
193-
console.error('Error applying texture:', error)
194-
return Promise.reject(error)
195-
}
196-
}
197-
198137
disposeLineartModel(): void {
199138
this.disposeEdgesModel()
200139
this.disposeShadowModel()

0 commit comments

Comments
 (0)