feat: improve export messages and apply materials to cube and ico sphere
This commit is contained in:
@@ -39,29 +39,41 @@ bpy.ops.export_scene.gltf(
|
||||
)
|
||||
print(f"Exported sphere.glb (GREEN) to {output_dir}")
|
||||
|
||||
# Delete sphere and create cube
|
||||
print(f"Exported sphere.glb (GREEN) to {output_dir}")
|
||||
|
||||
# Delete sphere and create cube with RED material
|
||||
bpy.ops.object.delete()
|
||||
bpy.ops.mesh.primitive_cube_add(size=1.0, location=(0, 0, 0))
|
||||
cube = bpy.context.active_object
|
||||
cube.name = "Cube"
|
||||
bpy.ops.object.shade_smooth()
|
||||
# Apply red material
|
||||
red_mat = create_material("CubeMaterial", (1.0, 0.2, 0.2, 1.0)) # Red
|
||||
cube.data.materials.append(red_mat)
|
||||
bpy.ops.export_scene.gltf(
|
||||
filepath=os.path.join(output_dir, "cube.glb"),
|
||||
export_format='GLB',
|
||||
use_selection=True
|
||||
)
|
||||
print(f"Exported cube.glb to {output_dir}")
|
||||
print(f"Exported cube.glb (RED) to {output_dir}")
|
||||
|
||||
# Delete cube and create ico sphere for the "model" placeholder
|
||||
print(f"Exported cube.glb (RED) to {output_dir}")
|
||||
|
||||
# Delete cube and create ico sphere for the "model" placeholder with BLUE material
|
||||
bpy.ops.object.delete()
|
||||
bpy.ops.mesh.primitive_ico_sphere_add(subdivisions=2, radius=0.5, location=(0, 0, 0))
|
||||
ico = bpy.context.active_object
|
||||
ico.name = "IcoSphere"
|
||||
bpy.ops.object.shade_smooth()
|
||||
# Apply blue material
|
||||
blue_mat = create_material("IcoSphereMaterial", (0.2, 0.2, 1.0, 1.0)) # Blue
|
||||
ico.data.materials.append(blue_mat)
|
||||
bpy.ops.export_scene.gltf(
|
||||
filepath=os.path.join(output_dir, "model.glb"),
|
||||
export_format='GLB',
|
||||
use_selection=True
|
||||
)
|
||||
print(f"Exported model.glb to {output_dir}")
|
||||
print(f"Exported model.glb (BLUE) to {output_dir}")
|
||||
|
||||
print("\n✓ All primitive models exported successfully!")
|
||||
print(f"Location: {output_dir}")
|
||||
|
||||
Reference in New Issue
Block a user