use vertra::camera::Camera;
use vertra::geometry::Geometry;
use vertra::objects::Object;
use vertra::transform::Transform;
use vertra::window::Window;
struct AppState {
cube_id: Option<usize>,
}
fn main() {
Window::new(AppState { cube_id: None })
.with_title("Hello, Cube!")
.with_camera(
Camera::new()
.with_position([0.0, 2.0, -5.0])
.with_rotation(90.0, -15.0),
)
.on_startup(|state, scene, _| {
let id = scene.spawn(
Object {
name: "Cube".to_string(),
str_id: "cube".to_string(),
geometry: Some(Geometry::Cube { size: 1.5 }),
color: [0.9, 0.5, 0.2, 1.0], transform: Transform::default(),
..Default::default()
},
None, );
state.cube_id = Some(id);
})
.on_update(|state, scene, ctx| {
if let Some(cube) = state.cube_id.and_then(|id| scene.world.get_mut(id)) {
cube.transform.rotation[1] += 45.0 * ctx.dt;
}
})
.create();
}