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: GizmoMode::all(),
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§
- enum_
set - Creates a EnumSet literal, which can be used in const contexts.
Structs§
- Color32
- This format is used for space-efficient color representation (32 bits).
- EnumSet
- An efficient set type for enums.
- Gizmo
- A 3D transformation gizmo.
- Gizmo
Config - Configuration of a gizmo.
- Gizmo
Draw Data - Data used to draw
Gizmo
. - Gizmo
Interaction - Information needed for interacting with the gizmo.
- Gizmo
Visuals - Controls the visual style of the gizmo
- Rect
- A rectangular region of space.
Enums§
- Gizmo
Direction - Gizmo
Mode - Operation mode of a gizmo.
- Gizmo
Orientation - Orientation of a gizmo.
- Gizmo
Result - Result of a gizmo transformation