Fix SparkPlug 3D preview, remove global loader overlay during generation, and fix empty scene hierarchy bug when transferring to Editor
Build and Deploy / build-and-push (push) Successful in 43s
Build and Deploy / build-and-push (push) Successful in 43s
This commit is contained in:
@@ -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]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user