Expand description

Provides a 3D transformation gizmo for the Egui library.

transform-gizmo-egui provides a feature-rich and configurable gizmo that can be used for 3d transformations (translation, rotation, scale).

§Usage

Create a new Gizmo instance once.

use transform_gizmo_egui::prelude::*;

let gizmo = Gizmo::default();

Update the gizmo configuration as needed, for example, when the camera moves.

gizmo.update_config(GizmoConfig {
    view_matrix: view_matrix.into(),
    projection_matrix: projection_matrix.into(),
    modes: enum_set!(GizmoMode::Rotate | GizmoMode::Translate | GizmoMode::Scale),
    orientation: GizmoOrientation::Local,
    ..Default::default()
});

Finally, interact with the gizmo. The function takes a slice of transforms as an input. The result is Some if the gizmo was successfully interacted with this frame. In the result you can find the modified transforms, in the same order as was given to the function as arguments.

 let mut transform = Transform::from_scale_rotation_translation(scale, rotation, translation);

 if let Some((result, new_transforms)) = gizmo.interact(ui, &[transform]) {
     for (new_transform, transform) in
         new_transforms.iter().zip(std::iter::once(&mut transform))
     {
         // Apply the modified transforms
         *transform = *new_transform;
     }
 }

Modules§

Macros§

  • Creates a EnumSet literal, which can be used in const contexts.

Structs§

Enums§

Traits§