From 2632228b8d963b337723c431ee252c5fbd1c802d Mon Sep 17 00:00:00 2001 From: Quaternions Date: Sat, 30 Sep 2023 19:15:16 -0700 Subject: [PATCH] council of monkeys (failed experiment map 5692150236) --- src/main.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 89052be..7947adc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -921,7 +921,8 @@ impl framework::Example for GraphicsData { device.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: None }); // update rotation - let camera_uniforms = to_uniform_data(&self.physics.camera,self.physics.body.extrapolated_position(time)); + let position=self.physics.body.extrapolated_position(time); + let camera_uniforms = to_uniform_data(&self.physics.camera,position); self.staging_belt .write_buffer( &mut encoder, @@ -932,7 +933,12 @@ impl framework::Example for GraphicsData { ) .copy_from_slice(bytemuck::cast_slice(&camera_uniforms)); //This code only needs to run when the uniforms change - for model in self.models.iter() { + for model in self.models.iter_mut() { + for instance in model.instances.iter_mut(){ + let model_pos=glam::Vec4Swizzles::xyz(instance.transform.col(3)); + let model_look=glam::Affine3A::look_at_rh(model_pos, position, glam::Vec3::Y); + instance.transform=glam::Mat4::from(model_look); + } let model_uniforms = get_instances_buffer_data(&model.instances); self.staging_belt .write_buffer(