3d transformation gizmo built on top of the egui library.

Overview

egui-gizmo

Latest version Documentation MIT

3d transformation gizmo built on top of the egui library.

Try it out in a web demo

Rotation Rotation

Usage

let gizmo = Gizmo::new("My gizmo")
    .view_matrix(view_matrix)
    .projection_matrix(projection_matrix)
    .model_matrix(model_matrix)
    .mode(GizmoMode::Rotate);

if let Some(response) = gizmo.interact(ui) {
    model_matrix = response.transform.into();
}

For a more complete example, see the demo source code.

The gizmo accepts matrices as Into<[[f32; 4]; 4]>, which means it is easy to use with matrix types from various crates such as nalgebra, glam and cgmath.

Comments
  • Problem with rotation gizmos (possibly related to handedness / coordinate space?)

    Problem with rotation gizmos (possibly related to handedness / coordinate space?)

    In my application, I'm using a left-handed, Y up coordinate system.

    When setting up this library, I encountered an issue with the rotation gizmos. At first they looked as if they were rotating inverse to the screen, but then I realized the real reason is that the arcs were being drawn with an offset of PI radians.

    The gizmo looks correct in the demo, so I'm thinking perhaps there's an offset that needs to be added to the arc that changes with the chosen coordinate system?

    This gif illustrates the issue: bug_1

    Here's what happens when I change rotation.rs:70:

    - painter.arc(radius, FRAC_PI_2 - angle, FRAC_PI_2 + angle, stroke);
    + painter.arc(radius, FRAC_PI_2 - angle + PI, FRAC_PI_2 + angle + PI, stroke);
    

    bug_2

    opened by setzer22 11
  • add simple modifiers to change precision/rounding

    add simple modifiers to change precision/rounding

    I would like to see a simple way to change the precision/rounding.

    i.e. in the demo, you could add so that while holding shift changes the rounding to half a cube size when moving it and for rotation round to nearest 90 degrees

    opened by Ryder17z 2
  • Doesn't work with infinite projection matrices

    Doesn't work with infinite projection matrices

    If you use an infinite projection matrix, then this operation will always result in an inf/nan target vector.

    Maybe we should try other ways of generating camera rays?

    Very nice library, thank you very much!

    opened by obiwanus 2
  • demo dose not run

    demo dose not run

    if I try to cargo run the demo (from within the demo folder), it panics, cannot find the docs/crate.png. Everything fine if I copy that whole docs folder into demo, but I guess that is not the initial intention how this has to go.

    opened by rsaccon 2
  • Support for lh coordinate systems

    Support for lh coordinate systems

    Sorry I know this is really specific but I'm making a tool that uses unreal's coordinate system which is the fun left-handed z-up one :| I love the crate but there's no way without editing the source - which I'm not good enough to do - and take this image and make it this image (the images are of the same scene in the same camera position)

    opened by bananaturtlesandwich 1
  • Cannot interact when multiple gizmos are present on screen

    Cannot interact when multiple gizmos are present on screen

    I tried adding multiple gizmos at the same time, and it seems only one of them (the first one I draw) is interactable.

    I've tracked down the issue to lib.rs:158

            if let Some(pointer_ray) = self.pointer_ray(ui) {
                let interaction = ui.interact(self.config.viewport, self.id, Sense::click_and_drag()); // <- Here
                let dragging = interaction.dragged_by(PointerButton::Primary);
    

    The problem is that egui will only generate drag events for one widget, so if you call ui.interact() during a frame where a drag starts, and the mouse is inside the interact area, no other call to interact will return a drag_started event no matter what.

    I implemented a fix for this (PR incoming) which seems to be working fine. The trick is deferring the call to interact until we're sure that the mouse is hovering something we're interested in. :smile:

    opened by setzer22 0
  • Rotation gizmo works with left-handed coordinate system

    Rotation gizmo works with left-handed coordinate system

    Fixes #14

    Arcs in the rotation gizmo point in the wrong direction when using left-handed coordinate system. Now the forward vector is inverted for rotation gizmo in such case.

    Also fixes snapping with ctrl & shift on Linux

    opened by urholaukkarinen 0
  • Picking now works when far plane is at infinity

    Picking now works when far plane is at infinity

    When calculating world space from screen space coordinates, a division by zero would occur if the projection had far plane set to infinity. Now a small non-zero value is used instead.

    Closes #7

    opened by urholaukkarinen 0
  • Graphical artifact at some angles

    Graphical artifact at some angles

    When looking at the translation gizmo from certain angles (perpendicularly), the figures stretches into some lines.

    This can be reproduced in the demo by looking exactly horizontally, the green square of the translation gizmo stretches into a line.

    opened by Lieunoir 0
  • Bump egui to v0.20, glam to v0.22.

    Bump egui to v0.20, glam to v0.22.

    While waiting for https://github.com/optozorax/egui-macroquad/pull/29#issue-1498460381 to be accepted by egui.macroquad, demo's egui-macroquad dependency has been temporarily modified to https://github.com/matthiascy/egui-macroquad.git.

    opened by matthiascy 0
  • Could this widget interact with 'wants_pointer_input'?

    Could this widget interact with 'wants_pointer_input'?

    Is it possible for this widget to capture the mouse on hover? So that the egui method below will return true? https://docs.rs/egui/0.19.0/egui/struct.Context.html#method.wants_pointer_input

    I am using the above method in my game to know when to listen to interactions with the game. Clicking on the gizmo on a part that is not over the current selected entity will change selection instead of rotating/scaling.

    Thank you.

    opened by WooterTheTroubleshooter 3
Owner
Urho Laukkarinen
Urho Laukkarinen
Scion is a tiny 2D game library built on top of wgpu, winit and legion.

Scion is a 2D game library made in rust. Please note that this project is in its first milestones and is subject to change according to convience need

Jérémy Thulliez 143 Dec 25, 2022
General purpose client/server networking library written in Rust, built on top of the QUIC protocol which is implemented by quinn

Overview "This library stinks!" ... "Unless you like durian" durian is a client-server networking library built on top of the QUIC protocol which is i

Michael 92 Dec 31, 2022
A novel path-based approach to UI built on top of existing Bevy features

Bevy Lunex A novel path-based approach to UI built on top of existing Bevy features. A recreation of Cyberpunk 2077 menu in Bevy using Lunex Table of

Bytestring 4 Jun 29, 2023
An alternative ggez implementation on top of miniquad.

Good Web Game good-web-game is a wasm32-unknown-unknown implementation of a ggez subset on top of miniquad. Originally built to run Zemeroth on the we

null 294 Jan 2, 2023
A plugin for Egui integration into Bevy

bevy_egui This crate provides a Egui integration for the Bevy game engine. Features: Desktop and web (bevy_webgl2) platforms support Clipboard (web su

Vladyslav Batyrenko 453 Jan 3, 2023
Show puffin profiler flamegraph in-game using egui

Show puffin profiler flamegraph in-game using egui puffin is an instrumentation profiler where you opt-in to profile parts of your code: fn my_functio

Emil Ernerfeldt 44 Jun 3, 2022
An egui backend for godot-rust

Godot Egui An egui backend for godot-rust. Rationale Godot has a perfectly valid GUI system, so why egui? Here are my personal reasons: Simplicity: No

null 109 Jan 4, 2023
API tool,but egui style and rusty

WEAVER About Weaver is a simple,easy-to-use and cross-platform API tool.Inspired by hoppscotch . It uses the Rust egui GUI library. Features Get,Post

will 14 Dec 11, 2022
Generic and extensible egui widgets to create analog synthesizer-like UI with data-oriented API

egui_cable A generic and extensible data-oriented widget for connecting ports by cables. I create this for the visual programming editor of Hihaheho/D

Ryo Hirayama 44 Dec 30, 2022
A dependency-free chess engine library built to run anywhere.

♔chess-engine♚ A dependency-free chess engine library built to run anywhere. Demo | Docs | Contact Me Written in Rust ?? ?? Why write a Chess engine?

adam mcdaniel 355 Dec 26, 2022
A simple and minimal game engine library built in rust.

Neptune A brand new free, open-source minimal and compact game engine built in rust. Design Goals We plan to make Neptune a small and minimal engine,

Levitate 17 Jan 25, 2023
A tilemap library for Bevy. With many algorithms built in.

Bevy EntiTiles A tilemap library for bevy. Notice that the crate is still in need of optimization. So don't use this in your formal projects. Strongly

443eb9#C 3 Nov 7, 2023
A refreshingly simple data-driven game engine built in Rust

What is Bevy? Bevy is a refreshingly simple data-driven game engine built in Rust. It is free and open-source forever! WARNING Bevy is still in the ve

Bevy Engine 21.1k Jan 4, 2023
compare gdnative rust based physics against Godot built-in physics

Godot vs. Rapier Rapier is an open source physics framework written in Rust. This project pits godots built-in physics against Rapier. It uses godot-r

Stephan Dilly 75 Nov 17, 2022
jlang--godot bridge, built in rust

jlang-rs-gd J is an extremely high-level mathematical notation and programming language. Godot is a game / gui / multimedia engine. jlang-rs-gd lets y

tangentstorm 2 Feb 15, 2022
My first attempt at game programming. This is a simple target shooting game built in macroquad.

sergio My first attempt at game programming. This is a simple target shooting game built in macroquad. Rules Hit a target to increase score by 1 Score

Laz 1 Jan 11, 2022
game engine built in rust, using wgpu and probably other stuff too

horizon game engine engine for devpty games, made in 99.9% rust and 0.1% shell. this is our main project currently. the engine will be used for most i

DEVPTY 2 Apr 12, 2022
Bevy is a refreshingly simple data-driven game engine built in Rust

What is Bevy? Bevy is a refreshingly simple data-driven game engine built in Rust. It is free and open-source forever! WARNING Bevy is still in the ve

John Winston 3 Jun 3, 2022
🎮 A Realtime Multiplayer Server/Client Game example built entirely with Rust 🦀

Example of a ?? Realtime Multiplayer Web Game Server/Client built entirely using Rust ??

Nick Baker 5 Dec 17, 2022