diff --git a/src/main.rs b/src/main.rs index 37813c3..0b907b5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -20,7 +20,7 @@ mod viewer; fn main() { App::new() - .insert_resource(ClearColor(Color::rgb(0.0, 0.1, 0.9))) + .insert_resource(ClearColor(Color::rgb(0.9, 0.9, 0.9))) .add_plugins(DefaultPlugins.set(WindowPlugin { window: WindowDescriptor { title: "PixSpace".to_string(), diff --git a/src/offaxis.rs b/src/offaxis.rs index 0586cd1..22b67e1 100644 --- a/src/offaxis.rs +++ b/src/offaxis.rs @@ -21,7 +21,7 @@ impl CameraProjection for OffAxisProjection { println!("Here we go! {:?}",self); - Mat4::perspective_rh_gl(45.0_f32.to_radians(), + Mat4::perspective_rh(45.0_f32.to_radians(), self.aspect, self.near, self.far) @@ -49,7 +49,6 @@ impl Default for OffAxisProjection { } } - pub fn make_projection_rh_from_frustum(left: f32, right: f32, bottom: f32, top: f32, near:f32, far:f32) -> Mat4 { // based on OpenSceneGraph / glFrustum implementation @@ -70,6 +69,8 @@ pub fn offaxis_camera_setup(mut commands: Commands) { let projection = OffAxisProjection::default(); + // let projection = PerspectiveProjection::default(); + // position the camera like bevy would do by default for 2D: let transform = Transform::from_xyz(0.0, 0.0, projection.far - 0.1); diff --git a/src/scene.rs b/src/scene.rs index 8b7fc07..ff5d68c 100644 --- a/src/scene.rs +++ b/src/scene.rs @@ -96,18 +96,18 @@ pub fn build_scene( shadows_enabled: true, ..default() }, - transform: Transform::from_xyz(4.0, 8.0, 4.0), + transform: Transform::from_xyz(4.0, 8.0, -4.0), ..default() }); // camera - let mut cam = Camera3dBundle { - transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y), + // let mut cam = Camera3dBundle { + // transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y), - ..default() - }; + // ..default() + // }; diff --git a/src/viewer.rs b/src/viewer.rs index 6066fbf..95176a2 100644 --- a/src/viewer.rs +++ b/src/viewer.rs @@ -35,7 +35,17 @@ pub fn simulate_viewer(mut query: Query<&mut Viewer>) for mut v in query.iter_mut() { //v.position += Vec3::Y * 0.005; v.alpha += 0.01; - let radius = 0.5; - v.position = Vec3::new(v.alpha.sin()*radius,v.alpha.cos()*radius,5.0); + let radius = 1.5; + v.position = Vec3::new(v.alpha.sin()*radius,v.alpha.cos()*radius + 1.0_f32,15.0); + + let vm = Mat4::look_at_rh(v.position, Vec3::ZERO, Vec3::Y); + + println!("{:?}",vm); + + // view matrices should be orientation only + let dir = Quat::from_mat4(&vm); + + v.orientation = dir; + } } \ No newline at end of file