Dear ImGuizmo - Rust Bindings
High-level Rust bindings for ImGuizmo, built on the C API (cimguizmo) and integrated with dear-imgui-rs.
This project is a Rust wrapper around the C shim (cimguizmo), not a direct C++ binding.
Links
Crate Layout
dear-imguizmo(this crate): safe, idiomatic wrapper integrated withdear-imgui-rs.dear-imguizmo-sys: low-level FFI generated from the C API (cimguizmo). Prefer not using it directly unless you need raw bindings.
Compatibility
| Item | Version |
|---|---|
| Crate | 0.8.x |
| dear-imgui-rs | 0.8.x |
| dear-imguizmo-sys | 0.8.x |
See also: docs/COMPATIBILITY.md for the full workspace matrix.
WASM (WebAssembly) support
This crate has experimental support for wasm32-unknown-unknown targets via the same import-style design used by the core ImGui bindings:
dear-imguizmo+dear-imguizmo-sysexpose awasmfeature which:- Enables import-style FFI that links against the shared
imgui-sys-v0provider module. - Avoids compiling C/C++ during the Rust build for wasm.
- Enables import-style FFI that links against the shared
- The provider module (
imgui-sys-v0) is built once using Emscripten and contains:- Dear ImGui + cimgui (from
dear-imgui-sys) - ImGuizmo + cimguizmo (from
dear-imguizmo-sys)
- Dear ImGui + cimgui (from
To try the web demo with ImGuizmo enabled:
# 1) Generate pregenerated wasm bindings (Dear ImGui core + ImGuizmo)
# 2) Build the main wasm + JS (includes an "ImGuizmo (Web)" window)
# 3) Build the provider (Emscripten imgui-sys-v0 with ImGui + ImGuizmo)
# 4) Serve and open in a browser
Notes:
- The
dear-imgui-web-democrate inexamples-wasmcan enable theimguizmofeature; when present, an “ImGuizmo (Web)” window is shown if bindings + provider are available. - This is an early, experimental path; API and build steps may evolve in future releases. For production use, pin to a specific
0.6.xrelease and follow changes indocs/WASM.md.
Features
glam(default): Useglam::Mat4seamlessly in the high-level API.mint(optional): Usemint::ColumnMatrix4<f32>seamlessly.- Without those features, you can always pass
[f32; 16](column-major) matrices.
All matrix arguments in the API are generic over a Mat4Like trait, implemented for [f32; 16], and when enabled, for glam::Mat4 and mint::ColumnMatrix4<f32>.
Quick Start
[]
= "0.8"
= "0.8"
Minimal usage (dear-imgui-style API):
use Context;
use ;
use Mat4;
let mut ctx = create;
let ui = ctx.frame;
// Begin ImGuizmo for this frame via Ui extension
let giz = ui.guizmo;
// Set the drawing rectangle to the full viewport
let ds = ui.io.display_size;
giz.set_rect;
// Choose where to draw (window/background/foreground)
giz.set_drawlist_window;
// Matrices (column-major). With the default `glam` feature, use `glam::Mat4`.
let mut model = IDENTITY;
let view = IDENTITY;
let proj = IDENTITY;
// Manipulate the model matrix
let used: bool = giz
.manipulate_config
.operation
.mode
//.snap([1.0, 1.0, 1.0])
//.bounds([minx,miny,minz], [maxx,maxy,maxz])
.build;
if used
See examples/imguizmo_basic.rs for a full demo with camera controls, snapping, bounds and helpers.
Per-frame pattern
Typical usage order within a single frame:
let giz = ui.guizmo; // call once per frame
// 1) Configure drawing area and destination
let ds = ui.io.display_size;
giz.set_rect;
giz.set_drawlist_window; // or Background/Foreground
// 2) Manipulate
let used = giz
.manipulate_config
.operation
.mode
.build;
Notes:
- Call
ui.guizmo()exactly once per frame, then setset_rect(...)and a draw target before callingmanipulate/draw_*. - You can select draw target with
giz.set_drawlist(DrawListTarget::Window|Background|Foreground). - Use RAII ID helpers:
let _id = giz.push_id(i);. - Style access:
let mut st = giz.style(); st.set_color(Color::Selection, [1.0,0.2,0.2,1.0]);. More fields:translation_line_arrow_size(),rotation_outer_line_thickness(),scale_line_circle_size(),hatched_axis_line_thickness(), etc. view_manipulate/view_manipulate_with_cameraaccept anyInto<[f32;2]>for position/size;set_rect_pos_sizeis available as a convenience.- Matrices are column-major;
Mat4Likesupports[f32;16], and (with features)glam::Mat4,mint::ColumnMatrix4<f32>.
Builder extras:
.drawlist(DrawListTarget::...),.rect(x,y,w,h),.orthographic(bool),.gizmo_size_clip_space(f32).axis_mask(AxisMask::X | AxisMask::Z).translate_snap([f32;3]),.rotate_snap_deg(f32),.scale_snap([f32;3])(also accepts(f32,f32,f32),glam::Vec3,mint::Vector3<f32>)
Extra helpers
Simple utility methods you may find handy:
// Hover test near a world-space position (in pixels)
// Call after you've established view/projection for the frame
// via manipulate/draw_grid/draw_cubes.
let hovered = giz.is_over_at;
// Compute an ImGuizmo hashed ID from a pointer
let id_from_ptr = giz.get_id_ptr;
Draw helpers
// Draw a grid aligned with a model transform (size in world units)
giz.draw_grid;
// Draw multiple cubes from a list of model matrices
let matrices = vec!;
giz.draw_cubes;
Notes
- This crate depends on
dear-imguizmo-sys(C API + bindgen). Linking to the base ImGui static library is provided bydear-imgui-sys; you do not need to configure it here.
Graph Editor (pure Rust, optional)
We provide a minimal, pure-Rust graph editor aligned with dear-imgui style, under dear_imguizmo::graph. It aims to mirror ImGuizmo's GraphEditor UX without relying on the C++ API.
use ;
use GraphEditorExt; // Ui extension
let mut graph = new;
let mut view = default;
// populate graph.nodes/links ...
ui.window
.size
.build;
Current features:
- Grid (toggle visibility, custom spacing/color)
- Panning (MMB), node dragging (LMB)
- Selection (click, Ctrl multi-select, box select)
- Link creation (drag from output to input), link selection
- Link reconnection (drag near a link endpoint onto another pin)
- Deletion via Delete key or helper
delete_selected(&mut Graph, &mut GraphView) - Fit helpers:
fit_all_nodes(...),fit_selected_nodes(...)
Notes:
- Pin hover, node/link hover outlines are shown using
GraphStylecolors. - Simple 2D interop:
graph::Vec2Likesupports(f32,f32),[f32;2],mint::Vector2<f32>, and (withglam)glam::Vec2. - This module is pure Rust and independent of the C++ GraphEditor; improvements are welcome.