Improved focus distance to be less close to the object

This commit is contained in:
Adrien GIVRY
2025-04-29 14:49:43 -04:00
parent 64c9caf76a
commit 2c7e3b1cac
2 changed files with 6 additions and 2 deletions
+5 -1
View File
@@ -241,7 +241,7 @@ impl CameraController {
world_space_position
}
pub fn fit_object(&mut self, scene: &mut Scene, handle: Handle<Node>) {
pub fn fit_object(&mut self, scene: &mut Scene, handle: Handle<Node>, scale: Option<f32>) {
// Combine AABBs from the descendants.
let mut aabb = AxisAlignedBoundingBox::default();
for (_, descendant) in scene.graph.traverse_iter(handle) {
@@ -256,6 +256,10 @@ impl CameraController {
aabb = AxisAlignedBoundingBox::from_point(scene.graph[handle].global_position());
}
if scale.is_some() {
aabb = aabb.transform(&Matrix4::identity().scale(scale.unwrap()));
}
let fit_parameters = scene.graph[self.camera].as_camera().fit(
&aabb,
scene
+1 -1
View File
@@ -990,7 +990,7 @@ impl SceneController for GameScene {
}
Message::FocusObject(handle) => {
let scene = &mut engine.scenes[self.scene];
self.camera_controller.fit_object(scene, *handle);
self.camera_controller.fit_object(scene, *handle, Some(2.0));
false
}
Message::SyncNodeHandleName { view, handle } => {