From 579ebfba9df0e48d0b371d504653c1ac50d564fc Mon Sep 17 00:00:00 2001 From: AI Bot Date: Wed, 2 Sep 2026 10:22:03 +0530 Subject: [PATCH] fix: restore default flipY for uploaded textures, fix main model deletion visibility --- src/components/ModelViewer.tsx | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/components/ModelViewer.tsx b/src/components/ModelViewer.tsx index b17c4b3..e8742df 100644 --- a/src/components/ModelViewer.tsx +++ b/src/components/ModelViewer.tsx @@ -103,7 +103,7 @@ const MeshMaterialManager = ({ mesh, sceneObj, textureCache }: MeshMaterialManag tex.name = url; if (type === 'map') tex.colorSpace = THREE.SRGBColorSpace; tex.wrapS = tex.wrapT = THREE.RepeatWrapping; - tex.flipY = false; + textureCache.current.set(url, tex); activeMat[type] = tex; if (mappingType === 'triplanar') activeMat.triplanarUniforms['t' + type.charAt(0).toUpperCase() + type.slice(1).replace('Map', '')].value = tex; @@ -235,11 +235,17 @@ export const ModelViewer = forwardRef(({ object, useEffect(() => { if (object && sceneObjects) { const mainModel = sceneObjects.find(obj => obj.type === 'model'); - if (mainModel && mainModel.transformProps && groupRef.current) { - const { position: p, rotation: r, scale: s } = mainModel.transformProps; - groupRef.current.position.set(p[0], p[1], p[2]); - groupRef.current.rotation.set(r[0], r[1], r[2]); - groupRef.current.scale.set(s[0], s[1], s[2]); + if (groupRef.current) { + if (mainModel && mainModel.transformProps) { + const { position: p, rotation: r, scale: s } = mainModel.transformProps; + groupRef.current.position.set(p[0], p[1], p[2]); + groupRef.current.rotation.set(r[0], r[1], r[2]); + groupRef.current.scale.set(s[0], s[1], s[2]); + groupRef.current.visible = true; + } else if (!mainModel) { + // If main model was deleted, hide the entire group + groupRef.current.visible = false; + } } } }, [object, sceneObjects]);