diff --git a/src/components/JuiceBox.tsx b/src/components/JuiceBox.tsx index 049fc41..c7bd1cd 100644 --- a/src/components/JuiceBox.tsx +++ b/src/components/JuiceBox.tsx @@ -62,6 +62,10 @@ export const JuiceBox = forwardRef(({ ctx.fillText("REFRESHING FRUIT DRINK", 256, 150); } const tex = new THREE.CanvasTexture(canvas); + tex.colorSpace = THREE.SRGBColorSpace; + tex.wrapS = tex.wrapT = THREE.RepeatWrapping; + tex.repeat.set(-1, -1); + tex.offset.set(1, 1); tex.needsUpdate = true; return tex; }, [color, map]); @@ -72,7 +76,8 @@ export const JuiceBox = forwardRef(({ const tex = loader.load(map); tex.colorSpace = THREE.SRGBColorSpace; tex.wrapS = tex.wrapT = THREE.RepeatWrapping; - tex.repeat.set(uvScale, uvScale); + tex.repeat.set(-uvScale, -uvScale); + tex.offset.set(1, 1); return tex; }, [map, uvScale]); diff --git a/src/components/ModelViewer.tsx b/src/components/ModelViewer.tsx index 0cf44ab..b17c4b3 100644 --- a/src/components/ModelViewer.tsx +++ b/src/components/ModelViewer.tsx @@ -244,6 +244,18 @@ export const ModelViewer = forwardRef(({ object, } }, [object, sceneObjects]); + // Hide deleted meshes + useEffect(() => { + if (object && sceneObjects) { + const activeIds = new Set(sceneObjects.map(obj => obj.id)); + meshCache.current.forEach((mesh, id) => { + if (!activeIds.has(id)) { + mesh.visible = false; + } + }); + } + }, [object, sceneObjects]); + if (!object) return null; const meshObjects = sceneObjects.filter(obj => obj.type === 'mesh'); diff --git a/src/pages/Editor.tsx b/src/pages/Editor.tsx index 09f7115..356801d 100644 --- a/src/pages/Editor.tsx +++ b/src/pages/Editor.tsx @@ -1715,7 +1715,20 @@ export default function Editor() { }; const deleteObjects = () => { - updateSceneObjects(prev => prev.filter(obj => !selectedIds.includes(obj.id))); + updateSceneObjects(prev => { + let idsToDelete = [...selectedIds]; + let added = true; + while (added) { + added = false; + prev.forEach(obj => { + if (obj.parentId && idsToDelete.includes(obj.parentId) && !idsToDelete.includes(obj.id)) { + idsToDelete.push(obj.id); + added = true; + } + }); + } + return prev.filter(obj => !idsToDelete.includes(obj.id)); + }); setSelectedIds([]); };