diff --git a/src/pages/Editor.tsx b/src/pages/Editor.tsx
index c784b63..651e1f9 100644
--- a/src/pages/Editor.tsx
+++ b/src/pages/Editor.tsx
@@ -1026,6 +1026,51 @@ export default function Editor() {
child.frustumCulled = false; // Prevent flickering on large models
}
});
+
+ setSceneObjects(prev => {
+ // If the scene already has objects, don't overwrite them
+ if (prev.length > 0) return prev;
+
+ // Build default hierarchy for fresh imported models (like from SparkPlug)
+ const mainModelId = `model-${Date.now()}`;
+ const builtObjects: SceneObject[] = [
+ {
+ id: mainModelId,
+ name: modelInfo.name || 'Imported Model',
+ type: 'model',
+ parentId: null,
+ visible: true,
+ transformProps: { position: [0, 0, 0], rotation: [0, 0, 0], scale: [1, 1, 1] }
+ }
+ ];
+
+ let mIdx = 0;
+ object!.traverse((child) => {
+ if (child instanceof THREE.Mesh) {
+ const meshId = `mesh-${mIdx++}`;
+ const material = Array.isArray(child.material) ? child.material[0] : child.material;
+ const mProps = { ...globalMaterialProps };
+
+ if (material) {
+ if (material.color) mProps.color = `#${material.color.getHexString()}`;
+ if (material.roughness !== undefined) mProps.roughness = material.roughness;
+ if (material.metalness !== undefined) mProps.metalness = material.metalness;
+ if (material.opacity !== undefined) mProps.opacity = material.opacity;
+ }
+
+ builtObjects.push({
+ id: meshId,
+ name: child.name || `Mesh ${meshId.slice(0, 4)}`,
+ type: 'mesh',
+ parentId: mainModelId,
+ visible: true,
+ materialProps: mProps
+ });
+ }
+ });
+ return builtObjects;
+ });
+
setLoadedModel(object);
setBlobURLs(prev => [...prev, url]);
}
diff --git a/src/pages/SparkPlug.tsx b/src/pages/SparkPlug.tsx
index 57f28da..27211f4 100644
--- a/src/pages/SparkPlug.tsx
+++ b/src/pages/SparkPlug.tsx
@@ -1,7 +1,14 @@
-import React, { useState } from 'react';
+import React, { useState, Suspense } from 'react';
import { useNavigate } from 'react-router-dom';
import { Sparkles, Upload, FileText, Image as ImageIcon, Box, Check, Loader2, ArrowRight, RefreshCw, ChevronLeft } from 'lucide-react';
import { api } from '../lib/api';
+import { Canvas } from '@react-three/fiber';
+import { OrbitControls, Stage, useGLTF } from '@react-three/drei';
+
+function ModelPreview({ url }: { url: string }) {
+ const { scene } = useGLTF(url);
+ return
- Meshy is constructing the model based on the Nano Banana concept images. -
++ Meshy is constructing the model based on the concept images. +
-