use vertra::camera::Camera;
use vertra::geometry::Geometry;
use vertra::objects::Object;
use vertra::transform::Transform;
use vertra::window::Window;
fn main() {
Window::new(())
.with_title("Geometry Showcase — Vertra example")
.with_camera(
Camera::new()
.with_position([0.0, 6.0, -18.0])
.with_rotation(90.0, -18.0),
)
.on_startup(|_, scene, _| {
let shapes: &[(&str, &str, Geometry, [f32; 4])] = &[
(
"Cube",
"geo_cube",
Geometry::Cube { size: 1.8 },
[0.9, 0.3, 0.3, 1.0], ),
(
"Box",
"geo_box",
Geometry::Box {
width: 1.2,
height: 2.0,
depth: 0.8,
},
[0.9, 0.6, 0.2, 1.0], ),
(
"Plane",
"geo_plane",
Geometry::Plane { size: 2.0 },
[0.9, 0.9, 0.2, 1.0], ),
(
"Pyramid",
"geo_pyramid",
Geometry::Pyramid {
base_size: 1.8,
height: 2.5,
},
[0.3, 0.8, 0.3, 1.0], ),
(
"Capsule",
"geo_capsule",
Geometry::Capsule {
radius: 0.6,
height: 1.6,
subdivisions: 20,
},
[0.2, 0.5, 1.0, 1.0], ),
(
"Sphere",
"geo_sphere",
Geometry::Sphere {
radius: 1.0,
subdivisions: 24,
},
[0.7, 0.2, 0.9, 1.0], ),
];
let count = shapes.len() as f32;
let spacing = 3.0_f32;
let start_x = -((count - 1.0) * spacing * 0.5);
for (i, (name, str_id, geometry, color)) in shapes.iter().enumerate() {
let x = start_x + i as f32 * spacing;
scene.spawn(
Object {
name: name.to_string(),
str_id: str_id.to_string(),
transform: Transform::from_position(x, 0.0, 0.0),
geometry: Some(geometry.clone()),
color: *color,
..Default::default()
},
None,
);
}
scene.enable_editor_mode();
})
.create();
}