Crate transform_gizmo_egui
source ·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§
- Mint - Math interoperability standard types.
Macros§
- Creates a EnumSet literal, which can be used in const contexts.
Structs§
- This format is used for space-efficient color representation (32 bits).
- An efficient set type for enums.
- A 3D transformation gizmo.
- Configuration of a [
Gizmo
]. - Data used to draw
Gizmo
. - Information needed for interacting with the gizmo.
- Controls the visual style of the gizmo
- A rectangular region of space.
Enums§
- Operation mode of a gizmo.
- Result of a gizmo transformation